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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fd670c6985f95fedf712bbbc341f0d34610c3cea
| 2,238
|
agda
|
Agda
|
Fields/FieldOfFractions/Setoid.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Fields/FieldOfFractions/Setoid.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Fields/FieldOfFractions/Setoid.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Rings.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Rings.IntegralDomains.Definition
open import Rings.IntegralDomains.Lemmas
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Fields.FieldOfFractions.Setoid {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where
record fieldOfFractionsSet : Set (a ⊔ b) where
field
num : A
denom : A
.denomNonzero : (Setoid._∼_ S denom (Ring.0R R) → False)
fieldOfFractionsSetoid : Setoid fieldOfFractionsSet
Setoid._∼_ fieldOfFractionsSetoid (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 }) = Setoid._∼_ S (a * d) (b * c)
Equivalence.reflexive (Setoid.eq fieldOfFractionsSetoid) {record { num = a ; denom = b ; denomNonzero = b!=0 }} = Ring.*Commutative R
Equivalence.symmetric (Setoid.eq fieldOfFractionsSetoid) {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} ad=bc = transitive (Ring.*Commutative R) (transitive (symmetric ad=bc) (Ring.*Commutative R))
where
open Equivalence (Setoid.eq S)
Equivalence.transitive (Setoid.eq fieldOfFractionsSetoid) {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} {record { num = e ; denom = f ; denomNonzero = f!=0 }} ad=bc cf=de = p5
where
open Setoid S
open Ring R
open Equivalence eq
p : (a * d) * f ∼ (b * c) * f
p = Ring.*WellDefined R ad=bc reflexive
p2 : (a * f) * d ∼ b * (d * e)
p2 = transitive (transitive (symmetric *Associative) (transitive (*WellDefined reflexive *Commutative) *Associative)) (transitive p (transitive (symmetric *Associative) (*WellDefined reflexive cf=de)))
p3 : (a * f) * d ∼ (b * e) * d
p3 = transitive p2 (transitive (*WellDefined reflexive *Commutative) *Associative)
p4 : ((d ∼ 0R) → False) → ((a * f) ∼ (b * e))
p4 = cancelIntDom I (transitive *Commutative (transitive p3 *Commutative))
p5 : (a * f) ∼ (b * e)
p5 = p4 λ t → exFalso (d!=0 t)
| 54.585366
| 260
| 0.652368
|
8b5769f0a179b60d6da56ce1dae951a5df1622ed
| 10,692
|
agda
|
Agda
|
Cubical/HITs/SetQuotients/Properties.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/HITs/SetQuotients/Properties.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/HITs/SetQuotients/Properties.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
{-
Set quotients:
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.SetQuotients.Properties where
open import Cubical.HITs.SetQuotients.Base
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Univalence
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Sigma
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary.Base
open import Cubical.HITs.PropositionalTruncation as PropTrunc using (∥_∥; ∣_∣; squash)
open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₂; ∣_∣₂; squash₂)
-- Type quotients
private
variable
ℓ : Level
A : Type ℓ
R : A → A → Type ℓ
B : A / R → Type ℓ
C : A / R → A / R → Type ℓ
D : A / R → A / R → A / R → Type ℓ
elimEq/ : (Bprop : (x : A / R ) → isProp (B x))
{x y : A / R}
(eq : x ≡ y)
(bx : B x)
(by : B y) →
PathP (λ i → B (eq i)) bx by
elimEq/ {B = B} Bprop {x = x} =
J (λ y eq → ∀ bx by → PathP (λ i → B (eq i)) bx by) (λ bx by → Bprop x bx by)
elimProp : ((x : A / R ) → isProp (B x))
→ ((a : A) → B ( [ a ]))
→ (x : A / R)
→ B x
elimProp Bprop f [ x ] = f x
elimProp Bprop f (squash/ x y p q i j) =
isOfHLevel→isOfHLevelDep 2 (λ x → isProp→isSet (Bprop x))
(g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j
where
g = elimProp Bprop f
elimProp Bprop f (eq/ a b r i) = elimEq/ Bprop (eq/ a b r) (f a) (f b) i
elimProp2 : ((x y : A / R ) → isProp (C x y))
→ ((a b : A) → C [ a ] [ b ])
→ (x y : A / R)
→ C x y
elimProp2 Cprop f = elimProp (λ x → isPropΠ (λ y → Cprop x y))
(λ x → elimProp (λ y → Cprop [ x ] y) (f x))
elimProp3 : ((x y z : A / R ) → isProp (D x y z))
→ ((a b c : A) → D [ a ] [ b ] [ c ])
→ (x y z : A / R)
→ D x y z
elimProp3 Dprop f = elimProp (λ x → isPropΠ2 (λ y z → Dprop x y z))
(λ x → elimProp2 (λ y z → Dprop [ x ] y z) (f x))
-- lemma 6.10.2 in hott book
[]surjective : (x : A / R) → ∃[ a ∈ A ] [ a ] ≡ x
[]surjective = elimProp (λ x → squash) (λ a → ∣ a , refl ∣)
elim : {B : A / R → Type ℓ}
→ ((x : A / R) → isSet (B x))
→ (f : (a : A) → (B [ a ]))
→ ((a b : A) (r : R a b) → PathP (λ i → B (eq/ a b r i)) (f a) (f b))
→ (x : A / R)
→ B x
elim Bset f feq [ a ] = f a
elim Bset f feq (eq/ a b r i) = feq a b r i
elim Bset f feq (squash/ x y p q i j) =
isOfHLevel→isOfHLevelDep 2 Bset
(g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j
where
g = elim Bset f feq
rec : {B : Type ℓ}
(Bset : isSet B)
(f : A → B)
(feq : (a b : A) (r : R a b) → f a ≡ f b)
→ A / R → B
rec Bset f feq [ a ] = f a
rec Bset f feq (eq/ a b r i) = feq a b r i
rec Bset f feq (squash/ x y p q i j) = Bset (g x) (g y) (cong g p) (cong g q) i j
where
g = rec Bset f feq
rec2 : {B : Type ℓ} (Bset : isSet B)
(f : A → A → B) (feql : (a b c : A) (r : R a b) → f a c ≡ f b c)
(feqr : (a b c : A) (r : R b c) → f a b ≡ f a c)
→ A / R → A / R → B
rec2 Bset f feql feqr = rec (isSetΠ (λ _ → Bset))
(λ a → rec Bset (f a) (feqr a))
(λ a b r → funExt (elimProp (λ _ → Bset _ _)
(λ c → feql a b c r)))
setQuotUniversalIso : {B : Type ℓ} (Bset : isSet B)
→ Iso (A / R → B) (Σ[ f ∈ (A → B) ] ((a b : A) → R a b → f a ≡ f b))
Iso.fun (setQuotUniversalIso Bset) g = (λ a → g [ a ]) , λ a b r i → g (eq/ a b r i)
Iso.inv (setQuotUniversalIso Bset) h = elim (λ x → Bset) (fst h) (snd h)
Iso.rightInv (setQuotUniversalIso Bset) h = refl
Iso.leftInv (setQuotUniversalIso Bset) g =
funExt (λ x → PropTrunc.elim (λ sur → Bset (out (intro g) x) (g x))
(λ sur → cong (out (intro g)) (sym (snd sur)) ∙ (cong g (snd sur))) ([]surjective x))
where
intro = Iso.fun (setQuotUniversalIso Bset)
out = Iso.inv (setQuotUniversalIso Bset)
setQuotUniversal : {B : Type ℓ} (Bset : isSet B) →
(A / R → B) ≃ (Σ[ f ∈ (A → B) ] ((a b : A) → R a b → f a ≡ f b))
setQuotUniversal Bset = isoToEquiv (setQuotUniversalIso Bset)
-- characterisation of binary functions/operations on set-quotients
setQuotUniversal2Iso : {B : Type ℓ} (Bset : isSet B) → isRefl R
→ Iso (A / R → A / R → B)
(Σ[ _∗_ ∈ (A → A → B) ] ((a a' b b' : A) → R a a' → R b b' → a ∗ b ≡ a' ∗ b'))
Iso.fun (setQuotUniversal2Iso {A = A} {R = R} {B = B} Bset isReflR) _∗/_ = _∗_ , h
where
_∗_ = λ a b → [ a ] ∗/ [ b ]
h : (a a' b b' : A) → R a a' → R b b' → a ∗ b ≡ a' ∗ b'
h a a' b b' ra rb = cong (_∗/ [ b ]) (eq/ _ _ ra) ∙ cong ([ a' ] ∗/_) (eq/ _ _ rb)
Iso.inv (setQuotUniversal2Iso {A = A} {R = R} {B = B} Bset isReflR) (_∗_ , h) =
rec2 Bset _∗_ hleft hright
where
hleft : ∀ a b c → R a b → (a ∗ c) ≡ (b ∗ c)
hleft _ _ c r = h _ _ _ _ r (isReflR c)
hright : ∀ a b c → R b c → (a ∗ b) ≡ (a ∗ c)
hright a _ _ r = h _ _ _ _ (isReflR a) r
Iso.rightInv (setQuotUniversal2Iso {A = A} {R = R} {B = B} Bset isReflR) (_∗_ , h) =
Σ≡Prop (λ _ → isPropΠ4 λ _ _ _ _ → isPropΠ2 λ _ _ → Bset _ _) refl
Iso.leftInv (setQuotUniversal2Iso {A = A} {R = R} {B = B} Bset isReflR) _∗/_ =
funExt₂ (elimProp2 (λ _ _ → Bset _ _) λ _ _ → refl)
setQuotUniversal2 : {B : Type ℓ} (Bset : isSet B) → isRefl R
→ (A / R → A / R → B)
≃ (Σ[ _∗_ ∈ (A → A → B) ] ((a a' b b' : A) → R a a' → R b b' → a ∗ b ≡ a' ∗ b'))
setQuotUniversal2 Bset isReflR = isoToEquiv (setQuotUniversal2Iso Bset isReflR)
-- corollary for binary operations
-- TODO: prove truncated inverse for effective relations
setQuotBinOp : isRefl R
→ (_∗_ : A → A → A)
→ (∀ a a' b b' → R a a' → R b b' → R (a ∗ b) (a' ∗ b'))
→ (A / R → A / R → A / R)
setQuotBinOp isReflR _∗_ h = Iso.inv (setQuotUniversal2Iso squash/ isReflR)
((λ a b → [ a ∗ b ]) , λ _ _ _ _ ra rb → eq/ _ _ (h _ _ _ _ ra rb))
setQuotSymmBinOp : isRefl R → isTrans R
→ (_∗_ : A → A → A)
→ (∀ a b → a ∗ b ≡ b ∗ a)
→ (∀ a a' b → R a a' → R (a ∗ b) (a' ∗ b))
→ (A / R → A / R → A / R)
setQuotSymmBinOp {A = A} {R = R} isReflR isTransR _∗_ ∗-symm h = setQuotBinOp isReflR _∗_ h'
where
h' : ∀ a a' b b' → R a a' → R b b' → R (a ∗ b) (a' ∗ b')
h' a a' b b' ra rb = isTransR _ _ _ (h a a' b ra)
(transport (λ i → R (∗-symm b a' i) (∗-symm b' a' i)) (h b b' a' rb))
effective : (Rprop : isPropValued R) (Requiv : isEquivRel R) (a b : A) → [ a ] ≡ [ b ] → R a b
effective {A = A} {R = R} Rprop (equivRel R/refl R/sym R/trans) a b p = transport aa≡ab (R/refl _)
where
helper : A / R → hProp _
helper =
rec isSetHProp (λ c → (R a c , Rprop a c))
(λ c d cd → Σ≡Prop (λ _ → isPropIsProp)
(hPropExt (Rprop a c) (Rprop a d)
(λ ac → R/trans _ _ _ ac cd) (λ ad → R/trans _ _ _ ad (R/sym _ _ cd))))
aa≡ab : R a a ≡ R a b
aa≡ab i = helper (p i) .fst
isEquivRel→effectiveIso : isPropValued R → isEquivRel R → (a b : A) → Iso ([ a ] ≡ [ b ]) (R a b)
Iso.fun (isEquivRel→effectiveIso {R = R} Rprop Req a b) = effective Rprop Req a b
Iso.inv (isEquivRel→effectiveIso {R = R} Rprop Req a b) = eq/ a b
Iso.rightInv (isEquivRel→effectiveIso {R = R} Rprop Req a b) _ = Rprop a b _ _
Iso.leftInv (isEquivRel→effectiveIso {R = R} Rprop Req a b) _ = squash/ _ _ _ _
isEquivRel→isEffective : isPropValued R → isEquivRel R → isEffective R
isEquivRel→isEffective Rprop Req a b = isoToIsEquiv (invIso (isEquivRel→effectiveIso Rprop Req a b))
discreteSetQuotients : Discrete A → isPropValued R → isEquivRel R → (∀ a₀ a₁ → Dec (R a₀ a₁)) → Discrete (A / R)
discreteSetQuotients {A = A} {R = R} Adis Rprop Req Rdec =
elim (λ a₀ → isSetΠ (λ a₁ → isProp→isSet (isPropDec (squash/ a₀ a₁))))
discreteSetQuotients' discreteSetQuotients'-eq
where
discreteSetQuotients' : (a : A) (y : A / R) → Dec ([ a ] ≡ y)
discreteSetQuotients' a₀ = elim (λ a₁ → isProp→isSet (isPropDec (squash/ [ a₀ ] a₁))) dis dis-eq
where
dis : (a₁ : A) → Dec ([ a₀ ] ≡ [ a₁ ])
dis a₁ with Rdec a₀ a₁
... | (yes p) = yes (eq/ a₀ a₁ p)
... | (no ¬p) = no λ eq → ¬p (effective Rprop Req a₀ a₁ eq )
dis-eq : (a b : A) (r : R a b) →
PathP (λ i → Dec ([ a₀ ] ≡ eq/ a b r i)) (dis a) (dis b)
dis-eq a b ab = J (λ b ab → ∀ k → PathP (λ i → Dec ([ a₀ ] ≡ ab i)) (dis a) k)
(λ k → isPropDec (squash/ _ _) _ _) (eq/ a b ab) (dis b)
discreteSetQuotients'-eq : (a b : A) (r : R a b) →
PathP (λ i → (y : A / R) → Dec (eq/ a b r i ≡ y))
(discreteSetQuotients' a) (discreteSetQuotients' b)
discreteSetQuotients'-eq a b ab =
J (λ b ab → ∀ k → PathP (λ i → (y : A / R) → Dec (ab i ≡ y))
(discreteSetQuotients' a) k)
(λ k → funExt (λ x → isPropDec (squash/ _ _) _ _)) (eq/ a b ab) (discreteSetQuotients' b)
-- Quotienting by the truncated relation is equivalent to quotienting by untruncated relation
truncRelIso : Iso (A / R) (A / (λ a b → ∥ R a b ∥))
Iso.fun truncRelIso = rec squash/ [_] λ _ _ r → eq/ _ _ ∣ r ∣
Iso.inv truncRelIso = rec squash/ [_] λ _ _ → PropTrunc.rec (squash/ _ _) λ r → eq/ _ _ r
Iso.rightInv truncRelIso = elimProp (λ _ → squash/ _ _) λ _ → refl
Iso.leftInv truncRelIso = elimProp (λ _ → squash/ _ _) λ _ → refl
truncRelEquiv : A / R ≃ A / (λ a b → ∥ R a b ∥)
truncRelEquiv = isoToEquiv truncRelIso
-- Using this we can obtain a useful characterization of
-- path-types for equivalence relations (not prop-valued)
-- and their quotients
isEquivRel→TruncIso : isEquivRel R → (a b : A) → Iso ([ a ] ≡ [ b ]) ∥ R a b ∥
isEquivRel→TruncIso {A = A} {R = R} Req a b = compIso (isProp→Iso (squash/ _ _) (squash/ _ _)
(cong (Iso.fun truncRelIso)) (cong (Iso.inv truncRelIso)))
(isEquivRel→effectiveIso (λ _ _ → PropTrunc.propTruncIsProp) ∥R∥eq a b)
where
open isEquivRel
∥R∥eq : isEquivRel λ a b → ∥ R a b ∥
reflexive ∥R∥eq a = ∣ reflexive Req a ∣
symmetric ∥R∥eq a b = PropTrunc.map (symmetric Req a b)
transitive ∥R∥eq a b c = PropTrunc.map2 (transitive Req a b c)
| 42.094488
| 121
| 0.519641
|
7ca926cf57e7a8e6e5a59d173037e42277bf417c
| 2,639
|
agda
|
Agda
|
Constructive/Axiom/Properties/Transport.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | 3
|
2020-04-07T17:49:42.000Z
|
2020-04-21T00:03:43.000Z
|
Constructive/Axiom/Properties/Transport.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
Constructive/Axiom/Properties/Transport.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
-- Transport properties
{-# OPTIONS --without-K --safe --exact-split #-}
module Constructive.Axiom.Properties.Transport where
-- agda-stdlib
open import Level renaming (suc to lsuc; zero to lzero)
open import Data.Sum as Sum
open import Data.Product as Prod
open import Relation.Binary.PropositionalEquality
open import Function.Base
import Function.LeftInverse as LInv -- TODO use new packages
import Function.Equality as Eq
-- agda-misc
open import Constructive.Common
open import Constructive.Combinators
open import Constructive.Axiom
open import Constructive.Axiom.Properties.Base
module Transport
{a b p} {A : Set a} {B : Set b}
(f : A → B) (g : B → A) (inv : ∀ x → f (g x) ≡ x)
where
private
∃Pf→∃P : {P : B → Set p} → ∃ (λ x → P (f x)) → ∃ P
∃Pf→∃P (x , Pfx) = (f x , Pfx)
∃P→∃Pf : {P : B → Set p} → ∃ P → ∃ (λ x → P (f x))
∃P→∃Pf {P = P} (x , Px) = g x , subst P (sym (inv x)) Px
∃Qg→∃Q : {Q : A → Set p} → ∃ (λ x → Q (g x)) → ∃ Q
∃Qg→∃Q (x , Qgx) = g x , Qgx
lpo-transport : LPO A p → LPO B p
lpo-transport lpo P? =
Sum.map ∃Pf→∃P (contraposition ∃P→∃Pf) $ lpo (DecU-map f P?)
llpo-transport : LLPO A p → LLPO B p
llpo-transport llpo P? Q? w =
Sum.map (contraposition ∃P→∃Pf) (contraposition ∃P→∃Pf) $
llpo (DecU-map f P?) (DecU-map f Q?)
(contraposition (Prod.map ∃Pf→∃P ∃Pf→∃P) w)
wlpo-Alt-transport : WLPO-Alt A p → WLPO-Alt B p
wlpo-Alt-transport wlpo-Alt P? =
Sum.map (contraposition ∃P→∃Pf) (DN-map ∃Pf→∃P) $ wlpo-Alt (DecU-map f P?)
wlpo-transport : WLPO A p → WLPO B p
wlpo-transport = wlpo-Alt⇒wlpo ∘′ wlpo-Alt-transport ∘′ wlpo⇒wlpo-Alt
mr-transport : MR A p → MR B p
mr-transport mr P? ¬¬∃P =
∃Pf→∃P $ mr (DecU-map f P?) (DN-map ∃P→∃Pf ¬¬∃P)
mp-transport : MP A p → MP B p
mp-transport = mr⇒mp ∘′ mr-transport ∘′ mp⇒mr
wmp-transport : WMP A p → WMP B p
wmp-transport wmp {P = P} P? hyp =
∃Pf→∃P $ wmp (DecU-map f P?)
λ Q? → Sum.map (DN-map ∃Qg→∃Q) (DN-map λ {(x , Px , ¬Qgx) →
g x , (subst P (sym (inv x)) Px) , ¬Qgx }) $ hyp (DecU-map g Q?)
mp⊎-transport : MP⊎ A p → MP⊎ B p
mp⊎-transport mp⊎ P? Q? w =
Sum.map (DN-map ∃Pf→∃P) (DN-map ∃Pf→∃P) $
mp⊎ (DecU-map f P?) (DecU-map f Q?)
(contraposition (Prod.map (contraposition ∃P→∃Pf)
(contraposition ∃P→∃Pf)) w)
open Transport public
module TransportByLeftInverse
{a b p} {A : Set a} {B : Set b} (linv : B LInv.↞ A) =
Transport {p = p} (LInv.LeftInverse.from linv Eq.⟨$⟩_)
(LInv.LeftInverse.to linv Eq.⟨$⟩_) (LInv.LeftInverse.left-inverse-of linv)
| 33.405063
| 78
| 0.582039
|
03e17b1bdf2f9855874175b68dba45332dc5dc25
| 1,532
|
agda
|
Agda
|
eq.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
eq.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
eq.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
module eq where
open import level
----------------------------------------------------------------------
-- datatypes
----------------------------------------------------------------------
data _≡_ {ℓ} {A : Set ℓ} (x : A) : A → Set ℓ where
refl : x ≡ x
{-# BUILTIN EQUALITY _≡_ #-}
----------------------------------------------------------------------
-- syntax
----------------------------------------------------------------------
infix 4 _≡_
----------------------------------------------------------------------
-- operations
----------------------------------------------------------------------
sym : ∀ {ℓ}{A : Set ℓ}{x y : A} → x ≡ y → y ≡ x
sym refl = refl
trans : ∀ {ℓ}{A : Set ℓ}{x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans refl refl = refl
cong : ∀ {ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}(p : A → B) {x y : A} → x ≡ y → p x ≡ p y
cong p refl = refl
congf : ∀{l l' : Level}{A : Set l}{B : Set l'}{f f' : A → B}{b c : A} → f ≡ f' → b ≡ c → (f b) ≡ (f' c)
congf refl refl = refl
congf2 : ∀{l l' l'' : Level}{A : Set l}{B : Set l'}{C : Set l''}{f f' : A → B → C}{b c : A}{d e : B} → f ≡ f' → b ≡ c → d ≡ e → (f b d) ≡ (f' c e)
congf2 refl refl refl = refl
cong2 : ∀{i j k}{A : Set i}{B : Set j}{C : Set k}{a a' : A}{b b' : B}
→ (f : A → B → C)
→ a ≡ a'
→ b ≡ b'
→ f a b ≡ f a' b'
cong2 f refl refl = refl
cong3 : ∀{i j k l}{A : Set i}{B : Set j}{C : Set k}{D : Set l}{a a' : A}{b b' : B}{c c' : C}
→ (f : A → B → C → D)
→ a ≡ a'
→ b ≡ b'
→ c ≡ c'
→ f a b c ≡ f a' b' c'
cong3 f refl refl refl = refl
| 28.90566
| 146
| 0.314621
|
43346b16b8577d32b64004abdebc2ff17ae17c44
| 32,237
|
agda
|
Agda
|
complexity/Pilot.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | 2
|
2016-04-26T20:22:22.000Z
|
2019-08-08T12:27:18.000Z
|
complexity/Pilot.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | 1
|
2020-03-23T08:39:04.000Z
|
2020-05-12T00:32:45.000Z
|
complexity/Pilot.agda
|
benhuds/Agda
|
2404a6ef2688f879bda89860bb22f77664ad813e
|
[
"MIT"
] | null | null | null |
open import Preliminaries
open import Preorder-Max
module Pilot where
data CTp : Set where
unit : CTp
nat : CTp -- discrete natural numbers ♭nat, where we interpret ≤ as =
_->c_ : CTp → CTp → CTp
_×c_ : CTp → CTp → CTp
list : CTp → CTp
bool : CTp
C : CTp
rnat : CTp -- natural numbers with ≤ actually interpreted as ≤
-- represent a context as a list of types
Ctx = List CTp
-- de Bruijn indices (for free variables)
data _∈_ : CTp → Ctx → Set where
i0 : ∀ {Γ τ}
→ τ ∈ (τ :: Γ)
iS : ∀ {Γ τ τ1}
→ τ ∈ Γ
→ τ ∈ (τ1 :: Γ)
rctx : Ctx → Ctx → Set
rctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → τ ∈ Γ
r-extend : ∀ {Γ Γ' τ} → rctx Γ Γ' → rctx (τ :: Γ) (τ :: Γ')
data _|-_ : Ctx → CTp → Set
sctx : Ctx → Ctx → Set
sctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → Γ |- τ
_∙rr_ : ∀ {A B C} → rctx A B → rctx B C → rctx A C
_rs_ : ∀ {A B C} → rctx A B → sctx B C → sctx A C
ren : ∀ {Γ Γ' τ} → Γ' |- τ → rctx Γ Γ' → Γ |- τ
subst : ∀ {Γ Γ' τ} → Γ' |- τ → sctx Γ Γ' → Γ |- τ
_ss_ : ∀ {A B C} → sctx A B → sctx B C → sctx A C
_sr_ : ∀ {A B C} → sctx A B → rctx B C → sctx A C
data _≤s_ : ∀ {Γ T} → Γ |- T → Γ |- T → Set
rename-var : ∀ {Γ Γ' τ} → rctx Γ Γ' → τ ∈ Γ' → τ ∈ Γ
idr : ∀ {Γ} → rctx Γ Γ
p∙ : ∀ {Γ Γ' τ} → rctx Γ Γ' → rctx (τ :: Γ) Γ'
p : ∀ {Γ τ} → rctx (τ :: Γ) Γ
rename-var-ident : ∀ {Γ τ} → (x : τ ∈ Γ) → rename-var idr x == x
rename-var-∙ : ∀ {A B C τ} → (r1 : rctx A B) (r2 : rctx B C) (x : τ ∈ C) → rename-var r1 (rename-var r2 x) == rename-var (r1 ∙rr r2) x
∙rr-assoc : ∀ {A B C D} → (r1 : rctx A B) (r2 : rctx B C) (r3 : rctx C D) → _==_ {_} {rctx A D} (r1 ∙rr (r2 ∙rr r3)) ((r1 ∙rr r2) ∙rr r3)
extend-ren-comp-lemma : ∀ {Γ Γ' Γ'' τ τ'} → (x : τ ∈ τ' :: Γ'') (ρ1 : rctx Γ Γ') (ρ2 : rctx Γ' Γ'') → Id {_} {_} ((r-extend ρ1 ∙rr r-extend ρ2) x) (r-extend (ρ1 ∙rr ρ2) x)
extend-ren-comp : ∀ {Γ Γ' Γ'' τ} → (ρ1 : rctx Γ Γ') → (ρ2 : rctx Γ' Γ'') → Id {_} {rctx (τ :: Γ) (τ :: Γ'')} (r-extend ρ1 ∙rr r-extend ρ2) (r-extend (ρ1 ∙rr ρ2))
wkn : ∀ {Γ τ1 τ2} → Γ |- τ2 → (τ1 :: Γ) |- τ2
s-extend : ∀ {Γ Γ' τ} → sctx Γ Γ' → sctx (τ :: Γ) (τ :: Γ')
ids : ∀ {Γ} → sctx Γ Γ
q∙ : ∀ {Γ Γ' τ} → sctx Γ Γ' → sctx (τ :: Γ) Γ'
lem3' : ∀ {Γ Γ' τ} → sctx Γ Γ' → Γ |- τ → sctx Γ (τ :: Γ')
q : ∀ {Γ τ} → Γ |- τ → sctx Γ (τ :: Γ)
svar : ∀ {Γ1 Γ2 τ} → sctx Γ1 Γ2 → τ ∈ Γ2 → Γ1 |- τ
lem4' : ∀ {Γ Γ' τ1 τ2} → sctx Γ Γ' → Γ |- τ1 → Γ |- τ2 → sctx Γ (τ1 :: (τ2 :: Γ'))
lem4 : ∀ {Γ τ1 τ2} → Γ |- τ1 → Γ |- τ2 → sctx Γ (τ1 :: (τ2 :: Γ))
lem5' : ∀ {Γ Γ' τ1 τ2 τ3} → sctx Γ Γ' → Γ |- τ1 → Γ |- τ2 → Γ |- τ3 → sctx Γ (τ1 :: (τ2 :: (τ3 :: Γ')))
lem5 : ∀ {Γ τ1 τ2 τ3} → Γ |- τ1 → Γ |- τ2 → Γ |- τ3 → sctx Γ (τ1 :: (τ2 :: (τ3 :: Γ)))
data _|-_ where
unit : ∀ {Γ} → Γ |- unit
0C : ∀ {Γ} → Γ |- C
1C : ∀ {Γ}→ Γ |- C
plusC : ∀ {Γ} → Γ |- C → Γ |- C → Γ |- C
var : ∀ {Γ τ} → τ ∈ Γ → Γ |- τ
z : ∀ {Γ} → Γ |- nat
s : ∀ {Γ} → (e : Γ |- nat) → Γ |- nat
rec : ∀ {Γ τ} → Γ |- nat → Γ |- τ → (nat :: (τ :: Γ)) |- τ → Γ |- τ
lam : ∀ {Γ τ ρ} → (ρ :: Γ) |- τ → Γ |- (ρ ->c τ)
app : ∀ {Γ τ1 τ2} → Γ |- (τ2 ->c τ1) → Γ |- τ2 → Γ |- τ1
rz : ∀ {Γ} → Γ |- rnat
rsuc : ∀ {Γ} → Γ |- rnat → Γ |- rnat
rrec : ∀ {Γ τ} → Γ |- rnat → (Z' : Γ |- τ) → (S' : Γ |- (rnat ->c (τ ->c τ))) → (P : Z' ≤s (app (app S' rz) Z')) → Γ |- τ
--→ (S' : (nat≤ :: (τ :: Γ)) |- τ) → (P : Z' ≤s subst S' (lem3' (lem3' ids Z') z')) (what we're doing is the same but just avoids termination problems)
prod : ∀ {Γ τ1 τ2} → Γ |- τ1 → Γ |- τ2 → Γ |- (τ1 ×c τ2)
l-proj : ∀ {Γ τ1 τ2} → Γ |- (τ1 ×c τ2) → Γ |- τ1
r-proj : ∀ {Γ τ1 τ2} → Γ |- (τ1 ×c τ2) → Γ |- τ2
nil : ∀ {Γ τ} → Γ |- list τ
_::c_ : ∀ {Γ τ} → Γ |- τ → Γ |- list τ → Γ |- list τ
listrec : ∀ {Γ τ τ'} → Γ |- list τ → Γ |- τ' → (τ :: (list τ :: (τ' :: Γ))) |- τ' → Γ |- τ'
true : ∀ {Γ} → Γ |- bool
false : ∀ {Γ} → Γ |- bool
data _≤s_ where
refl-s : ∀ {Γ T} → {e : Γ |- T} → e ≤s e
trans-s : ∀ {Γ T} → {e e' e'' : Γ |- T} → e ≤s e' → e' ≤s e'' → e ≤s e''
plus-s : ∀ {Γ} → {e1 e2 n1 n2 : Γ |- C} → e1 ≤s n1 → e2 ≤s n2 → (plusC e1 e2) ≤s (plusC n1 n2)
cong-refl : ∀ {Γ τ} {e e' : Γ |- τ} → e == e' → e ≤s e'
+-unit-l : ∀ {Γ} {e : Γ |- C} → (plusC 0C e) ≤s e
+-unit-l' : ∀ {Γ} {e : Γ |- C} → e ≤s (plusC 0C e)
+-unit-r : ∀ {Γ} {e : Γ |- C} → (plusC e 0C) ≤s e
+-unit-r' : ∀ {Γ} {e : Γ |- C} → e ≤s (plusC e 0C)
+-assoc : ∀ {Γ} {e1 e2 e3 : Γ |- C} → (plusC e1 (plusC e2 e3)) ≤s (plusC (plusC e1 e2) e3)
+-assoc' : ∀ {Γ} {e1 e2 e3 : Γ |- C} → (plusC e1 (plusC e2 e3)) ≤s (plusC (plusC e1 e2) e3)
refl-+ : ∀ {Γ} {e0 e1 : Γ |- C} → (plusC e0 e1) ≤s (plusC e1 e0)
cong-+ : ∀ {Γ} {e0 e1 e0' e1' : Γ |- C} → e0 ≤s e0' → e1 ≤s e1' → (plusC e0 e1) ≤s (plusC e0' e1')
cong-lproj : ∀ {Γ τ τ'} {e e' : Γ |- (τ ×c τ')} → e ≤s e' → (l-proj e) ≤s (l-proj e')
cong-rproj : ∀ {Γ τ τ'} {e e' : Γ |- (τ ×c τ')} → e ≤s e' → (r-proj e) ≤s (r-proj e')
cong-app : ∀ {Γ τ τ'} {e e' : Γ |- (τ ->c τ')} {e1 : Γ |- τ} → e ≤s e' → (app e e1) ≤s (app e' e1)
ren-cong : ∀ {Γ Γ' τ} {e1 e2 : Γ' |- τ} {ρ : rctx Γ Γ'} → e1 ≤s e2 → (ren e1 ρ) ≤s (ren e2 ρ)
subst-cong : ∀ {Γ Γ' τ} {e1 e2 : Γ' |- τ} {Θ : sctx Γ Γ'} → e1 ≤s e2 → (subst e1 Θ) ≤s (subst e2 Θ)
subst-cong2 : ∀ {Γ Γ' τ} {Θ Θ' : sctx Γ Γ'} {e : Γ' |- τ} → (∀ τ → (x : τ ∈ Γ') → Θ x ≤s Θ' x) → subst e Θ ≤s subst e Θ'
cong-rec : ∀ {Γ τ} {e e' : Γ |- nat} {e0 : Γ |- τ} {e1 : (nat :: (τ :: Γ)) |- τ}
→ e ≤s e' → rec e e0 e1 ≤s rec e' e0 e1
cong-listrec : ∀ {Γ τ τ'} {e e' : Γ |- list τ} {e0 : Γ |- τ'} {e1 : (τ :: (list τ :: (τ' :: Γ))) |- τ'}
→ e ≤s e' → listrec e e0 e1 ≤s listrec e' e0 e1
lam-s : ∀ {Γ T T'} → {e : (T :: Γ) |- T'} → {e2 : Γ |- T} → subst e (q e2) ≤s app (lam e) e2
l-proj-s : ∀ {Γ T1 T2} → {e1 : Γ |- T1} {e2 : Γ |- T2} → e1 ≤s (l-proj (prod e1 e2))
r-proj-s : ∀ {Γ T1 T2} → {e1 : Γ |- T1} → {e2 : Γ |- T2} → e2 ≤s (r-proj (prod e1 e2))
rec-steps-z : ∀ {Γ T} → {e0 : Γ |- T} → {e1 : (nat :: (T :: Γ)) |- T} → e0 ≤s (rec z e0 e1)
rec-steps-s : ∀ {Γ T} → {e : Γ |- nat} → {e0 : Γ |- T} → {e1 : (nat :: (T :: Γ)) |- T} → subst e1 (lem4 e (rec e e0 e1)) ≤s (rec (s e) e0 e1)
listrec-steps-nil : ∀ {Γ τ τ'} → {e0 : Γ |- τ'} → {e1 : (τ :: (list τ :: (τ' :: Γ))) |- τ'}
→ e0 ≤s (listrec nil e0 e1)
listrec-steps-cons : ∀ {Γ τ τ'} → {h : Γ |- τ} {t : Γ |- list τ}
→ {e0 : Γ |- τ'} → {e1 : (τ :: (list τ :: (τ' :: Γ))) |- τ'}
→ subst e1 (lem5 h t (listrec t e0 e1)) ≤s (listrec (h ::c t) e0 e1)
ren-comp-l : ∀ {Γ Γ' Γ'' τ} → (ρ1 : rctx Γ Γ') → (ρ2 : rctx Γ' Γ'') → (e : Γ'' |- τ) → (ren (ren e ρ2) ρ1) ≤s (ren e (ρ1 ∙rr ρ2))
ren-comp-r : ∀ {Γ Γ' Γ'' τ} → (ρ1 : rctx Γ Γ') → (ρ2 : rctx Γ' Γ'') → (e : Γ'' |- τ) → (ren e (ρ1 ∙rr ρ2)) ≤s (ren (ren e ρ2) ρ1)
subst-id-l : ∀ {Γ τ} → (e : Γ |- τ) → e ≤s subst e ids
subst-id-r : ∀ {Γ τ} → (e : Γ |- τ) → subst e ids ≤s e
subst-rs-l : ∀ {A B C τ} → (ρ : rctx C A) (Θ : sctx A B) (e : B |- τ)
→ ren (subst e Θ) ρ ≤s subst e (ρ rs Θ)
subst-rs-r : ∀ {A B C τ} → (ρ : rctx C A) (Θ : sctx A B) (e : B |- τ)
→ subst e (ρ rs Θ) ≤s ren (subst e Θ) ρ
subst-sr-l : ∀ {Γ Γ' Γ'' τ} → (Θ : sctx Γ Γ') → (ρ : rctx Γ' Γ'') → (e : Γ'' |- τ)
→ (subst (ren e ρ) Θ) ≤s subst e (Θ sr ρ)
subst-sr-r : ∀ {Γ Γ' Γ'' τ} → (Θ : sctx Γ Γ') → (ρ : rctx Γ' Γ'') → (e : Γ'' |- τ)
→ subst e (Θ sr ρ) ≤s (subst (ren e ρ) Θ)
subst-ss-l : ∀ {A B C τ} → (Θ1 : sctx A B) (Θ2 : sctx B C) (e : C |- τ)
→ subst e (Θ1 ss Θ2) ≤s subst (subst e Θ2) Θ1
subst-ss-r : ∀ {A B C τ} → (Θ1 : sctx A B) (Θ2 : sctx B C) (e : C |- τ)
→ subst (subst e Θ2) Θ1 ≤s subst e (Θ1 ss Θ2)
subst-compose-l : ∀ {Γ Γ' τ τ1} (Θ : sctx Γ Γ') (v : Γ |- τ) (e : (τ :: Γ' |- τ1) )
→ subst (subst e (s-extend Θ)) (q v) ≤s subst e (lem3' Θ v)
subst-compose-r : ∀ {Γ Γ' τ τ1} (Θ : sctx Γ Γ') (v : Γ |- τ) (e : (τ :: Γ' |- τ1) )
→ subst e (lem3' Θ v) ≤s subst (subst e (s-extend Θ)) (q v)
subst-compose2-l : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ |- τ1) (v2 : Γ |- τ2)
→ subst (subst e1 (s-extend (s-extend Θ))) (lem4 v1 v2) ≤s subst e1 (lem4' Θ v1 v2)
subst-compose2-r : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ |- τ1) (v2 : Γ |- τ2)
→ subst e1 (lem4' Θ v1 v2) ≤s subst (subst e1 (s-extend (s-extend Θ))) (lem4 v1 v2)
subst-compose3-l : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ' |- τ1) (v2 : Γ' |- τ2)
→ subst (subst e1 (lem4 v1 v2)) Θ ≤s subst e1 (lem4' Θ (subst v1 Θ) (subst v2 Θ))
subst-compose3-r : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ' |- τ1) (v2 : Γ' |- τ2)
→ subst e1 (lem4' Θ (subst v1 Θ) (subst v2 Θ)) ≤s subst (subst e1 (lem4 v1 v2)) Θ
subst-compose4-l : ∀ {Γ Γ' τ} (Θ : sctx Γ Γ') (v' : Γ |- nat) (r : Γ |- τ) (e2 : (nat :: (τ :: Γ')) |- τ)
→ subst (subst e2 (s-extend (s-extend Θ))) (lem4 v' r) ≤s subst e2 (lem4' Θ v' r)
subst-compose4-r : ∀ {Γ Γ' τ} (Θ : sctx Γ Γ') (v' : Γ |- nat) (r : Γ |- τ) (e2 : (nat :: (τ :: Γ')) |- τ)
→ subst e2 (lem4' Θ v' r) ≤s subst (subst e2 (s-extend (s-extend Θ))) (lem4 v' r)
subst-compose5-l : ∀ {Γ Γ' τ τ1 τ2 τ3} (Θ : sctx Γ Γ') (e : (τ1 :: (τ2 :: (τ3 :: Γ'))) |- τ) (v1 : Γ |- τ1) (v2 : Γ |- τ2) (v3 : Γ |- τ3)
→ subst (subst e (s-extend (s-extend (s-extend (Θ))))) (lem5 v1 v2 v3) ≤s subst e (lem5' Θ v1 v2 v3)
subst-compose5-r : ∀ {Γ Γ' τ τ1 τ2 τ3} (Θ : sctx Γ Γ') (e : (τ1 :: (τ2 :: (τ3 :: Γ'))) |- τ) (v1 : Γ |- τ1) (v2 : Γ |- τ2) (v3 : Γ |- τ3)
→ subst e (lem5' Θ v1 v2 v3) ≤s subst (subst e (s-extend (s-extend (s-extend (Θ))))) (lem5 v1 v2 v3)
-- r-extend : ∀ {Γ Γ' τ} → rctx Γ Γ' → rctx (τ :: Γ) (τ :: Γ')
r-extend ρ i0 = i0
r-extend ρ (iS x) = iS (ρ x)
-- _∙rr_ : ∀ {A B C} → rctx A B → rctx B C → rctx A C
ρ1 ∙rr ρ2 = ρ1 o ρ2
rename-var ρ a = ρ a
idr x = x
p∙ ρ = λ x → iS (ρ x)
p = p∙ idr
--free stuff
rename-var-ident _ = Refl
rename-var-∙ _ _ _ = Refl
∙rr-assoc r1 r2 r3 = Refl
ren unit ρ = unit
ren 0C ρ = 0C
ren 1C ρ = 1C
ren (plusC e e₁) ρ = plusC (ren e ρ) (ren e₁ ρ)
ren (var x) ρ = var (ρ x)
ren z ρ = z
ren (s e) ρ = s (ren e ρ)
ren (rec e e₁ e₂) ρ = rec (ren e ρ) (ren e₁ ρ) (ren e₂ (r-extend (r-extend ρ)))
ren (lam e) ρ = lam (ren e (r-extend ρ))
ren (app e e₁) ρ = app (ren e ρ) (ren e₁ ρ)
ren (prod e1 e2) ρ = prod (ren e1 ρ) (ren e2 ρ)
ren (l-proj e) ρ = l-proj (ren e ρ)
ren (r-proj e) ρ = r-proj (ren e ρ)
ren nil ρ = nil
ren (x ::c xs) ρ = ren x ρ ::c ren xs ρ
ren true ρ = true
ren false ρ = false
ren (listrec e e₁ e₂) ρ = listrec (ren e ρ) (ren e₁ ρ) (ren e₂ (r-extend (r-extend (r-extend ρ))))
ren rz ρ = rz
ren (rsuc e) ρ = rsuc (ren e ρ)
ren (rrec e e₁ e₂ p) ρ = rrec (ren e ρ) (ren e₁ ρ) (ren e₂ ρ) (ren-cong p)
extend-ren-comp-lemma i0 ρ1 ρ2 = Refl
extend-ren-comp-lemma (iS x) ρ1 ρ2 = Refl
extend-ren-comp ρ1 ρ2 = λ=i (λ τ → λ= (λ x → extend-ren-comp-lemma x ρ1 ρ2))
postulate
ren-comp : ∀ {Γ Γ' Γ'' τ} → (ρ1 : rctx Γ Γ') → (ρ2 : rctx Γ' Γ'') → (e : Γ'' |- τ) → (ren (ren e ρ2) ρ1) == (ren e (ρ1 ∙rr ρ2))
{- ren-comp ρ1 ρ2 unit = Refl
ren-comp ρ1 ρ2 0C = Refl
ren-comp ρ1 ρ2 1C = Refl
ren-comp ρ1 ρ2 (plusC e e₁) = ap2 plusC (ren-comp ρ1 ρ2 e) (ren-comp ρ1 ρ2 e₁)
ren-comp ρ1 ρ2 (var x) = ap var (rename-var-∙ ρ1 ρ2 x)
ren-comp ρ1 ρ2 z = Refl
ren-comp ρ1 ρ2 (s e) = ap s (ren-comp ρ1 ρ2 e)
ren-comp ρ1 ρ2 (rec e e₁ e₂) = ap3 rec (ren-comp ρ1 ρ2 e) (ren-comp ρ1 ρ2 e₁)
(ap (ren e₂) (ap r-extend (extend-ren-comp ρ1 ρ2) ∘
extend-ren-comp (r-extend ρ1) (r-extend ρ2)) ∘
ren-comp (r-extend (r-extend ρ1)) (r-extend (r-extend ρ2)) e₂)
ren-comp ρ1 ρ2 (lam e) = ap lam ((ap (ren e) (extend-ren-comp ρ1 ρ2)) ∘ ren-comp (r-extend ρ1) (r-extend ρ2) e)
ren-comp ρ1 ρ2 (app e e₁) = ap2 app (ren-comp ρ1 ρ2 e) (ren-comp ρ1 ρ2 e₁)
ren-comp ρ1 ρ2 (prod e e₁) = ap2 prod (ren-comp ρ1 ρ2 e) (ren-comp ρ1 ρ2 e₁)
ren-comp ρ1 ρ2 (l-proj e) = ap l-proj (ren-comp ρ1 ρ2 e)
ren-comp ρ1 ρ2 (r-proj e) = ap r-proj (ren-comp ρ1 ρ2 e)
ren-comp ρ1 ρ2 nil = Refl
ren-comp ρ1 ρ2 (e ::c e₁) = ap2 _::c_ (ren-comp ρ1 ρ2 e) (ren-comp ρ1 ρ2 e₁)
ren-comp ρ1 ρ2 (listrec e e₁ e₂) = ap3 listrec (ren-comp ρ1 ρ2 e) (ren-comp ρ1 ρ2 e₁)
(ap (ren e₂) (ap r-extend (ap r-extend (extend-ren-comp ρ1 ρ2)) ∘
(ap r-extend (extend-ren-comp (r-extend ρ1) (r-extend ρ2)) ∘
extend-ren-comp (r-extend (r-extend ρ1)) (r-extend (r-extend ρ2)))) ∘
ren-comp (r-extend (r-extend (r-extend ρ1)))
(r-extend (r-extend (r-extend ρ2))) e₂)
ren-comp ρ1 ρ2 true = Refl
ren-comp ρ1 ρ2 false = Refl
ren-comp ρ1 ρ2 rz = Refl
ren-comp ρ1 ρ2 (rs e) = ap rs (ren-comp ρ1 ρ2 e)
ren-comp ρ1 ρ2 (rrec e e₁ e₂ p) = {!!}
-}
-- weakening a context
wkn e = ren e iS
--lem2 (addvar)
s-extend Θ i0 = var i0
s-extend Θ (iS x) = wkn (Θ x)
ids x = var x
-- weakening with substitution
q∙ Θ = λ x → wkn (Θ x)
lem3' Θ e i0 = e
lem3' Θ e (iS i) = Θ i
--lem3
q e = lem3' ids e
-- subst-var
svar Θ i = q (Θ i) i0
lem4' Θ a b = lem3' (lem3' Θ b) a
lem4 e1 e2 = lem4' ids e1 e2
lem5' Θ a b c = lem3' (lem3' (lem3' Θ c) b) a
lem5 e1 e2 e3 = lem5' ids e1 e2 e3
subst unit Θ = unit
subst 0C Θ = 0C
subst 1C Θ = 1C
subst (plusC e e₁) Θ = plusC (subst e Θ) (subst e₁ Θ)
subst (var x) Θ = Θ x
subst z Θ = z
subst (s e) Θ = s (subst e Θ)
subst (rec e e₁ e₂) Θ = rec (subst e Θ) (subst e₁ Θ) (subst e₂ (s-extend (s-extend Θ)))
subst (lam e) Θ = lam (subst e (s-extend Θ))
subst (app e e₁) Θ = app (subst e Θ) (subst e₁ Θ)
subst (prod e1 e2) Θ = prod (subst e1 Θ) (subst e2 Θ)
subst (l-proj e) Θ = l-proj (subst e Θ)
subst (r-proj e) Θ = r-proj (subst e Θ)
subst nil Θ = nil
subst (x ::c xs) Θ = subst x Θ ::c subst xs Θ
subst true Θ = true
subst false Θ = false
subst (listrec e e₁ e₂) Θ = listrec (subst e Θ) (subst e₁ Θ) (subst e₂ (s-extend (s-extend (s-extend Θ))))
subst rz Θ = rz
subst (rsuc e) Θ = rsuc (subst e Θ)
subst (rrec e e₁ e₂ p) Θ = rrec (subst e Θ) (subst e₁ Θ) (subst e₂ Θ) (subst-cong p)
subst1 : ∀ {Γ τ τ1} → Γ |- τ1 → (τ1 :: Γ) |- τ → Γ |- τ
subst1 e e' = subst e' (q e)
_rs_ ρ Θ x = ren (subst (var x) Θ) ρ
_ss_ Θ1 Θ2 x = subst (subst (var x) Θ2) Θ1
_sr_ Θ ρ x = subst (ren (var x) ρ) Θ
--free stuff
{-
svar-rs : ∀ {A B C τ} (ρ : rctx A B) (Θ : sctx B C) (x : τ ∈ C)
→ svar (ρ rs Θ) x == ren (svar Θ x) ρ
svar-rs = λ ρ Θ x → Refl
svar-ss : ∀ {A B C τ} (Θ1 : sctx A B) (Θ2 : sctx B C) (x : τ ∈ C)
→ svar (Θ1 ss Θ2) x == subst (svar Θ2 x) Θ1
svar-ss = λ Θ1 Θ2 x → Refl
svar-sr : ∀ {A B C τ} (Θ : sctx A B) (ρ : rctx B C) (x : τ ∈ C)
→ svar Θ (rename-var ρ x) == svar (Θ sr ρ) x
svar-sr = λ Θ ρ x → Refl
svar-id : ∀ {Γ τ} → (x : τ ∈ Γ) → var x == svar ids x
svar-id = λ x → Refl
rsr-assoc : ∀ {A B C D} → (ρ1 : rctx A B) (Θ : sctx B C) (ρ2 : rctx C D)
→ Id {_} {sctx A D} ((ρ1 rs Θ) sr ρ2) (ρ1 rs (Θ sr ρ2))
rsr-assoc = λ ρ1 Θ ρ2 → Refl
-}
extend-id-once-lemma : ∀ {Γ τ τ'} → (x : τ ∈ τ' :: Γ) → _==_ {_} {τ' :: Γ |- τ}
(ids {τ' :: Γ} {τ} x) (s-extend {Γ} {Γ} {τ'} (ids {Γ}) {τ} x)
extend-id-once-lemma i0 = Refl
extend-id-once-lemma (iS x) = Refl
extend-id-once : ∀ {Γ τ} → Id {_} {sctx (τ :: Γ) (τ :: Γ)} (ids {τ :: Γ}) (s-extend ids)
extend-id-once = λ=i (λ τ → λ= (λ x → extend-id-once-lemma x))
extend-id-twice : ∀ {Γ τ1 τ2} → Id {_} {sctx (τ1 :: τ2 :: Γ) (τ1 :: τ2 :: Γ)} (ids {τ1 :: τ2 :: Γ}) (s-extend (s-extend ids))
extend-id-twice = ap s-extend extend-id-once ∘ extend-id-once
postulate
subst-id : ∀ {Γ τ} (e : Γ |- τ) → e == subst e ids
{- subst-id unit = Refl
subst-id 0C = Refl
subst-id 1C = Refl
subst-id (plusC e e₁) = ap2 plusC (subst-id e) (subst-id e₁)
subst-id (var x) = Refl
subst-id z = Refl
subst-id (s e) = ap s (subst-id e)
subst-id (rec e e₁ e₂) = ap3 rec (subst-id e) (subst-id e₁) (ap (subst e₂) extend-id-twice ∘ subst-id e₂)
subst-id (lam e) = ap lam (ap (subst e) extend-id-once ∘ subst-id e)
subst-id (app e e₁) = ap2 app (subst-id e) (subst-id e₁)
subst-id rz = Refl
subst-id (rsuc e) = ap rsuc (subst-id e)
subst-id (rrec e e₁ e₂ P) = {!!}
subst-id (prod e e₁) = ap2 prod (subst-id e) (subst-id e₁)
subst-id (l-proj e) = ap l-proj (subst-id e)
subst-id (r-proj e) = ap r-proj (subst-id e)
subst-id nil = Refl
subst-id (e ::c e₁) = ap2 _::c_ (subst-id e) (subst-id e₁)
subst-id true = Refl
subst-id false = Refl
subst-id (listrec e e₁ e₂) = ap3 listrec (subst-id e) (subst-id e₁) (ap (subst e₂) (ap s-extend (ap s-extend extend-id-once) ∘ extend-id-twice) ∘ subst-id e₂)
-}
extend-rs-once-lemma : ∀ {A B C τ τ'} → (x : τ ∈ τ' :: B) (ρ : rctx C A) (Θ : sctx A B) → _==_ {_} {τ' :: C |- τ}
(_rs_ {τ' :: C} {τ' :: A} {τ' :: B} (r-extend {C} {A} {τ'} ρ)
(s-extend {A} {B} {τ'} Θ) {τ} x)
(s-extend {C} {B} {τ'} (_rs_ {C} {A} {B} ρ Θ) {τ} x)
extend-rs-once-lemma i0 ρ Θ = Refl
extend-rs-once-lemma (iS x) ρ Θ = ! (ren-comp iS ρ (Θ x)) ∘ ren-comp (r-extend ρ) iS (Θ x)
{-
extend-rs-once : ∀ {A B C τ} → (ρ : rctx C A) (Θ : sctx A B)
→ Id {_} {sctx (τ :: C) (τ :: B)} (r-extend ρ rs s-extend Θ) (s-extend (ρ rs Θ))
extend-rs-once ρ Θ = λ=i (λ τ → λ= (λ x → extend-rs-once-lemma x ρ Θ))
extend-rs-twice : ∀ {A B C τ τ'} → (ρ : rctx C A) (Θ : sctx A B)
→ Id {_} {sctx (τ :: τ' :: C) (τ :: τ' :: B)} ((r-extend (r-extend ρ)) rs (s-extend (s-extend Θ))) ((s-extend (s-extend (ρ rs Θ))))
extend-rs-twice ρ Θ = ap s-extend (extend-rs-once ρ Θ) ∘ extend-rs-once (r-extend ρ) (s-extend Θ)
subst-rs : ∀ {A B C τ} → (ρ : rctx C A) (Θ : sctx A B) (e : B |- τ)
→ ren (subst e Θ) ρ == subst e (ρ rs Θ)
subst-rs ρ Θ unit = Refl
subst-rs ρ Θ 0C = Refl
subst-rs ρ Θ 1C = Refl
subst-rs ρ Θ (plusC e e₁) = ap2 plusC (subst-rs ρ Θ e) (subst-rs ρ Θ e₁)
subst-rs ρ Θ (var x) = svar-rs ρ Θ x
subst-rs ρ Θ z = Refl
subst-rs ρ Θ (suc e) = ap suc (subst-rs ρ Θ e)
subst-rs ρ Θ (rec e e₁ e₂) = ap3 rec (subst-rs ρ Θ e) (subst-rs ρ Θ e₁)
(ap (subst e₂) (extend-rs-twice ρ Θ) ∘
subst-rs (r-extend (r-extend ρ)) (s-extend (s-extend Θ)) e₂)
subst-rs ρ Θ (lam e) = ap lam (ap (subst e) (extend-rs-once ρ Θ) ∘ subst-rs (r-extend ρ) (s-extend Θ) e)
subst-rs ρ Θ (app e e₁) = ap2 app (subst-rs ρ Θ e) (subst-rs ρ Θ e₁)
subst-rs ρ Θ (prod e e₁) = ap2 prod (subst-rs ρ Θ e) (subst-rs ρ Θ e₁)
subst-rs ρ Θ (l-proj e) = ap l-proj (subst-rs ρ Θ e)
subst-rs ρ Θ (r-proj e) = ap r-proj (subst-rs ρ Θ e)
subst-rs ρ Θ nil = Refl
subst-rs ρ Θ (e ::c e₁) = ap2 _::c_ (subst-rs ρ Θ e) (subst-rs ρ Θ e₁)
subst-rs ρ Θ true = Refl
subst-rs ρ Θ false = Refl
subst-rs ρ Θ (listrec e e₁ e₂) = ap3 listrec (subst-rs ρ Θ e) (subst-rs ρ Θ e₁)
(ap (subst e₂) (ap s-extend (ap s-extend (extend-rs-once ρ Θ)) ∘
extend-rs-twice (r-extend ρ) (s-extend Θ)) ∘
subst-rs (r-extend (r-extend (r-extend ρ))) (s-extend (s-extend (s-extend Θ))) e₂)
extend-sr-once-lemma : ∀ {A B C τ τ'} → (Θ : sctx A B) (ρ : rctx B C) (x : τ ∈ τ' :: C)
→ _==_ {_} {τ' :: A |- τ} (s-extend (_sr_ Θ ρ) x) (_sr_ (s-extend Θ) (r-extend ρ) x)
extend-sr-once-lemma Θ ρ i0 = Refl
extend-sr-once-lemma Θ ρ (iS x) = Refl
extend-sr-once : ∀ {A B C τ} → (Θ : sctx A B) (ρ : rctx B C)
→ Id {_} {sctx (τ :: A) (τ :: C)} (s-extend Θ sr r-extend ρ) (s-extend (Θ sr ρ))
extend-sr-once Θ ρ = λ=i (λ τ → λ= (λ x → ! (extend-sr-once-lemma Θ ρ x)))
extend-sr-twice : ∀ {A B C τ τ'} → (Θ : sctx A B) (ρ : rctx B C)
→ Id {_} {sctx (τ' :: τ :: A) (τ' :: τ :: C)}
(s-extend (s-extend Θ) sr r-extend (r-extend ρ)) (s-extend (s-extend (Θ sr ρ)))
extend-sr-twice Θ ρ = ap s-extend (extend-sr-once Θ ρ) ∘ extend-sr-once (s-extend Θ) (r-extend ρ)
sr-comp : ∀ {Γ Γ' Γ'' τ} → (Θ : sctx Γ Γ') → (ρ : rctx Γ' Γ'') → (e : Γ'' |- τ)
→ (subst (ren e ρ) Θ) == subst e (Θ sr ρ)
sr-comp Θ ρ unit = Refl
sr-comp Θ ρ 0C = Refl
sr-comp Θ ρ 1C = Refl
sr-comp Θ ρ (plusC e e₁) = ap2 plusC (sr-comp Θ ρ e) (sr-comp Θ ρ e₁)
sr-comp Θ ρ (var x) = svar-sr Θ ρ x
sr-comp Θ ρ z = Refl
sr-comp Θ ρ (suc e) = ap suc (sr-comp Θ ρ e)
sr-comp Θ ρ (rec e e₁ e₂) = ap3 rec (sr-comp Θ ρ e) (sr-comp Θ ρ e₁)
(ap (subst e₂) (ap s-extend (extend-sr-once Θ ρ) ∘
extend-sr-once (s-extend Θ) (r-extend ρ)) ∘
sr-comp (s-extend (s-extend Θ)) (r-extend (r-extend ρ)) e₂)
sr-comp Θ ρ (lam e) = ap lam (ap (subst e) (extend-sr-once Θ ρ) ∘ sr-comp (s-extend Θ) (r-extend ρ) e)
sr-comp Θ ρ (app e e₁) = ap2 app (sr-comp Θ ρ e) (sr-comp Θ ρ e₁)
sr-comp Θ ρ (prod e e₁) = ap2 prod (sr-comp Θ ρ e) (sr-comp Θ ρ e₁)
sr-comp Θ ρ (l-proj e) = ap l-proj (sr-comp Θ ρ e)
sr-comp Θ ρ (r-proj e) = ap r-proj (sr-comp Θ ρ e)
sr-comp Θ ρ nil = Refl
sr-comp Θ ρ (e ::c e₁) = ap2 _::c_ (sr-comp Θ ρ e) (sr-comp Θ ρ e₁)
sr-comp Θ ρ (listrec e e₁ e₂) = ap3 listrec (sr-comp Θ ρ e) (sr-comp Θ ρ e₁)
(ap (subst e₂) (ap s-extend (ap s-extend (extend-sr-once Θ ρ)) ∘
extend-sr-twice (s-extend Θ) (r-extend ρ)) ∘
sr-comp (s-extend (s-extend (s-extend Θ)))
(r-extend (r-extend (r-extend ρ))) e₂)
sr-comp Θ ρ true = Refl
sr-comp Θ ρ false = Refl
extend-ss-once-lemma : ∀ {A B C τ τ'} → (Θ1 : sctx A B) (Θ2 : sctx B C) (x : τ ∈ τ' :: C)
→ _==_ {_} {τ' :: A |- τ} (s-extend (_ss_ Θ1 Θ2) x) (_ss_ (s-extend Θ1) (s-extend Θ2) x)
extend-ss-once-lemma Θ1 Θ2 i0 = Refl
extend-ss-once-lemma Θ1 Θ2 (iS x) = ! (sr-comp (s-extend Θ1) iS (Θ2 x)) ∘ rs-comp iS Θ1 (Θ2 x)
extend-ss-once : ∀ {A B C τ} → (Θ1 : sctx A B) (Θ2 : sctx B C)
→ _==_ {_} {sctx (τ :: A) (τ :: C)} (s-extend (Θ1 ss Θ2))
((s-extend Θ1) ss
(s-extend Θ2))
extend-ss-once Θ1 Θ2 = λ=i (λ τ → λ= (λ x → extend-ss-once-lemma Θ1 Θ2 x))
subst-ss : ∀ {A B C τ} → (Θ1 : sctx A B) (Θ2 : sctx B C) (e : C |- τ)
→ subst e (Θ1 ss Θ2) == subst (subst e Θ2) Θ1
subst-ss Θ1 Θ2 unit = Refl
subst-ss Θ1 Θ2 0C = Refl
subst-ss Θ1 Θ2 1C = Refl
subst-ss Θ1 Θ2 (plusC e e₁) = ap2 plusC (subst-ss Θ1 Θ2 e) (subst-ss Θ1 Θ2 e₁)
subst-ss Θ1 Θ2 (var x) = svar-ss Θ1 Θ2 x
subst-ss Θ1 Θ2 z = Refl
subst-ss Θ1 Θ2 (suc e) = ap suc (subst-ss Θ1 Θ2 e)
subst-ss Θ1 Θ2 (rec e e₁ e₂) = ap3 rec (subst-ss Θ1 Θ2 e) (subst-ss Θ1 Θ2 e₁)
(subst-ss (s-extend (s-extend Θ1)) (s-extend (s-extend Θ2)) e₂ ∘
ap (subst e₂) (extend-ss-once (s-extend Θ1) (s-extend Θ2) ∘
ap s-extend (extend-ss-once Θ1 Θ2)))
subst-ss Θ1 Θ2 (lam e) = ap lam (subst-ss (s-extend Θ1) (s-extend Θ2) e ∘ ap (subst e) (extend-ss-once Θ1 Θ2))
subst-ss Θ1 Θ2 (app e e₁) = ap2 app (subst-ss Θ1 Θ2 e) (subst-ss Θ1 Θ2 e₁)
subst-ss Θ1 Θ2 (prod e e₁) = ap2 prod (subst-ss Θ1 Θ2 e) (subst-ss Θ1 Θ2 e₁)
subst-ss Θ1 Θ2 (l-proj e) = ap l-proj (subst-ss Θ1 Θ2 e)
subst-ss Θ1 Θ2 (r-proj e) = ap r-proj (subst-ss Θ1 Θ2 e)
subst-ss Θ1 Θ2 nil = Refl
subst-ss Θ1 Θ2 (e ::c e₁) = ap2 _::c_ (subst-ss Θ1 Θ2 e) (subst-ss Θ1 Θ2 e₁)
subst-ss Θ1 Θ2 true = Refl
subst-ss Θ1 Θ2 false = Refl
subst-ss Θ1 Θ2 (listrec e e₁ e₂) = ap3 listrec (subst-ss Θ1 Θ2 e) (subst-ss Θ1 Θ2 e₁)
(subst-ss (s-extend (s-extend (s-extend Θ1))) (s-extend (s-extend (s-extend Θ2))) e₂ ∘
ap (subst e₂) (extend-ss-once (s-extend (s-extend Θ1)) (s-extend (s-extend Θ2)) ∘
ap s-extend (extend-ss-once (s-extend Θ1) (s-extend Θ2) ∘
ap s-extend (extend-ss-once Θ1 Θ2))))
throw : ∀ {Γ Γ' τ} → sctx Γ (τ :: Γ') → sctx Γ Γ'
throw Θ x = Θ (iS x)
fuse1 : ∀ {Γ Γ' τ τ'} (v : Γ |- τ') (Θ : sctx Γ Γ') (x : τ ∈ Γ') → (q v ss q∙ Θ) x == Θ x
fuse1 v Θ x = subst (ren (Θ x) iS) (q v) =⟨ sr-comp (q v) iS (Θ x) ⟩
subst (Θ x) (q v sr iS) =⟨ Refl ⟩
subst (Θ x) ids =⟨ ! (subst-id (Θ x)) ⟩
(Θ x ∎)
subst-compose-lemma-lemma : ∀ {Γ Γ' τ τ'} (v : Γ |- τ') (Θ : sctx Γ Γ') (x : τ ∈ τ' :: Γ')
→ _==_ {_} {Γ |- τ} (_ss_ (q v) (s-extend Θ) x) (lem3' Θ v x)
subst-compose-lemma-lemma v Θ i0 = Refl
subst-compose-lemma-lemma v Θ (iS x) = fuse1 v Θ x
subst-compose-lemma : ∀ {Γ Γ' τ} (v : Γ |- τ) (Θ : sctx Γ Γ')
→ _==_ {_} {sctx Γ (τ :: Γ')} ((q v) ss (s-extend Θ)) (lem3' Θ v)
subst-compose-lemma v Θ = λ=i (λ τ → λ= (λ x → subst-compose-lemma-lemma v Θ x))
subst-compose : ∀ {Γ Γ' τ τ1} (Θ : sctx Γ Γ') (v : Γ |- τ) (e : (τ :: Γ' |- τ1) )
→ subst (subst e (s-extend Θ)) (q v) == subst e (lem3' Θ v)
subst-compose Θ v e = ap (subst e) (subst-compose-lemma v Θ) ∘ (! (subst-ss (q v) (s-extend Θ) e))
fuse2 : ∀ {Γ Γ' τ τ1 τ2} (v1 : Γ |- τ1) (v2 : Γ |- τ2) (Θ : sctx Γ Γ') (x : τ ∈ τ2 :: Γ')
→ (lem4 v1 v2 ss throw (s-extend (s-extend Θ))) x == (lem3' Θ v2) x
fuse2 v1 v2 Θ x = subst (ren (s-extend Θ x) iS) (lem4 v1 v2) =⟨ sr-comp (lem4 v1 v2) iS (s-extend Θ x) ⟩
subst (s-extend Θ x) (lem4 v1 v2 sr iS) =⟨ Refl ⟩
subst (s-extend Θ x) (lem3' ids v2) =⟨ subst-compose-lemma-lemma v2 Θ x ⟩
(lem3' Θ v2 x ∎)
subst-compose2-lemma-lemma : ∀ {Γ Γ' τ τ1 τ2 τ'} (v1 : Γ |- τ1) (v2 : Γ |- τ2) (e1 : τ1 :: τ2 :: Γ' |- τ) (Θ : sctx Γ Γ') (x : τ' ∈ τ1 :: τ2 :: Γ')
→ _==_ {_} {_} ((lem4 v1 v2 ss s-extend (s-extend Θ)) x) (lem4' Θ v1 v2 x)
subst-compose2-lemma-lemma v1 v2 e1 Θ i0 = Refl
subst-compose2-lemma-lemma v1 v2 e1 Θ (iS x) = fuse2 v1 v2 Θ x
subst-compose2-lemma : ∀ {Γ Γ' τ τ1 τ2} (v1 : Γ |- τ1) (v2 : Γ |- τ2) (e1 : τ1 :: τ2 :: Γ' |- τ) (Θ : sctx Γ Γ')
→ _==_ {_} {sctx Γ (τ1 :: τ2 :: Γ')} (lem4 v1 v2 ss s-extend (s-extend Θ)) (lem4' Θ v1 v2)
subst-compose2-lemma v1 v2 e1 Θ = λ=i (λ τ → λ= (λ x → subst-compose2-lemma-lemma v1 v2 e1 Θ x))
fuse3 : ∀ {Γ Γ' τ1 τ2 τ'} (Θ : sctx Γ Γ') (v1 : Γ' |- τ1) (v2 : Γ' |- τ2) (x : τ' ∈ τ2 :: Γ')
→ subst (lem3' ids v2 x) Θ == lem3' Θ (subst v2 Θ) x
fuse3 Θ v1 v2 i0 = Refl
fuse3 Θ v1 v2 (iS x) = Refl
subst-compose3-lemma-lemma : ∀ {Γ Γ' τ τ1 τ2 τ'} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ' |- τ1) (v2 : Γ' |- τ2) (x : τ' ∈ τ1 :: τ2 :: Γ')
→ _==_ {_} {_} ((Θ ss lem4 v1 v2) x) (lem4' Θ (subst v1 Θ) (subst v2 Θ) x)
subst-compose3-lemma-lemma Θ e1 v1 v2 i0 = Refl
subst-compose3-lemma-lemma Θ e1 v1 v2 (iS x) = fuse3 Θ v1 v2 x
subst-compose3-lemma : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ' |- τ1) (v2 : Γ' |- τ2)
→ _==_ {_} {sctx Γ (τ1 :: τ2 :: Γ')} (Θ ss lem4 v1 v2) (lem4' Θ (subst v1 Θ) (subst v2 Θ))
subst-compose3-lemma Θ e1 v1 v2 = λ=i (λ τ → λ= (λ x → subst-compose3-lemma-lemma Θ e1 v1 v2 x))
subst-compose2 : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ |- τ1) (v2 : Γ |- τ2)
→ subst (subst e1 (s-extend (s-extend Θ))) (lem4 v1 v2) == subst e1 (lem4' Θ v1 v2)
subst-compose2 Θ e1 v1 v2 = ap (subst e1) (subst-compose2-lemma v1 v2 e1 Θ) ∘
! (subst-ss (lem4 v1 v2) (s-extend (s-extend Θ)) e1)
subst-compose3 : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ' |- τ1) (v2 : Γ' |- τ2)
→ subst (subst e1 (lem4 v1 v2)) Θ == subst e1 (lem4' Θ (subst v1 Θ) (subst v2 Θ))
subst-compose3 Θ e1 v1 v2 = ap (subst e1) (subst-compose3-lemma Θ e1 v1 v2) ∘ ! (subst-ss Θ (lem4 v1 v2) e1)
subst-compose4 : ∀ {Γ Γ' τ} (Θ : sctx Γ Γ') (v' : Γ |- nat) (r : Γ |- τ) (e2 : (nat :: (τ :: Γ')) |- τ)
→ subst (subst e2 (s-extend (s-extend Θ))) (lem4 v' r) == subst e2 (lem4' Θ v' r)
subst-compose4 Θ v' r e2 = subst-compose2 Θ e2 v' r
fuse4-lemma : ∀ {Γ Γ' τ τ1 τ2 τ3} (v1 : Γ |- τ1) (v2 : Γ |- τ2) (v3 : Γ |- τ3) (Θ : sctx Γ Γ') (x : τ ∈ Γ')
→ (lem3' (lem3' ids v3) v2 ss q∙ (q∙ Θ)) x == Θ x
fuse4-lemma v1 v2 v3 Θ x = subst (ren (wkn (Θ x)) iS) (lem3' (q v3) v2) =⟨ sr-comp (lem3' (q v3) v2) iS (wkn (Θ x)) ⟩
subst (wkn (Θ x)) (lem3' (q v3) v2 sr iS) =⟨ Refl ⟩
subst (ren (Θ x) iS) (lem3' (q v3) v2 sr iS) =⟨ sr-comp (lem3' (q v3) v2 sr iS) iS (Θ x) ⟩
subst (Θ x) ((lem3' (q v3) v2 sr iS) sr iS) =⟨ Refl ⟩
subst (Θ x) ids =⟨ ! (subst-id (Θ x)) ⟩
(Θ x ∎)
fuse4 : ∀ {Γ Γ' τ τ1 τ2 τ3} (v1 : Γ |- τ1) (v2 : Γ |- τ2) (v3 : Γ |- τ3) (Θ : sctx Γ Γ') (x : τ ∈ τ2 :: τ3 :: Γ')
→ subst (s-extend (s-extend Θ) x) (lem3' (lem3' ids v3) v2) == lem3' (lem3' Θ v3) v2 x
fuse4 v1 v2 v3 Θ i0 = Refl
fuse4 v1 v2 v3 Θ (iS i0) = Refl
fuse4 v1 v2 v3 Θ (iS (iS x)) = subst (wkn (wkn (Θ x))) (lem3' (lem3' ids v3) v2) =⟨ subst-ss (lem3' (lem3' ids v3) v2) (q∙ (q∙ Θ)) (var x) ⟩
subst (var x) (lem3' (lem3' ids v3) v2 ss q∙ (q∙ Θ)) =⟨ fuse4-lemma v1 v2 v3 Θ x ⟩
subst (var x) Θ =⟨ Refl ⟩
(Θ x ∎)
subst-compose5-lemma-lemma : ∀ {Γ Γ' τ τ1 τ2 τ3 τ'} (v1 : Γ |- τ1) (v2 : Γ |- τ2) (v3 : Γ |- τ3) (e1 : τ1 :: τ2 :: τ3 :: Γ' |- τ) (Θ : sctx Γ Γ') (x : τ' ∈ τ1 :: τ2 :: τ3 :: Γ')
→ _==_ {_} {_} ((lem5 v1 v2 v3 ss s-extend (s-extend (s-extend Θ))) x) (lem5' Θ v1 v2 v3 x)
subst-compose5-lemma-lemma v1 v2 v3 e Θ i0 = Refl
subst-compose5-lemma-lemma v1 v2 v3 e Θ (iS x) = (lem5 v1 v2 v3 ss s-extend (s-extend (s-extend Θ))) (iS x) =⟨ sr-comp (lem5 v1 v2 v3) iS (s-extend (s-extend Θ) x) ⟩
subst (s-extend (s-extend Θ) x) (lem3' (lem3' ids v3) v2) =⟨ fuse4 v1 v2 v3 Θ x ⟩
(lem3' (lem3' Θ v3) v2 x ∎)
subst-compose5-lemma : ∀ {Γ Γ' τ τ1 τ2 τ3} (v1 : Γ |- τ1) (v2 : Γ |- τ2) (v3 : Γ |- τ3) (e : τ1 :: τ2 :: τ3 :: Γ' |- τ) (Θ : sctx Γ Γ')
→ _==_ {_} {sctx Γ (τ1 :: τ2 :: τ3 :: Γ')} (lem5 v1 v2 v3 ss (s-extend (s-extend (s-extend Θ)))) (lem5' Θ v1 v2 v3)
subst-compose5-lemma v1 v2 v3 e Θ = λ=i (λ τ → λ= (λ x → subst-compose5-lemma-lemma v1 v2 v3 e Θ x))
subst-compose5 : ∀ {Γ Γ' τ τ1 τ2 τ3} (Θ : sctx Γ Γ') (e : (τ1 :: (τ2 :: (τ3 :: Γ'))) |- τ) (v1 : Γ |- τ1) (v2 : Γ |- τ2) (v3 : Γ |- τ3)
→ subst (subst e (s-extend (s-extend (s-extend (Θ))))) (lem5 v1 v2 v3) == subst e (lem5' Θ v1 v2 v3)
subst-compose5 Θ e v1 v2 v3 = ap (subst e) (subst-compose5-lemma v1 v2 v3 e Θ) ∘
! (subst-ss (lem5 v1 v2 v3) (s-extend (s-extend (s-extend Θ))) e)
-}
_+C_ : ∀ {Γ τ} → Γ |- C → Γ |- (C ×c τ)→ Γ |- (C ×c τ)
c +C e = prod (plusC c (l-proj e)) (r-proj e)
_trans_ : ∀ {Γ T}
→ {e e' e'' : Γ |- T}
→ e ≤s e' → e' ≤s e''
→ e ≤s e''
_trans_ = trans-s
infixr 10 _trans_
| 55.200342
| 179
| 0.463567
|
19cf0d6eaf6fff40634c3b1235f8e7b7a187d0d7
| 852
|
agda
|
Agda
|
test/Succeed/ByeByeSet.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/ByeByeSet.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/ByeByeSet.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- 'Set' is no longer a keyword but a primitive defined in
-- 'Agda.Primitive'. It is imported by default but this can be
-- disabled with a flag:
{-# OPTIONS --no-import-sorts #-}
-- By importing Agda.Primitive explicitly we can rename 'Set' to
-- something else:
open import Agda.Primitive renaming (Set to Type)
-- Now 'Set' is no longer in scope:
-- test₁ = Set
-- Error message: Not in scope: Set
-- Instead it is now called 'Type'. Note that suffixed versions
-- 'Type₁', 'Type₂', ... work as expected, as does 'Type ℓ' for a
-- level 'ℓ'!
Foo : Type₁
Foo = Type
Bar : ∀ ℓ → Type (lsuc ℓ)
Bar ℓ = Type ℓ
-- We can now redefine Set however we want:
open import Agda.Builtin.Equality
open import Agda.Builtin.Sigma
IsSet : ∀ {ℓ} → Type ℓ → Type ℓ
IsSet X = {x y : X} (p q : x ≡ y) → p ≡ q
Set : ∀ ℓ → Type (lsuc ℓ)
Set ℓ = Σ (Type ℓ) IsSet
| 25.818182
| 65
| 0.658451
|
2107c8d7278b114b27fd2424e0347693c2c70ddf
| 53
|
agda
|
Agda
|
test/Fail/Issue5781c.agda
|
sseefried/agda
|
6b13364d36eeb60d8ec15eaf8effe23c73401900
|
[
"BSD-2-Clause"
] | 1
|
2022-03-05T00:25:14.000Z
|
2022-03-05T00:25:14.000Z
|
test/Fail/Issue5781c.agda
|
SNU-2D/agda
|
b5b3b1657556f720a7310cb7744edb1fac71eaf4
|
[
"BSD-2-Clause"
] | 6
|
2021-10-18T08:12:24.000Z
|
2021-11-24T08:31:10.000Z
|
test/Fail/Issue5781c.agda
|
SNU-2D/agda
|
b5b3b1657556f720a7310cb7744edb1fac71eaf4
|
[
"BSD-2-Clause"
] | null | null | null |
{-# OPTIONS --profile=modules --profile=internal #-}
| 26.5
| 52
| 0.679245
|
1bb46e4993d7191ad0e3bca165cc068d5253c9e6
| 882
|
agda
|
Agda
|
test/Succeed/Issue3177.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3177.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3177.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
postulate
A : Set
Phantom : A → Set
Phantom _ = A
postulate
rigid : A → A
mutual
X : A → A → A → A
X = _
Y : (x y : A) → Phantom x
Y = _
-- This constraint triggers pruning of X in an attempt to remove the non-linearity.
-- It doesn't get rid of the non-linearity but prunes x setting X x y z := Z y z,
-- for a fresh meta Z.
c₁ : (x y : A) → X x y y ≡ rigid y
c₁ x y = refl
-- Here we end up with Z y z == rigid (Y x y) which requires pruning x from Y. This
-- fails due to the phantom dependency on x in the type of Y and the constraint is
-- left unsolved. If we hadn't pruned x from X we could have solved this with
-- X x y z := rigid (Y x y), turning the first constraint into rigid (Y x y) == rigid y,
-- which is solved by Y x y := y.
c₂ : (x y z : A) → X x y z ≡ rigid (Y x y)
c₂ x y z = refl
| 26.727273
| 90
| 0.613379
|
30a47727b863603f919568406be5e91197a88056
| 8,423
|
agda
|
Agda
|
src/Tactic/Nat/Simpl/Lemmas.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
src/Tactic/Nat/Simpl/Lemmas.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
src/Tactic/Nat/Simpl/Lemmas.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
module Tactic.Nat.Simpl.Lemmas where
open import Prelude
open import Tactic.Nat.NF
open import Tactic.Nat.Exp
open import Container.Bag
open import Tactic.Nat.Auto
open import Prelude.Nat.Properties
open import Container.List.Properties
open import Tactic.Nat.Auto.Lemmas
product1-sound : ∀ xs → product1 xs ≡ productR xs
product1-sound [] = refl
product1-sound (x ∷ xs)
rewrite sym (cong (λ x → foldl _*_ x xs) (mul-one-r x))
| foldl-assoc _*_ mul-assoc x 1 xs
| foldl-foldr _*_ 1 mul-assoc add-zero-r mul-one-r xs
= refl
map-eq : ∀ {c b} {A : Set c} {B : Set b} (f g : A → B) →
(∀ x → f x ≡ g x) → ∀ xs → map f xs ≡ map g xs
map-eq f g f=g [] = refl
map-eq f g f=g (x ∷ xs) rewrite f=g x | map-eq f g f=g xs = refl
fst-*** : ∀ {a b} {A₁ A₂ : Set a} {B₁ B₂ : Set b}
(f : A₁ → B₁) (g : A₂ → B₂) (p : A₁ × A₂) →
fst ((f *** g) p) ≡ f (fst p)
fst-*** f g (x , y) = refl
snd-*** : ∀ {a b} {A₁ A₂ : Set a} {B₁ B₂ : Set b}
(f : A₁ → B₁) (g : A₂ → B₂) (p : A₁ × A₂) →
snd ((f *** g) p) ≡ g (snd p)
snd-*** f g (x , y) = refl
eta : ∀ {a b} {A : Set a} {B : Set b} (p : A × B) → p ≡ (fst p , snd p)
eta (x , y) = refl
private
shuffle₁ : (a b c : Nat) → a + (b + c) ≡ b + (a + c)
shuffle₁ a b c = auto
module _ {Atom : Set} {{_ : Ord Atom}} where
NFEqS : NF Atom × NF Atom → Env Atom → Set
NFEqS (nf₁ , nf₂) ρ = ⟦ nf₁ ⟧ns ρ ≡ ⟦ nf₂ ⟧ns ρ
NFEq : NF Atom × NF Atom → Env Atom → Set
NFEq (nf₁ , nf₂) ρ = ⟦ nf₁ ⟧n ρ ≡ ⟦ nf₂ ⟧n ρ
ts-sound : ∀ x (ρ : Env Atom) → ⟦ x ⟧ts ρ ≡ ⟦ x ⟧t ρ
ts-sound (0 , x) ρ = mul-zero-r (product1 (map ρ x))
ts-sound (1 , x) ρ = product1-sound (map ρ x) ⟨≡⟩ʳ add-zero-r _
ts-sound (suc (suc i) , x) ρ
rewrite sym (product1-sound (map ρ x))
= auto
private
et : Env Atom → Nat × Tm Atom → Nat
et = flip ⟦_⟧t
ets : Env Atom → Nat × Tm Atom → Nat
ets = flip ⟦_⟧ts
plus-nf : Nat → Env Atom → NF Atom → Nat
plus-nf = λ a ρ xs → a + ⟦ xs ⟧n ρ
ns-sound : ∀ nf (ρ : Env Atom) → ⟦ nf ⟧ns ρ ≡ ⟦ nf ⟧n ρ
ns-sound [] ρ = refl
ns-sound (x ∷ nf) ρ
rewrite sym (foldl-map-fusion _+_ (ets ρ) (ets ρ x) nf)
| ts-sound x ρ
| map-eq (ets ρ) (et ρ) (flip ts-sound ρ) nf
| sym (foldl-foldr _+_ 0 add-assoc (λ _ → refl) add-zero-r (map (et ρ) nf))
| sym (foldl-assoc _+_ add-assoc (et ρ x) 0 (map (et ρ) nf))
| add-zero-r (et ρ x)
= refl
private
lem-sound : ∀ a b ρ f g (xs : NF Atom × NF Atom) →
a + ⟦ fst ((f *** g) xs) ⟧n ρ ≡ b + ⟦ snd ((f *** g) xs) ⟧n ρ →
a + ⟦ f (fst xs) ⟧n ρ ≡ b + ⟦ g (snd xs) ⟧n ρ
lem-sound a b ρ f g xs H =
cong (plus-nf a ρ) (fst-*** f g xs)
ʳ⟨≡⟩ H
⟨≡⟩ cong (plus-nf b ρ) (snd-*** f g xs)
cancel-sound′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) →
a + ⟦ fst (cancel nf₁ nf₂) ⟧n ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧n ρ →
a + ⟦ nf₁ ⟧n ρ ≡ b + ⟦ nf₂ ⟧n ρ
cancel-sound′ a b [] [] ρ H = H
cancel-sound′ a b [] (x ∷ nf₂) ρ H = H
cancel-sound′ a b (x ∷ nf₁) [] ρ H = H
cancel-sound′ a b ((i , x) ∷ nf₁) ((j , y) ∷ nf₂) ρ H
with compare x y
... | less _ = add-assoc a _ _ ⟨≡⟩ cancel-sound′ (a + et ρ (i , x)) b nf₁ ((j , y) ∷ nf₂) ρ
(add-assoc a _ _ ʳ⟨≡⟩ lem-sound a b ρ (_∷_ (i , x)) id (cancel nf₁ ((j , y) ∷ nf₂)) H)
... | greater _ =
cancel-sound′ a (b + et ρ (j , y)) ((i , x) ∷ nf₁) nf₂ ρ
(lem-sound a b ρ id (_∷_ (j , y)) (cancel ((i , x) ∷ nf₁) nf₂) H ⟨≡⟩ add-assoc b _ _)
⟨≡⟩ʳ add-assoc b _ _
cancel-sound′ a b ((i , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl
with compare i j
cancel-sound′ a b ((i , x) ∷ nf₁) ((.(suc k + i) , .x) ∷ nf₂) ρ H | equal refl | less (diff! k) =
shuffle₁ a (et ρ (i , x)) _
⟨≡⟩ cong (et ρ (i , x) +_) (cancel-sound′ a (b + et ρ (suc k , x)) nf₁ nf₂ ρ
(lem-sound a b ρ id (_∷_ (suc k , x)) (cancel nf₁ nf₂) H ⟨≡⟩ add-assoc b _ _))
⟨≡⟩ auto
cancel-sound′ a b ((.(suc k + j) , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl | greater (diff! k) =
sym (shuffle₁ b (et ρ (j , x)) _
⟨≡⟩ cong (et ρ (j , x) +_) (sym (cancel-sound′ (a + et ρ (suc k , x)) b nf₁ nf₂ ρ
(add-assoc a _ _ ʳ⟨≡⟩ lem-sound a b ρ (_∷_ (suc k , x)) id (cancel nf₁ nf₂) H)))
⟨≡⟩ auto)
cancel-sound′ a b ((i , x) ∷ nf₁) ((.i , .x) ∷ nf₂) ρ H | equal refl | equal refl =
shuffle₁ a (et ρ (i , x)) _
⟨≡⟩ cong (et ρ (i , x) +_) (cancel-sound′ a b nf₁ nf₂ ρ H)
⟨≡⟩ shuffle₁ (et ρ (i , x)) b _
cancel-sound-s′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) →
a + ⟦ fst (cancel nf₁ nf₂) ⟧ns ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧ns ρ →
a + ⟦ nf₁ ⟧ns ρ ≡ b + ⟦ nf₂ ⟧ns ρ
cancel-sound-s′ a b nf₁ nf₂ ρ eq =
(a +_) $≡ ns-sound nf₁ ρ ⟨≡⟩
cancel-sound′ a b nf₁ nf₂ ρ
((a +_) $≡ ns-sound (fst (cancel nf₁ nf₂)) ρ ʳ⟨≡⟩
eq ⟨≡⟩ (b +_) $≡ ns-sound (snd (cancel nf₁ nf₂)) ρ) ⟨≡⟩ʳ
(b +_) $≡ ns-sound nf₂ ρ
cancel-sound : ∀ nf₁ nf₂ ρ → NFEqS (cancel nf₁ nf₂) ρ → NFEq (nf₁ , nf₂) ρ
cancel-sound nf₁ nf₂ ρ H rewrite cong (λ p → NFEqS p ρ) (eta (cancel nf₁ nf₂)) =
(cancel-sound′ 0 0 nf₁ nf₂ ρ
(ns-sound (fst (cancel nf₁ nf₂)) ρ
ʳ⟨≡⟩ H ⟨≡⟩
ns-sound (snd (cancel nf₁ nf₂)) ρ))
private
prod : Env Atom → List Atom → Nat
prod ρ x = productR (map ρ x)
private
lem-complete : ∀ a b ρ f g (xs : NF Atom × NF Atom) →
a + ⟦ f (fst xs) ⟧n ρ ≡ b + ⟦ g (snd xs) ⟧n ρ →
a + ⟦ fst ((f *** g) xs) ⟧n ρ ≡ b + ⟦ snd ((f *** g) xs) ⟧n ρ
lem-complete a b ρ f g xs H =
cong (plus-nf a ρ) (fst-*** f g xs)
⟨≡⟩ H
⟨≡⟩ʳ cong (plus-nf b ρ) (snd-*** f g xs)
cancel-complete′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) →
a + ⟦ nf₁ ⟧n ρ ≡ b + ⟦ nf₂ ⟧n ρ →
a + ⟦ fst (cancel nf₁ nf₂) ⟧n ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧n ρ
cancel-complete′ a b [] [] ρ H = H
cancel-complete′ a b [] (x ∷ nf₂) ρ H = H
cancel-complete′ a b (x ∷ nf₁) [] ρ H = H
cancel-complete′ a b ((i , x) ∷ nf₁) ((j , y) ∷ nf₂) ρ H with compare x y
... | less lt =
lem-complete a b ρ (_∷_ (i , x)) id (cancel nf₁ ((j , y) ∷ nf₂))
(add-assoc a _ _
⟨≡⟩ cancel-complete′ (a + et ρ (i , x)) b nf₁ ((j , y) ∷ nf₂) ρ
(add-assoc a _ _ ʳ⟨≡⟩ H))
... | greater _ =
lem-complete a b ρ id (_∷_ (j , y)) (cancel ((i , x) ∷ nf₁) nf₂)
(cancel-complete′ a (b + et ρ (j , y)) ((i , x) ∷ nf₁) nf₂ ρ
(H ⟨≡⟩ add-assoc b _ _)
⟨≡⟩ʳ add-assoc b _ _)
cancel-complete′ a b ((i , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl with compare i j
cancel-complete′ a b ((i , x) ∷ nf₁) ((.(suc (k + i)) , .x) ∷ nf₂) ρ H | equal refl | less (diff! k) =
lem-complete a b ρ id (_∷_ (suc k , x)) (cancel nf₁ nf₂)
(cancel-complete′ a (b + suc k * prod ρ x) nf₁ nf₂ ρ
(add-inj₂ (i * prod ρ x) _ _
(shuffle₁ (i * prod ρ x) a _
⟨≡⟩ H ⟨≡⟩ auto))
⟨≡⟩ʳ add-assoc b _ _)
cancel-complete′ a b ((.(suc (k + j)) , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl | greater (diff! k) =
lem-complete a b ρ (_∷_ (suc k , x)) id (cancel nf₁ nf₂)
(add-assoc a _ _ ⟨≡⟩
cancel-complete′ (a + suc k * prod ρ x) b nf₁ nf₂ ρ
(add-inj₂ (j * prod ρ x) _ _
(sym (shuffle₁ (j * prod ρ x) b _ ⟨≡⟩ʳ
auto ʳ⟨≡⟩ H))))
cancel-complete′ a b ((i , x) ∷ nf₁) ((.i , .x) ∷ nf₂) ρ H | equal refl | equal refl =
cancel-complete′ a b nf₁ nf₂ ρ
(add-inj₂ (i * prod ρ x) _ _
(shuffle₁ a (i * prod ρ x) _ ʳ⟨≡⟩ H ⟨≡⟩ shuffle₁ b (i * prod ρ x) _))
cancel-complete-s′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) →
a + ⟦ nf₁ ⟧ns ρ ≡ b + ⟦ nf₂ ⟧ns ρ →
a + ⟦ fst (cancel nf₁ nf₂) ⟧ns ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧ns ρ
cancel-complete-s′ a b nf₁ nf₂ ρ eq =
(a +_) $≡ ns-sound (fst (cancel nf₁ nf₂)) ρ ⟨≡⟩
cancel-complete′ a b nf₁ nf₂ ρ
((a +_) $≡ ns-sound nf₁ ρ ʳ⟨≡⟩
eq ⟨≡⟩ (b +_) $≡ ns-sound nf₂ ρ) ⟨≡⟩ʳ
(b +_) $≡ ns-sound (snd (cancel nf₁ nf₂)) ρ
cancel-complete : ∀ nf₁ nf₂ ρ → NFEq (nf₁ , nf₂) ρ → NFEqS (cancel nf₁ nf₂) ρ
cancel-complete nf₁ nf₂ ρ H rewrite cong (λ p → NFEqS p ρ) (eta (cancel nf₁ nf₂)) =
ns-sound (fst (cancel nf₁ nf₂)) ρ
⟨≡⟩ cancel-complete′ 0 0 nf₁ nf₂ ρ H
⟨≡⟩ʳ ns-sound (snd (cancel nf₁ nf₂)) ρ
| 41.905473
| 107
| 0.479164
|
1bbeeef16c12c18c8b63a0c645a8a0c659650a32
| 12,848
|
agda
|
Agda
|
core/lib/types/Paths.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
core/lib/types/Paths.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
core/lib/types/Paths.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 lib.Basics
module lib.types.Paths where
{- ! is an equivalence and works on ≠ -}
module _ {i} {A : Type i} {x y : A} where
!-equiv : (x == y) ≃ (y == x)
!-equiv = equiv ! ! !-! !-!
≠-inv : (x ≠ y) → (y ≠ x)
≠-inv x≠y y=x = x≠y (! y=x)
{- Pre- and post- concatenation are equivalences -}
module _ {i} {A : Type i} {x y z : A} where
pre∙-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙ q)
pre∙-is-equiv p = is-eq (λ q → p ∙ q) (λ r → ! p ∙ r) f-g g-f
where f-g : ∀ r → p ∙ ! p ∙ r == r
f-g r = ! (∙-assoc p (! p) r) ∙ ap (λ s → s ∙ r) (!-inv-r p)
g-f : ∀ q → ! p ∙ p ∙ q == q
g-f q = ! (∙-assoc (! p) p q) ∙ ap (λ s → s ∙ q) (!-inv-l p)
pre∙-equiv : (p : x == y) → (y == z) ≃ (x == z)
pre∙-equiv p = ((λ q → p ∙ q) , pre∙-is-equiv p)
post∙-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙ p)
post∙-is-equiv p = is-eq (λ q → q ∙ p) (λ r → r ∙ ! p) f-g g-f
where f-g : ∀ r → (r ∙ ! p) ∙ p == r
f-g r = ∙-assoc r (! p) p ∙ ap (λ s → r ∙ s) (!-inv-l p) ∙ ∙-unit-r r
g-f : ∀ q → (q ∙ p) ∙ ! p == q
g-f q = ∙-assoc q p (! p) ∙ ap (λ s → q ∙ s) (!-inv-r p) ∙ ∙-unit-r q
post∙-equiv : (p : y == z) → (x == y) ≃ (x == z)
post∙-equiv p = ((λ q → q ∙ p) , post∙-is-equiv p)
pre∙'-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙' q)
pre∙'-is-equiv p = is-eq (λ q → p ∙' q) (λ r → ! p ∙' r) f-g g-f
where f-g : ∀ r → p ∙' ! p ∙' r == r
f-g r = ! (∙'-assoc p (! p) r) ∙ ap (λ s → s ∙' r) (!-inv'-r p)
∙ ∙'-unit-l r
g-f : ∀ q → ! p ∙' p ∙' q == q
g-f q = ! (∙'-assoc (! p) p q) ∙ ap (λ s → s ∙' q) (!-inv'-l p)
∙ ∙'-unit-l q
pre∙'-equiv : (p : x == y) → (y == z) ≃ (x == z)
pre∙'-equiv p = ((λ q → p ∙' q) , pre∙'-is-equiv p)
post∙'-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙' p)
post∙'-is-equiv p = is-eq (λ q → q ∙' p) (λ r → r ∙' ! p) f-g g-f
where f-g : ∀ r → (r ∙' ! p) ∙' p == r
f-g r = ∙'-assoc r (! p) p ∙ ap (λ s → r ∙' s) (!-inv'-l p)
g-f : ∀ q → (q ∙' p) ∙' ! p == q
g-f q = ∙'-assoc q p (! p) ∙ ap (λ s → q ∙' s) (!-inv'-r p)
post∙'-equiv : (p : y == z) → (x == y) ≃ (x == z)
post∙'-equiv p = ((λ q → q ∙' p) , post∙'-is-equiv p)
module _ {i j} {A : Type i} {B : Type j}
{f : A → B} {x y : A} {b : B} where
↓-app=cst-in : {p : x == y} {u : f x == b} {v : f y == b}
→ u == (ap f p ∙ v)
→ (u == v [ (λ x → f x == b) ↓ p ])
↓-app=cst-in {p = idp} q = q
↓-app=cst-out : {p : x == y} {u : f x == b} {v : f y == b}
→ (u == v [ (λ x → f x == b) ↓ p ])
→ u == (ap f p ∙ v)
↓-app=cst-out {p = idp} r = r
↓-app=cst-β : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == (ap f p ∙ v))
→ ↓-app=cst-out {p = p} (↓-app=cst-in q) == q
↓-app=cst-β {p = idp} q = idp
↓-app=cst-η : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == v [ (λ x → f x == b) ↓ p ])
→ ↓-app=cst-in (↓-app=cst-out q) == q
↓-app=cst-η {p = idp} q = idp
↓-app=cst-econv : {p : x == y} {u : f x == b} {v : f y == b}
→ (u == (ap f p ∙ v)) ≃ (u == v [ (λ x → f x == b) ↓ p ])
↓-app=cst-econv {p = p} = equiv ↓-app=cst-in ↓-app=cst-out
(↓-app=cst-η {p = p}) (↓-app=cst-β {p = p})
↓-cst=app-in : {p : x == y} {u : b == f x} {v : b == f y}
→ (u ∙' ap f p) == v
→ (u == v [ (λ x → b == f x) ↓ p ])
↓-cst=app-in {p = idp} q = q
↓-cst=app-out : {p : x == y} {u : b == f x} {v : b == f y}
→ (u == v [ (λ x → b == f x) ↓ p ])
→ (u ∙' ap f p) == v
↓-cst=app-out {p = idp} r = r
↓-cst=app-econv : {p : x == y} {u : b == f x} {v : b == f y}
→ ((u ∙' ap f p) == v) ≃ (u == v [ (λ x → b == f x) ↓ p ])
↓-cst=app-econv {p = idp} = equiv ↓-cst=app-in ↓-cst=app-out
(λ _ → idp) (λ _ → idp)
{- alternative versions -}
module _ {i j} {A : Type i} {B : Type j}
{f : A → B} {x y : A} {b : B} where
↓-app=cst-in' : {p : x == y} {u : f x == b} {v : f y == b}
→ u == (ap f p ∙' v)
→ (u == v [ (λ x → f x == b) ↓ p ])
↓-app=cst-in' {p = idp} {v = idp} q = q
↓-app=cst-out' : {p : x == y} {u : f x == b} {v : f y == b}
→ (u == v [ (λ x → f x == b) ↓ p ])
→ u == (ap f p ∙' v)
↓-app=cst-out' {p = idp} {v = idp} r = r
↓-app=cst-β' : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == (ap f p ∙' v))
→ ↓-app=cst-out' {p = p} {v = v} (↓-app=cst-in' q) == q
↓-app=cst-β' {p = idp} {v = idp} q = idp
↓-app=cst-η' : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == v [ (λ x → f x == b) ↓ p ])
→ ↓-app=cst-in' (↓-app=cst-out' q) == q
↓-app=cst-η' {p = idp} {v = idp} q = idp
↓-cst=app-in' : {p : x == y} {u : b == f x} {v : b == f y}
→ (u ∙ ap f p) == v
→ (u == v [ (λ x → b == f x) ↓ p ])
↓-cst=app-in' {p = idp} {u = idp} q = q
↓-cst=app-out' : {p : x == y} {u : b == f x} {v : b == f y}
→ (u == v [ (λ x → b == f x) ↓ p ])
→ (u ∙ ap f p) == v
↓-cst=app-out' {p = idp} {u = idp} r = r
module _ {i} {A : Type i} where
↓-app=idf-in : {f : A → A} {x y : A} {p : x == y}
{u : f x == x} {v : f y == y}
→ u ∙' p == ap f p ∙ v
→ u == v [ (λ z → f z == z) ↓ p ]
↓-app=idf-in {p = idp} q = q
↓-app=idf-out : {f : A → A} {x y : A} {p : x == y}
{u : f x == x} {v : f y == y}
→ u == v [ (λ z → f z == z) ↓ p ]
→ u ∙' p == ap f p ∙ v
↓-app=idf-out {p = idp} q = q
↓-cst=idf-in : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y}
→ (u ∙' p) == v
→ (u == v [ (λ x → a == x) ↓ p ])
↓-cst=idf-in {p = idp} q = q
↓-cst=idf-in' : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y}
→ (u ∙ p) == v
→ (u == v [ (λ x → a == x) ↓ p ])
↓-cst=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q
↓-idf=cst-in : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a}
→ u == p ∙ v
→ (u == v [ (λ x → x == a) ↓ p ])
↓-idf=cst-in {p = idp} q = q
↓-idf=cst-out : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a}
→ (u == v [ (λ x → x == a) ↓ p ])
→ u == p ∙ v
↓-idf=cst-out {p = idp} q = q
↓-idf=cst-in' : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a}
→ u == p ∙' v
→ (u == v [ (λ x → x == a) ↓ p ])
↓-idf=cst-in' {p = idp} q = q ∙ ∙'-unit-l _
↓-idf=idf-in' : {x y : A} {p : x == y} {u : x == x} {v : y == y}
→ u ∙ p == p ∙' v
→ (u == v [ (λ x → x == x) ↓ p ])
↓-idf=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ ∙'-unit-l _
↓-idf=idf-out' : {x y : A} {p : x == y} {u : x == x} {v : y == y}
→ (u == v [ (λ x → x == x) ↓ p ])
→ u ∙ p == p ∙' v
↓-idf=idf-out' {p = idp} q = ∙-unit-r _ ∙ q ∙ ! (∙'-unit-l _)
{- Nondependent identity type -}
module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where
abstract
↓-='-in : ∀ {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u ∙' ap g p) == (ap f p ∙ v)
→ (u == v [ (λ x → f x == g x) ↓ p ])
↓-='-in {p = idp} q = q
↓-='-out : ∀ {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u == v [ (λ x → f x == g x) ↓ p ])
→ (u ∙' ap g p) == (ap f p ∙ v)
↓-='-out {p = idp} q = q
↓-='-in' : ∀ {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u ∙ ap g p) == (ap f p ∙' v)
→ (u == v [ (λ x → f x == g x) ↓ p ])
↓-='-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ (∙'-unit-l _)
↓-='-out' : ∀ {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u == v [ (λ x → f x == g x) ↓ p ])
→ (u ∙ ap g p) == (ap f p ∙' v)
↓-='-out' {p = idp} q = (∙-unit-r _) ∙ q ∙ ! (∙'-unit-l _)
↓-='-in-=ₛ : ∀ {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ u ◃∙ ap g p ◃∎ =ₛ ap f p ◃∙ v ◃∎
→ (u == v [ (λ x → f x == g x) ↓ p ])
↓-='-in-=ₛ {p = idp} {u} (=ₛ-in q) = ! (∙-unit-r u) ∙ q
↓-='-out-=ₛ : ∀ {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u == v [ (λ x → f x == g x) ↓ p ])
→ u ◃∙ ap g p ◃∎ =ₛ ap f p ◃∙ v ◃∎
↓-='-out-=ₛ {p = idp} {u} {v} q =
u ◃∙ idp ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
u ◃∎
=ₛ₁⟨ q ⟩
v ◃∎
=ₛ⟨ 0 & 0 & contract ⟩
idp ◃∙ v ◃∎ ∎ₛ
{- Identity type where the type is dependent -}
module _ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} where
abstract
private
◃idp' = ◃idp {B = B}
idp▹' = idp▹ {B = B}
↓-=-in : {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ u ◃ apd f p == apd g p ▹ v
→ (u == v [ (λ x → g x == f x) ↓ p ])
↓-=-in {p = idp} {u} {v} q = ! (◃idp' u) ∙ q ∙ idp▹' v
↓-=-out : {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (u == v [ (λ x → g x == f x) ↓ p ])
→ u ◃ apd f p == apd g p ▹ v
↓-=-out {p = idp} {u} {v} q = (◃idp' u) ∙ q ∙ ! (idp▹' v)
↓-=-in-β : {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (q : u == v [ (λ x → g x == f x) ↓ p ])
→ ↓-=-in (↓-=-out q) == q
↓-=-in-β {p = idp} {u} {v} q =
! (◃idp' u) ∙ (◃idp' u ∙ q ∙ ! (idp▹' v)) ∙ idp▹' v
=⟨ ap (! (◃idp' u) ∙_) (∙-assoc (◃idp' u) (q ∙ ! (idp▹' v)) (idp▹' v)) ⟩
! (◃idp' u) ∙ ◃idp' u ∙ (q ∙ ! (idp▹' v)) ∙ idp▹' v
=⟨ ap (λ w → ! (◃idp' u) ∙ ◃idp' u ∙ w) (∙-assoc q (! (idp▹' v)) (idp▹' v)) ⟩
! (◃idp' u) ∙ ◃idp' u ∙ (q ∙ ! (idp▹' v) ∙ idp▹' v)
=⟨ ap (λ w → ! (◃idp' u) ∙ ◃idp' u ∙ (q ∙ w)) (!-inv-l (idp▹' v)) ⟩
! (◃idp' u) ∙ ◃idp' u ∙ q ∙ idp
=⟨ ap (λ w → ! (◃idp' u) ∙ ◃idp' u ∙ w) (∙-unit-r q) ⟩
! (◃idp' u) ∙ ◃idp' u ∙ q
=⟨ ! (∙-assoc (! (◃idp' u)) (◃idp' u) q) ⟩
(! (◃idp' u) ∙ ◃idp' u) ∙ q
=⟨ ap (_∙ q) (!-inv-l (◃idp' u)) ⟩
q =∎
↓-=-out-η : {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (q : u ◃ apd f p == apd g p ▹ v)
→ q == ↓-=-out (↓-=-in q)
↓-=-out-η {p = idp} {u} {v} q = ! $
◃idp' u ∙ (! (◃idp' u) ∙ q ∙ idp▹' v) ∙ ! (idp▹' v)
=⟨ ap (λ w → ◃idp' u ∙ w) (∙-assoc (! (◃idp' u)) (q ∙ idp▹' v) (! (idp▹' v))) ⟩
◃idp' u ∙ ! (◃idp' u) ∙ (q ∙ idp▹' v) ∙ ! (idp▹' v)
=⟨ ap (λ w → ◃idp' u ∙ ! (◃idp' u) ∙ w) (∙-assoc q (idp▹' v) (! (idp▹' v))) ⟩
◃idp' u ∙ ! (◃idp' u) ∙ q ∙ idp▹' v ∙ ! (idp▹' v)
=⟨ ap (λ w → ◃idp' u ∙ ! (◃idp' u) ∙ q ∙ w) (!-inv-r (idp▹' v)) ⟩
◃idp' u ∙ ! (◃idp' u) ∙ q ∙ idp
=⟨ ap (λ w → ◃idp' u ∙ ! (◃idp' u) ∙ w) (∙-unit-r q) ⟩
◃idp' u ∙ ! (◃idp' u) ∙ q
=⟨ ! (∙-assoc (◃idp' u) (! (◃idp' u)) q) ⟩
(◃idp' u ∙ ! (◃idp' u)) ∙ q
=⟨ ap (_∙ q) (!-inv-r (◃idp' u)) ⟩
q =∎
↓-=-in-is-equiv : {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ is-equiv (↓-=-in {p = p} {u = u} {v = v})
↓-=-in-is-equiv = is-eq _ ↓-=-out ↓-=-in-β λ q → ! (↓-=-out-η q)
↓-=-equiv : {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (u ◃ apd f p == apd g p ▹ v) ≃ (u == v [ (λ x → g x == f x) ↓ p ])
↓-=-equiv = ↓-=-in , ↓-=-in-is-equiv
-- Dependent path in a type of the form [λ x → g (f x) == x]
module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where
↓-∘=idf-in' : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y}
→ ((ap g (ap f p) ∙' v) == (u ∙ p))
→ (u == v [ (λ x → g (f x) == x) ↓ p ])
↓-∘=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ (! q) ∙ (∙'-unit-l _)
-- WIP, derive it from more primitive principles
-- ↓-∘=id-in f g {p = p} {u} {v} q =
-- ↓-=-in (u ◃ apd (λ x → g (f x)) p =⟨ apd-∘ f g p |in-ctx (λ t → u ◃ t) ⟩
-- u ◃ ↓-apd-out _ f p (apdd g p (apd f p)) =⟨ apdd-cst (λ _ b → g b) p (ap f p) (! (apd-nd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩
-- u ◃ ↓-apd-out _ f p (apd (λ t → g (π₂ t)) (pair= p (apd f p))) =⟨ apd-∘ π₂ g (pair= p (apd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩
-- u ◃ ↓-apd-out _ f p (↓-apd-out _ π₂ (pair= p (apd f p)) (apdd g (pair= p (apd f p)) (apd π₂ (pair= p (apd f p))))) =⟨ {!!} ⟩
-- apd (λ x → x) p ▹ v ∎)
-- module _ {i j} {A : Type i} {B : Type j} {x y z : A → B} where
-- lhs :
-- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'}
-- {r : y a == z a} {r' : y a' == z a'}
-- (α : q == q' [ (λ a → x a == y a) ↓ p ])
-- (β : r ∙ ap z p == ap y p ∙' r')
-- → (q ∙' r) ∙ ap z p == ap x p ∙' q' ∙' r'
-- lhs =
-- (q ∙' r) ∙ ap z p =⟨ ? ⟩ -- assoc
-- q ∙' (r ∙ ap z p) =⟨ ? ⟩ -- β
-- q ∙' (ap y p ∙' r') =⟨ ? ⟩ -- assoc
-- (q ∙' ap y p) ∙' r' =⟨ ? ⟩ -- ∙ = ∙'
-- (q ∙ ap y p) ∙' r' =⟨ ? ⟩ -- α
-- (ap x p ∙' q') ∙' r' =⟨ ? ⟩ -- assoc
-- ap x p ∙' q' ∙' r' ∎
-- thing :
-- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'}
-- {r : y a == z a} {r' : y a' == z a'}
-- (α : q == q' [ (λ a → x a == y a) ↓ p ])
-- (β : r ∙ ap z p == ap y p ∙' r')
-- → (_∙'2ᵈ_ {r = r} {r' = r'} α (↓-='-in' β) == ↓-='-in' {!!})
-- thing = {!!}
| 38.011834
| 147
| 0.322696
|
7c18ea75d2def7a16365ddf4b875c080a1dee45f
| 184
|
agda
|
Agda
|
test/Succeed/Issue1681.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1681.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1681.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
id : Set → Set
id A = A
F : Set → Set → Set
F _*_ = G
where
G : Set → Set
G _*_ = id _*_
G : Set → Set → Set
G _*_ = λ _*_ → id _*_
H : Set → Set → Set
H = λ _*_ _*_ → id _*_
| 12.266667
| 22
| 0.461957
|
375d93b72f50896e3fa0c28f3b54a6a6dddea18f
| 1,100
|
agda
|
Agda
|
Data/Binary/Relations.agda
|
oisdk/agda-binary
|
92af4d620febd47a9791d466d747278dc4a417aa
|
[
"MIT"
] | 1
|
2019-03-21T21:30:10.000Z
|
2019-03-21T21:30:10.000Z
|
Data/Binary/Relations.agda
|
oisdk/agda-binary
|
92af4d620febd47a9791d466d747278dc4a417aa
|
[
"MIT"
] | null | null | null |
Data/Binary/Relations.agda
|
oisdk/agda-binary
|
92af4d620febd47a9791d466d747278dc4a417aa
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Relations where
open import Data.Binary.Relations.Raw
open import Data.Binary.Definitions
open import Data.Binary.Operations.Addition
open import Relation.Binary
open import Relation.Nullary
import Data.Empty.Irrelevant as Irrel
infix 4 _≤_ _<_
record _≤_ (x y : 𝔹) : Set where
constructor ≤!
field
.proof : ⟅ I ⟆ x ≺ y
record _<_ (x y : 𝔹) : Set where
constructor <!
field
.proof : ⟅ O ⟆ x ≺ y
_≤?_ : Decidable _≤_
x ≤? y with I ! x ≺? y
(x ≤? y) | yes x₁ = yes (≤! x₁)
(x ≤? y) | no x₁ = no λ p → Irrel.⊥-elim (x₁ (_≤_.proof p))
_<?_ : Decidable _<_
x <? y with O ! x ≺? y
(x <? y) | yes x₁ = yes (<! x₁)
(x <? y) | no x₁ = no λ p → Irrel.⊥-elim (x₁ (_<_.proof p))
<⇒≤ : ∀ {x y} → x < y → x ≤ y
<⇒≤ {x} {y} x<y = ≤! (weaken x y (_<_.proof x<y))
≤-trans : Transitive _≤_
≤-trans {i} {j} {k} i≤j j≤k = ≤! (≺-trans I I i j k (_≤_.proof i≤j) (_≤_.proof j≤k))
<-trans : Transitive _<_
<-trans {i} {j} {k} i<j j<k = <! (≺-trans O O i j k (_<_.proof i<j) (_<_.proof j<k))
n≤m+n : ∀ x y → x ≤ y + x
n≤m+n x y = ≤! (≺-add y x)
| 25
| 84
| 0.556364
|
fd7ad42679a3e4ad1d71fc37ca0c26d8b7791cf6
| 2,761
|
agda
|
Agda
|
theorems/cw/cohomology/reconstructed/cochain/ZerothGroup.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/cw/cohomology/reconstructed/cochain/ZerothGroup.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/cw/cohomology/reconstructed/cochain/ZerothGroup.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
open import cohomology.ChainComplex
open import cohomology.Theory
open import groups.KernelImage
open import cw.CW
module cw.cohomology.reconstructed.cochain.ZerothGroup {i : ULevel} (OT : OrdinaryTheory i) where
open OrdinaryTheory OT
import cw.cohomology.reconstructed.TipCoboundary OT as TC
import cw.cohomology.reconstructed.TipAndAugment OT as TAA
open import cw.cohomology.reconstructed.Descending OT
open import cw.cohomology.reconstructed.cochain.Complex OT
import cw.cohomology.reconstructed.ZerothGroup OT as ZCG
import cw.cohomology.reconstructed.ZerothGroupOnDiag OT as ZCGD
private
≤-dec-has-all-paths : {m n : ℕ} → has-all-paths (Dec (m ≤ n))
≤-dec-has-all-paths = prop-has-all-paths
private
abstract
zeroth-cohomology-group-descend : ∀ {n} (⊙skel : ⊙Skeleton {i} (2 + n))
→ cohomology-group (cochain-complex ⊙skel) 0
== cohomology-group (cochain-complex (⊙cw-init ⊙skel)) 0
zeroth-cohomology-group-descend {n = O} ⊙skel
= ap
(λ δ → Ker/Im δ
(TAA.cw-coε (⊙cw-take (lteSR lteS) ⊙skel))
(TAA.C2×CX₀-is-abelian (⊙cw-take (lteSR lteS) ⊙skel) 0))
(coboundary-first-template-descend-from-two ⊙skel)
zeroth-cohomology-group-descend {n = S n} ⊙skel
= ap (λ δ → Ker/Im δ
(TAA.cw-coε (⊙cw-take (inr (O<S (2 + n))) ⊙skel))
(TAA.C2×CX₀-is-abelian (⊙cw-take (inr (O<S (2 + n))) ⊙skel) 0))
(coboundary-first-template-descend-from-far ⊙skel (O<S (1 + n)) (<-+-l 1 (O<S n)))
zeroth-cohomology-group-β : ∀ (⊙skel : ⊙Skeleton {i} 1)
→ cohomology-group (cochain-complex ⊙skel) 0
== Ker/Im
(TC.cw-co∂-head ⊙skel)
(TAA.cw-coε (⊙cw-init ⊙skel))
(TAA.C2×CX₀-is-abelian (⊙cw-init ⊙skel) 0)
zeroth-cohomology-group-β ⊙skel
= ap
(λ δ → Ker/Im δ
(TAA.cw-coε (⊙cw-init ⊙skel))
(TAA.C2×CX₀-is-abelian (⊙cw-init ⊙skel) 0))
(coboundary-first-template-β ⊙skel)
abstract
zeroth-cohomology-group : ∀ {n} (⊙skel : ⊙Skeleton {i} n)
→ ⊙has-cells-with-choice 0 ⊙skel i
→ C 0 ⊙⟦ ⊙skel ⟧ ≃ᴳ cohomology-group (cochain-complex ⊙skel) 0
zeroth-cohomology-group {n = 0} ⊙skel ac = ZCGD.C-cw-iso-ker/im ⊙skel ac
zeroth-cohomology-group {n = 1} ⊙skel ac =
coe!ᴳ-iso (zeroth-cohomology-group-β ⊙skel)
∘eᴳ ZCG.C-cw-iso-ker/im ⊙skel ac
zeroth-cohomology-group {n = S (S n)} ⊙skel ac =
coe!ᴳ-iso (zeroth-cohomology-group-descend ⊙skel)
∘eᴳ zeroth-cohomology-group (⊙cw-init ⊙skel) (⊙init-has-cells-with-choice ⊙skel ac)
∘eᴳ C-cw-descend-at-lower ⊙skel (O<S n) ac
| 42.476923
| 97
| 0.612821
|
211f33ce289751476104a61c87058cb0e9250017
| 910
|
agda
|
Agda
|
test/Fail/Issue3823.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue3823.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue3823.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2019-05-30, issue #3823
-- Named where module M should be in scope in rhs.
-- This enables to use it in expressions like record{M}.
-- Jesper, 2019-12-19, issue #4288
-- Moved to test/Fail because the fix caused a loop in the scope
-- checker.
open import Agda.Builtin.Equality
record R : Set₂ where
field
A : Set₁
r : R
r = record {M}
module M where
A = Set
-- ERROR WAS:
-- No module M in scope
-- when scope checking record { M }
test : r ≡ record {A = Set}
test = refl
-- Should succeed.
-- Should also work with module parameters.
s : Set₁ → R
s B = record {L}
module L where
A = B
-- With rewrite:
postulate
B : Set
a b : B
a≡b : a ≡ b
P : B → Set
record W : Set where
field
wrap : P b
w : P a → W
w p rewrite a≡b = record {N}
module N where
wrap = p
-- Should also succeed in the presence of `rewrite`.
module N' = N -- See issue #3824.
| 16.25
| 64
| 0.626374
|
191befb735309b0da163eeddb581260db0f6a5bc
| 4,220
|
agda
|
Agda
|
src/Fragment/Equational/FreeExtension/Properties.agda
|
yallop/agda-fragment
|
f2a6b1cf4bc95214bd075a155012f84c593b9496
|
[
"MIT"
] | 18
|
2021-06-15T15:45:39.000Z
|
2022-01-17T17:26:09.000Z
|
src/Fragment/Equational/FreeExtension/Properties.agda
|
yallop/agda-fragment
|
f2a6b1cf4bc95214bd075a155012f84c593b9496
|
[
"MIT"
] | 1
|
2021-06-16T09:44:31.000Z
|
2021-06-16T10:24:15.000Z
|
src/Fragment/Equational/FreeExtension/Properties.agda
|
yallop/agda-fragment
|
f2a6b1cf4bc95214bd075a155012f84c593b9496
|
[
"MIT"
] | 3
|
2021-06-15T15:34:50.000Z
|
2021-06-16T08:04:31.000Z
|
{-# OPTIONS --without-K --exact-split --safe #-}
open import Fragment.Equational.Theory
module Fragment.Equational.FreeExtension.Properties (Θ : Theory) where
open import Fragment.Algebra.Algebra (Σ Θ) using (Algebra)
open import Fragment.Algebra.Homomorphism (Σ Θ)
open import Fragment.Algebra.Free (Σ Θ)
open import Fragment.Equational.Model Θ
open import Fragment.Equational.Coproduct Θ
open import Fragment.Equational.FreeExtension.Base Θ
open import Fragment.Equational.FreeExtension.Synthetic Θ using (SynFrex)
open import Level using (Level)
open import Data.Nat using (ℕ)
open import Data.Vec using (Vec)
open import Relation.Binary using (Setoid)
import Relation.Binary.Reasoning.Setoid as Reasoning
private
variable
a ℓ₁ : Level
module _
(X : FreeExtension)
(Y : FreeExtension)
(A : Model {a} {ℓ₁})
(n : ℕ)
where
open FreeExtension X renaming (_[_] to _[_]₁; _[_]-isFrex to _[_]₁-isFrex)
open FreeExtension Y renaming (_[_] to _[_]₂; _[_]-isFrex to _[_]₂-isFrex)
open IsCoproduct (A [ n ]₁-isFrex)
renaming (inl to inl₁; inr to inr₁; _[_,_] to _[_,_]₁; commute₁ to commute₁₁; commute₂ to commute₂₁)
open IsCoproduct (A [ n ]₂-isFrex)
renaming (inl to inl₂; inr to inr₂; _[_,_] to _[_,_]₂; commute₁ to commute₁₂; commute₂ to commute₂₂)
using ()
to : ∥ A [ n ]₂ ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ
to = (A [ n ]₁) [ inl₁ , inr₁ ]₂
from : ∥ A [ n ]₁ ∥ₐ ⟿ ∥ A [ n ]₂ ∥ₐ
from = (A [ n ]₂) [ inl₂ , inr₂ ]₁
inv : to ⊙ from ≗ id
inv = begin
to ⊙ from
≈⟨ ≗-sym {f = (A [ n ]₁) [ inl₁ , inr₁ ]₁} {g = to ⊙ from} (universal {h = to ⊙ from} c₁ c₂) ⟩
(A [ n ]₁) [ inl₁ , inr₁ ]₁
≈⟨ universal {h = id} (id-unitˡ {f = inl₁}) (id-unitˡ {f = inr₁}) ⟩
id
∎
where c₁ : (to ⊙ from) ⊙ inl₁ ≗ inl₁
c₁ = begin
(to ⊙ from) ⊙ inl₁
≈⟨ ⊙-assoc to from inl₁ ⟩
to ⊙ (from ⊙ inl₁)
≈⟨ ⊙-congˡ to (from ⊙ inl₁) inl₂ (commute₁₁ {f = inl₂} {g = inr₂}) ⟩
to ⊙ inl₂
≈⟨ commute₁₂ {X = A [ n ]₁} {f = inl₁} {g = inr₁} ⟩
inl₁
∎
where open Reasoning (∥ A ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ /≗)
c₂ : (to ⊙ from) ⊙ inr₁ ≗ inr₁
c₂ = begin
(to ⊙ from) ⊙ inr₁
≈⟨ ⊙-assoc to from inr₁ ⟩
to ⊙ (from ⊙ inr₁)
≈⟨ ⊙-congˡ to (from ⊙ inr₁) inr₂ (commute₂₁ {f = inl₂} {g = inr₂}) ⟩
to ⊙ inr₂
≈⟨ commute₂₂ {X = A [ n ]₁} {f = inl₁} {g = inr₁} ⟩
inr₁
∎
where open Reasoning (∥ J n ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ /≗)
open Reasoning (∥ A [ n ]₁ ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ /≗)
module _
(X : FreeExtension)
(Y : FreeExtension)
(A : Model {a} {ℓ₁})
(n : ℕ)
where
open FreeExtension X renaming (_[_] to _[_]₁)
open FreeExtension Y renaming (_[_] to _[_]₂)
iso : ∥ A [ n ]₁ ∥ₐ ≃ ∥ A [ n ]₂ ∥ₐ
iso = record { _⃗ = to Y X A n
; _⃖ = from Y X A n
; invˡ = inv Y X A n
; invʳ = inv X Y A n
}
module _
(X : FreeExtension)
(A : Model {a} {ℓ₁})
{n : ℕ}
where
open FreeExtension X
open FreeExtension SynFrex renaming (_[_] to _[_]ₛ; _[_]-isFrex to _[_]ₛ-isFrex)
open IsCoproduct (A [ n ]-isFrex)
open IsCoproduct (A [ n ]ₛ-isFrex) renaming (_[_,_] to _[_,_]ₛ) using ()
open Setoid ∥ A [ n ] ∥/≈ renaming (_≈_ to _≋_)
open Setoid ∥ A ∥/≈ using (_≈_)
norm = to X SynFrex A n
syn = from X SynFrex A n
reduce : (θ : Env ∥ A ∥ₐ n) → ∥ A [ n ]ₛ ∥ₐ ⟿ ∥ A ∥ₐ
reduce θ = A [ id , interp A θ ]ₛ
module _ (Γ : Vec ∥ A ∥ n) where
private
θ : Env ∥ A ∥ₐ n
θ = env {A = ∥ A ∥ₐ} Γ
frexify : ∀ {lhs rhs : Term (BT ∥ A ∥ n)}
→ ∣ norm ∣ lhs ≋ ∣ norm ∣ rhs
→ ∣ reduce θ ∣ lhs ≈ ∣ reduce θ ∣ rhs
frexify {lhs = lhs} {rhs = rhs} p = begin
∣ reduce θ ∣ lhs
≈⟨ Setoid.sym ∥ A ∥/≈ (∣ reduce θ ∣-cong (inv SynFrex X A n {x = lhs})) ⟩
∣ reduce θ ∣ (∣ syn ∣ (∣ norm ∣ lhs))
≈⟨ ∣ reduce θ ∣-cong (∣ syn ∣-cong p) ⟩
∣ reduce θ ∣ (∣ syn ∣ (∣ norm ∣ rhs))
≈⟨ ∣ reduce θ ∣-cong (inv SynFrex X A n {x = rhs}) ⟩
∣ reduce θ ∣ rhs
∎
where open Reasoning ∥ A ∥/≈
| 30.359712
| 104
| 0.522038
|
d1f6e738163d85c6448a0e6d1f152b828bfe5c75
| 3,762
|
agda
|
Agda
|
Cubical/HITs/ListedFiniteSet/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/HITs/ListedFiniteSet/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/HITs/ListedFiniteSet/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.ListedFiniteSet.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Sum as ⊎ using (_⊎_; inl; inr)
open import Cubical.Functions.Logic
private
variable
ℓ : Level
A B : Type ℓ
infixr 20 _∷_
-- infix 30 _∈_
infixr 5 _++_
data LFSet (A : Type ℓ) : Type ℓ where
[] : LFSet A
_∷_ : (x : A) → (xs : LFSet A) → LFSet A
dup : ∀ x xs → x ∷ x ∷ xs ≡ x ∷ xs
comm : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs
trunc : isSet (LFSet A)
-- Membership.
--
-- Doing some proofs with equational reasoning adds an extra "_∙ refl"
-- at the end.
-- We might want to avoid it, or come up with a more clever equational reasoning.
_∈_ : {A : Type ℓ} → A → LFSet A → hProp ℓ
z ∈ [] = Lift ⊥.⊥ , isOfHLevelLift 1 isProp⊥
z ∈ (y ∷ xs) = (z ≡ₚ y) ⊔ (z ∈ xs)
z ∈ dup x xs i = proof i
where
-- proof : z ∈ (x ∷ x ∷ xs) ≡ z ∈ (x ∷ xs)
proof = z ≡ₚ x ⊔ (z ≡ₚ x ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ x) (z ∈ xs) ⟩
(z ≡ₚ x ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-idem (z ≡ₚ x)) ⟩
z ≡ₚ x ⊔ z ∈ xs ∎
z ∈ comm x y xs i = proof i
where
-- proof : z ∈ (x ∷ y ∷ xs) ≡ z ∈ (y ∷ x ∷ xs)
proof = z ≡ₚ x ⊔ (z ≡ₚ y ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ y) (z ∈ xs) ⟩
(z ≡ₚ x ⊔ z ≡ₚ y) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-comm (z ≡ₚ x) (z ≡ₚ y)) ⟩
(z ≡ₚ y ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ sym (⊔-assoc (z ≡ₚ y) (z ≡ₚ x) (z ∈ xs)) ⟩
z ≡ₚ y ⊔ (z ≡ₚ x ⊔ z ∈ xs) ∎
x ∈ trunc xs ys p q i j = isSetHProp (x ∈ xs) (x ∈ ys) (cong (x ∈_) p) (cong (x ∈_) q) i j
module Elim {ℓ}
{B : LFSet A → Type ℓ}
([]* : B [])
(_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs))
(comm* : (x y : A) {xs : LFSet A} (b : B xs)
→ PathP (λ i → B (comm x y xs i)) (x ∷* (y ∷* b)) (y ∷* (x ∷* b)))
(dup* : (x : A) {xs : LFSet A} (b : B xs)
→ PathP (λ i → B (dup x xs i)) (x ∷* (x ∷* b)) (x ∷* b))
(trunc* : (xs : LFSet A) → isSet (B xs)) where
f : ∀ x → B x
f [] = []*
f (x ∷ xs) = x ∷* f xs
f (dup x xs i) = dup* x (f xs) i
f (comm x y xs i) = comm* x y (f xs) i
f (trunc x y p q i j) =
isOfHLevel→isOfHLevelDep 2 trunc*
(f x) (f y)
(λ i → f (p i)) (λ i → f (q i))
(trunc x y p q) i j
module Rec {ℓ} {B : Type ℓ}
([]* : B)
(_∷*_ : (x : A) → B → B)
(comm* : (x y : A) (xs : B) → (x ∷* (y ∷* xs)) ≡ (y ∷* (x ∷* xs)))
(dup* : (x : A) (b : B) → (x ∷* (x ∷* b)) ≡ (x ∷* b))
(trunc* : isSet B) where
f : LFSet A → B
f =
Elim.f
[]* (λ x xs → x ∷* xs)
(λ x y b → comm* x y b) (λ x b → dup* x b)
λ _ → trunc*
module PropElim {ℓ}
{B : LFSet A → Type ℓ}
([]* : B []) (_∷*_ : (x : A) {xs : LFSet A} → B xs → B (x ∷ xs))
(trunc* : (xs : LFSet A) → isProp (B xs)) where
f : ∀ x → B x
f =
Elim.f
[]* _∷*_
(λ _ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _)
(λ _ _ → isOfHLevel→isOfHLevelDep 1 trunc* _ _ _)
λ xs → isProp→isSet (trunc* xs)
_++_ : ∀ (xs ys : LFSet A) → LFSet A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
dup x xs i ++ ys = dup x (xs ++ ys) i
comm x y xs i ++ ys = comm x y (xs ++ ys) i
trunc xs zs p q i j ++ ys =
trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j
map : (A → B) → LFSet A → LFSet B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
map f (dup x xs i) = dup (f x) (map f xs) i
map f (comm x y xs i) = comm (f x) (f y) (map f xs) i
map f (trunc xs ys p q i j) =
trunc (map f xs) (map f ys) (cong (map f) p) (cong (map f) q) i j
disj-union : LFSet A → LFSet B → LFSet (A ⊎ B)
disj-union xs ys = map ⊎.inl xs ++ map ⊎.inr ys
| 32.431034
| 90
| 0.45109
|
5e3a2aa49ae0ca7bd705722c9d6214f6d34fdfb6
| 71
|
agda
|
Agda
|
test/Fail/Sections-9.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Sections-9.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-9.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
⟨_⟩_ : Bool → Bool → Bool
⟨ _ ⟩_ = λ b → b
| 14.2
| 26
| 0.591549
|
21a26aa5e2f8801a1be63515c361cc5424d68382
| 1,477
|
agda
|
Agda
|
test/succeed/CopatternTrailingImplicit.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/CopatternTrailingImplicit.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/succeed/CopatternTrailingImplicit.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --copatterns --sized-types #-}
-- {-# OPTIONS -v tc.size.solve:30 #-}
-- {-# OPTIONS -v term:40 -v term.proj:60 --show-implicit #-}
-- Andreas, 2013-10-01 Make sure trailing implicit insertion
-- works with copatterns
module CopatternTrailingImplicit where
import Common.Level
open import Common.Size
open import Common.Prelude
-- Sized streams
record Stream (A : Set) {i : Size} : Set where
coinductive
field
head : A
tail : {j : Size< i} → Stream A {j}
open Stream
-- Mapping over streams
map : {A B : Set} (f : A → B) {i : Size} → Stream A {i} → Stream B {i}
tail (map f {i} s) {j} = map f (tail s)
head (map f s) = f (head s)
-- Nats defined using map
nats : {i : Size} → Stream Nat {i}
head nats = 0
tail nats = map suc nats
-- Before this patch, Agda would insert a {_} also in the `head' clause
-- leading to a type error.
-- 2013-10-12 works now also without manual {_} insertion
-- (See TermCheck.introHiddenLambdas.)
nats' : {i : Size} → Stream Nat {i}
head nats' = 0
tail nats' = map suc nats'
-- Before this latest patch, the termination checker would complain
-- since it would not see the type of the hidden {j : Size< i}
-- which is the argument to the recursive call.
-- All this would not be an issue if Agda still eagerly introduced
-- trailing hidden arguments on the LHS, but this has other
-- drawbacks (Q: even with varying arity?): cannot have
-- hidden lambdas on rhs (used to name trailing hiddens in with-clauses).
| 28.960784
| 73
| 0.679756
|
21149a18e05d1a806bc9f49ec251495f16f1c0ab
| 1,198
|
agda
|
Agda
|
Nehemiah/Change/Derive.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 10
|
2015-03-04T06:09:20.000Z
|
2019-07-19T07:06:59.000Z
|
Nehemiah/Change/Derive.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 6
|
2015-07-01T18:09:31.000Z
|
2017-05-04T13:53:59.000Z
|
Nehemiah/Change/Derive.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 1
|
2016-02-18T12:26:44.000Z
|
2016-02-18T12:26:44.000Z
|
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Incrementalization as term-to-term transformation with the Nehemiah plugin.
------------------------------------------------------------------------
module Nehemiah.Change.Derive where
open import Nehemiah.Syntax.Type
open import Nehemiah.Syntax.Term
open import Nehemiah.Change.Type
open import Nehemiah.Change.Term
open import Data.Integer
import Parametric.Change.Derive Const ΔBase as Derive
derive-const : Derive.Structure
derive-const (intlit-const n) = intlit (+ 0)
derive-const add-const = absV 4 (λ s ds t dt → add ds dt)
derive-const minus-const = absV 2 (λ t dt → minus dt)
derive-const empty-const = empty
derive-const insert-const = absV 4 (λ s ds t dt →
insert (s ⊕₍ int ₎ ds) (t ⊕₍ bag ₎ dt) ⊝ insert s t)
derive-const union-const = absV 4 (λ s ds t dt → union ds dt)
derive-const negate-const = absV 2 (λ t dt → negate dt)
derive-const flatmap-const = absV 4 (λ s ds t dt →
flatmap (s ⊕₍ int ⇒ bag ₎ ds) (t ⊕₍ bag ₎ dt) ⊝ flatmap s t)
derive-const sum-const = absV 2 (λ t dt → sum dt)
open Derive.Structure derive-const public
| 37.4375
| 78
| 0.607679
|
21200c2fe4acbc652abec946405bc20ea444f962
| 3,900
|
agda
|
Agda
|
Definition/LogicalRelation/Properties/Escape.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Properties/Escape.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Properties/Escape.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Properties.Escape {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Weakening
open import Definition.Typed.Properties
open import Definition.LogicalRelation
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Reducible types are well-formed.
escape : ∀ {l Γ A} → Γ ⊩⟨ l ⟩ A → Γ ⊢ A
escape (Uᵣ′ l′ l< ⊢Γ) = Uⱼ ⊢Γ
escape (ℕᵣ [ ⊢A , ⊢B , D ]) = ⊢A
escape (Emptyᵣ [ ⊢A , ⊢B , D ]) = ⊢A
escape (Unitᵣ [ ⊢A , ⊢B , D ]) = ⊢A
escape (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) = ⊢A
escape (Bᵣ′ W F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) = ⊢A
escape (emb 0<1 A) = escape A
-- Reducible type equality respect the equality relation.
escapeEq : ∀ {l Γ A B} → ([A] : Γ ⊩⟨ l ⟩ A)
→ Γ ⊩⟨ l ⟩ A ≡ B / [A]
→ Γ ⊢ A ≅ B
escapeEq (Uᵣ′ l′ l< ⊢Γ) PE.refl = ≅-Urefl ⊢Γ
escapeEq (ℕᵣ [ ⊢A , ⊢B , D ]) D′ = ≅-red D D′ ℕₙ ℕₙ (≅-ℕrefl (wf ⊢A))
escapeEq (Emptyᵣ [ ⊢A , ⊢B , D ]) D′ = ≅-red D D′ Emptyₙ Emptyₙ (≅-Emptyrefl (wf ⊢A))
escapeEq (Unitᵣ [ ⊢A , ⊢B , D ]) D′ = ≅-red D D′ Unitₙ Unitₙ (≅-Unitrefl (wf ⊢A))
escapeEq (ne′ K D neK K≡K) (ne₌ M D′ neM K≡M) =
≅-red (red D) (red D′) (ne neK) (ne neM) (~-to-≅ K≡M)
escapeEq (Bᵣ′ W F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) =
≅-red (red D) D′ ⟦ W ⟧ₙ ⟦ W ⟧ₙ A≡B
escapeEq (emb 0<1 A) A≡B = escapeEq A A≡B
-- Reducible terms are well-formed.
escapeTerm : ∀ {l Γ A t} → ([A] : Γ ⊩⟨ l ⟩ A)
→ Γ ⊩⟨ l ⟩ t ∷ A / [A]
→ Γ ⊢ t ∷ A
escapeTerm (Uᵣ′ l′ l< ⊢Γ) (Uₜ A [ ⊢t , ⊢u , d ] typeA A≡A [A]) = ⊢t
escapeTerm (ℕᵣ D) (ℕₜ n [ ⊢t , ⊢u , d ] t≡t prop) =
conv ⊢t (sym (subset* (red D)))
escapeTerm (Emptyᵣ D) (Emptyₜ e [ ⊢t , ⊢u , d ] t≡t prop) =
conv ⊢t (sym (subset* (red D)))
escapeTerm (Unitᵣ D) (Unitₜ e [ ⊢t , ⊢u , d ] prop) =
conv ⊢t (sym (subset* (red D)))
escapeTerm (ne′ K D neK K≡K) (neₜ k [ ⊢t , ⊢u , d ] nf) =
conv ⊢t (sym (subset* (red D)))
escapeTerm (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(Πₜ f [ ⊢t , ⊢u , d ] funcF f≡f [f] [f]₁) =
conv ⊢t (sym (subset* (red D)))
escapeTerm (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(Σₜ p [ ⊢t , ⊢u , d ] pProd p≅p [fst] [snd]) =
conv ⊢t (sym (subset* (red D)))
escapeTerm (emb 0<1 A) t = escapeTerm A t
-- Reducible term equality respect the equality relation.
escapeTermEq : ∀ {l Γ A t u} → ([A] : Γ ⊩⟨ l ⟩ A)
→ Γ ⊩⟨ l ⟩ t ≡ u ∷ A / [A]
→ Γ ⊢ t ≅ u ∷ A
escapeTermEq (Uᵣ′ l′ l< ⊢Γ) (Uₜ₌ A B d d′ typeA typeB A≡B [A] [B] [A≡B]) =
≅ₜ-red (id (Uⱼ ⊢Γ)) (redₜ d) (redₜ d′) Uₙ (typeWhnf typeA) (typeWhnf typeB) A≡B
escapeTermEq (ℕᵣ D) (ℕₜ₌ k k′ d d′ k≡k′ prop) =
let natK , natK′ = split prop
in ≅ₜ-red (red D) (redₜ d) (redₜ d′) ℕₙ
(naturalWhnf natK) (naturalWhnf natK′) k≡k′
escapeTermEq (Emptyᵣ D) (Emptyₜ₌ k k′ d d′ k≡k′ prop) =
let natK , natK′ = esplit prop
in ≅ₜ-red (red D) (redₜ d) (redₜ d′) Emptyₙ
(ne natK) (ne natK′) k≡k′
escapeTermEq {l} {Γ} {A} {t} {u} (Unitᵣ D) (Unitₜ₌ ⊢t ⊢u) =
let t≅u = ≅ₜ-η-unit ⊢t ⊢u
A≡Unit = subset* (red D)
in ≅-conv t≅u (sym A≡Unit)
escapeTermEq (ne′ K D neK K≡K)
(neₜ₌ k m d d′ (neNfₜ₌ neT neU t≡u)) =
≅ₜ-red (red D) (redₜ d) (redₜ d′) (ne neK) (ne neT) (ne neU)
(~-to-≅ₜ t≡u)
escapeTermEq (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) =
≅ₜ-red (red D) (redₜ d) (redₜ d′) Πₙ (functionWhnf funcF) (functionWhnf funcG) f≡g
escapeTermEq (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)
(Σₜ₌ p r d d′ pProd rProd p≅r [t] [u] [fstp] [fstr] [fst≡] [snd≡]) =
≅ₜ-red (red D) (redₜ d) (redₜ d′) Σₙ (productWhnf pProd) (productWhnf rProd) p≅r
escapeTermEq (emb 0<1 A) t≡u = escapeTermEq A t≡u
| 41.935484
| 85
| 0.52641
|
1bccc0f6ce00a1e78170086228874228b0e4e897
| 2,002
|
agda
|
Agda
|
agda-stdlib/src/Data/Container/Indexed/FreeMonad.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Container/Indexed/FreeMonad.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Container/Indexed/FreeMonad.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- The free monad construction on indexed containers
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --guardedness #-}
module Data.Container.Indexed.FreeMonad where
open import Level
open import Function hiding (const)
open import Category.Monad.Predicate
open import Data.Container.Indexed
open import Data.Container.Indexed.Combinator hiding (id; _∘_)
open import Data.Empty
open import Data.Sum.Base using (inj₁; inj₂)
open import Data.Product
open import Data.W.Indexed
open import Relation.Unary
open import Relation.Unary.PredicateTransformer
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
infixl 9 _⋆C_
infix 9 _⋆_
_⋆C_ : ∀ {i o c r} {I : Set i} {O : Set o} →
Container I O c r → Pred O c → Container I O _ _
C ⋆C X = const X ⊎ C
_⋆_ : ∀ {ℓ} {O : Set ℓ} → Container O O ℓ ℓ → Pt O ℓ
C ⋆ X = μ (C ⋆C X)
pattern returnP x = (inj₁ x , _)
pattern doP c k = (inj₂ c , k)
inn : ∀ {ℓ} {O : Set ℓ} {C : Container O O ℓ ℓ} {X} →
⟦ C ⟧ (C ⋆ X) ⊆ C ⋆ X
inn (c , k) = sup (doP c k)
rawPMonad : ∀ {ℓ} {O : Set ℓ} {C : Container O O ℓ ℓ} →
RawPMonad {ℓ = ℓ} (_⋆_ C)
rawPMonad {C = C} = record
{ return? = return
; _=<?_ = _=<<_
}
where
return : ∀ {X} → X ⊆ C ⋆ X
return x = sup (inj₁ x , ⊥-elim ∘ lower)
_=<<_ : ∀ {X Y} → X ⊆ C ⋆ Y → C ⋆ X ⊆ C ⋆ Y
f =<< sup (returnP x) = f x
f =<< sup (doP c k) = inn (c , λ r → f =<< k r)
leaf : ∀ {ℓ} {O : Set ℓ} {C : Container O O ℓ ℓ} {X : Pred O ℓ} →
⟦ C ⟧ X ⊆ C ⋆ X
leaf (c , k) = inn (c , return? ∘ k)
where
open RawPMonad rawPMonad
generic : ∀ {ℓ} {O : Set ℓ} {C : Container O O ℓ ℓ} {o}
(c : Command C o) →
o ∈ C ⋆ (⋃[ r ∶ Response C c ] { next C c r })
generic c = inn (c , λ r → return? (r , refl))
where
open RawPMonad rawPMonad
| 29.014493
| 72
| 0.516484
|
5e02e4238913cd4ef871177b0e9af814e77b0ada
| 377
|
agda
|
Agda
|
test/Fail/Issue2854.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue2854.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue2854.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2017-11-19, issue #2854
-- Agda should not complain about "possibly empty type of sizes"
-- if the SIZELT builtin is not bound.
data Tree : Set₁ where
node : {A : Set} (f : A → Tree) → Tree
const : Tree → Tree
const t = node λ x → t
-- WAS:
-- Failed to solve the following constraints:
-- Is not empty type of sizes: _A_6 t
-- Expected:
-- Unsolved meta.
| 20.944444
| 64
| 0.657825
|
3548fab9eb62a332e63c3e4c294520af2e6251e0
| 1,714
|
agda
|
Agda
|
agda-stdlib/src/Data/Vec/Recursive/Categorical.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/Categorical.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Vec/Recursive/Categorical.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- A categorical view of vectors defined by recursion
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Vec.Recursive.Categorical where
open import Agda.Builtin.Nat
open import Data.Product hiding (map)
open import Data.Vec.Recursive
open import Function
open import Category.Functor
open import Category.Applicative
open import Category.Monad
------------------------------------------------------------------------
-- Functor and applicative
functor : ∀ {ℓ} n → RawFunctor {ℓ} (_^ n)
functor n = record { _<$>_ = λ f → map f n }
applicative : ∀ {ℓ} n → RawApplicative {ℓ} (_^ n)
applicative n = record
{ pure = replicate n
; _⊛_ = ap n
}
------------------------------------------------------------------------
-- Get access to other monadic functions
module _ {f F} (App : RawApplicative {f} F) where
open RawApplicative App
sequenceA : ∀ {n A} → F A ^ n → F (A ^ n)
sequenceA {0} _ = pure _
sequenceA {1} fa = fa
sequenceA {2+ n} (fa , fas) = _,_ <$> fa ⊛ sequenceA fas
mapA : ∀ {n a} {A : Set a} {B} → (A → F B) → A ^ n → F (B ^ n)
mapA f = sequenceA ∘ map f _
forA : ∀ {n a} {A : Set a} {B} → A ^ n → (A → F B) → F (B ^ n)
forA = flip mapA
module _ {m M} (Mon : RawMonad {m} M) where
private App = RawMonad.rawIApplicative Mon
sequenceM : ∀ {n A} → M A ^ n → M (A ^ n)
sequenceM = sequenceA App
mapM : ∀ {n a} {A : Set a} {B} → (A → M B) → A ^ n → M (B ^ n)
mapM = mapA App
forM : ∀ {n a} {A : Set a} {B} → A ^ n → (A → M B) → M (B ^ n)
forM = forA App
| 27.645161
| 72
| 0.483664
|
1a59a4035e2e7c576ce6ac5cc7788cb01c99ead6
| 138
|
agda
|
Agda
|
test/Succeed/LetInstance.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/LetInstance.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/LetInstance.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module _ where
postulate
C : Set → Set
A : Set
i : C A
foo : {X : Set} {{_ : C X}} → X
bar : A
bar = let instance z = i in foo
| 11.5
| 33
| 0.514493
|
d19485d0b5d390c6258b50110f5563f8182f56e9
| 5,511
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/NaturalOrder/Left.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/NaturalOrder/Left.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/NaturalOrder/Left.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Conversion of binary operators to binary relations via the left
-- natural order.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
open import Algebra.FunctionProperties using (Op₂)
module Relation.Binary.Construct.NaturalOrder.Left
{a ℓ} {A : Set a} (_≈_ : Rel A ℓ) (_∙_ : Op₂ A) where
open import Algebra.FunctionProperties _≈_
open import Algebra.Structures _≈_
open import Data.Product using (_,_; _×_)
open import Data.Sum using (inj₁; inj₂)
open import Relation.Nullary using (¬_)
import Relation.Binary.Reasoning.Setoid as EqReasoning
open import Relation.Binary.Lattice using (Infimum)
------------------------------------------------------------------------
-- Definition
infix 4 _≤_
_≤_ : Rel A ℓ
x ≤ y = x ≈ (x ∙ y)
------------------------------------------------------------------------
-- Relational properties
reflexive : IsMagma _∙_ → Idempotent _∙_ → _≈_ ⇒ _≤_
reflexive magma idem {x} {y} x≈y = begin
x ≈⟨ sym (idem x) ⟩
x ∙ x ≈⟨ ∙-cong refl x≈y ⟩
x ∙ y ∎
where open IsMagma magma; open EqReasoning setoid
refl : Symmetric _≈_ → Idempotent _∙_ → Reflexive _≤_
refl sym idem {x} = sym (idem x)
antisym : IsEquivalence _≈_ → Commutative _∙_ → Antisymmetric _≈_ _≤_
antisym isEq comm {x} {y} x≤y y≤x = begin
x ≈⟨ x≤y ⟩
x ∙ y ≈⟨ comm x y ⟩
y ∙ x ≈⟨ sym y≤x ⟩
y ∎
where open IsEquivalence isEq; open EqReasoning (record { isEquivalence = isEq })
total : Symmetric _≈_ → Transitive _≈_ → Selective _∙_ → Commutative _∙_ → Total _≤_
total sym trans sel comm x y with sel x y
... | inj₁ x∙y≈x = inj₁ (sym x∙y≈x)
... | inj₂ x∙y≈y = inj₂ (sym (trans (comm y x) x∙y≈y))
trans : IsSemigroup _∙_ → Transitive _≤_
trans semi {x} {y} {z} x≤y y≤z = begin
x ≈⟨ x≤y ⟩
x ∙ y ≈⟨ ∙-cong S.refl y≤z ⟩
x ∙ (y ∙ z) ≈⟨ sym (assoc x y z) ⟩
(x ∙ y) ∙ z ≈⟨ ∙-cong (sym x≤y) S.refl ⟩
x ∙ z ∎
where open module S = IsSemigroup semi; open EqReasoning S.setoid
respʳ : IsMagma _∙_ → _≤_ Respectsʳ _≈_
respʳ magma {x} {y} {z} y≈z x≤y = begin
x ≈⟨ x≤y ⟩
x ∙ y ≈⟨ ∙-cong M.refl y≈z ⟩
x ∙ z ∎
where open module M = IsMagma magma; open EqReasoning M.setoid
respˡ : IsMagma _∙_ → _≤_ Respectsˡ _≈_
respˡ magma {x} {y} {z} y≈z y≤x = begin
z ≈⟨ sym y≈z ⟩
y ≈⟨ y≤x ⟩
y ∙ x ≈⟨ ∙-cong y≈z M.refl ⟩
z ∙ x ∎
where open module M = IsMagma magma; open EqReasoning M.setoid
resp₂ : IsMagma _∙_ → _≤_ Respects₂ _≈_
resp₂ magma = respʳ magma , respˡ magma
dec : Decidable _≈_ → Decidable _≤_
dec _≟_ x y = x ≟ (x ∙ y)
module _ (semi : IsSemilattice _∙_) where
private open module S = IsSemilattice semi
open EqReasoning setoid
x∙y≤x : ∀ x y → (x ∙ y) ≤ x
x∙y≤x x y = begin
x ∙ y ≈⟨ ∧-cong (sym (idem x)) S.refl ⟩
(x ∙ x) ∙ y ≈⟨ assoc x x y ⟩
x ∙ (x ∙ y) ≈⟨ comm x (x ∙ y) ⟩
(x ∙ y) ∙ x ∎
x∙y≤y : ∀ x y → (x ∙ y) ≤ y
x∙y≤y x y = begin
x ∙ y ≈⟨ ∧-cong S.refl (sym (idem y)) ⟩
x ∙ (y ∙ y) ≈⟨ sym (assoc x y y) ⟩
(x ∙ y) ∙ y ∎
∙-presʳ-≤ : ∀ {x y} z → z ≤ x → z ≤ y → z ≤ (x ∙ y)
∙-presʳ-≤ {x} {y} z z≤x z≤y = begin
z ≈⟨ z≤y ⟩
z ∙ y ≈⟨ ∧-cong z≤x S.refl ⟩
(z ∙ x) ∙ y ≈⟨ assoc z x y ⟩
z ∙ (x ∙ y) ∎
infimum : Infimum _≤_ _∙_
infimum x y = x∙y≤x x y , x∙y≤y x y , ∙-presʳ-≤
------------------------------------------------------------------------
-- Structures
isPreorder : IsBand _∙_ → IsPreorder _≈_ _≤_
isPreorder band = record
{ isEquivalence = isEquivalence
; reflexive = reflexive isMagma idem
; trans = trans isSemigroup
}
where open IsBand band hiding (reflexive; trans)
isPartialOrder : IsSemilattice _∙_ → IsPartialOrder _≈_ _≤_
isPartialOrder semilattice = record
{ isPreorder = isPreorder isBand
; antisym = antisym isEquivalence comm
}
where open IsSemilattice semilattice
isDecPartialOrder : IsSemilattice _∙_ → Decidable _≈_ →
IsDecPartialOrder _≈_ _≤_
isDecPartialOrder semilattice _≟_ = record
{ isPartialOrder = isPartialOrder semilattice
; _≟_ = _≟_
; _≤?_ = dec _≟_
}
isTotalOrder : IsSemilattice _∙_ → Selective _∙_ → IsTotalOrder _≈_ _≤_
isTotalOrder latt sel = record
{ isPartialOrder = isPartialOrder latt
; total = total sym S.trans sel comm
}
where open module S = IsSemilattice latt
isDecTotalOrder : IsSemilattice _∙_ → Selective _∙_ →
Decidable _≈_ → IsDecTotalOrder _≈_ _≤_
isDecTotalOrder latt sel _≟_ = record
{ isTotalOrder = isTotalOrder latt sel
; _≟_ = _≟_
; _≤?_ = dec _≟_
}
------------------------------------------------------------------------
-- Packages
preorder : IsBand _∙_ → Preorder a ℓ ℓ
preorder band = record
{ isPreorder = isPreorder band
}
poset : IsSemilattice _∙_ → Poset a ℓ ℓ
poset latt = record
{ isPartialOrder = isPartialOrder latt
}
decPoset : IsSemilattice _∙_ → Decidable _≈_ → DecPoset a ℓ ℓ
decPoset latt dec = record
{ isDecPartialOrder = isDecPartialOrder latt dec
}
totalOrder : IsSemilattice _∙_ → Selective _∙_ → TotalOrder a ℓ ℓ
totalOrder latt sel = record
{ isTotalOrder = isTotalOrder latt sel
}
decTotalOrder : IsSemilattice _∙_ → Selective _∙_ →
Decidable _≈_ → DecTotalOrder a ℓ ℓ
decTotalOrder latt sel dec = record
{ isDecTotalOrder = isDecTotalOrder latt sel dec
}
| 29.789189
| 84
| 0.565778
|
1bb126fd6ce8091e8c456c512e09f41199cf2a78
| 5,692
|
agda
|
Agda
|
agda/Music.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 28
|
2017-04-21T09:08:52.000Z
|
2022-03-04T18:04:07.000Z
|
agda/Music.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 1
|
2020-11-13T01:26:20.000Z
|
2020-11-17T00:58:55.000Z
|
agda/Music.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 3
|
2019-01-12T17:02:36.000Z
|
2020-11-10T04:04:40.000Z
|
{-# OPTIONS --erased-cubical --safe #-}
module Music where
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _≤_; _≤?_)
open import Data.Integer using (ℤ; +_)
open import Data.List using (List; foldr; []; _∷_; reverse; sum; map)
open import Data.Product using (_×_; _,_)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Vec using (Vec; []; _∷_; replicate; concat; zipWith; toList; _++_; foldr₁; take; drop) renaming (map to vmap)
open import Function using (_∘_)
open import Data.Nat.Properties using (<⇒≤)
open import Relation.Nullary using (yes; no)
open import Relation.Binary.PropositionalEquality using (sym; subst)
open import Nat
open import Note
open import Pitch
open import Interval
-- A point in the music grid, which can either be a tone,
-- a continuation of a previous tone, or a rest.
data Point : Set where
tone : Pitch → Point
hold : Pitch → Point
rest : Point
data Melody (n : ℕ) : Set where
melody : Vec Point n → Melody n
unmelody : {n : ℕ} → Melody n → Vec Point n
unmelody (melody ps) = ps
infixr 5 _m++_
_m++_ : {m n : ℕ} → Melody m → Melody n → Melody (m + n)
melody a m++ melody b = melody (a ++ b)
note→melody : (n : Note) → Melody (noteDuration n)
note→melody (tone zero p) = melody []
note→melody (tone (suc d) p) = melody (tone p ∷ replicate (hold p))
note→melody (rest _) = melody (replicate rest)
notes→melody : (ns : List Note) → Melody (sum (map noteDuration ns))
notes→melody [] = melody []
notes→melody (n ∷ ns) = note→melody n m++ notes→melody ns
pitches→melody : {n : ℕ} → (d : Duration) → (ps : Vec Pitch n) → Melody (n * d)
pitches→melody d ps = melody (concat (vmap (unmelody ∘ note→melody ∘ tone d) ps))
-- Assumes melody is well-formed in that a held note has the
-- same pitch as the note before it.
-- Does not consolidate rests.
melody→notes : {n : ℕ} → Melody n → List Note
melody→notes (melody m) = (reverse ∘ mn 0 ∘ reverse ∘ toList) m
where mn : ℕ → List Point → List Note -- c is the number of held points
mn c [] = []
mn c (tone p ∷ ps) = tone (suc c) p ∷ mn 0 ps
mn c (hold _ ∷ ps) = mn (suc c) ps
mn c (rest ∷ ps) = rest 1 ∷ mn 0 ps
transposePoint : ℤ → Point → Point
transposePoint k (tone p) = tone (transposePitch k p)
transposePoint k (hold p) = hold (transposePitch k p)
transposePoint k rest = rest
transposeMelody : {n : ℕ} → ℤ → Melody n → Melody n
transposeMelody k = melody ∘ vmap (transposePoint k) ∘ unmelody
data Chord (n : ℕ) : Set where
chord : Vec Point n → Chord n
unchord : {n : ℕ} → Chord n → Vec Point n
unchord (chord ps) = ps
-- We represent music as a v × d grid where v is the number of voices and d is the duration.
-- The primary representation is as parallel melodies (counterpoint).
data Counterpoint (v : ℕ) (d : ℕ): Set where
cp : Vec (Melody d) v → Counterpoint v d
uncp : {v d : ℕ} → Counterpoint v d → Vec (Melody d) v
uncp (cp m) = m
-- An alternative representation of music is as a series of chords (harmonic progression).
data Harmony (v : ℕ) (d : ℕ): Set where
harmony : Vec (Chord v) d → Harmony v d
unharmony : {v d : ℕ} → Harmony v d → Vec (Chord v) d
unharmony (harmony h) = h
pitches→harmony : {n : ℕ} (d : Duration) → (ps : Vec Pitch n) → Harmony n d
pitches→harmony zero ps = harmony []
pitches→harmony (suc d) ps = harmony (chord (vmap tone ps) ∷ replicate (chord (vmap hold ps)))
pitchPair→Harmony : (d : Duration) → PitchPair → Harmony 2 d
pitchPair→Harmony d (p , q) = pitches→harmony d (p ∷ q ∷ [])
pitchInterval→Harmony : (d : Duration) → PitchInterval → Harmony 2 d
pitchInterval→Harmony d = pitchPair→Harmony d ∘ pitchIntervalToPitchPair
{-
pitchIntervalsToCounterpoint : PitchInterval → Counterpoint
pitchIntervalsToCounterpoint = pitchPairToCounterpoint ∘ pitchIntervalToPitchPair
-}
addEmptyVoice : {v d : ℕ} → Harmony v d → Harmony (suc v) d
addEmptyVoice (harmony h) = harmony (vmap (chord ∘ (rest ∷_) ∘ unchord) h)
infixl 5 _+H+_
_+H+_ : {v d d' : ℕ} → Harmony v d → Harmony v d' → Harmony v (d + d')
h +H+ h' = harmony (unharmony h ++ unharmony h')
foldIntoHarmony : {k n : ℕ} (ds : Vec Duration (suc k)) → (pss : Vec (Vec Pitch n) (suc k)) → Harmony n (foldr₁ _+_ ds)
foldIntoHarmony (d ∷ []) (ps ∷ []) = pitches→harmony d ps
foldIntoHarmony (d ∷ d' ∷ ds) (ps ∷ ps' ∷ pss) = (pitches→harmony d ps) +H+ (foldIntoHarmony (d' ∷ ds) (ps' ∷ pss))
-- matrix transposition
mtranspose : {A : Set}{m n : ℕ} → Vec (Vec A n) m → Vec (Vec A m) n
mtranspose [] = replicate []
mtranspose (xs ∷ xss) = zipWith _∷_ xs (mtranspose xss)
counterpoint→harmony : {v d : ℕ} → Counterpoint v d → Harmony v d
counterpoint→harmony = harmony ∘ vmap chord ∘ mtranspose ∘ vmap unmelody ∘ uncp
harmony→counterpoint : {v d : ℕ} → Harmony v d → Counterpoint v d
harmony→counterpoint = cp ∘ vmap melody ∘ mtranspose ∘ vmap unchord ∘ unharmony
-- Fix length of a melody, either truncating or padding with rests
fixLength : {m : ℕ} → (n : ℕ) → Melody m → Melody n
fixLength {m} n (melody ns) with <-∨-≥ n m
... | inj₁ n<m = melody (take n (subst (Vec Point) (sym (m+n-m=n n m {<⇒≤ n<m})) ns))
... | inj₂ m≤n = melody (subst (Vec Point) (m+n-m=n m n) (ns ++ replicate {n = n - m ⟨ m≤n ⟩} rest))
holdToTone : Point → Point
holdToTone (tone p) = tone p
holdToTone (hold p) = tone p
holdToTone rest = rest
firstHoldToTone : {n : ℕ} → Melody n → Melody n
firstHoldToTone (melody []) = melody []
firstHoldToTone (melody (x ∷ xs)) = melody (holdToTone x ∷ xs)
-- Drop points, but convert any held tones to tones.
dropPoints : {n : ℕ} → (m : ℕ) → Melody (m + n) → Melody n
dropPoints m = firstHoldToTone ∘ melody ∘ drop m ∘ unmelody
| 38.721088
| 130
| 0.64863
|
fd57bf68d08f0a0801d287a037339a6201acba4b
| 146
|
agda
|
Agda
|
test/Succeed/Issue1538.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1538.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1538.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module _ (A : Set) where
open import Common.Prelude
open import Common.Reflection
macro
foo : Tactic
foo _ = returnTC _
bar : ⊤
bar = foo
| 11.230769
| 29
| 0.691781
|
432601d1160394503aa67634c352e03142bcdef2
| 4,369
|
agda
|
Agda
|
test/LibSucceed/InstanceArguments/13-implicitProofObligations.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/LibSucceed/InstanceArguments/13-implicitProofObligations.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/LibSucceed/InstanceArguments/13-implicitProofObligations.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --universe-polymorphism #-}
module InstanceArguments.13-implicitProofObligations where
module Imports where
module L where
open import Agda.Primitive public
using (Level; _⊔_) renaming (lzero to zero; lsuc to suc)
-- extract from Data.Unit
record ⊤ : Set where
constructor tt
-- extract from Data.Empty
data ⊥ : Set where
⊥-elim : ∀ {w} {Whatever : Set w} → ⊥ → Whatever
⊥-elim ()
-- extract from Function
id : ∀ {a} {A : Set a} → A → A
id x = x
_$_ : ∀ {a b} {A : Set a} {B : A → Set b} →
((x : A) → B x) → ((x : A) → B x)
f $ x = f x
_∘_ : ∀ {a b c}
{A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} →
(∀ {x} (y : B x) → C y) → (g : (x : A) → B x) →
((x : A) → C (g x))
f ∘ g = λ x → f (g x)
-- extract from Data.Bool
data Bool : Set where
true : Bool
false : Bool
not : Bool → Bool
not true = false
not false = true
T : Bool → Set
T true = ⊤
T false = ⊥
-- extract from Relation.Nullary.Decidable and friends
infix 3 ¬_
¬_ : ∀ {ℓ} → Set ℓ → Set ℓ
¬ P = P → ⊥
data Dec {p} (P : Set p) : Set p where
yes : ( p : P) → Dec P
no : (¬p : ¬ P) → Dec P
⌊_⌋ : ∀ {p} {P : Set p} → Dec P → Bool
⌊ yes _ ⌋ = true
⌊ no _ ⌋ = false
False : ∀ {p} {P : Set p} → Dec P → Set
False Q = T (not ⌊ Q ⌋)
-- extract from Relation.Binary.PropositionalEquality
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
cong : ∀ {a b} {A : Set a} {B : Set b}
(f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
_≢′_ : ∀ {a} {A : Set a} → A → A → Set a
x ≢′ y = ¬ (x ≡ y)
-- wrapper to be able to use instance search
data _≢_ {a} {A : Set a} (x y : A) : Set a where
not-equal : x ≢′ y → x ≢ y
-- extract from Data.Nat
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-}
pred : ℕ → ℕ
pred zero = zero
pred (suc n) = n
infixl 6 _+_
_+_ : ℕ → ℕ → ℕ
-- zero + n = n
-- suc m + n = suc (m + n)
zero + n = n
suc m + n = suc (m + n)
_*_ : ℕ → ℕ → ℕ
zero * n = zero
suc m * n = n + (m * n)
_≟_ : (x y : ℕ) → Dec (x ≡ y)
zero ≟ zero = yes refl
suc m ≟ suc n with m ≟ n
suc m ≟ suc .m | yes refl = yes refl
suc m ≟ suc n | no prf = no (prf ∘ cong pred)
zero ≟ suc n = no λ()
suc m ≟ zero = no λ()
-- extract from Data.Fin
data Fin : ℕ → Set where
zero : {n : ℕ} → Fin (suc n)
suc : {n : ℕ} (i : Fin n) → Fin (suc n)
-- A conversion: toℕ "n" = n.
toℕ : ∀ {n} → Fin n → ℕ
toℕ zero = 0
toℕ (suc i) = suc (toℕ i)
-- extract from Data.Product
record Σ {a b} (A : Set a) (B : A → Set b) : Set (a L.⊔ b) where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
_×_ : ∀ {a b} (A : Set a) (B : Set b) → Set (a L.⊔ b)
A × B = Σ A (λ (_ : A) → B)
-- extract from Data.Nat.DivMod
data DivMod : ℕ → ℕ → Set where
result : {divisor : ℕ} (q : ℕ) (r : Fin divisor) →
DivMod (toℕ r + (q * divisor)) divisor
data DivMod' (dividend divisor : ℕ) : Set where
result : (q : ℕ) (r : Fin divisor)
(eq : dividend ≡ (toℕ r + (q * divisor))) →
DivMod' dividend divisor
postulate
_div_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ
_divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} →
DivMod dividend divisor
_divMod'_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} →
DivMod' dividend divisor
open Imports
-- Begin of actual example!
postulate
d : ℕ
d≢0 : d ≢ 0
-- d≢0' : d ≢ 0
fromWitnessFalse : ∀ {p} {P : Set p} {Q : Dec P} → ¬ P → False Q
fromWitnessFalse {Q = yes p} ¬P = ⊥-elim $ ¬P p
fromWitnessFalse {Q = no ¬p} ¬P = tt
⋯ : {A : Set} → {{v : A}} → A
⋯ {{v}} = v
_divMod′_ : (dividend divisor : ℕ) {{ ≢0 : divisor ≢ 0 }} → ℕ × ℕ
_divMod′_ a d {{not-equal p}} with _divMod_ a d { fromWitnessFalse p }
_divMod′_ ._ d {{not-equal p}} | (result q r) = q , toℕ r
_div′_ : (dividend divisor : ℕ) {{ ≢0 : divisor ≢ 0 }} → ℕ
_div′_ a b {{_}} with a divMod′ b
a div′ b | (q , _) = q
--Agda can't resolve hiddens
-- test : {d≢0 : False (d ≟ 0)} → ℕ
-- test = 5 div d
-- test2 : {{d≢0 : d ≢ 0}} → ℕ
-- test2 = 5 div′ d
test3 = 5 div 2
test4 = 5 div′ 2
where
instance
nz : 2 ≢ 0
nz = not-equal λ()
| 23.616216
| 70
| 0.49073
|
1b73c694290d1618e51c1cbd81ade4f211038340
| 1,643
|
agda
|
Agda
|
Setoids/Cardinality/Infinite/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Setoids/Cardinality/Infinite/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Setoids/Cardinality/Infinite/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Functions.Definition
open import Numbers.Naturals.Definition
open import Numbers.Naturals.Order
open import Sets.FinSet.Definition
open import Sets.FinSet.Lemmas
open import Setoids.Setoids
open import Setoids.Cardinality.Infinite.Definition
open import Sets.Cardinality.Infinite.Lemmas
open import Setoids.Subset
open import Sets.EquivalenceRelations
module Setoids.Cardinality.Infinite.Lemmas where
finsetNotInfiniteSetoid : {n : ℕ} → InfiniteSetoid (reflSetoid (FinSet n)) → False
finsetNotInfiniteSetoid {n} isInfinite = isInfinite n id (record { inj = record { wellDefined = id ; injective = id } ; surj = record { wellDefined = id ; surjective = λ {x} → x , refl } })
dedekindInfiniteImpliesInfiniteSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → DedekindInfiniteSetoid S → InfiniteSetoid S
dedekindInfiniteImpliesInfiniteSetoid S record { inj = inj ; isInjection = isInj } zero f isBij with SetoidInvertible.inverse (setoidBijectiveImpliesInvertible isBij) (inj 0)
... | ()
dedekindInfiniteImpliesInfiniteSetoid {A = A} S record { inj = inj ; isInjection = isInj } (succ n) f isBij = noInjectionNToFinite {f = t} tInjective
where
t : ℕ → FinSet (succ n)
t n = SetoidInvertible.inverse (setoidBijectiveImpliesInvertible isBij) (inj n)
tInjective : Injection t
tInjective pr = SetoidInjection.injective isInj (SetoidInjection.injective (SetoidBijection.inj (setoidInvertibleImpliesBijective (inverseInvertible (setoidBijectiveImpliesInvertible isBij)))) pr)
| 54.766667
| 200
| 0.772368
|
1b02fbfbac81799074fb464e0521f87b97b6383e
| 1,872
|
agda
|
Agda
|
old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module FunctionProofs where
open FunctionSet ⦃ signature ⦄
[∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] : ∀{D : Domain}{P : BinaryRelator} → Proof(∀ₗ(x ↦ ∃ₗ(y ↦ (x ∈ D) ⟶ P(x)(y))) ⟷ ∀ₛ(D)(x ↦ ∃ₗ(y ↦ P(x)(y))))
[∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] {D}{P} = [↔]-with-[∀] ([∃]-unrelatedᵣ-[→])
[∀ₛ∃!]-to[∀ₛ∃] : ∀{P : BinaryRelator}{D : Domain} → Proof(∀ₛ(D)(x ↦ ∃ₗ!(y ↦ P(x)(y)))) → Proof(∀ₛ(D)(x ↦ ∃ₗ(y ↦ P(x)(y))))
[∀ₛ∃!]-to[∀ₛ∃] proof =
([∀ₛ]-intro(\{x} → xinD ↦
[∧].elimₗ([∀ₛ]-elim proof {x} xinD)
))
-- The construction of a meta-function in the meta-logic from a function in the set theory
fnset-witness : ∀{D} → (f : Domain) → ⦃ _ : Proof(Total(D)(f)) ⦄ → Function
fnset-witness f ⦃ proof ⦄ = [∃]-fn-witness ⦃ [↔].elimₗ [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] (proof) ⦄
fnset-value : ∀{D} → (f : Domain) → ⦃ proof : Proof(Total(D)(f)) ⦄ → Proof(∀ₛ(D)(x ↦ (x , fnset-witness f(x)) ∈ f))
fnset-value{D} f ⦃ proof ⦄ = [∃]-fn-proof ⦃ [↔].elimₗ [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] (proof) ⦄
fnset-proof : ∀{D} → (f : Domain) → ⦃ _ : Proof(FunctionSet(f)) ⦄ → ⦃ total : Proof(Total(D)(f)) ⦄ → Proof(∀ₛ(D)(x ↦ ∀ₗ(y ↦ (fnset-witness{D} f ⦃ total ⦄ x ≡ y) ⟷ ((x , y) ∈ f))))
fnset-proof{D} f ⦃ function ⦄ ⦃ total ⦄ =
([∀ₛ]-intro(\{x} → x∈D ↦
([∀].intro(\{y} →
([↔].intro
(xy∈f ↦
([→].elim
([∀].elim([∀].elim([∀].elim function{x}) {fnset-witness f(x)}) {y})
([∧].intro
([∀ₛ]-elim(fnset-value f) {x} (x∈D))
(xy∈f)
)
)
)
(fx≡y ↦
[≡].elimᵣ (fx≡y) ([∀ₛ]-elim (fnset-value(f)) {x} (x∈D))
)
)
))
))
[→ₛₑₜ]-witness : ∀{A B} → (f : Domain) → ⦃ _ : Proof(f ∈ (A →ₛₑₜ B)) ⦄ → Function
[→ₛₑₜ]-witness f ⦃ proof ⦄ (x) =
(fnset-witness f
⦃ [∧].elimᵣ([∧].elimᵣ([↔].elimᵣ
([∀].elim([∀].elim filter-membership))
(proof)
)) ⦄
(x)
)
| 36.705882
| 179
| 0.458868
|
379e358c297e1bc854f49efcbd187fcb7422748b
| 7,027
|
agda
|
Agda
|
Cubical/Algebra/CommAlgebra/Base.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommAlgebra/Base.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Algebra/CommAlgebra/Base.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe --no-import-sorts #-}
module Cubical.Algebra.CommAlgebra.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Structures.Axioms
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Ring
open import Cubical.Algebra.Algebra hiding (⟨_⟩a)
private
variable
ℓ ℓ′ : Level
record IsCommAlgebra (R : CommRing {ℓ}) {A : Type ℓ}
(0a : A) (1a : A)
(_+_ : A → A → A) (_·_ : A → A → A) (-_ : A → A)
(_⋆_ : ⟨ R ⟩ → A → A) : Type ℓ where
constructor iscommalgebra
field
isAlgebra : IsAlgebra (CommRing→Ring R) 0a 1a _+_ _·_ -_ _⋆_
·-comm : (x y : A) → x · y ≡ y · x
open IsAlgebra isAlgebra public
record CommAlgebra (R : CommRing {ℓ}) : Type (ℓ-suc ℓ) where
constructor commalgebra
field
Carrier : Type ℓ
0a : Carrier
1a : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_⋆_ : ⟨ R ⟩ → Carrier → Carrier
isCommAlgebra : IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_
open IsCommAlgebra isCommAlgebra public
module _ {R : CommRing {ℓ}} where
open CommRingStr (snd R) using (1r) renaming (_+_ to _+r_; _·_ to _·s_)
⟨_⟩a : CommAlgebra R → Type ℓ
⟨_⟩a = CommAlgebra.Carrier
CommAlgebra→Algebra : (A : CommAlgebra R) → Algebra (CommRing→Ring R)
CommAlgebra→Algebra (commalgebra Carrier _ _ _ _ _ _ (iscommalgebra isAlgebra ·-comm)) =
algebra Carrier _ _ _ _ _ _ isAlgebra
CommAlgebra→CommRing : (A : CommAlgebra R) → CommRing {ℓ}
CommAlgebra→CommRing (commalgebra Carrier _ _ _ _ _ _
(iscommalgebra isAlgebra ·-comm)) =
_ , commringstr _ _ _ _ _ (iscommring (IsAlgebra.isRing isAlgebra) ·-comm)
CommAlgebraEquiv : (R S : CommAlgebra R) → Type ℓ
CommAlgebraEquiv R S = AlgebraEquiv (CommAlgebra→Algebra R) (CommAlgebra→Algebra S)
makeIsCommAlgebra : {A : Type ℓ} {0a 1a : A}
{_+_ _·_ : A → A → A} { -_ : A → A} {_⋆_ : ⟨ R ⟩ → A → A}
(isSet-A : isSet A)
(+-assoc : (x y z : A) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : A) → x + 0a ≡ x)
(+-rinv : (x : A) → x + (- x) ≡ 0a)
(+-comm : (x y : A) → x + y ≡ y + x)
(·-assoc : (x y z : A) → x · (y · z) ≡ (x · y) · z)
(·-lid : (x : A) → 1a · x ≡ x)
(·-ldist-+ : (x y z : A) → (x + y) · z ≡ (x · z) + (y · z))
(·-comm : (x y : A) → x · y ≡ y · x)
(⋆-assoc : (r s : ⟨ R ⟩) (x : A) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x))
(⋆-ldist : (r s : ⟨ R ⟩) (x : A) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))
(⋆-rdist : (r : ⟨ R ⟩) (x y : A) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))
(⋆-lid : (x : A) → 1r ⋆ x ≡ x)
(⋆-lassoc : (r : ⟨ R ⟩) (x y : A) → (r ⋆ x) · y ≡ r ⋆ (x · y))
→ IsCommAlgebra R 0a 1a _+_ _·_ -_ _⋆_
makeIsCommAlgebra {A} {0a} {1a} {_+_} {_·_} { -_} {_⋆_} isSet-A
+-assoc +-rid +-rinv +-comm
·-assoc ·-lid ·-ldist-+ ·-comm
⋆-assoc ⋆-ldist ⋆-rdist ⋆-lid ⋆-lassoc
= iscommalgebra
(makeIsAlgebra
isSet-A
+-assoc +-rid +-rinv +-comm
·-assoc
(λ x → x · 1a ≡⟨ ·-comm _ _ ⟩ 1a · x ≡⟨ ·-lid _ ⟩ x ∎)
·-lid
(λ x y z → x · (y + z) ≡⟨ ·-comm _ _ ⟩
(y + z) · x ≡⟨ ·-ldist-+ _ _ _ ⟩
(y · x) + (z · x) ≡⟨ cong (λ u → (y · x) + u) (·-comm _ _) ⟩
(y · x) + (x · z) ≡⟨ cong (λ u → u + (x · z)) (·-comm _ _) ⟩
(x · y) + (x · z) ∎)
·-ldist-+
⋆-assoc
⋆-ldist
⋆-rdist
⋆-lid
⋆-lassoc
λ r x y → r ⋆ (x · y) ≡⟨ cong (λ u → r ⋆ u) (·-comm _ _) ⟩
r ⋆ (y · x) ≡⟨ sym (⋆-lassoc _ _ _) ⟩
(r ⋆ y) · x ≡⟨ ·-comm _ _ ⟩
x · (r ⋆ y) ∎)
·-comm
module CommAlgebraΣTheory (R : CommRing {ℓ}) where
open AlgebraΣTheory (CommRing→Ring R)
CommAlgebraAxioms : (A : Type ℓ) (s : RawAlgebraStructure A) → Type ℓ
CommAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_) = AlgebraAxioms A (_+_ , _·_ , 1a , _⋆_)
× ((x y : A) → x · y ≡ y · x)
CommAlgebraStructure : Type ℓ → Type ℓ
CommAlgebraStructure = AxiomsStructure RawAlgebraStructure CommAlgebraAxioms
CommAlgebraΣ : Type (ℓ-suc ℓ)
CommAlgebraΣ = TypeWithStr ℓ CommAlgebraStructure
CommAlgebraEquivStr : StrEquiv CommAlgebraStructure ℓ
CommAlgebraEquivStr = AxiomsEquivStr RawAlgebraEquivStr CommAlgebraAxioms
isPropCommAlgebraAxioms : (A : Type ℓ) (s : RawAlgebraStructure A)
→ isProp (CommAlgebraAxioms A s)
isPropCommAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_) =
isPropΣ (isPropAlgebraAxioms A (_+_ , _·_ , 1a , _⋆_))
λ isAlgebra → isPropΠ2 λ _ _ → (isSetAlgebraΣ (A , _ , isAlgebra)) _ _
CommAlgebra→CommAlgebraΣ : CommAlgebra R → CommAlgebraΣ
CommAlgebra→CommAlgebraΣ (commalgebra _ _ _ _ _ _ _ (iscommalgebra G C)) =
_ , _ , Algebra→AlgebraΣ (algebra _ _ _ _ _ _ _ G) .snd .snd , C
CommAlgebraΣ→CommAlgebra : CommAlgebraΣ → CommAlgebra R
CommAlgebraΣ→CommAlgebra (_ , _ , G , C) =
commalgebra _ _ _ _ _ _ _ (iscommalgebra (AlgebraΣ→Algebra (_ , _ , G) .Algebra.isAlgebra) C)
CommAlgebraIsoCommAlgebraΣ : Iso (CommAlgebra R) CommAlgebraΣ
CommAlgebraIsoCommAlgebraΣ =
iso CommAlgebra→CommAlgebraΣ CommAlgebraΣ→CommAlgebra (λ _ → refl) (λ _ → refl)
commAlgebraUnivalentStr : UnivalentStr CommAlgebraStructure CommAlgebraEquivStr
commAlgebraUnivalentStr = axiomsUnivalentStr _ isPropCommAlgebraAxioms rawAlgebraUnivalentStr
CommAlgebraΣPath : (A B : CommAlgebraΣ) → (A ≃[ CommAlgebraEquivStr ] B) ≃ (A ≡ B)
CommAlgebraΣPath = SIP commAlgebraUnivalentStr
CommAlgebraEquivΣ : (A B : CommAlgebra R) → Type ℓ
CommAlgebraEquivΣ A B = CommAlgebra→CommAlgebraΣ A ≃[ CommAlgebraEquivStr ] CommAlgebra→CommAlgebraΣ B
CommAlgebraPath : (A B : CommAlgebra R) → (CommAlgebraEquiv A B) ≃ (A ≡ B)
CommAlgebraPath A B =
CommAlgebraEquiv A B ≃⟨ isoToEquiv AlgebraEquivΣPath ⟩
CommAlgebraEquivΣ A B ≃⟨ CommAlgebraΣPath _ _ ⟩
CommAlgebra→CommAlgebraΣ A ≡ CommAlgebra→CommAlgebraΣ B
≃⟨ isoToEquiv (invIso (congIso CommAlgebraIsoCommAlgebraΣ)) ⟩
A ≡ B ■
CommAlgebraPath : (R : CommRing {ℓ}) → (A B : CommAlgebra R) → (CommAlgebraEquiv A B) ≃ (A ≡ B)
CommAlgebraPath = CommAlgebraΣTheory.CommAlgebraPath
| 41.335294
| 104
| 0.548171
|
21b6968a3dbaa01299e50b406f3ed06f3d9dc7f1
| 2,393
|
agda
|
Agda
|
src/hott/level/closure/core.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 20
|
2015-06-12T12:20:17.000Z
|
2022-02-01T11:25:54.000Z
|
src/hott/level/closure/core.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T14:32:16.000Z
|
2016-10-26T11:57:26.000Z
|
src/hott/level/closure/core.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T12:17:00.000Z
|
2019-05-04T19:31:00.000Z
|
{-# OPTIONS --without-K #-}
module hott.level.closure.core where
open import level
open import decidable
open import equality
open import function.isomorphism.core
-- open import function.isomorphism.properties
open import sum
open import hott.level.core
open import hott.equivalence.core
open import hott.univalence
open import sets.nat.core
open import sets.nat.ordering.leq.core
open import sets.nat.ordering.leq.decide
open import sets.empty
open import sets.unit
Σ-contr : ∀ {i j}{X : Set i}{Y : X → Set j}
→ contr X → ((x : X) → contr (Y x))
→ contr (Σ X Y)
Σ-contr {X = X}{Y = Y} (x₀ , cx) hY
= (x₀ , proj₁ (hY x₀)) , λ { (x , y) → c x y }
where
c : (x : X)(y : Y x) → (x₀ , proj₁ (hY x₀)) ≡ (x , y)
c x y = ap (λ x → (x , proj₁ (hY x))) (cx x)
· ap (_,_ x) (proj₂ (hY x) y)
×-contr : ∀ {i j}{X : Set i}{Y : Set j}
→ contr X → contr Y
→ contr (X × Y)
×-contr hX hY = Σ-contr hX (λ _ → hY)
unique-contr : ∀ {i}{A B : Set i}
→ contr A
→ contr B
→ A ≡ B
unique-contr {i}{A}{B} hA hB = ≈⇒≡ (f , f-we)
where
f : A → B
f _ = proj₁ hB
f-we : weak-equiv f
f-we b = ×-contr hA (h↑ hB _ _)
h-≤ : ∀ {i n m}{X : Set i}
→ n ≤ m → h n X → h m X
h-≤ {m = 0} z≤n hX = hX
h-≤ {m = suc m} z≤n hX = λ x y
→ h-≤ {m = m} z≤n (h↑ hX x y)
h-≤ (s≤s p) hX = λ x y
→ h-≤ p (hX x y)
h! : ∀ {i n m}{X : Set i}
→ {p : True (n ≤? m)}
→ h n X → h m X
h! {p = p} = h-≤ (witness p)
abstract
-- retractions preserve levels
retract-level : ∀ {i j n} {X : Set i}{Y : Set j}
→ (f : X → Y)(g : Y → X)
→ ((y : Y) → f (g y) ≡ y)
→ h n X → h n Y
retract-level {n = 0}{X}{Y} f g r (x , c) = (f x , c')
where
c' : (y : Y) → f x ≡ y
c' y = ap f (c (g y)) · r y
retract-level {n = suc n}{X}{Y} f g r hX = λ y y'
→ retract-level f' g' r' (hX (g y) (g y'))
where
f' : {y y' : Y} → g y ≡ g y' → y ≡ y'
f' {y}{y'} p = sym (r y) · ap f p · r y'
g' : {y y' : Y} → y ≡ y' → g y ≡ g y'
g' = ap g
r' : {y y' : Y}(p : y ≡ y') → f' (g' p) ≡ p
r' {y}{.y} refl = ap (λ α → α · r y) (left-unit (sym (r y)))
· right-inverse (r y)
iso-level : ∀ {i j n}{X : Set i}{Y : Set j}
→ X ≅ Y → h n X → h n Y
iso-level (iso f g H K) = retract-level f g K
| 28.152941
| 66
| 0.457167
|
35ff518bfcd7f10384bfba898b08740ea4528aa5
| 5,068
|
agda
|
Agda
|
Cubical/HITs/Ints/BiInvInt/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/BiInvInt/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/BiInvInt/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Ints.BiInvInt.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat hiding (_+_; +-comm)
open import Cubical.Data.Int
open import Cubical.Data.Bool
open import Cubical.HITs.Ints.BiInvInt.Base
-- addition
_+ᴮ_ : BiInvInt → BiInvInt → BiInvInt
m +ᴮ zero = m
m +ᴮ suc n = suc (m +ᴮ n)
m +ᴮ predr n = predr (m +ᴮ n)
m +ᴮ predl n = predl (m +ᴮ n)
m +ᴮ suc-predr n i = suc-predr (m +ᴮ n) i
m +ᴮ predl-suc n i = predl-suc (m +ᴮ n) i
-- properties of addition
+ᴮ-assoc : ∀ l m n → (l +ᴮ m) +ᴮ n ≡ l +ᴮ (m +ᴮ n)
+ᴮ-assoc l m zero i = l +ᴮ m
+ᴮ-assoc l m (suc n) i = suc (+ᴮ-assoc l m n i)
+ᴮ-assoc l m (predr n) i = predr (+ᴮ-assoc l m n i)
+ᴮ-assoc l m (predl n) i = predl (+ᴮ-assoc l m n i)
+ᴮ-assoc l m (suc-predr n i) j = suc-predr (+ᴮ-assoc l m n j) i
+ᴮ-assoc l m (predl-suc n i) j = predl-suc (+ᴮ-assoc l m n j) i
+ᴮ-unitʳ : ∀ n → n +ᴮ zero ≡ n
+ᴮ-unitʳ n i = n
+ᴮ-unitˡ : ∀ n → zero +ᴮ n ≡ n
+ᴮ-unitˡ zero i = zero
+ᴮ-unitˡ (suc n) i = suc (+ᴮ-unitˡ n i)
+ᴮ-unitˡ (predr n) i = predr (+ᴮ-unitˡ n i)
+ᴮ-unitˡ (predl n) i = predl (+ᴮ-unitˡ n i)
+ᴮ-unitˡ (suc-predr n i) j = suc-predr (+ᴮ-unitˡ n j) i
+ᴮ-unitˡ (predl-suc n i) j = predl-suc (+ᴮ-unitˡ n j) i
-- TODO: a direct proof of commutatitivty
-- (for now, we use Data.Int)
fwd-+≡+ᴮ : ∀ m n → fwd (m + n) ≡ (fwd m) +ᴮ (fwd n)
fwd-+≡+ᴮ m (pos zero) = refl
fwd-+≡+ᴮ m (pos (suc n)) = fwd-sucInt (m +pos n) ∙ cong suc (fwd-+≡+ᴮ m (pos n))
fwd-+≡+ᴮ m (negsuc zero) = fwd-predInt m
fwd-+≡+ᴮ m (negsuc (suc n)) = fwd-predInt (m +negsuc n) ∙ cong pred (fwd-+≡+ᴮ m (negsuc n))
+ᴮ≡+ : ∀ m n → m +ᴮ n ≡ fwd ((bwd m) + (bwd n))
+ᴮ≡+ m n = sym (fwd-+≡+ᴮ (bwd m) (bwd n) ∙ (λ i → (fwd-bwd m i) +ᴮ (fwd-bwd n i)))
+ᴮ-comm : ∀ m n → m +ᴮ n ≡ n +ᴮ m
+ᴮ-comm m n = +ᴮ≡+ m n ∙ cong fwd (+-comm (bwd m) (bwd n)) ∙ sym (+ᴮ≡+ n m)
-- some of the lemmas needed for a direct proof +ᴮ-comm are corollaries of +ᴮ-comm
suc-+ᴮ : ∀ m n → (suc m) +ᴮ n ≡ suc (m +ᴮ n)
suc-+ᴮ m n = +ᴮ-comm (suc m) n ∙ (λ i → suc (+ᴮ-comm n m i))
-- suc-+ᴮ m zero i = suc m
-- suc-+ᴮ m (suc n) i = suc (suc-+ᴮ m n i)
-- suc-+ᴮ m (predr n) = cong predr (suc-+ᴮ m n) ∙ predr-suc (m +ᴮ n) ∙ sym (suc-predr (m +ᴮ n))
-- suc-+ᴮ m (predl n) = cong predl (suc-+ᴮ m n) ∙ predl-suc (m +ᴮ n) ∙ sym (suc-predl (m +ᴮ n))
-- suc-+ᴮ m (suc-predr n i) j = {!!}
-- suc-+ᴮ m (predl-suc n i) j = {!!}
predr-+ᴮ : ∀ m n → (predr m) +ᴮ n ≡ predr (m +ᴮ n)
predr-+ᴮ m n = +ᴮ-comm (predr m) n ∙ (λ i → predr (+ᴮ-comm n m i))
predl-+ᴮ : ∀ m n → (predl m) +ᴮ n ≡ predl (m +ᴮ n)
predl-+ᴮ m n = +ᴮ-comm (predl m) n ∙ (λ i → predl (+ᴮ-comm n m i))
-- +ᴮ-comm : ∀ m n → n +ᴮ m ≡ m +ᴮ n
-- +ᴮ-comm m zero = +ᴮ-unitˡ m
-- +ᴮ-comm m (suc n) = suc-+ᴮ n m ∙ cong suc (+ᴮ-comm m n)
-- +ᴮ-comm m (predr n) = predr-+ᴮ n m ∙ cong predr (+ᴮ-comm m n)
-- +ᴮ-comm m (predl n) = predl-+ᴮ n m ∙ cong predl (+ᴮ-comm m n)
-- +ᴮ-comm m (suc-predr n i) j = {!!}
-- +ᴮ-comm m (predl-suc n i) j = {!!}
-- negation / subtraction
-ᴮ_ : BiInvInt → BiInvInt
-ᴮ zero = zero
-ᴮ suc n = predl (-ᴮ n)
-ᴮ predr n = suc (-ᴮ n)
-ᴮ predl n = suc (-ᴮ n)
-ᴮ suc-predr n i = predl-suc (-ᴮ n) i
-ᴮ predl-suc n i = suc-predl (-ᴮ n) i
_-ᴮ_ : BiInvInt → BiInvInt → BiInvInt
m -ᴮ n = m +ᴮ (-ᴮ n)
-- TODO: properties of negation
-- +ᴮ-invˡ : ∀ n → (-ᴮ n) +ᴮ n ≡ zero
-- +ᴮ-invˡ zero = refl
-- +ᴮ-invˡ (suc n) = (λ i → suc (predl-+ᴮ (-ᴮ n) n i)) ∙ (λ i → suc-pred (+ᴮ-invˡ n i) i)
-- +ᴮ-invˡ (predr n) = (λ i → predr (suc-+ᴮ (-ᴮ n) n i)) ∙ (λ i → predr-suc (+ᴮ-invˡ n i) i)
-- +ᴮ-invˡ (predl n) = (λ i → predl (suc-+ᴮ (-ᴮ n) n i)) ∙ (λ i → predl-suc (+ᴮ-invˡ n i) i)
-- +ᴮ-invˡ (suc-predr n i) j = {!!}
-- +ᴮ-invˡ (predl-suc n i) j = {!!}
-- +ᴮ-invʳ : ∀ n → n +ᴮ (-ᴮ n) ≡ zero
-- +ᴮ-invʳ n = {!!}
-- natural injections from ℕ
posᴮ : ℕ → BiInvInt
posᴮ zero = zero
posᴮ (suc n) = suc (posᴮ n)
negᴮ : ℕ → BiInvInt
negᴮ zero = zero
negᴮ (suc n) = pred (negᴮ n)
-- absolute value and sign
-- (Note that there doesn't appear to be any way around using
-- bwd here! Any direct proof ends up doing the same work...)
absᴮ : BiInvInt → ℕ
absᴮ n = abs (bwd n)
sgnᴮ : BiInvInt → Bool
sgnᴮ n = sgn (bwd n)
-- TODO: a direct definition of multiplication using +ᴮ-invˡ/ʳ
-- (for now we use abs and sgn, as in agda's stdlib)
_*ᴮ_ : BiInvInt → BiInvInt → BiInvInt
m *ᴮ n = caseBool posᴮ negᴮ (sgnᴮ m and sgnᴮ n) (absᴮ m * absᴮ n)
-- m *ᴮ zero = zero
-- m *ᴮ suc n = (m *ᴮ n) +ᴮ m
-- m *ᴮ predr n = (m *ᴮ n) -ᴮ m
-- m *ᴮ predl n = (m *ᴮ n) -ᴮ m
-- m *ᴮ suc-predr n i = ( +ᴮ-assoc (m *ᴮ n) (-ᴮ m) m
-- ∙ cong ((m *ᴮ n) +ᴮ_) (+ᴮ-invˡ m)
-- ∙ +ᴮ-unitʳ (m *ᴮ n)) i
-- m *ᴮ predl-suc n i = ( +ᴮ-assoc (m *ᴮ n) m (-ᴮ m)
-- ∙ cong ((m *ᴮ n) +ᴮ_) (+ᴮ-invʳ m)
-- ∙ +ᴮ-unitʳ (m *ᴮ n)) i
| 34.013423
| 100
| 0.519732
|
358a48954ce55146b6e377989002c288ac2c6f7e
| 161
|
agda
|
Agda
|
test/Succeed/Issue2487-1.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | null | null | null |
test/Succeed/Issue2487-1.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | 6
|
2021-10-18T08:12:24.000Z
|
2021-11-24T08:31:10.000Z
|
test/Succeed/Issue2487-1.agda
|
antoinevanmuylder/agda
|
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
|
[
"BSD-2-Clause"
] | null | null | null |
{-# OPTIONS --safe --cubical-compatible --no-universe-polymorphism --no-sized-types --no-guardedness #-}
module Issue2487-1 where
import Issue2487.Coinfective
| 26.833333
| 104
| 0.757764
|
371bd65767e27d996f6c68a5c791dee5ac766c37
| 7,453
|
agda
|
Agda
|
src/System/IO/Transducers/Stateful.agda
|
ilya-fiveisky/agda-system-io
|
d06c219c7b7afc85aae3b1d4d66951b889aa7371
|
[
"MIT"
] | 10
|
2015-01-04T13:45:16.000Z
|
2021-09-15T04:35:41.000Z
|
src/System/IO/Transducers/Stateful.agda
|
ilya-fiveisky/agda-system-io
|
d06c219c7b7afc85aae3b1d4d66951b889aa7371
|
[
"MIT"
] | null | null | null |
src/System/IO/Transducers/Stateful.agda
|
ilya-fiveisky/agda-system-io
|
d06c219c7b7afc85aae3b1d4d66951b889aa7371
|
[
"MIT"
] | 2
|
2017-08-10T06:12:54.000Z
|
2022-03-12T11:40:23.000Z
|
open import Coinduction using ( ∞ ; ♭ ; ♯_ )
open import Data.Bool using ( Bool ; true ; false )
open import Data.Nat using ( ℕ ; zero ; suc )
open import Data.Natural using ( Natural ; # ; % ; _+_ )
open import Data.Strict using ( Strict ; ! )
open import System.IO.Transducers.List using ( S⊆S&*T )
open import System.IO.Transducers.Lazy using ( _⇒_ ; inp ; out ; done ; out* ; _[&]_ ; _⟫_ )
open import System.IO.Transducers.Session using ( I ; Σ ; ⟨_⟩ ; _&_ ; ¿ ; * ; _&*_ )
open import System.IO.Transducers.Trace using ( [] ; _∷_ ; _≤_ )
module System.IO.Transducers.Stateful where
-- We apply the usual state transformer construction
-- for a premonoial category: morphisms
-- from T to U with state S are just regular morphisms
-- from T & S to U & S.
-- We are particularly interested in the case where T is I
-- and S is Bytes, since this collapses to Bytes ⇒ U & Bytes,
-- that is, the type for a parser over a byte stream.
-- The type Bytes ⇒ U & Bytes (or more generally * ⟨ B ⟩ ⇒ U & * ⟨ B ⟩)
-- is the type of an iteratee returning U.
-- Lookahead.
-- Lookahead buffers up all input until some output is produced.
-- If the output is (just x), then we discard the buffer, and
-- continue with the process. If the output is nothing, then we
-- return the buffer to the output stream and discard the process.
lookahead¿' : ∀ {T S S'} → (S' ≤ S) → (S' ⇒ ¿ T & S) → (S' ⇒ ¿ T & S)
lookahead¿' {T} as (inp F) = inp (♯ λ a → lookahead¿' {T} (a ∷ as) (♭ F a))
lookahead¿' {T} as (out true P) = out true P
lookahead¿' {T} as (out false P) = out false (out* as done)
lookahead¿' {T} as (done) = inp (♯ λ a → lookahead¿' {T} (a ∷ as) (out a done))
lookahead¿ : ∀ {T S} → (S ⇒ ¿ T & S) → (S ⇒ ¿ T & S)
lookahead¿ {T} = lookahead¿' {T} []
lookahead*' : ∀ {T S S'} → (S' ≤ S) → (S' ⇒ * T & S) → (S' ⇒ * T & S)
lookahead*' {T} as (inp F) = inp (♯ λ a → lookahead*' {T} (a ∷ as) (♭ F a))
lookahead*' {T} as (out true P) = out true P
lookahead*' {T} as (out false P) = out false (out* as done)
lookahead*' {T} as (done) = inp (♯ λ a → lookahead*' {T} (a ∷ as) (out a done))
lookahead* : ∀ {T S} → (S ⇒ * T & S) → (S ⇒ * T & S)
lookahead* {T} = lookahead*' {T} []
-- Iteration structure.
-- Deep breath.
-- This is the trickiest bit of building a stateful transducer
-- library. The idea is to turn a stateful transducer generating
-- an optional U into a stateful transducer generating many Us.
-- We transform the transducer P into one which runs P, then
-- if P returns nothing, then loop P returns nothing and terminates, and
-- if P returns (just x), then loop P finishes running P, then runs loop P again.
-- For example, given a function nat? : ℤ → (Maybe ℕ) which
-- such that nat? n = nothing if n < 0 and just n otherwise,
-- we can define:
-- loop (lookahead (inp (♯ λ n → out (nat? n) done))) :
-- * ⟨ ℤ ⟩ ⇒ * ⟨ ℕ ⟩ & * ⟨ ℤ ⟩
-- This transducer will return the longest non-negative prefix
-- of its input, for example on input just 2 ∷ just 5 ∷ just -3 ∷ ...
-- it will produce output just 2 ∷ just 5 ∷ nothing ∷ just -3 ∷ ...
mutual
-- This is a remarkably obscure piece of code, given that all its doing is wiring...
-- The n : ℕ parameter is the induction scheme that gets it all to pass the
-- termination checker. When loop P is used properly, it is with a contracting
-- P, that is one which produces stricly fewer S tokens than it consumes.
-- Without the n parameter, loop P could produce infinite output if P isn't
-- contracting. For example loop (out (just x) done) would just produce the stream
-- (just x) ∷ (just x) ∷ ... without ever consuming any input. With the n parameter
-- we keep track of how many tokens have been consumed. If we ever hit
-- a loop where n==0, we just run P one last time, then terminate.
-- For example, loop (out (just x) done) just produces the trace (just x) ∷ [].
-- For efficiency, we also pass n around as a Natural, not just an ℕ. When we
-- read input a, we add the weight of a onto n, strictly (in order to
-- avoid potentially keeping a live), discard the previous ℕ and build a new ℕ.
-- It would be nice to have an induction scheme for Natural.
-- It would be a bit nicer to track statically which processes are contractions,
-- and only allow loop P on contraction maps.
-- Note that contractions come up in many contexts with treatments of recursion,
-- for example in Plotkin uniformity, they're called strict maps. They're
-- closely related to the notion of guarded recursion which is used in checking
-- productivity of coinductive functions in Agda.
-- TODO: Find a way to statically enforce contraction and non-expansion maps.
-- Or alternatively, give in and allow coinductive output,
-- and hence lose termination for transducers.
-- TODO: Present this as a trace structure? Show that
-- it has the expected properties on contracting morphisms.
-- loop''' 0 P Q R is equivant to P ⟫ Q ⟫ (done ⟨&⟩ loop R)
loop'''' : ∀ {T T' U S S'} → (Strict Natural) → (U ⇒ S) → (S ⇒ T' & S') → (S' ⇒ ¿ T & S') → (U ⇒ (T' &* T) & S')
loop'''' {T} {T'} (! n) P Q R = loop''' {T} {T'} (% n) n P Q R
loop''' : ∀ {T T' U S S'} → ℕ → Natural → (U ⇒ S) → (S ⇒ T' & S') → (S' ⇒ ¿ T & S') → (U ⇒ (T' &* T) & S')
loop''' {T} {I} m n P Q R = loop' {T} m n (P ⟫ Q) R R
loop''' {T} {Σ V F} {Σ W G} m n (inp P) (inp Q) R = inp (♯ λ a → loop'''' {T} {Σ V F} (! (n + W a)) (♭ P a) (inp Q) R)
loop''' {T} {Σ V F} m n (out a P) (inp Q) R = loop''' {T} {Σ V F} m n P (♭ Q a) R
loop''' {T} {Σ V F} {Σ W G} m n done (inp P) R = inp (♯ λ a → loop'''' {T} {Σ V F} (! (n + W a)) done (♭ P a) R)
loop''' {T} {Σ V F} m n P (out b Q) R = out b (loop''' {T} {♭ F b} m n P Q R)
loop''' {T} {Σ V F} {Σ W G} m n (inp P) done R = inp (♯ λ a → loop'''' {T} {Σ V F} (! (n + W a)) (♭ P a) done R)
loop''' {T} {Σ V F} m n (out a P) done R = out a (loop''' {T} {♭ F a} m n P done R)
loop''' {T} {Σ V F} m n done done R = inp (♯ λ a → out a (loop'''' {T} {♭ F a} (! (n + (V a))) done done R))
-- loop' 0 P Q R is equivalent to P ⟫ Q ⟫ loop R ⟨¿⟩ done
loop'' : ∀ {T U S S'} → (Strict Natural) → (U ⇒ S) → (S ⇒ ¿ T & S') → (S' ⇒ ¿ T & S') → (U ⇒ * T & S')
loop'' {T} (! n) P Q R = loop' {T} (% n) n P Q R
loop' : ∀ {T U S S'} → ℕ → Natural → (U ⇒ S) → (S ⇒ ¿ T & S') → (S' ⇒ ¿ T & S') → (U ⇒ * T & S')
loop' {T} {Σ V F} m n (inp P) (inp Q) R = inp (♯ λ a → loop'' {T} (! (n + V a)) (♭ P a) (inp Q) R)
loop' {T} m n (out a P) (inp Q) R = loop' {T} m n P (♭ Q a) R
loop' {T} {Σ V F} m n done (inp Q) R = inp (♯ λ a → loop'' {T} (! (n + V a)) done (♭ Q a) R)
loop' {T} zero n P (out true Q) R = out true (P ⟫ Q ⟫ S⊆S&*T {T} [&] done)
loop' {T} (suc m) n P (out true Q) R = out true (loop''' {T} {T} m n P Q R)
loop' {T} m n P (out false Q) R = out false (P ⟫ Q)
loop' {T} {Σ V F} m n (inp P) done R = inp (♯ λ a → loop'' {T} (! (n + V a)) (♭ P a) done R)
loop' {T} m n (out a P) done R = loop' {T} m n P (out a done) R
loop' {T} m n done done R = inp (♯ λ a → loop'' {T} (! (n + # 1)) done (out a done) R)
loop : ∀ {T S} → (S ⇒ ¿ T & S) → (S ⇒ * T & S)
loop {T} P = loop' {T} zero (# 0) done P P
| 54.007246
| 128
| 0.554139
|
30a1da5a26c251cb00dffa5d8bcbfbd70472354b
| 959
|
agda
|
Agda
|
Graphs/Complement.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Graphs/Complement.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Graphs/Complement.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Functions.Definition
open import Setoids.Setoids
open import Setoids.Subset
open import Graphs.Definition
open import Sets.EquivalenceRelations
module Graphs.Complement {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) where
open Graph G
open Setoid V
open Equivalence eq
complement : Graph (b ⊔ c) V
Graph._<->_ complement x y = ((x <-> y) → False) && ((x ∼ y) → False)
Graph.noSelfRelation complement x (pr1 ,, pr2) = pr2 reflexive
Graph.symmetric complement (x!-y ,, x!=y) = (λ pr → x!-y (Graph.symmetric G pr)) ,, λ pr → x!=y (Equivalence.symmetric eq pr)
Graph.wellDefined complement x=y r=s (x!-r ,, x!=r) = (λ y-s → x!-r (wellDefined (Equivalence.symmetric eq x=y) (Equivalence.symmetric eq r=s) y-s)) ,, λ y=s → x!=r (transitive x=y (transitive y=s (Equivalence.symmetric eq r=s)))
| 43.590909
| 229
| 0.687174
|
3792920bc6c7e6954b6992f1f8a654b8772dff17
| 894
|
agda
|
Agda
|
Cubical/Algebra/RingSolver/NatAsAlmostRing.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/RingSolver/NatAsAlmostRing.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/RingSolver/NatAsAlmostRing.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.RingSolver.NatAsAlmostRing where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat
open import Cubical.Algebra.RingSolver.AlmostRing
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.AbGroup
ℕAsAlmostRing : AlmostRing {ℓ-zero}
ℕAsAlmostRing = almostring ℕ 0 1 _+_ _·_ (λ n → n) (isalmostring
(ismonoid (issemigroup isSetℕ +-assoc) (λ n → (+-zero n) , refl))
(ismonoid (issemigroup isSetℕ ·-assoc) λ n → (·-identityʳ n) , (·-identityˡ n))
+-comm
·-comm
(λ k l n → sym (·-distribˡ k l n) )
(λ k l n → sym (·-distribʳ k l n))
(λ _ _ → refl) (λ _ _ → refl)
(λ _ → refl) λ x → sym (0≡m·0 x))
| 40.636364
| 99
| 0.5783
|
217444ea56b29d788c80f1502da1d7a864fce918
| 8,876
|
agda
|
Agda
|
Cubical/Experiments/EscardoSIP.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Experiments/EscardoSIP.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/EscardoSIP.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-
This is a rather literal translation of Martin Hötzel-Escardó's structure identity principle into cubical Agda. See
https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#sns
All the needed preliminary results from the lecture notes are stated and proven in this file.
It would be interesting to compare the proves with the one in Cubical.Foundations.SIP
-}
{-# OPTIONS --safe #-}
module Cubical.Experiments.EscardoSIP where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Univalence
open import Cubical.Data.Sigma.Properties
private
variable
ℓ ℓ' ℓ'' : Level
S : Type ℓ → Type ℓ'
-- We prove several useful equalities and equivalences between Σ-types all the proofs are taken from
-- Martin Hötzel-Escardó's lecture notes.
-- The next result is just a reformulation of pathSigma≡sigmaPath from Sigma.Properties.
Σ-≡-≃ : {X : Type ℓ} {A : X → Type ℓ'}
→ (σ τ : Σ X A) → ((σ ≡ τ) ≃ (Σ[ p ∈ (σ .fst) ≡ (τ .fst) ] (subst A p (σ .snd) ≡ (τ .snd))))
Σ-≡-≃ {A = A} σ τ = invEquiv (ΣPathTransport≃PathΣ σ τ)
-- This cubical proof is much shorter than in HoTT but requires that A, B live in the same universe.
Σ-cong : {X : Type ℓ} {A B : X → Type ℓ'} →
((x : X) → (A x ≡ B x)) → (Σ X A ≡ Σ X B)
Σ-cong {X = X} p i = Σ[ x ∈ X ] (p x i)
-- Two lemmas for the more general formulation using equivalences
NatΣ : {X : Type ℓ} {A : X → Type ℓ'} {B : X → Type ℓ''}
→ ((x : X) → (A x) → (B x)) → (Σ X A) → (Σ X B)
NatΣ τ (x , a) = (x , τ x a)
Σ-to-PathP : {X : Type ℓ} {A : X → Type ℓ'} {x : X} {a b : A x}
→ (a ≡ b) → PathP (λ i → Σ X A) (x , a) (x , b)
Σ-to-PathP {x = x} p i = (x , p i)
Σ-cong-≃ : {X : Type ℓ} {A : X → Type ℓ'} {B : X → Type ℓ''} →
((x : X) → (A x ≃ B x)) → (Σ X A ≃ Σ X B)
Σ-cong-≃ {X = X} {A = A} {B = B} φ = isoToEquiv (iso (NatΣ f) (NatΣ g) NatΣ-ε NatΣ-η)
where
f : (x : X) → (A x) → (B x)
f x = equivFun (φ x)
g : (x : X) → (B x) → (A x)
g x = equivFun (invEquiv (φ x))
η : (x : X) → (a : A x) → (g x) ((f x) a) ≡ a
η x = secEq (invEquiv (φ x))
ε : (x : X) → (b : B x) → f x (g x b) ≡ b
ε x = retEq (invEquiv (φ x))
NatΣ-η : (w : Σ X A) → NatΣ g (NatΣ f w) ≡ w
NatΣ-η (x , a) = (x , g x (f x a)) ≡⟨ Σ-to-PathP (η x a) ⟩
(x , a) ∎
NatΣ-ε : (u : Σ X B) → NatΣ f (NatΣ g u) ≡ u
NatΣ-ε (x , b) = (x , f x (g x b)) ≡⟨ Σ-to-PathP (ε x b) ⟩
(x , b) ∎
-- The next result is stated a bit awkwardly but is rather straightforward to prove.
Σ-change-of-variable-Iso : {X : Type ℓ} {Y : Type ℓ'} {A : Y → Type ℓ''} (f : X → Y)
→ (isHAEquiv f) → (Iso (Σ X (A ∘ f)) (Σ Y A))
Σ-change-of-variable-Iso {ℓ = ℓ} {ℓ' = ℓ'} {X = X} {Y = Y} {A = A} f isHAEquivf = iso φ ψ φψ ψφ
where
g : Y → X
g = isHAEquiv.g isHAEquivf
ε : (x : X) → (g (f x)) ≡ x
ε = isHAEquiv.linv isHAEquivf
η : (y : Y) → f (g y) ≡ y
η = isHAEquiv.rinv isHAEquivf
τ : (x : X) → cong f (ε x) ≡ η (f x)
τ = isHAEquiv.com isHAEquivf
φ : (Σ X (A ∘ f)) → (Σ Y A)
φ (x , a) = (f x , a)
ψ : (Σ Y A) → (Σ X (A ∘ f))
ψ (y , a) = (g y , subst A (sym (η y)) a)
φψ : (z : (Σ Y A)) → φ (ψ z) ≡ z
φψ (y , a) =
ΣPathTransport→PathΣ _ _ (η y , transportTransport⁻ (λ i → A (η y i)) a)
-- last term proves transp (λ i → A (η y i)) i0 (transp (λ i → A (η y (~ i))) i0 a) ≡ a
ψφ : (z : (Σ X (A ∘ f))) → ψ (φ z) ≡ z
ψφ (x , a) = ΣPathTransport→PathΣ _ _ (ε x , q)
where
b : A (f (g (f x)))
b = (transp (λ i → A (η (f x) (~ i))) i0 a)
q : transp (λ i → A (f (ε x i))) i0 (transp (λ i → A (η (f x) (~ i))) i0 a) ≡ a
q = transp (λ i → A (f (ε x i))) i0 b ≡⟨ i ⟩
transp (λ i → A (η (f x) i)) i0 b ≡⟨ transportTransport⁻ (λ i → A (η (f x) i)) a ⟩
a ∎
where
i : (transp (λ i → A (f (ε x i))) i0 b) ≡ (transp (λ i → A (η (f x) i)) i0 b)
i = subst (λ p → (transp (λ i → A (f (ε x i))) i0 b) ≡ (transp (λ i → A (p i)) i0 b))
(τ x) refl
-- Using the result above we can prove the following quite useful result.
Σ-change-of-variable-≃ : {X : Type ℓ} {Y : Type ℓ'} {A : Y → Type ℓ''} (f : X → Y)
→ (isEquiv f) → ((Σ X (A ∘ f)) ≃ (Σ Y A))
Σ-change-of-variable-≃ f isEquivf =
isoToEquiv (Σ-change-of-variable-Iso f (equiv→HAEquiv (f , isEquivf) .snd))
-- A structure is a type-family S : Type ℓ → Type ℓ', i.e. for X : Type ℓ and s : S X, the pair (X , s)
-- means that X is equipped with a S-structure, which is witnessed by s.
-- An S-structure should have a notion of S-homomorphism, or rather S-isomorphism.
-- This will be implemented by a function ι
-- that gives us for any two types with S-structure (X , s) and (Y , t) a family:
-- ι (X , s) (Y , t) : (X ≃ Y) → Type ℓ''
-- Note that for any equivalence (f , e) : X ≃ Y the type ι (X , s) (Y , t) (f , e) need not to be
-- a proposition. Indeed this type should correspond to the ways s and t can be identified
-- as S-structures. This we call a standard notion of structure.
SNS : (S : Type ℓ → Type ℓ') (ι : StrEquiv S ℓ'') → Type (ℓ-max (ℓ-max (ℓ-suc ℓ) ℓ') ℓ'')
SNS {ℓ = ℓ} S ι = ∀ {X : (Type ℓ)} (s t : S X) → ((s ≡ t) ≃ ι (X , s) (X , t) (idEquiv X))
-- Escardo's ρ can actually be defined from this:
ρ : {ι : StrEquiv S ℓ''} (θ : SNS S ι) (A : TypeWithStr ℓ S) → (ι A A (idEquiv (typ A)))
ρ θ A = equivFun (θ (str A) (str A)) refl
-- We introduce the notation a bit differently:
_≃[_]_ : (A : TypeWithStr ℓ S) (ι : StrEquiv S ℓ'') (B : TypeWithStr ℓ S) → (Type (ℓ-max ℓ ℓ''))
A ≃[ ι ] B = Σ[ f ∈ ((typ A) ≃ (typ B)) ] (ι A B f)
Id→homEq : (S : Type ℓ → Type ℓ') (ι : StrEquiv S ℓ'')
→ (ρ : (A : TypeWithStr ℓ S) → ι A A (idEquiv (typ A)))
→ (A B : TypeWithStr ℓ S) → A ≡ B → (A ≃[ ι ] B)
Id→homEq S ι ρ A B p = J (λ y x → A ≃[ ι ] y) (idEquiv (typ A) , ρ A) p
-- Use a PathP version of Escardó's homomorphism-lemma
hom-lemma-dep : (S : Type ℓ → Type ℓ') (ι : StrEquiv S ℓ'') (θ : SNS S ι)
→ (A B : TypeWithStr ℓ S)
→ (p : (typ A) ≡ (typ B))
→ (PathP (λ i → S (p i)) (str A) (str B)) ≃ (ι A B (pathToEquiv p))
hom-lemma-dep S ι θ A B p = (J P (λ s → γ s) p) (str B)
where
P = (λ y x → (s : S y) → PathP (λ i → S (x i)) (str A) s ≃ ι A (y , s) (pathToEquiv x))
γ : (s : S (typ A)) → ((str A) ≡ s) ≃ ι A ((typ A) , s) (pathToEquiv refl)
γ s = subst (λ f → ((str A) ≡ s) ≃ ι A ((typ A) , s) f) (sym pathToEquivRefl) (θ (str A) s)
-- Define the inverse of Id→homEq directly.
ua-lemma : (A B : Type ℓ) (e : A ≃ B) → (pathToEquiv (ua e)) ≡ e
ua-lemma A B e = EquivJ (λ A f → (pathToEquiv (ua f)) ≡ f)
(subst (λ r → pathToEquiv r ≡ idEquiv B) (sym uaIdEquiv) pathToEquivRefl)
e
homEq→Id : (S : Type ℓ → Type ℓ') (ι : StrEquiv S ℓ'') (θ : SNS S ι)
→ (A B : TypeWithStr ℓ S) → (A ≃[ ι ] B) → A ≡ B
homEq→Id S ι θ A B (f , φ) = ΣPathP (p , q)
where
p = ua f
ψ : ι A B (pathToEquiv p)
ψ = subst (λ g → ι A B g) (sym (ua-lemma (typ A) (typ B) f)) φ
q : PathP (λ i → S (p i)) (str A) (str B)
q = equivFun (invEquiv (hom-lemma-dep S ι θ A B p)) ψ
-- Proof of the SIP:
SIP : (S : Type ℓ → Type ℓ') (ι : StrEquiv S ℓ'') (θ : SNS S ι)
→ (A B : TypeWithStr ℓ S) → ((A ≡ B) ≃ (A ≃[ ι ] B))
SIP S ι θ A B =
(A ≡ B) ≃⟨ i ⟩
(Σ[ p ∈ (typ A) ≡ (typ B) ] PathP (λ i → S (p i)) (str A) (str B)) ≃⟨ ii ⟩
(Σ[ p ∈ (typ A) ≡ (typ B) ] (ι A B (pathToEquiv p))) ≃⟨ iii ⟩
(A ≃[ ι ] B) ■
where
i = invEquiv ΣPath≃PathΣ
ii = Σ-cong-≃ (hom-lemma-dep S ι θ A B)
iii = Σ-change-of-variable-≃ pathToEquiv (equivIsEquiv univalence)
-- A simple example: pointed types
pointed-structure : Type ℓ → Type ℓ
pointed-structure X = X
Pointed-Type : Type (ℓ-suc ℓ)
Pointed-Type {ℓ = ℓ} = Σ (Type ℓ) pointed-structure
pointed-ι : (A B : Pointed-Type) → (A .fst) ≃ (B. fst) → Type ℓ
pointed-ι (X , x) (Y , y) f = (equivFun f) x ≡ y
pointed-is-sns : SNS {ℓ = ℓ} pointed-structure pointed-ι
pointed-is-sns s t = idEquiv (s ≡ t)
pointed-type-sip : (X Y : Type ℓ) (x : X) (y : Y)
→ (Σ[ f ∈ X ≃ Y ] (f .fst) x ≡ y) ≃ ((X , x) ≡ (Y , y))
pointed-type-sip X Y x y = invEquiv (SIP pointed-structure pointed-ι pointed-is-sns (X , x) (Y , y))
| 39.448889
| 115
| 0.509238
|
7ca3fab3c3da3daf66884841040b11e5455068ba
| 678
|
agda
|
Agda
|
test/Succeed/Issue1209-4.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1209-4.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1209-4.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- A variant of code reported by Andreas Abel (who suggested that this
-- way to trigger the bug might have been due to NAD).
{-# OPTIONS --guardedness --sized-types #-}
open import Agda.Builtin.Sigma
open import Agda.Builtin.Size
data ⊥ : Set where
record Delay (A : Set) : Set where
coinductive
constructor ♯
field ♭ : Σ A λ _ → ⊥ → Delay A
-- Recursive in order to please the termination checker.
open Delay
data D : Size → Set where
inn : ∀ i → Delay (D i) → D (↑ i)
iter : ∀{i} → D i → ⊥
iter (inn i t) = iter (fst (♭ t))
-- Should be rejected by the termination checker.
bla : Delay (D ∞)
♭ bla = inn ∞ bla , λ()
false : ⊥
false = iter (fst (♭ bla))
| 21.1875
| 70
| 0.635693
|
3762f22361bcacb2502e5b34fe92814753bb52e0
| 1,679
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Codata/Delay/Categorical.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/Codata/Delay/Categorical.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Codata/Delay/Categorical.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- A categorical view of Delay
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Delay.Categorical where
open import Codata.Delay
open import Function
open import Category.Functor
open import Category.Applicative
open import Category.Monad
open import Data.These using (leftMost)
functor : ∀ {i ℓ} → RawFunctor {ℓ} (λ A → Delay A i)
functor = record { _<$>_ = λ f → map f }
module Sequential where
applicative : ∀ {i ℓ} → RawApplicative {ℓ} (λ A → Delay A i)
applicative = record
{ pure = now
; _⊛_ = λ df da → bind df (λ f → map f da)
}
applicativeZero : ∀ {i ℓ} → RawApplicativeZero {ℓ} (λ A → Delay A i)
applicativeZero = record
{ applicative = applicative
; ∅ = never
}
monad : ∀ {i ℓ} → RawMonad {ℓ} (λ A → Delay A i)
monad = record
{ return = now
; _>>=_ = bind
}
monadZero : ∀ {i ℓ} → RawMonadZero {ℓ} (λ A → Delay A i)
monadZero = record
{ monad = monad
; applicativeZero = applicativeZero
}
module Zippy where
applicative : ∀ {i ℓ} → RawApplicative {ℓ} (λ A → Delay A i)
applicative = record
{ pure = now
; _⊛_ = zipWith id
}
applicativeZero : ∀ {i ℓ} → RawApplicativeZero {ℓ} (λ A → Delay A i)
applicativeZero = record
{ applicative = applicative
; ∅ = never
}
alternative : ∀ {i ℓ} → RawAlternative {ℓ} (λ A → Delay A i)
alternative = record
{ applicativeZero = applicativeZero
; _∣_ = alignWith leftMost
}
| 25.439394
| 72
| 0.550328
|
1d8f88719cd4918b54ee4cbc4cc38ef920c2392d
| 2,798
|
agda
|
Agda
|
src/Categories/Diagram/Equalizer.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
src/Categories/Diagram/Equalizer.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | null | null | null |
src/Categories/Diagram/Equalizer.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core using (Category)
-- Equalizers in a Category C
module Categories.Diagram.Equalizer {o ℓ e} (C : Category o ℓ e) where
open Category C
open HomReasoning
open Equiv
open import Level
open import Data.Product as Σ
open import Function using (_$_)
open import Categories.Morphism C
open import Categories.Morphism.Reasoning C
private
variable
A B X : Obj
h i j k : A ⇒ B
record Equalizer (f g : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where
field
{obj} : Obj
arr : obj ⇒ A
equality : f ∘ arr ≈ g ∘ arr
equalize : ∀ {h : X ⇒ A} → f ∘ h ≈ g ∘ h → X ⇒ obj
universal : ∀ {eq : f ∘ h ≈ g ∘ h} → h ≈ arr ∘ equalize eq
unique : ∀ {eq : f ∘ h ≈ g ∘ h} → h ≈ arr ∘ i → i ≈ equalize eq
unique′ : (eq eq′ : f ∘ h ≈ g ∘ h) → equalize eq ≈ equalize eq′
unique′ eq eq′ = unique universal
id-equalize : id ≈ equalize equality
id-equalize = unique (sym identityʳ)
equalize-resp-≈ : ∀ {eq : f ∘ h ≈ g ∘ h} {eq′ : f ∘ i ≈ g ∘ i} →
h ≈ i → equalize eq ≈ equalize eq′
equalize-resp-≈ {h = h} {i = i} {eq = eq} {eq′ = eq′} h≈i = unique $ begin
i ≈˘⟨ h≈i ⟩
h ≈⟨ universal ⟩
arr ∘ equalize eq ∎
equalize-resp-≈′ : (eq : f ∘ h ≈ g ∘ h) → (eq′ : f ∘ i ≈ g ∘ i) →
h ≈ i → j ≈ equalize eq → k ≈ equalize eq′ → j ≈ k
equalize-resp-≈′ {j = j} {k = k} eq eq′ h≈i eqj eqk = begin
j ≈⟨ eqj ⟩
equalize eq ≈⟨ equalize-resp-≈ h≈i ⟩
equalize eq′ ≈˘⟨ eqk ⟩
k ∎
equality-∘ : f ∘ arr ∘ h ≈ g ∘ arr ∘ h
equality-∘ {h = h} = begin
f ∘ arr ∘ h ≈⟨ pullˡ equality ⟩
(g ∘ arr) ∘ h ≈⟨ assoc ⟩
g ∘ arr ∘ h ∎
unique-diagram : arr ∘ h ≈ arr ∘ i → h ≈ i
unique-diagram {h = h} {i = i} eq = begin
h ≈⟨ unique (sym eq) ⟩
equalize (extendʳ equality) ≈˘⟨ unique refl ⟩
i ∎
Equalizer⇒Mono : (e : Equalizer h i) → Mono (Equalizer.arr e)
Equalizer⇒Mono e f g eq =
equalize-resp-≈′ equality-∘ equality-∘ eq (unique refl) (unique refl)
where open Equalizer e
up-to-iso : (e₁ e₂ : Equalizer h i) → Equalizer.obj e₁ ≅ Equalizer.obj e₂
up-to-iso e₁ e₂ = record
{ from = repack e₁ e₂
; to = repack e₂ e₁
; iso = record
{ isoˡ = repack-cancel e₂ e₁
; isoʳ = repack-cancel e₁ e₂
}
}
where
open Equalizer
repack : (e₁ e₂ : Equalizer h i) → obj e₁ ⇒ obj e₂
repack e₁ e₂ = equalize e₂ (equality e₁)
repack∘ : (e₁ e₂ e₃ : Equalizer h i) → repack e₂ e₃ ∘ repack e₁ e₂ ≈ repack e₁ e₃
repack∘ e₁ e₂ e₃ = unique e₃ (⟺ (glueTrianglesʳ (⟺ (universal e₃)) (⟺ (universal e₂))))
repack-cancel : (e₁ e₂ : Equalizer h i) → repack e₁ e₂ ∘ repack e₂ e₁ ≈ id
repack-cancel e₁ e₂ = repack∘ e₂ e₁ e₂ ○ ⟺ (id-equalize e₂)
| 31.088889
| 91
| 0.546819
|
7c7d0a612997c647b0976ae4ed20f6e1bdf06798
| 485
|
agda
|
Agda
|
lib/types/Join.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
lib/types/Join.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
lib/types/Join.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Sigma
open import lib.types.Span
open import lib.types.Pointed
open import lib.types.Pushout
module lib.types.Join where
module _ {i j} (A : Type i) (B : Type j) where
*-span : Span
*-span = span A B (A × B) fst snd
_*_ : Type _
_*_ = Pushout *-span
module _ {i j} (X : Ptd i) (Y : Ptd j) where
*-⊙span : ⊙Span
*-⊙span = ⊙span X Y (X ⊙× Y) ⊙fst ⊙snd
_⊙*_ : Ptd _
_⊙*_ = ⊙Pushout *-⊙span
| 18.653846
| 46
| 0.604124
|
13a8c13c72868a81b07f982ea13ff9aa39483c45
| 2,241
|
agda
|
Agda
|
typed-elaboration.agda
|
hazelgrove/hazelnut-dynamics-agda
|
229dfb06ea51ebe91cb3b1c973c2f2792e66797c
|
[
"MIT"
] | 16
|
2018-03-12T14:32:03.000Z
|
2021-12-19T02:50:23.000Z
|
typed-elaboration.agda
|
hazelgrove/hazelnut-dynamics-agda
|
229dfb06ea51ebe91cb3b1c973c2f2792e66797c
|
[
"MIT"
] | 54
|
2017-06-29T20:53:34.000Z
|
2018-11-29T16:32:40.000Z
|
typed-elaboration.agda
|
hazelgrove/hazelnut-dynamics-agda
|
229dfb06ea51ebe91cb3b1c973c2f2792e66797c
|
[
"MIT"
] | 1
|
2019-09-13T18:20:02.000Z
|
2019-09-13T18:20:02.000Z
|
open import Nat
open import Prelude
open import core
open import contexts
open import lemmas-consistency
open import lemmas-disjointness
open import weakening
module typed-elaboration where
mutual
typed-elaboration-synth : {Γ : tctx} {e : hexp} {τ : htyp} {d : ihexp} {Δ : hctx} →
Γ ⊢ e ⇒ τ ~> d ⊣ Δ →
Δ , Γ ⊢ d :: τ
typed-elaboration-synth ESConst = TAConst
typed-elaboration-synth (ESVar x₁) = TAVar x₁
typed-elaboration-synth (ESLam x₁ ex) = TALam x₁ (typed-elaboration-synth ex)
typed-elaboration-synth (ESAp {Δ1 = Δ1} _ d x₁ x₂ x₃ x₄)
with typed-elaboration-ana x₃ | typed-elaboration-ana x₄
... | con1 , ih1 | con2 , ih2 = TAAp (TACast (weaken-ta-Δ1 d ih1) con1) (TACast (weaken-ta-Δ2 {Δ1 = Δ1} d ih2) con2)
typed-elaboration-synth (ESEHole {Γ = Γ} {u = u}) = TAEHole (ctx-top ∅ u (Γ , ⦇-⦈) refl)(STAId (λ x τ z → z))
typed-elaboration-synth (ESNEHole {Γ = Γ} {τ = τ} {u = u} {Δ = Δ} (d1 , d2) ex)
with typed-elaboration-synth ex
... | ih1 = TANEHole {Δ = Δ ,, (u , Γ , ⦇-⦈)} (ctx-top Δ u (Γ , ⦇-⦈) (d2 u (lem-domsingle _ _))) (weaken-ta-Δ1 (d1 , d2) ih1)(STAId (λ x τ₁ z → z))
typed-elaboration-synth (ESAsc x)
with typed-elaboration-ana x
... | con , ih = TACast ih con
typed-elaboration-ana : {Γ : tctx} {e : hexp} {τ τ' : htyp} {d : ihexp} {Δ : hctx} →
Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ →
(τ' ~ τ) × (Δ , Γ ⊢ d :: τ')
typed-elaboration-ana (EALam x₁ MAHole ex)
with typed-elaboration-ana ex
... | con , D = TCHole1 , TALam x₁ D
typed-elaboration-ana (EALam x₁ MAArr ex)
with typed-elaboration-ana ex
... | con , D = TCArr TCRefl con , TALam x₁ D
typed-elaboration-ana (EASubsume x x₁ x₂ x₃) = ~sym x₃ , typed-elaboration-synth x₂
typed-elaboration-ana (EAEHole {Γ = Γ} {u = u}) = TCRefl , TAEHole (ctx-top ∅ u (Γ , _) refl) (STAId (λ x τ z → z))
typed-elaboration-ana (EANEHole {Γ = Γ} {u = u} {τ = τ} {Δ = Δ} (d1 , d2) x)
with typed-elaboration-synth x
... | ih1 = TCRefl , TANEHole {Δ = Δ ,, (u , Γ , τ)} (ctx-top Δ u (Γ , τ) (d2 u (lem-domsingle _ _)) ) (weaken-ta-Δ1 (d1 , d2) ih1) (STAId (λ x₁ τ₁ z → z))
| 53.357143
| 159
| 0.566711
|
301b58d42e81b5aa3ddafc5fbc7db235ce4eddbc
| 1,698
|
agda
|
Agda
|
src/options-main.agda
|
xoltar/cedille
|
acf691e37210607d028f4b19f98ec26c4353bfb5
|
[
"MIT"
] | null | null | null |
src/options-main.agda
|
xoltar/cedille
|
acf691e37210607d028f4b19f98ec26c4353bfb5
|
[
"MIT"
] | null | null | null |
src/options-main.agda
|
xoltar/cedille
|
acf691e37210607d028f4b19f98ec26c4353bfb5
|
[
"MIT"
] | null | null | null |
module options-main where
import parse
open import lib
open import options-types
import options
module parsem = parse options.gratr2-nt ptr
open parsem
open parsem.pnoderiv options.rrs options.options-rtn
open import run ptr
open noderiv {- from run.agda -}
process-start : start → string
process-start s = ""
process : Run → string
process (ParseTree (parsed-start p) :: []) = process-start p
process r = "Parsing failure (run with -" ^ "-showParsed).\n"
putStrRunIf : 𝔹 → Run → IO ⊤
putStrRunIf tt r = putStr (Run-to-string r) >> putStr "\n"
putStrRunIf ff r = return triv
processArgs : (showRun : 𝔹) → (showParsed : 𝔹) → 𝕃 string → IO ⊤
processArgs showRun showParsed (input-filename :: []) = (readFiniteFile input-filename) >>= processText
where processText : string → IO ⊤
processText x with runRtn (string-to-𝕃char x)
processText x | s with s
processText x | s | inj₁ cs = putStr "Characters left before failure : " >> putStr (𝕃char-to-string cs) >> putStr "\nCannot proceed to parsing.\n"
processText x | s | inj₂ r with putStrRunIf showRun r | rewriteRun r
processText x | s | inj₂ r | sr | r' with putStrRunIf showParsed r'
processText x | s | inj₂ r | sr | r' | sr' = sr >> sr' >> putStr (process r')
processArgs showRun showParsed ("--showRun" :: xs) = processArgs tt showParsed xs
processArgs showRun showParsed ("--showParsed" :: xs) = processArgs showRun tt xs
processArgs showRun showParsed (x :: xs) = putStr ("Unknown option " ^ x ^ "\n")
processArgs showRun showParsed [] = putStr "Please run with the name of a file to process.\n"
main : IO ⊤
main = getArgs >>= processArgs ff ff
| 39.488372
| 154
| 0.671378
|
1b202986808d0d0b17245dc46b6961338573e3de
| 889
|
agda
|
Agda
|
test/Succeed/Issue4880.agda
|
LaloHao/agda
|
7de768bb7bc65dbe1efa35c699cfa8b8f9510573
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue4880.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue4880.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2020-09-09, issue #4880
-- Parse all interleavings of hiding and irrelevance in non-dependent function space
module Issue4880 (A B : Set) where
postulate
-- dependent
-- * visible
_ : A → (_ : B) → A
_ : A → .(_ : B) → A
_ : A → ..(_ : B) → A
-- * hidden
_ : A → {_ : B} → A
_ : A → .{_ : B} → A
_ : A → ..{_ : B} → A
-- * instance
_ : A → ⦃ _ : B ⦄ → A
_ : A → .⦃ _ : B ⦄ → A
_ : A → ..⦃ _ : B ⦄ → A
-- non-dependent
-- * visible
_ : A → B → A
_ : A → .B → A
_ : A → ..B → A
-- * visible, parenthesized
_ : A → .(B) → A
_ : A → ..(B) → A
_ : A → (.B) → A
_ : A → (..B) → A
-- * hidden
_ : A → {B} → A
_ : A → .{B} → A
_ : A → ..{B} → A
_ : A → {.B} → A
_ : A → {..B} → A
-- * instance
_ : A → ⦃ B ⦄ → A
_ : A → .⦃ B ⦄ → A
_ : A → ..⦃ B ⦄ → A
_ : A → ⦃ .B ⦄ → A
_ : A → ⦃ ..B ⦄ → A
| 20.674419
| 84
| 0.364454
|
377880bd1da9db89db9b253ce537d053f40358bd
| 2,269
|
agda
|
Agda
|
agda-stdlib/src/Relation/Binary/Properties/TotalOrder.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Relation/Binary/Properties/TotalOrder.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Relation/Binary/Properties/TotalOrder.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties satisfied by total orders
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Relation.Binary.Properties.TotalOrder
{t₁ t₂ t₃} (T : TotalOrder t₁ t₂ t₃) where
open TotalOrder T
open import Data.Sum.Base using (inj₁; inj₂)
import Relation.Binary.Construct.Converse as Converse
import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict
import Relation.Binary.Properties.Poset poset as PosetProperties
open import Relation.Binary.Consequences
open import Relation.Nullary using (¬_)
open import Relation.Nullary.Negation using (contradiction)
------------------------------------------------------------------------
-- Total orders are almost decidable total orders
decTotalOrder : Decidable _≈_ → DecTotalOrder _ _ _
decTotalOrder ≟ = record
{ isDecTotalOrder = record
{ isTotalOrder = isTotalOrder
; _≟_ = ≟
; _≤?_ = total+dec⟶dec reflexive antisym total ≟
}
}
------------------------------------------------------------------------
-- _≥_ - the flipped relation is also a total order
open PosetProperties public
using
( _≥_
; ≥-refl
; ≥-reflexive
; ≥-trans
; ≥-antisym
; ≥-isPreorder
; ≥-isPartialOrder
; ≥-preorder
; ≥-poset
)
≥-isTotalOrder : IsTotalOrder _≈_ _≥_
≥-isTotalOrder = Converse.isTotalOrder isTotalOrder
≥-totalOrder : TotalOrder _ _ _
≥-totalOrder = record
{ isTotalOrder = ≥-isTotalOrder
}
open TotalOrder ≥-totalOrder public
using () renaming (total to ≥-total)
------------------------------------------------------------------------
-- _<_ - the strict version is a strict partial order
-- Note that total orders can NOT be turned into strict total orders as
-- in order to distinguish between the _≤_ and _<_ cases we must have
-- decidable equality _≈_.
open PosetProperties public
using
( _<_
; <-resp-≈
; <-respʳ-≈
; <-respˡ-≈
; <-irrefl
; <-asym
; <-trans
; <-isStrictPartialOrder
; <-strictPartialOrder
; <⇒≉
; ≤∧≉⇒<
; <⇒≱
; ≤⇒≯
)
≰⇒> : ∀ {x y} → ¬ (x ≤ y) → y < x
≰⇒> = ToStrict.≰⇒> Eq.sym reflexive total
| 25.494382
| 72
| 0.570736
|
219a1d1e330eb2b563e041a9ba404341efb25a32
| 6,004
|
agda
|
Agda
|
agda-stdlib/src/Data/Integer/Divisibility/Signed.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Integer/Divisibility/Signed.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Integer/Divisibility/Signed.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Alternative definition of divisibility without using modulus.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Integer.Divisibility.Signed where
open import Function
open import Data.Integer.Base
open import Data.Integer.Properties
open import Data.Integer.Divisibility as Unsigned
using (divides)
renaming (_∣_ to _∣ᵤ_)
import Data.Nat.Base as ℕ
import Data.Nat.Divisibility as ℕ
import Data.Nat.Coprimality as ℕ
import Data.Nat.Properties as ℕ
import Data.Sign as S
import Data.Sign.Properties as SProp
open import Level
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
import Relation.Binary.Reasoning.Preorder as PreorderReasoning
open import Relation.Nullary using (yes; no)
import Relation.Nullary.Decidable as DEC
------------------------------------------------------------------------
-- Type
infix 4 _∣_
record _∣_ (k z : ℤ) : Set where
constructor divides
field quotient : ℤ
equality : z ≡ quotient * k
open _∣_ using (quotient) public
------------------------------------------------------------------------
-- Conversion between signed and unsigned divisibility
∣ᵤ⇒∣ : ∀ {k i} → k ∣ᵤ i → k ∣ i
∣ᵤ⇒∣ {k} {i} (divides 0 eq) = divides (+ 0) (∣n∣≡0⇒n≡0 eq)
∣ᵤ⇒∣ {k} {i} (divides q@(ℕ.suc q') eq) with k ≟ + 0
... | yes refl = divides (+ 0) (∣n∣≡0⇒n≡0 (trans eq (ℕ.*-zeroʳ q)))
... | no ¬k≠0 = divides ((S._*_ on sign) i k ◃ q) (◃-≡ sign-eq abs-eq) where
k' = ℕ.suc (ℕ.pred ∣ k ∣)
ikq' = sign i S.* sign k ◃ ℕ.suc q'
sign-eq : sign i ≡ sign (((S._*_ on sign) i k ◃ q) * k)
sign-eq = sym $ begin
sign (((S._*_ on sign) i k ◃ ℕ.suc q') * k)
≡⟨ cong (λ m → sign (sign ikq' S.* sign k ◃ ∣ ikq' ∣ ℕ.* m))
(sym (ℕ.suc[pred[n]]≡n (¬k≠0 ∘ ∣n∣≡0⇒n≡0))) ⟩
sign (sign ikq' S.* sign k ◃ ∣ ikq' ∣ ℕ.* k')
≡⟨ cong (λ m → sign (sign ikq' S.* sign k ◃ m ℕ.* k'))
(abs-◃ (sign i S.* sign k) (ℕ.suc q')) ⟩
sign (sign ikq' S.* sign k ◃ _)
≡⟨ sign-◃ (sign ikq' S.* sign k) (ℕ.pred ∣ k ∣ ℕ.+ q' ℕ.* k') ⟩
sign ikq' S.* sign k
≡⟨ cong (S._* sign k) (sign-◃ (sign i S.* sign k) q') ⟩
sign i S.* sign k S.* sign k
≡⟨ SProp.*-assoc (sign i) (sign k) (sign k) ⟩
sign i S.* (sign k S.* sign k)
≡⟨ cong (sign i S.*_) (SProp.s*s≡+ (sign k)) ⟩
sign i S.* S.+
≡⟨ SProp.*-identityʳ (sign i) ⟩
sign i
∎ where open ≡-Reasoning
abs-eq : ∣ i ∣ ≡ ∣ ((S._*_ on sign) i k ◃ q) * k ∣
abs-eq = sym $ begin
∣ ((S._*_ on sign) i k ◃ ℕ.suc q') * k ∣
≡⟨ abs-◃ (sign ikq' S.* sign k) (∣ ikq' ∣ ℕ.* ∣ k ∣) ⟩
∣ ikq' ∣ ℕ.* ∣ k ∣
≡⟨ cong (ℕ._* ∣ k ∣) (abs-◃ (sign i S.* sign k) (ℕ.suc q')) ⟩
ℕ.suc q' ℕ.* ∣ k ∣
≡⟨ sym eq ⟩
∣ i ∣
∎ where open ≡-Reasoning
∣⇒∣ᵤ : ∀ {k i} → k ∣ i → k ∣ᵤ i
∣⇒∣ᵤ {k} {i} (divides q eq) = divides ∣ q ∣ $′ begin
∣ i ∣ ≡⟨ cong ∣_∣ eq ⟩
∣ q * k ∣ ≡⟨ abs-*-commute q k ⟩
∣ q ∣ ℕ.* ∣ k ∣ ∎ where open ≡-Reasoning
------------------------------------------------------------------------
-- _∣_ is a preorder
∣-refl : Reflexive _∣_
∣-refl = ∣ᵤ⇒∣ ℕ.∣-refl
∣-reflexive : _≡_ ⇒ _∣_
∣-reflexive refl = ∣-refl
∣-trans : Transitive _∣_
∣-trans i∣j j∣k = ∣ᵤ⇒∣ (ℕ.∣-trans (∣⇒∣ᵤ i∣j) (∣⇒∣ᵤ j∣k))
∣-isPreorder : IsPreorder _≡_ _∣_
∣-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ∣-reflexive
; trans = ∣-trans
}
∣-preorder : Preorder _ _ _
∣-preorder = record { isPreorder = ∣-isPreorder }
------------------------------------------------------------------------
-- Divisibility reasoning
module ∣-Reasoning where
private
module Base = PreorderReasoning ∣-preorder
open Base public
hiding (step-∼; step-≈; step-≈˘)
infixr 2 step-∣
step-∣ = Base.step-∼
syntax step-∣ x y∣z x∣y = x ∣⟨ x∣y ⟩ y∣z
------------------------------------------------------------------------
-- Other properties of _∣_
_∣?_ : Decidable _∣_
k ∣? m = DEC.map′ ∣ᵤ⇒∣ ∣⇒∣ᵤ (∣ k ∣ ℕ.∣? ∣ m ∣)
0∣⇒≡0 : ∀ {m} → + 0 ∣ m → m ≡ + 0
0∣⇒≡0 0|m = ∣n∣≡0⇒n≡0 (ℕ.0∣⇒≡0 (∣⇒∣ᵤ 0|m))
m∣∣m∣ : ∀ {m} → m ∣ (+ ∣ m ∣)
m∣∣m∣ = ∣ᵤ⇒∣ ℕ.∣-refl
∣m∣∣m : ∀ {m} → (+ ∣ m ∣) ∣ m
∣m∣∣m = ∣ᵤ⇒∣ ℕ.∣-refl
∣m∣n⇒∣m+n : ∀ {i m n} → i ∣ m → i ∣ n → i ∣ m + n
∣m∣n⇒∣m+n (divides q refl) (divides p refl) =
divides (q + p) (sym (*-distribʳ-+ _ q p))
∣m⇒∣-m : ∀ {i m} → i ∣ m → i ∣ - m
∣m⇒∣-m {i} {m} i∣m = ∣ᵤ⇒∣ $′ begin
∣ i ∣ ∣⟨ ∣⇒∣ᵤ i∣m ⟩
∣ m ∣ ≡⟨ sym (∣-n∣≡∣n∣ m) ⟩
∣ - m ∣ ∎
where open ℕ.∣-Reasoning
∣m∣n⇒∣m-n : ∀ {i m n} → i ∣ m → i ∣ n → i ∣ m - n
∣m∣n⇒∣m-n i∣m i∣n = ∣m∣n⇒∣m+n i∣m (∣m⇒∣-m i∣n)
∣m+n∣m⇒∣n : ∀ {i m n} → i ∣ m + n → i ∣ m → i ∣ n
∣m+n∣m⇒∣n {i} {m} {n} i∣m+n i∣m = begin
i ∣⟨ ∣m∣n⇒∣m-n i∣m+n i∣m ⟩
m + n - m ≡⟨ +-comm (m + n) (- m) ⟩
- m + (m + n) ≡⟨ sym (+-assoc (- m) m n) ⟩
- m + m + n ≡⟨ cong (_+ n) (+-inverseˡ m) ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎
where open ∣-Reasoning
∣m+n∣n⇒∣m : ∀ {i m n} → i ∣ m + n → i ∣ n → i ∣ m
∣m+n∣n⇒∣m {i} {m} {n} i|m+n i|n
rewrite +-comm m n
= ∣m+n∣m⇒∣n i|m+n i|n
∣n⇒∣m*n : ∀ {i} m {n} → i ∣ n → i ∣ m * n
∣n⇒∣m*n {i} m {n} (divides q eq) = divides (m * q) $′ begin
m * n ≡⟨ cong (m *_) eq ⟩
m * (q * i) ≡⟨ sym (*-assoc m q i) ⟩
m * q * i ∎
where open ≡-Reasoning
∣m⇒∣m*n : ∀ {i m} n → i ∣ m → i ∣ m * n
∣m⇒∣m*n {i} {m} n i|m
rewrite *-comm m n
= ∣n⇒∣m*n {i} n {m} i|m
*-monoʳ-∣ : ∀ k → (k *_) Preserves _∣_ ⟶ _∣_
*-monoʳ-∣ k i∣j = ∣ᵤ⇒∣ (Unsigned.*-monoʳ-∣ k (∣⇒∣ᵤ i∣j))
*-monoˡ-∣ : ∀ k → (_* k) Preserves _∣_ ⟶ _∣_
*-monoˡ-∣ k {i} {j} i∣j = ∣ᵤ⇒∣ (Unsigned.*-monoˡ-∣ k {i} {j} (∣⇒∣ᵤ i∣j))
*-cancelˡ-∣ : ∀ k {i j} → k ≢ + 0 → k * i ∣ k * j → i ∣ j
*-cancelˡ-∣ k k≢0 = ∣ᵤ⇒∣ ∘ Unsigned.*-cancelˡ-∣ k k≢0 ∘ ∣⇒∣ᵤ
*-cancelʳ-∣ : ∀ k {i j} → k ≢ + 0 → i * k ∣ j * k → i ∣ j
*-cancelʳ-∣ k {i} {j} k≢0 = ∣ᵤ⇒∣ ∘′ Unsigned.*-cancelʳ-∣ k {i} {j} k≢0 ∘′ ∣⇒∣ᵤ
| 30.948454
| 78
| 0.448201
|
432adc982b5390270532742d10cb4fdea0751494
| 3,096
|
agda
|
Agda
|
agda/rummy.agda
|
piyush-kurur/sample-code
|
1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8
|
[
"Unlicense"
] | 2
|
2017-06-19T12:34:08.000Z
|
2017-06-20T02:19:33.000Z
|
agda/rummy.agda
|
piyush-kurur/sample-code
|
1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8
|
[
"Unlicense"
] | 1
|
2017-11-01T05:48:28.000Z
|
2017-11-01T05:48:28.000Z
|
agda/rummy.agda
|
piyush-kurur/sample-code
|
1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8
|
[
"Unlicense"
] | null | null | null |
module rummy where
open import Data.Nat
-- The suit type
data Suit : Set where
♣ : Suit
♢ : Suit
♥ : Suit
♠ : Suit
-- A card consists of a value and a suite.
data Card : ℕ → Suit → Set where
_of_ : (n : ℕ) (s : Suit) → Card n s
-- Common names for cards
A : ℕ; A = 1
K : ℕ; K = 13
Q : ℕ; Q = 12
J : ℕ; J = 11
--
-- The clubs suit
--
A♣ : Card A ♣; A♣ = A of ♣
2♣ : Card 2 ♣; 2♣ = 2 of ♣
3♣ : Card 3 ♣; 3♣ = 3 of ♣
4♣ : Card 4 ♣; 4♣ = 4 of ♣
5♣ : Card 5 ♣; 5♣ = 5 of ♣
6♣ : Card 6 ♣; 6♣ = 6 of ♣
7♣ : Card 7 ♣; 7♣ = 7 of ♣
8♣ : Card 8 ♣; 8♣ = 8 of ♣
9♣ : Card 9 ♣; 9♣ = 9 of ♣
10♣ : Card 10 ♣; 10♣ = 10 of ♣
J♣ : Card J ♣; J♣ = J of ♣
Q♣ : Card Q ♣; Q♣ = Q of ♣
K♣ : Card K ♣; K♣ = K of ♣
--
-- The diamond suit
--
A♢ : Card A ♢; A♢ = A of ♢
2♢ : Card 2 ♢; 2♢ = 2 of ♢
3♢ : Card 3 ♢; 3♢ = 3 of ♢
4♢ : Card 4 ♢; 4♢ = 4 of ♢
5♢ : Card 5 ♢; 5♢ = 5 of ♢
6♢ : Card 6 ♢; 6♢ = 6 of ♢
7♢ : Card 7 ♢; 7♢ = 7 of ♢
8♢ : Card 8 ♢; 8♢ = 8 of ♢
9♢ : Card 9 ♢; 9♢ = 9 of ♢
10♢ : Card 10 ♢; 10♢ = 10 of ♢
J♢ : Card J ♢; J♢ = J of ♢
Q♢ : Card Q ♢; Q♢ = Q of ♢
K♢ : Card K ♢; K♢ = K of ♢
--
-- The heart suit
--
A♥ : Card A ♥; A♥ = A of ♥
2♥ : Card 2 ♥; 2♥ = 2 of ♥
3♥ : Card 3 ♥; 3♥ = 3 of ♥
4♥ : Card 4 ♥; 4♥ = 4 of ♥
5♥ : Card 5 ♥; 5♥ = 5 of ♥
6♥ : Card 6 ♥; 6♥ = 6 of ♥
7♥ : Card 7 ♥; 7♥ = 7 of ♥
8♥ : Card 8 ♥; 8♥ = 8 of ♥
9♥ : Card 9 ♥; 9♥ = 9 of ♥
10♥ : Card 10 ♥; 10♥ = 10 of ♥
J♥ : Card J ♥; J♥ = J of ♥
Q♥ : Card Q ♥; Q♥ = Q of ♥
K♥ : Card K ♥; K♥ = K of ♥
--
-- The spade suit
--
A♠ : Card A ♠; A♠ = A of ♠
2♠ : Card 2 ♠; 2♠ = 2 of ♠
3♠ : Card 3 ♠; 3♠ = 3 of ♠
4♠ : Card 4 ♠; 4♠ = 4 of ♠
5♠ : Card 5 ♠; 5♠ = 5 of ♠
6♠ : Card 6 ♠; 6♠ = 6 of ♠
7♠ : Card 7 ♠; 7♠ = 7 of ♠
8♠ : Card 8 ♠; 8♠ = 8 of ♠
9♠ : Card 9 ♠; 9♠ = 9 of ♠
10♠ : Card 10 ♠; 10♠ = 10 of ♠
J♠ : Card J ♠; J♠ = J of ♠
Q♠ : Card Q ♠; Q♠ = Q of ♠
K♠ : Card K ♠; K♠ = K of ♠
-- A run of length ℓ.
data Run (suit : Suit) : (start ℓ : ℕ) → Set where
[] : {start : ℕ} → Run suit start 0
_,_ : {n ℓ : ℕ}
→ Card n suit
→ Run suit (1 + n) ℓ
→ Run suit n (1 + ℓ)
-- A group of length ℓ.
data Group : (value ℓ : ℕ) → Set where
[] : {value : ℕ} → Group value 0
_,_ : {suit : Suit} {value ℓ : ℕ}
→ Card value suit
→ Group value ℓ
→ Group value (1 + ℓ)
-- Some pretty functions for creating runs. You can create a run as
-- follows:
--
-- myrun = ⟨ A♣ , 2♣ , 3♣ ⟩
--
⟨_ : {suit : Suit} {n ℓ : ℕ} → Run suit n ℓ → Run suit n ℓ
⟨ r = r
_⟩ : {suit : Suit} {n : ℕ} → Card n suit → Run suit n 1
c ⟩ = c , []
-- Some pretty functions for creating groups. You can create a group
-- group as follows:
--
-- mygroup = ⟦ A♣ , A♥ , A♢ ⟧
--
⟦_ : {value ℓ : ℕ} → Group value ℓ → Group value ℓ
⟦ g = g
_⟧ : {suit : Suit} {n : ℕ} → Card n suit → Group n 1
c ⟧ = c , []
infixr 2 _⟩ _⟧ _,_
infixl 1 ⟨_ ⟦_
mygroup = ⟦ A♣ , A♣ , A♠ ⟧
myrun = ⟨ A♣ , 2♣ , 3♣ ⟩
| 21.061224
| 68
| 0.413437
|
37a6c27c12ae549f1f6abb337c6a125f886d7473
| 1,096
|
agda
|
Agda
|
Cubical/ZCohomology/Base.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/ZCohomology/Base.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/ZCohomology/Base.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.ZCohomology.Base where
open import Cubical.Data.Int.Base
open import Cubical.Data.Nat.Base
open import Cubical.Data.Sigma
open import Cubical.Foundations.Pointed.Base
open import Cubical.HITs.Nullification.Base
open import Cubical.HITs.SetTruncation.Base
open import Cubical.HITs.Sn.Base
open import Cubical.HITs.Susp.Base
open import Cubical.HITs.Truncation.Base
private
variable
ℓ : Level
A : Type ℓ
--- Cohomology ---
{- Types Kₙ from Brunerie 2016 -}
coHomK : (n : ℕ) → Type₀
coHomK zero = Int
coHomK (suc n) = ∥ S₊ (suc n) ∥ (2 + suc n)
{- Cohomology -}
coHom : (n : ℕ) → Type ℓ → Type ℓ
coHom n A = ∥ (A → coHomK n) ∥₂
--- Reduced cohomology ---
{- Pointed version of Kₙ -}
coHomK-ptd : (n : ℕ) → Pointed (ℓ-zero)
coHomK-ptd zero = coHomK zero , (pos 0)
coHomK-ptd (suc n) = (coHomK (suc n) , ∣ north ∣)
{- Reduced cohomology -}
coHomRed : (n : ℕ) → (A : Pointed ℓ) → Type ℓ
coHomRed n A = ∥ (A →∙ (coHomK-ptd n)) ∥₂
coHom-pt : (n : ℕ) → coHomK n
coHom-pt zero = pos 0
coHom-pt (suc n) = ∣ north ∣
| 22.833333
| 50
| 0.660584
|
30247f1c71fc41f4646ba2b2580197b6d419e987
| 9,329
|
agda
|
Agda
|
Categories/Morphism/Isomorphism.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Morphism/Isomorphism.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Morphism/Isomorphism.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- Mainly *properties* of isomorphisms, and a lot of other things too
-- TODO: split things up more semantically?
module Categories.Morphism.Isomorphism {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level using (_⊔_)
open import Function using (flip)
open import Data.Product using (_,_)
open import Relation.Binary using (Rel; _Preserves_⟶_; IsEquivalence)
open import Relation.Binary.Construct.Closure.Transitive
open import Relation.Binary.PropositionalEquality as ≡ using (_≡_)
import Categories.Category.Construction.Core as Core
open import Categories.Category.Groupoid using (IsGroupoid)
import Categories.Category.Groupoid.Properties as GroupoidProps
import Categories.Morphism as Morphism
import Categories.Morphism.Properties as MorphismProps
import Categories.Morphism.IsoEquiv as IsoEquiv
import Categories.Category.Construction.Path as Path
open Core 𝒞 using (Core; Core-isGroupoid; CoreGroupoid)
open Morphism 𝒞
open MorphismProps 𝒞
open IsoEquiv 𝒞 using (_≃_; ⌞_⌟)
open Path 𝒞
import Categories.Morphism.Reasoning as MR
open Category 𝒞
private
module MCore where
open IsGroupoid Core-isGroupoid public
open GroupoidProps CoreGroupoid public
open MorphismProps Core public
open Morphism Core public
open Path Core public
variable
A B C D E F : Obj
open MCore using () renaming (_∘_ to _∘ᵢ_) public
CommutativeIso = IsGroupoid.CommutativeSquare Core-isGroupoid
--------------------
-- Also stuff about transitive closure
∘ᵢ-tc : A [ _≅_ ]⁺ B → A ≅ B
∘ᵢ-tc = MCore.∘-tc
infix 4 _≃⁺_
_≃⁺_ : Rel (A [ _≅_ ]⁺ B) _
_≃⁺_ = MCore._≈⁺_
TransitiveClosure : Category _ _ _
TransitiveClosure = MCore.Path
--------------------
-- some infrastructure setup in order to say something about morphisms and isomorphisms
module _ where
private
data IsoPlus : A [ _⇒_ ]⁺ B → Set (o ⊔ ℓ ⊔ e) where
[_] : {f : A ⇒ B} {g : B ⇒ A} → Iso f g → IsoPlus [ f ]
_∼⁺⟨_⟩_ : ∀ A {f⁺ : A [ _⇒_ ]⁺ B} {g⁺ : B [ _⇒_ ]⁺ C} → IsoPlus f⁺ → IsoPlus g⁺ → IsoPlus (_ ∼⁺⟨ f⁺ ⟩ g⁺)
open _≅_
≅⁺⇒⇒⁺ : A [ _≅_ ]⁺ B → A [ _⇒_ ]⁺ B
≅⁺⇒⇒⁺ [ f ] = [ from f ]
≅⁺⇒⇒⁺ (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = _ ∼⁺⟨ ≅⁺⇒⇒⁺ f⁺ ⟩ ≅⁺⇒⇒⁺ f⁺′
reverse : A [ _≅_ ]⁺ B → B [ _≅_ ]⁺ A
reverse [ f ] = [ ≅.sym f ]
reverse (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = _ ∼⁺⟨ reverse f⁺′ ⟩ reverse f⁺
reverse⇒≅-sym : (f⁺ : A [ _≅_ ]⁺ B) → ∘ᵢ-tc (reverse f⁺) ≡ ≅.sym (∘ᵢ-tc f⁺)
reverse⇒≅-sym [ f ] = ≡.refl
reverse⇒≅-sym (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = ≡.cong₂ (Morphism.≅.trans 𝒞) (reverse⇒≅-sym f⁺′) (reverse⇒≅-sym f⁺)
TransitiveClosure-groupoid : IsGroupoid TransitiveClosure
TransitiveClosure-groupoid = record
{ _⁻¹ = reverse
; iso = λ {_ _ f⁺} → record { isoˡ = isoˡ′ f⁺ ; isoʳ = isoʳ′ f⁺ }
}
where
open MCore.HomReasoning
isoˡ′ : (f⁺ : A [ _≅_ ]⁺ B) → ∘ᵢ-tc (reverse f⁺) ∘ᵢ ∘ᵢ-tc f⁺ ≃ ≅.refl
isoˡ′ f⁺ = begin
∘ᵢ-tc (reverse f⁺) ∘ᵢ ∘ᵢ-tc f⁺
≡⟨ ≡.cong (_∘ᵢ ∘ᵢ-tc f⁺) (reverse⇒≅-sym f⁺) ⟩
≅.sym (∘ᵢ-tc f⁺) ∘ᵢ ∘ᵢ-tc f⁺
≈⟨ MCore.iso.isoˡ ⟩
≅.refl
∎
isoʳ′ : (f⁺ : A [ _≅_ ]⁺ B) → ∘ᵢ-tc f⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺) ≃ ≅.refl
isoʳ′ f⁺ = begin
∘ᵢ-tc f⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺)
≡⟨ ≡.cong (∘ᵢ-tc f⁺ ∘ᵢ_) (reverse⇒≅-sym f⁺) ⟩
∘ᵢ-tc f⁺ ∘ᵢ ≅.sym (∘ᵢ-tc f⁺)
≈⟨ MCore.iso.isoʳ ⟩
≅.refl
∎
from-∘ᵢ-tc : (f⁺ : A [ _≅_ ]⁺ B) → from (∘ᵢ-tc f⁺) ≡ ∘-tc (≅⁺⇒⇒⁺ f⁺)
from-∘ᵢ-tc [ f ] = ≡.refl
from-∘ᵢ-tc (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = ≡.cong₂ _∘_ (from-∘ᵢ-tc f⁺′) (from-∘ᵢ-tc f⁺)
≅*⇒⇒*-cong : ≅⁺⇒⇒⁺ {A} {B} Preserves _≃⁺_ ⟶ _≈⁺_
≅*⇒⇒*-cong {_} {_} {f⁺} {g⁺} f⁺≃⁺g⁺ = begin
∘-tc (≅⁺⇒⇒⁺ f⁺) ≡˘⟨ from-∘ᵢ-tc f⁺ ⟩
from (∘ᵢ-tc f⁺) ≈⟨ _≃_.from-≈ f⁺≃⁺g⁺ ⟩
from (∘ᵢ-tc g⁺) ≡⟨ from-∘ᵢ-tc g⁺ ⟩
∘-tc (≅⁺⇒⇒⁺ g⁺) ∎
where open HomReasoning
≅-shift : ∀ {f⁺ : A [ _≅_ ]⁺ B} {g⁺ : B [ _≅_ ]⁺ C} {h⁺ : A [ _≅_ ]⁺ C} →
(_ ∼⁺⟨ f⁺ ⟩ g⁺) ≃⁺ h⁺ → g⁺ ≃⁺ (_ ∼⁺⟨ reverse f⁺ ⟩ h⁺)
≅-shift {f⁺ = f⁺} {g⁺ = g⁺} {h⁺ = h⁺} eq = begin
∘ᵢ-tc g⁺ ≈⟨ introʳ (I.isoʳ f⁺) ⟩
∘ᵢ-tc g⁺ ∘ᵢ (∘ᵢ-tc f⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺)) ≈⟨ pullˡ eq ⟩
∘ᵢ-tc h⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺) ∎
where
open MCore.HomReasoning
open MR Core
module I {A B} (f⁺ : A [ _≅_ ]⁺ B) = Morphism.Iso (IsGroupoid.iso TransitiveClosure-groupoid {f = f⁺})
lift : ∀ {f⁺ : A [ _⇒_ ]⁺ B} → IsoPlus f⁺ → A [ _≅_ ]⁺ B
lift [ iso ] = [ record
{ from = _
; to = _
; iso = iso
} ]
lift (_ ∼⁺⟨ iso ⟩ iso′) = _ ∼⁺⟨ lift iso ⟩ lift iso′
reduce-lift : ∀ {f⁺ : A [ _⇒_ ]⁺ B} (f′ : IsoPlus f⁺) → from (∘ᵢ-tc (lift f′)) ≡ ∘-tc f⁺
reduce-lift [ f ] = ≡.refl
reduce-lift (_ ∼⁺⟨ f′ ⟩ f″) = ≡.cong₂ _∘_ (reduce-lift f″) (reduce-lift f′)
lift-cong : ∀ {f⁺ g⁺ : A [ _⇒_ ]⁺ B} (f′ : IsoPlus f⁺) (g′ : IsoPlus g⁺) →
f⁺ ≈⁺ g⁺ → lift f′ ≃⁺ lift g′
lift-cong {_} {_} {f⁺} {g⁺} f′ g′ eq = ⌞ from-≈′ ⌟
where
open HomReasoning
from-≈′ : from (∘ᵢ-tc (lift f′)) ≈ from (∘ᵢ-tc (lift g′))
from-≈′ = begin
from (∘ᵢ-tc (lift f′)) ≡⟨ reduce-lift f′ ⟩
∘-tc f⁺ ≈⟨ eq ⟩
∘-tc g⁺ ≡˘⟨ reduce-lift g′ ⟩
from (∘ᵢ-tc (lift g′)) ∎
lift-triangle : {f : A ⇒ B} {g : C ⇒ A} {h : C ⇒ B} {k : B ⇒ C} {i : B ⇒ A} {j : A ⇒ C} →
f ∘ g ≈ h → (f′ : Iso f i) → (g′ : Iso g j) → (h′ : Iso h k) →
lift (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) ≃⁺ lift [ h′ ]
lift-triangle eq f′ g′ h′ = lift-cong (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) [ h′ ] eq
lift-square : {f : A ⇒ B} {g : C ⇒ A} {h : D ⇒ B} {i : C ⇒ D} {j : D ⇒ C} {a : B ⇒ A} {b : A ⇒ C} {c : B ⇒ D} →
f ∘ g ≈ h ∘ i → (f′ : Iso f a) → (g′ : Iso g b) → (h′ : Iso h c) → (i′ : Iso i j) →
lift (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) ≃⁺ lift (_ ∼⁺⟨ [ i′ ] ⟩ [ h′ ])
lift-square eq f′ g′ h′ i′ = lift-cong (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) (_ ∼⁺⟨ [ i′ ] ⟩ [ h′ ]) eq
lift-pentagon : {f : A ⇒ B} {g : C ⇒ A} {h : D ⇒ C} {i : E ⇒ B} {j : D ⇒ E} {l : E ⇒ D}
{a : B ⇒ A} {b : A ⇒ C} {c : C ⇒ D} {d : B ⇒ E} →
f ∘ g ∘ h ≈ i ∘ j →
(f′ : Iso f a) → (g′ : Iso g b) → (h′ : Iso h c) → (i′ : Iso i d) → (j′ : Iso j l) →
lift (_ ∼⁺⟨ _ ∼⁺⟨ [ h′ ] ⟩ [ g′ ] ⟩ [ f′ ]) ≃⁺ lift (_ ∼⁺⟨ [ j′ ] ⟩ [ i′ ])
lift-pentagon eq f′ g′ h′ i′ j′ = lift-cong (_ ∼⁺⟨ _ ∼⁺⟨ [ h′ ] ⟩ [ g′ ] ⟩ [ f′ ]) (_ ∼⁺⟨ [ j′ ] ⟩ [ i′ ]) eq
module _ where
open _≅_
-- projecting isomorphism commutations to morphism commutations
project-triangle : {g : A ≅ B} {f : C ≅ A} {h : C ≅ B} → g ∘ᵢ f ≃ h → from g ∘ from f ≈ from h
project-triangle = _≃_.from-≈
project-square : {g : A ≅ B} {f : C ≅ A} {i : D ≅ B} {h : C ≅ D} → g ∘ᵢ f ≃ i ∘ᵢ h → from g ∘ from f ≈ from i ∘ from h
project-square = _≃_.from-≈
-- direct lifting from morphism commutations to isomorphism commutations
lift-triangle′ : {f : A ≅ B} {g : C ≅ A} {h : C ≅ B} → from f ∘ from g ≈ from h → f ∘ᵢ g ≃ h
lift-triangle′ = ⌞_⌟
lift-square′ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ B} {i : C ≅ D} → from f ∘ from g ≈ from h ∘ from i → f ∘ᵢ g ≃ h ∘ᵢ i
lift-square′ = ⌞_⌟
lift-pentagon′ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ C} {i : E ≅ B} {j : D ≅ E} →
from f ∘ from g ∘ from h ≈ from i ∘ from j → f ∘ᵢ g ∘ᵢ h ≃ i ∘ᵢ j
lift-pentagon′ = ⌞_⌟
open MR Core
open MCore using (_⁻¹)
open MCore.HomReasoning
open MR.GroupoidR _ Core-isGroupoid
squares×≃⇒≃ : {f f′ : A ≅ B} {g : A ≅ C} {h : B ≅ D} {i i′ : C ≅ D} →
CommutativeIso f g h i → CommutativeIso f′ g h i′ → i ≃ i′ → f ≃ f′
squares×≃⇒≃ sq₁ sq₂ eq = MCore.isos×≈⇒≈ eq helper₁ (MCore.≅.sym helper₂) sq₁ sq₂
where
helper₁ = record { iso = MCore.iso }
helper₂ = record { iso = MCore.iso }
-- imagine a triangle prism, if all the sides and the top face commute, the bottom face commute.
triangle-prism : {i′ : A ≅ B} {f′ : C ≅ A} {h′ : C ≅ B} {i : D ≅ E} {j : D ≅ A}
{k : E ≅ B} {f : F ≅ D} {g : F ≅ C} {h : F ≅ E} →
i′ ∘ᵢ f′ ≃ h′ →
CommutativeIso i j k i′ → CommutativeIso f g j f′ → CommutativeIso h g k h′ →
i ∘ᵢ f ≃ h
triangle-prism {i′ = i′} {f′} {_} {i} {_} {k} {f} {g} {_} eq sq₁ sq₂ sq₃ =
squares×≃⇒≃ glued sq₃ eq
where
glued : CommutativeIso (i ∘ᵢ f) g k (i′ ∘ᵢ f′)
glued = sym (glue (sym sq₁) (sym sq₂))
elim-triangleˡ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ C} {i : D ≅ B} {j : D ≅ A} →
f ∘ᵢ g ∘ᵢ h ≃ i → f ∘ᵢ j ≃ i → g ∘ᵢ h ≃ j
elim-triangleˡ perim tri = MCore.mono _ _ (perim ○ ⟺ tri)
elim-triangleˡ′ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ C} {i : D ≅ B} {j : C ≅ B} →
f ∘ᵢ g ∘ᵢ h ≃ i → j ∘ᵢ h ≃ i → f ∘ᵢ g ≃ j
elim-triangleˡ′ {f = f} {g} {h} {i} {j} perim tri = MCore.epi _ _ ( begin
(f ∘ᵢ g) ∘ᵢ h ≈⟨ MCore.assoc ⟩
f ∘ᵢ g ∘ᵢ h ≈⟨ perim ⟩
i ≈˘⟨ tri ⟩
j ∘ᵢ h ∎ )
cut-squareʳ : {g : A ≅ B} {f : A ≅ C} {h : B ≅ D} {i : C ≅ D} {j : B ≅ C} →
CommutativeIso g f h i → i ∘ᵢ j ≃ h → j ∘ᵢ g ≃ f
cut-squareʳ {g = g} {f = f} {h = h} {i = i} {j = j} sq tri = begin
j ∘ᵢ g ≈⟨ switch-fromtoˡ′ {f = i} {h = j} {k = h} tri ⟩∘⟨ refl ⟩
(i ⁻¹ ∘ᵢ h) ∘ᵢ g ≈⟨ MCore.assoc ⟩
i ⁻¹ ∘ᵢ h ∘ᵢ g ≈˘⟨ switch-fromtoˡ′ {f = i} {h = f} {k = h ∘ᵢ g} (sym sq) ⟩
f ∎
| 38.390947
| 120
| 0.473791
|
3754ae6f225756fb82bbf05e677c7971a81e7c81
| 1,051
|
agda
|
Agda
|
notes/type-classes/InstanceArguments.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
notes/type-classes/InstanceArguments.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
notes/type-classes/InstanceArguments.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- From: On the Bright Side of Type Classes: Instances Arguments in
-- Agda (ICFP'11).
module InstanceArguments where
open import Data.Bool.Base
open import Data.Nat hiding ( equal ) renaming ( suc to succ )
-- Note: Agda doesn't have a primitive function primBoolEquality.
boolEq : Bool → Bool → Bool
boolEq true true = true
boolEq false false = true
{-# CATCHALL #-}
boolEq _ _ = false
natEq : ℕ → ℕ → Bool
natEq zero zero = true
natEq (succ m) (succ n) = natEq m n
{-# CATCHALL #-}
natEq _ _ = false
record Eq (t : Set) : Set where
field equal : t → t → Bool
instance
eqInstanceBool : Eq Bool
eqInstanceBool = record { equal = boolEq }
eqInstanceℕ : Eq ℕ
eqInstanceℕ = record { equal = natEq }
equal : {t : Set} → {{eqT : Eq t}} → t → t → Bool
equal {{eqT}} = Eq.equal eqT
test : Bool
test = equal 5 3 ∨ equal true false
| 25.02381
| 67
| 0.61275
|
37844b6ea466a7ede5fda2a73512083f2456c41a
| 632
|
agda
|
Agda
|
test/Fail/Issue1428.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/Issue1428.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Fail/Issue1428.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2013-05-16, raised by Andrea 2015-02-10
open import Common.Size
open import Common.Prelude
data Wrap (A : SizeUniv) : SizeUniv where
-- data Wrap (A : Set) : Set where
wrap : A → Wrap A
module M (f : ∀ i → Wrap (Size< i)) where
test : ∀ i → Wrap (Size< i) → ⊥
test i (wrap j) = test j (f j)
module N (pred : ∀ i → Size< i) where
f = (λ i → wrap (pred i))
open M f
loop : Size → ⊥
loop i = test i (f i)
-- = test i (wrap (pred i))
-- = test (pred i) ((λ i → wrap (pred i)) (pred i))
-- = test (pred i) (wrap (pred (pred i)))
-- = test (pred (pred i)) (wrap (pred (pred (pred i))))
-- = ...
| 23.407407
| 57
| 0.545886
|
9a9310aaa4506c8ae582f774e283ba60579865d1
| 3,284
|
agda
|
Agda
|
theorems/stash/cohomology/InverseInSusp.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/stash/cohomology/InverseInSusp.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/stash/cohomology/InverseInSusp.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
open import homotopy.FunctionOver
open import groups.ProductRepr
open import cohomology.Theory
open import cohomology.WedgeCofiber
{- For the cohomology group of a suspension ΣX, the group inverse has the
- explicit form Cⁿ(flip-susp) : Cⁿ(ΣX) → Cⁿ(ΣX).
-}
module cohomology.InverseInSusp {i} (CT : CohomologyTheory i)
(n : ℤ) {X : Ptd i} where
open CohomologyTheory CT
open import cohomology.Functor CT
open import cohomology.BaseIndependence CT
open import cohomology.Wedge CT
private
module CW = CWedge n (⊙Susp X) (⊙Susp X)
module Subtract = SuspRec {C = fst (⊙Susp X ⊙∨ ⊙Susp X)}
(winl south)
(winr south)
(λ x → ap winl (! (merid x)) ∙ wglue ∙ ap winr (merid x))
subtract = Subtract.f
⊙subtract : ⊙Susp X ⊙→ ⊙Susp X ⊙∨ ⊙Susp X
⊙subtract = (subtract , ! (ap winl (merid (pt X))))
projl-subtract : ∀ σ → projl _ _ (subtract σ) == Susp-flip σ
projl-subtract = Susp-elim idp idp $
↓-='-from-square ∘ vert-degen-square ∘ λ x →
ap-∘ (projl _ _) subtract (merid x)
∙ ap (ap (projl _ _)) (Subtract.merid-β x)
∙ ap-∙ (projl _ _) (ap winl (! (merid x))) (wglue ∙ ap winr (merid x))
∙ ((∘-ap (projl _ _) winl (! (merid x))
∙ ap-idf _)
∙2 (ap-∙ (projl _ _) wglue (ap winr (merid x))
∙ (Projl.glue-β _ _
∙2 (∘-ap (projl _ _) winr (merid x) ∙ ap-cst _ _))))
∙ ∙-unit-r _
∙ ! (FlipSusp.merid-β x)
projr-subtract : ∀ σ → projr _ _ (subtract σ) == σ
projr-subtract = Susp-elim idp idp $
↓-∘=idf-in' (projr _ _) subtract ∘ λ x →
ap (ap (projr _ _)) (Subtract.merid-β x)
∙ ap-∙ (projr _ _) (ap winl (! (merid x))) (wglue ∙ ap winr (merid x))
∙ ((∘-ap (projr _ _) winl (! (merid x)) ∙ ap-cst _ _)
∙2 (ap-∙ (projr _ _) wglue (ap winr (merid x))
∙ (Projr.glue-β _ _
∙2 (∘-ap (projr _ _) winr (merid x) ∙ ap-idf _))))
fold-subtract : ∀ σ → fold (subtract σ) == south
fold-subtract = Susp-elim idp idp $
↓-app=cst-in ∘ ! ∘ λ x →
∙-unit-r _
∙ ap-∘ fold subtract (merid x)
∙ ap (ap fold) (Subtract.merid-β x)
∙ ap-∙ fold (ap winl (! (merid x))) (wglue ∙ ap winr (merid x))
∙ ((∘-ap fold winl (! (merid x)) ∙ ap-idf _)
∙2 (ap-∙ fold wglue (ap winr (merid x))
∙ (Fold.glue-β
∙2 (∘-ap fold winr (merid x) ∙ ap-idf _))))
∙ !-inv-l (merid x)
cancel :
×ᴳ-fanin (C-is-abelian n _) (CF-hom n (⊙Susp-flip X)) (idhom _) ∘ᴳ ×ᴳ-diag
== cst-hom
cancel =
ap2 (λ φ ψ → ×ᴳ-fanin (C-is-abelian n _) φ ψ ∘ᴳ ×ᴳ-diag)
(! (CF-λ= n projl-subtract))
(! (CF-ident n) ∙ ! (CF-λ= n projr-subtract))
∙ transport (λ {(G , φ , ψ) → φ ∘ᴳ ψ == cst-hom})
(pair= (CW.path) $ ↓-×-in
(CW.Wedge-in-over ⊙subtract)
(CW.⊙Wedge-rec-over (⊙idf _) (⊙idf _)
▹ ap2 ×ᴳ-fanout (CF-ident n) (CF-ident n)))
(! (CF-comp n ⊙fold ⊙subtract)
∙ CF-λ= n (λ σ → fold-subtract σ ∙ ! (merid (pt X)))
∙ CF-cst n)
C-Susp-flip-is-inv :
CF-hom n (⊙Susp-flip X) == inv-hom (C n (⊙Susp X)) (C-is-abelian _ _)
C-Susp-flip-is-inv = group-hom= $ λ= λ g →
! (Group.inv-unique-l (C n (⊙Susp X)) _ g (app= (ap GroupHom.f cancel) g))
| 36.087912
| 78
| 0.543544
|
7c815e955cbd70c0a5dd33efa94fe3416c980621
| 3,379
|
agda
|
Agda
|
Experiment/Omniscience.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | 3
|
2020-04-07T17:49:42.000Z
|
2020-04-21T00:03:43.000Z
|
Experiment/Omniscience.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
Experiment/Omniscience.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe --exact-split #-}
module Experiment.Omniscience where
open import Level using () renaming (zero to lzero)
open import Data.Nat using (ℕ; zero; suc; _≤_; _+_)
open import Data.Nat.Properties using (≤-refl; +-identityʳ)
open import Data.Product using (Σ; _,_; proj₁; proj₂; ∃; _×_)
open import Data.Bool using (Bool; true; false; _∧_; not)
open import Data.Bool.Properties using (∧-assoc; ∧-idem)
open import Function.Base using (_$_)
open import Relation.Binary using (Rel)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; subst; sym; _≢_; cong; module ≡-Reasoning)
infix 5 _≤ᵇ_
_≤ᵇ_ : Bool → Bool → Bool
false ≤ᵇ false = true
true ≤ᵇ false = false
false ≤ᵇ true = true
true ≤ᵇ true = true
x≤ᵇtrue≡true : ∀ x → x ≤ᵇ true ≡ true
x≤ᵇtrue≡true false = refl
x≤ᵇtrue≡true true = refl
Decrease : (ℕ → Bool) → Set
Decrease α = ∀ i → α (suc i) ≤ᵇ α i ≡ true
ℕ∞ : Set
ℕ∞ = Σ (ℕ → Bool) Decrease
-- less n i ≡ true <=> n > i
less : ℕ → ℕ → Bool
less zero zero = false
less zero (suc n) = false
less (suc m) zero = true
less (suc m) (suc n) = less m n
less-decrease : ∀ n → Decrease (less n)
less-decrease zero zero = refl
less-decrease zero (suc i) = refl
less-decrease (suc n) zero = x≤ᵇtrue≡true (less n 0)
less-decrease (suc n) (suc i) = less-decrease n i
toℕ∞ : ℕ → ℕ∞
toℕ∞ n = less n , less-decrease n
_≈C_ : Rel (ℕ → Bool) lzero
α ≈C β = ∀ i → α i ≡ β i
_≈_ : Rel ℕ∞ lzero
x ≈ y = proj₁ x ≈C proj₁ y
_#C_ : Rel (ℕ → Bool) lzero
α #C β = ∃ λ i → α i ≢ β i
_#_ : Rel ℕ∞ lzero
x # y = proj₁ x #C proj₁ y
-- retract
𝓇 : (ℕ → Bool) → (ℕ → Bool)
𝓇 α zero = α 0
𝓇 α (suc n) = α (suc n) ∧ 𝓇 α n
𝓇-decrease : ∀ α → Decrease (𝓇 α)
𝓇-decrease α i = lemma (α (suc i)) (𝓇 α i)
where
lemma : ∀ x y → x ∧ y ≤ᵇ y ≡ true
lemma false false = refl
lemma false true = refl
lemma true false = refl
lemma true true = refl
𝓇-idem : ∀ α → 𝓇 (𝓇 α) ≈C 𝓇 α
𝓇-idem α zero = refl
𝓇-idem α (suc i) = begin
(α (suc i) ∧ 𝓇 α i) ∧ 𝓇 (𝓇 α) i
≡⟨ cong (λ v → (α (suc i) ∧ 𝓇 α i) ∧ v) $ 𝓇-idem α i ⟩
(α (suc i) ∧ 𝓇 α i) ∧ 𝓇 α i
≡⟨ ∧-assoc (α (suc i)) (𝓇 α i) (𝓇 α i) ⟩
α (suc i) ∧ (𝓇 α i ∧ 𝓇 α i)
≡⟨ cong (λ v → α (suc i) ∧ v) $ ∧-idem (𝓇 α i) ⟩
α (suc i) ∧ 𝓇 α i ∎
where open ≡-Reasoning
⟦_⟧ : ℕ∞ → (ℕ → Bool)
⟦_⟧ = proj₁
private
contraposition-Bool : ∀ {x y z} → (x ≡ z → y ≡ z) → y ≡ not z → x ≡ not z
contraposition-Bool {false} {false} {true} f e = refl
contraposition-Bool {false} {true} {false} f e = (λ ()) $ f refl
contraposition-Bool {true} {false} {true} f e = (λ ()) $ f refl
contraposition-Bool {true} {true} {false} f e = refl
≤ᵇ-to-fun : ∀ {x y} → x ≤ᵇ y ≡ true → x ≡ true → y ≡ true
≤ᵇ-to-fun {true} {true} _ _ = refl
lemma-3-2-lemma : ∀ (x : ℕ∞) m n → ⟦ x ⟧ n ≡ false → ⟦ x ⟧ (m + n) ≡ false
lemma-3-2-lemma x@(α , d) zero n αn≡false = αn≡false
lemma-3-2-lemma x@(α , d) (suc m) n αn≡false =
contraposition-Bool (≤ᵇ-to-fun (d (m + n))) (lemma-3-2-lemma x m n αn≡false)
lemma-3-2 : ∀ (x : ℕ∞) n → ⟦ x ⟧ n ≡ false → ∃ λ k → k ≤ n × x ≈ toℕ∞ k
lemma-3-2 x@(α , d) zero αn≡false = 0 , (≤-refl , f)
where
f : ∀ i → α i ≡ less 0 i
f zero = αn≡false
f (suc i) = subst (λ v → α (suc v) ≡ false) (+-identityʳ i) $
lemma-3-2-lemma x (suc i) 0 αn≡false
lemma-3-2 (α , d) (suc n) αn≡false = {! !}
-- α i ≡ less 0 i
| 29.12931
| 78
| 0.562592
|
5289f0cb2dc6365e3cf900f3773c6cf93c6878ef
| 3,137
|
agda
|
Agda
|
TypeTheory/Nat/Mono/Properties.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | 3
|
2020-04-07T17:49:42.000Z
|
2020-04-21T00:03:43.000Z
|
TypeTheory/Nat/Mono/Properties.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
TypeTheory/Nat/Mono/Properties.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
open import TypeTheory.Nat.Mono.Structure
module TypeTheory.Nat.Mono.Properties (nat : Nat) where
open import Level renaming (zero to lzero; suc to lsuc)
open import Data.Empty using (⊥)
open import Data.Product using (Σ; _×_; _,_)
open import Data.Sum
open import Relation.Binary using (Rel)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (¬_)
open import Function.Base
open Nat nat
+-suc : ∀ m n → suc m + n ≡ suc (m + n)
+-suc m n = rec-suc _ _ _
+-identityˡ : ∀ n → zero + n ≡ n
+-identityˡ n = rec-zero _ _
+-identityʳ : ∀ n → n + zero ≡ n
+-identityʳ n = ind (λ k → k + zero ≡ k) (+-identityˡ zero)
(λ k k+z≡k → trans (+-suc k zero) (cong suc k+z≡k) )
n
1N+n≡sn : ∀ n → 1N + n ≡ suc n
1N+n≡sn n = begin
suc zero + n ≡⟨ +-suc zero n ⟩
suc (zero + n) ≡⟨ cong suc (+-identityˡ n) ⟩
suc n ∎
where open ≡-Reasoning
+-suc-comm : ∀ m n → suc m + n ≡ m + suc n
+-suc-comm m n =
ind
(λ o → suc o + n ≡ o + suc n)
(begin
suc zero + n ≡⟨ 1N+n≡sn n ⟩
suc n ≡⟨ sym $ +-identityˡ (suc n) ⟩
zero + suc n ∎)
(λ o so+n≡o+sn → begin
suc (suc o) + n ≡⟨ +-suc (suc o) n ⟩
suc (suc o + n) ≡⟨ cong suc so+n≡o+sn ⟩
suc (o + suc n) ≡⟨ sym $ +-suc o (suc n) ⟩
suc o + suc n ∎)
m
where open ≡-Reasoning
z≤n : ∀ n → zero ≤ n
z≤n n = n , +-identityˡ n
≤-step : ∀ {m n} → m ≤ n → m ≤ suc n
≤-step {m} {n} (o , m+o≡n) = suc o , (begin
m + suc o ≡⟨ sym $ +-suc-comm m o ⟩
suc m + o ≡⟨ +-suc m o ⟩
suc (m + o) ≡⟨ cong suc m+o≡n ⟩
suc n ∎)
where open ≡-Reasoning
≤-refl : ∀ {n} → n ≤ n
≤-refl {n} = zero , +-identityʳ n
s≤s : ∀ {m n} → m ≤ n → suc m ≤ suc n
s≤s {m} {n} (o , m+o≡n) = o , trans (+-suc m o) (cong suc m+o≡n)
s<s : ∀ {m n} → m < n → suc m < suc n
s<s = s≤s
z<s : ∀ n → zero < suc n
z<s n = s≤s (z≤n n)
n<sn : ∀ n → n < suc n
n<sn n = ≤-refl {suc n}
≤⇒<∨≡ : ∀ {m n} → m ≤ n → m < n ⊎ m ≡ n
≤⇒<∨≡ {m} {n} (o , m+o≡n) =
ind (λ k → m + k ≡ n → m < n ⊎ m ≡ n)
(λ m+z≡n → inj₂ (trans (sym $ +-identityʳ m) m+z≡n))
(λ k _ m+sk≡n → inj₁ (k , (trans (+-suc-comm m k) m+sk≡n)))
o
m+o≡n
data Order (m n : N) : Set where
less : (m<n : m < n) → Order m n
equal : (m≡n : m ≡ n) → Order m n
greater : (m>n : m > n) → Order m n
order? : ∀ m n → Order m n
order? m₀ n₀ = ind (λ m → Order m n₀) order?-zero order?-suc m₀
where
order?-zero : Order zero n₀
order?-zero = ind (Order zero) (equal refl) (λ _ _ → less (z<s _)) n₀
order?-suc : ∀ m → Order m n₀ → Order (suc m) n₀
order?-suc m (less sm≤n) with ≤⇒<∨≡ sm≤n
... | inj₁ sm<n = less sm<n
... | inj₂ sm≡n = equal sm≡n
order?-suc m (equal refl) = greater (n<sn _)
order?-suc m (greater m>n) = greater (≤-step m>n)
-- indΔ :
module _ (P : N → N → Set) where
indΔ : P zero zero →
(∀ n → P zero (suc n)) →
(∀ m → P (suc m) zero) →
(∀ m n → P m n → P (suc m) (suc n)) →
∀ m n → P m n
indΔ Pzz Pzs Psz Pss m n with order? m n
... | less m<n = {! !}
... | equal m≡n = {! !}
... | greater m>n = {! !}
| 27.761062
| 72
| 0.491234
|
fd83fa80359e7e191d9107ae843c9e9e61e8c429
| 476
|
agda
|
Agda
|
test/Succeed/InferrableFields.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/InferrableFields.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/InferrableFields.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
module InferrableFields where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
data Vec A : ℕ → Set where
[] : Vec A zero
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
record SomeVec A : Set where
field n : ℕ
unpack : Vec A n
open SomeVec using (unpack)
pack : ∀ {A n} → Vec A n -> SomeVec A
pack xs = record { unpack = xs }
data _≡_ {A : Set}(x : A) : A → Set where
refl : x ≡ x
lemPack : ∀ {A}(xs : SomeVec A) → pack (unpack xs) ≡ xs
lemPack xs = refl
| 18.307692
| 55
| 0.556723
|
9a5b7bb96fb84a2bd1c35f9243b60d9e414f50e6
| 5,279
|
agda
|
Agda
|
Cubical/HITs/Delooping/Two/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/HITs/Delooping/Two/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/HITs/Delooping/Two/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.Delooping.Two.Properties where
open import Cubical.Functions.Involution
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Data.Bool
open import Cubical.Data.Empty
open import Cubical.Data.Unit
open import Cubical.HITs.Delooping.Two.Base
open import Cubical.HITs.PropositionalTruncation
private
variable
ℓ : Level
module Embed where
isPropDepIsSet : isOfHLevelDep {ℓ' = ℓ} 1 isSet
isPropDepIsSet = isOfHLevel→isOfHLevelDep 1 (λ _ → isPropIsSet)
notSet : PathP (λ i → isSet (notEq i)) isSetBool isSetBool
notSet = isPropDepIsSet isSetBool isSetBool notEq
notNot² : Square notEq refl refl notEq
notNot² = involPath² notnot
notNotSet
: SquareP (λ i j → isSet (notNot² i j)) notSet refl refl notSet
notNotSet = isPropDep→isSetDep'
isPropDepIsSet
(involPath² notnot)
notSet refl refl notSet
Code : Bℤ₂ → hSet ℓ-zero
Code = Elim.rec
(Bool , isSetBool)
(λ i → notEq i , notSet i)
(λ i j → λ where
.fst → notNot² i j
.snd → notNotSet i j)
(isOfHLevelTypeOfHLevel 2)
El : Bℤ₂ → Type₀
El b = Code b .fst
module BINARY where
open import Cubical.Data.FinSet.Binary.Large
sem : Bℤ₂ → Binary _
sem = Elim.rec Base Loop Loop² isGroupoidBinary
loop? : Bool → base ≡ base
loop? false = refl
loop? true = loop
Loop²-coh : (a b c : Bool) → Type₀
Loop²-coh false false false = Unit
Loop²-coh false true true = Unit
Loop²-coh true false true = Unit
Loop²-coh true true false = Unit
Loop²-coh _ _ _ = ⊥
rf : Bool ≡ Bool → Bool
rf P = transport P false
Loop²-coh-lemma₀
: ∀(p q r : Bool)
→ r ⊕ p ≡ q
→ Loop²-coh p q r
Loop²-coh-lemma₀ false false false sq = _
Loop²-coh-lemma₀ false true true sq = _
Loop²-coh-lemma₀ true false true sq = _
Loop²-coh-lemma₀ true true false sq = _
Loop²-coh-lemma₀ false true false = false≢true
Loop²-coh-lemma₀ false false true = true≢false
Loop²-coh-lemma₀ true false false = true≢false
Loop²-coh-lemma₀ true true true = false≢true
Loop²-coh-lemma
: ∀(P Q R : Bool ≡ Bool)
→ Square P Q refl R
→ Loop²-coh (rf P) (rf Q) (rf R)
Loop²-coh-lemma P Q R sq = Loop²-coh-lemma₀ p q r eqn
where
p = rf P
q = rf Q
r = rf R
open BoolReflection
cmp : P ∙ R ≡ Q
cmp i j
= hcomp (λ k → λ where
(i = i0) → compPath-filler P R k j
(i = i1) → Q j
(j = i0) → Bool
(j = i1) → R (i ∨ k))
(sq i j)
rcmp : ⊕-Path (r ⊕ p) ≡ ⊕-Path q
rcmp = ⊕-Path (r ⊕ p)
≡[ i ]⟨ ⊕-comp p r (~ i) ⟩
⊕-Path p ∙ ⊕-Path r
≡[ i ]⟨ ⊕-complete P (~ i) ∙ ⊕-complete R (~ i) ⟩
P ∙ R
≡⟨ cmp ⟩
Q
≡⟨ ⊕-complete Q ⟩
⊕-Path q ∎
open Iso
eqn : r ⊕ p ≡ q
eqn = transport (λ i →
reflectIso .leftInv (r ⊕ p) i ≡ reflectIso .leftInv q i)
(cong (reflectIso .inv) rcmp)
loop²?
: ∀ p q r → Loop²-coh p q r
→ Square (loop? p) (loop? q) refl (loop? r)
loop²? false false false _ = refl
loop²? false true true _ = λ i j → loop (i ∧ j)
loop²? true false true _ = loop²
loop²? true true false _ = refl
module _ (B : Type₀) where
based : (P : Bool ≃ B) → Bℤ₂
based _ = base
pull₀ : (P Q : Bool ≃ B) → Bool ≡ Bool
pull₀ P Q i
= hcomp (λ k → λ where
(i = i0) → ua P (~ k)
(i = i1) → ua Q (~ k))
B
pull₁ : (P Q : Bool ≃ B) → Square (ua P) (ua Q) (pull₀ P Q) refl
pull₁ P Q i j
= hcomp (λ k → λ where
(i = i0) → ua P (~ k ∨ j)
(i = i1) → ua Q (~ k ∨ j)
(j = i1) → B)
B
pull₂
: (P Q R : Bool ≃ B)
→ Square (pull₀ P Q) (pull₀ P R) refl (pull₀ Q R)
pull₂ P Q R i j
= hcomp (λ k → λ where
(j = i0) → ua P (~ k)
(i = i0) (j = i1) → ua Q (~ k)
(i = i1) (j = i1) → ua R (~ k))
B
pull₃
: (P Q R : Bool ≃ B)
→ Cube (pull₁ P Q) (pull₁ P R)
(λ _ → ua P) (pull₁ Q R)
(pull₂ P Q R) (λ _ _ → B)
pull₃ P Q R i j k
= hcomp (λ τ → λ where
(j = i0) → ua P (~ τ ∨ k)
(i = i0) (j = i1) → ua Q (~ τ ∨ k)
(i = i1) (j = i1) → ua R (~ τ ∨ k)
(k = i1) → B)
B
looped : (P Q : Bool ≃ B) → based P ≡ based Q
looped P Q = loop? b
where
b : Bool
b = rf (pull₀ P Q)
looped²
: (P Q R : Bool ≃ B)
→ Square (looped P Q) (looped P R) refl (looped Q R)
looped² P Q R = loop²? pq pr qr pqr
where
pq = rf (pull₀ P Q)
pr = rf (pull₀ P R)
qr = rf (pull₀ Q R)
pqr : Loop²-coh pq pr qr
pqr = Loop²-coh-lemma (pull₀ P Q) (pull₀ P R) (pull₀ Q R) (pull₂ P Q R)
syn : Binary _ → Bℤ₂
syn (B , tP) = rec→Gpd trunc (based B) 3k tP
where
open 3-Constant
3k : 3-Constant (based B)
3k .link = looped B
3k .coh₁ = looped² B
| 26.527638
| 77
| 0.536465
|
30e789da2d83487646d351ab3774903f20b53b9c
| 210
|
agda
|
Agda
|
test/interaction/Issue1516.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/interaction/Issue1516.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/interaction/Issue1516.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
{-# OPTIONS --copatterns #-}
record U : Set where
coinductive
field out : U
u : {A : Set} → U
u = {!!}
record Wrap (A : Set) : Set where
field
wrapped : A
wrap : ∀{A}{a : A} → Wrap A
wrap = {!!}
| 12.352941
| 33
| 0.52381
|
5ed93be5e246abcef2862380d836ff04c89e4eb0
| 1,341
|
agda
|
Agda
|
test/succeed/WithoutK.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T04:41:05.000Z
|
2019-11-27T04:41:05.000Z
|
test/succeed/WithoutK.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/WithoutK.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --universe-polymorphism #-}
module WithoutK where
open import Common.Level
-- Propositional equality.
data _≡_ {A : Set} : A → A → Set where
refl : ∀ x → x ≡ x
-- The J rule.
J : {A : Set} (P : {x y : A} → x ≡ y → Set) →
(∀ x → P (refl x)) →
∀ {x y} (x≡y : x ≡ y) → P x≡y
J P p (refl x) = p x
-- Christine Paulin-Mohring's version of the J rule.
J′ : {A : Set} {x : A} (P : {y : A} → x ≡ y → Set) →
P (refl x) →
∀ {y} (x≡y : x ≡ y) → P x≡y
J′ P p (refl x) = p
-- A variant of _≡_.
data _≡′_ {A : Set} (x : A) : A → Set where
refl : x ≡′ x
-- We normalise before checking index well-formedness.
const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A
const x _ = x
id : {A : Set} {x y : A} → const x y ≡′ const y x → x ≡′ y
id refl = refl
-- We can handle more complicated indices as well.
data ⊥ : Set where
data Bool : Set where
true false : Bool
true≢false : true ≡ false → ⊥
true≢false ()
data D : Set where
c₀ : D
c₂ : (i₁ i₂ : D) → D
f : ∀ {x y z} → x ≡ y → c₂ y c₀ ≡ c₂ c₀ z → x ≡ z
f x≡y (refl .(c₂ c₀ c₀)) = x≡y
-- The indices can contain literals.
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
g : 2 ≡ 3 → 3 ≡ 5
g ()
h : ∀ {n} → 2 ≡ suc n → n ≡ 1
h (refl .2) = refl _
| 18.887324
| 58
| 0.507084
|
352bab198bdceb40ef94aa4f37075081fa856bd1
| 21,423
|
agda
|
Agda
|
Pin.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 14
|
2015-08-18T21:40:15.000Z
|
2021-05-05T01:07:57.000Z
|
Pin.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 4
|
2018-06-07T16:27:41.000Z
|
2021-10-29T20:41:23.000Z
|
Pin.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 3
|
2016-05-29T01:56:33.000Z
|
2019-09-10T09:47:13.000Z
|
module Pin where
-- N-dimensional version of Pi
-- open import Data.Fin
open import Data.Nat
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Function renaming (_∘_ to _○_)
open import Relation.Binary.PropositionalEquality using (module ≡-Reasoning)
open ≡-Reasoning
open import Algebra
open import Data.Nat.Properties
open CommutativeSemiring commutativeSemiring using (+-commutativeMonoid)
open CommutativeMonoid +-commutativeMonoid using ()
renaming (comm to +-comm)
--infix 4 _≡_ -- propositional equality
--infixr 8 _∘_ -- path composition
infixr 10 _◎_
infixr 30 _⟷_
infixr 9 _>>>_
-- infixr 30 _⟺_
------------------------------------------------------------------------------
-- base types (or 0d types) are the usual finite types
data T : Set where
Zero : T
One : T
Plus : T → T → T
Times : T → T → T
-- Combinators on 0d types
data _⟷_ : T → T → Set where
unite₊ : { t : T } → Plus Zero t ⟷ t
uniti₊ : { t : T } → t ⟷ Plus Zero t
swap₊ : { t₁ t₂ : T } → Plus t₁ t₂ ⟷ Plus t₂ t₁
assocl₊ : { t₁ t₂ t₃ : T } → Plus t₁ (Plus t₂ t₃) ⟷ Plus (Plus t₁ t₂) t₃
assocr₊ : { t₁ t₂ t₃ : T } → Plus (Plus t₁ t₂) t₃ ⟷ Plus t₁ (Plus t₂ t₃)
unite⋆ : { t : T } → Times One t ⟷ t
uniti⋆ : { t : T } → t ⟷ Times One t
swap⋆ : { t₁ t₂ : T } → Times t₁ t₂ ⟷ Times t₂ t₁
assocl⋆ : { t₁ t₂ t₃ : T } → Times t₁ (Times t₂ t₃) ⟷ Times (Times t₁ t₂) t₃
assocr⋆ : { t₁ t₂ t₃ : T } → Times (Times t₁ t₂) t₃ ⟷ Times t₁ (Times t₂ t₃)
distz : { t : T } → Times Zero t ⟷ Zero
factorz : { t : T } → Zero ⟷ Times Zero t
dist : { t₁ t₂ t₃ : T } →
Times (Plus t₁ t₂) t₃ ⟷ Plus (Times t₁ t₃) (Times t₂ t₃)
factor : { t₁ t₂ t₃ : T } →
Plus (Times t₁ t₃) (Times t₂ t₃) ⟷ Times (Plus t₁ t₂) t₃
id⟷ : { t : T } → t ⟷ t
sym⟷ : { t₁ t₂ : T } → (t₁ ⟷ t₂) → (t₂ ⟷ t₁)
_◎_ : { t₁ t₂ t₃ : T } → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃)
_⊕_ : { t₁ t₂ t₃ t₄ : T } →
(t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (Plus t₁ t₂ ⟷ Plus t₃ t₄)
_⊗_ : { t₁ t₂ t₃ t₄ : T } →
(t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (Times t₁ t₂ ⟷ Times t₃ t₄)
-- Semantics
⟦_⟧ : T → Set
⟦ Zero ⟧ = ⊥
⟦ One ⟧ = ⊤
⟦ Plus t1 t2 ⟧ = ⟦ t1 ⟧ ⊎ ⟦ t2 ⟧
⟦ Times t1 t2 ⟧ = ⟦ t1 ⟧ × ⟦ t2 ⟧
mutual
eval : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ⟦ t₁ ⟧ → ⟦ t₂ ⟧
eval unite₊ (inj₁ ())
eval unite₊ (inj₂ v) = v
eval uniti₊ v = inj₂ v
eval swap₊ (inj₁ v) = inj₂ v
eval swap₊ (inj₂ v) = inj₁ v
eval assocl₊ (inj₁ v) = inj₁ (inj₁ v)
eval assocl₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v)
eval assocl₊ (inj₂ (inj₂ v)) = inj₂ v
eval assocr₊ (inj₁ (inj₁ v)) = inj₁ v
eval assocr₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v)
eval assocr₊ (inj₂ v) = inj₂ (inj₂ v)
eval unite⋆ (tt , v) = v
eval uniti⋆ v = (tt , v)
eval swap⋆ (v1 , v2) = (v2 , v1)
eval assocl⋆ (v1 , (v2 , v3)) = ((v1 , v2) , v3)
eval assocr⋆ ((v1 , v2) , v3) = (v1 , (v2 , v3))
eval distz (() , v)
eval factorz ()
eval dist (inj₁ v1 , v3) = inj₁ (v1 , v3)
eval dist (inj₂ v2 , v3) = inj₂ (v2 , v3)
eval factor (inj₁ (v1 , v3)) = (inj₁ v1 , v3)
eval factor (inj₂ (v2 , v3)) = (inj₂ v2 , v3)
eval id⟷ v = v
eval (sym⟷ c) v = evalB c v
eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v)
eval (c₁ ⊕ c₂) (inj₁ v) = inj₁ (eval c₁ v)
eval (c₁ ⊕ c₂) (inj₂ v) = inj₂ (eval c₂ v)
eval (c₁ ⊗ c₂) (v₁ , v₂) = (eval c₁ v₁ , eval c₂ v₂)
evalB : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ⟦ t₂ ⟧ → ⟦ t₁ ⟧
evalB unite₊ v = inj₂ v
evalB uniti₊ (inj₁ ())
evalB uniti₊ (inj₂ v) = v
evalB swap₊ (inj₁ v) = inj₂ v
evalB swap₊ (inj₂ v) = inj₁ v
evalB assocl₊ (inj₁ (inj₁ v)) = inj₁ v
evalB assocl₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v)
evalB assocl₊ (inj₂ v) = inj₂ (inj₂ v)
evalB assocr₊ (inj₁ v) = inj₁ (inj₁ v)
evalB assocr₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v)
evalB assocr₊ (inj₂ (inj₂ v)) = inj₂ v
evalB unite⋆ v = (tt , v)
evalB uniti⋆ (tt , v) = v
evalB swap⋆ (v1 , v2) = (v2 , v1)
evalB assocl⋆ ((v1 , v2) , v3) = (v1 , (v2 , v3))
evalB assocr⋆ (v1 , (v2 , v3)) = ((v1 , v2) , v3)
evalB distz ()
evalB factorz (() , v)
evalB dist (inj₁ (v1 , v3)) = (inj₁ v1 , v3)
evalB dist (inj₂ (v2 , v3)) = (inj₂ v2 , v3)
evalB factor (inj₁ v1 , v3) = inj₁ (v1 , v3)
evalB factor (inj₂ v2 , v3) = inj₂ (v2 , v3)
evalB id⟷ v = v
evalB (sym⟷ c) v = eval c v
evalB (c₁ ◎ c₂) v = evalB c₁ (evalB c₂ v)
evalB (c₁ ⊕ c₂) (inj₁ v) = inj₁ (evalB c₁ v)
evalB (c₁ ⊕ c₂) (inj₂ v) = inj₂ (evalB c₂ v)
evalB (c₁ ⊗ c₂) (v₁ , v₂) = (evalB c₁ v₁ , evalB c₂ v₂)
------------------------------------------------------------------------------
-- N dimensional version
data C : ℕ → Set where
ZD : T → C 0
Node : {n : ℕ} → C n → C n → C (suc n)
liftN : (n : ℕ) → (t : T) → C n
liftN 0 t = ZD t
liftN (suc n) t = Node (liftN n t) (liftN n Zero)
zeroN : (n : ℕ) → C n
zeroN n = liftN n Zero
oneN : (n : ℕ) → C n
oneN n = liftN n One
plus : {n : ℕ} → C n → C n → C n
plus (ZD t₁) (ZD t₂) = ZD (Plus t₁ t₂)
plus (Node c₁ c₂) (Node c₁' c₂') = Node (plus c₁ c₁') (plus c₂ c₂')
times : {m n : ℕ} → C m → C n → C (m + n)
times (ZD t1) (ZD t2) = ZD (Times t1 t2)
times (ZD t) (Node c1 c2) = Node (times (ZD t) c1) (times (ZD t) c2)
times (Node c1 c2) c = Node (times c1 c) (times c2 c)
-- Combinators on nd types
data _⟺_ : {n : ℕ} → C n → C n → Set where
baseC : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ((ZD t₁) ⟺ (ZD t₂))
nodeC : {n : ℕ} {c₁ : C n} {c₂ : C n} {c₃ : C n} {c₄ : C n} →
(c₁ ⟺ c₂) → (c₃ ⟺ c₄) → ((Node c₁ c₃) ⟺ (Node c₂ c₄))
zerolC : {n : ℕ} {c : C n} → ((Node c c) ⟺ (zeroN (suc n)))
zerorC : {n : ℕ} {c : C n} → ((zeroN (suc n)) ⟺ (Node c c))
-- Def. 2.1 lists the conditions for J-graded bipermutative category
mutual
_>>>_ = seqF
idN⟷ : {n : ℕ} {c : C n} → c ⟺ c
idN⟷ {0} {ZD t} = baseC (id⟷ {t})
idN⟷ {suc n} {Node c₁ c₂} = nodeC (idN⟷ {n} {c₁}) (idN⟷ {n} {c₂})
symN⟷ : {n : ℕ} {c₁ c₂ : C n} → (c₁ ⟺ c₂) → (c₂ ⟺ c₁)
symN⟷ (baseC f) = baseC (sym⟷ f)
symN⟷ (nodeC f g) = nodeC (symN⟷ f) (symN⟷ g)
symN⟷ (zerolC {n} {c}) = zerorC {n} {c}
symN⟷ (zerorC {n} {c}) = zerolC {n} {c}
seqF : {n : ℕ} {c₁ c₂ c₃ : C n} →
(c₁ ⟺ c₂) → (c₂ ⟺ c₃) → (c₁ ⟺ c₃)
seqF {0} (baseC f) (baseC g) = baseC (f ◎ g)
seqF {suc n} (nodeC f g) (nodeC f' g') = nodeC (seqF f f') (seqF g g')
seqF {suc n} (nodeC f g) zerolC = nodeC (seqF f {!!}) (seqF g {!!})
seqF {suc n} (nodeC f g) zerorC = {!!}
seqF {suc n} zerolC (nodeC f g) = {!!}
seqF {suc n} zerolC zerolC = {!!}
seqF {suc n} zerolC zerorC = {!!}
seqF {suc n} zerorC (nodeC f g) = {!!}
seqF {suc n} zerorC zerolC = {!!}
seqF {suc n} zerorC zerorC = {!!}
{--
plusF : {n : ℕ} {c₁ c₂ c₃ c₄ : C n} →
(c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (plus c₁ c₃ ⟺ plus c₂ c₄)
plusF (baseC f) (baseC g) = baseC (f ⊕ g)
plusF (nodeC f) (nodeC g) = nodeC {!!}
timesF : {m n : ℕ} {c₁ c₂ : C m} {c₃ c₄ : C n} →
(c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (times c₁ c₃ ⟺ times c₂ c₄)
timesF (baseC f) (baseC g) = baseC (f ⊗ g)
timesF (baseC f) (nodeC g) = nodeC {!!}
{--
nodeC (
seqF (plusF (timesF (baseC f) idN⟷) idN⟷) (
seqF (seqF (plusF swapN⋆ swapN⋆) factorN) (
seqF (timesF idN⟷ g) (
seqF (seqF distN (plusF swapN⋆ swapN⋆))
((plusF (timesF (baseC (sym⟷ f)) idN⟷) idN⟷))))))
--}
timesF (nodeC f) (baseC g) = {!!}
timesF (nodeC f) (nodeC g) = nodeC {!!}
-- nodeC (timesF f₁ g) (timesF f₂ g)
-- f : t1 <-> t2
-- g : c1 + c4 <=> c3 + c2
--?24 : plus (times (ZD t₁) c₁) (times (ZD t₂) c₄) ⟺
-- plus (times (ZD t₁) c₃) (times (ZD t₂) c₂)
{--
plus (times (ZD t₁) c₁) (times (ZD t₂) c₄) ⟺
-> s1
plus (times (ZD t2) c₁) (times (ZD t₂) c₄) ⟺
-> s2
times (ZD t2) (plus c1 c4)
-> s3
times (ZD t2) (plus c3 c2)
-> s4
plus (times (ZD t2) c3) (times (ZD t2) c2)
-> s5
plus (times (ZD t1) c3) (times (ZD t2) c2)
--}
uniteN₊ : {n : ℕ} {c : C n} → (plus (zeroN n) c) ⟺ c
uniteN₊ {0} {ZD t} = baseC (unite₊ {t})
uniteN₊ {suc n} {Node c₁ c₂} =
nodeC (seqF assocrN₊ (seqF (plusF idN⟷ swapN₊) assoclN₊))
unitiN₊ : {n : ℕ} {c : C n} → c ⟺ (plus (zeroN n) c)
unitiN₊ {0} {ZD t} = baseC (uniti₊ {t})
unitiN₊ {suc n} {Node c₁ c₂} =
nodeC (assoclN₊ >>> swapN₊ >>> (plusF idN⟷ swapN₊))
swapN₊ : { n : ℕ } { c₁ c₂ : C n } → plus c₁ c₂ ⟺ plus c₂ c₁
swapN₊ {0} {ZD t₁} {ZD t₂} = baseC (swap₊ {t₁} {t₂})
swapN₊ {suc n} {Node c₁ c₂} {Node c₁' c₂'} =
nodeC (swapN₊ >>> (plusF swapN₊ swapN₊))
assoclN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } →
plus c₁ (plus c₂ c₃) ⟺ plus (plus c₁ c₂) c₃
assoclN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocl₊ {t₁} {t₂} {t₃})
assoclN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} =
nodeC (swapN₊ >>> (plusF assocrN₊ assoclN₊))
assocrN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } →
plus (plus c₁ c₂) c₃ ⟺ plus c₁ (plus c₂ c₃)
assocrN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocr₊ {t₁} {t₂} {t₃})
assocrN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} =
nodeC (swapN₊ >>> (plusF assoclN₊ assocrN₊))
uniteN⋆ : {n : ℕ} {c : C n} → times (ZD One) c ⟺ c
uniteN⋆ {0} {ZD t} = baseC (unite⋆ {t})
uniteN⋆ {suc n} {Node c₁ c₂} = nodeC {!!}
unitiN⋆ : {n : ℕ} {c : C n} → c ⟺ times (ZD One) c
unitiN⋆ {0} {ZD t} = baseC (uniti⋆ {t})
unitiN⋆ {suc n} {Node c₁ c₂} = nodeC {!!}
-- Ugly hack or feature ???
times' : {m n : ℕ} → C n → C m → C (m + n)
times' {m} {n} c₁ c₂ rewrite +-comm m n = times c₁ c₂
swapN⋆ : {m n : ℕ} {c₁ : C m} {c₂ : C n} → times c₁ c₂ ⟺ times' c₂ c₁
swapN⋆ {0} {0} {ZD t₁} {ZD t₂} = baseC (swap⋆ {t₁} {t₂})
swapN⋆ {0} {suc n} {ZD t} {Node c₁ c₂} = {!!}
--nodeC (swapN⋆ {0} {n} {ZD t} {c₁}) (swapN⋆ {0} {n} {ZD t} {c₂})
swapN⋆ {suc m} {0} {Node c₁ c₂} {ZD t} = {!!}
--nodeC (swapN⋆ {0} {n} {c₁} {ZD t}) (swapN⋆ {0} {n} {c₂} {ZD t})
swapN⋆ {suc m} {n} {Node c₁ c₂} {c} = {!!}
--nodeC (swapN⋆ {m} {n} {c₁} {c}) (swapN⋆ {m} {n} {c₂} {c})
TODO : Set
TODO = {!!}
assoclN⋆ : {m n k : ℕ} {c₁ : C m} {c₂ : C n} {c₃ : C k} → TODO
-- times c₁ (times c₂ c₃) ⟺ times (times c₁ c₂) c₃
assoclN⋆ = {!!}
assocrN⋆ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } → TODO
-- times (times c₁ c₂) c₃ ⟺ times c₁ (times c₂ c₃)
assocrN⋆ = {!!}
distzN : {m n : ℕ} {c : C n} → times (zeroN m) c ⟺ zeroN (m + n)
distzN {0} {0} {ZD t} = baseC (distz {t})
distzN {0} {suc n} {Node c₁ c₂} = nodeC {!!}
-- nodeC (distzN {0} {n} {c₁}) (distzN {0} {n} {c₂})
distzN {suc m} {n} {c} = nodeC {!!}
-- nodeC (distzN {m} {n} {c}) (distzN {m} {n} {c})
factorzN : { m n : ℕ } { c : C n } → zeroN (m + n) ⟺ times (zeroN m) c
factorzN {0} {0} {ZD t} = baseC (factorz {t})
factorzN {0} {suc n} {Node c₁ c₂} = nodeC {!!}
-- nodeC (factorzN {0} {n} {c₁}) (factorzN {0} {n} {c₂})
factorzN {suc m} {n} {c} = nodeC {!!}
-- nodeC (factorzN {m} {n} {c}) (factorzN {m} {n} {c})
distN : {m n : ℕ} {c₁ c₂ : C m} {c₃ : C n} →
times (plus c₁ c₂) c₃ ⟺ plus (times c₁ c₃) (times c₂ c₃)
distN {0} {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (dist {t₁} {t₂} {t₃})
distN {0} {suc n} {ZD t₁} {ZD t₂} {Node c₁ c₂} = nodeC {!!}
-- nodeC
-- (distN {0} {n} {ZD t₁} {ZD t₂} {c₁})
-- (distN {0} {n} {ZD t₁} {ZD t₂} {c₂})
distN {suc m} {n} {Node c₁ c₂} {Node c₃ c₄} {c} = nodeC {!!}
-- nodeC
-- ((distN {m} {n} {c₁} {c₃} {c}))
-- ((distN {m} {n} {c₂} {c₄} {c}))
factorN : {m n : ℕ} {c₁ c₂ : C m} {c₃ : C n} →
plus (times c₁ c₃) (times c₂ c₃) ⟺ times (plus c₁ c₂) c₃
factorN {0} {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (factor {t₁} {t₂} {t₃})
factorN {0} {suc n} {ZD t₁} {ZD t₂} {Node c₁ c₂} = nodeC {!!}
-- nodeC
-- (factorN {0} {n} {ZD t₁} {ZD t₂} {c₁})
-- (factorN {0} {n} {ZD t₁} {ZD t₂} {c₂})
factorN {suc m} {n} {Node c₁ c₂} {Node c₃ c₄} {c} = nodeC {!!}
-- nodeC
-- ((factorN {m} {n} {c₁} {c₃} {c}))
-- ((factorN {m} {n} {c₂} {c₄} {c}))
--?25 : plus (times .c₁ .c₃) (times .c₆ .c₄) ⟺
-- plus (times .c₅ .c₃) (times .c₂ .c₄)
{--
data _⟺_ : {n : ℕ} → C n → C n → Set where
baseC : {t₁ t₂ : T} → (t₁ ⟷ t₂) → ((ZD t₁) ⟺ (ZD t₂))
nodeC : {n : ℕ} {c₁ : C n} {c₂ : C n} {c₃ : C n} {c₄ : C n} →
(plus c₁ c₄ ⟺ plus c₃ c₂) →
((Node c₁ c₃) ⟺ (Node c₂ c₄))
--}
-- eta/epsilon/trace
------------------------------------------------------------------------------
-- Semantics
⟦_⟧C : {n : ℕ} → C n → Set
⟦_⟧C (ZD t) = ⟦ t ⟧
⟦_⟧C (Node c₁ c₂) = ⟦ c₁ ⟧C ⊎ ⟦ c₂ ⟧C
evalC : {n : ℕ} {c₁ c₂ : C n} → (c₁ ⟺ c₂) → ⟦ c₁ ⟧C → ⟦ c₂ ⟧C
evalC (baseC iso) v = eval iso v
evalC (nodeC iso) (inj₁ v) = {!!} -- inj₁ (evalC iso v)
evalC (nodeC iso) (inj₂ v) = {!!} -- inj₂ (evalC iso v)
------------------------------------------------------------------------------
-- Example
-- Let's try a 3d program
Bool : T
Bool = Plus One One
vtrue : ⟦ Bool ⟧
vtrue = inj₁ tt
vfalse : ⟦ Bool ⟧
vfalse = inj₂ tt
Bool² : T
Bool² = Times Bool Bool
Bool³ : T
Bool³ = Times Bool² Bool
cond : {t₁ t₂ : T} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) →
((Times Bool t₁) ⟷ (Times Bool t₂))
cond f g = dist ◎ ((id⟷ ⊗ f) ⊕ (id⟷ ⊗ g)) ◎ factor
controlled : {t : T} → (t ⟷ t) → ((Times Bool t) ⟷ (Times Bool t))
controlled f = cond f id⟷
cnot : Bool² ⟷ Bool²
cnot = controlled swap₊
toffoli : Bool³ ⟷ Bool³
toffoli = assocr⋆ ◎ controlled cnot ◎ assocl⋆
test₁ : ⟦ Bool³ ⟧
test₁ = eval toffoli ((vtrue , vtrue) , vfalse)
--
condN : {n : ℕ} {c₁ c₂ : C n} → (c₁ ⟺ c₂) → (c₁ ⟺ c₂) →
((times (ZD Bool) c₁) ⟺ (times (ZD Bool) c₂))
condN {n} {c₁} {c₂} f g =
(seqF (distN {0} {n} {ZD One} {ZD One} {c₁})
(seqF (plusF {n}
(timesF {0} {n} (idN⟷ {0} {ZD One}) f)
(timesF {0} {n} (idN⟷ {0} {ZD One}) g))
(factorN {0} {n} {ZD One} {ZD One} {c₂})))
controlledN : {n : ℕ} {c : C n} →
(c ⟺ c) → ((times (ZD Bool) c) ⟺ (times (ZD Bool) c))
controlledN f = condN f idN⟷
BoolN : (n : ℕ) → C n
BoolN n = plus (oneN n) (oneN n)
{--
Note: liftN 3 Bool is not quite the same as plus (oneN 3) (oneN 3)
plus (oneN 3) (oneN 3)
=
Node
(Node
(Node (ZD (Plus One One)) (ZD (Plus Zero Zero)))
(Node (ZD (Plus Zero Zero)) (ZD (Plus Zero Zero))))
(Node
(Node (ZD (Plus Zero Zero)) (ZD (Plus Zero Zero)))
(Node (ZD (Plus Zero Zero)) (ZD (Plus Zero Zero))))
liftN 3 Bool
=
Node
(Node
(Node (ZD (Plus One One)) (ZD Zero))
(Node (ZD Zero) (ZD Zero)))
(Node
(Node (ZD Zero) (ZD Zero))
(Node (ZD Zero) (ZD Zero)))
--}
cnotN : {n : ℕ} → ((times (ZD Bool) (BoolN n)) ⟺ (times (ZD Bool) (BoolN n)))
cnotN {n} = controlledN {n} (swapN₊ {n} {oneN n} {oneN n})
-- Can't do toffoliN until we get all the products done
--}
------------------------------------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
{--
CODE THAT TRIED TO KEEP PROOF THAT DIMENSIONS ARE EQUAL
------------------------------------------------------------------------------
-- Types indexed by dimension... n-dimensional cubes
-- n-dimensional types represented as trees of depth n
-- Silly lemmas that should be in the library somewhere
suc-inj : {m n : ℕ} → suc m ≡ suc n → m ≡ n
suc-inj {0} {0} refl = refl
suc-inj {0} {suc i} ()
suc-inj {suc i} {suc .i} refl = refl
data C : ℕ → Set where
ZD : T → C 0
Node : {m n : ℕ} → C m → C n → (m ≡ n) → C (suc n)
Lower : {n : ℕ} → (c₁ c₂ : C n) → (c₁ ≡ c₂) → C 0
zeroN : (n : ℕ) → C n
zeroN 0 = ZD Zero
zeroN (suc n) = Node (zeroN n) (zeroN n) refl
plus : {m n : ℕ} → C m → C n → (m ≡ n) → C n
plus (ZD _) (Node _ _ _) ()
plus (Node _ _ _) (ZD _) ()
plus (ZD t1) (ZD t2) refl = ZD (Plus t1 t2)
plus {suc .m₂} {suc .m₂'}
(Node {m₁} {m₂} c1 c2 p₁)
(Node {m₁'} {m₂'} c1' c2' p₁') p =
Node (plus c1 c1' q)
(plus c2 c2' (suc-inj p))
p₁'
where q = begin
m₁
≡⟨ p₁ ⟩
m₂
≡⟨ suc-inj p ⟩
m₂'
≡⟨ sym p₁' ⟩
m₁' ∎
plus _ _ _ = {!!}
times : {m n : ℕ} → C m → C n → C (m + n)
times (ZD t1) (ZD t2) = ZD (Times t1 t2)
times (ZD t) (Node c1 c2 p) = Node (times (ZD t) c1) (times (ZD t) c2) p
times {n = n} (Node c1 c2 p) c =
Node (times c1 c) (times c2 c) (cong (λ z → z + n) p)
times _ _ = {!!}
-- Combinators on nd types
data _⟺_ : {m n : ℕ} → C m → C n → (m ≡ n) → Set where
baseC : { t₁ t₂ : T } → (t₁ ⟷ t₂) → (_⟺_ (ZD t₁) (ZD t₂) refl)
nodeC : {m n k l : ℕ} {c₁ : C m} {c₂ : C n} {c₃ : C k} {c₄ : C l}
{p₁ : m ≡ n} {p₂ : k ≡ l} {p : k ≡ m} →
(_⟺_ c₁ c₂ p₁) → (_⟺_ c₃ c₄ p₂) →
(_⟺_ (Node c₁ c₃ (sym p))
(Node c₂ c₄ (trans (trans (sym p₁) (sym p)) p₂))
(cong suc p₂))
eta : {m : ℕ} {c : C m} → _⟺_ (ZD Zero) (Lower c c refl) refl
-- Def. 2.1 lists the conditions for J-graded bipermutative category
-- (0)
-- the additive unit and assoc are implicit in the paper
uniteN₊ : {m : ℕ} {c : C m} → _⟺_ (plus (zeroN m) c refl) c refl
uniteN₊ {0} {ZD t} = baseC (unite₊ {t})
uniteN₊ {suc m} {Node {n} {.m} c₁ c₂ n≡m} = {!!}
uniteN₊ {_} {_} = {!!}
unitiN₊ : {m : ℕ} {c : C m} → _⟺_ c (plus (zeroN m) c refl) refl
unitiN₊ {0} {ZD t} = baseC (uniti₊ {t})
unitiN₊ {suc m} {Node {n} {.m} c₁ c₂ n≡m} = {!!}
-- nodeC (unitiN₊ {n} {c₁}) (unitiN₊ {n} {c₂})
unitiN₊ {_} {_} = {!!}
assoclN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } →
plus c₁ (plus c₂ c₃) ⟺ plus (plus c₁ c₂) c₃
assoclN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocl₊ {t₁} {t₂} {t₃})
assoclN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} =
nodeC (assoclN₊ {n} {c₁} {c₃} {c₅}) (assoclN₊ {n} {c₂} {c₄} {c₆})
assocrN₊ : { n : ℕ } { c₁ c₂ c₃ : C n } →
plus (plus c₁ c₂) c₃ ⟺ plus c₁ (plus c₂ c₃)
assocrN₊ {0} {ZD t₁} {ZD t₂} {ZD t₃} = baseC (assocr₊ {t₁} {t₂} {t₃})
assocrN₊ {suc n} {Node c₁ c₂} {Node c₃ c₄} {Node c₅ c₆} =
nodeC (assocrN₊ {n} {c₁} {c₃} {c₅}) (assocrN₊ {n} {c₂} {c₄} {c₆})
-- (1) have times functor on objects
-- define times functor on combinators
-- timesF should satisfying assoc and unitality conditions...
-- diagram on top of p.6 should commute
timesF : { m n : ℕ } { c₁ : C m } { c₂ : C m } { c₃ : C n } { c₄ : C n } →
(c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (times c₁ c₃ ⟺ times c₂ c₄)
timesF {0} {0} {ZD t₁} {ZD t₂} {ZD t₃} {ZD t₄} (baseC f) (baseC g) =
baseC (_⊗_ {t₁} {t₃} {t₂} {t₄} f g)
timesF {0} {suc n} {ZD t₁} {ZD t₂} {Node c₁ c₂} {Node c₃ c₄}
(baseC f) (nodeC g₁ g₂) = nodeC (timesF (baseC f) g₁) (timesF (baseC f) g₂)
timesF {suc m} {n} {Node c₁ c₂} {Node c₃ c₄} {c₅} {c₆}
(nodeC f₁ f₂) g = nodeC (timesF f₁ g) (timesF f₂ g)
-- (2) there is a unit object One of dimension 0
uniteN⋆ : {n : ℕ} {c : C n} → times (ZD One) c ⟺ c
uniteN⋆ {0} {ZD t} = baseC (unite⋆ {t})
uniteN⋆ {suc n} {Node c₁ c₂} = nodeC (uniteN⋆ {n} {c₁}) (uniteN⋆ {n} {c₂})
unitiN⋆ : {n : ℕ} {c : C n} → c ⟺ times (ZD One) c
unitiN⋆ {0} {ZD t} = baseC (uniti⋆ {t})
unitiN⋆ {suc n} {Node c₁ c₂} = nodeC (unitiN⋆ {n} {c₁}) (unitiN⋆ {n} {c₂})
-- (3) swap
swapN⋆ : {m n : ℕ} {c₁ : C m} {c₂ : C n} → times c₁ c₂ ⟺ times c₂ c₁
swapN⋆ {0} {0} {ZD t₁} {ZD t₂} = baseC (swap⋆ {t₁} {t₂})
swapN⋆ = ?
swapN₊ : { n : ℕ } { c₁ c₂ : C n } → plus c₁ c₂ ⟺ plus c₂ c₁
swapN₊ {0} {ZD t₁} {ZD t₂} = baseC (swap₊ {t₁} {t₂})
swapN₊ {suc n} {Node c₁ c₂} {Node c₁' c₂'} =
nodeC (swapN₊ {n} {c₁} {c₁'}) (swapN₊ {n} {c₂} {c₂'})
distzN : {m n : ℕ} {c : C n} → times (zeroN m) c ⟺ zeroN (m + n)
distzN {0} {0} {ZD t} = baseC (distz {t})
distzN {0} {suc n} {Node c₁ c₂} =
nodeC (distzN {0} {n} {c₁}) (distzN {0} {n} {c₂})
distzN {suc m} {n} {c} =
nodeC (distzN {m} {n} {c}) (distzN {m} {n} {c})
------------------------------------------------------------------------------
assocl⋆ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } →
times c₁ (times c₂ c₃) ⟺ times (times c₁ c₂) c₃
assocr⋆ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } →
times (times c₁ c₂) c₃ ⟺ times c₁ (times c₂ c₃)
distz : { m n : ℕ } { c : C n } → times (zeroN m) c ⟺ zeroN m
factorz : { m n : ℕ } { c : C n } → zeroN m ⟺ times (zeroN m) c
dist : { m n : ℕ } { c₁ c₂ : C m } { c₃ : C n } →
times (plus c₁ c₂) c₃ ⟺ plus (times c₁ c₃) (times c₂ c₃)
factor : { m n : ℕ } { c₁ c₂ : C m } { c₃ : C n } →
plus (times c₁ c₃) (times c₂ c₃) ⟺ times (plus c₁ c₂) c₃
id⟷ : { n : ℕ } { c : C n } → c ⟺ c
sym : { m n : ℕ } { c₁ : C m } { c₂ : C n } → (c₁ ⟺ c₂) → (c₂ ⟺ c₁)
_◎_ : { m n k : ℕ } { c₁ : C m } { c₂ : C n } { c₃ : C k } →
(c₁ ⟺ c₂) → (c₂ ⟺ c₃) → (c₁ ⟺ c₃)
_⊕_ : { m n : ℕ } { c₁ c₃ : C m } { c₂ c₄ : C n } →
(c₁ ⟺ c₂) → (c₃ ⟺ c₄) → (plus c₁ c₃ ⟺ plus c₂ c₄)
------------------------------------------------------------------------------
-- Semantics
-- probably should have our own × ?
-- should be a sum !
-- we have a value in one of the corners; not in all of them at once
⟦_⟧C : {n : ℕ} → C n → Set
⟦_⟧C (ZD t) = ⟦ t ⟧
⟦_⟧C (Node c₁ c₂ _) = ⟦ c₁ ⟧C ⊎ ⟦ c₂ ⟧C
⟦_⟧C (Lower c₁ c₂ _) = ⊥
evalC : {n m : ℕ} {c₁ : C n} {c₂ : C m} {p : n ≡ m} →
_⟺_ c₁ c₂ p → ⟦ c₁ ⟧C → ⟦ c₂ ⟧C
evalC (baseC iso) v = eval iso v
evalC (nodeC isoL isoR) (inj₁ v) = inj₁ (evalC isoL v)
evalC (nodeC isoL isoR) (inj₂ v) = inj₂ (evalC isoR v)
evalC _ _ = {!!}
-- now add etas and epsilons...
--}
| 34.167464
| 82
| 0.479205
|
033c4bd9c34ef79d2e436c19ad81fef9860f3e9e
| 3,378
|
agda
|
Agda
|
src/Categories/Functor/Monoidal/Symmetric.agda
|
bolt12/agda-categories
|
b813fa3e685eb4713bace6204b8084a343d549a3
|
[
"MIT"
] | 1
|
2021-04-18T18:21:47.000Z
|
2021-04-18T18:21:47.000Z
|
src/Categories/Functor/Monoidal/Symmetric.agda
|
andrejbauer/agda-categories
|
d07746023503cc8f49670e309a6170dc4b404b95
|
[
"MIT"
] | null | null | null |
src/Categories/Functor/Monoidal/Symmetric.agda
|
andrejbauer/agda-categories
|
d07746023503cc8f49670e309a6170dc4b404b95
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Monoidal.Structure
using (SymmetricMonoidalCategory)
module Categories.Functor.Monoidal.Symmetric {o o′ ℓ ℓ′ e e′}
(C : SymmetricMonoidalCategory o ℓ e) (D : SymmetricMonoidalCategory o′ ℓ′ e′)
where
open import Level
open import Data.Product using (_,_)
open import Categories.Category using (module Commutation)
open import Categories.Functor using (Functor)
open import Categories.Functor.Monoidal
open import Categories.NaturalTransformation.NaturalIsomorphism
using (NaturalIsomorphism)
open NaturalIsomorphism
private
module C = SymmetricMonoidalCategory C
module D = SymmetricMonoidalCategory D
module Lax where
-- Lax symmetric monoidal functors.
record IsSymmetricMonoidalFunctor (F : Functor C.U D.U)
: Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
open Functor F
field
isMonoidal : IsMonoidalFunctor C.monoidalCategory D.monoidalCategory F
open IsMonoidalFunctor isMonoidal public
open D
open Commutation D.U
-- coherence condition
field
braiding-compat : ∀ {X Y} →
[ F₀ X ⊗₀ F₀ Y ⇒ F₀ (Y C.⊗₀ X) ]⟨
⊗-homo.η (X , Y) ⇒⟨ F₀ (X C.⊗₀ Y) ⟩
F₁ (C.braiding.⇒.η (X , Y))
≈ D.braiding.⇒.η (F₀ X , F₀ Y) ⇒⟨ F₀ Y ⊗₀ F₀ X ⟩
⊗-homo.η (Y , X)
⟩
record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
F : Functor C.U D.U
isSymmetricMonoidal : IsSymmetricMonoidalFunctor F
open Functor F public
open IsSymmetricMonoidalFunctor isSymmetricMonoidal public
monoidalFunctor : MonoidalFunctor C.monoidalCategory D.monoidalCategory
monoidalFunctor = record { F = F ; isMonoidal = isMonoidal }
module Strong where
-- Strong symmetric monoidal functors.
record IsSymmetricMonoidalFunctor (F : Functor C.U D.U)
: Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where
open Functor F
field
isStrongMonoidal : IsStrongMonoidalFunctor C.monoidalCategory
D.monoidalCategory F
open IsStrongMonoidalFunctor isStrongMonoidal public
open D
open Commutation D.U
-- coherence condition
field
braiding-compat : ∀ {X Y} →
[ F₀ X ⊗₀ F₀ Y ⇒ F₀ (Y C.⊗₀ X) ]⟨
⊗-homo.⇒.η (X , Y) ⇒⟨ F₀ (X C.⊗₀ Y) ⟩
F₁ (C.braiding.⇒.η (X , Y))
≈ D.braiding.⇒.η (F₀ X , F₀ Y) ⇒⟨ F₀ Y ⊗₀ F₀ X ⟩
⊗-homo.⇒.η (Y , X)
⟩
isLaxSymmetricMonoidal : Lax.IsSymmetricMonoidalFunctor F
isLaxSymmetricMonoidal = record
{ isMonoidal = isMonoidal
; braiding-compat = braiding-compat
}
record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
F : Functor C.U D.U
isSymmetricMonoidal : IsSymmetricMonoidalFunctor F
open Functor F public
open IsSymmetricMonoidalFunctor isSymmetricMonoidal public
monoidalFunctor : StrongMonoidalFunctor C.monoidalCategory
D.monoidalCategory
monoidalFunctor = record { F = F ; isStrongMonoidal = isStrongMonoidal }
| 31.867925
| 80
| 0.588218
|
0b036aa6eb8d83aa9c7cccc401a3e22c6395318c
| 11,585
|
agda
|
Agda
|
Structure/Type/Identity/Proofs/Eliminator.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Type/Identity/Proofs/Eliminator.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Type/Identity/Proofs/Eliminator.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Structure.Type.Identity.Proofs.Eliminator where
import Lvl
open import Functional using (_→ᶠ_ ; id ; _on₂_ ; swap ; apply)
open import Logic
open import Logic.Propositional
open import Logic.Propositional.Proofs.Structures
open import Structure.Categorical.Properties
open import Structure.Function
open import Structure.Operator
open import Structure.Groupoid
open import Structure.Setoid using (Equiv ; intro) renaming (_≡_ to _≡ₛ_)
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Relator.Properties.Proofs
open import Structure.Relator
open import Structure.Type.Identity
open import Structure.Type.Identity.Proofs
open import Syntax.Function
open import Syntax.Transitivity
open import Syntax.Type
open import Type
private variable ℓ ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂ ℓₑ ℓₘₑ ℓₚ ℓₒ : Lvl.Level
private variable T A B : Type{ℓ}
private variable x y : T
private variable Id _≡_ _▫_ : T → T → Stmt{ℓ}
module Oper (Id : T → T → Type{ℓₑ}) ⦃ refl : Reflexivity(Id) ⦄ ⦃ identElim : IdentityEliminator{ℓₚ = ℓₑ}(Id) ⦄ where
open Symmetry (identity-eliminator-to-symmetry {Id = Id}) using () renaming (proof to sym) public
open Transitivity(identity-eliminator-to-transitivity {Id = Id}) using () renaming (proof to trans) public
ftrans = identity-eliminator-to-flipped-transitivityᵣ ⦃ refl ⦄ ⦃ identElim ⦄
module Oper2 (Id : A → A → Type{ℓₑ}) ⦃ refl : Reflexivity(Id) ⦄ ⦃ identElim : IdentityEliminator{ℓₚ = ℓₚ}(Id) ⦄ where
open Reflexivity (refl) using () renaming (proof to refl) public
module _ (_▫_ : A → A → Type{ℓₚ}) ⦃ [▫]-refl : Reflexivity(_▫_) ⦄ where
open _⊆₂_ identity-eliminator-to-reflexive-subrelation using () renaming (proof to sub) public
module _ (_▫_ : B → B → Type{ℓₚ}) ⦃ [▫]-refl : Reflexivity(_▫_) ⦄ (f : A → B) where
open _⊆₂_ (minimal-reflection-transport ⦃ minRefl = identity-eliminator-to-reflexive-subrelation ⦄ {_▫_ = _▫_} {f = f}) using () renaming (proof to transp) public
module _
{Id : T → T → Type{ℓₑ}} ⦃ refle-T : Reflexivity(Id) ⦄ ⦃ identElim-T : IdentityEliminator(Id) ⦄
{_≡_ : ∀{T : Type{ℓₑ}} → T → T → Type{ℓₘₑ}}
⦃ identElimOfIntro : IdentityEliminationOfIntro(Id)(_≡_) ⦄
where
open Oper(Id)
open Oper2{ℓₚ = ℓₑ}(Id)
identity-eliminator-symmetry-of-refl : ∀{x} → (sym refl ≡ refl{x})
identity-eliminator-symmetry-of-refl = idElimOfIntro(Id)(_≡_) (\{x y} _ → (Id y x)) refl
module _
{Id : T → T → Type{ℓₑ₁}} ⦃ refle-T : Reflexivity(Id) ⦄ ⦃ identElim-T : IdentityEliminator(Id) ⦄
{_≡_ : ∀{T : Type{ℓₑ₂}} → T → T → Type{ℓₘₑ}}
⦃ identElimOfIntro : IdentityEliminationOfIntro(Id)(_≡_) ⦄
{_▫_ : T → T → Type{ℓₑ₂}} ⦃ refl-op : Reflexivity(_▫_) ⦄
where
open Oper(Id)
open Oper2{ℓₚ = ℓₑ₂}(Id)
identity-eliminator-reflexive-subrelation-of-refl : ∀{x} → (sub(_▫_) refl ≡ reflexivity(_▫_){x})
identity-eliminator-reflexive-subrelation-of-refl = idElimOfIntro(Id)(_≡_) (\{x y} _ → (x ▫ y)) (reflexivity(_▫_))
module _
{Id : A → A → Type{ℓₑ₁}} ⦃ refle-A : Reflexivity(Id) ⦄ ⦃ identElim-A : IdentityEliminator(Id) ⦄
{_≡_ : ∀{T : Type{ℓₑ₂}} → T → T → Type{ℓₘₑ}}
⦃ identElimOfIntro : IdentityEliminationOfIntro(Id)(_≡_) ⦄
{_▫_ : B → B → Type{ℓₑ₂}} ⦃ refle-B : Reflexivity(_▫_) ⦄
{f : A → B}
where
open Oper(Id)
open Oper2{ℓₚ = ℓₑ₂}(Id)
identity-eliminator-transport-of-refl : ∀{a} → (transp(_▫_)(f) (refl{a}) ≡ reflexivity(_▫_) {f(a)})
identity-eliminator-transport-of-refl {a} = identity-eliminator-reflexive-subrelation-of-refl {_≡_ = _≡_} {_▫_ = (_▫_) on₂ f} ⦃ on₂-reflexivity ⦄ {x = a}
module _
{Id : T → T → Type{ℓₑ}}
⦃ refle-T : Reflexivity(Id) ⦄
⦃ identElim-T : IdentityEliminator(Id) ⦄
{_≡_ : ∀{T : Type{ℓₑ}} → T → T → Type{ℓₘₑ}}
⦃ refle-eq : ∀{T : Type} → Reflexivity(_≡_ {T = T}) ⦄
⦃ identElim-eq : ∀{T : Type} → IdentityEliminator{ℓₚ = ℓₘₑ}(_≡_ {T = T}) ⦄
⦃ identElimOfIntro : IdentityEliminationOfIntro(Id)(_≡_) ⦄
where
open Oper(Id)
open Oper2{ℓₚ = ℓₑ}(Id)
instance _ = identity-eliminator-to-reflexive-subrelation
identity-eliminator-flipped-transitivityᵣ-of-refl : ∀{x} → (ftrans refl refl ≡ refl{x})
identity-eliminator-flipped-transitivityᵣ-of-refl {z} = sub₂(_≡_)((_≡_) on₂ (apply refl)) ⦃ minimal-reflection-transport ⦄ identity-eliminator-transport-of-refl
identity-eliminator-transitivity-of-refl : ∀{x} → (trans refl refl ≡ refl{x})
identity-eliminator-transitivity-of-refl = transitivity(_≡_) ⦃ identity-eliminator-to-transitivity ⦄ p identity-eliminator-flipped-transitivityᵣ-of-refl where
p : trans refl refl ≡ ftrans refl refl
p = sub₂(_≡_)((_≡_) on₂ (p ↦ identity-eliminator-to-flipped-transitivityᵣ p refl)) ⦃ minimal-reflection-transport ⦄ identity-eliminator-symmetry-of-refl
module _
⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄
⦃ identElim-A : IdentityEliminator(Equiv._≡_ equiv-A) ⦄
⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄
{_≡_ : ∀{T : Type{ℓₑ₂}} → T → T → Type{ℓₘₑ}}
⦃ identElimOfIntro : IdentityEliminationOfIntro(Equiv._≡_ equiv-A)(_≡_) ⦄
where
open Reflexivity(Equiv.reflexivity equiv-A) using () renaming (proof to refl-A)
open Reflexivity(Equiv.reflexivity equiv-B) using () renaming (proof to refl-B)
instance _ = identity-eliminator-to-reflexive-subrelation
instance _ = minimal-reflection-to-function
identity-eliminator-function-of-refl : ∀{f : A → B}{a} → (congruence₁(f) (refl-A {a}) ≡ refl-B {f(a)})
identity-eliminator-function-of-refl = identity-eliminator-transport-of-refl
module _
⦃ equiv-T : Equiv{ℓₑ₁}(T) ⦄
⦃ identElim-T : IdentityEliminator(Equiv._≡_ equiv-T) ⦄
{_≡_ : ∀{T : Type{ℓₑ₂}} → T → T → Type{ℓₘₑ}}
⦃ refle-eq : ∀{T : Type} → Reflexivity(_≡_ {T = T}) ⦄
⦃ identElim-eq : ∀{T : Type} → IdentityEliminator{ℓₚ = ℓₘₑ}(_≡_ {T = T}) ⦄
⦃ identElimOfIntro : IdentityEliminationOfIntro(Equiv._≡_ equiv-T)(_≡_) ⦄
where
open Reflexivity(Equiv.reflexivity equiv-T) using () renaming (proof to refl)
instance _ = identity-eliminator-to-reflexive-subrelation
instance _ = minimal-reflection-to-relator
identity-eliminator-relator-of-refl : ∀{P : T → Stmt}{x}{p : P(x)} → (substitute₁(P) refl p ≡ p)
identity-eliminator-relator-of-refl {p = p} = sub₂(_≡_)((_≡_) on₂ (apply p)) ⦃ minimal-reflection-transport ⦄ identity-eliminator-transport-of-refl
module _
{Id : T → T → Type{ℓₑ}}
⦃ refle-T : Reflexivity(Id) ⦄
⦃ identElim-T : ∀{ℓₚ} → IdentityEliminator{ℓₚ = ℓₚ}(Id) ⦄
-- ⦃ identElim₁-T : IdentityEliminator{ℓₚ = ℓₑ}(Id) ⦄
-- ⦃ identElim₂-T : IdentityEliminator{ℓₚ = ℓₘₑ}(Id) ⦄
-- ⦃ identElim₃-T : IdentityEliminator{ℓₚ = ℓₑ Lvl.⊔ ℓₘₑ}(Id) ⦄
{_≡_ : ∀{T : Type{ℓₑ}} → T → T → Type{ℓₘₑ}}
⦃ refle-eq : ∀{T : Type} → Reflexivity(_≡_ {T = T}) ⦄
⦃ identElim-eq : ∀{T : Type} → IdentityEliminator{ℓₚ = ℓₘₑ}(_≡_ {T = T}) ⦄ -- TODO: Try to not have these and instead have the properties that are used
⦃ identElimOfIntro : IdentityEliminationOfIntro(Id)(_≡_) ⦄
where
open Reflexivity (refle-T) using () renaming (proof to refl)
open Symmetry (identity-eliminator-to-symmetry {Id = Id}) using () renaming (proof to sym)
open Transitivity(identity-eliminator-to-transitivity {Id = Id}) using () renaming (proof to trans)
instance _ = identity-eliminator-to-reflexive-subrelation
instance _ = \{T} → identity-eliminator-to-symmetry {Id = _≡_ {T = T}} ⦃ refl = refle-eq ⦄ ⦃ identElim = identElim-eq ⦄
instance _ = \{T} → identity-eliminator-to-transitivity {Id = _≡_ {T = T}} ⦃ refl = refle-eq ⦄ ⦃ identElim = identElim-eq ⦄
instance _ = \{T} → Structure.Setoid.intro(_) ⦃ identity-eliminator-to-equivalence {Id = _≡_ {T = T}} ⦃ refl = refle-eq ⦄ ⦃ identElim = identElim-eq ⦄ ⦄
identity-eliminator-identityₗ : ∀{x y}{p : Id x y} → (trans refl p ≡ p)
identity-eliminator-identityₗ {p = p} = idElim(Id) (p ↦ (trans refl p ≡ p)) identity-eliminator-transitivity-of-refl p
identity-eliminator-identityᵣ : ∀{x y}{p : Id x y} → (trans p refl ≡ p)
identity-eliminator-identityᵣ {p = p} = idElim(Id) (p ↦ (trans p refl ≡ p)) identity-eliminator-transitivity-of-refl p
identity-eliminator-associativity : ∀{x y z w}{p : Id x y}{q : Id y z}{r : Id z w} → (trans (trans p q) r ≡ trans p (trans q r))
identity-eliminator-associativity {p = p} {q = q} {r = r} =
idElim(Id)
(p ↦ ∀ q r → (trans (trans p q) r ≡ trans p (trans q r)))
(q ↦ r ↦ (
trans (trans refl q) r 🝖[ _≡_ ]-[ sub₂(_≡_)((_≡_) on₂ (expr ↦ trans expr r)) ⦃ identity-eliminator-to-reflexive-subrelation ⦃ refl = on₂-reflexivity ⦄ ⦄ identity-eliminator-identityₗ ]
trans q r 🝖[ _≡_ ]-[ identity-eliminator-identityₗ ]-sym
trans refl (trans q r) 🝖-end
))
p q r
identity-eliminator-inverseₗ : ∀{x y}{p : Id x y} → (trans (sym p) p ≡ refl)
identity-eliminator-inverseₗ {p = p} =
idElim(Id)
(p ↦ trans (sym p) p ≡ refl)
(
trans (sym refl) refl 🝖[ _≡_ ]-[ identity-eliminator-identityᵣ ]
sym refl 🝖[ _≡_ ]-[ identity-eliminator-symmetry-of-refl ]
refl 🝖-end
)
p
identity-eliminator-inverseᵣ : ∀{x y}{p : Id x y} → (trans p (sym p) ≡ refl)
identity-eliminator-inverseᵣ {p = p} =
idElim(Id)
(p ↦ trans p (sym p) ≡ refl)
(
trans refl (sym refl) 🝖[ _≡_ ]-[ identity-eliminator-identityₗ ]
sym refl 🝖[ _≡_ ]-[ identity-eliminator-symmetry-of-refl ]
refl 🝖-end
)
p
identity-eliminator-categorical-identityₗ : Morphism.Identityₗ{Obj = T} (\{x} → swap(trans{x})) (refl)
identity-eliminator-categorical-identityₗ = Morphism.intro identity-eliminator-identityᵣ
identity-eliminator-categorical-identityᵣ : Morphism.Identityᵣ{Obj = T} (\{x} → swap(trans{x})) (refl)
identity-eliminator-categorical-identityᵣ = Morphism.intro identity-eliminator-identityₗ
identity-eliminator-categorical-identity : Morphism.Identity{Obj = T} (\{x} → swap(trans{x})) (refl)
identity-eliminator-categorical-identity = [∧]-intro identity-eliminator-categorical-identityₗ identity-eliminator-categorical-identityᵣ
identity-eliminator-categorical-associativity : Morphism.Associativity{Obj = T} (\{x} → swap(trans{x}))
identity-eliminator-categorical-associativity = Morphism.intro (symmetry(_≡_) identity-eliminator-associativity)
identity-eliminator-categorical-inverterₗ : Polymorphism.Inverterₗ{Obj = T} (\{x} → swap(trans{x})) (refl) (sym)
identity-eliminator-categorical-inverterₗ = Polymorphism.intro identity-eliminator-inverseᵣ
identity-eliminator-categorical-inverterᵣ : Polymorphism.Inverterᵣ{Obj = T} (\{x} → swap(trans{x})) (refl) (sym)
identity-eliminator-categorical-inverterᵣ = Polymorphism.intro identity-eliminator-inverseₗ
identity-eliminator-categorical-inverter : Polymorphism.Inverter{Obj = T} (\{x} → swap(trans{x})) (refl) (sym)
identity-eliminator-categorical-inverter = [∧]-intro identity-eliminator-categorical-inverterₗ identity-eliminator-categorical-inverterᵣ
identity-eliminator-groupoid : Groupoid(Id)
Groupoid._∘_ identity-eliminator-groupoid = swap(trans)
Groupoid.id identity-eliminator-groupoid = refl
Groupoid.inv identity-eliminator-groupoid = sym
Groupoid.associativity identity-eliminator-groupoid = identity-eliminator-categorical-associativity
Groupoid.identity identity-eliminator-groupoid = identity-eliminator-categorical-identity
Groupoid.inverter identity-eliminator-groupoid = identity-eliminator-categorical-inverter
Groupoid.binaryOperator identity-eliminator-groupoid = intro a where postulate a : ∀{a} → a -- TODO
| 52.184685
| 192
| 0.671731
|
37ed3aef5ef5a64c4e9fb76492018730a67b6477
| 12,400
|
agda
|
Agda
|
Cubical/ZCohomology/CohomologyRings/Unit.agda
|
xekoukou/cubical
|
b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc
|
[
"MIT"
] | null | null | null |
Cubical/ZCohomology/CohomologyRings/Unit.agda
|
xekoukou/cubical
|
b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc
|
[
"MIT"
] | null | null | null |
Cubical/ZCohomology/CohomologyRings/Unit.agda
|
xekoukou/cubical
|
b6fbca9e83e553c5c2e4a16a2df7f9e9039034dc
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.CohomologyRings.Unit where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat renaming (_+_ to _+n_ ; _·_ to _·n_)
open import Cubical.Data.Int
open import Cubical.Data.Vec
open import Cubical.Data.FinData
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Int renaming (ℤGroup to ℤG)
open import Cubical.Algebra.DirectSum.Base
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤCommRing to ℤCR)
open import Cubical.Algebra.CommRing.FGIdeal
open import Cubical.Algebra.CommRing.QuotientRing
open import Cubical.Algebra.Polynomials.Multivariate.Base renaming (base to baseP)
open import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.A[X]X-A
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-Quotient
open import Cubical.Algebra.CommRing.Instances.MultivariatePoly-notationZ
open import Cubical.HITs.Truncation
open import Cubical.HITs.SetQuotients as SQ renaming (_/_ to _/sq_)
open import Cubical.HITs.PropositionalTruncation as PT
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.RingStructure.CupProduct
open import Cubical.ZCohomology.RingStructure.CohomologyRing
open import Cubical.ZCohomology.Groups.Unit
open Iso
module Equiv-Unit-Properties where
open CommRingStr (snd ℤCR) using ()
renaming
( 0r to 0ℤ
; 1r to 1ℤ
; _+_ to _+ℤ_
; -_ to -ℤ_
; _·_ to _·ℤ_
; +Assoc to +ℤAssoc
; +Identity to +ℤIdentity
; +Lid to +ℤLid
; +Rid to +ℤRid
; +Inv to +ℤInv
; +Linv to +ℤLinv
; +Rinv to +ℤRinv
; +Comm to +ℤComm
; ·Assoc to ·ℤAssoc
; ·Identity to ·ℤIdentity
; ·Lid to ·ℤLid
; ·Rid to ·ℤRid
; ·Rdist+ to ·ℤRdist+
; ·Ldist+ to ·ℤLdist+
; is-set to isSetℤ )
open RingStr (snd (H*R Unit)) using ()
renaming
( 0r to 0H*
; 1r to 1H*
; _+_ to _+H*_
; -_ to -H*_
; _·_ to _cup_
; +Assoc to +H*Assoc
; +Identity to +H*Identity
; +Lid to +H*Lid
; +Rid to +H*Rid
; +Inv to +H*Inv
; +Linv to +H*Linv
; +Rinv to +H*Rinv
; +Comm to +H*Comm
; ·Assoc to ·H*Assoc
; ·Identity to ·H*Identity
; ·Lid to ·H*Lid
; ·Rid to ·H*Rid
; ·Rdist+ to ·H*Rdist+
; ·Ldist+ to ·H*Ldist+
; is-set to isSetH* )
open CommRingStr (snd ℤ[X]) using ()
renaming
( 0r to 0Pℤ
; 1r to 1Pℤ
; _+_ to _+Pℤ_
; -_ to -Pℤ_
; _·_ to _·Pℤ_
; +Assoc to +PℤAssoc
; +Identity to +PℤIdentity
; +Lid to +PℤLid
; +Rid to +PℤRid
; +Inv to +PℤInv
; +Linv to +PℤLinv
; +Rinv to +PℤRinv
; +Comm to +PℤComm
; ·Assoc to ·PℤAssoc
; ·Identity to ·PℤIdentity
; ·Lid to ·PℤLid
; ·Rid to ·PℤRid
; ·Rdist+ to ·PℤRdist+
; ·Ldist+ to ·PℤLdist+
; is-set to isSetPℤ )
open CommRingStr (snd ℤ[X]/X) using ()
renaming
( 0r to 0PℤI
; 1r to 1PℤI
; _+_ to _+PℤI_
; -_ to -PℤI_
; _·_ to _·PℤI_
; +Assoc to +PℤIAssoc
; +Identity to +PℤIIdentity
; +Lid to +PℤILid
; +Rid to +PℤIRid
; +Inv to +PℤIInv
; +Linv to +PℤILinv
; +Rinv to +PℤIRinv
; +Comm to +PℤIComm
; ·Assoc to ·PℤIAssoc
; ·Identity to ·PℤIIdentity
; ·Lid to ·PℤILid
; ·Rid to ·PℤIRid
; ·Rdist+ to ·PℤIRdist+
; ·Ldist+ to ·PℤILdist+
; is-set to isSetPℤI )
-----------------------------------------------------------------------------
-- Direct Sens on ℤ[x]
ℤ[x]→H*-Unit : ℤ[x] → H* Unit
ℤ[x]→H*-Unit = Poly-Rec-Set.f _ _ _ isSetH*
0H*
base-trad
_+H*_
+H*Assoc
+H*Rid
+H*Comm
base-neutral-eq
base-add-eq
where
base-trad : _
base-trad (zero ∷ []) a = base zero (inv (fst H⁰-Unit≅ℤ) a)
base-trad (suc n ∷ []) a = 0H*
base-neutral-eq : _
base-neutral-eq (zero ∷ []) = base-neutral _
base-neutral-eq (suc n ∷ []) = refl
base-add-eq : _
base-add-eq (zero ∷ []) a b = base-add _ _ _
base-add-eq (suc n ∷ []) a b = +H*Rid _
ℤ[x]→H*-Unit-pres1Pℤ : ℤ[x]→H*-Unit (1Pℤ) ≡ 1H*
ℤ[x]→H*-Unit-pres1Pℤ = refl
ℤ[x]→H*-Unit-pres+ : (x y : ℤ[x]) → ℤ[x]→H*-Unit (x +Pℤ y) ≡ ℤ[x]→H*-Unit x +H* ℤ[x]→H*-Unit y
ℤ[x]→H*-Unit-pres+ x y = refl
-- Proving the morphism on the cup product
T0 : (z : ℤ) → coHom 0 Unit
T0 = λ z → inv (fst H⁰-Unit≅ℤ) z
T0g : IsGroupHom (ℤG .snd) (fst (invGroupIso H⁰-Unit≅ℤ) .fun) (coHomGr 0 Unit .snd)
T0g = snd (invGroupIso H⁰-Unit≅ℤ)
-- idea : control of the unfolding + simplification of T0 on the left
pres·-base-case-00 : (a : ℤ) → (b : ℤ) →
T0 (a ·ℤ b) ≡ (T0 a) ⌣ (T0 b)
pres·-base-case-00 (pos zero) b = (IsGroupHom.pres1 T0g)
pres·-base-case-00 (pos (suc n)) b = ((IsGroupHom.pres· T0g b (pos n ·ℤ b)))
∙ (cong (λ X → (T0 b) +ₕ X) (pres·-base-case-00 (pos n) b))
pres·-base-case-00 (negsuc zero) b = IsGroupHom.presinv T0g b
pres·-base-case-00 (negsuc (suc n)) b = cong T0 (+ℤComm (-ℤ b) (negsuc n ·ℤ b)) -- ·ℤ and ·₀ are defined asymetrically !
∙ IsGroupHom.pres· T0g (negsuc n ·ℤ b) (-ℤ b)
∙ cong₂ _+ₕ_ (pres·-base-case-00 (negsuc n) b)
(IsGroupHom.presinv T0g b)
pres·-base-case-int : (n : ℕ) → (a : ℤ) → (m : ℕ) → (b : ℤ) →
ℤ[x]→H*-Unit (baseP (n ∷ []) a ·Pℤ baseP (m ∷ []) b)
≡ ℤ[x]→H*-Unit (baseP (n ∷ []) a) cup ℤ[x]→H*-Unit (baseP (m ∷ []) b)
pres·-base-case-int zero a zero b = cong (base 0) (pres·-base-case-00 a b)
pres·-base-case-int zero a (suc m) b = refl
pres·-base-case-int (suc n) a m b = refl
pres·-base-case-vec : (v : Vec ℕ 1) → (a : ℤ) → (v' : Vec ℕ 1) → (b : ℤ) →
ℤ[x]→H*-Unit (baseP v a ·Pℤ baseP v' b)
≡ ℤ[x]→H*-Unit (baseP v a) cup ℤ[x]→H*-Unit (baseP v' b)
pres·-base-case-vec (n ∷ []) a (m ∷ []) b = pres·-base-case-int n a m b
ℤ[x]→H*-Unit-pres· : (x y : ℤ[x]) → ℤ[x]→H*-Unit (x ·Pℤ y) ≡ ℤ[x]→H*-Unit x cup ℤ[x]→H*-Unit y
ℤ[x]→H*-Unit-pres· = Poly-Ind-Prop.f _ _ _
(λ x p q i y j → isSetH* _ _ (p y) (q y) i j)
(λ y → refl)
base-case
λ {U V} ind-U ind-V y → cong₂ _+H*_ (ind-U y) (ind-V y)
where
base-case : _
base-case (n ∷ []) a = Poly-Ind-Prop.f _ _ _ (λ _ → isSetH* _ _)
(sym (RingTheory.0RightAnnihilates (H*R Unit) _))
(λ v' b → pres·-base-case-vec (n ∷ []) a v' b)
λ {U V} ind-U ind-V → (cong₂ _+H*_ ind-U ind-V) ∙ sym (·H*Rdist+ _ _ _)
-- raising to the product
ℤ[x]→H*-Unit-cancelX : (k : Fin 1) → ℤ[x]→H*-Unit (<X> k) ≡ 0H*
ℤ[x]→H*-Unit-cancelX zero = refl
ℤ[X]→H*-Unit : RingHom (CommRing→Ring ℤ[X]) (H*R Unit)
fst ℤ[X]→H*-Unit = ℤ[x]→H*-Unit
snd ℤ[X]→H*-Unit = makeIsRingHom ℤ[x]→H*-Unit-pres1Pℤ ℤ[x]→H*-Unit-pres+ ℤ[x]→H*-Unit-pres·
ℤ[X]/X→H*R-Unit : RingHom (CommRing→Ring ℤ[X]/X) (H*R Unit)
ℤ[X]/X→H*R-Unit = Quotient-FGideal-CommRing-Ring.f ℤ[X] (H*R Unit) ℤ[X]→H*-Unit <X> ℤ[x]→H*-Unit-cancelX
ℤ[x]/x→H*-Unit : ℤ[x]/x → H* Unit
ℤ[x]/x→H*-Unit = fst ℤ[X]/X→H*R-Unit
-----------------------------------------------------------------------------
-- Converse Sens on ℤ[X]
H*-Unit→ℤ[x] : H* Unit → ℤ[x]
H*-Unit→ℤ[x] = DS-Rec-Set.f _ _ _ _ isSetPℤ
0Pℤ
base-trad
_+Pℤ_
+PℤAssoc
+PℤRid
+PℤComm
base-neutral-eq
base-add-eq
where
base-trad : (n : ℕ) → coHom n Unit → ℤ[x]
base-trad zero a = baseP (0 ∷ []) (fun (fst H⁰-Unit≅ℤ) a)
base-trad (suc n) a = 0Pℤ
base-neutral-eq : _
base-neutral-eq zero = base-0P _
base-neutral-eq (suc n) = refl
base-add-eq : _
base-add-eq zero a b = base-poly+ _ _ _
∙ cong (baseP (0 ∷ [])) (sym (IsGroupHom.pres· (snd H⁰-Unit≅ℤ) a b))
base-add-eq (suc n) a b = +PℤRid _
H*-Unit→ℤ[x]-pres+ : (x y : H* Unit) → H*-Unit→ℤ[x] ( x +H* y) ≡ H*-Unit→ℤ[x] x +Pℤ H*-Unit→ℤ[x] y
H*-Unit→ℤ[x]-pres+ x y = refl
H*-Unit→ℤ[x]/x : H* Unit → ℤ[x]/x
H*-Unit→ℤ[x]/x = [_] ∘ H*-Unit→ℤ[x]
H*-Unit→ℤ[x]/x-pres+ : (x y : H* Unit) → H*-Unit→ℤ[x]/x (x +H* y) ≡ (H*-Unit→ℤ[x]/x x) +PℤI (H*-Unit→ℤ[x]/x y)
H*-Unit→ℤ[x]/x-pres+ x y = cong [_] (H*-Unit→ℤ[x]-pres+ x y)
-----------------------------------------------------------------------------
-- Section
e-sect : (x : H* Unit) → ℤ[x]/x→H*-Unit (H*-Unit→ℤ[x]/x x) ≡ x
e-sect = DS-Ind-Prop.f _ _ _ _ (λ _ → isSetH* _ _)
refl
base-case
λ {U V} ind-U ind-V → cong ℤ[x]/x→H*-Unit (H*-Unit→ℤ[x]/x-pres+ U V)
∙ IsRingHom.pres+ (snd ℤ[X]/X→H*R-Unit) (H*-Unit→ℤ[x]/x U) (H*-Unit→ℤ[x]/x V)
∙ cong₂ _+H*_ ind-U ind-V
where
base-case : _
base-case zero a = cong (base 0) (leftInv (fst H⁰-Unit≅ℤ) a)
base-case (suc n) a = (sym (base-neutral (suc n)))
∙ (cong (base (suc n)) ((isContr→isProp (isContrHⁿ-Unit n) _ a)))
-----------------------------------------------------------------------------
-- Retraction
e-retr : (x : ℤ[x]/x) → H*-Unit→ℤ[x]/x (ℤ[x]/x→H*-Unit x) ≡ x
e-retr = SQ.elimProp (λ _ → isSetPℤI _ _)
(Poly-Ind-Prop.f _ _ _ (λ _ → isSetPℤI _ _)
refl
base-case
λ {U V} ind-U ind-V → cong₂ _+PℤI_ ind-U ind-V)
where
base-case : _
base-case (zero ∷ []) a = refl
base-case (suc n ∷ []) a = eq/ 0Pℤ (baseP (suc n ∷ []) a) ∣ ((λ x → baseP (n ∷ []) (-ℤ a)) , foo) ∣₁
where
foo : (0P poly+ baseP (suc n ∷ []) (- a)) ≡ (baseP (n +n 1 ∷ []) (- a · pos 1) poly+ 0P)
foo = (0P poly+ baseP (suc n ∷ []) (- a)) ≡⟨ +PℤLid _ ⟩
baseP (suc n ∷ []) (- a) ≡⟨ cong₂ baseP (cong (λ X → X ∷ []) (sym ((+-suc n 0)
∙ (cong suc (+-zero n))))) (sym (·ℤRid _)) ⟩
baseP (n +n suc 0 ∷ []) (- a ·ℤ 1ℤ) ≡⟨ refl ⟩
baseP (n +n 1 ∷ []) (- a · pos 1) ≡⟨ sym (+PℤRid _) ⟩
(baseP (n +n 1 ∷ []) (- a · pos 1) poly+ 0P) ∎
-----------------------------------------------------------------------------
-- Computation of the Cohomology Ring
module _ where
open Equiv-Unit-Properties
open RingEquivs
Unit-CohomologyRingP : RingEquiv (CommRing→Ring ℤ[X]/X) (H*R Unit)
fst Unit-CohomologyRingP = isoToEquiv is
where
is : Iso ℤ[x]/x (H* Unit)
fun is = ℤ[x]/x→H*-Unit
inv is = H*-Unit→ℤ[x]/x
rightInv is = e-sect
leftInv is = e-retr
snd Unit-CohomologyRingP = snd ℤ[X]/X→H*R-Unit
CohomologyRing-UnitP : RingEquiv (H*R Unit) (CommRing→Ring ℤ[X]/X)
CohomologyRing-UnitP = invEquivRing Unit-CohomologyRingP
Unit-CohomologyRingℤ : RingEquiv (CommRing→Ring ℤCR) (H*R Unit)
Unit-CohomologyRingℤ = compRingEquiv (invEquivRing Equiv-ℤ[X]/X-ℤ) Unit-CohomologyRingP
CohomologyRing-Unitℤ : RingEquiv (H*R Unit) (CommRing→Ring ℤCR)
CohomologyRing-Unitℤ = compRingEquiv CohomologyRing-UnitP Equiv-ℤ[X]/X-ℤ
| 36.578171
| 122
| 0.495
|
4de68e2faab2d10633fe3d38b09cca2e210f24ae
| 507
|
agda
|
Agda
|
test/Fail/NotStronglyRigidOccurrence.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/NotStronglyRigidOccurrence.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/NotStronglyRigidOccurrence.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2011-04-15
module NotStronglyRigidOccurrence where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
-- Jason C. Read, PhD thesis, p. 109
test : (k : Nat) ->
let X : (Nat -> Nat) -> Nat
X = _
in (f : Nat -> Nat) -> X f ≡ suc (f (X (\ x -> k)))
test k f = refl -- {a = suc (f (suc k))}
-- leads to _30 : _22 k f ≡ suc (f (_22 k (λ x → k)))
-- this should give yellow, because above solution for _22 exists
| 26.684211
| 65
| 0.534517
|
57b9cbf386c5a8aecf4df8f1497eee247150560c
| 2,702
|
agda
|
Agda
|
Cubical/Algebra/DirectSum/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Algebra/DirectSum/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/DirectSum/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.DirectSum.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.Group
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.DirectSum.Base
private variable
ℓ ℓ' : Level
module _ (Idx : Type ℓ) (P : Idx → Type ℓ') (AGP : (r : Idx) → AbGroupStr (P r)) where
inv : ⊕ Idx P AGP → ⊕ Idx P AGP
inv = DS-Rec-Set.f Idx P AGP (⊕ Idx P AGP) trunc
-- elements
neutral
(λ r a → base r (AbGroupStr.-_ (AGP r) a))
(λ xs ys → xs add ys)
-- eq group
(λ xs ys zs → addAssoc xs ys zs)
(λ xs → addRid xs)
(λ xs ys → addComm xs ys)
-- eq base
(λ r → let open AbGroupStr (AGP r) in
let open GroupTheory (P r , AbGroupStr→GroupStr (AGP r)) in
(cong (base r) inv1g) ∙ (base-neutral r))
(λ r a b → let open AbGroupStr (AGP r) in
let open GroupTheory (P r , AbGroupStr→GroupStr (AGP r)) in
((base r (- a) add base r (- b)) ≡⟨ (base-add r (- a) (- b)) ⟩
base r ((- a) + (- b)) ≡⟨ (cong (base r) (sym (invDistr b a))) ⟩
base r (- (b + a)) ≡⟨ cong (base r) (cong (-_) (comm b a)) ⟩
base r (- (a + b)) ∎))
rinv : (z : ⊕ Idx P AGP) → z add (inv z) ≡ neutral
rinv = DS-Ind-Prop.f Idx P AGP (λ z → z add (inv z) ≡ neutral) (λ _ → trunc _ _)
-- elements
(addRid neutral)
(λ r a → let open AbGroupStr (AGP r) in
((base r a add base r (- a)) ≡⟨ base-add r a (- a) ⟩
base r (a + - a) ≡⟨ cong (base r) (invr a) ⟩
base r 0g ≡⟨ base-neutral r ⟩
neutral ∎))
(λ {x} {y} p q →
(((x add y) add ((inv x) add (inv y))) ≡⟨ cong (λ X → X add ((inv x) add (inv y))) (addComm x y) ⟩
((y add x) add (inv x add inv y)) ≡⟨ sym (addAssoc y x (inv x add inv y)) ⟩
(y add (x add (inv x add inv y))) ≡⟨ cong (λ X → y add X) (addAssoc x (inv x) (inv y)) ⟩
(y add ((x add inv x) add inv y)) ≡⟨ cong (λ X → y add (X add (inv y))) (p) ⟩
(y add (neutral add inv y)) ≡⟨ cong (λ X → y add X) (addComm neutral (inv y)) ⟩
(y add (inv y add neutral)) ≡⟨ cong (λ X → y add X) (addRid (inv y)) ⟩
(y add inv y) ≡⟨ q ⟩
neutral ∎))
| 47.403509
| 124
| 0.42487
|
7cb6e7a2ec4050300c66c3eac10aff42573f9ad5
| 1,084
|
agda
|
Agda
|
src/Bee2/Crypto/Belt.agda
|
semenov-vladyslav/bee2-agda
|
22682afc8d488e3812307e104785d2b8dc8b9d4a
|
[
"MIT"
] | null | null | null |
src/Bee2/Crypto/Belt.agda
|
semenov-vladyslav/bee2-agda
|
22682afc8d488e3812307e104785d2b8dc8b9d4a
|
[
"MIT"
] | null | null | null |
src/Bee2/Crypto/Belt.agda
|
semenov-vladyslav/bee2-agda
|
22682afc8d488e3812307e104785d2b8dc8b9d4a
|
[
"MIT"
] | null | null | null |
module Bee2.Crypto.Belt where
open import Data.ByteString
open import Data.ByteVec
open import Data.Nat using (ℕ)
open import Data.Product using (_,_)
open import Agda.Builtin.TrustMe using (primTrustMe)
import Bee2.Crypto.Defs
open Bee2.Crypto.Defs
open Bee2.Crypto.Defs using (Hash) public
{-# FOREIGN GHC import qualified Bee2.Crypto.Belt #-}
{-# FOREIGN GHC import qualified Data.ByteString #-}
Password = ByteString Strict
Salt = ByteString Strict
Key = ByteVec {Strict} 32
Header = ByteVec {Strict} 16
Kek = ByteVec {Strict} 32
{-# FOREIGN GHC import qualified Bee2.Crypto.Belt #-}
postulate
primBeltPBKDF : ByteString Strict → SizeT → ByteString Strict → ByteString Strict
primBeltHash : ByteString Strict → ByteString Strict
{-# COMPILE GHC primBeltPBKDF =
( Bee2.Crypto.Belt.beltPBKDF'bs ) #-}
{-# COMPILE GHC primBeltHash =
( Bee2.Crypto.Belt.beltHash'bs ) #-}
beltPBKDF : Password → ℕ → Salt → Kek
beltPBKDF p n s = (primBeltPBKDF p (SizeFromℕ n) s) , primTrustMe
beltHash : ByteString Strict → Hash
beltHash bs = primBeltHash bs , primTrustMe
| 29.297297
| 83
| 0.740775
|
21de6a27822a7905ee15413c8d4ec418ee106a60
| 393
|
agda
|
Agda
|
test/interaction/MetaNameSuggestion.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/MetaNameSuggestion.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/MetaNameSuggestion.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-09-12
--
-- Underscores should also get meaningful names
-- (not just metas from omitted hidden arguments)
-- {-# OPTIONS -v tc.meta.name:100 #-}
postulate
F : (A : Set) → Set
G : {B : Set} → Set
test1 : Set
test1 = F _
-- name of this meta should be _A_0
test2 : Set
test2 = G
-- creates meta _B_1
test3 : Set
test3 = G {_}
-- name of this meta should be _B_2
| 17.086957
| 49
| 0.633588
|
03aa8e3fb48c5468326ef3ac5d9e9759de2bd571
| 4,702
|
agda
|
Agda
|
agda-stdlib-0.9/src/Relation/Unary.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/Relation/Unary.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Relation/Unary.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Unary relations
------------------------------------------------------------------------
module Relation.Unary where
open import Data.Empty
open import Function
open import Data.Unit hiding (setoid)
open import Data.Product
open import Data.Sum
open import Level
open import Relation.Nullary
open import Relation.Binary using (Setoid; IsEquivalence)
------------------------------------------------------------------------
-- Unary relations
Pred : ∀ {a} → Set a → (ℓ : Level) → Set (a ⊔ suc ℓ)
Pred A ℓ = A → Set ℓ
------------------------------------------------------------------------
-- Unary relations can be seen as sets
-- I.e., they can be seen as subsets of the universe of discourse.
module _ {a} {A : Set a} -- The universe of discourse.
where
-- Set membership.
infix 4 _∈_ _∉_
_∈_ : ∀ {ℓ} → A → Pred A ℓ → Set _
x ∈ P = P x
_∉_ : ∀ {ℓ} → A → Pred A ℓ → Set _
x ∉ P = ¬ x ∈ P
-- The empty set.
∅ : Pred A zero
∅ = λ _ → ⊥
-- The property of being empty.
Empty : ∀ {ℓ} → Pred A ℓ → Set _
Empty P = ∀ x → x ∉ P
∅-Empty : Empty ∅
∅-Empty x ()
-- The universe, i.e. the subset containing all elements in A.
U : Pred A zero
U = λ _ → ⊤
-- The property of being universal.
Universal : ∀ {ℓ} → Pred A ℓ → Set _
Universal P = ∀ x → x ∈ P
U-Universal : Universal U
U-Universal = λ _ → _
-- Set complement.
∁ : ∀ {ℓ} → Pred A ℓ → Pred A ℓ
∁ P = λ x → x ∉ P
∁∅-Universal : Universal (∁ ∅)
∁∅-Universal = λ x x∈∅ → x∈∅
∁U-Empty : Empty (∁ U)
∁U-Empty = λ x x∈∁U → x∈∁U _
-- P ⊆ Q means that P is a subset of Q. _⊆′_ is a variant of _⊆_.
infix 4 _⊆_ _⊇_ _⊆′_ _⊇′_
_⊆_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _
P ⊆ Q = ∀ {x} → x ∈ P → x ∈ Q
_⊆′_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _
P ⊆′ Q = ∀ x → x ∈ P → x ∈ Q
_⊇_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _
Q ⊇ P = P ⊆ Q
_⊇′_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _
Q ⊇′ P = P ⊆′ Q
∅-⊆ : ∀ {ℓ} → (P : Pred A ℓ) → ∅ ⊆ P
∅-⊆ P ()
⊆-U : ∀ {ℓ} → (P : Pred A ℓ) → P ⊆ U
⊆-U P _ = _
-- Positive version of non-disjointness, dual to inclusion.
infix 4 _≬_
_≬_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Set _
P ≬ Q = ∃ λ x → x ∈ P × x ∈ Q
-- Set union.
infixr 6 _∪_
_∪_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Pred A _
P ∪ Q = λ x → x ∈ P ⊎ x ∈ Q
-- Set intersection.
infixr 7 _∩_
_∩_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Pred A _
P ∩ Q = λ x → x ∈ P × x ∈ Q
-- Implication.
infixl 8 _⇒_
_⇒_ : ∀ {ℓ₁ ℓ₂} → Pred A ℓ₁ → Pred A ℓ₂ → Pred A _
P ⇒ Q = λ x → x ∈ P → x ∈ Q
-- Infinitary union and intersection.
infix 9 ⋃ ⋂
⋃ : ∀ {ℓ i} (I : Set i) → (I → Pred A ℓ) → Pred A _
⋃ I P = λ x → Σ[ i ∈ I ] P i x
syntax ⋃ I (λ i → P) = ⋃[ i ∶ I ] P
⋂ : ∀ {ℓ i} (I : Set i) → (I → Pred A ℓ) → Pred A _
⋂ I P = λ x → (i : I) → P i x
syntax ⋂ I (λ i → P) = ⋂[ i ∶ I ] P
------------------------------------------------------------------------
-- Unary relation combinators
infixr 2 _⟨×⟩_
infixr 2 _⟨⊙⟩_
infixr 1 _⟨⊎⟩_
infixr 0 _⟨→⟩_
infixl 9 _⟨·⟩_
infixr 9 _⟨∘⟩_
infixr 2 _//_ _\\_
_⟨×⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} →
Pred A ℓ₁ → Pred B ℓ₂ → Pred (A × B) _
(P ⟨×⟩ Q) (x , y) = x ∈ P × y ∈ Q
_⟨⊙⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} →
Pred A ℓ₁ → Pred B ℓ₂ → Pred (A × B) _
(P ⟨⊙⟩ Q) (x , y) = x ∈ P ⊎ y ∈ Q
_⟨⊎⟩_ : ∀ {a b ℓ} {A : Set a} {B : Set b} →
Pred A ℓ → Pred B ℓ → Pred (A ⊎ B) _
P ⟨⊎⟩ Q = [ P , Q ]
_⟨→⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} →
Pred A ℓ₁ → Pred B ℓ₂ → Pred (A → B) _
(P ⟨→⟩ Q) f = P ⊆ Q ∘ f
_⟨·⟩_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b}
(P : Pred A ℓ₁) (Q : Pred B ℓ₂) →
(P ⟨×⟩ (P ⟨→⟩ Q)) ⊆ Q ∘ uncurry (flip _$_)
(P ⟨·⟩ Q) (p , f) = f p
-- Converse.
_~ : ∀ {a b ℓ} {A : Set a} {B : Set b} →
Pred (A × B) ℓ → Pred (B × A) ℓ
P ~ = P ∘ swap
-- Composition.
_⟨∘⟩_ : ∀ {a b c ℓ₁ ℓ₂} {A : Set a} {B : Set b} {C : Set c} →
Pred (A × B) ℓ₁ → Pred (B × C) ℓ₂ → Pred (A × C) _
(P ⟨∘⟩ Q) (x , z) = ∃ λ y → (x , y) ∈ P × (y , z) ∈ Q
-- Post and pre-division.
_//_ : ∀ {a b c ℓ₁ ℓ₂} {A : Set a} {B : Set b} {C : Set c} →
Pred (A × C) ℓ₁ → Pred (B × C) ℓ₂ → Pred (A × B) _
(P // Q) (x , y) = Q ∘ _,_ y ⊆ P ∘ _,_ x
_\\_ : ∀ {a b c ℓ₁ ℓ₂} {A : Set a} {B : Set b} {C : Set c} →
Pred (A × C) ℓ₁ → Pred (A × B) ℓ₂ → Pred (B × C) _
P \\ Q = (P ~ // Q ~) ~
------------------------------------------------------------------------
-- Properties of unary relations
Decidable : ∀ {a ℓ} {A : Set a} (P : Pred A ℓ) → Set _
Decidable P = ∀ x → Dec (P x)
| 23.277228
| 72
| 0.425776
|
03ae2bf644e537c8157405977077995eac6567b9
| 260
|
agda
|
Agda
|
test/Succeed/Issue2297.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2297.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2297.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
record R : Set₁ where
field
A : Set
module _ (r : R) where
open R r
data D : Set where
c : A → D
data P : D → Set where
d : (x : A) → P (c x)
postulate
f : D → A
g : (x : D) → P x → D
g x (d y) with Set
g x (d y) | _ = x
| 11.818182
| 25
| 0.446154
|
2189ead71accf171dce5d74df4f20567f9249da1
| 336
|
agda
|
Agda
|
test/Common/Size.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Common/Size.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Common/Size.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
{-# OPTIONS --without-K #-}
------------------------------------------------------------------------
-- From the Agda standard library
--
-- Sizes for Agda's sized types
------------------------------------------------------------------------
module Common.Size where
open import Agda.Builtin.Size public renaming (SizeU to SizeUniv)
| 30.545455
| 72
| 0.41369
|
fdd9d93e923ab90712f828caba3cc42b93d31e08
| 6,828
|
agda
|
Agda
|
src/Generic/Test/Data/List.agda
|
iblech/Generic
|
380554b20e0991290d1864ddf81f0587ec1647ed
|
[
"MIT"
] | 30
|
2016-07-19T21:10:54.000Z
|
2022-02-05T10:19:38.000Z
|
src/Generic/Test/Data/List.agda
|
iblech/Generic
|
380554b20e0991290d1864ddf81f0587ec1647ed
|
[
"MIT"
] | 9
|
2017-04-06T18:58:09.000Z
|
2022-01-04T15:43:14.000Z
|
src/Generic/Test/Data/List.agda
|
iblech/Generic
|
380554b20e0991290d1864ddf81f0587ec1647ed
|
[
"MIT"
] | 4
|
2017-07-17T07:23:39.000Z
|
2021-01-27T12:57:09.000Z
|
module Generic.Test.Data.List where
module _ where
open import Generic.Main as Main hiding ([]; _∷_) renaming (List to StdList)
infixr 5 _∷_ _∷′_
List : ∀ {α} -> Set α -> Set α
List = readData StdList
pattern [] = #₀ lrefl
pattern _∷_ x xs = !#₁ (relv x , xs , lrefl)
_∷′_ : ∀ {α} {A : Set α} -> A -> List A -> List A
_∷′_ = _∷_
elimList : ∀ {α π} {A : Set α}
-> (P : List A -> Set π)
-> (∀ {xs} x -> P xs -> P (x ∷ xs))
-> P []
-> ∀ xs
-> P xs
elimList P f z [] = z
elimList P f z (x ∷ xs) = f x (elimList P f z xs)
toStdList : ∀ {α} {A : Set α} -> List A -> StdList A
toStdList xs = guncoerce xs
-- The entire content of `Data.List.Base` (modulo `Generic.Test.Data.Maybe` instead of
-- `Data.Maybe.Base` and _∷_ was renamed to _∷′_ in some places)
open import Data.Nat.Base using (ℕ; zero; suc; _+_; _*_)
open import Data.Sum as Sum using (_⊎_; inj₁; inj₂)
open import Data.Bool.Base using (Bool; false; true; not; _∧_; _∨_; if_then_else_)
open import Generic.Test.Data.Maybe
open import Data.Product as Prod using (_×_; _,_)
open import Function
infixr 5 _++_
[_] : ∀ {a} {A : Set a} → A → List A
[ x ] = x ∷ []
_++_ : ∀ {a} {A : Set a} → List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
-- Snoc.
infixl 5 _∷ʳ_
_∷ʳ_ : ∀ {a} {A : Set a} → List A → A → List A
xs ∷ʳ x = xs ++ [ x ]
null : ∀ {a} {A : Set a} → List A → Bool
null [] = true
null (x ∷ xs) = false
-- * List transformations
map : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
replicate : ∀ {a} {A : Set a} → (n : ℕ) → A → List A
replicate zero x = []
replicate (suc n) x = x ∷ replicate n x
zipWith : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
→ (A → B → C) → List A → List B → List C
zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys
zipWith f _ _ = []
zip : ∀ {a b} {A : Set a} {B : Set b} → List A → List B → List (A × B)
zip = zipWith (_,_)
intersperse : ∀ {a} {A : Set a} → A → List A → List A
intersperse x [] = []
intersperse x (y ∷ []) = [ y ]
intersperse x (y ∷ z ∷ zs) = y ∷ x ∷ intersperse x (z ∷ zs)
-- * Reducing lists (folds)
foldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → B
foldr c n [] = n
foldr c n (x ∷ xs) = c x (foldr c n xs)
foldl : ∀ {a b} {A : Set a} {B : Set b} → (A → B → A) → A → List B → A
foldl c n [] = n
foldl c n (x ∷ xs) = foldl c (c n x) xs
-- ** Special folds
concat : ∀ {a} {A : Set a} → List (List A) → List A
concat = foldr _++_ []
concatMap : ∀ {a b} {A : Set a} {B : Set b} →
(A → List B) → List A → List B
concatMap f = concat ∘ map f
and : List Bool → Bool
and = foldr _∧_ true
or : List Bool → Bool
or = foldr _∨_ false
any : ∀ {a} {A : Set a} → (A → Bool) → List A → Bool
any p = or ∘ map p
all : ∀ {a} {A : Set a} → (A → Bool) → List A → Bool
all p = and ∘ map p
sum : List ℕ → ℕ
sum = foldr _+_ 0
product : List ℕ → ℕ
product = foldr _*_ 1
length : ∀ {a} {A : Set a} → List A → ℕ
length = foldr (λ _ → suc) 0
import Data.List.Base
reverse : ∀ {a} {A : Set a} → List A → List A
reverse = foldl (λ rev x → x ∷′ rev) []
-- * Building lists
-- ** Scans
scanr : ∀ {a b} {A : Set a} {B : Set b} →
(A → B → B) → B → List A → List B
scanr f e [] = e ∷ []
scanr f e (x ∷ xs) with scanr f e xs
... | [] = [] -- dead branch
... | y ∷ ys = f x y ∷ y ∷ ys
scanl : ∀ {a b} {A : Set a} {B : Set b} →
(A → B → A) → A → List B → List A
scanl f e [] = e ∷ []
scanl f e (x ∷ xs) = e ∷ scanl f (f e x) xs
-- ** Unfolding
-- Unfold. Uses a measure (a natural number) to ensure termination.
unfold : ∀ {a b} {A : Set a} (B : ℕ → Set b)
(f : ∀ {n} → B (suc n) → Maybe (A × B n)) →
∀ {n} → B n → List A
unfold B f {n = zero} s = []
unfold B f {n = suc n} s with f s
... | nothing = []
... | just (x , s') = x ∷ unfold B f s'
-- downFrom 3 = 2 ∷ 1 ∷ 0 ∷ [].
downFrom : ℕ → List ℕ
downFrom n = unfold Singleton f (wrap n)
where
data Singleton : ℕ → Set where
wrap : (n : ℕ) → Singleton n
f : ∀ {n} → Singleton (suc n) → Maybe (ℕ × Singleton n)
f {n} (wrap .(suc n)) = just (n , wrap n)
-- ** Conversions
fromMaybe : ∀ {a} {A : Set a} → Maybe A → List A
fromMaybe (just x) = [ x ]
fromMaybe nothing = []
-- * Sublists
-- ** Extracting sublists
take : ∀ {a} {A : Set a} → ℕ → List A → List A
take zero xs = []
take (suc n) [] = []
take (suc n) (x ∷ xs) = x ∷ take n xs
drop : ∀ {a} {A : Set a} → ℕ → List A → List A
drop zero xs = xs
drop (suc n) [] = []
drop (suc n) (x ∷ xs) = drop n xs
splitAt : ∀ {a} {A : Set a} → ℕ → List A → (List A × List A)
splitAt zero xs = ([] , xs)
splitAt (suc n) [] = ([] , [])
splitAt (suc n) (x ∷ xs) with splitAt n xs
... | (ys , zs) = (x ∷ ys , zs)
takeWhile : ∀ {a} {A : Set a} → (A → Bool) → List A → List A
takeWhile p [] = []
takeWhile p (x ∷ xs) with p x
... | true = x ∷ takeWhile p xs
... | false = []
dropWhile : ∀ {a} {A : Set a} → (A → Bool) → List A → List A
dropWhile p [] = []
dropWhile p (x ∷ xs) with p x
... | true = dropWhile p xs
... | false = x ∷ xs
span : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A)
span p [] = ([] , [])
span p (x ∷ xs) with p x
... | true = Prod.map (_∷′_ x) id (span p xs)
... | false = ([] , x ∷ xs)
break : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A)
break p = span (not ∘ p)
inits : ∀ {a} {A : Set a} → List A → List (List A)
inits [] = [] ∷ []
inits (x ∷ xs) = [] ∷ map (_∷′_ x) (inits xs)
tails : ∀ {a} {A : Set a} → List A → List (List A)
tails [] = [] ∷ []
tails (x ∷ xs) = (x ∷ xs) ∷ tails xs
infixl 5 _∷ʳ'_
data InitLast {a} {A : Set a} : List A → Set a where
[]ʳ : InitLast []
_∷ʳ'_ : (xs : List A) (x : A) → InitLast (xs ∷ʳ x)
initLast : ∀ {a} {A : Set a} (xs : List A) → InitLast xs
initLast [] = []ʳ
initLast (x ∷ xs) with initLast xs
initLast (x ∷ .[]) | []ʳ = [] ∷ʳ' x
initLast (x ∷ .(ys ∷ʳ y)) | ys ∷ʳ' y = (x ∷ ys) ∷ʳ' y
-- * Searching lists
-- ** Searching with a predicate
-- A generalised variant of filter.
gfilter : ∀ {a b} {A : Set a} {B : Set b} →
(A → Maybe B) → List A → List B
gfilter p [] = []
gfilter p (x ∷ xs) with p x
... | just y = y ∷ gfilter p xs
... | nothing = gfilter p xs
filter : ∀ {a} {A : Set a} → (A → Bool) → List A → List A
filter p = gfilter (λ x → if p x then just′ x else nothing)
partition : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A)
partition p [] = ([] , [])
partition p (x ∷ xs) with p x | partition p xs
... | true | (ys , zs) = (x ∷ ys , zs)
... | false | (ys , zs) = (ys , x ∷ zs)
| 26.88189
| 86
| 0.485062
|
4b0977bc42e41cf1089893a5e3a4b6087dfc2eb7
| 663
|
agda
|
Agda
|
test/fail/WhyWeNeedUntypedLambda.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | null | null | null |
test/fail/WhyWeNeedUntypedLambda.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | null | null | null |
test/fail/WhyWeNeedUntypedLambda.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
{- 2010-09-28 Andreas, see issue 336 -}
module WhyWeNeedUntypedLambda where
IdT = ({A : Set} -> A -> A)
data _==_ {A : Set2}(a : A) : A -> Set where
refl : a == a
-- Untyped lambda succeeds, because checking \ x -> x : X is postponed,
-- then the solution X = IdT is found, and upon revisiting the tc problem
-- a hidden lambda \ {A} is inserted.
foo : ({X : Set1} -> X -> X == IdT -> Set) -> Set
foo k = k (\ x -> x) refl -- succeeds
{-
-- Typed lambda fails, because \ (x : _) -> x has inferred type ?A -> ?A
-- but then unification with IdT fails.
foo' : ({X : Set1} -> X -> X == IdT -> Set) -> Set
foo' k = k (\ (x : _) -> x) refl -- fails
-}
| 30.136364
| 73
| 0.561086
|
52bb8cbc2ea2f680d81c432d70a3a430807e28a9
| 2,878
|
agda
|
Agda
|
src/Tactic/Nat/Simpl.agda
|
jespercockx/agda-prelude
|
1984cf0341835b2f7bfe678098bd57cfe16ea11f
|
[
"MIT"
] | null | null | null |
src/Tactic/Nat/Simpl.agda
|
jespercockx/agda-prelude
|
1984cf0341835b2f7bfe678098bd57cfe16ea11f
|
[
"MIT"
] | null | null | null |
src/Tactic/Nat/Simpl.agda
|
jespercockx/agda-prelude
|
1984cf0341835b2f7bfe678098bd57cfe16ea11f
|
[
"MIT"
] | null | null | null |
module Tactic.Nat.Simpl where
open import Prelude hiding (abs)
open import Builtin.Reflection
open import Tactic.Reflection.Quote
open import Tactic.Reflection
open import Tactic.Nat.Reflect
open import Tactic.Nat.NF
open import Tactic.Nat.Exp
open import Tactic.Nat.Auto
open import Tactic.Nat.Auto.Lemmas
open import Tactic.Nat.Simpl.Lemmas
module _ {Atom : Set} {{_ : Eq Atom}} {{_ : Ord Atom}} where
ExpEq : Exp Atom × Exp Atom → Env Atom → Set
ExpEq (e₁ , e₂) ρ = ⟦ e₁ ⟧e ρ ≡ ⟦ e₂ ⟧e ρ
CancelEq : Exp Atom × Exp Atom → Env Atom → Set
CancelEq (e₁ , e₂) ρ = NFEqS (cancel (norm e₁) (norm e₂)) ρ
⟦_⟧h : List (Exp Atom × Exp Atom) → Env Atom → Set
⟦ [] ⟧h ρ = ⊥
⟦ h ∷ [] ⟧h ρ = ExpEq h ρ
⟦ h ∷ g ⟧h ρ = ExpEq h ρ → ⟦ g ⟧h ρ
⟦_⟧hs : List (Exp Atom × Exp Atom) → Env Atom → Set
⟦ [] ⟧hs ρ = ⊥
⟦ h ∷ [] ⟧hs ρ = CancelEq h ρ
⟦ h ∷ g ⟧hs ρ = CancelEq h ρ → ⟦ g ⟧hs ρ
simplifyEq : ∀ eq (ρ : Env Atom) → CancelEq eq ρ → ExpEq eq ρ
simplifyEq (e₁ , e₂) ρ H = liftNFEq e₁ e₂ ρ (cancel-sound (norm e₁) (norm e₂) ρ H)
complicateEq : ∀ eq ρ → ExpEq eq ρ → CancelEq eq ρ
complicateEq (e₁ , e₂) ρ H =
cancel-complete (norm e₁) (norm e₂) ρ
(unliftNFEq e₁ e₂ ρ H)
simplifyH : ∀ goal ρ → ⟦ goal ⟧hs ρ → ⟦ goal ⟧h ρ
simplifyH [] ρ ()
simplifyH (h ∷ []) ρ H = simplifyEq h ρ H
simplifyH (h ∷ h₂ ∷ g) ρ H = λ H₁ → simplifyH (h₂ ∷ g) ρ $ H (complicateEq h ρ H₁)
simplify-tactic : {x y : Nat} → x ≡ y → Type → TC Term
simplify-tactic {x} {y} prf g = do
`x ← quoteTC x
`y ← quoteTC y
`prf ← quoteTC prf
let h = def₂ (quote _≡_) `x `y
t = pi (vArg h) (abs "_" (weaken 1 g))
just (goal , Γ) ← termToHyps t
where nothing → typeError (strErr "Invalid goal" ∷ termErr t ∷ [])
pure $ def (quote flip)
$ vArg (def (quote simplifyH)
( vArg (` goal)
∷ vArg (quotedEnv Γ) ∷ [] ))
∷ vArg `prf ∷ []
assumed-tactic : {x y : Nat} → x ≡ y → Type → TC Term
assumed-tactic {x} {y} prf g = do
`x ← withNormalisation true $ quoteTC x
`y ← withNormalisation true $ quoteTC y
`prf ← quoteTC prf
let h = def (quote _≡_) (hArg unknown ∷ hArg (def₀ (quote Nat)) ∷ vArg `x ∷ vArg `y ∷ [])
let t = pi (vArg h) (abs "_" (weaken 1 g))
just (goal , Γ) ← termToHyps t
where nothing → typeError (strErr "Invalid goal" ∷ termErr t ∷ [])
pure $
def (quote simplifyH) ( vArg (` goal)
∷ vArg (quotedEnv Γ)
∷ vArg (def (quote id) [])
∷ vArg `prf ∷ [] )
macro
follows-from : {x y : Nat} → x ≡ y → Tactic
follows-from prf hole = do
goal ← inferNormalisedType hole
unify hole =<< assumed-tactic prf goal
simplify : {x y : Nat} → x ≡ y → Tactic
simplify prf hole = do
goal ← inferNormalisedType hole
unify hole =<< simplify-tactic prf goal
| 33.465116
| 91
| 0.569145
|
301afa6cd2bbe60f513a7d8db28be577b54ade0a
| 1,616
|
agda
|
Agda
|
benchmark/proj/Record.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
benchmark/proj/Record.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
benchmark/proj/Record.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --type-in-type #-}
module Record where
infixr 2 _,_
record Σ (A : Set)(B : A → Set) : Set where
constructor _,_
field fst : A
snd : B fst
open Σ
data ⊤ : Set where
tt : ⊤
∃ : {A : Set}(B : A → Set) → Set
∃ B = Σ _ B
infix 10 _≡_
data _≡_ {A : Set}(a : A) : {B : Set} → B → Set where
refl : a ≡ a
trans : ∀ {A B C}{a : A}{b : B}{c : C} → a ≡ b → b ≡ c → a ≡ c
trans refl p = p
sym : ∀ {A B}{a : A}{b : B} → a ≡ b → b ≡ a
sym refl = refl
resp : ∀ {A}{B : A → Set}{a a' : A} →
(f : (a : A) → B a) → a ≡ a' → f a ≡ f a'
resp f refl = refl
Cat : Set
Cat =
∃ λ (Obj : Set) →
∃ λ (Hom : Obj → Obj → Set) →
∃ λ (id : ∀ X → Hom X X) →
∃ λ (_○_ : ∀ {X Y Z} → Hom Y Z → Hom X Y → Hom X Z) →
∃ λ (idl : ∀ {X Y}{f : Hom X Y} → (id Y ○ f) ≡ f) →
∃ λ (idr : ∀ {X Y}{f : Hom X Y} → (f ○ id X) ≡ f) →
∃ λ (assoc : ∀ {W X Y Z}{f : Hom W X}{g : Hom X Y}{h : Hom Y Z} →
((h ○ g) ○ f) ≡ (h ○ (g ○ f))) →
⊤
Obj : (C : Cat) → Set
Obj C = fst C
Hom : (C : Cat) → Obj C → Obj C → Set
Hom C = fst (snd C)
id : (C : Cat) → ∀ X → Hom C X X
id C = fst (snd (snd C))
comp : (C : Cat) → ∀ {X Y Z} → Hom C Y Z → Hom C X Y → Hom C X Z
comp C = fst (snd (snd (snd C)))
idl : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C (id C Y) f ≡ f
idl C = fst (snd (snd (snd (snd C))))
idr : (C : Cat) → ∀ {X Y}{f : Hom C X Y} → comp C f (id C X) ≡ f
idr C = fst (snd (snd (snd (snd (snd C)))))
assoc : (C : Cat) → ∀ {W X Y Z}{f : Hom C W X}{g : Hom C X Y}{h : Hom C Y Z} →
comp C (comp C h g) f ≡ comp C h (comp C g f)
assoc C = fst (snd (snd (snd (snd (snd (snd C))))))
| 24.484848
| 78
| 0.430074
|
37731c1139048a044f97db448332804b65aae03b
| 250
|
agda
|
Agda
|
test/Fail/Imports/Issue958.agda
|
MxmUrw/agda
|
6ede01fa854c5472e54f7d1799ca2c08ed316129
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Imports/Issue958.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Imports/Issue958.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Imports.Issue958 where
postulate FunctorOps : Set
module FunctorOps (ops : FunctorOps) where
postulate map : Set
postulate IsFunctor : Set
module IsFunctor (fun : IsFunctor) where
postulate ops : FunctorOps
open FunctorOps ops public
| 20.833333
| 42
| 0.78
|
52abbf0a3954df8b86bbb3346ce596121de683bd
| 81
|
agda
|
Agda
|
test/fail/ClashingModuleImport.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/fail/ClashingModuleImport.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/ClashingModuleImport.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
module ClashingModuleImport where
X = TODO--I-haven't-fully-understood-this-one
| 20.25
| 45
| 0.802469
|
35f836b1ec451466051406c0a235a535c6331933
| 4,909
|
agda
|
Agda
|
setoid-cats/Category/Subcategory.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
setoid-cats/Category/Subcategory.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
setoid-cats/Category/Subcategory.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
---------------------------------------------------------------
-- This file contains the definitions of several versions of --
-- subcategories. --
---------------------------------------------------------------
module Category.Subcategory where
open import Level
open import Data.Product
open import Setoid.Total
open import Relation.Relation
open import Category.Category
open Setoid
open SetoidFun
open Pred
open Subcarrier
open EqRel
open Cat
-- Categorical Predicate: A predicate on objects, and morphisms such
-- that the latter is closed under identities and composition.
record CatPred {l : Level} (ℂ : Cat {l}) : Set (lsuc l) where
field
oinc : Obj ℂ → Set l
minc : ∀{A B} → oinc A → oinc B → Pred {l} (Hom ℂ A B)
cp-idPf : ∀{A} → {p : oinc A} → pf (minc p p) (id ℂ {A})
cp-compPf : ∀{A B C} → (op₁ : (oinc A))
→ (op₂ : (oinc B))
→ (op₃ : (oinc C))
→ {f : el (Hom ℂ A B)}
→ {g : el (Hom ℂ B C)}
→ (pf (minc op₁ op₂) f)
→ (pf (minc op₂ op₃) g)
→ (pf (minc op₁ op₃) (f ○[ comp ℂ ] g))
open CatPred
-- Subcategories:
-- The restriction of a category ℂ to the category determined by the
-- categorical predicate P. Note that the objects of this category
-- are pairs of an object and a proof that the object belongs in the
-- category, and morphisms are similarly defined but using setoid
-- predicates.
subcatPred : {l : Level}{ℂ : Cat {l}}
→ (P : CatPred ℂ)
→ Cat {l}
subcatPred {_}{ℂ} P =
record
{ Obj = Σ[ x ∈ Obj ℂ ]( oinc P x)
; Hom = λ AP BP → let A = proj₁ AP
B = proj₁ BP
op₁ = proj₂ AP
op₂ = proj₂ BP
in Subsetoid (Hom ℂ A B) (minc P op₁ op₂)
; comp = λ {AP}{BP}{CP} →
let A = proj₁ AP
B = proj₁ BP
C = proj₁ CP
op₁ = proj₂ AP
op₂ = proj₂ BP
op₃ = proj₂ CP
in record {
appT = λ x →
record {
appT = λ x₁ →
record { subel = (subel x) ○[ comp ℂ ] (subel x₁) ;
insub = cp-compPf P op₁ op₂ op₃ (insub x) (insub x₁) } ;
extT = λ {y} {z} x₂ → eq-comp-right {_}{ℂ}{A}{B}{C}{subel x}{subel y}{subel z} x₂ } ;
extT = λ {f₁}{f₂} pf g₂ → extT (comp ℂ) pf (subel g₂) }
; id = λ {AP} → let A = proj₁ AP
A-op = proj₂ AP
in record { subel = id ℂ ; insub = cp-idPf P {_}{A-op} }
; assocPf = assocPf ℂ
; idPfCom = idPfCom ℂ
; idPf = idPf ℂ
}
-- Subcategories using subsetoids.
subcat : {l : Level}
→ (ℂ : Cat {l})(O : Set l)
→ (oinc : O → Obj ℂ)
→ (minc : ∀{A B} → Pred {l} (Hom ℂ (oinc A) (oinc B)))
→ (∀{A} → pf (minc {A}{A}) (id ℂ {oinc A}))
→ (∀{A B C}
→ {f : el (Hom ℂ (oinc A) (oinc B))}
→ {g : el (Hom ℂ (oinc B) (oinc C))}
→ (pf minc f)
→ (pf minc g)
→ (pf minc (f ○[ comp ℂ ] g)))
→ Cat {l}
subcat ℂ O oinc minc idPF compPF =
record {
Obj = O;
Hom = λ A B → Subsetoid (Hom ℂ (oinc A) (oinc B)) (minc {A}{B});
comp = λ {A} {B} {C} →
record { appT = λ x →
record { appT = λ x₁ →
record { subel = (subel x) ○[ comp ℂ ] (subel x₁);
insub = compPF {f = subel x}{subel x₁} (insub x) (insub x₁) };
extT = λ {y}{z} p → extT (appT (comp ℂ {oinc A}{oinc B}{oinc C}) (subel x)) {subel y}{subel z} p };
extT = λ {y}{z} x₁ x₂ → extT (comp ℂ {oinc A} {oinc B} {oinc C}) x₁ (subel x₂) };
id = λ {A} → record { subel = id ℂ {oinc A}; insub = idPF {A} };
assocPf = assocPf ℂ;
idPf = idPf ℂ;
idPfCom = idPfCom ℂ
}
-- An alternate definition of a subcategory where the predicate is not
-- a setoid predicate.
subcat-pred : {l : Level}
→ (ℂ : Cat {l})(O : Set l)
→ (oinc : O → Obj ℂ)
→ (minc : ∀{A B} → el (Hom ℂ (oinc A) (oinc B)) → Set l)
→ (∀{A} → minc (id ℂ {oinc A}))
→ (∀{A B C}
→ {f : el (Hom ℂ (oinc A) (oinc B))}
→ {g : el (Hom ℂ (oinc B) (oinc C))}
→ (minc f)
→ (minc g)
→ (minc (f ○[ comp ℂ ] g)))
→ Cat {l}
subcat-pred ℂ O oinc minc idPF compPF =
record {
Obj = O;
Hom = λ A B → ↓Setoid (Hom ℂ (oinc A) (oinc B)) (minc {A}{B});
comp = λ {A} {B} {C} → ↓BinSetoidFun (comp ℂ) compPF;
id = (id ℂ , idPF);
assocPf = assocPf ℂ;
idPf = idPf ℂ;
idPfCom = idPfCom ℂ}
| 37.189394
| 126
| 0.440823
|
52cc1c736c66b6a0b92a74e6a892d2bbeaf0a99d
| 846
|
agda
|
Agda
|
agda-stdlib/src/Data/String.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/String.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/String.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Strings
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.String where
open import Data.Vec.Base as Vec using (Vec)
open import Data.Char as Char using (Char)
open import Function.Base
------------------------------------------------------------------------
-- Re-export contents of base, and decidability of equality
open import Data.String.Base public
open import Data.String.Properties using (_≈?_; _≟_; _<?_; _==_) public
------------------------------------------------------------------------
-- Operations
toVec : (s : String) → Vec Char (length s)
toVec s = Vec.fromList (toList s)
fromVec : ∀ {n} → Vec Char n → String
fromVec = fromList ∘ Vec.toList
| 29.172414
| 72
| 0.460993
|
d169417458750cfaf1cdebc195640492eb2aaa5b
| 125
|
agda
|
Agda
|
test/Succeed/Issue794a.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue794a.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue794a.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
module Issue794a where
open import Common.Prelude
open import Common.MAlonzo
postulate A : Set
id : .A → A → A
id x y = y
| 12.5
| 26
| 0.712
|
21aa6afd0816832a4f8b795d90b50f940b6f62e6
| 2,157
|
agda
|
Agda
|
agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/Construct/At.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/Construct/At.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/Construct/At.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Instantiates indexed binary structures at an index to the equivalent
-- non-indexed structures.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Indexed.Heterogeneous.Construct.At where
open import Relation.Binary
open import Relation.Binary.Indexed.Heterogeneous
hiding (IsEquivalence; Setoid)
------------------------------------------------------------------------
-- Structures
module _ {a i} {I : Set i} {A : I → Set a} where
isEquivalence : ∀ {ℓ} {_≈_ : IRel A ℓ} → IsIndexedEquivalence A _≈_ →
(index : I) → IsEquivalence (_≈_ {index})
isEquivalence isEq index = record
{ refl = refl
; sym = sym
; trans = trans
}
where open IsIndexedEquivalence isEq
isPreorder : ∀ {ℓ₁ ℓ₂} {_≈_ : IRel A ℓ₁} {_∼_ : IRel A ℓ₂} →
IsIndexedPreorder A _≈_ _∼_ →
(index : I) → IsPreorder (_≈_ {index}) _∼_
isPreorder isPreorder index = record
{ isEquivalence = isEquivalence O.isEquivalence index
; reflexive = O.reflexive
; trans = O.trans
}
where module O = IsIndexedPreorder isPreorder
------------------------------------------------------------------------
-- Bundles
module _ {a i} {I : Set i} where
setoid : ∀ {ℓ} → IndexedSetoid I a ℓ → I → Setoid a ℓ
setoid S index = record
{ Carrier = S.Carrier index
; _≈_ = S._≈_
; isEquivalence = isEquivalence S.isEquivalence index
}
where module S = IndexedSetoid S
preorder : ∀ {ℓ₁ ℓ₂} → IndexedPreorder I a ℓ₁ ℓ₂ → I → Preorder a ℓ₁ ℓ₂
preorder O index = record
{ Carrier = O.Carrier index
; _≈_ = O._≈_
; _∼_ = O._∼_
; isPreorder = isPreorder O.isPreorder index
}
where module O = IndexedPreorder O
------------------------------------------------------------------------
-- Some useful shorthand infix notation
module _ {a i} {I : Set i} where
_atₛ_ : ∀ {ℓ} → IndexedSetoid I a ℓ → I → Setoid a ℓ
_atₛ_ = setoid
| 31.26087
| 73
| 0.514604
|
1b06b8f4994a112dc1c9b0aedd89e5aa13332380
| 142
|
agda
|
Agda
|
test/Succeed/Issue794.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue794.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue794.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
module Issue794 where
open import Common.Prelude
open import Common.MAlonzo
postulate A : Set
record R : Set where
id : A → A
id x = x
| 12.909091
| 26
| 0.711268
|
1bc53938be4c17d8c0c758258456c9314a778160
| 1,436
|
agda
|
Agda
|
src/AssocFree/STLambdaC/NF.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | 3
|
2016-11-22T11:48:31.000Z
|
2020-08-27T20:56:20.000Z
|
src/AssocFree/STLambdaC/NF.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | null | null | null |
src/AssocFree/STLambdaC/NF.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | 2
|
2018-03-03T04:39:31.000Z
|
2022-03-12T11:38:44.000Z
|
import AssocFree.STLambdaC.Typ
import AssocFree.STLambdaC.Exp
module AssocFree.STLambdaC.NF
(TConst : Set)
(Const : AssocFree.STLambdaC.Typ.Typ TConst → Set) where
open module Typ = AssocFree.STLambdaC.Typ TConst using
( Typ ; Ctxt ; const ; _⇝_ ; [_] ; [] ; _∷_ ; _++_ ; case ; singleton ; _≪_ )
open module Exp = AssocFree.STLambdaC.Exp TConst Const using
( Exp ; const ; abs ; app ; var ; var₀ ; weaken+ ; weaken* ; xweaken+ )
mutual
-- Normal forms
data Atom {Γ : Ctxt} {T : Typ} : Exp Γ T → Set where
const : ∀ c → Atom (const c)
var : ∀ x → Atom (var x)
app : ∀ {U M} {N : Exp Γ U} → Atom M → NF N → Atom (app M N)
data NF {Γ : Ctxt} : ∀ {T} → Exp Γ T → Set where
atom : ∀ {C} {M : Exp Γ (const C)} → Atom M → NF M
abs : ∀ T {U} {M : Exp (T ∷ Γ) U} → NF M → NF (abs {Γ} T M)
-- Shorthand
atom₀ : ∀ {Γ T} → Atom (var₀ {Γ} {T})
atom₀ {Γ} {T} = var (singleton T ≪ Γ)
-- Weakening
mutual
aweaken+ : ∀ B Γ Δ {T M} → Atom M → Atom (weaken+ B Γ Δ {T} M)
aweaken+ B Γ Δ (const c) = const c
aweaken+ B Γ Δ (app M N) = app (aweaken+ B Γ Δ M) (nweaken+ B Γ Δ N)
aweaken+ B Γ Δ (var x) = var (xweaken+ B Γ Δ x)
nweaken+ : ∀ B Γ Δ {T M} → NF M → NF (weaken+ B Γ Δ {T} M)
nweaken+ B Γ Δ (atom N) = atom (aweaken+ B Γ Δ N)
nweaken+ B Γ Δ (abs T N) = abs T (nweaken+ (T ∷ B) Γ Δ N)
aweaken* : ∀ Γ {Δ T M} → Atom M → Atom (weaken* Γ {Δ} {T} M)
aweaken* Γ {Δ} = aweaken+ [] Γ Δ
| 29.306122
| 79
| 0.555014
|
2194e050743f459faff1cd91cb1b9e4836417dee
| 6,538
|
agda
|
Agda
|
agda/Data/List/Relation/Unary.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | 4
|
2021-01-05T14:07:44.000Z
|
2021-01-05T15:32:14.000Z
|
agda/Data/List/Relation/Unary.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | null | null | null |
agda/Data/List/Relation/Unary.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | 1
|
2021-01-05T14:05:30.000Z
|
2021-01-05T14:05:30.000Z
|
{-# OPTIONS --cubical --safe #-}
module Data.List.Relation.Unary where
open import Prelude
open import Data.List.Base
open import Data.Fin
open import Relation.Nullary
open import Data.Sum
private
variable p : Level
module Inductive◇ where
data ◇ {A : Type a} (P : A → Type p) : List A → Type (a ℓ⊔ p) where
here : ∀ {x xs} → P x → ◇ P (x ∷ xs)
there : ∀ {x xs} → ◇ P xs → ◇ P (x ∷ xs)
◇ : (P : A → Type p) → List A → Type _
◇ P xs = ∃[ i ] P (xs ! i)
◇! : (P : A → Type p) → List A → Type _
◇! P xs = isContr (◇ P xs)
module Exists {a} {A : Type a} {p} (P : A → Type p) where
push : ∀ {x xs} → ◇ P xs → ◇ P (x ∷ xs)
push (n , p) = fs n , p
pull : ∀ {x xs} → ¬ P x → ◇ P (x ∷ xs) → ◇ P xs
pull ¬Px (f0 , p) = ⊥-elim (¬Px p)
pull ¬Px (fs n , p) = n , p
uncons : ∀ {x xs} → ◇ P (x ∷ xs) → P x ⊎ ◇ P xs
uncons (f0 , p) = inl p
uncons (fs x , p) = inr (x , p)
infixr 5 _++◇_ _◇++_
_++◇_ : ∀ {xs} ys → ◇ P xs → ◇ P (ys ++ xs)
[] ++◇ ys = ys
(x ∷ xs) ++◇ ys = push (xs ++◇ ys)
_◇++_ : ∀ xs → ◇ P xs → ∀ {ys} → ◇ P (xs ++ ys)
_◇++_ (x ∷ xs) (f0 , ∃Pxs) = f0 , ∃Pxs
_◇++_ (x ∷ xs) (fs n , ∃Pxs) = push (xs ◇++ (n , ∃Pxs))
push! : ∀ {x xs} → ¬ P x → ◇! P xs → ◇! P (x ∷ xs)
push! ¬Px x∈!xs .fst = push (x∈!xs .fst)
push! ¬Px x∈!xs .snd (f0 , px) = ⊥-elim (¬Px px)
push! ¬Px x∈!xs .snd (fs n , y∈xs) i = push (x∈!xs .snd (n , y∈xs) i)
pull! : ∀ {x xs} → ¬ P x → ◇! P (x ∷ xs) → ◇! P xs
pull! ¬Px ((f0 , px ) , uniq) = ⊥-elim (¬Px px)
pull! ¬Px ((fs n , x∈xs ) , uniq) .fst = (n , x∈xs)
pull! ¬Px ((fs n , x∈xs ) , uniq) .snd (m , x∈xs′) i =
pull ¬Px (uniq (fs m , x∈xs′ ) i)
here! : ∀ {x xs} → isContr (P x) → ¬ ◇ P xs → ◇! P (x ∷ xs)
here! Px p∉xs .fst = f0 , Px .fst
here! Px p∉xs .snd (f0 , p∈xs) i .fst = f0
here! Px p∉xs .snd (f0 , p∈xs) i .snd = Px .snd p∈xs i
here! Px p∉xs .snd (fs n , p∈xs) = ⊥-elim (p∉xs (n , p∈xs))
module _ (P? : ∀ x → Dec (P x)) where
open import Relation.Nullary.Decidable.Logic
◇? : ∀ xs → Dec (◇ P xs)
◇? [] = no λ ()
◇? (x ∷ xs) = ⟦yes ⟦l f0 ,_ ,r push ⟧ ,no uncons ⟧ (P? x || ◇? xs)
◻ : (P : A → Type p) → List A → Type _
◻ P xs = ∀ i → P (xs ! i)
module Forall {a} {A : Type a} {p} (P : A → Type p) where
push : ∀ {x xs} → P x → ◻ P xs → ◻ P (x ∷ xs)
push Px Pxs f0 = Px
push Px Pxs (fs n) = Pxs n
uncons : ∀ {x xs} → ◻ P (x ∷ xs) → P x × ◻ P xs
uncons Pxs = Pxs f0 , Pxs ∘ fs
pull : ∀ {x xs} → ◻ P (x ∷ xs) → ◻ P xs
pull = snd ∘ uncons
_++◇_ : ∀ xs {ys} → ◻ P (xs ++ ys) → ◻ P ys
[] ++◇ xs⊆P = xs⊆P
(x ∷ xs) ++◇ xs⊆P = xs ++◇ (xs⊆P ∘ fs)
_◇++_ : ∀ xs {ys} → ◻ P (xs ++ ys) → ◻ P xs
([] ◇++ xs⊆P) ()
((x ∷ xs) ◇++ xs⊆P) f0 = xs⊆P f0
((x ∷ xs) ◇++ xs⊆P) (fs n) = (xs ◇++ pull xs⊆P) n
both : ∀ xs {ys} → ◻ P xs → ◻ P ys → ◻ P (xs ++ ys)
both [] xs⊆P ys⊆P = ys⊆P
both (x ∷ xs) xs⊆P ys⊆P f0 = xs⊆P f0
both (x ∷ xs) xs⊆P ys⊆P (fs i) = both xs (pull xs⊆P) ys⊆P i
empty : ◻ P []
empty ()
module _ where
open import Relation.Nullary.Decidable.Logic
◻? : (∀ x → Dec (P x)) → ∀ xs → Dec (◻ P xs)
◻? P? [] = yes λ ()
◻? P? (x ∷ xs) = ⟦yes uncurry push
,no uncons
⟧ (P? x && ◻? P? xs)
module Forall-NotExists {a} {A : Type a} {p} (P : A → Type p) where
open import Relation.Nullary.Stable
open import Data.Empty.Properties
open Forall P
¬P = ¬_ ∘ P
module ∃¬ = Exists ¬P
∀⇒¬∃¬ : ∀ xs → ◻ P xs → ¬ (◇ ¬P xs)
∀⇒¬∃¬ (x ∷ xs) xs⊆P (f0 , ∃¬P∈xs) = ∃¬P∈xs(xs⊆P f0)
∀⇒¬∃¬ (x ∷ xs) xs⊆P (fs n , ∃¬P∈xs) = ∀⇒¬∃¬ xs (xs⊆P ∘ fs) (n , ∃¬P∈xs)
module _ (stable : ∀ {x} → Stable (P x)) where
¬∃¬⇒∀ : ∀ xs → ¬ (◇ ¬P xs) → ◻ P xs
¬∃¬⇒∀ (x ∷ xs) ¬∃¬P∈xs f0 = stable (¬∃¬P∈xs ∘ (f0 ,_))
¬∃¬⇒∀ (x ∷ xs) ¬∃¬P∈xs (fs n) = ¬∃¬⇒∀ xs (¬∃¬P∈xs ∘ ∃¬.push) n
leftInv′ : ∀ (prop : ∀ {x} → isProp (P x)) xs → (x : ◻ P xs) → ¬∃¬⇒∀ xs (∀⇒¬∃¬ xs x) ≡ x
leftInv′ prop [] x i ()
leftInv′ prop (x ∷ xs) xs⊆P i f0 = prop (stable λ ¬p → ¬p (xs⊆P f0)) (xs⊆P f0) i
leftInv′ prop (x ∷ xs) xs⊆P i (fs n) = leftInv′ prop xs (pull xs⊆P) i n
∀⇔¬∃¬ : ∀ (prop : ∀ {x} → isProp (P x)) xs → ◻ P xs ⇔ (¬ ◇ ¬P xs)
∀⇔¬∃¬ _ xs .fun = ∀⇒¬∃¬ xs
∀⇔¬∃¬ _ xs .inv = ¬∃¬⇒∀ xs
∀⇔¬∃¬ p xs .leftInv = leftInv′ p xs
∀⇔¬∃¬ _ xs .rightInv x = isProp¬ _ _ x
module Exists-NotForall {a} {A : Type a} {p} (P : A → Type p) where
open Exists P
¬P = ¬_ ∘ P
module ∀¬ = Forall ¬P
∃⇒¬∀¬ : ∀ xs → ◇ P xs → ¬ ◻ ¬P xs
∃⇒¬∀¬ (x ∷ xs) (f0 , P∈xs) xs⊆P = xs⊆P f0 P∈xs
∃⇒¬∀¬ (x ∷ xs) (fs n , P∈xs) xs⊆P = ∃⇒¬∀¬ xs (n , P∈xs) (xs⊆P ∘ fs)
module _ (P? : ∀ x → Dec (P x)) where
¬∀¬⇒∃ : ∀ xs → ¬ ◻ ¬P xs → ◇ P xs
¬∀¬⇒∃ [] ¬xs⊆¬P = ⊥-elim (¬xs⊆¬P λ ())
¬∀¬⇒∃ (x ∷ xs) ¬xs⊆¬P with P? x
¬∀¬⇒∃ (x ∷ xs) ¬xs⊆¬P | yes p = f0 , p
¬∀¬⇒∃ (x ∷ xs) ¬xs⊆¬P | no ¬p = push (¬∀¬⇒∃ xs (¬xs⊆¬P ∘ ∀¬.push ¬p))
module Congruence {p q} (P : A → Type p) (Q : B → Type q)
{f : A → B} (f↑ : ∀ {x} → P x → Q (f x)) where
cong-◇ : ∀ xs → ◇ P xs → ◇ Q (map f xs)
cong-◇ (x ∷ xs) (f0 , P∈xs) = f0 , f↑ P∈xs
cong-◇ (x ∷ xs) (fs n , P∈xs) = Exists.push Q (cong-◇ xs (n , P∈xs))
◇-concat : ∀ (P : A → Type p) xs → ◇ (◇ P) xs → ◇ P (concat xs)
◇-concat P (x ∷ xs) (f0 , ps) = Exists._◇++_ P x ps
◇-concat P (x ∷ xs) (fs n , ps) = Exists._++◇_ P x (◇-concat P xs (n , ps))
◻-concat : ∀ (P : A → Type p) xs → ◻ (◻ P) xs → ◻ P (concat xs)
◻-concat P [] xs⊆P ()
◻-concat P (x ∷ xs) xs⊆P = Forall.both P x (xs⊆P f0) (◻-concat P xs (xs⊆P ∘ fs))
module Search {A : Type a} where
data Result {p} (P : A → Type p) (xs : List A) : Bool → Type (a ℓ⊔ p) where
all′ : ◻ P xs → Result P xs true
except′ : ◇ (¬_ ∘ P) xs → Result P xs false
record Found {p} (P : A → Type p) (xs : List A) : Type (a ℓ⊔ p) where
field
found? : Bool
result : Result P xs found?
open Found public
pattern all ps = record { found? = true ; result = all′ ps }
pattern except ¬p = record { found? = false ; result = except′ ¬p }
module _ {p} {P : A → Type p} (P? : ∀ x → Dec (P x)) where
search : ∀ xs → Found P xs
search [] = all λ ()
search (x ∷ xs) = search′ x xs (P? x) (search xs)
where
search′ : ∀ x xs → Dec (P x) → Found P xs → Found P (x ∷ xs)
search′ x xs Px Pxs .found? = Px .does and Pxs .found?
search′ x xs (no ¬p) Pxs .result = except′ (f0 , ¬p)
search′ x xs (yes p) (except ¬p) .result = except′ (Exists.push (¬_ ∘ P) ¬p)
search′ x xs (yes p) (all ps) .result = all′ (Forall.push P p ps)
| 34.230366
| 92
| 0.44402
|
13bdb874caca60e0436cd801c8172ed14a9bc745
| 726
|
agda
|
Agda
|
agda-stdlib/src/Data/Nat/Binary/Induction.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Nat/Binary/Induction.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Nat/Binary/Induction.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Induction over _<_ for ℕᵇ.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Nat.Binary.Induction where
open import Data.Nat.Binary.Base
open import Data.Nat.Binary.Properties
open import Data.Nat.Base as ℕ using (ℕ)
import Data.Nat.Induction as ℕ
open import Induction.WellFounded
------------------------------------------------------------------------
-- _<_ is wellFounded
<-wellFounded : WellFounded _<_
<-wellFounded x = Subrelation.accessible <⇒<ℕ toℕ[x]-acc
where
toℕ[x]-acc = InverseImage.accessible toℕ (ℕ.<-wellFounded (toℕ x))
| 30.25
| 72
| 0.512397
|
43b605ba6176f2f50165213f11a8344aa454ad32
| 1,465
|
agda
|
Agda
|
test/Fail/Issue1271.agda
|
alex-mckenna/agda
|
78b62cd24bbd570271a7153e44ad280e52ef3e29
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/Issue1271.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue1271.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- Andreas, issue reported by Matteo Acerbi, 2014-09-04.
-- Short summary: x = c x is not impossible for coinductive constructors c,
-- so x should not be considered a strictly rigid occurrence in (c x).
-- Matteo:
-- In the following I cannot understand what justifies the absurd pattern
-- in the definition of ¬id≡In: as νId is coinductive, elaboration of the
-- no-cycles check to eliminators should not be possible (as far as I know).
-- Any two inhabitants of νId are bisimilar, but it seems that current
-- pattern matching makes it inconsistent to assume that bisimilarity
-- implies equality for νId, which *might* upset some. :-)
{-# OPTIONS --copatterns #-}
-- False and equality.
⊥ = (X : Set) → X
data _≡_ {A : Set}(x : A) : A → Set where
<> : x ≡ x
-- The cofixpoint of the identity functor.
record νId : Set where
coinductive
constructor In
field Out : νId
open νId
-- The "only" inhabitant of νId.
tt : νId
Out tt = tt
-- x ≡ In x is considered absurd.
¬id≡In : {x : νId} → x ≡ In x → ⊥
¬id≡In ()
-- _≈_ is bisimilarity for elements of νId.
record _≈νId_ (x y : νId) : Set where
coinductive
field step : Out x ≈νId Out y
open _≈νId_
-- Any two elements are bisimilar.
trivial-≈νId : ∀ {x y} → x ≈νId y
step trivial-≈νId = trivial-≈νId
-- For νId it is not consistent to assume that bisimilarity implies
-- equality.
problem? : (ext : ∀ {x y} → x ≈νId y → x ≡ y) → ⊥
problem? ext = ¬id≡In {tt} (ext trivial-≈νId)
| 24.830508
| 76
| 0.668942
|
34bc3e0d6d6708380d5655b2e2f321cfb0a9ec70
| 2,261
|
agda
|
Agda
|
examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Rational.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/AIM6/Cat/lib/Data/Rational.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/AIM6/Cat/lib/Data/Rational.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Data.Rational where
import Data.Bool as Bool
import Data.Nat as Nat
import Data.Integer as Int
open Int renaming
( _*_ to _*'_
; _+_ to _+'_
; -_ to -'_
; _-_ to _-'_
; !_! to !_!'
; _==_ to _=='_
; _≤_ to _≤'_
; _≥_ to _≥'_
; _>_ to _>'_
; _<_ to _<'_
)
open Nat using (Nat; zero; suc)
open Bool
infix 40 _==_ _<_ _>_ _≤_ _≥_
infixl 60 _+_ _-_
infixl 70 _%'_ _%_ _/_ _*_
infixr 80 _^_
infix 90 -_
data Rational : Set where
_%'_ : Int -> Int -> Rational
numerator : Rational -> Int
numerator (n %' d) = n
denominator : Rational -> Int
denominator (n %' d) = d
_%_ : Int -> Int -> Rational
neg n % neg m = pos (suc n) % pos (suc m)
pos 0 % neg m = pos 0 %' pos 1
pos (suc n) % neg m = neg n % pos (suc m)
x % y = div x z %' div y z
where
z = gcd x y
fromInt : Int -> Rational
fromInt x = x %' pos 1
fromNat : Nat -> Rational
fromNat x = fromInt (pos x)
_+_ : Rational -> Rational -> Rational
(a %' b) + (c %' d) = (a *' d +' c *' b) % (b *' d)
-_ : Rational -> Rational
- (a %' b) = -' a %' b
_-_ : Rational -> Rational -> Rational
a - b = a + (- b)
_/_ : Rational -> Rational -> Rational
(a %' b) / (c %' d) = (a *' d) % (b *' c)
_*_ : Rational -> Rational -> Rational
(a %' b) * (c %' d) = (a *' c) % (b *' d)
recip : Rational -> Rational
recip (a %' b) = b %' a
_^_ : Rational -> Int -> Rational
q ^ neg n = recip q ^ pos (suc n)
q ^ pos zero = fromNat 1
q ^ pos (suc n) = q * q ^ pos n
!_! : Rational -> Rational
! a %' b ! = pos ! a !' %' pos ! b !'
round : Rational -> Int
round (a %' b) = div (a +' div b (pos 2)) b
_==_ : Rational -> Rational -> Bool
(a %' b) == (c %' d) = a *' d ==' b *' c
_<_ : Rational -> Rational -> Bool
(a %' b) < (c %' d) = a *' d <' b *' c
_>_ : Rational -> Rational -> Bool
(a %' b) > (c %' d) = a *' d >' b *' c
_≤_ : Rational -> Rational -> Bool
(a %' b) ≤ (c %' d) = a *' d ≤' b *' c
_≥_ : Rational -> Rational -> Bool
(a %' b) ≥ (c %' d) = a *' d ≥' b *' c
max : Rational -> Rational -> Rational
max a b = if a < b then b else a
min : Rational -> Rational -> Rational
min a b = if a < b then a else b
| 22.166667
| 51
| 0.476338
|
03b718ce4e35e8b69c34b456a17a3f4552bfbfbe
| 212
|
agda
|
Agda
|
src/Calf/Types/Nat.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 29
|
2021-07-14T03:18:28.000Z
|
2022-03-22T20:35:11.000Z
|
src/Calf/Types/Nat.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | null | null | null |
src/Calf/Types/Nat.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 2
|
2021-10-06T10:28:24.000Z
|
2022-01-29T08:12:01.000Z
|
{-# OPTIONS --without-K --prop --rewriting #-}
module Calf.Types.Nat where
open import Calf.Prelude
open import Calf.Metalanguage
open import Data.Nat using (ℕ; zero; suc) public
nat : tp pos
nat = U (meta ℕ)
| 19.272727
| 48
| 0.712264
|
34c77fc7f97893289fb803277c0db3d3655b12c3
| 465
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Relation/Binary/EqReasoning.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/EqReasoning.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/EqReasoning.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use the
-- Relation.Binary.Reasoning.Setoid module directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Relation.Binary.EqReasoning {s₁ s₂} (S : Setoid s₁ s₂) where
open import Relation.Binary.Reasoning.Setoid S public
| 31
| 72
| 0.513978
|
ad9aa1f41c9676b1dc21aeb2f86b8d32b31a3319
| 6,683
|
agda
|
Agda
|
Univalence/OldUnivalence/TypeEquivalences.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 14
|
2015-08-18T21:40:15.000Z
|
2021-05-05T01:07:57.000Z
|
Univalence/OldUnivalence/TypeEquivalences.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 4
|
2018-06-07T16:27:41.000Z
|
2021-10-29T20:41:23.000Z
|
Univalence/OldUnivalence/TypeEquivalences.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 3
|
2016-05-29T01:56:33.000Z
|
2019-09-10T09:47:13.000Z
|
{-# OPTIONS --without-K #-}
module TypeEquivalences where
open import Data.Empty
open import Data.Unit
open import Data.Unit.Core
open import Data.Nat renaming (_⊔_ to _⊔ℕ_)
open import Data.Sum renaming (map to _⊎→_)
open import Data.Product renaming (map to _×→_)
open import Function renaming (_∘_ to _○_)
-- explicit using to show how little of HoTT is needed
open import SimpleHoTT using (refl; ap; ap2)
open import Equivalences
------------------------------------------------------------------------------
-- Type Equivalences
-- for each type combinator, define two functions that are inverses, and
-- establish an equivalence. These are all in the 'semantic space' with
-- respect to Pi combinators.
-- swap₊
swap₊ : {A B : Set} → A ⊎ B → B ⊎ A
swap₊ (inj₁ a) = inj₂ a
swap₊ (inj₂ b) = inj₁ b
swapswap₊ : {A B : Set} → swap₊ ○ swap₊ {A} {B} ∼ id
swapswap₊ (inj₁ a) = refl (inj₁ a)
swapswap₊ (inj₂ b) = refl (inj₂ b)
swap₊equiv : {A B : Set} → (A ⊎ B) ≃ (B ⊎ A)
swap₊equiv = (swap₊ , equiv₁ (mkqinv swap₊ swapswap₊ swapswap₊))
-- unite₊ and uniti₊
unite₊ : {A : Set} → ⊥ ⊎ A → A
unite₊ (inj₁ ())
unite₊ (inj₂ y) = y
uniti₊ : {A : Set} → A → ⊥ ⊎ A
uniti₊ a = inj₂ a
uniti₊∘unite₊ : {A : Set} → uniti₊ ○ unite₊ ∼ id {A = ⊥ ⊎ A}
uniti₊∘unite₊ (inj₁ ())
uniti₊∘unite₊ (inj₂ y) = refl (inj₂ y)
-- this is so easy, Agda can figure it out by itself (see below)
unite₊∙uniti₊ : {A : Set} → unite₊ ○ uniti₊ ∼ id {A = A}
unite₊∙uniti₊ = refl
unite₊equiv : {A : Set} → (⊥ ⊎ A) ≃ A
unite₊equiv = (unite₊ , mkisequiv uniti₊ refl uniti₊ uniti₊∘unite₊)
uniti₊equiv : {A : Set} → A ≃ (⊥ ⊎ A)
uniti₊equiv = uniti₊ , mkisequiv unite₊ uniti₊∘unite₊ unite₊ unite₊∙uniti₊
-- unite⋆ and uniti⋆
unite⋆ : {A : Set} → ⊤ × A → A
unite⋆ (tt , x) = x
uniti⋆ : {A : Set} → A → ⊤ × A
uniti⋆ x = tt , x
uniti⋆∘unite⋆ : {A : Set} → uniti⋆ ○ unite⋆ ∼ id {A = ⊤ × A}
uniti⋆∘unite⋆ (tt , x) = refl (tt , x)
unite⋆equiv : {A : Set} → (⊤ × A) ≃ A
unite⋆equiv = unite⋆ , mkisequiv uniti⋆ refl uniti⋆ uniti⋆∘unite⋆
uniti⋆equiv : {A : Set} → A ≃ (⊤ × A)
uniti⋆equiv = uniti⋆ , mkisequiv unite⋆ uniti⋆∘unite⋆ unite⋆ refl
-- swap⋆
swap⋆ : {A B : Set} → A × B → B × A
swap⋆ (a , b) = (b , a)
swapswap⋆ : {A B : Set} → swap⋆ ○ swap⋆ ∼ id {A = A × B}
swapswap⋆ (a , b) = refl (a , b)
swap⋆equiv : {A B : Set} → (A × B) ≃ (B × A)
swap⋆equiv = swap⋆ , mkisequiv swap⋆ swapswap⋆ swap⋆ swapswap⋆
-- assocl₊ and assocr₊
assocl₊ : {A B C : Set} → (A ⊎ (B ⊎ C)) → ((A ⊎ B) ⊎ C)
assocl₊ (inj₁ a) = inj₁ (inj₁ a)
assocl₊ (inj₂ (inj₁ b)) = inj₁ (inj₂ b)
assocl₊ (inj₂ (inj₂ c)) = inj₂ c
assocr₊ : {A B C : Set} → ((A ⊎ B) ⊎ C) → (A ⊎ (B ⊎ C))
assocr₊ (inj₁ (inj₁ a)) = inj₁ a
assocr₊ (inj₁ (inj₂ b)) = inj₂ (inj₁ b)
assocr₊ (inj₂ c) = inj₂ (inj₂ c)
assocl₊∘assocr₊ : {A B C : Set} → assocl₊ ○ assocr₊ ∼ id {A = ((A ⊎ B) ⊎ C)}
assocl₊∘assocr₊ (inj₁ (inj₁ a)) = refl (inj₁ (inj₁ a))
assocl₊∘assocr₊ (inj₁ (inj₂ b)) = refl (inj₁ (inj₂ b))
assocl₊∘assocr₊ (inj₂ c) = refl (inj₂ c)
assocr₊∘assocl₊ : {A B C : Set} → assocr₊ ○ assocl₊ ∼ id {A = (A ⊎ (B ⊎ C))}
assocr₊∘assocl₊ (inj₁ a) = refl (inj₁ a)
assocr₊∘assocl₊ (inj₂ (inj₁ b)) = refl (inj₂ (inj₁ b))
assocr₊∘assocl₊ (inj₂ (inj₂ c)) = refl (inj₂ (inj₂ c))
assocl₊equiv : {A B C : Set} → (A ⊎ (B ⊎ C)) ≃ ((A ⊎ B) ⊎ C)
assocl₊equiv =
assocl₊ , mkisequiv assocr₊ assocl₊∘assocr₊ assocr₊ assocr₊∘assocl₊
assocr₊equiv : {A B C : Set} → ((A ⊎ B) ⊎ C) ≃ (A ⊎ (B ⊎ C))
assocr₊equiv =
assocr₊ , mkisequiv assocl₊ assocr₊∘assocl₊ assocl₊ assocl₊∘assocr₊
-- assocl⋆ and assocr⋆
assocl⋆ : {A B C : Set} → (A × (B × C)) → ((A × B) × C)
assocl⋆ (a , (b , c)) = ((a , b) , c)
assocr⋆ : {A B C : Set} → ((A × B) × C) → (A × (B × C))
assocr⋆ ((a , b) , c) = (a , (b , c))
assocl⋆∘assocr⋆ : {A B C : Set} → assocl⋆ ○ assocr⋆ ∼ id {A = ((A × B) × C)}
assocl⋆∘assocr⋆ x = refl x
assocr⋆∘assocl⋆ : {A B C : Set} → assocr⋆ ○ assocl⋆ ∼ id {A = (A × (B × C))}
assocr⋆∘assocl⋆ x = refl x
assocl⋆equiv : {A B C : Set} → (A × (B × C)) ≃ ((A × B) × C)
assocl⋆equiv =
assocl⋆ , mkisequiv assocr⋆ assocl⋆∘assocr⋆ assocr⋆ assocr⋆∘assocl⋆
assocr⋆equiv : {A B C : Set} → ((A × B) × C) ≃ (A × (B × C))
assocr⋆equiv =
assocr⋆ , mkisequiv assocl⋆ assocr⋆∘assocl⋆ assocl⋆ assocl⋆∘assocr⋆
-- distz and factorz
distz : { A : Set} → (⊥ × A) → ⊥
distz (() , _)
factorz : {A : Set} → ⊥ → (⊥ × A)
factorz ()
distz∘factorz : {A : Set} → distz ○ factorz {A} ∼ id
distz∘factorz ()
factorz∘distz : {A : Set} → factorz {A} ○ distz ∼ id
factorz∘distz (() , proj₂)
distzequiv : {A : Set} → (⊥ × A) ≃ ⊥
distzequiv {A} =
distz , mkisequiv factorz (distz∘factorz {A}) factorz factorz∘distz
factorzequiv : {A : Set} → ⊥ ≃ (⊥ × A)
factorzequiv {A} =
factorz , mkisequiv distz factorz∘distz distz (distz∘factorz {A})
-- dist and factor
dist : {A B C : Set} → ((A ⊎ B) × C) → (A × C) ⊎ (B × C)
dist (inj₁ x , c) = inj₁ (x , c)
dist (inj₂ y , c) = inj₂ (y , c)
factor : {A B C : Set} → (A × C) ⊎ (B × C) → ((A ⊎ B) × C)
factor (inj₁ (a , c)) = inj₁ a , c
factor (inj₂ (b , c)) = inj₂ b , c
dist∘factor : {A B C : Set} → dist {A} {B} {C} ○ factor ∼ id
dist∘factor (inj₁ x) = refl (inj₁ x)
dist∘factor (inj₂ y) = refl (inj₂ y)
factor∘dist : {A B C : Set} → factor {A} {B} {C} ○ dist ∼ id
factor∘dist (inj₁ x , c) = refl (inj₁ x , c)
factor∘dist (inj₂ y , c) = refl (inj₂ y , c)
distequiv : {A B C : Set} → ((A ⊎ B) × C) ≃ ((A × C) ⊎ (B × C))
distequiv = dist , mkisequiv factor dist∘factor factor factor∘dist
factorequiv : {A B C : Set} → ((A × C) ⊎ (B × C)) ≃ ((A ⊎ B) × C)
factorequiv = factor , (mkisequiv dist factor∘dist dist dist∘factor)
-- ⊕
_⊎∼_ : {A B C D : Set} {f : A → C} {finv : C → A} {g : B → D} {ginv : D → B} →
(α : f ○ finv ∼ id) → (β : g ○ ginv ∼ id) →
(f ⊎→ g) ○ (finv ⊎→ ginv) ∼ id {A = C ⊎ D}
_⊎∼_ α β (inj₁ x) = ap inj₁ (α x)
_⊎∼_ α β (inj₂ y) = ap inj₂ (β y)
path⊎ : {A B C D : Set} → A ≃ C → B ≃ D → (A ⊎ B) ≃ (C ⊎ D)
path⊎ (fp , eqp) (fq , eqq) =
Data.Sum.map fp fq ,
mkisequiv (P.g ⊎→ Q.g) (P.α ⊎∼ Q.α) (P.h ⊎→ Q.h) (P.β ⊎∼ Q.β)
where module P = isequiv eqp
module Q = isequiv eqq
-- ⊗
_×∼_ : {A B C D : Set} {f : A → C} {finv : C → A} {g : B → D} {ginv : D → B} →
(α : f ○ finv ∼ id) → (β : g ○ ginv ∼ id) →
(f ×→ g) ○ (finv ×→ ginv) ∼ id {A = C × D}
_×∼_ α β (x , y) = ap2 _,_ (α x) (β y)
path× : {A B C D : Set} → A ≃ C → B ≃ D → (A × B) ≃ (C × D)
path× {A} {B} {C} {D} (fp , eqp) (fq , eqq) =
Data.Product.map fp fq ,
mkisequiv
(P.g ×→ Q.g)
(_×∼_ {A} {B} {C} {D} {fp} {P.g} {fq} {Q.g} P.α Q.α)
(P.h ×→ Q.h)
(_×∼_ {C} {D} {A} {B} {P.h} {fp} {Q.h} {fq} P.β Q.β)
where module P = isequiv eqp
module Q = isequiv eqq
idequiv : {A : Set} → A ≃ A
idequiv = id≃
| 30.377273
| 78
| 0.525662
|
22648cd63d1de3a6957823f9a4b8efdd055c4ba8
| 663
|
agda
|
Agda
|
test/Succeed/HeterogeneousRewriting.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/HeterogeneousRewriting.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/HeterogeneousRewriting.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
{-# OPTIONS --rewriting #-}
open import Agda.Primitive
postulate
_↦_ : ∀{i j}{A : Set i}{B : Set j} → A → B → Set (i ⊔ j)
{-# BUILTIN REWRITE _↦_ #-} -- currently fails a sanity check
postulate
resize : ∀{i j} → Set i → Set j
resize-id : ∀{i} {j} {A : Set i} → resize {i} {j} A ↦ A
{-# REWRITE resize-id #-}
-- Impredicative quantification
Forall : ∀{i} (F : Set i → Set) → Set
Forall {i} F = resize ((X : Set i) → F X)
-- Example: Impredicative encoding of natural numbers
Nat = Forall λ X → (X → X) → X → X
zero : Nat
zero X s z = z
suc : Nat → Nat
suc n X s z = s (n X s z)
-- requires impredicativity:
id : Nat → Nat
id n = n Nat suc zero
| 18.942857
| 62
| 0.576169
|
1e1d195b720187fba3bef56baa7e8eeb566b5217
| 1,584
|
agda
|
Agda
|
test/Succeed/Issue2354.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/Issue2354.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue2354.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2016-12-22, issue #2354
-- Interaction between size solver, constraint solver, and instance search.
-- The instance search fails initially because of a non rigid meta.
-- Before freezing, there is another attempt.
-- The instance search succeeds and instantiates the meta for M.
-- Then, a size constraint is solved which had blocked a term.
-- Finally the blocking constraint can be resolved.
-- Thus, we need to
-- * wake constraints
-- * solve size constraints
-- * wake constraints again.
-- In principle, there could be many alternations needed!?
-- {-# OPTIONS -v tc.meta:30 -v tc.instance:30 -v tc.constr:50 -v tc.size:30 -v tc.decl:10 #-}
-- {-# OPTIONS -v tc.instance:30 -v tc.decl:20 #-}
-- {-# OPTIONS -v tc.instance.rigid:100 -v tc.instance:70 -v tc.size:30 #-}
-- {-# OPTIONS -v tc.term.con:50 #-}
{-# BUILTIN SIZEUNIV SizeU #-}
{-# BUILTIN SIZE Size #-}
{-# BUILTIN SIZELT Size<_ #-}
{-# BUILTIN SIZESUC ↑_ #-}
{-# BUILTIN SIZEINF ∞ #-}
record ⊤ : Set where
constructor tt
record RawMonad (M : Set → Set) : Set₁ where
field return : ∀{A} → A → M A
mutual
data Delay (i : Size) (A : Set) : Set where
now : A → Delay i A
later : Delay∞ i A → Delay i A
record Delay∞ (i : Size) (A : Set) : Set where
coinductive
field force : ∀ {j : Size< i} → Delay j A
instance
RawMonad-Delay : ∀ {i} → RawMonad (Delay i)
RawMonad-Delay = record
{ return = Delay.now
}
open RawMonad {{...}}
test : ∀ {i} → Delay i ⊤
test {i} = return tt -- Solution: return {{RawMonad-Delay {i}}} tt
-- Should find solution!
| 29.333333
| 94
| 0.636995
|
4350e0f776976a3839e95218c6fb4b6494b08d6e
| 4,687
|
agda
|
Agda
|
src/AssocFree/STLambdaC/Eval.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | 3
|
2016-11-22T11:48:31.000Z
|
2020-08-27T20:56:20.000Z
|
src/AssocFree/STLambdaC/Eval.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | null | null | null |
src/AssocFree/STLambdaC/Eval.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | 2
|
2018-03-03T04:39:31.000Z
|
2022-03-12T11:38:44.000Z
|
open import Relation.Binary.PropositionalEquality using
( _≡_ ; refl ; sym ; trans ; subst ; subst₂ ; cong ; cong₂ )
open import AssocFree.Util using ( δsubst₂ )
import AssocFree.STLambdaC.Typ
import AssocFree.STLambdaC.Exp
import AssocFree.STLambdaC.NF
import AssocFree.STLambdaC.Redn
module AssocFree.STLambdaC.Eval
(TConst : Set)
(Const : AssocFree.STLambdaC.Typ.Typ TConst → Set) where
open Relation.Binary.PropositionalEquality.≡-Reasoning using ( begin_ ; _≡⟨_⟩_ ; _∎ )
open module Typ = AssocFree.STLambdaC.Typ TConst using
( Typ ; Ctxt ; const ; _⇝_ ; [_] ; [] ; _∷_ ; _++_ ; _∈_ ; uniq
; Case ; case ; inj₁ ; inj₂ ; case-≫ ; _≪_ ; _≫_ )
open module Exp = AssocFree.STLambdaC.Exp TConst Const using
( Exp ; exp ; const ; abs ; app ; var ; var₀
; Substn ; substn+ ; substn* ; xsubstn+ ; weaken+ ; weaken* ; weakens*
; ⟨_⟩ ; choose ; _◁_ ; id
; weaken*-[] ; weaken*-++ ; substn*-◁ ; substn*-id )
open module NF = AssocFree.STLambdaC.NF TConst Const using
( Atom ; NF ; var ; const ; app ; abs ; atom ; atom₀ ; aweaken* )
open module Redn = AssocFree.STLambdaC.Redn TConst Const using
( _⇒_ ; _⇓ ; _⇓′ ; eta ; beta ; lhs ; atom ; nf ; redn ; tgt ; ⇓abs ; ⇓app ; rweaken* )
-- Values
data cVal {Γ C} : Exp Γ (const C) → Set where
atom : ∀ {M} → Atom M → cVal M
redn : ∀ {M N} → (M ⇒ N) → cVal N → cVal M
data fVal {Γ T U} (F : ∀ {Γ} → Exp Γ T → Set) (G : ∀ {Γ} → Exp Γ U → Set) : Exp Γ (T ⇝ U) → Set where
fun : ∀ {M} → (∀ Δ → {N : Exp (Δ ++ Γ) T} → F N → G (app (weaken* Δ {Γ} M) N)) → fVal F G M
redn : ∀ {M N} → (M ⇒ N) → fVal F G N → fVal F G M
Val : ∀ {Γ T} → Exp Γ T → Set
Val {Γ} {const C} M = cVal M
Val {Γ} {T ⇝ U} M = fVal Val Val M
-- Values are closed under reduction and application
vredn : ∀ {Γ T} {M N : Exp Γ T} → (M ⇒ N) → Val N → Val M
vredn {Γ} {const C} = redn
vredn {Γ} {T ⇝ U} = redn
vapp : ∀ {Γ T U} {M : Exp Γ (T ⇝ U)} {N : Exp Γ T} → Val M → Val N → Val (app M N)
vapp {Γ} {T} {U} {M} {N} (fun f) W = subst (λ X → Val (app X N)) (weaken*-[] M) (f [] W)
vapp (redn M⇒N V) W = vredn (lhs M⇒N) (vapp V W)
-- Reification and reflection
mutual
reify : ∀ {Γ T} {M : Exp Γ T} → Val M → (M ⇓)
reify {Γ} {const C} (atom N) = nf (atom N)
reify {Γ} {const C} (redn M⇒N V) = redn M⇒N (reify V)
reify {Γ} {T ⇝ U} {M} (fun f) = redn (eta M) (⇓abs {Γ} T (reify (f [ T ] (reflect (atom (atom₀ {Γ}))))))
reify {Γ} {T ⇝ U} (redn M⇒N V) = redn M⇒N (reify V)
reflect : ∀ {Γ T} {M : Exp Γ T} → (M ⇓′) → Val M
reflect {Γ} {const C} (atom M) = atom M
reflect {Γ} {T ⇝ U} (atom M) = fun (λ Δ V → reflect (⇓app (atom (aweaken* Δ M)) (reify V)))
reflect (redn M⇒N N⇓) = vredn M⇒N (reflect N⇓)
-- Value substitutions
Vals : ∀ {Γ Δ} → Substn (exp var) Γ Δ → Set
Vals {Γ} {Δ} σ = ∀ {T} (x : T ∈ Δ) → Val (σ x)
⟪_⟫ : ∀ {Γ T} {N : Exp Γ T} → Val N → Vals ⟨ N ⟩
⟪ V ⟫ x = δsubst₂ (λ X Y → Val {T = X} Y) (uniq x) refl V
vchoose : ∀ {Γ Δ E} {σ : Substn (exp var) Γ Δ} {τ : Substn (exp var) Γ E} → Vals σ → Vals τ →
∀ {T} (x : Case T Δ E) → Val (choose σ τ x)
vchoose Vs Ws (inj₁ x) = Vs x
vchoose Vs Ws (inj₂ x) = Ws x
_◂_ : ∀ {Γ Δ T} {N : Exp Γ T} {σ : Substn (exp var) Γ Δ} → Val N → Vals σ → Vals (N ◁ σ)
_◂_ {Γ} {Δ} {T} V Vs x = vchoose ⟪ V ⟫ Vs (case [ T ] Δ x)
-- Weakening
vweaken* : ∀ {Γ} Δ {U} {M : Exp Γ U} → Val M → Val (weaken* Δ M)
vweaken* Δ {const C} (atom N) = atom (aweaken* Δ N)
vweaken* Δ {const C} (redn M⇒N V) = redn (rweaken* Δ M⇒N) (vweaken* Δ V)
vweaken* Δ {T ⇝ U} {M} (fun f) = fun (λ Φ {N} V → subst (λ X → Val (app X N)) (sym (weaken*-++ Φ Δ _ M)) (f (Φ ++ Δ) V))
vweaken* Δ {T ⇝ U} (redn M⇒N V) = redn (rweaken* Δ M⇒N) (vweaken* Δ V)
vweakens* : ∀ {Γ Δ} E {σ : Substn (exp var) Γ Δ} → Vals σ → Vals (weakens* E σ)
vweakens* E {σ} Vs x = vweaken* E (Vs x)
-- Evaluation
eval : ∀ {Γ Δ T} (M : Exp Γ T) → {σ : Substn (exp var) Δ Γ} →
Vals σ → Val (substn* σ M)
eval (const {T} c) Vs = reflect (atom (const c))
eval {Γ} {Δ} (var x) {σ} Vs =
subst Val (begin
σ x
≡⟨ sym (weaken*-[] (σ x)) ⟩
weaken* [] (σ x)
≡⟨ cong (xsubstn+ [] Δ Γ σ) (sym (case-≫ [] x)) ⟩
substn* σ (var x)
∎) (Vs x)
eval {Γ} {Δ} (abs T M) {σ} Vs =
fun (λ E {N} V →
vredn (beta {E ++ Δ} (weaken+ [ T ] E Δ (substn+ [ T ] Δ Γ σ M)) N)
(subst Val
(substn*-◁ Γ Δ E M N σ)
(eval M (V ◂ vweakens* E {σ} Vs))))
eval (app M N) Vs = vapp (eval M Vs) (eval N Vs)
vid : ∀ Γ → Vals (id Γ)
vid Γ x = reflect (atom (var x))
normalize : ∀ {Γ T} → (M : Exp Γ T) → (M ⇓)
normalize {Γ} M = reify (subst Val (substn*-id M) (eval M (vid Γ)))
normal : ∀ {Γ T} → Exp Γ T → Exp Γ T
normal M = tgt (normalize M)
| 36.617188
| 125
| 0.529977
|
434f91df79e539328d325681ef3bb239db31da1b
| 7,164
|
agda
|
Agda
|
RedBlack.agda
|
xuanruiqi/dtp
|
c0c33dff4b114381561c011df4d5cf5da7a083f0
|
[
"MIT"
] | null | null | null |
RedBlack.agda
|
xuanruiqi/dtp
|
c0c33dff4b114381561c011df4d5cf5da7a083f0
|
[
"MIT"
] | null | null | null |
RedBlack.agda
|
xuanruiqi/dtp
|
c0c33dff4b114381561c011df4d5cf5da7a083f0
|
[
"MIT"
] | null | null | null |
-- Copyright 2019, Xuanrui Qi
-- Original algorithm by: Jacques Garrigue, Xuanrui Qi & Kazunari Tanaka
open import Data.Nat hiding (compare)
open import Data.Nat.Properties
open import Relation.Binary
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; subst; sym; inspect; [_])
open Eq.≡-Reasoning
open import Data.Product
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Unit using (⊤; tt)
module RedBlack
{c r} {A : Set c} {_<_ : Rel A r}
(isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_)
where
open IsStrictTotalOrder isStrictTotalOrder
data Color : Set where
Red : Color
Black : Color
incr-Black : ℕ → Color → ℕ
incr-Black d Black = suc d
incr-Black d Red = d
color-valid : Color → Color → Set
color-valid Red Red = ⊥
color-valid _ _ = ⊤
inv : Color → Color
inv Red = Black
inv Black = Red
valid-*-Black : ∀ c → color-valid c Black
valid-*-Black Red = tt
valid-*-Black Black = tt
data Tree : ℕ → Color → Set c where
Leaf : Tree 0 Black
Node : ∀ {d cₗ cᵣ} c → color-valid c cₗ → color-valid c cᵣ →
Tree d cₗ → A → Tree d cᵣ → Tree (incr-Black d c) c
RNode : ∀ {d} → Tree d Black → A → Tree d Black → Tree d Red
RNode = Node Red tt tt
BNode : ∀ {d cₗ cᵣ} → Tree d cₗ → A → Tree d cᵣ → Tree (suc d) Black
BNode = Node Black tt tt
-- Insertion algorithm
data InsTree : ℕ → Color → Set c where
Fix : ∀ {d} → Tree d Black → A → Tree d Black → A → Tree d Black → InsTree d Red
T : ∀ {d c} cₚ → Tree d c → InsTree d cₚ
InsTree-color : ∀ {d c} → InsTree d c → Color
InsTree-color (Fix _ _ _ _ _) = Red
InsTree-color (T _ _) = Black
fix-color : ∀ {d c} → InsTree d c → Color
fix-color (Fix _ _ _ _ _) = Black
fix-color (T {c = c} _ _) = c
fix-InsTree : ∀ {d c} → (t : InsTree d c) → Tree (incr-Black d (inv (InsTree-color t))) (fix-color t)
fix-InsTree (Fix t₁ x t₂ y t₃) = BNode (RNode t₁ x t₂) y t₃
fix-InsTree (T _ t) = t
balanceₗ : ∀ {d cₗ cᵣ} c → (l : InsTree d cₗ) → A → Tree d cᵣ → color-valid c (InsTree-color l) → color-valid c cᵣ → InsTree (incr-Black d c) c
balanceₗ Black (Fix t₁ x t₂ y t₃) z t₄ _ _ = T Black (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄))
balanceₗ Black (T _ l) v r _ _ = T Black (BNode l v r)
balanceₗ {cᵣ = Black} Red (T _ (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₁ x t₂)) y t₃ _ _ = Fix t₁ x t₂ y t₃
balanceₗ {cᵣ = Black} Red (T {c = Black} _ l) v r _ _ = T Red (RNode l v r)
balanceᵣ : ∀ {d cₗ cᵣ} c → Tree d cₗ → A → (r : InsTree d cᵣ) → color-valid c cₗ → color-valid c (InsTree-color r) → InsTree (incr-Black d c) c
balanceᵣ Black t₁ x (Fix t₂ y t₃ z t₄) _ _ = T Black (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄))
balanceᵣ Black l v (T _ r) _ _ = T Black (BNode l v r)
balanceᵣ {cₗ = Black} Red t₁ x (T _ (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₂ y t₃)) _ _ = Fix t₁ x t₂ y t₃
balanceᵣ {cₗ = Black} Red l v (T {c = Black} _ r) _ _ = T Red (RNode l v r)
ins : ∀ {d c} → A → Tree d c → InsTree d c
ins x Leaf = T Black (RNode Leaf x Leaf)
ins x (Node c _ _ l v r) with (compare x v)
ins x (Node c _ _ l v r) | tri< x<v _ _ with ins x l | inspect (ins x) l
ins x (Node Black _ validᵣ l v r) | _ | Fix _ _ _ _ _ | [ insₗ ] = balanceₗ Black (ins x l) v r tt tt
ins x (Node c _ validᵣ l v r) | _ | T _ _ | [ insₗ ] = balanceₗ c (ins x l) v r validₗ validᵣ
where
validₗ = subst (λ t → color-valid c (InsTree-color t)) (sym insₗ) (valid-*-Black c)
ins x t@(Node c _ _ l v r) | tri≈ _ x≡v _ = T _ t
ins x (Node c _ _ l v r) | tri> _ _ x>v with ins x r | inspect (ins x) r
ins x (Node Black validₗ _ l v r) | _ | Fix _ _ _ _ _ | [ insᵣ ] = balanceᵣ Black l v (ins x r) tt tt
ins x (Node c validₗ _ l v r) | _ | T _ _ | [ insᵣ ] = balanceᵣ c l v (ins x r) validₗ validᵣ
where
validᵣ = subst (λ t → color-valid c (InsTree-color t)) (sym insᵣ) (valid-*-Black c)
blacken : ∀ {d c} → Tree d c → Tree (incr-Black d (inv c)) Black
blacken Leaf = Leaf
blacken (Node Black _ _ l v r) = BNode l v r
blacken (Node Red _ _ l v r) = BNode l v r
insert : ∀ {d} → A → Tree d Black → ∃ (λ d' → Tree d' Black)
insert {d = d} x t with ins x t
... | T {c = c} _ t' = (incr-Black d (inv c) , blacken t')
-- Deletion algorithm
data DelTree : ℕ → Color → Set c where
Stay : ∀ {d c} cₚ → color-valid c (inv cₚ) → Tree d c → DelTree d cₚ
Down : ∀ {d} → Tree d Black → DelTree (suc d) Black
bal-right : ∀ {d cₗ cᵣ} c → Tree d cₗ → A → DelTree d cᵣ → color-valid c cₗ → color-valid c cᵣ → DelTree (incr-Black d c) c
bal-right {cₗ = Black} Red l v (Stay {c = Black} _ _ r) _ _ = Stay Red tt (RNode l v r)
bal-right {cₗ = Black} Red l v (Stay {c = Red} Red _ _) _ ()
bal-right Red (Node {cᵣ = Black} Black _ _ t₁ x t₂) y (Down t₃) _ _ = Stay Red tt (BNode t₁ x (RNode t₂ y t₃))
bal-right Red (Node {cᵣ = Red} Black _ _ t₁ x (Node _ _ _ t₂ y t₃)) z (Down t₄) _ _ = Stay Red tt (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄))
bal-right Black l v (Stay _ _ r) _ _ = Stay Black tt (BNode l v r)
bal-right Black (Node {cᵣ = Red} Black _ _ t₁ x (Node _ _ _ t₂ y t₃)) z (Down t₄) _ _ = Stay Black tt (BNode (BNode t₁ x t₂) y (BNode t₃ z t₄))
bal-right Black (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₁ x (Node {cᵣ = Black} _ _ _ t₂ y t₃)) z (Down t₄) _ _ =
Stay Black tt (BNode t₁ x (BNode t₂ y (RNode t₃ z t₄)))
bal-right Black (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₁ x (Node {cᵣ = Red} _ _ _ t₂ y (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₃ z t₄))) w (Down t₅) _ _ =
Stay Black tt (BNode t₁ x (RNode (BNode t₂ y t₃) z (BNode t₄ w t₅)))
bal-right Black (Node {cᵣ = Black} Black _ _ t₁ x t₂) y (Down t₃) _ _ = Down (BNode t₁ x (RNode t₂ y t₃))
bal-left : ∀ {d cₗ cᵣ} c → DelTree d cₗ → A → Tree d cᵣ → color-valid c cₗ → color-valid c cᵣ → DelTree (incr-Black d c) c
bal-left {cₗ = Black} {cᵣ = Black} Red (Stay {c = Black} _ _ l) v r _ _ = Stay Red tt (RNode l v r)
bal-left {cₗ = Black} {cᵣ = Black} Red (Stay {c = Red} _ () l) v r _ _
bal-left {cₗ = Black} {cᵣ = Black} Red (Down t₁) x (Node {cₗ = Red} _ _ _ (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₂ y t₃) z t₄) _ _ =
Stay Red tt (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄))
bal-left {cₗ = Black} {cᵣ = Black} Red (Down t₁) x (Node {cₗ = Black} _ _ _ t₂ y t₃) _ _ = Stay Red tt (BNode (RNode t₁ x t₂) y t₃)
bal-left Black (Stay _ _ l) v r _ _ = Stay Black tt (BNode l v r)
bal-left {cᵣ = Black} Black (Down t₁) x (Node {cₗ = Red} Black _ _ (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₂ y t₃) z t₄) _ _ =
Stay Black tt (BNode (BNode t₁ x t₂) y (BNode t₃ z t₄))
bal-left {cᵣ = Red} Black (Down t₁) x (Node {cₗ = Black} {cᵣ = Black} _ _ _ (Node {cₗ = Red} Black _ _ (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₂ y t₃) z t₄) w t₅) _ _ =
Stay Black tt (BNode (BNode t₁ x t₂) y (RNode (BNode t₃ z t₄) w t₅))
bal-left {cᵣ = Red} Black (Down t₁) x (Node {cₗ = Black} {cᵣ = Black} _ _ _ (Node {cₗ = Black} _ _ _ t₂ y t₃) z t₄) _ _ =
Stay Black tt (BNode (BNode (RNode t₁ x t₂) y t₃) z t₄)
bal-left {cᵣ = Black} Black (Down t₁) x (Node {cₗ = Black} _ _ _ t₂ y t₃) _ _ = Down (BNode (RNode t₁ x t₂) y t₃)
| 52.291971
| 169
| 0.59129
|
030ceb02f4681d84f9ba89efda2309b36fdf0359
| 2,773
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Vec/Properties/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Vec/Properties/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Vec/Properties/WithK.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some Vec-related properties that depend on the K rule or make use
-- of heterogeneous equality
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Vec.Properties.WithK where
open import Data.Nat
open import Data.Nat.Properties using (+-assoc)
open import Data.Vec
open import Relation.Binary.PropositionalEquality as P using (_≡_; refl)
open import Relation.Binary.HeterogeneousEquality as H using (_≅_; refl)
------------------------------------------------------------------------
-- _[_]=_
module _ {a} {A : Set a} where
[]=-irrelevant : ∀ {n} {xs : Vec A n} {i x} →
(p q : xs [ i ]= x) → p ≡ q
[]=-irrelevant here here = refl
[]=-irrelevant (there xs[i]=x) (there xs[i]=x') =
P.cong there ([]=-irrelevant xs[i]=x xs[i]=x')
------------------------------------------------------------------------
-- _++_
module _ {a} {A : Set a} where
++-assoc : ∀ {m n k} (xs : Vec A m) (ys : Vec A n) (zs : Vec A k) →
(xs ++ ys) ++ zs ≅ xs ++ (ys ++ zs)
++-assoc [] ys zs = refl
++-assoc {suc m} (x ∷ xs) ys zs =
H.icong (Vec A) (+-assoc m _ _) (x ∷_) (++-assoc xs ys zs)
------------------------------------------------------------------------
-- foldr
foldr-cong : ∀ {a b} {A : Set a}
{B : ℕ → Set b} {f : ∀ {n} → A → B n → B (suc n)} {d}
{C : ℕ → Set b} {g : ∀ {n} → A → C n → C (suc n)} {e} →
(∀ {n x} {y : B n} {z : C n} → y ≅ z → f x y ≅ g x z) →
d ≅ e → ∀ {n} (xs : Vec A n) →
foldr B f d xs ≅ foldr C g e xs
foldr-cong _ d≅e [] = d≅e
foldr-cong f≅g d≅e (x ∷ xs) = f≅g (foldr-cong f≅g d≅e xs)
------------------------------------------------------------------------
-- foldl
foldl-cong : ∀ {a b} {A : Set a}
{B : ℕ → Set b} {f : ∀ {n} → B n → A → B (suc n)} {d}
{C : ℕ → Set b} {g : ∀ {n} → C n → A → C (suc n)} {e} →
(∀ {n x} {y : B n} {z : C n} → y ≅ z → f y x ≅ g z x) →
d ≅ e → ∀ {n} (xs : Vec A n) →
foldl B f d xs ≅ foldl C g e xs
foldl-cong _ d≅e [] = d≅e
foldl-cong f≅g d≅e (x ∷ xs) = foldl-cong f≅g (f≅g d≅e) xs
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.0
[]=-irrelevance = []=-irrelevant
{-# WARNING_ON_USAGE []=-irrelevance
"Warning: []=-irrelevance was deprecated in v1.0.
Please use []=-irrelevant instead."
#-}
| 36.012987
| 72
| 0.390191
|
3099ee79ec04251a1268f41bcea382b0b9923c01
| 3,219
|
agda
|
Agda
|
Categories/Functor/Power/NaturalTransformation.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Functor/Power/NaturalTransformation.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Functor/Power/NaturalTransformation.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Level
open import Categories.Category
module Categories.Functor.Power.NaturalTransformation {o ℓ e : Level} (C : Category o ℓ e) where
open import Data.Nat using (ℕ)
open import Data.Fin using (Fin; inject+; raise)
open import Data.Sum using (_⊎_; [_,_]′; inj₁; inj₂)
open import Function using () renaming (_∘_ to _∙_)
open import Function using () renaming (_∘_ to _∙_)
open import Data.Product using (_,_)
import Categories.Functor.Power as Power
module Pow = Power C
open Pow
open import Categories.Functor.Bifunctor using (Bifunctor)
-- open import Categories.Functor.Bifunctor.NaturalTransformation renaming (id to idⁿ; _≡_ to _≡ⁿ_)
open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper; _∘ˡ_)
open import Categories.Category.Product using (_※ⁿ_)
open import Categories.Functor using (Functor; module Functor)
flattenPⁿ : {D : Category o ℓ e} {m n : ℕ} {F G : Powerfunctor′ D (Fin m ⊎ Fin n)} (η : NaturalTransformation F G) →
NaturalTransformation (flattenP F) (flattenP G)
flattenPⁿ {m = m} {n} η = record
{ η = λ Xs → η.η (Xs ∙ pack)
; commute = λ fs → η.commute (fs ∙ pack)
; sym-commute = λ fs → η.sym-commute (fs ∙ pack)
}
where
private module η = NaturalTransformation η
pack = [ inject+ n , raise m ]′
reduceN′ : ∀ {i j : Level} {I : Set i} {J : Set j} {F F′ : Powerendo′ I} {G G′ : Powerendo′ J}
(H : Bifunctor C C C)
(φ : NaturalTransformation F F′) (γ : NaturalTransformation G G′) → NaturalTransformation (reduce′ H F G) (reduce′ H F′ G′)
reduceN′ {I = I} {J} {F} {F′} {G} {G′} H φ γ = ntHelper record
{ η = my-η
; commute = λ {Xs Ys} → my-commute Xs Ys
}
where
module C = Category C
module F = Functor F
module F′ = Functor F′
module G = Functor G
module G′ = Functor G′
module φ = NaturalTransformation φ
module γ = NaturalTransformation γ
module H = Functor H
module L = Functor (reduce′ H F G)
module R = Functor (reduce′ H F′ G′)
my-η : ∀ Xs → C [ L.F₀ Xs , R.F₀ Xs ]
my-η Xs = H.F₁ ((φ.η (Xs ∙ inj₁)) , (γ.η (Xs ∙ inj₂)))
my-commute : ∀ Xs Ys fs → C.CommutativeSquare (L.F₁ fs) (my-η Xs) (my-η Ys) (R.F₁ fs)
my-commute Xs Ys fs = begin
my-η Ys ∘ L.F₁ fs ≈˘⟨ H.homomorphism ⟩
H.F₁ ((φ.η _ ∘ F.F₁ _) , (γ.η _ ∘ G.F₁ _)) ≈⟨ H.F-resp-≈ ((φ.commute _) , (γ.commute _)) ⟩
H.F₁ ((F′.F₁ _ ∘ φ.η _) , (G′.F₁ _ ∘ γ.η _)) ≈⟨ H.homomorphism ⟩
R.F₁ fs ∘ my-η Xs
∎
where
open C using (_∘_)
open C.HomReasoning
-- Giving the implicits below is not necessary, but makes typechecking faster
reduceN : {m n : ℕ} {F F′ : Powerendo m} {G G′ : Powerendo n}
(H : Bifunctor C C C) (φ : NaturalTransformation F F′) (γ : NaturalTransformation G G′) →
NaturalTransformation (reduce H F G) (reduce H F′ G′)
reduceN {F = f} {f′} {g} {g′} H φ γ = flattenPⁿ {F = reduce′ H f g} {G = reduce′ H f′ g′} (reduceN′ H φ γ)
overlapN : {n : ℕ} {F F′ : Powerendo n} {G G′ : Powerendo n}
(H : Bifunctor C C C) (φ : NaturalTransformation F F′) (γ : NaturalTransformation G G′) →
NaturalTransformation (overlaps H F G) (overlaps H F′ G′)
overlapN H φ γ = H ∘ˡ (φ ※ⁿ γ)
| 42.355263
| 126
| 0.623486
|
579bdfa14a96c5257e0ea4bf1b7aef48fa8664e8
| 12,028
|
agda
|
Agda
|
src/Tactic/Reflection/Reright.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
src/Tactic/Reflection/Reright.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
src/Tactic/Reflection/Reright.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
module Tactic.Reflection.Reright where
open import Prelude hiding (abs)
open import Container.Traversable
open import Tactic.Reflection
open import Tactic.Reflection.Match
open import Tactic.Reflection.Replace
open import Tactic.Reflection.Quote
private
{-# TERMINATING #-}
reorderVars : List Nat → Term → Term
reorderVars xs (var x args) = var (maybe x id (index xs x)) (fmap (reorderVars xs) <$> args)
reorderVars xs (con c args) = con c ((fmap ∘ fmap) (reorderVars xs) args)
reorderVars xs (def f args) = def f (fmap (reorderVars xs) <$> args)
reorderVars xs (lam v t) = lam v (reorderVars (0 ∷ weaken 1 xs) <$> t)
reorderVars xs (pat-lam cs args) = pat-lam (fmap (reorderVarsInClause xs) cs) ((fmap ∘ fmap) (reorderVars xs) args) where
reorderVarsInClause : List Nat → Clause → Clause -- TODO reorder patterns?
reorderVarsInClause xs (clause ps t) = (clause ps (reorderVars xs t))
reorderVarsInClause xs (absurd-clause ps) = (absurd-clause ps)
reorderVars xs (pi a b) = pi (reorderVars xs <$> a) (reorderVars (0 ∷ weaken 1 xs) <$> b)
reorderVars xs (agda-sort (set t)) = agda-sort (set (reorderVars xs t))
reorderVars xs (agda-sort (lit n)) = agda-sort (lit n)
reorderVars xs (agda-sort unknown) = agda-sort unknown
reorderVars xs (lit l) = lit l
reorderVars xs (meta x args) = meta x $ (fmap ∘ fmap) (reorderVars xs) args
reorderVars xs unknown = unknown
{-# TERMINATING #-}
freeDependencies : List (Arg Type) → Type → Maybe VarSet
freeDependencies Γ x = foldr _∪_ (freeVars x) <$> mapM go (freeVars x) where
_∪_ : VarSet → VarSet → VarSet -- REFACTOR this was stolen from Tactic.Reflection.Free
[] ∪ ys = ys
xs ∪ [] = xs
(x ∷ xs) ∪ (y ∷ ys) with compare x y
... | (less _) = x ∷ (xs ∪ (y ∷ ys))
... | (equal _) = x ∷ (xs ∪ ys)
... | (greater _) = y ∷ ((x ∷ xs) ∪ ys)
go : Nat → Maybe VarSet
go v = weaken (suc v) $ join $ freeDependencies (drop (suc v) Γ) <$> (unArg <$> index Γ v)
.test-freeDependencies₁ : freeDependencies [] unknown ≡ just []
test-freeDependencies₁ = refl
.test-freeDependencies₂ : freeDependencies (vArg (var₀ 0) ∷ vArg unknown ∷ []) (var₀ 0) ≡ just (0 ∷ 1 ∷ [])
test-freeDependencies₂ = refl
.test-freeDependencies₃ : freeDependencies (vArg (var₀ 0) ∷ vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₀ 0) ≡ just (0 ∷ 1 ∷ 3 ∷ [])
test-freeDependencies₃ = refl
.test-freeDependencies₄ : freeDependencies (vArg (var₀ 0) ∷ vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₀ 1) ≡ just (1 ∷ 3 ∷ [])
test-freeDependencies₄ = refl
.test-freeDependencies₅ : freeDependencies (vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₀ 0) ≡ just (0 ∷ 2 ∷ [])
test-freeDependencies₅ = refl
.test-freeDependencies₆ : freeDependencies (vArg (var₀ 0) ∷ vArg (var₀ 1) ∷ vArg unknown ∷ vArg unknown ∷ []) (var₁ 0 (var₀ 1)) ≡ just (0 ∷ 1 ∷ 3 ∷ [])
test-freeDependencies₆ = refl
record Request : Set where
field
l≡r : Term
A : Type
L R : Type
Γᶜ : List (Arg Type)
𝐺 : Type
[iᶜ∣iᶜ∈FVᴬ] : VarSet
[iᶜ∣iᶜ∈FVᴬ] = maybe [] id $ freeDependencies Γᶜ A -- TODO this is a hack; I don't expect freeDependencies will return 'nothing', but if it does, I hope(!) the rest of the computation will fail
[iᶜ∣iᶜ∉FVᴬ] : VarSet
[iᶜ∣iᶜ∉FVᴬ] = filter (not ∘ flip elem [iᶜ∣iᶜ∈FVᴬ]) (from 0 for (length Γᶜ))
record γᶜ' : Set where
field
iᶜ : Nat
γᶜᵢ : Arg Type
iᶜ∈FVᴬ : Bool
iʷ : Nat
γᶜᵢ∈Γʳ : Bool
gᶜᵢ : Type
gᶜᵢ = unArg γᶜᵢ
Γᶜ' : List γᶜ'
Γᶜ' = go 0 (length Γᶜ) Γᶜ where
go : Nat → Nat → List (Arg Type) → List γᶜ'
go iᶜ 0 _ = []
go iᶜ _ [] = []
go iᶜ (suc n) (γᶜᵢ ∷ Γᶜ) = γᶜᵢ' ∷ go (suc iᶜ) n (weaken 1 Γᶜ) where
γᶜᵢ' = record
{ iᶜ = iᶜ
; γᶜᵢ = γᶜᵢ
; iᶜ∈FVᴬ = elem iᶜ [iᶜ∣iᶜ∈FVᴬ]
; iʷ = if elem iᶜ [iᶜ∣iᶜ∉FVᴬ] then (length (filter (_<? iᶜ) [iᶜ∣iᶜ∉FVᴬ])) else (length [iᶜ∣iᶜ∉FVᴬ] + (length (filter (_≤? iᶜ) [iᶜ∣iᶜ∈FVᴬ])))
; γᶜᵢ∈Γʳ = let gᶜᵢ = unArg γᶜᵢ in (isNo $ weaken 1 gᶜᵢ == weaken 1 gᶜᵢ r[ unknown / L ]) && (isNo $ l≡r == var₀ iᶜ)
}
[iʷ∣γᶜᵢ∈Γʳ] : VarSet
[iʷ∣γᶜᵢ∈Γʳ] = iʷ <$> filter γᶜᵢ∈Γʳ Γᶜ' where open γᶜ'
[iʷ] : List Nat
[iʷ] = iʷ <$> Γᶜ' where open γᶜ'
subsetList : {A : Set} → List A → List Nat → Maybe (List A)
subsetList xs is = traverse (index xs) is
module _ where
private
Γʷ/ᶜ : Maybe (List (Arg Type))
Γʷ/ᶜ = go [iʷ] Γᶜ where
go : List Nat → List (Arg Type) → Maybe (List (Arg Type))
go _ [] = just []
go [] _ = nothing
go (iʷ ∷ [iʷ]) (γᶜᵢ ∷ Γᶜ) = _∷_ <$> (strengthen (suc iʷ) $ reorderVars [iʷ] <$> γᶜᵢ) <*> (go [iʷ] Γᶜ)
Γʷ/ᴬ = join $ subsetList <$> Γʷ/ᶜ <*> pure [iᶜ∣iᶜ∈FVᴬ]
Γʷ/⁻ᴬ = join $ subsetList <$> Γʷ/ᶜ <*> pure [iᶜ∣iᶜ∉FVᴬ]
module _ where
private
Lʷ = reorderVars [iʷ] L
Γʷ = caseF Γʷ' of _R[ var₀ (length [iᶜ∣iᶜ∉FVᴬ]) / Lʷ ] where
Γʷ' : Maybe (List (Arg Type))
Γʷ' = _++_ <$> Γʷ/⁻ᴬ <*> (_∷_ <$> (strengthen (length [iᶜ∣iᶜ∉FVᴬ] + 1) $ hArg (reorderVars [iʷ] A)) <*> Γʷ/ᴬ) where
𝐺ʷ = reorderVars [iʷ] 𝐺 r[ var₀ (length [iᶜ∣iᶜ∉FVᴬ]) / Lʷ ]
module _ where
private
Rʷ = reorderVars [iʷ] R
gʳ : Maybe Type
gʳ = join $ go <$> gʳ' <*> pure [iʷ∣γᶜᵢ∈Γʳ] <*> pure 𝐺ʷʳ where
go : List (Arg Type) → List Nat → Type → Maybe Type
go [] [] 𝐺 = just 𝐺
go (γʷ ∷ Γʷ) (iʷ ∷ iʷs) 𝐺 = go Γʷ iʷs $ pi (weaken (1 + iʷ) γʷ) $ abs "_" $ weaken 1 𝐺 r[ var₀ 0 / var₀ $ weaken 1 iʷ ]
go _ _ _ = nothing
gʳ' : Maybe (List (Arg Type))
gʳ' = join $ subsetList <$> (caseF Γʷ of _R[ Rʷ / var₀ (length [iᶜ∣iᶜ∉FVᴬ]) ]) <*> pure [iʷ∣γᶜᵢ∈Γʳ]
𝐺ʷʳ = 𝐺ʷ r[ Rʷ / var₀ (length [iᶜ∣iᶜ∉FVᴬ]) ]
helper-type : Maybe Type
helper-type = telPi <$> (_++_ <$> (reverse <$> Γʷ) <*> (_∷_ <$> (pure $ vArg (def₂ (quote _≡_) (var₀ (length [iᶜ∣iᶜ∉FVᴬ])) Rʷ)) <*> ([_] ∘ vArg <$> (weaken 1 <$> gʳ)))) <*> pure (weaken 2 𝐺ʷ)
make-vars-from-args : List Nat → List (Arg Type) → Maybe (List (Arg Type))
make-vars-from-args [] [] = pure []
make-vars-from-args (i ∷ is) (x ∷ xs) = _∷_ <$> pure (var₀ i <$ x) <*> make-vars-from-args is xs
make-vars-from-args _ _ = nothing
defineHelper : Name → TC ⊤
defineHelper n =
maybe (typeError ( strErr "error constructing helper function type, patterns, or term" ∷
strErr "\nhelper-type:" ∷ termErr (maybe unknown id helper-type) ∷
strErr "\n`helper-type:" ∷ termErr (` helper-type) ∷
strErr "\nhelper-patterns:" ∷ termErr (` helper-patterns) ∷
strErr "\nhelper-term:" ∷ termErr (maybe unknown id helper-term) ∷
strErr "\ngʳ:" ∷ termErr (` gʳ) ∷
strErr "\nΓʷ:" ∷ termErr (` Γʷ) ∷
strErr "\n𝐺ʷ:" ∷ termErr (` 𝐺ʷ) ∷
strErr "\nl≡r:" ∷ termErr (` l≡r) ∷
strErr "\nA:" ∷ termErr (` A) ∷
strErr "\nL:" ∷ termErr (` L) ∷
strErr "\nR:" ∷ termErr (` R) ∷
strErr "\nΓᶜ:" ∷ termErr (` Γᶜ) ∷
strErr "\n𝐺:" ∷ termErr (` 𝐺) ∷
strErr "\nΓʷ/ᴬ" ∷ termErr (` Γʷ/ᴬ) ∷
strErr "\nΓʷ/⁻ᴬ" ∷ termErr (` Γʷ/⁻ᴬ) ∷
strErr "\n[iᶜ∣iᶜ∈FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∈FVᴬ]) ∷
strErr "\n[iᶜ∣iᶜ∉FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∉FVᴬ]) ∷
strErr "\n[iʷ]" ∷ termErr (` [iʷ]) ∷
[] ))
(λ {(helper-type , helper-patterns , helper-term) →
catchTC
(define (vArg n) helper-type [ clause helper-patterns helper-term ])
(typeError ( strErr "error defining helper function" ∷
strErr "\nhelper-type:" ∷ termErr helper-type ∷
strErr "\n`helper-type:" ∷ termErr (` helper-type) ∷
strErr "\nhelper-patterns:" ∷ termErr (` helper-patterns) ∷
strErr "\nhelper-term:" ∷ termErr helper-term ∷
strErr "\n`helper-term:" ∷ termErr (` helper-term) ∷
strErr "\ngʳ:" ∷ termErr (` gʳ) ∷
strErr "\nΓʷ:" ∷ termErr (` Γʷ) ∷
strErr "\n𝐺ʷ:" ∷ termErr (` 𝐺ʷ) ∷
strErr "\nl≡r:" ∷ termErr (` l≡r) ∷
strErr "\nA:" ∷ termErr (` A) ∷
strErr "\nL:" ∷ termErr (` L) ∷
strErr "\nR:" ∷ termErr (` R) ∷
strErr "\nΓᶜ:" ∷ termErr (` Γᶜ) ∷
strErr "\n𝐺:" ∷ termErr (` 𝐺) ∷
strErr "\nΓʷ/ᴬ" ∷ termErr (` Γʷ/ᴬ) ∷
strErr "\nΓʷ/⁻ᴬ" ∷ termErr (` Γʷ/⁻ᴬ) ∷
strErr "\n[iᶜ∣iᶜ∈FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∈FVᴬ]) ∷
strErr "\n[iᶜ∣iᶜ∉FVᴬ]" ∷ termErr (` [iᶜ∣iᶜ∉FVᴬ]) ∷
strErr "\n[iʷ]" ∷ termErr (` [iʷ]) ∷
[] ))
})
(_,_ <$> helper-type <*> (_,_ <$> helper-patterns <*> helper-term))
where
helper-patterns : Maybe (List (Arg Pattern))
helper-patterns = (λ pa w p-a pr → pa ++ w ∷ (p-a ++ pr)) <$> (telePat ∘ reverse <$> Γʷ/ᴬ) <*> just (hArg dot) <*> (telePat ∘ reverse <$> Γʷ/⁻ᴬ) <*> pure (vArg (con₀ (quote refl)) ∷ [ vArg (var "_") ])
helper-term : Maybe Term
helper-term = do
γʷs ← join $ subsetList <$> Γʷ <*> pure [iʷ∣γᶜᵢ∈Γʳ]
iʷs ← make-vars-from-args [iʷ∣γᶜᵢ∈Γʳ] γʷs
pure (var 0 (reverse (weaken 1 iʷs)))
callHelper : Name → Tactic
callHelper n hole =
maybe (typeError [ strErr "error constructing helper call" ])
(unify hole)
$ helper-call n
where
helper-call : Name → Maybe Term
helper-call n = def n <$> (reverse <$> (_∷_ <$> pure (vArg l≡r) <*> Γʰ)) where
Γʰ : Maybe $ List $ Arg Term
Γʰ = (λ xs → take (length [iᶜ∣iᶜ∉FVᴬ]) xs ++ hArg unknown ∷ drop (length [iᶜ∣iᶜ∉FVᴬ]) xs) <$> (join $ make-vars-from-args <$> pure ([iᶜ∣iᶜ∉FVᴬ] ++ [iᶜ∣iᶜ∈FVᴬ]) <*> Γʰ') where
Γʰ' : Maybe (List (Arg Type))
Γʰ' = _++_ <$> subsetList Γᶜ [iᶜ∣iᶜ∉FVᴬ] <*> subsetList Γᶜ [iᶜ∣iᶜ∈FVᴬ]
inferGoal : Term → TC Type
inferGoal hole = unPi =<< forceFun =<< inferType hole where
unPi : Type → TC Type
unPi (pi _ (abs _ (meta x _))) = blockOnMeta! x
unPi (pi _ (abs _ b)) = maybe (typeError (strErr "error strengthening" ∷ termErr b ∷ [])) pure $ strengthen 1 b
unPi x = typeError (strErr "goal is not a pi type" ∷ termErr x ∷ [])
getRequest : Term → Term → TC Request
getRequest l≡r hole = do
L≡R ← inferType l≡r
L≡R-matched ← maybe (typeError (strErr "not an equality" ∷ termErr l≡r ∷ termErr L≡R ∷ [])) pure $
match 3 (def (quote _≡_) (hArg unknown ∷ (hArg (var₀ 0)) ∷ (vArg (var₀ 1)) ∷ (vArg (var₀ 2)) ∷ [])) L≡R
𝐺 ← inferGoal hole
Γᶜ ← getContext
case L≡R-matched of λ { (A ∷ L ∷ R ∷ []) →
pure $ record { l≡r = l≡r ; A = A ; L = L ; R = R ; Γᶜ = Γᶜ ; 𝐺 = 𝐺 } }
macro
reright : Term → Tactic
reright l≡r hole = do
q ← getRequest l≡r hole
n ← freshName "reright"
let open Request q
defineHelper n
callHelper n hole
| 47.354331
| 209
| 0.498088
|
7c45011ea3d36832d463288884ca2a84f7599a58
| 171
|
agda
|
Agda
|
test/interaction/Issue2287.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue2287.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue2287.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
record R : Set₁ where
field
A : Set
{B} : Set
{{C}} : Set
open R
r : R
r = {!!}
-- C-c C-c produced
-- A r = {!!}
-- B {r} = {!!}
-- C {{r}} = {!!}
| 10.6875
| 21
| 0.345029
|
9ae7efc60b537b5a0d1dbc69b526a529300d9dfa
| 485
|
agda
|
Agda
|
agda-stdlib/src/Algebra/FunctionProperties/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Algebra/FunctionProperties/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Algebra/FunctionProperties/Core.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.Core`
-- instead.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Algebra.FunctionProperties.Core where
{-# WARNING_ON_IMPORT
"Algebra.FunctionProperties.Core was deprecated in v1.2.
Use Algebra.Core instead."
#-}
open import Algebra.Core public
| 26.944444
| 72
| 0.517526
|
34622c93be234000908e38352a25ff6a87b7e7c8
| 846
|
agda
|
Agda
|
test/LaTeXAndHTML/succeed/Issue4580NegativeLiterals.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/LaTeXAndHTML/succeed/Issue4580NegativeLiterals.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/LaTeXAndHTML/succeed/Issue4580NegativeLiterals.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2020-04-12, issue #4580
-- Highlighting for builtins FROMNAT, FROMNEG, FROMSTRING
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
record Number (A : Set) : Set where
field fromNat : Nat → A
record Negative (A : Set) : Set where
field fromNeg : Nat → A
open Number {{...}} public
open Negative {{...}} public
{-# BUILTIN FROMNAT fromNat #-} -- Should be highlighted.
{-# BUILTIN FROMNEG fromNeg #-} -- Jump to definition should work.
instance
NumberNat : Number Nat
NumberNat = record { fromNat = λ n → n }
data Int : Set where
pos : Nat → Int
neg : Nat → Int
instance
NumberInt : Number Int
NumberInt = record { fromNat = pos }
NegativeInt : Negative Int
NegativeInt = record { fromNeg = λ { zero → pos 0 ; (suc n) → neg n } }
minusFive : Int
minusFive = -5
thm : -5 ≡ neg 4
thm = refl
| 21.692308
| 73
| 0.664303
|
d1ee182aa35539c06fa4dd1f1995cb2c8ccd2c37
| 804
|
agda
|
Agda
|
Nat.agda
|
hazelgrove/agda-tfp16
|
86a755ca6749e080f9a03287e34d1cda889f1edb
|
[
"MIT"
] | 2
|
2016-06-10T04:35:39.000Z
|
2016-06-10T04:35:42.000Z
|
Nat.agda
|
hazelgrove/agda-tfp16
|
86a755ca6749e080f9a03287e34d1cda889f1edb
|
[
"MIT"
] | null | null | null |
Nat.agda
|
hazelgrove/agda-tfp16
|
86a755ca6749e080f9a03287e34d1cda889f1edb
|
[
"MIT"
] | null | null | null |
open import Prelude
module Nat where
data Nat : Set where
Z : Nat
1+ : Nat → Nat
{-# BUILTIN NATURAL Nat #-}
-- the succ operation is injective
1+inj : (x y : Nat) → (1+ x == 1+ y) → x == y
1+inj Z .0 refl = refl
1+inj (1+ x) .(1+ x) refl = refl
-- equality of naturals is decidable. we represent this as computing a
-- choice of units, with inl <> meaning that the naturals are indeed the
-- same and inr <> that they are not.
natEQ : (x y : Nat) → ((x == y) + ((x == y) → ⊥))
natEQ Z Z = Inl refl
natEQ Z (1+ y) = Inr (λ ())
natEQ (1+ x) Z = Inr (λ ())
natEQ (1+ x) (1+ y) with natEQ x y
natEQ (1+ x) (1+ .x) | Inl refl = Inl refl
... | Inr b = Inr (λ x₁ → b (1+inj x y x₁))
max : Nat → Nat → Nat
max Z m = m
max n Z = n
max (1+ n) (1+ m) = max n m
| 26.8
| 74
| 0.534826
|
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.