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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3da9aa5ebc152ee0fe46e891f2595730d9228fdc
| 1,588
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Instances/QuoInt.agda
|
anuyts/cubical
|
2868ce7542c0b63f185344cffbd90c1cc033027c
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Instances/QuoInt.agda
|
anuyts/cubical
|
2868ce7542c0b63f185344cffbd90c1cc033027c
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Instances/QuoInt.agda
|
anuyts/cubical
|
2868ce7542c0b63f185344cffbd90c1cc033027c
|
[
"MIT"
] | null | null | null |
{-
ℤ is a Commutative Ring (using QuoInt)
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.Instances.QuoInt where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.CommRing
open import Cubical.Data.Nat using (ℕ ; zero ; suc)
open import Cubical.Data.Bool using (not)
open import Cubical.Data.Int.MoreInts.QuoInt
renaming (ℤ to ℤType ; _+_ to _+ℤ_; _·_ to _·ℤ_; -_ to -ℤ_)
open CommRingStr
-- The missing additive inversion
+InvL' : ∀ n s → signed (not s) n +ℤ signed s n ≡ signed s zero
+InvL' zero _ = refl
+InvL' (suc n) spos = predℤ-+ʳ (neg n) (pos (suc n)) ∙ (λ i → neg n +ℤ predSucℤ (pos n) i) ∙ +InvL' n spos
+InvL' (suc n) sneg = sucℤ-+ʳ (pos n) (neg (suc n)) ∙ (λ i → pos n +ℤ sucPredℤ (neg n) i) ∙ +InvL' n sneg
+InvL : (n : ℤType) → (-ℤ n) +ℤ n ≡ 0
+InvL (signed spos n) = +InvL' n spos
+InvL (signed sneg n) = +InvL' n sneg ∙ sym posneg
+InvL (posneg i) j =
hcomp (λ k → λ
{ (i = i0) → 0
; (i = i1) → compPath-filler refl (sym posneg) k j
; (j = i0) → posneg i
; (j = i1) → posneg (i ∧ ~ k) })
(posneg i)
+InvR : (n : ℤType) → n +ℤ (-ℤ n) ≡ 0
+InvR n = +-comm n (-ℤ n) ∙ +InvL n
ℤCommRing : CommRing ℓ-zero
ℤCommRing .fst = ℤType
ℤCommRing .snd .0r = 0
ℤCommRing .snd .1r = 1
ℤCommRing .snd ._+_ = _+ℤ_
ℤCommRing .snd ._·_ = _·ℤ_
ℤCommRing .snd .-_ = -ℤ_
ℤCommRing .snd .isCommRing = isCommRingℤ
where
abstract
isCommRingℤ : IsCommRing 0 1 _+ℤ_ _·ℤ_ -ℤ_
isCommRingℤ = makeIsCommRing
isSetℤ +-assoc (+-zeroʳ _)
+InvR +-comm ·-assoc
·-identityʳ (λ x y z → sym (·-distribˡ x y z)) ·-comm
| 28.357143
| 106
| 0.61398
|
1afffb0da3abfd436439f361fec63588f59394b1
| 277
|
agda
|
Agda
|
prototyping/Utility/Bool.agda
|
JohnnyMorganz/luau
|
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
|
[
"MIT"
] | 1
|
2021-12-05T21:53:03.000Z
|
2021-12-05T21:53:03.000Z
|
prototyping/Utility/Bool.agda
|
JohnnyMorganz/luau
|
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
|
[
"MIT"
] | null | null | null |
prototyping/Utility/Bool.agda
|
JohnnyMorganz/luau
|
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
|
[
"MIT"
] | null | null | null |
module Utility.Bool where
open import Agda.Builtin.Bool using (Bool; true; false)
not : Bool → Bool
not false = true
not true = false
_or_ : Bool → Bool → Bool
true or _ = true
_ or true = true
_ or _ = false
_and_ : Bool → Bool → Bool
true and true = true
_ and _ = false
| 16.294118
| 55
| 0.68231
|
135c08b178be29393f866007bd95d66780ef701a
| 373
|
agda
|
Agda
|
test/interaction/Issue643.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue643.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue643.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue643 where
module M₁ (A : Set) where
record R : Set₁ where
field
P : A → Set
module M₂ (A : Set) where
open M₁ A
postulate
r : R
T : R → Set
open R r
p : ∀ x → P x
p x = {!!} -- The goal was printed as "P" rather than "P x".
q : T r
q = {!!} -- This goal was printed as T P at an intermediate stage of fixing
| 14.92
| 83
| 0.538874
|
416f8f55ead530629d8abcb8fc319a7e6c8e3bc8
| 1,880
|
agda
|
Agda
|
test/Succeed/Issue2288b.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2288b.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2288b.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Primitive
record Functor {a b} (F : Set a → Set b) : Set (lsuc a ⊔ b) where
field
fmap : ∀ {A B} → (A → B) → F A → F B
open Functor {{...}} public
module _ {a b} (F : Set a → Set b) where
record FunctorZero : Set (lsuc a ⊔ b) where
field
empty : ∀ {A} → F A
overlap {{super}} : Functor F
record Alternative : Set (lsuc a ⊔ b) where
infixl 3 _<|>_
field
_<|>_ : ∀ {A} → F A → F A → F A
overlap {{super}} : FunctorZero
open FunctorZero {{...}} public
open Alternative {{...}} public
record StateT {a} (S : Set a) (M : Set a → Set a) (A : Set a) : Set a where
no-eta-equality
constructor stateT
field runStateT : S → M A
open StateT public
module _ {a} {S : Set a} {M : Set a → Set a} where
instance
FunctorStateT : {{_ : Functor M}} → Functor {a = a} (StateT S M)
runStateT (fmap {{FunctorStateT}} f m) s = fmap f (runStateT m s)
FunctorZeroStateT : {{_ : FunctorZero M}} → FunctorZero {a = a} (StateT S M)
runStateT (empty {{FunctorZeroStateT}}) s = empty
AlternativeStateT : {{_ : Alternative M}} → Alternative {a = a} (StateT S M)
runStateT (_<|>_ {{AlternativeStateT}} x y) s = runStateT x s <|> runStateT y s
--- Example with some module parameter instantiations
open import Agda.Builtin.Nat
open import Agda.Builtin.Unit
data Vec (A : Set) : Nat → Set where
[] : Vec A 0
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
postulate
C₁ : Set → Set
record C₂ (A : Set) : Set where
field
f : A → A
overlap {{super}} : C₁ A
open C₂ {{...}}
postulate
T : (A : Set) → A → Set
module M (A : Set) (n : Nat) (xs : Vec A n) where
unpackT : Vec A n → Set
unpackT (x ∷ xs) = C₂ (T A x)
unpackT [] = ⊤
postulate instance C₁T : ∀ {x} {{C₁A : C₁ A}} → C₁ (T A x)
C₂T : {{C₂A : C₂ A}} (ys : Vec A n) → unpackT ys
C₂T [] = _
f {{C₂T (y ∷ ys)}} x = x
| 24.102564
| 83
| 0.569681
|
1cfb0c1afa18b3878632c6274971e0c4b23d0dac
| 1,754
|
agda
|
Agda
|
Rings/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Rings/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Rings/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Groups.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
-- Following Part IB's course Groups, Rings, and Modules, we take rings to be commutative with one.
module Rings.Definition where
record Ring {n m} {A : Set n} (S : Setoid {n} {m} A) (_+_ : A → A → A) (_*_ : A → A → A) : Set (lsuc n ⊔ m) where
field
additiveGroup : Group S _+_
open Group additiveGroup
open Setoid S
open Equivalence eq
0R : A
0R = 0G
_-R_ : A → A → A
a -R b = a + (inverse b)
field
*WellDefined : {r s t u : A} → (r ∼ t) → (s ∼ u) → r * s ∼ t * u
1R : A
groupIsAbelian : {a b : A} → a + b ∼ b + a
*Associative : {a b c : A} → (a * (b * c)) ∼ (a * b) * c
*Commutative : {a b : A} → a * b ∼ b * a
*DistributesOver+ : {a b c : A} → a * (b + c) ∼ (a * b) + (a * c)
identIsIdent : {a : A} → 1R * a ∼ a
timesZero : {a : A} → a * 0R ∼ 0R
timesZero {a} = symmetric (transitive (transitive (symmetric invLeft) (+WellDefined reflexive (transitive (*WellDefined {a} {a} reflexive (symmetric identRight)) *DistributesOver+))) (transitive +Associative (transitive (+WellDefined invLeft reflexive) identLeft)))
timesZero' : {a : A} → 0R * a ∼ 0R
timesZero' {a} = transitive *Commutative timesZero
*DistributesOver+' : {a b c : A} → (a + b) * c ∼ (a * c) + (b * c)
*DistributesOver+' = transitive *Commutative (transitive *DistributesOver+ (+WellDefined *Commutative *Commutative))
*Associative' : {a b c : A} → ((a * b) * c) ∼ (a * (b * c))
*Associative' = symmetric *Associative
identIsIdent' : {a : A} → a * 1R ∼ a
identIsIdent' = transitive *Commutative identIsIdent
| 43.85
| 267
| 0.606613
|
13918fa9f3dbb7febc4cca1f326c3827fef3f661
| 2,782
|
agda
|
Agda
|
Cubical/Data/Nat/Divisibility.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Data/Nat/Divisibility.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Data/Nat/Divisibility.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Nat.Divisibility where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Sigma
open import Cubical.Data.Empty as ⊥
open import Cubical.HITs.PropositionalTruncation as PropTrunc
open import Cubical.Data.Nat.Base
open import Cubical.Data.Nat.Properties
open import Cubical.Data.Nat.Order
private
variable
l m n : ℕ
_∣_ : ℕ → ℕ → Type₀
m ∣ n = ∃[ c ∈ ℕ ] c * m ≡ n
isProp∣ : isProp (m ∣ n)
isProp∣ = squash
prediv : ℕ → ℕ → Type₀
prediv m n = Σ[ c ∈ ℕ ] c * m ≡ n
-- an alternate definition of m ∣ n that doesn't use truncation
_∣'_ : ℕ → ℕ → Type₀
zero ∣' n = zero ≡ n
suc m ∣' n = Σ[ c ∈ ℕ ] c * suc m ≡ n
isProp∣' : isProp (m ∣' n)
isProp∣' {zero} {n} = isSetℕ _ _
isProp∣' {suc m} {n} (c₁ , p₁) (c₂ , p₂) =
ΣProp≡ (λ _ → isSetℕ _ _) (inj-*sm {c₁} {m} {c₂} (p₁ ∙ sym p₂))
∣≃∣' : (m ∣ n) ≃ (m ∣' n)
∣≃∣' {zero} = PropEquiv→Equiv isProp∣ isProp∣'
(PropTrunc.rec (isSetℕ _ _) λ { (c , p) → 0≡m*0 c ∙ p })
(λ p → ∣ zero , p ∣)
∣≃∣' {suc m} = propTruncIdempotent≃ isProp∣'
∣-untrunc : m ∣ n → Σ[ c ∈ ℕ ] c * m ≡ n
∣-untrunc {zero} p = zero , equivFun ∣≃∣' p
∣-untrunc {suc m} = equivFun ∣≃∣'
-- basic properties of ∣
∣-refl : m ≡ n → m ∣ n
∣-refl p = ∣ 1 , +-zero _ ∙ p ∣
∣-trans : l ∣ m → m ∣ n → l ∣ n
∣-trans = PropTrunc.map2 λ {
(c₁ , p) (c₂ , q) → (c₂ * c₁ , sym (*-assoc c₂ c₁ _) ∙ cong (c₂ *_) p ∙ q) }
∣-cancelʳ : ∀ k → (m * suc k) ∣ (n * suc k) → m ∣ n
∣-cancelʳ k = PropTrunc.map λ {
(c , p) → (c , inj-*sm (sym (*-assoc c _ (suc k)) ∙ p)) }
∣-multʳ : ∀ k → m ∣ n → (m * k) ∣ (n * k)
∣-multʳ k = PropTrunc.map λ {
(c , p) → (c , *-assoc c _ k ∙ cong (_* k) p) }
∣-zeroˡ : zero ∣ m → zero ≡ m
∣-zeroˡ = equivFun ∣≃∣'
∣-zeroʳ : ∀ m → m ∣ zero
∣-zeroʳ m = ∣ zero , refl ∣
∣-oneˡ : ∀ m → 1 ∣ m
∣-oneˡ m = ∣ m , *-identityʳ m ∣
-- if n > 0, then the constant c (s.t. c * m ≡ n) is also > 0
∣s-untrunc : m ∣ suc n → Σ[ c ∈ ℕ ] (suc c) * m ≡ suc n
∣s-untrunc ∣p∣ with ∣-untrunc ∣p∣
... | (zero , p) = ⊥.rec (znots p)
... | (suc c , p) = (c , p)
m∣sn→m≤sn : m ∣ suc n → m ≤ suc n
m∣sn→m≤sn {m} {n} = f ∘ ∣s-untrunc
where f : Σ[ c ∈ ℕ ] (suc c) * m ≡ suc n → Σ[ c ∈ ℕ ] c + m ≡ suc n
f (c , p) = (c * m) , (+-comm (c * m) m ∙ p)
m∣sn→z<m : m ∣ suc n → zero < m
m∣sn→z<m {zero} p = ⊥.rec (znots (∣-zeroˡ p))
m∣sn→z<m {suc m} p = suc-≤-suc zero-≤
antisym∣ : ∀ {m n} → m ∣ n → n ∣ m → m ≡ n
antisym∣ {zero} {n} z∣n _ = ∣-zeroˡ z∣n
antisym∣ {m} {zero} _ z∣m = sym (∣-zeroˡ z∣m)
antisym∣ {suc m} {suc n} p q = ≤-antisym (m∣sn→m≤sn p) (m∣sn→m≤sn q)
| 28.10101
| 86
| 0.525521
|
4dbb0853eff514ee65a64d28bbe06432ccbc6ec1
| 4,882
|
agda
|
Agda
|
cohomology/CofiberSequence.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
cohomology/CofiberSequence.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | null | null | null |
cohomology/CofiberSequence.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.FunctionOver
open import cohomology.FlipPushout
module cohomology.CofiberSequence {i} where
{- Lemma: pushing flip-susp through susp-fmap -}
flip-susp-fmap : {A B : Type i} (f : A → B)
→ ∀ σ → flip-susp (susp-fmap f σ) == susp-fmap f (flip-susp σ)
flip-susp-fmap f = Suspension-elim _ idp idp $ λ y → ↓-='-in $
ap-∘ (susp-fmap f) flip-susp (merid _ y)
∙ ap (ap (susp-fmap f)) (FlipSusp.glue-β y)
∙ ap-! (susp-fmap f) (merid _ y)
∙ ap ! (SuspFmap.glue-β f y)
∙ ! (FlipSusp.glue-β (f y))
∙ ! (ap (ap flip-susp) (SuspFmap.glue-β f y))
∙ ∘-ap flip-susp (susp-fmap f) (merid _ y)
{- Useful abbreviations -}
module _ {X Y : Ptd i} (f : fst (X ⊙→ Y)) where
⊙Cof² = ⊙Cof (⊙cfcod f)
⊙cfcod² = ⊙cfcod (⊙cfcod f)
cfcod² = fst ⊙cfcod²
⊙Cof³ = ⊙Cof ⊙cfcod²
⊙cfcod³ = ⊙cfcod ⊙cfcod²
cfcod³ = fst ⊙cfcod³
{- For [f : X → Y], the cofiber space [Cof(cfcod f)] is equivalent to
- [Suspension X]. This is essentially an application of the two pushouts
- lemma:
-
- f
- X ––––> Y ––––––––––––––> ∙
- | | |
- | |cfcod f |
- v v v
- ∙ ––> Cof f ––––––––––> Cof² f
- cfcod² f
-
- The map [cfcod² f : Cof f → Cof² f] becomes [ext-glue : Cof f → ΣX],
- and the map [ext-glue : Cof² f → ΣY] becomes [susp-fmap f : ΣX → ΣY].
-}
module Cof² {X Y : Ptd i} (f : fst (X ⊙→ Y)) where
module Equiv {X Y : Ptd i} (f : fst (X ⊙→ Y)) where
module Into = CofiberRec (cfcod (fst f)) {C = fst (⊙Susp X)}
(south _) ext-glue (λ _ → idp)
into = Into.f
⊙into : fst (⊙Cof² f ⊙→ ⊙Susp X)
⊙into = (into , ! (merid _ (snd X)))
module Out = SuspensionRec (fst X) {C = fst (⊙Cof² f)}
(cfcod _ (cfbase _)) (cfbase _)
(λ x → ap (cfcod _) (cfglue _ x) ∙ ! (cfglue _ (fst f x)))
out = Out.f
into-out : ∀ σ → into (out σ) == σ
into-out = Suspension-elim (fst X) idp idp
(λ x → ↓-∘=idf-in into out $
ap (ap into) (Out.glue-β x)
∙ ap-∙ into (ap (cfcod _) (cfglue _ x)) (! (cfglue _ (fst f x)))
∙ ap (λ w → ap into (ap (cfcod _) (cfglue _ x)) ∙ w)
(ap-! into (cfglue _ (fst f x)) ∙ ap ! (Into.glue-β (fst f x)))
∙ ∙-unit-r _
∙ ∘-ap into (cfcod _) (cfglue _ x) ∙ ExtGlue.glue-β x)
out-into : ∀ κ → out (into κ) == κ
out-into = Cofiber-elim (cfcod (fst f))
idp
(Cofiber-elim (fst f) idp (cfglue _)
(λ x → ↓-='-from-square $
(ap-∘ out ext-glue (cfglue _ x)
∙ ap (ap out) (ExtGlue.glue-β x) ∙ Out.glue-β x)
∙v⊡ (vid-square {p = ap (cfcod _) (cfglue _ x)}
⊡h rt-square (cfglue _ (fst f x)))
⊡v∙ ∙-unit-r _))
(λ y → ↓-∘=idf-from-square out into $
ap (ap out) (Into.glue-β y) ∙v⊡ connection)
eq = equiv into out into-out out-into
space-path : ⊙Cof² f == ⊙Susp X
space-path = ⊙ua (⊙ify-eq eq (! (merid _ (snd X))))
cfcod²-over : cfcod² f == ext-glue
[ (λ U → fst (⊙Cof f) → fst U) ↓ Equiv.space-path f ]
cfcod²-over = ↓-cst2-in _ _ $ codomain-over-equiv (cfcod² f) _
cfcod³-over : ext-glue == flip-susp ∘ susp-fmap (fst f)
[ (λ U → fst U → fst (⊙Susp Y)) ↓ Equiv.space-path f ]
cfcod³-over = ↓-cst2-in _ _ $
domain!-over-equiv ext-glue _ ▹ λ= lemma
where
lemma : (σ : fst (⊙Susp X))
→ ext-glue (Equiv.out f σ) == flip-susp (susp-fmap (fst f) σ)
lemma = Suspension-elim (fst X) idp idp
(λ x → ↓-='-in $
ap-∘ flip-susp (susp-fmap (fst f)) (merid _ x)
∙ ap (ap flip-susp) (SuspFmap.glue-β (fst f) x)
∙ FlipSusp.glue-β (fst f x)
∙ ! (ap-∘ ext-glue (Equiv.out f) (merid _ x)
∙ ap (ap ext-glue) (Equiv.Out.glue-β f x)
∙ ap-∙ ext-glue (ap (cfcod _) (cfglue _ x))
(! (cfglue _ (fst f x)))
∙ (∘-ap ext-glue (cfcod _) (cfglue _ x)
∙ ap-cst (south _) (cfglue _ x))
∙2
(ap-! ext-glue (cfglue _ (fst f x))
∙ ap ! (ExtGlue.glue-β (fst f x)))))
open Equiv f public
cofiber-sequence : {X Y : Ptd i} (f : fst (X ⊙→ Y)) → Path
{A = Σ (Ptd i × Ptd i)
(λ {(U , V) → (fst (⊙Cof f) → fst U) × (fst U → fst V)})}
((⊙Cof² f , ⊙Cof³ f) , cfcod² f , cfcod³ f)
((⊙Susp X , ⊙Susp Y) , ext-glue , susp-fmap (fst f))
cofiber-sequence {X} {Y} f =
ap (λ {(Z , g) → ((⊙Cof² f , Z) , cfcod² f , g)})
(pair= (Cof².space-path (⊙cfcod f)) (Cof².cfcod²-over (⊙cfcod f)))
∙ ap (λ {(Z , g , h) → ((Z , ⊙Susp Y) , g , h)})
(pair= (Cof².space-path f)
(↓-×-in (Cof².cfcod²-over f) (Cof².cfcod³-over f)))
∙ ap (λ {(Z , g) → ((⊙Susp X , Z) , ext-glue , g)})
(pair= (flip-⊙pushout-path (suspension-⊙span Y))
(↓-cst2-in _ _ $ codomain!-over-equiv _ _))
| 36.432836
| 76
| 0.500615
|
cb887cdc827a9f7bc46cf7fed648a775f80a9464
| 5,086
|
agda
|
Agda
|
Cubical/Modalities/Modality.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Modalities/Modality.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/Modalities/Modality.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | 1
|
2021-03-12T20:08:45.000Z
|
2021-03-12T20:08:45.000Z
|
{-# OPTIONS --safe #-}
module Cubical.Modalities.Modality where
{-
translated from
https://github.com/HoTT/HoTT-Agda/blob/master/core/lib/types/Modality.agda
-}
open import Cubical.Foundations.Everything
record Modality ℓ : Type (ℓ-suc ℓ) where
field
isModal : Type ℓ → Type ℓ
isModalIsProp : {A : Type ℓ} → isProp (isModal A)
◯ : Type ℓ → Type ℓ -- \ciO
◯-isModal : {A : Type ℓ} → isModal (◯ A)
η : {A : Type ℓ} → A → ◯ A
◯-elim : {A : Type ℓ} {B : ◯ A → Type ℓ}
(B-modal : (x : ◯ A) → isModal (B x))
→ ((x : A) → (B (η x))) → ((x : ◯ A) → B x)
◯-elim-β : {A : Type ℓ} {B : ◯ A → Type ℓ}
(B-modal : (x : ◯ A) → isModal (B x)) (f : (x : A) → (B (η x)))
→ (a : A) → ◯-elim B-modal f (η a) ≡ f a
◯-=-isModal : {A : Type ℓ} (x y : ◯ A) → isModal (x ≡ y)
◯-Types : Type (ℓ-suc ℓ)
◯-Types = TypeWithStr ℓ isModal
{- elimination rules -}
module ◯Elim {A : Type ℓ} {B : ◯ A → Type ℓ}
(B-modal : (x : ◯ A) → isModal (B x)) (η* : (x : A) → (B (η x))) where
f : (x : ◯ A) → B x
f = ◯-elim B-modal η*
η-β : (a : A) → ◯-elim B-modal η* (η a) ≡ η* a
η-β = ◯-elim-β B-modal η*
module ◯Rec {A : Type ℓ} {B : Type ℓ}
(B-modal : isModal B) (η* : A → B)
= ◯Elim (λ _ → B-modal) η*
◯-rec = ◯Rec.f
◯-rec-β = ◯Rec.η-β
{- functoriality -}
module ◯Fmap {A B : Type ℓ} (f : A → B) =
◯Rec ◯-isModal (η ∘ f)
◯-map = ◯Fmap.f
◯-map-β = ◯Fmap.η-β
◯-preservesEquiv : {A B : Type ℓ} (f : A → B) → isEquiv f → isEquiv (◯-map f)
◯-preservesEquiv f f-ise = isoToIsEquiv (iso _ (◯-map inv) to-from from-to) where
open Iso (equivToIso (f , f-ise))
to-from : ∀ ◯b → ◯-map f (◯-map inv ◯b) ≡ ◯b
to-from = ◯-elim
(λ ◯b → ◯-=-isModal (◯-map f (◯-map inv ◯b)) ◯b)
(λ b → cong (◯-map f) (◯-map-β inv b) ∙ ◯-map-β f (inv b) ∙ cong η (rightInv b))
from-to : ∀ ◯a → ◯-map inv (◯-map f ◯a) ≡ ◯a
from-to = ◯-elim
(λ ◯a → ◯-=-isModal (◯-map inv (◯-map f ◯a)) ◯a)
(λ a → cong (◯-map inv) (◯-map-β f a) ∙ ◯-map-β inv (f a) ∙ cong η (leftInv a))
◯-equiv : {A B : Type ℓ} → A ≃ B → ◯ A ≃ ◯ B
◯-equiv (f , f-ise) = ◯-map f , ◯-preservesEquiv f f-ise
{- equivalences preserve being modal -}
equivPreservesIsModal : {A B : Type ℓ} → A ≃ B → isModal A → isModal B
equivPreservesIsModal eq = fst (pathToEquiv (cong isModal (ua eq)))
{- modal types and [η] being an equivalence -}
isModalToIso : {A : Type ℓ} → isModal A → Iso A (◯ A)
Iso.fun (isModalToIso _) = η
Iso.inv (isModalToIso w) = ◯-rec w (idfun _)
Iso.rightInv (isModalToIso w) = ◯-elim (λ _ → ◯-=-isModal _ _) (λ a₀ → cong η (◯-rec-β w (idfun _) a₀))
Iso.leftInv (isModalToIso w) = ◯-rec-β w (idfun _)
isModalToIsEquiv : {A : Type ℓ} → isModal A → isEquiv (η {A})
isModalToIsEquiv {A} w = isoToIsEquiv (isModalToIso w)
isEquivToIsModal : {A : Type ℓ} → isEquiv (η {A}) → isModal A
isEquivToIsModal {A} eq = equivPreservesIsModal (invEquiv (η , eq)) ◯-isModal
retractIsModal : {A B : Type ℓ} (w : isModal A)
(f : A → B) (g : B → A) (r : (b : B) → f (g b) ≡ b) →
isModal B
retractIsModal {A} {B} w f g r =
isEquivToIsModal
(isoToIsEquiv (iso η η-inv inv-l inv-r))
where η-inv : ◯ B → B
η-inv = f ∘ (◯-rec w g)
inv-r : (b : B) → η-inv (η b) ≡ b
inv-r b = cong f (◯-rec-β w g b) ∙ r b
inv-l : (b : ◯ B) → η (η-inv b) ≡ b
inv-l = ◯-elim (λ b → ◯-=-isModal _ _) (λ b → cong η (inv-r b))
{- function types with modal codomain are modal -}
Π-isModal : {A : Type ℓ} {B : A → Type ℓ}
(w : (a : A) → isModal (B a)) → isModal ((x : A) → B x)
Π-isModal {A} {B} w = retractIsModal {◯ _} {(x : A) → B x} ◯-isModal η-inv η r
where η-inv : ◯ ((x : A) → B x) → (x : A) → B x
η-inv φ' a = ◯-rec (w a) (λ φ → φ a) φ'
r : (φ : (x : A) → B x) → η-inv (η φ) ≡ φ
r φ = funExt (λ a → ◯-rec-β (w a) (λ φ₀ → φ₀ a) φ)
→-isModal : {A B : Type ℓ} → isModal B → isModal (A → B)
→-isModal w = Π-isModal (λ _ → w)
{- sigma types of a modal dependent type with modal base are modal -}
Σ-isModal : {A : Type ℓ} (B : A → Type ℓ)
→ isModal A → ((a : A) → isModal (B a))
→ isModal (Σ A B)
Σ-isModal {A} B A-modal B-modal =
retractIsModal {◯ (Σ A B)} {Σ A B} ◯-isModal η-inv η r
where h : ◯ (Σ A B) → A
h = ◯-rec A-modal fst
h-β : (x : Σ A B) → h (η x) ≡ fst x
h-β = ◯-rec-β A-modal fst
f : (j : I) → (x : Σ A B) → B (h-β x j)
f j x = transp (λ i → B (h-β x ((~ i) ∨ j))) j (snd x)
k : (y : ◯ (Σ A B)) → B (h y)
k = ◯-elim (B-modal ∘ h) (f i0)
η-inv : ◯ (Σ A B) → Σ A B
η-inv y = h y , k y
p : (x : Σ A B) → k (η x) ≡ f i0 x
p = ◯-elim-β (B-modal ∘ h) (f i0)
almost : (x : Σ A B) → (h (η x) , f i0 x) ≡ x
almost x i = h-β x i , f i x
r : (x : Σ A B) → η-inv (η x) ≡ x
r x = (λ i → h (η x) , p x i) ∙ (almost x)
| 32.602564
| 105
| 0.470507
|
591500a3823eaa9d0c6aa4187f74899d78d8dd88
| 3,303
|
agda
|
Agda
|
Cubical/Relation/Binary/Raw/Construct/NonStrictToStrict.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Raw/Construct/NonStrictToStrict.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Raw/Construct/NonStrictToStrict.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Core.Everything
open import Cubical.Relation.Binary.Raw
module Cubical.Relation.Binary.Raw.Construct.NonStrictToStrict
{a ℓ} {A : Type a} (_≤_ : RawRel A ℓ) where
open import Cubical.Relation.Binary.Raw.Properties
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Data.Sum.Base using (inl; inr)
open import Cubical.Data.Empty hiding (rec)
open import Cubical.Foundations.Function using (_∘_; flip)
open import Cubical.Relation.Nullary
open import Cubical.HITs.PropositionalTruncation hiding (elim)
private
_≢_ : RawRel A a
x ≢ y = ¬ (x ≡ y)
------------------------------------------------------------------------
-- _≤_ can be turned into _<_ as follows:
_<_ : RawRel A _
x < y = x ≤ y × x ≢ y
------------------------------------------------------------------------
-- Relationship between relations
<⇒≤ : _<_ ⇒ _≤_
<⇒≤ = fst
<⇒≢ : _<_ ⇒ _≢_
<⇒≢ = snd
≤∧≢⇒< : ∀ {x y} → x ≤ y → x ≢ y → x < y
≤∧≢⇒< = _,_
<⇒≱ : Antisymmetric _≤_ → ∀ {x y} → x < y → ¬ (y ≤ x)
<⇒≱ antisym (x≤y , x≢y) y≤x = x≢y (antisym x≤y y≤x)
≤⇒≯ : Antisymmetric _≤_ → ∀ {x y} → x ≤ y → ¬ (y < x)
≤⇒≯ antisym x≤y y<x = <⇒≱ antisym y<x x≤y
≰⇒> : Reflexive _≤_ → Total _≤_ →
∀ {x y} → ¬ (x ≤ y) → y < x
≰⇒> rfl total {x} {y} x≰y with total x y
... | inl x≤y = elim (x≰y x≤y)
... | inr y≤x = y≤x , x≰y ∘ reflx→fromeq _≤_ rfl ∘ sym
≮⇒≥ : Discrete A → Reflexive _≤_ → Total _≤_ →
∀ {x y} → ¬ (x < y) → y ≤ x
≮⇒≥ _≟_ ≤-refl _≤?_ {x} {y} x≮y with x ≟ y
... | yes x≈y = reflx→fromeq _≤_ ≤-refl (sym x≈y)
... | no x≢y with y ≤? x
... | inl y≤x = y≤x
... | inr x≤y = elim (x≮y (x≤y , x≢y))
------------------------------------------------------------------------
-- Relational properties
<-isPropValued : isPropValued _≤_ → isPropValued _<_
<-isPropValued propv x y = isProp× (propv x y) (isPropΠ λ _ → isProp⊥)
<-toNotEq : ToNotEq _<_
<-toNotEq (_ , x≢y) x≡y = x≢y x≡y
<-irrefl : Irreflexive _<_
<-irrefl = tonoteq→irrefl _<_ <-toNotEq
<-transitive : IsPartialOrder _≤_ → Transitive _<_
<-transitive po (x≤y , x≢y) (y≤z , y≉z) =
(transitive x≤y y≤z , x≢y ∘ antisym x≤y ∘ transitive y≤z ∘ fromEq ∘ sym)
where open IsPartialOrder po
<-≤-trans : Transitive _≤_ → Antisymmetric _≤_ →
Trans _<_ _≤_ _<_
<-≤-trans transitive antisym (x≤y , x≢y) y≤z =
transitive x≤y y≤z , (λ x≡z → x≢y (antisym x≤y (Respectsʳ≡ _≤_ (sym x≡z) y≤z)))
≤-<-trans : Transitive _≤_ → Antisymmetric _≤_ →
Trans _≤_ _<_ _<_
≤-<-trans trans antisym x≤y (y≤z , y≢z) =
trans x≤y y≤z , (λ x≡z → y≢z (antisym y≤z (Respectsˡ≡ _≤_ x≡z x≤y)))
<-asym : Antisymmetric _≤_ → Asymmetric _<_
<-asym antisym (x≤y , x≢y) (y≤x , _) = x≢y (antisym x≤y y≤x)
<-decidable : Discrete A → Decidable _≤_ → Decidable _<_
<-decidable _≟_ _≤?_ x y with x ≤? y
... | no ¬p = no (¬p ∘ fst)
... | yes p with x ≟ y
... | yes q = no (λ x<y → snd x<y q)
... | no ¬q = yes (p , ¬q)
------------------------------------------------------------------------
-- Structures
isStrictPartialOrder : IsPartialOrder _≤_ → IsStrictPartialOrder _<_
isStrictPartialOrder po = record
{ irrefl = <-irrefl
; transitive = <-transitive po
} where open IsPartialOrder po
| 30.869159
| 81
| 0.539812
|
58cb4a2b1ba8c42a7d15c67bac8a4aa738b63cb6
| 3,041
|
agda
|
Agda
|
LargeCombinators.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | 1
|
2021-02-13T14:48:45.000Z
|
2021-02-13T14:48:45.000Z
|
LargeCombinators.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | null | null | null |
LargeCombinators.agda
|
nad/codata
|
1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Yet another implementation of the Fibonacci sequence using tail
------------------------------------------------------------------------
module LargeCombinators where
open import Codata.Musical.Notation
open import Codata.Musical.Stream as S using (Stream; _∷_; _≈_)
open import Data.Nat
import Relation.Binary.PropositionalEquality as P
-- Stream programs. Note that the destructor tail is encapsulated in a
-- larger combinator, which also incorporates a constructor. This
-- ensures that the combinator can be used freely, with no risk of
-- destroying productivity.
--
-- Note that, in the general case, the implementation of whnf for the
-- "large combinator" may be quite tricky. In this case the
-- implementation turns out to be very simple, though.
--
-- The idea to use a "large combinator" is due to Thorsten Altenkirch.
infixr 5 _∷_
data StreamP (A : Set) : Set where
_∷_ : (x : A) (xs : ∞ (StreamP A)) → StreamP A
zipWith : (f : A → A → A) (xs ys : StreamP A) → StreamP A
-- The intention is that ⟦ x ∷zipWith f · xs [tail ys ] ⟧P should be
-- equal to x ∷ ♯ S.zipWith f ⟦ xs ⟧P (S.tail ⟦ ys ⟧P).
_∷zipWith_·_[tail_] :
(x : A) (f : A → A → A) (xs ys : StreamP A) → StreamP A
-- WHNFs.
data StreamW (A : Set) : Set where
_∷_ : (x : A) (xs : StreamP A) → StreamW A
-- Stream programs can be turned into streams.
whnf : ∀ {A} → StreamP A → StreamW A
whnf (x ∷ xs) = x ∷ ♭ xs
whnf (x ∷zipWith f · xs′ [tail ys ]) with whnf ys
... | _ ∷ ys′ = x ∷ zipWith f xs′ ys′
whnf (zipWith f xs ys) with whnf xs | whnf ys
... | x ∷ xs′ | y ∷ ys′ = f x y ∷ zipWith f xs′ ys′
mutual
⟦_⟧W : ∀ {A} → StreamW A → Stream A
⟦ x ∷ xs ⟧W = x ∷ ♯ ⟦ xs ⟧P
⟦_⟧P : ∀ {A} → StreamP A → Stream A
⟦ xs ⟧P = ⟦ whnf xs ⟧W
-- The Fibonacci sequence.
fib : StreamP ℕ
fib = 0 ∷ ♯ (1 ∷zipWith _+_ · fib [tail fib ])
-- ⟦_⟧P is homomorphic with respect to zipWith/S.zipWith.
zipWith-hom :
∀ {A} (f : A → A → A) (xs ys : StreamP A) →
⟦ zipWith f xs ys ⟧P ≈ S.zipWith f ⟦ xs ⟧P ⟦ ys ⟧P
zipWith-hom f xs ys with whnf xs | whnf ys
... | x ∷ xs′ | y ∷ ys′ = P.refl ∷ ♯ zipWith-hom f xs′ ys′
-- The stream ⟦ fib ⟧P satisfies its intended defining equation.
fib-correct :
⟦ fib ⟧P ≈ 0 ∷ ♯ (1 ∷ ♯ (S.zipWith _+_ ⟦ fib ⟧P (S.tail ⟦ fib ⟧P)))
fib-correct =
P.refl ∷ ♯ (P.refl ∷ ♯
zipWith-hom _+_ fib (1 ∷zipWith _+_ · fib [tail fib ]))
-- For completeness, let us show that _∷zipWith_·_[tail_] is correctly
-- implemented.
open import Relation.Binary.PropositionalEquality as P using (_≡_; [_])
_∷zipWith_·_[tail_]-hom :
∀ {A} (x : A) (f : A → A → A) (xs ys : StreamP A) →
⟦ x ∷zipWith f · xs [tail ys ] ⟧P ≈
x ∷ ♯ S.zipWith f ⟦ xs ⟧P (S.tail ⟦ ys ⟧P)
x ∷zipWith f · xs [tail ys ]-hom with whnf ys | P.inspect whnf ys
... | y ∷ ys′ | [ eq ] = P.refl ∷ ♯ helper eq
where
helper : whnf ys ≡ y ∷ ys′ →
⟦ zipWith f xs ys′ ⟧P ≈
S.zipWith f ⟦ xs ⟧P (S.tail ⟦ ys ⟧P)
helper eq rewrite eq = zipWith-hom f xs ys′
| 32.351064
| 72
| 0.581059
|
c774f268d6925912ea59a6acb74416a9fcd0ab37
| 6,382
|
agda
|
Agda
|
Cubical/HITs/Susp/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-03-05T00:29:41.000Z
|
2022-03-05T00:29:41.000Z
|
Cubical/HITs/Susp/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Susp/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.HITs.Susp.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Pointed
open import Cubical.Data.Bool
open import Cubical.Data.Empty
open import Cubical.HITs.S1
open import Cubical.HITs.S2
open import Cubical.HITs.S3
open Iso
private
variable
ℓ ℓ′ : Level
data Susp (A : Type ℓ) : Type ℓ where
north : Susp A
south : Susp A
merid : (a : A) → north ≡ south
Susp∙ : (A : Type ℓ) → Pointed ℓ
Susp∙ A = Susp A , north
-- induced function
suspFun : {A : Type ℓ} {B : Type ℓ′} (f : A → B)
→ Susp A → Susp B
suspFun f north = north
suspFun f south = south
suspFun f (merid a i) = merid (f a) i
BoolIsoSusp⊥ : Iso Bool (Susp ⊥)
fun BoolIsoSusp⊥ = λ {true → north; false → south}
inv BoolIsoSusp⊥ = λ {north → true; south → false}
rightInv BoolIsoSusp⊥ = λ {north → refl; south → refl}
leftInv BoolIsoSusp⊥ = λ {true → refl; false → refl}
Bool≃Susp⊥ : Bool ≃ Susp ⊥
Bool≃Susp⊥ = isoToEquiv BoolIsoSusp⊥
SuspBool : Type₀
SuspBool = Susp Bool
SuspBool→S¹ : SuspBool → S¹
SuspBool→S¹ north = base
SuspBool→S¹ south = base
SuspBool→S¹ (merid false i) = loop i
SuspBool→S¹ (merid true i) = base
S¹→SuspBool : S¹ → SuspBool
S¹→SuspBool base = north
S¹→SuspBool (loop i) = (merid false ∙ sym (merid true)) i
SuspBool→S¹→SuspBool : (x : SuspBool) → Path _ (S¹→SuspBool (SuspBool→S¹ x)) x
SuspBool→S¹→SuspBool north = refl
SuspBool→S¹→SuspBool south = merid true
SuspBool→S¹→SuspBool (merid false i) j = hcomp (λ k → (λ { (j = i1) → merid false i
; (i = i0) → north
; (i = i1) → merid true (j ∨ ~ k)}))
(merid false i)
SuspBool→S¹→SuspBool (merid true i) j = merid true (i ∧ j)
S¹→SuspBool→S¹ : (x : S¹) → SuspBool→S¹ (S¹→SuspBool x) ≡ x
S¹→SuspBool→S¹ base = refl
S¹→SuspBool→S¹ (loop i) j = hfill (λ k → λ { (i = i0) → base
; (i = i1) → base })
(inS (loop i)) (~ j)
S¹IsoSuspBool : Iso S¹ SuspBool
fun S¹IsoSuspBool = S¹→SuspBool
inv S¹IsoSuspBool = SuspBool→S¹
rightInv S¹IsoSuspBool = SuspBool→S¹→SuspBool
leftInv S¹IsoSuspBool = S¹→SuspBool→S¹
S¹≃SuspBool : S¹ ≃ SuspBool
S¹≃SuspBool = isoToEquiv S¹IsoSuspBool
S¹≡SuspBool : S¹ ≡ SuspBool
S¹≡SuspBool = ua S¹≃SuspBool
-- Now the sphere
SuspS¹ : Type₀
SuspS¹ = Susp S¹
SuspS¹→S² : SuspS¹ → S²
SuspS¹→S² north = base
SuspS¹→S² south = base
SuspS¹→S² (merid base i) = base
SuspS¹→S² (merid (loop j) i) = surf i j
meridian-contraction : I → I → I → SuspS¹
meridian-contraction i j l = hfill (λ k → λ { (i = i0) → north
; (i = i1) → merid base (~ k)
; (j = i0) → merid base (~ k ∧ i)
; (j = i1) → merid base (~ k ∧ i) })
(inS (merid (loop j) i)) l
S²→SuspS¹ : S² → SuspS¹
S²→SuspS¹ base = north
S²→SuspS¹ (surf i j) = meridian-contraction i j i1
S²→SuspS¹→S² : ∀ x → SuspS¹→S² (S²→SuspS¹ x) ≡ x
S²→SuspS¹→S² base k = base
S²→SuspS¹→S² (surf i j) k = SuspS¹→S² (meridian-contraction i j (~ k))
SuspS¹→S²→SuspS¹ : ∀ x → S²→SuspS¹ (SuspS¹→S² x) ≡ x
SuspS¹→S²→SuspS¹ north k = north
SuspS¹→S²→SuspS¹ south k = merid base k
SuspS¹→S²→SuspS¹ (merid base j) k = merid base (k ∧ j)
SuspS¹→S²→SuspS¹ (merid (loop j) i) k = meridian-contraction i j (~ k)
S²IsoSuspS¹ : Iso S² SuspS¹
fun S²IsoSuspS¹ = S²→SuspS¹
inv S²IsoSuspS¹ = SuspS¹→S²
rightInv S²IsoSuspS¹ = SuspS¹→S²→SuspS¹
leftInv S²IsoSuspS¹ = S²→SuspS¹→S²
S²≃SuspS¹ : S² ≃ SuspS¹
S²≃SuspS¹ = isoToEquiv S²IsoSuspS¹
S²≡SuspS¹ : S² ≡ SuspS¹
S²≡SuspS¹ = ua S²≃SuspS¹
-- And the 3-sphere
SuspS² : Type₀
SuspS² = Susp S²
SuspS²→S³ : SuspS² → S³
SuspS²→S³ north = base
SuspS²→S³ south = base
SuspS²→S³ (merid base i) = base
SuspS²→S³ (merid (surf j k) i) = surf i j k
meridian-contraction-2 : I → I → I → I → SuspS²
meridian-contraction-2 i j k l = hfill (λ m → λ { (i = i0) → north
; (i = i1) → merid base (~ m)
; (j = i0) → merid base (~ m ∧ i)
; (j = i1) → merid base (~ m ∧ i)
; (k = i0) → merid base (~ m ∧ i)
; (k = i1) → merid base (~ m ∧ i) })
(inS (merid (surf j k) i)) l
S³→SuspS² : S³ → SuspS²
S³→SuspS² base = north
S³→SuspS² (surf i j k) = meridian-contraction-2 i j k i1
S³→SuspS²→S³ : ∀ x → SuspS²→S³ (S³→SuspS² x) ≡ x
S³→SuspS²→S³ base l = base
S³→SuspS²→S³ (surf i j k) l = SuspS²→S³ (meridian-contraction-2 i j k (~ l))
SuspS²→S³→SuspS² : ∀ x → S³→SuspS² (SuspS²→S³ x) ≡ x
SuspS²→S³→SuspS² north l = north
SuspS²→S³→SuspS² south l = merid base l
SuspS²→S³→SuspS² (merid base j) l = merid base (l ∧ j)
SuspS²→S³→SuspS² (merid (surf j k) i) l = meridian-contraction-2 i j k (~ l)
S³IsoSuspS² : Iso S³ SuspS²
fun S³IsoSuspS² = S³→SuspS²
inv S³IsoSuspS² = SuspS²→S³
rightInv S³IsoSuspS² = SuspS²→S³→SuspS²
leftInv S³IsoSuspS² = S³→SuspS²→S³
S³≃SuspS² : S³ ≃ SuspS²
S³≃SuspS² = isoToEquiv S³IsoSuspS²
S³≡SuspS² : S³ ≡ SuspS²
S³≡SuspS² = ua S³≃SuspS²
IsoType→IsoSusp : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → Iso A B → Iso (Susp A) (Susp B)
fun (IsoType→IsoSusp is) north = north
fun (IsoType→IsoSusp is) south = south
fun (IsoType→IsoSusp is) (merid a i) = merid (fun is a) i
inv (IsoType→IsoSusp is) north = north
inv (IsoType→IsoSusp is) south = south
inv (IsoType→IsoSusp is) (merid a i) = merid (inv is a) i
rightInv (IsoType→IsoSusp is) north = refl
rightInv (IsoType→IsoSusp is) south = refl
rightInv (IsoType→IsoSusp is) (merid a i) j = merid (rightInv is a j) i
leftInv (IsoType→IsoSusp is) north = refl
leftInv (IsoType→IsoSusp is) south = refl
leftInv (IsoType→IsoSusp is) (merid a i) j = merid (leftInv is a j) i
IsoSuspS²SuspSuspS¹ : Iso (Susp S²) (Susp (Susp S¹))
IsoSuspS²SuspSuspS¹ = IsoType→IsoSusp S²IsoSuspS¹
IsoS³S3 : Iso S³ (Susp (Susp S¹))
IsoS³S3 = compIso S³IsoSuspS² IsoSuspS²SuspSuspS¹
| 32.561224
| 93
| 0.600752
|
2ef6f632a2bd8080c0979d243748019317fcc99a
| 1,904
|
agda
|
Agda
|
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/spaceShipCell.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/spaceShipCell.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/spaceShipCell.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
module spaceShipCell where
open import Unit
open import Data.List.Base hiding ([])
open import Data.Bool.Base
open import Data.Integer
open import Data.Product hiding (map)
open import NativeIO
open import SizedIO.Object
open import SizedIO.IOObject
open import StateSizedIO.GUI.WxBindingsFFI
open import StateSizedIO.GUI.WxGraphicsLib
open import StateSized.GUI.ShipBitMap
open import SizedIO.Base
open import StateSizedIO.GUI.BaseStateDependent
open import StateSizedIO.GUI.VariableList
open import Sized.SimpleCell hiding (main; program)
VarType = Object (cellI ℤ)
cellℤC : (z : ℤ ) → VarType
objectMethod (cellℤC z) get = ( z , cellℤC z )
objectMethod (cellℤC z) (put z') = ( _ , cellℤC z' )
varInit : VarType
varInit = cellℤC (+ 150)
onPaint : ∀{i} → VarType → DC → Rect → IO GuiLev1Interface i VarType
onPaint c dc rect =
let (z , c₁) = objectMethod c get in
do (drawBitmap dc ship (z , (+ 150)) true) λ _ →
return c₁
moveSpaceShip : ∀{i} → Frame → VarType → IO GuiLev1Interface i VarType
moveSpaceShip fra c =
let (z , c₁) = objectMethod c get
(_ , c₂) = objectMethod c₁ (put (z + + 20))
in return c₂
callRepaint : ∀{i} → Frame → VarType → IO GuiLev1Interface i VarType
callRepaint fra c = do (repaint fra) λ _ → return c
buttonHandler : ∀{i} → Frame → List (VarType → IO GuiLev1Interface i VarType)
buttonHandler fra = moveSpaceShip fra ∷ [ callRepaint fra ]
program : ∀{i} → IOˢ GuiLev2Interface i (λ _ → Unit) []
program = doˢ (level1C makeFrame) λ fra →
doˢ (level1C (makeButton fra)) λ bt →
doˢ (level1C (addButton fra bt)) λ _ →
doˢ (createVar varInit) λ _ →
doˢ (setButtonHandler bt (buttonHandler fra)) λ _ →
doˢ (setOnPaint fra [ onPaint ])
returnˢ
main : NativeIO Unit
main = start (translateLev2 program)
| 32.271186
| 78
| 0.664916
|
5907ce72f9eecb18a5fc4519c10e1dfc5bea82fa
| 370
|
agda
|
Agda
|
src/prototyping/term/tests/Pruning.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
src/prototyping/term/tests/Pruning.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
src/prototyping/term/tests/Pruning.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
module Pruning where
le2 : {B : Set} -> (A : Set) -> A -> (C : Set) -> C -> (A -> C -> B) -> B
le2 _ x _ y f = f x y
test : le2 Set _ (Set -> Set) _ (\ H -> (\M -> (z : Set) -> H == M z))
test z = refl
{-
let : {B : Set} -> (A : Set) -> A -> (A -> B) -> B
let A x f = f x
test : let Set _ (\ H -> let (Set -> Set) _ (\ M -> (z : Set) -> H == M z))
test z = refl
-}
| 24.666667
| 75
| 0.4
|
ad3f0b4e5c67aa2a7318e913c5866110bda8a9c8
| 1,221
|
agda
|
Agda
|
Cubical/Algebra/Group/DirProd.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/DirProd.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/DirProd.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group.DirProd where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Semigroup
open GroupStr
open IsGroup hiding (·IdR ; ·IdL ; ·InvR ; ·InvL)
open IsMonoid hiding (·IdR ; ·IdL)
open IsSemigroup
DirProd : ∀ {ℓ ℓ'} → Group ℓ → Group ℓ' → Group (ℓ-max ℓ ℓ')
fst (DirProd G H) = (fst G) × (fst H)
1g (snd (DirProd G H)) = (1g (snd G)) , (1g (snd H))
_·_ (snd (DirProd G H)) (g , h) (g' , h') = _·_ (snd G) g g' , _·_ (snd H) h h'
inv (snd (DirProd G H)) (g , h) = (inv (snd G) g) , (inv (snd H) h)
isGroup (snd (DirProd G H)) = makeIsGroup
(isSet× (is-set (snd G)) (is-set (snd H)))
(λ x y z → ≡-× (·Assoc (snd G) _ _ _) (·Assoc (snd H) _ _ _))
(λ x → ≡-× (·IdR (snd G) _) (·IdR (snd H) _))
(λ x → ≡-× (·IdL (snd G) _) (·IdL (snd H) _))
(λ x → ≡-× (·InvR (snd G) _) (·InvR (snd H) _))
λ x → ≡-× (·InvL (snd G) _) (·InvL (snd H) _)
| 43.607143
| 91
| 0.511057
|
ad1e89a27aba3c8cc9dafd97df4470f7ff85f7a9
| 1,986
|
agda
|
Agda
|
src/Prelude/Alternative.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 111
|
2015-01-05T11:28:15.000Z
|
2022-02-12T23:29:26.000Z
|
src/Prelude/Alternative.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 59
|
2016-02-09T05:36:44.000Z
|
2022-01-14T07:32:36.000Z
|
src/Prelude/Alternative.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 24
|
2015-03-12T18:03:45.000Z
|
2021-04-22T06:10:41.000Z
|
module Prelude.Alternative where
open import Agda.Primitive
open import Prelude.Bool
open import Prelude.Maybe
open import Prelude.List
open import Prelude.Sum
open import Prelude.Decidable
open import Prelude.Functor
open import Prelude.Applicative
open import Prelude.Function
open import Prelude.Monoid
open import Prelude.Variables renaming (ℓ₁ to a; ℓ₂ to b)
module _ (F : Set a → Set b) where
record FunctorZero : Set (lsuc a ⊔ b) where
field
empty : ∀ {A} → F A
overlap {{super}} : Functor F
record Alternative : Set (lsuc a ⊔ b) where
infixl 3 _<|>_
field
_<|>_ : ∀ {A} → F A → F A → F A
overlap {{super}} : FunctorZero
open FunctorZero {{...}} public
open Alternative {{...}} public
{-# DISPLAY FunctorZero.empty _ = empty #-}
{-# DISPLAY Alternative._<|>_ _ x y = x <|> y #-}
instance
FunctorZeroMaybe : FunctorZero (Maybe {a})
empty {{FunctorZeroMaybe}} = nothing
-- Left-biased choice
AlternativeMaybe : Alternative (Maybe {a})
_<|>_ {{AlternativeMaybe}} nothing y = y
_<|>_ {{AlternativeMaybe}} x y = x
FunctorZeroList : FunctorZero (List {a})
empty {{FunctorZeroList}} = []
AlternativeList : Alternative (List {a})
_<|>_ {{AlternativeList}} = _++_
FunctorZeroEither : ⦃ Monoid A ⦄ → FunctorZero (Either {b = a} A)
empty {{FunctorZeroEither}} = left mempty
AlternativeEither : ⦃ Monoid A ⦄ → Alternative (Either {b = a} A)
_<|>_ {{AlternativeEither}} x y = either (const y) right x
module _ ⦃ _ : FunctorZero F ⦄ where
guard! : Bool → F A → F A
guard! true x = x
guard! false _ = empty
guard : (d : Dec A) → (⦃ A ⦄ → F B) → F B
guard (yes p) x = x ⦃ p ⦄
guard (no _) _ = empty
yes! : ⦃ Applicative F ⦄ → (d : Dec A) → F A
yes! (yes p) = pure p
yes! (no _) = empty
module _ ⦃ _ : Alternative F ⦄ where
choice : List (F A) → F A
choice = foldr _<|>_ empty
maybeA : ⦃ Applicative F ⦄ → F A → F (Maybe A)
maybeA x = just <$> x <|> pure nothing
| 25.792208
| 67
| 0.628399
|
4d1fe4041df7e4a585de9400ef0b8d143ecc3376
| 145
|
agda
|
Agda
|
test/interaction/Issue2568.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue2568.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue2568.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
postulate
A : Set
T : A → Set
g : {{a : A}} → Set → T a
test : {{a b : A}} → Set
test {{a}} {{b}} = {!g A!} -- C-u C-u C-c C-d gives T b
| 16.111111
| 55
| 0.406897
|
57c897b5070243d157f710d6e07e241b9de0cbb3
| 5,753
|
agda
|
Agda
|
src/Semantics/Soundness.agda
|
DimaSamoz/temporal-type-systems
|
7d993ba55e502d5ef8707ca216519012121a08dd
|
[
"MIT"
] | 4
|
2018-05-31T20:37:04.000Z
|
2022-01-04T09:33:48.000Z
|
src/Semantics/Soundness.agda
|
DimaSamoz/temporal-type-systems
|
7d993ba55e502d5ef8707ca216519012121a08dd
|
[
"MIT"
] | null | null | null |
src/Semantics/Soundness.agda
|
DimaSamoz/temporal-type-systems
|
7d993ba55e502d5ef8707ca216519012121a08dd
|
[
"MIT"
] | null | null | null |
-- Soundness of term equality
module Semantics.Soundness where
open import Syntax.Types
open import Syntax.Context renaming (_,_ to _,,_)
open import Syntax.Terms
open import Syntax.Equality
open import Syntax.Substitution
open import Semantics.Types
open import Semantics.Context
open import Semantics.Terms
open import Semantics.Substitution
open import Semantics.Bind
open import CategoryTheory.Categories using (ext)
open import CategoryTheory.BCCCs.Cartesian using (Product)
open import CategoryTheory.BCCCs
open import CategoryTheory.Instances.Reactive renaming (top to Top)
open import CategoryTheory.NatTrans
open import CategoryTheory.Monad
open import TemporalOps.Diamond
open import TemporalOps.OtherOps
open import Data.Sum
open import Data.Product using (_,_ ; proj₁ ; proj₂)
open import Relation.Binary.PropositionalEquality as ≡
using (_≡_ ; refl ; sym ; trans ; cong ; cong₂ ; subst)
open ≡.≡-Reasoning
open Monad M-◇
open import Holes.Term using (⌞_⌟)
open import Holes.Cong.Propositional
open ⟦Kit⟧ ⟦𝒯erm⟧
open Kit 𝒯erm
open ⟦K⟧ ⟦𝒯erm⟧
open K 𝒯erm
mutual
-- Soundness of term equality: equal terms have equal denotations
sound : ∀{A Γ} {M₁ M₂ : Γ ⊢ A}
-> Γ ⊢ M₁ ≡ M₂ ∷ A
-> ⟦ M₁ ⟧ₘ ≈ ⟦ M₂ ⟧ₘ
sound (refl M) = refl
sound (Eq.sym eq) = ≡.sym (sound eq)
sound (Eq.trans eq₁ eq₂) = ≡.trans (sound eq₁) (sound eq₂)
sound (β-lam N M) {n} {⟦Γ⟧} rewrite subst-sound M N {n} {⟦Γ⟧} = refl
sound (β-fst M N) = refl
sound (β-snd M N) = refl
sound (β-inl M N₁ N₂) {n} {⟦Γ⟧} rewrite subst-sound M N₁ {n} {⟦Γ⟧} = refl
sound (β-inr M N₁ N₂) {n} {⟦Γ⟧} rewrite subst-sound M N₂ {n} {⟦Γ⟧} = refl
sound (β-sig N M) {n} {⟦Γ⟧} rewrite subst-sound M N {n} {⟦Γ⟧} = refl
sound (η-lam {A} M) {n} {⟦Γ⟧} = ext λ ⟦A⟧ →
cong (λ x → x ⟦A⟧) (≡.sym (⟦𝓌⟧ (A now) M {n} {⟦Γ⟧ , ⟦A⟧}))
sound (η-pair M) = ≡.sym (⊗-η-exp {m = ⟦ M ⟧ₘ})
sound (η-unit M) = refl
sound (η-sum M) {n} {⟦Γ⟧} with ⟦ M ⟧ₘ n ⟦Γ⟧
sound (η-sum M) {n} {a} | inj₁ _ = refl
sound (η-sum M) {n} {a} | inj₂ _ = refl
sound (η-sig M) = refl
sound {Γ = Γ} (η-evt {A} M) {n} {a}
rewrite bind-to->>= Γ (⟦ M ⟧ₘ) (η.at ⟦ A ⟧ₜ ∘ π₂) n a
= ≡.sym (>>=-unit-right (⟦ M ⟧ₘ n a))
sound (cong-pair eq₁ eq₂) {n} {a} rewrite sound eq₁ {n} {a}
| sound eq₂ {n} {a} = refl
sound (cong-fst eq) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-snd eq) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-lam eq) {n} {a} = ext λ ⟦A⟧ → sound eq
sound (cong-app eq₁ eq₂) {n} {a} rewrite sound eq₁ {n} {a}
| sound eq₂ {n} {a} = refl
sound (cong-inl eq) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-inr eq) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-case eq N₁ N₂) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-sig eq) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-letSig eq N) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-sample eq) {n} {a} rewrite sound eq {n} {a} = refl
sound (cong-stable eq) = ext λ k → sound eq
sound (cong-event eq) {n} {a} rewrite sound′ eq {n} {a} = refl
-- Soundness of computational term equality: equal terms have equal denotations
sound′ : ∀{A Γ} {M₁ M₂ : Γ ⊨ A}
-> Γ ⊨ M₁ ≡ M₂ ∷ A
-> ⟦ M₁ ⟧ᵐ ≈ ⟦ M₂ ⟧ᵐ
sound′ (refl M) = refl
sound′ (Eq′.sym eq) = ≡.sym (sound′ eq)
sound′ (Eq′.trans eq₁ eq₂) = ≡.trans (sound′ eq₁) (sound′ eq₂)
sound′ (β-sig′ C M) {n} {⟦Γ⟧} rewrite subst′-sound M C {n} {⟦Γ⟧} = refl
sound′ (β-evt′ C D) {n} {⟦Γ⟧} rewrite subst″-sound D C {n} {⟦Γ⟧} = refl
sound′ {_}{Γ} (β-selectₚ {A}{B}{C} C₁ C₂ C₃ M₁ M₂) {n} {⟦Γ⟧} =
begin
⟦ select event (pure M₁) ↦ C₁ || event (pure M₂) ↦ C₂ ||both↦ C₃ ⟧ᵐ n ⟦Γ⟧
≡⟨⟩
⟦ C₃ ⟧ᵐ n ((⌞ ⟦ Γ ˢ⟧□ n ⟦Γ⟧ n ⌟ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) , ⟦ M₂ ⟧ₘ n ⟦Γ⟧)
≡⟨ cong! (⟦ˢ⟧-factor Γ {n} {⟦Γ⟧}) ⟩
⟦ C₃ ⟧ᵐ n ((⌞ ⟦ Γ ˢ⟧ n ⟦Γ⟧ ⌟ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) , ⟦ M₂ ⟧ₘ n ⟦Γ⟧)
≡⟨ cong! (⟦subst⟧-Γˢ⊆Γ Γ {n} {⟦Γ⟧}) ⟩
⟦ C₃ ⟧ᵐ n (⌞ (⟦subst⟧ (Γˢ⊆Γ Γ ⊆ₛ 𝒯erm) n ⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) ⌟ , ⟦ M₂ ⟧ₘ n ⟦Γ⟧ )
≡⟨ cong! (⟦↑⟧ (A now) (Γˢ⊆Γ Γ ⊆ₛ 𝒯erm) {n} {⟦Γ⟧ , (⟦ M₁ ⟧ₘ n ⟦Γ⟧)}) ⟩
⟦ C₃ ⟧ᵐ n ⌞ ((⟦subst⟧ (_↑_ {A now} (Γˢ⊆Γ Γ ⊆ₛ 𝒯erm) 𝒯erm) n (⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧)) , ⟦ M₂ ⟧ₘ n ⟦Γ⟧) ⌟
≡⟨ cong! (⟦↑⟧ (B now) (_↑_ {A now} (Γˢ⊆Γ Γ ⊆ₛ 𝒯erm) 𝒯erm) {n} {(⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) , (⟦ M₂ ⟧ₘ n ⟦Γ⟧)}) ⟩
⟦ C₃ ⟧ᵐ n (⟦subst⟧ (_↑_ {B now} (_↑_ {A now} (Γˢ⊆Γ Γ ⊆ₛ 𝒯erm) 𝒯erm) 𝒯erm) n ((⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) , ⌞ ⟦ M₂ ⟧ₘ n ⟦Γ⟧ ⌟))
≡⟨ cong! (⟦𝓌⟧ (A now) M₂ {n} {⟦Γ⟧ , (⟦ M₁ ⟧ₘ n ⟦Γ⟧)}) ⟩
⟦ C₃ ⟧ᵐ n (⟦subst⟧ (weakₛ 𝒯ermₛ s) n ((⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) , ⟦ 𝓌 M₂ ⟧ₘ n (⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧)))
≡⟨ ≡.sym (traverse′-sound ⟦𝒯erm⟧ (weakₛ 𝒯ermₛ s) C₃ {n} {(⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) , ⟦ 𝓌 M₂ ⟧ₘ n (⟦Γ⟧ , (⟦ M₁ ⟧ₘ n ⟦Γ⟧))}) ⟩
⟦ traverse′ (weakₛ 𝒯ermₛ s) C₃ ⟧ᵐ n ((⟦Γ⟧ , ⟦ M₁ ⟧ₘ n ⟦Γ⟧) , ⟦ 𝓌 M₂ ⟧ₘ n (⟦Γ⟧ , (⟦ M₁ ⟧ₘ n ⟦Γ⟧)))
≡⟨ ≡.sym (subst′-sound (𝓌 M₂) (weakening′ s C₃) {n} {⟦Γ⟧ , (⟦ M₁ ⟧ₘ n ⟦Γ⟧)}) ⟩
⟦ [ 𝓌 M₂ /′] (weakening′ s C₃) ⟧ᵐ n (⟦Γ⟧ , (⟦ M₁ ⟧ₘ n ⟦Γ⟧))
≡⟨ ≡.sym (subst′-sound M₁ ([ 𝓌 M₂ /′] (weakening′ s C₃)) {n} {⟦Γ⟧} ) ⟩
⟦ [ M₁ /′] ([ 𝓌 M₂ /′] (weakening′ s C₃)) ⟧ᵐ n ⟦Γ⟧
∎
where
s : Γ ˢ ,, A now ,, B now ⊆ Γ ,, A now ,, B now
s = keep (keep (Γˢ⊆Γ Γ))
sound′ (η-sig′ M) = refl
sound′ (cong-pure′ eq) {n} {⟦Γ⟧} rewrite sound eq {n} {⟦Γ⟧} = refl
sound′ (cong-letSig′ eq B) {n} {⟦Γ⟧} rewrite sound eq {n} {⟦Γ⟧} = refl
sound′ (cong-letEvt′ eq D) {n} {⟦Γ⟧} rewrite sound eq {n} {⟦Γ⟧} = refl
| 46.772358
| 132
| 0.505475
|
581330ae02c2543fb855a8bc29ba899dc61d9348
| 1,696
|
agda
|
Agda
|
examples/outdated-and-incorrect/Alonzo/PreludeList.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/outdated-and-incorrect/Alonzo/PreludeList.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/outdated-and-incorrect/Alonzo/PreludeList.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module PreludeList where
open import AlonzoPrelude as Prelude
open import PreludeNat
infixr 50 _::_ _++_
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL [] #-}
{-# BUILTIN CONS _::_ #-}
[_] : {A : Set} -> A -> List A
[ x ] = x :: []
length : {A : Set} -> List A -> Nat
length [] = 0
length (_ :: xs) = 1 + length xs
map : {A B : Set} -> (A -> B) -> List A -> List B
map f [] = []
map f (x :: xs) = f x :: map f xs
_++_ : {A : Set} -> List A -> List A -> List A
[] ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
zipWith : {A B C : Set} -> (A -> B -> C) -> List A -> List B -> List C
zipWith f [] [] = []
zipWith f (x :: xs) (y :: ys) = f x y :: zipWith f xs ys
zipWith f [] (_ :: _) = []
zipWith f (_ :: _) [] = []
foldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B
foldr f z [] = z
foldr f z (x :: xs) = f x (foldr f z xs)
foldl : {A B : Set} -> (B -> A -> B) -> B -> List A -> B
foldl f z [] = z
foldl f z (x :: xs) = foldl f (f z x) xs
replicate : {A : Set} -> Nat -> A -> List A
replicate zero x = []
replicate (suc n) x = x :: replicate n x
iterate : {A : Set} -> Nat -> (A -> A) -> A -> List A
iterate zero f x = []
iterate (suc n) f x = x :: iterate n f (f x)
splitAt : {A : Set} -> Nat -> List A -> List A × List A
splitAt zero xs = < [] , xs >
splitAt (suc n) [] = < [] , [] >
splitAt (suc n) (x :: xs) = add x $ splitAt n xs
where
add : _ -> List _ × List _ -> List _ × List _
add x < ys , zs > = < x :: ys , zs >
reverse : {A : Set} -> List A -> List A
reverse xs = foldl (flip _::_) [] xs
| 25.69697
| 70
| 0.45283
|
410637d378dd66d4a359a8dbe0ca52cea87ba5e1
| 2,640
|
agda
|
Agda
|
src/Tactic/Nat/Generic.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 111
|
2015-01-05T11:28:15.000Z
|
2022-02-12T23:29:26.000Z
|
src/Tactic/Nat/Generic.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 59
|
2016-02-09T05:36:44.000Z
|
2022-01-14T07:32:36.000Z
|
src/Tactic/Nat/Generic.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 24
|
2015-03-12T18:03:45.000Z
|
2021-04-22T06:10:41.000Z
|
open import Agda.Builtin.Reflection using (Name)
-- See Tactic.Nat for a description of the various tactics.
module Tactic.Nat.Generic (`≤ `toLeq `fromLeq : Name) where
open import Prelude
open import Tactic.Reflection
open import Tactic.Nat.Induction using (nat-induction)
open import Tactic.Nat.Subtract using (autosub-tactic; by-tactic; refutesub-tactic; simplifygoal-tactic; simplifysub-tactic)
private
a→0 : Type → Term
a→0 (def op _) = ifYes op == `≤ then def₀ `toLeq else def₀ (quote id)
a→0 _ = def₀ (quote id) -- TODO perhaps return unknown?
0→a : Type → Term
0→a (def op _) = ifYes op == `≤ then def₀ `fromLeq else def₀ (quote id)
0→a _ = def₀ (quote id) -- TODO perhaps return unknown?
applyTactic : (Type → TC Term) → Term → TC ⊤
applyTactic tac hole = do
goal ← inferType hole
unify hole ∘ (0→a goal `$_) =<< tac =<< inferNormalisedType (a→0 goal `$ hole)
macro
auto : Tactic
auto hole = applyTactic autosub-tactic hole
by : Term → Tactic
by prf hole = do
Prf ← inferNormalisedType prf
applyTactic (by-tactic (a→0 Prf `$ prf)) hole
refute : Term → Tactic
refute prf hole = do
Prf ← inferNormalisedType prf
unify hole =<< refutesub-tactic (a→0 Prf `$ prf)
simplify-goal : Tactic
simplify-goal hole = do
goal ← inferFunRange hole
s-goal₀ ← simplifygoal-tactic =<< inferFunRange (a→0 goal `∘ hole)
hole =′ 0→a goal `∘ s-goal₀ `∘ a→0 goal
simplify : Term → Tactic
simplify prf hole = do
goal ← inferFunRange hole
Prf ← inferNormalisedType prf
s-goal₀ ← simplifysub-tactic (a→0 Prf `$ prf) =<< inferFunRange (a→0 goal `∘ hole)
hole =′ (`λ $ 0→a goal `$ weaken 1 s-goal₀ `$ `λ $ a→0 goal `$ var₁ 1 (0→a Prf `$ var₀ 0))
induction : Tactic
induction hole = do
pi _ (abs _ goal) ← inferNormalisedType hole
where meta x _ → blockOnMeta x
_ → typeErrorS "Induction tactic must be applied to a function goal"
hole₀ ← (a→0 goal `∘ hole) :′ unknown
pi a b ← inferNormalisedType hole₀
where meta x _ → blockOnMeta x
_ → typeErrorS "Induction tactic must be applied to a function goal"
let P = lam visible b
inStepCxt : {A : Set} → TC A → TC A
inStepCxt {_} = λ′ (vArg (quoteTerm Nat)) ∘
λ′ (vArg unknown)
base ← unknown :′ unknown
step ← inStepCxt $ unknown :′ unknown
hole =′ 0→a goal `∘ def₃ (quote nat-induction)
P base (`λ $ `λ step)
unify base =<< autosub-tactic =<< inferNormalisedType base
inStepCxt (unify step =<< by-tactic (var₀ 0) =<< inferNormalisedType step)
| 36.164384
| 124
| 0.63447
|
043ec2ef579250c549da632cc6386d4815276228
| 2,007
|
agda
|
Agda
|
Thesis/ANormal.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 10
|
2015-03-04T06:09:20.000Z
|
2019-07-19T07:06:59.000Z
|
Thesis/ANormal.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 6
|
2015-07-01T18:09:31.000Z
|
2017-05-04T13:53:59.000Z
|
Thesis/ANormal.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 1
|
2016-02-18T12:26:44.000Z
|
2016-02-18T12:26:44.000Z
|
--
-- Formalize correctness of differentiation for the source calculus in the
-- static caching paper (typed version).
--
module Thesis.ANormal where
open import Thesis.Types public
open import Thesis.Contexts public
open import Relation.Binary.PropositionalEquality
data Term (Γ : Context) (τ : Type) : Set where
var : (x : Var Γ τ) →
Term Γ τ
lett : ∀ {σ τ₁} → (f : Var Γ (σ ⇒ τ₁)) → (x : Var Γ σ) → Term (τ₁ • Γ) τ → Term Γ τ
-- Also represent top-level definitions, so that we can somehow create functions
-- via syntax. Made up on the moment.
-- WARNING: this allows nested lambdas. That's more powerful than allowing only
-- closures whose bodies can't contain lambdas, like in the paper.
data Fun (Γ : Context) : (τ : Type) → Set where
term : ∀ {τ} → Term Γ τ → Fun Γ τ
abs : ∀ {σ τ} → Fun (σ • Γ) τ → Fun Γ (σ ⇒ τ)
-- Indeed, caching doesn't work there with Fun. It works on FunR. Eventually
-- should adapt definitions to FunR.
data FunR (Γ : Context) : (τ : Type) → Set where
cabsterm : ∀ {σ τ} → Term (σ • Γ) τ → FunR Γ (σ ⇒ τ)
open import Thesis.Environments public
⟦_⟧Term : ∀ {Γ τ} → Term Γ τ → ⟦ Γ ⟧Context → ⟦ τ ⟧Type
⟦ var x ⟧Term ρ = ⟦ x ⟧Var ρ
⟦ lett f x t ⟧Term ρ = ⟦ t ⟧Term (⟦ f ⟧Var ρ (⟦ x ⟧Var ρ) • ρ)
⟦_⟧Fun : ∀ {Γ τ} → Fun Γ τ → ⟦ Γ ⟧Context → ⟦ τ ⟧Type
⟦ term t ⟧Fun ρ = ⟦ t ⟧Term ρ
⟦ abs f ⟧Fun ρ = λ v → ⟦ f ⟧Fun (v • ρ)
-- Next steps:
-- 1. Add a functional big-step semantics for this language: DONE.
-- 2. Prove it sound wrt. the denotational semantics: DONE.
-- 3. Add an erasure to a uni-typed language. DONE.
-- 4. Redo 1 with an *untyped* functional big-step semantics.
-- 5. Prove that evaluation and erasure commute:
-- -- erasure-commute-term : ∀ {Γ τ} (t : T.Term Γ τ) ρ n →
-- -- erase-errVal (T.eval-term t ρ n) ≡ eval-term (erase-term t) (erase-env ρ) n
-- 6. Define new caching transformation into untyped language.
--
-- 7. Prove the new transformation correct in the untyped language, by reusing
-- evaluation on the source language.
| 37.166667
| 85
| 0.648729
|
58e504278fda38ee0c85284347bda12876ae4870
| 2,827
|
agda
|
Agda
|
nicolai/anonymousExistence/Sec6populatedness.agda
|
nicolaikraus/HoTT-Agda
|
939a2d83e090fcc924f69f7dfa5b65b3b79fe633
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
nicolai/anonymousExistence/Sec6populatedness.agda
|
nicolaikraus/HoTT-Agda
|
939a2d83e090fcc924f69f7dfa5b65b3b79fe633
|
[
"MIT"
] | null | null | null |
nicolai/anonymousExistence/Sec6populatedness.agda
|
nicolaikraus/HoTT-Agda
|
939a2d83e090fcc924f69f7dfa5b65b3b79fe633
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import library.Basics hiding (Type ; Σ)
open import library.types.Sigma
open import Sec2preliminaries
open import Sec3hedberg
open import Sec4hasConstToSplit
-- In this section, we require function extensionality again.
module Sec6populatedness where
-- Definition 6.1
Pop : Type → Type
Pop X = (f : X → X) → const f → fix f
-- Theorem 6.2
Trunc→Pop : {X : Type} → Trunc X → Pop X
Trunc→Pop z f c = rec {P = fix f} (fixed-point f c) (to-fix f c) z
-- Lemma 6.3
module _ {X : Type} where
pop→splitSup→X : Pop X → splitSup X → X
pop→splitSup→X pop sps = fst (pop (fst fc) (snd fc)) where
fc = (snd hasConst↔splitSup sps)
use-funct : (splitSup X → X) → Trunc (splitSup X) → Trunc X
use-funct f = trunc-functorial f
tr-hst-X→pop : (Trunc (splitSup X) → Trunc X) → Pop X
tr-hst-X→pop g f c = rec (fixed-point f c) (to-fix f c) (g ∣ hasConst→splitSup (f , c) ∣)
-- we formulate the two logical equivalence that we will need explicitly:
pop-alt : Pop X ↔ (Trunc (splitSup X) → Trunc X)
pop-alt = use-funct ∘ pop→splitSup→X , tr-hst-X→pop
pop-alt' : Pop X ↔ (splitSup X → X)
pop-alt' = pop→splitSup→X , tr-hst-X→pop ∘ use-funct
-- Theorem 6.4
pop-alt₂ : {X : Type} → Pop X ↔₀₁ ((P : Type) → (is-prop P) → (X ↔ P) → P)
pop-alt₂ {X} = one , two where
one : Pop X → (P : Type) → is-prop P → (X ↔ P) → P
one pop P pp (xp , px) = xp (fst (pop f c)) where
f : X → X
f = px ∘ xp
c : const f
c x₁ x₂ = ap px (prop-has-all-paths pp _ _)
two : ((P : Type) → is-prop P → (X ↔ P) → P) → Pop X
two rest f c = rest (fix f) (fixed-point f c) (to-fix f c , from-fix f)
-- Theorem 6.5
pop-property₁ : {X : Type} → X → Pop X
pop-property₁ = Trunc→Pop ∘ ∣_∣
-- this (and the following results of this section) needs function extensionality
open import library.types.Pi
pop-property₂ : {X : Type} → is-prop (Pop X)
pop-property₂ = Π-is-prop (λ f → Π-is-prop (λ c → fixed-point f c))
-- Theorem 6.6
hasConst↔PopX→X : {X : Type} → (hasConst X) ↔ (Pop X → X)
hasConst↔PopX→X {X} = hasConst→PopX→X , rev where
hasConst→PopX→X : hasConst X → Pop X → X
hasConst→PopX→X (f , c) pop = fst (pop f c)
rev : (Pop X → X) → hasConst X
rev pp = (pp ∘ pop-property₁) ,
(λ x₁ x₂ → ap pp (prop-has-all-paths pop-property₂ _ _))
-- Theorem 6.6, second part
prop→hasConst×PopX→X : {X : Type} → (is-prop X) → (hasConst X) × (Pop X → X)
prop→hasConst×PopX→X p = fc , fst hasConst↔PopX→X fc where
fc = idf _ , prop-has-all-paths p
-- Theorem 6.7
pop-idem : {X : Type} → (Pop (Pop X)) ≃ (Pop X)
pop-idem {X} = equiv f g auto₁ auto₂ where
f = snd (prop→hasConst×PopX→X pop-property₂)
g = pop-property₁
auto₁ = λ _ → prop-has-all-paths pop-property₂ _ _
auto₂ = λ _ → prop-has-all-paths pop-property₂ _ _
| 28.555556
| 92
| 0.60948
|
411cf7569540e96b36c436296959e52205fd6b95
| 1,855
|
agda
|
Agda
|
core/lib/groups/Unit.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
core/lib/groups/Unit.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
core/lib/groups/Unit.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 lib.Basics
open import lib.types.Group
open import lib.types.Unit
open import lib.groups.SubgroupProp
open import lib.groups.Homomorphism
open import lib.groups.Isomorphism
open import lib.groups.Lift
module lib.groups.Unit where
Unit-group-structure : GroupStructure Unit
Unit-group-structure = record
{ ident = unit
; inv = λ _ → unit
; comp = λ _ _ → unit
; unit-l = λ _ → idp
; assoc = λ _ _ _ → idp
; inv-l = λ _ → idp
}
Unit-group : Group lzero
Unit-group = group _ Unit-is-set Unit-group-structure
0ᴳ = Unit-group
abstract
Unit-group-is-trivial : is-trivialᴳ Unit-group
Unit-group-is-trivial = λ _ → idp
iso-Unit-is-trivial : ∀ {i} {G : Group i} → G ≃ᴳ Unit-group → is-trivialᴳ G
iso-Unit-is-trivial G-iso-0 = iso-preserves'-trivial G-iso-0 Unit-group-is-trivial
0ᴳ-is-trivial = Unit-group-is-trivial
iso-0ᴳ-is-trivial = iso-Unit-is-trivial
trivial-iso-Unit : ∀ {i} {G : Group i} → is-trivialᴳ G → G ≃ᴳ Unit-group
trivial-iso-Unit {G = G} G-triv = group-hom (λ _ → tt) (λ _ _ → idp) ,
is-eq _ (λ _ → Group.ident G) (λ _ → idp) (λ _ → ! (G-triv _))
trivial-iso-0ᴳ = trivial-iso-Unit
{- the following should be replaced by [is-trivial] completely -}
abstract
contr-iso-Unit : ∀ {i} (G : Group i) → is-contr (Group.El G) → G ≃ᴳ Unit-group
contr-iso-Unit G pA = ≃-to-≃ᴳ (contr-equiv-Unit pA) (λ _ _ → idp)
contr-iso-0ᴳ = contr-iso-Unit
Unit-group-is-abelian : is-abelian 0ᴳ
Unit-group-is-abelian _ _ = idp
0ᴳ-is-abelian = Unit-group-is-abelian
Unit-abgroup : AbGroup₀
Unit-abgroup = Unit-group , Unit-group-is-abelian
0ᴳ-abgroup = Unit-abgroup
abstract
hom₁-Unit-is-trivial : ∀ {i} (G : AbGroup i) → is-trivialᴳ (hom-group Unit-group G)
hom₁-Unit-is-trivial G φ = group-hom= $ λ= λ _ → GroupHom.pres-ident φ
hom₁-0ᴳ-is-trivial = hom₁-Unit-is-trivial
| 28.106061
| 85
| 0.679784
|
29777d5862ca3b41952909c2a7f1d6048660dd7f
| 1,691
|
agda
|
Agda
|
test/succeed/InductiveAndCoinductiveConstructors.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | null | null | null |
test/succeed/InductiveAndCoinductiveConstructors.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | null | null | null |
test/succeed/InductiveAndCoinductiveConstructors.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | null | null | null |
module InductiveAndCoinductiveConstructors where
open import Common.Coinduction
record ⊤ : Set where
data _×_ (A : Set) (B : Set) : Set where
_,_ : (x : A) (y : B) → A × B
data Stream (A : Set) : Set where
_≺_ : (x : A) (xs : ∞ (Stream A)) → Stream A
data U : Set where
stream : (a : U) → U
_⊗_ : (a b : U) → U
unit : U
El : U → Set
El (stream a) = Stream (El a)
El (a ⊗ b) = El a × El b
El unit = ⊤
mutual
data WHNF : U → Set where
_≺_ : ∀ {a} → El a → Prog (stream a) → WHNF (stream a)
_,_ : ∀ {a b} → WHNF a → WHNF b → WHNF (a ⊗ b)
data Prog : U → Set where
↓_ : ∀ {a} → ∞ (WHNF a) → Prog a
fst : ∀ {a b} → Prog (a ⊗ b) → Prog a
snd : ∀ {a b} → Prog (a ⊗ b) → Prog b
lab : Prog (stream unit) → Prog (stream (stream unit)) →
Prog (stream unit ⊗ stream (stream unit))
whnf : ∀ {a} → Prog a → WHNF a
whnf (↓ w) = ♭ w
whnf (fst p) with whnf p
... | (x , y) = x
whnf (snd p) with whnf p
... | (x , y) = y
whnf (lab xs lss) with whnf xs | whnf lss
... | _ ≺ xs′ | (x ≺ ls) ≺ lss′ =
((_ ≺ fst (lab xs′ lss′)) , (♭ ls ≺ snd (lab xs′ lss′)))
⟦_⟧ : Prog (stream unit) → Stream ⊤
⟦ p ⟧ with whnf p
... | x ≺ xs = x ≺ ♯ ⟦ xs ⟧
data _≈_ : Stream ⊤ → Stream ⊤ → Set where
cons : ∀ {xs xs′} → ∞ ((♭ xs) ≈ (♭ xs′)) → (_ ≺ xs) ≈ (_ ≺ xs′)
lemma : ∀ xs lss → ⟦ fst (lab xs lss) ⟧ ≈ ⟦ xs ⟧
lemma xs lss with whnf xs | whnf lss
... | _ ≺ xs′ | (x ≺ ls) ≺ lss′ = cons (♯ lemma xs′ lss′)
label : Prog (stream unit) → Stream ⊤ →
Prog (stream unit ⊗ stream (stream unit))
label xs ls = lab xs (↓ (♯ (ls ≺ snd (label xs ls))))
shape-preserved : ∀ xs ls → ⟦ fst (label xs ls) ⟧ ≈ ⟦ xs ⟧
shape-preserved xs ls = lemma xs _
| 26.84127
| 65
| 0.502661
|
addb5966595eccdd731366a133da6f87768d8f36
| 4,999
|
agda
|
Agda
|
Cubical/Data/Queue/Truncated2List.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Data/Queue/Truncated2List.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Data/Queue/Truncated2List.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --no-exact-split --safe #-}
module Cubical.Data.Queue.Truncated2List 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.HLevels
open import Cubical.Foundations.SIP
open import Cubical.Structures.Queue
open import Cubical.Data.Maybe
open import Cubical.Data.List
open import Cubical.Data.Sigma
open import Cubical.Data.Queue.1List
module Truncated2List {ℓ} (A : Type ℓ) (Aset : isSet A) where
open Queues-on A Aset
data Q : Type ℓ where
Q⟨_,_⟩ : (xs ys : List A) → Q
tilt : ∀ xs ys z → Q⟨ xs ++ [ z ] , ys ⟩ ≡ Q⟨ xs , ys ++ [ z ] ⟩
trunc : (q q' : Q) (α β : q ≡ q') → α ≡ β
multitilt : (xs ys zs : List A) → Q⟨ xs ++ rev zs , ys ⟩ ≡ Q⟨ xs , ys ++ zs ⟩
multitilt xs ys [] = cong₂ Q⟨_,_⟩ (++-unit-r xs) (sym (++-unit-r ys))
multitilt xs ys (z ∷ zs) =
cong (λ ws → Q⟨ ws , ys ⟩) (sym (++-assoc xs (rev zs) [ z ]))
∙ tilt (xs ++ rev zs) ys z
∙ multitilt xs (ys ++ [ z ]) zs
∙ cong (λ ws → Q⟨ xs , ws ⟩) (++-assoc ys [ z ] zs)
-- enq into the first list, deq from the second if possible
emp : Q
emp = Q⟨ [] , [] ⟩
enq : A → Q → Q
enq a Q⟨ xs , ys ⟩ = Q⟨ a ∷ xs , ys ⟩
enq a (tilt xs ys z i) = tilt (a ∷ xs) ys z i
enq a (trunc q q' α β i j) =
trunc _ _ (cong (enq a) α) (cong (enq a) β) i j
deqFlush : List A → Maybe (Q × A)
deqFlush [] = nothing
deqFlush (x ∷ xs) = just (Q⟨ [] , xs ⟩ , x)
deq : Q → Maybe (Q × A)
deq Q⟨ xs , [] ⟩ = deqFlush (rev xs)
deq Q⟨ xs , y ∷ ys ⟩ = just (Q⟨ xs , ys ⟩ , y)
deq (tilt xs [] z i) = path i
where
path : deqFlush (rev (xs ++ [ z ])) ≡ just (Q⟨ xs , [] ⟩ , z)
path =
cong deqFlush (rev-++ xs [ z ])
∙ cong (λ q → just (q , z)) (sym (multitilt [] [] (rev xs)))
∙ cong (λ ys → just (Q⟨ ys , [] ⟩ , z)) (rev-rev xs)
deq (tilt xs (y ∷ ys) z i) = just (tilt xs ys z i , y)
deq (trunc q q' α β i j) =
isOfHLevelMaybe 0
(isSetΣ trunc λ _ → Aset)
(deq q) (deq q') (cong deq α) (cong deq β)
i j
Raw : RawQueue
Raw = (Q , emp , enq , deq)
-- We construct an equivalence to 1Lists and prove this is an equivalence of queue structures
private
module One = 1List A Aset
open One renaming (Q to Q₁; emp to emp₁; enq to enq₁; deq to deq₁) using ()
quot : Q₁ → Q
quot xs = Q⟨ xs , [] ⟩
eval : Q → Q₁
eval Q⟨ xs , ys ⟩ = xs ++ rev ys
eval (tilt xs ys z i) = path i
where
path : (xs ++ [ z ]) ++ rev ys ≡ xs ++ rev (ys ++ [ z ])
path =
++-assoc xs [ z ] (rev ys)
∙ cong (_++_ xs) (sym (rev-++ ys [ z ]))
eval (trunc q q' α β i j) = -- truncated case
isOfHLevelList 0 Aset (eval q) (eval q') (cong eval α) (cong eval β) i j
quot∘eval : ∀ q → quot (eval q) ≡ q
quot∘eval Q⟨ xs , ys ⟩ = multitilt xs [] ys
quot∘eval (tilt xs ys z i) = -- truncated case
isOfHLevelPathP'
{A = λ i → quot (eval (tilt xs ys z i)) ≡ tilt xs ys z i}
0
(trunc _ _)
(multitilt (xs ++ [ z ]) [] ys) (multitilt xs [] (ys ++ [ z ]))
.fst i
quot∘eval (trunc q q' α β i j) = -- truncated case
isOfHLevelPathP'
{A = λ i →
PathP (λ j → quot (eval (trunc q q' α β i j)) ≡ trunc q q' α β i j)
(quot∘eval q) (quot∘eval q')}
0
(isOfHLevelPathP' 1 (isOfHLevelSuc 2 trunc _ _) _ _)
(cong quot∘eval α) (cong quot∘eval β)
.fst i j
eval∘quot : ∀ xs → eval (quot xs) ≡ xs
eval∘quot = ++-unit-r
-- We get our desired equivalence
quotEquiv : Q₁ ≃ Q
quotEquiv = isoToEquiv (iso quot eval quot∘eval eval∘quot)
-- Now it only remains to prove that this is an equivalence of queue structures
quot∘emp : quot emp₁ ≡ emp
quot∘emp = refl
quot∘enq : ∀ x xs → quot (enq₁ x xs) ≡ enq x (quot xs)
quot∘enq x xs = refl
quot∘deq : ∀ xs → deqMap quot (deq₁ xs) ≡ deq (quot xs)
quot∘deq [] = refl
quot∘deq (x ∷ []) = refl
quot∘deq (x ∷ x' ∷ xs) =
deqMap-∘ quot (enq₁ x) (deq₁ (x' ∷ xs))
∙ sym (deqMap-∘ (enq x) quot (deq₁ (x' ∷ xs)))
∙ cong (deqMap (enq x)) (quot∘deq (x' ∷ xs))
∙ lemma x x' (rev xs)
where
lemma : ∀ x x' ys
→ deqMap (enq x) (deqFlush (ys ++ [ x' ]))
≡ deqFlush ((ys ++ [ x' ]) ++ [ x ])
lemma x x' [] i = just (tilt [] [] x i , x')
lemma x x' (y ∷ ys) i = just (tilt [] (ys ++ [ x' ]) x i , y)
quotEquivHasQueueEquivStr : RawQueueEquivStr One.Raw Raw quotEquiv
quotEquivHasQueueEquivStr = quot∘emp , quot∘enq , quot∘deq
-- And we get a path between the raw 1Lists and 2Lists
Raw-1≡2 : One.Raw ≡ Raw
Raw-1≡2 = sip rawQueueUnivalentStr _ _ (quotEquiv , quotEquivHasQueueEquivStr)
-- We derive the axioms for 2List from those for 1List
WithLaws : Queue
WithLaws = Q , str Raw , subst (uncurry QueueAxioms) Raw-1≡2 (snd (str One.WithLaws))
WithLaws-1≡2 : One.WithLaws ≡ WithLaws
WithLaws-1≡2 = sip queueUnivalentStr _ _ (quotEquiv , quotEquivHasQueueEquivStr)
Finite : FiniteQueue
Finite = Q , str WithLaws , subst (uncurry FiniteQueueAxioms) WithLaws-1≡2 (snd (str One.Finite))
| 32.251613
| 98
| 0.580716
|
2fe41ef30669dae674d6bfd3d3d4a8cdbcd106dc
| 159
|
agda
|
Agda
|
test/Succeed/Issue1063.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1063.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1063.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module _ where
module M (A : _) where
y = Set -- type of A is solved if this is removed
x : Set
x = A
-- WAS: yellow on type of A
-- SHOULD: succeed
| 13.25
| 51
| 0.610063
|
226f251f09e8a1094a8c23b3bcaef9730def83f9
| 342
|
agda
|
Agda
|
Cubical/HITs/PropositionalTruncation/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/HITs/PropositionalTruncation/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/HITs/PropositionalTruncation/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-
This file contains:
- Definition of propositional truncation
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.PropositionalTruncation.Base where
open import Cubical.Core.Primitives
-- Propositional truncation as a higher inductive type:
data ∥_∥₁ {ℓ} (A : Type ℓ) : Type ℓ where
∣_∣₁ : A → ∥ A ∥₁
squash₁ : ∀ (x y : ∥ A ∥₁) → x ≡ y
| 19
| 55
| 0.666667
|
131077dae4906b4b50aafba7e7a6947c472311a8
| 1,678
|
agda
|
Agda
|
examples/outdated-and-incorrect/AIM6/Cat/lib/Data/List.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/List.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/List.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Data.List where
import Prelude
import Data.Nat
import Data.Tuple
open Prelude
open Data.Nat
open Data.Tuple
infixr 50 _::_ _++_
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL [] #-}
{-# BUILTIN CONS _::_ #-}
length : {A : Set} -> List A -> Nat
length [] = 0
length (_ :: xs) = 1 + length xs
map : {A B : Set} -> (A -> B) -> List A -> List B
map f [] = []
map f (x :: xs) = f x :: map f xs
_++_ : {A : Set} -> List A -> List A -> List A
[] ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
zipWith : {A B C : Set} -> (A -> B -> C) -> List A -> List B -> List C
zipWith f [] [] = []
zipWith f (x :: xs) (y :: ys) = f x y :: zipWith f xs ys
zipWith f [] (_ :: _) = []
zipWith f (_ :: _) [] = []
foldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B
foldr f z [] = z
foldr f z (x :: xs) = f x (foldr f z xs)
foldl : {A B : Set} -> (B -> A -> B) -> B -> List A -> B
foldl f z [] = z
foldl f z (x :: xs) = foldl f (f z x) xs
replicate : {A : Set} -> Nat -> A -> List A
replicate zero x = []
replicate (suc n) x = x :: replicate n x
iterate : {A : Set} -> Nat -> (A -> A) -> A -> List A
iterate zero f x = []
iterate (suc n) f x = x :: iterate n f (f x)
splitAt : {A : Set} -> Nat -> List A -> List A × List A
splitAt zero xs = < [] , xs >
splitAt (suc n) [] = < [] , [] >
splitAt (suc n) (x :: xs) = add x $ splitAt n xs
where
add : _ -> List _ × List _ -> List _ × List _
add x < ys , zs > = < x :: ys , zs >
reverse : {A : Set} -> List A -> List A
reverse xs = foldl (flip _::_) [] xs
| 25.044776
| 70
| 0.462455
|
4125cdf9cc7e223ba287d6624518bca0d4a2ae3f
| 102
|
agda
|
Agda
|
test/Succeed/Issue1425.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1425.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1425.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
postulate
A B : Set
C : .{{_ : B}} → Set
instance
f : {{_ : A}} → B
test : {{x : A}} → C
| 12.75
| 22
| 0.382353
|
ad35e96a9f32585f8fd28f745ac78388f461c4a3
| 348
|
agda
|
Agda
|
test/Succeed/Issue2117.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2117.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2117.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-07-27, issue #2117 reported by Guillermo Calderon
-- {-# OPTIONS -v tc:10 #-}
record R : Set₁ where
field
A : Set
open R {{...}}
record S (r : R) : Set where
instance i = r
field f : A
-- ERROR WAS:
-- No instance of type R was found in scope.
-- when checking that the expression A has type Set
-- Should succeed!
| 17.4
| 66
| 0.632184
|
0e7a6508d1b828ff2ec9567a252c090c79c232dd
| 6,275
|
agda
|
Agda
|
Thesis/Derive.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 10
|
2015-03-04T06:09:20.000Z
|
2019-07-19T07:06:59.000Z
|
Thesis/Derive.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 6
|
2015-07-01T18:09:31.000Z
|
2017-05-04T13:53:59.000Z
|
Thesis/Derive.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 1
|
2016-02-18T12:26:44.000Z
|
2016-02-18T12:26:44.000Z
|
module Thesis.Derive where
open import Thesis.Lang
open import Thesis.Changes
open import Thesis.LangChanges
open import Thesis.LangOps
open import Relation.Binary.PropositionalEquality
Γ≼ΔΓ : ∀ {Γ} → Γ ≼ ΔΓ Γ
Γ≼ΔΓ {∅} = ∅
Γ≼ΔΓ {τ • Γ} = drop Δt τ • keep τ • Γ≼ΔΓ
fit : ∀ {τ Γ} → Term Γ τ → Term (ΔΓ Γ) τ
fit = weaken Γ≼ΔΓ
⟦Γ≼ΔΓ⟧ : ∀ {Γ ρ1 ρ2 dρ} → (dρρ : [ Γ ]Γ dρ from ρ1 to ρ2) →
ρ1 ≡ ⟦ Γ≼ΔΓ ⟧≼ dρ
⟦Γ≼ΔΓ⟧ v∅ = refl
⟦Γ≼ΔΓ⟧ (dvv v• dρρ) = cong₂ _•_ refl (⟦Γ≼ΔΓ⟧ dρρ)
fit-sound : ∀ {Γ τ} → (t : Term Γ τ) →
∀ {dρ ρ1 ρ2} → [ Γ ]Γ dρ from ρ1 to ρ2 →
⟦ t ⟧Term ρ1 ≡ ⟦ fit t ⟧Term dρ
fit-sound t dρρ = trans
(cong ⟦ t ⟧Term (⟦Γ≼ΔΓ⟧ dρρ))
(sym (weaken-sound t _))
deriveConst : ∀ {τ} →
Const τ →
Term ∅ (Δt τ)
deriveConst unit = const unit
deriveConst (lit n) = const (lit (+ 0))
deriveConst plus = abs (abs (abs (abs (app₂ (const plus) (var (that (that this))) (var this)))))
-- minus = λ m n → m - n
-- dminus = λ m dm n dn → (m + dm) - (n + dn) - (m - n) = dm - dn
deriveConst minus = abs (abs (abs (abs (app₂ (const minus) (var (that (that this))) (var this)))))
deriveConst cons = abs (abs (abs (abs (app (app (const cons) (var (that (that this)))) (var this)))))
deriveConst fst = abs (abs (app (const fst) (var this)))
deriveConst snd = abs (abs (app (const snd) (var this)))
deriveConst linj = abs (abs (app (const linj) (app (const linj) (var this))))
deriveConst rinj = abs (abs (app (const linj) (app (const rinj) (var this))))
deriveConst (match {t1} {t2} {t3}) =
-- λ s ds f df g dg →
abs (abs (abs (abs (abs (abs
-- match ds
(app₃ (const match) (var (that (that (that (that this)))))
-- λ ds₁ → match ds₁
(abs (app₃ (const match) (var this)
-- case inj₁ da → absV 1 (λ da → match s
(abs (app₃ (const match) (var (that (that (that (that (that (that (that this))))))))
-- λ a → app₂ df a da
(abs (app₂ (var (that (that (that (that (that this)))))) (var this) (var (that this))))
-- absurd: λ b → dg b (nil b)
(abs (app₂ (var (that (that (that this)))) (var this) (app (onilτo t2) (var this))))))
-- case inj₂ db → absV 1 (λ db → match s
(abs (app₃ (const match) (var (that (that (that (that (that (that (that this))))))))
-- absurd: λ a → df a (nil a)
(abs (app₂ (var (that (that (that (that (that this)))))) (var this) (app (onilτo t1) (var this))))
-- λ b → app₂ dg b db
(abs (app₂ (var (that (that (that this)))) (var this) (var (that this))))))))
-- recomputation branch:
-- λ s2 → ominus (match s2 (f ⊕ df) (g ⊕ dg)) (match s f g)
(abs (app₂ (ominusτo t3)
-- (match s2 (f ⊕ df) (g ⊕ dg))
(app₃ (const match)
(var this)
(app₂ (oplusτo (t1 ⇒ t3))
(var (that (that (that (that this)))))
(var (that (that (that this)))))
(app₂ (oplusτo (t2 ⇒ t3))
(var (that (that this)))
(var (that this))))
-- (match s f g)
(app₃ (const match)
(var (that (that (that (that (that (that this)))))))
(var (that (that (that (that this)))))
(var (that (that this))))))))))))
{-
derive (λ s f g → match s f g) =
λ s ds f df g dg →
case ds of
ch1 da →
case s of
inj1 a → df a da
inj2 b → {- absurd -} dg b (nil b)
ch2 db →
case s of
inj2 b → dg b db
inj1 a → {- absurd -} df a (nil a)
rp s2 →
match (f ⊕ df) (g ⊕ dg) s2 ⊝
match f g s
-}
derive-var : ∀ {Γ τ} → Var Γ τ → Var (ΔΓ Γ) (Δt τ)
derive-var this = this
derive-var (that x) = that (that (derive-var x))
derive : ∀ {Γ τ} → Term Γ τ → Term (ΔΓ Γ) (Δt τ)
derive (const c) = weaken (∅≼Γ {ΔΓ _}) (deriveConst c)
derive (var x) = var (derive-var x)
derive (app s t) = app (app (derive s) (fit t)) (derive t)
derive (abs t) = abs (abs (derive t))
⟦_⟧ΔVar : ∀ {Γ τ} → (x : Var Γ τ) → (ρ : ⟦ Γ ⟧Context) (dρ : ChΓ Γ) → Chτ τ
⟦ x ⟧ΔVar ρ dρ = ⟦ derive-var x ⟧Var dρ
⟦_⟧ΔTerm : ∀ {Γ τ} → (t : Term Γ τ) → (ρ : ⟦ Γ ⟧Context) (dρ : ChΓ Γ) → Chτ τ
⟦ t ⟧ΔTerm ρ dρ = ⟦ derive t ⟧Term dρ
⟦_⟧ΔConst : ∀ {τ} (c : Const τ) → Chτ τ
⟦ c ⟧ΔConst = ⟦ deriveConst c ⟧Term ∅
⟦_⟧ΔConst-rewrite : ∀ {τ Γ} (c : Const τ) (ρ : ⟦ Γ ⟧Context) dρ → ⟦_⟧ΔTerm (const c) ρ dρ ≡ ⟦ c ⟧ΔConst
⟦ c ⟧ΔConst-rewrite ρ dρ rewrite weaken-sound {Γ₁≼Γ₂ = ∅≼Γ} (deriveConst c) dρ | ⟦∅≼Γ⟧-∅ dρ = refl
module _ {t1 t2 t3 : Type}
(f : ⟦ t1 ⟧Type → ⟦ t3 ⟧Type)
(df : Chτ (t1 ⇒ t3))
(g : ⟦ t2 ⟧Type → ⟦ t3 ⟧Type)
(dg : Chτ (t2 ⇒ t3))
where
private
Γ : Context
Γ = sum t1 t2 •
(t2 ⇒ Δt t2 ⇒ Δt t3) •
(t2 ⇒ t3) •
(t1 ⇒ Δt t1 ⇒ Δt t3) •
(t1 ⇒ t3) •
sum (sum (Δt t1) (Δt t2)) (sum t1 t2) •
sum t1 t2 • ∅
module _ where
private
Γ′ Γ′′ : Context
Γ′ = t2 • (t2 ⇒ Δt t2 ⇒ Δt t3) • (t2 ⇒ t3) • Γ
Γ′′ = t2 • Γ′
changeMatchSem-lem1 :
∀ a1 b2 →
⟦ match ⟧ΔConst (inj₁ a1) (inj₂ (inj₂ b2)) f df g dg
≡
g b2 ⊕ dg b2 (nil b2) ⊝ f a1
changeMatchSem-lem1 a1 b2 rewrite ominusτ-equiv-ext t2 Γ′′ | oplusτ-equiv-ext t3 Γ′ | ominusτ-equiv-ext t3 Γ = refl
module _ where
private
Γ′ Γ′′ : Context
Γ′ = t1 • (t1 ⇒ Δt t1 ⇒ Δt t3) • (t1 ⇒ t3) • Γ
Γ′′ = t1 • Γ′
changeMatchSem-lem2 :
∀ b1 a2 →
⟦ match ⟧ΔConst (inj₂ b1) (inj₂ (inj₁ a2)) f df g dg
≡
f a2 ⊕ df a2 (nil a2) ⊝ g b1
changeMatchSem-lem2 b1 a2 rewrite ominusτ-equiv-ext t1 Γ′′ | oplusτ-equiv-ext t3 Γ′ | ominusτ-equiv-ext t3 Γ = refl
module _ where
private
Γ′ Γ′′ : Context
Γ′ = t1 • (t1 ⇒ Δt t1 ⇒ Δt t3) • (t1 ⇒ t3) • Γ
Γ′′ = t1 • Γ′
changeMatchSem-lem3 :
∀ a1 a2 →
⟦ match ⟧ΔConst (inj₁ a1) (inj₂ (inj₁ a2)) f df g dg ≡
f a2 ⊕ df a2 (nil a2) ⊝ f a1
changeMatchSem-lem3 a1 a2 rewrite ominusτ-equiv-ext t1 Γ′′ | oplusτ-equiv-ext t3 Γ′ | ominusτ-equiv-ext t3 Γ = refl
module _ where
private
Γ′ Γ′′ : Context
Γ′ = t2 • (t2 ⇒ Δt t2 ⇒ Δt t3) • (t2 ⇒ t3) • Γ
Γ′′ = t2 • Γ′
changeMatchSem-lem4 :
∀ b1 b2 →
⟦ match ⟧ΔConst (inj₂ b1) (inj₂ (inj₂ b2)) f df g dg
≡
g b2 ⊕ dg b2 (nil b2) ⊝ g b1
changeMatchSem-lem4 b1 b2 rewrite ominusτ-equiv-ext t2 Γ′′ | oplusτ-equiv-ext t3 Γ′ | ominusτ-equiv-ext t3 Γ = refl
| 35.451977
| 119
| 0.52494
|
06c3a3467f89f5b487ee8d79b7ea1fc04af1a53b
| 826
|
agda
|
Agda
|
relations.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
relations.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
relations.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
{- This file describes properties of computable relations. -}
open import bool
open import level
open import eq
open import product
open import product-thms
open import negation
module relations where
-- Decidable relations.
-- This was taken from the Agda STDLIB.
data Dec {p} (P : Set p) : Set p where
yes : ( p : P) → Dec P
no : (¬p : ¬ P) → Dec P
module relationsOld {ℓ ℓ' : level}{A : Set ℓ} (_≥A_ : A → A → Set ℓ') where
reflexive : Set (ℓ ⊔ ℓ')
reflexive = ∀ {a : A} → a ≥A a
transitive : Set (ℓ ⊔ ℓ')
transitive = ∀ {a b c : A} → a ≥A b → b ≥A c → a ≥A c
preorder : Set (ℓ ⊔ ℓ')
preorder = reflexive ∧ transitive
_iso_ : A → A → Set ℓ'
d iso d' = d ≥A d' ∧ d' ≥A d
iso-intro : ∀{x y : A} → x ≥A y → y ≥A x → x iso y
iso-intro p1 p2 = p1 , p2
| 22.944444
| 77
| 0.558111
|
c7565402e91cef0185d3431ebcb3649ba6bcce28
| 525
|
agda
|
Agda
|
test/Succeed/Issue1345.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue1345.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue1345.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- {-# OPTIONS -v reify:80 #-}
open import Common.Prelude
open import Common.Reflection
open import Common.Equality
module Issue1345 (A : Set) where
-- Andreas, 2016-07-17
-- Also test correct handling of abstract
abstract
unquoteDecl idNat = define (vArg idNat)
(funDef (pi (vArg (def (quote Nat) [])) (abs "" (def (quote Nat) [])))
(clause (vArg (var "") ∷ []) (var 0 []) ∷ []))
-- This raised the UselessAbstract error in error.
-- Should work.
abstract
thm : ∀ n → idNat n ≡ n
thm n = refl
| 23.863636
| 74
| 0.628571
|
c73a67d76fe4835ede902dabb05f1847d6dfdfcc
| 16,855
|
agda
|
Agda
|
TotalParserCombinators/Lib.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | 1
|
2020-07-03T08:56:13.000Z
|
2020-07-03T08:56:13.000Z
|
TotalParserCombinators/Lib.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | null | null | null |
TotalParserCombinators/Lib.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- A small library of derived parser combinators
------------------------------------------------------------------------
module TotalParserCombinators.Lib where
open import Category.Monad
open import Codata.Musical.Notation
open import Function.Base
open import Function.Equality using (_⟶_; _⟨$⟩_)
open import Function.Injection using (Injection; Injective)
open import Function.Inverse using (_↔_; module Inverse)
open import Data.Bool hiding (_≤?_)
open import Data.Char as Char using (Char; _==_)
open import Data.List as List
import Data.List.Categorical
open import Data.List.Membership.Propositional
import Data.List.Membership.Propositional.Properties as ∈
open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_)
open import Data.List.Relation.Unary.Any
open import Data.Maybe hiding (_>>=_)
open import Data.Nat hiding (_^_)
open import Data.Product as Prod
open import Data.Unit using (⊤)
open import Data.Vec as Vec using (Vec; []; _∷_)
import Level
open import Relation.Binary
open import Relation.Binary.HeterogeneousEquality as H using (_≅_)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
import Relation.Binary.PropositionalEquality.WithK as P
open import Relation.Nullary
open import Relation.Nullary.Decidable
private
open module ListMonad =
RawMonad {f = Level.zero} Data.List.Categorical.monad
using ()
renaming (_<$>_ to _<$>′_; _⊛_ to _⊛′_; _>>=_ to _>>=′_)
import TotalParserCombinators.InitialBag as I
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics as S
hiding (_≅_; return; token)
------------------------------------------------------------------------
-- Kleene star
-- The intended semantics of the Kleene star.
infixr 5 _∷_
infix 4 _∈[_]⋆·_
data _∈[_]⋆·_ {Tok R xs} :
List R → Parser Tok R xs → List Tok → Set₁ where
[] : ∀ {p} → [] ∈[ p ]⋆· []
_∷_ : ∀ {x xs s₁ s₂ p} →
(x∈p : x ∈ p · s₁) (xs∈p⋆ : xs ∈[ p ]⋆· s₂) →
x ∷ xs ∈[ p ]⋆· s₁ ++ s₂
-- An implementation which requires that the argument parser is not
-- nullable.
infix 55 _⋆ _+
mutual
_⋆ : ∀ {Tok R} →
Parser Tok R [] →
Parser Tok (List R) [ [] ]
p ⋆ = return [] ∣ p +
_+ : ∀ {Tok R} →
Parser Tok R [] →
Parser Tok (List R) []
p + = _∷_ <$> p ⊛ ♯ (p ⋆)
module KleeneStar where
-- The implementation is correct.
sound : ∀ {Tok R xs s} {p : Parser Tok R []} →
xs ∈ p ⋆ · s → xs ∈[ p ]⋆· s
sound (∣-left S.return) = []
sound (∣-right ._ (<$> x∈p ⊛ xs∈p⋆)) = x∈p ∷ sound xs∈p⋆
complete : ∀ {Tok R xs s} {p : Parser Tok R []} →
xs ∈[ p ]⋆· s → xs ∈ p ⋆ · s
complete [] = ∣-left S.return
complete (_∷_ {s₁ = []} x∈p xs∈p⋆) with I.complete x∈p
... | ()
complete (_∷_ {s₁ = _ ∷ _} x∈p xs∈p⋆) =
∣-right [ [] ] ([ ○ - ◌ ] <$> x∈p ⊛ complete xs∈p⋆)
complete∘sound :
∀ {Tok R xs s} {p : Parser Tok R []} (xs∈ : xs ∈ p ⋆ · s) →
complete (sound xs∈) ≡ xs∈
complete∘sound (∣-left S.return) = P.refl
complete∘sound (∣-right ._ (_⊛_ {s₁ = _ ∷ _} (<$> x∈p) xs∈p⋆))
rewrite complete∘sound xs∈p⋆ = P.refl
complete∘sound (∣-right ._ (_⊛_ {s₁ = []} (<$> x∈p) xs∈p⋆))
with I.complete x∈p
... | ()
sound∘complete : ∀ {Tok R xs s} {p : Parser Tok R []}
(xs∈ : xs ∈[ p ]⋆· s) →
sound (complete xs∈) ≡ xs∈
sound∘complete [] = P.refl
sound∘complete (_∷_ {s₁ = []} x∈p xs∈p⋆) with I.complete x∈p
... | ()
sound∘complete (_∷_ {s₁ = _ ∷ _} x∈p xs∈p⋆) =
P.cong (_∷_ x∈p) $ sound∘complete xs∈p⋆
correct : ∀ {Tok R xs s} {p : Parser Tok R []} →
xs ∈ p ⋆ · s ↔ xs ∈[ p ]⋆· s
correct = record
{ to = P.→-to-⟶ sound
; from = P.→-to-⟶ complete
; inverse-of = record
{ left-inverse-of = complete∘sound
; right-inverse-of = sound∘complete
}
}
-- The definition of _⋆ is restricted to non-nullable parsers. This
-- restriction cannot be removed: an unrestricted Kleene star
-- operator would be incomplete because, in the present framework, a
-- parser can only return a finite number of results.
unrestricted-incomplete :
∀ {R Tok} →
R →
(f : ∀ {xs} → Parser Tok R xs → List (List R)) →
(_⋆′ : ∀ {xs} (p : Parser Tok R xs) → Parser Tok (List R) (f p)) →
¬ (∀ {xs ys s} {p : Parser Tok R ys} →
xs ∈[ p ]⋆· s → xs ∈ p ⋆′ · s)
unrestricted-incomplete {R} x f _⋆′ complete =
∈.finite (record { to = to; injective = injective })
(f (return x)) (I.complete ∘ complete ∘ lemma)
where
to : P.setoid ℕ ⟶ P.setoid (List R)
to = P.→-to-⟶ (flip replicate x)
helper : ∀ {xs ys} → _≡_ {A = List R} (x ∷ xs) (x ∷ ys) → xs ≡ ys
helper P.refl = P.refl
injective : Injective to
injective {zero} {zero} _ = P.refl
injective {suc m} {suc n} eq = P.cong suc $
injective $ helper eq
injective {zero} {suc n} ()
injective {suc m} {zero} ()
lemma : ∀ i → replicate i x ∈[ return x ]⋆· []
lemma zero = []
lemma (suc i) = S.return ∷ lemma i
------------------------------------------------------------------------
-- A combinator for recognising a string a fixed number of times
infixl 55 _^_ _↑_
^-initial : ∀ {R} → List R → (n : ℕ) → List (Vec R n)
^-initial xs zero = [ [] ]
^-initial xs (suc n) = List.map _∷_ xs ⊛′ ^-initial xs n
_^_ : ∀ {Tok R xs} →
Parser Tok R xs → (n : ℕ) → Parser Tok (Vec R n) (^-initial xs n)
p ^ 0 = return []
p ^ suc n = _∷_ <$> p ⊛ p ^ n
mutual
-- A variant.
-- The two functions below are not actually mutually recursive, but
-- are placed in a mutual block to ensure that the constraints
-- generated by the second function can be used to instantiate the
-- underscores in the body of the first.
↑-initial : ∀ {R} → List R → ℕ → List (List R)
↑-initial _ _ = _
_↑_ : ∀ {Tok R xs} →
Parser Tok R xs → (n : ℕ) → Parser Tok (List R) (↑-initial xs n)
p ↑ n = Vec.toList <$> p ^ n
-- Some lemmas relating _↑_ to _⋆.
module Exactly where
↑≲⋆ : ∀ {Tok R} {p : Parser Tok R []} n → p ↑ n ≲ p ⋆
↑≲⋆ {R = R} {p} n (<$> ∈pⁿ) = KleeneStar.complete $ helper n ∈pⁿ
where
helper : ∀ n {xs s} → xs ∈ p ^ n · s → Vec.toList xs ∈[ p ]⋆· s
helper zero S.return = []
helper (suc n) (<$> ∈p ⊛ ∈pⁿ) = ∈p ∷ helper n ∈pⁿ
⋆≲∃↑ : ∀ {Tok R} {p : Parser Tok R []} {xs s} →
xs ∈ p ⋆ · s → ∃ λ i → xs ∈ p ↑ i · s
⋆≲∃↑ {R = R} {p} ∈p⋆ with helper $ KleeneStar.sound ∈p⋆
where
helper : ∀ {xs s} → xs ∈[ p ]⋆· s →
∃₂ λ i (ys : Vec R i) →
xs ≡ Vec.toList ys × ys ∈ p ^ i · s
helper [] = (0 , [] , P.refl , S.return)
helper (∈p ∷ ∈p⋆) =
Prod.map suc (λ {i} →
Prod.map (_∷_ _) (
Prod.map (P.cong (_∷_ _))
(λ ∈pⁱ → [ ○ - ○ ] <$> ∈p ⊛ ∈pⁱ)))
(helper ∈p⋆)
... | (i , ys , P.refl , ∈pⁱ) = (i , <$> ∈pⁱ)
------------------------------------------------------------------------
-- A parser which returns any element in a given list
return⋆ : ∀ {Tok R} (xs : List R) → Parser Tok R xs
return⋆ [] = fail
return⋆ (x ∷ xs) = return x ∣ return⋆ xs
module Return⋆ where
sound : ∀ {Tok R x} {s : List Tok}
(xs : List R) → x ∈ return⋆ xs · s → s ≡ [] × x ∈ xs
sound [] ()
sound (y ∷ ys) (∣-left S.return) = (P.refl , here P.refl)
sound (y ∷ ys) (∣-right .([ y ]) x∈ys) =
Prod.map id there $ sound ys x∈ys
complete : ∀ {Tok R x} {xs : List R} →
x ∈ xs → x ∈ return⋆ {Tok} xs · []
complete (here P.refl) = ∣-left S.return
complete (there x∈xs) =
∣-right [ _ ] (complete x∈xs)
complete∘sound : ∀ {Tok R x} {s : List Tok}
(xs : List R) (x∈xs : x ∈ return⋆ xs · s) →
complete {Tok = Tok} (proj₂ $ sound xs x∈xs) ≅ x∈xs
complete∘sound [] ()
complete∘sound (y ∷ ys) (∣-left S.return) = H.refl
complete∘sound (y ∷ ys) (∣-right .([ y ]) x∈ys)
with sound ys x∈ys | complete∘sound ys x∈ys
complete∘sound (y ∷ ys) (∣-right .([ y ]) .(complete p))
| (P.refl , p) | H.refl = H.refl
sound∘complete : ∀ {Tok R x} {xs : List R} (x∈xs : x ∈ xs) →
sound {Tok = Tok} {s = []} xs (complete x∈xs) ≡
(P.refl , x∈xs)
sound∘complete (here P.refl) = P.refl
sound∘complete {Tok} (there {xs = xs} x∈xs)
with sound {Tok = Tok} xs (complete x∈xs)
| sound∘complete {Tok} {xs = xs} x∈xs
sound∘complete (there x∈xs) | .(P.refl , x∈xs) | P.refl = P.refl
correct : ∀ {Tok R} {xs : List R} {x s} →
(s ≡ [] × x ∈ xs) ↔ x ∈ return⋆ {Tok} xs · s
correct {xs = xs} {x} = record
{ to = P.→-to-⟶ complete′
; from = P.→-to-⟶ $ sound xs
; inverse-of = record
{ left-inverse-of = sound∘complete′
; right-inverse-of = complete′∘sound xs
}
}
where
complete′ : ∀ {Tok R x} {xs : List R} {s : List Tok} →
s ≡ [] × x ∈ xs → x ∈ return⋆ xs · s
complete′ (P.refl , x∈xs) = complete x∈xs
sound∘complete′ : ∀ {Tok R x} {xs : List R} {s : List Tok}
(p : s ≡ [] × x ∈ xs) → sound xs (complete′ p) ≡ p
sound∘complete′ (P.refl , x∈xs) = sound∘complete x∈xs
complete′∘sound : ∀ {Tok R x} {s : List Tok}
(xs : List R) (x∈xs : x ∈ return⋆ xs · s) →
complete′ (sound xs x∈xs) ≡ x∈xs
complete′∘sound xs x∈ with sound xs x∈ | complete∘sound xs x∈
complete′∘sound xs .(complete x∈xs) | (P.refl , x∈xs) | H.refl =
P.refl
------------------------------------------------------------------------
-- The sat parser
module Sat where
-- Helper functions for sat.
mutual
ok-bag : {R : Set} → Maybe R → List R
ok-bag nothing = _
ok-bag (just _) = _
ok : {Tok R : Set} → (x : Maybe R) → Parser Tok R (ok-bag x)
ok nothing = fail
ok (just x) = return x
ok-correct : ∀ {Tok R x s} (m : Maybe R) →
(s ≡ [] × m ≡ just x) ↔ x ∈ ok {Tok} m · s
ok-correct {Tok} {x = x} m = record
{ to = P.→-to-⟶ (to m)
; from = P.→-to-⟶ (from m)
; inverse-of = record
{ left-inverse-of = from∘to m
; right-inverse-of = to∘from m
}
}
where
to : ∀ {s} m → (s ≡ [] × m ≡ just x) → x ∈ ok {Tok} m · s
to (just .x) (P.refl , P.refl) = S.return
to nothing (P.refl , ())
from : ∀ {s} m → x ∈ ok {Tok} m · s → s ≡ [] × m ≡ just x
from (just .x) S.return = (P.refl , P.refl)
from nothing ()
from∘to : ∀ {s} m (eqs : s ≡ [] × m ≡ just x) →
from m (to m eqs) ≡ eqs
from∘to (just .x) (P.refl , P.refl) = P.refl
from∘to nothing (P.refl , ())
to∘from : ∀ {s} m (x∈ : x ∈ ok {Tok} m · s) →
to m (from m x∈) ≡ x∈
to∘from (just .x) S.return = P.refl
to∘from nothing ()
-- sat p accepts a single token t iff p t ≡ just x for some x. The
-- returned value is x.
sat : ∀ {Tok R} → (Tok → Maybe R) → Parser Tok R _
sat p = token >>= (ok ∘ p)
correct : ∀ {Tok R x s} (p : Tok → Maybe R) →
(∃ λ t → s ≡ [ t ] × p t ≡ just x) ↔ x ∈ sat p · s
correct {x = x} p = record
{ to = P.→-to-⟶ to
; from = P.→-to-⟶ from
; inverse-of = record
{ left-inverse-of = from∘to
; right-inverse-of = to∘from
}
}
where
to : ∀ {s} → (∃ λ t → s ≡ [ t ] × p t ≡ just x) → x ∈ sat p · s
to (t , P.refl , p-t≡just-x) =
[ ○ - ○ ] S.token >>=
(Inverse.to (ok-correct (p t)) ⟨$⟩ (P.refl , p-t≡just-x))
from : ∀ {s} → x ∈ sat p · s → ∃ λ t → s ≡ [ t ] × p t ≡ just x
from (S.token {x = t} >>= x∈ok-p-t) =
(t , Prod.map (P.cong (_∷_ t)) id
(Inverse.from (ok-correct (p t)) ⟨$⟩ x∈ok-p-t))
from∘to : ∀ {s} (eqs : ∃ λ t → s ≡ [ t ] × p t ≡ just x) →
from (to eqs) ≡ eqs
from∘to (t , P.refl , p-t≡just-x) =
P.cong₂ (λ eq₁ eq₂ → (t , eq₁ , eq₂))
(P.≡-irrelevant _ _)
(P.≡-irrelevant _ _)
to∘from : ∀ {s} (x∈ : x ∈ sat p · s) → to (from x∈) ≡ x∈
to∘from (S.token {x = t} >>= x∈ok-p-t)
with Inverse.from (ok-correct (p t)) ⟨$⟩ x∈ok-p-t
| Inverse.right-inverse-of (ok-correct (p t)) x∈ok-p-t
to∘from (S.token {x = t} >>= .(Inverse.to (ok-correct (p t)) ⟨$⟩
(P.refl , p-t≡just-x)))
| (P.refl , p-t≡just-x) | P.refl = P.refl
open Sat public using (sat)
-- A simplified variant of sat. Does not return anything interesting.
sat′ : ∀ {Tok} → (Tok → Bool) → Parser Tok ⊤ _
sat′ p = sat (boolToMaybe ∘ p)
-- Accepts a single whitespace character (from a limited set of such
-- characters).
whitespace : Parser Char ⊤ _
whitespace = sat′ isSpace
where
isSpace = λ c →
(c == ' ') ∨ (c == '\t') ∨ (c == '\n') ∨ (c == '\r')
------------------------------------------------------------------------
-- A parser for a given token
module Token
(Tok : Set)
(_≟_ : Decidable (_≡_ {A = Tok}))
where
private
p : Tok → Tok → Maybe Tok
p t t′ = if ⌊ t ≟ t′ ⌋ then just t′ else nothing
tok : Tok → Parser Tok Tok []
tok t = sat (p t)
sound : ∀ t {t′ s} →
t′ ∈ tok t · s → t ≡ t′ × s ≡ [ t′ ]
sound t t′∈ with Inverse.from (Sat.correct (p t)) ⟨$⟩ t′∈
sound t t′∈ | (t″ , P.refl , p-t-t″≡just-t′) with t ≟ t″
sound t t∈ | (.t , P.refl , P.refl) | yes P.refl = (P.refl , P.refl)
sound t t′∈ | (t″ , P.refl , ()) | no _
private
p-lemma : ∀ t → p t t ≡ just t
p-lemma t with t ≟ t
... | yes P.refl = P.refl
... | no t≢t with t≢t P.refl
... | ()
complete : ∀ {t} → t ∈ tok t · [ t ]
complete {t} =
Inverse.to (Sat.correct (p t)) ⟨$⟩ (t , P.refl , p-lemma t)
η : ∀ {t} (t∈ : t ∈ tok t · [ t ]) → t∈ ≡ complete {t = t}
η {t = t} t∈ = H.≅-to-≡ $ helper t∈ P.refl
where
helper₂ : (t∈ : t ∈ Sat.ok {Tok = Tok} (p t t) · []) →
t∈ ≡ Inverse.to (Sat.ok-correct (p t t)) ⟨$⟩
(P.refl , p-lemma t)
helper₂ t∈ with t ≟ t
helper₂ S.return | yes P.refl = P.refl
helper₂ t∈ | no t≢t with t≢t P.refl
helper₂ t∈ | no t≢t | ()
helper : ∀ {s} (t∈ : t ∈ tok t · s) → s ≡ [ t ] →
t∈ ≅ complete {t = t}
helper (S.token >>= t∈) P.refl rewrite helper₂ t∈ = H.refl
------------------------------------------------------------------------
-- Map then choice
-- y ∈ ⋁ f xs · s iff ∃ x ∈ xs. y ∈ f x · s.
⋁ : ∀ {Tok R₁ R₂} {f : R₁ → List R₂} →
((x : R₁) → Parser Tok R₂ (f x)) → (xs : List R₁) →
Parser Tok R₂ (xs >>=′ f)
⋁ f xs = return⋆ xs >>= f
module ⋁ where
sound : ∀ {Tok R₁ R₂ y s} {i : R₁ → List R₂} →
(f : (x : R₁) → Parser Tok R₂ (i x)) (xs : List R₁) →
y ∈ ⋁ f xs · s → ∃ λ x → (x ∈ xs) × (y ∈ f x · s)
sound f xs (∈ret⋆ >>= y∈fx) with Return⋆.sound xs ∈ret⋆
... | (P.refl , x∈xs) = (_ , x∈xs , y∈fx)
complete : ∀ {Tok R₁ R₂ x y s} {i : R₁ → List R₂} →
(f : (x : R₁) → Parser Tok R₂ (i x)) {xs : List R₁} →
x ∈ xs → y ∈ f x · s → y ∈ ⋁ f xs · s
complete f x∈xs y∈fx =
[ ○ - ○ ] Return⋆.complete x∈xs >>= y∈fx
complete∘sound : ∀ {Tok R₁ R₂ y s} {i : R₁ → List R₂} →
(f : (x : R₁) → Parser Tok R₂ (i x)) (xs : List R₁)
(y∈⋁fxs : y ∈ ⋁ f xs · s) →
let p = proj₂ $ sound f xs y∈⋁fxs in
complete f (proj₁ p) (proj₂ p) ≡ y∈⋁fxs
complete∘sound f xs (∈ret⋆ >>= y∈fx)
with Return⋆.sound xs ∈ret⋆
| Inverse.right-inverse-of Return⋆.correct ∈ret⋆
complete∘sound f xs (.(Return⋆.complete x∈xs) >>= y∈fx)
| (P.refl , x∈xs) | P.refl = P.refl
sound∘complete :
∀ {Tok R₁ R₂ x y s} {i : R₁ → List R₂} →
(f : (x : R₁) → Parser Tok R₂ (i x)) {xs : List R₁} →
(x∈xs : x ∈ xs) (y∈fx : y ∈ f x · s) →
sound f xs (complete f x∈xs y∈fx) ≡ (x , x∈xs , y∈fx)
sound∘complete {Tok} f {xs} x∈xs y∈fx
with Return⋆.sound {Tok = Tok} xs (Return⋆.complete x∈xs)
| Inverse.left-inverse-of (Return⋆.correct {Tok = Tok})
(P.refl , x∈xs)
... | (P.refl , .x∈xs) | P.refl = P.refl
------------------------------------------------------------------------
-- Digits and numbers
-- Digits.
digit = sat (λ t → if in-range t then just (to-number t) else nothing)
where
in-range : Char → Bool
in-range t = ⌊ Char.toℕ '0' ≤? Char.toℕ t ⌋ ∧
⌊ Char.toℕ t ≤? Char.toℕ '9' ⌋
to-number : Char → ℕ
to-number t = Char.toℕ t ∸ Char.toℕ '0'
-- Numbers.
number : Parser Char ℕ _
number = digit + >>= (return ∘ foldl (λ n d → 10 * n + d) 0)
| 33.913481
| 73
| 0.478908
|
dce7bd56f4cca43a2747d912655f5048d80a8234
| 2,645
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Ideal.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Algebra/CommRing/Ideal.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Algebra/CommRing/Ideal.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-
This is mostly for convenience, when working with ideals
(which are defined for general rings) in a commutative ring.
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.Ideal where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Powerset
open import Cubical.Data.Nat using (ℕ ; zero ; suc)
open import Cubical.Data.FinData
open import Cubical.Algebra.CommRing.Base
open import Cubical.Algebra.Ring.Ideal renaming (IdealsIn to IdealsInRing)
open import Cubical.Algebra.Ring.BigOps
open import Cubical.Algebra.RingSolver.ReflectionSolving
private
variable
ℓ : Level
IdealsIn : (R : CommRing ℓ) → Type _
IdealsIn R = IdealsInRing (CommRing→Ring R)
module _ (Ring@(R , str) : CommRing ℓ) where
open CommRingStr str
makeIdeal : (I : R → hProp ℓ)
→ (+-closed : {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I)
→ (0r-closed : 0r ∈ I)
→ (·-closedLeft : {x : R} → (r : R) → x ∈ I → r · x ∈ I)
→ IdealsIn (R , str)
makeIdeal I +-closed 0r-closed ·-closedLeft = I ,
(record
{ +-closed = +-closed
; -closed = λ x∈I → subst-∈ I (useSolver _)
(·-closedLeft (- 1r) x∈I)
; 0r-closed = 0r-closed
; ·-closedLeft = ·-closedLeft
; ·-closedRight = λ r x∈I →
subst-∈ I
(·-comm r _)
(·-closedLeft r x∈I)
})
where useSolver : (x : R) → - 1r · x ≡ - x
useSolver = solve Ring
-- better?
module _ (R' : CommRing ℓ) where
private R = fst R'
open CommRingStr (snd R')
open Sum (CommRing→Ring R')
record isCommIdeal (I : ℙ R) : Type ℓ where
constructor
makeIsCommIdeal
field
+Closed : ∀ {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I
contains0 : 0r ∈ I
·Closed : ∀ {x : R} (r : R) → x ∈ I → r · x ∈ I
open isCommIdeal
isPropIsCommIdeal : (I : ℙ R) → isProp (isCommIdeal I)
+Closed (isPropIsCommIdeal I ici₁ ici₂ i) x∈I y∈I =
I _ .snd (ici₁ .+Closed x∈I y∈I) (ici₂ .+Closed x∈I y∈I) i
contains0 (isPropIsCommIdeal I ici₁ ici₂ i) = I 0r .snd (ici₁ .contains0) (ici₂ .contains0) i
·Closed (isPropIsCommIdeal I ici₁ ici₂ i) r x∈I =
I _ .snd (ici₁ .·Closed r x∈I) (ici₂ .·Closed r x∈I) i
CommIdeal : Type _
CommIdeal = Σ[ I ∈ ℙ R ] isCommIdeal I
∑Closed : (I : CommIdeal) {n : ℕ} (V : FinVec R n)
→ (∀ i → V i ∈ fst I) → ∑ V ∈ fst I
∑Closed I {n = zero} _ _ = I .snd .contains0
∑Closed I {n = suc n} V h = I .snd .+Closed (h zero) (∑Closed I (V ∘ suc) (h ∘ suc))
| 33.0625
| 94
| 0.579962
|
31e90b0912c5673258df1f86e91676621d00d2f4
| 5,040
|
agda
|
Agda
|
formalization/agda/Spire/IDarkwingDuck/Primitive.agda
|
spire/spire
|
3d67f137ee9423b7e6f8593634583998cd692353
|
[
"BSD-3-Clause"
] | 43
|
2015-05-28T23:25:33.000Z
|
2022-03-08T17:10:59.000Z
|
formalization/agda/Spire/IDarkwingDuck/Primitive.agda
|
spire/spire
|
3d67f137ee9423b7e6f8593634583998cd692353
|
[
"BSD-3-Clause"
] | null | null | null |
formalization/agda/Spire/IDarkwingDuck/Primitive.agda
|
spire/spire
|
3d67f137ee9423b7e6f8593634583998cd692353
|
[
"BSD-3-Clause"
] | 1
|
2015-08-17T21:00:07.000Z
|
2015-08-17T21:00:07.000Z
|
module Spire.IDarkwingDuck.Primitive where
----------------------------------------------------------------------
infixr 4 _,_
infixr 5 _∷_
----------------------------------------------------------------------
postulate String : Set
{-# BUILTIN STRING String #-}
----------------------------------------------------------------------
data ⊥ : Set where
elimBot : (P : ⊥ → Set)
(v : ⊥) → P v
elimBot P ()
----------------------------------------------------------------------
data ⊤ : Set where
tt : ⊤
elimUnit : (P : ⊤ → Set)
(ptt : P tt)
(u : ⊤) → P u
elimUnit P ptt tt = ptt
----------------------------------------------------------------------
data Σ (A : Set) (B : A → Set) : Set where
_,_ : (a : A) (b : B a) → Σ A B
elimPair : {A : Set} {B : A → Set}
(P : Σ A B → Set)
(ppair : (a : A) (b : B a) → P (a , b))
(ab : Σ A B) → P ab
elimPair P ppair (a , b) = ppair a b
----------------------------------------------------------------------
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
elimEq : {A : Set} {x : A} (P : (y : A) → x ≡ y → Set)
(prefl : P x refl)
(y : A) (q : x ≡ y) → P y q
elimEq P prefl x refl = prefl
----------------------------------------------------------------------
data List (A : Set) : Set where
[] : List A
_∷_ : (x : A) (xs : List A) → List A
elimList : {A : Set} (P : List A → Set)
(pnil : P [])
(pcons : (x : A) (xs : List A) → P xs → P (x ∷ xs))
(xs : List A) → P xs
elimList P pnil pcons [] = pnil
elimList P pnil pcons (x ∷ xs) = pcons x xs (elimList P pnil pcons xs)
----------------------------------------------------------------------
data PointsTo (A : Set) : List A → Set where
here : ∀{x xs} → PointsTo A (x ∷ xs)
there : ∀{x xs} → PointsTo A xs → PointsTo A (x ∷ xs)
elimPointsTo : {A : Set} (P : (xs : List A) → PointsTo A xs → Set)
(phere : (x : A) (xs : List A) → P (x ∷ xs) here)
(pthere : (x : A) (xs : List A) (t : PointsTo A xs) → P xs t → P (x ∷ xs) (there t))
(xs : List A) (t : PointsTo A xs) → P xs t
elimPointsTo P phere pthere (x ∷ xs) here = phere x xs
elimPointsTo P phere pthere (x ∷ xs) (there t) = pthere x xs t (elimPointsTo P phere pthere xs t)
----------------------------------------------------------------------
data Tel : Set₁ where
End : Tel
Arg IArg : (A : Set) (B : A → Tel) → Tel
elimTel : (P : Tel → Set)
(pend : P End)
(parg : (A : Set) (B : A → Tel) (pb : (a : A) → P (B a)) → P (Arg A B))
(piarg : (A : Set) (B : A → Tel) (pb : (a : A) → P (B a)) → P (IArg A B))
(T : Tel) → P T
elimTel P pend parg piarg End = pend
elimTel P pend parg piarg (Arg A B) = parg A B (λ a → elimTel P pend parg piarg (B a))
elimTel P pend parg piarg (IArg A B) = piarg A B (λ a → elimTel P pend parg piarg (B a))
----------------------------------------------------------------------
data Desc (I : Set) : Set₁ where
End : (i : I) → Desc I
Rec : (i : I) (D : Desc I) → Desc I
Arg : (A : Set) (B : A → Desc I) → Desc I
IArg : (A : Set) (B : A → Desc I) → Desc I
elimDesc : {I : Set} (P : Desc I → Set)
(pend : (i : I) → P (End i))
(prec : (i : I) (D : Desc I) (pd : P D) → P (Rec i D))
(parg : (A : Set) (B : A → Desc I) (pb : (a : A) → P (B a)) → P (Arg A B))
(piarg : (A : Set) (B : A → Desc I) (pb : (a : A) → P (B a)) → P (IArg A B))
(D : Desc I) → P D
elimDesc P pend prec parg piarg (End i) = pend i
elimDesc P pend prec parg piarg (Rec i D) = prec i D (elimDesc P pend prec parg piarg D)
elimDesc P pend prec parg piarg (Arg A B) = parg A B (λ a → elimDesc P pend prec parg piarg (B a))
elimDesc P pend prec parg piarg (IArg A B) = piarg A B (λ a → elimDesc P pend prec parg piarg (B a))
Elᴰ : {I : Set} (D : Desc I) → (I → Set) → I → Set
Elᴰ (End j) X i = j ≡ i
Elᴰ (Rec j D) X i = Σ (X j) (λ _ → Elᴰ D X i)
Elᴰ (Arg A B) X i = Σ A (λ a → Elᴰ (B a) X i)
Elᴰ (IArg A B) X i = Σ A (λ a → Elᴰ (B a) X i)
Hyps : {I : Set} (D : Desc I) (X : I → Set) (P : (i : I) → X i → Set) (i : I) (xs : Elᴰ D X i) → Set
Hyps (End j) X P i q = ⊤
Hyps (Rec j D) X P i (x , xs) = Σ (P j x) (λ _ → Hyps D X P i xs)
Hyps (Arg A B) X P i (a , b) = Hyps (B a) X P i b
Hyps (IArg A B) X P i (a , b) = Hyps (B a) X P i b
----------------------------------------------------------------------
data μ {I : Set} (D : Desc I) (i : I) : Set where
init : Elᴰ D (μ D) i → μ D i
ind : {I : Set} (D : Desc I)
(M : (i : I) → μ D i → Set)
(α : ∀ i (xs : Elᴰ D (μ D) i) (ihs : Hyps D (μ D) M i xs) → M i (init xs))
(i : I)
(x : μ D i)
→ M i x
prove : {I : Set} (D E : Desc I)
(M : (i : I) → μ E i → Set)
(α : ∀ i (xs : Elᴰ E (μ E) i) (ihs : Hyps E (μ E) M i xs) → M i (init xs))
(i : I) (xs : Elᴰ D (μ E) i) → Hyps D (μ E) M i xs
ind D M α i (init xs) = α i xs (prove D D M α i xs)
prove (End j) E M α i q = tt
prove (Rec j D) E M α i (x , xs) = ind E M α j x , prove D E M α i xs
prove (Arg A B) E M α i (a , xs) = prove (B a) E M α i xs
prove (IArg A B) E M α i (a , xs) = prove (B a) E M α i xs
----------------------------------------------------------------------
| 33.825503
| 100
| 0.418651
|
136e4d5579338a02ba102ba10c73d63476fce0d1
| 4,582
|
agda
|
Agda
|
theorems/cohomology/SubFinBouquet.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/cohomology/SubFinBouquet.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/cohomology/SubFinBouquet.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 homotopy.Bouquet
open import homotopy.FinWedge
open import cohomology.Theory
module cohomology.SubFinBouquet (OT : OrdinaryTheory lzero) where
open OrdinaryTheory OT
open import cohomology.Sphere OT
open import cohomology.SubFinWedge cohomology-theory
open import cohomology.Bouquet OT
C-SubFinBouquet-diag : ∀ n {A B : Type₀} (B-ac : has-choice 0 B lzero) {I} (p : Fin I → Coprod A B)
→ C (ℕ-to-ℤ n) (⊙Bouquet B n) ≃ᴳ Πᴳ B (λ _ → C2 0)
C-SubFinBouquet-diag n {B = B} B-ac p = C-Bouquet-diag n B B-ac
C-FinBouquet-diag : ∀ n I → C (ℕ-to-ℤ n) (⊙FinBouquet I n) ≃ᴳ Πᴳ (Fin I) (λ _ → C2 0)
C-FinBouquet-diag n I = C-SubFinBouquet-diag n {A = Empty} {B = Fin I} (Fin-has-choice 0 lzero) inr
abstract
C-SubFinBouquet-diag-β : ∀ n {A B : Type₀} (B-ac : has-choice 0 B lzero) {I} (p : Fin I → Coprod A B) g b
→ GroupIso.f (C-FinBouquet-diag n I) g b
== GroupIso.f (C-Sphere-diag n)
(CEl-fmap (ℕ-to-ℤ n) ⊙lower
(CEl-fmap (ℕ-to-ℤ n) (⊙bwin b) g))
C-SubFinBouquet-diag-β n B-ac p g b =
GroupIso.f (C-Sphere-diag n)
(CEl-fmap (ℕ-to-ℤ n) (⊙bwin b)
(CEl-fmap (ℕ-to-ℤ n) (⊙–> (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) g))
=⟨ ap (GroupIso.f (C-Sphere-diag n)) $
∘-CEl-fmap (ℕ-to-ℤ n) (⊙bwin b) (⊙–> (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) g
∙ CEl-fmap-base-indep (ℕ-to-ℤ n) (λ _ → idp) g
∙ CEl-fmap-∘ (ℕ-to-ℤ n) (⊙bwin b) ⊙lower g ⟩
GroupIso.f (C-Sphere-diag n) (CEl-fmap (ℕ-to-ℤ n) ⊙lower (CEl-fmap (ℕ-to-ℤ n) (⊙bwin b) g))
=∎
C-FinBouquet-diag-β : ∀ n I g <I
→ GroupIso.f (C-FinBouquet-diag n I) g <I
== GroupIso.f (C-Sphere-diag n)
(CEl-fmap (ℕ-to-ℤ n) ⊙lower
(CEl-fmap (ℕ-to-ℤ n) (⊙bwin <I) g))
C-FinBouquet-diag-β n I =
C-SubFinBouquet-diag-β n {A = Empty} {B = Fin I}
(Fin-has-choice 0 lzero) inr
inverse-C-SubFinBouquet-diag-β : ∀ n
{A B : Type₀} (B-ac : has-choice 0 B lzero) (B-dec : has-dec-eq B) {I} (p : Fin I ≃ Coprod A B) g
→ GroupIso.g (C-SubFinBouquet-diag n B-ac (–> p)) g
== Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p)
(λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b)
(CEl-fmap (ℕ-to-ℤ n) ⊙lift
(GroupIso.g (C-Sphere-diag n) (g b))))
inverse-C-SubFinBouquet-diag-β n {B = B} B-ac B-dec p g =
CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv)))
(GroupIso.g (C-subfinite-additive-iso (ℕ-to-ℤ n) (–> p) (⊙Lift (⊙Sphere n)) B-ac)
(GroupIso.g (C-Sphere-diag n) ∘ g))
=⟨ ap (CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv)))) $
inverse-C-subfinite-additive-β (ℕ-to-ℤ n) B-ac B-dec p (GroupIso.g (C-Sphere-diag n) ∘ g) ⟩
CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv)))
(Group.subsum-r (C (ℕ-to-ℤ n) (⊙BouquetLift B n)) (–> p)
(λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b))))
=⟨ GroupHom.pres-subsum-r (C-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv)))) (–> p) $
(λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b))) ⟩
Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p)
(λ b →
CEl-fmap (ℕ-to-ℤ n) (⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv)))
(CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b) (GroupIso.g (C-Sphere-diag n) (g b))))
=⟨ ap (Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p))
(λ= λ b →
∘-CEl-fmap (ℕ-to-ℤ n)
(⊙<– (⊙BigWedge-emap-r (λ _ → ⊙lower-equiv))) (⊙bwproj B-dec b)
(GroupIso.g (C-Sphere-diag n) (g b))
∙ CEl-fmap-base-indep (ℕ-to-ℤ n)
(bwproj-BigWedge-emap-r-lift B-dec b)
(GroupIso.g (C-Sphere-diag n) (g b))
∙ CEl-fmap-∘ (ℕ-to-ℤ n) ⊙lift (⊙bwproj B-dec b)
(GroupIso.g (C-Sphere-diag n) (g b))) ⟩
Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet B n)) (–> p)
(λ b →
CEl-fmap (ℕ-to-ℤ n) (⊙bwproj B-dec b)
(CEl-fmap (ℕ-to-ℤ n) ⊙lift
(GroupIso.g (C-Sphere-diag n) (g b))))
=∎
inverse-C-FinBouquet-diag-β : ∀ n I g
→ GroupIso.g (C-FinBouquet-diag n I) g
== Group.sum (C (ℕ-to-ℤ n) (⊙FinBouquet I n))
(λ <I → CEl-fmap (ℕ-to-ℤ n) (⊙fwproj <I)
(CEl-fmap (ℕ-to-ℤ n) ⊙lift
(GroupIso.g (C-Sphere-diag n) (g <I))))
inverse-C-FinBouquet-diag-β n I =
inverse-C-SubFinBouquet-diag-β n {A = Empty} {B = Fin I}
(Fin-has-choice 0 lzero) Fin-has-dec-eq (⊔₁-Empty (Fin I) ⁻¹)
| 47.729167
| 107
| 0.541685
|
2e1c4a16b3287b59508d7cf449f195e67c1fe747
| 1,450
|
agda
|
Agda
|
agda/Avionics/List.agda
|
RPI-WCL/safety-envelopes-sentinels
|
896e67a2ad21041a1c9ef5f3ad6318c67d730341
|
[
"BSD-3-Clause"
] | null | null | null |
agda/Avionics/List.agda
|
RPI-WCL/safety-envelopes-sentinels
|
896e67a2ad21041a1c9ef5f3ad6318c67d730341
|
[
"BSD-3-Clause"
] | null | null | null |
agda/Avionics/List.agda
|
RPI-WCL/safety-envelopes-sentinels
|
896e67a2ad21041a1c9ef5f3ad6318c67d730341
|
[
"BSD-3-Clause"
] | 1
|
2020-09-20T00:36:09.000Z
|
2020-09-20T00:36:09.000Z
|
module Avionics.List where
open import Data.Bool using (Bool; true; false; T)
open import Data.List as List using (List; []; _∷_; any)
open import Data.List.Relation.Unary.Any using (Any; here; there)
open import Function using (_∘_)
open import Relation.Binary.PropositionalEquality using (_≡_; inspect; [_]; refl)
open import Avionics.Bool using (≡→T)
≡→any : ∀ {a} {A : Set a} (f) (ns : List A)
→ any f ns ≡ true
→ Any (T ∘ f) ns
--→ Any (λ x → T (f x)) ns
≡→any f [] ()
≡→any f (n ∷ ns) any-f-⟨n∷ns⟩≡true with f n | inspect f n
... | true | [ fn≡t ] = here (≡→T fn≡t)
... | false | _ = there (≡→any f ns any-f-⟨n∷ns⟩≡true)
any→≡ : ∀ {a} {A : Set a} (f) (ns : List A)
→ Any (T ∘ f) ns
→ any f ns ≡ true
any→≡ f (n ∷ _) (here _) with f n
... | true = refl -- or: T→≡ [*proof*from*here*]
any→≡ f (n ∷ ns) (there Any[T∘f]ns) with f n
... | true = refl
... | false = any→≡ f ns Any[T∘f]ns
any-map : ∀ {A B : Set} {p : B → Set} {ls : List A}
(f : A → B)
→ Any p (List.map f ls)
→ Any (p ∘ f) ls
--any-map {ls = []} _ ()
any-map {ls = l ∷ ls} f (here pb) = here pb
any-map {ls = l ∷ ls} f (there pb) = there (any-map f pb)
any-map-rev : ∀ {A B : Set} {p : B → Set} {ls : List A}
(f : A → B)
→ Any (p ∘ f) ls
→ Any p (List.map f ls)
any-map-rev {ls = l ∷ ls} f (here pb) = here pb
any-map-rev {ls = l ∷ ls} f (there pb) = there (any-map-rev f pb)
| 32.954545
| 81
| 0.513793
|
50f3c8c37e924e2c4b0e373478c3d99e84a1a60d
| 1,504
|
agda
|
Agda
|
examples/outdated-and-incorrect/lattice/PartialOrder.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/outdated-and-incorrect/lattice/PartialOrder.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/outdated-and-incorrect/lattice/PartialOrder.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module PartialOrder where
open import Prelude
record PartialOrder (A : Set) : Set1 where
field
_==_ : A -> A -> Set
_≤_ : A -> A -> Set
==-def : forall {x y} -> (x == y) ⇐⇒ (x ≤ y) ∧ (y ≤ x)
≤-refl : forall {x} -> x ≤ x
≤-trans : forall {x y z} -> x ≤ y -> y ≤ z -> x ≤ z
module POrder {A : Set}(ord : PartialOrder A) where
private module POrd = PartialOrder ord
open POrd public
infix 60 _≤_ _==_
Monotone : (A -> A) -> Set
Monotone f = forall {x y} -> x ≤ y -> f x ≤ f y
Antitone : (A -> A) -> Set
Antitone f = forall {x y} -> x ≤ y -> f y ≤ f x
≤-antisym : forall {x y} -> x ≤ y -> y ≤ x -> x == y
≤-antisym p q = snd ==-def (p , q)
==≤-L : forall {x y} -> x == y -> x ≤ y
==≤-L x=y = fst (fst ==-def x=y)
==≤-R : forall {x y} -> x == y -> y ≤ x
==≤-R x=y = snd (fst ==-def x=y)
==-refl : forall {x} -> x == x
==-refl = ≤-antisym ≤-refl ≤-refl
==-sym : forall {x y} -> x == y -> y == x
==-sym xy = snd ==-def (swap (fst ==-def xy))
==-trans : forall {x y z} -> x == y -> y == z -> x == z
==-trans xy yz = ≤-antisym
(≤-trans x≤y y≤z)
(≤-trans z≤y y≤x)
where
x≤y = ==≤-L xy
y≤z = ==≤-L yz
y≤x = ==≤-R xy
z≤y = ==≤-R yz
Dual : PartialOrder A
Dual = record
{ _==_ = _==_
; _≤_ = \x y -> y ≤ x
; ==-def = (swap ∘ fst ==-def , snd ==-def ∘ swap)
; ≤-refl = ≤-refl
; ≤-trans = \yx zy -> ≤-trans zy yx
}
| 25.066667
| 59
| 0.420878
|
59960ee529c756b03057ec9490531f6c28d96d17
| 1,085
|
agda
|
Agda
|
examples/examplesPaperJFP/VariableList.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
examples/examplesPaperJFP/VariableList.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
examples/examplesPaperJFP/VariableList.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
module examplesPaperJFP.VariableList where
open import Data.Product hiding (map)
open import Data.List
open import NativeIO
open import StateSizedIO.GUI.WxBindingsFFI
open import Relation.Binary.PropositionalEquality
data VarList : Set₁ where
[] : VarList
addVar : (A : Set) → Var A → VarList → VarList
prod : VarList → Set
prod [] = Unit
prod (addVar A v []) = A
prod (addVar A v l) = A × prod l
takeVar : (l : VarList) → NativeIO (prod l)
takeVar [] = nativeReturn unit
takeVar (addVar A v []) = nativeTakeVar {A} v
takeVar (addVar A v (addVar B v′ l)) =
nativeTakeVar {A} v native>>= λ a →
takeVar (addVar B v′ l) native>>= λ rest →
nativeReturn ( a , rest )
putVar : (l : VarList) → prod l → NativeIO Unit
putVar [] _ = nativeReturn unit
putVar (addVar A v []) a = nativePutVar {A} v a
putVar (addVar A v (addVar B v′ l)) (a , rest) =
nativePutVar {A} v a native>>= λ _ →
putVar (addVar B v′ l) rest
| 29.324324
| 71
| 0.574194
|
3d1ebcda32370e4e9841def1727a6d872b2ce7a8
| 3,110
|
agda
|
Agda
|
Grammar/Abstract.agda
|
nad/pretty
|
b956803ba90b6c5f57bbbaab01bb18485d948492
|
[
"MIT"
] | null | null | null |
Grammar/Abstract.agda
|
nad/pretty
|
b956803ba90b6c5f57bbbaab01bb18485d948492
|
[
"MIT"
] | null | null | null |
Grammar/Abstract.agda
|
nad/pretty
|
b956803ba90b6c5f57bbbaab01bb18485d948492
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Abstract grammars
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Grammar.Abstract where
open import Data.Bool
open import Data.Char
open import Data.Empty
open import Data.List
open import Data.Product
open import Data.Sum
open import Function
open import Relation.Binary.PropositionalEquality using (_≡_)
------------------------------------------------------------------------
-- Grammars
-- I use an abstract and general definition of grammars: a grammar is
-- a predicate that relates strings with parse results.
Grammar : Set → Set₁
Grammar A = A → List Char → Set
------------------------------------------------------------------------
-- Grammar combinators
-- A grammar for no strings.
fail : ∀ {A} → Grammar A
fail = λ _ _ → ⊥
-- Symmetric choice.
infixl 10 _∣_
_∣_ : ∀ {A} → Grammar A → Grammar A → Grammar A
g₁ ∣ g₂ = λ x s → g₁ x s ⊎ g₂ x s
-- Grammars for the empty string.
return : ∀ {A} → A → Grammar A
return x = λ y s → y ≡ x × s ≡ []
-- Map.
infixl 20 _<$>_ _<$_
_<$>_ : ∀ {A B} → (A → B) → Grammar A → Grammar B
f <$> g = λ x s → ∃ λ y → g y s × x ≡ f y
_<$_ : ∀ {A B} → A → Grammar B → Grammar A
x <$ g = const x <$> g
-- A sequencing combinator for partially applied grammars.
seq : (List Char → Set) → (List Char → Set) → (List Char → Set)
seq p₁ p₂ = λ s → ∃₂ λ s₁ s₂ → p₁ s₁ × p₂ s₂ × s ≡ s₁ ++ s₂
-- Monadic bind.
infixl 15 _>>=_ _>>_
_>>=_ : ∀ {A B} → Grammar A → (A → Grammar B) → Grammar B
g₁ >>= g₂ = λ y s → ∃ λ x → seq (g₁ x) (g₂ x y) s
_>>_ : ∀ {A B} → Grammar A → Grammar B → Grammar B
g₁ >> g₂ = g₁ >>= λ _ → g₂
-- "Applicative" sequencing.
infixl 20 _⊛_ _<⊛_ _⊛>_
_⊛_ : ∀ {A B} → Grammar (A → B) → Grammar A → Grammar B
g₁ ⊛ g₂ = g₁ >>= λ f → f <$> g₂
_<⊛_ : ∀ {A B} → Grammar A → Grammar B → Grammar A
g₁ <⊛ g₂ = λ x s → ∃ λ y → seq (g₁ x) (g₂ y) s
_⊛>_ : ∀ {A B} → Grammar A → Grammar B → Grammar B
_⊛>_ = _>>_
-- Kleene star.
infix 30 _⋆ _+
_⋆ : ∀ {A} → Grammar A → Grammar (List A)
(g ⋆) [] s = s ≡ []
(g ⋆) (x ∷ xs) s = seq (g x) ((g ⋆) xs) s
_+ : ∀ {A} → Grammar A → Grammar (List A)
(g +) [] s = ⊥
(g +) (x ∷ xs) s = (g ⋆) (x ∷ xs) s
-- Elements separated by something.
infixl 18 _sep-by_
_sep-by_ : ∀ {A B} → Grammar A → Grammar B → Grammar (List A)
g sep-by sep = _∷_ <$> g ⊛ (sep >> g) ⋆
-- A grammar for an arbitrary token.
token : Grammar Char
token = λ c s → s ≡ [ c ]
-- A grammar for a given token.
tok : Char → Grammar Char
tok c = λ c′ s → c′ ≡ c × token c′ s
-- A grammar for tokens satisfying a given predicate.
sat : (p : Char → Bool) → Grammar (∃ λ t → T (p t))
sat _ = λ { (c , _) s → token c s }
-- A grammar for whitespace.
whitespace : Grammar Char
whitespace = tok ' ' ∣ tok '\n'
-- A grammar for a given string.
string : List Char → Grammar (List Char)
string s = λ s′ s″ → s′ ≡ s × s″ ≡ s
-- A grammar for the given string, possibly followed by some
-- whitespace.
symbol : List Char → Grammar (List Char)
symbol s = string s <⊛ whitespace ⋆
| 23.208955
| 72
| 0.524116
|
df370493c6fe0e76d300f1e1bfefd154472ea146
| 2,797
|
agda
|
Agda
|
Definition/Typed/Consequences/Equality.agda
|
loic-p/logrel-mltt
|
2251b8da423be0c6fb916f2675d7bd8537e4cd96
|
[
"MIT"
] | null | null | null |
Definition/Typed/Consequences/Equality.agda
|
loic-p/logrel-mltt
|
2251b8da423be0c6fb916f2675d7bd8537e4cd96
|
[
"MIT"
] | null | null | null |
Definition/Typed/Consequences/Equality.agda
|
loic-p/logrel-mltt
|
2251b8da423be0c6fb916f2675d7bd8537e4cd96
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Consequences.Equality where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.EqRelInstance
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Fundamental.Reducibility
open import Tools.Embedding
open import Tools.Product
import Tools.PropositionalEquality as PE
U≡A′ : ∀ {A Γ l} ([U] : Γ ⊩⟨ l ⟩U)
→ Γ ⊩⟨ l ⟩ U ≡ A / (U-intr [U])
→ A PE.≡ U
U≡A′ (noemb [U]) (U₌ [U≡A]) = [U≡A]
U≡A′ (emb 0<1 [U]) (ιx [U≡A]) = U≡A′ [U] [U≡A]
-- If A is judgmentally equal to U, then A is propsitionally equal to U.
U≡A : ∀ {A Γ}
→ Γ ⊢ U ≡ A
→ A PE.≡ U
U≡A {A} U≡A with reducibleEq U≡A
U≡A {A} U≡A | [U] , [A] , [U≡A] =
U≡A′ (U-elim [U]) (irrelevanceEq [U] (U-intr (U-elim [U])) [U≡A])
ℕ≡A′ : ∀ {A Γ l} ([ℕ] : Γ ⊩⟨ l ⟩ℕ ℕ)
→ Γ ⊩⟨ l ⟩ ℕ ≡ A / (ℕ-intr [ℕ])
→ Whnf A
→ A PE.≡ ℕ
ℕ≡A′ (noemb x) (ιx (ℕ₌ [ℕ≡A])) whnfA = whnfRed* [ℕ≡A] whnfA
ℕ≡A′ (emb 0<1 [ℕ]) (ιx [ℕ≡A]) whnfA = ℕ≡A′ [ℕ] [ℕ≡A] whnfA
-- If A in WHNF is judgmentally equal to ℕ, then A is propsitionally equal to ℕ.
ℕ≡A : ∀ {A Γ}
→ Γ ⊢ ℕ ≡ A
→ Whnf A
→ A PE.≡ ℕ
ℕ≡A {A} ℕ≡A whnfA with reducibleEq ℕ≡A
ℕ≡A {A} ℕ≡A whnfA | [ℕ] , [A] , [ℕ≡A] =
ℕ≡A′ (ℕ-elim [ℕ]) (irrelevanceEq [ℕ] (ℕ-intr (ℕ-elim [ℕ])) [ℕ≡A]) whnfA
ne≡A′ : ∀ {A K Γ l}
→ ([K] : Γ ⊩⟨ l ⟩ne K)
→ Γ ⊩⟨ l ⟩ K ≡ A / (ne-intr [K])
→ Whnf A
→ ∃ λ M → Neutral M × A PE.≡ M
ne≡A′ (noemb [K]) (ιx (ne₌ M D′ neM K≡M)) whnfA =
M , neM , (whnfRed* (red D′) whnfA)
ne≡A′ (emb 0<1 [K]) (ιx [K≡A]) whnfA = ne≡A′ [K] [K≡A] whnfA
-- If A in WHNF is judgmentally equal to K, then there exists a M such that
-- A is propsitionally equal to M.
ne≡A : ∀ {A K Γ}
→ Neutral K
→ Γ ⊢ K ≡ A
→ Whnf A
→ ∃ λ M → Neutral M × A PE.≡ M
ne≡A {A} neK ne≡A whnfA with reducibleEq ne≡A
ne≡A {A} neK ne≡A whnfA | [ne] , [A] , [ne≡A] =
ne≡A′ (ne-elim neK [ne])
(irrelevanceEq [ne] (ne-intr (ne-elim neK [ne])) [ne≡A]) whnfA
Π≡A′ : ∀ {A F G Γ l} ([Π] : Γ ⊩⟨ l ⟩Π Π F ▹ G)
→ Γ ⊩⟨ l ⟩ Π F ▹ G ≡ A / (Π-intr [Π])
→ Whnf A
→ ∃₂ λ H E → A PE.≡ Π H ▹ E
Π≡A′ (noemb [Π]) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) whnfA =
F′ , G′ , whnfRed* D′ whnfA
Π≡A′ (emb 0<1 [Π]) (ιx [Π≡A]) whnfA = Π≡A′ [Π] [Π≡A] whnfA
-- If A is judgmentally equal to Π F ▹ G, then there exists H and E such that
-- A is propsitionally equal to Π H ▹ E.
Π≡A : ∀ {A F G Γ}
→ Γ ⊢ Π F ▹ G ≡ A
→ Whnf A
→ ∃₂ λ H E → A PE.≡ Π H ▹ E
Π≡A {A} Π≡A whnfA with reducibleEq Π≡A
Π≡A {A} Π≡A whnfA | [Π] , [A] , [Π≡A] =
Π≡A′ (Π-elim [Π]) (irrelevanceEq [Π] (Π-intr (Π-elim [Π])) [Π≡A]) whnfA
| 32.149425
| 80
| 0.543797
|
0e79fa7c05b86b73e4be6e69d150ee04912055a0
| 2,130
|
agda
|
Agda
|
Agda/Squaring.agda
|
Brethland/LEARNING-STUFF
|
eb2cef0556efb9a4ce11783f8516789ea48cc344
|
[
"MIT"
] | 2
|
2020-02-03T05:05:52.000Z
|
2020-03-11T10:35:42.000Z
|
Agda/Squaring.agda
|
Brethland/LEARNING-STUFF
|
eb2cef0556efb9a4ce11783f8516789ea48cc344
|
[
"MIT"
] | null | null | null |
Agda/Squaring.agda
|
Brethland/LEARNING-STUFF
|
eb2cef0556efb9a4ce11783f8516789ea48cc344
|
[
"MIT"
] | 1
|
2019-12-13T04:50:46.000Z
|
2019-12-13T04:50:46.000Z
|
{-# OPTIONS --safe #-}
module Squaring where
open import Relation.Binary.PropositionalEquality
open import Data.Nat
open import Data.Product
open import Data.Bool hiding (_≤_;_<_)
open import Data.Nat.Properties
open ≡-Reasoning
div-mod2 : ℕ → ℕ × Bool
div-mod2 0 = 0 , false
div-mod2 (suc 0) = 0 , true
div-mod2 (suc (suc n)) = let q , r = div-mod2 n in suc q , r
-- The first argument (k) helps Agda to prove
-- that the function terminates
pow-sqr-aux : ℕ → ℕ → ℕ → ℕ
pow-sqr-aux 0 _ _ = 1
pow-sqr-aux _ _ 0 = 1
pow-sqr-aux (suc k) b e with div-mod2 e
... | e' , false = pow-sqr-aux k (b * b) e'
... | e' , true = b * pow-sqr-aux k (b * b) e'
pow-sqr : ℕ → ℕ → ℕ
pow-sqr b e = pow-sqr-aux e b e
div-mod2-spec : ∀ n → let q , r = div-mod2 n in 2 * q + (if r then 1 else 0) ≡ n
div-mod2-spec 0 = refl
div-mod2-spec 1 = refl
div-mod2-spec (suc (suc n)) with div-mod2 n | div-mod2-spec n
... | q , r | eq rewrite +-suc q (q + 0) | eq = refl
div-mod2-lt : ∀ n → 0 < n → proj₁ (div-mod2 n) < n
div-mod2-lt 0 lt = lt
div-mod2-lt 1 lt = lt
div-mod2-lt 2 lt = s≤s (s≤s z≤n)
div-mod2-lt (suc (suc (suc n))) lt with
div-mod2 (suc n) | div-mod2-lt (suc n) (s≤s z≤n)
... | q , r | ih = ≤-step (s≤s ih)
pow-lemma : ∀ b e → (b * b) ^ e ≡ b ^ (2 * e)
pow-lemma b e = begin
(b * b) ^ e ≡⟨ cong (λ t → (b * t) ^ e) (sym (*-identityʳ b)) ⟩
(b ^ 2) ^ e ≡⟨ ^-*-assoc b 2 e ⟩
b ^ (2 * e) ∎
pow-sqr-lemma : ∀ k b e → e ≤ k → pow-sqr-aux k b e ≡ b ^ e
pow-sqr-lemma 0 _ 0 _ = refl
pow-sqr-lemma (suc k) _ 0 _ = refl
pow-sqr-lemma (suc k) b (suc e) (s≤s le) with
div-mod2 (suc e) | div-mod2-spec (suc e) | div-mod2-lt (suc e) (s≤s z≤n)
... | e' , false | eq | lt = begin
pow-sqr-aux k (b * b) e' ≡⟨ pow-sqr-lemma k (b * b) e' (≤-trans (≤-pred lt) le) ⟩
(b * b) ^ e' ≡⟨ pow-lemma b e' ⟩
b ^ (2 * e') ≡⟨ cong (b ^_) (trans (sym (+-identityʳ (e' + (e' + 0)))) eq) ⟩
b ^ suc e ∎
... | e' , true | eq | lt = cong (b *_) (begin
pow-sqr-aux k (b * b) e' ≡⟨ pow-sqr-lemma k (b * b) e' (≤-trans (≤-pred lt) le) ⟩
(b * b) ^ e' ≡⟨ pow-lemma b e' ⟩
b ^ (2 * e') ≡⟨ cong (b ^_) (suc-injective (trans (+-comm 1 _) eq)) ⟩
b ^ e ∎)
| 32.769231
| 83
| 0.541315
|
1aff282ebdecfdb8002d87d17de46eb12a9401fd
| 5,318
|
agda
|
Agda
|
doc/test.agda
|
StillerHarpo/masterarbeit
|
68afff2b0a7183751737ef20e713df1fef3d4cf2
|
[
"BSD-3-Clause"
] | null | null | null |
doc/test.agda
|
StillerHarpo/masterarbeit
|
68afff2b0a7183751737ef20e713df1fef3d4cf2
|
[
"BSD-3-Clause"
] | null | null | null |
doc/test.agda
|
StillerHarpo/masterarbeit
|
68afff2b0a7183751737ef20e713df1fef3d4cf2
|
[
"BSD-3-Clause"
] | null | null | null |
module test where
open import Relation.Binary.PropositionalEquality
module NewCodata where
open import Data.Nat
open import Data.List
open import Data.Maybe
record Pair (A B : Set) : Set where
field
fst : A
snd : B
record Stream (A : Set) : Set where
coinductive
field
hd : A
tl : Stream A
open Stream
repeat : ∀ {A : Set} → A → Stream A
hd (repeat x) = x
tl (repeat x) = repeat x
nth : ∀ {A : Set} → ℕ → Stream A → A
nth zero s = hd s
nth (suc n) s = nth n (tl s)
mutual
data μColist (A : Set) : Set where
[] : μColist A
_∷_ : (x : A) (xs : νColist A) → μColist A
record νColist (A : Set) : Set where
coinductive
field out : μColist A
open νColist
record νTree (A : Set) : Set where
coinductive
field label : A
subs : List (νTree A)
open νTree
append : {A : Set} → List A → νColist A → νColist A
out (append [] ys) = out ys
out (append (x ∷ xs) ys) = x ∷ append xs ys
appendS : {A : Set} → List A → Stream A → Stream A
hd (appendS [] s) = hd s
hd (appendS (x ∷ xs) s) = x
tl (appendS [] s) = tl s
tl (appendS (x ∷ xs) s) = tl (appendS xs s)
record Pi (A : Set) (B : A → Set) : Set where
field _$_ : (x : A) → B x
infixl 20 _$_
open Pi
_→'_ : Set → Set → Set
A →' B = Pi A (λ _ → B)
infixr 20 _→'_
plus2 : ℕ →' ℕ
plus2 $ x = suc (suc x)
plus : ℕ →' ℕ →' ℕ
plus $ 0 $ m = m
plus $ (suc n) $ m = suc (plus $ n $ m)
data Vec (A : Set) : ℕ → Set where
nil : Vec A 0
_:::_ : {n : ℕ} → A → Vec A n → Vec A (suc n)
test : Vec ℕ 2
test = 2 ::: (2 ::: nil)
repeat2V : Pi ℕ (λ n → Vec ℕ n)
repeat2V $ 0 = nil
repeat2V $ suc n = 2 ::: (repeat2V $ n)
{-
bf : {A : Set} → List (νTree A) → νColist A
out (bf []) = []
out (bf (t ∷ ts)) = label t ∷
append (map label ts)
(bf (concatMap subs (t ∷ ts)))
-}
record ℕ∞ : Set where
coinductive
field
pred∞ : Maybe ℕ∞
open ℕ∞
infinity : ℕ∞
pred∞ infinity = just infinity
zero∞ : ℕ∞
pred∞ zero∞ = nothing
one∞ : ℕ∞
pred∞ one∞ = just zero∞
suc∞ : ℕ∞ → ℕ∞
pred∞ (suc∞ x) = just x
plus∞ : ℕ∞ → ℕ∞ → ℕ∞
pred∞ (plus∞ n m) with pred∞ n
... | nothing = pred∞ m
... | just n' = just (plus∞ n' m)
{-
record PStr (A : Set) (n : ℕ∞) : Set where
coinductive
field
phd : (k : ℕ∞) → PStr A (suc∞ k) → A
ptl : (k : ℕ∞) → PStr A (suc∞ k) → PStr A k
-}
module OldCodata where
open import Codata.Musical.Notation
open import Data.Nat
data Stream (A : Set) : Set where
cons : A → ∞ (Stream A) → Stream A
repeat : {A : Set} → A → Stream A
repeat x = cons x (♯ (repeat x))
nth : {A : Set} → ℕ → Stream A → A
nth 0 (cons x _) = x
nth (suc n) (cons _ xs) = nth n (♭ xs)
data ℕ∞ : Set where
zero∞ : ℕ∞
suc∞ : ∞ (ℕ∞) → ℕ∞
infinity : ℕ∞
infinity = suc∞ (♯ infinity)
module NonTerminating where
open import Data.Nat
{-
_/_ : ℕ → ℕ → ℕ
zero / y = zero
suc x / y = suc ( (x ∸ y) / y)
-}
module PositiveSizedTypes where
open import Agda.Builtin.Size
data ℕ : Size → Set where
zero : {i : Size} → ℕ i
suc : {i : Size} → ℕ i → ℕ (↑ i)
one : ℕ ∞
one = suc zero
two : ℕ ∞
two = suc one
three : ℕ ∞
three = suc two
four : ℕ ∞
four = suc three
five : ℕ ∞
five = suc four
_-_ : {i : Size} → ℕ i → ℕ ∞ → ℕ i
zero - _ = zero
n - zero = n
(suc n) - (suc m) = n - m
infixl 20 _-_
-test₁ : five - two ≡ three
-test₁ = refl
_/_ : {i : Size} → ℕ i → ℕ ∞ → ℕ i
zero / _ = zero
suc x / y = suc ( (x - y) / y)
infixl 30 _/_
_+_ : ℕ ∞ → ℕ ∞ → ℕ ∞
zero + y = y
suc x + y = suc (x + y)
infixl 20 _+_
_*_ : ℕ ∞ → ℕ ∞ → ℕ ∞
zero * _ = zero
suc x * y = x + x * y
infixl 30 _*_
min : {i : Size} → ℕ i → ℕ i → ℕ i
min zero _ = zero
min _ zero = zero
min (suc m) (suc n) = suc (min m n)
test₁ : zero / zero ≡ zero
test₁ = refl
test₂ : zero / five ≡ zero
test₂ = refl
test₃ : one / one ≡ one
test₃ = refl
test₄ : two / two ≡ one
test₄ = refl
test₅ : five / five ≡ one
test₅ = refl
test₆ : one / zero ≡ one
test₆ = refl
test₇ : two / one ≡ one
test₇ = refl
test₈ : four / two ≡ two
test₈ = refl
module NegativSizedTypes where
open import Agda.Builtin.Size
open import Data.Nat
open import Data.Bool using (if_then_else_)
open import Relation.Nullary.Decidable using (⌊_⌋)
record Stream (i : Size) (A : Set) : Set where
coinductive
field
hd : A
tl : ∀ {j : Size< i} → Stream j A
open Stream
cons : {i : Size} {A : Set} → A -> Stream i A → Stream i A
hd (cons x _) = x
tl (cons _ xs) = xs
map : {A B : Set} {i : Size} → (A → B) → Stream i A → Stream i B
hd (map f xs) = f (hd xs)
tl (map f xs) = map f (tl xs)
merge : {i : Size} → Stream i ℕ → Stream i ℕ → Stream i ℕ
hd (merge xs ys) = hd xs ⊓ hd ys
tl (merge xs ys) = if ⌊ hd xs ≤? hd ys ⌋
then cons (hd ys) (merge (tl xs) (tl ys))
else cons (hd xs) (merge (tl xs) (tl ys))
ham : {i : Size} → Stream i ℕ
hd ham = 1
tl ham = (merge (map (_*_ 2) ham) (map (_*_ 3) ham))
| 21.272
| 66
| 0.503949
|
c7c9b398add3a7c3391f132d41fb2ba48e4916bb
| 2,522
|
agda
|
Agda
|
lib/Haskell/Prim/Bounded.agda
|
JonathanBrouwer/agda2hs
|
dcf63cc7ce51a325a97ac58bdd0aeace24c08b15
|
[
"MIT"
] | 55
|
2020-10-20T13:36:25.000Z
|
2022-03-26T21:57:56.000Z
|
lib/Haskell/Prim/Bounded.agda
|
SNU-2D/agda2hs
|
160478a51bc78b0fdab07b968464420439f9fed6
|
[
"MIT"
] | 63
|
2020-10-22T05:19:27.000Z
|
2022-02-25T15:47:30.000Z
|
lib/Haskell/Prim/Bounded.agda
|
SNU-2D/agda2hs
|
160478a51bc78b0fdab07b968464420439f9fed6
|
[
"MIT"
] | 18
|
2020-10-21T22:19:09.000Z
|
2022-03-12T11:42:52.000Z
|
module Haskell.Prim.Bounded where
open import Agda.Builtin.Nat
open import Agda.Builtin.Bool
open import Agda.Builtin.Char
open import Agda.Builtin.Equality
open import Agda.Builtin.List
open import Haskell.Prim
open import Haskell.Prim.Eq
open import Haskell.Prim.Int
open import Haskell.Prim.Maybe
open import Haskell.Prim.Ord
open import Haskell.Prim.Tuple
open import Haskell.Prim.Word
--------------------------------------------------
-- Bounded
record BoundedBelow (a : Set) : Set where
field
minBound : a
record BoundedAbove (a : Set) : Set where
field
maxBound : a
record Bounded (a : Set) : Set where
field
overlap ⦃ below ⦄ : BoundedBelow a
overlap ⦃ above ⦄ : BoundedAbove a
{-# COMPILE AGDA2HS Bounded existing-class #-}
open BoundedBelow ⦃ ... ⦄ public
open BoundedAbove ⦃ ... ⦄ public
instance
iBounded : ⦃ BoundedBelow a ⦄ → ⦃ BoundedAbove a ⦄ → Bounded a
iBounded .Bounded.below = it
iBounded .Bounded.above = it
instance
iBoundedBelowNatural : BoundedBelow Nat
iBoundedBelowNatural .minBound = 0
iBoundedBelowWord : BoundedBelow Word
iBoundedBelowWord .minBound = 0
iBoundedAboveWord : BoundedAbove Word
iBoundedAboveWord .maxBound = 18446744073709551615
iBoundedBelowInt : BoundedBelow Int
iBoundedBelowInt .minBound = -9223372036854775808
iBoundedAboveInt : BoundedAbove Int
iBoundedAboveInt .maxBound = 9223372036854775807
iBoundedBelowBool : BoundedBelow Bool
iBoundedBelowBool .minBound = false
iBoundedAboveBool : BoundedAbove Bool
iBoundedAboveBool .maxBound = true
iBoundedBelowChar : BoundedBelow Char
iBoundedBelowChar .minBound = '\0'
iBoundedAboveChar : BoundedAbove Char
iBoundedAboveChar .maxBound = '\1114111'
iBoundedBelowTuple₀ : BoundedBelow (Tuple [])
iBoundedBelowTuple₀ .minBound = []
iBoundedAboveTuple₀ : BoundedAbove (Tuple [])
iBoundedAboveTuple₀ .maxBound = []
iBoundedBelowTuple : ∀ {as} → ⦃ BoundedBelow a ⦄ → ⦃ BoundedBelow (Tuple as) ⦄ → BoundedBelow (Tuple (a ∷ as))
iBoundedBelowTuple .minBound = minBound ∷ minBound
iBoundedAboveTuple : ∀ {as} → ⦃ BoundedAbove a ⦄ → ⦃ BoundedAbove (Tuple as) ⦄ → BoundedAbove (Tuple (a ∷ as))
iBoundedAboveTuple .maxBound = maxBound ∷ maxBound
iBoundedBelowOrdering : BoundedBelow Ordering
iBoundedBelowOrdering .minBound = LT
iBoundedAboveOrdering : BoundedAbove Ordering
iBoundedAboveOrdering .maxBound = GT
-- Sanity checks
private
_ : addWord maxBound 1 ≡ minBound
_ = refl
_ : addInt maxBound 1 ≡ minBound
_ = refl
| 27.714286
| 112
| 0.735527
|
a102fd19b4d0ca9bba6330a618d6dc03e423eeec
| 1,124
|
agda
|
Agda
|
examples/Introduction/Data/Parameterised.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/Introduction/Data/Parameterised.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/Introduction/Data/Parameterised.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- This module introduces parameterised datatypes.
module Introduction.Data.Parameterised where
-- First some of our old friends.
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Bool : Set where
false : Bool
true : Bool
-- A datatype can be parameterised over a telescope, (A : Set) in the case of
-- lists. The parameters are bound in the types of the constructors.
data List (A : Set) : Set where
nil : List A
cons : A -> List A -> List A
-- When using the constructors the parameters to the datatype becomes implicit
-- arguments. In this case, the types of the constructors are :
-- nil : {A : Set} -> List A
-- cons : {A : Set} -> A -> List A -> List A
-- So, we can write
nilNat = nil {Nat} -- the type of this will be List Nat
-- When pattern matching on elements of a parameterised datatype you cannot
-- refer to the parameters--it wouldn't make sense to pattern match on the
-- element type of the list. So you can say
null : {A : Set} -> List A -> Bool
null nil = true
null (cons _ _) = false
-- but not
-- null (nil {A}) = true
-- null (cons {A} _ _) = false
| 24.434783
| 78
| 0.660142
|
040932de07207c23764a135ee41ff80587a1da0f
| 1,883
|
agda
|
Agda
|
test/Succeed/Issue1606.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue1606.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue1606.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
-- Andreas, 2015-07-07 continuation of issue 665
{-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.with.strip:60 -v tc.lhs:10 #-}
postulate
C : Set
anything : C
record I : Set where
constructor c
field
f : C
data Wrap : (j : I) → Set where
wrap : ∀ {j} → Wrap j
works1 : ∀ {j} → Wrap j → C
works1 {c ._} (wrap {c x}) with anything
... | z = z
works2 : ∀ {j} → Wrap j → C
works2 (wrap {_}) with anything
... | z = z
works3 : ∀ {j} → Wrap j → C
works3 wrap with anything
... | z = z
works : ∀ {j} → Wrap j → C
works {c _} (wrap {c ._}) with anything
works {c _} (wrap .{c _}) | z = z
-- The following should not pass, but issue 142 is hard to fix
-- with the current infrastructure for with-clauses.
-- Not many attempts have been made since 2009, and none succeeded.
issue142 : ∀ {j} → Wrap j → C
issue142 {c _} (wrap {c ._}) with anything
issue142 {c _} (wrap .{c anything}) | z = z
test : ∀ {j} → Wrap j → C
test {c _} (wrap {c ._}) with anything
test {c _} (wrap {c ._}) | z = z
test' : ∀ {j} → Wrap j → C
test' {c _} (wrap {c ._}) with anything
... | z = z
-- ERROR WAS::
-- Inaccessible (dotted) patterns from the parent clause must also be
-- inaccessible in the with clause, when checking the pattern {c ._},
-- when checking that the clause
-- test {c _} (wrap {c ._}) with anything
-- test {c _} (wrap {c ._}) | z = z
-- has type {j : I} → Wrap j → C
works1a : ∀ {j} → Wrap j → C
works1a {c ._} (wrap {c x}) with anything
works1a {c ._} (wrap {c x}) | z = z
works1b : ∀ {j} → Wrap j → C
works1b {c ._} (wrap {c x}) with anything
works1b .{c _} (wrap {c x}) | z = z
-- ERROR WAS:
-- With clause pattern .(c _) is not an instance of its parent pattern
-- (c .(Var 0 []) : {I})
-- when checking that the clause
-- works1b {c ._} (wrap {c _}) with anything
-- works1b {.(c _)} (wrap {c _}) | z = z
-- has type {j : I} → Wrap j → C
-- should pass
| 25.445946
| 70
| 0.584174
|
06e504ae30a3c0068b4f3bbe2e3bf7861dc19d34
| 1,381
|
agda
|
Agda
|
old/Algebra/F2NotCommutative.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
old/Algebra/F2NotCommutative.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
old/Algebra/F2NotCommutative.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K #-}
open import Base
module Algebra.F2NotCommutative where
import Algebra.FreeGroup
open Algebra.FreeGroup (bool {zero}) renaming (freegroup to F2)
X : Set
X = bool × bool
X-is-set : is-set X
X-is-set = ×-is-truncated _ bool-is-set bool-is-set
pattern a = (true , true )
pattern b = (true , false)
pattern c = (false , true )
pattern d = (false , false)
-- [map1] and [map2] are two involutive noncommutating bijections of [X]
map1 : X → X
map1 a = b
map1 b = a
map1 c = c
map1 d = d
map2 : X → X
map2 a = c
map2 b = b
map2 c = a
map2 d = d
act : bool {zero} → (X → X)
act true = map1
act false = map2
act-involutive : (b : bool) (x : X) → (act b (act b x) ≡ x)
act-involutive true a = refl
act-involutive true b = refl
act-involutive true c = refl
act-involutive true d = refl
act-involutive false a = refl
act-involutive false b = refl
act-involutive false c = refl
act-involutive false d = refl
F2-act-on-X : F2 → (X → X)
F2-act-on-X = freegroup-rec-nondep (X → X)
(id X)
(λ b f → f ◯ act b)
(λ b f → f ◯ act b)
(λ b f → funext (λ x → ap f (act-involutive b x)))
(λ b f → funext (λ x → ap f (act-involutive b x)))
(→-is-truncated _ X-is-set)
ab : F2
ab = true · (false · e)
ba : F2
ba = false · (true · e)
F2-non-commutative : ab ≢ ba
F2-non-commutative p =
bool-true≢false (base-path (happly (ap F2-act-on-X p) a))
| 20.61194
| 72
| 0.627082
|
2272611732b70098d781dee57ee57c18dacef652
| 8,905
|
agda
|
Agda
|
Structure/Container/IndexedIterable.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Container/IndexedIterable.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Container/IndexedIterable.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
open import Type
module Structure.Container.IndexedIterable {ℓᵢ} {Index : Type{ℓᵢ}} where
import Lvl
open import Data
open import Data.Boolean
open import Data.Boolean.Stmt
open import Data.Option
import Data.Option.Functions as Option
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Functional
open import Logic.Propositional
open import Logic.Predicate
open import Numeral.Natural
open import Numeral.Natural.Relation.Order
open import Relator.Equals
private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level
private variable T : Type{ℓ}
private variable Elem : Type{ℓₑ}
private variable i : Index
module _ (Iter : Index → Type{ℓ}) where
IsEmptyTypeFn = ∀{i} → Iter(i) → Bool
IndexStepFn : IsEmptyTypeFn → Type
IndexStepFn isEmpty = ∀{i} → (iter : Iter(i)) → (if isEmpty(iter) then Unit else Index)
CurrentFn : Type{ℓₑ} → IsEmptyTypeFn → Type
CurrentFn Element isEmpty = ∀{i} → (iter : Iter(i)) → (if isEmpty(iter) then Unit else Element)
StepFn : Type{ℓₑ} → (isEmpty : IsEmptyTypeFn) → IndexStepFn isEmpty → Type
StepFn Element isEmpty indexStep = ∀{i} → (iter : Iter(i)) → Out iter where
Out : Iter(i) → Type
Out iter with isEmpty iter | indexStep iter
... | 𝑇 | <> = Unit
... | 𝐹 | is = Iter(is)
-- An iterator type `Iter` is iterable when there may be elements that the iterator can yield in sequence.
-- It should be possible to decide whether the iterator is empty, and when it is not, get the element it points to and advancing to its next state containing the next element in order.
record Iterable (Iter : Index → Type{ℓ}) {ℓₑ} : Type{ℓ Lvl.⊔ ℓᵢ Lvl.⊔ Lvl.𝐒(ℓₑ)} where
field
-- The type of the elements in the iterator.
{Element} : Type{ℓₑ}
-- Whether there are no elements left in the iterator.
isEmpty : IsEmptyTypeFn(Iter)
-- The current/frontmost element in the iterator if it is non-empty.
current : CurrentFn(Iter) Element isEmpty
-- The next iterator index. Advances the index if the iterator is non-empty.
{indexStep} : IndexStepFn(Iter) isEmpty
-- The next iterator state. Advancing the iterator if it is non-empty.
step : StepFn(Iter) Element isEmpty indexStep
-- Whether there are at most the given number of elements in the iterator.
atMost : ℕ → Iter(i) → Bool
atMost(𝟎) iter = isEmpty(iter)
atMost(𝐒(n)) iter with isEmpty(iter) | indexStep iter | step iter
... | 𝑇 | <> | <> = 𝑇
... | 𝐹 | _ | is = atMost(n) is
-- Skipping the given number of iterator indices. Advances as many steps as possible.
indexWalk : (n : ℕ) → (iter : Iter(i)) → (if(atMost n iter) then Unit else Index)
indexWalk {i} 𝟎 iter with isEmpty(iter)
... | 𝑇 = <>
... | 𝐹 = i
indexWalk {i} (𝐒(n)) iter with isEmpty(iter) | indexStep iter | step iter
... | 𝑇 | <> | <> = <>
... | 𝐹 | _ | iters = indexWalk n iters
WalkFn : Type
WalkFn = ∀{i} → (n : ℕ) → (iter : Iter(i)) → Out n iter where
Out : ℕ → Iter(i) → Type
Out n iter with atMost n iter | indexWalk n iter
... | 𝑇 | <> = Unit
... | 𝐹 | is = Iter(is)
{-
walk : WalkFn
walk(𝟎) iter with isEmpty(iter)
... | 𝑇 = <>
... | 𝐹 = iter
walk(𝐒(n)) iter with isEmpty(iter) | indexStep iter | step iter | walk n iter
... | 𝑇 | <> | <> | _ = <>
... | 𝐹 | _ | iters | iters2 = ? -- walk n iters
-}
Foldᵣ : ∀{ℓ} → Type{ℓ} → Type
Foldᵣ(T) = ∀{i} → (Element → T → T) → T → Iter(i) → T
FoldᵣCriteria : Foldᵣ(T) → (∀{i} → (Element → T → T) → T → Iter(i) → Type)
FoldᵣCriteria foldᵣ(_▫_) id iter with isEmpty iter | indexStep iter | current iter | step iter
... | 𝑇 | <> | <> | <> = (foldᵣ(_▫_) id iter ≡ id)
... | 𝐹 | _ | x | iters = (foldᵣ(_▫_) id iter ≡ x ▫ foldᵣ(_▫_) id iters)
-- An iterator is finite when it is possible to fold it (when a fold function exists).
-- This works because a fold for an infinite iterator cannot terminate, and only terminating functions exist.
-- TODO: But it seems to be impossible to define a "foldUntil" function (though it is up to function extensionality).
Finite = ∀{ℓ}{T : Type{ℓ}} → ∃{Obj = Foldᵣ(T)}(foldᵣ ↦ ∀{i}{_▫_}{id : T}{iter : Iter(i)} → FoldᵣCriteria (\{i}(_▫_) id → foldᵣ{i}(_▫_) id) (_▫_) id iter)
module _ ⦃ fin : Finite ⦄ where
foldᵣ : ∀{i} → (Element → T → T) → T → Iter(i) → T
foldᵣ = [∃]-witness fin
length : ∀{i} → Iter(i) → ℕ
length = foldᵣ(const 𝐒) 𝟎
count : ∀{i} → (Element → Bool) → Iter(i) → ℕ
count(P) = foldᵣ(x ↦ if P(x) then 𝐒 else id) 𝟎
foldₗ : (T → Element → T) → T → Iter(i) → T
foldₗ(_▫_) = swap(foldᵣ(y ↦ f ↦ x ↦ f(x ▫ y)) id)
last : ∀{i} → Iter(i) → Option(Element)
last = foldₗ(const Some) None
-- Note: Below are possibly inefficient implementations of functions because if they were guaranteed to exit early, the number of computations would be reduced.
first : ∀{i} → Iter(i) → Option(Element)
first = foldᵣ(const ∘ Some) None
-- TODO: Complete = Surjective(step)
record Initialed (i : Index) : Type{ℓᵢ Lvl.⊔ ℓ} where
constructor initialed
eta-equality
field
iter : Iter(i)
left : ℕ
Initialed-iterable : Iterable(Initialed)
Element Initialed-iterable = Element
isEmpty Initialed-iterable (initialed iter 𝟎) = 𝑇
current Initialed-iterable (initialed iter 𝟎) = <>
indexStep Initialed-iterable (initialed iter 𝟎) = <>
step Initialed-iterable (initialed iter 𝟎) = <>
isEmpty Initialed-iterable (initialed iter (𝐒(_))) = isEmpty iter
current Initialed-iterable (initialed iter (𝐒(_))) = current iter
indexStep Initialed-iterable (initialed iter (𝐒(_))) = indexStep iter
step Initialed-iterable (initialed iter (𝐒(n))) with isEmpty iter | indexStep iter | step iter
... | 𝑇 | _ | _ = <>
... | 𝐹 | _ | sIter = initialed sIter n
{-
record Skipped (i : Index) : Type{ℓᵢ Lvl.⊔ ℓ} where
constructor skipped
eta-equality
field
iter : Iter(i)
still : ℕ
Skipped-iterable : Iterable(Skipped)
Element Skipped-iterable = Element
isEmpty Skipped-iterable (skipped iter 𝟎) = 𝑇
current Skipped-iterable (skipped iter 𝟎) = <>
indexStep Skipped-iterable (skipped iter 𝟎) = <>
step Skipped-iterable (skipped iter 𝟎) = <>
isEmpty Skipped-iterable (skipped iter (𝐒(_))) = isEmpty (walk (𝐒(n)) iter)
current Skipped-iterable (skipped iter (𝐒(_))) = current (walk (𝐒(n)) iter)
indexStep Skipped-iterable (skipped iter (𝐒(_))) = indexStep (walk (𝐒(n)) iter)
step Skipped-iterable (skipped iter (𝐒(n))) with isEmpty iter | indexStep iter | step iter
-}
mapped : (Element → Elem) → Iterable(Iter)
Element (mapped {Elem = Elem} f) = Elem
isEmpty (mapped f) = isEmpty
current (mapped f) iter with isEmpty iter | current iter
... | 𝑇 | <> = <>
... | 𝐹 | x = f(x)
indexStep (mapped f) iter = indexStep iter
step (mapped f) iter = step iter
{-record Stored (n : ℕ) {Iter : Index → Type{ℓ₁}} (iterable : Iterable(Iter)) : Type where
field
Queue(Iterator.Element(iterable))
-}
{- TODO: Also needs to store data, so it cannot be the same Iter
skipped : ℕ → Iterator{ℓₑ} → Iterator
Iterator.Element (skipped _ iterator) = Iterator.Element iterator
Iterator.isEmpty (skipped n iterator) = Iterator.atMost n iterator
Iterator.current (skipped _ iterator) =
Iterator.indexStep (skipped iterator) =
Iterator.step (skipped iterator) =
-}
{-
skipped : ℕ → ∀{iter} → Iterable{ℓₑ}(iter) → Iterable(iter)
skipped 𝟎 iterable = iterable
skipped (𝐒 n) iterable = {!!}
-}
-- An empty iterator of the iterable.
EmptyConstruction : ∀{i} → Iter(i) → Type
EmptyConstruction(empty) = IsTrue(isEmpty empty)
-- A function prepending an element to an iterator of the iterable.
PrependConstruction : ∀{indexPrepend : ∀{i} → Element → Iter(i) → Index} → (∀{i} → (x : Element) → (iter : Iter(i)) → Iter(indexPrepend x iter)) → Type
PrependConstruction{indexPrepend} (prepend) = ∀{i}{x}{iter : Iter(i)} → ∃{Obj = IndexStep x iter}(Out x iter) where
IndexStep : Element → Iter(i) → Type
IndexStep{i} x iter with isEmpty(prepend x iter) | indexStep(prepend x iter)
... | 𝑇 | _ = Empty
... | 𝐹 | p = (p ≡ i)
Out : (x : Element) → (iter : Iter(i)) → IndexStep x iter → Type
Out x iter stepProof with isEmpty(prepend x iter) | indexStep(prepend x iter) | current(prepend x iter) | step(prepend x iter)
... | 𝐹 | _ | cur | st with [≡]-intro ← stepProof = (x ≡ cur) ∧ (st ≡ iter)
module _
{indexEmpty}{empty}
⦃ empty-construciton : EmptyConstruction{indexEmpty}(empty) ⦄
{indexPrepend : ∀{i} → Element → Iter(i) → Index}
{prepend : ∀{i} → (x : Element) → (iter : Iter(i)) → Iter(indexPrepend x iter)}
⦃ prepend-construction : PrependConstruction{indexPrepend}(prepend) ⦄
where
singleton : (x : Element) → Iter(indexPrepend x empty)
singleton x = prepend x empty
| 40.294118
| 184
| 0.634812
|
1a64dc48bac7f97aa4dc617eca9da5532fd26ebb
| 658
|
agda
|
Agda
|
Pi-/Everything.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
Pi-/Everything.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
Pi-/Everything.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
module Pi-.Everything where
open import Pi-.Syntax -- Syntax of Pi-
open import Pi-.Opsem -- Abstract machine semantics of Pi-
open import Pi-.AuxLemmas -- Some auxiliary lemmas about opsem for forward/backward deterministic proof
open import Pi-.NoRepeat -- Forward/backward deterministic lemmas and Non-repeating lemma
open import Pi-.Invariants -- Some invariants about abstract machine semantics
open import Pi-.Eval -- Evaluator for Pi-
open import Pi-.Interp -- Big-step intepreter for Pi-
open import Pi-.Properties -- Properties of Pi-
open import Pi-.Examples -- Examples
open import Pi-.Category -- Pi- Category
| 54.833333
| 105
| 0.737082
|
adfbc15cfda13e2b463866fc81604bb5908be255
| 766
|
agda
|
Agda
|
type-level.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
type-level.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
type-level.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
module type-level where
open import bool
open import level
open import nat
{- multiApply{n} applies a sequence f1, f2, ..., f_n of functions
to a starting point a:
multiApply{n} a f1 f2 ... f_n = f_n (... (f2 (f1 a)))
-}
multiApplyTh : ℕ → Set → Set lone
multiApplyTh 0 A = Lift A
multiApplyTh (suc n) A = ∀{B : Set} → (A → B) → multiApplyTh n B
multiApplyT : ℕ → Set lone
multiApplyT n = ∀{A : Set} → A → multiApplyTh n A
multiApply-testT = multiApplyT 2
multiApplyh : {A : Set}{n : ℕ} → A → multiApplyTh n A
multiApplyh {n = zero} a = lift a
multiApplyh {n = suc n} a f = multiApplyh{n = n} (f a)
multiApply : {n : ℕ} → multiApplyT n
multiApply = λ a → multiApplyh a
multiApply-test1 : Lift 𝔹
multiApply-test1 = multiApply{3} 3 (_+_ 3) is-even ~_
| 24.709677
| 66
| 0.651436
|
0487d1136a2ec78616b74844a856227063e975db
| 4,509
|
agda
|
Agda
|
src/Categories/Category/Monoidal/Utilities.agda
|
sstucki/agda-categories
|
602ed2ae05dd449d77fc299c07a1cdd02ee5b823
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Monoidal/Utilities.agda
|
sstucki/agda-categories
|
602ed2ae05dd449d77fc299c07a1cdd02ee5b823
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Monoidal/Utilities.agda
|
sstucki/agda-categories
|
602ed2ae05dd449d77fc299c07a1cdd02ee5b823
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category; module Commutation)
open import Categories.Category.Monoidal.Core using (Monoidal)
module Categories.Category.Monoidal.Utilities {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where
open import Level
open import Function using (_$_)
open import Data.Product using (_×_; _,_; curry′)
open import Categories.Category.Product
import Categories.Category.Construction.Core as Core
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Bifunctor using (Bifunctor; appˡ; appʳ)
open import Categories.Functor.Properties using ([_]-resp-≅)
open import Categories.NaturalTransformation renaming (id to idN)
open import Categories.NaturalTransformation.NaturalIsomorphism
hiding (unitorˡ; unitorʳ; associator; _≃_)
--open import Categories.Morphism C using (_≅_)
--open import Categories.Morphism.IsoEquiv C using (_≃_; ⌞_⌟)
open import Categories.Morphism.Isomorphism C using (lift-triangle′; lift-pentagon′)
open import Categories.Morphism.Reasoning C
private
module C = Category C
open C hiding (identityˡ; identityʳ; assoc)
open Commutation C
open Core.Shorthands C
private
variable
X Y Z W A B : Obj
f g h i a b : X ⇒ Y
open Monoidal M
-- for exporting, it makes sense to use the above long names, but for
-- internal consumption, the traditional (short!) categorical names are more
-- convenient. However, they are not symmetric, even though the concepts are, so
-- we'll use ⇒ and ⇐ arrows to indicate that
module Shorthands where
λ⇒ = unitorˡ.from
λ⇐ = unitorˡ.to
ρ⇒ = unitorʳ.from
ρ⇐ = unitorʳ.to
-- eta expansion fixes a problem in 2.6.1, will be reported
α⇒ = λ {X} {Y} {Z} → associator.from {X} {Y} {Z}
α⇐ = λ {X} {Y} {Z} → associator.to {X} {Y} {Z}
open Shorthands
private
[x⊗y]⊗z : Bifunctor (Product C C) C C
[x⊗y]⊗z = ⊗ ∘F (⊗ ⁂ idF)
-- note how this one needs re-association to typecheck (i.e. be correct)
x⊗[y⊗z] : Bifunctor (Product C C) C C
x⊗[y⊗z] = ⊗ ∘F (idF ⁂ ⊗) ∘F assocˡ _ _ _
unitor-coherenceʳ : [ (A ⊗₀ unit) ⊗₀ unit ⇒ A ⊗₀ unit ]⟨ ρ⇒ ⊗₁ C.id ≈ ρ⇒ ⟩
unitor-coherenceʳ = cancel-fromˡ unitorʳ unitorʳ-commute-from
unitor-coherenceˡ : [ unit ⊗₀ unit ⊗₀ A ⇒ unit ⊗₀ A ]⟨ C.id ⊗₁ λ⇒ ≈ λ⇒ ⟩
unitor-coherenceˡ = cancel-fromˡ unitorˡ unitorˡ-commute-from
-- All the implicits below can be inferred, but being explicit is clearer
unitorˡ-naturalIsomorphism : NaturalIsomorphism (unit ⊗-) idF
unitorˡ-naturalIsomorphism = record
{ F⇒G = ntHelper record
{ η = λ X → λ⇒ {X}
; commute = λ f → unitorˡ-commute-from {f = f}
}
; F⇐G = ntHelper record
{ η = λ X → λ⇐ {X}
; commute = λ f → unitorˡ-commute-to {f = f}
}
; iso = λ X → unitorˡ.iso {X}
}
unitorʳ-naturalIsomorphism : NaturalIsomorphism (-⊗ unit) idF
unitorʳ-naturalIsomorphism = record
{ F⇒G = ntHelper record
{ η = λ X → ρ⇒ {X}
; commute = λ f → unitorʳ-commute-from {f = f}
}
; F⇐G = ntHelper record
{ η = λ X → ρ⇐ {X}
; commute = λ f → unitorʳ-commute-to {f = f}
}
; iso = λ X → unitorʳ.iso {X}
}
-- skipping the explicit arguments here, it does not increase understandability
associator-naturalIsomorphism : NaturalIsomorphism [x⊗y]⊗z x⊗[y⊗z]
associator-naturalIsomorphism = record
{ F⇒G = ntHelper record
{ η = λ { ((X , Y) , Z) → α⇒ {X} {Y} {Z}}
; commute = λ _ → assoc-commute-from
}
; F⇐G = ntHelper record
{ η = λ _ → α⇐
; commute = λ _ → assoc-commute-to
}
; iso = λ _ → associator.iso
}
module unitorˡ-natural = NaturalIsomorphism unitorˡ-naturalIsomorphism
module unitorʳ-natural = NaturalIsomorphism unitorʳ-naturalIsomorphism
module associator-natural = NaturalIsomorphism associator-naturalIsomorphism
infixr 10 _⊗ᵢ_
_⊗ᵢ_ : X ≅ Y → Z ≅ W → X ⊗₀ Z ≅ Y ⊗₀ W
f ⊗ᵢ g = [ ⊗ ]-resp-≅ record
{ from = from f , from g
; to = to f , to g
; iso = record
{ isoˡ = isoˡ f , isoˡ g
; isoʳ = isoʳ f , isoʳ g
}
}
triangle-iso : idᵢ ⊗ᵢ unitorˡ ∘ᵢ associator ≈ᵢ unitorʳ {X} ⊗ᵢ idᵢ {Y}
triangle-iso = ⌞ triangle ⌟
triangle-inv : α⇐ ∘ id ⊗₁ λ⇐ ≈ ρ⇐ {X} ⊗₁ id {Y}
triangle-inv = to-≈ triangle-iso
pentagon-iso :
idᵢ ⊗ᵢ associator ∘ᵢ associator ∘ᵢ associator {X} {Y} {Z} ⊗ᵢ idᵢ {W}
≈ᵢ associator ∘ᵢ associator
pentagon-iso = ⌞ pentagon ⌟
pentagon-inv : (α⇐ {X} {Y} {Z} ⊗₁ id {W} ∘ α⇐) ∘ id ⊗₁ α⇐ ≈ α⇐ ∘ α⇐
pentagon-inv = to-≈ pentagon-iso
refl⊗refl≃refl : idᵢ {A} ⊗ᵢ idᵢ {B} ≈ᵢ idᵢ
refl⊗refl≃refl = ⌞ ⊗.identity ⌟
| 31.3125
| 97
| 0.657352
|
ad2fd123812882ef050956109e1c446d11f4f0f0
| 212
|
agda
|
Agda
|
archive/agda-3/src/Oscar/Class/Pure.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-3/src/Oscar/Class/Pure.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-3/src/Oscar/Class/Pure.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
open import Oscar.Prelude
module Oscar.Class.Pure where
module _
{𝔬 𝔣}
(𝔉 : Ø 𝔬 → Ø 𝔣)
where
𝓹ure = ∀ {𝔒 : Ø 𝔬} → 𝔒 → 𝔉 𝔒
record 𝓟ure : Ø 𝔣 ∙̂ ↑̂ 𝔬 where
field pure : 𝓹ure
open 𝓟ure ⦃ … ⦄ public
| 15.142857
| 33
| 0.570755
|
317a8de5a527d5dc51a7e69e0bbbeef029ecfdb0
| 2,365
|
agda
|
Agda
|
src/Typed/STLC/Delay.agda
|
laMudri/linear.agda
|
461077552d88141ac1bba044aa55b65069c3c6c0
|
[
"MIT"
] | 34
|
2019-12-20T13:57:50.000Z
|
2021-02-03T15:22:33.000Z
|
src/Typed/STLC/Delay.agda
|
laMudri/linear.agda
|
461077552d88141ac1bba044aa55b65069c3c6c0
|
[
"MIT"
] | null | null | null |
src/Typed/STLC/Delay.agda
|
laMudri/linear.agda
|
461077552d88141ac1bba044aa55b65069c3c6c0
|
[
"MIT"
] | 2
|
2020-01-30T14:15:14.000Z
|
2020-05-23T00:34:36.000Z
|
open import Data.Nat
open import Data.Bool
open import Data.Product
open import Function
open import Data.List hiding (lookup)
open import Data.List.All
open import Data.List.Membership.Propositional
open import Data.Maybe.Categorical
open import Category.Monad
open import Agda.Primitive
open import Size
open import Codata.Thunk
open import Codata.Delay
open import Codata.Delay.Categorical
module Typed.STLC.Delay where
data Ty : Set where
numt boolt : Ty
_⟶_ : Ty → Ty → Ty
data Expr : List Ty → Ty → Set where
add : ∀ {Γ} →
Expr Γ numt → Expr Γ numt →
Expr Γ numt
num : ∀ {Γ} →
ℕ →
Expr Γ numt
true′ false′ : ∀ {Γ} →
Expr Γ boolt
if′_then_else : ∀ {Γ} →
∀ {t} → Expr Γ boolt → Expr Γ t → Expr Γ t →
Expr Γ t
ƛ_ : ∀ {Γ t₁ t₂} →
Expr (t₁ ∷ Γ) t₂ →
Expr Γ (t₁ ⟶ t₂)
_∙_ : ∀ {Γ t₁ t₂} →
Expr Γ (t₁ ⟶ t₂) → Expr Γ t₁ →
Expr Γ t₂
var : ∀ {Γ t} →
t ∈ Γ →
Expr Γ t
mutual
data Val : Ty → Set where
numv : ℕ → Val numt
boolv : Bool → Val boolt
⟨ƛ_,_⟩ : ∀ {Γ t₁ t₂} → Expr (t₁ ∷ Γ) t₂ → Env Γ → Val (t₁ ⟶ t₂)
Env : List Ty → Set
Env Γ = All Val Γ
ReaderT : ∀ {a} {M : Set a → Set a} (R : Set a) → RawMonad M → RawMonad (λ A → R → M A)
ReaderT _ M = record { return = λ a _ → return a ;
_>>=_ = λ f k r → f r >>= λ x → k x r }
where open RawMonad M
module _ {Γ : List Ty} {i} where
open RawMonad {lzero} (ReaderT (Env Γ) (Sequential.monad {i})) public
M : List Ty → Size → Set → Set
M Γ i A = Env Γ → Delay A i
getEnv : ∀ {Γ i} → M Γ i (Env Γ)
getEnv E = now E
withEnv : ∀ {Γ Γ' i A} → Env Γ → M Γ i A → M Γ' i A
withEnv E m _ = m E
get : ∀ {Γ t i} → t ∈ Γ → M Γ i (Val t)
get x E = now (lookup E x)
mutual
eval : ∀ {Γ t} → Expr Γ t → ∀ {i} → M Γ i (Val t)
eval (add e₁ e₂) = do
numv n₁ ← eval e₁
numv n₂ ← eval e₁
return (numv (n₁ + n₂))
eval (num n) = do
return (numv n)
eval true′ = do
return (boolv true)
eval false′ = do
return (boolv false)
eval (if′ c then t else e) = do
(boolv b) ← eval c
if b then eval t else eval e
eval (ƛ e) = do
E ← getEnv
return ⟨ƛ e , E ⟩
eval (f ∙ a) = do
⟨ƛ e , E ⟩ ← eval f
v ← eval a
withEnv (v ∷ E) (▹eval e)
eval (var x) = do
get x
▹eval : ∀ {Γ i t} → Expr Γ t → M Γ i (Val t)
▹eval e E = later λ where .force → eval e E
| 23.186275
| 87
| 0.55518
|
adaa96f6b723b18eb66d2d571c7066f10688b4df
| 1,244
|
agda
|
Agda
|
test/interaction/Auto-Modules.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Auto-Modules.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Auto-Modules.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Auto-Modules where
open import Auto.Prelude hiding (cong; trans)
module NonemptySet (X : Set) (x : X) where
h0 : (P : X → Set) → (∀ x → P x) → Σ X P
h0 = {!!}
-- h0 = λ P h → Σ-i x (h x)
module WithRAA (RAA : ∀ A → ¬ (¬ A) → A) where
h1 : ∀ A → A ∨ ¬ A
h1 = {!!}
--h1 = λ A → RAA (A ∨ ((x : A) → ⊥)) (λ z → z (∨-i₂ (λ x → z (∨-i₁ x))))
module B where
h2 : ∀ A → A ∨ ¬ A
h2 = {!!}
module A (X : Set) (x : X) where
postulate AllSame : {x y : X} → x ≡ y
n0 : (P : X → Set) → Σ X P → ∀ x → P x
-- n0 = {!subst AllSame!} -- no solution found
n0 = λ P h x → subst P (Σ.wit h) x AllSame (Σ.prf h)
module B (X : Set) (x y : X) (P : X → Set) where
postulate p : P x
h3 : P x
h3 = {!p!}
-- h3 = p
module Setoid (X : Set)
(Eq : X → X → Set)
(refl : ∀ {x} → Eq x x)
(symm : ∀ {x₁ x₂} → Eq x₁ x₂ → Eq x₂ x₁)
(subst : ∀ {x₁ x₂} → (P : X → Set) → Eq x₁ x₂ → P x₁ → P x₂)
where
cong : ∀ {x₁ x₂} → (f : X → X) → Eq x₁ x₂ → Eq (f x₁) (f x₂)
cong = {!!} -- hole 4
-- cong = λ {x₁} {x₂} f z → subst (λ z₁ → Eq (f x₁) (f z₁)) z refl
trans : ∀ {x₁ x₂ x₃} → Eq x₁ x₂ → Eq x₂ x₃ → Eq x₁ x₃
trans = {!!} -- hole 5
-- trans = λ {x₁} {x₂} {x₃} z z₁ → subst (Eq x₁) z₁ z
| 24.88
| 74
| 0.445338
|
57086400ce456eb25f6753b1323c0ed712a458bd
| 1,270
|
agda
|
Agda
|
out/Group/Equality.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 39
|
2021-11-09T20:39:55.000Z
|
2022-03-19T17:33:12.000Z
|
out/Group/Equality.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 1
|
2021-11-21T12:19:32.000Z
|
2021-11-21T12:19:32.000Z
|
out/Group/Equality.agda
|
JoeyEremondi/agda-soas
|
ff1a985a6be9b780d3ba2beff68e902394f0a9d8
|
[
"MIT"
] | 4
|
2021-11-09T20:39:59.000Z
|
2022-01-24T12:49:17.000Z
|
{-
This second-order equational theory was created from the following second-order syntax description:
syntax Group | G
type
* : 0-ary
term
unit : * | ε
add : * * -> * | _⊕_ l20
neg : * -> * | ⊖_ r40
theory
(εU⊕ᴸ) a |> add (unit, a) = a
(εU⊕ᴿ) a |> add (a, unit) = a
(⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))
(⊖N⊕ᴸ) a |> add (neg (a), a) = unit
(⊖N⊕ᴿ) a |> add (a, neg (a)) = unit
-}
module Group.Equality where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Families.Build
open import SOAS.ContextMaps.Inductive
open import Group.Signature
open import Group.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution G:Syn
open import SOAS.Metatheory.SecondOrder.Equality G:Syn
private
variable
α β γ τ : *T
Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ G) α Γ → (𝔐 ▷ G) α Γ → Set where
εU⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ε ⊕ 𝔞 ≋ₐ 𝔞
εU⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ ε ≋ₐ 𝔞
⊕A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊕ 𝔠 ≋ₐ 𝔞 ⊕ (𝔟 ⊕ 𝔠)
⊖N⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ (⊖ 𝔞) ⊕ 𝔞 ≋ₐ ε
⊖N⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ (⊖ 𝔞) ≋ₐ ε
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
| 23.518519
| 99
| 0.533858
|
22a14df9b2241300df87b0aa413bf54fd41bc47b
| 2,485
|
agda
|
Agda
|
BasicIPC/Metatheory/ClosedHilbert-TarskiGluedClosedImplicit.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
BasicIPC/Metatheory/ClosedHilbert-TarskiGluedClosedImplicit.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
BasicIPC/Metatheory/ClosedHilbert-TarskiGluedClosedImplicit.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
module BasicIPC.Metatheory.ClosedHilbert-TarskiGluedClosedImplicit where
open import BasicIPC.Syntax.ClosedHilbert public
open import BasicIPC.Semantics.TarskiGluedClosedImplicit public
open ImplicitSyntax (⊢_) public
-- Completeness with respect to a particular model.
module _ {{_ : Model}} where
reify : ∀ {A} → ⊩ A → ⊢ A
reify {α P} s = syn s
reify {A ▻ B} s = syn s
reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s))
reify {⊤} s = unit
-- Additional useful equipment.
module _ {{_ : Model}} where
⟪K⟫ : ∀ {A B} → ⊩ A → ⊩ B ▻ A
⟪K⟫ a = app ck (reify a) ⅋ K a
⟪S⟫′ : ∀ {A B C} → ⊩ A ▻ B ▻ C → ⊩ (A ▻ B) ▻ A ▻ C
⟪S⟫′ s₁ = app cs (reify s₁) ⅋ λ s₂ →
app (app cs (reify s₁)) (reify s₂) ⅋ ⟪S⟫ s₁ s₂
_⟪,⟫′_ : ∀ {A B} → ⊩ A → ⊩ B ▻ A ∧ B
_⟪,⟫′_ a = app cpair (reify a) ⅋ _,_ a
-- Soundness with respect to all models, or evaluation, for closed terms only.
eval₀ : ∀ {A} → ⊢ A → ⊨ A
eval₀ (app t u) = eval₀ t ⟪$⟫ eval₀ u
eval₀ ci = ci ⅋ I
eval₀ ck = ck ⅋ ⟪K⟫
eval₀ cs = cs ⅋ ⟪S⟫′
eval₀ cpair = cpair ⅋ _⟪,⟫′_
eval₀ cfst = cfst ⅋ π₁
eval₀ csnd = csnd ⅋ π₂
eval₀ unit = ∙
-- Correctness of evaluation with respect to conversion.
eval₀✓ : ∀ {{_ : Model}} {A} {t t′ : ⊢ A} → t ⋙ t′ → eval₀ t ≡ eval₀ t′
eval₀✓ refl⋙ = refl
eval₀✓ (trans⋙ p q) = trans (eval₀✓ p) (eval₀✓ q)
eval₀✓ (sym⋙ p) = sym (eval₀✓ p)
eval₀✓ (congapp⋙ p q) = cong² _⟪$⟫_ (eval₀✓ p) (eval₀✓ q)
eval₀✓ (congi⋙ p) = cong I (eval₀✓ p)
eval₀✓ (congk⋙ p q) = cong² K (eval₀✓ p) (eval₀✓ q)
eval₀✓ (congs⋙ p q r) = cong³ ⟪S⟫ (eval₀✓ p) (eval₀✓ q) (eval₀✓ r)
eval₀✓ (congpair⋙ p q) = cong² _,_ (eval₀✓ p) (eval₀✓ q)
eval₀✓ (congfst⋙ p) = cong π₁ (eval₀✓ p)
eval₀✓ (congsnd⋙ p) = cong π₂ (eval₀✓ p)
eval₀✓ beta▻ₖ⋙ = refl
eval₀✓ beta▻ₛ⋙ = refl
eval₀✓ beta∧₁⋙ = refl
eval₀✓ beta∧₂⋙ = refl
eval₀✓ eta∧⋙ = refl
eval₀✓ eta⊤⋙ = refl
-- The canonical model.
private
instance
canon : Model
canon = record
{ ⊩ᵅ_ = λ P → ⊢ α P
}
-- Completeness with respect to all models, or quotation, for closed terms only.
quot₀ : ∀ {A} → ⊨ A → ⊢ A
quot₀ s = reify s
-- Normalisation by evaluation, for closed terms only.
norm₀ : ∀ {A} → ⊢ A → ⊢ A
norm₀ = quot₀ ∘ eval₀
-- Correctness of normalisation with respect to conversion.
norm₀✓ : ∀ {{_ : Model}} {A} {t t′ : ⊢ A} → t ⋙ t′ → norm₀ t ≡ norm₀ t′
norm₀✓ p = cong reify (eval₀✓ p)
| 26.72043
| 80
| 0.55332
|
cb43cff4fb2a5980d0d5a65777bf5d39566a61d2
| 3,841
|
agda
|
Agda
|
src/Partiality-monad/Inductive/Strict-omega-continuous.agda
|
nad/partiality-monad
|
f69749280969f9093e5e13884c6feb0ad2506eae
|
[
"MIT"
] | 2
|
2020-05-21T22:59:18.000Z
|
2020-07-03T08:56:08.000Z
|
src/Partiality-monad/Inductive/Strict-omega-continuous.agda
|
nad/partiality-monad
|
f69749280969f9093e5e13884c6feb0ad2506eae
|
[
"MIT"
] | null | null | null |
src/Partiality-monad/Inductive/Strict-omega-continuous.agda
|
nad/partiality-monad
|
f69749280969f9093e5e13884c6feb0ad2506eae
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Strict ω-continuous functions
------------------------------------------------------------------------
{-# OPTIONS --cubical --safe #-}
module Partiality-monad.Inductive.Strict-omega-continuous where
open import Equality.Propositional.Cubical
open import Prelude hiding (⊥)
open import Bijection equality-with-J using (_↔_)
open import Function-universe equality-with-J hiding (_∘_)
open import Monad equality-with-J
import Partiality-algebra.Strict-omega-continuous as S
open import Partiality-monad.Inductive
open import Partiality-monad.Inductive.Eliminators
open import Partiality-monad.Inductive.Monad
open import Partiality-monad.Inductive.Monotone
open import Partiality-monad.Inductive.Omega-continuous
-- Definition of strict ω-continuous functions.
[_⊥→_⊥]-strict : ∀ {a b} → Type a → Type b → Type (a ⊔ b)
[ A ⊥→ B ⊥]-strict = S.[ partiality-algebra A ⟶ partiality-algebra B ]⊥
module [_⊥→_⊥]-strict
{a b} {A : Type a} {B : Type b}
(f : [ A ⊥→ B ⊥]-strict) =
S.[_⟶_]⊥ f
open [_⊥→_⊥]-strict
-- Identity.
id-strict : ∀ {a} {A : Type a} → [ A ⊥→ A ⊥]-strict
id-strict = S.id⊥
-- Composition.
infixr 40 _∘-strict_
_∘-strict_ :
∀ {a b c} {A : Type a} {B : Type b} {C : Type c} →
[ B ⊥→ C ⊥]-strict → [ A ⊥→ B ⊥]-strict → [ A ⊥→ C ⊥]-strict
_∘-strict_ = S._∘⊥_
-- Equality characterisation lemma for strict ω-continuous functions.
equality-characterisation-strict :
∀ {a b} {A : Type a} {B : Type b} {f g : [ A ⊥→ B ⊥]-strict} →
(∀ x → function f x ≡ function g x) ↔ f ≡ g
equality-characterisation-strict =
S.equality-characterisation-strict
-- Composition is associative.
∘-strict-assoc :
∀ {a b c d} {A : Type a} {B : Type b} {C : Type c} {D : Type d}
(f : [ C ⊥→ D ⊥]-strict) (g : [ B ⊥→ C ⊥]-strict)
(h : [ A ⊥→ B ⊥]-strict) →
f ∘-strict (g ∘-strict h) ≡ (f ∘-strict g) ∘-strict h
∘-strict-assoc = S.∘⊥-assoc
-- Strict ω-continuous functions satisfy an extra monad law.
>>=-∘-return :
∀ {a b} {A : Type a} {B : Type b} →
(f : [ A ⊥→ B ⊥]-strict) →
∀ x → x >>=′ (function f ∘ return) ≡ function f x
>>=-∘-return fs = ⊥-rec-⊥
(record
{ P = λ x → x >>=′ (f ∘ return) ≡ f x
; pe = never >>=′ f ∘ return ≡⟨ never->>= ⟩
never ≡⟨ sym (strict fs) ⟩∎
f never ∎
; po = λ x →
now x >>=′ f ∘ return ≡⟨ now->>= ⟩∎
f (now x) ∎
; pl = λ s p →
⨆ s >>=′ (f ∘ return) ≡⟨ ⨆->>= ⟩
⨆ ((f ∘ return) ∗-inc s) ≡⟨ cong ⨆ (_↔_.to equality-characterisation-increasing λ n →
(f ∘ return) ∗-inc s [ n ] ≡⟨ p n ⟩∎
[ f⊑ $ s ]-inc [ n ] ∎) ⟩
⨆ [ f⊑ $ s ]-inc ≡⟨ sym $ ω-continuous fs s ⟩∎
f (⨆ s) ∎
; pp = λ _ → ⊥-is-set
})
where
f⊑ = monotone-function fs
f = function fs
-- Strict ω-continuous functions from A ⊥ to B ⊥ are isomorphic to
-- functions from A to B ⊥.
partial↔strict :
∀ {a b} {A : Type a} {B : Type b} →
(A → B ⊥) ↔ [ A ⊥→ B ⊥]-strict
partial↔strict {a} = record
{ surjection = record
{ logical-equivalence = record
{ to = λ f → record
{ ω-continuous-function = f ∗
; strict =
never >>=′ f ≡⟨ never->>= ⟩∎
never ∎
}
; from = λ f x → function f (return x)
}
; right-inverse-of = λ f →
_↔_.to equality-characterisation-strict λ x →
x >>=′ (function f ∘ return) ≡⟨ >>=-∘-return f x ⟩∎
function f x ∎
}
; left-inverse-of = λ f → ⟨ext⟩ λ x →
return x >>=′ f ≡⟨ Monad-laws.left-identity x f ⟩∎
f x ∎
}
| 31.483607
| 100
| 0.492059
|
22e12b91cf14e5541fa0275dd72408c4cb34d108
| 164
|
agda
|
Agda
|
Cubical/Data/NatPlusOne.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Data/NatPlusOne.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Data/NatPlusOne.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.Data.NatPlusOne where
open import Cubical.Data.NatPlusOne.Base public
open import Cubical.Data.NatPlusOne.Properties public
| 23.428571
| 53
| 0.79878
|
3d8700d9e2d59d8924a4ef0a81fee6199f060a58
| 1,127
|
agda
|
Agda
|
src/fot/LTC-PCF/Program/GCD/Total/Definitions.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/LTC-PCF/Program/GCD/Total/Definitions.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/LTC-PCF/Program/GCD/Total/Definitions.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Common stuff used by the gcd example
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LTC-PCF.Program.GCD.Total.Definitions where
open import LTC-PCF.Base
open import LTC-PCF.Data.Nat.Divisibility.By0
open import LTC-PCF.Data.Nat.Inequalities
open import LTC-PCF.Data.Nat.Type
------------------------------------------------------------------------------
-- Common divisor.
CD : D → D → D → Set
CD m n cd = cd ∣ m ∧ cd ∣ n
-- Divisible for any common divisor.
Divisible : D → D → D → Set
Divisible m n gcd = ∀ cd → N cd → CD m n cd → cd ∣ gcd
-- Greatest common divisor specification.
--
-- The gcd is a common divisor and the gcd is divided by any common
-- divisor, thefore the gcd is the greatest common divisor according
-- to the partial order _∣_.
gcdSpec : D → D → D → Set
gcdSpec m n gcd = CD m n gcd ∧ Divisible m n gcd
| 34.151515
| 78
| 0.51819
|
a17b9a7a87cec917db0d69577a1a06507ac4e0fd
| 1,559
|
agda
|
Agda
|
src/API.agda
|
asr/alga
|
01f5f9f53ea81f692215300744aa77e26d8bf332
|
[
"MIT"
] | null | null | null |
src/API.agda
|
asr/alga
|
01f5f9f53ea81f692215300744aa77e26d8bf332
|
[
"MIT"
] | null | null | null |
src/API.agda
|
asr/alga
|
01f5f9f53ea81f692215300744aa77e26d8bf332
|
[
"MIT"
] | null | null | null |
module API where
open import Algebra
open import Prelude
empty : ∀ {A} -> Graph A
empty = ε
vertex : ∀ {A} -> A -> Graph A
vertex = v
overlay : ∀ {A} -> Graph A -> Graph A -> Graph A
overlay = _+_
connect : ∀ {A} -> Graph A -> Graph A -> Graph A
connect = _*_
edge : ∀ {A} -> A -> A -> Graph A
edge x y = connect (vertex x) (vertex y)
overlays : ∀ {A} -> List (Graph A) -> Graph A
overlays = foldr overlay empty
connects : ∀ {A} -> List (Graph A) -> Graph A
connects = foldr connect empty
vertices : ∀ {A} -> List A -> Graph A
vertices = overlays ∘ map vertex
edges : ∀ {A} -> List (A × A) -> Graph A
edges = overlays ∘ map (uncurry edge)
graph : ∀ {A} -> List A -> List (A × A) -> Graph A
graph vs es = overlay (vertices vs) (edges es)
foldg : ∀ {A} {B : Set} -> B -> (A -> B) -> (B -> B -> B) -> (B -> B -> B) -> Graph A -> B
foldg {A} {B} e w o c = go
where
go : Graph A -> B
go ε = e
go (v x) = w x
go (x + y) = o (go x) (go y)
go (x * y) = c (go x) (go y)
path : ∀ {A} -> List A -> Graph A
path [] = empty
path (x :: []) = vertex x
path (x :: xs) = edges (zip (x :: xs) xs)
circuit : ∀ {A} -> List A -> Graph A
circuit [] = empty
circuit (x :: xs) = path ([ x ] ++ xs ++ [ x ])
clique : ∀ {A} -> List A -> Graph A
clique = connects ∘ map vertex
biclique : ∀ {A} -> List A -> List A -> Graph A
biclique xs ys = connect (vertices xs) (vertices ys)
star : ∀ {A} -> A -> List A -> Graph A
star x ys = connect (vertex x) (vertices ys)
| 24.746032
| 91
| 0.504811
|
ad6e39d8e6186788df60a69ce510f8f534c8a9f5
| 2,882
|
agda
|
Agda
|
src/Tactic/Deriving/Quotable.agda
|
L-TChen/agda-prelude
|
158d299b1b365e186f00d8ef5b8c6844235ee267
|
[
"MIT"
] | null | null | null |
src/Tactic/Deriving/Quotable.agda
|
L-TChen/agda-prelude
|
158d299b1b365e186f00d8ef5b8c6844235ee267
|
[
"MIT"
] | null | null | null |
src/Tactic/Deriving/Quotable.agda
|
L-TChen/agda-prelude
|
158d299b1b365e186f00d8ef5b8c6844235ee267
|
[
"MIT"
] | null | null | null |
module Tactic.Deriving.Quotable where
open import Prelude
open import Container.Traversable
open import Tactic.Reflection
open import Tactic.Reflection.Quote.Class
open import Tactic.Deriving
private
-- Bootstrapping
qVis : Visibility → Term
qVis visible = con (quote visible) []
qVis hidden = con (quote hidden) []
qVis instance′ = con (quote instance′) []
qRel : Relevance → Term
qRel relevant = con (quote relevant) []
qRel irrelevant = con (quote irrelevant) []
qArgInfo : ArgInfo → Term
qArgInfo (arg-info v r) = con₂ (quote arg-info) (qVis v) (qRel r)
qArg : Arg Term → Term
qArg (arg i x) = con₂ (quote arg) (qArgInfo i) x
qList : List Term → Term
qList = foldr (λ x xs → con₂ (quote List._∷_) x xs)
(con₀ (quote List.[]))
-- Could compute this from the type of the dictionary constructor
quoteType : Name → TC Type
quoteType d =
caseM instanceTelescope d (quote Quotable) of λ
{ (tel , vs) → pure $ telPi tel $ def d vs `→ def (quote Term) []
}
dictConstructor : TC Name
dictConstructor =
caseM getConstructors (quote Quotable) of λ
{ (c ∷ []) → pure c
; _ → typeErrorS "impossible" }
patArgs : Telescope → List (Arg Pattern)
patArgs tel = zipWith (λ x (_ , a) → var x <$ a) (reverse (from 0 for length tel)) tel
quoteArgs′ : Nat → Telescope → List Term
quoteArgs′ 0 _ = []
quoteArgs′ _ [] = []
quoteArgs′ (suc n) ((x , a) ∷ tel) =
qArg (def₁ (quote `) (var n []) <$ a) ∷ quoteArgs′ n tel
quoteArgs : Nat → Telescope → Term
quoteArgs pars tel = qList $ replicate pars (qArg $ hArg (con₀ (quote Term.unknown))) ++
quoteArgs′ (length tel - pars) (drop pars tel)
constructorClause : Nat → Name → TC Clause
constructorClause pars c = do
tel , _ ← telView <$> getType c
let ps = patArgs tel
parPs , conPs = splitAt pars ps
pure (clause tel
(parPs ++ vArg (con c conPs) ∷ [])
(con₂ (quote Term.con) (lit (name c)) (quoteArgs pars tel)))
quoteClauses : Name → TC (List Clause)
quoteClauses d = do
n ← getParameters d
caseM getConstructors d of λ where
[] → pure [ absurd-clause (("()" , vArg unknown) ∷ []) (vArg (absurd 0) ∷ []) ]
cs → mapM (constructorClause n) cs
declareQuotableInstance : Name → Name → TC ⊤
declareQuotableInstance iname d =
declareDef (iArg iname) =<< instanceType d (quote Quotable)
defineQuotableInstance : Name → Name → TC ⊤
defineQuotableInstance iname d = do
fname ← freshName ("quote[" & show d & "]")
declareDef (vArg fname) =<< quoteType d
dictCon ← dictConstructor
defineFun iname (clause [] [] (con₁ dictCon (def₀ fname)) ∷ [])
defineFun fname =<< quoteClauses d
return _
deriveQuotable : Name → Name → TC ⊤
deriveQuotable iname d =
declareQuotableInstance iname d >>
defineQuotableInstance iname d
| 32.022222
| 90
| 0.638446
|
506140f5c775dfd6fae0aff2555495be59c0789a
| 2,358
|
agda
|
Agda
|
examples/simple-lib/Lib/List.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/simple-lib/Lib/List.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/simple-lib/Lib/List.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module Lib.List where
open import Lib.Prelude
open import Lib.Id
infix 30 _∈_
infixr 40 _::_ _++_
infix 45 _!_
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
{-# COMPILED_DATA List [] [] (:) #-}
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL [] #-}
{-# BUILTIN CONS _::_ #-}
_++_ : {A : Set} -> List A -> List A -> List A
[] ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
foldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B
foldr f z [] = z
foldr f z (x :: xs) = f x (foldr f z xs)
map : {A B : Set} -> (A -> B) -> List A -> List B
map f [] = []
map f (x :: xs) = f x :: map f xs
map-id : forall {A}(xs : List A) -> map id xs ≡ xs
map-id [] = refl
map-id (x :: xs) with map id xs | map-id xs
... | .xs | refl = refl
data _∈_ {A : Set} : A -> List A -> Set where
hd : forall {x xs} -> x ∈ x :: xs
tl : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs
data All {A : Set}(P : A -> Set) : List A -> Set where
[] : All P []
_::_ : forall {x xs} -> P x -> All P xs -> All P (x :: xs)
head : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> P x
head (x :: xs) = x
tail : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> All P xs
tail (x :: xs) = xs
_!_ : forall {A}{P : A -> Set}{x xs} -> All P xs -> x ∈ xs -> P x
xs ! hd = head xs
xs ! tl n = tail xs ! n
tabulate : forall {A}{P : A -> Set}{xs} -> ({x : A} -> x ∈ xs -> P x) -> All P xs
tabulate {xs = []} f = []
tabulate {xs = x :: xs} f = f hd :: tabulate (f ∘ tl)
mapAll : forall {A B}{P : A -> Set}{Q : B -> Set}{xs}(f : A -> B) ->
({x : A} -> P x -> Q (f x)) -> All P xs -> All Q (map f xs)
mapAll f h [] = []
mapAll f h (x :: xs) = h x :: mapAll f h xs
mapAll- : forall {A}{P Q : A -> Set}{xs} ->
({x : A} -> P x -> Q x) -> All P xs -> All Q xs
mapAll- {xs = xs} f zs with map id xs | map-id xs | mapAll id f zs
... | .xs | refl | r = r
infix 20 _⊆_
data _⊆_ {A : Set} : List A -> List A -> Set where
stop : [] ⊆ []
drop : forall {xs y ys} -> xs ⊆ ys -> xs ⊆ y :: ys
keep : forall {x xs ys} -> xs ⊆ ys -> x :: xs ⊆ x :: ys
⊆-refl : forall {A}{xs : List A} -> xs ⊆ xs
⊆-refl {xs = []} = stop
⊆-refl {xs = x :: xs} = keep ⊆-refl
_∣_ : forall {A}{P : A -> Set}{xs ys} -> All P ys -> xs ⊆ ys -> All P xs
[] ∣ stop = []
(x :: xs) ∣ drop p = xs ∣ p
(x :: xs) ∣ keep p = x :: (xs ∣ p)
| 28.071429
| 81
| 0.450382
|
fb67676470b975d43a67986969d3261961c4361a
| 2,012
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Integer/Divisibility.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Integer/Divisibility.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Integer/Divisibility.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Unsigned divisibility
------------------------------------------------------------------------
-- For signed divisibility see `Data.Integer.Divisibility.Signed`
{-# OPTIONS --without-K --safe #-}
module Data.Integer.Divisibility where
open import Function
open import Data.Integer
open import Data.Integer.Properties
import Data.Nat as ℕ
import Data.Nat.Properties as ℕᵖ
import Data.Nat.Divisibility as ℕᵈ
import Data.Nat.Coprimality as ℕᶜ
open import Level
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
-- Divisibility
infix 4 _∣_
_∣_ : Rel ℤ 0ℓ
_∣_ = ℕᵈ._∣_ on ∣_∣
open ℕᵈ public using (divides)
------------------------------------------------------------------------
-- Properties of divisibility
*-monoʳ-∣ : ∀ k → (k *_) Preserves _∣_ ⟶ _∣_
*-monoʳ-∣ k {i} {j} i∣j = begin
∣ k * i ∣ ≡⟨ abs-*-commute k i ⟩
∣ k ∣ ℕ.* ∣ i ∣ ∣⟨ ℕᵈ.*-cong ∣ k ∣ i∣j ⟩
∣ k ∣ ℕ.* ∣ j ∣ ≡⟨ sym (abs-*-commute k j) ⟩
∣ k * j ∣ ∎
where open ℕᵈ.∣-Reasoning
*-monoˡ-∣ : ∀ k → (_* k) Preserves _∣_ ⟶ _∣_
*-monoˡ-∣ k {i} {j}
rewrite *-comm i k
| *-comm j k
= *-monoʳ-∣ k
*-cancelˡ-∣ : ∀ k {i j} → k ≢ + 0 → k * i ∣ k * j → i ∣ j
*-cancelˡ-∣ k {i} {j} k≢0 k*i∣k*j = ℕᵈ./-cong (ℕ.pred ∣ k ∣) $ begin
let ∣k∣-is-suc = ℕᵖ.m≢0⇒suc[pred[m]]≡m (k≢0 ∘ ∣n∣≡0⇒n≡0) in
ℕ.suc (ℕ.pred ∣ k ∣) ℕ.* ∣ i ∣ ≡⟨ cong (ℕ._* ∣ i ∣) (∣k∣-is-suc) ⟩
∣ k ∣ ℕ.* ∣ i ∣ ≡⟨ sym (abs-*-commute k i) ⟩
∣ k * i ∣ ∣⟨ k*i∣k*j ⟩
∣ k * j ∣ ≡⟨ abs-*-commute k j ⟩
∣ k ∣ ℕ.* ∣ j ∣ ≡⟨ cong (ℕ._* ∣ j ∣) (sym ∣k∣-is-suc) ⟩
ℕ.suc (ℕ.pred ∣ k ∣) ℕ.* ∣ j ∣ ∎
where open ℕᵈ.∣-Reasoning
*-cancelʳ-∣ : ∀ k {i j} → k ≢ + 0 → i * k ∣ j * k → i ∣ j
*-cancelʳ-∣ k {i} {j} ≢0 = *-cancelˡ-∣ k ≢0 ∘
subst₂ _∣_ (*-comm i k) (*-comm j k)
| 31.4375
| 72
| 0.445328
|
2fe6d82a62d32884cf4edc2458f071cfb5f07de8
| 349
|
agda
|
Agda
|
test/succeed/Issue326.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/Issue326.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/Issue326.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
module Issue326 where
open import Common.Prelude
open import Common.MAlonzo using () -- see issue 561
postulate
QName : Set
printBool : Bool → IO Unit
{-# BUILTIN QNAME QName #-}
{-# COMPILED printBool print #-}
primitive primQNameEquality : QName → QName → Bool
main : IO Unit
main = printBool (primQNameEquality (quote Unit) (quote IO))
| 19.388889
| 60
| 0.722063
|
1a6f92fab3c8344d89fdc6e0742fb384491a2c97
| 156
|
agda
|
Agda
|
prototyping/Properties.agda
|
Tr4shh/Roblox-Luau
|
cd18adc20ecb805b8eeb770a9e5ef8e0cd123734
|
[
"MIT"
] | null | null | null |
prototyping/Properties.agda
|
Tr4shh/Roblox-Luau
|
cd18adc20ecb805b8eeb770a9e5ef8e0cd123734
|
[
"MIT"
] | null | null | null |
prototyping/Properties.agda
|
Tr4shh/Roblox-Luau
|
cd18adc20ecb805b8eeb770a9e5ef8e0cd123734
|
[
"MIT"
] | null | null | null |
module Properties where
import Properties.Contradiction
import Properties.Dec
import Properties.Equality
import Properties.Step
import Properties.Remember
| 19.5
| 31
| 0.878205
|
592c5849230805fbca6cc58b9808ff905ba6e479
| 7,103
|
agda
|
Agda
|
Cubical/Foundations/Path.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Foundations/Path.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Path.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.Path where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Transport
private
variable
ℓ ℓ' : Level
A : Type ℓ
-- Less polymorphic version of `cong`, to avoid some unresolved metas
cong′ : ∀ {B : Type ℓ'} (f : A → B) {x y : A} (p : x ≡ y)
→ Path B (f x) (f y)
cong′ f = cong f
PathP≡Path : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) →
PathP P p q ≡ Path (P i1) (transport (λ i → P i) p) q
PathP≡Path P p q i = PathP (λ j → P (i ∨ j)) (transp (λ j → P (i ∧ j)) (~ i) p) q
PathP≃Path : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) →
PathP P p q ≃ Path (P i1) (transport (λ i → P i) p) q
PathP≃Path P p q = transportEquiv (PathP≡Path P p q)
-- Alternative more unfolded proof
toPathP-isEquiv : ∀ (A : I → Set ℓ) {x y} → isEquiv (toPathP {A = A} {x} {y})
toPathP-isEquiv A {x} {y} = isoToIsEquiv (iso toPathP fromPathP to-from from-to)
where
to-from : ∀ (p : PathP A x y) → toPathP (fromPathP p) ≡ p
to-from p h i = outS (hcomp-unique (λ { j (i = i0) → x ; j (i = i1) → fromPathP p j })
(inS (transp (λ j → A (i ∧ j)) (~ i) x))
\ h → inS (sq1 h i))
h
where
sq1 : (\ h → A [ x ≡ transp (\ j → A (h ∨ j)) h (p h) ]) [ (\ i → transp (λ j → A (i ∧ j)) (~ i) x) ≡ p ]
sq1 = \ h i → comp (\ z → (hcomp (\ w →
\ { (z = i1) → A (i ∧ (w ∨ h))
; (z = i0) → A (i ∧ h)
; (i = i0) → A i0
; (i = i1) → A (h ∨ (w ∧ z))
; (h = i0) → A (i ∧ (w ∧ z))
; (h = i1) → A i})
((A (i ∧ h)))))
(\ z → \ { (i = i0) → x
; (i = i1) → transp (\ j → A (h ∨ (z ∧ j))) (h ∨ ~ z) (p h)
; (h = i0) → transp (λ j → A ((i ∧ z) ∧ j)) (~ (i ∧ z)) x
; (h = i1) → p i })
(p (i ∧ h))
from-to : ∀ (q : transp A i0 x ≡ y) → fromPathP (toPathP {A = A} q) ≡ q
from-to q = (\ h i → outS (transp-hcomp i {A' = A i1} (\ j → inS (A (i ∨ j)))
((λ { j (i = i0) → x ; j (i = i1) → q j }))
(inS ((transp (λ j → A (i ∧ j)) (~ i) x))))
h)
∙ (\ h i → outS (hcomp-unique {A = A i1} ((λ { j (i = i0) → transp A i0 x ; j (i = i1) → q j }))
(inS ((transp (λ j → A (i ∨ j)) i (transp (λ j → A (i ∧ j)) (~ i) x))))
\ h → inS (sq2 h i))
h)
∙ sym (lUnit q)
where
sq2 : (\ h → transp A i0 x ≡ q h) [ (\ i → transp (\ j → A (i ∨ j)) i (transp (\ j → A (i ∧ j)) (~ i) x)) ≡ refl ∙ q ]
sq2 = \ h i → comp (\ z → hcomp (\ w → \ { (i = i1) → A i1
; (i = i0) → A (h ∨ (w ∧ z))
; (h = i0) → A (i ∨ (w ∧ z))
; (h = i1) → A i1
; (z = i0) → A (i ∨ h)
; (z = i1) → A ((i ∨ h) ∨ w) })
(A (i ∨ h)))
(\ z → \ { (i = i0) → transp (λ j → A ((z ∨ h) ∧ j)) (~ z ∧ ~ h) x
; (i = i1) → q (z ∧ h)
; (h = i1) → compPath-filler refl q z i
; (h = i0) → transp (\ j → A (i ∨ (z ∧ j))) (i ∨ ~ z) (transp (\ j → A (i ∧ j)) (~ i) x)
})
(transp (\ j → A ((i ∨ h) ∧ j)) (~ (i ∨ h)) x)
PathP≡compPath : ∀ {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) (r : x ≡ z)
→ (PathP (λ i → x ≡ q i) p r) ≡ (p ∙ q ≡ r)
PathP≡compPath p q r k = PathP (λ i → p i0 ≡ q (i ∨ k)) (λ j → compPath-filler p q k j) r
PathP≡doubleCompPathˡ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)
→ (PathP (λ i → p i ≡ s i) q r) ≡ (p ⁻¹ ∙∙ q ∙∙ s ≡ r)
PathP≡doubleCompPathˡ p q r s k = PathP (λ i → p (i ∨ k) ≡ s (i ∨ k))
(λ j → doubleCompPath-filler (p ⁻¹) q s k j) r
PathP≡doubleCompPathʳ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)
→ (PathP (λ i → p i ≡ s i) q r) ≡ (q ≡ p ∙∙ r ∙∙ s ⁻¹)
PathP≡doubleCompPathʳ p q r s k = PathP (λ i → p (i ∧ (~ k)) ≡ s (i ∧ (~ k)))
q (λ j → doubleCompPath-filler p r (s ⁻¹) k j)
compPathl-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : x ≡ z) → p ∙ (sym p ∙ q) ≡ q
compPathl-cancel p q = p ∙ (sym p ∙ q) ≡⟨ assoc p (sym p) q ⟩
(p ∙ sym p) ∙ q ≡⟨ cong (_∙ q) (rCancel p) ⟩
refl ∙ q ≡⟨ sym (lUnit q) ⟩
q ∎
compPathr-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : z ≡ y) (q : x ≡ y) → (q ∙ sym p) ∙ p ≡ q
compPathr-cancel p q = (q ∙ sym p) ∙ p ≡⟨ sym (assoc q (sym p) p) ⟩
q ∙ (sym p ∙ p) ≡⟨ cong (q ∙_) (lCancel p) ⟩
q ∙ refl ≡⟨ sym (rUnit q) ⟩
q ∎
compPathl-isEquiv : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) → isEquiv (λ (q : y ≡ z) → p ∙ q)
compPathl-isEquiv p = isoToIsEquiv (iso (p ∙_) (sym p ∙_) (compPathl-cancel p) (compPathl-cancel (sym p)))
compPathr-isEquiv : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : y ≡ z) → isEquiv (λ (q : x ≡ y) → q ∙ p)
compPathr-isEquiv p = isoToIsEquiv (iso (_∙ p) (_∙ sym p) (compPathr-cancel p) (compPathr-cancel (sym p)))
-- Variation of isProp→isSet for PathP
isProp→isSet-PathP : ∀ {ℓ} {B : I → Type ℓ} → ((i : I) → isProp (B i))
→ (b0 : B i0) (b1 : B i1)
→ isProp (PathP (λ i → B i) b0 b1)
isProp→isSet-PathP {B = B} hB b0 b1 =
transport (λ i → isProp (PathP≡Path B b0 b1 (~ i))) (isProp→isSet (hB i1) _ _)
-- Flipping a square along its diagonal
flipSquare : ∀ {ℓ} {A : Type ℓ}
{a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁}
{a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁}
{a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁}
→ Square a₀₋ a₁₋ a₋₀ a₋₁
→ Square a₋₀ a₋₁ a₀₋ a₁₋
flipSquare sq i j = sq j i
flipSquarePath : ∀ {ℓ} {A : Type ℓ}
{a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁}
{a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁}
{a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁}
→ Square a₀₋ a₁₋ a₋₀ a₋₁ ≡ Square a₋₀ a₋₁ a₀₋ a₁₋
flipSquarePath = isoToPath (iso flipSquare flipSquare (λ _ → refl) (λ _ → refl))
| 53.406015
| 125
| 0.362804
|
4115eeacec7f0ee7f2ae44120d6b829a12ba9d7c
| 18,865
|
agda
|
Agda
|
agda/Number/Instances/QuoInt.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | 3
|
2020-07-31T18:15:26.000Z
|
2022-02-19T12:15:21.000Z
|
agda/Number/Instances/QuoInt.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
agda/Number/Instances/QuoInt.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-}
module Number.Instances.QuoInt where
open import Cubical.Foundations.Everything hiding (⋆) renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Foundations.Logic renaming (inl to inlᵖ; inr to inrᵖ)
open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)
open import Cubical.Relation.Binary.Base
open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)
open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_)
open import Cubical.Data.Sigma
open import Cubical.Data.Bool as Bool using (Bool; not; true; false)
open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim`
open import Cubical.Foundations.Logic renaming (¬_ to ¬ᵖ_; inl to inlᵖ; inr to inrᵖ)
open import Function.Base using (it; _∋_; _$_)
open import Cubical.Foundations.Isomorphism
open import Cubical.HITs.PropositionalTruncation --.Properties
open import Utils using (!_; !!_)
open import MoreLogic.Reasoning
open import MoreLogic.Definitions
open import MoreLogic.Properties
open import MorePropAlgebra.Definitions hiding (_≤''_)
open import MorePropAlgebra.Structures
open import MorePropAlgebra.Bundles
open import MorePropAlgebra.Consequences
open import Number.Structures2
open import Number.Bundles2
open import Cubical.Data.Nat.Literals
open import Cubical.Data.Nat using (suc; zero; ℕ; HasFromNat)
open import Number.Prelude.Nat using (¬-<ⁿ-zero; +ⁿ-comm; ¬suc<ⁿ0; _+ⁿ_; _·ⁿ_; ·ⁿ-reflects-≡ˡ')
open import Number.Instances.QuoIntFromInt public
open import Cubical.HITs.Ints.QuoInt as QuoInt using
( ℤ
; HasFromNat
; _+_
; Int≡ℤ
; signed
; posneg
; ℤ→Int
; sucℤ
; predℤ
; sign
; abs
; pos
; neg
; +-comm
; +-assoc
; sucℤ-+ʳ
; sucℤ-+ˡ
; spos
; sneg
; *-pos-suc
; negate-invol
) renaming
( isSetℤ to is-set
; _*_ to _·_
; -_ to infixl 6 -_
; *-comm to ·-comm
)
open IsLinearlyOrderedCommRing is-LinearlyOrderedCommRing using
( _-_
; <-irrefl
; <-trans
; +-<-ext
; +-rinv
; +-identity
; ·-identity
; _≤_
; ·-preserves-<
; <-tricho
; <-asym
; _#_
; +-inverse
; ·-assoc
)
0<1 : [ 0 < 1 ]
0<1 = 0 , refl
-- TODO: import these properties from somewhere else
+-reflects-< : ∀ x y z → [ (x + z < y + z) ⇒ ( x < y ) ]
+-preserves-< : ∀ x y z → [ ( x < y ) ⇒ (x + z < y + z) ]
+-creates-< : ∀ x y z → [ ( x < y ) ⇔ (x + z < y + z) ]
+-preserves-< a b x = snd (
( a < b ) ⇒ᵖ⟨ transport (λ i → [ sym (fst (+-identity a)) i < sym (fst (+-identity b)) i ]) ⟩
( a + 0 < b + 0 ) ⇒ᵖ⟨ transport (λ i → [ a + sym (+-rinv x) i < b + sym (+-rinv x) i ]) ⟩
( a + (x - x) < b + (x - x)) ⇒ᵖ⟨ transport (λ i → [ +-assoc a x (- x) i < +-assoc b x (- x) i ]) ⟩
((a + x) - x < (b + x) - x ) ⇒ᵖ⟨ +-<-ext (a + x) (- x) (b + x) (- x) ⟩
((a + x < b + x) ⊔ (- x < - x)) ⇒ᵖ⟨ (λ q → case q as (a + x < b + x) ⊔ (- x < - x) ⇒ a + x < b + x of λ
{ (inl a+x<b+x) → a+x<b+x -- somehow ⊥-elim needs a hint in the next line
; (inr -x<-x ) → ⊥-elim {A = λ _ → [ a + x < b + x ]} (<-irrefl (- x) -x<-x)
}) ⟩
a + x < b + x ◼ᵖ)
+-reflects-< x y z = snd
( x + z < y + z ⇒ᵖ⟨ +-preserves-< (x + z) (y + z) (- z) ⟩
(x + z) - z < (y + z) - z ⇒ᵖ⟨ transport (λ i → [ +-assoc x z (- z) (~ i) < +-assoc y z (- z) (~ i) ]) ⟩
x + (z - z) < y + (z - z) ⇒ᵖ⟨ transport (λ i → [ x + +-rinv z i < y + +-rinv z i ]) ⟩
x + 0 < y + 0 ⇒ᵖ⟨ transport (λ i → [ fst (+-identity x) i < fst (+-identity y) i ]) ⟩
x < y ◼ᵖ)
+-creates-< x y z .fst = +-preserves-< x y z
+-creates-< x y z .snd = +-reflects-< x y z
suc-creates-< : ∀ x y → [ (x < y) ⇔ (sucℤ x < sucℤ y) ]
suc-creates-< x y .fst p = substₚ (λ p → sucℤ x < p) (∣ +-comm y (pos 1) ∣) $ substₚ (λ p → p < y + pos 1) (∣ +-comm x (pos 1) ∣) (+-preserves-< x y (pos 1) p)
suc-creates-< x y .snd p = +-reflects-< x y (pos 1) $ substₚ (λ p → p < y + pos 1) (∣ +-comm (pos 1) x ∣) $ substₚ (λ p → sucℤ x < p) (∣ +-comm (pos 1) y ∣) p
·-creates-< : ∀ a b x → [ 0 < x ] → [ (a < b) ⇔ ((a · x) < (b · x)) ]
·-creates-< a b x p .fst q = ·-preserves-< a b x p q
·-creates-< a b x p .snd q = ·-reflects-< a b x p q
·-creates-<ˡ : ∀ a b x → [ 0 < x ] → [ (a < b) ⇔ ((x · a) < (x · b)) ]
·-creates-<ˡ a b x p .fst q = transport (λ i → [ ·-comm a x i < ·-comm b x i ]) $ ·-preserves-< a b x p q
·-creates-<ˡ a b x p .snd q = ·-reflects-< a b x p (transport (λ i → [ ·-comm x a i < ·-comm x b i ]) q)
·-creates-<-≡ : ∀ a b x → [ 0 < x ] → (a < b) ≡ ((a · x) < (b · x))
·-creates-<-≡ a b x p = ⇔toPath' (·-creates-< a b x p)
·-creates-<ˡ-≡ : ∀ a b x → [ 0 < x ] → (a < b) ≡ ((x · a) < (x · b))
·-creates-<ˡ-≡ a b x p = ⇔toPath' (·-creates-<ˡ a b x p)
+-creates-≤ : ∀ a b x → [ (a ≤ b) ⇔ ((a + x) ≤ (b + x)) ]
+-creates-≤ a b x = {! !}
·-creates-≤ : ∀ a b x → [ 0 ≤ x ] → [ (a ≤ b) ⇔ ((a · x) ≤ (b · x)) ]
·-creates-≤ a b x 0≤x .fst p = {! !}
·-creates-≤ a b x 0≤x .snd p = {! !}
·-creates-≤-≡ : ∀ a b x → [ 0 ≤ x ] → (a ≤ b) ≡ ((a · x) ≤ (b · x))
·-creates-≤-≡ a b x 0≤x = uncurry ⇔toPath $ ·-creates-≤ a b x 0≤x
≤-dicho : ∀ x y → [ (x ≤ y) ⊔ (y ≤ x) ]
≤-dicho x y with <-tricho x y
... | inl (inl x<y) = inlᵖ $ <-asym x y x<y
... | inl (inr y<x) = inrᵖ $ <-asym y x y<x
... | inr x≡y = inlᵖ $ subst (λ p → [ ¬(p < x) ]) x≡y (<-irrefl x)
ℤlattice : Lattice {ℓ-zero} {ℓ-zero}
ℤlattice = record { LinearlyOrderedCommRing bundle renaming (≤-Lattice to is-Lattice) }
open import MorePropAlgebra.Properties.Lattice ℤlattice
open OnSet is-set hiding (+-min-distribʳ; ·-min-distribʳ; +-max-distribʳ; ·-max-distribʳ)
≤-min-+ : ∀ a b c w → [ w ≤ (a + c) ] → [ w ≤ (b + c) ] → [ w ≤ (min a b + c) ]
≤-max-+ : ∀ a b c w → [ (a + c) ≤ w ] → [ (b + c) ≤ w ] → [ (max a b + c) ≤ w ]
≤-min-· : ∀ a b c w → [ w ≤ (a · c) ] → [ w ≤ (b · c) ] → [ w ≤ (min a b · c) ]
≤-max-· : ∀ a b c w → [ (a · c) ≤ w ] → [ (b · c) ≤ w ] → [ (max a b · c) ≤ w ]
≤-min-+ = OnType.≤-dicho⇒+.≤-min-+ _+_ ≤-dicho
≤-max-+ = OnType.≤-dicho⇒+.≤-max-+ _+_ ≤-dicho
≤-min-· = OnType.≤-dicho⇒·.≤-min-· _·_ ≤-dicho
≤-max-· = OnType.≤-dicho⇒·.≤-max-· _·_ ≤-dicho
+-min-distribʳ : ∀ x y z → (min x y + z) ≡ min (x + z) (y + z)
·-min-distribʳ : ∀ x y z → [ 0 ≤ z ] → (min x y · z) ≡ min (x · z) (y · z)
+-max-distribʳ : ∀ x y z → (max x y + z) ≡ max (x + z) (y + z)
·-max-distribʳ : ∀ x y z → [ 0 ≤ z ] → (max x y · z) ≡ max (x · z) (y · z)
+-min-distribˡ : ∀ x y z → (z + min x y) ≡ min (z + x) (z + y)
·-min-distribˡ : ∀ x y z → [ 0 ≤ z ] → (z · min x y) ≡ min (z · x) (z · y)
+-max-distribˡ : ∀ x y z → (z + max x y) ≡ max (z + x) (z + y)
·-max-distribˡ : ∀ x y z → [ 0 ≤ z ] → (z · max x y) ≡ max (z · x) (z · y)
+-min-distribʳ = OnSet.+-min-distribʳ is-set _+_ +-creates-≤ ≤-min-+
·-min-distribʳ = OnSet.·-min-distribʳ is-set 0 _·_ ·-creates-≤ ≤-min-·
+-max-distribʳ = OnSet.+-max-distribʳ is-set _+_ +-creates-≤ ≤-max-+
·-max-distribʳ = OnSet.·-max-distribʳ is-set 0 _·_ ·-creates-≤ ≤-max-·
+-min-distribˡ x y z = +-comm z (min x y) ∙ +-min-distribʳ x y z ∙ (λ i → min (+-comm x z i) (+-comm y z i))
·-min-distribˡ x y z p = ·-comm z (min x y) ∙ ·-min-distribʳ x y z p ∙ (λ i → min (·-comm x z i) (·-comm y z i))
+-max-distribˡ x y z = +-comm z (max x y) ∙ +-max-distribʳ x y z ∙ (λ i → max (+-comm x z i) (+-comm y z i))
·-max-distribˡ x y z p = ·-comm z (max x y) ∙ ·-max-distribʳ x y z p ∙ (λ i → max (·-comm x z i) (·-comm y z i))
pos<pos[suc] : ∀ x → [ pos x < pos (suc x) ]
pos<pos[suc] 0 = 0<1
pos<pos[suc] (suc x) = suc-creates-< (pos x) (pos (suc x)) .fst (pos<pos[suc] x)
0<ᶻpos[suc] : ∀ x → [ 0 < pos (suc x) ]
0<ᶻpos[suc] 0 = 0<1
0<ᶻpos[suc] (suc x) = <-trans 0 (pos (suc x)) (pos (suc (suc x))) (0<ᶻpos[suc] x) (suc-creates-< (pos x) (pos (suc x)) .fst (pos<pos[suc] x))
·-nullifiesˡ : ∀(x : ℤ) → 0 · x ≡ 0
·-nullifiesˡ (pos zero) = refl
·-nullifiesˡ (neg zero) = refl
·-nullifiesˡ (posneg i) = refl
·-nullifiesˡ (pos (suc n)) = refl
·-nullifiesˡ (neg (suc n)) = sym posneg
·-nullifiesʳ : ∀(x : ℤ) → x · 0 ≡ 0
·-nullifiesʳ x = ·-comm x 0 ∙ ·-nullifiesˡ x
·-preserves-0< : ∀ a b → [ 0 < a ] → [ 0 < b ] → [ 0 < a · b ]
·-preserves-0< a b p q = subst (λ p → [ p < a · b ]) (·-nullifiesˡ b) (·-preserves-< 0 a b q p)
private
term : ∀ b x → Type ℓ-zero
term b x = [ ((pos 0 < x) ⇒ (pos 0 < b)) ⊓ ((pos 0 < b) ⇒ (pos 0 < x)) ]
·-reflects-<ˡ : (x y z : ℤ) → [ pos 0 < z ] → [ z · x < z · y ] → [ x < y ]
·-reflects-<ˡ x y z p q = ·-reflects-< x y z p (transport (λ i → [ ·-comm z x i < ·-comm z y i ]) q)
-flips-<0 : ∀ x → [ (x < 0) ⇔ (0 < (- x)) ]
-flips-<0 (signed spos zero) = (λ x → x) , (λ x → x)
-flips-<0 (signed sneg zero) = (λ x → x) , (λ x → x)
-flips-<0 (ℤ.posneg i) = (λ x → x) , (λ x → x)
-flips-<0 (signed spos (suc n)) .fst p = ¬-<ⁿ-zero p
-flips-<0 (signed sneg (suc n)) .fst tt = n , +ⁿ-comm n 1
-flips-<0 (signed sneg (suc n)) .snd p = tt
-- NOTE: this could be a path, if we make `+-creates-<` into a path
-flips-< : ∀ x y → [ x < y ] → [ - y < - x ]
-flips-< x y p = (
( x < y ) ⇒ᵖ⟨ +-creates-< x y (- y) .fst ⟩
( x - y < y - y) ⇒ᵖ⟨ transport (λ i → [ +-comm x (- y) i < +-rinv y i ]) ⟩
( (- y) + x < 0 ) ⇒ᵖ⟨ +-creates-< ((- y) + x) 0 (- x) .fst ⟩
(((- y) + x) - x < 0 - x) ⇒ᵖ⟨ transport (λ i → [ +-assoc (- y) x (- x) (~ i) < +-identity (- x) .snd i ]) ⟩
( (- y) + (x - x) < - x ) ⇒ᵖ⟨ transport (λ i → [ (- y) + +-rinv x i < - x ]) ⟩
( (- y) + 0 < - x ) ⇒ᵖ⟨ transport (λ i → [ +-identity (- y) .fst i < - x ]) ⟩
( - y < - x ) ◼ᵖ) .snd p
-flips-<-⇔ : ∀ x y → [ (x < y) ⇔ (- y < - x) ]
-flips-<-⇔ x y .fst = -flips-< x y
-flips-<-⇔ x y .snd p = transport (λ i → [ negate-invol x i < negate-invol y i ]) $ -flips-< (- y) (- x) p
-flips-<-≡ : ∀ x y → (x < y) ≡ (- y < - x)
-flips-<-≡ x y = ⇔toPath' (-flips-<-⇔ x y)
-identity-· : ∀ a → (- 1) · a ≡ - a
-identity-· (pos zero) j = posneg (~ i0 ∨ ~ j)
-identity-· (neg zero) j = posneg (~ i1 ∨ ~ j)
-identity-· (posneg i) j = posneg (~ i ∨ ~ j)
-identity-· (pos (suc n)) i = neg (suc (+ⁿ-comm n 0 i))
-identity-· (neg (suc n)) i = pos (suc (+ⁿ-comm n 0 i))
-distˡ : ∀ a b → -(a · b) ≡ (- a) · b
-distˡ a b =
-(a · b) ≡⟨ sym $ -identity-· (a · b) ⟩
(- 1) · (a · b) ≡⟨ ·-assoc (- 1) a b ⟩
((- 1) · a) · b ≡⟨ (λ i → -identity-· a i · b) ⟩
(- a) · b ∎
private
lem : ∀ z → [ z < 0 ] → [ 0 < - z ]
lem z p = subst (λ p → [ p < - z ]) (sym posneg) $ -flips-< z 0 p
·-creates-<-flippedˡ-≡ : (x y z : ℤ) → [ z < 0 ] → (z · x < z · y) ≡ (y < x)
·-creates-<-flippedˡ-≡ x y z p =
z · x < z · y ≡⟨ -flips-<-≡ (z · x) (z · y) ⟩
- (z · y) < - (z · x) ≡⟨ (λ i → -distˡ z y i < -distˡ z x i) ⟩
(- z) · y < (- z) · x ≡⟨ sym $ ·-creates-<ˡ-≡ y x (- z) (lem z p) ⟩
y < x ∎
·-creates-<-flippedʳ-≡ : (x y z : ℤ) → [ z < 0 ] → (x · z < y · z) ≡ (y < x)
·-creates-<-flippedʳ-≡ x y z p = (λ i → ·-comm x z i < ·-comm y z i) ∙ ·-creates-<-flippedˡ-≡ x y z p
·-reflects-<-flippedˡ : (x y z : ℤ) → [ z < 0 ] → [ z · x < z · y ] → [ y < x ]
·-reflects-<-flippedˡ x y z p q = pathTo⇒ (·-creates-<-flippedˡ-≡ x y z p) q
-- (z · x < z · y ⇒ᵖ⟨ -flips-< (z · x) (z · y) ⟩
-- - (z · y) < - (z · x) ⇒ᵖ⟨ transport (λ i → [ -distˡ z y i < -distˡ z x i ]) ⟩
-- (- z) · y < (- z) · x ⇒ᵖ⟨ ·-creates-<ˡ y x (- z) (lem z p) .snd ⟩
-- y < x ◼ᵖ) .snd q
·-reflects-<-flippedʳ : (x y z : ℤ) → [ z < 0 ] → [ x · z < y · z ] → [ y < x ]
·-reflects-<-flippedʳ x y z p q = ·-reflects-<-flippedˡ x y z p (transport (λ i → [ ·-comm x z i < ·-comm y z i ]) q)
-- ·-preserves-<-flippedˡ : (x y z : ℤ) → [ z < 0 ] → [ x < y ] → [ z · y < z · x ]
-- ·-preserves-<-flippedˡ x y z p q = {! !}
·-reflects-0< : ∀ a b → [ 0 < a · b ] → [ ((0 < a) ⇔ (0 < b)) ⊓ ((a < 0) ⇔ (b < 0)) ]
·-reflects-0< a b p .fst .fst q = ·-reflects-<ˡ 0 b a q (transport (λ i → [ ·-nullifiesʳ a (~ i) < a · b ]) p)
·-reflects-0< a b p .fst .snd q = ·-reflects-< 0 a b q (transport (λ i → [ ·-nullifiesˡ b (~ i) < a · b ]) p)
·-reflects-0< a b p .snd .fst q = ·-reflects-<-flippedˡ 0 b a q (transport (λ i → [ ·-nullifiesʳ a (~ i) < a · b ]) p)
·-reflects-0< a b p .snd .snd q = ·-reflects-<-flippedʳ 0 a b q (transport (λ i → [ ·-nullifiesˡ b (~ i) < a · b ]) p)
#-dicho : ∀ x → [ x # 0 ] ⊎ (x ≡ 0)
#-dicho x = <-tricho x 0
⊕-identityʳ : ∀ s → (s Bool.⊕ spos) ≡ s
⊕-identityʳ spos = refl
⊕-identityʳ sneg = refl
·-preserves-signˡ : ∀ x y → [ 0 < y ] → sign (x · y) ≡ sign x
·-preserves-signˡ x (signed spos zero) p = ⊥-elim {A = λ _ → sign (x · ℤ.posneg i0) ≡ sign x} (¬-<ⁿ-zero p)
·-preserves-signˡ x (signed sneg zero) p = ⊥-elim {A = λ _ → sign (x · ℤ.posneg i1) ≡ sign x} (¬-<ⁿ-zero p)
·-preserves-signˡ x (ℤ.posneg i) p = ⊥-elim {A = λ _ → sign (x · ℤ.posneg i ) ≡ sign x} (¬-<ⁿ-zero p)
·-preserves-signˡ (signed spos zero) (signed spos (suc n)) p = refl
·-preserves-signˡ (signed sneg zero) (signed spos (suc n)) p = refl
·-preserves-signˡ (ℤ.posneg i) (signed spos (suc n)) p = refl
·-preserves-signˡ (signed s (suc n₁)) (signed spos (suc n)) p = ⊕-identityʳ s
#⇒≢ : ∀ x → [ x # 0 ] → ¬ᵗ(0 ≡ x)
#⇒≢ x (inl p) q = <-irrefl 0 $ subst (λ p → [ p < pos 0 ]) (sym q) p
#⇒≢ x (inr p) q = <-irrefl 0 $ subst (λ p → [ pos 0 < p ]) (sym q) p
<-split-pos : ∀ z → [ 0 < z ] → Σ[ n ∈ ℕ ] z ≡ pos (suc n)
<-split-pos (pos zero) p = ⊥-elim {A = λ _ → Σ[ n ∈ ℕ ] posneg i0 ≡ pos (suc n)} (<-irrefl 0 p)
<-split-pos (neg zero) p = ⊥-elim {A = λ _ → Σ[ n ∈ ℕ ] posneg i1 ≡ pos (suc n)} (<-irrefl 0 p)
<-split-pos (posneg i) p = ⊥-elim {A = λ _ → Σ[ n ∈ ℕ ] posneg i ≡ pos (suc n)} (<-irrefl 0 p)
<-split-pos (pos (suc n)) p = n , refl
<-split-neg : ∀ z → [ z < 0 ] → Σ[ n ∈ ℕ ] z ≡ neg (suc n)
<-split-neg (pos zero) p = ⊥-elim {A = λ _ → Σ[ n ∈ ℕ ] posneg i0 ≡ neg (suc n)} (<-irrefl 0 p)
<-split-neg (neg zero) p = ⊥-elim {A = λ _ → Σ[ n ∈ ℕ ] posneg i1 ≡ neg (suc n)} (<-irrefl 0 p)
<-split-neg (posneg i) p = ⊥-elim {A = λ _ → Σ[ n ∈ ℕ ] posneg i ≡ neg (suc n)} (<-irrefl 0 p)
<-split-neg (pos (suc m)) p = ⊥-elim {A = λ _ → Σ[ n ∈ ℕ ] pos (suc m) ≡ neg (suc n)} (¬suc<ⁿ0 m p)
<-split-neg (neg (suc m)) p = m , refl
#-split-abs : ∀ a → [ a # 0 ] → Σ[ x ∈ _ ] (abs a ≡ suc (abs x))
#-split-abs a (inl a<0) with <-split-neg a a<0; ... | (n , p) = neg n , λ i → abs (p i)
#-split-abs a (inr 0<a) with <-split-pos a 0<a; ... | (n , p) = pos n , λ i → abs (p i)
-- this is QuoInt.signed-zero
signed0≡0 : ∀ s → signed s 0 ≡ 0
signed0≡0 spos = refl
signed0≡0 sneg i = posneg (~ i)
·-sucIntʳ⁺ : ∀ m n → m · pos (suc n) ≡ m + m · pos n
·-sucIntʳ⁺ m n = ·-comm m (pos (suc n)) ∙ *-pos-suc n m ∙ (λ i → m + ·-comm (pos n) m i)
signed-respects-+ : ∀ s a b → signed s (a +ⁿ b) ≡ signed s a + signed s b
signed-respects-+ spos zero b = refl
signed-respects-+ sneg zero b = refl
signed-respects-+ spos (suc a) b i = sucℤ $ signed-respects-+ spos a b i
signed-respects-+ sneg (suc a) b i = predℤ $ signed-respects-+ sneg a b i
-- this is QuoInt.signed-inv
sign-abs-identity : ∀ a → signed (sign a) (abs a) ≡ a
sign-abs-identity (pos zero) j = posneg (i0 ∧ j)
sign-abs-identity (neg zero) j = posneg (i1 ∧ j)
sign-abs-identity (posneg i) j = posneg (i ∧ j)
sign-abs-identity (pos (suc n)) = refl
sign-abs-identity (neg (suc n)) = refl
signed-reflects-≡₁ : ∀ s₁ s₂ n → signed s₁ (suc n) ≡ signed s₂ (suc n) → s₁ ≡ s₂
signed-reflects-≡₁ s₁ s₂ n p i = sign (p i)
signed-reflects-≡₂ : ∀ s₁ s₂ a b → signed s₁ a ≡ signed s₂ b → a ≡ b
signed-reflects-≡₂ s₁ s₂ a b p i = abs (p i)
-abs : ∀ a → abs (- a) ≡ abs a
-abs (signed s n) = refl
-abs (posneg i) = refl
-reflects-≡ : ∀ a b → - a ≡ - b → a ≡ b
-reflects-≡ a b p = sym (negate-invol a) ∙ (λ i → - p i) ∙ negate-invol b
abs-preserves-· : ∀ a b → abs (a · b) ≡ abs a ·ⁿ abs b
abs-preserves-· a b = refl
sign-abs-≡ : ∀ a b → sign a ≡ sign b → abs a ≡ abs b → a ≡ b
sign-abs-≡ a b p q = transport (λ i → sign-abs-identity a i ≡ sign-abs-identity b i) λ i → signed (p i) (q i)
0<-sign : ∀ z → [ 0 < z ] → sign z ≡ spos
0<-sign z p i = sign $ <-split-pos z p .snd i
<0-sign : ∀ z → [ z < 0 ] → sign z ≡ sneg
<0-sign z p i = sign $ <-split-neg z p .snd i
sign-pos : ∀ n → sign (pos n) ≡ spos
sign-pos zero = refl
sign-pos (suc n) = refl
-- inj-*sm : l * suc m ≡ n * suc m → l ≡ n
-- inj-*sm {zero} {m} {n} p = 0≡n*sm→0≡n p
-- inj-*sm {l} {m} {zero} p = sym (0≡n*sm→0≡n (sym p))
-- inj-*sm {suc l} {m} {suc n} p = cong suc (inj-*sm (inj-m+ {m = suc m} p))
private
lem1 : ∀ a x → sign a ≡ sign (signed (sign a) (abs a +ⁿ x ·ⁿ abs a))
lem1 (pos zero) x = sym $ sign-pos (x ·ⁿ 0)
lem1 (neg zero) x = sym $ sign-pos (x ·ⁿ 0)
lem1 (posneg i) x = sym $ sign-pos (x ·ⁿ 0)
lem1 (pos (suc n)) x = refl
lem1 (neg (suc n)) x = refl
·-reflects-≡ˡ⁺ : ∀ a b x → (pos (suc x)) · a ≡ (pos (suc x)) · b → a ≡ b
·-reflects-≡ˡ⁺ a b x p = sym (sign-abs-identity a) ∙ (λ i → signed (κ i) (γ i)) ∙ sign-abs-identity b where
φ : suc x ·ⁿ abs a ≡ suc x ·ⁿ abs b
φ = signed-reflects-≡₂ _ _ _ _ p
γ : abs a ≡ abs b
γ = ·ⁿ-reflects-≡ˡ' {x} {abs a} {abs b} φ
κ = transport ( sign (signed (sign a) (suc x ·ⁿ abs a))
≡ sign (signed (sign b) (suc x ·ⁿ abs b)) ≡⟨ (λ i → lem1 a x (~ i) ≡ lem1 b x (~ i)) ⟩
sign a ≡ sign b ∎) (λ i → sign (p i))
·-reflects-≡ˡ⁻ : ∀ a b x → (neg (suc x)) · a ≡ (neg (suc x)) · b → a ≡ b
·-reflects-≡ˡ⁻ a b x p = sym (sign-abs-identity a) ∙ γ ∙ sign-abs-identity b where
φ : suc x ·ⁿ abs a ≡ suc x ·ⁿ abs b
φ = signed-reflects-≡₂ _ _ _ _ p
κ : abs a ≡ abs b
κ = ·ⁿ-reflects-≡ˡ' {x} {abs a} {abs b} φ
γ : signed (sign a) (abs a) ≡ signed (sign b) (abs b)
γ with #-dicho a
... | inl a#0 = -reflects-≡ _ _ (λ i → signed (θ i) (κ i)) where
abstract
c = #-split-abs a a#0 .fst
q₁ : abs a ≡ suc (abs c)
q₁ = #-split-abs a a#0 .snd
q₂ : abs b ≡ suc (abs c)
q₂ = sym κ ∙ q₁
θ : not (sign a) ≡ not (sign b)
θ = signed-reflects-≡₁ _ _ _ (transport (λ i → signed (not (sign a)) (suc x ·ⁿ q₁ i) ≡ signed (not (sign b)) (suc x ·ⁿ q₂ i)) p)
... | inr a≡0 = cong₂ signed refl (λ i → abs (a≡0 i)) ∙ signed0≡0 (sign a) ∙ sym (signed0≡0 (sign b)) ∙ cong₂ signed refl ((λ i → abs (a≡0 (~ i))) ∙ κ)
·-reflects-≡ˡ : ∀ a b x → [ x # 0 ] → x · a ≡ x · b → a ≡ b
·-reflects-≡ˡ a b x (inl x<0) q = let (y , r) = <-split-neg x x<0 in ·-reflects-≡ˡ⁻ a b y (transport (λ i → r i · a ≡ r i · b) q)
·-reflects-≡ˡ a b x (inr 0<x) q = let (y , r) = <-split-pos x 0<x in ·-reflects-≡ˡ⁺ a b y (transport (λ i → r i · a ≡ r i · b) q)
·-reflects-≡ʳ : ∀ a b x → [ x # 0 ] → a · x ≡ b · x → a ≡ b
·-reflects-≡ʳ a b x p q = ·-reflects-≡ˡ a b x p (·-comm x a ∙ q ∙ ·-comm b x)
| 45.348558
| 159
| 0.486986
|
41d8e9af969fbdb0eda589a66a99977f41e52837
| 710
|
agda
|
Agda
|
Cubical/Algebra/CommAlgebra/Kernel.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Algebra/CommAlgebra/Kernel.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommAlgebra/Kernel.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommAlgebra.Kernel where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Algebra.CommRing.Base
open import Cubical.Algebra.CommRing.Ideal using (Ideal→CommIdeal)
open import Cubical.Algebra.Ring.Kernel using () renaming (kernelIdeal to ringKernel)
open import Cubical.Algebra.CommAlgebra.Base
open import Cubical.Algebra.CommAlgebra.Properties
open import Cubical.Algebra.CommAlgebra.Ideal
private
variable
ℓ : Level
module _ {R : CommRing ℓ} (A B : CommAlgebra R ℓ) (ϕ : CommAlgebraHom A B) where
kernel : IdealsIn A
kernel = Ideal→CommIdeal (ringKernel (CommAlgebraHom→RingHom {A = A} {B = B} ϕ))
| 32.272727
| 85
| 0.778873
|
2e16bfa596371cd54ad08b9e03a7b045cb0518c4
| 242
|
agda
|
Agda
|
src/Data/Maybe/Properties/Extra.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 10
|
2017-11-17T17:10:36.000Z
|
2021-09-24T08:02:33.000Z
|
src/Data/Maybe/Properties/Extra.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 1
|
2019-01-13T13:03:47.000Z
|
2020-10-14T13:41:58.000Z
|
src/Data/Maybe/Properties/Extra.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 1
|
2021-12-28T17:38:05.000Z
|
2021-12-28T17:38:05.000Z
|
module Data.Maybe.Properties.Extra {a}{A : Set a} where
open import Data.Maybe
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
nothing≢just : ∀ {a : A} → ¬ (_≡_ {A = Maybe A} nothing (just a))
nothing≢just ()
| 26.888889
| 65
| 0.72314
|
4d7037b37514f8ca86ab4a04084fc20432b5f296
| 48
|
agda
|
Agda
|
test/Fail/FileNotFound.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/FileNotFound.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/FileNotFound.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module FileNotFound where
import A.B.WildGoose
| 12
| 25
| 0.833333
|
59f43c2cfe62b9ea4d3adeaf9a8fb21a3011b4ea
| 11,334
|
agda
|
Agda
|
Integer8.agda
|
righ1113/Agda
|
9117b6bec9880d8c0a5d6ee4399fd841c3544d84
|
[
"MIT"
] | null | null | null |
Integer8.agda
|
righ1113/Agda
|
9117b6bec9880d8c0a5d6ee4399fd841c3544d84
|
[
"MIT"
] | null | null | null |
Integer8.agda
|
righ1113/Agda
|
9117b6bec9880d8c0a5d6ee4399fd841c3544d84
|
[
"MIT"
] | null | null | null |
module Integer8 where
open import Data.Nat
open import Data.Nat.Properties
open import Data.Product
open import Relation.Binary.PropositionalEquality as PropEq
-- ---------- record ----------
record IsSemiGroup (A : Set) (_∙_ : A → A → A) : Set where
field
assoc : ∀ x y z → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)
record IsMonoid (A : Set) (_∙_ : A → A → A) (e : A) : Set where
field
isSemiGroup : IsSemiGroup A _∙_
identity : (∀ x → e ∙ x ≡ x) × (∀ x → x ∙ e ≡ x)
record IsGroup (A : Set) (_∙_ : A → A → A) (e : A) (iF : A → A) : Set where
field
isMonoid : IsMonoid A _∙_ e
inv : (∀ x → (iF x) ∙ x ≡ e) × (∀ x → x ∙ (iF x) ≡ e)
record IsAbelianGroup (A : Set) (_∙_ : A → A → A) (e : A) (iF : A → A) : Set where
field
isGroup : IsGroup A _∙_ e iF
comm : ∀ x y → x ∙ y ≡ y ∙ x
record IsRing (A : Set) (_⊕_ _⊗_ : A → A → A) (eP eT : A) (iF : A → A) : Set where
field
⊕isAbelianGroup : IsAbelianGroup A _⊕_ eP iF
⊗isMonoid : IsMonoid A _⊗_ eT
isDistR : (x y z : A) → (x ⊕ y) ⊗ z ≡ (x ⊗ z) ⊕ (y ⊗ z)
isDistL : (x y z : A) → x ⊗ (y ⊕ z) ≡ (x ⊗ y) ⊕ (x ⊗ z)
-- ----------------------------
-- ---------- practice nat ----------
ℕ+-isSemiGroup : IsSemiGroup ℕ _+_
ℕ+-isSemiGroup = record { assoc = ℕ+-assoc }
where
ℕ+-assoc : ∀ x y z → (x + y) + z ≡ x + (y + z)
ℕ+-assoc zero y z = refl
ℕ+-assoc (suc x) y z = cong suc (ℕ+-assoc x y z)
ℕ+0-isMonoid : IsMonoid ℕ _+_ 0
ℕ+0-isMonoid = record { isSemiGroup = ℕ+-isSemiGroup ; identity = (0+x≡x , x+0≡x) }
where
0+x≡x : ∀ x → 0 + x ≡ x
0+x≡x x = refl
x+0≡x : ∀ x → x + 0 ≡ x
x+0≡x zero = refl
x+0≡x (suc x) = cong suc (x+0≡x x)
-- -------------------------
-- ---------- Int ----------
data ℤ : Set where
O : ℤ
I : ℕ → ℕ → ℤ
postulate
zeroZ : (x : ℕ) → I x x ≡ O
zeroZ₂ : (x y : ℕ) → I (x + y) (y + x) ≡ O
-- plusInt
_++_ : ℤ → ℤ → ℤ
O ++ O = O
O ++ X = X
X ++ O = X
I x y ++ I z w = I (x + z) (y + w)
-- productInt
_**_ : ℤ → ℤ → ℤ
O ** O = O
O ** _ = O
_ ** O = O
I x y ** I z w = I (x * z + y * w) (x * w + y * z)
-- -------------------------
-- ---------- Int + ----------
ℤ++-isSemiGroup : IsSemiGroup ℤ _++_
ℤ++-isSemiGroup = record { assoc = ℤ++-assoc }
where
open IsSemiGroup
ℤ++-assoc : ∀ x y z → (x ++ y) ++ z ≡ x ++ (y ++ z)
ℤ++-assoc O O O = refl
ℤ++-assoc O O (I x x₁) = refl
ℤ++-assoc O (I x x₁) O = refl
ℤ++-assoc O (I x x₁) (I x₂ x₃) = refl
ℤ++-assoc (I x x₁) O O = refl
ℤ++-assoc (I x x₁) O (I x₂ x₃) = refl
ℤ++-assoc (I x x₁) (I x₂ x₃) O = refl
ℤ++-assoc (I x x₁) (I x₂ x₃) (I x₄ x₅)
= cong₂ I ((assoc ℕ+-isSemiGroup) x x₂ x₄) ((assoc ℕ+-isSemiGroup) x₁ x₃ x₅)
ℤ++O-isMonoid : IsMonoid ℤ _++_ O
ℤ++O-isMonoid = record { isSemiGroup = ℤ++-isSemiGroup ; identity = (O++x≡x , x++O≡x) }
where
O++x≡x : (x : ℤ) → (O ++ x) ≡ x
O++x≡x O = refl
O++x≡x (I x x₁) = refl
x++O≡x : (x : ℤ) → (x ++ O) ≡ x
x++O≡x O = refl
x++O≡x (I x x₁) = refl
invℤ : ℤ → ℤ
invℤ O = O
invℤ (I x x₁) = I x₁ x
ℤ++Oinvℤ-isGroup : IsGroup ℤ _++_ O invℤ
ℤ++Oinvℤ-isGroup = record { isMonoid = ℤ++O-isMonoid ; inv = (leftInv , rightInv) }
where
leftInv : (x : ℤ) → (invℤ x ++ x) ≡ O
leftInv O = refl
leftInv (I x x₁) = zeroZ₂ x₁ x
rightInv : (x : ℤ) → (x ++ invℤ x) ≡ O
rightInv O = refl
rightInv (I x x₁) = zeroZ₂ x x₁
ℤ++Oinvℤ-isAbelianGroup : IsAbelianGroup ℤ _++_ O invℤ
ℤ++Oinvℤ-isAbelianGroup = record { isGroup = ℤ++Oinvℤ-isGroup ; comm = ℤ++Oinvℤ-Comm }
where
ℤ++Oinvℤ-Comm : (x y : ℤ) → (x ++ y) ≡ (y ++ x)
ℤ++Oinvℤ-Comm O O = refl
ℤ++Oinvℤ-Comm O (I x x₁) = refl
ℤ++Oinvℤ-Comm (I x x₁) O = refl
ℤ++Oinvℤ-Comm (I x x₁) (I x₂ x₃) = cong₂ I (+-comm x x₂) (+-comm x₁ x₃)
-- ---------------------------
-- ---------- Int * ----------
ℤ**-isSemiGroup : IsSemiGroup ℤ _**_
ℤ**-isSemiGroup = record { assoc = ℤ**-assoc }
where
ℤ**-assoc : ∀ x y z → (x ** y) ** z ≡ x ** (y ** z)
ℤ**-assoc O O O = refl
ℤ**-assoc O O (I x x₁) = refl
ℤ**-assoc O (I x x₁) O = refl
ℤ**-assoc O (I x x₁) (I x₂ x₃) = refl
ℤ**-assoc (I x x₁) O O = refl
ℤ**-assoc (I x x₁) O (I x₂ x₃) = refl
ℤ**-assoc (I x x₁) (I x₂ x₃) O = refl
ℤ**-assoc (I x x₁) (I x₂ x₃) (I x₄ x₅)
= cong₂ I (ℤ**-assoc₁ x x₁ x₂ x₃ x₄ x₅) (ℤ**-assoc₁ x x₁ x₂ x₃ x₅ x₄)
where
open PropEq.≡-Reasoning
open IsSemiGroup
ℤ**-assoc₁ : ∀ x y z u v w →
(x * z + y * u) * v + (x * u + y * z) * w ≡ x * (z * v + u * w) + y * (z * w + u * v)
ℤ**-assoc₁ x y z u v w = begin
(x * z + y * u) * v + (x * u + y * z) * w
≡⟨ cong (\ t → (t + (x * u + y * z) * w)) (*-distribʳ-+ v (x * z) (y * u)) ⟩
x * z * v + y * u * v + (x * u + y * z) * w
≡⟨ cong (\ t → (x * z * v + y * u * v + t)) (*-distribʳ-+ w (x * u) (y * z)) ⟩
x * z * v + y * u * v + (x * u * w + y * z * w)
≡⟨ +-assoc (x * z * v) (y * u * v) (x * u * w + y * z * w) ⟩
x * z * v + (y * u * v + (x * u * w + y * z * w))
≡⟨ cong (\ t → ((x * z * v) + t)) (+-comm (y * u * v) (x * u * w + y * z * w)) ⟩
x * z * v + ((x * u * w + y * z * w) + y * u * v)
≡⟨ sym (+-assoc (x * z * v) (x * u * w + y * z * w) (y * u * v)) ⟩
x * z * v + (x * u * w + y * z * w) + y * u * v
≡⟨ sym (cong (\ t → (t + y * u * v)) ((assoc ℕ+-isSemiGroup) (x * z * v) (x * u * w) (y * z * w))) ⟩
x * z * v + x * u * w + y * z * w + y * u * v
≡⟨ cong (\ t → t + x * u * w + y * z * w + y * u * v) (*-assoc x z v) ⟩
x * (z * v) + x * u * w + y * z * w + y * u * v
≡⟨ cong (\ t → x * (z * v) + t + y * z * w + y * u * v) (*-assoc x u w) ⟩
x * (z * v) + x * (u * w) + y * z * w + y * u * v
≡⟨ cong (\ t → x * (z * v) + x * (u * w) + t + y * u * v) (*-assoc y z w) ⟩
x * (z * v) + x * (u * w) + y * (z * w) + y * u * v
≡⟨ cong (\ t → x * (z * v) + x * (u * w) + y * (z * w) + t) (*-assoc y u v) ⟩
x * (z * v) + x * (u * w) + y * (z * w) + y * (u * v)
≡⟨ sym (cong (\ t → (t + y * (z * w) + y * (u * v))) (*-distribˡ-+ x (z * v) (u * w))) ⟩
x * (z * v + u * w) + y * (z * w) + y * (u * v)
≡⟨ +-assoc (x * (z * v + u * w)) (y * (z * w)) (y * (u * v)) ⟩
x * (z * v + u * w) + (y * (z * w) + y * (u * v))
≡⟨ sym (cong (\ t → (x * (z * v + u * w) + t)) (*-distribˡ-+ y (z * w) (u * v))) ⟩
x * (z * v + u * w) + y * (z * w + u * v)
∎
ℤ**1-isMonoid : IsMonoid ℤ _**_ (I 1 0)
ℤ**1-isMonoid = record { isSemiGroup = ℤ**-isSemiGroup ; identity = (1**x≡x , x**1≡x) }
where
1**x≡x : (x : ℤ) → (I 1 0 ** x) ≡ x
1**x≡x O = refl
1**x≡x (I x x₁) = cong₂ I (x+z+z≡x x) (x+z+z≡x x₁)
where
x+z+z≡x : (x : ℕ) → x + 0 + 0 ≡ x
x+z+z≡x zero = refl
x+z+z≡x (suc x) = cong suc (x+z+z≡x x)
x**1≡x : (x : ℤ) → (x ** I 1 0) ≡ x
x**1≡x O = refl
x**1≡x (I x x₁) = cong₂ I (x*1+x*0≡x x x₁) (x*0+x*1=x x x₁)
where
x*1+x*0≡x : (x x₁ : ℕ) → x * 1 + x₁ * 0 ≡ x
x*1+x*0≡x zero zero = refl
x*1+x*0≡x zero (suc x₁) = x*1+x*0≡x zero x₁
x*1+x*0≡x (suc x) zero = cong suc (x*1+x*0≡x x zero)
x*1+x*0≡x (suc x) (suc x₁) = x*1+x*0≡x (suc x) x₁
x*0+x*1=x : (x x₁ : ℕ) → x * 0 + x₁ * 1 ≡ x₁
x*0+x*1=x zero zero = refl
x*0+x*1=x zero (suc x₁) = cong suc (x*0+x*1=x zero x₁)
x*0+x*1=x (suc x) zero = x*0+x*1=x x zero
x*0+x*1=x (suc x) (suc x₁) = x*0+x*1=x x (suc x₁)
-- ---------------------------
-- ---------- Int + * ----------
ℤ++0invℤ-**1-isRing : IsRing ℤ _++_ _**_ O (I 1 0) invℤ
ℤ++0invℤ-**1-isRing =
record
{ ⊕isAbelianGroup = ℤ++Oinvℤ-isAbelianGroup
; ⊗isMonoid = ℤ**1-isMonoid
; isDistR = ℤdistR
; isDistL = ℤdistL }
where
ℤdistR : (x y z : ℤ) → (x ++ y) ** z ≡ (x ** z) ++ (y ** z)
ℤdistR O O O = refl
ℤdistR O O (I x x₁) = refl
ℤdistR O (I x x₁) O = refl
ℤdistR O (I x x₁) (I x₂ x₃) = refl
ℤdistR (I x x₁) O O = refl
ℤdistR (I x x₁) O (I x₂ x₃) = refl
ℤdistR (I x x₁) (I x₂ x₃) O = refl
ℤdistR (I x x₁) (I x₂ x₃) (I x₄ x₅) = cong₂ I (ℤdistR₁ x x₂ x₄ x₁ x₃ x₅) (ℤdistR₁ x x₂ x₅ x₁ x₃ x₄)
where
open PropEq.≡-Reasoning
open IsSemiGroup
ℤdistR₁ : (x y z u v w : ℕ) →
(x + y) * z + (u + v) * w ≡ x * z + u * w + (y * z + v * w)
ℤdistR₁ x y z u v w = begin
(x + y) * z + (u + v) * w
≡⟨ cong (\ t → t + (u + v) * w) (*-distribʳ-+ z x y) ⟩
x * z + y * z + (u + v) * w
≡⟨ cong (\ t → (x * z + y * z + t)) (*-distribʳ-+ w u v) ⟩
x * z + y * z + (u * w + v * w)
≡⟨ +-assoc (x * z) (y * z) (u * w + v * w) ⟩
x * z + (y * z + (u * w + v * w))
≡⟨ cong (\ t → x * z + t) (+-comm (y * z) (u * w + v * w)) ⟩
x * z + ((u * w + v * w) + y * z)
≡⟨ cong (\ t → x * z + t) ((assoc ℕ+-isSemiGroup) (u * w) (v * w) (y * z)) ⟩
x * z + (u * w + (v * w + y * z))
≡⟨ cong (\ t → x * z + (u * w + t)) (+-comm (v * w) (y * z)) ⟩
x * z + (u * w + (y * z + v * w))
≡⟨ sym ((assoc ℕ+-isSemiGroup) (x * z) (u * w) (y * z + v * w)) ⟩
x * z + u * w + (y * z + v * w)
∎
ℤdistL : (x y z : ℤ) → x ** (y ++ z) ≡ (x ** y) ++ (x ** z)
ℤdistL O O O = refl
ℤdistL O O (I x x₁) = refl
ℤdistL O (I x x₁) O = refl
ℤdistL O (I x x₁) (I x₂ x₃) = refl
ℤdistL (I x x₁) O O = refl
ℤdistL (I x x₁) O (I x₂ x₃) = refl
ℤdistL (I x x₁) (I x₂ x₃) O = refl
ℤdistL (I x x₁) (I x₂ x₃) (I x₄ x₅) = cong₂ I (ℤdistL₁ x x₁ x₂ x₃ x₄ x₅) (ℤdistL₁ x x₁ x₃ x₂ x₅ x₄)
where
open PropEq.≡-Reasoning
open IsSemiGroup
ℤdistL₁ : (x y z u v w : ℕ) →
x * (z + v) + y * (u + w) ≡ x * z + y * u + (x * v + y * w)
ℤdistL₁ x y z u v w = begin
x * (z + v) + y * (u + w)
≡⟨ cong (\ t → t + y * (u + w)) (*-distribˡ-+ x z v) ⟩
x * z + x * v + y * (u + w)
≡⟨ cong (\ t → x * z + x * v + t) (*-distribˡ-+ y u w) ⟩
x * z + x * v + (y * u + y * w)
≡⟨ +-assoc (x * z) (x * v) (y * u + y * w) ⟩
x * z + (x * v + (y * u + y * w))
≡⟨ sym (cong (\ t → x * z + t) ((assoc ℕ+-isSemiGroup) (x * v) (y * u) (y * w))) ⟩
x * z + ((x * v + y * u) + y * w)
≡⟨ cong (\ t → x * z + (t + y * w)) (+-comm (x * v) (y * u)) ⟩
x * z + ((y * u + x * v) + y * w)
≡⟨ cong (\ t → x * z + t) ((assoc ℕ+-isSemiGroup) (y * u) (x * v) (y * w)) ⟩
x * z + (y * u + (x * v + y * w))
≡⟨ sym ((assoc ℕ+-isSemiGroup) (x * z) (y * u) (x * v + y * w)) ⟩
x * z + y * u + (x * v + y * w)
∎
-- ---------------------------
-- (-1) * (-1) = 1
minus : I 0 1 ** I 0 1 ≡ I 1 0
minus = refl
| 40.623656
| 111
| 0.374184
|
13760a127671ba6c32015c0ec9e146366d4dbeae
| 2,215
|
agda
|
Agda
|
Pi-/AuxLemmas.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
Pi-/AuxLemmas.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
Pi-/AuxLemmas.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
module Pi-.AuxLemmas where
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Relation.Binary.Core
open import Relation.Binary
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Data.Nat
open import Data.Nat.Properties
open import Data.List as L
open import Function using (_∘_)
open import Pi-.Syntax
open import Pi-.Opsem
Lemma₁ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c' ∣ v' ∣ κ' ⟩◁
→ A ≡ C × B ≡ D
Lemma₁ ↦⃖₁ = refl , refl
Lemma₁ ↦⃖₂ = refl , refl
Lemma₂ : ∀ {A B v v' κ κ'} {c c' : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c' ∣ v' ∣ κ' ⟩◁
→ c ≡ c' × κ ≡ κ'
Lemma₂ ↦⃖₁ = refl , refl
Lemma₂ ↦⃖₂ = refl , refl
Lemma₃ : ∀ {A B v v' κ} {c : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁
→ base c ⊎ A ≡ B
Lemma₃ (↦⃖₁ {b = b}) = inj₁ b
Lemma₃ ↦⃖₂ = inj₂ refl
Lemma₄ : ∀ {A v v' κ} {c : A ↔ A}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁
→ base c ⊎ c ≡ id↔
Lemma₄ (↦⃖₁ {b = b}) = inj₁ b
Lemma₄ ↦⃖₂ = inj₂ refl
Lemma₅ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D}
→ [ c ∣ v ∣ κ ]◁ ↦ [ c' ∣ v' ∣ κ' ]▷
→ A ≡ C × B ≡ D
Lemma₅ ↦η₁ = refl , refl
Lemma₅ ↦η₂ = refl , refl
Lemma₆ : ∀ {A B v v' κ κ'} {c c' : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ [ c' ∣ v' ∣ κ' ]▷
→ c ≡ c' × κ ≡ κ'
Lemma₆ ↦η₁ = refl , refl
Lemma₆ ↦η₂ = refl , refl
Lemma₇ : ∀ {A B v v' κ} {c : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ [ c ∣ v' ∣ κ ]▷
→ A ≡ 𝟘
Lemma₇ ↦η₁ = refl
Lemma₇ ↦η₂ = refl
Lemma₈ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D}
→ ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c' ∣ v' ∣ κ' ]▷
→ A ≡ C × B ≡ D
Lemma₈ ↦⃗₁ = refl , refl
Lemma₈ ↦⃗₂ = refl , refl
Lemma₉ : ∀ {A B v v' κ κ'} {c c' : A ↔ B}
→ ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c' ∣ v' ∣ κ' ]▷
→ c ≡ c' × κ ≡ κ'
Lemma₉ ↦⃗₁ = refl , refl
Lemma₉ ↦⃗₂ = refl , refl
Lemma₁₀ : ∀ {A B v v' κ} {c : A ↔ B}
→ (r : ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c ∣ v' ∣ κ ]▷)
→ base c ⊎ A ≡ B
Lemma₁₀ (↦⃗₁ {b = b}) = inj₁ b
Lemma₁₀ ↦⃗₂ = inj₂ refl
Lemma₁₁ : ∀ {A v v' κ} {c : A ↔ A}
→ (r : ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c ∣ v' ∣ κ ]▷)
→ base c ⊎ c ≡ id↔
Lemma₁₁ (↦⃗₁ {b = b}) = inj₁ b
Lemma₁₁ ↦⃗₂ = inj₂ refl
| 27.012195
| 55
| 0.439729
|
c7afcac6214f57a1f3c81c916c07af15e402135b
| 309
|
agda
|
Agda
|
agda/SList/Properties.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | 6
|
2015-05-21T12:50:35.000Z
|
2021-08-24T22:11:15.000Z
|
agda/SList/Properties.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
agda/SList/Properties.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --sized-types #-}
module SList.Properties (A : Set) where
open import Data.List
open import List.Permutation.Base A
open import SList
lemma-unsize-size : (xs : List A) → xs ∼ unsize A (size A xs)
lemma-unsize-size [] = ∼[]
lemma-unsize-size (x ∷ xs) = ∼x /head /head (lemma-unsize-size xs)
| 22.071429
| 67
| 0.669903
|
29cf512a4a676f189fb3dde1236c80ede64d4aa7
| 92
|
agda
|
Agda
|
test/Fail/Issue5410-4.agda
|
MxmUrw/agda
|
6ede01fa854c5472e54f7d1799ca2c08ed316129
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue5410-4.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue5410-4.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --without-K #-}
variable
@0 A : Set
record D : Set₁ where
field
f : A
| 10.222222
| 27
| 0.554348
|
126095c5c9d0030aad6d912966b67433e7dc48fa
| 182
|
agda
|
Agda
|
src/LFRef/Readme.agda
|
ajrouvoet/implicits.agda
|
ef2e347a4470e55083c83b743efbc2902ef1ad22
|
[
"MIT"
] | 4
|
2019-04-05T17:57:11.000Z
|
2021-05-07T04:08:41.000Z
|
src/LFRef/Readme.agda
|
ElessarWebb/implicits.agda
|
ef2e347a4470e55083c83b743efbc2902ef1ad22
|
[
"MIT"
] | null | null | null |
src/LFRef/Readme.agda
|
ElessarWebb/implicits.agda
|
ef2e347a4470e55083c83b743efbc2902ef1ad22
|
[
"MIT"
] | null | null | null |
module LFRef.Readme where
open import LFRef.Syntax
open import LFRef.Welltyped
open import LFRef.Eval
open import LFRef.Properties.Soundness
open import LFRef.Properties.Confluence
| 22.75
| 39
| 0.851648
|
048361d97a81f2173032e4f2ff98a69221c92d20
| 1,658
|
agda
|
Agda
|
Cubical/Foundations/Pointed/FunExt.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/FunExt.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/FunExt.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Pointed.FunExt where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Pointed.Base
open import Cubical.Foundations.Pointed.Properties
open import Cubical.Foundations.Pointed.Homotopy
private
variable
ℓ ℓ' : Level
module _ {A : Pointed ℓ} {B : typ A → Type ℓ'} {ptB : B (pt A)} where
-- pointed function extensionality
funExt∙P : {f g : Π∙ A B ptB} → f ∙∼P g → f ≡ g
funExt∙P (h , h∙) i = (λ x → h x i) , h∙ i
-- inverse of pointed function extensionality
funExt∙P⁻ : {f g : Π∙ A B ptB} → f ≡ g → f ∙∼P g
funExt∙P⁻ p = (λ a i → p i .fst a) , λ i → p i .snd
-- function extensionality is an isomorphism, PathP version
funExt∙PIso : (f g : Π∙ A B ptB) → Iso (f ∙∼P g) (f ≡ g)
Iso.fun (funExt∙PIso f g) = funExt∙P {f = f} {g = g}
Iso.inv (funExt∙PIso f g) = funExt∙P⁻ {f = f} {g = g}
Iso.rightInv (funExt∙PIso f g) p = refl
Iso.leftInv (funExt∙PIso f g) HP = refl
-- transformed to equivalence
funExt∙P≃ : (f g : Π∙ A B ptB) → (f ∙∼P g) ≃ (f ≡ g)
funExt∙P≃ f g = isoToEquiv (funExt∙PIso f g)
-- funExt∙≃ using the other kind of pointed homotopy
funExt∙≃ : (f g : Π∙ A B ptB) → (f ∙∼ g) ≃ (f ≡ g)
funExt∙≃ f g = compEquiv (∙∼≃∙∼P f g) (funExt∙P≃ f g)
-- standard pointed function extensionality and its inverse
funExt∙ : {f g : Π∙ A B ptB} → f ∙∼ g → f ≡ g
funExt∙ {f = f} {g = g} = equivFun (funExt∙≃ f g)
funExt∙⁻ : {f g : Π∙ A B ptB} → f ≡ g → f ∙∼ g
funExt∙⁻ {f = f} {g = g} = equivFun (invEquiv (funExt∙≃ f g))
| 35.276596
| 69
| 0.610374
|
12c5395b526e652d3ae827e210e8708887ace9a0
| 335
|
agda
|
Agda
|
test/Succeed/Issue616.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue616.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue616.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
module Issue616 where
open import Common.Coinduction
const : ∀ {a b}{A : Set a}{B : Set b} → A → B → A
const x _ = x
-- The recursive call should be ignored by the termination checker,
-- since ♭ is a projection function and shouldn't store its implicit
-- arguments.
contrived : Set₁
contrived = ♭ {A = const _ contrived} (♯ Set)
| 23.928571
| 68
| 0.689552
|
0b836b9f5ffa6396b0efdf0c2864d4989a2d6d4e
| 588
|
agda
|
Agda
|
proglangs-learning/Agda/Test.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | null | null | null |
proglangs-learning/Agda/Test.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | 4
|
2020-03-10T19:20:21.000Z
|
2021-06-07T15:39:48.000Z
|
proglangs-learning/Agda/Test.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | null | null | null |
module Test where
-- To compile code: stack exec -- agda Test.agda -c
-- or: agda Test.agda -c --ghc-flag=-dynamic
open import IO
-- All of these are not necessary but they help to reduce clutter when looking
-- at the types of the different things in the code
import Agda.Builtin.List as List
open import Agda.Builtin.Unit using (⊤)
open List using (_∷_)
import Agda.Builtin.String as String
main = run (putStrLn "Hello, World!")
data Bool : Set where
true : Bool
false : Bool
if_then_else_ : { A : Set } → Bool → A → A → A
if true then t else e = t
if false then t else e = e
| 25.565217
| 78
| 0.70068
|
c7df4364a4b6c05e60b5c8c094f9b099d0dc8521
| 166
|
agda
|
Agda
|
test/interaction/Issue1494.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue1494.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue1494.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue1494 where
open import Issue1494.Helper
module M (r : Record) where
open Module r
postulate
A : Set
a b : A
Foo : a ≡ b
Foo = {!!}
| 11.066667
| 28
| 0.596386
|
dc4b8dcf1b936845dde3d7d7182c068c84a694d0
| 2,090
|
agda
|
Agda
|
Cubical/Foundations/Equiv/Fiberwise.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Equiv/Fiberwise.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Equiv/Fiberwise.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical #-}
module Cubical.Foundations.Equiv.Fiberwise where
open import Cubical.Core.Everything
open import Cubical.Foundations.Everything
module _ {a p q} {A : Type a} (P : A → Type p) (Q : A → Type q)
(f : ∀ x → P x → Q x)
where
private
total : (Σ A P) → (Σ A Q)
total = (\ p → p .fst , f (p .fst) (p .snd))
-- Thm 4.7.6
fibers-total : ∀ {xv} → Iso (fiber total (xv)) (fiber (f (xv .fst)) (xv .snd))
fibers-total {xv} = iso h g h-g g-h
where
h : ∀ {xv} → fiber total xv → fiber (f (xv .fst)) (xv .snd)
h {xv} (p , eq) = J (\ xv eq → fiber (f (xv .fst)) (xv .snd)) ((p .snd) , refl) eq
g : ∀ {xv} → fiber (f (xv .fst)) (xv .snd) → fiber total xv
g {xv} (p , eq) = (xv .fst , p) , (\ i → _ , eq i)
h-g : ∀ {xv} y → h {xv} (g {xv} y) ≡ y
h-g {x , v} (p , eq) = J (λ _ eq₁ → h (g (p , eq₁)) ≡ (p , eq₁)) (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) ((p , refl))) (eq)
g-h : ∀ {xv} y → g {xv} (h {xv} y) ≡ y
g-h {xv} ((a , p) , eq) = J (λ _ eq₁ → g (h ((a , p) , eq₁)) ≡ ((a , p) , eq₁))
(cong g (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) (p , refl)))
eq
-- half of Thm 4.7.7 (fiberwise equivalences)
fiberEquiv : ([tf] : isEquiv total)
→ ∀ x → isEquiv (f x)
fiberEquiv [tf] x .equiv-proof y = isContrRetract (fibers-total .Iso.inv) (fibers-total .Iso.fun) (fibers-total .Iso.rightInv)
([tf] .equiv-proof (x , y))
module _ {ℓ : Level} {U : Type ℓ} {ℓr} (_~_ : U → U → Type ℓr)
(idTo~ : ∀ {A B} → A ≡ B → A ~ B)
(c : ∀ A → isContr (Σ U \ X → A ~ X))
where
isContrToUniv : ∀ {A B} → isEquiv (idTo~ {A} {B})
isContrToUniv {A} {B}
= fiberEquiv (λ z → A ≡ z) (λ z → A ~ z) (\ B → idTo~ {A} {B})
(λ { .equiv-proof y
→ isContrΣ ((_ , refl) , (\ z → contrSingl (z .snd)))
\ a → isContr→isContrPath (c A) _ _
})
B
| 42.653061
| 140
| 0.439234
|
ad7418a26dc17b815dbb93d097c19183c9ea2c2f
| 9,364
|
agda
|
Agda
|
theorems/homotopy/LoopSpaceCircle.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
theorems/homotopy/LoopSpaceCircle.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
theorems/homotopy/LoopSpaceCircle.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT
{-
This file contains three proofs of Ω(S¹) = ℤ and the fact that the circle is
a 1-type:
- Something closely related to Mike’s original proof
- Dan’s encode-decode proof
- Guillaume’s proof using the flattening lemma.
This file is divided in a lot of different parts so that common parts can be
factored:
1. Definition of the universal cover and the encoding map (this part is common
to all three proofs)
2. Proof that [encode (loop^ n) == n] (this part is common to Mike’s proof and
the encode-decode proof)
3. Dan’s encode-decode proof that [Ω S¹ ≃ ℤ]
4. Mike’s proof that [Σ S¹ Cover] is contractible
5. Proof with the flattening lemma that [Σ S¹ S¹Cover] is contractible
6. Proof of [Ω S¹ ≃ ℤ] using the fact that [Σ S¹ S¹Cover] is contractible (common
to Mike’s proof and the flattening lemma proof)
7. Encode-decode proof of the whole equivalence
8. Proof that the circle is a 1-type (common to all three proofs)
Keep
- 1, 2, 3 for the encode-decode proof (+ 7, 8 for S¹ is a 1-type)
- 1, 2, 4, 6 for Mike’s proof (+ 8)
- 1, 5, 6 for the flattening lemma proof (+ 8)
-}
module homotopy.LoopSpaceCircle where
{- 1. Universal cover and encoding map (common to all three proofs) -}
module S¹Cover = S¹RecType ℤ succ-equiv
S¹Cover : S¹ → Type₀
S¹Cover = S¹Cover.f
encode : {x : S¹} (p : base == x) → S¹Cover x
encode p = transport S¹Cover p 0
{- 2. Encoding [loop^ n] (common to Mike’s proof and the encode-decode proof) -}
-- We define the element of [Ω S¹] which is supposed to correspond to an
-- integer [n], this is the loop winding around the circle [n] times.
-- This is easy by induction on [n]
loop^ : (n : ℤ) → base == base
loop^ (pos O) = idp
loop^ (pos (S n)) = loop^ (pos n) ∙ loop
loop^ (negsucc O) = ! loop
loop^ (negsucc (S n)) = loop^ (negsucc n) ∙ (! loop)
-- Compatibility of [loop^] with the successor function
-- This is again not difficult by induction on [n]
loop^succ : (n : ℤ) → loop^ n ∙ loop == loop^ (succ n)
loop^succ (pos n) = idp
loop^succ (negsucc O) = !-inv-l loop
loop^succ (negsucc (S n)) =
(loop^ (negsucc n) ∙ ! loop) ∙ loop
=⟨ ∙-assoc (loop^ (negsucc n)) (! loop) loop ⟩
loop^ (negsucc n) ∙ (! loop ∙ loop)
=⟨ !-inv-l loop |in-ctx (λ u → loop^ (negsucc n) ∙ u) ⟩
loop^ (negsucc n) ∙ idp
=⟨ ∙-unit-r _ ⟩
loop^ (negsucc n) ∎
-- Now we check that encoding [loop^ n] gives indeed [n], again by induction
-- on [n]
encode-loop^ : (n : ℤ) → encode (loop^ n) == n
encode-loop^ (pos O) = idp
encode-loop^ (pos (S n)) =
encode (loop^ (pos n) ∙ loop) =⟨ idp ⟩
coe (ap S¹Cover (loop^ (pos n) ∙ loop)) 0
=⟨ ap-∙ S¹Cover (loop^ (pos n)) loop |in-ctx (λ u → coe u 0) ⟩
coe (ap S¹Cover (loop^ (pos n)) ∙ ap S¹Cover loop) 0
=⟨ coe-∙ (ap S¹Cover (loop^ (pos n)))
(ap S¹Cover loop) 0 ⟩
coe (ap S¹Cover loop) (coe (ap S¹Cover (loop^ (pos n))) 0)
=⟨ encode-loop^ (pos n) |in-ctx coe (ap S¹Cover loop) ⟩
coe (ap S¹Cover loop) (pos n)
=⟨ S¹Cover.coe-loop-β (pos n) ⟩
pos (S n) ∎
encode-loop^ (negsucc O) =
coe (ap S¹Cover (! loop)) 0 =⟨ coe-ap-! S¹Cover loop 0 ⟩
coe! (ap S¹Cover loop) 0 =⟨ S¹Cover.coe!-loop-β 0 ⟩
negsucc O ∎
encode-loop^ (negsucc (S n)) =
encode (loop^ (negsucc n) ∙ ! loop) =⟨ idp ⟩
coe (ap S¹Cover (loop^ (negsucc n) ∙ ! loop)) 0
=⟨ ap-∙ S¹Cover (loop^ (negsucc n)) (! loop)
|in-ctx (λ u → coe u 0) ⟩
coe (ap S¹Cover (loop^ (negsucc n)) ∙ ap S¹Cover (! loop)) 0
=⟨ coe-∙ (ap S¹Cover (loop^ (negsucc n)))
(ap S¹Cover (! loop)) 0 ⟩
coe (ap S¹Cover (! loop)) (coe (ap S¹Cover (loop^ (negsucc n))) 0)
=⟨ encode-loop^ (negsucc n) |in-ctx coe (ap S¹Cover (! loop)) ⟩
coe (ap S¹Cover (! loop)) (negsucc n)
=⟨ coe-ap-! S¹Cover loop (negsucc n) ⟩
coe! (ap S¹Cover loop) (negsucc n)
=⟨ S¹Cover.coe!-loop-β (negsucc n) ⟩
negsucc (S n) ∎
{- 3. Dan’s encode-decode proof -}
-- The decoding function at [base] is [loop^], but we extend it to the whole
-- of [S¹] so that [decode-encode] becomes easier (and we need [loop^succ] to
-- be able to extend it)
decode : (x : S¹) → (S¹Cover x → base == x)
decode =
S¹-elim loop^ (↓-→-in (λ {n} q →
↓-cst=idf-in
(loop^succ n ∙ ap loop^ (S¹Cover.↓-loop-out q))))
decode-encode : (x : S¹) (p : base == x) → decode x (encode p) == p
decode-encode _ p = J (λ x p → decode x (encode p) == p) idp p -- Magic!
-- And we get the theorem
ΩS¹≃ℤ : (base == base) ≃ ℤ
ΩS¹≃ℤ = equiv encode (decode base) encode-loop^ (decode-encode base)
{- 4. Mike’s proof that [Σ S¹ Cover] is contractible -}
-- We want to prove that every point of [Σ S¹ S¹Cover] is equal to [(base , O)]
paths-mike : (xt : Σ S¹ S¹Cover) → (base , 0) == xt
paths-mike (x , t) = paths-mike-c x t where
-- We do it by circle-induction on the first component. When it’s [base],
-- we use the [↓-loop^] below (which is essentially [encode-loop^]) and
-- for [loop] we use [loop^succ] and the fact that [ℤ] is a set.
paths-mike-c : (x : S¹) (t : S¹Cover x) → (base , 0) == (x , t) :> Σ S¹ S¹Cover
paths-mike-c = S¹-elim
(λ n → pair= (loop^ n) (↓-loop^ n))
(↓-Π-in (λ {n} {n'} q →
↓-cst=idf-in
(pair= (loop^ n) (↓-loop^ n) ∙ pair= loop q
=⟨ Σ-∙ (↓-loop^ n) q ⟩
pair= (loop^ n ∙ loop) (↓-loop^ n ∙ᵈ q)
=⟨ pair== (loop^succ n ∙ ap loop^ (S¹Cover.↓-loop-out q))
(set-↓-has-all-paths-↓ ℤ-is-set) ⟩
pair= (loop^ n') (↓-loop^ n') ∎))) where
↓-loop^ : (n : ℤ) → 0 == n [ S¹Cover ↓ loop^ n ]
↓-loop^ n = from-transp _ _ (encode-loop^ n)
contr-mike : is-contr (Σ S¹ S¹Cover)
contr-mike = ((base , 0) , paths-mike)
{- 5. Flattening lemma proof that [Σ S¹ Cover] is contractible -}
--We import the flattening lemma for the universal cover of the circle
--open FlatteningS¹ ℤ succ-equiv
open S¹Cover using (module Wt; Wt; cct; ppt; flattening-S¹)
-- We prove that the flattened HIT corresponding to the universal cover of the
-- circle (the real line) is contractible
Wt-is-contr : is-contr Wt
Wt-is-contr = (cct tt 0 , Wt.elim (base* ∘ snd) (loop* ∘ snd)) where
-- This is basically [loop^]
base* : (n : ℤ) → cct tt 0 == cct tt n
base* (pos O) = idp
base* (pos (S n)) = base* (pos n) ∙ ppt tt (pos n)
base* (negsucc O) = ! (ppt tt (negsucc O))
base* (negsucc (S n)) = base* (negsucc n) ∙ ! (ppt tt (negsucc (S n)))
loop* : (n : ℤ)
→ base* n == base* (succ n) [ (λ x → cct tt 0 == x) ↓ ppt tt n ]
loop* n = ↓-cst=idf-in (aux n) where
-- This is basically [loop^succ]
aux : (n : ℤ) → base* n ∙ ppt tt n == base* (succ n)
aux (pos n) = idp
aux (negsucc O) = !-inv-l (ppt tt (negsucc O))
aux (negsucc (S n)) =
base* (negsucc (S n)) ∙ ppt tt (negsucc (S n))
=⟨ idp ⟩
(base* (negsucc n) ∙ ! (ppt tt (negsucc (S n)))) ∙ ppt tt (negsucc (S n))
=⟨ ∙-assoc (base* (negsucc n)) _ _ ⟩
base* (negsucc n) ∙ (! (ppt tt (negsucc (S n))) ∙ ppt tt (negsucc (S n)))
=⟨ !-inv-l (ppt tt (negsucc (S n)))
|in-ctx (λ u → base* (negsucc n) ∙ u) ⟩
base* (negsucc n) ∙ idp
=⟨ ∙-unit-r _ ⟩
base* (negsucc n) ∎
-- Then, using the flattening lemma we get that the total space of [Cover] is
-- contractible
contr-flattening : is-contr (Σ S¹ S¹Cover)
contr-flattening = transport! is-contr flattening-S¹ Wt-is-contr
{- 6. Proof that [Ω S¹ ≃ ℤ] using the fact that [Σ S¹ Cover] is contractible -}
tot-encode : Σ S¹ (λ x → base == x) → Σ S¹ S¹Cover
tot-encode (x , y) = (x , encode y)
-- The previous map induces an equivalence on the total spaces, because both
-- total spaces are contractible
total-is-equiv : is-equiv tot-encode
total-is-equiv = contr-to-contr-is-equiv _ (pathfrom-is-contr base) contr-flattening
-- Hence it’s an equivalence fiberwise
postulate -- TODO, will be only one line using the fact that an equivalence on
-- total spaces induces an equivalence fiberwise
encode-is-equiv : (x : S¹) → is-equiv (encode {x})
-- We can then conclude that the loop space of the circle is equivalent to [ℤ]
ΩS¹≃ℤ' : (base == base) ≃ ℤ
ΩS¹≃ℤ' = (encode {base} , encode-is-equiv base)
{- 7. Encode-decode proof of the whole fiberwise equivalence -}
-- This is quite similar to [paths-mike], we’re doing it by circle-induction,
-- the base case is [encode-loop^] and the loop case is using the fact that [ℤ]
-- is a set (and [loop^succ] is already used in [decode])
encode-decode : (x : S¹) (t : S¹Cover x) → encode (decode x t) == t
encode-decode =
S¹-elim {P = λ x → (t : S¹Cover x) → encode (decode x t) == t}
encode-loop^ (↓-Π-in (λ q → prop-has-all-paths-↓ (ℤ-is-set _ _)))
encode-is-equiv' : (x : S¹) → is-equiv (encode {x})
encode-is-equiv' x = is-eq encode (decode x) (encode-decode x) (decode-encode x)
{- 8. Proof that the circle is a 1-type -}
S¹Cover-is-set : (y : S¹) → is-set (S¹Cover y)
S¹Cover-is-set = S¹-elim ℤ-is-set (prop-has-all-paths-↓ is-set-is-prop)
ΩS¹-is-set : (y : S¹) → is-set (base == y)
ΩS¹-is-set y = equiv-preserves-level ((encode {y} , encode-is-equiv y) ⁻¹)
(S¹Cover-is-set y)
S¹-level : has-level 1 S¹
S¹-level =
S¹-elim ΩS¹-is-set (prop-has-all-paths-↓ (Π-level (λ x → is-set-is-prop)))
| 39.510549
| 84
| 0.596113
|
2e71f25b69b076708032dbce1233049ab3208f35
| 968
|
agda
|
Agda
|
Data/List/Kleene/Relation/Unary.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 6
|
2020-09-11T17:45:41.000Z
|
2021-11-16T08:11:34.000Z
|
Data/List/Kleene/Relation/Unary.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | null | null | null |
Data/List/Kleene/Relation/Unary.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 1
|
2021-11-11T12:30:21.000Z
|
2021-11-11T12:30:21.000Z
|
{-# OPTIONS --cubical --safe #-}
module Data.List.Kleene.Relation.Unary where
open import Data.List.Kleene
open import Prelude
open import Data.Fin
open import Relation.Nullary
private
variable
p : Level
◇⁺ : ∀ {A : Type a} (P : A → Type p) → A ⁺ → Type _
◇⁺ P xs = ∃ i × P (xs !⁺ i)
◇⋆ : ∀ {A : Type a} (P : A → Type p) → A ⋆ → Type _
◇⋆ P xs = ∃ i × P (xs !⋆ i)
module Exists {a} {A : Type a} {p} (P : A → Type p) where
push : ∀ {x xs} → ◇⋆ P xs → ◇⁺ P (x & xs)
push (n , x∈xs) = (fs n , x∈xs)
pull : ∀ {x xs} → ¬ P x → ◇⁺ P (x & xs) → ◇⋆ P xs
pull ¬Px (f0 , p∈xs) = ⊥-elim (¬Px p∈xs)
pull ¬Px (fs n , p∈xs) = (n , p∈xs)
◻⁺ : {A : Type a} (P : A → Type p) → A ⁺ → Type _
◻⁺ P xs = ∀ i → P (xs !⁺ i)
◻⋆ : {A : Type a} (P : A → Type p) → 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
| 25.473684
| 57
| 0.472107
|
101541e9055f2b3e633e67e9c776b581c7472de9
| 4,582
|
agda
|
Agda
|
test/LibSucceed/InstanceArguments/07-subclasses.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/LibSucceed/InstanceArguments/07-subclasses.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/07-subclasses.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- {-# OPTIONS --verbose tc.records.ifs:15 #-}
-- {-# OPTIONS --verbose tc.constr.findInScope:15 #-}
-- {-# OPTIONS --verbose tc.term.args.ifs:15 #-}
-- {-# OPTIONS --verbose cta.record.ifs:15 #-}
-- {-# OPTIONS --verbose tc.section.apply:25 #-}
-- {-# OPTIONS --verbose tc.mod.apply:100 #-}
-- {-# OPTIONS --verbose scope.rec:15 #-}
-- {-# OPTIONS --verbose tc.rec.def:15 #-}
module InstanceArguments.07-subclasses where
module Imports where
module L where
open import Agda.Primitive public
using (Level; _⊔_) renaming (lzero to zero; lsuc to suc)
-- 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
infixr 5 _∨_
data Bool : Set where
true : Bool
false : Bool
not : Bool → Bool
not true = false
not false = true
_∨_ : Bool → Bool → Bool
true ∨ b = true
false ∨ b = b
-- extract from Relation.Nullary.Decidable and friends
infix 3 ¬_
data ⊥ : Set where
¬_ : ∀ {ℓ} → 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
-- 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
-- extract from Data.Nat
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-}
pred : ℕ → ℕ
pred zero = zero
pred (suc n) = 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 λ()
open Imports
-- Begin of actual example!
record Eq (A : Set) : Set where
field eq : A → A → Bool
primEqBool : Bool → Bool → Bool
primEqBool true = id
primEqBool false = not
instance
eqBool : Eq Bool
eqBool = record { eq = primEqBool }
primEqNat : ℕ → ℕ → Bool
primEqNat a b = ⌊ a ≟ b ⌋
primLtNat : ℕ → ℕ → Bool
primLtNat 0 _ = true
primLtNat (suc a) (suc b) = primLtNat a b
primLtNat _ _ = false
neq : {t : Set} → {{eqT : Eq t}} → t → t → Bool
neq a b = not $ eq a b
where open Eq {{...}}
record Ord₁ (A : Set) : Set where
infix 6 _<_
field _<_ : A → A → Bool
eqA : Eq A
instance
ord₁Nat : Ord₁ ℕ
ord₁Nat = record { _<_ = primLtNat; eqA = eqNat }
where eqNat : Eq ℕ
eqNat = record { eq = primEqNat }
record Ord₂ {A : Set} (eqA : Eq A) : Set where
infix 6 _<_
field _<_ : A → A → Bool
instance
ord₂Nat : Ord₂ (record { eq = primEqNat })
ord₂Nat = record { _<_ = primLtNat }
record Ord₃ (A : Set) : Set where
infix 6 _<_
field _<_ : A → A → Bool
eqA : Eq A
open Eq eqA public
instance
ord₃Nat : Ord₃ ℕ
ord₃Nat = record { _<_ = primLtNat; eqA = eqNat }
where eqNat : Eq ℕ
eqNat = record { eq = primEqNat }
record Ord₄ {A : Set} {{eqA : Eq A}} : Set where
infix 6 _<_
field _<_ : A → A → Bool
open Eq eqA public
instance
ord₄Nat : Ord₄ {{record { eq = primEqNat }}}
ord₄Nat = record { _<_ = primLtNat }
module test₁ where
open Ord₁ {{...}}
open Eq {{...}}
instance
eqNat : Eq ℕ
eqNat = eqA
test₁ = 5 < 3
test₂ = eq 5 3
test₃ = eq true false
test₄ : {A : Set} → {{ ordA : Ord₁ A }} → A → A → Bool
test₄ a b = a < b ∨ eq a b
where
instance
eqA' : Eq _
eqA' = eqA
module test₃ where
open Ord₃ {{...}}
open Eq {{...}} renaming (eq to eq')
test₁ = 5 < 3
test₂ = eq 5 3
test₃ = eq' true false
test₄ : {A : Set} → {{ ordA : Ord₃ A }} → A → A → Bool
test₄ a b = a < b ∨ eq a b
module test₄ where
open Ord₄ {{...}}
open Eq {{...}} renaming (eq to eq')
test₁ = 5 < 3
test₂ = eq 5 3
test₃ = eq' true false
test₄ : {A : Set} → {{eqA : Eq A}} → {{ ordA : Ord₄ }} → A → A → Bool
test₄ a b = a < b ∨ eq a b
module test₄′ where
open Ord₄ {{...}} hiding (eq)
open Eq {{...}}
eqNat : Eq ℕ
eqNat = record { eq = primEqNat }
test₁ = 5 < 3
test₂ = eq 5 3
test₃ = eq true false
test₄ : {A : Set} → {{ eqA : Eq A }} → {{ ordA : Ord₄ }} → A → A → Bool
test₄ a b = a < b ∨ eq a b
| 22.028846
| 73
| 0.524225
|
59f9700a2470bdfad6eb75c2f539fcbed1aed687
| 33,582
|
agda
|
Agda
|
src/syntax-util.agda
|
CarlOlson/cedille
|
f5ce42258b7d9bc66f75cd679c785d6133b82b58
|
[
"MIT"
] | null | null | null |
src/syntax-util.agda
|
CarlOlson/cedille
|
f5ce42258b7d9bc66f75cd679c785d6133b82b58
|
[
"MIT"
] | null | null | null |
src/syntax-util.agda
|
CarlOlson/cedille
|
f5ce42258b7d9bc66f75cd679c785d6133b82b58
|
[
"MIT"
] | null | null | null |
module syntax-util where
open import lib
open import cedille-types
open import general-util
open import constants
posinfo-gen : posinfo
posinfo-gen = "generated"
pi-gen = posinfo-gen
first-position : posinfo
first-position = "1"
dummy-var : var
dummy-var = "_dummy"
id-term : term
id-term = Lam posinfo-gen NotErased posinfo-gen "x" NoClass (Var posinfo-gen "x")
compileFailType : type
compileFailType = Abs posinfo-gen Erased posinfo-gen "X" (Tkk (Star posinfo-gen)) (TpVar posinfo-gen "X")
qualif-info : Set
qualif-info = var × args
qualif : Set
qualif = trie qualif-info
{-
data json : Set where
json-num : ℕ → json
json-bln : 𝔹 → json
json-str : rope → json
json-lst : 𝕃 json → json
json-obj : 𝕃 (string × json) → json
print-json : json → rope
print-json (json-num n) = [[ ℕ-to-string n ]]
print-json (json-bln b) = [[ if b then "true" else "false" ]]
print-json (json-str r) = r
print-json (json-lst l) = [[ "[" ]] ⊹⊹ h l [[]] ⊹⊹ [[ "]" ]] where
h : 𝕃 json → rope → rope
h [] acc = acc
h (j :: []) acc = acc ⊹⊹ print-json j
h (j :: js) acc = h js (acc ⊹⊹ print-json j ⊹⊹ [[ ", " ]])
print-json (json-obj o) = [[ "{" ]] ⊹⊹ h o [[]] ⊹⊹ [[ "}" ]] where
h : 𝕃 (string × json) → rope → rope
h [] acc = acc
h ((k , v) :: []) acc = acc ⊹⊹ [[ "\"" ^ k ^ "\": " ]] ⊹⊹ print-json v
h ((k , v) :: o) acc = h o (acc ⊹⊹ [[ "\"" ^ k ^ "\": " ]] ⊹⊹ print-json v ⊹⊹ [[ ", " ]])
-}
tag : Set
tag = string × rope
tagged-val : Set
tagged-val = string × rope × 𝕃 tag
tags-to-rope : 𝕃 tag → rope
tags-to-rope [] = [[]]
tags-to-rope ((t , v) :: []) = [[ "\"" ^ t ^ "\":" ]] ⊹⊹ v
tags-to-rope ((t , v) :: ts) = [[ "\"" ^ t ^ "\":" ]] ⊹⊹ v ⊹⊹ [[ "," ]] ⊹⊹ tags-to-rope ts
-- We number these when so we can sort them back in emacs
tagged-val-to-rope : ℕ → tagged-val → rope
tagged-val-to-rope n (t , v , []) = [[ "\"" ^ t ^ "\":[\"" ^ ℕ-to-string n ^ "\",\"" ]] ⊹⊹ v ⊹⊹ [[ "\"]" ]]
tagged-val-to-rope n (t , v , tags) = [[ "\"" ^ t ^ "\":[\"" ^ ℕ-to-string n ^ "\",\"" ]] ⊹⊹ v ⊹⊹ [[ "\",{" ]] ⊹⊹ tags-to-rope tags ⊹⊹ [[ "}]" ]]
tagged-vals-to-rope : ℕ → 𝕃 tagged-val → rope
tagged-vals-to-rope n [] = [[]]
tagged-vals-to-rope n (s :: []) = tagged-val-to-rope n s
tagged-vals-to-rope n (s :: (s' :: ss)) = tagged-val-to-rope n s ⊹⊹ [[ "," ]] ⊹⊹ tagged-vals-to-rope (suc n) (s' :: ss)
make-tag : (name : string) → (values : 𝕃 tag) → (start : ℕ) → (end : ℕ) → tag
make-tag name vs start end = name , [[ "{\"start\":\"" ^ ℕ-to-string start ^ "\",\"end\":\"" ^ ℕ-to-string end ^ "\"" ]] ⊹⊹ vs-to-rope vs ⊹⊹ [[ "}" ]]
where
vs-to-rope : 𝕃 tag → rope
vs-to-rope [] = [[]]
vs-to-rope ((t , v) :: ts) = [[ ",\"" ^ t ^ "\":\"" ]] ⊹⊹ v ⊹⊹ [[ "\"" ]] ⊹⊹ vs-to-rope ts
posinfo-to-ℕ : posinfo → ℕ
posinfo-to-ℕ pi with string-to-ℕ pi
posinfo-to-ℕ pi | just n = n
posinfo-to-ℕ pi | nothing = 0 -- should not happen
posinfo-plus : posinfo → ℕ → posinfo
posinfo-plus pi n = ℕ-to-string (posinfo-to-ℕ pi + n)
posinfo-plus-str : posinfo → string → posinfo
posinfo-plus-str pi s = posinfo-plus pi (string-length s)
star : kind
star = Star posinfo-gen
-- qualify variable by module name
_#_ : string → string → string
fn # v = fn ^ qual-global-str ^ v
_%_ : posinfo → var → string
pi % v = pi ^ qual-local-str ^ v
compileFail : var
compileFail = "compileFail"
compileFail-qual = "" % compileFail
arg-set-erased : maybeErased → arg → arg
arg-set-erased me (TermArg _ t) = TermArg me t
arg-set-erased me (TypeArg T) = TypeArg T
mk-inst : params → args → trie arg × params
mk-inst ((Decl _ _ me x _ _) :: ps) (a :: as) with mk-inst ps as
...| σ , ps' = trie-insert σ x (arg-set-erased me a) , ps'
mk-inst ps as = empty-trie , ps
apps-term : term → args → term
--apps-term f [] = f
--apps-term f ((TermArg me t) :: as) = apps-term (App f me t) as
--apps-term f ((TypeArg t) :: as) = apps-term (AppTp f t) as
apps-term = foldl λ {(TermArg me t) x → App x me t; (TypeArg T) x → AppTp x T}
apps-type : type → args → type
--apps-type f [] = f
--apps-type f ((TermArg _ t) :: as) = apps-type (TpAppt f t) as
--apps-type f ((TypeArg t) :: as) = apps-type (TpApp f t) as
apps-type = foldl λ {(TermArg _ t) x → TpAppt x t; (TypeArg T) x → TpApp x T}
qualif-lookup-term : qualif → string → term
qualif-lookup-term σ x with trie-lookup σ x
... | just (x' , as) = apps-term (Var posinfo-gen x') as
... | _ = Var posinfo-gen x
qualif-lookup-type : qualif → string → type
qualif-lookup-type σ x with trie-lookup σ x
... | just (x' , as) = apps-type (TpVar posinfo-gen x') as
... | _ = TpVar posinfo-gen x
qualif-lookup-kind : args → qualif → string → kind
qualif-lookup-kind xs σ x with trie-lookup σ x
... | just (x' , as) = KndVar posinfo-gen x' (as ++ xs)
... | _ = KndVar posinfo-gen x xs
inst-lookup-term : trie arg → string → term
inst-lookup-term σ x with trie-lookup σ x
... | just (TermArg me t) = t
... | _ = Var posinfo-gen x
inst-lookup-type : trie arg → string → type
inst-lookup-type σ x with trie-lookup σ x
... | just (TypeArg t) = t
... | _ = TpVar posinfo-gen x
params-to-args : params → args
--params-to-args [] = []
--params-to-args ((Decl _ p me v (Tkt t) _) :: ps) = TermArg me (Var posinfo-gen v) :: params-to-args ps
--params-to-args ((Decl _ p _ v (Tkk k) _) :: ps) = TypeArg (TpVar posinfo-gen v) :: params-to-args ps
params-to-args = map λ where
(Decl _ _ me v (Tkt T) _) → TermArg me (Var posinfo-gen v)
(Decl _ _ me v (Tkk k) _) → TypeArg (TpVar posinfo-gen v)
qualif-insert-params : qualif → var → var → params → qualif
qualif-insert-params σ qv v ps = trie-insert σ v (qv , params-to-args ps)
qualif-insert-import : qualif → var → optAs → 𝕃 string → args → qualif
qualif-insert-import σ mn oa [] as = σ
qualif-insert-import σ mn oa (v :: vs) as = qualif-insert-import (trie-insert σ (import-as v oa) (mn # v , as)) mn oa vs as
where
import-as : var → optAs → var
import-as v NoOptAs = v
import-as v (SomeOptAs _ pfx) = pfx # v
tk-is-type : tk → 𝔹
tk-is-type (Tkt _) = tt
tk-is-type (Tkk _) = ff
term-start-pos : term → posinfo
type-start-pos : type → posinfo
kind-start-pos : kind → posinfo
liftingType-start-pos : liftingType → posinfo
term-start-pos (App t x t₁) = term-start-pos t
term-start-pos (AppTp t tp) = term-start-pos t
term-start-pos (Hole pi) = pi
term-start-pos (Lam pi x _ x₁ x₂ t) = pi
term-start-pos (Let pi _ _ _) = pi
term-start-pos (Open pi _ _ _ _) = pi
term-start-pos (Parens pi t pi') = pi
term-start-pos (Var pi x₁) = pi
term-start-pos (Beta pi _ _) = pi
term-start-pos (IotaPair pi _ _ _ _) = pi
term-start-pos (IotaProj t _ _) = term-start-pos t
term-start-pos (Epsilon pi _ _ _) = pi
term-start-pos (Phi pi _ _ _ _) = pi
term-start-pos (Rho pi _ _ _ _ _) = pi
term-start-pos (Chi pi _ _) = pi
term-start-pos (Delta pi _ _) = pi
term-start-pos (Sigma pi _) = pi
term-start-pos (Theta pi _ _ _) = pi
term-start-pos (Mu pi _ _ _ _ _ _ _) = pi
term-start-pos (Mu' pi _ _ _ _ _ _) = pi
type-start-pos (Abs pi _ _ _ _ _) = pi
type-start-pos (TpLambda pi _ _ _ _) = pi
type-start-pos (Iota pi _ _ _ _) = pi
type-start-pos (Lft pi _ _ _ _) = pi
type-start-pos (TpApp t t₁) = type-start-pos t
type-start-pos (TpAppt t x) = type-start-pos t
type-start-pos (TpArrow t _ t₁) = type-start-pos t
type-start-pos (TpEq pi _ _ pi') = pi
type-start-pos (TpParens pi _ pi') = pi
type-start-pos (TpVar pi x₁) = pi
type-start-pos (NoSpans t _) = type-start-pos t -- we are not expecting this on input
type-start-pos (TpHole pi) = pi --ACG
type-start-pos (TpLet pi _ _) = pi
kind-start-pos (KndArrow k k₁) = kind-start-pos k
kind-start-pos (KndParens pi k pi') = pi
kind-start-pos (KndPi pi _ x x₁ k) = pi
kind-start-pos (KndTpArrow x k) = type-start-pos x
kind-start-pos (KndVar pi x₁ _) = pi
kind-start-pos (Star pi) = pi
liftingType-start-pos (LiftArrow l l') = liftingType-start-pos l
liftingType-start-pos (LiftParens pi l pi') = pi
liftingType-start-pos (LiftPi pi x₁ x₂ l) = pi
liftingType-start-pos (LiftStar pi) = pi
liftingType-start-pos (LiftTpArrow t l) = type-start-pos t
term-end-pos : term → posinfo
type-end-pos : type → posinfo
kind-end-pos : kind → posinfo
liftingType-end-pos : liftingType → posinfo
tk-end-pos : tk → posinfo
lterms-end-pos : posinfo → lterms → posinfo
args-end-pos : posinfo → args → posinfo
arg-end-pos : arg → posinfo
kvar-end-pos : posinfo → var → args → posinfo
params-end-pos : posinfo → params → posinfo
param-end-pos : decl → posinfo
term-end-pos (App t x t') = term-end-pos t'
term-end-pos (AppTp t tp) = type-end-pos tp
term-end-pos (Hole pi) = posinfo-plus pi 1
term-end-pos (Lam pi x _ x₁ x₂ t) = term-end-pos t
term-end-pos (Let _ _ _ t) = term-end-pos t
term-end-pos (Open pi _ _ _ t) = term-end-pos t
term-end-pos (Parens pi t pi') = pi'
term-end-pos (Var pi x) = posinfo-plus-str pi x
term-end-pos (Beta pi _ (SomeTerm t pi')) = pi'
term-end-pos (Beta pi (SomeTerm t pi') _) = pi'
term-end-pos (Beta pi NoTerm NoTerm) = posinfo-plus pi 1
term-end-pos (IotaPair _ _ _ _ pi) = pi
term-end-pos (IotaProj _ _ pi) = pi
term-end-pos (Epsilon pi _ _ t) = term-end-pos t
term-end-pos (Phi _ _ _ _ pi) = pi
term-end-pos (Rho pi _ _ _ t t') = term-end-pos t'
term-end-pos (Chi pi T t') = term-end-pos t'
term-end-pos (Delta pi oT t) = term-end-pos t
term-end-pos (Sigma pi t) = term-end-pos t
term-end-pos (Theta _ _ t ls) = lterms-end-pos (term-end-pos t) ls
term-end-pos (Mu _ _ _ _ _ _ _ pi) = pi
term-end-pos (Mu' _ _ _ _ _ _ pi) = pi
type-end-pos (Abs pi _ _ _ _ t) = type-end-pos t
type-end-pos (TpLambda _ _ _ _ t) = type-end-pos t
type-end-pos (Iota _ _ _ _ tp) = type-end-pos tp
type-end-pos (Lft pi _ _ _ t) = liftingType-end-pos t
type-end-pos (TpApp t t') = type-end-pos t'
type-end-pos (TpAppt t x) = term-end-pos x
type-end-pos (TpArrow t _ t') = type-end-pos t'
type-end-pos (TpEq pi _ _ pi') = pi'
type-end-pos (TpParens pi _ pi') = pi'
type-end-pos (TpVar pi x) = posinfo-plus-str pi x
type-end-pos (TpHole pi) = posinfo-plus pi 1
type-end-pos (NoSpans t pi) = pi
type-end-pos (TpLet _ _ t) = type-end-pos t
kind-end-pos (KndArrow k k') = kind-end-pos k'
kind-end-pos (KndParens pi k pi') = pi'
kind-end-pos (KndPi pi _ x x₁ k) = kind-end-pos k
kind-end-pos (KndTpArrow x k) = kind-end-pos k
kind-end-pos (KndVar pi x ys) = args-end-pos (posinfo-plus-str pi x) ys
kind-end-pos (Star pi) = posinfo-plus pi 1
tk-end-pos (Tkt T) = type-end-pos T
tk-end-pos (Tkk k) = kind-end-pos k
args-end-pos pi (x :: ys) = args-end-pos (arg-end-pos x) ys
args-end-pos pi [] = pi
arg-end-pos (TermArg me t) = term-end-pos t
arg-end-pos (TypeArg T) = type-end-pos T
kvar-end-pos pi v = args-end-pos (posinfo-plus-str pi v)
params-end-pos pi [] = pi
params-end-pos pi (p :: ps) = params-end-pos (param-end-pos p) ps
param-end-pos (Decl pi pi' me x atk pi'') = pi''
liftingType-end-pos (LiftArrow l l') = liftingType-end-pos l'
liftingType-end-pos (LiftParens pi l pi') = pi'
liftingType-end-pos (LiftPi x x₁ x₂ l) = liftingType-end-pos l
liftingType-end-pos (LiftStar pi) = posinfo-plus pi 1
liftingType-end-pos (LiftTpArrow x l) = liftingType-end-pos l
lterms-end-pos pi [] = posinfo-plus pi 1 -- must add one for the implicit Beta that we will add at the end
lterms-end-pos pi ((Lterm _ t) :: ls) = lterms-end-pos (term-end-pos t) ls
{- return the end position of the given term if it is there, otherwise
the given posinfo -}
optTerm-end-pos : posinfo → optTerm → posinfo
optTerm-end-pos pi NoTerm = pi
optTerm-end-pos pi (SomeTerm x x₁) = x₁
optTerm-end-pos-beta : posinfo → optTerm → optTerm → posinfo
optTerm-end-pos-beta pi _ (SomeTerm x pi') = pi'
optTerm-end-pos-beta pi (SomeTerm x pi') NoTerm = pi'
optTerm-end-pos-beta pi NoTerm NoTerm = posinfo-plus pi 1
optAs-or : optAs → posinfo → var → posinfo × var
optAs-or NoOptAs pi x = pi , x
optAs-or (SomeOptAs pi x) _ _ = pi , x
tk-arrow-kind : tk → kind → kind
tk-arrow-kind (Tkk k) k' = KndArrow k k'
tk-arrow-kind (Tkt t) k = KndTpArrow t k
TpApp-tk : type → var → tk → type
TpApp-tk tp x (Tkk _) = TpApp tp (TpVar posinfo-gen x)
TpApp-tk tp x (Tkt _) = TpAppt tp (Var posinfo-gen x)
-- expression descriptor
data exprd : Set where
TERM : exprd
TYPE : exprd
KIND : exprd
LIFTINGTYPE : exprd
TK : exprd
ARG : exprd
QUALIF : exprd
⟦_⟧ : exprd → Set
⟦ TERM ⟧ = term
⟦ TYPE ⟧ = type
⟦ KIND ⟧ = kind
⟦ LIFTINGTYPE ⟧ = liftingType
⟦ TK ⟧ = tk
⟦ ARG ⟧ = arg
⟦ QUALIF ⟧ = qualif-info
exprd-name : exprd → string
exprd-name TERM = "term"
exprd-name TYPE = "type"
exprd-name KIND = "kind"
exprd-name LIFTINGTYPE = "lifting type"
exprd-name TK = "type-kind"
exprd-name ARG = "argument"
exprd-name QUALIF = "qualification"
-- checking-sythesizing enum
data checking-mode : Set where
checking : checking-mode
synthesizing : checking-mode
untyped : checking-mode
maybe-to-checking : {A : Set} → maybe A → checking-mode
maybe-to-checking (just _) = checking
maybe-to-checking nothing = synthesizing
is-app : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-app{TERM} (App _ _ _) = tt
is-app{TERM} (AppTp _ _) = tt
is-app{TYPE} (TpApp _ _) = tt
is-app{TYPE} (TpAppt _ _) = tt
is-app _ = ff
is-term-level-app : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-term-level-app{TERM} (App _ _ _) = tt
is-term-level-app{TERM} (AppTp _ _) = tt
is-term-level-app _ = ff
is-type-level-app : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-type-level-app{TYPE} (TpApp _ _) = tt
is-type-level-app{TYPE} (TpAppt _ _) = tt
is-type-level-app _ = ff
is-parens : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-parens{TERM} (Parens _ _ _) = tt
is-parens{TYPE} (TpParens _ _ _) = tt
is-parens{KIND} (KndParens _ _ _) = tt
is-parens{LIFTINGTYPE} (LiftParens _ _ _) = tt
is-parens _ = ff
is-arrow : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-arrow{TYPE} (TpArrow _ _ _) = tt
is-arrow{KIND} (KndTpArrow _ _) = tt
is-arrow{KIND} (KndArrow _ _) = tt
is-arrow{LIFTINGTYPE} (LiftArrow _ _) = tt
is-arrow{LIFTINGTYPE} (LiftTpArrow _ _) = tt
is-arrow _ = ff
is-abs : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-abs{TERM} (Let _ _ _ _) = tt
is-abs{TERM} (Lam _ _ _ _ _ _) = tt
is-abs{TYPE} (Abs _ _ _ _ _ _) = tt
is-abs{TYPE} (TpLambda _ _ _ _ _) = tt
is-abs{TYPE} (Iota _ _ _ _ _) = tt
is-abs{KIND} (KndPi _ _ _ _ _) = tt
is-abs{LIFTINGTYPE} (LiftPi _ _ _ _) = tt
is-abs _ = ff
is-eq-op : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-eq-op{TERM} (Sigma _ _) = tt
is-eq-op{TERM} (Epsilon _ _ _ _) = tt
is-eq-op{TERM} (Rho _ _ _ _ _ _) = tt
is-eq-op{TERM} (Chi _ _ _) = tt
is-eq-op{TERM} (Phi _ _ _ _ _) = tt
is-eq-op{TERM} (Delta _ _ _) = tt
is-eq-op _ = ff
is-beta : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-beta{TERM} (Beta _ _ _) = tt
is-beta _ = ff
is-hole : {ed : exprd} → ⟦ ed ⟧ → 𝔹
is-hole{TERM} (Hole _) = tt
is-hole{TERM} _ = ff
is-hole{TYPE} (TpHole _) = tt
is-hole{TYPE} _ = ff
is-hole{KIND} e = ff
is-hole{LIFTINGTYPE} e = ff
is-hole{TK} (Tkk x) = is-hole x
is-hole{TK} (Tkt x) = is-hole x
is-hole{ARG} (TermArg e? t) = is-hole t
is-hole{ARG} (TypeArg tp) = is-hole tp
is-hole{QUALIF} _ = ff
record is-eq-tp! : Set where
constructor mk-eq-tp!
field
lhs rhs : term -- left-hand side, right-hand side
pil pir : posinfo -- position left, position right
is-eq-tp? : {ed : exprd} → ⟦ ed ⟧ → maybe is-eq-tp!
is-eq-tp? {TYPE} (NoSpans t _) = is-eq-tp? t
is-eq-tp? {TYPE} (TpParens _ t _) = is-eq-tp? t
is-eq-tp? {TYPE} (TpEq pi t₁ t₂ pi') = just $ mk-eq-tp! t₁ t₂ pi pi'
is-eq-tp?{_} _ = nothing
eq-maybeErased : maybeErased → maybeErased → 𝔹
eq-maybeErased Erased Erased = tt
eq-maybeErased Erased NotErased = ff
eq-maybeErased NotErased Erased = ff
eq-maybeErased NotErased NotErased = tt
eq-checking-mode : (m₁ m₂ : checking-mode) → 𝔹
eq-checking-mode checking checking = tt
eq-checking-mode checking synthesizing = ff
eq-checking-mode checking untyped = ff
eq-checking-mode synthesizing checking = ff
eq-checking-mode synthesizing synthesizing = tt
eq-checking-mode synthesizing untyped = ff
eq-checking-mode untyped checking = ff
eq-checking-mode untyped synthesizing = ff
eq-checking-mode untyped untyped = tt
------------------------------------------------------
-- functions intended for building terms for testing
------------------------------------------------------
mlam : var → term → term
mlam x t = Lam posinfo-gen NotErased posinfo-gen x NoClass t
Mlam : var → term → term
Mlam x t = Lam posinfo-gen Erased posinfo-gen x NoClass t
mappe : term → term → term
mappe t1 t2 = App t1 Erased t2
mapp : term → term → term
mapp t1 t2 = App t1 NotErased t2
mvar : var → term
mvar x = Var posinfo-gen x
mtpvar : var → type
mtpvar x = TpVar posinfo-gen x
mall : var → tk → type → type
mall x tk tp = Abs posinfo-gen All posinfo-gen x tk tp
mtplam : var → tk → type → type
mtplam x tk tp = TpLambda posinfo-gen posinfo-gen x tk tp
{- strip off lambda-abstractions from the term, return the lambda-bound vars and the innermost body.
The intention is to call this with at least the erasure of a term, if not the hnf -- so we do
not check for parens, etc. -}
decompose-lams : term → (𝕃 var) × term
decompose-lams (Lam _ _ _ x _ t) with decompose-lams t
decompose-lams (Lam _ _ _ x _ t) | vs , body = (x :: vs) , body
decompose-lams t = [] , t
{- decompose a term into spine form consisting of a non-applications head and arguments.
The outer arguments will come earlier in the list than the inner ones.
As for decompose-lams, we assume the term is at least erased. -}
{-decompose-apps : term → term × (𝕃 term)
decompose-apps (App t _ t') with decompose-apps t
decompose-apps (App t _ t') | h , args = h , (t' :: args)
decompose-apps t = t , []-}
decompose-apps : term → term × args
decompose-apps = h [] where
h : args → term → term × args
h acc (App t me t') = h (TermArg me t' :: acc) t
h acc (AppTp t T) = h (TypeArg T :: acc) t
h acc t = t , acc
decompose-var-headed : (var → 𝔹) → term → maybe (var × args)
decompose-var-headed is-bound t with decompose-apps t
decompose-var-headed is-bound t | Var _ x , args = if is-bound x then nothing else (just (x , args))
decompose-var-headed is-bound t | _ = nothing
data tty : Set where
tterm : term → tty
ttype : type → tty
tty-to-arg : maybeErased → tty → arg
tty-to-arg me (tterm t) = TermArg me t
tty-to-arg me (ttype T) = TypeArg T
ttys-to-args : maybeErased → 𝕃 tty → args
ttys-to-args = map ∘ tty-to-arg
ttys-to-args-for-params : (keep-extra : maybe maybeErased) → params → 𝕃 tty → args
ttys-to-args-for-params b ((Decl _ _ me _ _ _) :: ps) ((tterm t) :: as) =
TermArg me t :: ttys-to-args-for-params b ps as
ttys-to-args-for-params b (_ :: ps) ((ttype T) :: as) =
TypeArg T :: ttys-to-args-for-params b ps as
ttys-to-args-for-params nothing _ _ = []
ttys-to-args-for-params (just me) _ as = ttys-to-args me as
arg-to-tty : arg → tty
arg-to-tty (TermArg me t) = tterm t
arg-to-tty (TypeArg T) = ttype T
args-to-ttys : args → 𝕃 tty
args-to-ttys = map arg-to-tty
{-
decompose-tpapps : type → type × 𝕃 tty
decompose-tpapps (TpApp t t') with decompose-tpapps t
decompose-tpapps (TpApp t t') | h , args = h , (ttype t') :: args
decompose-tpapps (TpAppt t t') with decompose-tpapps t
decompose-tpapps (TpAppt t t') | h , args = h , (tterm t') :: args
decompose-tpapps (TpParens _ t _) = decompose-tpapps t
decompose-tpapps t = t , []
-}
decompose-tpapps : type → type × 𝕃 tty
decompose-tpapps = h [] where
h : 𝕃 tty → type → type × 𝕃 tty
h acc (TpApp T T') = h (ttype T' :: acc) T
h acc (TpAppt T t) = h (tterm t :: acc) T
h acc (TpParens _ T _) = h acc T
h acc T = T , acc
recompose-tpapps : 𝕃 tty → type → type
recompose-tpapps = flip $ foldl λ {(ttype T') T → TpApp T T'; (tterm t) T → TpAppt T t}
--recompose-tpapps (h , []) = h
--recompose-tpapps (h , ((tterm t') :: args)) = TpAppt (recompose-tpapps (h , args)) t'
--recompose-tpapps (h , ((ttype t') :: args)) = TpApp (recompose-tpapps (h , args)) t'
recompose-apps : args → term → term
recompose-apps = flip $ foldl λ {(TermArg me t') t → App t me t'; (TypeArg T) t → AppTp t T}
--recompose-apps me [] h = h
--recompose-apps me ((tterm t') :: args) h = App (recompose-apps me args h) me t'
--recompose-apps me ((ttype t') :: args) h = AppTp (recompose-apps me args h) t'
vars-to-𝕃 : vars → 𝕃 var
vars-to-𝕃 (VarsStart v) = [ v ]
vars-to-𝕃 (VarsNext v vs) = v :: vars-to-𝕃 vs
{- lambda-abstract the input variables in reverse order around the
given term (so closest to the top of the list is bound deepest in
the resulting term). -}
Lam* : 𝕃 var → term → term
Lam* [] t = t
Lam* (x :: xs) t = Lam* xs (Lam posinfo-gen NotErased posinfo-gen x NoClass t)
App* : term → 𝕃 (maybeErased × term) → term
App* t [] = t
App* t ((m , arg) :: args) = App (App* t args) m arg
App*' : term → 𝕃 term → term
App*' t [] = t
App*' t (arg :: args) = App*' (App t NotErased arg) args
TpApp* : type → 𝕃 type → type
TpApp* t [] = t
TpApp* t (arg :: args) = (TpApp (TpApp* t args) arg)
LiftArrow* : 𝕃 liftingType → liftingType → liftingType
LiftArrow* [] l = l
LiftArrow* (l' :: ls) l = LiftArrow* ls (LiftArrow l' l)
is-intro-form : term → 𝔹
is-intro-form (Lam _ _ _ _ _ _) = tt
--is-intro-form (IotaPair _ _ _ _ _) = tt
is-intro-form _ = ff
lterms-to-term : theta → term → lterms → term
lterms-to-term AbstractEq t [] = App t Erased (Beta (term-end-pos t) NoTerm NoTerm)
lterms-to-term _ t [] = t
lterms-to-term u t ((Lterm e t') :: ls) = lterms-to-term u (App t e t') ls
erase-args : args → 𝕃 term
erase-args [] = []
erase-args (TermArg NotErased t :: as) = t :: erase-args as
erase-args (_ :: as) = erase-args as
erase-params : params → 𝕃 (var × type)
erase-params [] = []
erase-params (Decl _ _ NotErased x (Tkt T) _ :: ps) = (x , T) :: erase-params ps
erase-params (_ :: ps) = erase-params ps
unerased-arrows : type → ℕ
unerased-arrows (TpArrow T NotErased T') = suc $ unerased-arrows T'
unerased-arrows (TpArrow T Erased T') = unerased-arrows T'
unerased-arrows (Abs _ NotErased _ _ _ T) = suc $ unerased-arrows T
unerased-arrows (Abs _ Erased _ _ _ T) = unerased-arrows T
unerased-arrows (TpParens _ T _) = unerased-arrows T
unerased-arrows T = 0
imps-to-cmds : imports → cmds
imps-to-cmds = map ImportCmd
-- TODO handle qualif & module args
get-imports : start → 𝕃 string
get-imports (File is _ _ mn _ cs _) = imports-to-include is ++ get-imports-cmds cs
where import-to-include : imprt → string
import-to-include (Import _ _ _ x oa _ _) = x
imports-to-include : imports → 𝕃 string
imports-to-include = map import-to-include
singleton-if-include : cmd → 𝕃 string
singleton-if-include (ImportCmd imp) = [ import-to-include imp ]
singleton-if-include _ = []
get-imports-cmds : cmds → 𝕃 string
get-imports-cmds (c :: cs) = singleton-if-include c ++ get-imports-cmds cs
get-imports-cmds [] = []
data language-level : Set where
ll-term : language-level
ll-type : language-level
ll-kind : language-level
ll-to-string : language-level → string
ll-to-string ll-term = "term"
ll-to-string ll-type = "type"
ll-to-string ll-kind = "kind"
split-var-h : 𝕃 char → 𝕃 char × 𝕃 char
split-var-h [] = [] , []
split-var-h (qual-global-chr :: xs) = [] , xs
split-var-h (x :: xs) with split-var-h xs
... | xs' , ys = (x :: xs') , ys
split-var : var → var × var
split-var v with split-var-h (reverse (string-to-𝕃char v))
... | xs , ys = 𝕃char-to-string (reverse ys) , 𝕃char-to-string (reverse xs)
var-suffix : var → maybe var
var-suffix v with split-var v
... | "" , _ = nothing
... | _ , sfx = just sfx
-- unique qualif domain prefixes
qual-pfxs : qualif → 𝕃 var
qual-pfxs q = uniq (prefixes (trie-strings q))
where
uniq : 𝕃 var → 𝕃 var
uniq vs = stringset-strings (stringset-insert* empty-stringset vs)
prefixes : 𝕃 var → 𝕃 var
prefixes [] = []
prefixes (v :: vs) with split-var v
... | "" , sfx = vs
... | pfx , sfx = pfx :: prefixes vs
unqual-prefix : qualif → 𝕃 var → var → var → var
unqual-prefix q [] sfx v = v
unqual-prefix q (pfx :: pfxs) sfx v
with trie-lookup q (pfx # sfx)
... | just (v' , _) = if v =string v' then pfx # sfx else v
... | nothing = v
unqual-bare : qualif → var → var → var
unqual-bare q sfx v with trie-lookup q sfx
... | just (v' , _) = if v =string v' then sfx else v
... | nothing = v
unqual-local : var → var
unqual-local v = f' (string-to-𝕃char v) where
f : 𝕃 char → maybe (𝕃 char)
f [] = nothing
f ('@' :: t) = f t maybe-or just t
f (h :: t) = f t
f' : 𝕃 char → string
f' (meta-var-pfx :: t) = maybe-else' (f t) v (𝕃char-to-string ∘ _::_ meta-var-pfx)
f' t = maybe-else' (f t) v 𝕃char-to-string
unqual-all : qualif → var → string
unqual-all q v with var-suffix v
... | nothing = v
... | just sfx = unqual-bare q sfx (unqual-prefix q (qual-pfxs q) sfx v)
-- Given a qualified variable and a function that renames it,
-- we strip away the qualification prefix, call the function,
-- then preprend the prefix to the result
reprefix : (var → var) → var → var
reprefix f x =
maybe-else' (pfx (string-to-𝕃char x) [])
(f x) $ uncurry λ p s → p ^ f s where
ret : 𝕃 char → 𝕃 char → maybe (var × var)
ret pfx sfx = just (𝕃char-to-string (reverse pfx) , 𝕃char-to-string sfx)
pfx : 𝕃 char → 𝕃 char → maybe (var × var)
pfx (qual-global-chr :: xs) acc =
pfx xs (qual-global-chr :: acc) maybe-or ret (qual-global-chr :: acc) xs
pfx (qual-local-chr :: xs) acc =
pfx xs (qual-local-chr :: acc) maybe-or ret (qual-local-chr :: acc) xs
pfx (x :: xs) acc = pfx xs (x :: acc)
pfx [] pfx = nothing
data-to/ = reprefix ("to/" ^_)
data-Is/ = reprefix ("Is/" ^_)
data-is/ = reprefix ("is/" ^_)
mu-Type/ = reprefix ("Type/" ^_)
mu-isType/ = reprefix ("isType/" ^_)
erased-params : params → 𝕃 string
erased-params ((Decl _ _ Erased x (Tkt _) _) :: ps) with var-suffix x
... | nothing = x :: erased-params ps
... | just x' = x' :: erased-params ps
erased-params (p :: ps) = erased-params ps
erased-params [] = []
lam-expand-term : params → term → term
lam-expand-term ((Decl _ _ me x tk _) :: ps) t =
Lam posinfo-gen (if tk-is-type tk then me else Erased) posinfo-gen x (SomeClass tk) (lam-expand-term ps t)
lam-expand-term [] t = t
lam-expand-type : params → type → type
lam-expand-type ((Decl _ _ me x tk _) :: ps) t =
TpLambda posinfo-gen posinfo-gen x tk (lam-expand-type ps t)
lam-expand-type [] t = t
abs-expand-type : params → type → type
abs-expand-type ((Decl _ _ me x tk _) :: ps) t =
Abs posinfo-gen (if tk-is-type tk then me else All) posinfo-gen x tk (abs-expand-type ps t)
abs-expand-type [] t = t
abs-expand-kind : params → kind → kind
abs-expand-kind ((Decl _ _ me x tk _) :: ps) k =
KndPi posinfo-gen posinfo-gen x tk (abs-expand-kind ps k)
abs-expand-kind [] k = k
erased-args-length : args → ℕ
erased-args-length ((TermArg NotErased _) :: ps) = suc (erased-args-length ps)
erased-args-length ((TermArg Erased _) :: ps) = erased-args-length ps
erased-args-length ((TypeArg _) :: ps) = erased-args-length ps
erased-args-length [] = 0
me-args-length : maybeErased → args → ℕ
me-args-length Erased = erased-args-length
me-args-length NotErased = length
spineApp : Set
spineApp = qvar × 𝕃 arg
term-to-spapp : term → maybe spineApp
term-to-spapp (App t me t') = term-to-spapp t ≫=maybe
(λ { (v , as) → just (v , TermArg me t' :: as) })
term-to-spapp (AppTp t T) = term-to-spapp t ≫=maybe
(λ { (v , as) → just (v , TypeArg T :: as) })
term-to-spapp (Var _ v) = just (v , [])
term-to-spapp _ = nothing
type-to-spapp : type → maybe spineApp
type-to-spapp (TpApp T T') = type-to-spapp T ≫=maybe
(λ { (v , as) → just (v , TypeArg T' :: as) })
type-to-spapp (TpAppt T t) = type-to-spapp T ≫=maybe
(λ { (v , as) → just (v , TermArg NotErased t :: as) })
type-to-spapp (TpVar _ v) = just (v , [])
type-to-spapp _ = nothing
spapp-term : spineApp → term
spapp-term (v , []) = Var posinfo-gen v
spapp-term (v , TermArg me t :: as) = App (spapp-term (v , as)) me t
spapp-term (v , TypeArg T :: as) = AppTp (spapp-term (v , as)) T
spapp-type : spineApp → type
spapp-type (v , []) = TpVar posinfo-gen v
spapp-type (v , TermArg me t :: as) = TpAppt (spapp-type (v , as)) t
spapp-type (v , TypeArg T :: as) = TpApp (spapp-type (v , as)) T
caseArgs-to-lams : caseArgs → term → term
caseArgs-to-lams = flip $ foldr λ {(CaseTermArg pi me x) → Lam pi-gen me pi-gen x NoClass; (CaseTypeArg pi x) → Lam pi-gen Erased pi-gen x NoClass}
expand-case : case → var × term
expand-case (Case _ x as t) = x , caseArgs-to-lams as t
expand-cases : cases → trie term
expand-cases = flip foldr empty-trie λ c σ → uncurry (trie-insert σ) (expand-case c)
expand-cases-n : cases → trie (term × ℕ)
expand-cases-n = flip foldr empty-trie λ where
(Case _ x as t) σ → trie-insert σ x (caseArgs-to-lams as t , length as)
caseArg-to-var : caseArg → posinfo × var × maybeErased × 𝔹
caseArg-to-var (CaseTermArg pi me x) = pi , x , me , tt
caseArg-to-var (CaseTypeArg pi x) = pi , x , Erased , ff
{-
cast-abstract-datatype? : var → args → term → term
cast-abstract-datatype? x as with string-split x '/'
...| bₓ :: Tₓ :: [] = mapp (recompose-apps as $ mvar $ mu-name-cast bₓ)
...| _ = id
-}
num-gt : num → ℕ → 𝕃 string
num-gt n n' = maybe-else [] (λ n'' → if n'' > n' then [ n ] else []) (string-to-ℕ n)
nums-gt : nums → ℕ → 𝕃 string
nums-gt (NumsStart n) n' = num-gt n n'
nums-gt (NumsNext n ns) n' =
maybe-else [] (λ n'' → if n'' > n' || iszero n'' then [ n ] else []) (string-to-ℕ n)
++ nums-gt ns n'
nums-to-stringset : nums → stringset × 𝕃 string {- Repeated numbers -}
nums-to-stringset (NumsStart n) = stringset-insert empty-stringset n , []
nums-to-stringset (NumsNext n ns) with nums-to-stringset ns
...| ss , rs = if stringset-contains ss n
then ss , n :: rs
else stringset-insert ss n , rs
optNums-to-stringset : optNums → maybe stringset × (ℕ → maybe string)
optNums-to-stringset NoNums = nothing , λ _ → nothing
optNums-to-stringset (SomeNums ns) with nums-to-stringset ns
...| ss , [] = just ss , λ n → case nums-gt ns n of λ where
[] → nothing
ns-g → just ("Occurrences not found: " ^ 𝕃-to-string id ", " ns-g ^ " (total occurrences: " ^ ℕ-to-string n ^ ")")
...| ss , rs = just ss , λ n →
just ("The list of occurrences contains the following repeats: " ^ 𝕃-to-string id ", " rs)
------------------------------------------------------
-- any delta contradiction → boolean contradiction
------------------------------------------------------
{-
nlam : ℕ → term → term
nlam 0 t = t
nlam (suc n) t = mlam ignored-var (nlam n t)
delta-contra-app : ℕ → (ℕ → term) → term
delta-contra-app 0 nt = mvar "x"
delta-contra-app (suc n) nt = mapp (delta-contra-app n nt) (nt n)
delta-contrahh : ℕ → trie ℕ → trie ℕ → var → var → args → args → maybe term
delta-contrahh n ls rs x1 x2 as1 as2 with trie-lookup ls x1 | trie-lookup rs x2
...| just n1 | just n2 =
let t1 = nlam (length as1) (mlam "x" (mlam "y" (mvar "x")))
t2 = nlam (length as2) (mlam "x" (mlam "y" (mvar "y"))) in
if n1 =ℕ n2
then nothing
else just (mlam "x" (delta-contra-app n
(λ n → if n =ℕ n1 then t1 else if n =ℕ n2 then t2 else id-term)))
...| _ | _ = nothing
{-# TERMINATING #-}
delta-contrah : ℕ → trie ℕ → trie ℕ → term → term → maybe term
delta-contrah n ls rs (Lam _ _ _ x1 _ t1) (Lam _ _ _ x2 _ t2) =
delta-contrah (suc n) (trie-insert ls x1 n) (trie-insert rs x2 n) t1 t2
delta-contrah n ls rs (Lam _ _ _ x1 _ t1) t2 =
delta-contrah (suc n) (trie-insert ls x1 n) (trie-insert rs x1 n) t1 (mapp t2 (mvar x1))
delta-contrah n ls rs t1 (Lam _ _ _ x2 _ t2) =
delta-contrah (suc n) (trie-insert ls x2 n) (trie-insert rs x2 n) (mapp t1 (mvar x2)) t2
delta-contrah n ls rs t1 t2 with decompose-apps t1 | decompose-apps t2
...| Var _ x1 , as1 | Var _ x2 , as2 = delta-contrahh n ls rs x1 x2 as1 as2
...| _ | _ = nothing
-- For terms t1 and t2, given that check-beta-inequiv t1 t2 ≡ tt,
-- delta-contra produces a function f such that f t1 ≡ tt and f t2 ≡ ff
-- If it returns nothing, no contradiction could be found
delta-contra : term → term → maybe term
delta-contra = delta-contrah 0 empty-trie empty-trie
-- postulate: check-beta-inequiv t1 t2 ≡ isJust (delta-contra t1 t2)
check-beta-inequiv : term → term → 𝔹
check-beta-inequiv t1 t2 = isJust (delta-contra t1 t2)
-}
tk-map : tk → (type → type) → (kind → kind) → tk
tk-map (Tkt T) fₜ fₖ = Tkt $ fₜ T
tk-map (Tkk k) fₜ fₖ = Tkk $ fₖ k
tk-map2 : tk → (∀ {ed} → ⟦ ed ⟧ → ⟦ ed ⟧) → tk
tk-map2 atk f = tk-map atk f f
optTerm-map : optTerm → (term → term) → optTerm
optTerm-map NoTerm f = NoTerm
optTerm-map (SomeTerm t pi) f = SomeTerm (f t) pi
optType-map : optType → (type → type) → optType
optType-map NoType f = NoType
optType-map (SomeType T) f = SomeType $ f T
optGuide-map : optGuide → (var → type → type) → optGuide
optGuide-map NoGuide f = NoGuide
optGuide-map (Guide pi x T) f = Guide pi x $ f x T
optClass-map : optClass → (tk → tk) → optClass
optClass-map NoClass f = NoClass
optClass-map (SomeClass atk) f = SomeClass $ f atk
tk-elim : ∀ {ℓ} {X : Set ℓ} → tk → (type → X) → (kind → X) → X
tk-elim (Tkt T) tp kd = tp T
tk-elim (Tkk k) tp kd = kd k
optTerm-elim : ∀ {ℓ} {X : Set ℓ} → optTerm → X → (term → X) → X
optTerm-elim NoTerm nt st = nt
optTerm-elim (SomeTerm t _) nt st = st t
optType-elim : ∀ {ℓ} {X : Set ℓ} → optType → X → (type → X) → X
optType-elim NoType nT sT = nT
optType-elim (SomeType T) nT sT = sT T
optGuide-elim : ∀ {a} {X : Set a} → optGuide → X → (var → type → X) → X
optGuide-elim NoGuide ng sg = ng
optGuide-elim (Guide pi x T) ng sg = sg x T
optClass-elim : ∀ {ℓ} {X : Set ℓ} → optClass → X → (tk → X) → X
optClass-elim NoClass nc sc = nc
optClass-elim (SomeClass atk) nc sc = sc atk
defTermOrType-is-term : defTermOrType → 𝔹
defTermOrType-is-term (DefTerm _ _ _ _) = tt
defTermOrType-is-term (DefType _ _ _ _) = ff
defTermOrType-get-var : defTermOrType → var
defTermOrType-get-var (DefTerm _ x _ _) = x
defTermOrType-get-var (DefType _ x _ _) = x
| 35.238195
| 150
| 0.631439
|
4a8af3ed5ca543d093a89e643ca4711ef2d231bd
| 5,656
|
agda
|
Agda
|
Cubical/Foundations/Transport.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Transport.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Transport.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
{- Basic theory about transport:
- transport is invertible
- transport is an equivalence ([transportEquiv])
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Transport where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.GroupoidLaws
-- Direct definition of transport filler, note that we have to
-- explicitly tell Agda that the type is constant (like in CHM)
transpFill : ∀ {ℓ} {A : Type ℓ}
(φ : I)
(A : (i : I) → Type ℓ [ φ ↦ (λ _ → A) ])
(u0 : outS (A i0))
→ --------------------------------------
PathP (λ i → outS (A i)) u0 (transp (λ i → outS (A i)) φ u0)
transpFill φ A u0 i = transp (λ j → outS (A (i ∧ j))) (~ i ∨ φ) u0
transport⁻ : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → B → A
transport⁻ p = transport (λ i → p (~ i))
subst⁻ : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} (B : A → Type ℓ') (p : x ≡ y) → B y → B x
subst⁻ B p pa = transport⁻ (λ i → B (p i)) pa
transport-fillerExt : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → A → p i) (λ x → x) (transport p)
transport-fillerExt p i x = transport-filler p x i
transport⁻-fillerExt : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → p i → A) (λ x → x) (transport⁻ p)
transport⁻-fillerExt p i x = transp (λ j → p (i ∧ ~ j)) (~ i) x
transport-fillerExt⁻ : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → p i → B) (transport p) (λ x → x)
transport-fillerExt⁻ p = symP (transport⁻-fillerExt (sym p))
transport⁻-fillerExt⁻ : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → B → p i) (transport⁻ p) (λ x → x)
transport⁻-fillerExt⁻ p = symP (transport-fillerExt (sym p))
transport⁻-filler : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) (x : B)
→ PathP (λ i → p (~ i)) x (transport⁻ p x)
transport⁻-filler p x = transport-filler (λ i → p (~ i)) x
transport⁻Transport : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (a : A) →
transport⁻ p (transport p a) ≡ a
transport⁻Transport p a j = transport⁻-fillerExt p (~ j) (transport-fillerExt p (~ j) a)
transportTransport⁻ : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (b : B) →
transport p (transport⁻ p b) ≡ b
transportTransport⁻ p b j = transport-fillerExt⁻ p j (transport⁻-fillerExt⁻ p j b)
-- Transport is an equivalence
isEquivTransport : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) → isEquiv (transport p)
isEquivTransport {A = A} {B = B} p =
transport (λ i → isEquiv (transport-fillerExt p i)) (idIsEquiv A)
transportEquiv : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → A ≃ B
transportEquiv p = (transport p , isEquivTransport p)
substEquiv : ∀ {ℓ ℓ'} {A B : Type ℓ} (P : Type ℓ → Type ℓ') (p : A ≡ B) → P A ≃ P B
substEquiv P p = (subst P p , isEquivTransport (λ i → P (p i)))
liftEquiv : ∀ {ℓ ℓ'} {A B : Type ℓ} (P : Type ℓ → Type ℓ') (e : A ≃ B) → P A ≃ P B
liftEquiv P e = substEquiv P (ua e)
transpEquiv : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) → ∀ i → p i ≃ B
transpEquiv P i .fst = transp (λ j → P (i ∨ j)) i
transpEquiv P i .snd
= transp (λ k → isEquiv (transp (λ j → P (i ∨ (j ∧ k))) (i ∨ ~ k)))
i (idIsEquiv (P i))
uaTransportη : ∀ {ℓ} {A B : Type ℓ} (P : A ≡ B) → ua (transportEquiv P) ≡ P
uaTransportη P i j
= Glue (P i1) λ where
(j = i0) → P i0 , transportEquiv P
(i = i1) → P j , transpEquiv P j
(j = i1) → P i1 , idEquiv (P i1)
pathToIso : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → Iso A B
pathToIso x = iso (transport x) (transport⁻ x) (transportTransport⁻ x) (transport⁻Transport x)
isInjectiveTransport : ∀ {ℓ : Level} {A B : Type ℓ} {p q : A ≡ B}
→ transport p ≡ transport q → p ≡ q
isInjectiveTransport {p = p} {q} α i =
hcomp
(λ j → λ
{ (i = i0) → secEq univalence p j
; (i = i1) → secEq univalence q j
})
(invEq univalence ((λ a → α i a) , t i))
where
t : PathP (λ i → isEquiv (λ a → α i a)) (pathToEquiv p .snd) (pathToEquiv q .snd)
t = isProp→PathP (λ i → isPropIsEquiv (λ a → α i a)) _ _
isSet-subst : ∀ {ℓ ℓ′} {A : Type ℓ} {B : A → Type ℓ′}
→ (isSet-A : isSet A)
→ ∀ {a : A}
→ (p : a ≡ a) → (x : B a) → subst B p x ≡ x
isSet-subst {B = B} isSet-A p x = subst (λ p′ → subst B p′ x ≡ x) (isSet-A _ _ refl p) (substRefl {B = B} x)
-- substituting along a composite path is equivalent to substituting twice
substComposite : ∀ {ℓ ℓ′} {A : Type ℓ} → (B : A → Type ℓ′)
→ {x y z : A} (p : x ≡ y) (q : y ≡ z) (u : B x)
→ subst B (p ∙ q) u ≡ subst B q (subst B p u)
substComposite B p q Bx i =
transport (cong B (compPath-filler' p q (~ i))) (transport-fillerExt (cong B p) i Bx)
-- substitution commutes with morphisms in slices
substCommSlice : ∀ {ℓ ℓ′} {A : Type ℓ}
→ (B C : A → Type ℓ′)
→ (F : ∀ i → B i → C i)
→ {x y : A} (p : x ≡ y) (u : B x)
→ subst C p (F x u) ≡ F y (subst B p u)
substCommSlice B C F p Bx i =
transport-fillerExt⁻ (cong C p) i (F _ (transport-fillerExt (cong B p) i Bx))
-- transports between loop spaces preserve path composition
overPathFunct : ∀ {ℓ} {A : Type ℓ} {x y : A} (p q : x ≡ x) (P : x ≡ y)
→ transport (λ i → P i ≡ P i) (p ∙ q)
≡ transport (λ i → P i ≡ P i) p ∙ transport (λ i → P i ≡ P i) q
overPathFunct p q =
J (λ y P → transport (λ i → P i ≡ P i) (p ∙ q) ≡ transport (λ i → P i ≡ P i) p ∙ transport (λ i → P i ≡ P i) q)
(transportRefl (p ∙ q) ∙ cong₂ _∙_ (sym (transportRefl p)) (sym (transportRefl q)))
| 42.208955
| 113
| 0.530057
|
4a39a3349ed7ed28b31a98b34dc4c77b7eb78092
| 1,055
|
agda
|
Agda
|
src/Ints/Add/Invert.agda
|
ice1k/Theorems
|
7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc
|
[
"Apache-2.0"
] | 1
|
2020-04-15T15:28:03.000Z
|
2020-04-15T15:28:03.000Z
|
src/Ints/Add/Invert.agda
|
ice1k/Theorems
|
7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc
|
[
"Apache-2.0"
] | null | null | null |
src/Ints/Add/Invert.agda
|
ice1k/Theorems
|
7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc
|
[
"Apache-2.0"
] | null | null | null |
module Ints.Add.Invert where
open import Ints
open import Ints.Properties
open import Ints.Add.Comm
open import Nats.Add.Invert
open import Data.Empty
open import Relation.Nullary
open import Equality
open import Function
------------------------------------------------------------------------
-- internal stuffs
private
nat→int′ : ∀ a b → -[1+ nsuc $ a :+: a ] ≡ -[1+ nsuc $ b :+: b ] → a ≡ b
nat→int′ a b = nat-add-invert a b ∘ nat-add-invert-1 (a :+: a) (b :+: b) ∘ eq-neg-int-to-nat
impossible : ∀ a b → ¬ (+ a + + a ≡ -[1+ b ] + -[1+ b ])
impossible a b ()
+-invert : ∀ a b → (a + a ≡ b + b) → a ≡ b
+-invert (+ a ) (+ b ) = eq-nat-to-int ∘ nat-add-invert a b ∘ eq-int-to-nat
+-invert (+ a ) -[1+ b ] = ⊥-elim ∘ impossible a b
+-invert -[1+ a ] (+ b ) = ⊥-elim ∘ impossible b a ∘ sym
+-invert -[1+ a ] -[1+ b ] = eq-neg-nat-to-int ∘ nat→int′ a b
------------------------------------------------------------------------
-- public aliases
int-add-invert : ∀ a b → (a + a ≡ b + b) → a ≡ b
int-add-invert = +-invert
| 28.513514
| 94
| 0.477725
|
0420bba0d00239a1d2bc580266ad23e3a4398de7
| 1,194
|
agda
|
Agda
|
test/Common/Prelude.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/Common/Prelude.agda
|
dagit/agda
|
4383a3d20328a6c43689161496cee8eb479aca08
|
[
"MIT"
] | null | null | null |
test/Common/Prelude.agda
|
dagit/agda
|
4383a3d20328a6c43689161496cee8eb479aca08
|
[
"MIT"
] | null | null | null |
module Common.Prelude where
postulate String : Set
{-# BUILTIN STRING String #-}
data Nat : Set where
zero : Nat
suc : Nat → Nat
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN SUC suc #-}
{-# BUILTIN ZERO zero #-}
{-# COMPILED_JS Nat function (x,v) { return (x < 1? v.zero(): v.suc(x-1)); } #-}
{-# COMPILED_JS zero 0 #-}
{-# COMPILED_JS suc function (x) { return x+1; } #-}
_+_ : Nat → Nat → Nat
zero + n = n
suc m + n = suc (m + n)
{-# COMPILED_JS _+_ function (x) { return function (y) { return x+y; }; } #-}
_∸_ : Nat → Nat → Nat
m ∸ zero = m
zero ∸ _ = zero
suc m ∸ suc n = m ∸ n
{-# COMPILED_JS _∸_ function (x) { return function (y) { return Math.max(0,x-y); }; } #-}
data List A : Set where
[] : List A
_∷_ : A → List A → List A
infixr 40 _∷_
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL [] #-}
{-# BUILTIN CONS _∷_ #-}
data Bool : Set where
true false : Bool
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE true #-}
{-# BUILTIN FALSE false #-}
{-# COMPILED_DATA Bool Bool True False #-}
{-# COMPILED_JS Bool function (x,v) { return (x? v["true"](): v["false"]()); } #-}
{-# COMPILED_JS true true #-}
{-# COMPILED_JS false false #-}
| 21.709091
| 89
| 0.552764
|
2eec4f5403ff7bf4eca32cfaf3a0db6d013442e2
| 2,158
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous/Construct/At.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous/Construct/At.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous/Construct/At.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- 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
------------------------------------------------------------------------
-- Packages
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.275362
| 73
| 0.514829
|
133a78b3bbfc5299fca3e1533b9abf4336afeab6
| 255
|
agda
|
Agda
|
archive/agda-2/Oscar/Data/Proposextensequality.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-2/Oscar/Data/Proposextensequality.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-2/Oscar/Data/Proposextensequality.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module Oscar.Data.Proposextensequality where
open import Oscar.Data.Proposequality using (_≡_)
open import Oscar.Level
infix 4 _≡̇_
_≡̇_ : ∀ {a} {A : Set a} {b} {B : A → Set b} → ((x : A) → B x) → ((x : A) → B x) → Set (a ⊔ b)
f ≡̇ g = ∀ x → f x ≡ g x
| 25.5
| 94
| 0.560784
|
31373b278160a89e2ac193ff2d7a4215107ca9a9
| 7,436
|
agda
|
Agda
|
Univalence/VecHelpers.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 14
|
2015-08-18T21:40:15.000Z
|
2021-05-05T01:07:57.000Z
|
Univalence/VecHelpers.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 4
|
2018-06-07T16:27:41.000Z
|
2021-10-29T20:41:23.000Z
|
Univalence/VecHelpers.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 VecHelpers where
open import Data.Nat
import Data.Fin as F
open import Data.Vec
open import Function renaming (_∘_ to _○_)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
infixl 10 _∘̬_ -- vector composition
------------------------------------------------------------------
-- VECTOR LEMMAS AND HELPERS
vmap : {n : ℕ} → {A B : Set} → (A → B) → Vec A n → Vec B n
vmap f [] = []
vmap f (x ∷ xs) = (f x) ∷ (vmap f xs)
-- Syntactic sugar for lookup that's a lot nicer
_!!_ : {A : Set} → {n : ℕ} → Vec A n → F.Fin n → A
_!!_ v i = lookup i v
-- XXX: is this in the right order?
_∘̬_ : {m n : ℕ} {A : Set} → Vec (F.Fin n) m → Vec A n → Vec A m
v₁ ∘̬ v₂ = tabulate (λ i → v₂ !! (v₁ !! i))
_∘̬′_ : {m n : ℕ} {A : Set} → Vec (F.Fin n) m → Vec A n → Vec A m
[] ∘̬′ v₂ = []
(i ∷ is) ∘̬′ v₂ = (v₂ !! i) ∷ (is ∘̬′ v₂)
∘̬≡∘̬′ : {m n : ℕ} {A : Set} (v₁ : Vec (F.Fin n) m) (v₂ : Vec A n) →
(v₁ ∘̬ v₂) ≡ (v₁ ∘̬′ v₂)
∘̬≡∘̬′ [] v₂ = refl
∘̬≡∘̬′ (x ∷ v₁) v₂ = cong (_∷_ (v₂ !! x)) (∘̬≡∘̬′ v₁ v₂)
ntimes : {A : Set} → ℕ → (f : A → A) → A → A
ntimes zero f a = a
ntimes (suc n) f a = f (ntimes n f a)
ntimesD : {A : Set} → {B : A → Set} → {g : A → A} → (n : ℕ) →
(f : {a : A} → B a → B (g a)) →
{a : A} →
B a → B (ntimes n g a)
ntimesD zero f b = b
ntimesD {g = g} (suc n) f {a = a} b =
f {ntimes n g a} (ntimesD {g = g} n (λ {a} → f {a}) {a = a} b)
ntails : {A : Set} → {n k : ℕ} → Vec A (ntimes k suc n) → Vec A n
ntails {k = zero} v = v
ntails {k = suc n} (x ∷ xs) = ntails {k = n} xs
ntails₀ : {A : Set} → {k : ℕ} → (v : Vec A (ntimes k suc zero)) →
[] ≡ ntails {k = k} v
ntails₀ {k = zero} [] = refl
ntails₀ {k = suc k} (x ∷ v) = ntails₀ {k = k} v
-- Important lemma about lookup; for some reason it doesn't seem to be in the
-- library even though it's in the main agda tutorial, iirc
map!! : {n : ℕ} → {A B : Set} → (f : A → B) → (v : Vec A n) → (i : F.Fin n) →
(vmap f v) !! i ≡ f (v !! i)
map!! {zero} f [] ()
map!! {suc n} f (x ∷ xs) F.zero = refl
map!! {suc n} f (x ∷ xs) (F.suc i) = map!! f xs i
lookupTab : {A : Set} {n : ℕ} {f : F.Fin n → A} → (i : F.Fin n) →
(tabulate f) !! i ≡ (f i)
lookupTab {f = f} F.zero = refl
lookupTab (F.suc i) = lookupTab i
mapTab : {A B : Set} → {n : ℕ} → (f : A → B) → (g : F.Fin n → A) →
vmap f (tabulate g) ≡ tabulate (f ○ g)
mapTab {n = zero} f g = refl
mapTab {n = suc n} f g =
cong (_∷_ (f (g F.zero))) (mapTab {n = n} f (g ○ F.suc))
-- Lemma for proving that two vectors are equal if their tabulates agree
-- on all inputs.
tabf∼g : {n : ℕ} → {A : Set} → (f g : F.Fin n → A) → (∀ x → f x ≡ g x) →
tabulate f ≡ tabulate g
tabf∼g {zero} f g p = refl
tabf∼g {suc n} f g p with f F.zero | g F.zero | p F.zero
tabf∼g {suc n} f g p | x | .x | refl =
cong (_∷_ x) (tabf∼g {n} (f ○ F.suc) (g ○ F.suc) (p ○ F.suc))
lookup∼vec : {n : ℕ} → {A : Set} →
(v₁ v₂ : Vec A n) → (∀ i → v₁ !! i ≡ v₂ !! i) → v₁ ≡ v₂
lookup∼vec [] [] p = refl
lookup∼vec (x ∷ v₁) (x₁ ∷ v₂) p with p F.zero
lookup∼vec (x ∷ v₁) (.x ∷ v₂) p | refl =
cong (_∷_ x) (lookup∼vec v₁ v₂ (p ○ F.suc))
∘̬id : {A : Set} → {n : ℕ} → (k : ℕ) → (v : Vec A (ntimes k suc n)) →
(tabulate {n} (ntimesD {ℕ} {F.Fin} {suc} k F.suc)) ∘̬ v ≡
(tabulate (λ i → v !! (ntimesD {ℕ} {F.Fin} {suc} k F.suc i)))
∘̬id {n = n} k v = begin
(tabulate {n} (ntimesD {ℕ} {F.Fin} {suc} k F.suc)) ∘̬ v
≡⟨ refl ⟩
(tabulate
(λ i → v !! (tabulate (ntimesD {ℕ} {F.Fin} {suc} k F.suc) !! i)))
≡⟨ tabf∼g
(λ i → v !! (tabulate (ntimesD {ℕ} {F.Fin} {suc} k F.suc) !! i))
(λ i → v !! ntimesD {ℕ} {F.Fin} {suc} k F.suc i)
(λ i → cong (_!!_ v) (lookupTab i)) ⟩
(tabulate (λ i → v !! (ntimesD {ℕ} {F.Fin} {suc} k F.suc i))) ∎
map2+id : {m n : ℕ} → (v : Vec (F.Fin n) m) → {x y : F.Fin (suc (suc n))} →
(vmap F.suc (vmap F.suc v)) ∘̬′
(x ∷ y ∷ tabulate {n} (F.suc ○ F.suc)) ≡
(vmap F.suc (vmap F.suc v))
map2+id [] = refl
map2+id {suc m} {n} (i ∷ v) {x} {y} =
begin
(vmap F.suc (vmap F.suc (i ∷ v))) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc))
≡⟨ refl ⟩
(tabulate (F.suc ○ F.suc) !! i) ∷
(vmap F.suc (vmap F.suc v)) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc))
≡⟨ cong (λ z → z ∷ ((vmap F.suc (vmap F.suc v))) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc)))
(lookupTab i) ⟩
F.suc (F.suc i) ∷ (vmap F.suc (vmap F.suc v) ∘̬′ (x ∷ y ∷ tabulate (F.suc ○ F.suc)))
≡⟨ cong (_∷_ (F.suc (F.suc i))) (map2+id v) ⟩
F.suc (F.suc i) ∷ (vmap F.suc (vmap F.suc v))
≡⟨ refl ⟩
(vmap F.suc (vmap F.suc (i ∷ v))) ∎
head!!0 : {n : ℕ} {A : Set} (v : Vec A (suc n)) → v !! F.zero ≡ head v
head!!0 (x ∷ v) = refl
headmap : {n : ℕ} {A B : Set} {f : A → B} (v : Vec A (suc n)) →
head (vmap f v) ≡ f (head v)
headmap (x ∷ v) = refl
tailmap : {n : ℕ} {A B : Set} {f : A → B} (v : Vec A (suc n)) →
tail (vmap f v) ≡ vmap f (tail v)
tailmap (x ∷ v) = refl
2suc∘̬2tail : {n : ℕ} {A : Set} (v : Vec A (suc (suc n))) →
(tabulate (F.suc ○ F.suc)) ∘̬ v ≡ (tail (tail v))
2suc∘̬2tail (x ∷ x₁ ∷ v) =
begin
(tabulate (F.suc ○ F.suc)) ∘̬ (x ∷ x₁ ∷ v)
≡⟨ refl ⟩
tabulate (λ i → (x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! i))
≡⟨ lookup∼vec
(tabulate (λ i → (x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! i)))
v
(λ i →
begin
tabulate (λ j → (x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! j)) !! i
≡⟨ lookupTab i ⟩
(x ∷ x₁ ∷ v) !! (tabulate (F.suc ○ F.suc) !! i)
≡⟨ cong (λ q → (x ∷ x₁ ∷ v) !! q) (lookupTab i) ⟩
v !! i ∎) ⟩
v ∎
-- upTo n returns [0, 1, ..., n-1] as Fins
upTo : (n : ℕ) → Vec (F.Fin n) n
upTo n = tabulate {n} id
upToTail : (n : ℕ) → (tail (tail (upTo (suc (suc n))))) ≡ (vmap F.suc (tail (upTo (suc n))))
upToTail n =
begin
tail (tail (upTo (suc (suc n))))
≡⟨ refl ⟩
tabulate (F.suc ○ F.suc)
≡⟨ sym (mapTab F.suc F.suc) ⟩
vmap F.suc (tabulate F.suc) ∎
sidfn : {A : Set} {n : ℕ} (v : Vec A n) (i : F.Fin n) →
((upTo n) ∘̬ v) !! i ≡ v !! i
sidfn {n = n} v i =
begin
((upTo n) ∘̬ v) !! i
≡⟨ lookupTab {f = λ x → v !! ((upTo n) !! x)} i ⟩
v !! ((upTo n) !! i)
≡⟨ cong (_!!_ v) (lookupTab {f = id} i) ⟩
v !! i ∎
∘̬simpleid : {A : Set} {n : ℕ} (v : Vec A n) → (upTo n) ∘̬ v ≡ v
∘̬simpleid {n = n} v = lookup∼vec (upTo n ∘̬ v) v (sidfn v)
lookupMap : {A B : Set} → {n : ℕ} → {f : A → B} →
(i : F.Fin n) → (v : Vec A n) →
lookup i (vmap f v) ≡ f (lookup i v)
lookupMap F.zero (x ∷ _) = refl
lookupMap (F.suc i) (_ ∷ v) = lookupMap i v
lookup∘tabulate : ∀ {a n} → {A : Set a} →
(i : F.Fin n) → (f : F.Fin n → A) →
lookup i (tabulate f) ≡ f i
lookup∘tabulate F.zero f = refl
lookup∘tabulate (F.suc i) f = lookup∘tabulate i (f ○ F.suc)
vmap∘vmap : {n : ℕ} {A B C : Set} (f : B → C) (g : A → B) (v : Vec A n) →
vmap f (vmap g v) ≡ vmap (f ○ g) v
vmap∘vmap {zero} f g [] = refl
vmap∘vmap {suc n} f g (x ∷ v) = cong (λ y → f (g x) ∷ y) (vmap∘vmap f g v)
vmap∘id : {n : ℕ} {A : Set} {v : Vec A n} {f : A → A } → (∀ {x} → f x ≡ x) → vmap f v ≡ v
vmap∘id {zero} {v = []} eq = refl
vmap∘id {suc n} {v = (x ∷ v)} {f} eq = cong₂ _∷_ eq (vmap∘id {v = v} eq)
| 36.45098
| 92
| 0.450108
|
41195b61c8fe11ca3c23c4d1fa7381274c80826e
| 1,811
|
agda
|
Agda
|
test/Fail/Issue1271a.agda
|
hborum/agda
|
aac88412199dd4cbcb041aab499d8a6b7e3f4a2e
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/Issue1271a.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue1271a.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- Empty, unit and equality.
⊥ = (X : Set) → X
⊤ = (X : Set) → X → X
data _≡_ {l}{A : Set l}(x : A) : A → Set l where
<> : x ≡ x
-- The fixpoint of the identity functor as a data definition.
module Data where
data μId : Set where
In : μId → μId
-- μId can be proved empty. Here are both a direct proof and one that
-- relies on the eliminator for μId.
¬μId : μId → ⊥
¬μId (In x) = ¬μId x
μId-elim : ∀ {l}(P : μId → Set l) → (∀ x → P x → P (In x)) → ∀ x → P x
μId-elim P m (In x) = m x (μId-elim P m x)
¬Id' : μId → ⊥
¬Id' = μId-elim (λ _ → ⊥) (λ _ p → p)
-- To prove ∀ x → ¬ (x ≡ In x) it is enough to call ¬μId (or ¬μId'): the
-- equality proof is not inspected.
¬id≡In-empty : ∀ {x} → x ≡ In x → ⊥
¬id≡In-empty {x} _ = ¬μId x -- or ¬Id' x
-- Alternatively, one could use an absurd pattern which relies on the
-- presence of a cycle.
¬id≡In-pm : ∀ {x} → x ≡ In x → ⊥
¬id≡In-pm ()
-- The case of inductive records is a bit different. Here is the fixpoint
-- of the identity functor as an inductive record definition.
module Record where
record μId : Set where
inductive
constructor In
field Out : μId
open μId
-- It does not seem possible to prove Record.μId empty, as Agda does not
-- consider the following definitions as terminating.
{-# NON_TERMINATING #-}
¬μId : μId → ⊥
¬μId (In x) = ¬μId x
{-# NON_TERMINATING #-}
μId-elim : ∀ {l}(P : μId → Set l) → (∀ x → P x → P (In x)) → ∀ x → P x
μId-elim P m (In x) = m x (μId-elim P m x)
¬Id' : μId → ⊥
¬Id' = μId-elim (λ _ → ⊥) (λ _ p → p)
¬id≡In-empty : ∀ {x} → x ≡ In x → ⊥
¬id≡In-empty {x} _ = ¬μId x -- or ¬Id' x
-- However, we can still use an absurd pattern as in Data.¬id≡In-pm.
¬id≡In-pm : ∀ {x} → x ≡ In x → ⊥
¬id≡In-pm ()
-- This should not be possible.
| 24.146667
| 73
| 0.559912
|
2e77066fb00a47f4e3f7203da6c0571e7ba93f20
| 978
|
agda
|
Agda
|
src/Definitions.agda
|
Akshobhya1234/agda-NonAssociativeAlgebra
|
443e831e536b756acbd1afd0d6bae7bc0d288048
|
[
"MIT"
] | 2
|
2021-08-15T06:16:13.000Z
|
2021-08-17T09:14:03.000Z
|
src/Definitions.agda
|
Akshobhya1234/agda-NonAssociativeAlgebra
|
443e831e536b756acbd1afd0d6bae7bc0d288048
|
[
"MIT"
] | 2
|
2021-10-04T05:30:30.000Z
|
2021-10-09T08:24:56.000Z
|
src/Definitions.agda
|
Akshobhya1234/agda-NonAssociativeAlgebra
|
443e831e536b756acbd1afd0d6bae7bc0d288048
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary.Core
module Definitions
{a ℓ} {A : Set a} -- The underlying set
(_≈_ : Rel A ℓ) -- The underlying equality
where
open import Algebra.Core
open import Data.Product
open import Algebra.Definitions
-- (x²y)x = x²(yx)
JordanIdentity: : Op₂ A → Set _
JordanIdentity: _∙_ = ∀ x y → (((x ∙ x) ∙ y) ∙ x) ≈ (((x ∙ x) ∙ y) ∙ x)
-- x = xyx
PesudoInverse₁ : Op₂ A → Set _
PesudoInverse₁ _∙_ = ∀ x y → ((x ∙ y) ∙ x) ≈ x
-- y = yxy
PseudoInverse₂ : Op₂ A → Set _
PseudoInverse₂ _∙_ = ∀ x y → ((y ∙ x) ∙ y) ≈ y
PseudoInverse : Op₂ A → Set _
PseudoInverse ∙ = (PesudoInverse₁ ∙) × (PseudoInverse₂ ∙)
-- JacobiIdentity is (x ∙ (y ∙ z)) + ((y ∙ (z ∙ x)) + (z ∙ (x ∙ y))) = 0
-- Using the antisymmetry property Jacobi identity may be rewritten as a modification of the associative property
JacobiIdentity : Op₂ A → Op₂ A → Set _
JacobiIdentity _∙_ _-_ = ∀ x y z → (x ∙ (y ∙ z)) ≈ ((y ∙ (z ∙ x)) - (z ∙ (x ∙ y)))
| 28.764706
| 113
| 0.59407
|
4b5ede7701cc4bde67fe56651026e5c2c4ad2cec
| 780
|
agda
|
Agda
|
test/Succeed/fol-theorems/Agda/InternalTerms/DefTerm2.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 10
|
2015-09-03T20:54:16.000Z
|
2019-12-03T13:44:25.000Z
|
test/Succeed/fol-theorems/Agda/InternalTerms/DefTerm2.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 121
|
2015-01-25T13:22:12.000Z
|
2018-04-22T06:01:44.000Z
|
test/Succeed/fol-theorems/Agda/InternalTerms/DefTerm2.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 4
|
2016-05-10T23:06:19.000Z
|
2016-08-03T03:54:55.000Z
|
------------------------------------------------------------------------------
-- Testing Agda internal term: @Def@
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Agda.InternalTerms.DefTerm2 where
------------------------------------------------------------------------------
postulate
D : Set
_≡_ : D → D → Set
P³ : D → D → D → Set
a b c : D
-- A definition with three arguments.
postulate foo : P³ a b c
{-# ATP axiom foo #-}
-- We need to have at least one conjecture to generate a TPTP file.
postulate bar : ∀ d → d ≡ d
{-# ATP prove bar #-}
| 28.888889
| 78
| 0.394872
|
2fea1694e46b50a98d5d0ceb688ab9a0dfcc5aa4
| 764
|
agda
|
Agda
|
benchmark/Syntacticosmos/UntypedLambda.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
benchmark/Syntacticosmos/UntypedLambda.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
benchmark/Syntacticosmos/UntypedLambda.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module UntypedLambda where
open import Basics
open import Pr
open import Nom
import Syntacticosmos
data Tag : Set where
lamT : Tag
appT : Tag
open module ULam = Syntacticosmos TT TT (\_ -> Tag)
LAM : Kind
LAM = Ty _
SigLAM : Kind
SigLAM = Pi _ conk where
conk : Tag -> Kind
conk lamT = (LAM |> LAM) |> LAM
conk appT = LAM |> LAM |> LAM
Lam : Cxt -> Set
Lam G = G [! SigLAM !]- LAM
lam : {G : Cxt}(x : Nom){Gx : [| G Hasn't x |]} ->
Lam ((G [ x - LAM ]) {Gx}) -> Lam G
lam x {Gx} b = G[ lamT G^ G\\ (bind x {Gx} b) G& Gnil ]
app : {G : Cxt} -> Lam G -> Lam G -> Lam G
app f s = G[ appT G^ f G& s G& Gnil ]
moo : Lam EC
moo = lam Ze (lam (Su Ze) (var Ze))
noo : Lam EC
noo = lam (Su Ze) (lam Ze (var (Su Ze)))
coo : Id moo noo
coo = refl
| 18.190476
| 55
| 0.568063
|
1a995fbc70d395ed5ce529c4443746211d660c90
| 334
|
agda
|
Agda
|
test/Succeed/Issue3900.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3900.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3900.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2019-07-09, issue #3900
-- Regression introduced by the fix of #3434
-- {-# OPTIONS -v tc.inj:100 #-}
data Bool : Set where
true false : Bool
abstract
data Unit : Set where
unit : Unit
f : Unit
f with true
... | true = unit
... | false = unit
-- Error WAS:
-- Not in Scope: unit
-- Should succeed.
| 14.521739
| 44
| 0.601796
|
13d4ea10fa73950daf74c6d6b6f90c047594ca8e
| 659
|
agda
|
Agda
|
src/Data/Nat/Properties/Extra.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 10
|
2017-11-17T17:10:36.000Z
|
2021-09-24T08:02:33.000Z
|
src/Data/Nat/Properties/Extra.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 1
|
2019-01-13T13:03:47.000Z
|
2020-10-14T13:41:58.000Z
|
src/Data/Nat/Properties/Extra.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 1
|
2021-12-28T17:38:05.000Z
|
2021-12-28T17:38:05.000Z
|
module Data.Nat.Properties.Extra where
open import Data.Nat.Base
open import Data.Nat.Properties
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open import Data.Empty
≤′-unique : ∀ {i u} (p q : i ≤′ u) → p ≡ q
≤′-unique ≤′-refl ≤′-refl = refl
≤′-unique ≤′-refl (≤′-step q) = ⊥-elim (1+n≰n (≤′⇒≤ q))
≤′-unique (≤′-step p) ≤′-refl = ⊥-elim (1+n≰n (≤′⇒≤ p))
≤′-unique (≤′-step p) (≤′-step q) = cong ≤′-step (≤′-unique p q)
m+n+o≡n+m+o : ∀ m n o → m + (n + o) ≡ n + (m + o)
m+n+o≡n+m+o m n o = begin
m + (n + o) ≡⟨ sym (+-assoc m n o) ⟩
(m + n) + o ≡⟨ cong (λ x → x + o) (+-comm m n) ⟩
(n + m) + o ≡⟨ +-assoc n m o ⟩
n + (m + o) ∎
| 29.954545
| 64
| 0.518968
|
1364f4dc17f66f6b1b999973ab5a4ac8542a6567
| 402
|
agda
|
Agda
|
test/succeed/InstanceGuessesMeta.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | null | null | null |
test/succeed/InstanceGuessesMeta.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | null | null | null |
test/succeed/InstanceGuessesMeta.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- Andreas, 2012-01-10
-- {-# OPTIONS -v tc.constr.findInScope:50 #-}
module InstanceGuessesMeta where
data Bool : Set where
true false : Bool
postulate
D : Bool -> Set
E : Bool -> Set
d : {x : Bool} -> D x
f : {x : Bool}{{ dx : D x }} -> E x
b : E true
b = f -- should succeed
-- Agda is now allowed to solve hidden x in type of d by unification,
-- when searching for inhabitant of D x
| 22.333333
| 69
| 0.624378
|
41f98f7479021c31d240cdeab19eea2472e5687d
| 4,818
|
agda
|
Agda
|
Progress.agda
|
danelahman/aeff-agda
|
71ebed9f90a3eb37ae6cd209457bae23a4d122d1
|
[
"MIT"
] | 4
|
2020-07-17T00:15:00.000Z
|
2021-03-22T22:48:48.000Z
|
Progress.agda
|
danelahman/aeff-agda
|
71ebed9f90a3eb37ae6cd209457bae23a4d122d1
|
[
"MIT"
] | null | null | null |
Progress.agda
|
danelahman/aeff-agda
|
71ebed9f90a3eb37ae6cd209457bae23a4d122d1
|
[
"MIT"
] | null | null | null |
open import Data.Empty
open import Data.Maybe
open import Data.Product
open import Data.Sum
open import Data.Unit
open import AEff
open import AwaitingComputations
open import EffectAnnotations
open import Preservation
open import Renamings
open import Substitutions
open import Types
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary
open import Relation.Nullary.Negation
module Progress where
-- WRAPPING PROMISES AROUND A CONTEXT
⟨⟨_⟩⟩ : Ctx → Ctx
⟨⟨ [] ⟩⟩ = []
⟨⟨ Γ ∷ X ⟩⟩ = ⟨⟨ Γ ⟩⟩ ∷ ⟨ X ⟩
-- RESULTS
data RunResult⟨_∣_⟩ (Γ : Ctx) : {C : CType} → ⟨⟨ Γ ⟩⟩ ⊢M⦂ C → Set where
return : {X : VType}
{o : O}
{i : I}
(V : ⟨⟨ Γ ⟩⟩ ⊢V⦂ X) →
------------------------------------------
RunResult⟨ Γ ∣ return {o = o} {i = i} V ⟩
promise : {X Y : VType}
{o o' : O}
{i i' : I}
{op : Σₛ}
{p : lkpᵢ op i ≡ just (o' , i')}
{M : ⟨⟨ Γ ⟩⟩ ∷ ``(payload op) ⊢M⦂ ⟨ X ⟩ ! (o' , i')}
{N : ⟨⟨ Γ ⟩⟩ ∷ ⟨ X ⟩ ⊢M⦂ Y ! (o , i)} →
RunResult⟨ Γ ∷ X ∣ N ⟩ →
----------------------------------------------------
RunResult⟨ Γ ∣ promise op ∣ p ↦ M `in N ⟩
awaiting : {C : CType}
{Y : VType}
{y : ⟨ Y ⟩ ∈ ⟨⟨ Γ ⟩⟩}
{M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ C} →
y ⧗ M →
---------------------
RunResult⟨ Γ ∣ M ⟩
data CompResult⟨_∣_⟩ (Γ : Ctx) : {C : CType} → ⟨⟨ Γ ⟩⟩ ⊢M⦂ C → Set where
comp : {C : CType}
{M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ C} →
RunResult⟨ Γ ∣ M ⟩ →
---------------------
CompResult⟨ Γ ∣ M ⟩
signal : {X : VType}
{o : O}
{i : I}
{op : Σₛ}
{p : op ∈ₒ o}
{V : ⟨⟨ Γ ⟩⟩ ⊢V⦂ ``(payload op)}
{M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ X ! (o , i)} →
CompResult⟨ Γ ∣ M ⟩ →
--------------------------------
CompResult⟨ Γ ∣ ↑ op p V M ⟩
-- PROGRESS THEOREM FOR PROMISE-OPEN COMPUTATIONS
⇒-not-in-ctx : {Γ : Ctx} {X : VType} {C : CType} → X ⇒ C ∈ ⟨⟨ Γ ⟩⟩ → ⊥
⇒-not-in-ctx {Γ ∷ y} (Tl x) =
⇒-not-in-ctx x
{- THEOREM 3.3 -}
progress : {Γ : Ctx}
{C : CType} →
(M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ C) →
-------------------------------
(Σ[ N ∈ ⟨⟨ Γ ⟩⟩ ⊢M⦂ C ] (M ↝ N)
⊎
CompResult⟨ Γ ∣ M ⟩)
progress (return V) =
inj₂ (comp (return V))
progress (let= M `in N) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (let= [-] `in N) r)
... | inj₂ (comp (return V)) =
inj₁ (_ , let-return V N)
... | inj₂ (comp (promise {_} {_} {_} {_} {_} {_} {_} {p} {M'} {M''} R)) =
inj₁ (_ , let-promise p M' M'' N)
... | inj₂ (comp (awaiting R)) =
inj₂ (comp (awaiting (let-in R)))
... | inj₂ (signal {_} {_} {_} {_} {p} {V} {M'} R) =
inj₁ (_ , let-↑ p V M' N)
progress (letrec M `in N) =
inj₁ (_ , letrec-unfold M N)
progress ((` x) · W) with ⇒-not-in-ctx x
... | ()
progress (ƛ M · W) =
inj₁ (_ , apply M W)
progress (↑ op p V M) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (↑ op p V [-]) r)
... | inj₂ R =
inj₂ (signal R)
progress (↓ op V M) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (↓ op V [-]) r)
... | inj₂ (comp (return W)) =
inj₁ (_ , (↓-return V W))
... | inj₂ (comp (awaiting R)) =
inj₂ (comp (awaiting (interrupt R)))
... | inj₂ (signal {X} {o} {i} {op'} {p} {W} {M'} R) =
inj₁ (_ , (↓-↑ p V W M'))
... | inj₂ (comp (promise {_} {_} {_} {_} {_} {_} {op'} {p} {M'} {M''} R)) with decₛ op op'
... | yes refl =
inj₁ (_ , ↓-promise-op p V M' M'')
... | no ¬q =
inj₁ (_ , ↓-promise-op' ¬q p V M' M'')
progress (promise op ∣ p ↦ M `in N) with progress N
... | inj₁ (M' , r) =
inj₁ (_ , context (promise op ∣ p ↦ M `in [-]) r)
... | inj₂ (comp R) =
inj₂ (comp (promise R))
... | inj₂ (signal {_} {_} {_} {_} {q} {V} {M'} R) =
inj₁ (_ , promise-↑ p q V M M')
progress (await ` x until M) =
inj₂ (comp (awaiting await))
progress (await ⟨ V ⟩ until M) =
inj₁ (_ , await-promise V M)
progress (coerce p q M) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (coerce p q [-]) r)
... | inj₂ (comp (return V)) =
inj₁ (_ , coerce-return V)
... | inj₂ (comp (promise {_} {_} {_} {_} {_} {_} {op'} {r} {M'} {M''} R)) =
inj₁ (_ , coerce-promise r M' M'')
... | inj₂ (comp (awaiting R)) =
inj₂ (comp (awaiting (coerce R)))
... | inj₂ (signal {_} {_} {_} {_} {r} {V} {M'} R) =
inj₁ (_ , coerce-↑ r V M')
-- PROGRESS THEOREM FOR CLOSED COMPUTATIONS
{- COROLLARY 3.4 -}
closed-progress : {C : CType} →
(M : [] ⊢M⦂ C) →
--------------------------
(Σ[ N ∈ [] ⊢M⦂ C ] (M ↝ N)
⊎
CompResult⟨ [] ∣ M ⟩)
closed-progress M =
progress M
| 28.341176
| 91
| 0.426526
|
226a5971297b7c8edd60d17d396d3b990280e88d
| 5,020
|
agda
|
Agda
|
Categories/DinaturalTransformation.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 98
|
2015-04-15T14:57:33.000Z
|
2022-03-08T05:20:36.000Z
|
Categories/DinaturalTransformation.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 19
|
2015-05-23T06:47:10.000Z
|
2019-08-09T16:31:40.000Z
|
Categories/DinaturalTransformation.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 23
|
2015-02-05T13:03:09.000Z
|
2021-11-11T13:50:56.000Z
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.DinaturalTransformation where
open import Level
open import Data.Product
open import Categories.Category
import Categories.NaturalTransformation
private module NT = Categories.NaturalTransformation
open import Categories.Functor using (Functor) renaming (_∘_ to _∘F_)
open import Categories.Bifunctor using (Bifunctor; module Functor)
open import Categories.Product
open import Categories.Square
record DinaturalTransformation {o ℓ e o′ ℓ′ e′}
{C : Category o ℓ e}
{D : Category o′ ℓ′ e′}
(F G : Bifunctor (Category.op C) C D) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
private
module C = Category C
module D = Category D
open Functor F renaming (op to Fop)
open Functor G renaming (F₀ to G₀; F₁ to G₁; op to Gop)
open D hiding (op)
field
α : (c : C.Obj) → D [ F₀ (c , c) , G₀ (c , c) ]
.commute : ∀ {c c′} (f : C [ c , c′ ]) → G₁ (f , C.id) ∘ α c′ ∘ F₁ ( C.id , f ) ≡ G₁ ( C.id , f ) ∘ α c ∘ F₁ ( f , C.id )
op : DinaturalTransformation {C = C.op} {D = D.op} Gop Fop
op = record { α = α; commute = λ f → D.Equiv.trans assoc (D.Equiv.trans (D.Equiv.sym (commute f)) (D.Equiv.sym assoc)) }
_<∘_ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G H : Bifunctor (Category.op C) C D}
→ NT.NaturalTransformation G H → DinaturalTransformation {C = C} F G → DinaturalTransformation {C = C} F H
_<∘_ {C = C} {D} {F} {G} {H} eta alpha = record { α = λ c → η (c , c) ∘ α c; commute = λ {c} {c′} f →
begin
H.F₁ (f , C.id) ∘ ((η (c′ , c′) ∘ α c′) ∘ F.F₁ (C.id , f))
↓⟨ ∘-resp-≡ʳ assoc ⟩
H.F₁ (f , C.id) ∘ (η (c′ , c′) ∘ (α c′ ∘ F.F₁ (C.id , f)))
↑⟨ assoc ⟩
(H.F₁ (f , C.id) ∘ η (c′ , c′)) ∘ (α c′ ∘ F.F₁ (C.id , f))
↑⟨ ∘-resp-≡ˡ (eta.commute (f , C.id)) ⟩
(η (c , c′) ∘ G.F₁ (f , C.id)) ∘ (α c′ ∘ F.F₁ (C.id , f))
↓⟨ pullʳ (commute f) ⟩
η (c , c′) ∘ G.F₁ (C.id , f) ∘ (α c ∘ F.F₁ (f , C.id))
↓⟨ pullˡ (eta.commute (C.id , f)) ⟩
(H.F₁ (C.id , f) ∘ η (c , c)) ∘ (α c ∘ F.F₁ (f , C.id))
↓⟨ assoc ⟩
H.F₁ (C.id , f) ∘ (η (c , c) ∘ (α c ∘ F.F₁ (f , C.id)))
↑⟨ ∘-resp-≡ʳ assoc ⟩
H.F₁ (C.id , f) ∘ ((η (c , c) ∘ α c) ∘ F.F₁ (f , C.id))
∎
{- This uses 'associative-unital reasoning, which is now broken. Above uses
direct reasoning, which is heavier, but works. JC.
begin
H.F₁ (f , C.id) ∙ ((η (c′ , c′) ∙ α c′) ∙ F.F₁ (C.id , f))
↑⟨ refl ⟩
(H.F₁ (f , C.id) ∙ η (c′ , c′)) ∙ (α c′ ∙ F.F₁ (C.id , f))
↑≡⟨ ∘-resp-≡ˡ (eta.commute (f , C.id)) ⟩
(η (c , c′) ∙ G.F₁ (f , C.id)) ∙ (α c′ ∙ F.F₁ (C.id , f))
↓≡⟨ pullʳ (commute f) ⟩
η (c , c′) ∙ G.F₁ (C.id , f) ∙ α c ∙ F.F₁ (f , C.id)
↓≡⟨ pullˡ (eta.commute (C.id , f)) ⟩
(H.F₁ (C.id , f) ∙ η (c , c)) ∙ α c ∙ F.F₁ (f , C.id)
↓⟨ refl ⟩
H.F₁ (C.id , f) ∙ (η (c , c) ∙ α c) ∙ F.F₁ (f , C.id)
∎ -} }
where
module C = Category C
module D = Category D
open D
open D.Equiv
module F = Functor F
module G = Functor G
module H = Functor H
module eta = NT.NaturalTransformation eta
open eta using (η)
open DinaturalTransformation alpha
-- open AUReasoning D
open HomReasoning
open GlueSquares D
_∘>_ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G H : Bifunctor (Category.op C) C D}
→ DinaturalTransformation {C = C} G H → NT.NaturalTransformation F G → DinaturalTransformation {C = C} F H
alpha ∘> eta = DinaturalTransformation.op (eta.op <∘ alpha.op)
where
module eta = NT.NaturalTransformation eta
module alpha = DinaturalTransformation alpha
_∘ʳ_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂}
→ {C : Category o₀ ℓ₀ e₀} {D : Category o₁ ℓ₁ e₁} {E : Category o₂ ℓ₂ e₂}
→ {F G : Bifunctor (Category.op C) C D}
→ (η : DinaturalTransformation {C = C} F G) → (K : Functor E C) → DinaturalTransformation {C = E} (F ∘F ((Functor.op K) ⁂ K)) (G ∘F ((Functor.op K) ⁂ K))
_∘ʳ_ {C = C} {D = D} {E} {F} {G} η K = record
{ α = λ c → DinaturalTransformation.α η (K.F₀ c)
; commute = λ {c} {c′} f → begin
G.F₁ (K.F₁ f , K.F₁ E.id) D.∘ η.α (K.F₀ c′) D.∘ F.F₁ (K.F₁ E.id , K.F₁ f)
↓⟨ G.F-resp-≡ (C.Equiv.refl , K.identity) ⟩∘⟨ D.Equiv.refl ⟩∘⟨ F.F-resp-≡ (K.identity , C.Equiv.refl) ⟩
G.F₁ (K.F₁ f , C.id) D.∘ η.α (K.F₀ c′) D.∘ F.F₁ (C.id , K.F₁ f)
↓⟨ DinaturalTransformation.commute η (K.F₁ f) ⟩
G.F₁ (C.id , K.F₁ f) D.∘ η.α (K.F₀ c) D.∘ F.F₁ (K.F₁ f , C.id)
↑⟨ G.F-resp-≡ (K.identity , C.Equiv.refl) ⟩∘⟨ D.Equiv.refl ⟩∘⟨ F.F-resp-≡ (C.Equiv.refl , K.identity) ⟩
G.F₁ (K.F₁ E.id , K.F₁ f) D.∘ η.α (K.F₀ c) D.∘ F.F₁ (K.F₁ f , K.F₁ E.id)
∎
}
where
module K = Functor K
module C = Category C
module D = Category D
module E = Category E
module F = Functor F
module G = Functor G
module η = DinaturalTransformation η
open D.HomReasoning
| 42.905983
| 158
| 0.521713
|
233f0a7bae6746f4128f2518d8a396ac6a15e5f6
| 17,987
|
agda
|
Agda
|
Cubical/HITs/Pushout/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:02.000Z
|
2022-02-05T01:25:02.000Z
|
Cubical/HITs/Pushout/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Pushout/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-
This file contains:
- Elimination principle for pushouts
- Homotopy natural equivalences of pushout spans
Written by: Loïc Pujet, September 2019
- 3×3 lemma for pushouts
Written by: Loïc Pujet, April 2019
- Homotopy natural equivalences of pushout spans
(unpacked and avoiding transports)
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.Pushout.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Function
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.HITs.Pushout.Base
private
variable
ℓ ℓ' ℓ'' ℓ''' : Level
A : Type ℓ
B : Type ℓ'
C : Type ℓ''
{-
Elimination for propositions
-}
elimProp : {f : A → B} {g : A → C}
→ (P : Pushout f g → Type ℓ''')
→ ((x : Pushout f g) → isProp (P x))
→ ((b : B) → P (inl b))
→ ((c : C) → P (inr c))
→ (x : Pushout f g) → P x
elimProp P isPropP PB PC (inl x) = PB x
elimProp P isPropP PB PC (inr x) = PC x
elimProp {f = f} {g = g} P isPropP PB PC (push a i) =
isOfHLevel→isOfHLevelDep 1 isPropP (PB (f a)) (PC (g a)) (push a) i
{-
Switching the span does not change the pushout
-}
pushoutSwitchEquiv : {f : A → B} {g : A → C}
→ Pushout f g ≃ Pushout g f
pushoutSwitchEquiv = isoToEquiv (iso f inv leftInv rightInv)
where f = λ {(inr x) → inl x; (inl x) → inr x; (push a i) → push a (~ i)}
inv = λ {(inr x) → inl x; (inl x) → inr x; (push a i) → push a (~ i)}
leftInv = λ {(inl x) → refl; (inr x) → refl; (push a i) → refl}
rightInv = λ {(inl x) → refl; (inr x) → refl; (push a i) → refl}
{-
Definition of pushout diagrams
-}
record 3-span : Type₁ where
field
A0 A2 A4 : Type₀
f1 : A2 → A0
f3 : A2 → A4
3span : {A0 A2 A4 : Type₀} → (A2 → A0) → (A2 → A4) → 3-span
3span f1 f3 = record { f1 = f1 ; f3 = f3 }
spanPushout : (s : 3-span) → Type₀
spanPushout s = Pushout (3-span.f1 s) (3-span.f3 s)
{-
Definition of a homotopy natural diagram equivalence
-}
record 3-span-equiv (s1 : 3-span) (s2 : 3-span) : Type₀ where
field
e0 : 3-span.A0 s1 ≃ 3-span.A0 s2
e2 : 3-span.A2 s1 ≃ 3-span.A2 s2
e4 : 3-span.A4 s1 ≃ 3-span.A4 s2
H1 : ∀ x → 3-span.f1 s2 (e2 .fst x) ≡ e0 .fst (3-span.f1 s1 x)
H3 : ∀ x → 3-span.f3 s2 (e2 .fst x) ≡ e4 .fst (3-span.f3 s1 x)
{-
Proof that homotopy equivalent spans are in fact equal
-}
spanEquivToPath : {s1 : 3-span} → {s2 : 3-span} → (e : 3-span-equiv s1 s2) → s1 ≡ s2
spanEquivToPath {s1} {s2} e = spanPath
where
open 3-span-equiv e
open 3-span
path0 : A0 s1 ≡ A0 s2
path0 = ua e0
path2 : A2 s1 ≡ A2 s2
path2 = ua e2
path4 : A4 s1 ≡ A4 s2
path4 = ua e4
spanPath1 : I → 3-span
spanPath1 i = record { A0 = path0 i ; A2 = path2 i ; A4 = path4 i ;
f1 = λ x → (transp (λ j → path0 (i ∧ j)) (~ i) (f1 s1 (transp (λ j → path2 (~ j ∧ i)) (~ i) x))) ;
f3 = λ x → (transp (λ j → path4 (i ∧ j)) (~ i) (f3 s1 (transp (λ j → path2 (~ j ∧ i)) (~ i) x))) }
spanPath2 : I → 3-span
spanPath2 i = record { A0 = A0 s2 ; A2 = A2 s2 ; A4 = A4 s2 ; f1 = f1Path i ; f3 = f3Path i }
where
f1Path : I → A2 s2 → A0 s2
f1Path i x = ((uaβ e0 (f1 s1 (transport (λ j → path2 (~ j)) x)))
∙ (H1 (transport (λ j → path2 (~ j)) x)) ⁻¹
∙ (λ j → f1 s2 (uaβ e2 (transport (λ j → path2 (~ j)) x) (~ j)))
∙ (λ j → f1 s2 (transportTransport⁻ path2 x j))) i
f3Path : I → A2 s2 → A4 s2
f3Path i x = ((uaβ e4 (f3 s1 (transport (λ j → path2 (~ j)) x)))
∙ (H3 (transport (λ j → path2 (~ j)) x)) ⁻¹
∙ (λ j → f3 s2 (uaβ e2 (transport (λ j → path2 (~ j)) x) (~ j)))
∙ (λ j → f3 s2 (transportTransport⁻ path2 x j))) i
spanPath : s1 ≡ s2
spanPath = (λ i → spanPath1 i) ∙ (λ i → spanPath2 i)
-- as a corollary, they have the same pushout
spanEquivToPushoutPath : {s1 : 3-span} → {s2 : 3-span} → (e : 3-span-equiv s1 s2)
→ spanPushout s1 ≡ spanPushout s2
spanEquivToPushoutPath {s1} {s2} e = cong spanPushout (spanEquivToPath e)
{-
3×3 lemma for pushouts
Let Aᵢⱼ denote a type, fᵢⱼ a map and Hᵢⱼ a homotopy. Given a diagram of the following shape:
A00 ←—f01—— A02 ——f03—→ A04
↑ ↑ ↑
f10 H11 f12 H13 f14
| | |
A20 ←—f21—— A22 ——f23—→ A24
| | |
f30 H31 f32 H33 f34
↓ ↓ ↓
A40 ←—f41—— A42 ——f43—→ A44
one can build its colimit from pushouts in two ways:
- either build pushouts A□0, A□2, A□4 of the lines and then build the pushout A□○ of the resulting
diagram A□0 ←—f□1—— A□2 ——f□3—→ A□4 ;
- or build pushouts of the columns and build the pushout A○□ of the resulting diagram A0□ ← A2□ → A4□.
Then the lemma states there is an equivalence A□○ ≃ A○□.
-}
record 3x3-span : Type₁ where
field
A00 A02 A04 A20 A22 A24 A40 A42 A44 : Type₀
f10 : A20 → A00
f12 : A22 → A02
f14 : A24 → A04
f30 : A20 → A40
f32 : A22 → A42
f34 : A24 → A44
f01 : A02 → A00
f21 : A22 → A20
f41 : A42 → A40
f03 : A02 → A04
f23 : A22 → A24
f43 : A42 → A44
H11 : ∀ x → f01 (f12 x) ≡ f10 (f21 x)
H13 : ∀ x → f03 (f12 x) ≡ f14 (f23 x)
H31 : ∀ x → f41 (f32 x) ≡ f30 (f21 x)
H33 : ∀ x → f43 (f32 x) ≡ f34 (f23 x)
-- pushouts of the lines
A□0 : Type₀
A□0 = Pushout f10 f30
A□2 : Type₀
A□2 = Pushout f12 f32
A□4 : Type₀
A□4 = Pushout f14 f34
-- maps between pushouts
f□1 : A□2 → A□0
f□1 (inl x) = inl (f01 x)
f□1 (inr x) = inr (f41 x)
f□1 (push a j) = ((λ i → inl (H11 a i))
∙∙ push (f21 a)
∙∙ (λ i → inr (H31 a (~ i)))) j
f□3 : A□2 → A□4
f□3 (inl x) = inl (f03 x)
f□3 (inr x) = inr (f43 x)
f□3 (push a j) = ((λ i → inl (H13 a i))
∙∙ push (f23 a)
∙∙ (λ i → inr (H33 a (~ i)))) j
-- total pushout
A□○ : Type₀
A□○ = Pushout f□1 f□3
-- pushouts of the columns
A0□ : Type₀
A0□ = Pushout f01 f03
A2□ : Type₀
A2□ = Pushout f21 f23
A4□ : Type₀
A4□ = Pushout f41 f43
-- maps between pushouts
f1□ : A2□ → A0□
f1□ (inl x) = inl (f10 x)
f1□ (inr x) = inr (f14 x)
f1□ (push a j) = ((λ i → inl (H11 a (~ i)))
∙∙ push (f12 a)
∙∙ (λ i → inr (H13 a i))) j
f3□ : A2□ → A4□
f3□ (inl x) = inl (f30 x)
f3□ (inr x) = inr (f34 x)
f3□ (push a j) = ((λ i → inl (H31 a (~ i)))
∙∙ push (f32 a)
∙∙ (λ i → inr (H33 a i))) j
-- total pushout
A○□ : Type₀
A○□ = Pushout f1□ f3□
-- forward map of the equivalence A□○ ≃ A○□
forward-l : A□0 → A○□
forward-l (inl x) = inl (inl x)
forward-l (inr x) = inr (inl x)
forward-l (push a i) = push (inl a) i
forward-r : A□4 → A○□
forward-r (inl x) = inl (inr x)
forward-r (inr x) = inr (inr x)
forward-r (push a i) = push (inr a) i
forward-filler : A22 → I → I → I → A○□
forward-filler a i j = hfill (λ t → λ { (i = i0) → inl (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) (~ t) j)
; (i = i1) → inr (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) (~ t) j)
; (j = i0) → forward-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) t i)
; (j = i1) → forward-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) t i) })
(inS (push (push a j) i))
A□○→A○□ : A□○ → A○□
A□○→A○□ (inl x) = forward-l x
A□○→A○□ (inr x) = forward-r x
A□○→A○□ (push (inl x) i) = inl (push x i)
A□○→A○□ (push (inr x) i) = inr (push x i)
A□○→A○□ (push (push a i) j) = forward-filler a i j i1
-- backward map
backward-l : A0□ → A□○
backward-l (inl x) = inl (inl x)
backward-l (inr x) = inr (inl x)
backward-l (push a i) = push (inl a) i
backward-r : A4□ → A□○
backward-r (inl x) = inl (inr x)
backward-r (inr x) = inr (inr x)
backward-r (push a i) = push (inr a) i
backward-filler : A22 → I → I → I → A□○
backward-filler a i j = hfill (λ t → λ { (i = i0) → inl (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) (~ t) j)
; (i = i1) → inr (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) (~ t) j)
; (j = i0) → backward-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) t i)
; (j = i1) → backward-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) t i) })
(inS (push (push a j) i))
A○□→A□○ : A○□ → A□○
A○□→A□○ (inl x) = backward-l x
A○□→A□○ (inr x) = backward-r x
A○□→A□○ (push (inl x) i) = inl (push x i)
A○□→A□○ (push (inr x) i) = inr (push x i)
A○□→A□○ (push (push a i) j) = backward-filler a i j i1
-- first homotopy
homotopy1-l : ∀ x → A□○→A○□ (backward-l x) ≡ inl x
homotopy1-l (inl x) = refl
homotopy1-l (inr x) = refl
homotopy1-l (push a i) = refl
homotopy1-r : ∀ x → A□○→A○□ (backward-r x) ≡ inr x
homotopy1-r (inl x) = refl
homotopy1-r (inr x) = refl
homotopy1-r (push a i) = refl
A○□→A□○→A○□ : ∀ x → A□○→A○□ (A○□→A□○ x) ≡ x
A○□→A□○→A○□ (inl x) = homotopy1-l x
A○□→A□○→A○□ (inr x) = homotopy1-r x
A○□→A□○→A○□ (push (inl x) i) k = push (inl x) i
A○□→A□○→A○□ (push (inr x) i) k = push (inr x) i
A○□→A□○→A○□ (push (push a i) j) k =
hcomp (λ t → λ { (i = i0) → forward-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) (~ t) j)
; (i = i1) → forward-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) (~ t) j)
; (j = i0) → homotopy1-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) t i) k
; (j = i1) → homotopy1-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) t i) k
; (k = i0) → A□○→A○□ (backward-filler a i j t)
; (k = i1) → forward-filler a j i (~ t) })
(forward-filler a j i i1)
-- second homotopy
homotopy2-l : ∀ x → A○□→A□○ (forward-l x) ≡ inl x
homotopy2-l (inl x) = refl
homotopy2-l (inr x) = refl
homotopy2-l (push a i) = refl
homotopy2-r : ∀ x → A○□→A□○ (forward-r x) ≡ inr x
homotopy2-r (inl x) = refl
homotopy2-r (inr x) = refl
homotopy2-r (push a i) = refl
A□○→A○□→A□○ : ∀ x → A○□→A□○ (A□○→A○□ x) ≡ x
A□○→A○□→A□○ (inl x) = homotopy2-l x
A□○→A○□→A□○ (inr x) = homotopy2-r x
A□○→A○□→A□○ (push (inl x) i) k = push (inl x) i
A□○→A○□→A□○ (push (inr x) i) k = push (inr x) i
A□○→A○□→A□○ (push (push a i) j) k =
hcomp (λ t → λ { (i = i0) → backward-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) (~ t) j)
; (i = i1) → backward-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) (~ t) j)
; (j = i0) → homotopy2-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) t i) k
; (j = i1) → homotopy2-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) t i) k
; (k = i0) → A○□→A□○ (forward-filler a i j t)
; (k = i1) → backward-filler a j i (~ t) })
(backward-filler a j i i1)
3x3-Iso : Iso A□○ A○□
Iso.fun 3x3-Iso = A□○→A○□
Iso.inv 3x3-Iso = A○□→A□○
Iso.rightInv 3x3-Iso = A○□→A□○→A○□
Iso.leftInv 3x3-Iso = A□○→A○□→A□○
-- the claimed result
3x3-lemma : A□○ ≡ A○□
3x3-lemma = isoToPath 3x3-Iso
PushoutToProp : {f : A → B} {g : A → C}
{D : Pushout f g → Type ℓ'''}
→ ((x : Pushout f g) → isProp (D x))
→ ((a : B) → D (inl a))
→ ((c : C) → D (inr c))
→ (x : Pushout f g) → D x
PushoutToProp isset baseB baseC (inl x) = baseB x
PushoutToProp isset baseB baseC (inr x) = baseC x
PushoutToProp {f = f} {g = g} isset baseB baseC (push a i) =
isOfHLevel→isOfHLevelDep 1 isset (baseB (f a)) (baseC (g a)) (push a) i
-- explicit characterisation of equivalences
-- Pushout f₁ g₁ ≃ Pushout f₂ g₂ avoiding
-- transports
open Iso
private
module PushoutIso {ℓ : Level} {A₁ B₁ C₁ A₂ B₂ C₂ : Type ℓ}
(A≃ : A₁ ≃ A₂) (B≃ : B₁ ≃ B₂) (C≃ : C₁ ≃ C₂)
(f₁ : A₁ → B₁) (g₁ : A₁ → C₁)
(f₂ : A₂ → B₂) (g₂ : A₂ → C₂)
(id1 : (fst B≃) ∘ f₁ ≡ f₂ ∘ (fst A≃))
(id2 : (fst C≃) ∘ g₁ ≡ g₂ ∘ (fst A≃))
where
F : Pushout f₁ g₁ → Pushout f₂ g₂
F (inl x) = inl (fst B≃ x)
F (inr x) = inr (fst C≃ x)
F (push a i) =
((λ i → inl (funExt⁻ id1 a i))
∙∙ push (fst A≃ a)
∙∙ λ i → inr (sym (funExt⁻ id2 a) i)) i
G : Pushout f₂ g₂ → Pushout f₁ g₁
G (inl x) = inl (invEq B≃ x)
G (inr x) = inr (invEq C≃ x)
G (push a i) =
((λ i → inl ((sym (cong (invEq B≃) (funExt⁻ id1 (invEq A≃ a)
∙ cong f₂ (secEq A≃ a)))
∙ retEq B≃ (f₁ (invEq A≃ a))) i))
∙∙ push (invEq A≃ a)
∙∙ λ i → inr (((sym (retEq C≃ (g₁ (invEq A≃ a)))
∙ (cong (invEq C≃) ((funExt⁻ id2 (invEq A≃ a)))))
∙ cong (invEq C≃) (cong g₂ (secEq A≃ a))) i)) i
abbrType₁ : {ℓ : Level} {A₁ B₁ C₁ A₂ B₂ C₂ : Type ℓ}
(A≃ : A₁ ≃ A₂) (B≃ : B₁ ≃ B₂) (C≃ : C₁ ≃ C₂)
→ (f₁ : A₁ → B₁) (g₁ : A₁ → C₁)
(f₂ : A₂ → B₂) (g₂ : A₂ → C₂)
→ (id1 : (fst B≃) ∘ f₁ ≡ f₂ ∘ (fst A≃))
(id2 : (fst C≃) ∘ g₁ ≡ g₂ ∘ (fst A≃))
→ Type _
abbrType₁ A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2 =
((x : _) → PushoutIso.F A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2
(PushoutIso.G A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2 x) ≡ x)
× ((x : _) → PushoutIso.G A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2
(PushoutIso.F A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2 x) ≡ x)
abbrType : {ℓ : Level} {A₁ B₁ C₁ A₂ B₂ C₂ : Type ℓ}
(A≃ : A₁ ≃ A₂) (B≃ : B₁ ≃ B₂) (C≃ : C₁ ≃ C₂)
→ Type _
abbrType {A₁ = A₁} {B₁ = B₁} {C₁ = C₁} {A₂ = A₂} {B₂ = B₂} {C₂ = C₂}
A≃ B≃ C≃ =
(f₁ : A₁ → B₁) (g₁ : A₁ → C₁)
(f₂ : A₂ → B₂) (g₂ : A₂ → C₂)
(id1 : (fst B≃) ∘ f₁ ≡ f₂ ∘ (fst A≃))
(id2 : (fst C≃) ∘ g₁ ≡ g₂ ∘ (fst A≃))
→ abbrType₁ A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2
F-G-cancel : {ℓ : Level} {A₁ B₁ C₁ A₂ B₂ C₂ : Type ℓ}
(A≃ : A₁ ≃ A₂) (B≃ : B₁ ≃ B₂) (C≃ : C₁ ≃ C₂)
→ abbrType A≃ B≃ C≃
F-G-cancel {A₁ = A₁} {B₁ = B₁} {C₁ = C₁} {A₂ = A₂} {B₂ = B₂} {C₂ = C₂} =
EquivJ (λ A₁ A≃ → (B≃ : B₁ ≃ B₂) (C≃ : C₁ ≃ C₂) →
abbrType A≃ B≃ C≃)
(EquivJ (λ B₁ B≃ → (C≃ : C₁ ≃ C₂) →
abbrType (idEquiv A₂) B≃ C≃)
(EquivJ (λ C₁ C≃ → abbrType (idEquiv A₂) (idEquiv B₂) C≃)
λ f₁ g₁ f₂ g₂
→ J (λ f₂ id1 → (id2 : g₁ ≡ g₂)
→ abbrType₁ (idEquiv A₂) (idEquiv B₂) (idEquiv C₂)
f₁ g₁ f₂ g₂ id1 id2)
(J (λ g₂ id2 → abbrType₁ (idEquiv A₂) (idEquiv B₂) (idEquiv C₂)
f₁ g₁ f₁ g₂ refl id2)
(postJ f₁ g₁))))
where
postJ : (f₁ : A₂ → B₂) (g₁ : A₂ → C₂)
→ abbrType₁ (idEquiv A₂) (idEquiv B₂) (idEquiv C₂)
f₁ g₁ f₁ g₁ refl refl
postJ f₁ g₁ = FF-GG , GG-FF
where
refl-lem : ∀ {ℓ} {A : Type ℓ} (x : A)
→ (refl {x = x} ∙ refl) ∙ refl ≡ refl
refl-lem x = sym (rUnit _) ∙ sym (rUnit _)
FF = PushoutIso.F (idEquiv A₂) (idEquiv B₂) (idEquiv C₂)
f₁ g₁ f₁ g₁ refl refl
GG = PushoutIso.G (idEquiv A₂) (idEquiv B₂) (idEquiv C₂)
f₁ g₁ f₁ g₁ refl refl
FF-GG : (x : Pushout f₁ g₁) → FF (GG x) ≡ x
FF-GG (inl x) = refl
FF-GG (inr x) = refl
FF-GG (push a i) j = lem j i
where
lem : Path (Path (Pushout f₁ g₁) (inl (f₁ a)) (inr (g₁ a)))
(cong FF ((λ i → inl (((refl ∙ refl) ∙ (refl {x = f₁ a})) i ))
∙∙ push {f = f₁} {g = g₁} a
∙∙ λ i → inr (((refl ∙ refl) ∙ (refl {x = g₁ a})) i)))
(push a)
lem = (λ i → cong FF ((λ j → inl (refl-lem (f₁ a) i j))
∙∙ push a
∙∙ λ j → inr (refl-lem (g₁ a) i j)))
∙∙ cong (cong FF) (sym (rUnit (push a)))
∙∙ sym (rUnit (push a))
GG-FF : (x : _) → GG (FF x) ≡ x
GG-FF (inl x) = refl
GG-FF (inr x) = refl
GG-FF (push a i) j = lem j i
where
lem : cong GG (refl ∙∙ push a ∙∙ refl) ≡ push a
lem = cong (cong GG) (sym (rUnit (push a)))
∙∙ (λ i → ((λ j → inl (refl-lem (f₁ a) i j))
∙∙ push a
∙∙ λ j → inr (refl-lem (g₁ a) i j)))
∙∙ sym (rUnit (push a))
module _ {ℓ : Level} {A₁ B₁ C₁ A₂ B₂ C₂ : Type ℓ}
(f₁ : A₁ → B₁) (g₁ : A₁ → C₁)
(f₂ : A₂ → B₂) (g₂ : A₂ → C₂)
(A≃ : A₁ ≃ A₂) (B≃ : B₁ ≃ B₂) (C≃ : C₁ ≃ C₂)
(id1 : fst B≃ ∘ f₁ ≡ f₂ ∘ fst A≃)
(id2 : fst C≃ ∘ g₁ ≡ g₂ ∘ fst A≃)
where
private
module P = PushoutIso A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2
l-r-cancel = F-G-cancel A≃ B≃ C≃ f₁ g₁ f₂ g₂ id1 id2
pushoutIso : Iso (Pushout f₁ g₁) (Pushout f₂ g₂)
fun pushoutIso = P.F
inv pushoutIso = P.G
rightInv pushoutIso = fst l-r-cancel
leftInv pushoutIso = snd l-r-cancel
pushoutEquiv : Pushout f₁ g₁ ≃ Pushout f₂ g₂
pushoutEquiv = isoToEquiv pushoutIso
| 35.268627
| 152
| 0.487352
|
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.