Search is not available for this dataset
text
string | meta
dict |
---|---|
-- Andreas, May-July 2016, implementing postfix projections
{-# OPTIONS --postfix-projections #-}
open import Common.Product
open import Common.Bool
pair : ∀{A : Set}(a : A) → A × A
pair a = {!!} -- C-c C-c here outputs postfix projections
record BoolFun : Set where
field out : Bool → Bool
open BoolFun
neg : BoolFun
neg .out x = {!x!} -- splitting here should preserve postfix proj
neg2 : BoolFun
out neg2 x = {!x!} -- splitting here should preserve prefix proj
module ExtendedLambda where
neg3 : BoolFun
neg3 = λ{ .out → {!!} }
pair2 : ∀{A : Set}(a : A) → A × A
pair2 = λ{ a → {!!} }
neg4 : BoolFun
neg4 = λ{ .out b → {!b!} }
-- DOES NOT WORK DUE TO ISSUE #2020
-- module LambdaWhere where
-- neg3 : BoolFun
-- neg3 = λ where
-- .out → {!!} -- splitting on result here crashes
-- pair2 : ∀{A : Set}(a : A) → A × A
-- pair2 = λ where
-- a → {!!}
-- extlam-where : Bool → Bool
-- extlam-where = λ where
-- b → {!b!}
-- -- extlam : Bool → Bool
-- -- extlam = λ
-- -- { b → {!b!}
-- -- }
| {
"alphanum_fraction": 0.571291866,
"avg_line_length": 20.0961538462,
"ext": "agda",
"hexsha": "1d54600bc516cda28d1b494c3b69e2879a406bae",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/interaction/Issue1963.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/interaction/Issue1963.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue1963.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 345,
"size": 1045
} |
module _ where
open import Issue1278.A Set
open import Agda.Builtin.Equality
test : (c : D) -> (c ≡ c)
test d = {!!} -- goal ".#A-60005532.d ≡ .#A-60005532.d"
| {
"alphanum_fraction": 0.6234567901,
"avg_line_length": 18,
"ext": "agda",
"hexsha": "87fc798790d74fb9872401a38dc5d99fe9f554e1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/interaction/Issue1278.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/interaction/Issue1278.agda",
"max_line_length": 55,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue1278.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 62,
"size": 162
} |
------------------------------------------------------------------------
-- Eliminators and initiality
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
module Partiality-algebra.Eliminators where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_⇔_)
open import Prelude hiding (T)
open import Bijection equality-with-J using (_↔_)
import Equivalence equality-with-J as Eq
open import Function-universe equality-with-J hiding (id; _∘_)
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import Surjection equality-with-J using (_↠_)
open import Partiality-algebra as PA hiding (id; _∘_)
------------------------------------------------------------------------
-- Eliminators
-- I (NAD) have tried to follow the spirit of the rules for HITs
-- specified in the HoTT-Agda library
-- (https://github.com/HoTT/HoTT-Agda/blob/master/core/lib/types/HIT_README.txt).
-- However, at the time of writing those rules don't apply to indexed
-- types.
-- A specification of a given partiality algebra's eliminator
-- arguments (for given motive sizes).
record Arguments {a p′ q′} {A : Type a} p q
(PA : Partiality-algebra p′ q′ A) :
Type (a ⊔ lsuc (p ⊔ q) ⊔ p′ ⊔ q′) where
open Partiality-algebra PA
-- Predicate transformer related to increasing sequences.
Inc : (P : T → Type p)
(Q : ∀ {x y} → P x → P y → x ⊑ y → Type q) →
Increasing-sequence → Type (p ⊔ q)
Inc P Q s =
∃ λ (p : ∀ n → P (s [ n ])) →
∀ n → Q (p n) (p (suc n)) (increasing s n)
field
P : T → Type p
Q : ∀ {x y} → P x → P y → x ⊑ y → Type q
pe : P never
po : ∀ x → P (now x)
pl : ∀ s (pq : Inc P Q s) → P (⨆ s)
pa : ∀ {x y} (x⊑y : x ⊑ y) (x⊒y : x ⊒ y)
(p-x : P x) (p-y : P y)
(q-x⊑y : Q p-x p-y x⊑y) (q-x⊒y : Q p-y p-x x⊒y) →
subst P (antisymmetry x⊑y x⊒y) p-x ≡ p-y
pp : ∀ {x} → Is-set (P x)
qr : ∀ x (p : P x) → Q p p (⊑-refl x)
qt : ∀ {x y z} (x⊑y : x ⊑ y) (y⊑z : y ⊑ z) →
(px : P x) (py : P y) (pz : P z) →
Q px py x⊑y → Q py pz y⊑z → Q px pz (⊑-trans x⊑y y⊑z)
qe : ∀ x (p : P x) → Q pe p (never⊑ x)
qu : ∀ s (pq : Inc P Q s) n →
Q (proj₁ pq n) (pl s pq) (upper-bound s n)
ql : ∀ s ub is-ub (pq : Inc P Q s) (pu : P ub)
(qu : ∀ n → Q (proj₁ pq n) pu (is-ub n)) →
Q (pl s pq) pu (least-upper-bound s ub is-ub)
qp : ∀ {x y} (p-x : P x) (p-y : P y) (x⊑y : x ⊑ y) →
Is-proposition (Q p-x p-y x⊑y)
-- A specification of a given partiality algebra's eliminators.
record Eliminators {a p q p′ q′} {A : Type a}
{PA : Partiality-algebra p′ q′ A}
(args : Arguments p q PA) :
Type (a ⊔ p ⊔ q ⊔ p′ ⊔ q′) where
open Partiality-algebra PA
open Arguments args
field
⊥-rec : (x : T) → P x
⊑-rec : ∀ {x y} (x⊑y : x ⊑ y) → Q (⊥-rec x) (⊥-rec y) x⊑y
inc-rec : (s : Increasing-sequence) → Inc P Q s
inc-rec = λ { (s , inc) → ( (λ n → ⊥-rec (s n))
, (λ n → ⊑-rec (inc n))
) }
field
-- Some "computation" rules.
⊥-rec-never : ⊥-rec never ≡ pe
⊥-rec-now : ∀ x → ⊥-rec (now x) ≡ po x
⊥-rec-⨆ : ∀ s → ⊥-rec (⨆ s) ≡ pl s (inc-rec s)
-- A specification of the elimination principle for a given partiality
-- algebra (for motives of certain sizes).
Elimination-principle :
∀ {a p′ q′} {A : Type a} →
∀ p q → Partiality-algebra p′ q′ A → Type (a ⊔ lsuc (p ⊔ q) ⊔ p′ ⊔ q′)
Elimination-principle p q P =
(args : Arguments p q P) → Eliminators args
------------------------------------------------------------------------
-- Initiality
-- The statement that a given partiality algebra is homotopy-initial.
Initial : ∀ {a p q} p′ q′ {A : Type a} → Partiality-algebra p q A →
Type (a ⊔ p ⊔ q ⊔ lsuc (p′ ⊔ q′))
Initial p′ q′ {A} P =
(P′ : Partiality-algebra p′ q′ A) → Contractible (Morphism P P′)
-- If a partiality algebra is initial at certain sizes, then it is
-- also initial at smaller sizes.
lower-initiality :
∀ {a p q p₁ q₁} p₂ q₂ {A : Type a}
(P : Partiality-algebra p q A)
(initial : Initial (p₁ ⊔ p₂) (q₁ ⊔ q₂) P) →
Initial p₁ q₁ P
lower-initiality {p₁ = p₁} {q₁} p₂ q₂ {A} P initial P′ =
Σ-map lower-morphism lemma (initial P″)
where
open Partiality-algebra P′
P″ : Partiality-algebra (p₁ ⊔ p₂) (q₁ ⊔ q₂) A
P″ = record
{ T = ↑ p₂ T
; partiality-algebra-with = record
{ _⊑_ = λ x y → ↑ q₂ (lower x ⊑ lower y)
; never = lift never
; now = lift ∘ now
; ⨆ = lift ∘ ⨆ ∘ Σ-map (lower ∘_) (lower ∘_)
; antisymmetry = λ x⊑y y⊑x →
cong lift (antisymmetry (lower x⊑y)
(lower y⊑x))
; T-is-set-unused = λ _ _ → ↑-closure 2 T-is-set _ _
; ⊑-refl = lift ∘ ⊑-refl ∘ lower
; ⊑-trans = λ x⊑y y⊑z →
lift (⊑-trans (lower x⊑y)
(lower y⊑z))
; never⊑ = lift ∘ never⊑ ∘ lower
; upper-bound = λ _ → lift ∘ upper-bound _
; least-upper-bound = λ _ _ →
lift ∘
least-upper-bound _ _ ∘
(lower ∘_)
; ⊑-propositional = ↑-closure 1 ⊑-propositional
}
}
lower-morphism : Morphism P P″ → Morphism P P′
lower-morphism m = record
{ function = lower ∘ function
; monotone = lower ∘ monotone
; strict = cong lower strict
; now-to-now = cong lower ∘ now-to-now
; ω-continuous = cong lower ∘ ω-continuous
}
where
open Morphism m
lift-morphism : Morphism P P′ → Morphism P P″
lift-morphism m = record
{ function = lift ∘ function
; monotone = lift ∘ monotone
; strict = cong lift strict
; now-to-now = cong lift ∘ now-to-now
; ω-continuous = cong lift ∘ ω-continuous
}
where
open Morphism m
lemma : {m : Morphism P P″} →
(∀ m′ → m ≡ m′) →
(∀ m′ → lower-morphism m ≡ m′)
lemma {m} hyp m′ = _↔_.to equality-characterisation-Morphism
(lower ∘ Morphism.function m ≡⟨ cong ((lower ∘_) ∘ Morphism.function) (hyp (lift-morphism m′)) ⟩∎
Morphism.function m′ ∎)
------------------------------------------------------------------------
-- Specifying the partiality monad using eliminators is logically
-- equivalent (at the meta-level) to specifying it using initiality
-- Any partiality algebra with eliminators (at certain sizes) is
-- initial (at the same sizes).
eliminators→initiality :
∀ {a p q p′ q′} {A : Type a} →
(P : Partiality-algebra p′ q′ A) →
Elimination-principle p q P →
Initial p q P
eliminators→initiality {p = p} {q} P elims P′ = morphism , unique
where
module P = Partiality-algebra P
module P′ = Partiality-algebra P′
args : Arguments p q P
args = record
{ P = λ _ → P′.T
; Q = λ x y _ → x P′.⊑ y
; pe = P′.never
; po = P′.now
; pl = λ _ → P′.⨆
; pa = λ x⊑y y⊑x u v u⊑v v⊑u →
let eq = Partiality-algebra.antisymmetry P x⊑y y⊑x in
subst (const P′.T) eq u ≡⟨ subst-const eq ⟩
u ≡⟨ P′.antisymmetry u⊑v v⊑u ⟩∎
v ∎
; pp = P′.T-is-set
; qr = λ _ → P′.⊑-refl
; qt = λ _ _ _ _ _ → P′.⊑-trans
; qe = λ _ → P′.never⊑
; qu = λ _ → P′.upper-bound
; ql = λ _ _ _ → P′.least-upper-bound
; qp = λ _ _ _ → P′.⊑-propositional
}
module E = Eliminators (elims args)
morphism : Morphism P P′
morphism = record
{ function = E.⊥-rec
; monotone = E.⊑-rec
; strict = E.⊥-rec-never
; now-to-now = E.⊥-rec-now
; ω-continuous = E.⊥-rec-⨆
}
open Morphism
function-unique : (f : Morphism P P′) →
E.⊥-rec ≡ function f
function-unique f = sym $ ⟨ext⟩ $ Eliminators.⊥-rec (elims (record
{ Q = λ _ _ _ → ↑ _ ⊤
; pe = function f P.never ≡⟨ strict f ⟩
P′.never ≡⟨ sym $ E.⊥-rec-never ⟩∎
E.⊥-rec P.never ∎
; po = λ x →
function f (P.now x) ≡⟨ now-to-now f x ⟩
P′.now x ≡⟨ sym $ E.⊥-rec-now x ⟩∎
E.⊥-rec (P.now x) ∎
; pl = λ s hyp →
function f (P.⨆ s) ≡⟨ ω-continuous f s ⟩
P′.⨆ (sequence-function f s) ≡⟨ cong P′.⨆ $ _↔_.to P′.equality-characterisation-increasing (proj₁ hyp) ⟩
P′.⨆ (E.inc-rec s) ≡⟨ sym $ E.⊥-rec-⨆ s ⟩
E.⊥-rec (P.⨆ s) ∎
; pa = λ _ _ _ _ _ _ → P′.T-is-set _ _
; pp = λ _ _ → mono₁ 1 P′.T-is-set _ _
; qp = λ _ _ _ _ _ → refl
}))
unique : ∀ f → morphism ≡ f
unique f =
_↔_.to equality-characterisation-Morphism (function-unique f)
-- Any partiality algebra with initiality (at certain sufficiently
-- large sizes) has eliminators (at certain sizes).
initiality→eliminators :
∀ {a p q p′ q′} {A : Type a} {P : Partiality-algebra p′ q′ A}
(initial : Initial (p ⊔ p′) (q ⊔ q′) P) →
Elimination-principle p q P
initiality→eliminators {p = p} {q} {p′} {q′} {A} {PA} initial args =
record
{ ⊥-rec = ⊥-rec
; ⊑-rec = ⊑-rec
; ⊥-rec-never = ⊥-rec-never
; ⊥-rec-now = ⊥-rec-now
; ⊥-rec-⨆ = ⊥-rec-⨆
}
where
open Partiality-algebra PA
open Arguments args
private
-- A partiality algebra with ∃ P as the carrier type.
∃PA : Partiality-algebra (p ⊔ p′) (q ⊔ q′) A
∃PA = record
{ T = ∃ P
; partiality-algebra-with = record
{ _⊑_ = λ { (_ , p) (_ , q) → ∃ (Q p q) }
; never = never , pe
; now = λ x → now x , po x
; ⨆ = λ s → ⨆ (Σ-map (proj₁ ∘_) (proj₁ ∘_) s)
, pl _ ( proj₂ ∘ proj₁ s
, proj₂ ∘ proj₂ s
)
; antisymmetry = λ { {x = (x , p)} {y = (y , q)}
(x⊑y , Qx⊑y) (y⊑x , Qy⊑x) →
Σ-≡,≡→≡
(antisymmetry x⊑y y⊑x)
(pa x⊑y y⊑x p q Qx⊑y Qy⊑x)
}
; T-is-set-unused = Σ-closure 2 T-is-set (λ _ → pp)
; ⊑-refl = λ _ → _ , qr _ _
; ⊑-trans = Σ-zip ⊑-trans (qt _ _ _ _ _)
; never⊑ = λ _ → _ , qe _ _
; upper-bound = λ _ _ → upper-bound _ _ , qu _ _ _
; least-upper-bound = λ _ _ ⊑qs →
least-upper-bound _ _ (proj₁ ∘ ⊑qs)
, ql _ _ _ _ _ (proj₂ ∘ ⊑qs)
; ⊑-propositional = Σ-closure 1 ⊑-propositional λ _ → qp _ _ _
}
}
-- Initiality gives us a morphism from PA to ∃PA.
eliminator-morphism : Morphism PA ∃PA
eliminator-morphism = proj₁ (initial ∃PA)
open Morphism eliminator-morphism
-- We can construct a morphism from ∃PA to PA directly.
proj₁-morphism : Morphism ∃PA PA
proj₁-morphism = record
{ function = proj₁
; monotone = proj₁
; strict = refl
; now-to-now = λ _ → refl
; ω-continuous = λ _ → refl
}
-- By composing the two morphisms we get an endomorphism on PA.
id′ : Morphism PA PA
id′ = proj₁-morphism PA.∘ eliminator-morphism
-- Due to initiality this morphism must be equal to id.
id′≡id : id′ ≡ PA.id
id′≡id =
let m , unique = lower-initiality p q PA initial PA in
id′ ≡⟨ sym $ unique id′ ⟩
m ≡⟨ unique PA.id ⟩∎
PA.id ∎
abstract
-- This provides us with a key lemma used to define the
-- eliminators.
lemma : ∀ x → proj₁ (function x) ≡ x
lemma x = cong (λ m → Morphism.function m x) id′≡id
-- As an aside this means that there is a split surjection from
-- ∃ P to T.
↠T : ∃ P ↠ T
↠T = record
{ logical-equivalence = record
{ to = Morphism.function proj₁-morphism
; from = function
}
; right-inverse-of = lemma
}
-- The eliminators.
⊥-rec : ∀ x → P x
⊥-rec x = $⟨ proj₂ (function x) ⟩
P (proj₁ (function x)) ↝⟨ subst P (lemma x) ⟩□
P x □
⊑-rec : ∀ {x y} (x⊑y : x ⊑ y) → Q (⊥-rec x) (⊥-rec y) x⊑y
⊑-rec {x} {y} x⊑y = $⟨ proj₂ (monotone x⊑y) ⟩
Q (proj₂ (function x)) (proj₂ (function y)) (proj₁ (monotone x⊑y)) ↝⟨ subst Q′ $
Σ-≡,≡→≡ (cong₂ _,_ (lemma x) (lemma y)) (
subst (λ xy → P (proj₁ xy) × P (proj₂ xy) ×
proj₁ xy ⊑ proj₂ xy)
(cong₂ _,_ (lemma x) (lemma y))
( proj₂ (function x)
, proj₂ (function y)
, proj₁ (monotone x⊑y)
) ≡⟨ push-subst-, {y≡z = cong₂ _,_ (lemma x) (lemma y)}
(λ xy → P (proj₁ xy))
(λ xy → P (proj₂ xy) × proj₁ xy ⊑ proj₂ xy)
{p = ( proj₂ (function x)
, proj₂ (function y)
, proj₁ (monotone x⊑y)
)} ⟩
( subst (λ xy → P (proj₁ xy))
(cong₂ _,_ (lemma x) (lemma y))
(proj₂ (function x))
, subst (λ xy → P (proj₂ xy) × proj₁ xy ⊑ proj₂ xy)
(cong₂ _,_ (lemma x) (lemma y))
( proj₂ (function y)
, proj₁ (monotone x⊑y)
)
) ≡⟨ cong₂ _,_
(subst-∘ P proj₁ (cong₂ _,_ (lemma x) (lemma y))
{p = proj₂ (function x)})
(push-subst-, {y≡z = cong₂ _,_ (lemma x) (lemma y)}
(λ xy → P (proj₂ xy))
(λ xy → proj₁ xy ⊑ proj₂ xy)
{p = ( proj₂ (function y)
, proj₁ (monotone x⊑y)
)}) ⟩
( subst P (cong proj₁ $ cong₂ _,_ (lemma x) (lemma y))
(proj₂ (function x))
, subst (λ xy → P (proj₂ xy))
(cong₂ _,_ (lemma x) (lemma y))
(proj₂ (function y))
, subst (λ xy → proj₁ xy ⊑ proj₂ xy)
(cong₂ _,_ (lemma x) (lemma y))
(proj₁ (monotone x⊑y))
) ≡⟨ cong₂ _,_
(cong (λ p → subst P p (proj₂ (function x))) $
cong-proj₁-cong₂-, (lemma x) (lemma y))
(cong₂ _,_
(subst-∘ P proj₂ (cong₂ _,_ (lemma x) (lemma y))
{p = proj₂ (function y)})
(⊑-propositional _ _)) ⟩
( subst P (lemma x) (proj₂ (function x))
, subst P (cong proj₂ $ cong₂ _,_ (lemma x) (lemma y))
(proj₂ (function y))
, x⊑y
) ≡⟨ cong (λ p → ⊥-rec x , subst P p (proj₂ (function y)) , x⊑y) $
cong-proj₂-cong₂-, (lemma x) (lemma y) ⟩∎
(⊥-rec x , ⊥-rec y , x⊑y) ∎) ⟩□
Q (⊥-rec x) (⊥-rec y) x⊑y □
where
Q′ :
(∃ λ xy → P (proj₁ xy) × P (proj₂ xy) × proj₁ xy ⊑ proj₂ xy) →
Type q
Q′ (_ , px , py , x⊑y) = Q px py x⊑y
inc-rec : ∀ s → Inc P Q s
inc-rec (s , inc) = ⊥-rec ∘ s , ⊑-rec ∘ inc
-- "Computation" rules.
private
-- A lemma.
⊥-rec-lemma′ :
∀ {a b} {A : Type a} {B : A → Type b} {x y : Σ A B} →
Is-set A →
x ≡ y → (p : proj₁ x ≡ proj₁ y) →
subst B p (proj₂ x) ≡ proj₂ y
⊥-rec-lemma′ {B = B} A-set =
elim (λ {x y} _ → (p : proj₁ x ≡ proj₁ y) →
subst B p (proj₂ x) ≡ proj₂ y)
(λ { (_ , x₂) p →
subst B p x₂ ≡⟨ cong (λ p → subst B p _) $ A-set p refl ⟩
subst B refl x₂ ≡⟨⟩
x₂ ∎
})
-- A specific instance of the lemma above.
⊥-rec-lemma : ∀ {x y} → function x ≡ (x , y) → ⊥-rec x ≡ y
⊥-rec-lemma {x} {y} eq =
⊥-rec x ≡⟨⟩
subst P (lemma x) (proj₂ (function x)) ≡⟨ ⊥-rec-lemma′ T-is-set eq (lemma x) ⟩∎
y ∎
⊥-rec-never : ⊥-rec never ≡ pe
⊥-rec-never = ⊥-rec-lemma strict
⊥-rec-now : ∀ x → ⊥-rec (now x) ≡ po x
⊥-rec-now x = ⊥-rec-lemma (now-to-now x)
⊥-rec-⨆ : ∀ s → ⊥-rec (⨆ s) ≡ pl s (inc-rec s)
⊥-rec-⨆ s = ⊥-rec-lemma
(function (⨆ s) ≡⟨ ω-continuous s ⟩
⨆ (Σ-map (proj₁ ∘_) (proj₁ ∘_) (sequence-function s)) ,
pl _ ( proj₂ ∘ proj₁ (sequence-function s)
, proj₂ ∘ proj₂ (sequence-function s)
) ≡⟨⟩
⨆ ( proj₁ ∘ function ∘ proj₁ s
, proj₁ ∘ monotone ∘ proj₂ s
) ,
pl _ ( proj₂ ∘ function ∘ proj₁ s
, proj₂ ∘ monotone ∘ proj₂ s
) ≡⟨ Σ-≡,≡→≡ (cong ⨆ lemma₁) lemma₂ ⟩
⨆ s , pl s ( ⊥-rec ∘ proj₁ s
, ⊑-rec ∘ proj₂ s
) ≡⟨⟩
⨆ s , pl s (inc-rec s) ∎)
where
lemma₁ =
( proj₁ ∘ function ∘ proj₁ s
, proj₁ ∘ monotone ∘ proj₂ s
) ≡⟨ _↔_.to equality-characterisation-increasing (λ n →
lemma (s [ n ])) ⟩∎
s ∎
lemma₂ =
subst P (cong ⨆ lemma₁)
(pl _ ( proj₂ ∘ function ∘ proj₁ s
, proj₂ ∘ monotone ∘ proj₂ s
)) ≡⟨ sym $ subst-∘ P ⨆ lemma₁ ⟩
subst (P ∘ ⨆) lemma₁
(pl _ ( proj₂ ∘ function ∘ proj₁ s
, proj₂ ∘ monotone ∘ proj₂ s
)) ≡⟨ elim
(λ {s′ s} eq → ∀ {i′ i} →
subst (λ s → ∀ n → P (s [ n ])) eq (proj₁ i′) ≡ proj₁ i →
subst (P ∘ ⨆) eq (pl s′ i′) ≡ pl s i)
(λ s {i′ i} eq →
pl s i′ ≡⟨ cong (pl s) (Σ-≡,≡→≡ eq (⟨ext⟩ λ _ → qp _ _ _ _ _)) ⟩∎
pl s i ∎)
lemma₁
(⟨ext⟩ λ n →
let lemma₃ =
cong _[ n ] lemma₁ ≡⟨ sym $ cong-∘ (_$ n) proj₁ lemma₁ ⟩
cong (_$ n) (cong proj₁ lemma₁) ≡⟨ cong (cong (_$ n)) $ proj₁-Σ-≡,≡→≡ (⟨ext⟩ (lemma ∘ proj₁ s)) _ ⟩
cong (_$ n) (⟨ext⟩ (lemma ∘ proj₁ s)) ≡⟨ cong-ext (lemma ∘ proj₁ s) ⟩∎
lemma (s [ n ]) ∎
in
subst (λ s → ∀ n → P (s [ n ])) lemma₁
(proj₂ ∘ function ∘ proj₁ s) n ≡⟨ sym $ push-subst-application lemma₁ (λ s n → P (s [ n ])) ⟩
subst (λ s → P (s [ n ])) lemma₁
(proj₂ (function (s [ n ]))) ≡⟨ subst-∘ P _[ n ] lemma₁ ⟩
subst P (cong _[ n ] lemma₁)
(proj₂ (function (s [ n ]))) ≡⟨ cong (λ eq → subst P eq (proj₂ (function (s [ n ])))) lemma₃ ⟩∎
subst P (lemma (s [ n ]))
(proj₂ (function (s [ n ]))) ∎) ⟩
pl s ( (λ n → subst P (lemma (s [ n ]))
(proj₂ (function (s [ n ]))))
, ⊑-rec ∘ proj₂ s
) ≡⟨⟩
pl s ( ⊥-rec ∘ proj₁ s
, ⊑-rec ∘ proj₂ s
) ∎
-- For any partiality algebra (with certain levels) initiality (at
-- possibly larger levels) is logically equivalent to having
-- eliminators (at the same possibly larger levels).
initiality⇔eliminators :
∀ {a p q p′ q′} {A : Type a} →
(P : Partiality-algebra p′ q′ A) →
Initial (p ⊔ p′) (q ⊔ q′) P
⇔
Elimination-principle (p ⊔ p′) (q ⊔ q′) P
initiality⇔eliminators P = record
{ to = initiality→eliminators
; from = eliminators→initiality P
}
-- For any partiality algebra initiality at all levels is logically
-- equivalent (at the meta-level) to having eliminators at all levels.
∀initiality→∀eliminators :
∀ {a p q} {A : Type a} →
(P : Partiality-algebra p q A) →
(∀ p q → Initial p q P) →
(∀ p q → Elimination-principle p q P)
∀initiality→∀eliminators {p = p′} {q = q′} P initial p q =
initiality→eliminators (initial (p ⊔ p′) (q ⊔ q′))
∀eliminators→∀initiality :
∀ {a p q} {A : Type a} →
(P : Partiality-algebra p q A) →
(∀ p q → Elimination-principle p q P) →
(∀ p q → Initial p q P)
∀eliminators→∀initiality P elim p q =
eliminators→initiality P (elim p q)
| {
"alphanum_fraction": 0.39729313,
"avg_line_length": 39.9794520548,
"ext": "agda",
"hexsha": "08f4518753f062f00f390b8c59e80df3f0952087",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/partiality-monad",
"max_forks_repo_path": "src/Partiality-algebra/Eliminators.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/partiality-monad",
"max_issues_repo_path": "src/Partiality-algebra/Eliminators.agda",
"max_line_length": 144,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/partiality-monad",
"max_stars_repo_path": "src/Partiality-algebra/Eliminators.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z",
"num_tokens": 7327,
"size": 23348
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.NaturalIsomorphism where
open import Level
open import Relation.Binary using (IsEquivalence)
open import Categories.Support.PropositionalEquality
open import Categories.Support.Equivalence
open import Categories.Category
open import Categories.Functor hiding (id) renaming (_∘_ to _∘F_; _≡_ to _≡F_; equiv to equivF)
open import Categories.NaturalTransformation.Core hiding (_≡_; equiv; setoid)
open import Categories.NaturalTransformation using (_∘ˡ_; _∘ʳ_)
import Categories.Morphisms as Morphisms
open import Categories.Functor.Properties using (module FunctorsAlways)
record NaturalIsomorphism {o ℓ e o′ ℓ′ e′}
{C : Category o ℓ e}
{D : Category o′ ℓ′ e′}
(F G : Functor C D) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
private module C = Category C
private module D = Category D
private module F = Functor F
private module G = Functor G
open F
open G renaming (F₀ to G₀; F₁ to G₁)
field
F⇒G : NaturalTransformation F G
F⇐G : NaturalTransformation G F
module ⇒ = NaturalTransformation F⇒G
module ⇐ = NaturalTransformation F⇐G
open Morphisms D
field
.iso : ∀ X → Iso (⇒.η X) (⇐.η X)
equiv : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → IsEquivalence (NaturalIsomorphism {C = C} {D})
equiv {C = C} {D} = record
{ refl = record
{ F⇒G = id
; F⇐G = id
; iso = λ _ → record
{ isoˡ = D.identityˡ
; isoʳ = D.identityˡ
}
}
; sym = λ X → let module X Z = Morphisms.Iso (NaturalIsomorphism.iso X Z) in record
{ F⇒G = NaturalIsomorphism.F⇐G X
; F⇐G = NaturalIsomorphism.F⇒G X
; iso = λ Y → record
{ isoˡ = X.isoʳ Y
; isoʳ = X.isoˡ Y
}
}
; trans = trans′
}
where
module C = Category C
module D = Category D
open D hiding (id)
trans′ : {x y z : Functor C D} → NaturalIsomorphism x y → NaturalIsomorphism y z → NaturalIsomorphism x z
trans′ X Y = record
{ F⇒G = F⇒G′
; F⇐G = F⇐G′
; iso = iso′
}
where
F⇒G′ = NaturalIsomorphism.F⇒G Y ∘₁ NaturalIsomorphism.F⇒G X
F⇐G′ = NaturalIsomorphism.F⇐G X ∘₁ NaturalIsomorphism.F⇐G Y
.iso′ : (X : C.Obj) → _
iso′ Z = record
{ isoˡ = isoˡ′
; isoʳ = isoʳ′
}
where
open NaturalIsomorphism
open NaturalTransformation
module Y Z = Morphisms.Iso (iso Y Z)
module X Z = Morphisms.Iso (iso X Z)
isoˡ′ : (η (F⇐G X) Z ∘ η (F⇐G Y) Z) ∘ (η (F⇒G Y) Z ∘ η (F⇒G X) Z) ≡ D.id
isoˡ′ = begin
(η (F⇐G X) Z ∘ η (F⇐G Y) Z) ∘ (η (F⇒G Y) Z ∘ η (F⇒G X) Z)
↓⟨ D.assoc ⟩
η (F⇐G X) Z ∘ (η (F⇐G Y) Z ∘ (η (F⇒G Y) Z ∘ η (F⇒G X) Z))
↑⟨ D.∘-resp-≡ʳ D.assoc ⟩
η (F⇐G X) Z ∘ ((η (F⇐G Y) Z ∘ η (F⇒G Y) Z) ∘ η (F⇒G X) Z)
↓⟨ D.∘-resp-≡ʳ (D.∘-resp-≡ˡ (Y.isoˡ Z)) ⟩
η (F⇐G X) Z ∘ (D.id ∘ η (F⇒G X) Z)
↓⟨ D.∘-resp-≡ʳ D.identityˡ ⟩
η (F⇐G X) Z ∘ η (F⇒G X) Z
↓⟨ X.isoˡ Z ⟩
D.id
∎
where
open D.HomReasoning
isoʳ′ : (η (F⇒G Y) Z ∘ η (F⇒G X) Z) ∘ (η (F⇐G X) Z ∘ η (F⇐G Y) Z) ≡ D.id
isoʳ′ = begin
(η (F⇒G Y) Z ∘ η (F⇒G X) Z) ∘ (η (F⇐G X) Z ∘ η (F⇐G Y) Z)
↓⟨ D.assoc ⟩
η (F⇒G Y) Z ∘ (η (F⇒G X) Z ∘ (η (F⇐G X) Z ∘ η (F⇐G Y) Z))
↑⟨ D.∘-resp-≡ʳ D.assoc ⟩
η (F⇒G Y) Z ∘ ((η (F⇒G X) Z ∘ η (F⇐G X) Z) ∘ η (F⇐G Y) Z)
↓⟨ D.∘-resp-≡ʳ (D.∘-resp-≡ˡ (X.isoʳ Z)) ⟩
η (F⇒G Y) Z ∘ (D.id ∘ η (F⇐G Y) Z)
↓⟨ D.∘-resp-≡ʳ D.identityˡ ⟩
η (F⇒G Y) Z ∘ η (F⇐G Y) Z
↓⟨ Y.isoʳ Z ⟩
D.id
∎
where
open D.HomReasoning
setoid : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Setoid _ _
setoid {C = C} {D} = record
{ Carrier = Functor C D
; _≈_ = NaturalIsomorphism
; isEquivalence = equiv {C = C} {D}
}
_ⓘˡ_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂}
→ {C : Category o₀ ℓ₀ e₀} {D : Category o₁ ℓ₁ e₁} {E : Category o₂ ℓ₂ e₂}
→ {F G : Functor C D}
→ (H : Functor D E) → (η : NaturalIsomorphism F G) → NaturalIsomorphism (H ∘F F) (H ∘F G)
_ⓘˡ_ {C = C} {D} {E} {F} {G} H η = record
{ F⇒G = H ∘ˡ η.F⇒G
; F⇐G = H ∘ˡ η.F⇐G
; iso = λ X → FunctorsAlways.resp-Iso H (η.iso X)
}
where
module η = NaturalIsomorphism η
_ⓘʳ_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂}
→ {C : Category o₀ ℓ₀ e₀} {D : Category o₁ ℓ₁ e₁} {E : Category o₂ ℓ₂ e₂}
→ {F G : Functor C D}
→ (η : NaturalIsomorphism F G) → (K : Functor E C) → NaturalIsomorphism (F ∘F K) (G ∘F K)
η ⓘʳ K = record
{ F⇒G = η.F⇒G ∘ʳ K
; F⇐G = η.F⇐G ∘ʳ K
; iso = λ X → η.iso (K.F₀ X)
}
where
module η = NaturalIsomorphism η
module K = Functor K
-- try ≡→iso again, but via first de-embedding some helpers, as that seems to make things
-- go 'weird' in combination with irrelevance
private
_©_ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G : Functor C D} →
NaturalTransformation F G → (x : Category.Obj C) → D [ Functor.F₀ F x , Functor.F₀ G x ]
_©_ = NaturalTransformation.η
my-sym : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F G : Functor C D) → F ≡F G → G ≡F F
my-sym {D = D} _ _ F≡G X = Heterogeneous.sym D (F≡G X)
oneway : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F G : Functor C D) →
F ≡F G → NaturalTransformation F G
oneway {C = C} {D} F G F≡G =
record
{ η = my-η
; commute = my-commute
}
where
module C = Category C
module D = Category D
module F = Functor F
module G = Functor G
open Heterogeneous D
same-Objs : ∀ A → F.F₀ A ≣ G.F₀ A
same-Objs A = domain-≣ (F≡G (C.id {A}))
my-η : ∀ X → D [ F.F₀ X , G.F₀ X ]
my-η X = ≣-subst (λ x → D [ F.F₀ X , x ]) (same-Objs X) D.id
.my-commute : ∀ {X Y} (f : C [ X , Y ]) → D [ D [ my-η Y ∘ F.F₁ f ] ≡ D [ G.F₁ f ∘ my-η X ] ]
my-commute {X} {Y} f with helper₃
where
helper₁ : D [ my-η Y ∘ F.F₁ f ] ∼ F.F₁ f
helper₁ with F.F₀ Y | G.F₀ Y | same-Objs Y | F.F₁ f
helper₁ | _ | ._ | ≣-refl | f′ = ≡⇒∼ D.identityˡ
helper₂ : G.F₁ f ∼ D [ G.F₁ f ∘ my-η X ]
helper₂ with F.F₀ X | G.F₀ X | same-Objs X | G.F₁ f
helper₂ | _ | ._ | ≣-refl | f′ = ≡⇒∼ (D.Equiv.sym D.identityʳ)
helper₃ : D [ my-η Y ∘ F.F₁ f ] ∼ D [ G.F₁ f ∘ my-η X ]
helper₃ = trans helper₁ (trans (F≡G f) helper₂)
my-commute f | Heterogeneous.≡⇒∼ pf = irr pf
≡→iso : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F G : Functor C D) → F ≡F G → NaturalIsomorphism F G
≡→iso {C = C} {D} F G F≡G =
record
{ F⇒G = oneway F G F≡G
; F⇐G = oneway G F (my-sym F G F≡G)
; iso = λ X → record
{ isoˡ = my-iso G F (my-sym F G F≡G) F≡G X
; isoʳ = my-iso F G F≡G (my-sym F G F≡G) X
}
}
where
module C = Category C
module D = Category D
open Heterogeneous D
.my-iso : (F G : Functor C D) (F≡G : F ≡F G) (G≡F : G ≡F F) (x : C.Obj) → D [ D [ oneway F G F≡G © x ∘ oneway G F G≡F © x ] ≡ D.id ]
my-iso F G F≡G G≡F x = func (F.F₀ x) (G.F₀ x) (domain-≣ (F≡G (C.id {x}))) (domain-≣ (G≡F (C.id {x})))
where
module F = Functor F
module G = Functor G
-- hand-written function that "with" cannot properly abstract on its own, it gets itself all confused.
func : (w z : D.Obj) (zz : w ≣ z ) (ww : z ≣ w) →
≣-subst (D._⇒_ w) zz (D.id {w}) D.∘ ≣-subst (D._⇒_ z) ww (D.id {z}) D.≡ D.id
func w .w ≣-refl ≣-refl = D.identityʳ
| {
"alphanum_fraction": 0.512797075,
"avg_line_length": 35.2903225806,
"ext": "agda",
"hexsha": "f07a836bd6e3541a60b45ec649a9c64f06b2dc61",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/NaturalIsomorphism.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/NaturalIsomorphism.agda",
"max_line_length": 134,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/NaturalIsomorphism.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 3456,
"size": 7658
} |
{-# OPTIONS --sized-types #-}
module SizedTypesVarSwap where
open import Common.Size renaming (↑_ to _^)
data Nat : {size : Size} -> Set where
zero : {size : Size} -> Nat {size ^}
suc : {size : Size} -> Nat {size} -> Nat {size ^}
bad : {i j : Size} -> Nat {i} -> Nat {j} -> Nat {∞}
bad (suc x) y = bad (suc y) x
bad zero y = y
| {
"alphanum_fraction": 0.5625,
"avg_line_length": 24,
"ext": "agda",
"hexsha": "743e875ea6b4ddd0b290ab57c3b6f39db87b86f2",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/SizedTypesVarSwap.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/SizedTypesVarSwap.agda",
"max_line_length": 52,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/SizedTypesVarSwap.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 118,
"size": 336
} |
module Sessions.Semantics.Communication {E : Set} (delay : E) where
open import Prelude
open import Data.List.Relation.Ternary.Interleaving
open import Data.List.Relation.Ternary.Interleaving.Propositional
open import Data.List.Relation.Equality.Propositional
open import Data.List.Properties
import Data.List as L
open import Relation.Unary hiding (Empty; _∈_)
open import Relation.Unary.PredicateTransformer using (Pt)
open import Relation.Ternary.Separation.Construct.Market
open import Relation.Ternary.Separation.Construct.Product
open import Relation.Ternary.Separation.Morphisms
open import Relation.Ternary.Separation.Monad
open import Relation.Ternary.Separation.Monad
open import Relation.Ternary.Separation.Monad.Error
open import Relation.Ternary.Separation.Monad.State
open import Sessions.Syntax.Types
open import Sessions.Syntax.Values
open import Sessions.Syntax.Expr
open import Sessions.Semantics.Commands
open import Sessions.Semantics.Runtime delay
{- A specification of the update we are performing -}
_≔_ : ∀ {x} {ys} {zs} → [ endp x ] ⊎ ys ≣ zs → SType → RCtx
_≔_ {zs = x ∷ zs} (to-right s) α = x ∷ s ≔ α
_≔_ {zs = chan l r ∷ zs} (divide lr s) α = chan α r ∷ zs
_≔_ {zs = chan l r ∷ zs} (divide rl s) α = chan l α ∷ zs
_≔_ {zs = .(endp _) ∷ zs} (to-left s) α = endp α ∷ zs
{- Type of actions on a link -}
private
Action : ∀ (from to : SType) → Pt RCtx 0ℓ
Action from to P Φ = ∀ {τ} → (end : End from τ) → (Channel τ ─✴ Except E (P ✴ Channel (end ≔ₑ to))) Φ
module _ where
open ExceptMonad {A = RCtx} E
open Monads.Monad except-monad
open Monads using (str)
{- Takes an endpointer and the channel list and updates it using a link action -}
act : ∀ {P α xs ds} →
(ptr : [ endp α ] ⊎ ds ≣ xs) →
∀[ Action α β P
⇒ Channels' xs
─✴ Except E (Empty ([ endp β ] ⊎ ds ≣ (ptr ≔ β)) ✴ P ✴ Channels' (ptr ≔ β)) ]
-- the pointer points to a channel where one end is already closed
app (act {xs = x ∷ xs} (to-left ptr) f) (ch :⟨ τ ⟩: chs) σ with ⊎-unassoc σ τ
... | _ , τ₁ , τ₂ = do
px ×⟨ τ₄ ⟩ (ch' ×⟨ τ₅ ⟩ chs) ← mapM (app (f (-, to-left [])) ch τ₁ &⟨ τ₂ ⟩ chs) ✴-assocᵣ
return (emp (to-left ptr) ×⟨ ⊎-idˡ ⟩ px ×⟨ τ₄ ⟩ cons (ch' ×⟨ τ₅ ⟩ chs))
-- the pointer points to the left side of a channel in the state
app (act {xs = x ∷ xs} (divide lr ptr) f) (ch :⟨ τ ⟩: chs) σ with ⊎-unassoc σ τ
... | _ , τ₂ , τ₃ = do
px ×⟨ τ₄ ⟩ chs ← mapM (app (f (ending lr)) ch τ₂ &⟨ τ₃ ⟩ chs) ✴-assocᵣ
return (emp (divide lr ptr) ×⟨ ⊎-idˡ ⟩ px ×⟨ τ₄ ⟩ cons chs)
-- the pointer points to the right side of a channel in the state
app (act {xs = x ∷ xs} (divide rl ptr) f) (ch :⟨ τ ⟩: chs) σ with ⊎-unassoc σ τ
... | _ , τ₂ , τ₃ = do
px ×⟨ τ₄ ⟩ (ch' ×⟨ τ₅ ⟩ chs) ← mapM (app (f (ending rl)) ch τ₂ &⟨ τ₃ ⟩ chs) ✴-assocᵣ
return (emp (divide rl ptr) ×⟨ ⊎-idˡ ⟩ px ×⟨ τ₄ ⟩ cons (ch' ×⟨ τ₅ ⟩ chs))
-- the pointer points to some channel further down the list
app (act {xs = x ∷ xs} (to-right ptr) f) (ch :⟨ τ ⟩: chs) σ with ⊎-unassoc σ (⊎-comm τ)
... | _ , τ₁ , τ₂ = do
emp ptr ×⟨ τ₃ ⟩ rhs ← mapM (app (act ptr f) chs τ₁ &⟨ τ₂ ⟩ ch) ✴-assocᵣ
let px ×⟨ τ₄ ⟩ chs' = ✴-assocᵣ rhs
return (emp (to-right ptr) ×⟨ τ₃ ⟩ (px ×⟨ τ₄ ⟩ cons (✴-swap chs')))
module _ where
open StateWithErr {C = RCtx} E
open Monads.Monad {{...}}
{- Updating a single link based on a pointer to one of its endpoints -}
operate : ∀ {P} → ∀[ Action α β P ⇒ Endptr α ─✴ State? Channels (P ✴ Endptr β) ]
app (app (operate f) refl σ₁) (lift chs k) (offerᵣ σ₂) with ⊎-assoc σ₂ k
... | _ , σ₃ , σ₄ with ⊎-assoc (⊎-comm σ₁) σ₃
... | _ , σ₅ , σ₆ with ⊎-unassoc σ₆ (⊎-comm σ₄)
... | _ , σ₇ , σ₈ with app (act σ₅ f) chs σ₇
... | error _ = error delay
... | partial (inj₂ (emp ptr' ×⟨ σ ⟩ (px ×⟨ τ ⟩ chs'))) with ⊎-id⁻ˡ σ
... | refl with ⊎-unassoc ptr' σ₈
... | _ , τ₁ , τ₂ with ⊎-unassoc τ₁ τ
... | _ , τ₃ , τ₄ with ⊎-assoc (⊎-comm τ₄) τ₂
... | _ , τ₅ , eureka =
partial (inj₂ (inj (px ×⟨ ⊎-comm τ₃ ⟩ refl) ×⟨ offerᵣ eureka ⟩ lift chs' (⊎-comm τ₅)))
{- Getting a value from a ready-to-receive endpoint -}
receive? : ∀[ Endptr (a ¿ β) ⇒ State? Channels (Val a ✴ Endptr β) ]
receive? ptr = app (operate (λ end → wandit (chan-receive end))) ptr ⊎-idˡ
{- Putting a value in a ready-to-send endpoint -}
send! : ∀[ Endptr (a ! β) ⇒ Val a ─✴ State? Channels (Endptr β) ]
app (send! {a = a} ptr) v σ = do
empty ×⟨ σ ⟩ ptr ← app (operate sender) ptr (⊎-comm σ)
case ⊎-id⁻ˡ σ of λ where
refl → return ptr
where
sender : Action (a ! γ) γ Emp _
app (sender e) ch σ =
let ch' = app (chan-send e ch) v (⊎-comm σ)
in ✓ (empty ×⟨ ⊎-idˡ ⟩ ch')
newChan : ε[ State? Channels (Endptr α ✴ Endptr (α ⁻¹)) ]
app newChan (lift chs k) σ with ⊎-id⁻ˡ σ
... | refl = ✓ (
(inj (refl ×⟨ divide lr ⊎-idˡ ⟩ refl))
×⟨ offerᵣ ⊎-∙ ⟩
lift (cons (emptyChannel ×⟨ ⊎-idˡ ⟩ chs)) (⊎-∙ₗ k))
closeChan : ∀[ Endptr end ⇒ State? Channels Emp ]
app (closeChan refl) (lift chs k) (offerᵣ σ) =
let
_ , σ₂ , σ₃ = ⊎-assoc σ k
chs' = close'em σ₂ chs
in ✓ (inj empty ×⟨ ⊎-idˡ ⟩ lift chs' σ₃)
where
-- This is really cool:
-- The pointer, in the form of the splitting of the store, contains all the necessary information
-- for the shape of the underlying buffer.
-- Depending on the shape of the splitting, we know, just by dependent pattern matching,
-- whether the channel is two- or onesided
close'em : ∀ {ds xs} → (ptr : [ endp end ] ⊎ ds ≣ xs) → ∀[ Channels' xs ⇒ Channels' ds ]
close'em (divide lr ptr) (twosided (link refl (emp ×⟨ τ ⟩ bᵣ)) :⟨ σ ⟩: chs) with ⊎-id⁻ˡ ptr | ⊎-id⁻ˡ τ
... | refl | refl = cons (onesided bᵣ ×⟨ σ ⟩ chs)
close'em (divide rl ptr) (twosided (link eq (bₗ ×⟨ τ ⟩ emp)) :⟨ σ ⟩: chs) with ⊎-id⁻ˡ ptr | ⊎-id⁻ʳ τ
... | refl | refl with dual-end (sym eq)
... | refl = cons (onesided bₗ ×⟨ σ ⟩ chs)
close'em (to-left ptr) (cons (onesided emp ×⟨ σ ⟩ chs)) with ⊎-id⁻ˡ ptr | ⊎-id⁻ˡ σ
... | refl | refl = chs
close'em (to-right ptr) (ch :⟨ σ ⟩: chs) =
let chs' = close'em ptr chs
in cons (ch ×⟨ σ ⟩ chs')
| {
"alphanum_fraction": 0.5870686875,
"avg_line_length": 43.0694444444,
"ext": "agda",
"hexsha": "44d74907aef26a39043fe382e008b153a150f1dd",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Sessions/Semantics/Communication.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "laMudri/linear.agda",
"max_issues_repo_path": "src/Sessions/Semantics/Communication.agda",
"max_line_length": 108,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Sessions/Semantics/Communication.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 2482,
"size": 6202
} |
-- MIT License
-- Copyright (c) 2021 Luca Ciccone and Luca Padovani
-- Permission is hereby granted, free of charge, to any person
-- obtaining a copy of this software and associated documentation
-- files (the "Software"), to deal in the Software without
-- restriction, including without limitation the rights to use,
-- copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following
-- conditions:
-- The above copyright notice and this permission notice shall be
-- included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-- OTHER DEALINGS IN THE SOFTWARE.
{-# OPTIONS --guardedness #-}
open import Data.Product
open import Data.List using (List; []; _∷_; _∷ʳ_; _++_)
open import Data.List.Properties using (∷-injective)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong)
open import Common
module Trace {ℙ : Set} (message : Message ℙ)
where
open import Action message public
open import SessionType message
Trace : Set
Trace = List Action
--| CO-TRACES |--
co-trace : Trace -> Trace
co-trace = Data.List.map co-action
co-trace-involution : (φ : Trace) -> co-trace (co-trace φ) ≡ φ
co-trace-involution [] = refl
co-trace-involution (α ∷ φ) rewrite co-action-involution α | co-trace-involution φ = refl
co-trace-++ : (φ ψ : Trace) -> co-trace (φ ++ ψ) ≡ co-trace φ ++ co-trace ψ
co-trace-++ [] _ = refl
co-trace-++ (α ∷ φ) ψ = cong (co-action α ∷_) (co-trace-++ φ ψ)
co-trace-injective : ∀{φ ψ} -> co-trace φ ≡ co-trace ψ -> φ ≡ ψ
co-trace-injective {[]} {[]} eq = refl
co-trace-injective {x ∷ φ} {x₁ ∷ ψ} eq with ∷-injective eq
... | eq1 , eq2 rewrite co-action-injective eq1 | co-trace-injective eq2 = refl
--| PREFIX RELATION |--
data _⊑_ : Trace -> Trace -> Set where
none : ∀{φ} -> [] ⊑ φ
some : ∀{φ ψ α} -> φ ⊑ ψ -> (α ∷ φ) ⊑ (α ∷ ψ)
⊑-refl : (φ : Trace) -> φ ⊑ φ
⊑-refl [] = none
⊑-refl (_ ∷ φ) = some (⊑-refl φ)
⊑-tran : ∀{φ ψ χ} -> φ ⊑ ψ -> ψ ⊑ χ -> φ ⊑ χ
⊑-tran none _ = none
⊑-tran (some le1) (some le2) = some (⊑-tran le1 le2)
⊑-++ : ∀{φ χ} -> φ ⊑ (φ ++ χ)
⊑-++ {[]} = none
⊑-++ {_ ∷ φ} = some (⊑-++ {φ})
⊑-precong-++ : ∀{φ ψ χ} -> ψ ⊑ χ -> (φ ++ ψ) ⊑ (φ ++ χ)
⊑-precong-++ {[]} le = le
⊑-precong-++ {_ ∷ _} le = some (⊑-precong-++ le)
⊑-co-trace : ∀{φ ψ} -> φ ⊑ ψ -> co-trace φ ⊑ co-trace ψ
⊑-co-trace none = none
⊑-co-trace (some le) = some (⊑-co-trace le)
⊑-trace : ∀{φ ψ} -> ψ ⊑ φ -> ∃[ φ' ] (φ ≡ ψ ++ φ')
⊑-trace {φ} none = φ , refl
⊑-trace {α ∷ φ} (some le) with ⊑-trace le
... | φ' , eq rewrite eq = φ' , refl
absurd-++-≡ : ∀{φ ψ : Trace}{α} -> (φ ++ α ∷ ψ) ≢ []
absurd-++-≡ {[]} ()
absurd-++-≡ {_ ∷ _} ()
absurd-++-⊑ : ∀{φ α ψ} -> ¬ (φ ++ α ∷ ψ) ⊑ []
absurd-++-⊑ {[]} ()
absurd-++-⊑ {_ ∷ _} ()
--| STRICT PREFIX RELATION |--
data _⊏_ : Trace -> Trace -> Set where
none : ∀{α φ} -> [] ⊏ (α ∷ φ)
some : ∀{φ ψ α} -> φ ⊏ ψ -> (α ∷ φ) ⊏ (α ∷ ψ)
⊏-irreflexive : ∀{φ} -> ¬ φ ⊏ φ
⊏-irreflexive (some lt) = ⊏-irreflexive lt
⊏-++ : ∀{φ ψ α} -> φ ⊏ (φ ++ (ψ ∷ʳ α))
⊏-++ {[]} {[]} = none
⊏-++ {[]} {_ ∷ _} = none
⊏-++ {_ ∷ φ} = some (⊏-++ {φ})
⊏->≢ : ∀{φ ψ} -> φ ⊏ ψ -> φ ≢ ψ
⊏->≢ (some lt) refl = ⊏-irreflexive lt
⊏->⊑ : ∀{φ ψ} -> φ ⊏ ψ -> φ ⊑ ψ
⊏->⊑ none = none
⊏->⊑ (some lt) = some (⊏->⊑ lt)
| {
"alphanum_fraction": 0.585462207,
"avg_line_length": 30.8699186992,
"ext": "agda",
"hexsha": "fa43b1a686eee05614c2a388a855ba54ac6d5217",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "boystrange/FairSubtypingAgda",
"max_forks_repo_path": "src/Trace.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "boystrange/FairSubtypingAgda",
"max_issues_repo_path": "src/Trace.agda",
"max_line_length": 89,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "boystrange/FairSubtypingAgda",
"max_stars_repo_path": "src/Trace.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z",
"num_tokens": 1506,
"size": 3797
} |
open import Level hiding ( suc ; zero )
open import Algebra
module sym5a where
open import Symmetric
open import Data.Unit using (⊤ ; tt )
open import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_)
open import Function hiding (flip)
open import Data.Nat hiding (_⊔_) -- using (ℕ; suc; zero)
open import Data.Nat.Properties
open import Relation.Nullary
open import Data.Empty
open import Data.Product
open import Gutil
open import Putil
open import Solvable using (solvable)
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import Data.Fin hiding (_<_ ; _≤_ ; lift )
open import Data.Fin.Permutation hiding (_∘ₚ_)
infixr 200 _∘ₚ_
_∘ₚ_ = Data.Fin.Permutation._∘ₚ_
open import Data.List hiding ( [_] )
open import nat
open import fin
open import logic
open _∧_
¬sym5solvable : ¬ ( solvable (Symmetric 5) )
¬sym5solvable sol = counter-example (end5 (abc 0<3 0<4 ) (any3de (dervied-length sol) 3rot 0<3 0<4 ) ) where
--
-- dba 1320 d → b → a → d
-- (dba)⁻¹ 3021 a → b → d → a
-- aec 21430
-- (aec)⁻¹ 41032
-- [ dba , aec ] = (abd)(cea)(dba)(aec) = abc
-- so commutator always contains abc, dba and aec
open ≡-Reasoning
open solvable
open Solvable ( Symmetric 5)
end5 : (x : Permutation 5 5) → deriving (dervied-length sol) x → x =p= pid
end5 x der = end sol x der
0<4 : 0 < 4
0<4 = s≤s z≤n
0<3 : 0 < 3
0<3 = s≤s z≤n
--- 1 ∷ 2 ∷ 0 ∷ [] abc
3rot : Permutation 3 3
3rot = pid {3} ∘ₚ pins (n≤ 2)
save2 : {i j : ℕ } → (i ≤ 3 ) → ( j ≤ 4 ) → Permutation 5 5
save2 i<3 j<4 = flip (pins (s≤s i<3)) ∘ₚ flip (pins j<4)
-- Permutation 5 5 include any Permutation 3 3
any3 : {i j : ℕ } → Permutation 3 3 → (i ≤ 3 ) → ( j ≤ 4 ) → Permutation 5 5
any3 abc i<3 j<4 = (save2 i<3 j<4 ∘ₚ (pprep (pprep abc))) ∘ₚ flip (save2 i<3 j<4 )
any3cong : {i j : ℕ } → {x y : Permutation 3 3 } → {i<3 : i ≤ 3 } → {j<4 : j ≤ 4 } → x =p= y → any3 x i<3 j<4 =p= any3 y i<3 j<4
any3cong {i} {j} {x} {y} {i<3} {j<4} x=y = presp {5} {save2 i<3 j<4 ∘ₚ (pprep (pprep x))} {_} {flip (save2 i<3 j<4 )}
(presp {5} {save2 i<3 j<4} prefl (pprep-cong (pprep-cong x=y)) ) prefl
open _=p=_
-- derving n includes any Permutation 3 3,
any3de : {i j : ℕ } → (n : ℕ) → (abc : Permutation 3 3) → (i<3 : i ≤ 3 ) → (j<4 : j ≤ 4 ) → deriving n (any3 abc i<3 j<4)
any3de {i} {j} zero abc i<3 j<4 = Level.lift tt
any3de {i} {j} (suc n) abc i<3 j<4 = ccong abc-from-comm (comm (any3de n (abc ∘ₚ abc) i<3 j0<4 ) (any3de n (abc ∘ₚ abc) i0<3 j<4 )) where
i0 : ℕ
i0 = ?
j0 : ℕ
j0 = ?
i0<3 : i0 ≤ 3
i0<3 = {!!}
j0<4 : j0 ≤ 4
j0<4 = {!!}
abc-from-comm : [ any3 (abc ∘ₚ abc) i<3 j0<4 , any3 (abc ∘ₚ abc) i0<3 j<4 ] =p= any3 abc i<3 j<4
abc-from-comm = {!!}
abc : {i j : ℕ } → (i ≤ 3 ) → ( j ≤ 4 ) → Permutation 5 5
abc i<3 j<4 = any3 3rot i<3 j<4
counter-example : ¬ (abc 0<3 0<4 =p= pid )
counter-example eq with ←pleq _ _ eq
... | ()
| {
"alphanum_fraction": 0.5445042762,
"avg_line_length": 33.2315789474,
"ext": "agda",
"hexsha": "7e6be8e9c4f9f27b10619e9ba7ab793000ae1f3b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shinji-kono/Galois",
"max_forks_repo_path": "src/sym5a.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "shinji-kono/Galois",
"max_issues_repo_path": "src/sym5a.agda",
"max_line_length": 145,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shinji-kono/Galois",
"max_stars_repo_path": "src/sym5a.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z",
"num_tokens": 1338,
"size": 3157
} |
-- Andreas, 2016-02-11, bug reported by sanzhiyan
module Issue610-module-alias-with where
import Common.Level
open import Common.Equality
data ⊥ : Set where
record ⊤ : Set where
data A : Set₁ where
set : .Set → A
module M .(x : Set) where
.out : _
out = x
.ack : A → Set
ack (set x) = M.out x
hah : set ⊤ ≡ set ⊥
hah = refl
.moo : ⊥
moo with cong ack hah
moo | q = subst (λ x → x) q _
-- Expected error:
-- .(⊥) !=< ⊥ of type Set
-- when checking that the expression subst (λ x → x) q _ has type ⊥
baa : .⊥ → ⊥
baa ()
yoink : ⊥
yoink = baa moo
| {
"alphanum_fraction": 0.6085409253,
"avg_line_length": 14.7894736842,
"ext": "agda",
"hexsha": "5ffddb4e71ecd27f6684857ed5e009f17c1c040c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Fail/Issue610-module-alias-with.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Fail/Issue610-module-alias-with.agda",
"max_line_length": 67,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/Issue610-module-alias-with.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 215,
"size": 562
} |
{-
Agda Implementors' Meeting VI
Göteborg
May 24 - 30, 2007
Hello Agda!
Ulf Norell
-}
-- Something which is rather useful is the ability to pattern match
-- on intermediate computations. That's where the with-construct comes
-- in.
module TestWith where
-- open import Nat
open import PreludeNat hiding(_==_; even; odd)
open import PreludeShow
{-
Basic idea
-}
-- The basic principle is that you can add argument to your
-- function on the fly. For instance,
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A -> Maybe A
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
compare : (n m : Nat) -> Maybe (n == m)
compare zero zero = just refl
compare (suc _) zero = nothing
compare zero (suc _) = nothing
compare (suc n)(suc m) with compare n m
compare (suc n)(suc .n) | just refl = just refl
compare (suc n)(suc m) | nothing = nothing
-- To add more than one argument separate by |
silly : Nat -> Nat
silly zero = zero
silly (suc n) with n | n
silly (suc n) | zero | suc m = m -- the values of the extra argument are
-- not taken into consideration
silly (suc n) | _ | _ = n
{-
The parity example
-}
-- This is a cute example of what you can do with with.
data Parity : Nat -> Set where
even : (k : Nat) -> Parity (k * 2)
odd : (k : Nat) -> Parity (1 + k * 2)
parity : (n : Nat) -> Parity n
parity zero = even 0
parity (suc n) with parity n
parity (suc .( k * 2)) | even k = odd k
parity (suc .(1 + k * 2)) | odd k = even (suc k)
half : Nat -> Nat
half n with parity n
half .( k * 2) | even k = k
half .(1 + k * 2) | odd k = k
mainS = showNat (half 44)
{-
What's next?
-}
-- Move on to: Modules.agda | {
"alphanum_fraction": 0.5848636617,
"avg_line_length": 20.4204545455,
"ext": "agda",
"hexsha": "e5bf67f0383f30ed85bf1248ff36554a3f4c7cfa",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/TestWith.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/TestWith.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/TestWith.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 570,
"size": 1797
} |
{-# OPTIONS --safe #-}
module Cubical.Categories.Abelian where
open import Cubical.Categories.Abelian.Base public
| {
"alphanum_fraction": 0.775862069,
"avg_line_length": 19.3333333333,
"ext": "agda",
"hexsha": "4fea6bb322e048942c556e1b02736b5cda925132",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Categories/Abelian.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Categories/Abelian.agda",
"max_line_length": 50,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Categories/Abelian.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 25,
"size": 116
} |
{-# OPTIONS --cubical --safe #-}
module Categories.Product where
open import Prelude hiding (_×_)
open import Categories
module _ {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) where
open Category C
module _ (X Y : Ob) where
record Product : Type (ℓ₁ ℓ⊔ ℓ₂) where
field
obj : Ob
proj₁ : C [ obj , X ]
proj₂ : C [ obj , Y ]
ump : (f : C [ Z , X ]) (g : C [ Z , Y ]) →
∃![ f×g ] ((C [ proj₁ ∘ f×g ] ≡ f) Prelude.× (C [ proj₂ ∘ f×g ] ≡ g))
_P[_×_] : ∀ {Z} → (π₁ : C [ Z , X ]) (π₂ : C [ Z , Y ]) →
C [ Z , obj ]
_P[_×_] π₁ π₂ = fst (ump π₁ π₂)
record HasProducts : Type (ℓ₁ ℓ⊔ ℓ₂) where
field product : (X Y : Ob) → Product X Y
_×_ : Ob → Ob → Ob
A × B = Product.obj (product A B)
module _ {A A′ B B′ : Ob} where
open Product using (_P[_×_])
open Product (product A B) hiding (_P[_×_])
_|×|_ : C [ A , A′ ] → C [ B , B′ ] → C [ Product.obj (product A B) , Product.obj (product A′ B′) ]
f |×| g = product A′ B′ P[ C [ f ∘ proj₁ ] × C [ g ∘ proj₂ ] ]
| {
"alphanum_fraction": 0.4765478424,
"avg_line_length": 30.4571428571,
"ext": "agda",
"hexsha": "15860a0c393258eb3d92e4b1b51453316822bbd1",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Categories/Product.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Categories/Product.agda",
"max_line_length": 105,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Categories/Product.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 409,
"size": 1066
} |
{-
This file contains:
- Definition of groupoid quotients
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.GroupoidQuotients.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Relation.Binary.Base
-- Groupoid quotients as a higher inductive type:
-- For the definition, only transitivity is needed
data _//_ {ℓ ℓ'} (A : Type ℓ) {R : A → A → Type ℓ'}
(Rt : BinaryRelation.isTrans R) : Type (ℓ-max ℓ ℓ') where
[_] : (a : A) → A // Rt
eq// : {a b : A} → (r : R a b) → [ a ] ≡ [ b ]
comp// : {a b c : A} → (r : R a b) → (s : R b c)
→ PathP (λ j → [ a ] ≡ eq// s j) (eq// r) (eq// (Rt a b c r s))
squash// : ∀ (x y : A // Rt) (p q : x ≡ y) (r s : p ≡ q) → r ≡ s
{- The comp// constructor fills the square:
eq// (Rt a b c r s)
[a]— — — >[c]
‖ ^
‖ | eq// s ^
‖ | j |
[a]— — — >[b] ∙ — >
eq// r i
We use this to give another constructor-like construction:
-}
comp'// : {ℓ ℓ' : Level} (A : Type ℓ) {R : A → A → Type ℓ'}
(Rt : BinaryRelation.isTrans R)
{a b c : A} → (r : R a b) → (s : R b c)
→ eq// {Rt = Rt} (Rt a b c r s) ≡ eq// r ∙ eq// s
comp'// A Rt r s i = compPath-unique refl (eq// r) (eq// s)
(eq// {Rt = Rt} (Rt _ _ _ r s) , comp// r s)
(eq// r ∙ eq// s , compPath-filler (eq// r) (eq// s)) i .fst
| {
"alphanum_fraction": 0.4786324786,
"avg_line_length": 31.9090909091,
"ext": "agda",
"hexsha": "0e141fea7a1792714762e3c127daed21cf34e9ca",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/HITs/GroupoidQuotients/Base.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/HITs/GroupoidQuotients/Base.agda",
"max_line_length": 73,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/HITs/GroupoidQuotients/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 543,
"size": 1404
} |
module Bee2.Crypto.Belt where
open import Data.ByteString
open import Data.ByteVec
open import Data.Nat using (ℕ)
open import Data.Product using (_,_)
open import Agda.Builtin.TrustMe using (primTrustMe)
import Bee2.Crypto.Defs
open Bee2.Crypto.Defs
open Bee2.Crypto.Defs using (Hash) public
{-# FOREIGN GHC import qualified Bee2.Crypto.Belt #-}
{-# FOREIGN GHC import qualified Data.ByteString #-}
Password = ByteString Strict
Salt = ByteString Strict
Key = ByteVec {Strict} 32
Header = ByteVec {Strict} 16
Kek = ByteVec {Strict} 32
{-# FOREIGN GHC import qualified Bee2.Crypto.Belt #-}
postulate
primBeltPBKDF : ByteString Strict → SizeT → ByteString Strict → ByteString Strict
primBeltHash : ByteString Strict → ByteString Strict
{-# COMPILE GHC primBeltPBKDF =
( Bee2.Crypto.Belt.beltPBKDF'bs ) #-}
{-# COMPILE GHC primBeltHash =
( Bee2.Crypto.Belt.beltHash'bs ) #-}
beltPBKDF : Password → ℕ → Salt → Kek
beltPBKDF p n s = (primBeltPBKDF p (SizeFromℕ n) s) , primTrustMe
beltHash : ByteString Strict → Hash
beltHash bs = primBeltHash bs , primTrustMe
| {
"alphanum_fraction": 0.7407749077,
"avg_line_length": 29.2972972973,
"ext": "agda",
"hexsha": "7cb6e7a2ec4050300c66c3eac10aff42573f9ad5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/bee2-agda",
"max_forks_repo_path": "src/Bee2/Crypto/Belt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "semenov-vladyslav/bee2-agda",
"max_issues_repo_path": "src/Bee2/Crypto/Belt.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/bee2-agda",
"max_stars_repo_path": "src/Bee2/Crypto/Belt.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 311,
"size": 1084
} |
module Structure.Sets.Operator where
open import Data.Boolean
open import Data.Boolean.Stmt
open import Functional
import Lvl
open import Logic
open import Logic.Propositional
open import Logic.Predicate
open import Structure.Function
open import Structure.Relator
open import Structure.Setoid using (Equiv) renaming (_≡_ to _≡ₛ_ ; _≢_ to _≢ₛ_)
import Structure.Sets.Names as Names
open import Structure.Sets.Relator using (SubsetRelation)
open import Type
private variable ℓ ℓₗ ℓₗ₁ ℓₗ₂ ℓᵣ ℓᵣₑₗ ℓₒ ℓₛ : Lvl.Level
private variable A B C S S₁ S₂ Sₒ Sᵢ Sₗ Sᵣ E E₁ E₂ Eₗ Eᵣ I O : Type{ℓ}
private variable _∈_ _∈ₒ_ _∈ᵢ_ : E → S → Stmt{ℓₗ}
private variable _∈ₗ_ : E → Sₗ → Stmt{ℓₗ}
private variable _∈ᵣ_ : E → Sᵣ → Stmt{ℓᵣ}
private variable _⊆_ : Sₗ → Sᵣ → Stmt{ℓᵣ}
private variable ⦃ equiv-I ⦄ : Equiv{ℓₗ}(I)
private variable ⦃ equiv-E ⦄ : Equiv{ℓₗ}(E)
private variable ⦃ equiv-Eₗ ⦄ : Equiv{ℓₗ}(Eₗ)
private variable ⦃ equiv-Eᵣ ⦄ : Equiv{ℓₗ}(Eᵣ)
private variable ⦃ equiv-O ⦄ : Equiv{ℓₗ}(O)
private variable ⦃ sub ⦄ : SubsetRelation(_∈ₗ_)(_∈ᵣ_)(_⊆_)
module _ (_∈_ : E → S → Stmt{ℓₗ}) where
record EmptySet(∅ : S) : Type{Lvl.of(E) Lvl.⊔ ℓₗ} where
constructor intro
field membership : Names.EmptyMembership(_∈_)(∅)
record UniversalSet(𝐔 : S) : Type{Lvl.of(E) Lvl.⊔ ℓₗ} where
constructor intro
field membership : Names.UniversalMembership(_∈_)(𝐔)
module _ ⦃ equiv-I : Equiv{ℓₗ₁}(I) ⦄ ⦃ equiv-E : Equiv{ℓₗ₂}(E) ⦄ where
record ImageFunction(⊶ : (f : I → E) → ⦃ func : Function(f) ⦄ → S) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(I) Lvl.⊔ ℓₗ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where
constructor intro
field membership : Names.ImageMembership(_∈_)(⊶)
module _ ⦃ equiv-E : Equiv{ℓₗ₁}(E) ⦄ {O : Type{ℓ}} ⦃ equiv-O : Equiv{ℓₗ₂}(O) ⦄ where
record FiberFunction(fiber : (f : E → O) → ⦃ func : Function(f) ⦄ → (O → S)) : Type{Lvl.of(E) Lvl.⊔ ℓ Lvl.⊔ ℓₗ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where
constructor intro
field membership : Names.FiberMembership(_∈_)(fiber)
module _ ⦃ equiv-E : Equiv{ℓₗ}(E) ⦄ where
record SingletonFunction(singleton : E → S) : Type{Lvl.of(E) Lvl.⊔ ℓₗ} where
constructor intro
field membership : Names.SingletonMembership(_∈_)(singleton)
record PairFunction(pair : E → E → S) : Type{Lvl.of(E) Lvl.⊔ ℓₗ} where
constructor intro
field membership : Names.PairMembership(_∈_)(pair)
record ComprehensionFunction(comp : (P : E → Stmt{ℓ}) ⦃ unaryRelator : UnaryRelator(P) ⦄ → S) : Type{Lvl.of(E) Lvl.⊔ ℓₗ Lvl.⊔ Lvl.𝐒(ℓ)} where
constructor intro
field membership : Names.ComprehensionMembership(_∈_)(comp)
module _ (_∈ₗ_ : E → Sₗ → Stmt{ℓₗ}) (_∈ᵣ_ : E → Sᵣ → Stmt{ℓᵣ}) where
record ComplementOperator(∁ : Sₗ → Sᵣ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ} where
constructor intro
field membership : Names.ComplementMembership(_∈ₗ_)(_∈ᵣ_)(∁)
module _ ⦃ equiv-E : Equiv{ℓₗ}(E) ⦄ where
record AddOperator(add : E → Sₗ → Sᵣ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ} where
constructor intro
field membership : Names.AddMembership(_∈ₗ_)(_∈ᵣ_)(add)
record RemoveOperator(remove : E → Sₗ → Sᵣ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ} where
constructor intro
field membership : Names.RemoveMembership(_∈ₗ_)(_∈ᵣ_)(remove)
record FilterFunction(filter : (P : E → Stmt{ℓ}) ⦃ unaryRelator : UnaryRelator(P) ⦄ → (Sₗ → Sᵣ)) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ Lvl.𝐒(ℓ)} where
constructor intro
field membership : Names.FilterMembership(_∈ₗ_)(_∈ᵣ_)(filter)
record BooleanFilterFunction(boolFilter : (E → Bool) → (Sₗ → Sᵣ)) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ} where
constructor intro
field membership : Names.BooleanFilterMembership(_∈ₗ_)(_∈ᵣ_)(boolFilter)
record IndexedBigUnionOperator(⋃ᵢ : (I → Sₗ) → Sᵣ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ Lvl.of(I)} where
constructor intro
field membership : Names.IndexedBigUnionMembership(_∈ₗ_)(_∈ᵣ_)(⋃ᵢ)
record IndexedBigIntersectionOperator(⋂ᵢ : (I → Sₗ) → Sᵣ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ Lvl.of(I)} where
constructor intro
field membership : Names.IndexedBigIntersectionMembership(_∈ₗ_)(_∈ᵣ_)(⋂ᵢ)
module _ (_∈ₗ_ : Eₗ → Sₗ → Stmt{ℓₗ}) (_∈ᵣ_ : Eᵣ → Sᵣ → Stmt{ℓᵣ}) where
module _ ⦃ equiv-Eₗ : Equiv{ℓₗ₁}(Eₗ) ⦄ ⦃ equiv-Eᵣ : Equiv{ℓₗ₂}(Eᵣ) ⦄ where
record MapFunction(map : (f : Eₗ → Eᵣ) ⦃ func : Function(f) ⦄ → (Sₗ → Sᵣ)) : Type{Lvl.of(Eₗ) Lvl.⊔ Lvl.of(Eᵣ) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where
constructor intro
field membership : Names.MapMembership(_∈ₗ_)(_∈ᵣ_)(map)
record UnmapFunction(unmap : (f : Eₗ → Eᵣ) ⦃ func : Function(f) ⦄ → (Sᵣ → Sₗ)) : Type{Lvl.of(Eₗ) Lvl.⊔ Lvl.of(Eᵣ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where
constructor intro
field membership : Names.UnmapMembership(_∈ₗ_)(_∈ᵣ_)(unmap)
module _ (_∈ₗ_ : E → Sₗ → Stmt{ℓₗ}) (_∈ᵣ_ : E → Sᵣ → Stmt{ℓᵣ}) (_∈ₒ_ : E → Sₒ → Stmt{ℓₒ}) where
record UnionOperator(_∪_ : Sₗ → Sᵣ → Sₒ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓₒ} where
constructor intro
field membership : Names.UnionMembership(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)(_∪_)
record IntersectionOperator(_∩_ : Sₗ → Sᵣ → Sₒ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓₒ} where
constructor intro
field membership : Names.IntersectMembership(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)(_∩_)
record WithoutOperator(_∖_ : Sₗ → Sᵣ → Sₒ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓₒ} where
constructor intro
field membership : Names.WithoutMembership(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)(_∖_)
module _ (_∈ₗ_ : E → Sₗ → Stmt{ℓₗ}) (_∈ᵣ_ : E → Sᵣ → Stmt{ℓᵣ}) (_∈ₒ_ : Sₗ → Sₒ → Stmt{ℓₒ}) {_⊆_ : Sₗ → Sᵣ → Stmt{ℓₛ}} ⦃ sub : SubsetRelation(_∈ₗ_)(_∈ᵣ_)(_⊆_) ⦄ where
record PowerFunction(℘ : Sᵣ → Sₒ) : Type{Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₛ Lvl.⊔ ℓₒ} where
constructor intro
field membership : Names.PowerMembership(_∈ₒ_)(_⊆_)(℘)
module _ (_∈ₗ_ : E → Sₗ → Stmt{ℓₗ}) (_∈ᵣ_ : Sₗ → Sᵣ → Stmt{ℓᵣ}) (_∈ₒ_ : E → Sₒ → Stmt{ℓₒ}) where
record BigUnionOperator(⋃ : Sᵣ → Sₒ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓₒ} where
constructor intro
field membership : Names.BigUnionMembership(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)(⋃)
record BigIntersectionOperator(⋂ : Sᵣ → Sₒ) : Type{Lvl.of(E) Lvl.⊔ Lvl.of(Sₗ) Lvl.⊔ Lvl.of(Sᵣ) Lvl.⊔ ℓₗ Lvl.⊔ ℓᵣ Lvl.⊔ ℓₒ} where
constructor intro
field membership : Names.BigIntersectionMembership(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)(⋂)
module _ ⦃ p : ∃(EmptySet(_∈_)) ⦄ where
open ∃(p) using () renaming (witness to ∅) public
open EmptySet([∃]-proof p) using () renaming (membership to [∅]-membership) public
module _ ⦃ p : ∃(UniversalSet(_∈_)) ⦄ where
open ∃(p) using () renaming (witness to 𝐔) public
open UniversalSet([∃]-proof p) using () renaming (membership to [𝐔]-membership) public
module _ ⦃ p : ∃(ImageFunction(_∈_) ⦃ equiv-I ⦄ ⦃ equiv-E ⦄) ⦄ where
open ∃(p) using () renaming (witness to ⊶) public
open ImageFunction([∃]-proof p) using () renaming (membership to [⊶]-membership) public
module _ ⦃ p : ∃(FiberFunction(_∈_) ⦃ equiv-E ⦄ ⦃ equiv-O ⦄) ⦄ where
open ∃(p) using () renaming (witness to fiber) public
open FiberFunction([∃]-proof p) using () renaming (membership to Fiber-membership) public
module _ ⦃ p : ∃(SingletonFunction(_∈_) ⦃ equiv-E ⦄) ⦄ where
open ∃(p) using () renaming (witness to singleton) public
open SingletonFunction([∃]-proof p) using () renaming (membership to Singleton-membership) public
module _ ⦃ p : ∃(PairFunction(_∈_) ⦃ equiv-E ⦄) ⦄ where
open ∃(p) using () renaming (witness to pair) public
open PairFunction([∃]-proof p) using () renaming (membership to Pair-membership) public
module _ ⦃ p : ∃(ComplementOperator(_∈ₗ_)(_∈ᵣ_)) ⦄ where
open ∃(p) using () renaming (witness to ∁) public
open ComplementOperator([∃]-proof p) using () renaming (membership to [∁]-membership) public
module _ ⦃ p : ∃(AddOperator(_∈ₗ_)(_∈ᵣ_) ⦃ equiv-E ⦄) ⦄ where
open ∃(p) using () renaming (witness to add) public
open AddOperator([∃]-proof p) using () renaming (membership to Add-membership) public
module _ ⦃ p : ∃(RemoveOperator(_∈ₗ_)(_∈ᵣ_) ⦃ equiv-E ⦄) ⦄ where
open ∃(p) using () renaming (witness to remove) public
open RemoveOperator([∃]-proof p) using () renaming (membership to Remove-membership) public
module _ ⦃ p : ∃(FilterFunction(_∈ₗ_)(_∈ᵣ_) ⦃ equiv-E ⦄ {ℓ}) ⦄ where
open ∃(p) using () renaming (witness to filter) public
open FilterFunction([∃]-proof p) using () renaming (membership to Filter-membership) public
module _ ⦃ p : ∃(BooleanFilterFunction(_∈ₗ_)(_∈ᵣ_)) ⦄ where
open ∃(p) using () renaming (witness to boolFilter) public
open BooleanFilterFunction([∃]-proof p) using () renaming (membership to BooleanFilter-membership) public
module _ ⦃ p : ∃(IndexedBigUnionOperator(_∈ₗ_)(_∈ᵣ_) {I = I}) ⦄ where
open ∃(p) using () renaming (witness to ⋃ᵢ) public
open IndexedBigUnionOperator([∃]-proof p) using () renaming (membership to [⋃ᵢ]-membership) public
module _ ⦃ p : ∃(IndexedBigIntersectionOperator(_∈ₗ_)(_∈ᵣ_) {I = I}) ⦄ where
open ∃(p) using () renaming (witness to ⋂ᵢ) public
open IndexedBigIntersectionOperator([∃]-proof p) using () renaming (membership to [⋂ᵢ]-membership) public
module _ ⦃ p : ∃(MapFunction(_∈ₗ_)(_∈ᵣ_) ⦃ equiv-Eₗ ⦄ ⦃ equiv-Eᵣ ⦄) ⦄ where
open ∃(p) using () renaming (witness to map) public
open MapFunction([∃]-proof p) using () renaming (membership to Map-membership) public
module _ ⦃ p : ∃(UnmapFunction(_∈ₗ_)(_∈ᵣ_) ⦃ equiv-Eₗ ⦄ ⦃ equiv-Eᵣ ⦄) ⦄ where
open ∃(p) using () renaming (witness to unmap) public
open UnmapFunction([∃]-proof p) using () renaming (membership to Unmap-membership) public
module _ ⦃ p : ∃(UnionOperator(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)) ⦄ where
open ∃(p) using () renaming (witness to _∪_) public
open UnionOperator([∃]-proof p) using () renaming (membership to [∪]-membership) public
module _ ⦃ p : ∃(IntersectionOperator(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)) ⦄ where
open ∃(p) using () renaming (witness to _∩_) public
open IntersectionOperator([∃]-proof p) using () renaming (membership to [∩]-membership) public
module _ ⦃ p : ∃(WithoutOperator(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)) ⦄ where
open ∃(p) using () renaming (witness to _∖_) public
open WithoutOperator([∃]-proof p) using () renaming (membership to [∖]-membership) public
module _ ⦃ p : ∃(PowerFunction(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_) ⦃ sub ⦄) ⦄ where
open ∃(p) using () renaming (witness to ℘) public
open PowerFunction([∃]-proof p) using () renaming (membership to [℘]-membership) public
module _ ⦃ p : ∃(BigUnionOperator(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)) ⦄ where
open ∃(p) using () renaming (witness to ⋃) public
open BigUnionOperator([∃]-proof p) using () renaming (membership to [⋃]-membership) public
module _ ⦃ p : ∃(BigIntersectionOperator(_∈ₗ_)(_∈ᵣ_)(_∈ₒ_)) ⦄ where
open ∃(p) using () renaming (witness to ⋂) public
open BigIntersectionOperator([∃]-proof p) using () renaming (membership to [⋂]-membership) public
| {
"alphanum_fraction": 0.657546657,
"avg_line_length": 51.8215962441,
"ext": "agda",
"hexsha": "2bc23e48c3efa2fcee2f6843cee2078f9032868b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Sets/Operator.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Sets/Operator.agda",
"max_line_length": 179,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Sets/Operator.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 4994,
"size": 11038
} |
module Base.Change.Sums where
open import Data.Sum
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Level
open import Base.Ascription
open import Base.Change.Algebra
open import Base.Change.Equivalence
open import Base.Change.Equivalence.Realizers
open import Postulate.Extensionality
module SumChanges ℓ {X Y : Set ℓ} {{CX : ChangeAlgebra X}} {{CY : ChangeAlgebra Y}} where
open ≡-Reasoning
-- This is an indexed datatype, so it has two constructors per argument. But
-- erasure would probably not be smart enough to notice.
-- Should we rewrite this as two separate datatypes?
data SumChange : X ⊎ Y → Set ℓ where
ch₁ : ∀ {x} → (dx : Δ x) → SumChange (inj₁ x)
rp₁₂ : ∀ {x} → (y : Y) → SumChange (inj₁ x)
ch₂ : ∀ {y} → (dy : Δ y) → SumChange (inj₂ y)
rp₂₁ : ∀ {y} → (x : X) → SumChange (inj₂ y)
_⊕_ : (v : X ⊎ Y) → SumChange v → X ⊎ Y
inj₁ x ⊕ ch₁ dx = inj₁ (x ⊞ dx)
inj₂ y ⊕ ch₂ dy = inj₂ (y ⊞ dy)
inj₁ x ⊕ rp₁₂ y = inj₂ y
inj₂ y ⊕ rp₂₁ x = inj₁ x
_⊝_ : ∀ (v₂ v₁ : X ⊎ Y) → SumChange v₁
inj₁ x₂ ⊝ inj₁ x₁ = ch₁ (x₂ ⊟ x₁)
inj₂ y₂ ⊝ inj₂ y₁ = ch₂ (y₂ ⊟ y₁)
inj₂ y₂ ⊝ inj₁ x₁ = rp₁₂ y₂
inj₁ x₂ ⊝ inj₂ y₁ = rp₂₁ x₂
s-nil : (v : X ⊎ Y) → SumChange v
s-nil (inj₁ x) = ch₁ (nil x)
s-nil (inj₂ y) = ch₂ (nil y)
s-update-diff : ∀ (u v : X ⊎ Y) → v ⊕ (u ⊝ v) ≡ u
s-update-diff (inj₁ x₂) (inj₁ x₁) = cong inj₁ (update-diff x₂ x₁)
s-update-diff (inj₂ y₂) (inj₂ y₁) = cong inj₂ (update-diff y₂ y₁)
s-update-diff (inj₁ x₂) (inj₂ y₁) = refl
s-update-diff (inj₂ y₂) (inj₁ x₁) = refl
s-update-nil : ∀ v → v ⊕ (s-nil v) ≡ v
s-update-nil (inj₁ x) = cong inj₁ (update-nil x)
s-update-nil (inj₂ y) = cong inj₂ (update-nil y)
instance
changeAlgebraSums : ChangeAlgebra (X ⊎ Y)
changeAlgebraSums = record
{ Change = SumChange
; update = _⊕_
; diff = _⊝_
; nil = s-nil
; isChangeAlgebra = record
{ update-diff = s-update-diff
; update-nil = s-update-nil
}
}
inj₁′ : Δ (inj₁ as (X → (X ⊎ Y)))
inj₁′ = nil inj₁
inj₁′-realizer : RawChange (inj₁ as (X → (X ⊎ Y)))
inj₁′-realizer x dx = ch₁ dx
inj₁′Derivative : IsDerivative (inj₁ as (X → (X ⊎ Y))) inj₁′-realizer
inj₁′Derivative x dx = refl
inj₁′-realizer-correct : ∀ a da → apply inj₁′ a da ≙₍ inj₁ a as (X ⊎ Y) ₎ inj₁′-realizer a da
inj₁′-realizer-correct a da = diff-update
inj₁′-faster-w-proof : equiv-raw-change-to-change-ResType inj₁ inj₁′-realizer
inj₁′-faster-w-proof = equiv-raw-change-to-change inj₁ inj₁′ inj₁′-realizer inj₁′-realizer-correct
inj₁′-faster : Δ inj₁
inj₁′-faster = proj₁ inj₁′-faster-w-proof
inj₂′ : Δ (inj₂ as (Y → (X ⊎ Y)))
inj₂′ = nil inj₂
inj₂′-realizer : RawChange (inj₂ as (Y → (X ⊎ Y)))
inj₂′-realizer y dy = ch₂ dy
inj₂′Derivative : IsDerivative (inj₂ as (Y → (X ⊎ Y))) inj₂′-realizer
inj₂′Derivative y dy = refl
inj₂′-realizer-correct : ∀ b db → apply inj₂′ b db ≙₍ inj₂ b as (X ⊎ Y) ₎ inj₂′-realizer b db
inj₂′-realizer-correct b db = diff-update
inj₂′-faster-w-proof : equiv-raw-change-to-change-ResType inj₂ inj₂′-realizer
inj₂′-faster-w-proof = equiv-raw-change-to-change inj₂ inj₂′ inj₂′-realizer inj₂′-realizer-correct
inj₂′-faster : Δ inj₂
inj₂′-faster = proj₁ inj₂′-faster-w-proof
module _ {Z : Set ℓ} {{CZ : ChangeAlgebra Z}} where
-- Elimination form for sums. This is a less dependently-typed version of
-- [_,_].
match : (X → Z) → (Y → Z) → X ⊎ Y → Z
match f g (inj₁ x) = f x
match f g (inj₂ y) = g y
match′ : Δ match
match′ = nil match
match′-realizer : (f : X → Z) → Δ f → (g : Y → Z) → Δ g → (s : X ⊎ Y) → Δ s → Δ (match f g s)
match′-realizer f df g dg (inj₁ x) (ch₁ dx) = apply df x dx
match′-realizer f df g dg (inj₁ x) (rp₁₂ y) = ((g ⊞ dg) y) ⊟ (f x)
match′-realizer f df g dg (inj₂ y) (rp₂₁ x) = ((f ⊞ df) x) ⊟ (g y)
match′-realizer f df g dg (inj₂ y) (ch₂ dy) = apply dg y dy
match′-realizer-correct :
(f : X → Z) → (df : Δ f) → (g : Y → Z) → (dg : Δ g) → (s : X ⊎ Y) → (ds : Δ s) →
apply (apply (apply match′ f df) g dg) s ds ≙₍ match f g s ₎ match′-realizer f df g dg s ds
match′-realizer-correct f df g dg (inj₁ x) (ch₁ dx) = ≙-incrementalization f df x dx
match′-realizer-correct f df g dg (inj₁ x) (rp₁₂ y) = ≙-refl
match′-realizer-correct f df g dg (inj₂ y) (ch₂ dy) = ≙-incrementalization g dg y dy
match′-realizer-correct f df g dg (inj₂ y) (rp₂₁ x) = ≙-refl
-- We need a ternary variant of the lemma here.
match′-faster-w-proof : equiv-raw-change-to-change-ternary-ResType match match′-realizer
match′-faster-w-proof = equiv-raw-change-to-change-ternary match match′ match′-realizer match′-realizer-correct
match′-faster : Δ match
match′-faster = proj₁ match′-faster-w-proof
| {
"alphanum_fraction": 0.6136599543,
"avg_line_length": 37.0538461538,
"ext": "agda",
"hexsha": "1e46aa46ad9c37c4b4f6d2112404ff1785b3e888",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Base/Change/Sums.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Base/Change/Sums.agda",
"max_line_length": 115,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Base/Change/Sums.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 1941,
"size": 4817
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.Product.Relation.Binary.Lex.Strict directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Product.Relation.Lex.Strict where
open import Data.Product.Relation.Binary.Lex.Strict public
| {
"alphanum_fraction": 0.4891566265,
"avg_line_length": 31.9230769231,
"ext": "agda",
"hexsha": "dbc5a5ade954b73cb895c3f0d97940ad9838ab4a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Lex/Strict.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Lex/Strict.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Lex/Strict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 63,
"size": 415
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Functor.Hom.Properties.Covariant {o ℓ e} (C : Category o ℓ e) where
open import Level
open import Function.Equality using (Π)
open import Relation.Binary using (Setoid)
open import Categories.Category.Construction.Cones
open import Categories.Category.Instance.Setoids
open import Categories.Diagram.Cone.Properties
open import Categories.Diagram.Limit
open import Categories.Functor
open import Categories.Functor.Limits
open import Categories.Functor.Hom
import Categories.Morphism.Reasoning as MR
private
variable
o′ ℓ′ e′ : Level
J : Category o′ ℓ′ e′
module C = Category C
open Category C
open Hom C
open Π
-- Hom functor preserves limits in C
module _ (W : Obj) {F : Functor J C} (lim : Limit F) where
private
module F = Functor F
module lim = Limit lim
open lim
HomF : Functor J (Setoids ℓ e)
HomF = Hom[ W ,-] ∘F F
open HomReasoning
open MR C
⊤ : Cone HomF
⊤ = F-map-Coneˡ Hom[ W ,-] limit
module _ (K : Cone HomF) where
private
module K = Cone _ K
KW : Setoid.Carrier (Cone.N K) → Cone F
KW x = record
{ N = W
; apex = record
{ ψ = λ X → K.ψ X ⟨$⟩ x
; commute = λ f → ⟺ (∘-resp-≈ʳ identityʳ) ○ K.commute f (Setoid.refl K.N)
}
}
! : Cones HomF [ K , ⊤ ]
! = record
{ arr = record
{ _⟨$⟩_ = λ x → rep (KW x)
; cong = λ {x y} eq → ψ-≈⇒rep-≈ F W (Cone.apex (KW x)) (Cone.apex (KW y)) lim
(λ A → cong (K.ψ A) eq)
}
; commute = λ {X} {x y} eq → begin
proj X ∘ rep (KW x) ∘ C.id ≈⟨ refl⟩∘⟨ C.identityʳ ⟩
proj X ∘ rep (KW x) ≈⟨ lim.commute ⟩
K.ψ X ⟨$⟩ x ≈⟨ cong (K.ψ X) eq ⟩
K.ψ X ⟨$⟩ y ∎
}
!-unique : ∀ {K : Cone HomF} (f : Cones HomF [ K , ⊤ ]) → Cones HomF [ ! K ≈ f ]
!-unique {K} f {x} {y} x≈y = begin
rep (KW K x) ≈⟨ terminal.!-unique f′ ⟩
f.arr ⟨$⟩ x ≈⟨ cong f.arr x≈y ⟩
f.arr ⟨$⟩ y ∎
where module K = Cone _ K
module f = Cone⇒ _ f
f′ : Cones F [ KW K x , limit ]
f′ = record
{ arr = f.arr ⟨$⟩ x
; commute = ⟺ (∘-resp-≈ʳ C.identityʳ) ○ f.commute (Setoid.refl K.N)
}
hom-resp-limit : Limit HomF
hom-resp-limit = record
{ terminal = record
{ ⊤ = ⊤
; ⊤-is-terminal = record
{ ! = ! _
; !-unique = !-unique
}
}
}
Hom-Continuous : ∀ X o′ ℓ′ e′ → Continuous o′ ℓ′ e′ Hom[ X ,-]
Hom-Continuous X _ _ _ L = terminal.⊤-is-terminal
where open Limit (hom-resp-limit X L)
| {
"alphanum_fraction": 0.513397642,
"avg_line_length": 27.99,
"ext": "agda",
"hexsha": "0fb807ccd7231ef28588997ec70dd2010d517e48",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Functor/Hom/Properties/Covariant.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Functor/Hom/Properties/Covariant.agda",
"max_line_length": 88,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Functor/Hom/Properties/Covariant.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 953,
"size": 2799
} |
module Issue947 where
A : Set₁
A = Set
where
B : Set₁
B = Set
module _ where
C : Set₁
C = Set
module M where
| {
"alphanum_fraction": 0.6302521008,
"avg_line_length": 7.9333333333,
"ext": "agda",
"hexsha": "80ab82387b3432b2ddbba8ca8d1ff1d48dd5c4b2",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue947.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Succeed/Issue947.agda",
"max_line_length": 21,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Succeed/Issue947.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 46,
"size": 119
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Module.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Displayed.Base
open import Cubical.Displayed.Auto
open import Cubical.Displayed.Record
open import Cubical.Displayed.Universe
open import Cubical.Reflection.RecordEquiv
open import Cubical.Algebra.Ring
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Group
open Iso
private
variable
ℓ ℓ' : Level
record IsLeftModule (R : Ring ℓ) {M : Type ℓ'}
(0m : M)
(_+_ : M → M → M)
(-_ : M → M)
(_⋆_ : ⟨ R ⟩ → M → M) : Type (ℓ-max ℓ ℓ') where
open RingStr (snd R) using (_·_; 1r) renaming (_+_ to _+r_)
field
+IsAbGroup : IsAbGroup 0m _+_ -_
⋆Assoc : (r s : ⟨ R ⟩) (x : M) → (r · s) ⋆ x ≡ r ⋆ (s ⋆ x)
⋆DistR+ : (r : ⟨ R ⟩) (x y : M) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y)
⋆DistL+ : (r s : ⟨ R ⟩) (x : M) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x)
⋆IdL : (x : M) → 1r ⋆ x ≡ x
open IsAbGroup +IsAbGroup public
renaming
( isSemigroup to +IsSemigroup
; isMonoid to +IsMonoid
; isGroup to +IsGroup
)
unquoteDecl IsLeftModuleIsoΣ = declareRecordIsoΣ IsLeftModuleIsoΣ (quote IsLeftModule)
record LeftModuleStr (R : Ring ℓ) (A : Type ℓ') : Type (ℓ-max ℓ ℓ') where
field
0m : A
_+_ : A → A → A
-_ : A → A
_⋆_ : ⟨ R ⟩ → A → A
isLeftModule : IsLeftModule R 0m _+_ -_ _⋆_
open IsLeftModule isLeftModule public
LeftModule : (R : Ring ℓ) → ∀ ℓ' → Type (ℓ-max ℓ (ℓ-suc ℓ'))
LeftModule R ℓ' = Σ[ A ∈ Type ℓ' ] LeftModuleStr R A
module _ {R : Ring ℓ} where
module _ (M : LeftModule R ℓ') where
LeftModule→AbGroup : AbGroup ℓ'
LeftModule→AbGroup .fst = M .fst
LeftModule→AbGroup .snd .AbGroupStr.0g = _
LeftModule→AbGroup .snd .AbGroupStr._+_ = _
LeftModule→AbGroup .snd .AbGroupStr.-_ = _
LeftModule→AbGroup .snd .AbGroupStr.isAbGroup =
IsLeftModule.+IsAbGroup (M .snd .LeftModuleStr.isLeftModule)
isSetLeftModule : (M : LeftModule R ℓ') → isSet ⟨ M ⟩
isSetLeftModule M = isSetAbGroup (LeftModule→AbGroup M)
open RingStr (snd R) using (1r) renaming (_+_ to _+r_; _·_ to _·s_)
module _ {M : Type ℓ'} {0m : M}
{_+_ : M → M → M} { -_ : M → M} {_⋆_ : ⟨ R ⟩ → M → M}
(isSet-M : isSet M)
(+Assoc : (x y z : M) → x + (y + z) ≡ (x + y) + z)
(+IdR : (x : M) → x + 0m ≡ x)
(+InvR : (x : M) → x + (- x) ≡ 0m)
(+Comm : (x y : M) → x + y ≡ y + x)
(⋆Assoc : (r s : ⟨ R ⟩) (x : M) → (r ·s s) ⋆ x ≡ r ⋆ (s ⋆ x))
(⋆DistR+ : (r : ⟨ R ⟩) (x y : M) → r ⋆ (x + y) ≡ (r ⋆ x) + (r ⋆ y))
(⋆DistL+ : (r s : ⟨ R ⟩) (x : M) → (r +r s) ⋆ x ≡ (r ⋆ x) + (s ⋆ x))
(⋆IdL : (x : M) → 1r ⋆ x ≡ x)
where
makeIsLeftModule : IsLeftModule R 0m _+_ -_ _⋆_
makeIsLeftModule .IsLeftModule.+IsAbGroup = makeIsAbGroup isSet-M +Assoc +IdR +InvR +Comm
makeIsLeftModule .IsLeftModule.⋆Assoc = ⋆Assoc
makeIsLeftModule .IsLeftModule.⋆DistR+ = ⋆DistR+
makeIsLeftModule .IsLeftModule.⋆DistL+ = ⋆DistL+
makeIsLeftModule .IsLeftModule.⋆IdL = ⋆IdL
record IsLeftModuleHom {R : Ring ℓ} {A B : Type ℓ'}
(M : LeftModuleStr R A) (f : A → B) (N : LeftModuleStr R B)
: Type (ℓ-max ℓ ℓ')
where
-- Shorter qualified names
private
module M = LeftModuleStr M
module N = LeftModuleStr N
field
pres0 : f M.0m ≡ N.0m
pres+ : (x y : A) → f (x M.+ y) ≡ f x N.+ f y
pres- : (x : A) → f (M.- x) ≡ N.- (f x)
pres⋆ : (r : ⟨ R ⟩) (y : A) → f (r M.⋆ y) ≡ r N.⋆ f y
LeftModuleHom : {R : Ring ℓ} (M N : LeftModule R ℓ') → Type (ℓ-max ℓ ℓ')
LeftModuleHom M N = Σ[ f ∈ (⟨ M ⟩ → ⟨ N ⟩) ] IsLeftModuleHom (M .snd) f (N .snd)
IsLeftModuleEquiv : {R : Ring ℓ} {A B : Type ℓ'}
(M : LeftModuleStr R A) (e : A ≃ B) (N : LeftModuleStr R B)
→ Type (ℓ-max ℓ ℓ')
IsLeftModuleEquiv M e N = IsLeftModuleHom M (e .fst) N
LeftModuleEquiv : {R : Ring ℓ} (M N : LeftModule R ℓ') → Type (ℓ-max ℓ ℓ')
LeftModuleEquiv M N = Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] IsLeftModuleEquiv (M .snd) e (N .snd)
isPropIsLeftModule : (R : Ring ℓ) {M : Type ℓ'}
(0m : M)
(_+_ : M → M → M)
(-_ : M → M)
(_⋆_ : ⟨ R ⟩ → M → M)
→ isProp (IsLeftModule R 0m _+_ -_ _⋆_)
isPropIsLeftModule R _ _ _ _ =
isOfHLevelRetractFromIso 1 IsLeftModuleIsoΣ
(isPropΣ (isPropIsAbGroup _ _ _)
(λ ab →
isProp× (isPropΠ3 λ _ _ _ → ab .is-set _ _)
(isProp× (isPropΠ3 λ _ _ _ → ab .is-set _ _)
(isProp× (isPropΠ3 λ _ _ _ → ab .is-set _ _)
(isPropΠ λ _ → ab .is-set _ _)))))
where
open IsAbGroup
𝒮ᴰ-LeftModule : (R : Ring ℓ) → DUARel (𝒮-Univ ℓ') (LeftModuleStr R) (ℓ-max ℓ ℓ')
𝒮ᴰ-LeftModule R =
𝒮ᴰ-Record (𝒮-Univ _) (IsLeftModuleEquiv {R = R})
(fields:
data[ 0m ∣ autoDUARel _ _ ∣ pres0 ]
data[ _+_ ∣ autoDUARel _ _ ∣ pres+ ]
data[ -_ ∣ autoDUARel _ _ ∣ pres- ]
data[ _⋆_ ∣ autoDUARel _ _ ∣ pres⋆ ]
prop[ isLeftModule ∣ (λ _ _ → isPropIsLeftModule _ _ _ _ _) ])
where
open LeftModuleStr
open IsLeftModuleHom
LeftModulePath : {R : Ring ℓ} (M N : LeftModule R ℓ') → (LeftModuleEquiv M N) ≃ (M ≡ N)
LeftModulePath {R = R} = ∫ (𝒮ᴰ-LeftModule R) .UARel.ua
| {
"alphanum_fraction": 0.5604933793,
"avg_line_length": 33.8220858896,
"ext": "agda",
"hexsha": "7eba63f89467f4db5ac804be6609d428acea056a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/Module/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/Module/Base.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/Module/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2301,
"size": 5513
} |
{-# OPTIONS --without-K --safe #-}
open import Level using (Level)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_)
open import Data.Nat using (ℕ; suc; zero)
open import Data.Empty using (⊥)
open import Data.Vec using (Vec)
renaming ([] to []ⱽ; _∷_ to _∷ⱽ_)
module FLA.Data.Vec+.Base where
private
variable
ℓ : Level
A : Set ℓ
n : ℕ
-- TODO: Can this be replaced with something like the List⁺ definition so that
-- the proofs from Vec can be transferred? This definition is convenient because
-- the size is correct (it is not n - 1).
data Vec⁺ (A : Set ℓ) : ℕ → Set ℓ where
[_] : A → Vec⁺ A 1
_∷_ : ∀ {n} (x : A) (xs : Vec⁺ A n) → Vec⁺ A (suc n)
infixr 5 _∷_
-- Want to prove that is it not possible to construct an empty vector
emptyVecImpossible : Vec⁺ A 0 → ⊥
emptyVecImpossible = λ ()
Vec⁺→Vec : Vec⁺ A n → Vec A n
Vec⁺→Vec [ v ] = v ∷ⱽ []ⱽ
Vec⁺→Vec (v ∷ vs⁺) = v ∷ⱽ Vec⁺→Vec vs⁺
Vec⁺→n≢0 : Vec⁺ A n → n ≢ 0
Vec⁺→n≢0 {ℓ} {A} {suc n} v = suc≢0
where
suc≢0 : {n : ℕ} → suc n ≢ 0
suc≢0 {zero} ()
suc≢0 {suc n} = λ ()
-- Closer maybe but still buggered
-- Vec→Vec⁺ : ∀ {ℓ} → {A : Set ℓ} {n : ℕ} → (n ≢ 0) → Vec A n → Vec⁺ A n
-- Vec→Vec⁺ {ℓ} {A} {0} p []ⱽ = ⊥-elim (p refl)
-- Vec→Vec⁺ {ℓ} {A} {1} p (x ∷ⱽ []ⱽ) = [ x ]
-- Vec→Vec⁺ {ℓ} {A} {suc n} p (x ∷ⱽ xs) = x ∷ (Vec→Vec⁺ {!!} xs)
| {
"alphanum_fraction": 0.5655677656,
"avg_line_length": 29.0425531915,
"ext": "agda",
"hexsha": "ee7b9bddcc276ff08b5650cf0f56d28d2c6b7cf2",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z",
"max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "turion/functional-linear-algebra",
"max_forks_repo_path": "src/FLA/Data/Vec+/Base.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "turion/functional-linear-algebra",
"max_issues_repo_path": "src/FLA/Data/Vec+/Base.agda",
"max_line_length": 80,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "turion/functional-linear-algebra",
"max_stars_repo_path": "src/FLA/Data/Vec+/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z",
"num_tokens": 593,
"size": 1365
} |
{-
This file contains:
- The inductive construction of James.
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.James.Inductive.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat
open import Cubical.HITs.SequentialColimit
private
variable
ℓ : Level
module _
(X∙@(X , x₀) : Pointed ℓ) where
-- The family 𝕁ames n is equivalence to Brunerie's J n
data 𝕁ames : ℕ → Type ℓ where
[] : 𝕁ames 0
_∷_ : {n : ℕ} → X → 𝕁ames n → 𝕁ames (1 + n)
incl : {n : ℕ} → 𝕁ames n → 𝕁ames (1 + n)
incl∷ : {n : ℕ} → (x : X)(xs : 𝕁ames n) → incl (x ∷ xs) ≡ x ∷ incl xs
unit : {n : ℕ} → (xs : 𝕁ames n) → incl xs ≡ x₀ ∷ xs
coh : {n : ℕ} → (xs : 𝕁ames n) → PathP (λ i → incl (unit xs i) ≡ x₀ ∷ incl xs) (unit (incl xs)) (incl∷ x₀ xs)
-- The direct system defined by 𝕁ames
open Sequence
𝕁amesSeq : Sequence ℓ
𝕁amesSeq .space = 𝕁ames
𝕁amesSeq .map = incl
-- The 𝕁ames∞ wanted is the direct colimit of 𝕁ames n
𝕁ames∞ : Type ℓ
𝕁ames∞ = Lim→ 𝕁amesSeq
| {
"alphanum_fraction": 0.6312554873,
"avg_line_length": 24.2340425532,
"ext": "agda",
"hexsha": "fafcd8c6305f0d36ee1bbb337493742e968e39d7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/HITs/James/Inductive/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/HITs/James/Inductive/Base.agda",
"max_line_length": 115,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/HITs/James/Inductive/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 453,
"size": 1139
} |
{-# OPTIONS --erased-cubical --safe #-}
module Note where
open import Data.Integer using (ℤ)
open import Data.Nat using (ℕ; _+_; _*_; ⌊_/2⌋)
open import Function using (_∘_)
open import Pitch using (Pitch; transposePitch)
open import Interval using (Upi; Opi; transposePitchInterval)
Duration : Set
Duration = ℕ
data Note : Set where
tone : Duration → Pitch → Note
rest : Duration → Note
noteDuration : Note → ℕ
noteDuration (tone d _) = d
noteDuration (rest d) = d
liftPitch : (Pitch → Pitch) → Note → Note
liftPitch f (tone d p) = tone d (f p)
liftPitch f (rest d) = rest d
transposeNote : ℤ → Note → Note
transposeNote = liftPitch ∘ transposePitch
transposeNoteInterval : Opi → Note → Note
transposeNoteInterval = liftPitch ∘ transposePitchInterval
-- rounds down
doubleSpeed : Note → Note
doubleSpeed (tone d p) = tone (⌊_/2⌋ d) p
doubleSpeed (rest d) = rest (⌊_/2⌋ d)
slowDown : ℕ → Note → Note
slowDown k (tone d p) = tone (d * k) p
slowDown k (rest d) = rest (d * k)
-- duration in 16th notes
-- assume duration of a 16th note is 1
16th 8th d8th qtr dqtr half whole : Duration
16th = 1
8th = 2
d8th = 3
qtr = 4
dqtr = 6
half = 8
dhalf = 12
whole = 16
dwhole = 24
| {
"alphanum_fraction": 0.6604688763,
"avg_line_length": 22.9074074074,
"ext": "agda",
"hexsha": "90a7be20ee039d7f87c0461e60370e9570b89e32",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z",
"max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/MusicTools",
"max_forks_repo_path": "agda/Note.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "halfaya/MusicTools",
"max_issues_repo_path": "agda/Note.agda",
"max_line_length": 65,
"max_stars_count": 28,
"max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/MusicTools",
"max_stars_repo_path": "agda/Note.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z",
"num_tokens": 420,
"size": 1237
} |
------------------------------------------------------------------------
-- A solution to a problem posed by Venanzio Capretta
------------------------------------------------------------------------
module VenanziosProblem where
open import Codata.Musical.Notation
open import Codata.Musical.Stream as Stream
using (Stream; _⋎_; evens; odds; _≈_)
open Stream.Stream; open Stream._≈_
open import Data.Nat
open import Relation.Binary
import Relation.Binary.PropositionalEquality as P
private
module S {A : Set} = Setoid (Stream.setoid A)
------------------------------------------------------------------------
-- Problem formulation
-- The problem concerns functions satisfying a certain equation:
rhs : {A : Set} → (Stream A → Stream A) → Stream A → Stream A
rhs φ s = s ⋎ φ (evens (φ s))
SatisfiesEquation : {A : Set} → (Stream A → Stream A) → Set
SatisfiesEquation φ = ∀ s → φ s ≈ rhs φ s
-- The statement of the problem:
Statement : Set₁
Statement = {A : Set} {φ₁ φ₂ : Stream A → Stream A} →
SatisfiesEquation φ₁ → SatisfiesEquation φ₂ →
∀ s → φ₁ s ≈ φ₂ s
------------------------------------------------------------------------
-- Solution
module Solution {A : Set} where
infixr 5 _∷_
infix 4 _∣_∣_≈P_ _∣_∣_≈W_
infix 3 _∎
infixr 2 _≈⟨_⟩_
-- Let us first define a small language of equality proofs.
--
-- m ∣ n ∣ xs ≈P ys means that xs and ys, which are streams
-- generated in chunks of size 1 + m, where the outer chunk has size
-- n, are equal.
mutual
-- Weak head normal forms of programs.
data _∣_∣_≈W_ : ℕ → ℕ → Stream A → Stream A → Set where
reset : ∀ {xs₁ xs₂ m} (xs₁≈xs₂ : ∞ (m ∣ suc m ∣ xs₁ ≈P xs₂)) →
m ∣ 0 ∣ xs₁ ≈W xs₂
_∷_ : ∀ x {xs₁ xs₂ m n} (xs₁≈xs₂ : m ∣ n ∣ ♭ xs₁ ≈W ♭ xs₂) →
m ∣ suc n ∣ x ∷ xs₁ ≈W x ∷ xs₂
-- Programs.
data _∣_∣_≈P_ : ℕ → ℕ → Stream A → Stream A → Set where
-- WHNFs are programs.
↑ : ∀ {m n xs₁ xs₂} (xs₁≈xs₂ : m ∣ n ∣ xs₁ ≈W xs₂) →
m ∣ n ∣ xs₁ ≈P xs₂
-- Various congruences.
_∷_ : ∀ x {xs₁ xs₂ m n} (xs₁≈xs₂ : m ∣ n ∣ ♭ xs₁ ≈P ♭ xs₂) →
m ∣ suc n ∣ x ∷ xs₁ ≈P x ∷ xs₂
_⋎-cong_ : ∀ {xs₁ xs₂ ys₁ ys₂}
(xs₁≈xs₂ : 1 ∣ 1 ∣ xs₁ ≈P xs₂)
(ys₁≈ys₂ : 0 ∣ 1 ∣ ys₁ ≈P ys₂) →
1 ∣ 2 ∣ xs₁ ⋎ ys₁ ≈P xs₂ ⋎ ys₂
evens-cong : ∀ {xs₁ xs₂}
(xs₁≈xs₂ : 1 ∣ 1 ∣ xs₁ ≈P xs₂) →
0 ∣ 1 ∣ evens xs₁ ≈P evens xs₂
odds-cong : ∀ {xs₁ xs₂}
(xs₁≈xs₂ : 1 ∣ 2 ∣ xs₁ ≈P xs₂) →
0 ∣ 1 ∣ odds xs₁ ≈P odds xs₂
-- Equational reasoning.
_≈⟨_⟩_ : ∀ xs₁ {xs₂ xs₃ m n}
(xs₁≈xs₂ : m ∣ n ∣ xs₁ ≈P xs₂)
(xs₂≈xs₃ : m ∣ n ∣ xs₂ ≈P xs₃) →
m ∣ n ∣ xs₁ ≈P xs₃
_∎ : ∀ {n m} xs → m ∣ n ∣ xs ≈P xs
-- If we have already produced 1 + n elements of the last chunk,
-- then it is safe to pretend that we have only produced n
-- elements.
shift : ∀ {n m xs₁ xs₂} (xs₁≈xs₂ : m ∣ suc n ∣ xs₁ ≈P xs₂) →
m ∣ n ∣ xs₁ ≈P xs₂
-- A variation of the statement we want to prove.
goal′ : ∀ {φ₁ φ₂ xs₁ xs₂}
(s₁ : SatisfiesEquation φ₁)
(s₂ : SatisfiesEquation φ₂)
(xs₁≈xs₂ : 0 ∣ 1 ∣ xs₁ ≈P xs₂) →
1 ∣ 1 ∣ rhs φ₁ xs₁ ≈P rhs φ₂ xs₂
-- The equality language is complete.
completeW : ∀ {n m xs ys} → xs ≈ ys → m ∣ n ∣ xs ≈W ys
completeW {zero} xs≈ys = reset (♯ ↑ (completeW xs≈ys))
completeW {suc n} (P.refl ∷ xs≈ys) = _ ∷ completeW (♭ xs≈ys)
-- If we can prove that the equality language is sound, then the
-- following lemma implies the intended result.
goal : ∀ {φ₁ φ₂ xs₁ xs₂}
(s₁ : SatisfiesEquation φ₁) (s₂ : SatisfiesEquation φ₂) →
0 ∣ 1 ∣ xs₁ ≈P xs₂ → 1 ∣ 1 ∣ φ₁ xs₁ ≈P φ₂ xs₂
goal {φ₁} {φ₂} {xs₁} {xs₂} s₁ s₂ xs₁≈xs₂ =
φ₁ xs₁ ≈⟨ ↑ (completeW (s₁ xs₁)) ⟩
rhs φ₁ xs₁ ≈⟨ goal′ s₁ s₂ xs₁≈xs₂ ⟩
rhs φ₂ xs₂ ≈⟨ ↑ (completeW (S.sym (s₂ xs₂))) ⟩
φ₂ xs₂ ∎
-- Some lemmas about weak head normal forms.
evens-congW : {xs₁ xs₂ : Stream A} →
1 ∣ 1 ∣ xs₁ ≈W xs₂ → 0 ∣ 1 ∣ evens xs₁ ≈W evens xs₂
evens-congW (x ∷ reset xs₁≈xs₂) =
x ∷ reset (♯ odds-cong (♭ xs₁≈xs₂))
reflW : ∀ xs {m} n → m ∣ n ∣ xs ≈W xs
reflW xs zero = reset (♯ (xs ∎))
reflW (x ∷ xs) (suc n) = x ∷ reflW (♭ xs) n
transW : ∀ {xs ys zs m n} →
m ∣ n ∣ xs ≈W ys → m ∣ n ∣ ys ≈W zs → m ∣ n ∣ xs ≈W zs
transW (x ∷ xs≈ys) (.x ∷ ys≈zs) = x ∷ transW xs≈ys ys≈zs
transW (reset xs≈ys) (reset ys≈zs) =
reset (♯ (_ ≈⟨ ♭ xs≈ys ⟩ ♭ ys≈zs))
shiftW : ∀ n {m xs₁ xs₂} →
m ∣ suc n ∣ xs₁ ≈W xs₂ → m ∣ n ∣ xs₁ ≈W xs₂
shiftW zero (x ∷ reset xs₁≈xs₂) = reset (♯ (x ∷ shift (♭ xs₁≈xs₂)))
shiftW (suc n) (x ∷ xs₁≈xs₂) = x ∷ shiftW n xs₁≈xs₂
-- Every program can be transformed into WHNF.
whnf : ∀ {xs ys m n} → m ∣ n ∣ xs ≈P ys → m ∣ n ∣ xs ≈W ys
whnf (↑ xs≈ys) = xs≈ys
whnf (x ∷ xs₁≈xs₂) = x ∷ whnf xs₁≈xs₂
whnf (xs₁≈xs₂ ⋎-cong ys₁≈ys₂) with whnf xs₁≈xs₂ | whnf ys₁≈ys₂
... | x ∷ reset xs₁≈xs₂′ | y ∷ reset ys₁≈ys₂′ =
x ∷ y ∷ reset (♯ (shift (♭ xs₁≈xs₂′) ⋎-cong ♭ ys₁≈ys₂′))
whnf (evens-cong xs₁≈xs₂) = evens-congW (whnf xs₁≈xs₂)
whnf (odds-cong xs₁≈xs₂) with whnf xs₁≈xs₂
... | x ∷ xs₁≈xs₂′ = evens-congW xs₁≈xs₂′
whnf (xs₁ ≈⟨ xs₁≈xs₂ ⟩ xs₂≈xs₃) = transW (whnf xs₁≈xs₂) (whnf xs₂≈xs₃)
whnf (xs ∎) = reflW xs _
whnf (shift xs₁≈xs₂) = shiftW _ (whnf xs₁≈xs₂)
whnf (goal′ s₁ s₂ xs₁≈xs₂) with whnf xs₁≈xs₂
... | (x ∷ reset xs₁≈xs₂′) =
x ∷ reset (♯ (goal s₁ s₂ (evens-cong (goal s₁ s₂ xs₁≈xs₂))
⋎-cong
♭ xs₁≈xs₂′))
-- Soundness follows by a corecursive repetition of the whnf
-- procedure.
⟦_⟧W : ∀ {xs ys m n} → m ∣ n ∣ xs ≈W ys → xs ≈ ys
⟦ reset ys≈zs ⟧W with whnf (♭ ys≈zs)
... | x ∷ ys≈zs′ = P.refl ∷ ♯ ⟦ ys≈zs′ ⟧W
⟦ x ∷ ys≈zs ⟧W = P.refl ∷ ♯ ⟦ ys≈zs ⟧W
⟦_⟧P : ∀ {xs ys m n} → m ∣ n ∣ xs ≈P ys → xs ≈ ys
⟦ xs≈ys ⟧P = ⟦ whnf xs≈ys ⟧W
-- Wrapping up.
solution : Statement
solution s₁ s₂ s = ⟦ goal s₁ s₂ (s ∎) ⟧P
where open Solution
| {
"alphanum_fraction": 0.4902736043,
"avg_line_length": 33.8128342246,
"ext": "agda",
"hexsha": "73392a83b9e40892770cf89adc9208c0057a781e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "VenanziosProblem.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/codata",
"max_issues_repo_path": "VenanziosProblem.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "VenanziosProblem.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 2705,
"size": 6323
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import groups.KernelImage
module groups.KernelImageEmap where
module _ {i₀ i₁ j₀ j₁ k₀ k₁}
{G₀ : Group i₀} {H₀ : Group j₀} {K₀ : Group k₀}
{G₁ : Group i₁} {H₁ : Group j₁} {K₁ : Group k₁}
{ψ₀ : H₀ →ᴳ K₀} {φ₀ : G₀ →ᴳ H₀} (H₀-ab : is-abelian H₀)
{ψ₁ : H₁ →ᴳ K₁} {φ₁ : G₁ →ᴳ H₁} (H₁-ab : is-abelian H₁)
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {ξK : K₀ →ᴳ K₁}
(ψ₀∼ψ₁ : CommSquareᴳ ψ₀ ψ₁ ξH ξK)
(φ₀∼φ₁ : CommSquareᴳ φ₀ φ₁ ξG ξH)
where
module ξG = GroupHom ξG
module ξH = GroupHom ξH
module ξK = GroupHom ξK
module ψ₀ = GroupHom ψ₀
module ψ₁ = GroupHom ψ₁
module φ₀ = GroupHom φ₀
module φ₁ = GroupHom φ₁
private
f : Ker/Im.El ψ₀ φ₀ H₀-ab → Ker/Im.El ψ₁ φ₁ H₁-ab
f = SetQuot-rec to pres-rel
where
abstract
ξh-in-Ker : ∀ h (ψ₀h=0 : ψ₀.f h == Group.ident K₀)
→ ψ₁.f (ξH.f h) == Group.ident K₁
ξh-in-Ker h ψ₀h=0 = (! $ ψ₀∼ψ₁ □$ᴳ h) ∙ ap ξK.f ψ₀h=0 ∙ ξK.pres-ident
to : Ker.El ψ₀ → Ker/Im.El ψ₁ φ₁ H₁-ab
to (h , ψ₀h=0) = q[ ξH.f h , ξh-in-Ker h ψ₀h=0 ]
abstract
pres-rel : ∀ {h h'}
→ ker/im-rel ψ₀ φ₀ H₀-ab h h'
→ to h == to h'
pres-rel {(h , _)} {(h' , _)} = Trunc-rec
λ{(g , φg=h-h') → quot-rel
[ ξG.f g , (! $ φ₀∼φ₁ □$ᴳ g) ∙ ap ξH.f φg=h-h' ∙ ξH.pres-diff h h' ]}
abstract
f-is-hom : preserves-comp (Ker/Im.comp ψ₀ φ₀ H₀-ab) (Ker/Im.comp ψ₁ φ₁ H₁-ab) f
f-is-hom = SetQuot-elim
(λ{(h , _) → SetQuot-elim
(λ{(h' , _) → ap q[_] (Ker.El=-out ψ₁ (ξH.pres-comp h h'))})
(λ _ → prop-has-all-paths-↓)})
(λ _ → prop-has-all-paths-↓)
Ker/Im-fmap : Ker/Im ψ₀ φ₀ H₀-ab →ᴳ Ker/Im ψ₁ φ₁ H₁-ab
Ker/Im-fmap = group-hom f f-is-hom
module _ {i₀ i₁ j₀ j₁ k₀ k₁}
{G₀ : Group i₀} {H₀ : Group j₀} {K₀ : Group k₀}
{G₁ : Group i₁} {H₁ : Group j₁} {K₁ : Group k₁}
{ψ₀ : H₀ →ᴳ K₀} {φ₀ : G₀ →ᴳ H₀} (H₀-ab : is-abelian H₀)
{ψ₁ : H₁ →ᴳ K₁} {φ₁ : G₁ →ᴳ H₁} (H₁-ab : is-abelian H₁)
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {ξK : K₀ →ᴳ K₁}
(ψ₀∼ψ₁ : CommSquareᴳ ψ₀ ψ₁ ξH ξK)
(φ₀∼φ₁ : CommSquareᴳ φ₀ φ₁ ξG ξH)
(ξG-ise : is-equiv (GroupHom.f ξG))
(ξH-ise : is-equiv (GroupHom.f ξH))
(ξK-ise : is-equiv (GroupHom.f ξK))
where
private
to : Ker/Im.El ψ₀ φ₀ H₀-ab → Ker/Im.El ψ₁ φ₁ H₁-ab
to = GroupHom.f (Ker/Im-fmap H₀-ab H₁-ab ψ₀∼ψ₁ φ₀∼φ₁)
from : Ker/Im.El ψ₁ φ₁ H₁-ab → Ker/Im.El ψ₀ φ₀ H₀-ab
from = GroupHom.f (Ker/Im-fmap H₁-ab H₀-ab (CommSquareᴳ-inverse-v ψ₀∼ψ₁ ξH-ise ξK-ise) (CommSquareᴳ-inverse-v φ₀∼φ₁ ξG-ise ξH-ise))
abstract
to-from : ∀ x → to (from x) == x
to-from = SetQuot-elim
{{=-preserves-level ⟨⟩}}
(λ{(h , _) → ap q[_] $ Ker.El=-out ψ₁ $ is-equiv.f-g ξH-ise h})
(λ {h} {h'} _ → prop-has-all-paths-↓ {{has-level-apply SetQuot-is-set (to (from q[ h' ])) q[ h' ]}})
from-to : ∀ x → from (to x) == x
from-to = SetQuot-elim
{{=-preserves-level ⟨⟩}}
(λ{(h , _) → ap q[_] $ Ker.El=-out ψ₀ $ is-equiv.g-f ξH-ise h})
(λ {h} {h'} _ → prop-has-all-paths-↓ {{has-level-apply SetQuot-is-set (from (to q[ h' ])) q[ h' ]}})
Ker/Im-emap : Ker/Im ψ₀ φ₀ H₀-ab ≃ᴳ Ker/Im ψ₁ φ₁ H₁-ab
Ker/Im-emap = Ker/Im-fmap H₀-ab H₁-ab ψ₀∼ψ₁ φ₀∼φ₁ ,
is-eq to from to-from from-to
| {
"alphanum_fraction": 0.535426009,
"avg_line_length": 35.9677419355,
"ext": "agda",
"hexsha": "be5aed9548777c351a19aa777b0a5c17d2d5fdf1",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/groups/KernelImageEmap.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/groups/KernelImageEmap.agda",
"max_line_length": 135,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/groups/KernelImageEmap.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 1634,
"size": 3345
} |
module WErrorOverride where
postulate
IO : Set → Set
{-# COMPILED_TYPE IO IO #-}
{-# BUILTIN IO IO #-}
infixl 1 _>>=_
postulate
return : {A : Set} → A → IO A
_>>=_ : {A : Set} {B : Set} → IO A → (A → IO B) → IO B
{-# COMPILED return (\_ -> return) #-}
{-# COMPILED _>>=_ (\_ _ -> (>>=)) #-}
------------------------------------------------------------------------
-- An error should be raised if one tries to do something like this:
data PartialBool : Set where
true : PartialBool
{-# COMPILED_DATA PartialBool Bool True #-}
-- However one can override such behaviour by passing the flag
-- --ghc-flag=-Wwarn to Agda upon compilation.
main = return true
| {
"alphanum_fraction": 0.5508100147,
"avg_line_length": 21.21875,
"ext": "agda",
"hexsha": "9255cbf07c664863055d2822e797005a77e6daf8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/WErrorOverride.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/WErrorOverride.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/WErrorOverride.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 186,
"size": 679
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.Vec.Relation.Unary.All.Properties directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Vec.All.Properties where
open import Data.Vec.Relation.Unary.All.Properties public
| {
"alphanum_fraction": 0.4777227723,
"avg_line_length": 31.0769230769,
"ext": "agda",
"hexsha": "41016caf5a662e986166cce8b41908617ff86398",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/All/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/All/Properties.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/All/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 63,
"size": 404
} |
{-# OPTIONS --prop --rewriting #-}
module Examples where
-- Sequential
import Examples.Id
import Examples.Gcd
import Examples.Queue
-- Parallel
import Examples.TreeSum
import Examples.Exp2
-- Hybrid
import Examples.Sorting
| {
"alphanum_fraction": 0.7709251101,
"avg_line_length": 14.1875,
"ext": "agda",
"hexsha": "c78d0ad387191768e768f7ae77c7e2be35f4d4c7",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z",
"max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "jonsterling/agda-calf",
"max_forks_repo_path": "src/Examples.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "jonsterling/agda-calf",
"max_issues_repo_path": "src/Examples.agda",
"max_line_length": 34,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "jonsterling/agda-calf",
"max_stars_repo_path": "src/Examples.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z",
"num_tokens": 49,
"size": 227
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
import homotopy.ConstantToSetExtendsToProp as ConstExt
open import homotopy.RibbonCover
module homotopy.GroupSetsRepresentCovers {i} (X : Ptd i)
{{_ : is-connected 0 (de⊙ X)}} where
open Cover
private
A : Type i
A = de⊙ X
a₁ : A
a₁ = pt X
-- A covering space constructed from a G-set.
grpset-to-cover : ∀ {j} → GroupSet (πS 0 X) j → Cover A (lmax i j)
grpset-to-cover gs = Ribbon-cover X gs
-- Covering spaces to G-sets.
cover-to-grpset-struct : ∀ {j} (cov : Cover A j)
→ GroupSetStructure (πS 0 X) (Fiber cov a₁)
cover-to-grpset-struct cov = record
{ act = cover-trace cov
; unit-r = cover-trace-idp₀ cov
; assoc = cover-paste cov
}
cover-to-grpset : ∀ {j} → Cover A j → GroupSet (πS 0 X) j
cover-to-grpset cov = record
{ El = Fiber cov a₁
; grpset-struct = cover-to-grpset-struct cov
}
-- This is derivable from connectedness condition.
module _ where
abstract
[base-path] : ∀ {a₂ : A} → Trunc -1 (a₁ == a₂)
[base-path] {a₂} =
–> (Trunc=-equiv [ a₁ ] [ a₂ ]) (contr-has-all-paths [ a₁ ] [ a₂ ])
-- Part 1: Show that the synthesized cover (ribbon) is fiberwisely
-- equivalent to the original fiber.
private
module _ {j} (cov : Cover A j) where
-- Suppose that we get the path, we can compute the ribbon easily.
fiber+path-to-ribbon : ∀ {a₂} (a↑ : Fiber cov a₂) (p : a₁ == a₂)
→ Ribbon X (cover-to-grpset cov) a₂
fiber+path-to-ribbon {a₂} a↑ p =
trace (cover-trace cov a↑ [ ! p ]) [ p ]
abstract
-- Our construction is "constant" with respect to paths.
fiber+path-to-ribbon-is-path-irrelevant :
∀ {a₂} (a↑ : Fiber cov a₂) (p₁ p₂ : a₁ == a₂)
→ fiber+path-to-ribbon a↑ p₁ == fiber+path-to-ribbon a↑ p₂
fiber+path-to-ribbon-is-path-irrelevant a↑ p idp =
trace (cover-trace cov a↑ [ ! p ]) [ p ]
=⟨ paste a↑ [ ! p ] [ p ] ⟩
trace a↑ [ ! p ∙ p ]
=⟨ !₀-inv-l [ p ] |in-ctx trace a↑ ⟩
trace a↑ idp₀
∎
module FiberAndPathToRibbon {a₂} (a↑ : Fiber cov a₂)
= ConstExt
(fiber+path-to-ribbon a↑)
(fiber+path-to-ribbon-is-path-irrelevant a↑)
fiber+path₋₁-to-ribbon : ∀ {a₂} (a↑ : Cover.Fiber cov a₂)
→ Trunc -1 (a₁ == a₂) → Ribbon X (cover-to-grpset cov) a₂
fiber+path₋₁-to-ribbon a↑ = FiberAndPathToRibbon.ext a↑
-- So the conversion from fiber to ribbon is done.
fiber-to-ribbon : ∀ {j} (cov : Cover A j)
→ {a₂ : A} (a↑ : Cover.Fiber cov a₂)
→ Ribbon X (cover-to-grpset cov) a₂
fiber-to-ribbon cov a↑ = fiber+path₋₁-to-ribbon cov a↑ [base-path]
-- The other direction is easy.
ribbon-to-fiber : ∀ {j} (cov : Cover A j) {a₂}
→ Ribbon X (cover-to-grpset cov) a₂ → Cover.Fiber cov a₂
ribbon-to-fiber cov {a₂} r =
Ribbon-rec (cover-trace cov) (cover-paste cov) r
private
-- Some routine computations.
abstract
ribbon-to-fiber-to-ribbon : ∀ {j} (cov : Cover A j) {a₂}
→ (r : Ribbon X (cover-to-grpset cov) a₂)
→ fiber-to-ribbon cov (ribbon-to-fiber cov r) == r
ribbon-to-fiber-to-ribbon cov {a₂} = Ribbon-elim
{P = λ r → fiber-to-ribbon cov (ribbon-to-fiber cov r) == r}
(λ a↑ p → Trunc-elim
-- All ugly things will go away when bp = proj bp′
{{λ bp → has-level-apply Ribbon-is-set
(fiber+path₋₁-to-ribbon cov (cover-trace cov a↑ p) bp)
(trace a↑ p)}}
(lemma a↑ p)
[base-path])
(λ _ _ _ → prop-has-all-paths-↓)
where
abstract
lemma : ∀ {a₂} (a↑ : Cover.Fiber cov a₁) (p : a₁ =₀ a₂) (bp : a₁ == a₂)
→ trace {X = X} {gs = cover-to-grpset cov}
(cover-trace cov (cover-trace cov a↑ p) [ ! bp ]) [ bp ]
== trace {X = X} {gs = cover-to-grpset cov} a↑ p
lemma a↑ p idp =
trace (cover-trace cov a↑ p) idp₀
=⟨ paste a↑ p idp₀ ⟩
trace a↑ (p ∙₀ idp₀)
=⟨ ap (trace a↑) $ ∙₀-unit-r p ⟩
trace a↑ p
∎
fiber-to-ribbon-to-fiber : ∀ {j} (cov : Cover A j) {a₂}
→ (a↑ : Cover.Fiber cov a₂)
→ ribbon-to-fiber cov (fiber-to-ribbon cov {a₂} a↑) == a↑
fiber-to-ribbon-to-fiber cov {a₂} a↑ = Trunc-elim
-- All ugly things will go away when bp = proj bp′
{{λ bp → has-level-apply (Cover.Fiber-is-set cov)
(ribbon-to-fiber cov
(fiber+path₋₁-to-ribbon cov a↑ bp))
a↑}}
(lemma a↑)
[base-path]
where
abstract
lemma : ∀ {a₂} (a↑ : Cover.Fiber cov a₂) (bp : a₁ == a₂)
→ cover-trace cov (cover-trace cov a↑ [ ! bp ]) [ bp ]
== a↑
lemma a↑ idp = idp
cover-to-grpset-to-cover : ∀ {j} (cov : Cover A (lmax i j))
→ grpset-to-cover (cover-to-grpset cov) == cov
cover-to-grpset-to-cover cov = cover= λ _ →
ribbon-to-fiber cov , is-eq
(ribbon-to-fiber cov)
(fiber-to-ribbon cov)
(fiber-to-ribbon-to-fiber cov)
(ribbon-to-fiber-to-ribbon cov)
-- The second direction : grpset -> covering -> grpset
-- Part 2.1: The fiber over the point a is the carrier.
ribbon-a₁-to-El : ∀ {j} {gs : GroupSet (πS 0 X) j}
→ Ribbon X gs a₁ → GroupSet.El gs
ribbon-a₁-to-El {j} {gs} = let open GroupSet gs in
Ribbon-rec act assoc
ribbon-a₁-to-El-equiv : ∀ {j} {gs : GroupSet (πS 0 X) j}
→ Ribbon X gs a₁ ≃ GroupSet.El gs
ribbon-a₁-to-El-equiv {j} {gs} = let open GroupSet gs in
ribbon-a₁-to-El , is-eq _
(λ r → trace r idp₀)
(λ a↑ → unit-r a↑)
(Ribbon-elim
{P = λ r → trace (ribbon-a₁-to-El r) idp₀ == r}
(λ y p →
trace (act y p) idp₀
=⟨ paste y p idp₀ ⟩
trace y (p ∙₀ idp₀)
=⟨ ap (trace y) $ ∙₀-unit-r p ⟩
trace y p
∎)
(λ _ _ _ → prop-has-all-paths-↓))
grpset-to-cover-to-grpset : ∀ {j} (gs : GroupSet (πS 0 X) (lmax i j))
→ cover-to-grpset (grpset-to-cover gs) == gs
grpset-to-cover-to-grpset gs =
groupset=
ribbon-a₁-to-El-equiv
(λ {x₁}{x₂} x= → Trunc-elim λ g →
ribbon-a₁-to-El (transport (Ribbon X gs) g x₁)
=⟨ ap (λ x → ribbon-a₁-to-El (transport (Ribbon X gs) g x))
$ ! $ <–-inv-l ribbon-a₁-to-El-equiv x₁ ⟩
ribbon-a₁-to-El (transport (Ribbon X gs) g (trace (ribbon-a₁-to-El x₁) idp₀))
=⟨ ap (λ x → ribbon-a₁-to-El (transport (Ribbon X gs) g (trace x idp₀))) x= ⟩
ribbon-a₁-to-El (transport (Ribbon X gs) g (trace x₂ idp₀))
=⟨ ap ribbon-a₁-to-El $ transp-trace g x₂ idp₀ ⟩
GroupSet.act gs x₂ [ g ]
∎)
-- Finally...
grpset-equiv-cover : ∀ {j}
→ GroupSet (πS 0 X) (lmax i j) ≃ Cover A (lmax i j)
grpset-equiv-cover {j} =
grpset-to-cover , is-eq
_
(λ c → cover-to-grpset c)
(λ c → cover-to-grpset-to-cover {lmax i j} c)
(grpset-to-cover-to-grpset {lmax i j})
-- The path-set cover is represented by the fundamental group itself
path-set-repr-by-π1 : cover-to-grpset (path-set-cover X)
== group-to-group-set (πS 0 X)
path-set-repr-by-π1 = groupset= (ide _)
(λ {x₁} p g → (transp₀-cst=₀idf g x₁ ∙ ∙₀'=∙₀ x₁ g) ∙' ap (_∙₀ g) p)
| {
"alphanum_fraction": 0.5399326599,
"avg_line_length": 36.7574257426,
"ext": "agda",
"hexsha": "1a3a529da175482e23887e8a99faaacc992689e8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/GroupSetsRepresentCovers.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/GroupSetsRepresentCovers.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/GroupSetsRepresentCovers.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2564,
"size": 7425
} |
{-# OPTIONS --sized-types #-}
open import Relation.Binary.Core
module Quicksort.Correctness.Order {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_)
(trans≤ : Transitive _≤_) where
open import Data.List
open import Function using (_∘_)
open import List.Sorted _≤_
open import Quicksort _≤_ tot≤
open import SBList _≤_
open import Size
open import SOList.Total _≤_
open import SOList.Total.Properties _≤_ trans≤
theorem-quickSort-sorted : (xs : List A) → Sorted (forget (quickSort (bound xs)))
theorem-quickSort-sorted = lemma-solist-sorted ∘ quickSort ∘ bound
| {
"alphanum_fraction": 0.6672077922,
"avg_line_length": 30.8,
"ext": "agda",
"hexsha": "42cfa525b7173a288cab7ed85298efae71ace757",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/Quicksort/Correctness/Order.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/Quicksort/Correctness/Order.agda",
"max_line_length": 81,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/Quicksort/Correctness/Order.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 178,
"size": 616
} |
------------------------------------------------------------------------
-- Adjunctions and monads (for 1-categories)
------------------------------------------------------------------------
-- The code is based on the presentation in the HoTT book (but might
-- not follow it exactly).
{-# OPTIONS --without-K --safe #-}
open import Equality
module Adjunction
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Prelude hiding (id)
open import Category eq
open Derived-definitions-and-properties eq
open import Functor eq
------------------------------------------------------------------------
-- Adjunctions
private
-- Is-left-adjoint-of ext F G means that F is a left adjoint of G.
-- This definition tries to follow the HoTT book closely.
Is-left-adjoint-of :
∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂}
{ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} →
Extensionality (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) →
C ⇨ D → D ⇨ C → Type _
Is-left-adjoint-of {ℓ₁} {ℓ₂} {C} {ℓ₃} {ℓ₄} {D} ext F G =
∃ λ (η : id⇨ ⇾ G ∙⇨ F) →
∃ λ (ε : F ∙⇨ G ⇾ id⇨) →
subst ((F ∙⇨ G) ∙⇨ F ⇾_) (id⇨∙⇨ ext₁) (ε ⇾∙⇨ F) ∙⇾
subst (_⇾ (F ∙⇨ G) ∙⇨ F) (∙⇨id⇨ ext₁)
(subst (F ∙⇨ id⇨ ⇾_) (∙⇨-assoc ext₁ F G) (F ⇨∙⇾ η))
≡
id⇾ F
×
subst (G ∙⇨ F ∙⇨ G ⇾_) (∙⇨id⇨ ext₂) (G ⇨∙⇾ ε) ∙⇾
subst (_⇾ G ∙⇨ F ∙⇨ G) (id⇨∙⇨ ext₂)
(subst (id⇨ ∙⇨ G ⇾_) (sym $ ∙⇨-assoc ext₂ G F) (η ⇾∙⇨ G))
≡
id⇾ G
where
ext₁ : Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄)
ext₁ = lower-extensionality (ℓ₃ ⊔ ℓ₄) ℓ₃ ext
ext₂ : Extensionality (ℓ₃ ⊔ ℓ₄) (ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄)
ext₂ = lower-extensionality (ℓ₁ ⊔ ℓ₂) ℓ₁ ext
-- F ⊣ G means that F is a left adjoint of G.
--
-- This definition avoids the use of subst in the previous definition
-- by making use of the equality characterisation for natural
-- transformations (equality-characterisation⇾). I (NAD) took the idea
-- for this definition from the HoTT-Agda library
-- (https://github.com/HoTT/HoTT-Agda/blob/2871c6f6dbe90b47b3b2770e57abc4732cd1c295/theorems/homotopy/PtdAdjoint.agda).
--
-- TODO: Prove that the two definitions are equivalent.
_⊣_ :
∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂}
{ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} →
C ⇨ D → D ⇨ C → Type _
_⊣_ {ℓ₁} {ℓ₂} {C} {ℓ₃} {ℓ₄} {D} F G =
∃ λ (η : id⇨ ⇾ G ∙⇨ F) →
∃ λ (ε : F ∙⇨ G ⇾ id⇨) →
(∀ {X} → transformation ε D.∙ (F ⊙ transformation η {X = X}) ≡ D.id)
×
(∀ {X} → (G ⊙ transformation ε {X = X}) C.∙ transformation η ≡ C.id)
where
open _⇾_
module C = Precategory C
module D = Precategory D
-- Adjunctions.
Adjunction :
∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} →
Precategory ℓ₁ ℓ₂ → Precategory ℓ₃ ℓ₄ → Type _
Adjunction C D = ∃ λ (F : C ⇨ D) → ∃ λ (G : D ⇨ C) → F ⊣ G
------------------------------------------------------------------------
-- Monads
-- A monad on a precategory.
--
-- This definition is taken from Wikipedia
-- (https://en.wikipedia.org/wiki/Monad_%28category_theory%29).
Monad : ∀ {ℓ₁ ℓ₂} (C : Precategory ℓ₁ ℓ₂) → Type (ℓ₁ ⊔ ℓ₂)
Monad C =
∃ λ (F : C ⇨ C) →
∃ λ (η : id⇨ ⇾ F) →
∃ λ (μ : F ∙⇨ F ⇾ F) →
(∀ {X} → transformation μ ∙ (F ⊙ transformation μ {X = X})
≡
transformation μ ∙ transformation μ {X = F ⊚ X})
×
(∀ {X} → transformation μ ∙ (F ⊙ transformation η {X = X}) ≡ id)
×
(∀ {X} → transformation μ ∙ transformation η {X = F ⊚ X} ≡ id)
where
open _⇾_
open Precategory C
-- Adjunctions give rise to monads.
--
-- This definition is taken from Wikipedia
-- (https://en.wikipedia.org/wiki/Monad_%28category_theory%29).
adjunction→monad :
∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂}
{ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} →
Adjunction C D → Monad C
adjunction→monad {C = C} {D = D} (F , G , η , ε , εFFη≡1 , GεηG≡1) =
G ∙⇨ F
, η
, GεF
, lemma₁
, lemma₂
, lemma₃
where
open _⇾_
module C = Precategory C
module D = Precategory D
-- This natural transformation is defined directly, rather than by
-- using composition, to avoid the use of casts.
GεF : (G ∙⇨ F) ∙⇨ (G ∙⇨ F) ⇾ G ∙⇨ F
natural-transformation GεF =
G ⊙ transformation ε
, nat
where
abstract
nat :
∀ {X Y} {f : C.Hom X Y} →
((G ∙⇨ F) ⊙ f) C.∙ (G ⊙ transformation ε) ≡
(G ⊙ transformation ε) C.∙ (((G ∙⇨ F) ∙⇨ (G ∙⇨ F)) ⊙ f)
nat {f = f} =
((G ∙⇨ F) ⊙ f) C.∙ (G ⊙ transformation ε) ≡⟨⟩
(G ⊙ F ⊙ f) C.∙ (G ⊙ transformation ε) ≡⟨ sym (⊙-∙ G) ⟩
G ⊙ ((F ⊙ f) D.∙ transformation ε) ≡⟨ cong (G ⊙_) (natural ε) ⟩
G ⊙ (transformation ε D.∙ (F ⊙ G ⊙ F ⊙ f)) ≡⟨ ⊙-∙ G ⟩
(G ⊙ transformation ε) C.∙ (G ⊙ F ⊙ G ⊙ F ⊙ f) ≡⟨⟩
(G ⊙ transformation ε) C.∙ (((G ∙⇨ F) ∙⇨ (G ∙⇨ F)) ⊙ f) ∎
abstract
lemma₁ :
∀ {X} →
transformation GεF {X = X} C.∙ ((G ∙⇨ F) ⊙ transformation GεF) ≡
transformation GεF C.∙ transformation GεF
lemma₁ =
(G ⊙ transformation ε) C.∙ (G ⊙ F ⊙ G ⊙ transformation ε) ≡⟨ sym (⊙-∙ G) ⟩
G ⊙ (transformation ε D.∙ (F ⊙ G ⊙ transformation ε)) ≡⟨ cong (G ⊙_) (sym $ natural ε) ⟩
G ⊙ (transformation ε D.∙ transformation ε) ≡⟨ ⊙-∙ G ⟩∎
(G ⊙ transformation ε) C.∙ (G ⊙ transformation ε) ∎
lemma₂ :
∀ {X} →
transformation GεF {X = X} C.∙ ((G ∙⇨ F) ⊙ transformation η) ≡
C.id
lemma₂ =
(G ⊙ transformation ε) C.∙ (G ⊙ F ⊙ transformation η) ≡⟨ sym (⊙-∙ G) ⟩
G ⊙ (transformation ε D.∙ (F ⊙ transformation η)) ≡⟨ cong (G ⊙_) εFFη≡1 ⟩
G ⊙ D.id ≡⟨ ⊙-id G ⟩∎
C.id ∎
lemma₃ :
∀ {X} →
transformation GεF {X = X} C.∙ transformation η ≡ C.id
lemma₃ =
(G ⊙ transformation ε) C.∙ transformation η ≡⟨ GεηG≡1 ⟩∎
C.id ∎
| {
"alphanum_fraction": 0.4922920549,
"avg_line_length": 32.6132596685,
"ext": "agda",
"hexsha": "088e9296c93aa4a99879f4021c81e487c3e2bc17",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Adjunction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Adjunction.agda",
"max_line_length": 119,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Adjunction.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 2516,
"size": 5903
} |
open import Common.Equality
data Bool : Set where
true false : Bool
data IsTrue : Bool → Set where
itis : IsTrue true
module M (u : Bool) where
foo bar : (p : IsTrue u) → Bool
foo = \ { itis → true }
bar = \ { itis → false }
test : ∀ u → M.foo u ≡ M.bar u
test u = refl
-- Trigger printing of the extended lambdas.
-- Ideally, this would not show the internal names, like in
--
-- .Issue2047a.M..extendedlambda0 u p !=
-- .Issue2047a.M..extendedlambda1 u p of type Bool
-- when checking that the expression refl has type M.foo u ≡ M.bar u
--
-- but rather show
--
-- (\ { itis → true }) .p != (\ { itis → false }) .p
| {
"alphanum_fraction": 0.6205287714,
"avg_line_length": 22.9642857143,
"ext": "agda",
"hexsha": "e9725c691194882f2a97c07ca71c2207da6b6a35",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue2047a.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue2047a.agda",
"max_line_length": 70,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2047a.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 204,
"size": 643
} |
module MultipleFixityDecl where
infixl 40 _+_
infixr 60 _+_
_+_ : Set -> Set -> Set
A + B = A
| {
"alphanum_fraction": 0.6428571429,
"avg_line_length": 9.8,
"ext": "agda",
"hexsha": "903b41a7764f5599e38a50903cf120cdb3489449",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/MultipleFixityDecl.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/MultipleFixityDecl.agda",
"max_line_length": 31,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/MultipleFixityDecl.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 39,
"size": 98
} |
module Tactic.Reflection.Meta where
open import Prelude
open import Builtin.Reflection
open import Tactic.Reflection.DeBruijn
ensureNoMetas : Term → TC ⊤
noMetaArg : Arg Term → TC ⊤
noMetaArg (arg _ v) = ensureNoMetas v
noMetaArgs : List (Arg Term) → TC ⊤
noMetaArgs [] = pure _
noMetaArgs (v ∷ vs) = noMetaArg v *> noMetaArgs vs
noMetaClause : Clause → TC ⊤
noMetaClause (clause ps t) = ensureNoMetas t
noMetaClause (absurd-clause ps) = pure _
noMetaClauses : List Clause → TC ⊤
noMetaClauses [] = pure _
noMetaClauses (c ∷ cs) = noMetaClause c *> noMetaClauses cs
noMetaAbs : Abs Term → TC ⊤
noMetaAbs (abs _ v) = ensureNoMetas v
noMetaSort : Sort → TC ⊤
noMetaSort (set t) = ensureNoMetas t
noMetaSort (lit n) = pure _
noMetaSort unknown = pure _
ensureNoMetas (var x args) = noMetaArgs args
ensureNoMetas (con c args) = noMetaArgs args
ensureNoMetas (def f args) = noMetaArgs args
ensureNoMetas (lam v (abs _ t)) = ensureNoMetas t
ensureNoMetas (pat-lam cs args) = noMetaClauses cs *> noMetaArgs args
ensureNoMetas (pi a b) = noMetaArg a *> noMetaAbs b
ensureNoMetas (agda-sort s) = noMetaSort s
ensureNoMetas (lit l) = pure _
ensureNoMetas (meta x x₁) = blockOnMeta x
ensureNoMetas unknown = pure _
normaliseNoMetas : Term → TC Term
normaliseNoMetas a = do a ← normalise a
stripBoundNames a <$ ensureNoMetas a
| {
"alphanum_fraction": 0.7266666667,
"avg_line_length": 28.7234042553,
"ext": "agda",
"hexsha": "33fc0a5d74c00d6c14da9b60380f68d0af8bbf24",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "lclem/agda-prelude",
"max_forks_repo_path": "src/Tactic/Reflection/Meta.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "lclem/agda-prelude",
"max_issues_repo_path": "src/Tactic/Reflection/Meta.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "lclem/agda-prelude",
"max_stars_repo_path": "src/Tactic/Reflection/Meta.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 448,
"size": 1350
} |
--------------------------------------------------------------------------------
-- This file provides the generateCFG function that turns a list of strings of
-- the current syntax for grammars into a grammar as defined in Parser.agda
--------------------------------------------------------------------------------
{-# OPTIONS --type-in-type #-}
module Parse.Generate where
open import Class.Monad.Except
open import Data.Fin.Map
import Data.List.NonEmpty as NE
open NE using (List⁺; _∷_)
open import Data.String using (toList; fromChar; uncons) renaming (fromList to fromListS)
open import Data.Vec using (Vec; lookup; fromList; []; _∷_; _[_]%=_)
open import Data.Vec.Exts
open import Parse.LL1
open import Parse.MarkedString
open import Parse.MultiChar
open import Parse.Escape
open import Prelude
open import Prelude.Strings
-- Grammar with show functions for rules and non-terminals
Grammar = ∃[ n ]
Σ[ G ∈ CFG (Fin (suc n)) MultiChar ] (CFG.Rule G → String) × (Fin (suc n) → String)
NonTerminal : Grammar → Set
NonTerminal (n , _) = Fin (suc n)
initNT : (G : Grammar) → NonTerminal G
initNT (_ , G , _) = CFG.S G
findNT : (G : Grammar) → String → Maybe (NonTerminal G)
findNT (n , _ , _ , showNT) NT = findIndex (NT ≟_) (Data.Vec.tabulate showNT)
checkRuleName : String → String × List MarkedString → Set
checkRuleName s r = s ≡ proj₁ r
checkRuleNameDec : ∀ s → Decidable (checkRuleName s)
checkRuleNameDec s (s' , _) = s ≟ s'
module _ {M} {{_ : Monad M}} {{_ : MonadExcept M String}} where
-- Read until the closing marker
bracketHelper : Marker → MarkedString → M (List⁺ String × MarkedString)
bracketHelper m [] = throwError "Unexpected end of string! Expected a marker!"
bracketHelper m (inj₁ x ∷ s) = do
(head ∷ tail , rest) ← bracketHelper m s
return (fromChar x + head ∷ tail , rest)
bracketHelper m (inj₂ x ∷ s) =
if x ≣ m
then return (NE.[ "" ] , s)
else
if x ≣ WildcardSeparator
then if (m ≣ WildcardBracket true) ∨ (m ≣ WildcardBracket false)
then (do
(res , rest) ← bracketHelper m s
return ("" NE.∷⁺ res , rest))
else throwError "Found a wildcard separator outside of a wildcard bracket!"
else throwError "Found unexpected marker!"
preParseCFG : List MarkedString → M (∃[ n ] Vec (String × List MarkedString) n)
preParseCFG [] = return $ zero , []
preParseCFG (x ∷ l) with break (_≟ inj₂ NameDivider) x
... | name , rule' = if null name
then throwError $ "Parsing rule has no/empty name! Rule: " + markedStringToString x
else do
_ , rules ← preParseCFG l
let rule = dropHeadIfAny rule'
return $ case findIndex (checkRuleNameDec $ markedStringToString name) rules of λ
{ (just x) → -, rules [ x ]%= map₂ (rule ∷_)
; nothing → -, (markedStringToString name , [ rule ]) ∷ rules}
{-# TERMINATING #-}
generateCFG' : ∀ {n} → String → Vec (String × List MarkedString) (suc n) → M Grammar
generateCFG' {n} start rules = do
ruleTable ← parseRuleTable
case findIndex (checkRuleNameDec start) rules of λ where
(just i) →
return $
(-, record
{ S = i
; R = Fin ∘ numOfRules
; AllRules = allFin ∘ numOfRules
; Rstring'' = λ {v} → ruleTable v }
, (λ where (NT , rule) → let (NT' , rules') = lookup rules NT
in NT' + "$" + markedStringToString (lookup (fromList rules') rule))
, proj₁ ∘ lookup rules)
nothing → throwError $ "No non-terminal named " + start + " found!"
where
numOfRules : Fin (suc n) → ℕ
numOfRules = length ∘ proj₂ ∘ lookup rules
RuleTable : Set → Set
RuleTable T = DepFinMap (suc n) (λ v → FinMap (numOfRules v) T)
RuleString : Set
RuleString = List ((Fin (suc n) × Bool) ⊎ MultiChar ⊎ String)
sequenceRuleTable : ∀ {A} → RuleTable (M A) → M (RuleTable A)
sequenceRuleTable f = sequenceDepFinMap (sequenceDepFinMap ∘ f)
addCharToRuleString : Char → RuleString → RuleString
addCharToRuleString c [] = [ inj₂ (inj₂ $ fromChar c) ]
addCharToRuleString c s@(inj₁ _ ∷ _) = inj₂ (inj₂ $ fromChar c) ∷ s
addCharToRuleString c s@(inj₂ (inj₁ _) ∷ _) = inj₂ (inj₂ $ fromChar c) ∷ s
addCharToRuleString c (inj₂ (inj₂ y) ∷ s) = inj₂ (inj₂ (fromChar c + y)) ∷ s
markedStringToRule : MarkedString → M RuleString
markedStringToRule [] = return []
markedStringToRule (inj₁ x ∷ s) = do
res ← markedStringToRule s
return (addCharToRuleString x res)
-- this terminates because 'rest' is shorter than 's'
markedStringToRule (inj₂ (NonTerminalBracket b) ∷ s) = do
(nonTerm ∷ _ , rest) ← bracketHelper (NonTerminalBracket b) s
res ← markedStringToRule rest
nonTerm' ← maybeToError
(findIndex (checkRuleNameDec nonTerm) rules)
("Couldn't find a non-terminal named '" + nonTerm + "'")
return (inj₁ (nonTerm' , b) ∷ res)
markedStringToRule (inj₂ NameDivider ∷ s) =
throwError "The rule cannot contain a name divider!"
markedStringToRule (inj₂ (WildcardBracket b) ∷ s) = do
(multiChar , rest) ← bracketHelper (WildcardBracket b) s
inj₂ (inj₁ $ parseMultiCharNE b multiChar) ∷_ <$> markedStringToRule rest
markedStringToRule (inj₂ WildcardSeparator ∷ s) =
throwError "Wildcard separator outside of a wildcard!"
parseRuleTable : M (RuleTable RuleString)
parseRuleTable = sequenceRuleTable
λ v x → let y = lookup (fromList $ proj₂ (lookup rules v)) x in
appendIfError (markedStringToRule y) (" In: " + show y)
-- The first parameter describes the non-terminal the grammar should start with
generateCFGNonEscaped : String → List String → M Grammar
generateCFGNonEscaped start l = do
(suc k , y) ← preParseCFG $ map convertToMarked l
where _ → throwError "The grammar is empty!"
generateCFG' start y
-- The first parameter describes the non-terminal the grammar should start with
generateCFG : String → List String → M Grammar
generateCFG start l =
maybe (generateCFGNonEscaped start)
(throwError "Error while un-escaping parsing rules!")
(sequence $ ((_<$>_ fromListS) ∘ translate ∘ toList) <$> l)
| {
"alphanum_fraction": 0.6251184834,
"avg_line_length": 41.9205298013,
"ext": "agda",
"hexsha": "79098cbcb1648e76baf4e63795a1360c7f9fb814",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
"max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "WhatisRT/meta-cedille",
"max_forks_repo_path": "src/Parse/Generate.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "WhatisRT/meta-cedille",
"max_issues_repo_path": "src/Parse/Generate.agda",
"max_line_length": 103,
"max_stars_count": 35,
"max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "WhatisRT/meta-cedille",
"max_stars_repo_path": "src/Parse/Generate.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z",
"num_tokens": 1787,
"size": 6330
} |
-- 2010-10-05 Andreas
module TerminationRecordPatternLie where
data Empty : Set where
record Unit : Set where
data Bool : Set where
true false : Bool
T : Bool -> Set
T true = Unit
T false = Empty
-- Thorsten suggests on the Agda list thread "Coinductive families"
-- to encode lists as records
record List (A : Set) : Set where
inductive
constructor list
field
isCons : Bool
head : T isCons -> A
tail : T isCons -> List A
open List public
-- However, we have to be careful to preserve termination
-- in the presence of a lie
postulate
lie : {b : Bool} -> T b
-- this function is rejected
f : {A : Set} -> List A -> Empty
f (list b h t) = f (t lie)
-- since its internal representation is
g : {A : Set} -> List A -> Empty
g l = g (tail l lie)
-- however could record constructors still count as structural increase
-- if they cannot be translated away
-- should we accept this?
-- f (list true h t) = f (t _)
| {
"alphanum_fraction": 0.6684210526,
"avg_line_length": 20.2127659574,
"ext": "agda",
"hexsha": "540f33c52b5369b393960969d76f180fa0737310",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "hborum/agda",
"max_forks_repo_path": "test/Fail/TerminationRecordPatternLie.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/TerminationRecordPatternLie.agda",
"max_line_length": 71,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/TerminationRecordPatternLie.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 271,
"size": 950
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lexicographic products of binary relations
------------------------------------------------------------------------
-- The definition of lexicographic product used here is suitable if
-- the left-hand relation is a (non-strict) partial order.
module Relation.Binary.Product.NonStrictLex where
open import Data.Product
open import Data.Sum
open import Level
open import Relation.Binary
open import Relation.Binary.Consequences
import Relation.Binary.NonStrictToStrict as Conv
open import Relation.Binary.Product.Pointwise as Pointwise
using (_×-Rel_)
import Relation.Binary.Product.StrictLex as Strict
module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
×-Lex : (_≈₁_ _≤₁_ : Rel A₁ ℓ₁) → (_≤₂_ : Rel A₂ ℓ₂) →
Rel (A₁ × A₂) _
×-Lex _≈₁_ _≤₁_ _≤₂_ = Strict.×-Lex _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_
-- Some properties which are preserved by ×-Lex (under certain
-- assumptions).
×-reflexive : ∀ _≈₁_ _≤₁_ {_≈₂_} _≤₂_ →
_≈₂_ ⇒ _≤₂_ → (_≈₁_ ×-Rel _≈₂_) ⇒ (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-reflexive _≈₁_ _≤₁_ _≤₂_ refl₂ {x} {y} =
Strict.×-reflexive _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_ refl₂ {x} {y}
×-transitive : ∀ {_≈₁_ _≤₁_} → IsPartialOrder _≈₁_ _≤₁_ →
∀ {_≤₂_} → Transitive _≤₂_ →
Transitive (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-transitive {_≈₁_ = _≈₁_} {_≤₁_ = _≤₁_} po₁ {_≤₂_ = _≤₂_} trans₂
{x} {y} {z} =
Strict.×-transitive
{_<₁_ = Conv._<_ _≈₁_ _≤₁_}
isEquivalence (Conv.<-resp-≈ _ _ isEquivalence ≤-resp-≈)
(Conv.trans _ _ po₁)
{_≤₂_ = _≤₂_} trans₂ {x} {y} {z}
where open IsPartialOrder po₁
×-antisymmetric :
∀ {_≈₁_ _≤₁_} → IsPartialOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → Antisymmetric _≈₂_ _≤₂_ →
Antisymmetric (_≈₁_ ×-Rel _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-antisymmetric {_≈₁_ = _≈₁_} {_≤₁_ = _≤₁_}
po₁ {_≤₂_ = _≤₂_} antisym₂ {x} {y} =
Strict.×-antisymmetric {_<₁_ = Conv._<_ _≈₁_ _≤₁_}
≈-sym₁ irrefl₁ asym₁
{_≤₂_ = _≤₂_} antisym₂ {x} {y}
where
open IsPartialOrder po₁
open Eq renaming (refl to ≈-refl₁; sym to ≈-sym₁)
irrefl₁ : Irreflexive _≈₁_ (Conv._<_ _≈₁_ _≤₁_)
irrefl₁ = Conv.irrefl _≈₁_ _≤₁_
asym₁ : Asymmetric (Conv._<_ _≈₁_ _≤₁_)
asym₁ = trans∧irr⟶asym {_≈_ = _≈₁_}
≈-refl₁ (Conv.trans _ _ po₁) irrefl₁
×-≈-respects₂ :
∀ {_≈₁_ _≤₁_} → IsEquivalence _≈₁_ → _≤₁_ Respects₂ _≈₁_ →
∀ {_≈₂_ _≤₂_ : Rel A₂ ℓ₂} → _≤₂_ Respects₂ _≈₂_ →
(×-Lex _≈₁_ _≤₁_ _≤₂_) Respects₂ (_≈₁_ ×-Rel _≈₂_)
×-≈-respects₂ eq₁ resp₁ resp₂ =
Strict.×-≈-respects₂ eq₁ (Conv.<-resp-≈ _ _ eq₁ resp₁) resp₂
×-decidable : ∀ {_≈₁_ _≤₁_} → Decidable _≈₁_ → Decidable _≤₁_ →
∀ {_≤₂_} → Decidable _≤₂_ →
Decidable (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-decidable dec-≈₁ dec-≤₁ dec-≤₂ =
Strict.×-decidable dec-≈₁ (Conv.decidable _ _ dec-≈₁ dec-≤₁)
dec-≤₂
×-total : ∀ {_≈₁_ _≤₁_} → Symmetric _≈₁_ → Decidable _≈₁_ →
Antisymmetric _≈₁_ _≤₁_ → Total _≤₁_ →
∀ {_≤₂_} → Total _≤₂_ →
Total (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-total {_≈₁_ = _≈₁_} {_≤₁_ = _≤₁_} sym₁ dec₁ antisym₁ total₁
{_≤₂_ = _≤₂_} total₂ = total
where
tri₁ : Trichotomous _≈₁_ (Conv._<_ _≈₁_ _≤₁_)
tri₁ = Conv.trichotomous _ _ sym₁ dec₁ antisym₁ total₁
total : Total (×-Lex _≈₁_ _≤₁_ _≤₂_)
total x y with tri₁ (proj₁ x) (proj₁ y)
... | tri< x₁<y₁ x₁≉y₁ x₁≯y₁ = inj₁ (inj₁ x₁<y₁)
... | tri> x₁≮y₁ x₁≉y₁ x₁>y₁ = inj₂ (inj₁ x₁>y₁)
... | tri≈ x₁≮y₁ x₁≈y₁ x₁≯y₁ with total₂ (proj₂ x) (proj₂ y)
... | inj₁ x₂≤y₂ = inj₁ (inj₂ (x₁≈y₁ , x₂≤y₂))
... | inj₂ x₂≥y₂ = inj₂ (inj₂ (sym₁ x₁≈y₁ , x₂≥y₂))
-- Some collections of properties which are preserved by ×-Lex
-- (under certain assumptions).
_×-isPartialOrder_ :
∀ {_≈₁_ _≤₁_} → IsPartialOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → IsPartialOrder _≈₂_ _≤₂_ →
IsPartialOrder (_≈₁_ ×-Rel _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
_×-isPartialOrder_ {_≈₁_ = _≈₁_} {_≤₁_ = _≤₁_} po₁
{_≤₂_ = _≤₂_} po₂ = record
{ isPreorder = record
{ isEquivalence = Pointwise._×-isEquivalence_
(isEquivalence po₁)
(isEquivalence po₂)
; reflexive = λ {x y} →
×-reflexive _≈₁_ _≤₁_ _≤₂_ (reflexive po₂)
{x} {y}
; trans = λ {x y z} →
×-transitive po₁ {_≤₂_ = _≤₂_} (trans po₂)
{x} {y} {z}
}
; antisym = λ {x y} →
×-antisymmetric {_≤₁_ = _≤₁_} po₁
{_≤₂_ = _≤₂_} (antisym po₂) {x} {y}
}
where open IsPartialOrder
×-isTotalOrder :
∀ {_≈₁_ _≤₁_} → Decidable _≈₁_ → IsTotalOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → IsTotalOrder _≈₂_ _≤₂_ →
IsTotalOrder (_≈₁_ ×-Rel _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
×-isTotalOrder {_≤₁_ = _≤₁_} ≈₁-dec to₁ {_≤₂_ = _≤₂_} to₂ = record
{ isPartialOrder = isPartialOrder to₁ ×-isPartialOrder
isPartialOrder to₂
; total = ×-total {_≤₁_ = _≤₁_} (Eq.sym to₁) ≈₁-dec
(antisym to₁) (total to₁)
{_≤₂_ = _≤₂_} (total to₂)
}
where open IsTotalOrder
_×-isDecTotalOrder_ :
∀ {_≈₁_ _≤₁_} → IsDecTotalOrder _≈₁_ _≤₁_ →
∀ {_≈₂_ _≤₂_} → IsDecTotalOrder _≈₂_ _≤₂_ →
IsDecTotalOrder (_≈₁_ ×-Rel _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
_×-isDecTotalOrder_ {_≤₁_ = _≤₁_} to₁ {_≤₂_ = _≤₂_} to₂ = record
{ isTotalOrder = ×-isTotalOrder (_≟_ to₁)
(isTotalOrder to₁)
(isTotalOrder to₂)
; _≟_ = Pointwise._×-decidable_ (_≟_ to₁) (_≟_ to₂)
; _≤?_ = ×-decidable (_≟_ to₁) (_≤?_ to₁) (_≤?_ to₂)
}
where open IsDecTotalOrder
-- "Packages" (e.g. posets) can also be combined.
_×-poset_ :
∀ {p₁ p₂ p₃ p₄} → Poset p₁ p₂ _ → Poset p₃ p₄ _ → Poset _ _ _
p₁ ×-poset p₂ = record
{ isPartialOrder = isPartialOrder p₁ ×-isPartialOrder
isPartialOrder p₂
} where open Poset
_×-totalOrder_ :
∀ {d₁ d₂ t₃ t₄} →
DecTotalOrder d₁ d₂ _ → TotalOrder t₃ t₄ _ → TotalOrder _ _ _
t₁ ×-totalOrder t₂ = record
{ isTotalOrder = ×-isTotalOrder T₁._≟_ T₁.isTotalOrder T₂.isTotalOrder
}
where
module T₁ = DecTotalOrder t₁
module T₂ = TotalOrder t₂
_×-decTotalOrder_ :
∀ {d₁ d₂ d₃ d₄} →
DecTotalOrder d₁ d₂ _ → DecTotalOrder d₃ d₄ _ → DecTotalOrder _ _ _
t₁ ×-decTotalOrder t₂ = record
{ isDecTotalOrder = isDecTotalOrder t₁ ×-isDecTotalOrder
isDecTotalOrder t₂
} where open DecTotalOrder
| {
"alphanum_fraction": 0.534512761,
"avg_line_length": 38.7415730337,
"ext": "agda",
"hexsha": "4f89cdcb1121f4647925d6e50b03c2bc3b27d9fd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Product/NonStrictLex.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Product/NonStrictLex.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Binary/Product/NonStrictLex.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 2922,
"size": 6896
} |
{-
Verified Koopa Troopa Movement
Toon Nolten
-}
module koopa where
open import Data.Nat
open import Data.Fin renaming (_+_ to _F+_; _<_ to _F<_; suc to fsuc;
zero to fzero)
open import Data.Vec renaming (map to vmap; lookup to vlookup;
replicate to vreplicate)
open import Data.Unit
open import Data.Empty
module Matrix where
data Matrix (A : Set) : ℕ → ℕ → Set where
Mat : {w h : ℕ} → Vec (Vec A w) h → Matrix A w h
lookup : ∀ {w h} {A : Set} → Fin h → Fin w → Matrix A w h → A
lookup row column (Mat rows) = vlookup column (vlookup row rows)
open Matrix
data Color : Set where
Green : Color
Red : Color
data KoopaTroopa : Color → Set where
_KT : (c : Color) → KoopaTroopa c
data Material : Set where
gas : Material
-- liquid : Material
solid : Material
data Clearance : Set where
Low : Clearance
High : Clearance
God : Clearance
record Position : Set where
constructor pos
field
x : ℕ
y : ℕ
mat : Material
clr : Clearance
data _c>_ : Color → Clearance → Set where
<red> : ∀ {c} → c c> Low
<green> : Green c> High
data _follows_⟨_⟩ : Position → Position → Color → Set where
stay : ∀ {c x y} → pos x y gas Low follows pos x y gas Low ⟨ c ⟩
next : ∀ {c cl x y}{{_ : c c> cl}} →
pos (suc x) y gas cl follows pos x y gas Low ⟨ c ⟩
back : ∀ {c cl x y}{{_ : c c> cl}} →
pos x y gas cl follows pos (suc x) y gas Low ⟨ c ⟩
-- jump : ∀ {c x y} → pos x (suc y) gas High follows pos x y gas Low ⟨ c ⟩
fall : ∀ {c cl x y} → pos x y gas cl follows pos x (suc y) gas High ⟨ c ⟩
infixr 5 _↠⟨_⟩_
data Path {c : Color} (Koopa : KoopaTroopa c) :
Position → Position → Set where
[] : ∀ {p} → Path Koopa p p
_↠⟨_⟩_ : {q r : Position} → (p : Position) → q follows p ⟨ c ⟩
→ (qs : Path Koopa q r) → Path Koopa p r
ex_path : Path (Red KT) (pos 0 0 gas Low) (pos 0 0 gas Low)
ex_path = pos 0 0 gas Low ↠⟨ next ⟩
pos 1 0 gas Low ↠⟨ back ⟩
pos 0 0 gas Low ↠⟨ stay ⟩ []
matToPosVec : {n : ℕ} → Vec Material n → Vec Material n → ℕ → ℕ →
Vec Position n
matToPosVec [] [] _ _ = []
matToPosVec (mat ∷ mats) (under ∷ unders) x y =
pos x y mat cl ∷ matToPosVec mats unders (x + 1) y
where
clearance : Material → Material → Clearance
clearance gas gas = High
clearance gas solid = Low
clearance solid _ = God
cl = clearance mat under
matToPosVecs : {w h : ℕ} → Vec (Vec Material w) h → Vec (Vec Position w) h
matToPosVecs [] = []
matToPosVecs (_∷_ {y} mats matss) =
matToPosVec mats (unders matss gas) 0 y ∷ matToPosVecs matss
where
unders : ∀ {m n ℓ}{A : Set ℓ} → Vec (Vec A m) n → A → Vec A m
unders [] fallback = vreplicate fallback
unders (us ∷ _) _ = us
matsToMat : {w h : ℕ} → Vec (Vec Material w) h → Matrix Position w h
matsToMat matss = Mat (reverse (matToPosVecs matss))
□ : Material
□ = gas
■ : Material
■ = solid
example_level : Matrix Position 10 7
example_level = matsToMat (
(□ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ []) ∷
(□ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ ■ ∷ ■ ∷ ■ ∷ □ ∷ []) ∷
(□ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ []) ∷
(□ ∷ □ ∷ □ ∷ ■ ∷ ■ ∷ ■ ∷ □ ∷ □ ∷ □ ∷ □ ∷ []) ∷
(□ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ []) ∷
(■ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ □ ∷ ■ ∷ []) ∷
(■ ∷ ■ ∷ ■ ∷ ■ ∷ ■ ∷ □ ∷ □ ∷ ■ ∷ ■ ∷ ■ ∷ []) ∷ [])
_<'_ : ℕ → ℕ → Set
m <' zero = ⊥
zero <' suc n = ⊤
suc m <' suc n = m <' n
fromNat : ∀ {n}(k : ℕ){_ : k <' n} → Fin n
fromNat {zero} k {}
fromNat {suc n} zero = fzero
fromNat {suc n} (suc k) {p} = fsuc (fromNat k {p})
f : ∀ {n}(k : ℕ){_ : k <' n} → Fin n
f = fromNat
p : (x : Fin 10) → (y : Fin 7) → Position
p x y = lookup y x example_level
red_path_one : Path (Red KT) (p (f 7) (f 6)) (p (f 8) (f 6))
red_path_one = p (f 7) (f 6) ↠⟨ back ⟩
p (f 6) (f 6) ↠⟨ next ⟩
p (f 7) (f 6) ↠⟨ next ⟩
p (f 8) (f 6) ↠⟨ stay ⟩ []
red_path_two : Path (Red KT) (p (f 2) (f 1)) (p (f 3) (f 1))
red_path_two = p (f 2) (f 1) ↠⟨ back ⟩
p (f 1) (f 1) ↠⟨ next ⟩
p (f 2) (f 1) ↠⟨ next ⟩
p (f 3) (f 1) ↠⟨ next ⟩
p (f 4) (f 1) ↠⟨ back ⟩
p (f 3) (f 1) ↠⟨ stay ⟩
[]
-- -- Type error shows up 'late' because 'cons' is right associative
-- red_nopath_one : Path (Red KT) (p (f 1) (f 1)) (p (f 0) (f 1))
-- red_nopath_one = p (f 1) (f 1) ↠⟨ back ⟩
-- p (f 0) (f 1) ↠⟨ stay ⟩
-- []
-- -- Red KoopaTroopa can't step into a wall
-- red_nopath_two : Path (Red KT) (p (f 1) (f 1)) (p (f 0) (f 1))
-- red_nopath_two = p (f 1) (f 1) ↠⟨ back ⟩ []
-- -- Red KoopaTroopa can't step into air
-- red_nopath_three : Path (Red KT) (p (f 4) (f 1)) (p (f 5) (f 1))
-- red_nopath_three = p (f 4) (f 1) ↠⟨ next ⟩ []
-- Any path that is valid for red KoopaTroopas, is also valid for green
-- KoopaTroopas because we did not constrain KoopaTroopas to only turn
-- When there is an obstacle
green_path_one : Path (Green KT) (p (f 7) (f 6)) (p (f 8) (f 6))
green_path_one = p (f 7) (f 6) ↠⟨ back ⟩
p (f 6) (f 6) ↠⟨ next ⟩
p (f 7) (f 6) ↠⟨ next ⟩
p (f 8) (f 6) ↠⟨ stay ⟩ []
green_path_two : Path (Green KT) (p (f 7) (f 6)) (p (f 5) (f 0))
green_path_two = p (f 7) (f 6) ↠⟨ back ⟩
p (f 6) (f 6) ↠⟨ back ⟩
p (f 5) (f 6) ↠⟨ fall ⟩
p (f 5) (f 5) ↠⟨ fall ⟩
p (f 5) (f 4) ↠⟨ back ⟩
p (f 4) (f 4) ↠⟨ back ⟩
p (f 3) (f 4) ↠⟨ back ⟩
p (f 2) (f 4) ↠⟨ fall ⟩
p (f 2) (f 3) ↠⟨ fall ⟩
p (f 2) (f 2) ↠⟨ fall ⟩
p (f 2) (f 1) ↠⟨ back ⟩
p (f 1) (f 1) ↠⟨ next ⟩
p (f 2) (f 1) ↠⟨ next ⟩
p (f 3) (f 1) ↠⟨ next ⟩
p (f 4) (f 1) ↠⟨ next ⟩
p (f 5) (f 1) ↠⟨ fall ⟩
[]
-- -- Green KoopaTroopa can't step into a wall
-- green_nopath_one : Path (Green KT) (p (f 1) (f 1)) (p (f 0) (f 1))
-- green_nopath_one = p (f 1) (f 1) ↠⟨ back ⟩ []
| {
"alphanum_fraction": 0.4540132491,
"avg_line_length": 34.1631578947,
"ext": "agda",
"hexsha": "901c2856687af8b46ef7f1dfd76bcfe2916a17e4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "153763f135ee71bbed2881323646190ceeccf49c",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "toonn/popartt",
"max_forks_repo_path": "koopa.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "153763f135ee71bbed2881323646190ceeccf49c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "toonn/popartt",
"max_issues_repo_path": "koopa.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "153763f135ee71bbed2881323646190ceeccf49c",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "toonn/popartt",
"max_stars_repo_path": "koopa.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2713,
"size": 6491
} |
module Equality where
open import Agda.Builtin.Equality public
open import Relation.Nullary
infix 4 _≅_ _≢_
infixr 2 _≡⟨_⟩_
infix 3 _QED
data _≅_ {ℓ} {A : Set ℓ} (x : A) : {B : Set ℓ} → B → Set ℓ where
refl : x ≅ x
≡→≅ : ∀ {ℓ} {A : Set ℓ} {a b : A} → a ≡ b → a ≅ b
≡→≅ refl = refl
sym : ∀ {ℓ} {A : Set ℓ} {a b : A} → a ≡ b → b ≡ a
sym refl = refl
sym′ : ∀ {ℓ} {A B : Set ℓ} {a : A} {b : B} → a ≅ b → b ≅ a
sym′ refl = refl
subst₂ : ∀ {a b p} {A : Set a} {B : Set b} (P : A → B → Set p)
{x₁ x₂ y₁ y₂} → x₁ ≡ x₂ → y₁ ≡ y₂ → P x₁ y₁ → P x₂ y₂
subst₂ P refl refl p = p
cong : ∀ {a b} {A : Set a} {B : Set b}
(f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
cong-app : ∀ {a b} {A : Set a} {B : A → Set b} {f g : (x : A) → B x} →
f ≡ g → (x : A) → f x ≡ g x
cong-app refl x = refl
cong₂ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
(f : A → B → C) {x y u v} → x ≡ y → u ≡ v → f x u ≡ f y v
cong₂ f refl refl = refl
_≢_ : ∀ {a} {A : Set a} → A → A → Set a
x ≢ y = ¬ x ≡ y
_≡⟨_⟩_ : ∀ {A : Set} (x : A) {y z : A}
→ x ≡ y → y ≡ z → x ≡ z
x ≡⟨ refl ⟩ refl = refl
_QED : ∀ {A : Set} (x : A) → x ≡ x
x QED = refl
| {
"alphanum_fraction": 0.4341880342,
"avg_line_length": 24.8936170213,
"ext": "agda",
"hexsha": "efffca01a9f9db9982024096edd40e4ba9dc484f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ice1k/Theorems",
"max_forks_repo_path": "src/Equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "ice1k/Theorems",
"max_issues_repo_path": "src/Equality.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ice1k/Theorems",
"max_stars_repo_path": "src/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z",
"num_tokens": 605,
"size": 1170
} |
{-# OPTIONS --safe #-}
module JVM.Model {ℓ} (T : Set ℓ) where
open import Level hiding (Lift)
open import Data.Product
open import Data.Unit
open import Data.List
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Relation.Ternary.Core
open import Relation.Ternary.Structures
open import Relation.Ternary.Construct.Empty T public
open import Relation.Ternary.Construct.Duplicate T public
open import Data.List.Relation.Binary.Permutation.Propositional
using ()
renaming (_↭_ to _≈_)
open import Data.List.Relation.Binary.Permutation.Propositional.Properties
using (++-isMonoid)
instance ++-monoid-instance = ++-isMonoid
module Disjoint where
open import Relation.Ternary.Construct.Bag empty-rel tt public
open IsPartialSemigroup bags-isSemigroup public
open IsPartialMonoid bags-isMonoid public
open IsCommutative bags-isCommutative public
module Overlap where
open import Relation.Ternary.Construct.Bag duplicate tt public
open IsPartialSemigroup bags-isSemigroup public
open IsPartialMonoid bags-isMonoid public
open IsCommutative bags-isCommutative public
open IsTotal bags-isTotal public
open Disjoint using (bag-emptiness) renaming
( empty-unique to empty-bag-unique
; singleton-unique to singleton-bag-unique)
public
open Rel₃ Disjoint.bags using ()
renaming (_∙_≣_ to _⊕_≣_; _✴_ to _⊕_; _─✴_ to _─⊕_; _∙⟨_⟩_ to _⊕⟨_⟩_) public
open Rel₃ Overlap.bags using ()
renaming (_∙_≣_ to _⊗_≣_; _✴_ to _⊗_; _─✴_ to _─⊗_; _∙⟨_⟩_ to _⊗⟨_⟩_) public
open import Relation.Ternary.Construct.Bag.Properties
open import Data.List.Relation.Binary.Permutation.Propositional
open CrossSplittable {{div₁ = duplicate}} {{empty-rel}} (λ _ ())
abstract
private
m₁ : IsPartialMonoid _↭_ Disjoint.bags []
m₁ = Disjoint.bags-isMonoid
m₂ : IsPartialMonoid _↭_ Overlap.bags []
m₂ = Overlap.bags-isMonoid
p₁ : IsPositiveWithZero 0ℓ _↭_ Disjoint.bags []
p₁ = Disjoint.bags-isPositive-w/0
p₂ : IsPositiveWithZero 0ℓ _↭_ Overlap.bags []
p₂ = Overlap.bags-isPositive-w/0
c₁ : IsCommutative Disjoint.bags
c₁ = Disjoint.bags-isCommutative
c₂ : IsCommutative Overlap.bags
c₂ = Overlap.bags-isCommutative
x : CrossSplit Overlap.bags Disjoint.bags
x = xsplit
ux : Uncross Disjoint.bags Overlap.bags
ux = uncrossover (unxcross λ ())
open import Relation.Ternary.Construct.Exchange
{A = List T}
{{m₁}} {{m₂}} {{p₁}} {{p₂}} {{empty-bag-unique}} {{c₁}} {{c₂}}
{{Disjoint.bags-isTotal}}
{{Overlap.bags-isTotal}}
{{++-isMonoid}}
x ux
public
renaming
(Account to Intf
; _≈_ to _≈intf≈_
; exchange-rel to intf-rel
; exchange-emptiness to intf-emptiness
; exchange-isSemigroup to intf-isSemigroup
; exchange-isCommutative to intf-isCommutative
; exchange-isMonoid to intf-isMonoid
; exchange-isTotal to intf-isTotal)
open DownIntuitive {{Overlap.bags-isContractive}} public
module Syntax where
open Rel₃ intf-rel public
open Emptiness intf-emptiness public
open IsPartialSemigroup intf-isSemigroup public
open IsPartialMonoid intf-isMonoid public
open IsCommutative intf-isCommutative public
open CommutativeSemigroupOps {{intf-isSemigroup}} {{intf-isCommutative}} public
-- module _ {P} where
-- open IsIntuitionistic (intf-isIntuitive {P}) w public
open Syntax
| {
"alphanum_fraction": 0.7246036406,
"avg_line_length": 31.247706422,
"ext": "agda",
"hexsha": "1d0da00332ca25a66879dae26a5f612419ac450b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ajrouvoet/jvm.agda",
"max_forks_repo_path": "src/JVM/Model.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "ajrouvoet/jvm.agda",
"max_issues_repo_path": "src/JVM/Model.agda",
"max_line_length": 81,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ajrouvoet/jvm.agda",
"max_stars_repo_path": "src/JVM/Model.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z",
"num_tokens": 1063,
"size": 3406
} |
open import OutsideIn.Prelude
open import OutsideIn.X
module OutsideIn.Environments(x : X) where
open import Data.Vec hiding (map)
import OutsideIn.TypeSchema as TS
import OutsideIn.Expressions as E
open TS(x)
open E(x)
open X(x)
private
module TS-f {x} = Functor(type-schema-is-functor {x})
Environment : Set → Set → Set
Environment ev tv = ∀ {x} → Name ev x → TypeSchema tv x
⟨_⟩,_ : ∀{ev}{tv} → TypeSchema tv Regular → (∀{x} → Name ev x → TypeSchema tv x)
→ ∀{x} → Name (Ⓢ ev) x → TypeSchema tv x
(⟨ τ ⟩, Γ) (N zero) = τ
(⟨ τ ⟩, Γ) (N (suc n)) = Γ (N n)
(⟨ τ ⟩, Γ) (DC n) = Γ (DC n)
_↑Γ : {ev tv : Set} → Environment ev tv → Environment ev (Ⓢ tv)
Γ ↑Γ = TS-f.map suc ∘ Γ
addAll : ∀{n}{ev}{tv} → Vec (Type tv) n → ( Environment ev tv) → Environment (ev ⨁ n) tv
addAll [] Γ = Γ
addAll (τ ∷ τs) Γ = addAll τs (⟨ ∀′ 0 · ε ⇒ τ ⟩, Γ ) | {
"alphanum_fraction": 0.5704697987,
"avg_line_length": 29.8,
"ext": "agda",
"hexsha": "c61c9de1e1195ccd701c541f93f5f58ceda0bdb4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "liamoc/outside-in",
"max_forks_repo_path": "OutsideIn/Environments.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "liamoc/outside-in",
"max_issues_repo_path": "OutsideIn/Environments.agda",
"max_line_length": 90,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "liamoc/outside-in",
"max_stars_repo_path": "OutsideIn/Environments.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z",
"num_tokens": 348,
"size": 894
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- An inductive definition of the sublist relation. This is commonly
-- known as Order Preserving Embeddings (OPE).
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Binary.Sublist.Propositional
{a} {A : Set a} where
open import Data.List.Base using (List)
open import Data.List.Relation.Binary.Equality.Propositional using (≋⇒≡)
import Data.List.Relation.Binary.Sublist.Setoid as SetoidSublist
open import Data.List.Relation.Unary.Any using (Any)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Relation.Unary using (Pred)
------------------------------------------------------------------------
-- Re-export definition and operations from setoid sublists
open SetoidSublist (setoid A) public
hiding
(lookup; ⊆-reflexive; ⊆-antisym
; ⊆-isPreorder; ⊆-isPartialOrder
; ⊆-preorder; ⊆-poset
)
------------------------------------------------------------------------
-- Additional operations
module _ {p} {P : Pred A p} where
lookup : ∀ {xs ys} → xs ⊆ ys → Any P xs → Any P ys
lookup = SetoidSublist.lookup (setoid A) (subst _)
------------------------------------------------------------------------
-- Relational properties
⊆-reflexive : _≡_ ⇒ _⊆_
⊆-reflexive refl = ⊆-refl
⊆-antisym : Antisymmetric _≡_ _⊆_
⊆-antisym xs⊆ys ys⊆xs = ≋⇒≡ (SetoidSublist.⊆-antisym (setoid A) xs⊆ys ys⊆xs)
⊆-isPreorder : IsPreorder _≡_ _⊆_
⊆-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ⊆-reflexive
; trans = ⊆-trans
}
⊆-isPartialOrder : IsPartialOrder _≡_ _⊆_
⊆-isPartialOrder = record
{ isPreorder = ⊆-isPreorder
; antisym = ⊆-antisym
}
⊆-preorder : Preorder a a a
⊆-preorder = record
{ isPreorder = ⊆-isPreorder
}
⊆-poset : Poset a a a
⊆-poset = record
{ isPartialOrder = ⊆-isPartialOrder
}
------------------------------------------------------------------------
-- Separating two sublists
--
-- Two possibly overlapping sublists τ : xs ⊆ zs and σ : ys ⊆ zs
-- can be turned into disjoint lists τρ : xs ⊆ zs and τρ : ys ⊆ zs′
-- by duplicating all entries of zs that occur both in xs and ys,
-- resulting in an extension ρ : zs ⊆ zs′ of zs.
record Separation {xs ys zs} (τ₁ : xs ⊆ zs) (τ₂ : ys ⊆ zs) : Set a where
field
{inflation} : List A
separator₁ : zs ⊆ inflation
separator₂ : zs ⊆ inflation
separated₁ = ⊆-trans τ₁ separator₁
separated₂ = ⊆-trans τ₂ separator₂
field
disjoint : Disjoint separated₁ separated₂
infixr 5 _∷ₙ-Sep_ _∷ₗ-Sep_ _∷ᵣ-Sep_
-- Empty separation
[]-Sep : Separation [] []
[]-Sep = record { separator₁ = [] ; separator₂ = [] ; disjoint = [] }
-- Weaken a separation
_∷ₙ-Sep_ : ∀ {xs ys zs} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} →
∀ z → Separation τ₁ τ₂ → Separation (z ∷ʳ τ₁) (z ∷ʳ τ₂)
z ∷ₙ-Sep record{ separator₁ = ρ₁; separator₂ = ρ₂; disjoint = d } = record
{ separator₁ = refl ∷ ρ₁
; separator₂ = refl ∷ ρ₂
; disjoint = z ∷ₙ d
}
-- Extend a separation by an element of the first sublist.
--
-- Note: this requires a category law from the underlying equality,
-- trans x=z refl = x=z, thus, separation is not available for Sublist.Setoid.
_∷ₗ-Sep_ : ∀ {xs ys zs} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} →
∀ {x z} (x≡z : x ≡ z) → Separation τ₁ τ₂ → Separation (x≡z ∷ τ₁) (z ∷ʳ τ₂)
refl ∷ₗ-Sep record{ separator₁ = ρ₁; separator₂ = ρ₂; disjoint = d } = record
{ separator₁ = refl ∷ ρ₁
; separator₂ = refl ∷ ρ₂
; disjoint = refl ∷ₗ d
}
-- Extend a separation by an element of the second sublist.
_∷ᵣ-Sep_ : ∀ {xs ys zs} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} →
∀ {y z} (y≡z : y ≡ z) → Separation τ₁ τ₂ → Separation (z ∷ʳ τ₁) (y≡z ∷ τ₂)
refl ∷ᵣ-Sep record{ separator₁ = ρ₁; separator₂ = ρ₂; disjoint = d } = record
{ separator₁ = refl ∷ ρ₁
; separator₂ = refl ∷ ρ₂
; disjoint = refl ∷ᵣ d
}
-- Extend a separation by a common element of both sublists.
--
-- Left-biased: the left separator gets the first copy
-- of the common element.
∷-Sepˡ : ∀ {xs ys zs} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} →
∀ {x y z} (x≡z : x ≡ z) (y≡z : y ≡ z) →
Separation τ₁ τ₂ → Separation (x≡z ∷ τ₁) (y≡z ∷ τ₂)
∷-Sepˡ refl refl record{ separator₁ = ρ₁; separator₂ = ρ₂; disjoint = d } = record
{ separator₁ = _ ∷ʳ refl ∷ ρ₁
; separator₂ = refl ∷ _ ∷ʳ ρ₂
; disjoint = refl ∷ᵣ (refl ∷ₗ d)
}
-- Left-biased separation of two sublists. Of common elements,
-- the first sublist receives the first copy.
separateˡ : ∀ {xs ys zs} (τ₁ : xs ⊆ zs) (τ₂ : ys ⊆ zs) → Separation τ₁ τ₂
separateˡ [] [] = []-Sep
separateˡ (z ∷ʳ τ₁) (z ∷ʳ τ₂) = z ∷ₙ-Sep separateˡ τ₁ τ₂
separateˡ (z ∷ʳ τ₁) (y≡z ∷ τ₂) = y≡z ∷ᵣ-Sep separateˡ τ₁ τ₂
separateˡ (x≡z ∷ τ₁) (z ∷ʳ τ₂) = x≡z ∷ₗ-Sep separateˡ τ₁ τ₂
separateˡ (x≡z ∷ τ₁) (y≡z ∷ τ₂) = ∷-Sepˡ x≡z y≡z (separateˡ τ₁ τ₂)
| {
"alphanum_fraction": 0.5794260307,
"avg_line_length": 32.5526315789,
"ext": "agda",
"hexsha": "b50945f54a2afddd5da52b2dc5ede4aa0bdf9569",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Sublist/Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Sublist/Propositional.agda",
"max_line_length": 84,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Sublist/Propositional.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 1804,
"size": 4948
} |
module Verifier where
open import Definitions
open import DeMorgan using (deMorgan)
check : {A B : Set} → ¬ A ∧ ¬ B → ¬ (A ∨ B)
check = deMorgan
| {
"alphanum_fraction": 0.6666666667,
"avg_line_length": 18.375,
"ext": "agda",
"hexsha": "1930e7cb9ebc424d1c618f54f6029ed095a5d0e2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "danr/agder",
"max_forks_repo_path": "problems/DeMorgan/Verifier.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "danr/agder",
"max_issues_repo_path": "problems/DeMorgan/Verifier.agda",
"max_line_length": 43,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "danr/agder",
"max_stars_repo_path": "problems/DeMorgan/Verifier.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-17T12:07:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-17T12:07:03.000Z",
"num_tokens": 48,
"size": 147
} |
-- Let's play with agda.
-- Am i having fun doing this? @KMx404
module intro where --load the file with C-c - like that
data Bool: Set where
true : Bool
false : Bool
data Empty: Set Empty
Empty : Empty -- I'm gonna leave this here. Moving to tests
| {
"alphanum_fraction": 0.6704545455,
"avg_line_length": 17.6,
"ext": "agda",
"hexsha": "296c825fabd87bd9dd909fc33bdeeab2016a36a3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b2cf336215025de01b3b3f4b2296f9afd7c2d295",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "KMx404/selfev.agda",
"max_forks_repo_path": "intro/intro.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b2cf336215025de01b3b3f4b2296f9afd7c2d295",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "KMx404/selfev.agda",
"max_issues_repo_path": "intro/intro.agda",
"max_line_length": 62,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "b2cf336215025de01b3b3f4b2296f9afd7c2d295",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "KMx404/selfev.agda",
"max_stars_repo_path": "intro/intro.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-12T15:57:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-08-18T11:22:21.000Z",
"num_tokens": 74,
"size": 264
} |
module Issue2858-nbe where
open import Agda.Builtin.List
data Ty : Set where
α : Ty
_↝_ : Ty → Ty → Ty
variable
σ τ : Ty
Γ Δ Θ : List Ty
Scoped : Set₁
Scoped = Ty → List Ty → Set
data Var : Scoped where
z : Var σ (σ ∷ Γ)
s : Var σ Γ → Var σ (τ ∷ Γ)
record Ren (Γ Δ : List Ty) : Set where
field lookup : ∀ {σ} → Var σ Γ → Var σ Δ
open Ren public
bind : Ren Γ Δ → Ren (σ ∷ Γ) (σ ∷ Δ)
lookup (bind ρ) z = z
lookup (bind ρ) (s v) = s (lookup ρ v)
refl : Ren Γ Γ
lookup refl v = v
step : Ren Γ (σ ∷ Γ)
lookup step v = s v
_∘_ : Ren Δ Θ → Ren Γ Δ → Ren Γ Θ
lookup (ρ′ ∘ ρ) v = lookup ρ′ (lookup ρ v)
interleaved mutual
data Syn : Scoped
data Chk : Scoped
th^Syn : Ren Γ Δ → Syn σ Γ → Syn σ Δ
th^Chk : Ren Γ Δ → Chk σ Γ → Chk σ Δ
-- variable rule
constructor
var : Var σ Γ → Syn σ Γ
th^Syn ρ (var v) = var (lookup ρ v)
-- change of direction rules
constructor
emb : Syn σ Γ → Chk σ Γ
cut : Chk σ Γ → Syn σ Γ
th^Chk ρ (emb t) = emb (th^Syn ρ t)
th^Syn ρ (cut c) = cut (th^Chk ρ c)
-- function introduction and elimination
constructor
app : Syn (σ ↝ τ) Γ → Chk σ Γ → Syn τ Γ
lam : Chk τ (σ ∷ Γ) → Chk (σ ↝ τ) Γ
th^Syn ρ (app f t) = app (th^Syn ρ f) (th^Chk ρ t)
th^Chk ρ (lam b) = lam (th^Chk (bind ρ) b)
-- Model construction
Val : Scoped
Val α Γ = Syn α Γ
Val (σ ↝ τ) Γ = ∀ {Δ} → Ren Γ Δ → Val σ Δ → Val τ Δ
th^Val : Ren Γ Δ → Val σ Γ → Val σ Δ
th^Val {σ = α} ρ t = th^Syn ρ t
th^Val {σ = σ ↝ τ} ρ t = λ ρ′ → t (ρ′ ∘ ρ)
interleaved mutual
reify : ∀ σ → Val σ Γ → Chk σ Γ
reflect : ∀ σ → Syn σ Γ → Val σ Γ
-- base case
reify α t = emb t
reflect α t = t
-- arrow case
reify (σ ↝ τ) t = lam (reify τ (t step (reflect σ (var z))))
reflect (σ ↝ τ) t = λ ρ v → reflect τ (app (th^Syn ρ t) (reify σ v))
record Env (Γ Δ : List Ty) : Set where
field lookup : ∀ {σ} → Var σ Γ → Val σ Δ
open Env public
th^Env : Ren Δ Θ → Env Γ Δ → Env Γ Θ
lookup (th^Env ρ vs) v = th^Val ρ (lookup vs v)
placeholders : Env Γ Γ
lookup placeholders v = reflect _ (var v)
extend : Env Γ Δ → Val σ Δ → Env (σ ∷ Γ) Δ
lookup (extend ρ t) z = t
lookup (extend ρ t) (s v) = lookup ρ v
interleaved mutual
eval^Syn : Env Γ Δ → Syn σ Γ → Val σ Δ
eval^Chk : Env Γ Δ → Chk σ Γ → Val σ Δ
-- variable
eval^Syn vs (var v) = lookup vs v
-- change of direction
eval^Syn vs (cut t) = eval^Chk vs t
eval^Chk vs (emb t) = eval^Syn vs t
-- function introduction & elimination
eval^Syn vs (app f t) = eval^Syn vs f refl (eval^Chk vs t)
eval^Chk vs (lam b) = λ ρ v → eval^Chk (extend (th^Env ρ vs) v) b
interleaved mutual
norm^Syn : Syn σ Γ → Chk σ Γ
norm^Chk : Chk σ Γ → Chk σ Γ
norm^Syn t = norm^Chk (emb t)
norm^Chk t = reify _ (eval^Chk placeholders t)
| {
"alphanum_fraction": 0.5706031058,
"avg_line_length": 22.512195122,
"ext": "agda",
"hexsha": "9659368918d3e22b688ea0b8c611bceddff884ae",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/Issue2858-nbe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue2858-nbe.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue2858-nbe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1135,
"size": 2769
} |
{-# OPTIONS --without-K #-}
-- Rending the Program Runner
-- A proof of Lӧb′s theorem: quoted interpreters are inconsistent
-- Jason Gross
{- Title and some comments inspired by and drawn heavily from
"Scooping the Loop Sniffer: A proof that the Halting Problem is
undecidable", by Geoffrey K. Pullum
(http://www.lel.ed.ac.uk/~gpullum/loopsnoop.html) -}
open import common
infixl 2 _▻_
infixl 3 _‘’_
infixr 1 _‘→’_
{- "Scooping the Loop Sniffer", with slight modifications for this
code.
No general procedure for type-checking will do.
Now, I won’t just assert that, I’ll prove it to you.
I will prove that although you might work till you drop,
you cannot tell if computation will stop.
For imagine we have a procedure called P
that for specified input permits you to see
what specified source code, with all of its faults,
defines a routine that eventually halts.
You feed in your program, with suitable data,
and P gets to work, and a little while later
(in finite compute time) correctly infers
whether infinite looping behavior occurs.
If there will be no looping, then P prints out ‘Good.’
That means work on this input will halt, as it should.
But if it detects an unstoppable loop,
then P reports ‘Bad!’ — which means you’re in the soup.
Well, the truth is that P cannot possibly be,
because if you wrote it and gave it to me,
I could use it to set up a logical bind
that would shatter your reason and scramble your mind.
For a specified program, say ‶A″, one supplies,
the first step of this program called Q I devise
is to find out from P what’s the right thing to say
of the looping behavior of A run on ‶A″.
If P’s answer is ‘Bad!’, Q will suddenly stop.
But otherwise, Q will go back to the top,
and start off again, looping endlessly back,
till the universe dies and turns frozen and black.
And this program called Q wouldn’t stay on the shelf;
I would ask it to forecast its run on itself.
When it reads its own source code, just what will it do?
What’s the looping behavior of Q run on Q?
If P warns of infinite loops, Q will quit;
yet P is supposed to speak truly of it!
And if Q’s going to quit, then P should say ‘Good.’
Which makes Q start to loop! (P denied that it would.)
No matter how P might perform, Q will scoop it:
Q uses P’s output to make P look stupid.
Whatever P says, it cannot predict Q:
P is right when it’s wrong, and is false when it’s true!
I’ve created a paradox, neat as can be —
and simply by using your putative P.
When you posited P you stepped into a snare;
Your assumption has led you right into my lair.
So where can this argument possibly go?
I don’t have to tell you; I’m sure you must know.
A reductio: There cannot possibly be
a procedure that acts like the mythical P.
You can never find general mechanical means
for predicting the acts of computing machines;
it’s something that cannot be done. So we users
must find our own bugs. Our computers are losers! -}
{- Our program will act much like this Q, except that instead of saying that
Q will go back to the top,
and start off again, looping endlessly back,
till the universe dies and turns frozen and black.
We would say something more like that
Q will go back to the top,
and ask for the output of A run on ‶A″,
trusting P that execution will not run away.
Further more, we combine the type-checker and the interpreter; we show
there cannot be a well-typed quoted interpreter that interprets all
well-typed quoted terms directly, rather than having a separate phase
of type-checking. Morally, they should be equivalent. -}
{- We start off by defining Contexts, Types, and Terms which are
well-typed by construction.
We will prove that assuming Lӧb′s theorem is consistent in a minimal
representation, and doesn′t require anything fancy to support it in a
model of the syntax. Thus any reasonable syntax, which has a model,
will also have a model validating Lӧb′s theorem.
This last part is informal; it′s certainly conceivable that something
like internalized parametricity, which needs to do something special
with each constructor of the language, won't be able to do anything
with the quotation operator.
There's a much longer formalization of Lӧb′s theorem in this
repository which just assumes a quotation operator, and proves Lӧb′s
theorem by constructing it (though to build a quine, we end up needing
to decide equality of Contexts, which is fine); the quotation operator
is, in principle, definable, by stuffing the constructors of the
syntax into an initial context, and building up the quoted terms by
structural recursion. This would be even more painful, though, unless
there′s a nice way to give specific quoted terms.
Now, down to business. -}
mutual
-- Contexts are utterly standard
data Context : Set where
ε : Context
_▻_ : (Γ : Context) → Type Γ → Context
-- Types have standard substituition and non-dependent function
-- types.
data Type : Context → Set where
_‘’_ : ∀ {Γ A} → Type (Γ ▻ A) → Term {Γ} A → Type Γ
_‘→’_ : ∀ {Γ} → Type Γ → Type Γ → Type Γ
-- We also require that there be a quotation of ‶Type ε″ (called
-- ‘Typeε’), and a quotation of ‶Term ε″ (called ‘□’)
‘Typeε’ : Type ε
‘□’ : Type (ε ▻ ‘Typeε’)
-- We don′t really need quoted versions of ⊤ and ⊥, but they are
-- useful stating a few things after the proof of Lӧb′s theorem
‘⊤’ : ∀ {Γ} → Type Γ
‘⊥’ : ∀ {Γ} → Type Γ
-- Note that you can add whatever other constructors to this data
-- type you would like;
data Term : {Γ : Context} → Type Γ → Set where
-- We require the existence of a function (in the ambient language)
-- that takes a type in the empty context, and returns the quotation
-- of that type.
⌜_⌝ : Type ε → Term {ε} ‘Typeε’
-- Finally, we assume Lӧb′s theorem; we will show that this syntax
-- has a model.
Lӧb : ∀ {X} → Term {ε} (‘□’ ‘’ ⌜ X ⌝ ‘→’ X) → Term {ε} X
-- This is not strictly required, just useful for showing that some
-- type is inhabited.
‘tt’ : ∀ {Γ} → Term {Γ} ‘⊤’
{- ‶□ T″ is read ‶T is provable″ or ‶T is inhabited″ or ‶the type of
syntactic terms of the syntactic type T″ or ‶the type of quoted terms
of the quoted type T″. -}
□ : Type ε → Set _
□ = Term {ε}
mutual
{- Having an inhabitant of type ‶the interpretation of a given
Context″ is having an inhabitant of the interpretation of every type
in that Context. If we wanted to represent more universes, we could
sprinkle lifts and lowers, and it would not cause us trouble. They
are elided here for simplicity. -}
Context⇓ : (Γ : Context) → Set
Context⇓ ε = ⊤
Context⇓ (Γ ▻ T) = Σ (Context⇓ Γ) (Type⇓ {Γ} T)
-- Substitution and function types are interpreted standardly.
Type⇓ : {Γ : Context} → Type Γ → Context⇓ Γ → Set
Type⇓ (T ‘’ x) Γ⇓ = Type⇓ T (Γ⇓ , Term⇓ x Γ⇓)
Type⇓ (A ‘→’ B) Γ⇓ = Type⇓ A Γ⇓ → Type⇓ B Γ⇓
-- ‘Typeε’ is, unsurprisingly, interpreted as Type ε, the type of
-- syntactic types in the empty context.
Type⇓ ‘Typeε’ Γ⇓ = Type ε
-- ‘□’ expects Term of Type ‘Typeε’ as the last element of the
-- context, and represents the type of Terms of that Type. We take
-- the (already-interpreted) last element of the Context, and feed
-- it to Term {ε}, to get the Set of Terms of that Type.
Type⇓ ‘□’ Γ⇓ = Term {ε} (Σ.proj₂ Γ⇓)
-- The rest of the interpreter, for types not formally needed in
-- Lӧb′s theorem.
Type⇓ ‘⊤’ Γ⇓ = ⊤
Type⇓ ‘⊥’ Γ⇓ = ⊥
Term⇓ : ∀ {Γ : Context} {T : Type Γ} → Term T → (Γ⇓ : Context⇓ Γ) → Type⇓ T Γ⇓
-- Unsurprisingly, we interpret the quotation of a given source code
-- as the source code itself. (Defining the interpretation of
-- quotation is really trivial. Defining quotation itself is much
-- tricker.) Note that it is, I believe, essential, that every Type
-- be quotable. Otherwise Lӧb′s theorem cannot be internalized in
-- our syntactic representation, and will require both being given
-- both a type, and syntax which denotes to that type.
Term⇓ ⌜ x ⌝ Γ⇓ = x
-- Now, the interesting part. Given an interpreter (P in the poem,
-- □‘X’→X in this code), we validate Lӧb′s theorem (Q run on Q) by
-- running the interpreter on ... Q run on Q! It takes a bit of
-- thinking to wrap your head around, but the types line up, and
-- it′s beautifully simple.
Term⇓ (Lӧb □‘X’→X) Γ⇓ = Term⇓ □‘X’→X Γ⇓ (Lӧb □‘X’→X)
-- Inhabiting ⊤
Term⇓ ‘tt’ Γ⇓ = tt
⌞_⌟ : Type ε → Set _
⌞ T ⌟ = Type⇓ T tt
‘¬’_ : ∀ {Γ} → Type Γ → Type Γ
‘¬’ T = T ‘→’ ‘⊥’
-- With our interpreter, we can chain Lӧb′s theorem with itself: if we
-- can prove that ‶proving ‘X’ is sufficient to make ‘X’ true″, then
-- we can already inhabit X.
lӧb : ∀ {‘X’} → □ (‘□’ ‘’ ⌜ ‘X’ ⌝ ‘→’ ‘X’) → ⌞ ‘X’ ⌟
lӧb f = Term⇓ (Lӧb f) tt
-- We can thus prove that it′s impossible to prove that contradictions
-- are unprovable.
incompleteness : ¬ □ (‘¬’ (‘□’ ‘’ ⌜ ‘⊥’ ⌝))
incompleteness = lӧb
-- We can also prove that contradictions are, in fact, unprovable.
soundness : ¬ □ ‘⊥’
soundness x = Term⇓ x tt
-- And we can prove that some things are provable, namely, ‘⊤’
non-emptyness : Σ (Type ε) (λ T → □ T)
non-emptyness = ‘⊤’ , ‘tt’
| {
"alphanum_fraction": 0.6968271335,
"avg_line_length": 38.7288135593,
"ext": "agda",
"hexsha": "78a4f63f8dd07a131d172de47be2de7f78541e2f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z",
"max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JasonGross/lob",
"max_forks_repo_path": "internal/mini-lob-poem.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3",
"max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JasonGross/lob",
"max_issues_repo_path": "internal/mini-lob-poem.agda",
"max_line_length": 80,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JasonGross/lob",
"max_stars_repo_path": "internal/mini-lob-poem.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z",
"num_tokens": 2824,
"size": 9140
} |
open import Data.Product using ( _,_ ; proj₁ ; proj₂ )
open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )
open import Relation.Binary.PropositionalEquality using ( refl )
open import Relation.Unary using ( _∈_ )
open import Web.Semantic.DL.ABox using ( ABox ; _,_ ; ⟨ABox⟩ )
open import Web.Semantic.DL.ABox.Interp using ( Interp ; _,_ ; ⌊_⌋ ; ind ; _*_ )
open import Web.Semantic.DL.ABox.Interp.Morphism using
( _≲_ ; _,_ ; ≲⌊_⌋ ; ≲-resp-ind ; _**_ ; ≡³-impl-≈ ; ≡³-impl-≲ )
open import Web.Semantic.DL.ABox.Model using
( _⊨a_ ; _⊨b_ ; bnodes ; on-bnode ; _,_
; ⟨ABox⟩-resp-⊨ ; ⊨a-resp-≲ ; *-resp-⟨ABox⟩ )
open import Web.Semantic.DL.Category.Morphism using
( _⇒_ ; _⇒_w/_ ; _,_ ; BN ; impl ; impl✓ )
open import Web.Semantic.DL.Category.Object using
( Object ; _,_ ; IN ; fin ; iface )
open import Web.Semantic.DL.Integrity using
( _⊕_⊨_ ; Unique ; Mediated ; Mediator ; Initial
; _,_ ; extension ; ext-init ; ext-⊨ ; ext✓ ; init-≲ )
open import Web.Semantic.DL.KB using ( _,_ )
open import Web.Semantic.DL.KB.Model using ( _⊨_ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox using ( TBox ; _,_ )
open import Web.Semantic.DL.TBox.Interp using
( Δ ; _⊨_≈_ ; ≈-refl ; ≈-sym ; ≈-trans )
open import Web.Semantic.DL.TBox.Model using ( _⊨t_ )
open import Web.Semantic.DL.TBox.Interp.Morphism using
( ≲-image ; ≲-resp-≈ ; ≲-trans ) renaming ( _≲_ to _≲′_ )
open import Web.Semantic.Util using
( _∘_ ; Finite ; ⊎-resp-Fin ; _⊕_⊕_ ; inode ; bnode ; enode ; up ; down ; vmerge )
module Web.Semantic.DL.Category.Tensor {Σ : Signature} where
_&_ : ∀ {X₁ X₂} → ABox Σ X₁ → ABox Σ X₂ → ABox Σ (X₁ ⊎ X₂)
A₁ & A₂ = (⟨ABox⟩ inj₁ A₁ , ⟨ABox⟩ inj₂ A₂)
_⊗_ : ∀ {S T : TBox Σ} → Object S T → Object S T → Object S T
A₁ ⊗ A₂ =
( (IN A₁ ⊎ IN A₂)
, ⊎-resp-Fin (fin A₁) (fin A₂)
, iface A₁ & iface A₂ )
_⟨&⟩_ : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} →
ABox Σ (X₁ ⊕ V₁ ⊕ Y₁) → ABox Σ (X₂ ⊕ V₂ ⊕ Y₂) →
ABox Σ ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂))
F₁ ⟨&⟩ F₂ = (⟨ABox⟩ up F₁ , ⟨ABox⟩ down F₂)
⊨a-intro-⟨&⟩ : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} →
(I : Interp Σ ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂))) →
(F₁ : ABox Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (F₂ : ABox Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(up * I ⊨a F₁) → (down * I ⊨a F₂) → (I ⊨a F₁ ⟨&⟩ F₂)
⊨a-intro-⟨&⟩ (I , i) F₁ F₂ I₁⊨F₁ I₂⊨F₂ =
( ⟨ABox⟩-resp-⊨ up (λ x → ≈-refl I) F₁ I₁⊨F₁
, ⟨ABox⟩-resp-⊨ down (λ x → ≈-refl I) F₂ I₂⊨F₂ )
⊨b-intro-⟨&⟩ : ∀ {V₁ V₂ W₁ W₂ X₁ X₂ Y₁ Y₂} →
(I : Interp Σ ((X₁ ⊎ X₂) ⊕ (W₁ ⊎ W₂) ⊕ (Y₁ ⊎ Y₂))) →
(F₁ : ABox Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (F₂ : ABox Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(up * I ⊨b F₁) → (down * I ⊨b F₂) → (I ⊨b F₁ ⟨&⟩ F₂)
⊨b-intro-⟨&⟩ {V₁} {V₂} I F₁ F₂ (f₁ , I₁⊨F₁) (f₂ , I₂⊨F₂) =
(f , I⊨F₁F₂) where
f : (V₁ ⊎ V₂) → Δ ⌊ I ⌋
f (inj₁ v) = f₁ v
f (inj₂ v) = f₂ v
I⊨F₁F₂ : bnodes I f ⊨a F₁ ⟨&⟩ F₂
I⊨F₁F₂ =
( ⟨ABox⟩-resp-⊨ up
(≡³-impl-≈ ⌊ I ⌋ (on-bnode f₁ (ind I ∘ up))
(on-bnode f (ind I) ∘ up) refl)
F₁ I₁⊨F₁
, ⟨ABox⟩-resp-⊨ down
(≡³-impl-≈ ⌊ I ⌋ (on-bnode f₂ (ind I ∘ down))
(on-bnode f (ind I) ∘ down) refl)
F₂ I₂⊨F₂ )
go₂ : ∀ {V₁ X₁ X₂ Y₁} → (I : Interp Σ (X₁ ⊎ X₂)) →
(J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (⌊ I ⌋ ≲′ ⌊ J₁ ⌋) →
Interp Σ X₂
go₂ I J₁ I≲J = (⌊ J₁ ⌋ , ≲-image I≲J ∘ ind I ∘ inj₂)
go₂-≳ : ∀ {V₁ X₁ X₂ Y₁} → (I : Interp Σ (X₁ ⊎ X₂)) →
(J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (I≲J : ⌊ I ⌋ ≲′ ⌊ J₁ ⌋) →
(inj₂ * I ≲ go₂ I J₁ I≲J)
go₂-≳ I (J , j₁) I≲J = (I≲J , λ x → ≈-refl J)
go₂-≲ : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (I : Interp Σ (X₁ ⊎ X₂)) →
(J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) →
(L : Interp Σ ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂))) →
(I₁≲J₁ : inj₁ * I ≲ inode * J₁) → (I≲L : I ≲ inode * L) →
(Mediated (inj₁ * I) J₁ (up * L) I₁≲J₁ (inj₁ ** I≲L)) →
(go₂ I J₁ ≲⌊ I₁≲J₁ ⌋ ≲ inode * (down * L))
go₂-≲ (I , i) (J , j₁) (L , l) (I≲J , i₁≲j₁) (I≲L , i≲l)
((J≲L , j₁≲l₁) , I≲L≋I≲J≲L , J₁≲L₁-uniq) =
(J≲L , λ x → ≈-trans L (≈-sym L (I≲L≋I≲J≲L (i (inj₂ x)))) (i≲l (inj₂ x)))
par : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) →
(K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) → (⌊ J₁ ⌋ ≲′ ⌊ K₂ ⌋) →
Interp Σ ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂))
par J₁ K₂ J≲K =
(⌊ K₂ ⌋ , vmerge (≲-image J≲K ∘ ind J₁) (ind K₂))
par-inj₁ : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) →
(K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) → (J≲K : ⌊ J₁ ⌋ ≲′ ⌊ K₂ ⌋) →
(J₁ ≲ up * par J₁ K₂ J≲K)
par-inj₁ (J , j₁) (K , k₂) J≲K =
( J≲K
, ≡³-impl-≈ K
(≲-image J≲K ∘ j₁)
(vmerge (≲-image J≲K ∘ j₁) k₂ ∘ up)
refl )
par-inj₂ : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) →
(K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) → (J≲K : ⌊ J₁ ⌋ ≲′ ⌊ K₂ ⌋) →
(K₂ ≲ down * par J₁ K₂ J≲K)
par-inj₂ (J , j₁) (K , k₂) J≲K =
≡³-impl-≲ (K , k₂) (vmerge (≲-image J≲K ∘ j₁) k₂ ∘ down) refl
par-exp : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) →
(K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) → (J≲K : ⌊ J₁ ⌋ ≲′ ⌊ K₂ ⌋) →
(T : TBox Σ) → (B₁ : ABox Σ Y₁) → (B₂ : ABox Σ Y₂) →
(enode * J₁ ⊨ T , B₁) → (enode * K₂ ⊨ T , B₂) →
(enode * (par J₁ K₂ J≲K) ⊨ T , (B₁ & B₂))
par-exp J₁ K₂ J≲K T B₁ B₂ (J⊨T , J₁⊨B₁) (K⊨T , K₂⊨B₂) =
( K⊨T
, ⟨ABox⟩-resp-⊨ inj₁ (λ y → ≈-refl ⌊ K₂ ⌋) B₁
(⊨a-resp-≲ (enode ** par-inj₁ J₁ K₂ J≲K) B₁ J₁⊨B₁)
, ⟨ABox⟩-resp-⊨ inj₂ (λ y → ≈-refl ⌊ K₂ ⌋) B₂ K₂⊨B₂)
par-≳ : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (I : Interp Σ (X₁ ⊎ X₂)) →
(J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(I₁≲J₁ : inj₁ * I ≲ inode * J₁) →
(J₂≲K₂ : go₂ I J₁ ≲⌊ I₁≲J₁ ⌋ ≲ inode * K₂) →
(I ≲ inode * par J₁ K₂ ≲⌊ J₂≲K₂ ⌋)
par-≳ I J₁ K₂ (I≲J , i₁≲j₁) (J≲K , j₂≲k₂) =
( ≲-trans I≲J J≲K , lemma ) where
lemma : ∀ x → ⌊ K₂ ⌋ ⊨
≲-image J≲K (≲-image I≲J (ind I x)) ≈
vmerge (≲-image J≲K ∘ ind J₁) (ind K₂) (inode x)
lemma (inj₁ x) = ≲-resp-≈ J≲K (i₁≲j₁ x)
lemma (inj₂ x) = j₂≲k₂ x
par-impl : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) →
(K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) → (J≲K : ⌊ J₁ ⌋ ≲′ ⌊ K₂ ⌋) →
(F₁ : ABox Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (F₂ : ABox Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(J₁ ⊨a F₁) → (K₂ ⊨a F₂) →
(par J₁ K₂ J≲K ⊨a F₁ ⟨&⟩ F₂)
par-impl J₁ K₂ J≲K F₁ F₂ J₁⊨F₁ K₂⊨F₂ =
( ⟨ABox⟩-resp-⊨ up (λ x → ≈-refl ⌊ K₂ ⌋) F₁
(⊨a-resp-≲ (par-inj₁ J₁ K₂ J≲K) F₁ J₁⊨F₁)
, ⟨ABox⟩-resp-⊨ down (λ x → ≈-refl ⌊ K₂ ⌋) F₂
(⊨a-resp-≲ (par-inj₂ J₁ K₂ J≲K) F₂ K₂⊨F₂) )
par-mediated : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (I : Interp Σ (X₁ ⊎ X₂)) →
(J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(L : Interp Σ ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂))) →
(I₁≲J₁ : inj₁ * I ≲ inode * J₁) → (I≲L : I ≲ inode * L) →
(J₂≲K₂ : go₂ I J₁ ≲⌊ I₁≲J₁ ⌋ ≲ inode * K₂) →
(m : Mediated (inj₁ * I) J₁ (up * L) I₁≲J₁ (inj₁ ** I≲L)) →
(Mediated (go₂ I J₁ ≲⌊ I₁≲J₁ ⌋) K₂ (down * L) J₂≲K₂ (go₂-≲ I J₁ L I₁≲J₁ I≲L m)) →
(Mediated I (par J₁ K₂ ≲⌊ J₂≲K₂ ⌋) L (par-≳ I J₁ K₂ I₁≲J₁ J₂≲K₂) I≲L)
par-mediated (I , i) (J , j₁) (K , k₂) (L , l) (I≲J , i₁≲j₁) (I≲L , i≲l) (J≲K , j₂≲k₂)
((J≲L , j₁≲l₁) , I≲L≋I≲J≲L , J₁≲L₁-uniq) ((K≲L , k₂≲l₂) , J≲L≋J≲K≲L , K₂≲L₂-uniq) =
((K≲L , k≲l) , I≲L≋I≲K≲L , K≲L-uniq) where
k = vmerge (≲-image J≲K ∘ j₁) k₂
I≲K : I ≲′ K
I≲K = ≲-trans I≲J J≲K
i≲k : ∀ x → K ⊨ ≲-image I≲K (i x) ≈ k (inode x)
i≲k = ≲-resp-ind (par-≳ (I , i) (J , j₁) (K , k₂) (I≲J , i₁≲j₁) (J≲K , j₂≲k₂))
k≲l : ∀ x → L ⊨ ≲-image K≲L (k x) ≈ l x
k≲l (inode (inj₁ x)) = ≈-trans L (≈-sym L (J≲L≋J≲K≲L (j₁ (inode x)))) (j₁≲l₁ (inode x))
k≲l (inode (inj₂ x)) = k₂≲l₂ (inode x)
k≲l (bnode (inj₁ v)) = ≈-trans L (≈-sym L (J≲L≋J≲K≲L (j₁ (bnode v)))) (j₁≲l₁ (bnode v))
k≲l (bnode (inj₂ v)) = k₂≲l₂ (bnode v)
k≲l (enode (inj₁ y)) = ≈-trans L (≈-sym L (J≲L≋J≲K≲L (j₁ (enode y)))) (j₁≲l₁ (enode y))
k≲l (enode (inj₂ y)) = k₂≲l₂ (enode y)
I≲L≋I≲K≲L : ∀ x → L ⊨ ≲-image I≲L x ≈ ≲-image K≲L (≲-image I≲K x)
I≲L≋I≲K≲L x = ≈-trans L (I≲L≋I≲J≲L x) (J≲L≋J≲K≲L (≲-image I≲J x))
lemma₁ : ∀ (K≲L : (K , k) ≲ (L , l)) x → (L ⊨ ≲-image ≲⌊ K≲L ⌋ (≲-image J≲K (j₁ x)) ≈ l (up x))
lemma₁ (K≲L' , k≲l) (inode x) = k≲l (inode (inj₁ x))
lemma₁ (K≲L' , k≲l) (bnode v) = k≲l (bnode (inj₁ v))
lemma₁ (K≲L' , k≲l) (enode y) = k≲l (enode (inj₁ y))
lemma₂ : ∀ (K≲L : (K , k) ≲ (L , l)) x → (L ⊨ ≲-image ≲⌊ K≲L ⌋ (k₂ x) ≈ l (down x))
lemma₂ (K≲L , k≲l) (inode x) = k≲l (inode (inj₂ x))
lemma₂ (K≲L , k≲l) (bnode v) = k≲l (bnode (inj₂ v))
lemma₂ (K≲L , k≲l) (enode y) = k≲l (enode (inj₂ y))
K≲L-uniq : Unique (I , i) (K , k) (L , l) (I≲K , i≲k) (I≲L , i≲l)
K≲L-uniq (K≲₁L , k≲₁l) (K≲₂L , k≲₂l) I≲L≋I≲K≲₁L I≲L≋I≲K≲₂L =
K₂≲L₂-uniq (K≲₁L , lemma₂ (K≲₁L , k≲₁l)) (K≲₂L , lemma₂ (K≲₂L , k≲₂l))
(J₁≲L₁-uniq (J≲L , j₁≲l₁) (≲-trans J≲K K≲₁L , lemma₁ (K≲₁L , k≲₁l)) I≲L≋I≲J≲L I≲L≋I≲K≲₁L)
(J₁≲L₁-uniq (J≲L , j₁≲l₁) (≲-trans J≲K K≲₂L , lemma₁ (K≲₂L , k≲₂l)) I≲L≋I≲J≲L I≲L≋I≲K≲₂L)
par-mediator : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (I : Interp Σ (X₁ ⊎ X₂)) →
(J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(I₁≲J₁ : inj₁ * I ≲ inode * J₁) →
(J₂≲K₂ : go₂ I J₁ ≲⌊ I₁≲J₁ ⌋ ≲ inode * K₂) → (S : TBox Σ) →
(F₁ : ABox Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (F₂ : ABox Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(Mediator (inj₁ * I) J₁ I₁≲J₁ (S , F₁)) →
(Mediator (go₂ I J₁ ≲⌊ I₁≲J₁ ⌋) K₂ J₂≲K₂ (S , F₂)) →
(Mediator I (par J₁ K₂ ≲⌊ J₂≲K₂ ⌋)
(par-≳ I J₁ K₂ I₁≲J₁ J₂≲K₂) (S , (F₁ ⟨&⟩ F₂)))
par-mediator I J₁ K₂ I₁≲J₁ J₂≲K₂ S F₁ F₂ J₁-med K₂-med L I≲L (L⊨S , L⊨F₁ , L⊨F₂) =
par-mediated I J₁ K₂ L I₁≲J₁ I≲L J₂≲K₂ I₁≲J₁≲L₁-med J₂≲K₂≲L₂-med where
I₁≲J₁≲L₁-med : Mediated (inj₁ * I) J₁ (up * L) I₁≲J₁ (inj₁ ** I≲L)
I₁≲J₁≲L₁-med = J₁-med (up * L) (inj₁ ** I≲L) (L⊨S , *-resp-⟨ABox⟩ up L F₁ L⊨F₁)
J₂≲K₂≲L₂-med : Mediated (go₂ I J₁ ≲⌊ I₁≲J₁ ⌋) K₂ (down * L) J₂≲K₂ (go₂-≲ I J₁ L I₁≲J₁ I≲L I₁≲J₁≲L₁-med)
J₂≲K₂≲L₂-med = K₂-med (down * L) (go₂-≲ I J₁ L I₁≲J₁ I≲L I₁≲J₁≲L₁-med) (L⊨S , *-resp-⟨ABox⟩ down L F₂ L⊨F₂)
par-init : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (I : Interp Σ (X₁ ⊎ X₂)) →
(J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(S : TBox Σ) → (F₁ : ABox Σ (X₁ ⊕ V₁ ⊕ Y₁)) → (F₂ : ABox Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(J₁-init : J₁ ∈ Initial (inj₁ * I) (S , F₁)) →
(K₂-init : K₂ ∈ Initial (go₂ I J₁ ≲⌊ init-≲ J₁-init ⌋) (S , F₂)) →
(par J₁ K₂ ≲⌊ init-≲ K₂-init ⌋ ∈
Initial I (S , (F₁ ⟨&⟩ F₂)))
par-init I J₁ K₂ S F₁ F₂
(I₁≲J₁ , (J⊨S , J₁⊨F₁) , J₁-med) (J₂≲K₂ , (K⊨S , K₂⊨F₂) , K₂-med) =
( par-≳ I J₁ K₂ I₁≲J₁ J₂≲K₂
, (K⊨S , par-impl J₁ K₂ ≲⌊ J₂≲K₂ ⌋ F₁ F₂ J₁⊨F₁ K₂⊨F₂)
, par-mediator I J₁ K₂ I₁≲J₁ J₂≲K₂ S F₁ F₂ J₁-med K₂-med )
tensor-⊨ : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (S T : TBox Σ) →
(A₁ : ABox Σ X₁) → (A₂ : ABox Σ X₂) → (B₁ : ABox Σ Y₁) → (B₂ : ABox Σ Y₂) →
(F₁ : ABox Σ (X₁ ⊕ V₁ ⊕ Y₁)) (F₂ : ABox Σ (X₂ ⊕ V₂ ⊕ Y₂)) →
(∀ I → (I ⊨ (S , T) , A₁) → (I ⊕ S , F₁ ⊨ T , B₁)) →
(∀ I → (I ⊨ (S , T) , A₂) → (I ⊕ S , F₂ ⊨ T , B₂)) →
(∀ I → (I ⊨ (S , T) , (A₁ & A₂)) →
(I ⊕ S , F₁ ⟨&⟩ F₂ ⊨ T , (B₁ & B₂)))
tensor-⊨ {V₁} {V₂} {X₁} {X₂} {Y₁} {Y₂}
S T A₁ A₂ B₁ B₂ F₁ F₂ F₁✓ F₂✓ I (I⊨ST , (I⊨A₁ , I⊨A₂)) =
( par J₁ K₂ ≲⌊ J₂≲K₂ ⌋
, par-init I J₁ K₂ S F₁ F₂ J₁-init K₂-init
, par-exp J₁ K₂ ≲⌊ J₂≲K₂ ⌋ T B₁ B₂
(ext-⊨ I₁⊕SF₁⊨TB₁) (ext-⊨ J₂⊕SF₂⊨TB₂) ) where
I₁ : Interp Σ X₁
I₁ = inj₁ * I
I₂ : Interp Σ X₂
I₂ = inj₂ * I
I₁⊨A₁ : I₁ ⊨a A₁
I₁⊨A₁ = *-resp-⟨ABox⟩ inj₁ I A₁ I⊨A₁
I₂⊨A₂ : I₂ ⊨a A₂
I₂⊨A₂ = *-resp-⟨ABox⟩ inj₂ I A₂ I⊨A₂
I₁⊕SF₁⊨TB₁ : I₁ ⊕ S , F₁ ⊨ T , B₁
I₁⊕SF₁⊨TB₁ = F₁✓ I₁ (I⊨ST , I₁⊨A₁)
J₁ : Interp Σ (X₁ ⊕ V₁ ⊕ Y₁)
J₁ = extension I₁⊕SF₁⊨TB₁
J₁-init : J₁ ∈ Initial I₁ (S , F₁)
J₁-init = ext-init I₁⊕SF₁⊨TB₁
I₁≲J₁ : I₁ ≲ inode * J₁
I₁≲J₁ = init-≲ J₁-init
J₂ : Interp Σ X₂
J₂ = go₂ I J₁ ≲⌊ I₁≲J₁ ⌋
I₂≲J₂ : I₂ ≲ J₂
I₂≲J₂ = go₂-≳ I J₁ ≲⌊ I₁≲J₁ ⌋
J⊨ST : ⌊ J₂ ⌋ ⊨t (S , T)
J⊨ST = proj₁ (ext✓ I₁⊕SF₁⊨TB₁)
J₂⊨A₂ : J₂ ⊨a A₂
J₂⊨A₂ = ⊨a-resp-≲ I₂≲J₂ A₂ I₂⊨A₂
J₂⊕SF₂⊨TB₂ : J₂ ⊕ S , F₂ ⊨ T , B₂
J₂⊕SF₂⊨TB₂ = F₂✓ J₂ (J⊨ST , J₂⊨A₂)
K₂ : Interp Σ (X₂ ⊕ V₂ ⊕ Y₂)
K₂ = extension J₂⊕SF₂⊨TB₂
K₂-init : K₂ ∈ Initial J₂ (S , F₂)
K₂-init = ext-init J₂⊕SF₂⊨TB₂
J₂≲K₂ : J₂ ≲ inode * K₂
J₂≲K₂ = init-≲ K₂-init
_⟨⊗⟩′_ : ∀ {S T : TBox Σ} {A₁ A₂ B₁ B₂ : Object S T} →
(F₁ : A₁ ⇒ B₁) → (F₂ : A₂ ⇒ B₂) →
((A₁ ⊗ A₂) ⇒ (B₁ ⊗ B₂) w/ (BN F₁ ⊎ BN F₂))
_⟨⊗⟩′_ {S} {T} {X₁ , X₁∈Fin , A₁} {X₂ , X₂∈Fin , A₂} {Y₁ , Y₁∈Fin , B₁} {Y₂ , Y₂∈Fin , B₂}
(V₁ , F₁ , F₁✓) (V₂ , F₂ , F₂✓) =
(F₁ ⟨&⟩ F₂ , tensor-⊨ S T A₁ A₂ B₁ B₂ F₁ F₂ F₁✓ F₂✓)
_⟨⊗⟩_ : ∀ {S T : TBox Σ} {A₁ A₂ B₁ B₂ : Object S T} →
(A₁ ⇒ B₁) → (A₂ ⇒ B₂) → ((A₁ ⊗ A₂) ⇒ (B₁ ⊗ B₂))
F₁ ⟨⊗⟩ F₂ = ( (BN F₁ ⊎ BN F₂) , F₁ ⟨⊗⟩′ F₂ )
| {
"alphanum_fraction": 0.4724683544,
"avg_line_length": 41.4426229508,
"ext": "agda",
"hexsha": "a37718126c0f7db84d920671deea48307923f0ef",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
"max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/Category/Tensor.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/Category/Tensor.agda",
"max_line_length": 109,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/DL/Category/Tensor.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
"num_tokens": 7982,
"size": 12640
} |
open import Relation.Ternary.Separation
module Relation.Ternary.Separation.Monad.CompleteUpdate
{a} {A : Set a} {{r : RawSep A}} {u} {{ s : IsUnitalSep r u }}
where
open import Function
open import Level hiding (Lift)
open import Data.Product
open import Data.Unit using (⊤)
open import Relation.Unary
open import Relation.Unary.PredicateTransformer using (Pt)
open import Relation.Binary hiding (_⇒_)
open import Relation.Binary.PropositionalEquality as P
open import Relation.Ternary.Separation.Morphisms
open import Relation.Ternary.Separation.Monad
open import Relation.Ternary.Separation.Construct.Product
open import Relation.Ternary.Separation.Construct.Market
open Monads {{ bs = record { Carrier = A × A } }} (id-morph (A × A))
open ⟰_
module Update where
private bind' : ∀ {p q} {P : Pred (A × A) p} {Q : Pred (A × A) q} → ∀[ (P ─✴ ⟰ Q) ⇒ (⟰ P ─✴ ⟰ Q) ]
updater (app (bind' f) c σ) fr with ⊎-assoc (⊎-comm σ) fr
... | xs , σ₂ , σ₃ with updater c σ₂
... | ys , zs , σ₄ , px with ⊎-unassoc σ₄ σ₃
... | _ , σ₅ , σ₆ = updater (app f px (⊎-comm σ₅)) σ₆
⟰-monad : Monad ⊤ a (λ _ _ → ⟰_)
updater (Monad.return ⟰-monad px) fr = -, -, fr , px
Monad.bind ⟰-monad = bind'
{- updates with failure -}
module UpdateWithFailure where
open import Relation.Ternary.Separation.Monad.Error
open import Data.Sum
⟰? : Pt (A × A) a
⟰? P = ⟰ (Err P)
instance ⟰?-monad : Monad ⊤ a (λ _ _ → ⟰?)
Monad.return ⟰?-monad px = Monad.return Update.⟰-monad (return px)
updater (app (Monad.bind ⟰?-monad f) m σ) fr with ⊎-assoc (⊎-comm σ) fr
... | _ , σ₂ , σ₃ with updater m σ₂
... | _ , _ , τ₁ , error = -, -, fr , error
... | _ , _ , τ₁ , partial (inj₂ v) with ⊎-unassoc τ₁ σ₃
... | _ , τ₃ , τ₄ = updater (app f v (⊎-comm τ₃)) τ₄
⟰error : ∀ P → ∀[ ⟰? P ]
updater (⟰error _) fr = -, -, fr , error
| {
"alphanum_fraction": 0.6296296296,
"avg_line_length": 33.3818181818,
"ext": "agda",
"hexsha": "19ec29e50eb88dc3aafb15ae01605473b8c23511",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Relation/Ternary/Separation/Monad/CompleteUpdate.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "laMudri/linear.agda",
"max_issues_repo_path": "src/Relation/Ternary/Separation/Monad/CompleteUpdate.agda",
"max_line_length": 100,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Relation/Ternary/Separation/Monad/CompleteUpdate.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 674,
"size": 1836
} |
--{-# OPTIONS --verbose 10 #-}
open import ExtractSac as ES using ()
open import Extract (ES.kompile-fun)
open import Data.Nat as N using (ℕ; zero; suc; _≤_; _≥_; _<_; s≤s; z≤n)
import Data.Nat.DivMod as N
open import Data.Nat.Properties as N
open import Data.List as L using (List; []; _∷_)
open import Data.Vec as V using (Vec; []; _∷_)
import Data.Vec.Properties as V
open import Data.Fin as F using (Fin; zero; suc; #_)
import Data.Fin.Properties as F
open import Data.Product as Prod using (Σ; _,_; curry; uncurry) renaming (_×_ to _⊗_)
open import Relation.Binary.PropositionalEquality
open import Reflection
open import Structures
open import Function
open import ReflHelper
open import Array.Base
open import Array.Properties
open import APL2
open import Agda.Builtin.Float
-- Verbose facts about transitivity of <, ≤, and ≡
a≤b⇒b≡c⇒a≤c : ∀ {a b c} → a ≤ b → b ≡ c → a ≤ c
a≤b⇒b≡c⇒a≤c a≤b refl = a≤b
a≤b⇒a≡c⇒b≡d⇒c≤d : ∀ {a b c d} → a ≤ b → a ≡ c → b ≡ d → c ≤ d
a≤b⇒a≡c⇒b≡d⇒c≤d a≤b refl refl = a≤b
a<b⇒0<b : ∀ {a b} → a < b → zero < b
a<b⇒0<b {a} a<b = ≤-trans (s≤s z≤n) a<b
a<b⇒c≤a⇒c<b : ∀ {a b c} → a < b → c ≤ a → c < b
a<b⇒c≤a⇒c<b a<b z≤n = a<b⇒0<b a<b
a<b⇒c≤a⇒c<b (s≤s a<b) (s≤s c≤a) = s≤s (a<b⇒c≤a⇒c<b a<b c≤a)
a≤b⇒c≤a⇒c≤b : ∀ {a b c} → a ≤ b → c ≤ a → c ≤ b
a≤b⇒c≤a⇒c≤b {a} {b} {c} a≤b c≤a = ≤-trans c≤a a≤b
A<B⇒B≤C⇒A≤C : ∀ {n}{ix s s₁ : Ar ℕ 1 (n ∷ [])}
→ ix <a s → s₁ ≥a s → s₁ ≥a ix
A<B⇒B≤C⇒A≤C {ix = imap x} {imap x₁} {imap x₂} ix<s ix≤s₁ iv = ≤-trans (<⇒≤ $ ix<s iv) (ix≤s₁ iv)
A≥B⇒A≡C⇒C≥B : ∀ {d s}{A B C : Ar ℕ d s}
→ A ≥a B → A =a C → C ≥a B
A≥B⇒A≡C⇒C≥B {A = imap x} {imap x₁} {imap x₂} A≥B A≡C iv rewrite (sym $ A≡C iv) = A≥B iv
-- Something that could go in Stdlib.
a≤a*b : ∀ {a b} → a ≤ a N.* suc b
a≤a*b {a} {b = zero} rewrite (*-identityʳ a) = ≤-refl
a≤a*b {a} {b = suc b} = ≤-trans a≤a*b (*-monoʳ-≤ a (≤-step ≤-refl))
a-s[b]+1≡a-b : ∀ {a b} → b < a → a N.∸ suc b N.+ 1 ≡ a N.∸ b
a-s[b]+1≡a-b {a} {b} pf = begin
a N.∸ suc (b) N.+ 1 ≡⟨ sym $ N.+-∸-comm 1 pf ⟩
a N.+ 1 N.∸ suc b ≡⟨ cong₂ N._∸_ (N.+-comm a 1) (refl {x = suc b}) ⟩
a N.∸ b
∎
where open ≡-Reasoning
conv-ix-inb : ∀ {n}{ix s s₁ : Ar ℕ 1 (n ∷ [])}
→ (ix<s : ix <a s)
→ (s₁≥s : s₁ ≥a s)
→ (s₁ - ix) {≥ = A<B⇒B≤C⇒A≤C {s₁ = s₁} ix<s s₁≥s}
≥a ((s₁ - s) {≥ = s₁≥s} + ( 1))
conv-ix-inb {ix = imap ix} {imap s} {imap s₁} ix<s s₁≥s iv =
let
s₁-[1+ix]≥s₁-s = ∸-monoʳ-≤ (s₁ iv) (ix<s iv)
s₁-[1+ix]+1≥s₁-s+1 = +-monoˡ-≤ 1 s₁-[1+ix]≥s₁-s
in a≤b⇒b≡c⇒a≤c s₁-[1+ix]+1≥s₁-s+1 (a-s[b]+1≡a-b {a = s₁ iv} {b = ix iv} (≤-trans (ix<s iv) (s₁≥s iv)))
undo-lkptab : ∀ {n s₁}{ix : Ar ℕ 1 (n ∷ [])} (iv : Ix 1 (n ∷ [])) →
V.lookup s₁ (ix-lookup iv zero) N.∸ sel ix iv ≡
V.lookup (V.tabulate (λ i → V.lookup s₁ i N.∸ sel ix (i ∷ [])))
(ix-lookup iv zero)
undo-lkptab {s₁ = s₁}{ix} (i ∷ []) = sym (V.lookup∘tabulate _ i)
-- conv ← {a←⍵ ⋄ w←⍺ ⋄ ⊃+/,w×{(1+(⍴a)-⍴w)↑⍵↓a}¨⍳⍴w}
infixr 20 _conv_
_conv_ : ∀ {n wₛ aₛ}
→ Ar Float n wₛ
→ Ar Float n aₛ
→ {≥ : ▴ aₛ ≥a ▴ wₛ}
→ Ar Float n $ ▾ ((aₛ - wₛ){≥} + 1)
_conv_ {n = n} {wₛ = s} {aₛ = s₁} w a {s₁≥s} = let
sr = (s₁ - s) {≥ = s₁≥s} + 1
idxs = ι ρ w
rots ix ix<s = let
~ix≥ρa = A<B⇒B≤C⇒A≤C ix<s s₁≥s
ix↓a = (ix ↓ a) {pf = ~ix≥ρa}
~ix-inb = conv-ix-inb {s₁ = s→a s₁} ix<s s₁≥s
~ρix↓a≥sr = A≥B⇒A≡C⇒C≥B ~ix-inb (undo-lkptab {s₁ = s₁}{ix = ix})
in
(sr ↑ ix↓a) {pf = ~ρix↓a≥sr }
r = (uncurry rots) ̈ idxs
mul = w ̈⟨ _×ᵣ_ ⟩ (subst-ar (a→s∘s→a s) r)
res = reduce-1d _+ᵣ_ (cst 0.0) (, mul)
in res
--kconv : Prog
kconv = kompile _conv_ (quote _≥a_ ∷ quote reduce-1d ∷ quote _↑_ ∷ quote _↓_ ∷ []) [] -- (quote reduce-1d ∷ [])
--kconvr = frefl _conv_ (quote _≥a_ ∷ quote reduce-1d ∷ quote _↑_ ∷ quote _↓_ ∷ [])
--kconvr = frefl _conv_ (quote _≥a_ ∷ quote reduce-1d ∷ [])
--ktake : Term
--ktake = frefl _↑_ (quote _≥a_ ∷ quote reduce-1d ∷ [])
test-lw : ℕ → ℕ
test-lw n = case n of λ where
1 → n N.+ 5
_ → n N.+ 6
--ktest-lw = frefl test-lw []
n≤sn-i : ∀ {i n} → i N.≤ 1 → n N.≤ suc n N.∸ i
n≤sn-i z≤n = <⇒≤ N.≤-refl
n≤sn-i (s≤s z≤n) = N.≤-refl
--test-take : ∀ {n} → Ix 1 V.[ 2 ] → Ar ℕ 1 V.[ 1 N.+ n ] → Ar ℕ 1 V.[ n ]
--test-take {n} ix@(i ∷ []) a =
-- let ixₐ , ix<[2] = ix→a ix
-- r' = (ixₐ ↓ a) {λ where jv@(zero ∷ []) → N.≤-trans (≤-pred $ ix<[2] jv) (s≤s z≤n)}
-- r = (cst n ↑ r') {λ where jv@(zero ∷ []) → n≤sn-i (≤-pred $ F.toℕ<n i) }
-- in r
test-take : ∀ {n} → Ix 1 V.[ 2 ] → Ar ℕ 1 V.[ 1 N.+ n ] → Ar ℕ 1 V.[ n ]
test-take {n} ix@(i ∷ []) a = r
where
ixₐ = Prod.proj₁ $ ix→a ix
ix<[2] = Prod.proj₂ $ ix→a ix
r' = (ixₐ ↓ a) {λ where jv@(zero ∷ []) → N.≤-trans (≤-pred $ ix<[2] jv) (s≤s z≤n)}
r = (cst n ↑ r') {λ where jv@(zero ∷ []) → n≤sn-i (≤-pred $ F.toℕ<n i) }
-- XXX These guys cause an impossible state.
--ktestr = frefl test-take []
--ktest : Prog
--ktest = kompile test-take (quote _≥a_ ∷ quote reduce-1d ∷ quote N._≟_ ∷ quote prod ∷ quote _↑_ ∷ quote _↓_ ∷ []) []
-- multiconv←{(a ws bs)←⍵⋄bs{⍺+⍵ conv a}⍤(0,(⍴⍴a))⊢ws}
multiconv : ∀ {n m s sw so} → (a : Ar Float n s)
→ (ws : Ar (Ar Float n sw) m so)
→ (bs : Ar Float m so)
→ {≥ : ▴ s ≥a ▴ sw}
→ Ar (Ar Float n $ ▾ ((s - sw){≥} + 1)) m so
multiconv a ws bs {≥} = bs ̈⟨ (λ α ω → α +ᵣ (ω conv a){≥}) ⟩ ws
--kmconv = kompile multiconv (quote _≥a_ ∷ quote reduce-1d ∷ quote _↑_ ∷ quote _↓_ ∷ []) [] -- (quote reduce-1d ∷ [])
{-
takeN : ∀ {n s}
→ (sh : Ar ℕ 1 (n ∷ []))
→ (a : Ar ℕ n s)
→ {pf : s→a s ≥a sh}
→ Ar ℕ n $ a→s sh
takeN sh a {pf} = (sh ↑ a){pf}
module _ where
open import Relation.Nullary
dec-test : ∀ {n} → (sh : Ar ℕ 1 V.[ n ]) → Ar ℕ n (▾ sh)
dec-test a with (prod $ a→s a) N.≟ 0
... | yes p = mkempty _ p
... | no ¬p = cst 2
open import Level as L
bf : Names
bf = (quote _≥a_ ∷ quote reduce-1d ∷ quote N._≟_ ∷ quote prod ∷ [])
kdec-test = kompile dec-test bf ([])
kdec-testR = frefl dec-test bf
--kdec-testR2 = frefln dec-test bf ("Example-04._.with-350" ∷ [])
ktakeN : Prog
ktakeN = kompile takeN bf []
ktakeNR = frefl takeN bf
--ktakeNRW = ftyn takeN bf ("APL2.with-1366" ∷ [])
-}
{- --This moved into bug-nat-level--
poop : ∀ {d s} → Ar ℕ d s → Ix 1 V.[ prod s ] → ℕ
poop a ix = sel a (off→idx _ ix)
n≤sn-i : ∀ {i n} → i ≤ 1 → n ≤ suc n N.∸ i
n≤sn-i z≤n = <⇒≤ ≤-refl
n≤sn-i (s≤s z≤n) = ≤-refl
test-take : ∀ {n} → Ix 1 V.[ 2 ] → Ar ℕ 1 V.[ 1 N.+ n ] → Ar ℕ 1 V.[ n ]
test-take {n} ix@(i ∷ []) a =
let ixₐ , ix<[2] = ix→a ix
r' = (ixₐ ↓ a){λ where jv@(zero ∷ []) → ≤-trans (≤-pred $ ix<[2] jv) (s≤s z≤n)}
r = (cst n ↑ r'){ λ where jv@(zero ∷ []) → n≤sn-i (≤-pred $ F.toℕ<n i) }
in r
ktest = kompile test-take [] []
-}
| {
"alphanum_fraction": 0.4629194863,
"avg_line_length": 30.9444444444,
"ext": "agda",
"hexsha": "eec68d19f362d3cde67d48a5dbcb4ccaf03382e6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "ashinkarov/agda-extractor",
"max_forks_repo_path": "Example-04.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "ashinkarov/agda-extractor",
"max_issues_repo_path": "Example-04.agda",
"max_line_length": 117,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "ashinkarov/agda-extractor",
"max_stars_repo_path": "Example-04.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-11T14:52:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-11T14:52:59.000Z",
"num_tokens": 3577,
"size": 7241
} |
module New.Unused where
open import New.Changes
module _ {ℓ₁} {ℓ₂}
{A : Set ℓ₁} {B : Set ℓ₂} {{CA : ChAlg A}} {{CB : ChAlg B}} where
open ≡-Reasoning
open import Postulate.Extensionality
module _ (f : A → B) where
nil-is-derivative : IsDerivative f (nil f)
nil-is-derivative a da v =
begin
f (a ⊕ da)
≡⟨ sym (cong (λ □ → □ (_⊕_ a da)) (update-nil f)) ⟩
(f ⊕ nil f) (a ⊕ da)
≡⟨ proj₂ (nil-valid f a da v) ⟩
f a ⊕ (nil f a da)
∎
derivative-is-nil : ∀ df → IsDerivative f df → f ⊕ df ≡ f
derivative-is-nil df f-df =
ext (λ v →
begin
f v ⊕ df v (nil v)
≡⟨ sym (f-df v (nil v) (nil-valid v)) ⟩
f (v ⊕ nil v)
≡⟨ cong f (update-nil v) ⟩
f v
∎)
derivative-is-valid : ∀ df
(IsDerivative-f-df : IsDerivative f df) →
WellDefinedFunChange f df
derivative-is-valid df IsDerivative-f-df a da ada
rewrite sym (IsDerivative-f-df (a ⊕ da) (nil (a ⊕ da)) (nil-valid (a ⊕ da)))
| update-nil (a ⊕ da)
| IsDerivative-f-df a da ada
= refl
equal-future-expand-derivative : ∀ df → IsDerivative f df →
∀ v1 dv1 → valid v1 dv1 →
∀ v2 →
v2 ≡ v1 ⊕ dv1 →
f v2 ≡ f v1 ⊕ df v1 dv1
equal-future-expand-derivative df is-derivative-f-df v1 dv1 v1dv1 v2 eq-fut =
begin
f v2
≡⟨ cong f eq-fut ⟩
f (v1 ⊕ dv1)
≡⟨ is-derivative-f-df v1 dv1 v1dv1 ⟩
f v1 ⊕ df v1 dv1
∎
-- -- equal-future-expand-derivative df is-derivative-f-df v1 dv1 v1dv1 v2 dv2 v2dv2 eq-fut =
-- -- begin
-- -- (f ⊕ df) (v1 ⊕ dv1)
-- -- ≡⟨ cong (f ⊕ df) eq-fut ⟩
-- -- (f ⊕ df) (v2 ⊕ dv2)
-- -- ≡⟨ well-defined-f-df v2 dv2 v2dv2 ⟩
-- -- f v2 ⊕ df v2 dv2
-- -- ∎
-- -- equal-future-expand-base df (derivative-is-valid df is-derivative-f-df)
equal-future-base : ∀ df → WellDefinedFunChange f df →
∀ v1 dv1 → valid v1 dv1 →
∀ v2 dv2 → valid v2 dv2 →
v1 ⊕ dv1 ≡ v2 ⊕ dv2 →
f v1 ⊕ df v1 dv1 ≡ f v2 ⊕ df v2 dv2
equal-future-base df well-defined-f-df v1 dv1 v1dv1 v2 dv2 v2dv2 eq-fut =
begin
f v1 ⊕ df v1 dv1
≡⟨ sym (well-defined-f-df v1 dv1 v1dv1) ⟩
(f ⊕ df) (v1 ⊕ dv1)
≡⟨ cong (f ⊕ df) eq-fut ⟩
(f ⊕ df) (v2 ⊕ dv2)
≡⟨ well-defined-f-df v2 dv2 v2dv2 ⟩
f v2 ⊕ df v2 dv2
∎
equal-future-change : ∀ df → valid f df →
∀ v1 dv1 → valid v1 dv1 →
∀ v2 dv2 → valid v2 dv2 →
v1 ⊕ dv1 ≡ v2 ⊕ dv2 →
f v1 ⊕ df v1 dv1 ≡ f v2 ⊕ df v2 dv2
equal-future-change df fdf =
equal-future-base df
(λ a da ada → proj₂ (fdf a da ada))
equal-future-derivative : ∀ df → IsDerivative f df →
∀ v1 dv1 → valid v1 dv1 →
∀ v2 dv2 → valid v2 dv2 →
v1 ⊕ dv1 ≡ v2 ⊕ dv2 →
f v1 ⊕ df v1 dv1 ≡ f v2 ⊕ df v2 dv2
equal-future-derivative df is-derivative-f-df =
equal-future-base df (derivative-is-valid df is-derivative-f-df)
| {
"alphanum_fraction": 0.5184079602,
"avg_line_length": 31.7368421053,
"ext": "agda",
"hexsha": "d221a7bd75ccad9bcab310b856c48c63f0fe233d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "New/Unused.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "New/Unused.agda",
"max_line_length": 97,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "New/Unused.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 1232,
"size": 3015
} |
{-# OPTIONS --safe --without-K #-}
open import Relation.Binary.PropositionalEquality using (refl)
open import Relation.Nullary using (yes)
open import Data.Unit using (⊤; tt)
open import Data.Product using (_,_)
open import Data.Sum using (inj₁)
open import PiCalculus.LinearTypeSystem.Algebras
module PiCalculus.LinearTypeSystem.Algebras.Shared where
pattern ω = tt
Shared : Algebra ⊤
Algebra.0∙ Shared = ω
Algebra.1∙ Shared = ω
Algebra._≔_∙_ Shared _ _ _ = ⊤
Algebra.∙-computeʳ Shared _ _ = yes (ω , tt)
Algebra.∙-unique Shared _ _ = refl
Algebra.∙-uniqueˡ Shared _ _ = refl
Algebra.0∙-minˡ Shared _ = refl
Algebra.∙-idˡ Shared = tt
Algebra.∙-comm Shared _ = tt
Algebra.∙-assoc Shared _ _ = ω , tt , tt
| {
"alphanum_fraction": 0.7285513361,
"avg_line_length": 26.3333333333,
"ext": "agda",
"hexsha": "ea60cde9ba9dfaefde64e6ee3e8ac64eb48230c6",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T16:24:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-25T13:57:13.000Z",
"max_forks_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guilhermehas/typing-linear-pi",
"max_forks_repo_path": "src/PiCalculus/LinearTypeSystem/Algebras/Shared.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_issues_repo_issues_event_max_datetime": "2022-03-15T09:16:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-15T09:16:14.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "guilhermehas/typing-linear-pi",
"max_issues_repo_path": "src/PiCalculus/LinearTypeSystem/Algebras/Shared.agda",
"max_line_length": 62,
"max_stars_count": 26,
"max_stars_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guilhermehas/typing-linear-pi",
"max_stars_repo_path": "src/PiCalculus/LinearTypeSystem/Algebras/Shared.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-14T15:18:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-02T23:32:11.000Z",
"num_tokens": 241,
"size": 711
} |
{-# OPTIONS --without-K #-}
open import container.core
module container.w.fibration
{li la lb}(c : Container li la lb) where
open import sum
open import equality
open import function
open import container.w.core
open import container.w.algebra c
open import hott.level
open Container c
AlgFib : ∀ ℓ → Set _
AlgFib ℓ = Σ ((i : I) → W c i → Set ℓ) λ P
→ (∀ i x → ((b : B (proj₁ x)) → P (r b) (proj₂ x b)) → P i (inW c i x))
AlgSection : ∀ {ℓ} (𝓟 : AlgFib ℓ) → Set _
AlgSection (P , θ) = Σ (∀ i x → P i x) λ f
→ _≡_ {A = ∀ i x → P i (inW c i x)}
(λ i x → θ i x (λ b → f (r b) (proj₂ x b)))
(λ i x → f i (inW c i x))
alg-total : ∀ {ℓ} → AlgFib ℓ → Alg _
alg-total (P , θ) = X , ψ
where
X : I → Set _
X i = Σ (W c i) (P i)
ψ : F X →ⁱ X
ψ i (a , u) = inW c i (a , λ b → proj₁ (u b))
, θ i (a , λ b → proj₁ (u b)) (λ b → proj₂ (u b))
module _ {ℓ} (𝓟 : AlgFib ℓ) where
private 𝓧 = alg-total 𝓟
open Σ 𝓟 renaming (proj₁ to P ; proj₂ to θ)
open Σ (alg-total 𝓟) renaming (proj₁ to X ; proj₂ to ψ)
section : AlgSection 𝓟
section = f₀ , refl
where
f₀ : ∀ i x → P i x
f₀ i (sup a u) = θ i (a , u) (λ b → f₀ (r b) (u b))
private
split-lem : ∀ {ℓ'} (Y : I → Set ℓ')
→ (Y →ⁱ X)
≅ ( Σ (Y →ⁱ W c) λ g₀
→ ∀ i x → P i (g₀ i x) )
split-lem Y
= sym≅ (curry-iso (λ i _ → X i))
·≅ ΠΣ-swap-iso
·≅ Σ-ap-iso (curry-iso (λ i _ → W c i))
(λ g₀ → curry-iso (λ i x → P i (g₀ (i , x))))
section-mor-iso : Mor 𝓦 𝓧 ≅ AlgSection 𝓟
section-mor-iso = begin
( Σ (W c →ⁱ X) λ f → ψ ∘ⁱ imap f ≡ f ∘ⁱ inW c )
≅⟨ Σ-ap-iso (split-lem (W c)) (λ _ → refl≅) ⟩
( Σ (Σ (W c →ⁱ W c) λ f₀ → ∀ i → (w : W c i) → P i (f₀ i w)) λ { (f₀ , f₁)
→ _≡_ {A = ∀ i (x : F (W c) i) → X i}
(λ i x → let x' = imap f₀ i x
in (inW c i x' , θ i x' (λ b → f₁ (r b) (proj₂ x b))))
(λ i x → (f₀ i (inW c i x) , f₁ i (inW c i x))) } )
≅⟨ ( Σ-ap-iso refl≅ λ { (f₀ , f₁) → iso≡ (split-lem (F (W c)))
·≅ sym≅ Σ-split-iso } ) ⟩
( Σ (Σ (W c →ⁱ W c) λ f₀ → ∀ i → (w : W c i) → P i (f₀ i w)) λ { (f₀ , f₁)
→ Σ ( _≡_ {A = ∀ i (x : F (W c) i) → W c i}
(λ i x → inW c i (imap f₀ i x))
(λ i x → f₀ i (inW c i x)) ) λ eq
→ subst (λ g → ∀ i (x : F (W c) i) → P i (g i x)) eq
(λ i x → θ i (imap f₀ i x) (λ b → f₁ (r b) (proj₂ x b)))
≡ (λ i x → f₁ i (inW c i x)) } )
≅⟨ record
{ to = λ { ((f₀ , f₁) , (α₀ , α₁)) → ((f₀ , α₀) , (f₁ , α₁)) }
; from = λ { ((f₀ , α₀) , (f₁ , α₁)) → ((f₀ , f₁) , (α₀ , α₁)) }
; iso₁ = λ { ((f₀ , f₁) , (α₀ , α₁)) → refl }
; iso₂ = λ { ((f₀ , α₀) , (f₁ , α₁)) → refl } } ⟩
( Σ ( Σ (∀ i → W c i → W c i) λ f₀
→ ( _≡_ {A = ∀ i (x : F (W c) i) → W c i}
(λ i x → inW c i (imap f₀ i x))
(λ i x → f₀ i (inW c i x)) ) ) λ { (f₀ , eq)
→ Σ (∀ i w → P i (f₀ i w)) λ f₁
→ subst (λ g → ∀ i (x : F (W c) i) → P i (g i x)) eq
(λ i x → θ i (imap f₀ i x) (λ b → f₁ (r b) (proj₂ x b)))
≡ (λ i x → f₁ i (inW c i x)) } )
≅⟨ sym≅ ( Σ-ap-iso (sym≅ (contr-⊤-iso W-initial-W)) λ _ → refl≅ ) ·≅ ×-left-unit ⟩
( Σ (∀ i w → P i w) λ f₁
→ (λ i x → θ i x (λ b → f₁ (r b) (proj₂ x b)))
≡ (λ i x → f₁ i (inW c i x)) )
∎
where
open ≅-Reasoning
W-section-contr : contr (AlgSection 𝓟)
W-section-contr = iso-level section-mor-iso (W-initial 𝓧)
| {
"alphanum_fraction": 0.4093922652,
"avg_line_length": 36.5656565657,
"ext": "agda",
"hexsha": "8e40ab3f7a26ac24bce3894d9e0196c4f5fbc144",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "container/w/fibration.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/container/w/fibration.agda",
"max_line_length": 86,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "container/w/fibration.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 1638,
"size": 3620
} |
open import FRP.JS.String using ( _≟_ )
open import FRP.JS.Bool using ( Bool ; true ; false ; if_then_else_ ; _∧_ ; _∨_ ; not ; _xor_ )
open import FRP.JS.QUnit using ( TestSuite ; ok ; test ; _,_ )
module FRP.JS.Test.Bool where
tests : TestSuite
tests =
( test "true"
( ok "true" true )
, test "false"
( ok "false" (not false) )
, test "if"
( ok "if true" (if true then "a" else "b" ≟ "a")
, ok "if false" (if false then "a" else "b" ≟ "b") )
, test "∧"
( ok "true ∧ true" (true ∧ true)
, ok "true ∧ false" (not (true ∧ false))
, ok "false ∧ true" (not (false ∧ true))
, ok "false ∧ false" (not (false ∧ false)) )
, test "∨"
( ok "true ∨ true" (true ∨ true)
, ok "true ∨ false" (true ∨ false)
, ok "false ∨ true" (false ∨ true)
, ok "false ∨ false" (not (false ∨ false)) )
, test "xor"
( ok "true xor true" (not (true xor true))
, ok "true xor false" (true xor false)
, ok "false xor true" (false xor true)
, ok "false xor false" (not (false xor false)) )
) | {
"alphanum_fraction": 0.5473684211,
"avg_line_length": 33.7096774194,
"ext": "agda",
"hexsha": "5f5b4e695dbbab1f57436b520414f35e42c828dc",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "test/agda/FRP/JS/Test/Bool.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "test/agda/FRP/JS/Test/Bool.agda",
"max_line_length": 95,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "test/agda/FRP/JS/Test/Bool.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 378,
"size": 1045
} |
{-# OPTIONS --without-K --exact-split #-}
import 05-identity-types
open 05-identity-types public
-- Inversion is uninteresting and comes from:
inversion-proof :
{i : Level} {A : UU i} (x : A) → (y : A) → Id x y → Id y x
inversion-proof x y = ind-Id x (λ y' p' → Id y' x) refl y
lemma-2-2-2-i :
{i j : Level} {A : UU i} {B : UU j} (x y z : A) (f : A → B) → (p : Id x y) → (q : Id y z)
→ Id (ap f (p ∙ q)) ((ap f p) ∙ (ap f q))
lemma-2-2-2-i x y z f refl q = refl
-- We apparently don't need a second induction on q..
lemma-2-2-2-ii :
{i j : Level} {A : UU i} {B : UU j} (x y : A) (f : A → B) → (p : Id x y)
→ Id (ap f (inv p)) (inv (ap f p))
lemma-2-2-2-ii x y f refl = refl
lemma-2-2-2-iii :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} (x y : A) (f : A → B) → (g : B → C) → (p : Id x y)
→ Id (ap g (ap f p)) (ap (g ∘ f) p)
lemma-2-2-2-iii x y f g refl = refl
lemma-2-2-2-iv :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} (x y : A) → (p : Id x y)
→ Id (ap (λ x → x) p) p
lemma-2-2-2-iv x y refl = refl
-- Path lifting property
lemma-2-3-2 :
{i j : Level} {A : UU i} {P : A → UU j} (x y : A) (u : P x) → (p : Id x y)
→ Id (pair x u) (pair y (tr P p u))
lemma-2-3-2 x y u refl = refl
lemma-2-3-9 :
{i j : Level} {A : UU i} {P : A → UU j} (x y z : A) (u : P x) → (p : Id x y)
→ (q : Id y z) → Id (tr P q (tr P p u)) (tr P (p ∙ q) u)
lemma-2-3-9 x y z u refl q = refl
lemma-2-3-10 :
{i j k : Level} {A : UU i} {B : UU j} {P : B → UU k} (x y : A) (f : A → B) (u : P (f x)) → (p : Id x y)
→ Id (tr (P ∘ f) p u) (tr P (ap f p) u)
lemma-2-3-10 x y f u refl = refl
lemma-2-3-11 :
{i j k : Level} {A : UU i} {P : A → UU j} {Q : A → UU k}
(x y : A) (f : (z : A) → P z → Q z) (u : P x) → (p : Id x y)
→ Id (tr Q p (f x u)) (f y (tr P p u))
lemma-2-3-11 x y f u refl = refl
-- Eckert-Hamilton
-- First, the loop
loop-type : {i : Level} {A : UU i} (x : A) → UU i
loop-type x = Id x x
order-2-star :
{i : Level} {A : UU i} (a b c : A) → (p q : Id a b) → (r s : Id b c)
→ (alpha : Id p q) → (beta : Id r s) → Id (concat p c r) (concat q c s)
order-2-star a b c refl q refl s refl refl = refl
left-whisker :
{i : Level} {A : UU i} (a b c : A) → (p q : Id a b) → (r : Id b c)
→ (alpha : Id p q) → Id (concat p c r) (concat q c r)
left-whisker a b c refl refl r refl = refl
right-whisker :
{i : Level} {A : UU i} (a b c : A) → (p : Id a b) → (r s : Id b c)
→ (beta : Id r s) → Id (concat p c r) (concat p c s)
right-whisker a b c p refl refl refl = refl
-- TODO: Eckmann Hilton
-- 2.4: the equivalence of functions, quasi-inverses
-- `Sim-By` might be poorly set up since it basically takes the witness of what it
-- actually should just be. (../07- has the correct stuff.)
data Homotopic-Fn {i j : Level} (A : UU i) (B : UU j) (f g : A → B) : UU (i ⊔ j) where
Sim-By : ((x : A) → (Id (f x) (g x))) → Homotopic-Fn A B f g
data Is-Equiv {i j : Level} {A : UU i} {B : UU j} (f : A → B) : UU (i ⊔ j) where
With-Qinv : (g : B → A) → (Homotopic-Fn A A (g ∘ f) (λ x → x))
→ (Homotopic-Fn B B (f ∘ g) (λ x → x))
→ Is-Equiv f
-- Relying on the book's lemma 2.4.12, we're just using the above for type equivalence
data Equiv-Types {i j : Level} (A : UU i) (B : UU j) : UU (i ⊔ j) where
Eq-By : (Σ (A → B) Is-Equiv) → Equiv-Types A B
-- 2.6.1
product-functoriality :
{i j : Level} {A : UU i} {B : UU j} (x y : prod A B) → (Id x y)
→ (prod (Id (pr1 x) (pr1 y)) (Id (pr2 x) (pr2 y)))
product-functoriality x y refl = pair refl refl
-- 2.6.2
pair= :
{i j : Level} {A : UU i} {B : UU j} (a₁ a₂ : A) → (b₁ b₂ : B)
→ (prod (Id a₁ a₂) (Id b₁ b₂)) → (Id (pair a₁ b₁) (pair a₂ b₂))
pair= a₁ a₂ b₁ b₂ (pair refl refl) = refl
-- This is a bit of laziness to exhibit both bits of the proof with the same a₁ etc.
-- The point is to show that product-functoriality and pair= are quasi-inverses.
functoriality-is-equiv-to-2-6-2 :
{i j : Level} {A : UU i} {B : UU j} {a₁ a₂ : A} {b₁ b₂ : B} →
-- First two bindings give us shorthands for the proper invocations of the above
-- functions (currying away aₙ and bₙ).
let functorial = (product-functoriality (pair a₁ b₁) (pair a₂ b₂))
2-6-2 = (pair= a₁ a₂ b₁ b₂)
thm-after-funct = (Homotopic-Fn (prod (Id a₁ a₂) (Id b₁ b₂))
(prod (Id a₁ a₂) (Id b₁ b₂))
(λ x → x)
(functorial ∘ 2-6-2))
funct-after-thm = (Homotopic-Fn (Id (pair a₁ b₁) (pair a₂ b₂))
(Id (pair a₁ b₁) (pair a₂ b₂))
(2-6-2 ∘ functorial)
(λ x → x))
in (prod thm-after-funct funct-after-thm)
functoriality-is-equiv-to-2-6-2 = pair (Sim-By (λ {(pair refl refl) → refl})) (Sim-By (λ {refl → refl}))
-- 2.6.4
pair-transport :
{i j k : Level} {Z : UU k} {A : Z → UU i} {B : Z → UU j} (z w : Z) → (p : Id z w) → (x : prod (A z) (B z))
→ (Id (tr (λ z → (prod (A z) (B z))) p x) (pair (tr A p (pr1 x)) (tr B p (pr2 x))))
pair-transport z w refl (pair az bz) = refl
-- 2.6.5
ap-functorial :
{i j k l : Level} {A : UU i} {A' : UU j} {B : UU k} {B' : UU l} (g : A → A') → (h : B → B')
→ (x y : prod A B) → (p : Id (pr1 x) (pr1 y)) → (q : Id (pr2 x) (pr2 y)) →
let pf= = (pair= (pr1 x) (pr1 y) (pr2 x) (pr2 y))
pgh = (pair= (g (pr1 x)) (g (pr1 y)) (h (pr2 x)) (h (pr2 y)))
f = (λ x → pair (g (pr1 x)) (h (pr2 x)))
in Id (ap f (pf= (pair p q))) (pgh (pair (ap g p) (ap h q)))
ap-functorial g h (pair aₓ bₓ) (pair ay by) refl refl = refl
-- 2.9: Extensionality
happly : {i j : Level} {A : UU i} {B : A → UU j} (f g : (x : A) → B(x)) →
(Id f g) → ((x : A) → (Id (f x) (g x)))
happly f g refl = λ x → refl
postulate fn-ext : Is-Equiv happly
dependent-fn-transport : {i j : Level} {X : UU i} (A : X → UU j) → (B : (x : X) → A x → UU (i ⊔ j))
(x₁ x₂ : X) → (Id x₁ x₂) →
(f : (a : A x₁) → (B x₁ a)) → (A x₂) → ((a : A x₂) → (B x₂ a))
dependent-fn-transport A B x₁ x₂ refl f a = tr (B-hat B) (pair= x₁ x₂ (tr A refl a) a
(pair refl refl))
(f (tr A refl a))
where
B-hat : {i j : Level} {X : UU i} {A : X → UU j} (B : (x : X) → A x → UU (i ⊔ j)) → (Σ X (λ x → A x)) → UU (i ⊔ j)
B-hat B w = B (pr1 w) (pr2 w)
| {
"alphanum_fraction": 0.481768813,
"avg_line_length": 41.3141025641,
"ext": "agda",
"hexsha": "f8ef409b6e0c8ad4a8b23abf3726894ed2331190",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "hemangandhi/HoTT-Intro",
"max_forks_repo_path": "Agda/univalent-hott/2-homotopy-type-theory.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "hemangandhi/HoTT-Intro",
"max_issues_repo_path": "Agda/univalent-hott/2-homotopy-type-theory.agda",
"max_line_length": 117,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "hemangandhi/HoTT-Intro",
"max_stars_repo_path": "Agda/univalent-hott/2-homotopy-type-theory.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2791,
"size": 6445
} |
module Semantics.Substitution where
open import Semantics.Substitution.Kits public
open import Semantics.Substitution.Traversal public
open import Semantics.Substitution.Instances public
open import Semantics.Substitution.Soundness public
| {
"alphanum_fraction": 0.8755186722,
"avg_line_length": 30.125,
"ext": "agda",
"hexsha": "93ef88cf003a5bb2257ca7cdabbc744793fb039d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DimaSamoz/temporal-type-systems",
"max_forks_repo_path": "src/Semantics/Substitution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DimaSamoz/temporal-type-systems",
"max_issues_repo_path": "src/Semantics/Substitution.agda",
"max_line_length": 51,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DimaSamoz/temporal-type-systems",
"max_stars_repo_path": "src/Semantics/Substitution.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
"num_tokens": 48,
"size": 241
} |
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Verification.CorruptFormalisations where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Base.Loop
open import FOTC.Program.ABP.Terms
------------------------------------------------------------------------------
-- Corrupt as a constant.
module Constant where
postulate
corrupt : D
corrupt-T : ∀ os x xs →
corrupt · (T ∷ os) · (x ∷ xs) ≡ ok x ∷ corrupt · os · xs
corrupt-F : ∀ os x xs →
corrupt · (F ∷ os) · (x ∷ xs) ≡ error ∷ corrupt · os · xs
-- Corrupt as a binary function.
module BinaryFunction where
postulate
corrupt : D → D → D
corrupt-T : ∀ os x xs →
corrupt (T ∷ os) (x ∷ xs) ≡ ok x ∷ corrupt os xs
corrupt-F : ∀ os x xs →
corrupt (F ∷ os) (x ∷ xs) ≡ error ∷ corrupt os xs
| {
"alphanum_fraction": 0.5101832994,
"avg_line_length": 30.6875,
"ext": "agda",
"hexsha": "10662b02868e1d6bc108be2d4eded6d818cf0c57",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/thesis/report/Verification/CorruptFormalisations.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/thesis/report/Verification/CorruptFormalisations.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/thesis/report/Verification/CorruptFormalisations.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 269,
"size": 982
} |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Span
open import lib.types.Pointed
open import lib.types.Pushout
open import lib.types.PushoutFlattening
open import lib.types.Unit
open import lib.types.Paths
open import lib.cubical.Square
-- Suspension is defined as a particular case of pushout
module lib.types.Suspension where
module _ {i} (A : Type i) where
suspension-span : Span
suspension-span = span Unit Unit A (λ _ → tt) (λ _ → tt)
Suspension : Type i
Suspension = Pushout suspension-span
north : Suspension
north = left tt
south : Suspension
south = right tt
merid : A → north == south
merid x = glue x
module SuspensionElim {j} {P : Suspension → Type j} (n : P north)
(s : P south) (p : (x : A) → n == s [ P ↓ merid x ])
= PushoutElim (λ _ → n) (λ _ → s) p
open SuspensionElim public using () renaming (f to Suspension-elim)
module SuspensionRec {j} {C : Type j} (n s : C) (p : A → n == s)
= PushoutRec {d = suspension-span} (λ _ → n) (λ _ → s) p
module SuspensionRecType {j} (n s : Type j) (p : A → n ≃ s)
= PushoutRecType {d = suspension-span} (λ _ → n) (λ _ → s) p
suspension-⊙span : ∀ {i} → Ptd i → ⊙Span
suspension-⊙span X =
⊙span ⊙Unit ⊙Unit X (⊙cst {X = X}) (⊙cst {X = X})
⊙Susp : ∀ {i} → Ptd i → Ptd i
⊙Susp (A , _) = ⊙[ Suspension A , north A ]
σloop : ∀ {i} (X : Ptd i) → fst X → north (fst X) == north (fst X)
σloop (_ , x₀) x = merid _ x ∙ ! (merid _ x₀)
σloop-pt : ∀ {i} {X : Ptd i} → σloop X (snd X) == idp
σloop-pt {X = (_ , x₀)} = !-inv-r (merid _ x₀)
module FlipSusp {i} {A : Type i} = SuspensionRec A
(south A) (north A) (! ∘ merid A)
flip-susp : ∀ {i} {A : Type i} → Suspension A → Suspension A
flip-susp = FlipSusp.f
⊙flip-susp : ∀ {i} (X : Ptd i) → fst (⊙Susp X ⊙→ ⊙Susp X)
⊙flip-susp X = (flip-susp , ! (merid _ (snd X)))
module _ {i j} where
module SuspFmap {A : Type i} {B : Type j} (f : A → B) =
SuspensionRec A (north B) (south B) (merid B ∘ f)
susp-fmap : {A : Type i} {B : Type j} (f : A → B)
→ (Suspension A → Suspension B)
susp-fmap = SuspFmap.f
⊙susp-fmap : {X : Ptd i} {Y : Ptd j} (f : fst (X ⊙→ Y))
→ fst (⊙Susp X ⊙→ ⊙Susp Y)
⊙susp-fmap (f , fpt) = (susp-fmap f , idp)
module _ {i} where
susp-fmap-idf : (A : Type i) → ∀ a → susp-fmap (idf A) a == a
susp-fmap-idf A = Suspension-elim _ idp idp $ λ a →
↓-='-in (ap-idf (merid _ a) ∙ ! (SuspFmap.glue-β (idf A) a))
⊙susp-fmap-idf : (X : Ptd i)
→ ⊙susp-fmap (⊙idf X) == ⊙idf (⊙Susp X)
⊙susp-fmap-idf X = ⊙λ= (susp-fmap-idf (fst X)) idp
module _ {i j} where
susp-fmap-cst : {A : Type i} {B : Type j} (b : B)
(a : Suspension A) → susp-fmap (cst b) a == north _
susp-fmap-cst b = Suspension-elim _ idp (! (merid _ b)) $ (λ a →
↓-app=cst-from-square $ SuspFmap.glue-β (cst b) a ∙v⊡ tr-square _)
⊙susp-fmap-cst : {X : Ptd i} {Y : Ptd j}
→ ⊙susp-fmap (⊙cst {X = X} {Y = Y}) == ⊙cst
⊙susp-fmap-cst = ⊙λ= (susp-fmap-cst _) idp
module _ {i j k} where
susp-fmap-∘ : {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B)
(σ : Suspension A) → susp-fmap (g ∘ f) σ == susp-fmap g (susp-fmap f σ)
susp-fmap-∘ g f = Suspension-elim _
idp
idp
(λ a → ↓-='-in $
ap-∘ (susp-fmap g) (susp-fmap f) (merid _ a)
∙ ap (ap (susp-fmap g)) (SuspFmap.glue-β f a)
∙ SuspFmap.glue-β g (f a)
∙ ! (SuspFmap.glue-β (g ∘ f) a))
⊙susp-fmap-∘ : {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
(g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y))
→ ⊙susp-fmap (g ⊙∘ f) == ⊙susp-fmap g ⊙∘ ⊙susp-fmap f
⊙susp-fmap-∘ g f = ⊙λ= (susp-fmap-∘ (fst g) (fst f)) idp
{- Extract the 'glue component' of a pushout -}
module _ {i j k} {s : Span {i} {j} {k}} where
module ExtGlue = PushoutRec {d = s} {D = Suspension (Span.C s)}
(λ _ → north _) (λ _ → south _) (merid _)
ext-glue = ExtGlue.f
module _ {i j k} {s : Span {i} {j} {k}} {x₀ : Span.A s} where
⊙ext-glue :
fst ((Pushout s , left x₀) ⊙→ (Suspension (Span.C s) , north _))
⊙ext-glue = (ext-glue , idp)
| {
"alphanum_fraction": 0.5584802583,
"avg_line_length": 29.8296296296,
"ext": "agda",
"hexsha": "2815ad54f26d8d64e26fa63c4bbeba23db75468d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "lib/types/Suspension.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "lib/types/Suspension.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "lib/types/Suspension.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 1691,
"size": 4027
} |
module BBHeap.Properties {A : Set}(_≤_ : A → A → Set) where
open import BBHeap _≤_
open import BBHeap.Perfect _≤_
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import Data.Empty
sym≃ : {b b' : Bound}{h : BBHeap b}{h' : BBHeap b'} → h ≃ h' → h' ≃ h
sym≃ ≃lf = ≃lf
sym≃ (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l≃l') = ≃nd b'≤x' b≤x l'⋘r' l⋘r l'≃r' l≃r (sym≃ l≃l')
trans≃ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≃ h' → h' ≃ h'' → h ≃ h''
trans≃ ≃lf ≃lf = ≃lf
trans≃ (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r _ l≃l') (≃nd .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' _ l''≃r'' l'≃l'') = ≃nd b≤x b''≤x'' l⋘r l''⋘r'' l≃r l''≃r'' (trans≃ l≃l' l'≃l'')
lemma≃ : {b b' : Bound}{h : BBHeap b}{h' : BBHeap b'} → h ≃ h' → h ⋘ h'
lemma≃ ≃lf = lf⋘
lemma≃ (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l≃l') = ll⋘ b≤x b'≤x' l⋘r l'⋘r' l'≃r' (trans≃ (sym≃ l≃r) l≃l')
lemma⋗≃ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋗ h' → h' ≃ h'' → h ⋗ h''
lemma⋗≃ (⋗lf b≤x) ≃lf = ⋗lf b≤x
lemma⋗≃ (⋗nd b≤x b'≤x' l⋘r l'⋘r' l≃r _ l⋗l') (≃nd .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' _ l''≃r'' l'≃l'') = ⋗nd b≤x b''≤x'' l⋘r l''⋘r'' l≃r l''≃r'' (lemma⋗≃ l⋗l' l'≃l'')
lemma⋗ : {b b' : Bound}{h : BBHeap b}{h' : BBHeap b'} → h ⋗ h' → h ⋙ h'
lemma⋗ (⋗lf b≤x) = ⋙lf b≤x
lemma⋗ (⋗nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l⋗l') = ⋙rl b≤x b'≤x' l⋘r l≃r l'⋘r' (lemma⋗≃ l⋗l' l'≃r')
lemma⋗⋗ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋗ h' → h'' ⋗ h' → h ≃ h''
lemma⋗⋗ (⋗lf b≤x) (⋗lf b''≤x'') = ≃nd b≤x b''≤x'' lf⋘ lf⋘ ≃lf ≃lf ≃lf
lemma⋗⋗ (⋗nd b≤x b'≤x' l⋘r l'⋘r' l≃r _ l⋗l') (⋗nd b''≤x'' .b'≤x' l''⋘r'' .l'⋘r' l''≃r'' _ l''⋗l') = ≃nd b≤x b''≤x'' l⋘r l''⋘r'' l≃r l''≃r'' (lemma⋗⋗ l⋗l' l''⋗l')
lemma⋗⋗' : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋗ h' → h ⋗ h'' → h' ≃ h''
lemma⋗⋗' (⋗lf b≤x) (⋗nd .b≤x _ .lf⋘ _ _ _ ())
lemma⋗⋗' (⋗nd .b≤x _ .lf⋘ _ _ _ ()) (⋗lf b≤x)
lemma⋗⋗' (⋗lf b≤x) (⋗lf .b≤x) = ≃lf
lemma⋗⋗' (⋗nd b≤x b'≤x' l⋘r l'⋘r' _ l'≃r' l⋗l') (⋗nd .b≤x b''≤x'' .l⋘r l''⋘r'' _ l''≃r'' l⋗l'') = ≃nd b'≤x' b''≤x'' l'⋘r' l''⋘r'' l'≃r' l''≃r'' (lemma⋗⋗' l⋗l' l⋗l'')
lemma≃⋗ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≃ h' → h' ⋗ h'' → h ⋗ h''
lemma≃⋗ (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r _ l≃l') (⋗nd .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' _ l''≃r'' l'⋗l'') = ⋗nd b≤x b''≤x'' l⋘r l''⋘r'' l≃r l''≃r'' (lemma≃⋗ l≃l' l'⋗l'')
lemma≃⋗ (≃nd b≤x b'≤x' lf⋘ lf⋘ ≃lf ≃lf ≃lf) (⋗lf .b'≤x') = ⋗lf b≤x
lemma-⋘-≃ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋘ h' → h' ≃ h'' → h ⋘ h''
lemma-⋘-≃ lf⋘ ≃lf = lf⋘
lemma-⋘-≃ (ll⋘ b≤x b'≤x' l⋘r l'⋘r' _ r≃l') (≃nd .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' _ l''≃r'' l'≃l'') = ll⋘ b≤x b''≤x'' l⋘r l''⋘r'' l''≃r'' (trans≃ r≃l' l'≃l'')
lemma-⋘-≃ (lr⋘ b≤x b'≤x' l⋙r l'⋘r' _ l⋗l') (≃nd .b'≤x' b''≤x'' .l'⋘r' l''⋘r'' _ l''≃r'' l'≃l'') = lr⋘ b≤x b''≤x'' l⋙r l''⋘r'' l''≃r'' (lemma⋗≃ l⋗l' l'≃l'')
lemma-≃-⋙ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ≃ h' → h' ⋙ h'' → h ⋙ h''
lemma-≃-⋙ (≃nd b≤x b'≤x' lf⋘ lf⋘ ≃lf ≃lf ≃lf) (⋙lf .b'≤x') = ⋙lf b≤x
lemma-≃-⋙ (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r _ l≃l') (⋙rl .b'≤x' b''≤x'' .l'⋘r' _ l''⋘r'' l'⋗r'') = ⋙rl b≤x b''≤x'' l⋘r l≃r l''⋘r'' (lemma≃⋗ l≃l' l'⋗r'')
lemma-≃-⋙ (≃nd b≤x b'≤x' l⋘r l'⋘r' l≃r _ l≃l') (⋙rr .b'≤x' b''≤x'' .l'⋘r' _ l''⋙r'' l'≃l'') = ⋙rr b≤x b''≤x'' l⋘r l≃r l''⋙r'' (trans≃ l≃l' l'≃l'')
lemma-⋘-⋗ : {b b' b'' : Bound}{h : BBHeap b}{h' : BBHeap b'}{h'' : BBHeap b''} → h ⋘ h' → h'' ⋗ h' → h'' ⋙ h
lemma-⋘-⋗ lf⋘ (⋗lf b≤x) = ⋙lf b≤x
lemma-⋘-⋗ (ll⋘ b≤x b'≤x' l⋘r l'⋘r' _ r≃l') (⋗nd b''≤x'' .b'≤x' l''⋘r'' .l'⋘r' l''≃r'' _ l''⋗l') = ⋙rl b''≤x'' b≤x l''⋘r'' l''≃r'' l⋘r (lemma⋗≃ l''⋗l' (sym≃ r≃l'))
lemma-⋘-⋗ (lr⋘ b≤x b'≤x' l⋙r l'⋘r' _ l⋗l') (⋗nd b''≤x'' .b'≤x' l''⋘r'' .l'⋘r' l''≃r'' _ l''⋗l') = ⋙rr b''≤x'' b≤x l''⋘r'' l''≃r'' l⋙r (lemma⋗⋗ l''⋗l' l⋗l')
lemma-≃-⊥ : {b b' : Bound}{h : BBHeap b}{h' : BBHeap b'} → h ≃ h' → h ⋗ h' → ⊥
lemma-≃-⊥ () (⋗lf _)
lemma-≃-⊥ (≃nd .b≤x .b'≤x' .l⋘r .l'⋘r' _ _ l≃l') (⋗nd b≤x b'≤x' l⋘r l'⋘r' l≃r l'≃r' l⋗l')
with lemma-≃-⊥ l≃l' l⋗l'
... | ()
lemma-⋘-⊥ : {b b' : Bound}{x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')}(b≤x : LeB b (val x))(b'≤x' : LeB b' (val x'))(l⋙r : l ⋙ r)(l'⋘r' : l' ⋘ r') → l ≃ l' → right b≤x l⋙r ⋘ left b'≤x' l'⋘r' → ⊥
lemma-⋘-⊥ b≤x b'≤x' l⋙r l'⋘r' l≃l' (lr⋘ .b≤x .b'≤x' .l⋙r .l'⋘r' _ l⋗l')
with lemma-≃-⊥ l≃l' l⋗l'
... | ()
lemma-perfect : {b b' : Bound}{h : BBHeap b}{h' : BBHeap b'} → h ⋘ h' → Perfect h'
lemma-perfect lf⋘ = plf
lemma-perfect (ll⋘ b≤x b'≤x' l⋘l l'⋘l' l'≃r' r≃l') = pnd b'≤x' l'⋘l' l'≃r'
lemma-perfect (lr⋘ b≤x b'≤x' l⋙r l'⋘l' l'≃r' l⋗l') = pnd b'≤x' l'⋘l' l'≃r'
| {
"alphanum_fraction": 0.407566638,
"avg_line_length": 61.2105263158,
"ext": "agda",
"hexsha": "918d8e0c746a9b7df88588c63f60d8594c03ad2d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/BBHeap/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/BBHeap/Properties.agda",
"max_line_length": 208,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/BBHeap/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 3536,
"size": 4652
} |
module IncompletePatternMatching where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data True : Set where
tt : True
data False : Set where
_==_ : Nat -> Nat -> Set
zero == zero = True
suc n == suc m = n == m
thm : zero == suc zero
thm = tt
| {
"alphanum_fraction": 0.6076923077,
"avg_line_length": 13,
"ext": "agda",
"hexsha": "1892622cb195bd3a3580feeb13f37a2df7862add",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/IncompletePatternMatching.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/IncompletePatternMatching.agda",
"max_line_length": 38,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/IncompletePatternMatching.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 86,
"size": 260
} |
-- Idiom bracket notation.
module Syntax.Idiom where
import Lvl
open import Type
private variable ℓ ℓ₁ ℓ₂ : Lvl.Level
private variable A B : Type{ℓ}
private variable F : Type{ℓ₁} → Type{ℓ₂}
-- The notation `⦇ f x₁ x₂ x₃ ⦈` will automatically be translated to `((pure f <*> x₁) <*> x₂) <*> x₃`.
record IdiomBrackets (F : Type{ℓ₁} → Type{ℓ₂}) : Type{Lvl.𝐒(ℓ₁) Lvl.⊔ ℓ₂} where
constructor intro
field
pure : (A → F(A))
_<*>_ : F(A → B) → (F(A) → F(B))
open IdiomBrackets ⦃ … ⦄ using (pure ; _<*>_) public
-- The notation `⦇⦈` will automatically be translated to `empty`.
record IdiomBrackets₀ (F : Type{ℓ₁} → Type{ℓ₂}) : Type{Lvl.𝐒(ℓ₁) Lvl.⊔ ℓ₂} where
constructor intro
field
empty : F(A)
open IdiomBrackets₀ ⦃ … ⦄ using (empty) public
-- The notation `⦇ f₁ x₁ x₂ x₃ | f₂ y₁ y₂ | f₃ z₁ ⦈` will automatically be translated to `(((pure f <*> x₁) <*> x₂) <*> x₃) <|> (((pure f₂ <*> y₁) <*> y₂) <|> (pure f₃ <*> z₁))`.
record IdiomBrackets₊ (F : Type{ℓ₁} → Type{ℓ₂}) ⦃ _ : IdiomBrackets(F) ⦄ : Type{Lvl.𝐒(ℓ₁) Lvl.⊔ ℓ₂} where
constructor intro
field
_<|>_ : F(A) → F(A) → F(A)
open IdiomBrackets₊ ⦃ … ⦄ using (_<|>_) public
| {
"alphanum_fraction": 0.6091854419,
"avg_line_length": 36.0625,
"ext": "agda",
"hexsha": "d2024c63a39ce328836380caf19df8d96e00a078",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Syntax/Idiom.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Syntax/Idiom.agda",
"max_line_length": 178,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Syntax/Idiom.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 498,
"size": 1154
} |
open import Prelude
open import Nat
open import dynamics-core
open import contexts
open import lemmas-disjointness
module exchange where
-- exchanging just two disequal elements produces the same context
swap-little : {A : Set} {x y : Nat} {τ1 τ2 : A} → (x ≠ y) →
((■ (x , τ1)) ,, (y , τ2)) == ((■ (y , τ2)) ,, (x , τ1))
swap-little {A} {x} {y} {τ1} {τ2} neq = ∪comm (■ (y , τ2))
(■ (x , τ1))
(disjoint-singles (flip neq))
-- really the dynamics-core of all the exchange arguments: contexts with two
-- disequal elements exchanged are the same. we reassociate the unions,
-- swap as above, and then associate them back.
--
-- note that this is generic in the contents of the context. the proofs
-- below show the exchange properties that we actually need in the
-- various other proofs; the remaning exchange properties for both Δ and
-- Γ positions for all the other hypothetical judgements are exactly in
-- this pattern.
swap : {A : Set} {x y : Nat} {τ1 τ2 : A} (Γ : A ctx) (x≠y : x == y → ⊥) →
((Γ ,, (x , τ1)) ,, (y , τ2)) == ((Γ ,, (y , τ2)) ,, (x , τ1))
swap {A} {x} {y} {τ1} {τ2} Γ neq = funext eq
where
eq : (z : Nat) → ((Γ ,, (x , τ1)) ,, (y , τ2)) z == ((Γ ,, (y , τ2)) ,, (x , τ1)) z
eq z with natEQ y z
... | Inr y≠z with natEQ x z
... | Inl refl = refl
... | Inr x≠z with natEQ y z
... | Inl refl = abort (y≠z refl)
... | Inr y≠z' = refl
eq z | Inl refl with natEQ x z
... | Inl refl = abort (neq refl)
... | Inr x≠z with natEQ z z
... | Inl refl = refl
... | Inr z≠z = abort (z≠z refl)
-- (∪assoc Γ (■ (x , τ1)) (■ (y , τ2)) (disjoint-singles neq)) ·
-- (ap1 (λ qq → Γ ∪ qq) (swap-little neq) ·
-- the above exchange principle used via transport in the judgements we needed
exchange-subst-Γ : ∀{Δ Γ x y τ1 τ2 σ Γ'} →
x ≠ y →
Δ , (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ σ :s: Γ' →
Δ , (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ σ :s: Γ'
exchange-subst-Γ {Δ} {Γ} {x} {y} {τ1} {τ2} {σ} {Γ'} x≠y =
tr (λ qq → Δ , qq ⊢ σ :s: Γ') (swap Γ x≠y)
exchange-synth : ∀{Γ x y τ τ1 τ2 e}
→ x ≠ y
→ (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e => τ
→ (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e => τ
exchange-synth {Γ} {x} {y} {τ} {τ1} {τ2} {e} neq =
tr (λ qq → qq ⊢ e => τ) (swap Γ neq)
exchange-ana : ∀{Γ x y τ τ1 τ2 e}
→ x ≠ y
→ (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e <= τ
→ (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e <= τ
exchange-ana {Γ} {x} {y} {τ} {τ1} {τ2} {e} neq =
tr (λ qq → qq ⊢ e <= τ) (swap Γ neq)
exchange-elab-synth : ∀{Γ x y τ1 τ2 e τ d Δ} →
x ≠ y →
(Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e ⇒ τ ~> d ⊣ Δ →
(Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e ⇒ τ ~> d ⊣ Δ
exchange-elab-synth {Γ = Γ} {e = e} {τ = τ} {d = d } {Δ = Δ} neq =
tr (λ qq → qq ⊢ e ⇒ τ ~> d ⊣ Δ) (swap Γ neq)
exchange-elab-ana : ∀ {Γ x y τ1 τ2 τ τ' d e Δ} →
x ≠ y →
(Γ ,, (x , τ1) ,, (y , τ2)) ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ →
(Γ ,, (y , τ2) ,, (x , τ1)) ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ
exchange-elab-ana {Γ = Γ} {τ = τ} {τ' = τ'} {d = d} {e = e} {Δ = Δ} neq =
tr (λ qq → qq ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ) (swap Γ neq)
exchange-ta-Γ : ∀{Γ x y τ1 τ2 d τ Δ } →
x ≠ y →
Δ , (Γ ,, (x , τ1) ,, (y , τ2)) ⊢ d :: τ →
Δ , (Γ ,, (y , τ2) ,, (x , τ1)) ⊢ d :: τ
exchange-ta-Γ {Γ = Γ} {d = d} {τ = τ} {Δ = Δ} neq =
tr (λ qq → Δ , qq ⊢ d :: τ) (swap Γ neq)
| {
"alphanum_fraction": 0.4069072968,
"avg_line_length": 44.2643678161,
"ext": "agda",
"hexsha": "2a28bd68fcc11649b22689e5659b3bdb47155bc7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-agda",
"max_forks_repo_path": "exchange.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazelnut-agda",
"max_issues_repo_path": "exchange.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazelnut-agda",
"max_stars_repo_path": "exchange.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1508,
"size": 3851
} |
{-# OPTIONS --safe #-}
module Cubical.Relation.Nullary where
open import Cubical.Relation.Nullary.Base public
open import Cubical.Relation.Nullary.Properties public
| {
"alphanum_fraction": 0.8072289157,
"avg_line_length": 27.6666666667,
"ext": "agda",
"hexsha": "ac3c57818837cd85fb6cf6ad05716642feb2be7e",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/Relation/Nullary.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/Relation/Nullary.agda",
"max_line_length": 54,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/Relation/Nullary.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 36,
"size": 166
} |
-- Andreas, 2018-10-16, erased lambda-arguments
open import Agda.Builtin.List
open import Common.Prelude
sum : List Nat → Nat
sum (x ∷ xs) = x + sum xs
sum [] = 0
zipWith : {A B C : Set} (f : A → B → C) → List A → List B → List C
zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys
zipWith _ _ _ = []
-- Shorten the first list to the length of the second.
restrict : {A : Set} (xs ys : List A) → List A
restrict = zipWith (λ x (@0 _) → x)
-- It does not matter that we annotated the second argument as erased,
-- since the compiler does not actually erase function arguments, only
-- their content to the empty tuple. Thus, this is no type error.
main : IO Unit
main = printNat (sum (restrict (13 ∷ 14 ∷ 15 ∷ 16 ∷ []) (1 ∷ 2 ∷ 3 ∷ [])))
-- Expected output: 42
| {
"alphanum_fraction": 0.6368352789,
"avg_line_length": 28.5555555556,
"ext": "agda",
"hexsha": "75cf9ab15731f5a36cfdd1c9d8bca58e37ac68cb",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Compiler/simple/ErasureSubtyping.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Compiler/simple/ErasureSubtyping.agda",
"max_line_length": 74,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Compiler/simple/ErasureSubtyping.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z",
"num_tokens": 258,
"size": 771
} |
-- Andreas, 2014-09-23
syntax bla (λ x → e) = blub e
-- Should trigger error:
-- malformed syntax declaration: syntax must use binding holes exactly once
| {
"alphanum_fraction": 0.7179487179,
"avg_line_length": 22.2857142857,
"ext": "agda",
"hexsha": "0cafe1d40c696dc6722aa53e1be4b5ab0a2f82b1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/NotationDoesNotUseAllBinders.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/NotationDoesNotUseAllBinders.agda",
"max_line_length": 75,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/NotationDoesNotUseAllBinders.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 42,
"size": 156
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some unit types
------------------------------------------------------------------------
-- The definitions in this file are reexported by Data.Unit.
module Data.Unit.Core where
open import Level
------------------------------------------------------------------------
-- A unit type defined as a data-type
-- The ⊤ type (see Data.Unit) comes with η-equality, which is often
-- nice to have, but sometimes it is convenient to be able to stop
-- unfolding (see "Hidden types" below).
data Unit : Set where
unit : Unit
------------------------------------------------------------------------
-- Hidden types
-- "Hidden" values.
Hidden : ∀ {a} → Set a → Set a
Hidden A = Unit → A
-- The hide function can be used to hide function applications. Note
-- that the type-checker doesn't see that "hide f x" contains the
-- application "f x".
hide : ∀ {a b} {A : Set a} {B : A → Set b} →
((x : A) → B x) → ((x : A) → Hidden (B x))
hide f x unit = f x
-- Reveals a hidden value.
reveal : ∀ {a} {A : Set a} → Hidden A → A
reveal f = f unit
| {
"alphanum_fraction": 0.4797238999,
"avg_line_length": 26.9534883721,
"ext": "agda",
"hexsha": "a4ddcd537c78189c3a0d433627b0771637f1faab",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/Unit/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/Unit/Core.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Data/Unit/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 266,
"size": 1159
} |
{-# OPTIONS --warning=error #-}
module UselessAbstractPrimitive where
postulate Int : Set
{-# BUILTIN INTEGER Int #-}
abstract
primitive
primIntegerPlus : Int -> Int -> Int
| {
"alphanum_fraction": 0.693989071,
"avg_line_length": 15.25,
"ext": "agda",
"hexsha": "96ed34f2f5e8d9694f7b618ee5fc7433a9686928",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/UselessAbstractPrimitive.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/UselessAbstractPrimitive.agda",
"max_line_length": 39,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/UselessAbstractPrimitive.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 42,
"size": 183
} |
------------------------------------------------------------------------------
-- Distributive laws properties
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module DistributiveLaws.PropertiesI where
open import DistributiveLaws.Base
------------------------------------------------------------------------------
-- Congruence properties
-- The propositional equality is compatible with the binary operation.
·-leftCong : ∀ {a b c} → a ≡ b → a · c ≡ b · c
·-leftCong refl = refl
·-rightCong : ∀ {a b c} → b ≡ c → a · b ≡ a · c
·-rightCong refl = refl
| {
"alphanum_fraction": 0.4199475066,
"avg_line_length": 31.75,
"ext": "agda",
"hexsha": "3d827cad97a62eca72cfda603f242aeab0a6e966",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/DistributiveLaws/PropertiesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/DistributiveLaws/PropertiesI.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/DistributiveLaws/PropertiesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 147,
"size": 762
} |
module Data.Vec.All.Properties.Extra {a p}{A : Set a}{P : A → Set p} where
open import Data.List using (List)
import Data.List.Relation.Unary.All as All
open import Data.Vec hiding (_[_]≔_)
open import Data.Vec.Relation.Unary.All hiding (lookup)
open import Data.Fin
all-fromList : ∀ {xs : List A} → All.All P xs → All P (fromList xs)
all-fromList All.[] = []
all-fromList (px All.∷ p) = px ∷ all-fromList p
_[_]≔_ : ∀ {n}{l : Vec A n} → All P l → (i : Fin n) → P (lookup l i)→ All P l
[] [ () ]≔ px
(px ∷ l) [ zero ]≔ px₁ = px₁ ∷ l
(px ∷ l) [ suc i ]≔ px₁ = px ∷ (l [ i ]≔ px₁)
| {
"alphanum_fraction": 0.6048109966,
"avg_line_length": 34.2352941176,
"ext": "agda",
"hexsha": "ea4222c76d4f6c7f2083249991a4bd512788ad8b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Data/Vec/All/Properties/Extra.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Data/Vec/All/Properties/Extra.agda",
"max_line_length": 77,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Data/Vec/All/Properties/Extra.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 222,
"size": 582
} |
open import Relation.Unary using ( ∅ ; _∪_ )
open import Web.Semantic.DL.Concept using ( Concept )
open import Web.Semantic.DL.Role using ( Role )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.Util using ( Subset ; ⁅_⁆ )
module Web.Semantic.DL.TBox where
infixl 5 _⊑₁_ _⊑₂_
infixr 4 _,_
{- a Terminology Box on a Signature (Concept and Role Names)
is constructed by specifying
- ε the empty TBox
- Combination of TBoxes (_,_) - ie. a Union
- subsumption relations ⊑ between roles and between concepts
- properties of Roles (Reflexivity, Irreflexivity, Transitivity)
- disjointness relation between Roles -}
data TBox (Σ : Signature) : Set where
ε : TBox Σ
_,_ : (T U : TBox Σ) → TBox Σ
_⊑₁_ : (C D : Concept Σ) → TBox Σ
_⊑₂_ : (Q R : Role Σ) → TBox Σ
Ref : (R : Role Σ) → TBox Σ
Irr : (R : Role Σ) → TBox Σ
Tra : (R : Role Σ) → TBox Σ
Dis : (Q R : Role Σ) → TBox Σ
Axioms : ∀ {Σ} → TBox Σ → Subset (TBox Σ)
Axioms ε = ∅
Axioms (T , U) = (Axioms T) ∪ (Axioms U)
Axioms (C ⊑₁ D) = ⁅ C ⊑₁ D ⁆
Axioms (Q ⊑₂ R) = ⁅ Q ⊑₂ R ⁆
Axioms (Ref R) = ⁅ Ref R ⁆
Axioms (Irr R) = ⁅ Irr R ⁆
Axioms (Tra R) = ⁅ Tra R ⁆
Axioms (Dis Q R) = ⁅ Dis Q R ⁆
| {
"alphanum_fraction": 0.61908646,
"avg_line_length": 31.4358974359,
"ext": "agda",
"hexsha": "b9373c77ac4b82521543ea466cdfbe9cf645ba5f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/TBox.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bblfish/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/TBox.agda",
"max_line_length": 67,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bblfish/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/DL/TBox.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-22T09:43:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-22T09:43:23.000Z",
"num_tokens": 505,
"size": 1226
} |
----------------------------------------------------------------------------------
-- Types for parse trees
----------------------------------------------------------------------------------
module cws-types where
open import lib
open import parse-tree
posinfo = string
{-# FOREIGN GHC import qualified CedilleCommentsLexer #-}
data entity : Set where
EntityComment : posinfo → posinfo → entity
EntityNonws : entity
EntityWs : posinfo → posinfo → entity
{-# COMPILE GHC entity = data CedilleCommentsLexer.Entity (CedilleCommentsLexer.EntityComment | CedilleCommentsLexer.EntityNonws | CedilleCommentsLexer.EntityWs) #-}
data entities : Set where
EndEntity : entities
Entity : entity → entities → entities
{-# COMPILE GHC entities = data CedilleCommentsLexer.Entities (CedilleCommentsLexer.EndEntity | CedilleCommentsLexer.Entity) #-}
data start : Set where
File : entities → start
{-# COMPILE GHC start = data CedilleCommentsLexer.Start (CedilleCommentsLexer.File) #-}
postulate
scanComments : string → start
{-# COMPILE GHC scanComments = CedilleCommentsLexer.scanComments #-}
-- embedded types:
data ParseTreeT : Set where
parsed-entities : entities → ParseTreeT
parsed-entity : entity → ParseTreeT
parsed-start : start → ParseTreeT
parsed-posinfo : posinfo → ParseTreeT
parsed-alpha : ParseTreeT
parsed-alpha-bar-3 : ParseTreeT
parsed-alpha-range-1 : ParseTreeT
parsed-alpha-range-2 : ParseTreeT
parsed-anychar : ParseTreeT
parsed-anychar-bar-59 : ParseTreeT
parsed-anychar-bar-60 : ParseTreeT
parsed-anychar-bar-61 : ParseTreeT
parsed-anychar-bar-62 : ParseTreeT
parsed-anychar-bar-63 : ParseTreeT
parsed-anynonwschar : ParseTreeT
parsed-anynonwschar-bar-68 : ParseTreeT
parsed-anynonwschar-bar-69 : ParseTreeT
parsed-aws : ParseTreeT
parsed-aws-bar-65 : ParseTreeT
parsed-aws-bar-66 : ParseTreeT
parsed-comment : ParseTreeT
parsed-comment-star-64 : ParseTreeT
parsed-nonws : ParseTreeT
parsed-nonws-plus-70 : ParseTreeT
parsed-num : ParseTreeT
parsed-num-plus-5 : ParseTreeT
parsed-numone : ParseTreeT
parsed-numone-range-4 : ParseTreeT
parsed-numpunct : ParseTreeT
parsed-numpunct-bar-10 : ParseTreeT
parsed-numpunct-bar-11 : ParseTreeT
parsed-numpunct-bar-6 : ParseTreeT
parsed-numpunct-bar-7 : ParseTreeT
parsed-numpunct-bar-8 : ParseTreeT
parsed-numpunct-bar-9 : ParseTreeT
parsed-otherpunct : ParseTreeT
parsed-otherpunct-bar-12 : ParseTreeT
parsed-otherpunct-bar-13 : ParseTreeT
parsed-otherpunct-bar-14 : ParseTreeT
parsed-otherpunct-bar-15 : ParseTreeT
parsed-otherpunct-bar-16 : ParseTreeT
parsed-otherpunct-bar-17 : ParseTreeT
parsed-otherpunct-bar-18 : ParseTreeT
parsed-otherpunct-bar-19 : ParseTreeT
parsed-otherpunct-bar-20 : ParseTreeT
parsed-otherpunct-bar-21 : ParseTreeT
parsed-otherpunct-bar-22 : ParseTreeT
parsed-otherpunct-bar-23 : ParseTreeT
parsed-otherpunct-bar-24 : ParseTreeT
parsed-otherpunct-bar-25 : ParseTreeT
parsed-otherpunct-bar-26 : ParseTreeT
parsed-otherpunct-bar-27 : ParseTreeT
parsed-otherpunct-bar-28 : ParseTreeT
parsed-otherpunct-bar-29 : ParseTreeT
parsed-otherpunct-bar-30 : ParseTreeT
parsed-otherpunct-bar-31 : ParseTreeT
parsed-otherpunct-bar-32 : ParseTreeT
parsed-otherpunct-bar-33 : ParseTreeT
parsed-otherpunct-bar-34 : ParseTreeT
parsed-otherpunct-bar-35 : ParseTreeT
parsed-otherpunct-bar-36 : ParseTreeT
parsed-otherpunct-bar-37 : ParseTreeT
parsed-otherpunct-bar-38 : ParseTreeT
parsed-otherpunct-bar-39 : ParseTreeT
parsed-otherpunct-bar-40 : ParseTreeT
parsed-otherpunct-bar-41 : ParseTreeT
parsed-otherpunct-bar-42 : ParseTreeT
parsed-otherpunct-bar-43 : ParseTreeT
parsed-otherpunct-bar-44 : ParseTreeT
parsed-otherpunct-bar-45 : ParseTreeT
parsed-otherpunct-bar-46 : ParseTreeT
parsed-otherpunct-bar-47 : ParseTreeT
parsed-otherpunct-bar-48 : ParseTreeT
parsed-otherpunct-bar-49 : ParseTreeT
parsed-otherpunct-bar-50 : ParseTreeT
parsed-otherpunct-bar-51 : ParseTreeT
parsed-otherpunct-bar-52 : ParseTreeT
parsed-otherpunct-bar-53 : ParseTreeT
parsed-otherpunct-bar-54 : ParseTreeT
parsed-otherpunct-bar-55 : ParseTreeT
parsed-otherpunct-bar-56 : ParseTreeT
parsed-otherpunct-bar-57 : ParseTreeT
parsed-otherpunct-bar-58 : ParseTreeT
parsed-ws : ParseTreeT
parsed-ws-plus-67 : ParseTreeT
------------------------------------------
-- Parse tree printing functions
------------------------------------------
posinfoToString : posinfo → string
posinfoToString x = "(posinfo " ^ x ^ ")"
mutual
entitiesToString : entities → string
entitiesToString (EndEntity) = "EndEntity" ^ ""
entitiesToString (Entity x0 x1) = "(Entity" ^ " " ^ (entityToString x0) ^ " " ^ (entitiesToString x1) ^ ")"
entityToString : entity → string
entityToString (EntityComment x0 x1) = "(EntityComment" ^ " " ^ (posinfoToString x0) ^ " " ^ (posinfoToString x1) ^ ")"
entityToString (EntityNonws) = "EntityNonws" ^ ""
entityToString (EntityWs x0 x1) = "(EntityWs" ^ " " ^ (posinfoToString x0) ^ " " ^ (posinfoToString x1) ^ ")"
startToString : start → string
startToString (File x0) = "(File" ^ " " ^ (entitiesToString x0) ^ ")"
ParseTreeToString : ParseTreeT → string
ParseTreeToString (parsed-entities t) = entitiesToString t
ParseTreeToString (parsed-entity t) = entityToString t
ParseTreeToString (parsed-start t) = startToString t
ParseTreeToString (parsed-posinfo t) = posinfoToString t
ParseTreeToString parsed-alpha = "[alpha]"
ParseTreeToString parsed-alpha-bar-3 = "[alpha-bar-3]"
ParseTreeToString parsed-alpha-range-1 = "[alpha-range-1]"
ParseTreeToString parsed-alpha-range-2 = "[alpha-range-2]"
ParseTreeToString parsed-anychar = "[anychar]"
ParseTreeToString parsed-anychar-bar-59 = "[anychar-bar-59]"
ParseTreeToString parsed-anychar-bar-60 = "[anychar-bar-60]"
ParseTreeToString parsed-anychar-bar-61 = "[anychar-bar-61]"
ParseTreeToString parsed-anychar-bar-62 = "[anychar-bar-62]"
ParseTreeToString parsed-anychar-bar-63 = "[anychar-bar-63]"
ParseTreeToString parsed-anynonwschar = "[anynonwschar]"
ParseTreeToString parsed-anynonwschar-bar-68 = "[anynonwschar-bar-68]"
ParseTreeToString parsed-anynonwschar-bar-69 = "[anynonwschar-bar-69]"
ParseTreeToString parsed-aws = "[aws]"
ParseTreeToString parsed-aws-bar-65 = "[aws-bar-65]"
ParseTreeToString parsed-aws-bar-66 = "[aws-bar-66]"
ParseTreeToString parsed-comment = "[comment]"
ParseTreeToString parsed-comment-star-64 = "[comment-star-64]"
ParseTreeToString parsed-nonws = "[nonws]"
ParseTreeToString parsed-nonws-plus-70 = "[nonws-plus-70]"
ParseTreeToString parsed-num = "[num]"
ParseTreeToString parsed-num-plus-5 = "[num-plus-5]"
ParseTreeToString parsed-numone = "[numone]"
ParseTreeToString parsed-numone-range-4 = "[numone-range-4]"
ParseTreeToString parsed-numpunct = "[numpunct]"
ParseTreeToString parsed-numpunct-bar-10 = "[numpunct-bar-10]"
ParseTreeToString parsed-numpunct-bar-11 = "[numpunct-bar-11]"
ParseTreeToString parsed-numpunct-bar-6 = "[numpunct-bar-6]"
ParseTreeToString parsed-numpunct-bar-7 = "[numpunct-bar-7]"
ParseTreeToString parsed-numpunct-bar-8 = "[numpunct-bar-8]"
ParseTreeToString parsed-numpunct-bar-9 = "[numpunct-bar-9]"
ParseTreeToString parsed-otherpunct = "[otherpunct]"
ParseTreeToString parsed-otherpunct-bar-12 = "[otherpunct-bar-12]"
ParseTreeToString parsed-otherpunct-bar-13 = "[otherpunct-bar-13]"
ParseTreeToString parsed-otherpunct-bar-14 = "[otherpunct-bar-14]"
ParseTreeToString parsed-otherpunct-bar-15 = "[otherpunct-bar-15]"
ParseTreeToString parsed-otherpunct-bar-16 = "[otherpunct-bar-16]"
ParseTreeToString parsed-otherpunct-bar-17 = "[otherpunct-bar-17]"
ParseTreeToString parsed-otherpunct-bar-18 = "[otherpunct-bar-18]"
ParseTreeToString parsed-otherpunct-bar-19 = "[otherpunct-bar-19]"
ParseTreeToString parsed-otherpunct-bar-20 = "[otherpunct-bar-20]"
ParseTreeToString parsed-otherpunct-bar-21 = "[otherpunct-bar-21]"
ParseTreeToString parsed-otherpunct-bar-22 = "[otherpunct-bar-22]"
ParseTreeToString parsed-otherpunct-bar-23 = "[otherpunct-bar-23]"
ParseTreeToString parsed-otherpunct-bar-24 = "[otherpunct-bar-24]"
ParseTreeToString parsed-otherpunct-bar-25 = "[otherpunct-bar-25]"
ParseTreeToString parsed-otherpunct-bar-26 = "[otherpunct-bar-26]"
ParseTreeToString parsed-otherpunct-bar-27 = "[otherpunct-bar-27]"
ParseTreeToString parsed-otherpunct-bar-28 = "[otherpunct-bar-28]"
ParseTreeToString parsed-otherpunct-bar-29 = "[otherpunct-bar-29]"
ParseTreeToString parsed-otherpunct-bar-30 = "[otherpunct-bar-30]"
ParseTreeToString parsed-otherpunct-bar-31 = "[otherpunct-bar-31]"
ParseTreeToString parsed-otherpunct-bar-32 = "[otherpunct-bar-32]"
ParseTreeToString parsed-otherpunct-bar-33 = "[otherpunct-bar-33]"
ParseTreeToString parsed-otherpunct-bar-34 = "[otherpunct-bar-34]"
ParseTreeToString parsed-otherpunct-bar-35 = "[otherpunct-bar-35]"
ParseTreeToString parsed-otherpunct-bar-36 = "[otherpunct-bar-36]"
ParseTreeToString parsed-otherpunct-bar-37 = "[otherpunct-bar-37]"
ParseTreeToString parsed-otherpunct-bar-38 = "[otherpunct-bar-38]"
ParseTreeToString parsed-otherpunct-bar-39 = "[otherpunct-bar-39]"
ParseTreeToString parsed-otherpunct-bar-40 = "[otherpunct-bar-40]"
ParseTreeToString parsed-otherpunct-bar-41 = "[otherpunct-bar-41]"
ParseTreeToString parsed-otherpunct-bar-42 = "[otherpunct-bar-42]"
ParseTreeToString parsed-otherpunct-bar-43 = "[otherpunct-bar-43]"
ParseTreeToString parsed-otherpunct-bar-44 = "[otherpunct-bar-44]"
ParseTreeToString parsed-otherpunct-bar-45 = "[otherpunct-bar-45]"
ParseTreeToString parsed-otherpunct-bar-46 = "[otherpunct-bar-46]"
ParseTreeToString parsed-otherpunct-bar-47 = "[otherpunct-bar-47]"
ParseTreeToString parsed-otherpunct-bar-48 = "[otherpunct-bar-48]"
ParseTreeToString parsed-otherpunct-bar-49 = "[otherpunct-bar-49]"
ParseTreeToString parsed-otherpunct-bar-50 = "[otherpunct-bar-50]"
ParseTreeToString parsed-otherpunct-bar-51 = "[otherpunct-bar-51]"
ParseTreeToString parsed-otherpunct-bar-52 = "[otherpunct-bar-52]"
ParseTreeToString parsed-otherpunct-bar-53 = "[otherpunct-bar-53]"
ParseTreeToString parsed-otherpunct-bar-54 = "[otherpunct-bar-54]"
ParseTreeToString parsed-otherpunct-bar-55 = "[otherpunct-bar-55]"
ParseTreeToString parsed-otherpunct-bar-56 = "[otherpunct-bar-56]"
ParseTreeToString parsed-otherpunct-bar-57 = "[otherpunct-bar-57]"
ParseTreeToString parsed-otherpunct-bar-58 = "[otherpunct-bar-58]"
ParseTreeToString parsed-ws = "[ws]"
ParseTreeToString parsed-ws-plus-67 = "[ws-plus-67]"
------------------------------------------
-- Reorganizing rules
------------------------------------------
mutual
{-# TERMINATING #-}
norm-start : (x : start) → start
norm-start x = x
{-# TERMINATING #-}
norm-posinfo : (x : posinfo) → posinfo
norm-posinfo x = x
{-# TERMINATING #-}
norm-entity : (x : entity) → entity
norm-entity x = x
{-# TERMINATING #-}
norm-entities : (x : entities) → entities
norm-entities x = x
isParseTree : ParseTreeT → 𝕃 char → string → Set
isParseTree p l s = ⊤ {- this will be ignored since we are using simply typed runs -}
ptr : ParseTreeRec
ptr = record { ParseTreeT = ParseTreeT ; isParseTree = isParseTree ; ParseTreeToString = ParseTreeToString }
| {
"alphanum_fraction": 0.7371331728,
"avg_line_length": 43.4534883721,
"ext": "agda",
"hexsha": "547fcb00b53f21865960426f8a16e6470b3fcfb1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xoltar/cedille",
"max_forks_repo_path": "src/cws-types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "xoltar/cedille",
"max_issues_repo_path": "src/cws-types.agda",
"max_line_length": 165,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xoltar/cedille",
"max_stars_repo_path": "src/cws-types.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3183,
"size": 11211
} |
module Cats.Profunctor where
open import Data.Product using (_,_)
open import Level using (suc ; _⊔_)
open import Cats.Category
open import Cats.Category.Op using (_ᵒᵖ)
open import Cats.Category.Product.Binary using (_×_)
open import Cats.Category.Setoids using (Setoids)
open import Cats.Functor
import Cats.Category.Cat as Cat
import Cats.Category.Cat.Facts.Product as Cat
-- The usual definition inverts C and D, so
--
-- Profunctor C D E = Functor (Dᵒᵖ × C) E
--
-- but that's just confusing.
Profunctor : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}
→ Category lo la l≈
→ Category lo′ la′ l≈′
→ Category lo″ la″ l≈″
→ Set (lo ⊔ la ⊔ l≈ ⊔ lo′ ⊔ la′ ⊔ l≈′ ⊔ lo″ ⊔ la″ ⊔ l≈″)
Profunctor C D E = Functor ((C ᵒᵖ) × D) E
module Profunctor {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}
{C : Category lo la l≈}
{D : Category lo′ la′ l≈′}
{E : Category lo″ la″ l≈″}
(F : Profunctor C D E)
where
private
module C = Category C
module D = Category D
module E = Category E
pobj : C.Obj → D.Obj → E.Obj
pobj c d = fobj F (c , d)
pmap : ∀ {c c′} (f : c′ C.⇒ c) {d d′} (g : d D.⇒ d′)
→ pobj c d E.⇒ pobj c′ d′
pmap f g = fmap F (f , g)
pmap₁ : ∀ {c c′ d} (f : c′ C.⇒ c)
→ pobj c d E.⇒ pobj c′ d
pmap₁ f = pmap f D.id
pmap₂ : ∀ {c d d′} (g : d D.⇒ d′)
→ pobj c d E.⇒ pobj c d′
pmap₂ g = pmap C.id g
open Profunctor public
Functor→Profunctor₁ : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}
→ {C : Category lo la l≈} {D : Category lo′ la′ l≈′} {X : Category lo″ la″ l≈″}
→ Functor (C ᵒᵖ) D
→ Profunctor C X D
Functor→Profunctor₁ F = F Cat.∘ Cat.proj₁
Functor→Profunctor₂ : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″}
→ {C : Category lo la l≈} {D : Category lo′ la′ l≈′} {X : Category lo″ la″ l≈″}
→ Functor C D
→ Profunctor X C D
Functor→Profunctor₂ F = F Cat.∘ Cat.proj₂
| {
"alphanum_fraction": 0.5818681319,
"avg_line_length": 23.9473684211,
"ext": "agda",
"hexsha": "f2f4a76a001b0baef227f95f15f935312d931c03",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Profunctor.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Profunctor.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Profunctor.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 791,
"size": 1820
} |
-- There was a rare bug in display form generation for with functions
-- in local blocks.
module WithInWhere where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Z? : Nat -> Set where
yes : Z? zero
no : forall {n} -> Z? (suc n)
z? : (n : Nat) -> Z? n
z? zero = yes
z? (suc n) = no
bug : Nat -> Nat
bug n = ans
where
ans : Nat
ans with z? (suc n)
... | no with zero
... | _ = zero
| {
"alphanum_fraction": 0.5516431925,
"avg_line_length": 16.3846153846,
"ext": "agda",
"hexsha": "60d6d030374535ef2c38e44617ea5459ae014180",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/WithInWhere.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/WithInWhere.agda",
"max_line_length": 69,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/WithInWhere.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 151,
"size": 426
} |
module Cats.Category.Preorder.Facts.PreorderAsCategory where
open import Data.Bool using (true ; false)
open import Relation.Binary using (Preorder)
import Level
open import Cats.Category
open import Cats.Category.Preorder using (preorderAsCategory)
open import Cats.Util.Logic.Constructive
module _ {lc l≈ l≤} (P : Preorder lc l≈ l≤) where
C : Category _ _ _
C = preorderAsCategory P
open module P = Preorder P using (_∼_) renaming (_≈_ to _≋_)
open Category C
_≈_⊔_ : Obj → Obj → Obj → Set l≤
lub ≈ x ⊔ y = x ∼ lub ∧ y ∼ lub ∧ (lub ∼ x ∨ lub ∼ y)
_≈_⊓_ : Obj → Obj → Obj → Set l≤
glb ≈ x ⊓ y = glb ∼ x ∧ glb ∼ y ∧ (x ∼ glb ∨ y ∼ glb)
IsMinimum : Obj → Set (lc Level.⊔ l≤)
IsMinimum m = ∀ x → m ∼ x
IsMaximum : Obj → Set (lc Level.⊔ l≤)
IsMaximum m = ∀ x → x ∼ m
initial : ∀ {x} → IsMinimum x → IsInitial x
initial min y = ∃!-intro (min y) _ _
terminal : ∀ {x} → IsMaximum x → IsTerminal x
terminal max y = ∃!-intro (max y) _ _
⊓-isBinaryProduct : ∀ {glb x y}
→ (pl : glb ∼ x)
→ (pr : glb ∼ y)
→ (x ∼ glb ∨ y ∼ glb)
→ IsBinaryProduct glb pl pr
⊓-isBinaryProduct pl pr (∨-introl x∼glb) xl xr = ∃!-intro (x∼glb ∘ xl) _ _
⊓-isBinaryProduct pl pr (∨-intror y∼glb) xl xr = ∃!-intro (y∼glb ∘ xr) _ _
⊓-to-BinaryProduct : ∀ {glb x y} → glb ≈ x ⊓ y → BinaryProduct x y
⊓-to-BinaryProduct {glb} (pl , pr , maximal)
= mkBinaryProduct pl pr (⊓-isBinaryProduct pl pr maximal)
mono : ∀ {x y} (f : x ⇒ y) → IsMono f
mono = _
epi : ∀ {x y} (f : x ⇒ y) → IsEpi f
epi = _
unique : ∀ {x y} (f : x ⇒ y) → IsUnique f
unique = _
| {
"alphanum_fraction": 0.5832817337,
"avg_line_length": 22.7464788732,
"ext": "agda",
"hexsha": "ca1bb1fec4989afd2348c0d57a07fd7af4f900be",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Category/Preorder/Facts/PreorderAsCategory.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Preorder/Facts/PreorderAsCategory.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Preorder/Facts/PreorderAsCategory.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 659,
"size": 1615
} |
{-# OPTIONS --safe #-}
module Cubical.Data.FinType where
open import Cubical.Data.FinType.Base public
open import Cubical.Data.FinType.Properties public
| {
"alphanum_fraction": 0.7870967742,
"avg_line_length": 22.1428571429,
"ext": "agda",
"hexsha": "f92d28a66d552aee381573b6fff45dbeb3536244",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Data/FinType.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Data/FinType.agda",
"max_line_length": 50,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Data/FinType.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 36,
"size": 155
} |
{-# OPTIONS --cubical --safe --postfix-projections #-}
open import Prelude
open import Relation.Binary
module Data.List.Mapping {kℓ} {K : Type kℓ} {r₁ r₂} (totalOrder : TotalOrder K r₁ r₂) where
open import Relation.Binary.Construct.Decision totalOrder
open import Relation.Binary.Construct.LowerBound dec-ord
open import Data.Nat using (_+_)
open TotalOrder lb-ord using (<-trans) renaming (refl to <-refl)
import Data.Unit.UniversePolymorphic as Poly
open import Data.Maybe.Properties using (IsJust)
open TotalOrder dec-ord using (_<?_; _<_; total⇒isSet; irrefl; compare)
instance
top-inst : Poly.⊤ {ℓzero}
top-inst = Poly.tt
private
variable
n m : ℕ
v : Level
Val : K → Type v
infixr 5 _︓_,_
data MapFrom (lb : ⌊∙⌋) {v} (Val : K → Type v) : Type (kℓ ℓ⊔ r₁ ℓ⊔ v) where
∅ : MapFrom lb Val
_︓_,_ : (k : K) → ⦃ inBounds : lb <⌊ k ⌋ ⦄ → (v : Val k) → MapFrom ⌊ k ⌋ Val → MapFrom lb Val
private
variable
lb : ⌊∙⌋
weaken : ∀ {x} → ⦃ _ : lb <⌊ x ⌋ ⦄ → MapFrom ⌊ x ⌋ Val → MapFrom lb Val
weaken ∅ = ∅
weaken {lb = lb} {x = x} (k ︓ val , xs) = k ︓ val , xs
where
instance
_ : lb <⌊ k ⌋
_ = <-trans {x = lb} {y = ⌊ x ⌋} {z = ⌊ k ⌋} it it
-- module _ {v} {Val : K → Type v} where
-- _[_]? : MapFrom lb Val → (k : K) ⦃ inBounds : lb <⌊ k ⌋ ⦄ → Maybe (Val k)
-- ∅ [ k ]? = nothing
-- k₂ ︓ v , xs [ k₁ ]? = case compare k₁ k₂ of
-- λ { (lt _) → nothing ;
-- (eq _) → just (subst Val (sym it) v) ;
-- (gt _) → xs [ k₁ ]? }
-- infixl 4 _[_]?
-- -- _[_]︓_ : MapFrom lb Val → (k : K) ⦃ inBounds : lb <⌊ k ⌋ ⦄ → (val : Val k) → MapFrom lb Val
-- -- ∅ [ k₁ ]︓ v₁ = k₁ ︓ v₁ , ∅
-- -- (k₂ ︓ v₂ , xs) [ k₁ ]︓ v₁ =
-- -- comparing k₁ ∙ k₂
-- -- |< k₁ ︓ v₁ , k₂ ︓ v₂ , xs
-- -- |≡ k₂ ︓ subst Val it v₁ , xs
-- -- |> k₂ ︓ v₂ , (xs [ k₁ ]︓ v₁)
-- -- infixl 4 _[_]︓_
-- -- _[_]︓∅ : MapFrom lb Val → (k : K) ⦃ inBounds : lb <⌊ k ⌋ ⦄ → MapFrom lb Val
-- -- ∅ [ k₁ ]︓∅ = ∅
-- -- (k₂ ︓ v₂ , xs) [ k₁ ]︓∅ = comparing k₁ ∙ k₂
-- -- |< k₂ ︓ v₂ , xs
-- -- |≡ weaken xs
-- -- |> k₂ ︓ v₂ , (xs [ k₁ ]︓∅)
-- -- infixl 4 _[_]︓∅
-- -- infixr 0 Map
-- -- Map : ∀ {v} (Val : K → Type v) → Type _
-- -- Map = MapFrom ⌊⊥⌋
-- -- syntax Map (λ s → e) = s ↦ e
-- -- Map′ : ∀ {v} (Val : Type v) → Type _
-- -- Map′ V = Map (const V)
-- -- infixr 5 _≔_,_
-- -- data RecordFrom (lb : ⌊∙⌋) : MapFrom lb (const Type) → Type (kℓ ℓ⊔ r₁ ℓ⊔ ℓsuc ℓzero) where
-- -- ∅ : RecordFrom lb ∅
-- -- _≔_,_ : (k : K) → ⦃ inBounds : lb <⌊ k ⌋ ⦄ → {xs : MapFrom ⌊ k ⌋ (const Type)} {t : Type} → (v : t) → RecordFrom ⌊ k ⌋ xs → RecordFrom lb (k ︓ t , xs)
-- -- Record : Map′ Type → Type _
-- -- Record = RecordFrom ⌊⊥⌋
-- -- infixr 5 _∈_
-- -- _∈_ : (k : K) → ⦃ inBounds : lb <⌊ k ⌋ ⦄ → MapFrom lb Val → Type
-- -- k ∈ xs = IsJust (xs [ k ]?)
-- -- _[_]! : (xs : MapFrom lb Val) → (k : K) → ⦃ inBounds : lb <⌊ k ⌋ ⦄ → ⦃ k∈xs : k ∈ xs ⦄ → Val k
-- -- xs [ k ]! with xs [ k ]? | inspect (_[_]? xs) k
-- -- xs [ k ]! | just x | _ = x
-- -- xs [ k ]! | nothing | _ = ⊥-elim it
-- -- infixl 4 _[_]
-- -- _[_] : {xs : MapFrom lb (const Type)} → RecordFrom lb xs → (k : K) ⦃ inBounds : lb <⌊ k ⌋ ⦄ ⦃ k∈xs : k ∈ xs ⦄ → xs [ k ]!
-- -- _[_] {xs = xs} (k₂ ≔ v , r) k₁ with xs [ k₁ ]? | compare′ k₁ k₂
-- -- (k₂ ≔ v , r) [ k₁ ] | _ | lt′ = ⊥-elim it
-- -- (k₂ ≔ v , r) [ k₁ ] | _ | eq′ = v
-- -- (k₂ ≔ v , r) [ k₁ ] | _ | gt′ = r [ k₁ ]
-- -- infixl 4 _[_]≔_
-- -- _[_]≔_ : {xs : MapFrom lb (const Type)} → RecordFrom lb xs → (k : K) ⦃ inBounds : lb <⌊ k ⌋ ⦄ → A → RecordFrom lb (xs [ k ]︓ A)
-- -- ∅ [ k ]≔ x = k ≔ x , ∅
-- -- (k₂ ≔ v₁ , rs) [ k₁ ]≔ x with compare′ k₁ k₂
-- -- (k₂ ≔ v₁ , rs) [ k₁ ]≔ x | lt′ = k₁ ≔ x , k₂ ≔ v₁ , rs
-- -- (k₂ ≔ v₁ , rs) [ k₁ ]≔ x | eq′ = k₂ ≔ x , rs
-- -- (k₂ ≔ v₁ , rs) [ k₁ ]≔ x | gt′ = k₂ ≔ v₁ , (rs [ k₁ ]≔ x)
| {
"alphanum_fraction": 0.4682352941,
"avg_line_length": 35.0917431193,
"ext": "agda",
"hexsha": "a3f156433b01f401c953e13db3519000f2be19ba",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/List/Mapping.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/List/Mapping.agda",
"max_line_length": 158,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/List/Mapping.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 1833,
"size": 3825
} |
{-# OPTIONS --rewriting #-}
module Interpreter where
open import Agda.Builtin.IO using (IO)
open import Agda.Builtin.Int using (pos)
open import Agda.Builtin.Unit using (⊤)
open import FFI.IO using (getContents; putStrLn; _>>=_; _>>_)
open import FFI.Data.Aeson using (Value; eitherDecode)
open import FFI.Data.Either using (Left; Right)
open import FFI.Data.Maybe using (just; nothing)
open import FFI.Data.String using (String; _++_)
open import FFI.Data.Text.Encoding using (encodeUtf8)
open import FFI.System.Exit using (exitWith; ExitFailure)
open import Luau.StrictMode.ToString using (warningToStringᴮ)
open import Luau.Syntax using (Block; yes; maybe; isAnnotatedᴮ)
open import Luau.Syntax.FromJSON using (blockFromJSON)
open import Luau.Syntax.ToString using (blockToString; valueToString)
open import Luau.Run using (run; return; done; error)
open import Luau.RuntimeError.ToString using (errToStringᴮ)
open import Properties.StrictMode using (wellTypedProgramsDontGoWrong)
runBlock′ : ∀ a → Block a → IO ⊤
runBlock′ a block with run block
runBlock′ a block | return V D = putStrLn ("\nRAN WITH RESULT: " ++ valueToString V)
runBlock′ a block | done D = putStrLn ("\nRAN")
runBlock′ maybe block | error E D = putStrLn ("\nRUNTIME ERROR:\n" ++ errToStringᴮ _ E)
runBlock′ yes block | error E D with wellTypedProgramsDontGoWrong _ block _ D E
runBlock′ yes block | error E D | W = putStrLn ("\nRUNTIME ERROR:\n" ++ errToStringᴮ _ E ++ "\n\nTYPE ERROR:\n" ++ warningToStringᴮ _ W)
runBlock : Block maybe → IO ⊤
runBlock B with isAnnotatedᴮ B
runBlock B | nothing = putStrLn ("UNANNOTATED PROGRAM:\n" ++ blockToString B) >> runBlock′ maybe B
runBlock B | just B′ = putStrLn ("ANNOTATED PROGRAM:\n" ++ blockToString B) >> runBlock′ yes B′
runJSON : Value → IO ⊤
runJSON value with blockFromJSON(value)
runJSON value | (Left err) = putStrLn ("LUAU ERROR: " ++ err) >> exitWith (ExitFailure (pos 1))
runJSON value | (Right block) = runBlock block
runString : String → IO ⊤
runString txt with eitherDecode (encodeUtf8 txt)
runString txt | (Left err) = putStrLn ("JSON ERROR: " ++ err) >> exitWith (ExitFailure (pos 1))
runString txt | (Right value) = runJSON value
main : IO ⊤
main = getContents >>= runString
| {
"alphanum_fraction": 0.7376237624,
"avg_line_length": 43.568627451,
"ext": "agda",
"hexsha": "d8036740c546d8e5d27efdd8f393a83d8805274e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "XanderYZZ/luau",
"max_forks_repo_path": "prototyping/Interpreter.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "XanderYZZ/luau",
"max_issues_repo_path": "prototyping/Interpreter.agda",
"max_line_length": 136,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TheGreatSageEqualToHeaven/luau",
"max_stars_repo_path": "prototyping/Interpreter.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z",
"num_tokens": 629,
"size": 2222
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.PtdMapSequence
module homotopy.CofiberSequence {i} where
{- Useful abbreviations -}
module _ {X Y : Ptd i} (f : X ⊙→ Y) where
⊙Cofiber² = ⊙Cofiber (⊙cfcod' f)
⊙cfcod²' = ⊙cfcod' (⊙cfcod' f)
⊙Cofiber³ = ⊙Cofiber ⊙cfcod²'
⊙cfcod³' = ⊙cfcod' ⊙cfcod²'
module _ {A B : Type i} (f : A → B) where
Cofiber² = Cofiber (cfcod' f)
cfcod²' = cfcod' (cfcod' f)
Cofiber³ = Cofiber cfcod²'
cfcod³' = cfcod' cfcod²'
{- For [f : X → Y], the cofiber space [Cofiber(cfcod f)] is equivalent to
- [Susp X]. This is essentially an application of the two pushouts
- lemma:
-
- f
- X ––––> Y ––––––––––––––> ∙
- | | |
- | |cfcod f |
- v v v
- ∙ ––> Cofiber f ––––––––––> Cofiber² f
- cfcod² f
-
- The map [cfcod² f : Cofiber f → Cofiber² f] becomes [extract-glue : Cofiber f → ΣX],
- and the map [cfcod³ f : Cofiber² f → Cofiber³ f] becomes [Susp-fmap f : ΣX → ΣY].
-}
private
{- the equivalences between [Cofiber² f] and [ΣX] (and so [Cofiber³ f] and [ΣY]) -}
module Equiv {X Y : Ptd i} (f : X ⊙→ Y) where
module Into = CofiberRec {f = cfcod' (fst f)} {C = Susp (de⊙ X)}
south extract-glue (λ _ → idp)
into : Cofiber² (fst f) → Susp (de⊙ X)
into = Into.f
⊙into : ⊙Cofiber² f ⊙→ ⊙Susp X
⊙into = into , ! (merid (pt X))
module Out = SuspRec {C = de⊙ (⊙Cofiber² f)}
(cfcod cfbase) cfbase
(λ x → ap cfcod (cfglue x) ∙ ! (cfglue (fst f x)))
out : Susp (de⊙ X) → Cofiber² (fst f)
out = Out.f
abstract
into-out : ∀ σ → into (out σ) == σ
into-out = Susp-elim idp idp
(λ x → ↓-∘=idf-in' into out $
ap (ap into) (Out.merid-β 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) ∙ ExtractGlue.glue-β x)
out-into : ∀ κ → out (into κ) == κ
out-into = Cofiber-elim {f = cfcod' (fst f)}
idp
(Cofiber-elim {f = fst f} idp cfglue
(λ x → ↓-='-from-square $
(ap-∘ out extract-glue (cfglue x)
∙ ap (ap out) (ExtractGlue.glue-β x) ∙ Out.merid-β 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)
eqv : Cofiber² (fst f) ≃ Susp (de⊙ X)
eqv = equiv into out into-out out-into
⊙eqv : ⊙Cofiber² f ⊙≃ ⊙Susp X
⊙eqv = ≃-to-⊙≃ eqv (! (merid (pt X)))
module _ {X Y : Ptd i} (f : X ⊙→ Y) where
⊙Cof²-to-⊙Susp : ⊙Cofiber² f ⊙→ ⊙Susp X
⊙Cof²-to-⊙Susp = Equiv.⊙into f
Cof²-to-Susp = fst ⊙Cof²-to-⊙Susp
⊙Susp-to-⊙Cof² : ⊙Susp X ⊙→ ⊙Cofiber² f
⊙Susp-to-⊙Cof² = ⊙<– (Equiv.⊙eqv f)
Susp-to-Cof² = fst ⊙Susp-to-⊙Cof²
Cof²-equiv-Susp : Cofiber² (fst f) ≃ Susp (de⊙ X)
Cof²-equiv-Susp = Equiv.eqv f
cod²-extract-glue-comm-sqr : CommSquare (cfcod²' (fst f)) extract-glue (idf _) Cof²-to-Susp
cod²-extract-glue-comm-sqr = comm-sqr λ _ → idp
extract-glue-cod²-comm-sqr : CommSquare extract-glue (cfcod²' (fst f)) (idf _) Susp-to-Cof²
extract-glue-cod²-comm-sqr = CommSquare-inverse-v cod²-extract-glue-comm-sqr
(idf-is-equiv _) (snd Cof²-equiv-Susp)
abstract
cod³-Susp-fmap-comm-sqr : CommSquare (cfcod³' (fst f)) (Susp-fmap (fst f))
Cof²-to-Susp (Susp-flip ∘ Equiv.into (⊙cfcod' f))
cod³-Susp-fmap-comm-sqr = comm-sqr $ Cofiber-elim {f = cfcod' (fst f)}
idp
(Cofiber-elim {f = fst f}
idp (λ y → merid y)
(λ x → ↓-cst=app-in $
ap (idp ∙'_)
( ap-∘ (Susp-fmap (fst f)) extract-glue (cfglue x)
∙ ap (ap (Susp-fmap (fst f))) (ExtractGlue.glue-β x)
∙ SuspFmap.merid-β (fst f) x)
∙ ∙'-unit-l (merid (fst f x))))
(λ y → ↓-='-in' $
ap (Susp-fmap (fst f) ∘ Cof²-to-Susp) (cfglue y)
=⟨ ap-∘ (Susp-fmap (fst f)) Cof²-to-Susp (cfglue y) ⟩
ap (Susp-fmap (fst f)) (ap Cof²-to-Susp (cfglue y))
=⟨ Equiv.Into.glue-β f y |in-ctx ap (Susp-fmap (fst f)) ⟩
idp
=⟨ ! $ !-inv'-l (merid y) ⟩
! (merid y) ∙' merid y
=⟨ ! $ SuspFlip.merid-β y |in-ctx _∙' merid y ⟩
ap Susp-flip (merid y) ∙' merid y
=⟨ ! $ ExtractGlue.glue-β y |in-ctx (λ p → ap Susp-flip p ∙' merid y) ⟩
ap Susp-flip (ap extract-glue (cfglue y)) ∙' merid y
=⟨ ! $ ap-∘ Susp-flip extract-glue (cfglue y) |in-ctx _∙' merid y ⟩
ap (Susp-flip ∘ extract-glue) (cfglue y) ∙' merid y
=∎)
iterated-cofiber-seq : PtdMapSequence X (⊙Cofiber³ f)
iterated-cofiber-seq =
X ⊙→⟨ f ⟩ Y ⊙→⟨ ⊙cfcod' f ⟩ ⊙Cofiber f ⊙→⟨ ⊙cfcod²' f ⟩ ⊙Cofiber² f ⊙→⟨ ⊙cfcod³' f ⟩ ⊙Cofiber³ f ⊙⊣|
cyclic-cofiber-seq : PtdMapSequence X (⊙Susp Y)
cyclic-cofiber-seq =
X ⊙→⟨ f ⟩ Y ⊙→⟨ ⊙cfcod' f ⟩ ⊙Cofiber f ⊙→⟨ ⊙extract-glue ⟩ ⊙Susp X ⊙→⟨ ⊙Susp-fmap f ⟩ ⊙Susp Y ⊙⊣|
iterated-to-cyclic : PtdMapSeqMap iterated-cofiber-seq cyclic-cofiber-seq
(⊙idf X) (⊙Susp-flip Y ⊙∘ Equiv.⊙into (⊙cfcod' f))
iterated-to-cyclic =
⊙idf X ⊙↓⟨ comm-sqr (λ _ → idp) ⟩
⊙idf Y ⊙↓⟨ comm-sqr (λ _ → idp) ⟩
⊙idf (⊙Cofiber f) ⊙↓⟨ cod²-extract-glue-comm-sqr ⟩
⊙Cof²-to-⊙Susp ⊙↓⟨ cod³-Susp-fmap-comm-sqr ⟩
⊙Susp-flip Y ⊙∘ Equiv.⊙into (⊙cfcod' f) ⊙↓|
iterated-to-cyclic-is-equiv : is-⊙seq-equiv iterated-to-cyclic
iterated-to-cyclic-is-equiv =
idf-is-equiv _
, idf-is-equiv _
, idf-is-equiv _
, snd (Equiv.eqv f)
, snd (Susp-flip-equiv ∘e (Equiv.eqv (⊙cfcod' f)))
iterated-equiv-cyclic : PtdMapSeqEquiv iterated-cofiber-seq cyclic-cofiber-seq
(⊙idf X) (⊙Susp-flip Y ⊙∘ Equiv.⊙into (⊙cfcod' f))
iterated-equiv-cyclic = iterated-to-cyclic , iterated-to-cyclic-is-equiv
| {
"alphanum_fraction": 0.5274138768,
"avg_line_length": 36.5857988166,
"ext": "agda",
"hexsha": "2b1075e117efcf678a042668176511b043bb8742",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/CofiberSequence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/CofiberSequence.agda",
"max_line_length": 104,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/CofiberSequence.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2639,
"size": 6183
} |
open import FRP.JS.Behaviour using ( Beh ; [_] ; hold )
open import FRP.JS.Event using ( tag )
open import FRP.JS.DOM using ( DOM ; text ; element ; listen ; click ; _++_ )
open import FRP.JS.RSet using ( ⟦_⟧ )
module FRP.JS.Demo.Button where
main : ∀ {w} → ⟦ Beh (DOM w) ⟧
main = text lab ++ but where
but = element "button" (text ["OK"])
lab = hold "Press me: " (tag "Pressed: " (listen click but))
| {
"alphanum_fraction": 0.6314496314,
"avg_line_length": 33.9166666667,
"ext": "agda",
"hexsha": "4999ebcb6d38dd4767b8517288296e65c8e4e909",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "demo/agda/FRP/JS/Demo/Button.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "demo/agda/FRP/JS/Demo/Button.agda",
"max_line_length": 77,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "demo/agda/FRP/JS/Demo/Button.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 135,
"size": 407
} |
module _ where
module A where
infixr 5 _∷_
data D : Set₂ where
[] : D
_∷_ : Set₁ → D → D
module B where
infix 5 _∷_
data D : Set₂ where
_∷_ : Set₁ → Set₁ → D
open A
open B
foo : A.D
foo = Set ∷ []
bar : B.D
bar = Set ∷ Set
| {
"alphanum_fraction": 0.5375494071,
"avg_line_length": 9.7307692308,
"ext": "agda",
"hexsha": "9bb2dede9eef5dc6b908d9ceb6747570ce081156",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue1436-16.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue1436-16.agda",
"max_line_length": 25,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue1436-16.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 107,
"size": 253
} |
{-# OPTIONS --without-K --exact-split --safe #-}
module Basic_Types where
-- Already in the builtin's of agda, there are Π types, which is ∀, and lambda
-- abstraction, which is λ{ } and function types, which is →.
-- ------------------------------------
-- Some operations for function types
-- The curly brackts ∀{} should be viewed as contexts.
-- identity function
id : ∀ {A : Set} → A → A
id = λ{ x → x }
-- function composition
comp : ∀ {A B C : Set} → (B → C) → (A → B) → A → C
comp {A} {B} {C} = λ (f : B → C) (g : A → B) (x : A) → f (g x)
-- The judgemental equality of association of functions is builtin in agda,
-- i.e., all the rules of derivation in the basic language of type theory,
-- e.g., the β-, η- reduction is automatic in agda.
-- swapping the argument
swap : ∀ {A B : Set} {C : A → B → Set} →
(∀ (a : A) (b : B) → C a b) → (∀ (b : B) (a : A) → C a b)
swap {A} {B} {C} = λ { p → λ (b : B) (a : A) → p a b }
-- ------------------------------------
-- the unit type
data 𝟙 : Set where
⋆ : 𝟙
𝟙-ind : ∀ {A : 𝟙 → Set} → ∀ (a : A ⋆) → ∀ (x : 𝟙) → A x
𝟙-ind {A} a = 𝟙-indhelper
where 𝟙-indhelper : ∀ (x : 𝟙) → A x
𝟙-indhelper ⋆ = a
-- ------------------------------------
-- the empty type
data 𝟘 : Set where
𝟘-ind : ∀ {A : 𝟘 → Set} → ∀ (x : 𝟘) → A x
𝟘-ind {A} ()
-- define negation
¬_ : ∀ (A : Set) → Set
¬ A = A → 𝟘
-- ------------------------------------
-- the boolean type
data 𝟚 : Set where
tt ff : 𝟚
𝟚-ind : ∀ {A : 𝟚 → Set} → A ff → A tt → ∀ (x : 𝟚) → A x
𝟚-ind Aff _ ff = Aff
𝟚-ind _ Att tt = Att
-- ------------------------------------
-- natural numbers
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
-- ℕ induction
ℕ-ind : ∀ {A : ℕ → Set} →
∀ (a : A 0) → (∀ (n : ℕ) → A n → A (succ n)) → ∀ (m : ℕ) → A m
ℕ-ind {A} a p = ℕ-indhelper
where ℕ-indhelper : ∀ (m : ℕ) → A m
ℕ-indhelper 0 = a
ℕ-indhelper (succ n) = p n (ℕ-indhelper n)
-- From this exercise, we can actually see that the idea of induction is
-- builtin in agda, since we essentially use the induction builtin in agda
-- to prove ℕ-ind.
-- ℕ recursion, which is a special case for ℕ induction, where the type is not
-- dependent on ℕ
ℕ-rec : ∀ {A : Set} →
∀ (a : A) → (∀ (n : ℕ) → A → A) → ∀ (m : ℕ) → A
ℕ-rec {A} = ℕ-ind {λ { n → A }}
-- for example, we can use ℕ-rec to define addition
add : ℕ → ℕ → ℕ
add = ℕ-rec {ℕ → ℕ} (id {ℕ}) (λ (n : ℕ) (p : ℕ → ℕ) → comp succ p)
-- ------------------------------------
-- the sum type
record Σ (A : Set) (B : A → Set) : Set where
constructor
_,_
field
a : A
b : B a
-- the two projections
π₁ : ∀ {A : Set} {B : A → Set} → Σ A B → A
π₁ (x , y) = x
π₂ : ∀ {A : Set} {B : A → Set} → ∀ (z : Σ A B) → B (π₁ z)
π₂ (x , y) = y
syntax Σ A (λ a → b) = Σ a ∶ A , b
-- Σ induction
Σ-ind : ∀ {A : Set} {B : A → Set} {P : Σ A B → Set} →
(∀ (a : A) (b : B a) → P (a , b)) → ∀ (z : Σ A B) → P z
Σ-ind {A} {B} {P} = λ (f : ∀ (a : A) (b : B a) → P (a , b)) →
λ (z : Σ A B) → f (π₁ z) (π₂ z)
-- cartesion product type
_×_ : Set → Set → Set
A × B = Σ a ∶ A , B
×-ind : ∀ {A : Set} {B : Set} {P : A × B → Set} →
(∀ (a : A) (b : B) → P (a , b)) → ∀ (z : A × B) → P z
×-ind {A} {B} {P} = Σ-ind {A} {λ (a : A) → B} {P}
-- ------------------------------------
-- the coproduct type
data _⊎_ (A : Set) (B : Set) : Set where
inl : A → A ⊎ B
inr : B → A ⊎ B
⊎-ind : ∀ {A : Set} {B : Set} {P : A ⊎ B → Set} →
(∀ (a : A) → P (inl a)) → (∀ (b : B) → P (inr b)) →
∀ (u : A ⊎ B) → P u
⊎-ind f _ (inl x) = f x
⊎-ind _ g (inr y) = g y
| {
"alphanum_fraction": 0.4439523941,
"avg_line_length": 27.1654135338,
"ext": "agda",
"hexsha": "3915693ceb51f001de8ce12b4ac883debedc76a5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andyfreeyy/agda_and_math",
"max_forks_repo_path": "HoTT/Basic_Types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "andyfreeyy/agda_and_math",
"max_issues_repo_path": "HoTT/Basic_Types.agda",
"max_line_length": 78,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andyfreeyy/agda_and_math",
"max_stars_repo_path": "HoTT/Basic_Types.agda",
"max_stars_repo_stars_event_max_datetime": "2020-05-24T10:56:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-03-23T09:01:42.000Z",
"num_tokens": 1474,
"size": 3613
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of products
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Product.Properties where
open import Data.Product
open import Function using (_∘_)
open import Relation.Binary using (Decidable)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary.Product
import Relation.Nullary.Decidable as Dec
------------------------------------------------------------------------
-- Equality (dependent)
module _ {a b} {A : Set a} {B : A → Set b} where
,-injectiveˡ : ∀ {a c} {b : B a} {d : B c} → (a , b) ≡ (c , d) → a ≡ c
,-injectiveˡ refl = refl
-- See also Data.Product.Properties.WithK.,-injectiveʳ.
------------------------------------------------------------------------
-- Equality (non-dependent)
module _ {a b} {A : Set a} {B : Set b} where
,-injectiveʳ : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → b ≡ d
,-injectiveʳ refl = refl
,-injective : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → a ≡ c × b ≡ d
,-injective refl = refl , refl
≡-dec : Decidable {A = A} _≡_ → Decidable {A = B} _≡_ →
Decidable {A = A × B} _≡_
≡-dec dec₁ dec₂ (a , b) (c , d) =
Dec.map′ (uncurry (cong₂ _,_)) ,-injective (dec₁ a c ×-dec dec₂ b d)
| {
"alphanum_fraction": 0.4701601164,
"avg_line_length": 31.9534883721,
"ext": "agda",
"hexsha": "34e345c3fa464373d0e926d91f1d956d031e314b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Product/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Product/Properties.agda",
"max_line_length": 73,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Product/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 400,
"size": 1374
} |
module Options-in-right-order where
data Unit : Set where
unit : Unit
postulate
IO : Set → Set
{-# COMPILE GHC IO = type IO #-}
{-# BUILTIN IO IO #-}
postulate
return : {A : Set} → A → IO A
{-# COMPILE GHC return = \_ -> return #-}
main = return unit
| {
"alphanum_fraction": 0.608365019,
"avg_line_length": 14.6111111111,
"ext": "agda",
"hexsha": "17b9f004b29efa5cd3145b461e86b9fc6ab95ba7",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Options-in-right-order.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Options-in-right-order.agda",
"max_line_length": 41,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Options-in-right-order.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 76,
"size": 263
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Object.Subobject {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Data.Product
open import Data.Unit
open import Relation.Binary using (Poset)
open import Categories.Functor
open import Categories.Category.Slice
open import Categories.Category.SubCategory
open import Categories.Category.Construction.Thin
import Categories.Morphism as Mor
import Categories.Morphism.Reasoning as MR
open import Categories.Morphism.Notation
private
module 𝒞 = Category 𝒞
-- The Full Subcategory of the over category 𝒞/c on monomorphisms
slice-mono : 𝒞.Obj → Category _ _ _
slice-mono c = FullSubCategory (Slice 𝒞 c) {I = Σ[ α ∈ 𝒞.Obj ](α ↣ c)} λ (_ , i) → sliceobj (mor i)
where open Mor 𝒞
open _↣_
-- Poset of subobjects for some c ∈ 𝒞
Subobjects : 𝒞.Obj → Poset _ _ _
Subobjects c = record
{ Carrier = 𝒞ᶜ.Obj
; _≈_ = 𝒞ᶜ [_≅_]
; _≤_ = 𝒞ᶜ [_,_]
; isPartialOrder = record
{ isPreorder = record
{ isEquivalence = Mor.≅-isEquivalence 𝒞ᶜ
; reflexive = λ iso → Mor._≅_.from iso
; trans = λ {(α , f) (β , g) (γ , h)} i j → slicearr (chase f g h i j)
}
; antisym = λ {(α , f) (β , g)} h i → record
{ from = h
; to = i
; iso = record
{ isoˡ = mono f _ _ (chase f g f h i ○ ⟺ 𝒞.identityʳ)
; isoʳ = mono g _ _ (chase g f g i h ○ ⟺ 𝒞.identityʳ)
}
}
}
}
where
𝒞ᶜ : Category _ _ _
𝒞ᶜ = slice-mono c
module 𝒞ᶜ = Category 𝒞ᶜ
open Mor 𝒞 using (_↣_)
open MR 𝒞
open 𝒞.HomReasoning
open _↣_
chase : ∀ {α β γ : 𝒞.Obj} (f : 𝒞 [ α ↣ c ]) (g : 𝒞 [ β ↣ c ]) (h : 𝒞 [ γ ↣ c ])
→ (i : 𝒞ᶜ [ (α , f) , (β , g) ]) → (j : 𝒞ᶜ [ (β , g) , (γ , h) ])
→ 𝒞 [ 𝒞 [ mor h ∘ 𝒞 [ Slice⇒.h j ∘ Slice⇒.h i ] ] ≈ mor f ]
chase f g h i j = begin
𝒞 [ mor h ∘ 𝒞 [ Slice⇒.h j ∘ Slice⇒.h i ] ] ≈⟨ pullˡ (Slice⇒.△ j) ⟩
𝒞 [ mor g ∘ Slice⇒.h i ] ≈⟨ Slice⇒.△ i ⟩
mor f ∎
| {
"alphanum_fraction": 0.5648514851,
"avg_line_length": 28.8571428571,
"ext": "agda",
"hexsha": "8c78188e17e049330fce5ddcdc1d96913ef253df",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Object/Subobject.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Object/Subobject.agda",
"max_line_length": 99,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Object/Subobject.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 812,
"size": 2020
} |
{-# OPTIONS --cubical --save-metas #-}
-- The code in this module should not be compiled. However, the
-- following re-exported code should be compiled.
open import Agda.Builtin.Bool public
postulate
easy : {A : Set} → A
data Not-compiled : Set where
| {
"alphanum_fraction": 0.7081712062,
"avg_line_length": 21.4166666667,
"ext": "agda",
"hexsha": "3cdb19a1717fe253fb454dd0fbb492717f602c34",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "Seanpm2001-Agda-lang/agda",
"max_forks_repo_path": "test/Compiler/simple/Erased-cubical-Cubical.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "Seanpm2001-Agda-lang/agda",
"max_issues_repo_path": "test/Compiler/simple/Erased-cubical-Cubical.agda",
"max_line_length": 63,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "6b13364d36eeb60d8ec15eaf8effe23c73401900",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "sseefried/agda",
"max_stars_repo_path": "test/Compiler/simple/Erased-cubical-Cubical.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z",
"num_tokens": 67,
"size": 257
} |
module Bee2.Crypto.Defs where
open import Data.ByteString
open import Data.ByteVec
open import Agda.Builtin.Nat renaming (Nat to ℕ)
{-# FOREIGN GHC import qualified Bee2.Defs #-}
postulate
SizeT : Set
SizeFromℕ : ℕ → SizeT
{-# COMPILE GHC SizeT = type (Bee2.Defs.Size) #-}
{-# COMPILE GHC SizeFromℕ =
( Prelude.fromIntegral ) #-}
Hash = ByteVec {Strict} 32
data SecurityLevel : Set where
l128 l192 l256 : SecurityLevel
| {
"alphanum_fraction": 0.7133027523,
"avg_line_length": 22.9473684211,
"ext": "agda",
"hexsha": "b986ce08d76cd1049d8d4853a5bf4e7849f5de2a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/bee2-agda",
"max_forks_repo_path": "src/Bee2/Crypto/Defs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "semenov-vladyslav/bee2-agda",
"max_issues_repo_path": "src/Bee2/Crypto/Defs.agda",
"max_line_length": 49,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/bee2-agda",
"max_stars_repo_path": "src/Bee2/Crypto/Defs.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 126,
"size": 436
} |
module std-reduction.Properties where
open import std-reduction
open import sn-calculus
open import Relation.Binary.PropositionalEquality using (_≡_)
open _≡_
{-
std-redution-deterministic : ∀{p q r} →
p ⇁ q →
p ⇁ r →
q ≡ r
std-redution-deterministic = ?
std=>calc : ∀{p q} → p ⇁ q → p sn⟶₁ q
std=>calc = ?
-}
| {
"alphanum_fraction": 0.5311720698,
"avg_line_length": 21.1052631579,
"ext": "agda",
"hexsha": "8f1517550b5fcdbe9291f608f3cab632c8ae6211",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/std-reduction/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "florence/esterel-calculus",
"max_issues_repo_path": "agda/std-reduction/Properties.agda",
"max_line_length": 61,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/std-reduction/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 111,
"size": 401
} |
open import Agda.Builtin.Size
record R (A : Size → Set) (i : Size) : Set where
field
force : (j : Size< i) → A j
data D (A : Size → Set) (i : Size) : Set where
c : R A i → D A i
postulate
P : (A : Size → Set) → D A ∞ → D A ∞ → Set
F : (Size → Set) → Set
F A = (x : A ∞) (y : D A ∞) →
P _ (c (record { force = λ j → x })) y
-- WAS:
-- x != ∞ of type Size
-- when checking that the expression y has type D (λ _ → A ∞) ∞
-- SHOULD BE:
-- x₁ != ∞ of type Size
-- when checking that the expression y has type D (λ _ → A ∞) ∞
| {
"alphanum_fraction": 0.5184501845,
"avg_line_length": 22.5833333333,
"ext": "agda",
"hexsha": "1b6ff6c9cac36a58d83a7496f01bd0e9f17c4deb",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-06-14T11:07:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-14T11:07:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue2522.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue2522.agda",
"max_line_length": 63,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2522.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z",
"num_tokens": 213,
"size": 542
} |
module Screen where
import Data.Nat
import Data.Bool
import Data.List
import Logic.Base
open Data.Bool
open Data.List
open Data.Nat
open Logic.Base
-- Ranges -----------------------------------------------------------------
data Range : Set where
range : Nat -> Nat -> Range
inRange : Range -> Nat -> Bool
inRange (range lo hi) x = lo ≤ x && x ≤ hi
low : Range -> Nat
low (range lo _) = lo
high : Range -> Nat
high (range _ hi) = hi
size : Range -> Nat
size (range lo hi) = suc hi - lo
enumerate : Range -> List Nat
enumerate (range lo hi) = enum lo hi
where
list : Nat -> Nat -> List Nat
list _ 0 = []
list k (suc n) = k :: list (suc k) n
enum : Nat -> Nat -> List Nat
enum lo hi = map (_+_ lo) (list 0 (suc hi - lo))
-- The screen example -----------------------------------------------------
xRange : Range
xRange = range 0 79
yRange : Range
yRange = range 0 24
screenRange : Range
screenRange = range 0xb8000 0xb87ff
-- Converting (x,y) to addr
plot : Nat -> Nat -> Nat
plot x y = low screenRange + x + size xRange * y
-- The property
forAll : Range -> (Nat -> Bool) -> Bool
forAll r p = foldr (\n b -> p n && b) true (enumerate r)
prop : Bool
prop = forAll xRange \x ->
forAll yRange \y ->
inRange screenRange (plot x y)
proof : IsTrue prop
proof = tt
| {
"alphanum_fraction": 0.5638699924,
"avg_line_length": 18.9,
"ext": "agda",
"hexsha": "98058b84023e9d51c1c8ed205ddb37d652eeaaff",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/Screen.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/Screen.agda",
"max_line_length": 75,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/Screen.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 388,
"size": 1323
} |
{-# OPTIONS --without-K #-}
-- Approx. 15-20 min are required to typecheck this file (for Agda 2.6.1) on
-- my MacBook 13-inch 2017 with 3.5 GHz Core i7 CPU and 16 GB memory.
--
-- Since most of the time was spent for termination analysis, please
-- uncomment {-# TERMINATING #-} before evalR and eval to remove the
-- termination checks.
module Definitional where
open import Syntax
open import Data.Nat
open import Data.Fin using (Fin ; suc; zero)
open import Data.List using (length ; [] ; _∷_ )
open import Data.List.Properties using (length-++)
open import Data.Vec using ([] ; _∷_)
open import Data.Vec.Relation.Unary.All using (All ; [] ; _∷_)
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Level renaming (zero to lzero ; suc to lsuc)
open ≡-Reasoning
open import Function using () renaming (case_of_ to CASE_OF_)
open import Value
open import Size
open import Codata.Thunk
module Interpreter where
open import Codata.Delay renaming (length to dlength ; map to dmap )
open import PInj
open _⊢_⇔_
-- A variant of the Delay monad in which the bind operator is
-- frozen. While we cannot restrict levels in general, using Set is
-- enough for enough for our purpose.
data DELAY : (A : Set) -> (i : Size) -> Set₁ where
Now : ∀ {A i} -> A -> DELAY A i
Later : ∀ {A i} -> Thunk (DELAY A) i -> DELAY A i
Bind : ∀ {A B i}
-> (m : DELAY A i) -> (f : A -> DELAY B i) -> DELAY B i
Never : ∀ {A i} -> DELAY A i
Never = Later λ where .force -> Never
Dmap : ∀ {A B i} -> (A -> B) -> DELAY A i -> DELAY B i
Dmap f d = Bind d (λ x -> Now (f x))
-- The function runD thaws the frozen operations.
runD : ∀ {A : Set} {i : Size} -> DELAY A i -> Delay A i
runD (Now x) = now x
runD (Later x) = later λ where .force -> runD (force x)
runD (Bind d f) = bind (runD d) (λ x -> runD (f x))
-- The frozen version of _⊢_⇔_
record _⊢F_⇔_ (i : Size) (A B : Set) : Set₁ where
field
Forward : A -> DELAY B i
Backward : B -> DELAY A i
open _⊢F_⇔_
forwardF : ∀ {A B i} -> i ⊢F A ⇔ B -> A -> Delay B i
forwardF h a = runD (Forward h a)
backwardF : ∀ {A B i} -> i ⊢F A ⇔ B -> B -> Delay A i
backwardF h b = runD (Backward h b)
-- Similarly to runD, runD⇔ thawas the frozen operations in
-- _⊢F_⇔_.
runD⇔ : ∀ {A B i} -> i ⊢F A ⇔ B -> i ⊢ A ⇔ B
forward (runD⇔ f) = forwardF f
backward (runD⇔ f) = backwardF f
-- Environments handled by the forward and backward evaluations,
-- which correponds to μ in the paper.
data RValEnv : (Θ : TyEnv) (Ξ : MultEnv (length Θ)) -> Set where
[] : RValEnv [] []
skip : ∀ {Θ Ξ A} -> RValEnv Θ Ξ -> RValEnv (A ∷ Θ) (zero ∷ Ξ)
_∷_ : ∀ {Θ Ξ A} -> Value [] ∅ A -> RValEnv Θ Ξ -> RValEnv (A ∷ Θ) (one ∷ Ξ)
emptyRValEnv : ∀ {Θ} -> RValEnv Θ ∅
emptyRValEnv {[]} = []
emptyRValEnv {_ ∷ _} = skip emptyRValEnv
splitRValEnv : ∀ {Θ Ξ₁ Ξ₂} -> RValEnv Θ (Ξ₁ +ₘ Ξ₂) -> RValEnv Θ Ξ₁ × RValEnv Θ Ξ₂
splitRValEnv {[]} {[]} {[]} [] = [] , []
splitRValEnv {_ ∷ Θ} {zero ∷ Ξ₁} {zero ∷ Ξ₂} (skip ρ)
with splitRValEnv ρ
... | ρ₁ , ρ₂ = skip ρ₁ , skip ρ₂
splitRValEnv {_ ∷ Θ} {zero ∷ Ξ₁} {one ∷ Ξ₂} (x ∷ ρ)
with splitRValEnv ρ
... | ρ₁ , ρ₂ = skip ρ₁ , x ∷ ρ₂
splitRValEnv {_ ∷ Θ} {one ∷ Ξ₁} {zero ∷ Ξ₂} (x ∷ ρ)
with splitRValEnv ρ
... | ρ₁ , ρ₂ = x ∷ ρ₁ , skip ρ₂
-- An inverse of splitRValEnv.
mergeRValEnv : ∀ {Θ Ξ₁ Ξ₂} -> all-no-omega (Ξ₁ +ₘ Ξ₂) -> RValEnv Θ Ξ₁ -> RValEnv Θ Ξ₂ -> RValEnv Θ (Ξ₁ +ₘ Ξ₂)
mergeRValEnv {.[]} {.[]} {.[]} _ [] [] = []
mergeRValEnv {.(_ ∷ _)} {.(zero ∷ _)} {.(zero ∷ _)} (_ ∷ ano) (skip ρ₁) (skip ρ₂) = skip (mergeRValEnv ano ρ₁ ρ₂)
mergeRValEnv {.(_ ∷ _)} {.(zero ∷ _)} {.(one ∷ _)} (_ ∷ ano) (skip ρ₁) (x ∷ ρ₂) = x ∷ (mergeRValEnv ano ρ₁ ρ₂)
mergeRValEnv {.(_ ∷ _)} {.(one ∷ _)} {.(zero ∷ _)} (_ ∷ ano) (x ∷ ρ₁) (skip ρ₂) = x ∷ mergeRValEnv ano ρ₁ ρ₂
mergeRValEnv {.(_ ∷ _)} {.(one ∷ _)} {.(one ∷ _)} (() ∷ ano) (x ∷ ρ₁) (x₁ ∷ ρ₂)
-- Construction of the empty value environment.
from-all-zero : ∀ {Θ Ξ} -> all-zero Ξ -> RValEnv Θ Ξ
from-all-zero {[]} {[]} [] = []
from-all-zero {_ ∷ Θ} {.(zero ∷ _)} (refl ∷ az) = skip (from-all-zero az)
-- Value environments conforms to an empty invertible environment must be empty.
all-zero-canon : ∀ {Θ Ξ} -> (az : all-zero Ξ) -> (θ : RValEnv Θ Ξ) -> θ ≡ (from-all-zero az)
all-zero-canon {[]} {[]} [] [] = refl
all-zero-canon {_ ∷ Θ} {_ ∷ Ξ} (refl ∷ az) (skip θ) = cong skip (all-zero-canon az θ)
-- Looking-up function for RValEnv
lkup : ∀ {Θ A} {x : Θ ∋ A} {Ξ} -> varOk● Θ x Ξ -> RValEnv Θ Ξ -> Value [] ∅ A
lkup (there ok) (skip ρ) = lkup ok ρ
lkup (here ad) (x ∷ ρ) = x -- ad asserts ρ consists only of skip and []
-- An inverse of lkup; the linearity matters here.
unlkup : ∀ {Θ A} {x : Θ ∋ A} {Ξ} -> varOk● Θ x Ξ -> Value [] ∅ A -> RValEnv Θ Ξ
unlkup (there ok) v = skip (unlkup ok v)
unlkup (here ad) v = v ∷ from-all-zero ad
-- Some utility functions.
var●₀ : ∀ {A Θ} -> Residual (A ∷ Θ) (one ∷ ∅) (A ●)
var●₀ = var● vz (here all-zero-∅)
BindR : ∀ {i Θ Ξ A} {r : Set} -> DELAY (Value Θ Ξ (A ●)) i -> (Residual Θ Ξ (A ●) -> DELAY r i) -> DELAY r i
BindR x f = Bind x λ { (red r) -> f r }
-- For the do trick for the pattern matching
-- See https://github.com/agda/agda/issues/2298
_>>=_ : ∀ {a b : Level} {A : Set a} {B : A -> Set b} -> ∀ (x : A) -> (∀ x -> B x) -> B x
x >>= f = f x
-- Function application.
apply :
∀ {Θ Ξ₁ Ξ₂ A m B} i ->
all-no-omega (Ξ₁ +ₘ m ×ₘ Ξ₂) ->
Value Θ Ξ₁ (A # m ~> B) -> Value Θ Ξ₂ A -> DELAY (Value Θ (Ξ₁ +ₘ m ×ₘ Ξ₂) B) i
-- Forward, backward and unidirectional evalautions are given as
-- mutually recursive functions. Notice that, the existence of these
-- functions essentially proves the type safety (i.e., the
-- preservation and progree prperty). Thus, in a sense, they are
-- generalizations of Lemma 3.1 and Lemma 3.2 in the paper.
-- Forward and backward evaluation.
-- {-# TERMINATING #-}
evalR :
∀ {Θ Ξ A} i ->
all-no-omega Ξ -> Residual Θ Ξ (A ●) -> i ⊢F (RValEnv Θ Ξ) ⇔ Value [] ∅ A
-- Unidirectional evaluation. Also, an important thing is that this function keeps
-- the invariant all-no-omega (Ξₑ +ₘ Ξ) for recursive calls, which essentially supports
-- the claim in Section 3.4: "This assumption is actually an invariant in our system ...".
-- {-# TERMINATING #-}
eval :
∀ {Θ Ξₑ Γ Δ Ξ A} i ->
all-no-omega (Ξₑ +ₘ Ξ) -> ValEnv Γ Δ Θ Ξₑ -> Term Γ Δ Θ Ξ A -> DELAY (Value Θ (Ξₑ +ₘ Ξ) A) i
apply {Θ} {Ξ₁} {Ξ₂} i ano (clo {Ξ' = Ξ'} {Ξₜ = Ξₜ} m refl θ t) v with all-no-omega-dist _ _ ano
... | ano-'t , ano-m2 = Later λ { .force {j} ->
let T = eval j (subst all-no-omega lemma ano) (tup _ _ refl (value-to-multM ano-m2 v) θ) t
in subst (λ x -> DELAY (Value Θ x _) j) (sym lemma) T
}
where
lemma : Ξ' +ₘ Ξₜ +ₘ m ×ₘ Ξ₂ ≡ m ×ₘ Ξ₂ +ₘ Ξ' +ₘ Ξₜ
lemma = trans (+ₘ-comm _ _)
(sym (+ₘ-assoc (m ×ₘ Ξ₂) Ξ' _))
-- evalR is defined so that evalR ∞ ano r actually defines a
-- bijection. See Invertiblity.agda for its proof.
Forward (evalR i ano unit●) _ = Now (unit refl)
Backward (evalR i ano unit●) _ = Now emptyRValEnv
Forward (evalR i ano (letunit● r₁ r₂)) ρ = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
ρ₁ , ρ₂ <- splitRValEnv ρ
Bind (Forward (evalR i ano₁ r₁) ρ₁) λ { (unit eq) -> Forward (evalR i ano₂ r₂) ρ₂ }
Backward (evalR i ano (letunit● r₁ r₂)) v = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
Bind (Backward (evalR i ano₂ r₂) v) λ ρ₂ ->
Bind (Backward (evalR i ano₁ r₁) (unit refl)) λ ρ₁ ->
Now (mergeRValEnv ano ρ₁ ρ₂)
Forward (evalR i ano (pair● r₁ r₂)) ρ = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
ρ₁ , ρ₂ <- splitRValEnv ρ
Bind (Forward (evalR i ano₁ r₁) ρ₁) λ v₁ ->
Bind (Forward (evalR i ano₂ r₂) ρ₂) λ v₂ ->
Now (pair refl v₁ v₂)
Backward (evalR i ano (pair● {A = A} {B} r₁ r₂)) (pair {Ξ₁ = []} {[]} spΞ v₁ v₂) = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
Bind (Backward (evalR i ano₁ r₁) v₁) λ ρ₁ ->
Bind (Backward (evalR i ano₂ r₂) v₂) λ ρ₂ ->
Now (mergeRValEnv ano ρ₁ ρ₂)
Forward (evalR i ano (letpair● r₁ r₂)) ρ = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
ρ₁ , ρ₂ <- splitRValEnv ρ
Bind (Forward (evalR i ano₁ r₁) ρ₁) λ {
(pair {Ξ₁ = []} {[]} spΞ v₁ v₂ ) ->
Forward (evalR i (one ∷ one ∷ ano₂) r₂) (v₁ ∷ v₂ ∷ ρ₂)
}
Backward (evalR i ano (letpair● r₁ r₂)) v = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
Bind (Backward (evalR i (one ∷ one ∷ ano₂) r₂) v) λ { (v₁ ∷ v₂ ∷ ρ₂) ->
Bind (Backward (evalR i ano₁ r₁) (pair refl v₁ v₂)) λ ρ₁ ->
Now (mergeRValEnv ano ρ₁ ρ₂)
}
Forward (evalR i ano (inl● r)) ρ = Bind (Forward (evalR i ano r) ρ) λ x -> Now (inl x)
Backward (evalR i ano (inl● r)) v =
CASE v OF λ {
(inl v₁) -> Backward (evalR i ano r) v₁ ;
(inr v₂) -> Never
}
Forward (evalR i ano (inr● r)) ρ = Bind (Forward (evalR i ano r) ρ) λ x -> Now (inr x)
Backward (evalR i ano (inr● r)) v =
CASE v OF λ {
(inl v₁) -> Never ;
(inr v₂) -> Backward (evalR i ano r) v₂
}
Forward (evalR i ano (case● {Γ₁ = Γ₁} {Γ₂} r refl θ₁ t₁ θ₂ t₂ f)) ρ = do
ano₀ , ano- <- all-no-omega-dist _ _ ano
ρ₀ , ρ- <- splitRValEnv ρ
Bind (Forward (evalR i ano₀ r) ρ₀) λ {
(inl v₁) ->
Bind (eval i (one ∷ ano-) (weakenΘ-valEnv Γ₁ (compat-ext-here ext-id) θ₁) t₁) λ { (red r₁) ->
Later λ { .force {j} ->
Bind (Forward (evalR j (one ∷ ano-) r₁) (v₁ ∷ ρ-)) λ v ->
Bind (apply j [] f v) λ {
(inl _) -> Now v ;
(inr _) -> Never
}
}
}
;
(inr v₂) ->
Bind (eval i (one ∷ ano-) (weakenΘ-valEnv Γ₂ (compat-ext-here ext-id) θ₂) t₂) λ { (red r₂) ->
Later λ { .force {j} ->
Bind (Forward (evalR j (one ∷ ano-) r₂) (v₂ ∷ ρ-)) λ v ->
Bind (apply j [] f v) λ {
(inl _) -> Never ;
(inr _) -> Now v
}
}
}
}
Backward (evalR i ano (case● {Γ₁ = Γ₁} {Γ₂} r refl θ₁ t₁ θ₂ t₂ f)) v = do
ano₀ , ano- <- all-no-omega-dist _ _ ano
Bind (apply i [] f v) λ {
(inl _) ->
Bind (eval i (one ∷ ano-) (weakenΘ-valEnv Γ₁ (compat-ext-here ext-id) θ₁) t₁) λ { (red r₁) ->
Later λ { .force {j} ->
Bind (Backward (evalR j (one ∷ ano-) r₁) v) λ { (v₁ ∷ ρ-) ->
Bind (Backward (evalR j ano₀ r) (inl v₁)) λ ρ₀ ->
Now (mergeRValEnv ano ρ₀ ρ-)
}
}
}
;
(inr _) ->
Bind (eval i (one ∷ ano-) (weakenΘ-valEnv Γ₂ (compat-ext-here ext-id) θ₂) t₂) λ { (red r₂) ->
Later λ where .force {j} ->
Bind (Backward (evalR j (one ∷ ano-) r₂) v) λ { (v₂ ∷ ρ-) ->
Bind (Backward (evalR j ano₀ r) (inr v₂)) λ ρ₀ ->
Now (mergeRValEnv ano ρ₀ ρ-)
}
}
}
Forward (evalR i ano (var● x ok)) ρ = Now (lkup ok ρ)
Backward (evalR i ano (var● x ok)) v = Now (unlkup ok v)
Forward (evalR i ano (pin r f)) ρ = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
ρ₁ , ρ₂ <- splitRValEnv ρ
Bind (Forward (evalR i ano₁ r) ρ₁) λ v₁ ->
CASE f OF λ { (clo .omega refl θ t) →
Later λ { .force {j} ->
Bind (eval j ano₂ (tup ∅ _ (∅-lid _) (mult-omega (weakenΘ-value extendΘ v₁) refl) θ) t) λ {
(red r₂) ->
-- maybe another delaying would be needed here
Bind (Forward (evalR j ano₂ r₂) ρ₂) λ v₂ ->
Now (pair refl v₁ v₂)
}
}
}
Backward (evalR i ano (pin r (clo .omega refl θ t))) (pair {Ξ₁ = []} {[]} refl v₁ v₂) = do
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
Later λ { .force {j} ->
BindR (eval j ano₂ (tup ∅ _ (∅-lid _) (mult-omega (weakenΘ-value extendΘ v₁) refl) θ) t) λ r₂ ->
Bind (Backward (evalR j ano₂ r₂) v₂) λ ρ₂ ->
Bind (Backward (evalR j ano₁ r) v₁) λ ρ₁ ->
Now (mergeRValEnv ano ρ₁ ρ₂)
}
-- The unidirectional evaluation, of which definition would be
-- routine except for rather tedious manipulation of value
-- environments.
eval {Θ} _ ano θ (var x ok) = Now (subst (λ x -> Value Θ x _) (sym (∅-rid _)) (lookupVar θ ok))
eval _ ano θ (abs m t) = Now (clo m refl θ t)
eval {Θ} {Γ = Γ} i ano θ (app {Δ₁ = Δ₁} {Δ₂} {Ξ₁ = Ξ₁} {Ξ₂} {m = m} t₁ t₂)
with separateEnv {Γ} Δ₁ (m ×ₘ Δ₂) θ
... | tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂ with eval i (proj₁ lemma) θ₁ t₁ | proj₂ lemma | un×ₘ-valEnv Γ θ₂
where
lemma' : Ξₑ₁ +ₘ Ξₑ₂ +ₘ (Ξ₁ +ₘ m ×ₘ Ξ₂) ≡ (Ξₑ₁ +ₘ Ξ₁) +ₘ (Ξₑ₂ +ₘ m ×ₘ Ξ₂)
lemma' = +ₘ-transpose Ξₑ₁ Ξₑ₂ Ξ₁ (m ×ₘ Ξ₂)
lemma : all-no-omega (Ξₑ₁ +ₘ Ξ₁) × all-no-omega (Ξₑ₂ +ₘ m ×ₘ Ξ₂)
lemma = all-no-omega-dist (Ξₑ₁ +ₘ Ξ₁) _ (subst all-no-omega lemma' ano)
... | T₁ | ano-e2m2 | Ξₑ₂' , θ₂' , refl with (subst all-no-omega (sym (×ₘ-dist m Ξₑ₂' _)) ano-e2m2)
... | ano-m[e2'2] with eval i (all-no-omega-dist-×ₘ m (Ξₑ₂' +ₘ Ξ₂) ano-m[e2'2]) θ₂' t₂
... | T₂ =
Bind T₁ (λ { (clo {Ξ' = Ξ'} {Ξₜ = Ξₜ} m spΞ θf t) → Bind T₂ λ v₂ ->
Later λ { .force ->
let lemma : m ×ₘ (Ξₑ₂' +ₘ Ξ₂) +ₘ Ξ' +ₘ Ξₜ ≡ Ξₑ₁ +ₘ m ×ₘ Ξₑ₂' +ₘ (Ξ₁ +ₘ m ×ₘ Ξ₂)
lemma =
begin
m ×ₘ (Ξₑ₂' +ₘ Ξ₂) +ₘ Ξ' +ₘ Ξₜ
≡⟨ +ₘ-assoc (m ×ₘ (Ξₑ₂' +ₘ Ξ₂)) Ξ' _ ⟩
m ×ₘ (Ξₑ₂' +ₘ Ξ₂) +ₘ (Ξ' +ₘ Ξₜ)
≡⟨ cong (_ +ₘ_) spΞ ⟩
m ×ₘ (Ξₑ₂' +ₘ Ξ₂) +ₘ (Ξₑ₁ +ₘ Ξ₁)
≡⟨ cong (_+ₘ _) (×ₘ-dist m Ξₑ₂' Ξ₂) ⟩
m ×ₘ Ξₑ₂' +ₘ m ×ₘ Ξ₂ +ₘ (Ξₑ₁ +ₘ Ξ₁)
≡⟨ +ₘ-transpose (m ×ₘ Ξₑ₂') (m ×ₘ Ξ₂) Ξₑ₁ _ ⟩
m ×ₘ Ξₑ₂' +ₘ Ξₑ₁ +ₘ (m ×ₘ Ξ₂ +ₘ Ξ₁)
≡⟨ cong₂ (_+ₘ_) (+ₘ-comm _ _) (+ₘ-comm _ _) ⟩
Ξₑ₁ +ₘ m ×ₘ Ξₑ₂' +ₘ (Ξ₁ +ₘ m ×ₘ Ξ₂)
∎
lemma-ano : all-no-omega (m ×ₘ (Ξₑ₂' +ₘ Ξ₂) +ₘ Ξ' +ₘ Ξₜ)
lemma-ano = subst all-no-omega (sym lemma) ano
in (Bind (eval _ lemma-ano (tup (m ×ₘ (Ξₑ₂' +ₘ Ξ₂)) Ξ' refl (value-to-multM ano-m[e2'2] v₂) θf) t) λ v -> Now (subst (λ Ξ -> Value Θ Ξ _) lemma v)
)}
})
eval {Γ = Γ} _ ano θ (unit ad) with discardable-has-no-resources {Γ} θ ad
... | refl = Now (substV (sym (∅-lid _)) (unit refl))
eval {Θ} {Ξₑ} {Γ} i ano θ (letunit {Δ₀ = Δ₀} {Δ} {Ξ₀ = Ξ₀} {Ξ} m t₀ t)
with separateEnv {Γ} (m ×ₘ Δ₀) Δ θ
... | tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂
with un×ₘ-valEnv Γ θ₁
... | Ξₑ₁' , θ₁' , refl
with subst all-no-omega (+ₘ-transpose (m ×ₘ Ξₑ₁') Ξₑ₂ (m ×ₘ Ξ₀) _) ano
... | ano'
with all-no-omega-dist (m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀) _ ano'
... | ano-me1'm0 , ano-e2
with eval i (all-no-omega-dist-×ₘ m (Ξₑ₁' +ₘ Ξ₀) (subst all-no-omega (sym (×ₘ-dist m Ξₑ₁' Ξ₀)) ano-me1'm0)) θ₁' t₀
... | T₀ = Bind T₀ λ { (unit emp-e1'0) →
let lemma : Ξₑ₂ +ₘ Ξ ≡ (m ×ₘ Ξₑ₁' +ₘ Ξₑ₂) +ₘ ((m ×ₘ Ξ₀) +ₘ Ξ)
lemma =
begin
Ξₑ₂ +ₘ Ξ
≡⟨ sym (∅-lid _) ⟩
∅ +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ cong (_+ₘ (Ξₑ₂ +ₘ Ξ)) (sym (×ₘ∅ m)) ⟩
m ×ₘ ∅ +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ cong (λ h -> m ×ₘ h +ₘ (Ξₑ₂ +ₘ Ξ)) (emp-e1'0) ⟩
m ×ₘ (Ξₑ₁' +ₘ Ξ₀) +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ cong (_+ₘ _) (×ₘ-dist m Ξₑ₁' Ξ₀) ⟩
m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ +ₘ-transpose (m ×ₘ Ξₑ₁') (m ×ₘ Ξ₀) Ξₑ₂ Ξ ⟩
(m ×ₘ Ξₑ₁' +ₘ Ξₑ₂) +ₘ ((m ×ₘ Ξ₀) +ₘ Ξ)
∎
in Dmap (substV lemma) (eval i ano-e2 θ₂ t)
}
eval {Θ} {Ξₑ} {Γ} i ano θ (pair {Δ₁ = Δ₁} {Δ₂} {Ξ₁ = Ξ₁} {Ξ₂} t₁ t₂)
with separateEnv {Γ} Δ₁ Δ₂ θ
... | tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂
with subst all-no-omega (+ₘ-transpose Ξₑ₁ Ξₑ₂ Ξ₁ _) ano
... | ano'
with all-no-omega-dist (Ξₑ₁ +ₘ Ξ₁) _ ano'
... | ano-e11 , ano-e22
with eval i ano-e11 θ₁ t₁ | eval i ano-e22 θ₂ t₂
... | T₁ | T₂ = Bind T₁ λ v₁ ->
Bind T₂ λ v₂ -> Now (pair (+ₘ-transpose Ξₑ₁ Ξ₁ Ξₑ₂ _) v₁ v₂)
eval {Θ} {Ξₑ} {Γ} i ano θ (letpair {Δ₀ = Δ₀} {Δ} {Ξ₀ = Ξ₀} {Ξ} m t₀ t)
with separateEnv {Γ} (m ×ₘ Δ₀) Δ θ
... | tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂
with un×ₘ-valEnv Γ θ₁
... | Ξₑ₁' , θ₁' , refl
with subst all-no-omega (+ₘ-transpose (m ×ₘ Ξₑ₁') Ξₑ₂ (m ×ₘ Ξ₀) Ξ) ano
... | ano'
with all-no-omega-dist (m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀) _ ano'
... | ano-me1'm0 , ano-e2-
with subst all-no-omega (sym (×ₘ-dist m Ξₑ₁' _)) ano-me1'm0
... | ano-m[e1'0]
with all-no-omega-dist-×ₘ m _ ano-m[e1'0]
... | ano-e1'0
with eval i ano-e1'0 θ₁' t₀
... | T₀ = Bind T₀ λ { (pair {Ξ₁ = Ξ₁} {Ξ₂} spΞ v₁ v₂) →
let ano-m[12] : all-no-omega (m ×ₘ (Ξ₁ +ₘ Ξ₂))
ano-m[12] = subst all-no-omega (cong (m ×ₘ_) (sym spΞ)) ano-m[e1'0]
ano-m1m2 : all-no-omega (m ×ₘ Ξ₁ +ₘ m ×ₘ Ξ₂)
ano-m1m2 = subst all-no-omega (×ₘ-dist m Ξ₁ Ξ₂) ano-m[12]
an : all-no-omega (m ×ₘ Ξ₁) × all-no-omega (m ×ₘ Ξ₂)
an = all-no-omega-dist (m ×ₘ Ξ₁) _ ano-m1m2
eq : m ×ₘ Ξ₁ +ₘ (m ×ₘ Ξ₂ +ₘ Ξₑ₂) ≡ m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ Ξₑ₂
eq = begin
m ×ₘ Ξ₁ +ₘ (m ×ₘ Ξ₂ +ₘ Ξₑ₂)
≡⟨ sym (+ₘ-assoc (m ×ₘ Ξ₁) (m ×ₘ Ξ₂) _) ⟩
m ×ₘ Ξ₁ +ₘ m ×ₘ Ξ₂ +ₘ Ξₑ₂
≡⟨ cong (_+ₘ Ξₑ₂) (sym (×ₘ-dist m Ξ₁ Ξ₂)) ⟩
m ×ₘ (Ξ₁ +ₘ Ξ₂) +ₘ Ξₑ₂
≡⟨ cong (_+ₘ Ξₑ₂) (cong (m ×ₘ_) spΞ) ⟩
m ×ₘ (Ξₑ₁' +ₘ Ξ₀) +ₘ Ξₑ₂
≡⟨ cong (_+ₘ Ξₑ₂) (×ₘ-dist m _ _) ⟩
m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ Ξₑ₂
∎
θ' : ValEnv (_ ∷ _ ∷ Γ) (M→M₀ m ∷ M→M₀ m ∷ Δ) Θ (m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ Ξₑ₂)
θ' = tup (m ×ₘ Ξ₁) _ eq (value-to-multM (proj₁ an) v₁)
(tup (m ×ₘ Ξ₂) Ξₑ₂ refl (value-to-multM (proj₂ an) v₂) θ₂)
eq' : m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ Ξₑ₂ +ₘ Ξ ≡ (m ×ₘ Ξₑ₁' +ₘ Ξₑ₂) +ₘ (m ×ₘ Ξ₀ +ₘ Ξ)
eq' = begin
m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ Ξₑ₂ +ₘ Ξ
≡⟨ +ₘ-assoc (m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀) Ξₑ₂ _ ⟩
m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ +ₘ-transpose (m ×ₘ Ξₑ₁') (m ×ₘ Ξ₀) Ξₑ₂ _ ⟩
(m ×ₘ Ξₑ₁' +ₘ Ξₑ₂) +ₘ (m ×ₘ Ξ₀ +ₘ Ξ)
∎
-- solve 4 (λ a b c d ->
-- ((a ⊞ b) ⊞ c) ⊞ d ⊜
-- (a ⊞ c) ⊞ (b ⊞ d)) refl (m ×ₘ Ξₑ₁') (m ×ₘ Ξ₀) Ξₑ₂ Ξ
in Dmap (substV eq') (eval i (subst all-no-omega (sym eq') ano) θ' t)
}
eval {Θ} {Ξₑ} {Γ} i ano θ (many m t) = do
(Ξₑ' , θ' , refl) <- un×ₘ-valEnv Γ θ
ano-m[e'-] <- subst all-no-omega (sym (×ₘ-dist m Ξₑ' _)) ano
ano-e'- <- all-no-omega-dist-×ₘ m _ ano-m[e'-]
Bind (eval i ano-e'- θ' t) λ v ->
Now (many m (×ₘ-dist m Ξₑ' _) v)
eval {Θ} {Ξₑ} {Γ} i ano θ (unmany {Δ₀ = Δ₀} {Δ} {Ξ₀ = Ξ₀} {Ξ} {m₀ = m₀} {A} m t₀ t) = do
tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂ <- separateEnv {Γ} (m ×ₘ Δ₀) Δ θ
Ξₑ₁' , θ₁' , refl <- un×ₘ-valEnv Γ θ₁
ano' <- subst all-no-omega (+ₘ-transpose (m ×ₘ Ξₑ₁') Ξₑ₂ (m ×ₘ Ξ₀) Ξ) ano
ano-me1'm0 , ano-e2 <- all-no-omega-dist (m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀) _ ano'
ano-m[e1'0] <- subst all-no-omega (sym (×ₘ-dist m Ξₑ₁' _)) ano-me1'm0
ano-e1'0 <- all-no-omega-dist-×ₘ m _ ano-m[e1'0]
Bind (eval i ano-e1'0 θ₁' t₀ ) λ where
(many {Ξ₀ = Ξ''} .m₀ sp v₀) -> do
let ano-mm₀[e1'0] : all-no-omega (m ×ₘ m₀ ×ₘ Ξ'')
ano-mm₀[e1'0] = subst all-no-omega (cong (m ×ₘ_) (sym sp)) ano-m[e1'0]
ano-mul[e1'0] : all-no-omega (mul m m₀ ×ₘ Ξ'')
ano-mul[e1'0] = subst all-no-omega (sym (mul-×ₘ m m₀ Ξ'')) ano-mm₀[e1'0]
eq : m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ) ≡ mul m m₀ ×ₘ Ξ'' +ₘ Ξₑ₂ +ₘ Ξ
eq =
begin
m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ cong (_+ₘ _) (sym (×ₘ-dist m Ξₑ₁' _)) ⟩
m ×ₘ (Ξₑ₁' +ₘ Ξ₀) +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ cong (λ e -> m ×ₘ e +ₘ _) (sym sp) ⟩
m ×ₘ m₀ ×ₘ Ξ'' +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ cong (_+ₘ _) (sym (mul-×ₘ m m₀ Ξ'')) ⟩
mul m m₀ ×ₘ Ξ'' +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ sym (+ₘ-assoc _ _ _) ⟩
mul m m₀ ×ₘ Ξ'' +ₘ Ξₑ₂ +ₘ Ξ
∎
ano'' : all-no-omega (mul m m₀ ×ₘ Ξ'' +ₘ Ξₑ₂ +ₘ Ξ)
ano'' = subst all-no-omega eq ano'
θ' : ValEnv (A ∷ Γ) (M→M₀ (mul m m₀) ∷ Δ) Θ (mul m m₀ ×ₘ Ξ'' +ₘ Ξₑ₂)
θ' = tup _ Ξₑ₂ refl (value-to-multM ano-mul[e1'0] v₀) θ₂
Bind (eval i ano'' θ' t) λ v -> Now (substV (trans (sym eq) (sym (+ₘ-transpose (m ×ₘ Ξₑ₁') Ξₑ₂ (m ×ₘ Ξ₀) Ξ))) v)
eval i ano θ (inl t) = Dmap inl (eval i ano θ t)
eval i ano θ (inr t) = Dmap inr (eval i ano θ t)
eval {Θ} {Ξₑ = Ξₑ} {Γ} i ano θ (case {Δ₀ = Δ₀} {Δ} {Ξ₀ = Ξ₀} {Ξ} m t₀ t₁ t₂)
with separateEnv {Γ} (m ×ₘ Δ₀) Δ θ
... | tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂
with un×ₘ-valEnv Γ θ₁
... | Ξₑ₁' , θ₁' , refl
with subst all-no-omega (+ₘ-transpose (m ×ₘ Ξₑ₁') Ξₑ₂ (m ×ₘ Ξ₀) Ξ) ano
... | ano'
with all-no-omega-dist (m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀) _ ano'
... | ano-me1'm0 , ano-e2-
with subst all-no-omega (sym (×ₘ-dist m Ξₑ₁' _)) ano-me1'm0
... | ano-m[e1'0]
with all-no-omega-dist-×ₘ m _ ano-m[e1'0]
... | ano-e1'0
with eval i ano-e1'0 θ₁' t₀
... | T₀ = Bind T₀ λ {
(inl v) →
let θ' : ValEnv (_ ∷ Γ) (M→M₀ m ∷ Δ) Θ (m ×ₘ (Ξₑ₁' +ₘ Ξ₀) +ₘ Ξₑ₂)
θ' = tup (m ×ₘ (Ξₑ₁' +ₘ Ξ₀)) Ξₑ₂ refl (value-to-multM ano-m[e1'0] v) θ₂
in Dmap (substV lemma) (eval i (subst all-no-omega (sym lemma) ano) θ' t₁) ;
(inr v) →
let θ' : ValEnv (_ ∷ Γ) (M→M₀ m ∷ Δ) Θ (m ×ₘ (Ξₑ₁' +ₘ Ξ₀) +ₘ Ξₑ₂)
θ' = tup (m ×ₘ (Ξₑ₁' +ₘ Ξ₀)) Ξₑ₂ refl (value-to-multM ano-m[e1'0] v) θ₂
in Dmap (substV lemma) (eval i (subst all-no-omega (sym lemma) ano) θ' t₂)
}
where
lemma : m ×ₘ (Ξₑ₁' +ₘ Ξ₀) +ₘ Ξₑ₂ +ₘ Ξ ≡
(m ×ₘ Ξₑ₁' +ₘ Ξₑ₂) +ₘ (m ×ₘ Ξ₀ +ₘ Ξ)
lemma =
begin
m ×ₘ (Ξₑ₁' +ₘ Ξ₀) +ₘ Ξₑ₂ +ₘ Ξ
≡⟨ cong (λ x -> x +ₘ Ξₑ₂ +ₘ Ξ) (×ₘ-dist m Ξₑ₁' _) ⟩
m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ Ξₑ₂ +ₘ Ξ
≡⟨ +ₘ-assoc (m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀) Ξₑ₂ _ ⟩
m ×ₘ Ξₑ₁' +ₘ m ×ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ)
≡⟨ +ₘ-transpose _ _ _ _ ⟩
(m ×ₘ Ξₑ₁' +ₘ Ξₑ₂) +ₘ (m ×ₘ Ξ₀ +ₘ Ξ)
∎
eval i ano θ (roll t) = Dmap roll (eval i ano θ t)
eval i ano θ (unroll t) =
Bind (eval i ano θ t) λ { (roll v) → Later λ where .force -> Now v }
eval {Γ = Γ} i ano θ (unit● ad) with discardable-has-no-resources {Γ} θ ad
... | refl = Now (red (substR (sym (∅-lid _)) unit●))
eval {Θ} {Ξₑ} {Γ} i ano θ (letunit● {Δ₀ = Δ₀} {Δ} {Ξ₀ = Ξ₀} {Ξ} t₀ t) = do
tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂ <- separateEnv {Γ} Δ₀ Δ θ
let lemma : Ξₑ₁ +ₘ Ξₑ₂ +ₘ (Ξ₀ +ₘ Ξ) ≡ Ξₑ₁ +ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ)
lemma = +ₘ-transpose _ _ _ _
let ano' = subst all-no-omega lemma ano
ano-e10 , ano-e2- <- all-no-omega-dist (Ξₑ₁ +ₘ Ξ₀) _ ano'
BindR (eval i ano-e10 θ₁ t₀) λ E₀ ->
BindR (eval i ano-e2- θ₂ t) λ E ->
Now (red (substR (sym lemma) (letunit● E₀ E)))
eval {Θ} {Ξₑ} {Γ} i ano θ (pair● {Δ₁ = Δ₁} {Δ₂} {Ξ₁ = Ξ₁} {Ξ₂} t₁ t₂) = do
tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂ <- separateEnv {Γ} Δ₁ Δ₂ θ
let lemma : Ξₑ₁ +ₘ Ξₑ₂ +ₘ (Ξ₁ +ₘ Ξ₂) ≡ Ξₑ₁ +ₘ Ξ₁ +ₘ (Ξₑ₂ +ₘ Ξ₂)
lemma = +ₘ-transpose _ _ _ _
let ano' = subst all-no-omega lemma ano
ano-e11 , ano-e22 <- all-no-omega-dist (Ξₑ₁ +ₘ Ξ₁) _ ano'
BindR (eval i ano-e11 θ₁ t₁) λ E₁ ->
BindR (eval i ano-e22 θ₂ t₂) λ E₂ ->
Now (red (substR (sym lemma) (pair● E₁ E₂)))
eval {Θ} {Ξₑ} {Γ} i ano θ (letpair● {Δ₀ = Δ₀} {Δ} {Ξ₀ = Ξ₀} {Ξ} t₀ t)
with separateEnv {Γ} Δ₀ Δ θ
... | tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂
with subst all-no-omega (+ₘ-transpose Ξₑ₁ Ξₑ₂ Ξ₀ _) ano
... | ano'
with all-no-omega-dist (Ξₑ₁ +ₘ Ξ₀) _ ano'
... | ano-e10 , ano-e2-
with eval i ano-e10 θ₁ t₀ | eval i (one ∷ one ∷ ano-e2-) (weakenΘ-valEnv Γ (compat-ext-here (compat-ext-here ext-id)) θ₂) t
... | T₁ | T =
Bind T₁ λ { (red E₁) ->
Bind T λ { (red E ) ->
Now (red (substR (+ₘ-transpose Ξₑ₁ Ξ₀ _ _) (letpair● E₁ E)))
}}
eval i ano θ (inl● t) =
BindR (eval i ano θ t) λ E -> Now (red (inl● E))
eval i ano θ (inr● t) =
BindR (eval i ano θ t) λ E -> Now (red (inr● E))
eval {Θ} {Ξₑ} {Γ} i ano θ (case● {Δ₀ = Δ₀} {Δ} {Δ'} {Ξ₀ = Ξ₀} {Ξ} {Ξ'} t t₁ t₂ t₃)
with separateEnv {Γ} (Δ₀ +ₘ Δ) _ θ
... | tup Ξₑ₁₂ Ξₑ₃ refl θ' θ₃
with discardable-has-no-resources {Γ} θ₃ (omega×ₘ-discardable Δ')
... | refl
with un×ₘ-valEnv Γ θ₃
... | Ξₑ₃' , θ₃' , eq
with omega×ₘ∅-inv Ξₑ₃' eq
... | refl
with separateEnv {Γ} Δ₀ Δ θ'
... | tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂
with subst all-no-omega lemma ano | lemma
where
open import Algebra.Solver.CommutativeMonoid (+ₘ-commutativeMonoid (length Θ))
renaming (_⊕_ to _⊞_)
lemma : Ξₑ₁ +ₘ Ξₑ₂ +ₘ ∅ +ₘ (Ξ₀ +ₘ Ξ +ₘ omega ×ₘ Ξ')
≡ (Ξₑ₁ +ₘ Ξ₀) +ₘ (Ξₑ₂ +ₘ Ξ) +ₘ omega ×ₘ Ξ'
lemma = solve 5 (\a b c d e -> ((a ⊞ b) ⊞ id) ⊞ ((c ⊞ d) ⊞ e)
⊜ ((a ⊞ c) ⊞ (b ⊞ d)) ⊞ e) refl Ξₑ₁ Ξₑ₂ Ξ₀ Ξ (omega ×ₘ Ξ')
... | ano' | lemma
with all-no-omega-dist ((Ξₑ₁ +ₘ Ξ₀) +ₘ (Ξₑ₂ +ₘ Ξ)) _ ano'
... | ano'' , ano₃
with all-no-omega-dist (Ξₑ₁ +ₘ Ξ₀) _ ano''
... | ano-e10 , ano-e2-
with all-no-omega-omega×ₘ Ξ' ano₃
... | refl
with eval i ano-e10 θ₁ t | eval i (subst all-no-omega (sym (∅-lid _)) all-no-omega-∅) θ₃' t₃
... | T | T₃ =
Bind T λ { (red r) ->
Bind T₃ λ { f ->
Now (red (substR (trans lemma' (sym lemma))
let f' = weakenΘ-value smashΘ (subst (λ x -> Value Θ x _) (∅-lid ∅) f)
in (case● r refl θ₂ t₁ θ₂ t₂ f')))
}
}
where
lemma' : Ξₑ₁ +ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ)
≡ Ξₑ₁ +ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ) +ₘ omega ×ₘ ∅
lemma' =
sym (trans (cong (λ x -> Ξₑ₁ +ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ) +ₘ x)
(×ₘ∅ omega))
(∅-rid (Ξₑ₁ +ₘ Ξ₀ +ₘ (Ξₑ₂ +ₘ Ξ) )))
eval {Θ} {Ξₑ} {Γ} i ano θ (var● x ad ok)
with discardable-has-no-resources {Γ} θ ad
... | refl = Now (red (substR (sym (∅-lid _)) (var● x ok)))
eval {Θ} {Ξₑ} {Γ} i ano θ (pin {Δ₁ = Δ₁} {Δ₂} {Ξ₁ = Ξ₁} {Ξ₂} t₁ t₂) = do
tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂ <- separateEnv {Γ} Δ₁ Δ₂ θ
let ano' = subst all-no-omega (+ₘ-transpose Ξₑ₁ Ξₑ₂ Ξ₁ _) ano
ano-e11 , ano-e22 <- all-no-omega-dist (Ξₑ₁ +ₘ Ξ₁) _ ano'
BindR (eval i ano-e11 θ₁ t₁) λ r ->
Bind (eval i ano-e22 θ₂ t₂) λ v ->
Now (red (substR (+ₘ-transpose _ _ _ _) (pin r v)))
eval {Γ = Γ} i ano θ (unlift e) = do
Ξ' , θ' , refl <- un×ₘ-valEnv Γ θ
ano₁ , ano₂ <- all-no-omega-dist _ _ ano
refl <- all-no-omega-omega×ₘ _ ano₁
refl <- all-no-omega-omega×ₘ _ ano₂
Bind (eval i (subst all-no-omega (sym (∅-lid ∅)) all-no-omega-∅ ) θ' e) λ v ->
BindR (apply i (one ∷ subst all-no-omega (sym lemma₁) all-no-omega-∅) (weakenΘ-value (compat-ext-here ext-id) v) (red var●₀)) λ r ->
Now (substV (sym lemma₂) (inj refl (weakenΘ-residual (compat-skip smashΘ) (substR (cong (one ∷_) lemma₁) r) )))
where
open import Data.Vec.Properties using (map-id)
lemma₁ : ∀ {n} -> ∅ +ₘ ∅ +ₘ Data.Vec.map (λ y -> y) ∅ ≡ ∅ {n}
lemma₁ {n} rewrite map-id (∅ {n}) | ∅-rid {n} ∅ = ∅-lid ∅
lemma₂ : ∀ {n} -> omega ×ₘ ∅ +ₘ omega ×ₘ ∅ ≡ ∅ {n}
lemma₂ {n} rewrite ×ₘ∅ {n} omega | ∅-lid {n} ∅ = refl
eval {Γ = Γ} i ano θ (fapp e₁ e₂) = do
anoₑ , ano' <- all-no-omega-dist _ _ ano
ano₁ , ano'' <- all-no-omega-dist _ _ ano'
refl <- all-no-omega-omega×ₘ _ ano''
tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂ <- separateEnv {Γ} _ _ θ
Ξₑ₂' , θ₂' , refl <- un×ₘ-valEnv Γ θ₂
ano₁' , _ <- all-no-omega-dist _ _ (subst all-no-omega lemma' ano)
Bind (eval i ano₁' θ₁ e₁) λ {
(inj spΞ r) → do
refl , refl <- ∅+ₘ∅-inv _ _ (sym spΞ)
refl <- all-no-omega-omega×ₘ _ (subst all-no-omega (∅-lid _) anoₑ)
Bind (eval i (subst all-no-omega (sym (∅-lid ∅)) all-no-omega-∅) θ₂' e₂) λ v -> Later λ { .force {j} ->
Bind (Forward (evalR j (one ∷ all-no-omega-∅) r) (weakenΘ-value smashΘ (substV (∅-lid ∅) v) ∷ [])) λ v' ->
Now (substV (sym lemma) (weakenΘ-value extendΘ v'))
}
}
where
lemma' : ∀ {n} {Ξₑ₁ Ξ₁ X Y : MultEnv n} -> Ξₑ₁ +ₘ X +ₘ (Ξ₁ +ₘ Y) ≡ Ξₑ₁ +ₘ Ξ₁ +ₘ (X +ₘ Y)
lemma' {n} {A} {B} {C} {D} = +ₘ-transpose A C B D
lemma : ∀ {n} -> ∅ +ₘ omega ×ₘ ∅ +ₘ (∅ +ₘ omega ×ₘ ∅) ≡ ∅ {n}
lemma {n} rewrite ×ₘ∅ {n} omega | ∅-lid {n} ∅ = ∅-lid ∅
eval {Γ = Γ} i ano θ (bapp e₁ e₂) = do
anoₑ , ano' <- all-no-omega-dist _ _ ano
ano₁ , ano'' <- all-no-omega-dist _ _ ano'
refl <- all-no-omega-omega×ₘ _ ano''
tup Ξₑ₁ Ξₑ₂ refl θ₁ θ₂ <- separateEnv {Γ} _ _ θ
Ξₑ₂' , θ₂' , refl <- un×ₘ-valEnv Γ θ₂
ano₁' , _ <- all-no-omega-dist _ _ (subst all-no-omega lemma' ano)
Bind (eval i ano₁' θ₁ e₁) λ {
(inj spΞ r) → do
refl , refl <- ∅+ₘ∅-inv _ _ (sym spΞ)
refl <- all-no-omega-omega×ₘ _ (subst all-no-omega (∅-lid _) anoₑ)
Bind (eval i (subst all-no-omega (sym (∅-lid ∅)) all-no-omega-∅) θ₂' e₂) λ v -> Later λ { .force {j} ->
Bind (Backward (evalR j (one ∷ all-no-omega-∅) r) (weakenΘ-value smashΘ (substV (∅-lid ∅) v))) λ { (v' ∷ []) ->
Now (substV (sym lemma) (weakenΘ-value extendΘ v'))
}
}
}
where
lemma' : ∀ {n} {Ξₑ₁ Ξ₁ X Y : MultEnv n} -> Ξₑ₁ +ₘ X +ₘ (Ξ₁ +ₘ Y) ≡ Ξₑ₁ +ₘ Ξ₁ +ₘ (X +ₘ Y)
lemma' {n} {A} {B} {C} {D} = +ₘ-transpose A C B D
lemma : ∀ {n} -> ∅ +ₘ omega ×ₘ ∅ +ₘ (∅ +ₘ omega ×ₘ ∅) ≡ ∅ {n}
lemma {n} rewrite ×ₘ∅ {n} omega | ∅-lid {n} ∅ = ∅-lid ∅
open Interpreter public
| {
"alphanum_fraction": 0.4819907049,
"avg_line_length": 42.6776859504,
"ext": "agda",
"hexsha": "fb1f0a56381527397ac671970ed167d14590e804",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "e2fb3a669e733a9020a51b24244d89abd8fcf725",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "kztk-m/sparcl-agda",
"max_forks_repo_path": "Definitional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e2fb3a669e733a9020a51b24244d89abd8fcf725",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "kztk-m/sparcl-agda",
"max_issues_repo_path": "Definitional.agda",
"max_line_length": 157,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e2fb3a669e733a9020a51b24244d89abd8fcf725",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "kztk-m/sparcl-agda",
"max_stars_repo_path": "Definitional.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 14234,
"size": 30984
} |
module Oscar.Data.Equality.properties where
-- open import Relation.Binary.PropositionalEquality public using (cong; cong₂; cong-app; subst; subst₂; sym; trans)
-- open import Oscar.Data.Equality
-- open import Oscar.Function
-- open import Oscar.Level
-- open import Oscar.Relation
-- -- ≡̇-refl : ∀ {a} {A : Set a} {b} {B : A → Set b} (f : (x : A) → B x) → f ≡̇ f
-- -- ≡̇-refl _ _ = refl
-- -- ≡̇-sym : ∀ {a} {A : Set a} {b} {B : A → Set b} {f g : (x : A) → B x} → f ≡̇ g → g ≡̇ f
-- -- ≡̇-sym f≡̇g = sym ∘ f≡̇g
-- -- ≡̇-trans : ∀ {a} {A : Set a} {b} {B : A → Set b} {f g : (x : A) → B x} → f ≡̇ g → {h : (x : A) → B x} → g ⟨ _≡̇ h ⟩→ f
-- -- ≡̇-trans f≡̇g g≡̇h x = trans (f≡̇g x) (g≡̇h x)
-- -- -- open import Oscar.Category.Setoid
-- -- -- instance
-- -- -- IsEquivalencePropositionalEquality : ∀ {a} {A : Set a} → IsEquivalence (_≡_ {A = A})
-- -- -- IsEquivalence.reflexivity IsEquivalencePropositionalEquality _ = refl
-- -- -- IsEquivalence.symmetry IsEquivalencePropositionalEquality = sym
-- -- -- IsEquivalence.transitivity IsEquivalencePropositionalEquality = λ ‵ → trans ‵
-- -- -- IsEquivalenceIndexedPropositionalEquality : ∀ {a} {A : Set a} {b} {B : A → Set b} → IsEquivalence (_≡̇_ {B = B})
-- -- -- IsEquivalence.reflexivity IsEquivalenceIndexedPropositionalEquality = ≡̇-refl
-- -- -- IsEquivalence.symmetry IsEquivalenceIndexedPropositionalEquality = ≡̇-sym
-- -- -- IsEquivalence.transitivity IsEquivalenceIndexedPropositionalEquality = ≡̇-trans
-- -- -- instance
-- -- -- IsSetoidPropositionalEquality : ∀ {a} {A : Set a} → IsSetoid A a
-- -- -- IsSetoid._≋_ IsSetoidPropositionalEquality = _≡_
-- -- -- IsSetoidIndexedPropositionalEquality : ∀ {a} {A : Set a} {b} {B : A → Set b} → IsSetoid ((x : A) → B x) (a ⊔ b)
-- -- -- IsSetoid._≋_ IsSetoidIndexedPropositionalEquality = _≡̇_
-- -- -- setoidPropositionalEquality : ∀ {a} (A : Set a) → Setoid a a
-- -- -- Setoid.⋆ (setoidPropositionalEquality A) = A
-- -- -- setoidIndexedPropositionalEquality : ∀ {a} {A : Set a} {b} (B : A → Set b) → Setoid (a ⊔ b) (a ⊔ b)
-- -- -- Setoid.⋆ (setoidIndexedPropositionalEquality {A = A} B) = (x : A) → B x
-- -- -- Setoid.isSetoid (setoidIndexedPropositionalEquality B) = IsSetoidIndexedPropositionalEquality {B = B}
-- -- -- open import Oscar.Category.Action
-- -- -- actionΣ : ∀ {a} {A : Set a} {b} (B : A → Set b) → Action A b b
-- -- -- Action.𝔄 (actionΣ B) x = setoidPropositionalEquality (B x)
-- -- -- _⇒_ : ∀ {a} (A : Set a) {b} (B : Set b) → Setoid _ _
-- -- -- _⇒_ A B = setoidIndexedPropositionalEquality {A = A} λ _ → B
-- -- -- open import Oscar.Category.Semigroupoid
-- -- -- open import Oscar.Category.Morphism
-- -- -- ⇧ : ∀ {a} {A : Set a} {b} (B : A → A → Set b) → Morphism A b b
-- -- -- Morphism._⇒_ (⇧ B) x y = setoidPropositionalEquality (B x y)
-- -- -- _⇨_ : ∀ {a} {A : Set a} {b} (B : A → Set b) {c} (C : A → Set c) → Morphism A (b ⊔ c) (b ⊔ c)
-- -- -- Morphism._⇒_ (B ⇨ C) = λ m n → B m ⇒ C n
-- -- -- IsSemigroupoid⋆ : ∀ {a} {A : Set a} {b} {B : A → Set b} {c} {C : A → Set c}
-- -- -- (let _↦_ = λ m n → B m → C n)
-- -- -- (_∙_ : ∀ {y z} → y ↦ z → ∀ {x} → x ↦ y → x ↦ z) → Set (lsuc (a ⊔ b ⊔ c))
-- -- -- IsSemigroupoid⋆ _∙_ = IsSemigroupoid (_ ⇨ _) _∙_
-- -- -- Semigroupoid⋆ :
-- -- -- ∀ {a} {A : Set a} {b} {B : A → Set b} {c} {C : A → Set c}
-- -- -- (let _↦_ = λ m n → B m → C n)
-- -- -- (_∙_ : ∀ {y z} → y ↦ z → ∀ {x} → x ↦ y → x ↦ z)
-- -- -- ⦃ _ : IsSemigroupoid⋆ _∙_ ⦄
-- -- -- → Semigroupoid _ _ _
-- -- -- Semigroupoid⋆ _∙_ = _ ⇨ _ , _∙_
-- -- -- open import Oscar.Category.Semigroupoid
-- -- -- instance
-- -- -- isSemigroupoidFunctions≡̇ : ∀ {a} {A : Set a} {b} {B : A → Set b} → IsSemigroupoid (B ⇨ B) (λ g f → g ∘ f)
-- -- -- IsSemigroupoid.extensionality isSemigroupoidFunctions≡̇ {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = g₁≡̇g₂ (f₂ x)
-- -- -- IsSemigroupoid.associativity isSemigroupoidFunctions≡̇ _ _ _ _ = refl
-- -- -- semigroupoidFunction : ∀ {a} {A : Set a} {b} (B : A → Set b) → Semigroupoid _ _ _
-- -- -- semigroupoidFunction B = B ⇨ B , (λ ‵ → _∘_ ‵)
-- -- -- open import Oscar.Category.Category
-- -- -- instance
-- -- -- isCategoryFunctions≡̇ : ∀ {a} {A : Set a} {b} {B : A → Set b} → IsCategory (semigroupoidFunction B) id
-- -- -- IsCategory.left-identity isCategoryFunctions≡̇ _ _ = refl
-- -- -- IsCategory.right-identity isCategoryFunctions≡̇ _ _ = refl
-- -- -- categoryFunction : ∀ {a} {A : Set a} {b} (B : A → Set b) → Category _ _ _
-- -- -- categoryFunction B = semigroupoidFunction B , id
-- -- -- -- -- open import Oscar.Property.Reflexivity
-- -- -- -- -- instance Reflexivity≡ : ∀ {a} {A : Set a} → Reflexivity (_≡_ {A = A})
-- -- -- -- -- Reflexivity.reflexivity Reflexivity≡ _ = refl
-- -- -- -- -- instance Reflexivity≡̇ : ∀ {a} {A : Set a} {b} {B : A → Set b} → Reflexivity (_≡̇_ {B = B})
-- -- -- -- -- Reflexivity.reflexivity Reflexivity≡̇ _ _ = refl
-- -- -- -- -- open import Oscar.Property.Symmetry
-- -- -- -- -- instance Symmetry≡ : ∀ {a} {A : Set a} → Symmetry (_≡_ {A = A})
-- -- -- -- -- Symmetry.symmetry Symmetry≡ = sym
-- -- -- -- -- instance Symmetry≡̇ : ∀ {a} {A : Set a} {b} {B : A → Set b} → Symmetry (_≡̇_ {B = B})
-- -- -- -- -- Symmetry.symmetry Symmetry≡̇ = ≡̇-sym
-- -- -- -- -- open import Oscar.Property.Transitivity
-- -- -- -- -- instance Transitivity≡ : ∀ {a} {A : Set a} → Transitivity (_≡_ {A = A})
-- -- -- -- -- Transitivity.transitivity Transitivity≡ x≡y = trans x≡y
-- -- -- -- -- instance Transitivity≡̇ : ∀ {a} {A : Set a} {b} {B : A → Set b} → Transitivity (_≡̇_ {B = B})
-- -- -- -- -- Transitivity.transitivity Transitivity≡̇ = ≡̇-trans
-- -- -- -- -- -- {-
-- -- -- -- -- -- _∘₂_ : ∀ {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)
-- -- -- -- -- -- -}
-- -- -- -- -- -- open import Oscar.Class.Equivalence
-- -- -- -- -- -- instance ReflexivityPropositional : ∀ {a} {A : Set a} → Reflexivity (_≡_ {A = A})
-- -- -- -- -- -- Reflexivity.reflexivity ReflexivityPropositional = refl
-- -- -- -- -- -- instance SymmetryPropositional : ∀ {a} {A : Set a} → Symmetry (_≡_ {A = A})
-- -- -- -- -- -- Symmetry.symmetry SymmetryPropositional = sym
-- -- -- -- -- -- instance TransitivityPropositional : ∀ {a} {A : Set a} → Transitivity (_≡_ {A = A})
-- -- -- -- -- -- Transitivity.transitivity TransitivityPropositional = trans
-- -- -- -- -- -- open import Prelude using (it)
-- -- -- -- -- -- instance Equivalence⋆ : ∀ {a} {A : Set a} {ℓ} {_≋_ : A → A → Set ℓ} ⦃ _ : Reflexivity _≋_ ⦄ ⦃ _ : Symmetry _≋_ ⦄ ⦃ _ : Transitivity _≋_ ⦄ → Equivalence _≋_
-- -- -- -- -- -- Equivalence.reflexivityI Equivalence⋆ = it
-- -- -- -- -- -- Equivalence.symmetryI Equivalence⋆ = it
-- -- -- -- -- -- Equivalence.transitivityI Equivalence⋆ = it
-- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- instance EquivalencePropositional : ∀ {a} {A : Set a} → Equivalence (_≡_ {A = A})
-- -- -- -- -- -- -- -- Equivalence.reflexivity EquivalencePropositional = refl
-- -- -- -- -- -- -- -- Equivalence.symmetry EquivalencePropositional = sym
-- -- -- -- -- -- -- -- Equivalence.transitivity EquivalencePropositional = trans
-- -- -- -- -- -- -- -- instance EquivalencePointwise : ∀ {a} {A : Set a} {b} {B : A → Set b} → Equivalence (_≡̇_ {B = B})
-- -- -- -- -- -- -- -- Equivalence.reflexivity EquivalencePointwise x = refl
-- -- -- -- -- -- -- -- Equivalence.symmetry EquivalencePointwise = ≡̇-sym
-- -- -- -- -- -- -- -- Equivalence.transitivity EquivalencePointwise = ≡̇-trans
-- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- instance CongruousEquivalencesPropositional : ∀ {a} {A : Set a} {b} {B : Set b} → CongruousEquivalences (_≡_ {A = A}) (_≡_ {A = B})
-- -- -- -- -- -- CongruousEquivalences.equivalence₁ CongruousEquivalencesPropositional = it
-- -- -- -- -- -- CongruousEquivalences.equivalence₂ CongruousEquivalencesPropositional = it
-- -- -- -- -- -- CongruousEquivalences.congruity CongruousEquivalencesPropositional = cong
-- -- -- -- -- -- postulate
-- -- -- -- -- -- FunctionName : Set
-- -- -- -- -- -- open import Oscar.Data.Nat
-- -- -- -- -- -- open import Oscar.Data.Fin
-- -- -- -- -- -- open import Oscar.Data.Term FunctionName
-- -- -- -- -- -- open import Oscar.Data.Term.Injectivity FunctionName
-- -- -- -- -- -- instance InjectiveEquivalencesTermI : ∀ {m : Nat} → InjectiveEquivalences (_≡_ {A = Fin m}) (_≡_ {A = Term m}) Term.i Term.i
-- -- -- -- -- -- InjectiveEquivalences.equivalence₁ InjectiveEquivalencesTermI = it
-- -- -- -- -- -- InjectiveEquivalences.equivalence₂ InjectiveEquivalencesTermI = it
-- -- -- -- -- -- InjectiveEquivalences.injectivity InjectiveEquivalencesTermI refl = reflexivity
-- -- -- -- -- -- instance InjectiveEquivalencesTermLeft : ∀ {m : Nat} {r₁ r₂ : Term m} → InjectiveEquivalences _≡_ _≡_ (_fork r₁) (_fork r₂)
-- -- -- -- -- -- InjectiveEquivalences.equivalence₁ InjectiveEquivalencesTermLeft = it
-- -- -- -- -- -- InjectiveEquivalences.equivalence₂ InjectiveEquivalencesTermLeft = it
-- -- -- -- -- -- InjectiveEquivalences.injectivity InjectiveEquivalencesTermLeft refl = reflexivity
-- -- -- -- -- -- instance InjectiveEquivalencesTermRight : ∀ {m : Nat} {l₁ l₂ : Term m} → InjectiveEquivalences _≡_ _≡_ (l₁ fork_) (l₂ fork_)
-- -- -- -- -- -- InjectiveEquivalences.equivalence₁ InjectiveEquivalencesTermRight = it
-- -- -- -- -- -- InjectiveEquivalences.equivalence₂ InjectiveEquivalencesTermRight = it
-- -- -- -- -- -- InjectiveEquivalences.injectivity InjectiveEquivalencesTermRight refl = reflexivity
-- -- -- -- -- -- injectivity' :
-- -- -- -- -- -- ∀ {a} {A : Set a} {ℓ₁} {_≋₁_ : A → A → Set ℓ₁}
-- -- -- -- -- -- {b} {B : Set b}
-- -- -- -- -- -- {f : A → B}
-- -- -- -- -- -- {g : A → B}
-- -- -- -- -- -- ⦃ _ : InjectiveEquivalences _≋₁_ _≡_ f g ⦄ →
-- -- -- -- -- -- ∀ {x y} → f x ≡ g y → x ≋₁ y
-- -- -- -- -- -- injectivity' x = injectivity {_≋₂_ = _≡_} x
-- -- -- -- -- -- Term-forkLeft-inj' : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → l₁ ≡ l₂
-- -- -- -- -- -- Term-forkLeft-inj' {n} {l₁} {r₁} {l₂} {r₂} x = injectivity' x
-- -- -- -- -- -- --Term-forkLeft-inj' {n} {l₁} {r₁} {l₂} {r₂} x = injectivity {_≋₂_ = _≡_} x
-- -- -- -- -- -- -- injectivity {_≋₁_ = {!_≡_!}} {_≋₂_ = {!_≡_!}} ⦃ InjectiveEquivalencesTermLeft ⦄ x
-- -- -- -- -- -- Term-forkRight-inj' : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → r₁ ≡ r₂
-- -- -- -- -- -- Term-forkRight-inj' {n} {l₁} {r₁} {l₂} {r₂} x = injectivity' x
-- -- -- -- -- -- --Term-forkLeft-inj' {n} {l₁} {r₁} {l₂} {r₂} x = injectivity {_≋₂_ = _≡_} x
-- -- -- -- -- -- -- injectivity {_≋₁_ = {!_≡_!}} {_≋₂_ = {!_≡_!}} ⦃ InjectiveEquivalencesTermLeft ⦄ x
| {
"alphanum_fraction": 0.5373626374,
"avg_line_length": 51.5094339623,
"ext": "agda",
"hexsha": "4e5ae00a0481150a83a58bb8c28f505c482ed5aa",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-2/Oscar/Data/Equality/properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-2/Oscar/Data/Equality/properties.agda",
"max_line_length": 173,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-2/Oscar/Data/Equality/properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4123,
"size": 10920
} |
{-# OPTIONS --with-K #-}
module Agda.Builtin.Equality.Erase where
open import Agda.Builtin.Equality
primitive primEraseEquality : ∀ {a} {A : Set a} {x y : A} → x ≡ y → x ≡ y
| {
"alphanum_fraction": 0.6497175141,
"avg_line_length": 22.125,
"ext": "agda",
"hexsha": "97704dce62357b00c5a07ba34f83d4180d80d95b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "bennn/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Equality/Erase.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "bennn/agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Equality/Erase.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "bennn/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Equality/Erase.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 59,
"size": 177
} |
module Data.Num.Bounded where
open import Data.Num.Core
open import Data.Num.Maximum
open import Data.Nat
open import Data.Nat.Properties
open import Data.Nat.Properties.Simple
open import Data.Nat.Properties.Extra
open import Data.Fin as Fin
using (Fin; fromℕ≤; inject≤)
renaming (zero to z; suc to s)
open import Data.Fin.Properties using (toℕ-fromℕ≤; bounded)
open import Data.Product
open import Function
open import Relation.Nullary.Decidable
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_)
open DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl)
------------------------------------------------------------------------
-- a system is bounded if there exists the greatest number
Bounded : ∀ b d o → Set
Bounded b d o = Σ[ xs ∈ Numeral b d o ] Maximum xs
Bounded-NullBase : ∀ d o → Bounded 0 (suc d) o
Bounded-NullBase d o = (greatest-digit d ∙) , (Maximum-NullBase-Greatest (greatest-digit d ∙) (greatest-digit-is-the-Greatest d))
Bounded-NoDigits : ∀ b o → ¬ (Bounded b 0 o)
Bounded-NoDigits b o (xs , claim) = NoDigits-explode xs
Bounded-AllZeros : ∀ b → Bounded (suc b) 1 0
Bounded-AllZeros b = (z ∙) , Maximum-AllZeros (z ∙)
Bounded-Proper : ∀ b d o → 2 ≤ suc (d + o) → ¬ (Bounded (suc b) (suc d) o)
Bounded-Proper b d o proper (xs , claim) =
contradiction claim (Maximum-Proper xs proper)
Bounded? : ∀ b d o → Dec (Bounded b d o)
Bounded? b d o with numView b d o
Bounded? _ _ _ | NullBase d o
= yes (Bounded-NullBase d o)
Bounded? _ _ _ | NoDigits b o
= no (Bounded-NoDigits b o)
Bounded? _ _ _ | AllZeros b
= yes (Bounded-AllZeros b)
Bounded? _ _ _ | Proper b d o proper
= no (Bounded-Proper b d o proper)
--------------------------------------------------------------------------------
-- Misc
Maximum⇒Bounded : ∀ {b d o}
→ (xs : Numeral b d o)
→ Maximum xs
→ Bounded b d o
Maximum⇒Bounded xs max = xs , max
-- contraposition of Maximum⇒Bounded
¬Bounded⇒¬Maximum : ∀ {b d o}
→ (xs : Numeral b d o)
→ ¬ (Bounded b d o)
→ ¬ (Maximum xs)
¬Bounded⇒¬Maximum xs = contraposition (Maximum⇒Bounded xs)
-- begin
-- {! !}
-- ≡⟨ {! !} ⟩
-- {! !}
-- ≡⟨ {! !} ⟩
-- {! !}
-- ≡⟨ {! !} ⟩
-- {! !}
-- ≡⟨ {! !} ⟩
-- {! !}
-- ∎
-- start
-- {! !}
-- ≤⟨ {! !} ⟩
-- {! !}
-- ≤⟨ {! !} ⟩
-- {! !}
-- ≤⟨ {! !} ⟩
-- {! !}
-- □
| {
"alphanum_fraction": 0.580078125,
"avg_line_length": 26.6666666667,
"ext": "agda",
"hexsha": "debc6b11db7b9d0f13b4c75458a147bc3dd4f6df",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "Data/Num/Bounded.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "Data/Num/Bounded.agda",
"max_line_length": 129,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "Data/Num/Bounded.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 872,
"size": 2560
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some derivable properties
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Algebra.Bundles
module Algebra.Properties.DistributiveLattice
{dl₁ dl₂} (DL : DistributiveLattice dl₁ dl₂)
where
open DistributiveLattice DL
import Algebra.Properties.Lattice as LatticeProperties
open import Algebra.Structures
open import Algebra.Definitions _≈_
open import Relation.Binary
open import Relation.Binary.Reasoning.Setoid setoid
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence using (_⇔_; module Equivalence)
open import Data.Product using (_,_)
------------------------------------------------------------------------
-- Export properties of lattices
open LatticeProperties lattice public
hiding (replace-equality)
------------------------------------------------------------------------
-- Other properties
∨-distribˡ-∧ : _∨_ DistributesOverˡ _∧_
∨-distribˡ-∧ x y z = begin
x ∨ y ∧ z ≈⟨ ∨-comm _ _ ⟩
y ∧ z ∨ x ≈⟨ ∨-distribʳ-∧ _ _ _ ⟩
(y ∨ x) ∧ (z ∨ x) ≈⟨ ∨-comm _ _ ⟨ ∧-cong ⟩ ∨-comm _ _ ⟩
(x ∨ y) ∧ (x ∨ z) ∎
∨-distrib-∧ : _∨_ DistributesOver _∧_
∨-distrib-∧ = ∨-distribˡ-∧ , ∨-distribʳ-∧
∧-distribˡ-∨ : _∧_ DistributesOverˡ _∨_
∧-distribˡ-∨ x y z = begin
x ∧ (y ∨ z) ≈⟨ ∧-congʳ $ sym (∧-absorbs-∨ _ _) ⟩
(x ∧ (x ∨ y)) ∧ (y ∨ z) ≈⟨ ∧-congʳ $ ∧-congˡ $ ∨-comm _ _ ⟩
(x ∧ (y ∨ x)) ∧ (y ∨ z) ≈⟨ ∧-assoc _ _ _ ⟩
x ∧ ((y ∨ x) ∧ (y ∨ z)) ≈⟨ ∧-congˡ $ sym (∨-distribˡ-∧ _ _ _) ⟩
x ∧ (y ∨ x ∧ z) ≈⟨ ∧-congʳ $ sym (∨-absorbs-∧ _ _) ⟩
(x ∨ x ∧ z) ∧ (y ∨ x ∧ z) ≈⟨ sym $ ∨-distribʳ-∧ _ _ _ ⟩
x ∧ y ∨ x ∧ z ∎
∧-distribʳ-∨ : _∧_ DistributesOverʳ _∨_
∧-distribʳ-∨ x y z = begin
(y ∨ z) ∧ x ≈⟨ ∧-comm _ _ ⟩
x ∧ (y ∨ z) ≈⟨ ∧-distribˡ-∨ _ _ _ ⟩
x ∧ y ∨ x ∧ z ≈⟨ ∧-comm _ _ ⟨ ∨-cong ⟩ ∧-comm _ _ ⟩
y ∧ x ∨ z ∧ x ∎
∧-distrib-∨ : _∧_ DistributesOver _∨_
∧-distrib-∨ = ∧-distribˡ-∨ , ∧-distribʳ-∨
-- The dual construction is also a distributive lattice.
∧-∨-isDistributiveLattice : IsDistributiveLattice _≈_ _∧_ _∨_
∧-∨-isDistributiveLattice = record
{ isLattice = ∧-∨-isLattice
; ∨-distribʳ-∧ = ∧-distribʳ-∨
}
∧-∨-distributiveLattice : DistributiveLattice _ _
∧-∨-distributiveLattice = record
{ isDistributiveLattice = ∧-∨-isDistributiveLattice
}
-- One can replace the underlying equality with an equivalent one.
replace-equality : {_≈′_ : Rel Carrier dl₂} →
(∀ {x y} → x ≈ y ⇔ (x ≈′ y)) →
DistributiveLattice _ _
replace-equality {_≈′_} ≈⇔≈′ = record
{ _≈_ = _≈′_
; _∧_ = _∧_
; _∨_ = _∨_
; isDistributiveLattice = record
{ isLattice = Lattice.isLattice
(LatticeProperties.replace-equality lattice ≈⇔≈′)
; ∨-distribʳ-∧ = λ x y z → to ⟨$⟩ ∨-distribʳ-∧ x y z
}
} where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.1
∨-∧-distribˡ = ∨-distribˡ-∧
{-# WARNING_ON_USAGE ∨-∧-distribˡ
"Warning: ∨-∧-distribˡ was deprecated in v1.1.
Please use ∨-distribˡ-∧ instead."
#-}
∨-∧-distrib = ∨-distrib-∧
{-# WARNING_ON_USAGE ∨-∧-distrib
"Warning: ∨-∧-distrib was deprecated in v1.1.
Please use ∨-distrib-∧ instead."
#-}
∧-∨-distribˡ = ∧-distribˡ-∨
{-# WARNING_ON_USAGE ∧-∨-distribˡ
"Warning: ∧-∨-distribˡ was deprecated in v1.1.
Please use ∧-distribˡ-∨ instead."
#-}
∧-∨-distribʳ = ∧-distribʳ-∨
{-# WARNING_ON_USAGE ∧-∨-distribʳ
"Warning: ∧-∨-distribʳ was deprecated in v1.1.
Please use ∧-distribʳ-∨ instead."
#-}
∧-∨-distrib = ∧-distrib-∨
{-# WARNING_ON_USAGE ∧-∨-distrib
"Warning: ∧-∨-distrib was deprecated in v1.1.
Please use ∧-distrib-∨ instead."
#-}
| {
"alphanum_fraction": 0.5277642474,
"avg_line_length": 32.078125,
"ext": "agda",
"hexsha": "33f43353e9bb7d272774daaedeb2faf61f35ca21",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Algebra/Properties/DistributiveLattice.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Algebra/Properties/DistributiveLattice.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Algebra/Properties/DistributiveLattice.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 1615,
"size": 4106
} |
data ⊥ : Set where
postulate
M : Set → Set
A : Set
_>>=_ : ∀ {A B} → M A → (A → M B) → M B
ma : M A
f : A → M ⊥
pure : ∀ {A} → A → M A
absurd-do : ∀ {A} → M A
absurd-do = do
x ← ma
() ← f x
atabsurd-do : ∀ {A} → M A
atabsurd-do = do
x ← ma
(y@()) ← f x -- I don't know why you would do that but we can support it
| {
"alphanum_fraction": 0.4606413994,
"avg_line_length": 17.15,
"ext": "agda",
"hexsha": "5a4ea874412e952b344c06875eac67448b8ccb49",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/absurddo.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/absurddo.agda",
"max_line_length": 74,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/absurddo.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 155,
"size": 343
} |
-- Andreas, 2017-03-27, issue #2183
-- Better error message for splitting on non-visible dot pattern.
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat
data Fin : Nat → Set where
fzero : ∀ n → Fin (suc n)
test : ∀ n (i : Fin n) → Set
test n (fzero m) = {!n!} -- C-c C-c
-- Current error:
-- Cannot split on variable n, because it is bound to term suc m
-- when checking that the expression ? has type Set
-- Desired behavior: succeed.
| {
"alphanum_fraction": 0.6768558952,
"avg_line_length": 25.4444444444,
"ext": "agda",
"hexsha": "790da1c28cf6282ddbcbb8cee7765562bb808788",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/interaction/Issue2183-no-module.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/interaction/Issue2183-no-module.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue2183-no-module.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 138,
"size": 458
} |
module Formalization.ClassicalPropositionalLogic.Place where
open import Data.Boolean
open import Data.Tuple as Tuple using (_,_ ; _⨯_)
import Lvl
open import Formalization.ClassicalPropositionalLogic.Syntax
open import Functional as Fn using (_∘_ ; const)
open import Sets.PredicateSet using (PredSet)
open import Type
private variable ℓₚ ℓᵢ ℓ : Lvl.Level
private variable T A B I : Type{ℓ}
private variable f : A → B
module _ (P : Type{ℓₚ}) where
private variable s e : Bool
private variable p : P
private variable φ ψ γ : Formula(P)
record Index(I : Type{ℓ}) : Type{ℓ} where
field
id : I
∧ₗ : I → I
∧ᵣ : I → I
∨ₗ : I → I
∨ᵣ : I → I
⟶ₗ : I → I
⟶ᵣ : I → I
∧ₗ₀ : I → I
∧ᵣ₀ : I → I
∨ₗ₀ : I → I
∨ᵣ₀ : I → I
⟶ₗ₀ : I → I
⟶ᵣ₀ : I → I
module _ (ind : Index(I)) where
private variable i : I
data Context : I → (Formula(P) → Formula(P)) → Type{Lvl.of(I) Lvl.⊔ ℓₚ} where
identity : Context(Index.id ind) Fn.id
conjunctionₗ : Context(Index.∧ₗ₀ ind i) f → Context(Index.∧ₗ ind i) ((φ ∧_) ∘ f)
conjunctionᵣ : Context(Index.∧ᵣ₀ ind i) f → Context(Index.∧ᵣ ind i) ((_∧ φ) ∘ f)
disjunctionₗ : Context(Index.∨ₗ₀ ind i) f → Context(Index.∨ₗ ind i) ((φ ∨_) ∘ f)
disjunctionᵣ : Context(Index.∨ᵣ₀ ind i) f → Context(Index.∨ᵣ ind i) ((_∨ φ) ∘ f)
implicationₗ : Context(Index.⟶ₗ₀ ind i) f → Context(Index.⟶ₗ ind i) ((φ ⟶_) ∘ f)
implicationᵣ : Context(Index.⟶ᵣ₀ ind i) f → Context(Index.⟶ᵣ ind i) ((_⟶ φ) ∘ f)
Place : Bool → Bool → (Formula(P) → Formula(P)) → Type
Place s e = Context index (s , e) where
index : Index(Bool ⨯ Bool)
Index.id index = (𝑇 , e)
Index.∧ₗ index = Fn.id
Index.∧ᵣ index = Fn.id
Index.∨ₗ index = Fn.id
Index.∨ᵣ index = Fn.id
Index.⟶ₗ index = Fn.id
Index.⟶ᵣ index = Tuple.map Fn.id (const 𝑇)
Index.∧ₗ₀ index = Fn.id
Index.∧ᵣ₀ index = Fn.id
Index.∨ₗ₀ index = Fn.id
Index.∨ᵣ₀ index = Fn.id
Index.⟶ₗ₀ index = Fn.id
Index.⟶ᵣ₀ index = Tuple.map not (const 𝑇)
{-
-- (Place s e F φ) means that the formula F lies on a (strictly (e = 𝐹) / not strictly (e = 𝑇)) (positive (s = 𝑇) / negative (s = 𝐹)) position in the formula φ.
-- Also called: Occurrence, part, (strictly) positive/negative subformula.
data Place : Bool → Bool → Formula(P) → Formula(P) → Type{ℓₚ} where
refl : Place 𝑇 e φ φ
conjunctionₗ : Place s e γ φ → Place s e γ (φ ∧ ψ)
conjunctionᵣ : Place s e γ ψ → Place s e γ (φ ∧ ψ)
disjunctionₗ : Place s e γ φ → Place s e γ (φ ∨ ψ)
disjunctionᵣ : Place s e γ ψ → Place s e γ (φ ∨ ψ)
implicationₗ : Place (not s) e γ φ → Place s 𝑇 γ (φ ⟶ ψ)
implicationᵣ : Place s e γ ψ → Place s e γ (φ ⟶ ψ)
-}
StrictlyPositive = Place 𝑇 𝐹
StrictlyNegative = Place 𝐹 𝐹
Positive = Place 𝑇 𝑇
Negative = Place 𝐹 𝑇
strictly-negative-to-strictly-positive : Place 𝐹 𝐹 f → Place 𝑇 𝐹 f
strictly-negative-to-strictly-positive (conjunctionₗ p) = conjunctionₗ (strictly-negative-to-strictly-positive p)
strictly-negative-to-strictly-positive (conjunctionᵣ p) = conjunctionᵣ (strictly-negative-to-strictly-positive p)
strictly-negative-to-strictly-positive (disjunctionₗ p) = disjunctionₗ (strictly-negative-to-strictly-positive p)
strictly-negative-to-strictly-positive (disjunctionᵣ p) = disjunctionᵣ (strictly-negative-to-strictly-positive p)
strictly-negative-to-strictly-positive (implicationₗ p) = implicationₗ (strictly-negative-to-strictly-positive p)
strictly-to-not-strictly : Place s 𝐹 f → Place s 𝑇 f
strictly-to-not-strictly identity = identity
strictly-to-not-strictly (conjunctionₗ p) = conjunctionₗ (strictly-to-not-strictly p)
strictly-to-not-strictly (conjunctionᵣ p) = conjunctionᵣ (strictly-to-not-strictly p)
strictly-to-not-strictly (disjunctionₗ p) = disjunctionₗ (strictly-to-not-strictly p)
strictly-to-not-strictly (disjunctionᵣ p) = disjunctionᵣ (strictly-to-not-strictly p)
strictly-to-not-strictly (implicationₗ p) = implicationₗ (strictly-to-not-strictly p)
| {
"alphanum_fraction": 0.638700291,
"avg_line_length": 42.5154639175,
"ext": "agda",
"hexsha": "88acfe5888df00ce82c165d88fb48c6c22685535",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Formalization/ClassicalPropositionalLogic/Place.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Formalization/ClassicalPropositionalLogic/Place.agda",
"max_line_length": 162,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Formalization/ClassicalPropositionalLogic/Place.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 1515,
"size": 4124
} |
---------------------------------------------------------------------------
-- Normalization by Evaluation for Intuitionistic Propositional Logic
--
-- We employ a monadic interpreter for the soundness part,
-- and a special class of monads, called cover monads,
-- for the completeness part.
--
-- Normalization is completeness after soundness.
--
-- We give two instances of a cover monad: the free cover monad
-- and the continuation monad with normal forms as answer type.
---------------------------------------------------------------------------
{-# OPTIONS --postfix-projections #-}
open import Library
module NfModelMonad (Base : Set) where
import Formulas ; open module Form = Formulas Base
import Derivations; open module Der = Derivations Base
---------------------------------------------------------------------------
-- Specification of a strong monad on presheaves.
-- Devoid of monad laws.
record Monad : Set₁ where
-- Presheaf transformer.
field
C : (P : Cxt → Set) (Γ : Cxt) → Set
monC : ∀{P} (monP : Mon P) → Mon (C P)
-- Strong functor.
field
mapC' : ∀{P Q} → ⟨ P ⇒̂ Q ⊙ C P ⟩→̇ C Q
-- Ordinary functor: an instance of mapC'.
mapC : ∀{P Q} → (P →̇ Q) → (C P →̇ C Q)
mapC f = mapC' λ τ → f
-- Monad.
field
return : ∀{P} (monP : Mon P) → P →̇ C P
joinC : ∀{P} → C (C P) →̇ C P
-- Kleisli extension.
extC : ∀{P Q} → (P →̇ C Q) → C P →̇ C Q
extC f = joinC ∘ mapC f
-- Strong bind.
bindC' : ∀{P Q} (monP : Mon P) → C P →̇ (P ⇒̂ C Q) ⇒̂ C Q
bindC' monP c τ k = joinC (mapC' k (monC monP τ c))
---------------------------------------------------------------------------
-- A model of IPL parametrized by a strong monad.
module Soundness (monad : Monad) (open Monad monad) where
-- The negative connectives True, ∧, and ⇒ are explained as usual by η-expansion
-- and the meta-level connective.
-- The positive connectives False and ∨ are inhabited by case trees.
-- In case False, the tree has no leaves.
-- In case A ∨ B, each leaf must be in the semantics of either A or B.
T⟦_⟧ : (A : Form) (Γ : Cxt) → Set
T⟦ Atom P ⟧ = C (Ne' (Atom P))
T⟦ False ⟧ = C λ Δ → ⊥
T⟦ A ∨ B ⟧ = C λ Δ → T⟦ A ⟧ Δ ⊎ T⟦ B ⟧ Δ
T⟦ True ⟧ Γ = ⊤
T⟦ A ∧ B ⟧ Γ = T⟦ A ⟧ Γ × T⟦ B ⟧ Γ
T⟦ A ⇒ B ⟧ Γ = ∀{Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Δ → T⟦ B ⟧ Δ
-- Monotonicity of the model is proven by induction on the proposition,
-- using monotonicity of covers and the built-in monotonicity at implication.
-- monT : ∀ A {Γ Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Γ → T⟦ A ⟧ Δ
monFalse : Mon (λ Γ → ⊥)
monFalse τ ()
mutual
monT : ∀ A → Mon T⟦ A ⟧
monT (Atom P) = monC monNe
monT False = monC monFalse
monT (A ∨ B) = monC (monOr A B)
monT True = _
monT (A ∧ B) τ (a , b) = monT A τ a , monT B τ b
monT (A ⇒ B) τ f σ = f (σ • τ)
monOr : ∀ A B → Mon (λ Γ → T⟦ A ⟧ Γ ⊎ T⟦ B ⟧ Γ)
monOr A B τ = map-⊎ (monT A τ) (monT B τ)
returnOr : ∀ A B {Γ} → T⟦ A ⟧ Γ ⊎ T⟦ B ⟧ Γ → T⟦ A ∨ B ⟧ Γ
returnOr A B = return (monOr A B)
-- We can run computations of semantic values.
-- This replaces the paste (weak sheaf condition) of Beth models.
run : ∀ A → C T⟦ A ⟧ →̇ T⟦ A ⟧
run (Atom P) = joinC
run False = joinC
run (A ∨ B) = joinC
run True = _
run (A ∧ B) = < run A ∘ mapC proj₁ , run B ∘ mapC proj₂ >
run (A ⇒ B) c τ a = run B $ mapC' (λ δ f → f id≤ (monT A δ a)) $ monC (monT (A ⇒ B)) τ c
-- Remark: A variant of run in the style of bind.
run' : ∀ {P} (monP : Mon P) A → C P →̇ (P ⇒̂ T⟦ A ⟧) ⇒̂ T⟦ A ⟧
run' monP (Atom p) = bindC' monP
run' monP False = bindC' monP
run' monP (A ∨ B) = bindC' monP
run' monP True = _
run' monP (A ∧ B) c τ k = run' monP A c τ (λ σ → proj₁ ∘ k σ) , run' monP B c τ (λ σ → proj₂ ∘ k σ)
run' monP (A ⇒ B) c τ k σ a = run' monP B c (σ • τ) λ σ' p → k (σ' • σ) p id≤ (monT A σ' a)
-- Fundamental theorem (interpretation / soundness).
-- Pointwise extension of T⟦_⟧ to contexts.
G⟦_⟧ : ∀ (Γ Δ : Cxt) → Set
G⟦ ε ⟧ Δ = ⊤
G⟦ Γ ∙ A ⟧ Δ = G⟦ Γ ⟧ Δ × T⟦ A ⟧ Δ
-- monG : ∀{Γ Δ Φ} (τ : Φ ≤ Δ) → G⟦ Γ ⟧ Δ → G⟦ Γ ⟧ Φ
monG : ∀{Γ} → Mon G⟦ Γ ⟧
monG {ε} τ _ = _
monG {Γ ∙ A} τ (γ , a) = monG τ γ , monT A τ a
-- Variable case.
lookup : ∀{Γ A} (x : Hyp A Γ) → G⟦ Γ ⟧ →̇ T⟦ A ⟧
lookup top = proj₂
lookup (pop x) = lookup x ∘ proj₁
-- A lemma for the orE case.
orElim : ∀ A B C → ⟨ T⟦ A ∨ B ⟧ ⊙ T⟦ A ⇒ C ⟧ ⊙ T⟦ B ⇒ C ⟧ ⟩→̇ T⟦ C ⟧
orElim A B C c g h = run C (mapC' (λ τ → [ g τ , h τ ]) c)
orElim' : ∀ A B C → ⟨ T⟦ A ∨ B ⟧ ⊙ T⟦ A ⇒ C ⟧ ⊙ T⟦ B ⇒ C ⟧ ⟩→̇ T⟦ C ⟧
orElim' A B C c g h = run' (monOr A B) C c id≤ λ τ → [ g τ , h τ ]
-- A lemma for the falseE case.
-- Casts an empty cover into any semantic value (by contradiction).
falseElim : ∀ C → T⟦ False ⟧ →̇ T⟦ C ⟧
falseElim C = run C ∘ mapC ⊥-elim
-- The fundamental theorem
eval : ∀{A Γ} (t : Γ ⊢ A) → G⟦ Γ ⟧ →̇ T⟦ A ⟧
eval (hyp x) = lookup x
eval (impI t) γ τ a = eval t (monG τ γ , a)
eval (impE t u) γ = eval t γ id≤ (eval u γ)
eval (andI t u) γ = eval t γ , eval u γ
eval (andE₁ t) = proj₁ ∘ eval t
eval (andE₂ t) = proj₂ ∘ eval t
eval (orI₁ {A} {B} t) γ = returnOr A B (inj₁ (eval t γ))
eval (orI₂ {A} {B} t) γ = returnOr A B (inj₂ (eval t γ))
eval (orE {A = A} {B} {C} t u v) γ = orElim A B C (eval t γ)
(λ τ a → eval u (monG τ γ , a))
(λ τ b → eval v (monG τ γ , b))
eval {C} (falseE t) γ = falseElim C (eval t γ)
eval trueI γ = _
---------------------------------------------------------------------------
-- A strong monad with services to provide a cover.
-- Devoid of laws.
record CoverMonad : Set₁ where
field
monad : Monad
open Monad monad public renaming (C to Cover)
-- Services for case distinction.
field
falseC : ∀{P} → Ne' False →̇ Cover P
orC : ∀{P Γ C D} (t : Ne Γ (C ∨ D))
(c : Cover P (Γ ∙ C))
(d : Cover P (Γ ∙ D)) → Cover P Γ
-- Service for reification of into case trees.
field
runNf : ∀{A} → Cover (Nf' A) →̇ Nf' A
-- A continuation version of runNf.
runNf' : ∀ {A P} (monP : Mon P) → Cover P →̇ (P ⇒̂ Nf' A) ⇒̂ Nf' A
runNf' monP c τ k = runNf (mapC' k (monC monP τ c))
---------------------------------------------------------------------------
-- Completeness of IPL via a cover monad.
module Completeness (covM : CoverMonad) (open CoverMonad covM) where
open Soundness monad
-- Reflection / reification, proven simultaneously by induction on the proposition.
-- Reflection is η-expansion (and recursively reflection);
-- at positive connections we build a case tree with a single scrutinee: the neutral
-- we are reflecting.
-- At implication, we need reification, which produces introductions
-- and reifies the stored case trees.
mutual
fresh : ∀ {Γ} A → T⟦ A ⟧ (Γ ∙ A)
fresh A = reflect A (hyp top)
reflect : ∀ A → Ne' A →̇ T⟦ A ⟧
reflect (Atom P) t = return monNe t
reflect False t = falseC t
reflect (A ∨ B) t = orC t (returnOr A B (inj₁ (fresh A)))
(returnOr A B (inj₂ (fresh B)))
reflect True t = _
reflect (A ∧ B) t = reflect A (andE₁ t) , reflect B (andE₂ t)
reflect (A ⇒ B) t τ a = reflect B (impE (monNe τ t) (reify A a))
reify : ∀ A → T⟦ A ⟧ →̇ Nf' A
reify (Atom P) = runNf ∘ mapC ne
reify False = runNf ∘ mapC ⊥-elim
reify (A ∨ B) = runNf ∘ mapC [ orI₁ ∘ reify A , orI₂ ∘ reify B ]
reify True _ = trueI
reify (A ∧ B) (a , b) = andI (reify A a) (reify B b)
reify (A ⇒ B) ⟦f⟧ = impI (reify B (⟦f⟧ (weak id≤) (fresh A)))
---------------------------------------------------------------------------
-- Normalization is completeness (reification) after soundness (evaluation)
module Normalization (covM : CoverMonad) (open CoverMonad covM) where
open Soundness monad
open Completeness covM
-- Identity environment, constructed by reflection.
freshG : ∀ Γ → G⟦ Γ ⟧ Γ
freshG ε = _
freshG (Γ ∙ A) = monG (weak id≤) (freshG Γ) , fresh A
-- A variant (no improvement).
freshG' : ∀ Γ {Δ} (τ : Δ ≤ Γ) → G⟦ Γ ⟧ Δ
freshG' ε τ = _
freshG' (Γ ∙ A) τ = freshG' Γ (τ • weak id≤) , monT A τ (fresh A)
-- Normalization
norm : ∀{A} → Tm A →̇ Nf' A
norm t = reify _ (eval t (freshG _))
---------------------------------------------------------------------------
-- Case tree instance of cover monad
module CaseTree where
data Cover (P : Cxt → Set) (Γ : Cxt) : Set where
returnC : (p : P Γ) → Cover P Γ
falseC : (t : Ne Γ False) → Cover P Γ
orC : ∀{C D} (t : Ne Γ (C ∨ D))
(c : Cover P (Γ ∙ C))
(d : Cover P (Γ ∙ D)) → Cover P Γ
return : ∀{P} (monP : Mon P) → P →̇ Cover P
return monP p = returnC p
-- Syntactic paste.
runNf : ∀{A} → Cover (Nf' A) →̇ Nf' A
runNf (returnC p) = p
runNf (falseC t) = falseE t
runNf (orC t c d) = orE t (runNf c) (runNf d)
-- Weakening covers: A case tree in Γ can be transported to a thinning Δ
-- by weakening all the scrutinees.
monC : ∀{P} → (monP : Mon P) → Mon (Cover P)
monC monP τ (returnC p) = returnC (monP τ p)
monC monP τ (falseC t) = falseC (monNe τ t)
monC monP τ (orC t c d) = orC (monNe τ t) (monC monP (lift τ) c)
(monC monP (lift τ) d)
-- Monad.
mapC : ∀{P Q} → (P →̇ Q) → (Cover P →̇ Cover Q)
mapC f (returnC p) = returnC (f p)
mapC f (falseC t) = falseC t
mapC f (orC t c d) = orC t (mapC f c) (mapC f d)
joinC : ∀{P} → Cover (Cover P) →̇ Cover P
joinC (returnC p) = p
joinC (falseC t) = falseC t
joinC (orC t c d) = orC t (joinC c) (joinC d)
-- Strong functoriality.
mapC' : ∀{P Q Γ} → KFun P Q Γ → Cover P Γ → Cover Q Γ
mapC' f (returnC p) = returnC (f id≤ p)
mapC' f (falseC t) = falseC t
mapC' f (orC t c d) = orC t (mapC' (λ τ → f (τ • weak id≤)) c)
(mapC' (λ τ → f (τ • weak id≤)) d)
caseTreeMonad : CoverMonad
caseTreeMonad = record {monad = record{CaseTree}; CaseTree}
-- A normalization function using case trees.
open Normalization caseTreeMonad using () renaming (norm to normCaseTree)
---------------------------------------------------------------------------
-- Continuation instance of cover monad
module Continuation where
record Cover (P : Cxt → Set) (Γ : Cxt) : Set where
field runNf' : ∀ {A} → ((P ⇒̂ Nf' A) ⇒̂ Nf' A) Γ
open Cover
-- Services.
runNf : ∀{A} → Cover (Nf' A) →̇ Nf' A
runNf {A} {Γ} c = c .runNf' id≤ (λ τ → id)
falseC : ∀{P} → Ne' False →̇ Cover P
falseC t .runNf' τ k = falseE (monNe τ t)
orC : ∀{P Γ C D} (t : Ne Γ (C ∨ D))
(c : Cover P (Γ ∙ C))
(d : Cover P (Γ ∙ D)) → Cover P Γ
orC t c d .runNf' τ k = orE (monNe τ t)
(c .runNf' (lift τ) (λ δ → k (δ • weak id≤)))
(d .runNf' (lift τ) (λ δ → k (δ • weak id≤)))
-- Monad infrastructure.
monC : ∀{P} → (monP : Mon P) → Mon (Cover P)
monC monP τ c .runNf' τ₁ k = c .runNf' (τ₁ • τ) k
mapC' : ∀{P Q} → ⟨ P ⇒̂ Q ⊙ Cover P ⟩→̇ Cover Q
mapC' k c .runNf' τ l = c .runNf' τ λ δ p → l δ (k (δ • τ) p)
mapC : ∀{P Q} → (P →̇ Q) → (Cover P →̇ Cover Q)
mapC f = mapC' λ τ → f
return : ∀{P} (monP : Mon P) → P →̇ Cover P
return monP p .runNf' τ k = k id≤ (monP τ p)
joinC : ∀{P} → Cover (Cover P) →̇ Cover P
joinC c .runNf' τ k = c .runNf' τ λ δ c' → c' .runNf' id≤ λ δ' → k (δ' • δ)
extC : ∀{P Q} → (P →̇ Cover Q) → Cover P →̇ Cover Q
extC f = joinC ∘ mapC f
bindC' : ∀{P Q} → Cover P →̇ (P ⇒̂ Cover Q) ⇒̂ Cover Q
bindC' c τ k .runNf' τ' k' = c .runNf' (τ' • τ) λ σ p → k (σ • τ') p .runNf' id≤ λ σ' → k' (σ' • σ)
continuationMonad : CoverMonad
continuationMonad = record{monad = record{Continuation}; Continuation}
-- A normalization function using continuations.
open Normalization continuationMonad using () renaming (norm to normContinuation)
-- Q.E.D.
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.5053550832,
"avg_line_length": 31.8582677165,
"ext": "agda",
"hexsha": "f752154a0f2214f814702f857f950cc5ffe30d69",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src/NfModelMonad.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/ipl",
"max_issues_repo_path": "src/NfModelMonad.agda",
"max_line_length": 105,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src/NfModelMonad.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 4662,
"size": 12138
} |
module M where
Foo : Set
Foo = Set
| {
"alphanum_fraction": 0.6666666667,
"avg_line_length": 7.2,
"ext": "agda",
"hexsha": "38f9d4f96f9dd63458ff7aece3278612724ada64",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/interaction/Error-in-imported-module/M.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/interaction/Error-in-imported-module/M.agda",
"max_line_length": 14,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/interaction/Error-in-imported-module/M.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 12,
"size": 36
} |
{-# OPTIONS --safe --without-K #-}
module Data.List.Membership.Propositional.Distinct where
open import Data.List using (List)
import Relation.Binary.PropositionalEquality as P
open import Data.List.Membership.Setoid.Distinct as D hiding (Distinct) public
Distinct : ∀ {a} {A : Set a} → List A → Set a
Distinct {A = A} = D.Distinct {S = P.setoid A}
| {
"alphanum_fraction": 0.7231638418,
"avg_line_length": 27.2307692308,
"ext": "agda",
"hexsha": "55f89750df0bc8b1b259185b33a0e39f1f0060a3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "tizmd/agda-distinct-disjoint",
"max_forks_repo_path": "src/Data/List/Membership/Propositional/Distinct.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "tizmd/agda-distinct-disjoint",
"max_issues_repo_path": "src/Data/List/Membership/Propositional/Distinct.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tizmd/agda-distinct-disjoint",
"max_stars_repo_path": "src/Data/List/Membership/Propositional/Distinct.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 96,
"size": 354
} |
module Inst (Gnd : Set)(U : Set)(El : U -> Set) where
open import Basics
open import Pr
open import Nom
import Kind
open Kind Gnd U El
import Cxt
open Cxt Kind
import Loc
open Loc Kind
import Term
open Term Gnd U El
import Shift
open Shift Gnd U El
mutual
winst : {G : Cxt}{C : Kind}{L : Loc}{I : Kind}
(x : L ! I) -> G [ L bar x / Term C ]- I ->
{T : Kind}(t : L [ Term C ]- T) -> [| Good G t |] ->
G [ L bar x / Term C ]- T
winst x i [ s ] sg = G[ winsts x i s sg ]
winst x i (fn A f) fg = Gfn A \ a -> winst x i (f a) (fg a)
winst x i (\\ b) bg = G\\ (winst (pop x) (shift popH i) b bg)
winst x i (h $ s) pg = wing x i h (fst pg) (winsts x i s (snd pg))
winsts : {G : Cxt}{C : Kind}{L : Loc}{Z : Gnd}{I : Kind}
(x : L ! I) -> G [ L bar x / Term C ]- I ->
{T : Kind}(s : L [ Args C Z ]- T) -> [| Good G s |] ->
G [ L bar x / Args C Z ]- T
winsts x i (a ^ s) sg = a G^ winsts x i s sg
winsts x i (r & s) pg = winst x i r (fst pg) G& winsts x i s (snd pg)
winsts x i nil _ = Gnil
wing : {G : Cxt}{C : Kind}{L : Loc}{Z : Gnd}{I : Kind}
(x : L ! I) -> G [ L bar x / Term C ]- I ->
{T : Kind}(h : L [ Head ]- T) -> [| Good G h |] ->
G [ L bar x / Args C Z ]- T ->
G [ L bar x / Term C ]- Ty Z
wing x i (` k) kg s = (` k -! kg) G$ s
wing x i (# y) _ s with varQV x y
wing x i (# .x) _ s | vSame = go i s
wing x i (# .(x thin y)) _ s | vDiff y = (# y -! _) G$ s
go : {G : Cxt}{C : Kind}{L : Loc}{Z : Gnd}{I : Kind} ->
G [ L / Term C ]- I -> G [ L / Args C Z ]- I ->
G [ L / Term C ]- Ty Z
go (fn A f -! fg) ((a ^ s) -! sg) = go (f a -! fg a) (s -! sg)
go (\\ b -! bg) ((r & s) -! pg) =
go (winst top (r -! fst pg) b bg) (s -! snd pg)
go t (nil -! _) = t
inst : {G : Cxt}{C : Kind}{L : Loc}{I : Kind}
(x : L ! I) -> G [ L bar x / Term C ]- I ->
{T : Kind} -> G [ L / Term C ]- T -> G [ L bar x / Term C ]- T
inst x i (t -! tg) = winst x i t tg
_$$_ : {G : Cxt}{C S T : Kind}{L : Loc} ->
G [! C !]- (S |> T) -> G [! C !]- S -> G [! C !]- T
(\\ b -! bg) $$ sg = inst top sg (b -! bg)
| {
"alphanum_fraction": 0.4298085688,
"avg_line_length": 35.3870967742,
"ext": "agda",
"hexsha": "0104418c57da51f56ed00fca68b74699a88f9a08",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "benchmark/Syntacticosmos/Inst.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "benchmark/Syntacticosmos/Inst.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "benchmark/Syntacticosmos/Inst.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 920,
"size": 2194
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.