Search is not available for this dataset
text
string | meta
dict |
---|---|
module Oscar.Data.Proposextensequality where
open import Oscar.Data.Proposequality using (_≡_)
open import Oscar.Level
infix 4 _≡̇_
_≡̇_ : ∀ {a} {A : Set a} {b} {B : A → Set b} → ((x : A) → B x) → ((x : A) → B x) → Set (a ⊔ b)
f ≡̇ g = ∀ x → f x ≡ g x
| {
"alphanum_fraction": 0.5607843137,
"avg_line_length": 25.5,
"ext": "agda",
"hexsha": "133a78b3bbfc5299fca3e1533b9abf4336afeab6",
"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/Proposextensequality.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/Proposextensequality.agda",
"max_line_length": 94,
"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/Proposextensequality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 111,
"size": 255
} |
module _ where
open import Agda.Builtin.List
open import Agda.Builtin.Reflection
macro
easy : Term → TC _
easy t =
bindTC (freshName "A") λ A →
bindTC (declarePostulate (arg (arg-info visible relevant) A)
(agda-sort (lit 0))) λ _ →
unify (def A []) t
B : Set
B = {!easy!}
-- WAS:
-- Parse error
-- ;<ERROR>
-- Example.A...
-- SHOULD: complain that A is not in scope
| {
"alphanum_fraction": 0.587529976,
"avg_line_length": 17.375,
"ext": "agda",
"hexsha": "3d726055f8587bf3862d990841deb3d0a175b90d",
"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/interaction/Issue3316.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/interaction/Issue3316.agda",
"max_line_length": 64,
"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/interaction/Issue3316.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": 122,
"size": 417
} |
-- There was a bug which caused the type checker to forget
-- the name of implicit arguments which weren't used in the
-- return type.
module UnusedNamedImplicits where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- Simple example
f : {n m : Nat} -> Nat
f {m = m} = m
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
data Even : Nat -> Set where
evenZ : Even zero
evenSS : {n : Nat} -> Even n -> Even (suc (suc n))
index : {n : Nat} -> Even n -> Nat
index evenZ = zero
index (evenSS e) = suc (suc (index e))
sameIndex : {n : Nat}(e : Even n) -> index e == n
sameIndex evenZ = refl
sameIndex (evenSS e) with index e | sameIndex e
... | ._ | refl = refl
-- It could also show up when the argument is used in the top level type,
-- but not by the generated type for the with function.
* : {n : Nat}{e : Even n} -> Even (index e)
* {e = e} with index e | sameIndex e
... | ._ | refl = e
| {
"alphanum_fraction": 0.6093073593,
"avg_line_length": 24.972972973,
"ext": "agda",
"hexsha": "75d512df6743360b06b7d78742ee77eb09d545fc",
"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": "4383a3d20328a6c43689161496cee8eb479aca08",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dagit/agda",
"max_forks_repo_path": "test/succeed/UnusedNamedImplicits.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08",
"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": "dagit/agda",
"max_issues_repo_path": "test/succeed/UnusedNamedImplicits.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": "test/succeed/UnusedNamedImplicits.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z",
"num_tokens": 300,
"size": 924
} |
-- Andreas, 2018-10-27, issue #3323, reported by Guillaume Brunerie
--
-- Mismatches between original and repeated parameter list
-- should not lead to internal errors.
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
record R ..(b : Bool) : Set
record R .b where -- Cannot change relevance
field foo : Bool
-- Should fail.
| {
"alphanum_fraction": 0.7362318841,
"avg_line_length": 24.6428571429,
"ext": "agda",
"hexsha": "e770d29dd3ef9aa264a81b0f9872aee59e935c69",
"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/Issue3323r.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/Issue3323r.agda",
"max_line_length": 67,
"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/Issue3323r.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": 92,
"size": 345
} |
------------------------------------------------------------------------
-- Bag equivalence for lists
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Bag-equivalence
{c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where
open Derived-definitions-and-properties eq hiding (trans)
open import Logical-equivalence using (_⇔_)
open import Prelude as P hiding (id; swap)
open import Bijection eq using (_↔_; module _↔_; Σ-≡,≡↔≡)
open import Equality.Decision-procedures eq
open import Fin eq as Finite
open import Function-universe eq as Function-universe
hiding (_∘_; Kind; module Kind; bijection)
open import H-level eq
open import H-level.Closure eq
open import Injection eq using (_↣_)
open import List eq
open import Monad eq hiding (map)
open import Nat eq hiding (_≟_)
private
variable
a ℓ p q : Level
A B : Type a
P Q : A → Type p
x y z : A
xs xs₁ xs₂ ys ys₁ ys₂ zs : List A
xss yss : List (List A)
k : Function-universe.Kind
m n : ℕ
------------------------------------------------------------------------
-- Any
-- Any.
Any : (A → Type p) → List A → Type p
Any P [] = ⊥
Any P (x ∷ xs) = P x ⊎ Any P xs
-- Alternative definition of Any.
data Any′ {A : Type a} (P : A → Type p) : List A → Type (a ⊔ p) where
here : ∀ {x xs} → P x → Any′ P (x ∷ xs)
there : ∀ {x xs} → Any′ P xs → Any′ P (x ∷ xs)
-- The two definitions of Any are isomorphic.
Any′-[] : Any′ P [] ↔ ⊥ {ℓ = ℓ}
Any′-[] = record
{ surjection = record
{ logical-equivalence = record
{ from = λ ()
; to = λ ()
}
; right-inverse-of = λ ()
}
; left-inverse-of = λ ()
}
Any′-∷ : Any′ P (x ∷ xs) ↔ P x ⊎ Any′ P xs
Any′-∷ = record
{ surjection = record
{ logical-equivalence = record
{ from = [ here , there ]
; to = λ where
(here p) → inj₁ p
(there p) → inj₂ p
}
; right-inverse-of = [ (λ _ → refl _) , (λ _ → refl _) ]
}
; left-inverse-of = λ where
(here _) → refl _
(there _) → refl _
}
Any↔Any′ : Any P xs ↔ Any′ P xs
Any↔Any′ {P = P} {xs = []} =
⊥ ↔⟨ inverse Any′-[] ⟩
Any′ P [] □
Any↔Any′ {P = P} {xs = x ∷ xs} =
P x ⊎ Any P xs ↔⟨ id ⊎-cong Any↔Any′ {P = P} ⟩
P x ⊎ Any′ P xs ↔⟨ inverse Any′-∷ ⟩
Any′ P (x ∷ xs) □
------------------------------------------------------------------------
-- Lemmas relating Any to some basic list functions
Any-++ : (P : A → Type p) (xs ys : List A) →
Any P (xs ++ ys) ↔ Any P xs ⊎ Any P ys
Any-++ P [] ys =
Any P ys ↔⟨ inverse ⊎-left-identity ⟩
⊥ ⊎ Any P ys □
Any-++ P (x ∷ xs) ys =
P x ⊎ Any P (xs ++ ys) ↔⟨ id ⊎-cong Any-++ P xs ys ⟩
P x ⊎ (Any P xs ⊎ Any P ys) ↔⟨ ⊎-assoc ⟩
(P x ⊎ Any P xs) ⊎ Any P ys □
Any-concat : (P : A → Type p) (xss : List (List A)) →
Any P (concat xss) ↔ Any (Any P) xss
Any-concat P [] = id
Any-concat P (xs ∷ xss) =
Any P (xs ++ concat xss) ↔⟨ Any-++ P xs (concat xss) ⟩
Any P xs ⊎ Any P (concat xss) ↔⟨ id ⊎-cong Any-concat P xss ⟩
Any P xs ⊎ Any (Any P) xss □
Any-map : (P : B → Type p) (f : A → B) (xs : List A) →
Any P (map f xs) ↔ Any (P ∘ f) xs
Any-map P f [] = id
Any-map P f (x ∷ xs) =
P (f x) ⊎ Any P (map f xs) ↔⟨ id ⊎-cong Any-map P f xs ⟩
(P ∘ f) x ⊎ Any (P ∘ f) xs □
Any->>= : {A B : Type ℓ}
(P : B → Type p) (xs : List A) (f : A → List B) →
Any P (xs >>= f) ↔ Any (Any P ∘ f) xs
Any->>= P xs f =
Any P (concat (map f xs)) ↔⟨ Any-concat P (map f xs) ⟩
Any (Any P) (map f xs) ↔⟨ Any-map (Any P) f xs ⟩
Any (Any P ∘ f) xs □
Any-filter : (P : A → Type p) (p : A → Bool) (xs : List A) →
Any P (filter p xs) ↔ Any (λ x → P x × T (p x)) xs
Any-filter P p [] = ⊥ □
Any-filter P p (x ∷ xs) with p x
... | true =
P x ⊎ Any P (filter p xs) ↔⟨ inverse ×-right-identity ⊎-cong Any-filter P p xs ⟩
(P x × ⊤) ⊎ Any (λ x → P x × T (p x)) xs □
... | false =
Any P (filter p xs) ↔⟨ Any-filter P p xs ⟩
Any (λ x → P x × T (p x)) xs ↔⟨ inverse ⊎-left-identity ⟩
⊥₀ ⊎ Any (λ x → P x × T (p x)) xs ↔⟨ inverse ×-right-zero ⊎-cong (_ □) ⟩
(P x × ⊥) ⊎ Any (λ x → P x × T (p x)) xs □
------------------------------------------------------------------------
-- List membership
infix 4 _∈_
_∈_ : A → List A → Type _
x ∈ xs = Any (λ y → x ≡ y) xs
-- Any can be expressed using _∈_.
Any-∈ : (P : A → Type p) (xs : List A) →
Any P xs ↔ ∃ λ x → P x × x ∈ xs
Any-∈ P [] =
⊥ ↔⟨ inverse ×-right-zero ⟩
(∃ λ x → ⊥₀) ↔⟨ ∃-cong (λ x → inverse ×-right-zero) ⟩
(∃ λ x → P x × ⊥) □
Any-∈ P (x ∷ xs) =
P x ⊎ Any P xs ↔⟨ ∃-intro P x ⊎-cong Any-∈ P xs ⟩
(∃ λ y → P y × y ≡ x) ⊎ (∃ λ y → P y × y ∈ xs) ↔⟨ inverse ∃-⊎-distrib-left ⟩
(∃ λ y → P y × y ≡ x ⊎ P y × y ∈ xs) ↔⟨ ∃-cong (λ y → inverse ×-⊎-distrib-left) ⟩
(∃ λ y → P y × (y ≡ x ⊎ y ∈ xs)) □
-- Using this property we can prove that Any and _⊎_ commute.
Any-⊎ : (P : A → Type p) (Q : A → Type q) (xs : List A) →
Any (λ x → P x ⊎ Q x) xs ↔ Any P xs ⊎ Any Q xs
Any-⊎ P Q xs =
Any (λ x → P x ⊎ Q x) xs ↔⟨ Any-∈ (λ x → P x ⊎ Q x) xs ⟩
(∃ λ x → (P x ⊎ Q x) × x ∈ xs) ↔⟨ ∃-cong (λ x → ×-⊎-distrib-right) ⟩
(∃ λ x → P x × x ∈ xs ⊎ Q x × x ∈ xs) ↔⟨ ∃-⊎-distrib-left ⟩
(∃ λ x → P x × x ∈ xs) ⊎ (∃ λ x → Q x × x ∈ xs) ↔⟨ inverse $ Any-∈ P xs ⊎-cong Any-∈ Q xs ⟩
Any P xs ⊎ Any Q xs □
------------------------------------------------------------------------
-- Some lemmas related to list membership
-- If f and g are pointwise equal for elements in xs, then map f xs
-- and map g xs are equal.
map-cong-∈ :
(f g : A → B) (xs : List A) →
(∀ {x} → x ∈ xs → f x ≡ g x) →
map f xs ≡ map g xs
map-cong-∈ p q [] p≡q = refl _
map-cong-∈ p q (x ∷ xs) p≡q =
cong₂ _∷_ (p≡q (inj₁ (refl _))) (map-cong-∈ p q xs (p≡q ∘ inj₂))
-- If p and q are pointwise equal for elements in xs, then filter p xs
-- and filter q xs are equal.
filter-cong-∈ :
(p q : A → Bool) (xs : List A) →
(∀ {x} → x ∈ xs → p x ≡ q x) →
filter p xs ≡ filter q xs
filter-cong-∈ p q [] p≡q = refl _
filter-cong-∈ p q (x ∷ xs) p≡q
with p x | q x | p≡q (inj₁ (refl _))
| filter-cong-∈ p q xs (p≡q ∘ inj₂)
... | true | true | _ | ih = cong (x ∷_) ih
... | false | false | _ | ih = ih
... | true | false | t≡f | _ = ⊥-elim $ Bool.true≢false t≡f
... | false | true | f≡t | _ = ⊥-elim $ Bool.true≢false $ sym f≡t
-- The ordering of natural numbers can be related to list membership
-- and nats-<.
<-↔-∈-nats-< : m < n ↔ m ∈ nats-< n
<-↔-∈-nats-< {m = m} {n = zero} =
m < zero ↝⟨ <zero↔ ⟩
⊥ ↔⟨⟩
m ∈ nats-< zero □
<-↔-∈-nats-< {m = m} {n = suc n} =
m < suc n ↔⟨⟩
suc m ≤ suc n ↝⟨ suc≤suc↔ ⟩
m ≤ n ↝⟨ ≤↔<⊎≡ ⟩
m < n ⊎ m ≡ n ↝⟨ ⊎-comm ⟩
m ≡ n ⊎ m < n ↝⟨ Function-universe.id ⊎-cong <-↔-∈-nats-< ⟩
m ≡ n ⊎ m ∈ nats-< n ↔⟨⟩
m ∈ nats-< (suc n) □
------------------------------------------------------------------------
-- Bag and set equivalence and the subset and subbag orders
-- Various kinds of relatedness.
--
-- NOTE: Perhaps it would be better to define the subbag property in
-- terms of embeddings, rather than injections. The HoTT book (first
-- edition) claims that injectivity "is an ill-behaved notion for
-- non-sets".
open Function-universe public using (Kind) hiding (module Kind)
module Kind where
open Function-universe public
using ()
renaming ( implication to subset
; logical-equivalence to set
; injection to subbag
; bijection to bag
; equivalence to bag-with-equivalence
; equivalenceᴱ to bag-with-equivalenceᴱ
)
open Kind public
-- A general definition of "relatedness" for lists.
infix 4 _∼[_]_
_∼[_]_ : {A : Type a} → List A → Kind → List A → Type a
xs ∼[ k ] ys = ∀ z → z ∈ xs ↝[ k ] z ∈ ys
-- Bag equivalence.
infix 4 _≈-bag_
_≈-bag_ : {A : Type a} → List A → List A → Type a
xs ≈-bag ys = xs ∼[ bag ] ys
-- Alternative definition of bag equivalence.
infix 4 _≈-bag′_
record _≈-bag′_ {A : Type a} (xs ys : List A) : Type a where
field
bijection : Fin (length xs) ↔ Fin (length ys)
related : xs And ys Are-related-by bijection
-- Yet another definition of bag equivalence. This definition is taken
-- from Coq's standard library.
infixr 5 _∷_
infix 4 _≈-bag″_
data _≈-bag″_ {A : Type a} : List A → List A → Type a where
[] : [] ≈-bag″ []
_∷_ : ∀ x {xs ys} (xs≈ys : xs ≈-bag″ ys) → x ∷ xs ≈-bag″ x ∷ ys
swap : ∀ {x y xs} → x ∷ y ∷ xs ≈-bag″ y ∷ x ∷ xs
trans : ∀ {xs ys zs}
(xs≈ys : xs ≈-bag″ ys) (ys≈zs : ys ≈-bag″ zs) → xs ≈-bag″ zs
------------------------------------------------------------------------
-- Some congruence lemmas
Any-cong : (∀ x → P x ↝[ k ] Q x) → xs ∼[ k ] ys →
Any P xs ↝[ k ] Any Q ys
Any-cong {P = P} {Q = Q} {xs = xs} {ys = ys} P↔Q xs≈ys =
Any P xs ↔⟨ Any-∈ P xs ⟩
(∃ λ z → P z × z ∈ xs) ↝⟨ ∃-cong (λ z → P↔Q z ×-cong xs≈ys z) ⟩
(∃ λ z → Q z × z ∈ ys) ↔⟨ inverse (Any-∈ Q ys) ⟩
Any Q ys □
++-cong : xs₁ ∼[ k ] ys₁ → xs₂ ∼[ k ] ys₂ →
xs₁ ++ xs₂ ∼[ k ] ys₁ ++ ys₂
++-cong {xs₁ = xs₁} {ys₁ = ys₁} {xs₂ = xs₂} {ys₂ = ys₂}
xs₁∼ys₁ xs₂∼ys₂ = λ z →
z ∈ xs₁ ++ xs₂ ↔⟨ Any-++ _ xs₁ xs₂ ⟩
z ∈ xs₁ ⊎ z ∈ xs₂ ↝⟨ xs₁∼ys₁ z ⊎-cong xs₂∼ys₂ z ⟩
z ∈ ys₁ ⊎ z ∈ ys₂ ↔⟨ inverse (Any-++ _ ys₁ ys₂) ⟩
z ∈ ys₁ ++ ys₂ □
map-cong : (f : A → B) → xs ∼[ k ] ys → map f xs ∼[ k ] map f ys
map-cong {xs = xs} {ys = ys} f xs∼ys = λ z →
z ∈ map f xs ↔⟨ Any-map _ f xs ⟩
Any (λ x → z ≡ f x) xs ↝⟨ Any-cong (λ x → z ≡ f x □) xs∼ys ⟩
Any (λ x → z ≡ f x) ys ↔⟨ inverse (Any-map _ f ys) ⟩
z ∈ map f ys □
concat-cong : xss ∼[ k ] yss → concat xss ∼[ k ] concat yss
concat-cong {xss = xss} {yss = yss} xss∼yss = λ z →
z ∈ concat xss ↔⟨ Any-concat _ xss ⟩
Any (λ zs → z ∈ zs) xss ↝⟨ Any-cong (λ zs → z ∈ zs □) xss∼yss ⟩
Any (λ zs → z ∈ zs) yss ↔⟨ inverse (Any-concat _ yss) ⟩
z ∈ concat yss □
>>=-cong : {A B : Type ℓ} {xs ys : List A} {f g : A → List B} →
xs ∼[ k ] ys → (∀ x → f x ∼[ k ] g x) →
(xs >>= f) ∼[ k ] (ys >>= g)
>>=-cong {xs = xs} {ys = ys} {f = f} {g = g} xs∼ys f∼g = λ z →
z ∈ xs >>= f ↔⟨ Any->>= _ xs f ⟩
Any (λ x → z ∈ f x) xs ↝⟨ Any-cong (λ x → f∼g x z) xs∼ys ⟩
Any (λ x → z ∈ g x) ys ↔⟨ inverse (Any->>= _ ys g) ⟩
z ∈ ys >>= g □
filter-cong : (p : A → Bool) (xs ys : List A) →
xs ∼[ k ] ys → filter p xs ∼[ k ] filter p ys
filter-cong p xs ys xs∼ys = λ z →
z ∈ filter p xs ↔⟨ Any-filter _ p xs ⟩
Any (λ x → z ≡ x × T (p x)) xs ↝⟨ Any-cong (λ _ → _ □) xs∼ys ⟩
Any (λ x → z ≡ x × T (p x)) ys ↔⟨ inverse (Any-filter _ p ys) ⟩
z ∈ filter p ys □
------------------------------------------------------------------------
-- More properties
-- Any preserves decidability of equality.
module Dec (dec : ∀ {x} → Decidable-equality (P x)) where
infix 4 _≟_
_≟_ : Decidable-equality (Any P xs)
_≟_ {xs = _ ∷ _} = ⊎.Dec._≟_ dec _≟_
-- If the type of x is a set, then equality is decidable for x ∈ xs.
module Dec-∈ (A-set : Is-set A) where
infix 4 _≟_
_≟_ : ∀ {x xs} → Decidable-equality (x ∈ xs)
_≟_ = Dec._≟_ λ _ _ → yes (A-set _ _)
-- Bind distributes from the left over append.
>>=-left-distributive :
{A B : Type ℓ} (xs : List A) (f g : A → List B) →
xs >>= (λ x → f x ++ g x) ≈-bag (xs >>= f) ++ (xs >>= g)
>>=-left-distributive xs f g = λ z →
z ∈ xs >>= (λ x → f x ++ g x) ↔⟨ Any->>= (_≡_ z) xs (λ x → f x ++ g x) ⟩
Any (λ x → z ∈ f x ++ g x) xs ↔⟨ Any-cong (λ x → Any-++ (_≡_ z) (f x) (g x)) (λ _ → id) ⟩
Any (λ x → z ∈ f x ⊎ z ∈ g x) xs ↔⟨ Any-⊎ (λ x → z ∈ f x) (λ x → z ∈ g x) xs ⟩
Any (λ x → z ∈ f x) xs ⊎ Any (λ x → z ∈ g x) xs ↔⟨ inverse (Any->>= (_≡_ z) xs f ⊎-cong Any->>= (_≡_ z) xs g) ⟩
z ∈ xs >>= f ⊎ z ∈ xs >>= g ↔⟨ inverse (Any-++ (_≡_ z) (xs >>= f) (xs >>= g)) ⟩
z ∈ (xs >>= f) ++ (xs >>= g) □
-- This property does not hold for ordinary list equality.
¬->>=-left-distributive :
¬ ({A B : Type} (xs : List A) (f g : A → List B) →
xs >>= (λ x → f x ++ g x) ≡ (xs >>= f) ++ (xs >>= g))
¬->>=-left-distributive distrib = Bool.true≢false true≡false
where
tf = true ∷ false ∷ []
f = λ x → x ∷ []
g = f
ttff≡tftf : true ∷ true ∷ false ∷ false ∷ [] ≡
true ∷ false ∷ true ∷ false ∷ []
ttff≡tftf = distrib tf f g
true≡false : true ≡ false
true≡false = List.cancel-∷-head (List.cancel-∷-tail ttff≡tftf)
-- _++_ is commutative.
++-comm : (xs ys : List A) → xs ++ ys ≈-bag ys ++ xs
++-comm xs ys = λ z →
z ∈ xs ++ ys ↔⟨ Any-++ (_≡_ z) xs ys ⟩
z ∈ xs ⊎ z ∈ ys ↔⟨ ⊎-comm ⟩
z ∈ ys ⊎ z ∈ xs ↔⟨ inverse (Any-++ (_≡_ z) ys xs) ⟩
z ∈ ys ++ xs □
-- _++_ is idempotent (when set equivalence is used).
++-idempotent : (xs : List A) → xs ++ xs ∼[ set ] xs
++-idempotent xs = λ z →
z ∈ xs ++ xs ↔⟨ Any-++ (_≡_ z) xs xs ⟩
z ∈ xs ⊎ z ∈ xs ↝⟨ ⊎-idempotent ⟩
z ∈ xs □
-- The so-called "range splitting" property (see, for instance,
-- Hoogendijks "(Relational) Programming Laws in the Boom Hierarchy of
-- Types").
range-splitting : (p : A → Bool) (xs : List A) →
filter p xs ++ filter (not ∘ p) xs ≈-bag xs
range-splitting p xs = λ z →
z ∈ filter p xs ++ filter (not ∘ p) xs ↔⟨ Any-++ _ _ (filter (not ∘ p) xs) ⟩
z ∈ filter p xs ⊎ z ∈ filter (not ∘ p) xs ↔⟨ Any-filter _ p xs ⊎-cong Any-filter _ (not ∘ p) xs ⟩
Any (λ x → z ≡ x × T (p x)) xs ⊎
Any (λ x → z ≡ x × T (not (p x))) xs ↔⟨ inverse $ Any-⊎ _ _ xs ⟩
Any (λ x → z ≡ x × T (p x) ⊎ z ≡ x × T (not (p x))) xs ↔⟨ Any-cong (λ x → lemma (z ≡ x) (p x)) (λ x → x ∈ xs □) ⟩
z ∈ xs □
where
lemma : ∀ {a} (A : Type a) (b : Bool) → A × T b ⊎ A × T (not b) ↔ A
lemma A b =
A × T b ⊎ A × T (not b) ↔⟨ ×-comm ⊎-cong ×-comm ⟩
T b × A ⊎ T (not b) × A ↔⟨ if-lemma (λ _ → A) id id b ⟩
A □
-- The so-called "range disjunction" property, strengthened to use the
-- subbag preorder instead of set equivalence.
range-disjunction :
(p q : A → Bool) (xs : List A) →
filter (λ x → p x ∨ q x) xs ∼[ subbag ]
filter p xs ++ filter q xs
range-disjunction p q xs = λ z →
z ∈ filter (λ x → p x ∨ q x) xs ↔⟨ Any-filter _ (λ x → p x ∨ q x) _ ⟩
Any (λ x → z ≡ x × T (p x ∨ q x)) xs ↝⟨ Any-cong (λ x → lemma (z ≡ x) (p x) (q x)) (λ x → x ∈ xs □) ⟩
Any (λ x → z ≡ x × T (p x) ⊎ z ≡ x × T (q x)) xs ↔⟨ Any-⊎ _ _ _ ⟩
Any (λ x → z ≡ x × T (p x)) xs ⊎ Any (λ x → z ≡ x × T (q x)) xs ↔⟨ inverse (Any-filter _ p _ ⊎-cong Any-filter _ q _) ⟩
z ∈ filter p xs ⊎ z ∈ filter q xs ↔⟨ inverse $ Any-++ _ _ _ ⟩
z ∈ filter p xs ++ filter q xs □
where
inj : (b₁ b₂ : Bool) → T (b₁ ∨ b₂) ↣ T b₁ ⊎ T b₂
inj true true = record { to = inj₁; injective = λ _ → refl _ }
inj true false = record { to = inj₁; injective = ⊎.cancel-inj₁ }
inj false true = record { to = inj₂; injective = ⊎.cancel-inj₂ }
inj false false = record { to = λ (); injective = λ {} }
lemma : ∀ {a} (A : Type a) (b₁ b₂ : Bool) →
A × T (b₁ ∨ b₂) ↣ A × T b₁ ⊎ A × T b₂
lemma A b₁ b₂ =
A × T (b₁ ∨ b₂) ↝⟨ id ×-cong inj b₁ b₂ ⟩
A × (T b₁ ⊎ T b₂) ↔⟨ ×-⊎-distrib-left ⟩
A × T b₁ ⊎ A × T b₂ □
------------------------------------------------------------------------
-- The first two definitions of bag equivalence above are logically
-- equivalent
-- One direction follows from the following lemma, which states that
-- list membership can be expressed as "there is an index which points
-- to the element".
--
-- As an aside, note that the right-hand side is almost
-- index xs ⁻¹ z.
∈-index : (xs : List A) → z ∈ xs ↔ ∃ λ i → z ≡ index xs i
∈-index {z = z} [] =
⊥ ↔⟨ inverse $ ∃-Fin-zero _ ⟩
(∃ λ (i : ⊥) → z ≡ index [] i) □
∈-index {z = z} (x ∷ xs) =
z ≡ x ⊎ z ∈ xs ↔⟨ id ⊎-cong ∈-index xs ⟩
z ≡ x ⊎ (∃ λ i → z ≡ index xs i) ↔⟨ inverse $ ∃-Fin-suc _ ⟩
(∃ λ i → z ≡ index (x ∷ xs) i) □
-- The index which points to the element.
index-of : z ∈ xs → Fin (length xs)
index-of = proj₁ ∘ _↔_.to (∈-index _)
-- For the other direction a sequence of lemmas is used.
-- The first lemma states that ∃ λ z → z ∈ xs is isomorphic to Fin n,
-- where n is the length of xs. Thierry Coquand pointed out that this
-- is a generalisation of singleton-contractible.
Fin-length : (xs : List A) → (∃ λ z → z ∈ xs) ↔ Fin (length xs)
Fin-length xs =
(∃ λ z → z ∈ xs) ↔⟨ ∃-cong (λ _ → ∈-index xs) ⟩
(∃ λ z → ∃ λ i → z ≡ index xs i) ↔⟨ ∃-comm ⟩
(∃ λ i → ∃ λ z → z ≡ index xs i) ↔⟨⟩
(∃ λ i → Singleton (index xs i)) ↔⟨ ∃-cong (λ _ → _⇔_.to contractible⇔↔⊤ (singleton-contractible _)) ⟩
Fin (length xs) × ⊤ ↔⟨ ×-right-identity ⟩
Fin (length xs) □
-- From this lemma we get that lists which are bag equivalent have
-- related lengths.
Fin-length-cong : xs ≈-bag ys → Fin (length xs) ↔ Fin (length ys)
Fin-length-cong {xs = xs} {ys = ys} xs≈ys =
Fin (length xs) ↔⟨ inverse $ Fin-length xs ⟩
∃ (λ z → z ∈ xs) ↔⟨ ∃-cong xs≈ys ⟩
∃ (λ z → z ∈ ys) ↔⟨ Fin-length ys ⟩
Fin (length ys) □
abstract
-- In fact, they have equal lengths.
length-cong : xs ≈-bag ys → length xs ≡ length ys
length-cong = _⇔_.to Finite.isomorphic-same-size ∘ Fin-length-cong
-- All that remains (except for some bookkeeping) is to show that
-- the isomorphism which Fin-length-cong returns relates the two
-- lists.
Fin-length-cong-relates :
{xs ys : List A} (xs≈ys : xs ≈-bag ys) →
xs And ys Are-related-by Fin-length-cong xs≈ys
Fin-length-cong-relates {xs = xs} {ys = ys} xs≈ys i =
index xs i ≡⟨ proj₂ $ to (∈-index _) $ to (xs≈ys _) (from (∈-index _) (i , refl _)) ⟩
index ys (proj₁ $ to (∈-index _) $
to (xs≈ys _) $
from (∈-index _) (i , refl _)) ≡⟨⟩
index ys (to (Fin-length-cong xs≈ys) i) ∎
where open _↔_
-- We get that the two definitions of bag equivalence are logically
-- equivalent.
≈⇔≈′ : xs ≈-bag ys ⇔ xs ≈-bag′ ys
≈⇔≈′ = record
{ to = λ xs≈ys → record
{ bijection = Fin-length-cong xs≈ys
; related = Fin-length-cong-relates xs≈ys
}
; from = from
}
where
equality-lemma : y ≡ z → (x ≡ y) ↔ (x ≡ z)
equality-lemma = flip-trans-isomorphism
from : xs ≈-bag′ ys → xs ≈-bag ys
from {xs = xs} {ys = ys} xs≈ys z =
z ∈ xs ↔⟨ ∈-index xs ⟩
∃ (λ i → z ≡ index xs i) ↔⟨ Σ-cong (_≈-bag′_.bijection xs≈ys)
(λ i → equality-lemma $
_≈-bag′_.related xs≈ys i) ⟩
∃ (λ i → z ≡ index ys i) ↔⟨ inverse (∈-index ys) ⟩
z ∈ ys □
------------------------------------------------------------------------
-- Left cancellation
-- We have basically already showed that cons is left cancellative for
-- the (first) alternative definition of bag equivalence.
∷-left-cancellative′ : ∀ xs ys → x ∷ xs ≈-bag′ x ∷ ys → xs ≈-bag′ ys
∷-left-cancellative′ {x = x} xs ys x∷xs≈x∷ys = record
{ bijection = Finite.cancel-suc (_≈-bag′_.bijection x∷xs≈x∷ys)
; related = Finite.cancel-suc-preserves-relatedness x xs ys
(_≈-bag′_.bijection x∷xs≈x∷ys)
(_≈-bag′_.related x∷xs≈x∷ys)
}
-- By the equivalence above we get the result also for the first
-- definition of bag equivalence, but we can show this directly, with
-- the help of some lemmas.
abstract
-- The index-of function commutes with applications of certain
-- inverses. Note that the last three equational reasoning steps do
-- not need to be written out; I included them in an attempt to make
-- it easier to understand why the lemma holds.
index-of-commutes :
{xs ys : List A} (xs≈ys : xs ≈-bag ys) (p : z ∈ xs) →
index-of (_↔_.to (xs≈ys z) p) ≡
_↔_.to (Fin-length-cong xs≈ys) (index-of p)
index-of-commutes {z = z} {xs = xs} {ys = ys} xs≈ys p =
index-of $ to (xs≈ys z) p ≡⟨⟩
index-of $ proj₂ $ Σ-map P.id (λ {x} → to (xs≈ys x)) (z , p) ≡⟨ cong (index-of ∘ proj₂ ∘ Σ-map P.id (to (xs≈ys _))) $ sym $
left-inverse-of (Fin-length xs) (z , p) ⟩
index-of $ proj₂ $ Σ-map P.id (λ {x} → to (xs≈ys x)) $
from (Fin-length xs) $ to (Fin-length xs) (z , p) ≡⟨⟩
to (Fin-length ys) $ Σ-map P.id (λ {x} → to (xs≈ys x)) $
from (Fin-length xs) $ index-of p ≡⟨⟩
to (Fin-length-cong xs≈ys) $ index-of p ∎
where
open _↔_
-- Bag equivalence isomorphisms preserve index equality. Note that
-- this means that, even if the underlying equality is proof
-- relevant, a bag equivalence isomorphism cannot map two distinct
-- proofs, that point to the same position, to different positions.
index-equality-preserved :
{xs ys : List A} {p q : z ∈ xs}
(xs≈ys : xs ≈-bag ys) →
index-of p ≡ index-of q →
index-of (_↔_.to (xs≈ys z) p) ≡ index-of (_↔_.to (xs≈ys z) q)
index-equality-preserved {z = z} {p = p} {q = q} xs≈ys eq =
index-of (_↔_.to (xs≈ys z) p) ≡⟨ index-of-commutes xs≈ys p ⟩
_↔_.to (Fin-length-cong xs≈ys) (index-of p) ≡⟨ cong (_↔_.to (Fin-length-cong xs≈ys)) eq ⟩
_↔_.to (Fin-length-cong xs≈ys) (index-of q) ≡⟨ sym $ index-of-commutes xs≈ys q ⟩∎
index-of (_↔_.to (xs≈ys z) q) ∎
-- If x ∷ xs is bag equivalent to x ∷ ys, then xs and ys are bag
-- equivalent.
∷-left-cancellative : x ∷ xs ≈-bag x ∷ ys → xs ≈-bag ys
∷-left-cancellative {x = x} x∷xs≈x∷ys z =
⊎-left-cancellative
(x∷xs≈x∷ys z)
(lemma x∷xs≈x∷ys)
(lemma (inverse ∘ x∷xs≈x∷ys))
where
abstract
-- If the equality type is proof irrelevant (so that p and q are
-- equal), then this lemma can be proved without the help of
-- index-equality-preserved.
lemma : (inv : x ∷ xs ≈-bag x ∷ ys) →
Well-behaved (_↔_.to (inv z))
lemma {xs = xs} inv {b = z∈xs} {a = p} {a′ = q} hyp₁ hyp₂ =
⊎.inj₁≢inj₂ (
fzero ≡⟨⟩
index-of {xs = x ∷ xs} (inj₁ p) ≡⟨ cong index-of $ sym $ to-from hyp₂ ⟩
index-of {xs = x ∷ xs} (from (inj₁ q)) ≡⟨ index-equality-preserved (inverse ∘ inv) (refl _) ⟩
index-of {xs = x ∷ xs} (from (inj₁ p)) ≡⟨ cong index-of $ to-from hyp₁ ⟩
index-of {xs = x ∷ xs} (inj₂ z∈xs) ≡⟨⟩
fsuc (index-of {xs = xs} z∈xs) ∎)
where open _↔_ (inv z)
-- Cons is not left cancellative for set equivalence.
∷-not-left-cancellative :
¬ (∀ {A : Type} {x : A} {xs ys} →
x ∷ xs ∼[ set ] x ∷ ys → xs ∼[ set ] ys)
∷-not-left-cancellative cancel =
_⇔_.to (cancel (++-idempotent (tt ∷ [])) tt) (inj₁ (refl _))
-- _++_ is left and right cancellative (for bag equivalence).
++-left-cancellative :
∀ xs → xs ++ ys ≈-bag xs ++ zs → ys ≈-bag zs
++-left-cancellative [] eq = eq
++-left-cancellative (x ∷ xs) eq =
++-left-cancellative xs (∷-left-cancellative eq)
++-right-cancellative : xs ++ zs ≈-bag ys ++ zs → xs ≈-bag ys
++-right-cancellative {xs = xs} {zs = zs} {ys = ys} eq =
++-left-cancellative zs (λ z →
z ∈ zs ++ xs ↔⟨ ++-comm zs xs z ⟩
z ∈ xs ++ zs ↔⟨ eq z ⟩
z ∈ ys ++ zs ↔⟨ ++-comm ys zs z ⟩
z ∈ zs ++ ys □)
------------------------------------------------------------------------
-- The third definition of bag equivalence is sound with respect to
-- the other two
-- _∷_ preserves _∼[ k ]_.
infixr 5 _∷-cong_
_∷-cong_ : x ≡ y → xs ∼[ k ] ys → x ∷ xs ∼[ k ] y ∷ ys
_∷-cong_ {x = x} {y = y} {xs = xs} {ys = ys} x≡y xs≈ys = λ z →
z ≡ x ⊎ z ∈ xs ↝⟨ from-bijection (flip-trans-isomorphism x≡y) ⊎-cong xs≈ys z ⟩□
z ≡ y ⊎ z ∈ ys □
-- We can swap the first two elements of a list.
swap-first-two : x ∷ y ∷ xs ≈-bag y ∷ x ∷ xs
swap-first-two {x = x} {y = y} {xs = xs} = λ z →
z ≡ x ⊎ z ≡ y ⊎ z ∈ xs ↔⟨ ⊎-assoc ⟩
(z ≡ x ⊎ z ≡ y) ⊎ z ∈ xs ↔⟨ ⊎-comm ⊎-cong id ⟩
(z ≡ y ⊎ z ≡ x) ⊎ z ∈ xs ↔⟨ inverse ⊎-assoc ⟩
z ≡ y ⊎ z ≡ x ⊎ z ∈ xs □
-- The third definition of bag equivalence is sound with respect to
-- the first one.
≈″⇒≈ : xs ≈-bag″ ys → xs ≈-bag ys
≈″⇒≈ [] = λ _ → id
≈″⇒≈ (x ∷ xs≈ys) = refl _ ∷-cong ≈″⇒≈ xs≈ys
≈″⇒≈ swap = swap-first-two
≈″⇒≈ (trans xs≈ys ys≈zs) = λ z → _ ↔⟨ ≈″⇒≈ xs≈ys z ⟩ ≈″⇒≈ ys≈zs z
-- The other direction should also be provable, but I expect that this
-- requires some work.
| {
"alphanum_fraction": 0.4748243789,
"avg_line_length": 36.7161383285,
"ext": "agda",
"hexsha": "c84cc6eeb172ff4f4555b1686edd079035b904d8",
"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/Bag-equivalence.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/Bag-equivalence.agda",
"max_line_length": 131,
"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/Bag-equivalence.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": 9965,
"size": 25481
} |
module Numeric.Nat.Prime.Properties where
open import Prelude
open import Control.WellFounded
open import Numeric.Nat.Properties
open import Numeric.Nat.Divide
open import Numeric.Nat.Divide.Properties
open import Numeric.Nat.GCD
open import Numeric.Nat.GCD.Extended
open import Numeric.Nat.GCD.Properties
open import Numeric.Nat.Prime
open import Tactic.Nat
prime-nonzero : ∀ {p} → Prime p → NonZero p
prime-nonzero {0} (prime p>1 _) = refute p>1
prime-nonzero {suc _} _ = _
prime-coprime/divide : ∀ p a → Prime p → Either (Coprime p a) (p Divides a)
prime-coprime/divide p a (prime _ isp) with gcd p a
prime-coprime/divide p a (prime _ isp) | gcd-res d isGCD =
case isp d (IsGCD.d|a isGCD) of λ where
(left d=1) → left d=1
(right refl) → right (IsGCD.d|b isGCD)
prime-divide-prime : ∀ {p q} → Prime p → Prime q → p Divides q → p ≡ q
prime-divide-prime {p} (prime p>1 _) (prime _ dq) p|q =
case dq p p|q of λ where
(left refl) → refute p>1
(right p=q) → p=q
prime-split : ∀ {p} a b → Prime p → p Divides (a * b) → Either (p Divides a) (p Divides b)
prime-split a b isP p|ab =
case prime-coprime/divide _ a isP of λ where
(left p/a) → right (coprime-divide-mul-l _ a b p/a p|ab)
(right p|a) → left p|a
-- It's enough to check prime divisors when checking coprimality.
module _ (a b : Nat) (f : ∀ p → Prime p → p Divides a → p Divides b → p Divides 1) where
private
coprimeByPrimes′ : (k : Nat) → Acc _<_ k → k Divides a → k Divides b → k Divides 1
coprimeByPrimes′ k (acc wf) k|a k|b =
case isPrime k of λ where
(yes isP) → f k isP k|a k|b
(no (composite i j i>1 j>1 refl)) →
let i|1 : i Divides 1
i|1 = coprimeByPrimes′ i (wf i (less-mul-l i>1 j>1))
(mul-divides-l i j a k|a) (mul-divides-l i j b k|b)
j|1 : j Divides 1
j|1 = coprimeByPrimes′ j (wf j (less-mul-r i>1 j>1))
(mul-divides-r i j a k|a) (mul-divides-r i j b k|b)
in case₂ divides-one i|1 , divides-one j|1 of λ where
refl refl → factor! 1
(tiny (diff! 0)) → factor! 1
(tiny (diff! 1)) →
case₂ divides-zero k|a , divides-zero k|b of λ where
refl refl →
let 2∤1 = fromDec (2 divides? 1)
2|0 = fromDec (2 divides? 0) in
⊥-elim (2∤1 (f 2 (fromDec (decPrime 2)) 2|0 2|0))
(tiny (diff (suc (suc _)) eq)) → refute eq
coprimeByPrimes : Coprime a b
coprimeByPrimes = coprimeByDivide a b λ k → coprimeByPrimes′ k (wfNat k)
coprime-mul-r : ∀ a b c → Coprime a b → Coprime a c → Coprime a (b * c)
coprime-mul-r a b c a/b a/c =
coprimeByPrimes a (b * c) λ p isP p|a p|bc →
case prime-split b c isP p|bc of λ where
(left p|b) → divide-coprime p a b a/b p|a p|b
(right p|c) → divide-coprime p a c a/c p|a p|c
coprime-mul-l : ∀ a b c → Coprime a c → Coprime b c → Coprime (a * b) c
coprime-mul-l a b c a/c b/c =
coprime-sym c _ (coprime-mul-r c a b (coprime-sym a _ a/c) (coprime-sym b _ b/c))
prime-divide-coprime : ∀ p a b → Prime p → Coprime a b → p Divides a → p Divides b → ⊥
prime-divide-coprime p a b isP a/b p|a p|b =
case divides-one {p} (divide-coprime p a b a/b p|a p|b) of λ where
refl → fromDec (decPrime 1) isP
| {
"alphanum_fraction": 0.5978326309,
"avg_line_length": 40.512195122,
"ext": "agda",
"hexsha": "be5a297c0abda112a93c8ab5ffee1020d08b7190",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "t-more/agda-prelude",
"max_forks_repo_path": "src/Numeric/Nat/Prime/Properties.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "t-more/agda-prelude",
"max_issues_repo_path": "src/Numeric/Nat/Prime/Properties.agda",
"max_line_length": 90,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "t-more/agda-prelude",
"max_stars_repo_path": "src/Numeric/Nat/Prime/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 1245,
"size": 3322
} |
open import Agda.Builtin.Bool public
open import Agda.Builtin.Nat public
data IsTrue : Bool → Set where
instance truth : IsTrue true
postulate
foo : {{IsTrue (3 < 2)}} → Nat
test : Nat
test = foo
| {
"alphanum_fraction": 0.7009803922,
"avg_line_length": 15.6923076923,
"ext": "agda",
"hexsha": "ced75f194799f13e354b5a6b538640feb7941888",
"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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue4530.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/Issue4530.agda",
"max_line_length": 36,
"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/Issue4530.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": 63,
"size": 204
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Naturals
open import Numbers.Naturals.Order
open import Numbers.Naturals.Order.Lemmas
open import Numbers.Naturals.Order.WellFounded
open import Orders.WellFounded.Induction
open import Orders.Total.Definition
open import Semirings.Definition
module Numbers.Naturals.Division where
open import Numbers.Naturals.EuclideanAlgorithm public using (_∣_ ; zeroDividesNothing ; divisionAlgResult ; divides ; biggerThanCantDivide ; aDivA ; aDivZero ; divEquality ; oneDivN ; dividesBothImpliesDividesSum ; dividesBothImpliesDividesDifference)
divOneImpliesOne : {a : ℕ} → a ∣ 1 → a ≡ 1
divOneImpliesOne {zero} a|1 = exFalso (zeroDividesNothing _ a|1)
divOneImpliesOne {succ zero} a|1 = refl
divOneImpliesOne {succ (succ a)} (divides record { quot = zero ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = quotSmall } refl) rewrite Semiring.sumZeroRight ℕSemiring (a *N zero) | multiplicationNIsCommutative a 0 = exFalso (naughtE pr)
divOneImpliesOne {succ (succ a)} (divides record { quot = (succ quot) ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = quotSmall } refl) rewrite Semiring.commutative ℕSemiring quot (succ (quot +N a *N succ quot)) = exFalso (naughtE (equalityCommutative (succInjective pr)))
| {
"alphanum_fraction": 0.7753464624,
"avg_line_length": 62.3181818182,
"ext": "agda",
"hexsha": "5f33221c8b35cc9889cab7e43b0ad050553076f7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Numbers/Naturals/Division.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Numbers/Naturals/Division.agda",
"max_line_length": 285,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Numbers/Naturals/Division.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 401,
"size": 1371
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.DStructures.Structures.PeifferGraph where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Structure
open import Cubical.Functions.FunExtEquiv
open import Cubical.Homotopy.Base
open import Cubical.Data.Sigma
open import Cubical.Relation.Binary
open import Cubical.Algebra.Group
open import Cubical.Structures.LeftAction
open import Cubical.DStructures.Base
open import Cubical.DStructures.Meta.Properties
open import Cubical.DStructures.Structures.Constant
open import Cubical.DStructures.Structures.Type
open import Cubical.DStructures.Structures.Group
open import Cubical.DStructures.Structures.ReflGraph
open GroupLemmas
open MorphismLemmas
private
variable
ℓ ℓ' : Level
module _ (𝒢 : ReflGraph ℓ ℓ') where
open ReflGraphNotation 𝒢
----------------------------------------------------
-- The peiffer condition for reflexive graphs,
-- i.e. the missing property to turn a precrossed
-- module into a crossed module
----------------------------------------------------
isPeifferGraph : Type ℓ'
isPeifferGraph = (a b : ⟨ G₁ ⟩) → ((is b +₁ (a -₁ it a)) +₁ (-is b +₁ b)) +₁ it a ≡ b +₁ a
-- G₁ is a set, so isPeifferGraph is a proposition
isPropIsPeifferGraph : isProp isPeifferGraph
isPropIsPeifferGraph = isPropΠ2 (λ a b → set₁ (((is b +₁ (a -₁ it a)) +₁ (-is b +₁ b)) +₁ it a) (b +₁ a))
---------------------------------------------------
-- lemmas about the peiffer graphs
---------------------------------------------------
module _ (isPeifferG : isPeifferGraph) where
abstract
-- the peiffer condition can be simplified to this
isPeifferGraph2 : (a b : ⟨ G₁ ⟩) → (a -₁ it a) +₁ (-is b +₁ b) ≡ (-is b +₁ (b +₁ a)) -₁ it a
isPeifferGraph2 a b = (a -₁ ita) +₁ (-isb +₁ b)
≡⟨ sym (lCancel-lId G₁ isb ((a -₁ ita) +₁ (-isb +₁ b)))
∙ sym (rCancel-rId G₁ ((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) ita) ⟩
((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) +₁ (ita -₁ ita)
≡⟨ assoc₁ ((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) ita -ita ⟩
(((-isb +₁ isb) +₁ ((a -₁ ita) +₁ (-isb +₁ b))) +₁ ita) +₁ -ita
≡⟨ cong (λ z → (z +₁ ita) -₁ ita)
(sym (assoc₁ -isb isb _)) ⟩
((-isb +₁ (isb +₁ ((a -₁ ita) +₁ (-isb +₁ b)))) +₁ ita) +₁ -ita
≡⟨ cong (λ z → ((-isb +₁ z) +₁ ita) +₁ -ita)
(assoc₁ _ _ _) ⟩
((-isb +₁ ((isb +₁ (a -₁ ita)) +₁ (-isb +₁ b))) +₁ ita) +₁ -ita
≡⟨ cong (_+₁ -ita)
(sym (assoc₁ -isb _ ita)) ⟩
(-isb +₁ (((isb +₁ (a -₁ ita)) +₁ (-isb +₁ b)) +₁ ita)) -₁ ita
≡⟨ cong (λ z → (-isb +₁ z) -₁ ita)
(isPeifferG a b) ⟩
(-isb +₁ (b +₁ a)) -₁ ita ∎
where
-a = -₁ a
-ita = -it a
ita = it a
isb = is b
-isb = -is b
-b = -₁ b
-- inverting both sides of the identity isPeifferGraph2 and simplifying
-- gives this
isPeifferGraph3 : (a b : ⟨ G₁ ⟩) → (-₁ b) +₁ (is b +₁ (it a -₁ a)) ≡ it a +₁ ((-₁ a) +₁ ((-₁ b) +₁ is b))
isPeifferGraph3 a b = -b +₁ (isb +₁ (ita -₁ a))
≡⟨ cong (λ z → -b +₁ (z +₁ (ita -₁ a)))
(sym (invInvo G₁ isb))
∙ cong (λ z → -b +₁ ((-₁ -isb) +₁ (z -₁ a)))
(sym (invInvo G₁ ita)) ⟩
-b +₁ ((-₁ -isb) +₁ ((-₁ -ita) -₁ a))
≡⟨ sym (invDistr₄ G₁ a -ita -isb b) ⟩
-₁ (((a +₁ -ita) +₁ -isb) +₁ b)
≡⟨ cong -₁_ (sym (assoc₁ _ -isb b)) ⟩
-₁ ((a -₁ ita) +₁ (-isb +₁ b))
≡⟨ cong -₁_ (isPeifferGraph2 a b) ⟩
-₁ ((-isb +₁ (b +₁ a)) -₁ ita)
≡⟨ cong (λ z → -₁ (z -₁ ita)) (assoc₁ -isb b a) ⟩
-₁ (((-isb +₁ b) +₁ a) -₁ ita)
≡⟨ invDistr₄ G₁ -isb b a -ita ⟩
(-₁ -ita) +₁ (-a +₁ (-b +₁ (-₁ -isb)))
≡⟨ cong (_+₁ (-a +₁ (-b +₁ (-₁ -isb))))
(invInvo G₁ ita)
∙ cong (λ z → ita +₁ (-a +₁ (-b +₁ z)))
(invInvo G₁ isb) ⟩
ita +₁ (-a +₁ (-b +₁ isb)) ∎
where
-a = -₁ a
-ita = -₁ (it a)
ita = it a
isb = is b
-isb = -₁ isb
-b = -₁ b
-- plugging -a and -b into isPeifferGraph4 gives this
isPeifferGraph4 : (a b : ⟨ G₁ ⟩) → b +₁ ((-₁ (is b)) +₁ ((-₁ (it a)) +₁ a)) ≡ (-₁ (it a)) +₁ (a +₁ (b -₁ (is b)))
isPeifferGraph4 a b = b +₁ (-isb +₁ (-ita +₁ a))
≡⟨ cong (_+₁ (-isb +₁ (-ita +₁ a)))
(sym (invInvo G₁ b)) ⟩
(-₁ -b) +₁ (-isb +₁ (-ita +₁ a))
≡⟨ cong (λ z → (-₁ -b) +₁ (-isb +₁ (-ita +₁ z)))
(sym (invInvo G₁ a)) ⟩
(-₁ -b) +₁ (-isb +₁ (-ita -₁ -a))
≡⟨ cong (λ z → (-₁ -b) +₁ (-isb +₁ (z -₁ -a))) (sym (mapInv ι∘τ a)) ⟩
(-₁ -b) +₁ (-isb +₁ ((it -a) -₁ -a))
≡⟨ cong (λ z → (-₁ -b) +₁ (z +₁ ((it -a) -₁ -a))) (sym (mapInv ι∘σ b)) ⟩
(-₁ -b) +₁ (is -b +₁ ((it -a) -₁ -a))
≡⟨ isPeifferGraph3 -a -b ⟩
it -a +₁ ((-₁ -a) +₁ ((-₁ -b) +₁ is -b))
≡⟨ cong (_+₁ ((-₁ -a) +₁ ((-₁ -b) +₁ is -b)))
(mapInv ι∘τ a) ⟩
-ita +₁ ((-₁ -a) +₁ ((-₁ -b) +₁ is -b))
≡⟨ cong (λ z → -ita +₁ (z +₁ ((-₁ -b) +₁ is -b)))
(invInvo G₁ a) ⟩
-ita +₁ (a +₁ ((-₁ -b) +₁ is -b))
≡⟨ cong (λ z → -ita +₁ (a +₁ (z +₁ is -b)))
(invInvo G₁ b) ⟩
-ita +₁ (a +₁ (b +₁ is -b))
≡⟨ cong (λ z → -ita +₁ (a +₁ (b +₁ z)))
(mapInv ι∘σ b) ⟩
-ita +₁ (a +₁ (b -₁ isb)) ∎
where
-a = -₁ a
-ita = -it a
isb = is b
-isb = -is b
-b = -₁ b
-----------------------------------------------
-- URG structure on the type of peiffer graphs
--
-- isPeifferGraph
-- |
-- ReflGraph
-----------------------------------------------
module _ (ℓ ℓ' : Level) where
private
ℓℓ' = ℓ-max ℓ ℓ'
𝒮ᴰ-ReflGraph\Peiffer : URGStrᴰ (𝒮-ReflGraph ℓ ℓℓ')
(λ 𝒢 → isPeifferGraph 𝒢)
ℓ-zero
𝒮ᴰ-ReflGraph\Peiffer = Subtype→Sub-𝒮ᴰ (λ 𝒢 → isPeifferGraph 𝒢 , isPropIsPeifferGraph 𝒢)
(𝒮-ReflGraph ℓ ℓℓ')
PeifferGraph : Type (ℓ-suc ℓℓ')
PeifferGraph = Σ[ 𝒢 ∈ ReflGraph ℓ ℓℓ' ] isPeifferGraph 𝒢
𝒮-PeifferGraph : URGStr PeifferGraph ℓℓ'
𝒮-PeifferGraph = ∫⟨ 𝒮-ReflGraph ℓ ℓℓ' ⟩ 𝒮ᴰ-ReflGraph\Peiffer
| {
"alphanum_fraction": 0.3681439765,
"avg_line_length": 47.2138728324,
"ext": "agda",
"hexsha": "aad692310ea949467d3bf5ed3ba64a9368a7abf0",
"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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/DStructures/Structures/PeifferGraph.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"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": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/DStructures/Structures/PeifferGraph.agda",
"max_line_length": 118,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/DStructures/Structures/PeifferGraph.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2618,
"size": 8168
} |
open import FRP.JS.Behaviour using ( Beh ; [_] ; map ; accumHoldBy )
open import FRP.JS.Event using ( Evt ; tag )
open import FRP.JS.DOM using ( DOM ; element ; text ; listen ; click ; _++_ ; element+ ; _+++_ )
open import FRP.JS.RSet using ( RSet ; ⟦_⟧ ; ⟨_⟩ ; _⇒_ )
open import FRP.JS.Nat using ( ℕ ; _+_ ; _*_ ; _∸_ ; show )
open import FRP.JS.Time using ( Time )
open import FRP.JS.String using ( String )
open import FRP.JS.Bool using ( Bool ; true ; false )
open import FRP.JS.Product using ( _∧_ ; _,_ )
module FRP.JS.Demo.Calculator.Model where
data Op : Set where
plus minus times eq : Op
data Button : Set where
digit : ℕ → Button
op : Op → Button
clear : Button
data State : Set where
state : ℕ → ℕ → Bool → Op → State
init : State
init = state 0 0 false eq
eval : ℕ → Op → ℕ → ℕ
eval m plus n = m + n
eval m minus n = m ∸ n
eval m times n = m * n
eval m eq n = n
step : State → Button → State
step (state m n true p) (digit d) = state m (n * 10 + d) true p
step (state m n false p) (digit d) = state n d true p
step (state m n true p) (op q) = state n (eval m p n) false q
step (state m n false p) (op q) = state m (eval m p n) false q
step (state m n b p) clear = state 0 0 false eq
button$ : Button → String
button$ (digit d) = show d
button$ (op plus) = "+"
button$ (op minus) = "-"
button$ (op times) = "×"
button$ (op eq) = "="
button$ clear = "C"
state$ : State → String
state$ (state m n b p) = show n
model : ⟦ Evt ⟨ Button ⟩ ⇒ Beh ⟨ State ⟩ ⟧
model = accumHoldBy step init | {
"alphanum_fraction": 0.6001271456,
"avg_line_length": 30.25,
"ext": "agda",
"hexsha": "4d7cef3925b47b0bdc0c503bcaf2a6e6b6f7be9a",
"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/Calculator/Model.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/Calculator/Model.agda",
"max_line_length": 96,
"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/Calculator/Model.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": 547,
"size": 1573
} |
module _ where
open import DeadCodePatSyn.Lib
-- Check that pattern synonyms count when computing dead code
f : _ → Set₁
f not-hidden = Set
| {
"alphanum_fraction": 0.7552447552,
"avg_line_length": 15.8888888889,
"ext": "agda",
"hexsha": "0e7157505a46a45784cc8a636c9ca3497f5b2f86",
"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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/DeadCodePatSyn.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/Succeed/DeadCodePatSyn.agda",
"max_line_length": 61,
"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/Succeed/DeadCodePatSyn.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": 37,
"size": 143
} |
module Eq where
import Prelude
open Prelude
abstract
data _=^=_ {a : Set} (x y : a) : Set1 where
leibniz : ((P : a -> Set) -> P x <-> P y) -> x =^= y
leibnizSubst : {a : Set} -> {x y : a}
-> x =^= y -> (P : a -> Set) -> P x -> P y
leibnizSubst (leibniz f) P p = iffLeft (f P) p
leibnizRefl : {a : Set} -> {x : a} -> x =^= x
leibnizRefl = leibniz (\_ -> iff id id)
leibnizSym : {a : Set} -> {x y : a} -> x =^= y -> y =^= x
leibnizSym (leibniz f) =
leibniz (\P -> iff (iffRight (f P)) (iffLeft (f P)))
| {
"alphanum_fraction": 0.4570928196,
"avg_line_length": 25.9545454545,
"ext": "agda",
"hexsha": "844fb89834b4aeb056afb03d76a381077567fb9d",
"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": "examples/AIM4/bag/Eq.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": "examples/AIM4/bag/Eq.agda",
"max_line_length": 61,
"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": "examples/AIM4/bag/Eq.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": 247,
"size": 571
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Maybes where one of the elements satisfies a given property
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Maybe.Relation.Unary.Any where
open import Data.Maybe.Base using (Maybe; just; nothing)
open import Data.Product as Prod using (∃; _,_; -,_)
open import Function using (id)
open import Function.Equivalence using (_⇔_; equivalence)
open import Level
open import Relation.Binary.PropositionalEquality as P using (_≡_; cong)
open import Relation.Unary
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
------------------------------------------------------------------------
-- Definition
data Any {a p} {A : Set a} (P : Pred A p) : Pred (Maybe A) (a ⊔ p) where
just : ∀ {x} → P x → Any P (just x)
------------------------------------------------------------------------
-- Basic operations
module _ {a p} {A : Set a} {P : Pred A p} where
drop-just : ∀ {x} → Any P (just x) → P x
drop-just (just px) = px
just-equivalence : ∀ {x} → P x ⇔ Any P (just x)
just-equivalence = equivalence just drop-just
map : ∀ {q} {Q : Pred A q} → P ⊆ Q → Any P ⊆ Any Q
map f (just px) = just (f px)
satisfied : ∀ {x} → Any P x → ∃ P
satisfied (just p) = -, p
------------------------------------------------------------------------
-- (un/)zip(/With)
module _ {a p q r} {A : Set a} {P : Pred A p} {Q : Pred A q} {R : Pred A r} where
zipWith : P ∩ Q ⊆ R → Any P ∩ Any Q ⊆ Any R
zipWith f (just px , just qx) = just (f (px , qx))
unzipWith : P ⊆ Q ∩ R → Any P ⊆ Any Q ∩ Any R
unzipWith f (just px) = Prod.map just just (f px)
module _ {a p q} {A : Set a} {P : Pred A p} {Q : Pred A q} where
zip : Any P ∩ Any Q ⊆ Any (P ∩ Q)
zip = zipWith id
unzip : Any (P ∩ Q) ⊆ Any P ∩ Any Q
unzip = unzipWith id
------------------------------------------------------------------------
-- Seeing Any as a predicate transformer
module _ {a p} {A : Set a} {P : Pred A p} where
dec : Decidable P → Decidable (Any P)
dec P-dec nothing = no λ ()
dec P-dec (just x) = Dec.map just-equivalence (P-dec x)
irrelevant : Irrelevant P → Irrelevant (Any P)
irrelevant P-irrelevant (just p) (just q) = cong just (P-irrelevant p q)
satisfiable : Satisfiable P → Satisfiable (Any P)
satisfiable P-satisfiable = Prod.map just just P-satisfiable
| {
"alphanum_fraction": 0.5182186235,
"avg_line_length": 32.0779220779,
"ext": "agda",
"hexsha": "714e6fc985326e23703c58dcccd3baf088961a9c",
"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/Maybe/Relation/Unary/Any.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/Maybe/Relation/Unary/Any.agda",
"max_line_length": 81,
"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/Maybe/Relation/Unary/Any.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 701,
"size": 2470
} |
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Data.NatPlusOne.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Data.Nat
open import Cubical.Data.NatPlusOne.Base
open import Cubical.Reflection.StrictEquiv
1+Path : ℕ ≡ ℕ₊₁
1+Path = ua e
where
unquoteDecl e = declStrictEquiv e 1+_ -1+_
ℕ₊₁→ℕ-inj : ∀ {m n} → ℕ₊₁→ℕ m ≡ ℕ₊₁→ℕ n → m ≡ n
ℕ₊₁→ℕ-inj p i = 1+ (injSuc p i)
infixl 7 _·₊₁_
_·₊₁_ : ℕ₊₁ → ℕ₊₁ → ℕ₊₁
(1+ m) ·₊₁ (1+ n) = 1+ (n + m · (suc n))
private
ℕ₊₁→ℕ-·₊₁-comm : ∀ m n → ℕ₊₁→ℕ (m ·₊₁ n) ≡ (ℕ₊₁→ℕ m) · (ℕ₊₁→ℕ n)
ℕ₊₁→ℕ-·₊₁-comm (1+ m) (1+ n) = refl
·₊₁-comm : ∀ m n → m ·₊₁ n ≡ n ·₊₁ m
·₊₁-comm (1+ m) (1+ n) = cong 1+_ (injSuc (·-comm (suc m) (suc n)))
·₊₁-assoc : ∀ m n o → m ·₊₁ (n ·₊₁ o) ≡ m ·₊₁ n ·₊₁ o
·₊₁-assoc (1+ m) (1+ n) (1+ o) = cong 1+_ (injSuc (·-assoc (suc m) (suc n) (suc o)))
·₊₁-identityˡ : ∀ n → 1 ·₊₁ n ≡ n
·₊₁-identityˡ (1+ n) = cong 1+_ (injSuc (·-identityˡ (suc n)))
·₊₁-identityʳ : ∀ n → n ·₊₁ 1 ≡ n
·₊₁-identityʳ (1+ n) = cong 1+_ (injSuc (·-identityʳ (suc n)))
| {
"alphanum_fraction": 0.5644007156,
"avg_line_length": 28.6666666667,
"ext": "agda",
"hexsha": "ca8a15a96f8644a803655ad80e330cd14d663c07",
"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": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Edlyr/cubical",
"max_forks_repo_path": "Cubical/Data/NatPlusOne/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"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": "Edlyr/cubical",
"max_issues_repo_path": "Cubical/Data/NatPlusOne/Properties.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Edlyr/cubical",
"max_stars_repo_path": "Cubical/Data/NatPlusOne/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 594,
"size": 1118
} |
-- Quotients of additive categories
{-# OPTIONS --safe #-}
module Cubical.Categories.Additive.Quotient where
open import Cubical.Algebra.AbGroup.Base
open import Cubical.Categories.Additive.Base
open import Cubical.Categories.Additive.Properties
open import Cubical.Categories.Category.Base
open import Cubical.Categories.Constructions.Quotient
open import Cubical.Categories.Limits.Terminal
open import Cubical.Foundations.Prelude
open import Cubical.HITs.SetQuotients renaming ([_] to ⟦_⟧)
private
variable
ℓ ℓ' ℓq : Level
-- Quotients of preadditive categories
module _ (C : PreaddCategory ℓ ℓ') where
open PreaddCategory C
open PreaddCategoryTheory C
module _ (_~_ : {x y : ob} (f g : Hom[ x , y ] ) → Type ℓq)
(~refl : {x y : ob} (f : Hom[ x , y ] ) → f ~ f)
(~cong⋆ : {x y z : ob}
(f f' : Hom[ x , y ]) → f ~ f'
→ (g g' : Hom[ y , z ]) → g ~ g'
→ (f ⋆ g) ~ (f' ⋆ g'))
(~cong+ : {x y : ob} (f f' g g' : Hom[ x , y ])
→ f ~ f' → g ~ g' → (f + g) ~ (f' + g'))
(~cong- : {x y : ob} (f f' : Hom[ x , y ])
→ f ~ f' → (- f) ~ (- f')) where
private
C/~ = QuotientCategory cat _~_ ~refl ~cong⋆
Hom[_,_]/~ = λ (x y : ob) → (Hom[ x , y ]) / _~_
_⋆/~_ = C/~ .Category._⋆_
_+/~_ : {x y : ob} (f g : Hom[ x , y ]/~) → Hom[ x , y ]/~
_+/~_ = setQuotBinOp ~refl ~refl _+_ ~cong+
-- Quotient group structure on homsets
private
open AbGroupStr renaming (_+_ to add; -_ to inv)
homAbStr/~ : (x y : ob) → AbGroupStr Hom[ x , y ]/~
homAbStr/~ x y .0g = ⟦ 0h ⟧
homAbStr/~ x y .add = _+/~_
homAbStr/~ x y .inv = (setQuotUnaryOp -_ ~cong-)
homAbStr/~ x y .isAbGroup = makeIsAbGroup squash/
(elimProp3 (λ _ _ _ → squash/ _ _) λ _ _ _ → cong ⟦_⟧ (+assoc _ _ _))
(elimProp (λ _ → squash/ _ _) λ _ → cong ⟦_⟧ (+idr _))
(elimProp (λ _ → squash/ _ _) λ _ → cong ⟦_⟧ (+invr _))
(elimProp2 (λ _ _ → squash/ _ _) λ _ _ → cong ⟦_⟧ (+comm _ _))
-- Distributivity
⋆distl+/~ : {x y z : ob} → (f : Hom[ x , y ]/~) → (g g' : Hom[ y , z ]/~) →
f ⋆/~ (g +/~ g') ≡ (f ⋆/~ g) +/~ (f ⋆/~ g')
⋆distl+/~ = elimProp3 (λ _ _ _ → squash/ _ _) λ _ _ _ → cong ⟦_⟧ (⋆distl+ _ _ _)
⋆distr+/~ : {x y z : ob} → (f f' : Hom[ x , y ]/~) → (g : Hom[ y , z ]/~) →
(f +/~ f') ⋆/~ g ≡ (f ⋆/~ g) +/~ (f' ⋆/~ g)
⋆distr+/~ = elimProp3 (λ _ _ _ → squash/ _ _) λ _ _ _ → cong ⟦_⟧ (⋆distr+ _ _ _)
-- Quotient of preadditive category
open PreaddCategory
open PreaddCategoryStr
PreaddQuotient : PreaddCategory ℓ (ℓ-max ℓ' ℓq)
PreaddQuotient .cat = QuotientCategory (cat C) _~_ ~refl ~cong⋆
PreaddQuotient .preadd .homAbStr = homAbStr/~
PreaddQuotient .preadd .⋆distl+ = ⋆distl+/~
PreaddQuotient .preadd .⋆distr+ = ⋆distr+/~
-- Quotients of additive categories
module _ (A : AdditiveCategory ℓ ℓ') where
open AdditiveCategory A
module _ (_~_ : {x y : ob} (f g : Hom[ x , y ] ) → Type ℓq)
(~refl : {x y : ob} (f : Hom[ x , y ] ) → f ~ f)
(~cong⋆ : {x y z : ob}
(f f' : Hom[ x , y ]) → f ~ f'
→ (g g' : Hom[ y , z ]) → g ~ g'
→ (f ⋆ g) ~ (f' ⋆ g'))
(~cong+ : {x y : ob} (f f' g g' : Hom[ x , y ])
→ f ~ f' → g ~ g' → (f + g) ~ (f' + g'))
(~cong- : {x y : ob} (f f' : Hom[ x , y ])
→ f ~ f' → (- f) ~ (- f')) where
private
A/~ = PreaddQuotient preaddcat _~_ ~refl ~cong⋆ ~cong+ ~cong-
-- Zero object
open ZeroObject
zero/~ : ZeroObject A/~
zero/~ .z = zero .z
zero/~ .zInit = isInitial/~ cat _~_ ~refl ~cong⋆ (zInit zero)
zero/~ .zTerm = isTerminal/~ cat _~_ ~refl ~cong⋆ (zTerm zero)
-- Biproducts
module _ (x y : ob) where
open Biproduct
open IsBiproduct
biprod/~ : Biproduct A/~ x y
biprod/~ .x⊕y = x ⊕ y
biprod/~ .i₁ = ⟦ i₁ (biprod x y) ⟧
biprod/~ .i₂ = ⟦ i₂ (biprod x y) ⟧
biprod/~ .π₁ = ⟦ π₁ (biprod x y) ⟧
biprod/~ .π₂ = ⟦ π₂ (biprod x y) ⟧
biprod/~ .isBipr .i₁⋆π₁ = cong ⟦_⟧ (i₁⋆π₁ (biprod x y))
biprod/~ .isBipr .i₁⋆π₂ = cong ⟦_⟧ (i₁⋆π₂ (biprod x y))
biprod/~ .isBipr .i₂⋆π₁ = cong ⟦_⟧ (i₂⋆π₁ (biprod x y))
biprod/~ .isBipr .i₂⋆π₂ = cong ⟦_⟧ (i₂⋆π₂ (biprod x y))
biprod/~ .isBipr .∑π⋆i = cong ⟦_⟧ (∑π⋆i (biprod x y))
open AdditiveCategoryStr
AdditiveQuotient : AdditiveCategory ℓ (ℓ-max ℓ' ℓq)
AdditiveQuotient .preaddcat = A/~
AdditiveQuotient .addit .zero = zero/~
AdditiveQuotient .addit .biprod = biprod/~
| {
"alphanum_fraction": 0.492898914,
"avg_line_length": 38.6129032258,
"ext": "agda",
"hexsha": "16e13ec179c8d6dffc4f5c0eb9ad0f8034b3e5dd",
"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/Additive/Quotient.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/Additive/Quotient.agda",
"max_line_length": 84,
"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/Additive/Quotient.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": 1965,
"size": 4788
} |
module sn-calculus-compatconf.same where
open import sn-calculus-compatconf.base
open import sn-calculus
open import sn-calculus-confluence.helper
using (ready-irr-on-irr-θʳ)
open import utility renaming (_U̬_ to _∪_)
open import context-properties
using (get-view ; wrap-rho
; ->E-view ; ->pot-view ; wrap-rho-pot' ; unwrap-rho
)
open import Esterel.Lang
open import Esterel.Lang.Properties
open import Esterel.Lang.Binding
open import Esterel.Lang.CanFunction
using (Can ; Canₛ ; Canₛₕ ; Canₖ ; Canθ ; Canθₛ ; Canθₛₕ ; module CodeSet)
open import Esterel.Lang.CanFunction.Properties
using (canθₛ-mergeʳ ; canθₛₕ-mergeʳ)
open import Esterel.Environment as Env
using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap)
open import Esterel.Context
using (EvaluationContext ; EvaluationContext1 ; _⟦_⟧e ; _≐_⟦_⟧e ;
Context ; Context1 ; _⟦_⟧c ; _≐_⟦_⟧c)
open import Esterel.Context.Properties
using (unplug ; unplugc ; plug ; plugc ; unplug-eq ; ⟦⟧c-to-⟦⟧e)
open import Esterel.CompletionCode as Code
using () renaming (CompletionCode to Code)
open import Esterel.Variable.Signal as Signal
using (Signal ; _ₛ)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar ; _ₛₕ)
open import Esterel.Variable.Sequential as SeqVar
using (SeqVar ; _ᵥ)
open import Relation.Nullary
using (¬_ ; Dec ; yes ; no)
open import Relation.Binary.PropositionalEquality
using (_≡_ ; refl ; sym ; cong ; trans ; subst ; subst₂ ; module ≡-Reasoning)
open import Data.Bool
using (Bool ; if_then_else_)
open import Data.Empty
using (⊥ ; ⊥-elim)
open import Data.List
using (List ; _∷_ ; [] ; _++_ ; map)
open import Data.List.Any
using (Any ; any ; here ; there)
open import Data.List.Any.Properties
using ()
renaming ( ++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ )
open import Data.Maybe
using (Maybe ; just ; nothing)
open import Data.Nat
using (ℕ ; zero ; suc ; _+_) renaming (_⊔_ to _⊔ℕ_)
open import Data.Product
using (Σ-syntax ; Σ ; _,_ ; _,′_ ; proj₁ ; proj₂ ; _×_ ; ∃)
open import Data.Sum
using (_⊎_ ; inj₁ ; inj₂)
open import Function using (_∘_ ; id ; _∋_ ; _$_)
open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM
open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM
open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM
open ->E-view
open ->pot-view
open EvaluationContext1
open _≐_⟦_⟧e
open Context1
open _≐_⟦_⟧c
open ListSet Data.Nat._≟_
open ≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎)
{-
Modified proof from the old E-lift C-any confluence lemma.
Basically this is arbitrary multi-wrap-rho given the correct binding
of p: from a reduction (where E ⟦ ρ θ · qin ⟧ has correct binding)
E ⟦ ρ θ · qin ⟧ sn⟶₁ E ⟦ ρ θr · ro ⟧
construct the E-wrapped reduction
ρ θ · E ⟦ qin ⟧ sn⟶₁ ρ θr · E ⟦ ro ⟧
( = q ) ( = r )
-}
conf-lift-lemma : ∀ {E qin ro p q θ θr BV FV A Ar} →
CorrectBinding p BV FV →
p ≐ E ⟦ ρ⟨ θ , A ⟩· qin ⟧e →
q ≐ E ⟦ qin ⟧e →
ρ⟨ θ , A ⟩· qin sn⟶₁ ρ⟨ θr , Ar ⟩· ro →
∃ λ r →
r ≐ E ⟦ ro ⟧e ×
ρ⟨ θ , A ⟩· q sn⟶₁ ρ⟨ θr , Ar ⟩· r
conf-lift-lemma cb dehole dehole ρθ·pinsn⟶₁ρθq·qin = _ , dehole , ρθ·pinsn⟶₁ρθq·qin
conf-lift-lemma cb@(CBpar cbp' cbq' _ _ _ _) (depar₁ p≐E⟦ρθ·pin⟧) (depar₁ r≐E⟦pin⟧) ρθ·pinsn⟶₁ρθq·qin
with conf-lift-lemma cbp' p≐E⟦ρθ·pin⟧ r≐E⟦pin⟧ ρθ·pinsn⟶₁ρθq·qin
... | q , q≐E⟦qin⟧ , ρθ·rsn⟶₁ρθq·q
with get-view ρθ·rsn⟶₁ρθq·q
... | inj₁ (E' , pin' , qin' , r≐E'⟦pin'⟧ , q≐E'⟦qin'⟧ , e-view) =
_ , depar₁ q≐E⟦qin⟧ ,′
proj₁ (wrap-rho ρθ·rsn⟶₁ρθq·q r≐E'⟦pin'⟧ q≐E'⟦qin'⟧ e-view _
(depar₁ r≐E'⟦pin'⟧) (depar₁ q≐E'⟦qin'⟧))
... | inj₂ (refl , refl , pot) with wrap-rho-pot' (depar₁ p≐E⟦ρθ·pin⟧) cb ρθ·rsn⟶₁ρθq·q pot
... | _ , depar₁ dehole , ρθ·p'∥tsn⟶₁ρθq·p'∥t , pot' = -- need pattern matching for LHS of sn⟶₁
_ , depar₁ q≐E⟦qin⟧ ,′
ρθ·p'∥tsn⟶₁ρθq·p'∥t
conf-lift-lemma cb@(CBpar cbp' cbq' _ _ _ _) (depar₂ p≐E⟦ρθ·pin⟧) (depar₂ r≐E⟦pin⟧) ρθ·pinsn⟶₁ρθq·qin
with conf-lift-lemma cbq' p≐E⟦ρθ·pin⟧ r≐E⟦pin⟧ ρθ·pinsn⟶₁ρθq·qin
... | q , q≐E⟦qin⟧ , ρθ·rsn⟶₁ρθq·q
with get-view ρθ·rsn⟶₁ρθq·q
... | inj₁ (E' , pin' , qin' , r≐E'⟦pin'⟧ , q≐E'⟦qin'⟧ , e-view) =
_ , depar₂ q≐E⟦qin⟧ ,′
proj₁ (wrap-rho ρθ·rsn⟶₁ρθq·q r≐E'⟦pin'⟧ q≐E'⟦qin'⟧ e-view _
(depar₂ r≐E'⟦pin'⟧) (depar₂ q≐E'⟦qin'⟧))
... | inj₂ (refl , refl , pot) with wrap-rho-pot' (depar₂ p≐E⟦ρθ·pin⟧) cb ρθ·rsn⟶₁ρθq·q pot
... | _ , depar₂ dehole , ρθ·t∥q'sn⟶₁ρθq·t∥q' , pot' =
_ , depar₂ q≐E⟦qin⟧ ,′
ρθ·t∥q'sn⟶₁ρθq·t∥q'
conf-lift-lemma cb@(CBseq cbp' cbq' _) (deseq p≐E⟦ρθ·pin⟧) (deseq r≐E⟦pin⟧) ρθ·pinsn⟶₁ρθq·qin
with conf-lift-lemma cbp' p≐E⟦ρθ·pin⟧ r≐E⟦pin⟧ ρθ·pinsn⟶₁ρθq·qin
... | q , q≐E⟦qin⟧ , ρθ·rsn⟶₁ρθq·q
with get-view ρθ·rsn⟶₁ρθq·q
... | inj₁ (E' , pin' , qin' , r≐E'⟦pin'⟧ , q≐E'⟦qin'⟧ , e-view) =
_ , deseq q≐E⟦qin⟧ ,′
proj₁ (wrap-rho ρθ·rsn⟶₁ρθq·q r≐E'⟦pin'⟧ q≐E'⟦qin'⟧ e-view _
(deseq r≐E'⟦pin'⟧) (deseq q≐E'⟦qin'⟧))
... | inj₂ (refl , refl , pot) with wrap-rho-pot' (deseq p≐E⟦ρθ·pin⟧) cb ρθ·rsn⟶₁ρθq·q pot
... | _ , deseq dehole , ρθ·t>>q'sn⟶₁ρθq·t>>q' , pot' =
_ , deseq q≐E⟦qin⟧ ,′
ρθ·t>>q'sn⟶₁ρθq·t>>q'
conf-lift-lemma cb@(CBloopˢ cbp' cbq' _ _) (deloopˢ p≐E⟦ρθ·pin⟧) (deloopˢ r≐E⟦pin⟧) ρθ·pinsn⟶₁ρθq·qin
with conf-lift-lemma cbp' p≐E⟦ρθ·pin⟧ r≐E⟦pin⟧ ρθ·pinsn⟶₁ρθq·qin
... | q , q≐E⟦qin⟧ , ρθ·rsn⟶₁ρθq·q
with get-view ρθ·rsn⟶₁ρθq·q
... | inj₁ (E' , pin' , qin' , r≐E'⟦pin'⟧ , q≐E'⟦qin'⟧ , e-view) =
_ , deloopˢ q≐E⟦qin⟧ ,′
proj₁ (wrap-rho ρθ·rsn⟶₁ρθq·q r≐E'⟦pin'⟧ q≐E'⟦qin'⟧ e-view _
(deloopˢ r≐E'⟦pin'⟧) (deloopˢ q≐E'⟦qin'⟧))
... | inj₂ (refl , refl , pot) with wrap-rho-pot' (deloopˢ p≐E⟦ρθ·pin⟧) cb ρθ·rsn⟶₁ρθq·q pot
... | _ , deloopˢ dehole , ρθ·t>>q'sn⟶₁ρθq·t>>q' , pot' =
_ , deloopˢ q≐E⟦qin⟧ ,′
ρθ·t>>q'sn⟶₁ρθq·t>>q'
conf-lift-lemma cb@(CBsusp cb' _) (desuspend p≐E⟦ρθ·pin⟧) (desuspend r≐E⟦pin⟧) ρθ·pinsn⟶₁ρθq·qin
with conf-lift-lemma cb' p≐E⟦ρθ·pin⟧ r≐E⟦pin⟧ ρθ·pinsn⟶₁ρθq·qin
... | q , q≐E⟦qin⟧ , ρθ·rsn⟶₁ρθq·q
with get-view ρθ·rsn⟶₁ρθq·q
... | inj₁ (E' , pin' , qin' , r≐E'⟦pin'⟧ , q≐E'⟦qin'⟧ , e-view) =
_ , desuspend q≐E⟦qin⟧ ,′
proj₁ (wrap-rho ρθ·rsn⟶₁ρθq·q r≐E'⟦pin'⟧ q≐E'⟦qin'⟧ e-view _
(desuspend r≐E'⟦pin'⟧) (desuspend q≐E'⟦qin'⟧))
... | inj₂ (refl , refl , pot) with wrap-rho-pot' (desuspend p≐E⟦ρθ·pin⟧) cb ρθ·rsn⟶₁ρθq·q pot
... | _ , desuspend dehole , ρθ·susptsn⟶₁ρθq·suspt , pot' =
_ , desuspend q≐E⟦qin⟧ ,′
ρθ·susptsn⟶₁ρθq·suspt
conf-lift-lemma cb@(CBtrap cb') (detrap p≐E⟦ρθ·pin⟧) (detrap r≐E⟦pin⟧) ρθ·pinsn⟶₁ρθq·qin
with conf-lift-lemma cb' p≐E⟦ρθ·pin⟧ r≐E⟦pin⟧ ρθ·pinsn⟶₁ρθq·qin
... | q , q≐E⟦qin⟧ , ρθ·rsn⟶₁ρθq·q
with get-view ρθ·rsn⟶₁ρθq·q
... | inj₁ (E' , pin' , qin' , r≐E'⟦pin'⟧ , q≐E'⟦qin'⟧ , e-view) =
_ , detrap q≐E⟦qin⟧ ,′
proj₁ (wrap-rho ρθ·rsn⟶₁ρθq·q r≐E'⟦pin'⟧ q≐E'⟦qin'⟧ e-view _
(detrap r≐E'⟦pin'⟧) (detrap q≐E'⟦qin'⟧))
... | inj₂ (refl , refl , pot) with wrap-rho-pot' (detrap p≐E⟦ρθ·pin⟧) cb ρθ·rsn⟶₁ρθq·q pot
... | _ , detrap dehole , ρθ·traptsn⟶₁ρθq·trapt , pot' =
_ , detrap q≐E⟦qin⟧ ,′
ρθ·traptsn⟶₁ρθq·trapt
{-
Base case where (E, C) = ([], []).
The most complicated case where LHS is ρθ.ρθ'.qin sn⟶₁ ρ(θ←θ').qin (qin = ρθ'.rin)
and RHS is (ρθ.) ρθ'.rin sn⟶₁ (ρθ.) ρθr.ro, i.e. arbitrary ->E-view and ->pot-view.
p
ρθ. E⟦ρθ'.qin⟧ -- sn⟶₁ -> ρ(θ←θ'). E⟦qin⟧
(ρθ) E⟦ρθ'.qin⟧ -- sn⟶₁ -> (ρθ) E⟦ρθr.ro⟧
-}
1-steplρ-E-view-ecsame : ∀{E p qin q qo rin r ro θ θ←θ' BV FV A A⊓A'} →
{ρθ·psn⟶₁ρθ←θ'·q : ρ⟨ θ , A ⟩· p sn⟶₁ ρ⟨ θ←θ' , A⊓A' ⟩· q} →
CorrectBinding p BV FV →
(p≐E⟦qin⟧ : p ≐ E ⟦ qin ⟧e) →
(q≐E⟦qo⟧ : q ≐ E ⟦ qo ⟧e) →
->E-view ρθ·psn⟶₁ρθ←θ'·q p≐E⟦qin⟧ q≐E⟦qo⟧ →
(p≐E⟦rin⟧ : p ≐ (map ceval E) ⟦ rin ⟧c) →
(r≐E⟦ro⟧ : r ≐ (map ceval E) ⟦ ro ⟧c) →
-- rinsn⟶₁ro can only be (ρ⟨ θ' , A' ⟩· qin) sn⟶₁ (ρ⟨ θr , Ar ⟩· ro)
(rinsn⟶₁ro : rin sn⟶₁ ro) →
Σ ((Env × Ctrl × Term) × EvaluationContext × Term × Term) λ { ((θo , Ao , po) , E' , roin , poin) →
ρ⟨ θ←θ' , A⊓A' ⟩· q sn⟶₁ ρ⟨ θo , Ao ⟩· po ×
Σ[ ρθ·rsn⟶₁ρθo·po ∈ ρ⟨ θ , A ⟩· r sn⟶₁ ρ⟨ θo , Ao ⟩· po ]
Σ[ r≐E'⟦roin⟧ ∈ r ≐ E' ⟦ roin ⟧e ]
Σ[ po≐E'⟦poin⟧ ∈ po ≐ E' ⟦ poin ⟧e ]
->E-view ρθ·rsn⟶₁ρθo·po r≐E'⟦roin⟧ po≐E'⟦poin⟧
}
1-steplρ-E-view-ecsame cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ e-view p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro
with unplug-eq p≐E⟦ρθ'·qin⟧ (⟦⟧c-to-⟦⟧e p≐C⟦rin⟧)
1-steplρ-E-view-ecsame cb _ _ vis-present _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vis-absent _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vemit _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vraise-shared _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vset-shared-value-old _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vset-shared-value-new _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vraise-var _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vset-var _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vif-false _ _ () | refl
1-steplρ-E-view-ecsame cb _ _ vif-true _ _ () | refl
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb
p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge
p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl
with ρ-stays-ρ-sn⟶₁ rinsn⟶₁ro
... | θr , roin , Ar , refl
with conf-lift-lemma cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ rinsn⟶₁ro
... | r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r' -- q ≐ E ⟦ qin ⟧
with get-view ρθ'·qsn⟶₁ρθr·r'
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦present⟧ , r'≐E⟦roin'⟧ ,
vis-present {.θ'} {S} {E = .E'} {S∈Domθ'} {θ'S≡present} {q≐E'⟦present⟧}) =
_ ,
(ris-present {S = S}
(Env.sig-←-monoʳ S θr θ S∈Domθ')
(trans
(SigMap.get-U-right-irr-m {_} S (Env.sig θ) (Env.sig θr)
(Env.sig-←-monoʳ S θr θ S∈Domθ') S∈Domθ')
θ'S≡present)
q≐E'⟦present⟧) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , q≐E⟦qo'⟧ , r'≐E⟦roin'⟧ ,
vis-absent {.θ'} {S} {E = .E'} {S∈Domθ'} {θ'S≡absent} {q≐E'⟦absent⟧}) =
_ ,
(ris-absent {S = S}
(Env.sig-←-monoʳ S θr θ S∈Domθ')
(trans
(SigMap.get-U-right-irr-m {_} S (Env.sig θ) (Env.sig θr)
(Env.sig-←-monoʳ S θr θ S∈Domθ') S∈Domθ')
θ'S≡absent)
q≐E'⟦absent⟧) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦if⟧ , r'≐E⟦roin'⟧ ,
vif-false {x = x} {.E'} {x∈Domθ'} {θ'x≡zero} {q≐E'⟦if⟧}) =
_ ,
(rif-false {x = x}
(Env.seq-←-monoʳ x θr θ x∈Domθ')
(trans
(VarMap.get-U-right-irr-m {_} x (Env.var θ) (Env.var θr)
(Env.seq-←-monoʳ x θr θ x∈Domθ') x∈Domθ')
θ'x≡zero)
q≐E'⟦if⟧) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦if⟧ , r'≐E⟦roin'⟧ ,
vif-true {x = x} {.E'} {_} {x∈Domθ'} {θ'x≡suc} {q≐E'⟦if⟧}) =
_ ,
(rif-true {x = x}
(Env.seq-←-monoʳ x θr θ x∈Domθ')
(trans
(Env.var-vals-←-right-irr' x θ θr x∈Domθ' (Env.seq-←-monoʳ x θr θ x∈Domθ'))
θ'x≡suc)
q≐E'⟦if⟧) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦shared⟧ , r'≐E⟦roin'⟧ ,
vraise-shared {s = s} {E = .E'} {e'} {q≐E'⟦shared⟧})
with ready-irr-on-irr-θʳ θ e'
... | e'' , δe'≡δe'' rewrite δe'≡δe'' =
_ ,
rraise-shared e'' q≐E'⟦shared⟧ ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦var⟧ , r'≐E⟦roin'⟧ ,
vraise-var {E = .E'} {e'} {q≐E'⟦var⟧})
with ready-irr-on-irr-θʳ θ e'
... | e'' , δe'≡δe'' rewrite δe'≡δe'' =
_ ,
rraise-var e'' q≐E'⟦var⟧ ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} {A₁ = A} {.GO} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦emit⟧ , r'≐E⟦roin'⟧ ,
vemit {S = S} {.E'} {S∈Domθ'} {θ'S≢absent} {q≐E'⟦emit⟧}) =
_ ,
(subst₂ (λ θ* go → ρ⟨ (θ ← θ') , go ⟩· E ⟦ qin ⟧e sn⟶₁ ρ⟨ θ* , go ⟩· E' ⟦ nothin ⟧e)
(begin
Env.set-sig {S} (θ ← θ') S∈Domθ←θ' Signal.present
≡⟨ Env.sig-set=← (θ ← θ') S Signal.present S∈Domθ←θ' ⟩
(θ ← θ') ← [S↦present]
≡⟨ sym (Env.←-assoc θ θ' [S↦present]) ⟩
θ ← (θ' ← [S↦present])
≡⟨ cong (θ ←_) (sym (Env.sig-set=← θ' S Signal.present S∈Domθ')) ⟩
θ ← (Env.set-sig {S} θ' S∈Domθ' Signal.present)
∎)
(sym $ A-max-GO-≡-right A)
(remit {θ ← θ'} {S = S} S∈Domθ←θ'
(θ'S≢absent ∘ trans (sym ⟨θ←θ'⟩S≡θ'S))
q≐E'⟦emit⟧)) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
where
[S↦present] = Θ SigMap.[ S ↦ Signal.present ] ShrMap.empty VarMap.empty
S∈Domθ←θ' = Env.sig-←-monoʳ S θ' θ S∈Domθ'
⟨θ←θ'⟩S≡θ'S = Env.sig-stats-←-right-irr' S θ θ' S∈Domθ' S∈Domθ←θ'
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} {A₁ = A} {.GO} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦s⇐e⟧ , r'≐E⟦roin'⟧ ,
vset-shared-value-old {s = s} {E = .E'} {e'} {s∈Domθ'} {θ's≡old} {q≐E'⟦s⇐e⟧})
with ready-irr-on-irr-θʳ θ e'
... | e'' , δe'≡δe'' rewrite δe'≡δe'' =
_ ,
(subst₂ (λ θ* go → ρ⟨ (θ ← θ') , go ⟩· E ⟦ qin ⟧e sn⟶₁ ρ⟨ θ* , go ⟩· E' ⟦ nothin ⟧e)
(begin
Env.set-shr {s} (θ ← θ') s∈Domθ←θ' SharedVar.new (δ e'')
≡⟨ Env.shr-set=← (θ ← θ') s SharedVar.new (δ e'') s∈Domθ←θ' ⟩
(θ ← θ') ← [s↦new,δe'']
≡⟨ sym (Env.←-assoc θ θ' [s↦new,δe'']) ⟩
θ ← (θ' ← [s↦new,δe''])
≡⟨ cong (θ ←_) (sym (Env.shr-set=← θ' s SharedVar.new (δ e'') s∈Domθ')) ⟩
θ ← (Env.set-shr {s} θ' s∈Domθ' SharedVar.new (δ e''))
∎)
(sym $ A-max-GO-≡-right A)
(rset-shared-value-old {θ ← θ'} e'' s∈Domθ←θ'
(trans (Env.shr-stats-←-right-irr' s θ θ' s∈Domθ' s∈Domθ←θ') θ's≡old)
q≐E'⟦s⇐e⟧)) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
where
[s↦new,δe''] = [s,δe-new]-env s (δ e'')
s∈Domθ←θ' = Env.shr-←-monoʳ s θ' θ s∈Domθ'
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} {A₁ = A} {.GO} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , .q≐E'⟦s⇐e⟧ , r'≐E⟦roin'⟧ ,
vset-shared-value-new {s = s} {E = .E'} {e'} {s∈Domθ'} {θ's≡old} {q≐E'⟦s⇐e⟧})
with ready-irr-on-irr-θʳ θ e'
... | e'' , δe'≡δe'' rewrite δe'≡δe'' =
_ ,
(subst₂ (λ θ* go → ρ⟨ (θ ← θ') , go ⟩· E ⟦ qin ⟧e sn⟶₁ ρ⟨ θ* , go ⟩· E' ⟦ nothin ⟧e)
(begin
Env.set-shr {s} (θ ← θ') s∈Domθ←θ' SharedVar.new (⟨θ←θ'⟩s + δ e'')
≡⟨ cong(Env.set-shr{s}(θ ← θ')s∈Domθ←θ' SharedVar.new ∘ (_+ δ e''))⟨θ←θ'⟩s≡θ's ⟩
Env.set-shr {s} (θ ← θ') s∈Domθ←θ' SharedVar.new (θ's + δ e'')
≡⟨ Env.shr-set=← (θ ← θ') s SharedVar.new (θ's + δ e'') s∈Domθ←θ' ⟩
(θ ← θ') ← [s↦new,θ's+δe'']
≡⟨ sym (Env.←-assoc θ θ' [s↦new,θ's+δe'']) ⟩
θ ← (θ' ← [s↦new,θ's+δe''])
≡⟨ cong (θ ←_) (sym (Env.shr-set=← θ' s SharedVar.new (θ's + δ e'') s∈Domθ')) ⟩
θ ← (Env.set-shr {s} θ' s∈Domθ' SharedVar.new (θ's + δ e''))
∎)
(sym $ A-max-GO-≡-right A)
(rset-shared-value-new {θ ← θ'} e'' s∈Domθ←θ'
(trans (Env.shr-stats-←-right-irr' s θ θ' s∈Domθ' s∈Domθ←θ') θ's≡old)
q≐E'⟦s⇐e⟧)) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
where
s∈Domθ←θ' = Env.shr-←-monoʳ s θ' θ s∈Domθ'
θ's = Env.shr-vals {s} θ' s∈Domθ'
⟨θ←θ'⟩s = Env.shr-vals {s} (θ ← θ') s∈Domθ←θ'
⟨θ←θ'⟩s≡θ's = Env.shr-vals-←-right-irr' s θ θ' s∈Domθ' s∈Domθ←θ'
[s↦new,θ's+δe''] = [s,δe-new]-env s (θ's + δ e'')
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} {A₁ = A} {A'} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , q≐E⟦qo'⟧ , r'≐E⟦roin'⟧ ,
vset-var {x = x} {E = .E'} {x∈Domθ'} {e'} {q≐E'⟦x≔e⟧})
with ready-irr-on-irr-θʳ θ e'
... | e'' , δe'≡δe'' rewrite δe'≡δe'' =
_ ,
(subst (λ θ* → ρ⟨ (θ ← θ') , A-max A A' ⟩· E ⟦ qin ⟧e sn⟶₁ ρ⟨ θ* , A-max A A' ⟩· E' ⟦ nothin ⟧e)
(begin
Env.set-var {x} (θ ← θ') x∈Domθ←θ' (δ e'')
≡⟨ Env.seq-set=← (θ ← θ') x (δ e'') x∈Domθ←θ' ⟩
(θ ← θ') ← [x↦δe'']
≡⟨ sym (Env.←-assoc θ θ' [x↦δe'']) ⟩
θ ← (θ' ← [x↦δe''])
≡⟨ cong (θ ←_) (sym (Env.seq-set=← θ' x (δ e'') x∈Domθ')) ⟩
θ ← (Env.set-var {x} θ' x∈Domθ' (δ e''))
∎)
(rset-var {θ ← θ'} x∈Domθ←θ' e'' q≐E'⟦x≔e⟧)) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
where
[x↦δe''] = [x,δe]-env x (δ e'')
x∈Domθ←θ' = Env.seq-←-monoʳ x θ' θ x∈Domθ'
1-steplρ-E-view-ecsame {E} {A = A} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} {A₂ = A'} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | (.(θ' ← θr) , roin , .(A-max A' Ar) , refl)
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₁ (E' , qo' , roin' , q≐E⟦qo'⟧ , r'≐E⟦roin'⟧ ,
vmerge {.θ'} {θr} {_} {.roin'} {.E'} {_} {Ar} {q≐E'⟦ρθr·roin'⟧}) =
((_ , (A-max A (A-max A' Ar)) , _) , _) ,
(subst₂ (λ θ* A* → ρ⟨ (θ ← θ') , A-max A A' ⟩· E ⟦ qin ⟧e sn⟶₁ ρ⟨ θ* , A* ⟩· E' ⟦ roin' ⟧e)
(sym (Env.←-assoc θ θ' θr))
(sym (A-max-assoc A A' Ar))
(rmerge {θ ← θ'} {θr} {A₁ = A-max A A'} {Ar} q≐E'⟦ρθr·roin'⟧)) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₂ (refl , refl , vabsence S S∈Domθ' θ'S≡unknown S∉canθ-θ'-q-[]) =
_ ,
(subst (λ θ* → ρ⟨ (θ ← θ') , _ ⟩· E ⟦ qin ⟧e sn⟶₁ ρ⟨ θ* , _ ⟩· E ⟦ qin ⟧e)
(begin
Env.set-sig {S} (θ ← θ') S∈Domθ←θ' Signal.absent
≡⟨ Env.sig-set=← (θ ← θ') S Signal.absent S∈Domθ←θ' ⟩
(θ ← θ') ← [S↦absent]
≡⟨ sym (Env.←-assoc θ θ' [S↦absent]) ⟩
θ ← (θ' ← [S↦absent])
≡⟨ cong (θ ←_) (sym (Env.sig-set=← θ' S Signal.absent S∈Domθ')) ⟩
θ ← (Env.set-sig {S} θ' S∈Domθ' Signal.absent)
∎)
(rabsence {θ ← θ'} {S = S} S∈Domθ←θ'
(trans (Env.sig-stats-←-right-irr' S θ θ' S∈Domθ' S∈Domθ←θ') θ'S≡unknown)
(λ S∈canθ-θ←θ''-q-[] →
S∉canθ-θ'-q-[]
(canθₛ-mergeʳ (Env.sig θ) θ' (E ⟦ qin ⟧e) Env.[]env (λ _ ())
S S∈canθ-θ←θ''-q-[])))) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
where
[S↦absent] = Θ SigMap.[ S ↦ Signal.absent ] ShrMap.empty VarMap.empty
S∈Domθ←θ' = Env.sig-←-monoʳ S θ' θ S∈Domθ'
1-steplρ-E-view-ecsame {E} {ρθ·psn⟶₁ρθ←θ'·q = rmerge {θ} {θ'} {_} {qin} {.E} .p≐E⟦ρθ'·qin⟧}
cb p≐E⟦ρθ'·qin⟧ q≐E⟦qin⟧ vmerge p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro | refl | θr , roin , Ar , refl
| r' , r'≐E⟦roin⟧ , ρθ'·qsn⟶₁ρθr·r'
| inj₂ (refl , refl , vreadyness s s∈Domθ' θ's≡old⊎θ's≡new s∉canθ-θ'-q-[]) =
_ ,
(subst (λ θ* → ρ⟨ (θ ← θ') , _ ⟩· E ⟦ qin ⟧e sn⟶₁ ρ⟨ θ* , _ ⟩· E ⟦ qin ⟧e)
(begin
Env.set-shr {s} (θ ← θ') s∈Domθ←θ' SharedVar.ready ⟨θ←θ'⟩s
≡⟨ cong (Env.set-shr {s} (θ ← θ') s∈Domθ←θ' SharedVar.ready) ⟨θ←θ'⟩s≡θ's ⟩
Env.set-shr {s} (θ ← θ') s∈Domθ←θ' SharedVar.ready θ's
≡⟨ Env.shr-set=← (θ ← θ') s SharedVar.ready θ's s∈Domθ←θ' ⟩
(θ ← θ') ← [s↦ready,θ's]
≡⟨ sym (Env.←-assoc θ θ' [s↦ready,θ's]) ⟩
θ ← (θ' ← [s↦ready,θ's])
≡⟨ cong (θ ←_) (sym (Env.shr-set=← θ' s SharedVar.ready θ's s∈Domθ')) ⟩
θ ← (Env.set-shr {s} θ' s∈Domθ' SharedVar.ready θ's)
∎)
(rreadyness {θ ← θ'} {s = s} s∈Domθ←θ'
(Data.Sum.map
(trans (Env.shr-stats-←-right-irr' s θ θ' s∈Domθ' s∈Domθ←θ'))
(trans (Env.shr-stats-←-right-irr' s θ θ' s∈Domθ' s∈Domθ←θ'))
θ's≡old⊎θ's≡new)
(λ s∈canθ-θ←θ''-q-[] →
s∉canθ-θ'-q-[]
(canθₛₕ-mergeʳ (Env.sig θ) θ' (E ⟦ qin ⟧e) Env.[]env (λ _ ())
s s∈canθ-θ←θ''-q-[])))) ,′
(subst (λ po* → Σ[ r ∈ ρ⟨ _ , _ ⟩· _ sn⟶₁ ρ⟨ _ , _ ⟩· po* ]
Σ[ a ∈ _ ≐ _ ⟦ _ ⟧e ]
Σ[ b ∈ po* ≐ _ ⟦ _ ⟧e ]
->E-view r a b)
(unplug r'≐E⟦roin⟧)
(rmerge (⟦⟧c-to-⟦⟧e r≐C⟦ro⟧) ,
_ , plug refl , vmerge))
where
s∈Domθ←θ' = Env.shr-←-monoʳ s θ' θ s∈Domθ'
θ's = Env.shr-vals {s} θ' s∈Domθ'
⟨θ←θ'⟩s = Env.shr-vals {s} (θ ← θ') s∈Domθ←θ'
⟨θ←θ'⟩s≡θ's = Env.shr-vals-←-right-irr' s θ θ' s∈Domθ' s∈Domθ←θ'
[s↦ready,θ's] =
Θ ShrMap.empty ShrMap.[ s ↦ (SharedVar.ready , θ's) ] VarMap.empty
| {
"alphanum_fraction": 0.476892321,
"avg_line_length": 42.6605351171,
"ext": "agda",
"hexsha": "b3e82ff0196ea20d6b36e06dd1ffdcdb0493205e",
"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/sn-calculus-compatconf/same.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/sn-calculus-compatconf/same.agda",
"max_line_length": 113,
"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/sn-calculus-compatconf/same.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": 13936,
"size": 25511
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The lifting of a strict order to incorporate a new supremum
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- This module is designed to be used with
-- Relation.Nullary.Construct.Add.Supremum
open import Relation.Binary
module Relation.Binary.Construct.Add.Supremum.Strict
{a r} {A : Set a} (_<_ : Rel A r) where
open import Level using (_⊔_)
open import Data.Product
open import Function
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
import Relation.Binary.PropositionalEquality as P
open import Relation.Nullary.Construct.Add.Supremum
import Relation.Binary.Construct.Add.Supremum.Equality as Equality
import Relation.Binary.Construct.Add.Supremum.NonStrict as NonStrict
------------------------------------------------------------------------
-- Definition
infix 4 _<⁺_
data _<⁺_ : Rel (A ⁺) (a ⊔ r) where
[_] : {k l : A} → k < l → [ k ] <⁺ [ l ]
[_]<⊤⁺ : (k : A) → [ k ] <⁺ ⊤⁺
------------------------------------------------------------------------
-- Relational properties
[<]-injective : ∀ {k l} → [ k ] <⁺ [ l ] → k < l
[<]-injective [ p ] = p
<⁺-asym : Asymmetric _<_ → Asymmetric _<⁺_
<⁺-asym <-asym [ p ] [ q ] = <-asym p q
<⁺-asym <-asym [ k ]<⊤⁺ ()
<⁺-trans : Transitive _<_ → Transitive _<⁺_
<⁺-trans <-trans [ p ] [ q ] = [ <-trans p q ]
<⁺-trans <-trans [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺
<⁺-dec : Decidable _<_ → Decidable _<⁺_
<⁺-dec _<?_ [ k ] [ l ] = Dec.map′ [_] [<]-injective (k <? l)
<⁺-dec _<?_ [ k ] ⊤⁺ = yes [ k ]<⊤⁺
<⁺-dec _<?_ ⊤⁺ [ l ] = no (λ ())
<⁺-dec _<?_ ⊤⁺ ⊤⁺ = no (λ ())
<⁺-irrelevant : Irrelevant _<_ → Irrelevant _<⁺_
<⁺-irrelevant <-irr [ p ] [ q ] = P.cong _ (<-irr p q)
<⁺-irrelevant <-irr [ k ]<⊤⁺ [ k ]<⊤⁺ = P.refl
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<⁺-cmp : Trichotomous _≈_ _<_ → Trichotomous _≈⁺_ _<⁺_
<⁺-cmp <-cmp ⊤⁺ ⊤⁺ = tri≈ (λ ()) ⊤⁺≈⊤⁺ (λ ())
<⁺-cmp <-cmp ⊤⁺ [ l ] = tri> (λ ()) (λ ()) [ l ]<⊤⁺
<⁺-cmp <-cmp [ k ] ⊤⁺ = tri< [ k ]<⊤⁺ (λ ()) (λ ())
<⁺-cmp <-cmp [ k ] [ l ] with <-cmp k l
... | tri< a ¬b ¬c = tri< [ a ] (¬b ∘ [≈]-injective) (¬c ∘ [<]-injective)
... | tri≈ ¬a b ¬c = tri≈ (¬a ∘ [<]-injective) [ b ] (¬c ∘ [<]-injective)
... | tri> ¬a ¬b c = tri> (¬a ∘ [<]-injective) (¬b ∘ [≈]-injective) [ c ]
<⁺-irrefl : Irreflexive _≈_ _<_ → Irreflexive _≈⁺_ _<⁺_
<⁺-irrefl <-irrefl [ p ] [ q ] = <-irrefl p q
<⁺-irrefl <-irrefl ⊤⁺≈⊤⁺ ()
<⁺-respˡ-≈⁺ : _<_ Respectsˡ _≈_ → _<⁺_ Respectsˡ _≈⁺_
<⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] [ q ] = [ <-respˡ-≈ p q ]
<⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] ([ l ]<⊤⁺) = [ _ ]<⊤⁺
<⁺-respˡ-≈⁺ <-respˡ-≈ ⊤⁺≈⊤⁺ q = q
<⁺-respʳ-≈⁺ : _<_ Respectsʳ _≈_ → _<⁺_ Respectsʳ _≈⁺_
<⁺-respʳ-≈⁺ <-respʳ-≈ [ p ] [ q ] = [ <-respʳ-≈ p q ]
<⁺-respʳ-≈⁺ <-respʳ-≈ ⊤⁺≈⊤⁺ q = q
<⁺-resp-≈⁺ : _<_ Respects₂ _≈_ → _<⁺_ Respects₂ _≈⁺_
<⁺-resp-≈⁺ = map <⁺-respʳ-≈⁺ <⁺-respˡ-≈⁺
module _ {r} {_≤_ : Rel A r} where
open NonStrict _≤_
<⁺-transʳ : Trans _≤_ _<_ _<_ → Trans _≤⁺_ _<⁺_ _<⁺_
<⁺-transʳ <-transʳ [ p ] [ q ] = [ <-transʳ p q ]
<⁺-transʳ <-transʳ [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺
<⁺-transˡ : Trans _<_ _≤_ _<_ → Trans _<⁺_ _≤⁺_ _<⁺_
<⁺-transˡ <-transˡ [ p ] [ q ] = [ <-transˡ p q ]
<⁺-transˡ <-transˡ [ p ] ([ _ ] ≤⊤⁺) = [ _ ]<⊤⁺
<⁺-transˡ <-transˡ [ k ]<⊤⁺ (⊤⁺ ≤⊤⁺) = [ k ]<⊤⁺
------------------------------------------------------------------------
-- Structures
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<⁺-isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_ →
IsStrictPartialOrder _≈⁺_ _<⁺_
<⁺-isStrictPartialOrder strict = record
{ isEquivalence = ≈⁺-isEquivalence isEquivalence
; irrefl = <⁺-irrefl irrefl
; trans = <⁺-trans trans
; <-resp-≈ = <⁺-resp-≈⁺ <-resp-≈
} where open IsStrictPartialOrder strict
<⁺-isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_ →
IsDecStrictPartialOrder _≈⁺_ _<⁺_
<⁺-isDecStrictPartialOrder dectot = record
{ isStrictPartialOrder = <⁺-isStrictPartialOrder isStrictPartialOrder
; _≟_ = ≈⁺-dec _≟_
; _<?_ = <⁺-dec _<?_
} where open IsDecStrictPartialOrder dectot
<⁺-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_ →
IsStrictTotalOrder _≈⁺_ _<⁺_
<⁺-isStrictTotalOrder strictot = record
{ isEquivalence = ≈⁺-isEquivalence isEquivalence
; trans = <⁺-trans trans
; compare = <⁺-cmp compare
} where open IsStrictTotalOrder strictot
| {
"alphanum_fraction": 0.4810421521,
"avg_line_length": 35.4962406015,
"ext": "agda",
"hexsha": "dfd228d98359e63e65f85540a38690c6aef9398d",
"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/Relation/Binary/Construct/Add/Supremum/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/Relation/Binary/Construct/Add/Supremum/Strict.agda",
"max_line_length": 75,
"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/Relation/Binary/Construct/Add/Supremum/Strict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2029,
"size": 4721
} |
-- The SIP applied to groups
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group.GroupPath where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws hiding (assoc)
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
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.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
private
variable
ℓ ℓ' ℓ'' : Level
open Iso
open GroupStr
open IsGroupHom
𝒮ᴰ-Group : DUARel (𝒮-Univ ℓ) GroupStr ℓ
𝒮ᴰ-Group =
𝒮ᴰ-Record (𝒮-Univ _) IsGroupEquiv
(fields:
data[ _·_ ∣ autoDUARel _ _ ∣ pres· ]
data[ 1g ∣ autoDUARel _ _ ∣ pres1 ]
data[ inv ∣ autoDUARel _ _ ∣ presinv ]
prop[ isGroup ∣ (λ _ _ → isPropIsGroup _ _ _) ])
where
open GroupStr
open IsGroupHom
GroupPath : (M N : Group ℓ) → GroupEquiv M N ≃ (M ≡ N)
GroupPath = ∫ 𝒮ᴰ-Group .UARel.ua
-- The module below defines a group induced from an equivalence
-- between a group G and a type A which preserves the full raw group
-- structure from G to A. This version is useful when proving that
-- some type equivalent to a group is a group while also specifying
-- the binary operation, unit and inverse.
module _ (G : Group ℓ) {A : Type ℓ}
(m : A → A → A)
(u : A)
(inverse : A → A)
(e : ⟨ G ⟩ ≃ A)
(p· : ∀ x y → e .fst (G .snd ._·_ x y) ≡ m (e .fst x) (e .fst y))
(pu : e .fst (G .snd .1g) ≡ u)
(pinv : ∀ x → e .fst (G .snd .inv x) ≡ inverse (e .fst x))
where
private
module G = GroupStr (G .snd)
BaseΣ : Type (ℓ-suc ℓ)
BaseΣ = Σ[ B ∈ Type ℓ ] (B → B → B) × B × (B → B)
FamilyΣ : BaseΣ → Type ℓ
FamilyΣ (B , m , u , i) = IsGroup u m i
inducedΣ : FamilyΣ (A , m , u , inverse)
inducedΣ =
subst FamilyΣ
(UARel.≅→≡ (autoUARel BaseΣ) (e , p· , pu , pinv))
G.isGroup
InducedGroup : Group ℓ
InducedGroup .fst = A
InducedGroup .snd ._·_ = m
InducedGroup .snd .1g = u
InducedGroup .snd .inv = inverse
InducedGroup .snd .isGroup = inducedΣ
InducedGroupEquiv : GroupEquiv G InducedGroup
fst InducedGroupEquiv = e
snd InducedGroupEquiv = makeIsGroupHom p·
InducedGroupPath : G ≡ InducedGroup
InducedGroupPath = GroupPath _ _ .fst InducedGroupEquiv
-- The module below defines a group induced from an equivalence which
-- preserves the binary operation (i.e. a group isomorphism). This
-- version is useful when proving that some type equivalent to a group
-- G is a group when one doesn't care about what the unit and inverse
-- are. When using this version the unit and inverse will both be
-- defined by transporting over the unit and inverse from G to A.
module _ (G : Group ℓ) {A : Type ℓ}
(m : A → A → A)
(e : ⟨ G ⟩ ≃ A)
(p· : ∀ x y → e .fst (G .snd ._·_ x y) ≡ m (e .fst x) (e .fst y))
where
private
module G = GroupStr (G .snd)
FamilyΣ : Σ[ B ∈ Type ℓ ] (B → B → B) → Type ℓ
FamilyΣ (B , n) = Σ[ e ∈ B ] Σ[ i ∈ (B → B) ] IsGroup e n i
inducedΣ : FamilyΣ (A , m)
inducedΣ =
subst FamilyΣ
(UARel.≅→≡ (autoUARel (Σ[ B ∈ Type ℓ ] (B → B → B))) (e , p·))
(G.1g , G.inv , G.isGroup)
InducedGroupFromPres· : Group ℓ
InducedGroupFromPres· .fst = A
InducedGroupFromPres· .snd ._·_ = m
InducedGroupFromPres· .snd .1g = inducedΣ .fst
InducedGroupFromPres· .snd .inv = inducedΣ .snd .fst
InducedGroupFromPres· .snd .isGroup = inducedΣ .snd .snd
InducedGroupEquivFromPres· : GroupEquiv G InducedGroupFromPres·
fst InducedGroupEquivFromPres· = e
snd InducedGroupEquivFromPres· = makeIsGroupHom p·
InducedGroupPathFromPres· : G ≡ InducedGroupFromPres·
InducedGroupPathFromPres· = GroupPath _ _ .fst InducedGroupEquivFromPres·
uaGroup : {G H : Group ℓ} → GroupEquiv G H → G ≡ H
uaGroup {G = G} {H = H} = equivFun (GroupPath G H)
-- Group-ua functoriality
Group≡ : (G H : Group ℓ) → (
Σ[ p ∈ ⟨ G ⟩ ≡ ⟨ H ⟩ ]
Σ[ q ∈ PathP (λ i → p i) (1g (snd G)) (1g (snd H)) ]
Σ[ r ∈ PathP (λ i → p i → p i → p i) (_·_ (snd G)) (_·_ (snd H)) ]
Σ[ s ∈ PathP (λ i → p i → p i) (inv (snd G)) (inv (snd H)) ]
PathP (λ i → IsGroup (q i) (r i) (s i)) (isGroup (snd G)) (isGroup (snd H)))
≃ (G ≡ H)
Group≡ G H = isoToEquiv theIso
where
theIso : Iso _ _
fun theIso (p , q , r , s , t) i = p i , groupstr (q i) (r i) (s i) (t i)
inv theIso x = cong ⟨_⟩ x , cong (1g ∘ snd) x , cong (_·_ ∘ snd) x , cong (inv ∘ snd) x , cong (isGroup ∘ snd) x
rightInv theIso _ = refl
leftInv theIso _ = refl
caracGroup≡ : {G H : Group ℓ} (p q : G ≡ H) → cong ⟨_⟩ p ≡ cong ⟨_⟩ q → p ≡ q
caracGroup≡ {G = G} {H = H} p q P =
sym (transportTransport⁻ (ua (Group≡ G H)) p)
∙∙ cong (transport (ua (Group≡ G H))) helper
∙∙ transportTransport⁻ (ua (Group≡ G H)) q
where
helper : transport (sym (ua (Group≡ G H))) p ≡ transport (sym (ua (Group≡ G H))) q
helper = Σ≡Prop
(λ _ → isPropΣ
(isOfHLevelPathP' 1 (is-set (snd H)) _ _)
λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set (snd H)) _ _)
λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ λ _ → is-set (snd H)) _ _)
λ _ → isOfHLevelPathP 1 (isPropIsGroup _ _ _) _ _)
(transportRefl (cong ⟨_⟩ p) ∙ P ∙ sym (transportRefl (cong ⟨_⟩ q)))
uaGroupId : (G : Group ℓ) → uaGroup (idGroupEquiv {G = G}) ≡ refl
uaGroupId G = caracGroup≡ _ _ uaIdEquiv
uaCompGroupEquiv : {F G H : Group ℓ} (f : GroupEquiv F G) (g : GroupEquiv G H)
→ uaGroup (compGroupEquiv f g) ≡ uaGroup f ∙ uaGroup g
uaCompGroupEquiv f g = caracGroup≡ _ _ (
cong ⟨_⟩ (uaGroup (compGroupEquiv f g))
≡⟨ uaCompEquiv _ _ ⟩
cong ⟨_⟩ (uaGroup f) ∙ cong ⟨_⟩ (uaGroup g)
≡⟨ sym (cong-∙ ⟨_⟩ (uaGroup f) (uaGroup g)) ⟩
cong ⟨_⟩ (uaGroup f ∙ uaGroup g) ∎)
-- J-rule for GroupEquivs
GroupEquivJ : {G : Group ℓ} (P : (H : Group ℓ) → GroupEquiv G H → Type ℓ')
→ P G idGroupEquiv
→ ∀ {H} e → P H e
GroupEquivJ {G = G} P p {H} e =
transport (λ i → P (GroupPath G H .fst e i)
(transp (λ j → GroupEquiv G (GroupPath G H .fst e (i ∨ ~ j))) i e))
(subst (P G) (sym lem) p)
where
lem : transport (λ j → GroupEquiv G (GroupPath G H .fst e (~ j))) e
≡ idGroupEquiv
lem = Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(Σ≡Prop (λ _ → isPropIsEquiv _)
(funExt λ x → (λ i → fst (fst (fst e .snd .equiv-proof
(transportRefl (fst (fst e) (transportRefl x i)) i))))
∙ retEq (fst e) x))
| {
"alphanum_fraction": 0.6094328869,
"avg_line_length": 35.4444444444,
"ext": "agda",
"hexsha": "84c33a481e09ce8bca522e792d4235a5276dcae6",
"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/Group/GroupPath.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/Group/GroupPath.agda",
"max_line_length": 114,
"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/Group/GroupPath.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2585,
"size": 7018
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.List.Properties where
open import Agda.Builtin.List
open import Cubical.Core.Everything
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Nat
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Relation.Nullary
open import Cubical.Data.List.Base
module _ {ℓ} {A : Type ℓ} where
++-unit-r : (xs : List A) → xs ++ [] ≡ xs
++-unit-r [] = refl
++-unit-r (x ∷ xs) = cong (_∷_ x) (++-unit-r xs)
++-assoc : (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs
++-assoc [] ys zs = refl
++-assoc (x ∷ xs) ys zs = cong (_∷_ x) (++-assoc xs ys zs)
rev-snoc : (xs : List A) (y : A) → rev (xs ++ [ y ]) ≡ y ∷ rev xs
rev-snoc [] y = refl
rev-snoc (x ∷ xs) y = cong (_++ [ x ]) (rev-snoc xs y)
rev-++ : (xs ys : List A) → rev (xs ++ ys) ≡ rev ys ++ rev xs
rev-++ [] ys = sym (++-unit-r (rev ys))
rev-++ (x ∷ xs) ys =
cong (λ zs → zs ++ [ x ]) (rev-++ xs ys)
∙ ++-assoc (rev ys) (rev xs) [ x ]
rev-rev : (xs : List A) → rev (rev xs) ≡ xs
rev-rev [] = refl
rev-rev (x ∷ xs) = rev-snoc (rev xs) x ∙ cong (_∷_ x) (rev-rev xs)
rev-rev-snoc : (xs : List A) (y : A) →
Square (rev-rev (xs ++ [ y ])) (cong (_++ [ y ]) (rev-rev xs)) (cong rev (rev-snoc xs y)) refl
rev-rev-snoc [] y = sym (lUnit refl)
rev-rev-snoc (x ∷ xs) y i j =
hcomp
(λ k → λ
{ (i = i1) → compPath-filler (rev-snoc (rev xs) x) (cong (x ∷_) (rev-rev xs)) k j ++ [ y ]
; (j = i0) → rev (rev-snoc xs y i ++ [ x ])
; (j = i1) → x ∷ rev-rev-snoc xs y i k
})
(rev-snoc (rev-snoc xs y i) x j)
data SnocView : List A → Type ℓ where
nil : SnocView []
snoc : (x : A) → (xs : List A) → (sx : SnocView xs) → SnocView (xs ∷ʳ x)
snocView : (xs : List A) → SnocView xs
snocView xs = helper nil xs
where
helper : {l : List A} -> SnocView l -> (r : List A) -> SnocView (l ++ r)
helper {l} sl [] = subst SnocView (sym (++-unit-r l)) sl
helper {l} sl (x ∷ r) = subst SnocView (++-assoc l (x ∷ []) r) (helper (snoc x l sl) r)
-- Path space of list type
module ListPath {ℓ} {A : Type ℓ} where
Cover : List A → List A → Type ℓ
Cover [] [] = Lift Unit
Cover [] (_ ∷ _) = Lift ⊥
Cover (_ ∷ _) [] = Lift ⊥
Cover (x ∷ xs) (y ∷ ys) = (x ≡ y) × Cover xs ys
reflCode : ∀ xs → Cover xs xs
reflCode [] = lift tt
reflCode (_ ∷ xs) = refl , reflCode xs
encode : ∀ xs ys → (p : xs ≡ ys) → Cover xs ys
encode xs _ = J (λ ys _ → Cover xs ys) (reflCode xs)
encodeRefl : ∀ xs → encode xs xs refl ≡ reflCode xs
encodeRefl xs = JRefl (λ ys _ → Cover xs ys) (reflCode xs)
decode : ∀ xs ys → Cover xs ys → xs ≡ ys
decode [] [] _ = refl
decode [] (_ ∷ _) (lift ())
decode (x ∷ xs) [] (lift ())
decode (x ∷ xs) (y ∷ ys) (p , c) = cong₂ _∷_ p (decode xs ys c)
decodeRefl : ∀ xs → decode xs xs (reflCode xs) ≡ refl
decodeRefl [] = refl
decodeRefl (x ∷ xs) = cong (cong₂ _∷_ refl) (decodeRefl xs)
decodeEncode : ∀ xs ys → (p : xs ≡ ys) → decode xs ys (encode xs ys p) ≡ p
decodeEncode xs _ =
J (λ ys p → decode xs ys (encode xs ys p) ≡ p)
(cong (decode xs xs) (encodeRefl xs) ∙ decodeRefl xs)
isOfHLevelCover : (n : HLevel) (p : isOfHLevel (suc (suc n)) A)
(xs ys : List A) → isOfHLevel (suc n) (Cover xs ys)
isOfHLevelCover n p [] [] =
isOfHLevelLift (suc n) (isProp→isOfHLevelSuc n isPropUnit)
isOfHLevelCover n p [] (y ∷ ys) =
isOfHLevelLift (suc n) (isProp→isOfHLevelSuc n isProp⊥)
isOfHLevelCover n p (x ∷ xs) [] =
isOfHLevelLift (suc n) (isProp→isOfHLevelSuc n isProp⊥)
isOfHLevelCover n p (x ∷ xs) (y ∷ ys) =
isOfHLevelΣ (suc n) (p x y) (\ _ → isOfHLevelCover n p xs ys)
isOfHLevelList : ∀ {ℓ} (n : HLevel) {A : Type ℓ}
→ isOfHLevel (suc (suc n)) A → isOfHLevel (suc (suc n)) (List A)
isOfHLevelList n ofLevel xs ys =
isOfHLevelRetract (suc n)
(ListPath.encode xs ys)
(ListPath.decode xs ys)
(ListPath.decodeEncode xs ys)
(ListPath.isOfHLevelCover n ofLevel xs ys)
private
variable
ℓ : Level
A : Type ℓ
caseList : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → (n c : B) → List A → B
caseList n _ [] = n
caseList _ c (_ ∷ _) = c
safe-head : A → List A → A
safe-head x [] = x
safe-head _ (x ∷ _) = x
safe-tail : List A → List A
safe-tail [] = []
safe-tail (_ ∷ xs) = xs
cons-inj₁ : ∀ {x y : A} {xs ys} → x ∷ xs ≡ y ∷ ys → x ≡ y
cons-inj₁ {x = x} p = cong (safe-head x) p
cons-inj₂ : ∀ {x y : A} {xs ys} → x ∷ xs ≡ y ∷ ys → xs ≡ ys
cons-inj₂ = cong safe-tail
¬cons≡nil : ∀ {x : A} {xs} → ¬ (x ∷ xs ≡ [])
¬cons≡nil {A = A} p = lower (subst (caseList (Lift ⊥) (List A)) p [])
¬nil≡cons : ∀ {x : A} {xs} → ¬ ([] ≡ x ∷ xs)
¬nil≡cons {A = A} p = lower (subst (caseList (List A) (Lift ⊥)) p [])
¬snoc≡nil : ∀ {x : A} {xs} → ¬ (xs ∷ʳ x ≡ [])
¬snoc≡nil {xs = []} contra = ¬cons≡nil contra
¬snoc≡nil {xs = x ∷ xs} contra = ¬cons≡nil contra
¬nil≡snoc : ∀ {x : A} {xs} → ¬ ([] ≡ xs ∷ʳ x)
¬nil≡snoc contra = ¬snoc≡nil (sym contra)
cons≡rev-snoc : (x : A) → (xs : List A) → x ∷ rev xs ≡ rev (xs ∷ʳ x)
cons≡rev-snoc _ [] = refl
cons≡rev-snoc x (y ∷ ys) = λ i → cons≡rev-snoc x ys i ++ y ∷ []
isContr[]≡[] : isContr (Path (List A) [] [])
isContr[]≡[] = refl , ListPath.decodeEncode [] []
isPropXs≡[] : {xs : List A} → isProp (xs ≡ [])
isPropXs≡[] {xs = []} = isOfHLevelSuc 0 isContr[]≡[]
isPropXs≡[] {xs = x ∷ xs} = λ p _ → ⊥.rec (¬cons≡nil p)
discreteList : Discrete A → Discrete (List A)
discreteList eqA [] [] = yes refl
discreteList eqA [] (y ∷ ys) = no ¬nil≡cons
discreteList eqA (x ∷ xs) [] = no ¬cons≡nil
discreteList eqA (x ∷ xs) (y ∷ ys) with eqA x y | discreteList eqA xs ys
... | yes p | yes q = yes (λ i → p i ∷ q i)
... | yes _ | no ¬q = no (λ p → ¬q (cons-inj₂ p))
... | no ¬p | _ = no (λ q → ¬p (cons-inj₁ q))
foldrCons : (xs : List A) → foldr _∷_ [] xs ≡ xs
foldrCons [] = refl
foldrCons (x ∷ xs) = cong (x ∷_) (foldrCons xs)
| {
"alphanum_fraction": 0.5496721311,
"avg_line_length": 34.4632768362,
"ext": "agda",
"hexsha": "20120e22d3bbd01f762bafa079945177c5b0f576",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/List/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Data/List/Properties.agda",
"max_line_length": 98,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Data/List/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2504,
"size": 6100
} |
open import Data.Product using ( ∃ ; _×_ ; _,_ ; proj₁ ; proj₂ )
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 ; _≋_ )
open import Web.Semantic.DL.ABox.Model using
( _⊨a_ ; ⊨a-resp-≲ ; ⟨ABox⟩-resp-⊨ ; *-resp-⟨ABox⟩
; on-bnode ; bnodes ; _⊨b_ ; _,_ )
open import Web.Semantic.DL.Category.Morphism using
( _⇒_ ; _⇒_w/_ ; _,_ ; BN ; impl ; impl✓ )
open import Web.Semantic.DL.Category.Object using
( Object ; _,_ ; IN ; iface )
open import Web.Semantic.DL.Integrity using
( Unique ; Mediated ; Mediator ; Initial ; _⊕_⊨_ ; _>>_ ; _,_
; med-≲ ; med-≋ ; med-uniq ; init-≲ ; init-⊨ ; init-med
; extension ; ext-⊨ ; ext-init ; ext✓ )
open import Web.Semantic.DL.KB using ( KB ; _,_ )
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 ) renaming
( Interp to Interp′ )
open import Web.Semantic.DL.TBox.Model using ( _⊨t_ )
open import Web.Semantic.DL.TBox.Interp.Morphism using
( ≲-image ; ≲-refl ; ≲-trans ; ≲-resp-≈ ) renaming
( _≲_ to _≲′_ )
open import Web.Semantic.Util using
( _⊕_⊕_ ; inode ; bnode ; enode ; left ; right ; hmerge ; _∘_ )
module Web.Semantic.DL.Category.Composition {Σ : Signature} where
infixr 5 _⟫_ _∙_
_⟫_ : ∀ {V W X Y Z} → ABox Σ (X ⊕ V ⊕ Y) → ABox Σ (Y ⊕ W ⊕ Z) →
ABox Σ (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z)
F ⟫ G = (⟨ABox⟩ left F , ⟨ABox⟩ right G)
pipe : ∀ {V W X Y Z} →
(J : Interp Σ (X ⊕ V ⊕ Y)) → (K : Interp Σ (Y ⊕ W ⊕ Z)) →
(enode * J ≲ inode * K) → (Interp Σ (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z))
pipe (J , j) (K , k) (J≲K , j≲k) = (K , hmerge (≲-image J≲K ∘ j) k)
pipe-≳ : ∀ {V W X Y Z} → (I : Interp Σ X) →
(J : Interp Σ (X ⊕ V ⊕ Y)) → (K : Interp Σ (Y ⊕ W ⊕ Z)) →
(I≲J : I ≲ inode * J) → (J≲K : enode * J ≲ inode * K) →
(I ≲ inode * (pipe J K J≲K))
pipe-≳ (I , i) (J , j) (K , k) (I≲J , i≲j) (J≲K , j≲k) =
(≲-trans I≲J J≲K , λ x → ≲-resp-≈ J≲K (i≲j x))
pipe-left : ∀ {V W X Y Z} → (J : Interp Σ (X ⊕ V ⊕ Y)) →
(K : Interp Σ (Y ⊕ W ⊕ Z)) → (J≲K : enode * J ≲ inode * K) →
(J ≲ left * (pipe J K J≲K))
pipe-left (J , j) (K , k) (J≲K , j≲k) = (J≲K , lemma) where
lemma : ∀ x →
K ⊨ ≲-image J≲K (j x) ≈ hmerge (≲-image J≲K ∘ j) k (left x)
lemma (inode x) = ≈-refl K
lemma (bnode v) = ≈-refl K
lemma (enode y) = j≲k y
pipe-right : ∀ {V W X Y Z} → (J : Interp Σ (X ⊕ V ⊕ Y)) →
(K : Interp Σ (Y ⊕ W ⊕ Z)) → (J≲K : enode * J ≲ inode * K) →
(K ≲ right * (pipe J K J≲K))
pipe-right (J , j) (K , k) (J≲K , j≲k) = (≲-refl K , lemma) where
lemma : ∀ x →
K ⊨ k x ≈ hmerge (≲-image J≲K ∘ j) k (right x)
lemma (inode y) = ≈-refl K
lemma (bnode w) = ≈-refl K
lemma (enode z) = ≈-refl K
pipe-exp : ∀ {V W X Y Z} → (J : Interp Σ (X ⊕ V ⊕ Y)) →
(K : Interp Σ (Y ⊕ W ⊕ Z)) → (J≲K : enode * J ≲ inode * K) →
∀ KB → (enode * K ⊨ KB) → (enode * pipe J K J≲K ⊨ KB)
pipe-exp (J , j) (K , k) (J≲K , j≲k) KB K⊨KB = K⊨KB
⊨a-intro-⟫ : ∀ {V W X Y Z} → (I : Interp Σ (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z)) →
(F : ABox Σ (X ⊕ V ⊕ Y)) → (G : ABox Σ (Y ⊕ W ⊕ Z)) →
(left * I ⊨a F) → (right * I ⊨a G) → (I ⊨a F ⟫ G)
⊨a-intro-⟫ (I , i) F G I⊨F I⊨G =
( ⟨ABox⟩-resp-⊨ left (λ x → ≈-refl I) F I⊨F
, ⟨ABox⟩-resp-⊨ right (λ x → ≈-refl I) G I⊨G )
⊨b-intro-⟫ : ∀ {V₁ W₁ V₂ W₂ X Y Z} → (I : Interp Σ (X ⊕ (V₁ ⊕ Y ⊕ W₁) ⊕ Z)) →
(F : ABox Σ (X ⊕ V₂ ⊕ Y)) → (G : ABox Σ (Y ⊕ W₂ ⊕ Z)) →
(left * I ⊨b F) → (right * I ⊨b G) → (I ⊨b F ⟫ G)
⊨b-intro-⟫ {V₂ = V₂} {W₂ = W₂} {Y = Y} (I , i) F G (f , I⊨F) (g , I⊨G) =
(h , I⊨F⟫G) where
h : (V₂ ⊕ Y ⊕ W₂) → Δ I
h (inode v) = f v
h (bnode y) = i (bnode (bnode y))
h (enode w) = g w
lemmaˡ : ∀ x →
I ⊨ on-bnode f (i ∘ left) x ≈ on-bnode h i (left x)
lemmaˡ (inode x) = ≈-refl I
lemmaˡ (bnode v) = ≈-refl I
lemmaˡ (enode y) = ≈-refl I
lemmaʳ : ∀ x →
I ⊨ on-bnode g (i ∘ right) x ≈ on-bnode h i (right x)
lemmaʳ (inode x) = ≈-refl I
lemmaʳ (bnode v) = ≈-refl I
lemmaʳ (enode y) = ≈-refl I
I⊨F⟫G : bnodes (I , i) h ⊨a F ⟫ G
I⊨F⟫G = ⊨a-intro-⟫ (bnodes (I , i) h) F G
(⊨a-resp-≲ (≲-refl I , lemmaˡ) F I⊨F)
(⊨a-resp-≲ (≲-refl I , lemmaʳ) G I⊨G)
pipe-uniq : ∀ {V W X Y Z} I J K (M : Interp Σ (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z))
(I≲J : I ≲ inode * J) (I≲M : I ≲ inode * M) →
(J≲K : enode * J ≲ inode * K) (J≲M : J ≲ left * M) →
(I≲M ≋ I≲J >> J≲M) →
(Unique I J (left * M) I≲J I≲M) →
(Unique (enode * J) K (right * M) J≲K (enode ** J≲M)) →
(Unique I (pipe J K J≲K) M (pipe-≳ I J K I≲J J≲K) I≲M)
pipe-uniq {V} {W} {X} {Y} {Z} (I , i) (J , j) (K , k) (M , m)
(I≲J , i≲j) (I≲M , i≲m) (J≲K , j≲k) (J≲M , j≲m) I≲M≋I≲J≲M J≲M-uniq K≲M-uniq
(L≲₁M , l≲₁m) (L≲₂M , l≲₂m) I≲M≋I≲L≲₁M I≲M≋I≲L≲₂M =
K≲M-uniq
(L≲₁M , lemmaʳ L≲₁M l≲₁m I≲M≋I≲L≲₁M)
(L≲₂M , lemmaʳ L≲₂M l≲₂m I≲M≋I≲L≲₂M)
(J≲M-uniq (J≲M , j≲m)
(≲-trans J≲K L≲₁M , lemmaˡ L≲₁M l≲₁m I≲M≋I≲L≲₁M)
I≲M≋I≲J≲M
I≲M≋I≲L≲₁M )
(J≲M-uniq (J≲M , j≲m)
( ≲-trans J≲K L≲₂M , lemmaˡ L≲₂M l≲₂m I≲M≋I≲L≲₂M)
I≲M≋I≲J≲M
I≲M≋I≲L≲₂M ) where
L : Interp′ Σ
L = K
l : (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z) → Δ L
l = hmerge (≲-image J≲K ∘ j) k
I≲L : I ≲′ L
I≲L = ≲-trans I≲J J≲K
lemmaˡ : ∀ L≲M → (∀ x → M ⊨ ≲-image L≲M (l x) ≈ m x) →
(∀ x → M ⊨ ≲-image I≲M x ≈ ≲-image L≲M (≲-image I≲L x)) →
∀ x → M ⊨ ≲-image L≲M (≲-image J≲K (j x)) ≈ m (left x)
lemmaˡ L≲M l≲m I≲M≋I≲L≲M (inode x) = l≲m (inode x)
lemmaˡ L≲M l≲m I≲M≋I≲L≲M (bnode v) = l≲m (bnode (inode v))
lemmaˡ L≲M l≲m I≲M≋I≲L≲M (enode y) =
≈-trans M (≲-resp-≈ L≲M (j≲k y)) (l≲m (bnode (bnode y)))
lemmaʳ : ∀ L≲M → (∀ x → M ⊨ ≲-image L≲M (l x) ≈ m x) →
(∀ x → M ⊨ ≲-image I≲M x ≈ ≲-image L≲M (≲-image I≲L x)) →
∀ x → M ⊨ ≲-image L≲M (k x) ≈ m (right x)
lemmaʳ L≲M l≲m I≲M≋I≲L≲M (inode y) = l≲m (bnode (bnode y))
lemmaʳ L≲M l≲m I≲M≋I≲L≲M (bnode w) = l≲m (bnode (enode w))
lemmaʳ L≲M l≲m I≲M≋I≲L≲M (enode z) = l≲m (enode z)
pipe-mediated : ∀ {V W X Y Z} I J K (M : Interp Σ (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z))
(I≲J : I ≲ inode * J) (I≲M : I ≲ inode * M) →
(J≲K : enode * J ≲ inode * K) →
(m : Mediated I J (left * M) I≲J I≲M) →
(Mediated (enode * J) K (right * M) J≲K (enode ** (med-≲ m))) →
(Mediated I (pipe J K J≲K) M (pipe-≳ I J K I≲J J≲K) I≲M)
pipe-mediated {V} {W} {X} {Y} {Z} (I , i) (J , j) (K , k) (M , m)
(I≲J , i≲j) (I≲M , i≲m) (J≲K , j≲k)
((J≲M , j≲m) , I≲M≋I≲J≲M , J≲M-uniq)
((K≲M , k≲m) , J≲M≋J≲K≲M , K≲M-uniq) =
( (L≲M , l≲m) , I≲M≋I≲L≲M , L≲M-uniq) where
L : Interp′ Σ
L = K
l : (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z) → Δ L
l = hmerge (≲-image J≲K ∘ j) k
I≲L : I ≲′ L
I≲L = ≲-trans I≲J J≲K
i≲l : ∀ x → L ⊨ ≲-image I≲L (i x) ≈ l (inode x)
i≲l x = ≲-resp-≈ J≲K (i≲j x)
L≲M : L ≲′ M
L≲M = K≲M
l≲m : ∀ x → M ⊨ ≲-image K≲M (l x) ≈ m x
l≲m (inode x) =
≈-trans M (≈-sym M (J≲M≋J≲K≲M (j (inode x)))) (j≲m (inode x))
l≲m (bnode (inode v)) =
≈-trans M (≈-sym M (J≲M≋J≲K≲M (j (bnode v)))) (j≲m (bnode v))
l≲m (bnode (bnode y)) = k≲m (inode y)
l≲m (bnode (enode w)) = k≲m (bnode w)
l≲m (enode z) = k≲m (enode z)
I≲M≋I≲L≲M : ∀ x → M ⊨ ≲-image I≲M x ≈ ≲-image L≲M (≲-image I≲L x)
I≲M≋I≲L≲M x = ≈-trans M (I≲M≋I≲J≲M x) (J≲M≋J≲K≲M (≲-image I≲J x))
L≲M-uniq : Unique (I , i) (L , l) (M , m) (I≲L , i≲l) (I≲M , i≲m)
L≲M-uniq = pipe-uniq (I , i) (J , j) (K , k) (M , m)
(I≲J , i≲j) (I≲M , i≲m) (J≲K , j≲k) (J≲M , j≲m)
I≲M≋I≲J≲M J≲M-uniq K≲M-uniq
pipe-mediator : ∀ S {V W X Y Z I}
{J : Interp Σ (X ⊕ V ⊕ Y)} {K : Interp Σ (Y ⊕ W ⊕ Z)} {I≲J J≲K} F G →
(Mediator I J I≲J (S , F)) → (Mediator (enode * J) K J≲K (S , G)) →
(Mediator I (pipe J K J≲K) (pipe-≳ I J K I≲J J≲K) (S , F ⟫ G))
pipe-mediator S {V} {W} {X} {Y} {Z}
{I , i} {J , j} {K , k} {I≲J , i≲j} {J≲K , j≲k}
F G J-med K-med (M , m) (I≲M , i≲m) (M⊨S , M⊨F , M⊨G) =
pipe-mediated (I , i) (J , j) (K , k) (M , m)
(I≲J , i≲j) (I≲M , i≲m) (J≲K , j≲k)
I≲J≲M-med J≲K≲M-med where
mˡ : (X ⊕ V ⊕ Y) → Δ M
mˡ x = m (left x)
mʳ : (Y ⊕ W ⊕ Z) → Δ M
mʳ x = m (right x)
I≲J≲M-med : Mediated (I , i) (J , j) (M , mˡ) (I≲J , i≲j) (I≲M , i≲m)
I≲J≲M-med = J-med (M , mˡ) (I≲M , i≲m)
(M⊨S , *-resp-⟨ABox⟩ left (M , m) F M⊨F)
J≲M : J ≲′ M
J≲M = ≲⌊ med-≲ I≲J≲M-med ⌋
j≲m : ∀ x → M ⊨ ≲-image J≲M (j x) ≈ mˡ x
j≲m = ≲-resp-ind (med-≲ I≲J≲M-med)
j′ : Y → Δ J
j′ y = j (enode y)
j≲m′ : ∀ x → M ⊨ ≲-image J≲M (j′ x) ≈ m (bnode (bnode x))
j≲m′ x = j≲m (enode x)
J≲K≲M-med : Mediated (J , j′) (K , k) (M , mʳ) (J≲K , j≲k) (J≲M , j≲m′)
J≲K≲M-med = K-med (M , mʳ) (J≲M , j≲m′)
(M⊨S , *-resp-⟨ABox⟩ right (M , m) G M⊨G)
pipe-init : ∀ {S V W X Y Z I}
{J : Interp Σ (X ⊕ V ⊕ Y)} {K : Interp Σ (Y ⊕ W ⊕ Z)} {F G} →
(J-init : J ∈ Initial I (S , F)) →
(K-init : K ∈ Initial (enode * J) (S , G)) →
(pipe J K (init-≲ K-init) ∈ Initial I (S , F ⟫ G))
pipe-init {S} {V} {W} {X} {Y} {Z} {I , i} {J , j} {K , k} {F} {G}
((I≲J , i≲j) , (J⊨S , J⊨F) , J-med) ((J≲K , j≲k) , (K⊨S , K⊨G) , K-med) =
( (I≲L , i≲l) , (L⊨S , L⊨F⟫G) , L-med) where
L : Interp′ Σ
L = K
l : (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z) → Δ L
l = hmerge (≲-image J≲K ∘ j) k
I≲L : I ≲′ L
I≲L = ≲-trans I≲J J≲K
i≲l : ∀ x → L ⊨ ≲-image I≲L (i x) ≈ l (inode x)
i≲l x = ≲-resp-≈ J≲K (i≲j x)
L⊨S : L ⊨t S
L⊨S = K⊨S
L⊨F⟫G : (L , l) ⊨a F ⟫ G
L⊨F⟫G = ⊨a-intro-⟫ (L , l) F G
(⊨a-resp-≲ (pipe-left (J , j) (K , k) (J≲K , j≲k)) F J⊨F)
(⊨a-resp-≲ (pipe-right (J , j) (K , k) (J≲K , j≲k)) G K⊨G)
L-med : Mediator (I , i) (L , l) (I≲L , i≲l) (S , F ⟫ G)
L-med = pipe-mediator S F G J-med K-med
compose-⊨ : ∀ {S T V W X Y Z} A B C
(F : ABox Σ (X ⊕ V ⊕ Y)) (G : ABox Σ (Y ⊕ W ⊕ Z)) →
(∀ I → (I ⊨ (S , T) , A) → (I ⊕ S , F ⊨ T , B)) →
(∀ J → (J ⊨ (S , T) , B) → (J ⊕ S , G ⊨ T , C)) →
(∀ I → (I ⊨ (S , T) , A) → (I ⊕ S , F ⟫ G ⊨ T , C))
compose-⊨ {S} {T} {V} {W} {X} {Y} {Z} A B C F G F✓ G✓ I I⊨STA =
( pipe J K J≲K
, pipe-init J-init K-init
, pipe-exp J K J≲K (T , C) K⊨TC ) where
I⊕SF⊨TB : I ⊕ S , F ⊨ T , B
I⊕SF⊨TB = F✓ I I⊨STA
J : Interp Σ (X ⊕ V ⊕ Y)
J = extension I⊕SF⊨TB
J-init : J ∈ Initial I (S , F)
J-init = ext-init I⊕SF⊨TB
J⊕SG⊨TC : enode * J ⊕ S , G ⊨ T , C
J⊕SG⊨TC = G✓ (enode * J) (ext✓ I⊕SF⊨TB)
K : Interp Σ (Y ⊕ W ⊕ Z)
K = extension J⊕SG⊨TC
K⊨TC : enode * K ⊨ (T , C)
K⊨TC = ext-⊨ J⊕SG⊨TC
K-init : K ∈ Initial (enode * J) (S , G)
K-init = ext-init J⊕SG⊨TC
J≲K : enode * J ≲ inode * K
J≲K = init-≲ K-init
_∙′_ : ∀ {S T} {A B C : Object S T} → (F : A ⇒ B) → (G : B ⇒ C) →
(A ⇒ C w/ (BN F ⊕ IN B ⊕ BN G))
_∙′_ {S} {T} {X , X∈Fin , A} {Y , Y∈Fin , B} {Z , Z∈Fin , C} (V , F , F✓) (W , G , G✓) =
(F ⟫ G , compose-⊨ A B C F G F✓ G✓)
_∙_ : ∀ {S T} {A B C : Object S T} → (A ⇒ B) → (B ⇒ C) → (A ⇒ C)
F ∙ G = ( _ , F ∙′ G )
| {
"alphanum_fraction": 0.4431014415,
"avg_line_length": 35.4571428571,
"ext": "agda",
"hexsha": "07abe95cedf02c1b48e49e83d9a4624f85510011",
"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/Composition.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/Composition.agda",
"max_line_length": 89,
"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/Composition.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": 6636,
"size": 11169
} |
module Utility.Bool where
open import Agda.Builtin.Bool using (Bool; true; false)
not : Bool → Bool
not false = true
not true = false
_or_ : Bool → Bool → Bool
true or _ = true
_ or true = true
_ or _ = false
_and_ : Bool → Bool → Bool
true and true = true
_ and _ = false
| {
"alphanum_fraction": 0.6823104693,
"avg_line_length": 16.2941176471,
"ext": "agda",
"hexsha": "1afffb0da3abfd436439f361fec63588f59394b1",
"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/Utility/Bool.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/Utility/Bool.agda",
"max_line_length": 55,
"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/Utility/Bool.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": 84,
"size": 277
} |
{-# OPTIONS --no-pattern-matching #-}
id : {A : Set} (x : A) → A
id x = x
const : {A B : Set} (x : A) (y : B) → A
const x y = x
happ : {A B C : Set} (f : A → B → C) (g : A → B) (x : A) → C
happ f g x = f x (g x)
K = const
S = happ
I : {A : Set} (x : A) → A
I = S K K
-- Mmh, pretty boring...
| {
"alphanum_fraction": 0.432885906,
"avg_line_length": 15.6842105263,
"ext": "agda",
"hexsha": "904e68ac34e5b2e72b11f98b12587670dc48a28d",
"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/NoPatternMatching.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/NoPatternMatching.agda",
"max_line_length": 60,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/NoPatternMatching.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 137,
"size": 298
} |
-- Andreas, 2013-11-07
-- Instance candidates are now considered module judgemental equality.
module Issue899 where
postulate
A B : Set
f : {{ x : A }} → B
instance a : A
instance
a' : A
a' = a
test : B
test = f
{- The previous code fails with the following message:
Resolve implicit argument _x_257 : A. Candidates: [a : A, a : A]
There are indeed two values in scope of type A (a and a'), but given
that they are definitionally equal, Agda should not complain about it
but just pick any one of them. -}
| {
"alphanum_fraction": 0.6889312977,
"avg_line_length": 21.8333333333,
"ext": "agda",
"hexsha": "5f7c15b87879e5971ca3d58866d9e4abd1166806",
"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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/Issue899.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/Succeed/Issue899.agda",
"max_line_length": 70,
"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/Succeed/Issue899.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": 151,
"size": 524
} |
{-# OPTIONS --cubical --no-import-sorts #-}
module Test3 where
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Foundations.Logic
abstract
!_ : ∀{ℓ} {X : Type ℓ} → X → X
! x = x
!-≡ : ∀{ℓ} {X : Type ℓ} → (! X) ≡ X
!-≡ = refl -- makes use of the definition of `!_` within this block
!!_ : ∀{ℓ} {X : Type ℓ} → X → ! X
!!_ {X = X} x = transport (sym (!-≡ {X = X})) x
!!⁻¹_ : ∀{ℓ} {X : Type ℓ} → ! X → X
!!⁻¹_ {X = X} x = transport (!-≡ {X = X}) x
infix 1 !_
infix 1 !!_
infix 1 !!⁻¹_
-- !-≡' : ∀{ℓ} {X : Type ℓ} → (! X) ≡ X
-- !-≡' = refl -- cannot make use of the definition of `!_` anymore
hPropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
hPropRel A B ℓ' = A → B → hProp ℓ'
module TestB {ℓ ℓ'} (X : Type ℓ)
(0ˣ : X) (_+_ _·_ : X → X → X) (_<_ : hPropRel X X ℓ')
(let infixl 5 _+_; _+_ = _+_) where
_≤_ : hPropRel X X ℓ'
x ≤ y = ¬(y < x)
postulate
sqrt : (x : X) → {{ ! [ 0ˣ ≤ x ] }} → X
0≤x² : ∀ x → [ 0ˣ ≤ (x · x) ]
instance -- module-scope instances
_ = λ {x} → !! 0≤x² x
test4 : (x y z : X) → [ 0ˣ ≤ x ] → [ 0ˣ ≤ y ] → X
test4 x y z 0≤x 0≤y =
let instance -- let-scope instances
_ = !! 0≤x
_ = !! 0≤y
_ = !! 0≤x² x -- preferred over the instance from module-scope
in ( (sqrt x) -- works
+ (sqrt y) -- also works
+ (sqrt (z · z)) -- uses instance from module scope
+ (sqrt (x · x)) -- uses instance from let-scope (?) -- NOTE: see https://github.com/agda/agda/issues/4688
)
| {
"alphanum_fraction": 0.4796044499,
"avg_line_length": 28.8928571429,
"ext": "agda",
"hexsha": "738e18110147d5ec290a0007fdcff896608f64fc",
"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": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "test/Test3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"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": "mchristianl/synthetic-reals",
"max_issues_repo_path": "test/Test3.agda",
"max_line_length": 113,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "test/Test3.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z",
"num_tokens": 695,
"size": 1618
} |
module Oscar where
import Everything
import Test
-- journals
import $RequiredForInstanceResolution
import AbstractStrictlyPositive
import AgdaErrorDisplayForm197
import AgdaFeatureInstanceResolutionViaConstraint
import AgdaFeatureNeedHiddenVariableTypeConstructorWrapper
import AgdaFeatureNoInstanceFromHidden
import AgdaFeaturePitfallInstanceResolution
import AgdaFeatureTerminationViaExplicitness
import AgdaIssue2557
import AgdaModuleEqualsSyntaxProblem
import AgdaSubstitute98Bug
import ExplicitInstanceSearchRequired
import MutualLevel
import NoEtaExpandedInstanceFromSuperclass
import NonuniqueUnification
import ReflexivityInFlexibility
import TroubleUnifyingExtensionalReflection
import UnificationIncompleteness
import UnificationRant
| {
"alphanum_fraction": 0.9290495315,
"avg_line_length": 27.6666666667,
"ext": "agda",
"hexsha": "831cf91e3d7c102e529a4825f0fac7d2fef86df7",
"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-3/src/Oscar.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-3/src/Oscar.agda",
"max_line_length": 58,
"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-3/src/Oscar.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 161,
"size": 747
} |
module Coirc where
open import Coinduction
open import IO
open import Data.String
open import Data.Maybe
data SP (A B : Set) : Set where
get : (A → SP A B) → SP A B
put : B → ∞ (SP A B) → SP A B
data Event : Set where
notice mode numeric ping : Event
privmsg : (source text : String) → Event
data Action : Set where
print : (text : String) → Action
nick : (name : String) → Action
user : (name real : String) → Action
pong : (name : String) → Action
join part : (channel : String) → Action
privmsg : (target text : String) → Action
quit : (text : String) → Action
Bot = SP Event Action
| {
"alphanum_fraction": 0.647634584,
"avg_line_length": 23.5769230769,
"ext": "agda",
"hexsha": "5307d157ed367841957377faa890d69bb49706b0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:53:29.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:53:29.000Z",
"max_forks_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/coirc",
"max_forks_repo_path": "src/Coirc.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461",
"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": "larrytheliquid/coirc",
"max_issues_repo_path": "src/Coirc.agda",
"max_line_length": 43,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/coirc",
"max_stars_repo_path": "src/Coirc.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 189,
"size": 613
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import Functions.Definition
open import Groups.Definition
open import Rings.Homomorphisms.Definition
open import Setoids.Setoids
open import Rings.Definition
open import Sets.EquivalenceRelations
open import Groups.Lemmas
open import Rings.Ideals.Definition
module Rings.Cosets {a b c : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) {pred : A → Set c} (ideal : Ideal R pred) where
open Ring R
open import Rings.Lemmas R
open import Groups.Subgroups.Normal.Lemmas
open import Groups.Cosets additiveGroup (Ideal.isSubgroup ideal)
open Setoid S
open Equivalence eq
open Ideal ideal
open Group additiveGroup
cosetRing : Ring cosetSetoid _+_ _*_
Ring.additiveGroup cosetRing = cosetGroup (abelianGroupSubgroupIsNormal (Ideal.isSubgroup ideal) abelianUnderlyingGroup)
Ring.*WellDefined cosetRing {r} {s} {t} {u} r=t s=u = need
where
r=t' : pred ((inverse t + r) * u)
r=t' = accumulatesTimes r=t
s=u' : pred ((inverse u + s) * r)
s=u' = accumulatesTimes s=u
need : pred (inverse (t * u) + (r * s))
need = isSubset (transitive (+WellDefined (*DistributesOver+') *DistributesOver+') (transitive +Associative (+WellDefined (transitive (symmetric +Associative) (transitive (+WellDefined ringMinusExtracts' (transitive (+WellDefined reflexive (transitive ringMinusExtracts' (inverseWellDefined additiveGroup *Commutative))) invRight)) identRight)) *Commutative))) (closedUnderPlus r=t' s=u')
Ring.1R cosetRing = 1R
Ring.groupIsAbelian cosetRing = isSubset (transitive (symmetric invLeft) (+WellDefined (inverseWellDefined additiveGroup groupIsAbelian) reflexive)) containsIdentity
Ring.*Associative cosetRing = isSubset (transitive (symmetric invLeft) (+WellDefined (inverseWellDefined additiveGroup *Associative) reflexive)) containsIdentity
Ring.*Commutative cosetRing {a} {b} = isSubset (transitive (symmetric invLeft) (+WellDefined (inverseWellDefined additiveGroup *Commutative) reflexive)) containsIdentity
Ring.*DistributesOver+ cosetRing = isSubset (symmetric (transitive (+WellDefined (inverseWellDefined additiveGroup (symmetric *DistributesOver+)) reflexive) invLeft)) containsIdentity
Ring.identIsIdent cosetRing = isSubset (symmetric (transitive (Group.+WellDefined additiveGroup reflexive identIsIdent) invLeft)) containsIdentity
cosetRingHom : RingHom R cosetRing id
RingHom.preserves1 cosetRingHom = isSubset (symmetric invLeft) (Ideal.containsIdentity ideal)
RingHom.ringHom cosetRingHom = isSubset (symmetric invLeft) (Ideal.containsIdentity ideal)
RingHom.groupHom cosetRingHom = cosetGroupHom (abelianGroupSubgroupIsNormal (Ideal.isSubgroup ideal) abelianUnderlyingGroup)
| {
"alphanum_fraction": 0.7810650888,
"avg_line_length": 58.7826086957,
"ext": "agda",
"hexsha": "ad4da7f550d20f00277bf7289df850162ccfa8f7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Rings/Cosets.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Rings/Cosets.agda",
"max_line_length": 392,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Rings/Cosets.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 753,
"size": 2704
} |
module BasicIPC.Metatheory.Hilbert-TarskiGluedClosedImplicit where
open import BasicIPC.Syntax.Hilbert public
open import BasicIPC.Semantics.TarskiGluedClosedImplicit public
open ImplicitSyntax (∅ ⊢_) public
-- Completeness with respect to a particular model, for closed terms only.
module _ {{_ : Model}} where
reify : ∀ {A} → ⊩ A → ∅ ⊢ A
reify {α P} s = syn s
reify {A ▻ B} s = syn s
reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s))
reify {⊤} s = unit
-- Additional useful equipment.
module _ {{_ : Model}} where
⟪K⟫ : ∀ {A B} → ⊩ A → ⊩ B ▻ A
⟪K⟫ a = app ck (reify a) ⅋ K a
⟪S⟫′ : ∀ {A B C} → ⊩ A ▻ B ▻ C → ⊩ (A ▻ B) ▻ A ▻ C
⟪S⟫′ s₁ = app cs (reify s₁) ⅋ λ s₂ →
app (app cs (reify s₁)) (reify s₂) ⅋ ⟪S⟫ s₁ s₂
_⟪,⟫′_ : ∀ {A B} → ⊩ A → ⊩ B ▻ A ∧ B
_⟪,⟫′_ a = app cpair (reify a) ⅋ _,_ a
-- Soundness with respect to all models, or evaluation.
eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A
eval (var i) γ = lookup i γ
eval (app t u) γ = eval t γ ⟪$⟫ eval u γ
eval ci γ = ci ⅋ I
eval ck γ = ck ⅋ ⟪K⟫
eval cs γ = cs ⅋ ⟪S⟫′
eval cpair γ = cpair ⅋ _⟪,⟫′_
eval cfst γ = cfst ⅋ π₁
eval csnd γ = csnd ⅋ π₂
eval unit γ = ∙
-- Correctness of evaluation with respect to conversion.
eval✓ : ∀ {{_ : Model}} {A Γ} {t t′ : Γ ⊢ A} → t ⋙ t′ → eval t ≡ eval t′
eval✓ refl⋙ = refl
eval✓ (trans⋙ p q) = trans (eval✓ p) (eval✓ q)
eval✓ (sym⋙ p) = sym (eval✓ p)
eval✓ (congapp⋙ p q) = cong² _⟦$⟧_ (eval✓ p) (eval✓ q)
eval✓ (congi⋙ p) = cong I (eval✓ p)
eval✓ (congk⋙ p q) = cong² K (eval✓ p) (eval✓ q)
eval✓ (congs⋙ p q r) = cong³ ⟦S⟧ (eval✓ p) (eval✓ q) (eval✓ r)
eval✓ (congpair⋙ {A} {B} p q) = cong² (_⟦,⟧_ {A} {B}) (eval✓ p) (eval✓ q)
eval✓ (congfst⋙ {A} {B} p) = cong (⟦π₁⟧ {A} {B}) (eval✓ p)
eval✓ (congsnd⋙ {A} {B} p) = cong (⟦π₂⟧ {A} {B}) (eval✓ p)
eval✓ beta▻ₖ⋙ = refl
eval✓ beta▻ₛ⋙ = refl
eval✓ beta∧₁⋙ = refl
eval✓ beta∧₂⋙ = refl
eval✓ eta∧⋙ = refl
eval✓ eta⊤⋙ = refl
-- The canonical model.
private
instance
canon : Model
canon = record
{ ⊩ᵅ_ = λ P → ∅ ⊢ α P
}
-- Completeness with respect to all models, or quotation, for closed terms only.
quot₀ : ∀ {A} → ∅ ⊨ A → ∅ ⊢ A
quot₀ t = reify (t ∙)
-- Normalisation by evaluation, for closed terms only.
norm₀ : ∀ {A} → ∅ ⊢ A → ∅ ⊢ A
norm₀ = quot₀ ∘ eval
-- TODO: Correctness of normalisation with respect to conversion.
| {
"alphanum_fraction": 0.5118723239,
"avg_line_length": 28.2307692308,
"ext": "agda",
"hexsha": "2980f84052b6f1a00e58f67b4fb40adffdeafbb1",
"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": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIPC/Metatheory/Hilbert-TarskiGluedClosedImplicit.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIPC/Metatheory/Hilbert-TarskiGluedClosedImplicit.agda",
"max_line_length": 80,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIPC/Metatheory/Hilbert-TarskiGluedClosedImplicit.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 1121,
"size": 2569
} |
------------------------------------------------------------------------
-- Code related to the paper draft "Structurally Recursive Descent
-- Parsing"
--
-- Nils Anders Danielsson and Ulf Norell
------------------------------------------------------------------------
module StructurallyRecursiveDescentParsing where
-- The code presented here is not identical to that in the paper; it
-- has evolved.
-- Parser type indices.
import StructurallyRecursiveDescentParsing.Index
-- Parsers containing non-terminals, and grammars using such parsers.
import StructurallyRecursiveDescentParsing.Grammar
-- A library of derived parser combinators.
import StructurallyRecursiveDescentParsing.Lib
-- Some small examples.
import StructurallyRecursiveDescentParsing.Examples
-- An example: parsing PBM image files.
import StructurallyRecursiveDescentParsing.PBM
-- A depth-first backend.
import StructurallyRecursiveDescentParsing.DepthFirst
-- The backend does not work directly on the parsers in
-- StructurallyRecursiveDescentParsing.Grammar. The following
-- simplified parsers are used instead. The function
-- StructurallyRecursiveDescentParsing.Grammar.⟦_⟧ turns parsers
-- containing non-terminals into simplified parsers.
import StructurallyRecursiveDescentParsing.Simplified
import StructurallyRecursiveDescentParsing.Simplified.Semantics
| {
"alphanum_fraction": 0.7400295421,
"avg_line_length": 30.0888888889,
"ext": "agda",
"hexsha": "4800965ee93be941731df20e01ab9a52938a7df8",
"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": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "StructurallyRecursiveDescentParsing.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "StructurallyRecursiveDescentParsing.agda",
"max_line_length": 72,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yurrriq/parser-combinators",
"max_stars_repo_path": "StructurallyRecursiveDescentParsing.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z",
"num_tokens": 260,
"size": 1354
} |
module IrrelevantRecordField where
import Common.Irrelevance
record R (A : Set) : Set where
constructor inn
field
.out : A
proj : {A : Set} -> R A -> A
proj (inn a) = a
-- needs to fail, since a is irrelevant under inn | {
"alphanum_fraction": 0.6666666667,
"avg_line_length": 21,
"ext": "agda",
"hexsha": "08419b244884b7a8a420c90c7efd101f4879140b",
"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": "test/fail/IrrelevantRecordField.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/fail/IrrelevantRecordField.agda",
"max_line_length": 49,
"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": "test/fail/IrrelevantRecordField.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": 70,
"size": 231
} |
{-# OPTIONS --without-K --rewriting #-}
module Base where
open import lib.Basics
open import lib.Funext
open import lib.NType2
open import lib.types.Truncation
open import lib.types.Bool
quodlibet : {i : ULevel} {A : Type i} → ⊥ → A
quodlibet = ⊥-elim
-- infix notation for piping a term argument into a dependent function
_|>_ : ∀ {i j} {A : Type i} {B : A → Type j}
(a : A) (f : (a : A) → B a) → B a
a |> f = f a
-- infix notation for applying a path between two functions to an argument to give a path from f x to g x
_at_ : ∀ {i j} {A : Type i} {P : A → Type j} {f g : Π A P} (p : f == g) → f ∼ g
p at x = app= p x
End : ∀ {i} (X : Type i) → Type i
End X = X → X
-- composition of a dependent function with a fiberwise dependent function
infixl 80 _>>_
_>>_ : ∀ {i j k} {A : Type i} {B : A → Type j} {C : (a : A) → (B a → Type k)}
→ (f : Π A B) → (g : {a : A} → Π (B a) (C a)) → Π A (λ a → C a (f a))
f >> g = λ x → g (f x)
-- Crisp function types (the domain must be crisp)
_::→_ : {@♭ i : ULevel} {j : ULevel} (@♭ A : Type i) (B : Type j) → Type (lmax i j)
A ::→ B = (@♭ _ : A) → B
crispen : {@♭ i : ULevel} {j : ULevel} {@♭ A : Type i} {B : A → Type j}
→ ((a : A) → B a)
→ ((@♭ a : A) → B a)
crispen f a = f a
const : {i j : ULevel} {A : Type i} {B : Type j}
(b : B) → A → B
const b _ = b
crisp-const : {@♭ i : ULevel} {j : ULevel} {@♭ A : Type i} {B : Type j}
(b : B) → A ::→ B
crisp-const b _ = b
-- Crisp function extensionality (postulated for now, because I'm lazy)
postulate
-- domain is a crisp term of a crisp type
♭λ= : {@♭ i : ULevel} {j : ULevel} {@♭ A : Type i}
{B : A → Type j} {f g : (@♭ a : A) → B a}
(h : (@♭ a : A) → f a == g a)
→ f == g
-- Fully crisp function extensionalty: domain and codomain are crisp types
♭♭λ= : {@♭ i j : ULevel} {@♭ A : Type i}
{@♭ B : A → Type j} {@♭ f g : (@♭ a : A) → B a}
(@♭ h : (@♭ a : A) → f a == g a)
→ f == g
♭♭λ= h = ♭λ= h
-- The "identity path" is called refl
-- refl : ∀ {i} { A : Type i} {a : A} → a == a
pattern refl = idp
_is-an-equiv = is-equiv
_is-an-equivalence-because_is-inverse-by_and_ : ∀ {i} {j} {A : Type i} {B : Type j}
→ (f : A → B)
(g : B → A) (f-g : (b : B) → f (g b) == b)
(g-f : (a : A) → g (f a) == a) → is-equiv f
f is-an-equivalence-because g is-inverse-by f-g and g-f = is-eq f g f-g g-f
_is-split-inj : {i j : ULevel} {A : Type i} {B : Type j} (s : A → B) → Type (lmax i j)
_is-split-inj {A = A} {B = B} s = Σ (B → A) (λ r → (a : A) → r (s a) == a)
-- Implicit and Explicit function types are equivalent
imp-equiv-exp : {i j : ULevel} {A : Type i} {B : A → Type j}
→ ({a : A} → B a) ≃ ((a : A) → B a)
imp-equiv-exp = (λ f x → f {x}) ,
record
{ g = λ z {x} → z x
; f-g = λ b → idp
; g-f = λ a → idp
; adj = λ a → idp
}
exp-equiv-imp : {i j : ULevel} {A : Type i} {B : A → Type j}
→ ((a : A) → B a) ≃ ({a : A} → B a)
exp-equiv-imp = imp-equiv-exp ⁻¹
_⊔→_ : {i j k l : ULevel} {A : Type i} {B : Type j} {C : Type k} {D : Type l}
(f : A → C) (g : B → D)
→ A ⊔ B → C ⊔ D
(f ⊔→ g) (inl a) = inl (f a)
(f ⊔→ g) (inr b) = inr (g b)
_⊔e_ : {i j k l : ULevel} {A : Type i} {B : Type j} {C : Type k} {D : Type l}
(f : A ≃ C) (g : B ≃ D)
→ A ⊔ B ≃ C ⊔ D
f ⊔e g =
equiv
((–> f) ⊔→ (–> g))
((<– f) ⊔→ (<– g))
(λ {(inl c) → ap inl ((<–-inv-r f) c) ; (inr d) → ap inr ((<–-inv-r g) d) })
(λ {(inl a) → ap inl ((<–-inv-l f) a) ; (inr b) → ap inr ((<–-inv-l g) b) })
-- A non-instance version of this function because I find that instance so annoying
≃-preserves-level : ∀ {i j} {A : Type i} {B : Type j} {n : ℕ₋₂} (e : A ≃ B)
→ has-level n A → has-level n B
≃-preserves-level e p = equiv-preserves-level e {{p}}
-- An equivalence version of the above
≃-preserves-level-eq : ∀ {i j} {A : Type i} {B : Type j} {n : ℕ₋₂} (e : A ≃ B)
→ has-level n A ≃ has-level n B
≃-preserves-level-eq e =
equiv
(≃-preserves-level e)
(≃-preserves-level (e ⁻¹))
(λ b → prop-path has-level-is-prop _ _)
(λ a → prop-path has-level-is-prop _ _)
-- An equivalence between has-level-aux and has-level
has-level-def-eq : {i : ULevel} {A : Type i} {n : ℕ₋₂}
→ (has-level n A) ≃ (has-level-aux n A)
has-level-def-eq {A = A} {n = n} = equiv has-level-apply has-level-in (λ b → refl) (λ a → refl)
-- Compositional reasoning (like equational reasoning, but for composing)
infixr 15 _→∎
infixr 10 _–⟨_⟩→_
_–⟨_⟩→_ : ∀ {i j k} (A : Type i) {B : A → Type j} {C : (a : A) → B a → Type k}
→ (f : (a : A) → B a) → (g : {a : A} → (b : B a) → C a b)
→ ((a : A) → C a (f a))
_ –⟨ f ⟩→ g = f >> g
_→∎ : ∀ {i} (A : Type i) → A → A
_→∎ = idf
{-
-- SKETCHING
lemma : ∀ {i j} (A : Type i) (B : Type j) (a₀ : A)
(p : (f : A → B) (a : A) → (f a₀) == (f a))
→ (const {A = A} {B = B}) is-an-equiv
lemma A B a₀ p = is-eq const (λ f → f a₀) fro-to to-fro
where
to-fro : ∀ a → ((const a) a₀) == a
to-fro a = refl
fro-to : ∀ (f : A → B) → (const (f a₀)) == f
fro-to f =
λ= $
λ a → p f a
module _ {i j} (R : Type i) (r₀ : R) (B : Type j) (S : Type j) where
postulate
σ : B → S
contr : (γ : R → S) (r : R) → (γ r₀) == (γ r)
_is-discrete : ∀ {k} (X : Type k) → Type _
X is-discrete = (const {A = R} {B = X}) is-an-equiv
S-is-discrete : S is-discrete
S-is-discrete = lemma R S r₀ contr
-}
| {
"alphanum_fraction": 0.4358421751,
"avg_line_length": 34.4685714286,
"ext": "agda",
"hexsha": "d34847f5ec15296c6f9f00e87af3b53d12c2a790",
"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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "glangmead/formalization",
"max_forks_repo_path": "cohesion/david_jaz_261/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "glangmead/formalization",
"max_issues_repo_path": "cohesion/david_jaz_261/Base.agda",
"max_line_length": 107,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "glangmead/formalization",
"max_stars_repo_path": "cohesion/david_jaz_261/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z",
"num_tokens": 2384,
"size": 6032
} |
record R : Set where
a : R
a = r -- r should not ever be in scope
| {
"alphanum_fraction": 0.6,
"avg_line_length": 17.5,
"ext": "agda",
"hexsha": "c0ba732828078319f785a8998d0ace1fa0b9ff0a",
"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/Issue3566-4.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/Issue3566-4.agda",
"max_line_length": 40,
"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/Issue3566-4.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": 24,
"size": 70
} |
-- Andreas, 2021-07-14, issue #5470, reported by HarrisonGrodin
--
-- Importing a rewrite rule that was declared private
-- at the point of definition caused an internal error.
{-# OPTIONS --rewriting #-}
-- {-# OPTIONS -v impossible:10 #-}
-- {-# OPTIONS -v rewriting:100 #-}
module Issue5470 where
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Issue5470.Import
postulate
_≤_ : (n m : Nat) → Set
≤-refl : ∀{n} → n ≤ n
infix 4 _IsRelatedTo_
data _IsRelatedTo_ (x : Nat) : (y : Nat) → Set where
equals : x IsRelatedTo x
begin : ∀ {x y} → x IsRelatedTo y → x ≤ y
begin equals = ≤-refl
example : ∀ n → n ≤ bar n
example n = begin equals
-- WAS: internal error
-- Unbound name: Issue5470Import.lemma[0,10]@ModuleNameHash 8608063155492000951
| {
"alphanum_fraction": 0.6858237548,
"avg_line_length": 22.3714285714,
"ext": "agda",
"hexsha": "7ade1a1ec9ed926f733e71471073a572da2d6664",
"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/Issue5470.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/Issue5470.agda",
"max_line_length": 79,
"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/Issue5470.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": 251,
"size": 783
} |
------------------------------------------------------------------------
-- Connectedness for pointed types
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
import Equality.Path as P
module Pointed-type.Connected
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
open import Prelude
open import Equivalence equality-with-J as Eq using (_≃_)
open import Function-universe equality-with-J
open import Group equality-with-J as G using (_≃ᴳ_)
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import H-level.Truncation.Propositional eq as T using (∥_∥; ∣_∣)
import Nat equality-with-J as Nat
open import Pointed-type equality-with-J
open import Pointed-type.Homotopy-group eq
private
variable
p : Level
P : Pointed-type p
-- Connectedness.
--
-- This definition of what it means for a pointed type to be connected
-- is based on a characterisation given in the HoTT Book.
Connected : Pointed-type p → Type p
Connected (A , x) = (y : A) → ∥ x ≡ y ∥
-- The connected component of a pointed type.
--
-- I got this definition from Christian Sattler.
Connected-component : Pointed-type p → Pointed-type p
Connected-component (A , x) =
(∃ λ y → ∥ x ≡ y ∥) , (x , ∣ refl _ ∣)
-- There is a based embedding from the connected component of P to P.
--
-- This definition was suggested to me by Christian Sattler.
Connected-component↣ᴮ : Connected-component P ↝[ embedding ]ᴮ P
Connected-component↣ᴮ =
record { to = proj₁
; is-embedding = λ x y →
_≃_.is-equivalence $
Eq.with-other-function
(x ≡ y ↔⟨ inverse $ ignore-propositional-component T.truncation-is-proposition ⟩□
proj₁ x ≡ proj₁ y □)
(cong proj₁)
proj₁-Σ-≡,≡←≡
}
, refl _
-- The connected component is connected.
--
-- This definition was suggested to me by Christian Sattler.
Connected-Connected-component :
{P : Pointed-type p} →
Connected (Connected-component P)
Connected-Connected-component y =
flip T.∥∥-map (proj₂ y) λ eq →
Σ-≡,≡→≡ eq (T.truncation-is-proposition _ _)
-- If P has a certain positive h-level, then the same applies to the
-- connected component of P.
H-level-Connected-component :
∀ {P : Pointed-type p} n →
H-level (1 + n) (proj₁ P) →
H-level (1 + n) (proj₁ (Connected-component P))
H-level-Connected-component {P = A , x} n =
H-level (1 + n) A ↝⟨ (λ h →
Σ-closure (1 + n) h λ _ →
mono (Nat.suc≤suc (Nat.zero≤ n))
T.truncation-is-proposition) ⟩
H-level (1 + n) (∃ λ y → ∥ x ≡ y ∥) □
-- If the loop space of P has a certain h-level, then the same applies
-- to the loop space of the connected component of P.
H-level-Ω-Connected-component :
∀ {P : Pointed-type p} n →
H-level n (proj₁ (Ω P)) →
H-level n (proj₁ (Ω (Connected-component P)))
H-level-Ω-Connected-component {P = _ , x} n =
H-level n (x ≡ x) ↝⟨ H-level-cong _ _ (ignore-propositional-component T.truncation-is-proposition) ⟩□
H-level n ((x , _) ≡ (x , _)) □
-- The fundamental group of the connected component of P is equivalent
-- to the fundamental group of P.
--
-- This definition was suggested to me by Christian Sattler.
Fundamental-group′-Connected-component≃ᴳ :
{s₁ : Is-set (proj₁ (Ω (Connected-component P)))}
{s₂ : Is-set (proj₁ (Ω P))} →
Fundamental-group′ (Connected-component P) s₁ ≃ᴳ
Fundamental-group′ P s₂
Fundamental-group′-Connected-component≃ᴳ {P = _ , x} = λ where
.G.Homomorphic.related →
Eq.with-other-function
((x , _) ≡ (x , _) ↔⟨ inverse $ ignore-propositional-component T.truncation-is-proposition ⟩□
x ≡ x □)
(cong proj₁)
proj₁-Σ-≡,≡←≡
.G.Homomorphic.homomorphic p q →
cong proj₁ (trans p q) ≡⟨ cong-trans _ _ _ ⟩∎
trans (cong proj₁ p) (cong proj₁ q) ∎
| {
"alphanum_fraction": 0.5963636364,
"avg_line_length": 34.375,
"ext": "agda",
"hexsha": "fffbbbe035e22de6f2870128249fb797b6b60469",
"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/Pointed-type/Connected.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/Pointed-type/Connected.agda",
"max_line_length": 116,
"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/Pointed-type/Connected.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": 1203,
"size": 4125
} |
-- Example:
-- postulate ℓ : Lvl.Level
-- postulate A B C D : Type{ℓ}
-- postulate a : A
-- postulate ab : A → B
-- postulate bc : B → C
-- postulate cd : C → D
--
-- ad : A → D
-- ad =
-- A ⇒-[ ab ]
-- B ⇒-[ bc ]
-- C ⇒-[ cd ]
-- D ⇒-end
--
-- d : D
-- d =
-- a ⇒
-- A ⇒-[ ab ]
-- B ⇒-[ bc ]
-- C ⇒-[ cd ]
-- D ⇒-end
module Syntax.Implication where
open import Functional using (const ; id ; _∘_ ; _∘₂_ ; _∘₃_ ; swap)
open import Logic.Propositional
import Lvl
import Syntax.Implication.Dependent as Dependent
open import Type
private variable ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ : Lvl.Level
open Dependent using (_⇒-end ; _⇒_) public
_⇒-start_ : ∀{X : Type{ℓ₁}}{Y : Type{ℓ₂}} → X → (X → Y) → Y
_⇒-start_ x xy = xy x
infixr 0.98 _⇒-start_
{-# INLINE _⇒-start_ #-}
_⇒-[_]_ : ∀(X : Type{ℓ₁}){Y : Type{ℓ₂}}{Z : Type{ℓ₃}} → (X → Y) → (Y → Z) → (X → Z)
_⇒-[_]_ _ = swap(_∘_)
infixr 0.98 _⇒-[_]_
{-# INLINE _⇒-[_]_ #-}
_⇒-[]_ : ∀(X : Type{ℓ₁}){Y : Type{ℓ₂}} → (X → Y) → (X → Y)
_⇒-[]_ _ = id
infixr 0.98 _⇒-[]_
{-# INLINE _⇒-[]_ #-}
•_•_⇒₂-[_]_ : ∀{X₁ : Type{ℓ₁}}{X₂ : Type{ℓ₂}}{Y : Type{ℓ₃}}{Z : Type{ℓ₄}} → X₁ → X₂ → (X₁ → X₂ → Y) → (Y → Z) → Z
•_•_⇒₂-[_]_ x₁ x₂ g f = (f ∘₂ g) x₁ x₂
infixr 0.97 •_•_⇒₂-[_]_
{-# INLINE •_•_⇒₂-[_]_ #-}
•_•_•_⇒₃-[_]_ : ∀{X₁ : Type{ℓ₁}}{X₂ : Type{ℓ₂}}{X₃ : Type{ℓ₃}}{Y : Type{ℓ₄}}{Z : Type{ℓ₅}} → X₁ → X₂ → X₃ → (X₁ → X₂ → X₃ → Y) → (Y → Z) → Z
•_•_•_⇒₃-[_]_ x₁ x₂ x₃ g f = (f ∘₃ g) x₁ x₂ x₃
infixr 0.97 •_•_•_⇒₃-[_]_
{-# INLINE •_•_•_⇒₃-[_]_ #-}
_⇔-end : ∀(X : Type{ℓ₁}) → (X ↔ X)
_⇔-end _ = [↔]-intro id id
infixr 0.99 _⇔-end
{-# INLINE _⇔-end #-}
_⇔_ = Functional.apply
infixl 0.97 _⇔_
{-# INLINE _⇔_ #-}
_⇔-[_]_ : ∀(X : Type{ℓ₁}){Y : Type{ℓ₂}}{Z : Type{ℓ₃}} → (X ↔ Y) → (Y ↔ Z) → (X ↔ Z)
_⇔-[_]_ _ ([↔]-intro pₗ pᵣ) ([↔]-intro qₗ qᵣ) = [↔]-intro (pₗ ∘ qₗ) (qᵣ ∘ pᵣ)
infixr 0.98 _⇔-[_]_
{-# INLINE _⇔-[_]_ #-}
_⇔-[_]-sym_ : ∀(X : Type{ℓ₁}){Y : Type{ℓ₂}}{Z : Type{ℓ₃}} → (Y ↔ X) → (Y ↔ Z) → (X ↔ Z)
_⇔-[_]-sym_ X ([↔]-intro pₗ pᵣ) q = X ⇔-[ ([↔]-intro pᵣ pₗ) ] q
infixr 0.98 _⇔-[_]-sym_
{-# INLINE _⇔-[_]-sym_ #-}
_⇔-[]_ : ∀(X : Type{ℓ₁}){Y : Type{ℓ₂}} → (X ↔ Y) → (X ↔ Y)
_⇔-[]_ _ = id
infixr 0.98 _⇔-[]_
{-# INLINE _⇔-[]_ #-}
| {
"alphanum_fraction": 0.4666064982,
"avg_line_length": 26.6987951807,
"ext": "agda",
"hexsha": "dc90a3f57fee49eafa8283522ef59dee01f7b1d5",
"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/Implication.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/Implication.agda",
"max_line_length": 140,
"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/Implication.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": 1270,
"size": 2216
} |
{-
This file contains:
- Definitions equivalences
- Glue types
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Core.Glue where
open import Cubical.Core.Primitives
open import Agda.Builtin.Cubical.Glue public
using ( isEquiv -- ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) → Type (ℓ ⊔ ℓ')
; equiv-proof -- ∀ (y : B) → isContr (fiber f y)
; _≃_ -- ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ ⊔ ℓ')
; equivFun -- ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → A ≃ B → A → B
; equivProof -- ∀ {ℓ ℓ'} (T : Type ℓ) (A : Type ℓ') (w : T ≃ A) (a : A) φ →
-- Partial φ (fiber (equivFun w) a) → fiber (equivFun w) a
; primGlue -- ∀ {ℓ ℓ'} (A : Type ℓ) {φ : I} (T : Partial φ (Type ℓ'))
-- → (e : PartialP φ (λ o → T o ≃ A)) → Type ℓ'
; prim^unglue -- ∀ {ℓ ℓ'} {A : Type ℓ} {φ : I} {T : Partial φ (Type ℓ')}
-- → {e : PartialP φ (λ o → T o ≃ A)} → primGlue A T e → A
-- The ∀ operation on I. This is commented out as it is not currently used for anything
-- ; primFaceForall -- (I → I) → I
)
renaming ( prim^glue to glue -- ∀ {ℓ ℓ'} {A : Type ℓ} {φ : I} {T : Partial φ (Type ℓ')}
-- → {e : PartialP φ (λ o → T o ≃ A)}
-- → PartialP φ T → A → primGlue A T e
; pathToEquiv to lineToEquiv -- ∀ {ℓ : I → Level} (P : (i : I) → Type (ℓ i)) → P i0 ≃ P i1
)
private
variable
ℓ ℓ' : Level
-- Uncurry Glue to make it more pleasant to use
Glue : (A : Type ℓ) {φ : I}
→ (Te : Partial φ (Σ[ T ∈ Type ℓ' ] T ≃ A))
→ Type ℓ'
Glue A Te = primGlue A (λ x → Te x .fst) (λ x → Te x .snd)
-- Make the φ argument of prim^unglue explicit
unglue : {A : Type ℓ} (φ : I) {T : Partial φ (Type ℓ')}
{e : PartialP φ (λ o → T o ≃ A)} → primGlue A T e → A
unglue φ = prim^unglue {φ = φ}
-- People unfamiliar with [Glue], [glue] and [uglue] can find the types below more
-- informative as they demonstrate the computational behavior.
--
-- Full inference rules can be found in Section 6 of CCHM:
-- https://arxiv.org/pdf/1611.02108.pdf
-- Cubical Type Theory: a constructive interpretation of the univalence axiom
-- Cyril Cohen, Thierry Coquand, Simon Huber, Anders Mörtberg
private
module GluePrims (A : Type ℓ) {φ : I} (Te : Partial φ (Σ[ T ∈ Type ℓ' ] T ≃ A)) where
T : Partial φ (Type ℓ')
T φ1 = Te φ1 .fst
e : PartialP φ (λ φ → T φ ≃ A)
e φ1 = Te φ1 .snd
-- Glue can be seen as a subtype of Type that, at φ, is definitionally equal to the left type
-- of the given equivalences.
Glue-S : Type ℓ' [ φ ↦ T ]
Glue-S = inS (Glue A Te)
-- Which means partial elements of T are partial elements of Glue
coeT→G :
∀ (t : PartialP φ T)
→ Partial φ (Glue A Te)
coeT→G t (φ = i1) = t 1=1
-- ... and elements of Glue can be seen as partial elements of T
coeG→T :
∀ (g : Glue A Te)
→ PartialP φ T
coeG→T g (φ = i1) = g
-- What about elements that are applied to the equivalences?
trans-e :
∀ (t : PartialP φ T)
→ Partial φ A
trans-e t ϕ1 = equivFun (e ϕ1) (t ϕ1)
-- glue gives a partial element of Glue given an element of A. Note that it "undoes"
-- the application of the equivalences!
glue-S :
∀ (t : PartialP φ T)
→ A [ φ ↦ trans-e t ]
→ Glue A Te [ φ ↦ coeT→G t ]
glue-S t s = inS (glue t (outS s))
-- typechecking glue enforces this, e.g. you can not simply write
-- glue-bad : (t : PartialP φ T) → A → Glue A Te
-- glue-bad t s = glue t s
-- unglue does the inverse:
unglue-S :
∀ (b : Glue A Te)
→ A [ φ ↦ trans-e (coeG→T b) ]
unglue-S b = inS (unglue φ b)
module GlueTransp (A : I → Type ℓ) (Te : (i : I) → Partial (i ∨ ~ i) (Σ[ T ∈ Type ℓ' ] T ≃ A i)) where
A0 A1 : Type ℓ
A0 = A i0
A1 = A i1
T : (i : I) → Partial (i ∨ ~ i) (Type ℓ')
T i φ = Te i φ .fst
e : (i : I) → PartialP (i ∨ ~ i) (λ φ → T i φ ≃ A i)
e i φ = Te i φ .snd
T0 T1 : Type ℓ'
T0 = T i0 1=1
T1 = T i1 1=1
e0 : T0 ≃ A0
e0 = e i0 1=1
e1 : T1 ≃ A1
e1 = e i1 1=1
open import Cubical.Foundations.Prelude using (transport)
transportA : A0 → A1
transportA = transport (λ i → A i)
-- copied over from Foundations/Equiv for readability, can't directly import due to cyclic dependency
invEq : ∀ {X : Type ℓ'} {ℓ''} {Y : Type ℓ''} (w : X ≃ Y) → Y → X
invEq w y = w .snd .equiv-proof y .fst .fst
-- transport in Glue reduces to transport in A + the application of the equivalences in forward and backward
-- direction.
transp-S : (t0 : T0) → T1 [ i1 ↦ (λ _ → invEq e1 (transportA (equivFun e0 t0))) ]
transp-S t0 = inS (transport (λ i → Glue (A i) (Te i)) t0)
| {
"alphanum_fraction": 0.5252997358,
"avg_line_length": 34.6549295775,
"ext": "agda",
"hexsha": "521fa3b6dc191bf05cd8c94227b26cd024b30405",
"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": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Core/Glue.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Core/Glue.agda",
"max_line_length": 112,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Core/Glue.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1807,
"size": 4921
} |
module Tactic.Nat.Subtract.Reflect where
open import Prelude
import Agda.Builtin.Nat as Builtin
open import Builtin.Reflection
open import Control.Monad.State
open import Control.Monad.Transformer
open import Tactic.Reflection
open import Tactic.Reflection.Quote
open import Tactic.Nat.Reflect
open import Tactic.Nat.Subtract.Exp
⟨suc⟩s : SubExp → SubExp
⟨suc⟩s (lit n) = lit (suc n)
⟨suc⟩s (lit n ⟨+⟩ e) = lit (suc n) ⟨+⟩ e
⟨suc⟩s e = lit 1 ⟨+⟩ e
freshS : Term → R SubExp
freshS t =
get >>= uncurry′ λ i Γ →
var i <$ put (suc i , (t , i) ∷ Γ)
pattern _`-_ x y = def (quote Builtin._-_) (vArg x ∷ vArg y ∷ [])
private
forceInstance : Name → Term → R ⊤
forceInstance i v = lift $ unify v (def₀ i)
forceNumber = forceInstance (quote NumberNat)
forceSemiring = forceInstance (quote SemiringNat)
forceSubtractive = forceInstance (quote SubtractiveNat)
termToSubExpR : Term → R SubExp
termToSubExpR (a `+ b) = _⟨+⟩_ <$> termToSubExpR a <*> termToSubExpR b
termToSubExpR (a `* b) = _⟨*⟩_ <$> termToSubExpR a <*> termToSubExpR b
termToSubExpR (a `- b) = _⟨-⟩_ <$> termToSubExpR a <*> termToSubExpR b
-- Handle unsolved instances
termToSubExpR (def (quote Semiring._+_) (_ ∷ _ ∷ vArg i@(meta _ _) ∷ vArg a ∷ vArg b ∷ [])) = do
forceSemiring i
⦇ termToSubExpR a ⟨+⟩ termToSubExpR b ⦈
termToSubExpR (def (quote Semiring._*_) (_ ∷ _ ∷ vArg i@(meta _ _) ∷ vArg a ∷ vArg b ∷ [])) = do
lift $ unify i (def₀ (quote SemiringNat))
⦇ termToSubExpR a ⟨*⟩ termToSubExpR b ⦈
termToSubExpR (def (quote Subtractive._-_) (_ ∷ _ ∷ vArg i@(meta _ _) ∷ vArg a ∷ vArg b ∷ [])) = do
forceSubtractive i
⦇ termToSubExpR a ⟨-⟩ termToSubExpR b ⦈
termToSubExpR (def (quote Semiring.zro) (_ ∷ _ ∷ vArg i@(meta _ _) ∷ [])) = do
forceSemiring i
pure (lit 0)
termToSubExpR (def (quote Semiring.one) (_ ∷ _ ∷ vArg i@(meta _ _) ∷ [])) = do
forceSemiring i
pure (lit 1)
termToSubExpR (def (quote Number.fromNat) (_ ∷ _ ∷ vArg i@(meta _ _) ∷ vArg a ∷ _ ∷ [])) = do
forceNumber i
termToSubExpR a
termToSubExpR `0 = pure (lit 0)
termToSubExpR (`suc a) = ⟨suc⟩s <$> termToSubExpR a
termToSubExpR (meta x _) = lift (blockOnMeta x)
termToSubExpR (lit (nat n)) = pure (lit n)
termToSubExpR unknown = fail
termToSubExpR t = do
lift $ ensureNoMetas t
just i ← gets (flip lookup t ∘ snd)
where nothing → freshS t
pure (var i)
termToSubEqR : Term → R (SubExp × SubExp)
termToSubEqR (lhs `≡ rhs) = _,_ <$> termToSubExpR lhs <*> termToSubExpR rhs
termToSubEqR (def (quote _≡_) (_ ∷ hArg (meta x _) ∷ _)) = lift (blockOnMeta x)
termToSubEqR _ = fail
termToSubEq : Term → TC (Maybe ((SubExp × SubExp) × List Term))
termToSubEq t = runR (termToSubEqR t)
pattern _`<_ a b = def (quote LessNat) (vArg a ∷ vArg b ∷ [])
termToSubEqnR : Term → R Eqn
termToSubEqnR (def (quote Ord._<_) (_ ∷ _ ∷ vArg i@(meta _ _) ∷ vArg lhs ∷ vArg rhs ∷ [])) = do
forceInstance (quote OrdNat) i
⦇ termToSubExpR lhs :< termToSubExpR rhs ⦈
termToSubEqnR (lhs `< rhs) = _:<_ <$> termToSubExpR lhs <*> termToSubExpR rhs
termToSubEqnR (lhs `≡ rhs) = _:≡_ <$> termToSubExpR lhs <*> termToSubExpR rhs
termToSubEqnR (def (quote _≡_) (_ ∷ hArg (meta x _) ∷ _)) = lift (blockOnMeta x)
termToSubEqnR t = lift (ensureNoMetas t) *> fail
termToSubEqn : Term → TC (Maybe (Eqn × List Term))
termToSubEqn t = runR (termToSubEqnR t)
private
lower : Nat → Term → R Term
lower 0 = pure
lower i = liftMaybe ∘ strengthen i
termToSubHypsR′ : Nat → Term → R (List Eqn)
termToSubHypsR′ i (pi (vArg hyp) (abs _ a)) =
_∷_ <$> (termToSubEqnR =<< lower i hyp) <*> termToSubHypsR′ (suc i) a
termToSubHypsR′ _ (meta x _) = lift (blockOnMeta x)
termToSubHypsR′ i a = [_] <$> (termToSubEqnR =<< lower i a)
termToSubHypsR : Term → R (List Eqn)
termToSubHypsR = termToSubHypsR′ 0
termToSubHyps : Term → TC (Maybe (List Eqn × List Term))
termToSubHyps t = runR (termToSubHypsR t)
instance
QuotableSubExp : Quotable SubExp
` {{QuotableSubExp}} (var x) = con (quote SubExp.var) (vArg (` x) ∷ [])
` {{QuotableSubExp}} (lit n) = con (quote SubExp.lit) (vArg (` n) ∷ [])
` {{QuotableSubExp}} (e ⟨+⟩ e₁) = con (quote SubExp._⟨+⟩_) (map defaultArg $ ` e ∷ ` e₁ ∷ [])
` {{QuotableSubExp}} (e ⟨-⟩ e₁) = con (quote SubExp._⟨-⟩_) (map defaultArg $ ` e ∷ ` e₁ ∷ [])
` {{QuotableSubExp}} (e ⟨*⟩ e₁) = con (quote SubExp._⟨*⟩_) (map defaultArg $ ` e ∷ ` e₁ ∷ [])
QuotableEqn : Quotable Eqn
` {{QuotableEqn}} (a :≡ b) = con (quote _:≡_) (vArg (` a) ∷ vArg (` b) ∷ [])
` {{QuotableEqn}} (a :< b) = con (quote _:<_) (vArg (` a) ∷ vArg (` b) ∷ [])
| {
"alphanum_fraction": 0.6457964602,
"avg_line_length": 38.3050847458,
"ext": "agda",
"hexsha": "0399f5bba390b7c0ca0176d4820316b2dccfa1b7",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Tactic/Nat/Subtract/Reflect.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Tactic/Nat/Subtract/Reflect.agda",
"max_line_length": 99,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Tactic/Nat/Subtract/Reflect.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 1818,
"size": 4520
} |
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
record R₁ (F : Set → Set) : Set₁ where
constructor mkR₁
field
f₁ : ∀ {A} → A → F A
open R₁ {{...}}
record R₂ (F : Set → Set) : Set₁ where
constructor mkR₂
field
instance
r₁ : R₁ F
record R₃ (_ : Set) : Set where
constructor mkR₃
postulate
instance
r₃ : R₂ R₃
A : Set
a : A
record R₄ : Set where
constructor c
field
f₂ : A
postulate
F : (r₄ : R₄) → c a ≡ r₄ → Set
G : Set → Set
G _ = F _ (refl {x = f₁ a})
| {
"alphanum_fraction": 0.5415860735,
"avg_line_length": 13.6052631579,
"ext": "agda",
"hexsha": "19688adbc28545d38471f0549a3b9e22f21ccb26",
"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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Fail/Issue1974.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"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": "alhassy/agda",
"max_issues_repo_path": "test/Fail/Issue1974.agda",
"max_line_length": 42,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Fail/Issue1974.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": 223,
"size": 517
} |
open import Relation.Binary.Core
module PLRTree.DropLast.Heap {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import PLRTree {A}
open import PLRTree.Drop _≤_ tot≤
open import PLRTree.Heap _≤_
lemma-dropLast-≤* : {x : A}{t : PLRTree} → x ≤* t → x ≤* dropLast t
lemma-dropLast-≤* {x} (lf≤* .x) = lf≤* x
lemma-dropLast-≤* (nd≤* {perfect} {x} {y} {l} {r} x≤y x≤*l x≤*r)
with r
... | leaf = x≤*r
... | node _ _ _ _ = nd≤* x≤y x≤*l (lemma-dropLast-≤* x≤*r)
lemma-dropLast-≤* (nd≤* {left} {x} {y} {l} {r} x≤y x≤*l x≤*r)
with l | x≤*l | dropLast l | lemma-dropLast-≤* x≤*l
... | leaf | _ | _ | _ = lf≤* x
... | node perfect _ _ _ | _ | node perfect y' l' r' | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node perfect _ _ _ | _ | leaf | (lf≤* .x) = nd≤* x≤y (lf≤* x) x≤*r
... | node perfect _ _ _ | _ | node left _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node perfect _ _ _ | _ | node right _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node left _ _ _ | _ | node perfect y' l' r' | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node left _ _ _ | _ | leaf | (lf≤* .x) = nd≤* x≤y (lf≤* x) x≤*r
... | node left _ _ _ | _ | node left _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node left _ _ _ | _ | node right _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node right _ _ _ | _ | node perfect y' l' r' | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node right _ _ _ | _ | leaf | (lf≤* .x) = nd≤* x≤y (lf≤* x) x≤*r
... | node right _ _ _ | _ | node left _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r
... | node right _ _ _ | _ | node right _ _ _ | x≤*dll = nd≤* x≤y x≤*dll x≤*r
lemma-dropLast-≤* (nd≤* {right} {x} {y} {l} {r} x≤y x≤*l x≤*r)
with r
... | leaf = nd≤* x≤y x≤*r x≤*r
... | node perfect y' l' r' = nd≤* x≤y (lemma-dropLast-≤* x≤*l) x≤*r
... | node left _ _ _ = nd≤* x≤y x≤*l (lemma-dropLast-≤* x≤*r)
... | node right _ _ _ = nd≤* x≤y x≤*l (lemma-dropLast-≤* x≤*r)
lemma-dropLast-heap : {t : PLRTree} → Heap t → Heap (dropLast t)
lemma-dropLast-heap leaf = leaf
lemma-dropLast-heap (node {perfect} {x} {l} {r} x≤*l x≤*r hl hr)
with r
... | leaf = hr
... | node _ _ _ _ = node x≤*l (lemma-dropLast-≤* x≤*r) hl (lemma-dropLast-heap hr)
lemma-dropLast-heap (node {left} {x} {l} {r} x≤*l x≤*r hl hr)
with l | x≤*l | hl | dropLast l | lemma-dropLast-≤* x≤*l | lemma-dropLast-heap hl
... | leaf | _ | _ | _ | _ | _ = leaf
... | node perfect _ _ _ | _ | _ | node perfect y' l' r' | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node perfect _ _ _ | _ | _ | leaf | (lf≤* .x) | leaf = node (lf≤* x) x≤*r leaf hr
... | node perfect _ _ _ | _ | _ | node left _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node perfect _ _ _ | _ | _ | node right _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node left _ _ _ | _ | _ | node perfect y' l' r' | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node left _ _ _ | _ | _ | leaf | (lf≤* .x) | leaf = node (lf≤* x) x≤*r leaf hr
... | node left _ _ _ | _ | _ | node left _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node left _ _ _ | _ | _ | node right _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node right _ _ _ | _ | _ | node perfect y' l' r' | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node right _ _ _ | _ | _ | leaf | (lf≤* .x) | leaf = node (lf≤* x) x≤*r leaf hr
... | node right _ _ _ | _ | _ | node left _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
... | node right _ _ _ | _ | _ | node right _ _ _ | x≤*dll | hdll = node x≤*dll x≤*r hdll hr
lemma-dropLast-heap (node {right} {x} {l} {r} x≤*l x≤*r hl hr)
with r
... | leaf = node x≤*r x≤*r hr hr
... | node perfect y' l' r' = node (lemma-dropLast-≤* x≤*l) x≤*r (lemma-dropLast-heap hl) hr
... | node left _ _ _ = node x≤*l (lemma-dropLast-≤* x≤*r) hl (lemma-dropLast-heap hr)
... | node right _ _ _ = node x≤*l (lemma-dropLast-≤* x≤*r) hl (lemma-dropLast-heap hr)
| {
"alphanum_fraction": 0.5173126615,
"avg_line_length": 58.6363636364,
"ext": "agda",
"hexsha": "c8163dd694c20f8101cb7c713e77f8c46aac2e68",
"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/PLRTree/DropLast/Heap.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/PLRTree/DropLast/Heap.agda",
"max_line_length": 100,
"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/PLRTree/DropLast/Heap.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": 1892,
"size": 3870
} |
data D : Set where
@0 c : D
postulate
P : D → Set
p : (x : D) → P x
bad : P c
bad = p _
| {
"alphanum_fraction": 0.46875,
"avg_line_length": 9.6,
"ext": "agda",
"hexsha": "a8bb750073c7a06bec94582cdbd1fb6db44e41c7",
"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": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Fail/Issue4727.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"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-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Fail/Issue4727.agda",
"max_line_length": 19,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Fail/Issue4727.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": 44,
"size": 96
} |
module Datalog where
open import Data.Nat as ℕ
open import Data.List
open import Data.Integer as ℤ
open import Relation.Binary.PropositionalEquality
open import Data.List.Any
module Term where
data tt : Set where
τ-int : tt
open Membership (setoid tt)
ctx = List tt
data Lit : tt → Set where
int : ℤ → Lit τ-int
data Expr {τ : tt} {{ Γ : ctx }} {{ Δ : ctx }} : Set where
lit : (Lit τ) → Expr {τ}
e-var : (τ ∈ Γ) → Expr {τ}
a-var : (τ ∈ Δ) → Expr {τ}
module Program where
at = List Term.tt
open Membership (setoid at)
ctx = List at
data PartialAtom {Γ : Term.ctx} {Δ : Term.ctx} {Ρ : ctx} (ρ : at) : Set where
predicate : (ρ ∈ Ρ) → PartialAtom ρ
apply : ∀ {τ : Term.tt} → PartialAtom {Γ} {Δ} {Ρ} (τ ∷ ρ) → Term.Expr {τ} ⦃ Γ ⦄ ⦃ Δ ⦄ → PartialAtom {Γ} {Δ} {Ρ} ρ
data Atom {Γ : Term.ctx} {Δ : Term.ctx} ⦃ Ρ : ctx ⦄ : Set where
close : PartialAtom {Γ} {Δ} {Ρ} [] → Atom
data Rule {Ρ : ctx} : Set where
-- Here, we should also be checking that the rhs uses Γ to make it a relevant ctx
-- when used in the universal position
-- I don't think I need that property for proofs yet, so it can wait
rule : {Γ : Term.ctx} → Atom {Γ} {[]} → List (Atom {[]} {Γ}) → Rule
Program : {Ρ : ctx} → Set
Program {Ρ} = List (Rule {Ρ})
data Derivable {Ρ} : Program {Ρ} → Atom {[]} {[]} → Set where
{-
Proof sketch:
0.) match as an assumed-correct-primitive
1.) Proof of upper bound : prog, ∀ r ∈ prog. ∀ db. ∀ s ∈ match db r.body. subst s r.head ∈ upper
2.) semantics : p : Program → db → ∀ a ∈ db. Derivable Ρ prog a → upper → (∀ r ∈ p. ∀ vdb. ∀ s ∈ match vdb r.body. let h = subst s r.head in (h ∈ upper) || (h ∈ db))
a.) Go through prog, trying to generate the proof of termination
b.) If on any rule you fail, take the failing fact:
i.) Move the fact from upper to db
ii.) Add derivability proof for the fact you just derived (look up the matched facts derivation and build up)
iii.) Fix up the completeness term by demonstrating that if all that happened moved from upper to db, the property is just as true
3.) Proof of correctness is:
db, ∀ a ∈ db. Derivable {Ρ} prog a, ∀ r ∈ prog. ∀ s ∈ match db r.body. subst s r.head ∈ db
e.g. database, proof that database is sound, proof that database is complete
-}
| {
"alphanum_fraction": 0.60749255,
"avg_line_length": 36.703125,
"ext": "agda",
"hexsha": "2a63c843b62489067f882822ea72b2b440f3c268",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-03-18T13:51:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-01-12T23:35:10.000Z",
"max_forks_repo_head_hexsha": "0348b702860f1252458e657001989c154030f03c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "maurer/holmes",
"max_forks_repo_path": "formal/Datalog.agda",
"max_issues_count": 21,
"max_issues_repo_head_hexsha": "0348b702860f1252458e657001989c154030f03c",
"max_issues_repo_issues_event_max_datetime": "2017-12-08T02:45:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-12-13T11:15:04.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "maurer/holmes",
"max_issues_repo_path": "formal/Datalog.agda",
"max_line_length": 167,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "0348b702860f1252458e657001989c154030f03c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "maurer/holmes",
"max_stars_repo_path": "formal/Datalog.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-14T22:21:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-11-24T18:04:01.000Z",
"num_tokens": 769,
"size": 2349
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Well-founded induction
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Induction.WellFounded where
open import Data.Product
open import Function
open import Induction
open import Level
open import Relation.Binary.PropositionalEquality hiding (trans)
open import Relation.Unary
private
variable
a b ℓ ℓ₁ ℓ₂ r : Level
A : Set a
B : Set b
------------------------------------------------------------------------
-- Definitions
-- When using well-founded recursion you can recurse arbitrarily, as
-- long as the arguments become smaller, and "smaller" is
-- well-founded.
WfRec : Rel A r → ∀ {ℓ} → RecStruct A ℓ _
WfRec _<_ P x = ∀ y → y < x → P y
-- The accessibility predicate: x is accessible if everything which is
-- smaller than x is also accessible (inductively).
data Acc {A : Set a} (_<_ : Rel A ℓ) (x : A) : Set (a ⊔ ℓ) where
acc : (rs : WfRec _<_ (Acc _<_) x) → Acc _<_ x
acc-inverse : ∀ {_<_ : Rel A ℓ} {x : A} (q : Acc _<_ x) →
(y : A) → y < x → Acc _<_ y
acc-inverse (acc rs) y y<x = rs y y<x
-- The accessibility predicate encodes what it means to be
-- well-founded; if all elements are accessible, then _<_ is
-- well-founded.
WellFounded : Rel A ℓ → Set _
WellFounded _<_ = ∀ x → Acc _<_ x
Well-founded = WellFounded
{-# WARNING_ON_USAGE Well-founded
"Warning: Well-founded was deprecated in v0.15.
Please use WellFounded instead."
#-}
------------------------------------------------------------------------
-- Basic properties
Acc-resp-≈ : {_≈_ : Rel A ℓ₁} {_<_ : Rel A ℓ₂} → Symmetric _≈_ →
_<_ Respectsʳ _≈_ → (Acc _<_) Respects _≈_
Acc-resp-≈ sym respʳ x≈y (acc rec) =
acc (λ z z<y → rec z (respʳ (sym x≈y) z<y))
------------------------------------------------------------------------
-- Well-founded induction for the subset of accessible elements:
module Some {_<_ : Rel A r} {ℓ} where
wfRecBuilder : SubsetRecursorBuilder (Acc _<_) (WfRec _<_ {ℓ = ℓ})
wfRecBuilder P f x (acc rs) = λ y y<x →
f y (wfRecBuilder P f y (rs y y<x))
wfRec : SubsetRecursor (Acc _<_) (WfRec _<_)
wfRec = subsetBuild wfRecBuilder
unfold-wfRec : (P : Pred A ℓ) (f : WfRec _<_ P ⊆′ P) {x : A} (q : Acc _<_ x) →
wfRec P f x q ≡ f x (λ y y<x → wfRec P f y (acc-inverse q y y<x))
unfold-wfRec P f (acc rs) = refl
wfRec-builder = wfRecBuilder
{-# WARNING_ON_USAGE wfRec-builder
"Warning: wfRec-builder was deprecated in v0.15.
\ \Please use wfRecBuilder instead."
#-}
------------------------------------------------------------------------
-- Well-founded induction for all elements, assuming they are all
-- accessible:
module All {_<_ : Rel A r} (wf : WellFounded _<_) ℓ where
wfRecBuilder : RecursorBuilder (WfRec _<_ {ℓ = ℓ})
wfRecBuilder P f x = Some.wfRecBuilder P f x (wf x)
wfRec : Recursor (WfRec _<_)
wfRec = build wfRecBuilder
wfRec-builder = wfRecBuilder
{-# WARNING_ON_USAGE wfRec-builder
"Warning: wfRec-builder was deprecated in v0.15.
\ \Please use wfRecBuilder instead."
#-}
module FixPoint
{_<_ : Rel A ℓ} (wf : WellFounded _<_)
(P : Pred A ℓ) (f : WfRec _<_ P ⊆′ P)
(f-ext : (x : A) {IH IH' : WfRec _<_ P x} → (∀ {y} y<x → IH y y<x ≡ IH' y y<x) → f x IH ≡ f x IH')
where
some-wfRec-irrelevant : ∀ x → (q q' : Acc _<_ x) → Some.wfRec P f x q ≡ Some.wfRec P f x q'
some-wfRec-irrelevant = All.wfRec wf _
(λ x → (q q' : Acc _<_ x) → Some.wfRec P f x q ≡ Some.wfRec P f x q')
(λ { x IH (acc rs) (acc rs') → f-ext x (λ y<x → IH _ y<x (rs _ y<x) (rs' _ y<x)) })
open All wf ℓ
wfRecBuilder-wfRec : ∀ {x y} y<x → wfRecBuilder P f x y y<x ≡ wfRec P f y
wfRecBuilder-wfRec {x} {y} y<x with wf x
... | acc rs = some-wfRec-irrelevant y (rs y y<x) (wf y)
unfold-wfRec : ∀ {x} → wfRec P f x ≡ f x (λ y _ → wfRec P f y)
unfold-wfRec {x} = f-ext x wfRecBuilder-wfRec
------------------------------------------------------------------------
-- It might be useful to establish proofs of Acc or Well-founded using
-- combinators such as the ones below (see, for instance,
-- "Constructing Recursion Operators in Intuitionistic Type Theory" by
-- Lawrence C Paulson).
module Subrelation {_<₁_ : Rel A ℓ₁} {_<₂_ : Rel A ℓ₂}
(<₁⇒<₂ : ∀ {x y} → x <₁ y → x <₂ y) where
accessible : Acc _<₂_ ⊆ Acc _<₁_
accessible (acc rs) = acc (λ y y<x → accessible (rs y (<₁⇒<₂ y<x)))
wellFounded : WellFounded _<₂_ → WellFounded _<₁_
wellFounded wf = λ x → accessible (wf x)
well-founded = wellFounded
{-# WARNING_ON_USAGE well-founded
"Warning: well-founded was deprecated in v0.15.
\ \Please use wellFounded instead."
#-}
module InverseImage {_<_ : Rel B ℓ} (f : A → B) where
accessible : ∀ {x} → Acc _<_ (f x) → Acc (_<_ on f) x
accessible (acc rs) = acc (λ y fy<fx → accessible (rs (f y) fy<fx))
wellFounded : WellFounded _<_ → WellFounded (_<_ on f)
wellFounded wf = λ x → accessible (wf (f x))
well-founded = wellFounded
{-# WARNING_ON_USAGE well-founded
"Warning: well-founded was deprecated in v0.15.
\ \Please use wellFounded instead."
#-}
module TransitiveClosure {A : Set a} (_<_ : Rel A ℓ) where
infix 4 _<⁺_
data _<⁺_ : Rel A (a ⊔ ℓ) where
[_] : ∀ {x y} (x<y : x < y) → x <⁺ y
trans : ∀ {x y z} (x<y : x <⁺ y) (y<z : y <⁺ z) → x <⁺ z
downwardsClosed : ∀ {x y} → Acc _<⁺_ y → x <⁺ y → Acc _<⁺_ x
downwardsClosed (acc rs) x<y = acc (λ z z<x → rs z (trans z<x x<y))
mutual
accessible : ∀ {x} → Acc _<_ x → Acc _<⁺_ x
accessible acc-x = acc (accessible′ acc-x)
accessible′ : ∀ {x} → Acc _<_ x → WfRec _<⁺_ (Acc _<⁺_) x
accessible′ (acc rs) y [ y<x ] = accessible (rs y y<x)
accessible′ acc-x y (trans y<z z<x) =
downwardsClosed (accessible′ acc-x _ z<x) y<z
wellFounded : WellFounded _<_ → WellFounded _<⁺_
wellFounded wf = λ x → accessible (wf x)
downwards-closed = downwardsClosed
{-# WARNING_ON_USAGE downwards-closed
"Warning: downwards-closed was deprecated in v0.15.
\ \Please use downwardsClosed instead."
#-}
well-founded = wellFounded
{-# WARNING_ON_USAGE well-founded
"Warning: well-founded was deprecated in v0.15.
\ \Please use wellFounded instead."
#-}
-- DEPRECATED in v1.3.
-- Please use `×-Lex` from `Data.Product.Relation.Binary.Lex.Strict` instead.
module Lexicographic {A : Set a} {B : A → Set b}
(RelA : Rel A ℓ₁)
(RelB : ∀ x → Rel (B x) ℓ₂) where
data _<_ : Rel (Σ A B) (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where
left : ∀ {x₁ y₁ x₂ y₂} (x₁<x₂ : RelA x₁ x₂) → (x₁ , y₁) < (x₂ , y₂)
right : ∀ {x y₁ y₂} (y₁<y₂ : RelB x y₁ y₂) → (x , y₁) < (x , y₂)
mutual
accessible : ∀ {x y} →
Acc RelA x → (∀ {x} → WellFounded (RelB x)) →
Acc _<_ (x , y)
accessible accA wfB = acc (accessible′ accA (wfB _) wfB)
accessible′ :
∀ {x y} →
Acc RelA x → Acc (RelB x) y → (∀ {x} → WellFounded (RelB x)) →
WfRec _<_ (Acc _<_) (x , y)
accessible′ (acc rsA) _ wfB ._ (left x′<x) = accessible (rsA _ x′<x) wfB
accessible′ accA (acc rsB) wfB ._ (right y′<y) =
acc (accessible′ accA (rsB _ y′<y) wfB)
wellFounded : WellFounded RelA → (∀ {x} → WellFounded (RelB x)) →
WellFounded _<_
wellFounded wfA wfB p = accessible (wfA (proj₁ p)) wfB
well-founded = wellFounded
{-# WARNING_ON_USAGE _<_
"Warning: _<_ was deprecated in v1.3.
\ \Please use `×-Lex` from `Data.Product.Relation.Binary.Lex.Strict` instead."
#-}
{-# WARNING_ON_USAGE accessible
"Warning: accessible was deprecated in v1.3."
#-}
{-# WARNING_ON_USAGE accessible′
"Warning: accessible′ was deprecated in v1.3."
#-}
{-# WARNING_ON_USAGE wellFounded
"Warning: wellFounded was deprecated in v1.3.
\ \Please use `×-wellFounded` from `Data.Product.Relation.Binary.Lex.Strict` instead."
#-}
{-# WARNING_ON_USAGE well-founded
"Warning: well-founded was deprecated in v0.15.
\ \Please use wellFounded instead."
#-}
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.0
module Inverse-image = InverseImage
module Transitive-closure = TransitiveClosure
| {
"alphanum_fraction": 0.5666627785,
"avg_line_length": 32.7213740458,
"ext": "agda",
"hexsha": "d98386891fb892ede22523001dbba0058111e86c",
"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/Induction/WellFounded.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/Induction/WellFounded.agda",
"max_line_length": 118,
"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/Induction/WellFounded.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": 2723,
"size": 8573
} |
-- Andreas, 2016-02-02 postpone type checking of extended lambda
-- See also issue 480 and 1159
open import Common.Maybe
open import Common.String
record ⊤ : Set where
record IOInterface : Set₁ where
field Command : Set
Response : (m : Command) → Set
open IOInterface
data IO I A : Set where
do' : (c : Command I) (f : Response I c → IO I A) → IO I A
return : (a : A) → IO I A
-- Alias of constructor which is a function
do : ∀{I A} (c : Command I) (f : Response I c → IO I A) → IO I A
do c f = do' c f
data C : Set where
getLine : C
putStrLn : String → C
R : C → Set
R getLine = Maybe String
R (putStrLn s) = ⊤
I : IOInterface
Command I = C
Response I = R
works : IO I ⊤
works = do' getLine λ{ nothing → return _ ; (just line) →
do (putStrLn line) λ _ →
return _ }
test : IO I ⊤
test = do getLine λ{ nothing → return _ ; (just line) →
do (putStrLn line) λ _ →
return _ }
| {
"alphanum_fraction": 0.5442435775,
"avg_line_length": 24.4418604651,
"ext": "agda",
"hexsha": "b784c80c4164ec9273c6645d3239600c072bd770",
"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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/Issue1811.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/Succeed/Issue1811.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/Succeed/Issue1811.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": 343,
"size": 1051
} |
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.FunctionOver
open import homotopy.elims.CofPushoutSection
module cohomology.MayerVietoris {i} where
{- Mayer-Vietoris Sequence: Given a span X ←f– Z –g→ Y, the cofiber space
of the natural map [reglue : X ∨ Y → X ⊔_Z Y] (defined below) is equivalent
to the suspension of Z. -}
{- Relevant functions -}
module MayerVietorisFunctions (ps : ⊙Span {i} {i} {i}) where
open ⊙Span ps
module Reglue = ⊙WedgeRec (⊙left ps) (⊙right ps)
reglue : X ∨ Y → fst (⊙Pushout ps)
reglue = Reglue.f
⊙reglue : fst (X ⊙∨ Y ⊙→ ⊙Pushout ps)
⊙reglue = Reglue.⊙f
module MVDiff = SuspensionRec (fst Z) {C = Suspension (X ∨ Y)}
(north _)
(north _)
(λ z → merid _ (winl (fst f z)) ∙ ! (merid _ (winr (fst g z))))
mv-diff : Suspension (fst Z) → Suspension (X ∨ Y)
mv-diff = MVDiff.f
⊙mv-diff : fst (⊙Susp Z ⊙→ ⊙Susp (X ⊙∨ Y))
⊙mv-diff = (mv-diff , idp)
{- We use path induction (via [⊙pushout-J]) to assume that the
basepoint preservation paths of the span maps are [idp]. The module
[MayerVietorisBase] contains the proof of the theorem for this case. -}
module MayerVietorisBase
{A B : Type i} (Z : Ptd i) (f : fst Z → A) (g : fst Z → B) where
X = ⊙[ A , f (snd Z) ]
Y = ⊙[ B , g (snd Z) ]
ps = ⊙span X Y Z (f , idp) (g , idp)
F : fst (Z ⊙→ X)
F = (f , idp)
G : fst (Z ⊙→ Y)
G = (g , idp)
open MayerVietorisFunctions ps
{- Definition of the maps
into : Cofiber reglue → ΣZ
out : ΣZ → Cofiber reglue
-}
private
into-glue-square :
Square idp idp (ap (ext-glue ∘ reglue) wglue) (merid _ (snd Z))
into-glue-square =
connection ⊡v∙
! (ap-∘ ext-glue reglue wglue
∙ ap (ap ext-glue) (Reglue.glue-β ∙ !-! (glue (snd Z)))
∙ ExtGlue.glue-β (snd Z))
module IntoGlue = WedgeElim {P = λ xy → north _ == ext-glue (reglue xy)}
(λ _ → idp)
(λ _ → merid _ (snd Z))
(↓-cst=app-from-square into-glue-square)
into-glue = IntoGlue.f
module Into = CofiberRec reglue (north _) ext-glue into-glue
private
out-glue-and-square : (z : fst Z)
→ Σ (cfbase reglue == cfbase reglue)
(λ p → Square (cfglue _ (winl (f z))) p
(ap (cfcod _) (glue z)) (cfglue _ (winr (g z))))
out-glue-and-square z = fill-square-top _ _ _
out-glue = fst ∘ out-glue-and-square
out-square = snd ∘ out-glue-and-square
module Out = SuspensionRec (fst Z) {C = Cofiber reglue}
(cfbase _)
(cfbase _)
out-glue
into = Into.f
out = Out.f
{- [out] is a right inverse for [into] -}
private
into-out-sq : (z : fst Z) →
Square idp (ap into (ap out (merid _ z))) (merid _ z) (merid _ (snd Z))
into-out-sq z =
(ap (ap into) (Out.glue-β z) ∙v⊡
(! (Into.glue-β (winl (f z)))) ∙h⊡
ap-square into (out-square z)
⊡h∙ (Into.glue-β (winr (g z))))
⊡v∙ (∘-ap into (cfcod _) (glue z) ∙ ExtGlue.glue-β z)
into-out : ∀ σ → into (out σ) == σ
into-out = Suspension-elim (fst Z)
idp
(merid _ (snd Z))
(λ z → ↓-∘=idf-from-square into out (into-out-sq z))
{- [out] is a left inverse for [into] -}
{- [out] is left inverse on codomain part of cofiber space,
- i.e. [out (into (cfcod _ γ)) == cfcod _ γ] -}
private
out-into-cod-square : (z : fst Z) →
Square (cfglue reglue (winl (f z)))
(ap (out ∘ ext-glue {s = ⊙span-out ps}) (glue z))
(ap (cfcod _) (glue z)) (cfglue _ (winr (g z)))
out-into-cod-square z =
(ap-∘ out ext-glue (glue z)
∙ ap (ap out) (ExtGlue.glue-β z) ∙ Out.glue-β z)
∙v⊡ out-square z
module OutIntoCod = PushoutElim
{d = ⊙span-out ps} {P = λ γ → out (into (cfcod _ γ)) == cfcod _ γ}
(λ x → cfglue _ (winl x))
(λ y → cfglue _ (winr y))
(λ z → ↓-='-from-square (out-into-cod-square z))
out-into-cod = OutIntoCod.f
out-into : ∀ κ → out (into κ) == κ
out-into = CofPushoutSection.elim reglue
(λ _ → unit) (λ _ → idp)
idp
out-into-cod
(↓-='-from-square ∘ λ x →
(ap-∘ out into (cfglue _ (winl x))
∙ ap (ap out) (Into.glue-β (winl x)))
∙v⊡ connection
⊡v∙ ! (ap-idf (glue (winl x))))
(↓-='-from-square ∘ λ y →
(ap-∘ out into (cfglue _ (winr y))
∙ ap (ap out) (Into.glue-β (winr y))
∙ Out.glue-β (snd Z)
∙ square-top-unique (out-square (snd Z))
(! (ap-cst (cfbase _) wglue) ∙v⊡
natural-square (cfglue _) wglue
⊡v∙ (ap-∘ (cfcod _) reglue wglue
∙ ap (ap (cfcod _)) (Reglue.glue-β ∙ !-! (glue (snd Z))))))
∙v⊡ connection
⊡v∙ ! (ap-idf (glue (winr y))))
{- equivalence and path -}
eq : Cofiber reglue ≃ Suspension (fst Z)
eq = equiv into out into-out out-into
⊙eq : ⊙Cof ⊙reglue ⊙≃ ⊙Susp Z
⊙eq = ⊙≃-in eq idp
path = ua eq
⊙path = ⊙ua ⊙eq
{- Transporting [cfcod reglue] over the equivalence -}
cfcod-over : cfcod reglue == ext-glue
[ (λ W → fst (⊙Pushout ps) → fst W) ↓ ⊙path ]
cfcod-over = ↓-cst2-in _ _ $ codomain-over-equiv _ _
{- Transporting [ext-glue] over the equivalence. -}
ext-over : ext-glue == mv-diff
[ (λ W → fst W → fst (⊙Susp (X ⊙∨ Y))) ↓ ⊙path ]
ext-over = ↓-cst2-in _ _ $ ! (λ= fn-lemma) ◃ domain-over-equiv _ _
where
fn-lemma : ∀ κ → mv-diff (into κ) == ext-glue κ
fn-lemma = CofPushoutSection.elim reglue
(λ _ → unit) (λ _ → idp)
idp
(Pushout-elim
(λ x → merid _ (winl x))
(λ y → merid _ (winr y))
(↓-='-from-square ∘ λ z →
(ap-∘ mv-diff ext-glue (glue z)
∙ ap (ap mv-diff) (ExtGlue.glue-β z)
∙ MVDiff.glue-β z)
∙v⊡ (lt-square (merid _ (winl (f z)))
⊡h rt-square (merid _ (winr (g z))))
⊡v∙ ! (ap-cst (south _) (glue z))))
(↓-='-from-square ∘ λ x →
(ap-∘ mv-diff into (cfglue _ (winl x))
∙ ap (ap mv-diff) (Into.glue-β (winl x)))
∙v⊡ connection
⊡v∙ ! (ExtGlue.glue-β (winl x)))
(↓-='-from-square ∘ λ y →
(ap-∘ mv-diff into (cfglue _ (winr y))
∙ ap (ap mv-diff) (Into.glue-β (winr y))
∙ MVDiff.glue-β (snd Z)
∙ ap (λ w → merid _ w ∙ ! (merid _ (winr (g (snd Z))))) wglue
∙ !-inv-r (merid _ (winr (g (snd Z)))))
∙v⊡ connection
⊡v∙ ! (ExtGlue.glue-β (winr y)))
{- Main results -}
module MayerVietoris (ps : ⊙Span {i} {i} {i}) where
private
record Results (ps : ⊙Span {i} {i} {i}) : Type (lsucc i) where
open ⊙Span ps
open MayerVietorisFunctions ps public
field
eq : Cofiber reglue ≃ Suspension (fst Z)
⊙eq : ⊙Cof ⊙reglue ⊙≃ ⊙Susp Z
path : Cofiber reglue == Suspension (fst Z)
⊙path : ⊙Cof ⊙reglue == ⊙Susp Z
cfcod-over : cfcod reglue == ext-glue
[ (λ W → fst (⊙Pushout ps) → fst W) ↓ ⊙path ]
ext-over : ext-glue == mv-diff
[ (λ W → fst W → fst (⊙Susp (X ⊙∨ Y))) ↓ ⊙path ]
results : Results ps
results = ⊙pushout-J Results base-results ps
where
base-results : ∀ {A} {B} Z (f : fst Z → A) (g : fst Z → B) →
Results (⊙span _ _ Z (f , idp) (g , idp))
base-results Z f g = record {
eq = eq;
⊙eq = ⊙eq;
path = path;
⊙path = ⊙path;
cfcod-over = cfcod-over;
ext-over = ext-over}
where open MayerVietorisBase Z f g
open Results results public
| {
"alphanum_fraction": 0.5310787328,
"avg_line_length": 30.7860082305,
"ext": "agda",
"hexsha": "e77a4aaa06ce29854aaad842e5043e6471b764de",
"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": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "theorems/cohomology/MayerVietoris.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"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": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "theorems/cohomology/MayerVietoris.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "theorems/cohomology/MayerVietoris.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2917,
"size": 7481
} |
module hnf-tests where
open import bool
open import list
open import nat
open import product
open import string
open import cedille-types
open import conversion
open import ctxt
open import is-free
open import rename
open import subst
open import syntax-util
open import to-string
S : term
S = mlam "n" (mlam "s" (mlam "z" (mapp (mvar "s") (mapp (mapp (mvar "n") (mvar "s")) (mvar "z")))))
plus : term
plus = mlam "n" (mlam "m" (mapp (mapp (mvar "n") S) (mvar "m")))
run : term → term
run t = hnf new-ctxt unfold-head t
show : term → string
show t = term-to-string t
s2 = show (run (mapp S (mvar "z")))
-- λ s . (λ x . λ s . x λ s' . f s' s) s
t1 = mlam "s" (mapp (mlam "x" (mlam "s" (mapp (mvar "x") (mlam "s'" (mapp (mapp (mvar "f") (mvar "s'")) (mvar "s")))))) (mvar "s"))
s1 = show (run t1)
Γ = ctxt-var-decl "s" new-ctxt
q = show (subst-term Γ (mvar "s") "x" (mlam "s" (mapp (mvar "x") (mlam "s'" (mapp (mapp (mvar "f") (mvar "s'")) (mvar "s"))))))
r = show (subst-term Γ (mvar "s") "x" (mlam "s" (mlam "s'" (mapp (mapp (mvar "f") (mvar "s'")) (mvar "s")))))
aa = rename-var-if Γ empty-renamectxt "s" (mvar "s")
Γ' = ctxt-var-decl "s'" Γ
ρ = renamectxt-insert empty-renamectxt "s" "s'"
bb = show (substh-term Γ' ρ (mvar "s") "x" (mlam "s'" (mapp (mapp (mvar "f") (mvar "s'")) (mvar "s"))))
cc = rename-var-if Γ' ρ "s'" (mvar "s")
try-pull-lift-types : type → type → type
try-pull-lift-types tp1 tp2 with decompose-tpapps tp1 | decompose-tpapps (hnf new-ctxt unfold-head tp2)
try-pull-lift-types tp1 tp2 | Lft _ _ X t l , args1 | Lft _ _ X' t' l' , args2 =
if conv-tty* new-ctxt args1 args2 then
try-pull-term-in t l (length args1) [] []
else
TpApp tp1 tp2
where try-pull-term-in : term → liftingType → ℕ → 𝕃 var → 𝕃 liftingType → type
try-pull-term-in t (LiftParens _ l _) n vars ltps = try-pull-term-in t l n vars ltps
try-pull-term-in t (LiftArrow _ l) 0 vars ltps =
recompose-tpapps
(Lft posinfo-gen posinfo-gen X (Lam* vars (hnf Γ no-unfolding (App t NotErased (App* t' (map mvar vars)))))
(LiftArrow* ltps l) , args1)
try-pull-term-in (Lam _ _ _ x _ t) (LiftArrow l1 l2) (suc n) vars ltps =
try-pull-term-in t l2 n (x :: vars) (l1 :: ltps)
try-pull-term-in t (LiftArrow l1 l2) (suc n) vars ltps =
let x = fresh-var "x" (ctxt-binds-var Γ) empty-renamectxt in
try-pull-term-in (App t NotErased (mvar x)) l2 n (x :: vars) (l1 :: ltps)
try-pull-term-in t l n vars ltps = TpApp tp1 tp2
try-pull-lift-types tp1 tp2 | h , a | h' , a' = TpApp tp1 tp2
lta = (TpApp (Lft posinfo-gen posinfo-gen "X" (mvar "f")
(LiftArrow (LiftStar posinfo-gen) (LiftArrow (LiftStar posinfo-gen) (LiftStar posinfo-gen))))
(mtpvar "doit"))
ltb = (TpApp (Lft posinfo-gen posinfo-gen "X" (mvar "t") (LiftStar posinfo-gen)) (mtpvar "doit"))
lt = try-pull-lift-types lta ltb
lts = to-string lt
| {
"alphanum_fraction": 0.5972409152,
"avg_line_length": 34.9647058824,
"ext": "agda",
"hexsha": "b8d9ffa96cd43ecd5ca191e9571f051ca343ddb5",
"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/hnf-tests.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/hnf-tests.agda",
"max_line_length": 131,
"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/hnf-tests.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1143,
"size": 2972
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Bicategory
-- The two Hom 2-functors from (op C) and C to Cats.
module Categories.Pseudofunctor.Hom {o ℓ e t} (C : Bicategory o ℓ e t) where
open import Data.Product using (_,_)
import Categories.Bicategory.Extras as BicategoryExtras
open import Categories.Bicategory.Opposite using (op)
open import Categories.Bicategory.Instance.Cats using (Cats)
import Categories.Category.Construction.Core as Core
open import Categories.Functor.Bifunctor.Properties
open import Categories.Pseudofunctor using (Pseudofunctor)
import Categories.Morphism.Reasoning as MorphismReasoning
import Categories.Morphism as Morphism
open import Categories.NaturalTransformation using (ntHelper)
open import Categories.NaturalTransformation.NaturalIsomorphism
using (niHelper)
open BicategoryExtras C
open Shorthands
open hom.HomReasoning
private
module MR {A} {B} where
open Core.Shorthands (hom A B) public
open MorphismReasoning (hom A B) public
open MR
-- The left and right hom-pseudofunctors for a given bicategory.
--
-- Note that these are *not* simply partial applications of a single
-- *binary* hom-pseudofunctor because pre-/post-composition with
-- identity 1-cells in bicategories is only weakly unitary, i.e. the
-- partial applications Hom[ id , f ] and Hom[ g , id ] would send a
-- 1-cell h to (id ∘ h ∘ f) and (g ∘ h ∘ id) which are isomorphic but
-- not strictly equal to (h ∘ f) and (g ∘ h).
-- The right hom-pseudofunctor (post-composition)
Hom[_,-] : Obj → Pseudofunctor C (Cats o ℓ e)
Hom[ A ,-] = record
{ P₀ = hom A
; P₁ = [-]⊚-
-- A curried version of the left unitor
; P-identity = niHelper (record
{ η = λ _ → ntHelper (record
{ η = λ f → unitˡ.⇐.η (_ , f)
; commute = λ _ → ⟺ ▷-∘ᵥ-λ⇐
})
; η⁻¹ = λ _ → ntHelper (record
{ η = λ f → unitˡ.⇒.η (_ , f)
; commute = λ _ → λ⇒-∘ᵥ-▷
})
; commute = λ _ → unitˡ.⇐.commute (_ , hom.id)
; iso = λ _ → record
{ isoˡ = λ {f} → unitˡ.iso.isoʳ (_ , f)
; isoʳ = λ {f} → unitˡ.iso.isoˡ (_ , f)
}
})
-- A curried version of the associator
; P-homomorphism = niHelper (record
{ η = λ{ (f , g) → ntHelper (record
{ η = λ h → ⊚-assoc.⇐.η ((f , g) , h)
; commute = λ _ → α⇐-▷-∘₁
}) }
; η⁻¹ = λ{ (f , g) → ntHelper (record
{ η = λ h → ⊚-assoc.⇒.η ((f , g) , h)
; commute = λ _ → α⇒-▷-∘₁
}) }
; commute = λ{ {f₁ , g₁} {f₂ , g₂} (β , γ) {h} → begin
α⇐ ∘ᵥ f₂ ▷ (γ ◁ h) ∘ᵥ β ◁ (g₁ ⊚₀ h)
≈˘⟨ refl⟩∘⟨ [ ⊚ ]-decompose₂ ⟩
α⇐ ∘ᵥ β ⊚₁ (γ ◁ h)
≈⟨ ⊚-assoc.⇐.commute ((β , γ) , id₂) ⟩
(β ⊚₁ γ) ◁ h ∘ᵥ α⇐
∎ }
; iso = λ{ (f , g) → record
{ isoˡ = λ {h} → ⊚-assoc.iso.isoʳ ((f , g) , h)
; isoʳ = λ {h} → ⊚-assoc.iso.isoˡ ((f , g) , h) }
}
})
; unitaryˡ = λ {_ _ f g} → begin
λ⇒ ◁ g ∘ᵥ α⇐ ∘ᵥ (id₂ ◁ (f ⊚₀ g)) ∘ᵥ λ⇐
≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⊚.identity ⟩∘⟨refl ⟩
λ⇒ ◁ g ∘ᵥ α⇐ ∘ᵥ id₂ ∘ᵥ λ⇐ ≈⟨ unitorˡ-coherence ⟩∘⟨ refl⟩∘⟨ hom.identityˡ ⟩
(λ⇒ ∘ᵥ α⇒) ∘ᵥ α⇐ ∘ᵥ λ⇐ ≈⟨ isoʳ (unitorˡ ∘ᵢ associator) ⟩
id₂ ∎
; unitaryʳ = λ {_ _ f g} → begin
ρ⇒ ◁ g ∘ᵥ α⇐ ∘ᵥ f ▷ λ⇐ ∘ᵥ id₂
≈⟨ pushʳ (refl⟩∘⟨ hom.identityʳ) ⟩
(ρ⇒ ◁ g ∘ᵥ α⇐) ∘ᵥ f ▷ λ⇐
≈˘⟨ switch-tofromʳ (associator ⁻¹) triangle ⟩∘⟨refl ⟩
f ▷ λ⇒ ∘ᵥ f ▷ λ⇐
≈⟨ isoʳ (f ▷ᵢ unitorˡ) ⟩
id₂
∎
; assoc = λ {_ _ _ _ f g h e} → begin
α⇒ ◁ e ∘ᵥ α⇐ ∘ᵥ (id₂ ⊚₁ id₂) ∘ᵥ α⇐
≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⊚.identity ⟩∘⟨refl ⟩
α⇒ ◁ e ∘ᵥ α⇐ ∘ᵥ id₂ ∘ᵥ α⇐
≈⟨ refl⟩∘⟨ refl⟩∘⟨ hom.identityˡ ⟩
α⇒ ◁ e ∘ᵥ α⇐ ∘ᵥ α⇐
≈˘⟨ switch-fromtoˡ ((associator ◁ᵢ e) ⁻¹)
(hom.sym-assoc ○ pentagon-inv) ⟩
α⇐ ∘ᵥ h ▷ α⇐
≈˘⟨ pushʳ hom.identityʳ ○ hom.identityʳ ⟩
α⇐ ∘ᵥ (h ▷ α⇐ ∘ᵥ id₂) ∘ᵥ id₂
∎
}
-- The left hom-pseudofunctor (pre-composition)
Hom[-,_] : Obj → Pseudofunctor (op C) (Cats o ℓ e)
Hom[-, B ] = record
{ P₀ = λ A → hom A B
; P₁ = -⊚[-]
-- A curried version of the right unitor
; P-identity = niHelper (record
{ η = λ _ → ntHelper (record
{ η = λ f → unitʳ.⇐.η (f , _)
; commute = λ _ → ⟺ ◁-∘ᵥ-ρ⇐
})
; η⁻¹ = λ _ → ntHelper (record
{ η = λ f → unitʳ.⇒.η (f , _)
; commute = λ _ → ρ⇒-∘ᵥ-◁
})
; commute = λ _ → unitʳ.⇐.commute (hom.id , _)
; iso = λ _ → record
{ isoˡ = λ {f} → unitʳ.iso.isoʳ (f , _)
; isoʳ = λ {f} → unitʳ.iso.isoˡ (f , _)
}
})
-- A curried version of the associator
; P-homomorphism = niHelper (record
{ η = λ{ (f , g) → ntHelper (record
{ η = λ h → ⊚-assoc.⇒.η ((h , g) , f)
; commute = λ _ → α⇒-◁-∘₁
}) }
; η⁻¹ = λ{ (f , g) → ntHelper (record
{ η = λ h → ⊚-assoc.⇐.η ((h , g) , f)
; commute = λ _ → α⇐-◁-∘₁
}) }
; commute = λ{ {f₁ , g₁} {f₂ , g₂} (β , γ) {h} → begin
α⇒ ∘ᵥ (h ▷ γ) ◁ f₂ ∘ᵥ (h ⊚₀ g₁) ▷ β
≈˘⟨ refl⟩∘⟨ [ ⊚ ]-decompose₁ ⟩
α⇒ ∘ᵥ (h ▷ γ) ⊚₁ β
≈⟨ ⊚-assoc.⇒.commute ((id₂ , γ) , β) ⟩
h ▷ (γ ⊚₁ β) ∘ᵥ α⇒
∎ }
; iso = λ{ (f , g) → record
{ isoˡ = λ {h} → ⊚-assoc.iso.isoˡ ((h , g) , f)
; isoʳ = λ {h} → ⊚-assoc.iso.isoʳ ((h , g) , f) }
}
})
; unitaryˡ = λ {_ _ f g} → begin
g ▷ ρ⇒ ∘ᵥ α⇒ ∘ᵥ ((g ⊚₀ f) ▷ id₂) ∘ᵥ ρ⇐
≈⟨ pushʳ (refl⟩∘⟨ ⊚.identity ⟩∘⟨refl) ⟩
(g ▷ ρ⇒ ∘ᵥ α⇒) ∘ᵥ id₂ ∘ᵥ ρ⇐ ≈⟨ ⟺ unitorʳ-coherence ⟩∘⟨ hom.identityˡ ⟩
ρ⇒ ∘ᵥ ρ⇐ ≈⟨ isoʳ unitorʳ ⟩
id₂ ∎
; unitaryʳ = λ {_ _ f g} → begin
g ▷ λ⇒ ∘ᵥ α⇒ ∘ᵥ ρ⇐ ◁ f ∘ᵥ id₂
≈⟨ pushʳ (refl⟩∘⟨ hom.identityʳ) ⟩
(g ▷ λ⇒ ∘ᵥ α⇒) ∘ᵥ ρ⇐ ◁ f
≈⟨ triangle ⟩∘⟨refl ⟩
ρ⇒ ◁ f ∘ᵥ ρ⇐ ◁ f
≈⟨ isoʳ (unitorʳ ◁ᵢ f) ⟩
id₂
∎
; assoc = λ {_ _ _ _ f g h e} → begin
e ▷ α⇐ ∘ᵥ α⇒ ∘ᵥ (id₂ ⊚₁ id₂) ∘ᵥ α⇒
≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⊚.identity ⟩∘⟨refl ⟩
e ▷ α⇐ ∘ᵥ α⇒ ∘ᵥ id₂ ∘ᵥ α⇒
≈⟨ refl⟩∘⟨ refl⟩∘⟨ hom.identityˡ ⟩
e ▷ α⇐ ∘ᵥ α⇒ ∘ᵥ α⇒
≈˘⟨ switch-fromtoˡ (e ▷ᵢ associator) pentagon ⟩
α⇒ ∘ᵥ α⇒ ◁ h
≈˘⟨ pushʳ hom.identityʳ ○ hom.identityʳ ⟩
α⇒ ∘ᵥ (α⇒ ◁ h ∘ᵥ id₂) ∘ᵥ id₂
∎
}
| {
"alphanum_fraction": 0.4750272289,
"avg_line_length": 34.5537634409,
"ext": "agda",
"hexsha": "91879d8600222188f3cb907b74b2a585b1100b4e",
"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": "8f3c844d929508040dfa21f681fa260056214b73",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "maxsnew/agda-categories",
"max_forks_repo_path": "src/Categories/Pseudofunctor/Hom.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73",
"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": "maxsnew/agda-categories",
"max_issues_repo_path": "src/Categories/Pseudofunctor/Hom.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "maxsnew/agda-categories",
"max_stars_repo_path": "src/Categories/Pseudofunctor/Hom.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3173,
"size": 6427
} |
------------------------------------------------------------------------
-- A counterexample: The trace of stack sizes produced by the virtual
-- machine is not necessarily bisimilar to that produced by the
-- instrumented interpreter
------------------------------------------------------------------------
module Lambda.Interpreter.Stack-sizes.Counterexample where
open import Equality.Propositional as E using (_≡_)
open import Prelude
open import Prelude.Size
open import Colist E.equality-with-J
open import Function-universe E.equality-with-J
open import Vec.Data E.equality-with-J
import Lambda.Compiler
import Lambda.Interpreter.Stack-sizes
import Lambda.Virtual-machine
import Lambda.Virtual-machine.Instructions
-- This module uses a name type with two inhabitants.
open import Lambda.Syntax Bool
open Closure Tm
-- Two unary functions.
def : Bool → Tm 1
def true = call false (con true)
def false = con true
-- The instrumented interpreter, compiler and virtual machine are
-- instantiated with this definition.
module I = Lambda.Interpreter.Stack-sizes def
open Lambda.Compiler def
open Lambda.Virtual-machine.Instructions Bool
open module VM = Lambda.Virtual-machine comp-name
-- A top-level term to get things going. The important property of
-- this term is that when it is compiled and the resulting code is
-- executed on the virtual machine, then one tail call is made to a
-- function that terminates successfully.
go : Tm 0
go = call true (con true)
-- The trace of stack sizes produced by the virtual machine is not
-- necessarily bisimilar to that produced by the instrumented
-- interpreter.
stack-sizes-not-bisimilar :
¬ [ ∞ ] VM.stack-sizes ⟨ comp₀ go , [] , [] ⟩ ∼ I.stack-sizes go
stack-sizes-not-bisimilar =
[ ∞ ] VM.stack-sizes ⟨ comp₀ go , [] , [] ⟩ ∼ I.stack-sizes go ↝⟨ take-cong 8 ⟩
take 8 (VM.stack-sizes ⟨ comp₀ go , [] , [] ⟩) ≡
take 8 (I.stack-sizes go) ↔⟨⟩
0 ∷ 1 ∷ 1 ∷ 2 ∷ 1 ∷ 2 ∷ 1 ∷ [] ≡
0 ∷ 1 ∷ 1 ∷ 2 ∷ 1 ∷ 2 ∷ 2 ∷ 1 ∷ [] ↝⟨ (λ ()) ⟩□
⊥ □
| {
"alphanum_fraction": 0.6266915539,
"avg_line_length": 32.4696969697,
"ext": "agda",
"hexsha": "24efdf03b9c942d4f7873ea3d043d1fa28deddbc",
"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": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/definitional-interpreters",
"max_forks_repo_path": "src/Lambda/Interpreter/Stack-sizes/Counterexample.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
"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/definitional-interpreters",
"max_issues_repo_path": "src/Lambda/Interpreter/Stack-sizes/Counterexample.agda",
"max_line_length": 82,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/definitional-interpreters",
"max_stars_repo_path": "src/Lambda/Interpreter/Stack-sizes/Counterexample.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 535,
"size": 2143
} |
{-# OPTIONS --without-K --safe #-}
module Categories.2-Category where
open import Level
open import Categories.Category.Monoidal.Instance.StrictCats using (module Product)
open import Categories.Enriched.Category using (Category)
2-Category : (o ℓ e t : Level) → Set (suc (o ⊔ ℓ ⊔ e ⊔ t))
2-Category o ℓ e t = Category (Product.Cats-Monoidal {o} {ℓ} {e}) t
| {
"alphanum_fraction": 0.7119113573,
"avg_line_length": 30.0833333333,
"ext": "agda",
"hexsha": "9c1323bef43d759cabac2a21b3754eb6eaf98b2c",
"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/2-Category.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/2-Category.agda",
"max_line_length": 83,
"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/2-Category.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": 106,
"size": 361
} |
-- {-# OPTIONS -v tc.with:40 #-}
module RewriteAndWhere where
open import Common.Equality
data ℕ : Set where
zero : ℕ
-- good : (a b : ℕ) → a ≡ b → b ≡ a
-- good a b eq with a | eq
-- ... | .b | refl = foo
-- where
-- foo : b ≡ b
-- foo = refl
mutual
aux : (a b : ℕ)(w : ℕ) → w ≡ b → b ≡ w
aux a b .b refl = foo
where
foo : b ≡ b
foo = refl
good₂ : (a b : ℕ) → a ≡ b → b ≡ a
good₂ a b eq = aux a b a eq
bad : (a b : ℕ) → a ≡ b → b ≡ a
bad a b eq rewrite eq = foo
where
foo : b ≡ b
foo = refl
-- Andreas, 2014-11-06: this rewrite is trying to touch
-- variable b bound in pattern of parent function, which is
-- illegal.
--
-- foo rewrite sym eq = bar
-- where
-- bar : a ≡ a
-- bar = refl
-- Andreas, 2015-11-18 added test during exploration of issue 1692.
-- Ulf, 2016-02-25 after fix to #745 this no longer works.
-- test : (a b : ℕ) → a ≡ b → b ≡ a
-- test a b eq with a | eq
-- test a b eq | .b | refl = eq
| {
"alphanum_fraction": 0.5184079602,
"avg_line_length": 21.847826087,
"ext": "agda",
"hexsha": "ca34666bd7c6e3b4918a7ebea3091519a85304d5",
"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/RewriteAndWhere.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/RewriteAndWhere.agda",
"max_line_length": 67,
"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/RewriteAndWhere.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": 378,
"size": 1005
} |
{-# OPTIONS --type-in-type #-} -- yes, I will let you cheat in this exercise
{-# OPTIONS --allow-unsolved-metas #-} -- allows import, unfinished
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- CS410 2017/18 Exercise 3 WINDOWS AND OTHER STORIES (worth 25%)
------------------------------------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Dependencies
------------------------------------------------------------------------------
open import CS410-Prelude
open import CS410-Categories
open import Ex2
------------------------------------------------------------------------------
-- PART I: Splittings
------------------------------------------------------------------------------
-- The type ls <[ ms ]> rs
-- is similar to that found in Lec2.agda, but it works on lists, not numbers.
-- It provides the evidence that a list ms can be split into a left sublist ls
-- and a right sublist rs. In effect, it's a vector of bits that say which
-- elements of ms go left and which go right.
data _<[_]>_ {X : Set} : List X -> List X -> List X -> Set where
sz : [] <[ [] ]> []
sl : forall {l ls ms rs} -> ls <[ ms ]> rs -> (l ,- ls) <[ l ,- ms ]> rs
sr : forall {r ls ms rs} -> ls <[ ms ]> rs -> ls <[ r ,- ms ]> (r ,- rs)
--??--3.1---------------------------------------------------------------------
-- Adapt _>[_]<_ from Lec2 to work for All. Given a P for each element of
-- ls and rs, riffle them together to get Ps for all the ms.
_>[_]<_ : {X : Set}{ls ms rs : List X} -> {P : X -> Set} ->
All P ls -> ls <[ ms ]> rs -> All P rs ->
All P ms
pl >[ s ]< pr = {!!}
-- Now, buikd the view that shows riffling can be inverted, using a splitting
-- as the instructions to discover how to split an All in two.
data IsRiffle {X : Set}{ls ms rs : List X}(s : ls <[ ms ]> rs){P : X -> Set}
: All P ms -> Set where
mkRiffle : (pl : All P ls)(pr : All P rs) -> IsRiffle s (pl >[ s ]< pr)
isRiffle : {X : Set}{ls ms rs : List X}(s : ls <[ ms ]> rs)
{P : X -> Set}(pm : All P ms) -> IsRiffle s pm
isRiffle s pm = {!!}
--??--------------------------------------------------------------------------
--??--3.2---------------------------------------------------------------------
-- Construct the "all on the right" splitting.
srs : forall {X : Set}{xs : List X} -> [] <[ xs ]> xs
srs = {!!}
-- Construct a view to show that any "none on the left" splitting is
-- "all on the right". Come up with the type yourself.
-- Construct the splitting that corresponds to concatenation.
slrs : forall {X : Set}(xs ys : List X) -> xs <[ xs +L ys ]> ys
slrs xs ys = {!!}
--??--------------------------------------------------------------------------
--??--3.3---------------------------------------------------------------------
-- Invent other useful operations which transform splittings.
-- You will need some to do later parts of the exercise, so maybe
-- wait until you see what you need.
-- I expect you will need at least something that takes a pair of splittings
-- that make a tree, like
--
-- ms
-- <[ ]>
-- ls rs
-- <[ ]>
-- lrs rrs
--
-- and compute a "rotated" pair of splittings like
--
-- ms
-- <[ ]>
-- ?? rrs
-- <[ ]>
-- ls lrs
-- HINT: Sg is your friend
-- You'll probably need some other stuff, too.
--??--------------------------------------------------------------------------
------------------------------------------------------------------------------
-- PART II: Permutations
------------------------------------------------------------------------------
-- When is one list a permutation of another?
data _~_ {X : Set} : List X -> List X -> Set where
-- [] is a permutation of []
[] : [] ~ []
-- if xs ~ ys, then (x ,- xs) is a permutation of any list made by
-- shoving x somewhere into ys
_,-_ : forall {x xs ys' ys} ->
(x ,- []) <[ ys' ]> ys ->
xs ~ ys ->
(x ,- xs) ~ ys'
--??--3.4---------------------------------------------------------------------
-- Show that every list is a permutation of itself.
reflP : {X : Set}{xs : List X} -> xs ~ xs
reflP = {!!}
--??--------------------------------------------------------------------------
--??--3.5---------------------------------------------------------------------
-- Construct an "unbiased" insertion operator which lets you grow a
-- permutation by inserting a new element anywhere, left and right
insP : forall {X : Set}{z : X}{xs xs' ys ys'} ->
(z ,- []) <[ xs' ]> xs ->
(z ,- []) <[ ys' ]> ys ->
xs ~ ys -> xs' ~ ys'
insP l r p = {!!}
-- Now show that, given a permutation, and any element on the left,
-- you can find out where it ended up on the right, and why the
-- remaining elements form a permutation.
findLonR : forall {X : Set}{z : X}{xs xs' ys'} ->
(z ,- []) <[ xs' ]> xs ->
xs' ~ ys' ->
{!!}
findLonR l p = {!!}
-- HINT: again, you may need Sg to give a sensible return type.
--??--------------------------------------------------------------------------
--??--3.6---------------------------------------------------------------------
-- Show that permutation is transitive.
transP : {X : Set}{xs ys zs : List X} -> xs ~ ys -> ys ~ zs -> xs ~ zs
transP p q = {!!}
-- HINT: you will need to define some useful operations on splittings to
-- get this to work.
-- HINT: this may help you figure out what you need for findLonR
-- For a small bonus, show that permutations are the morphisms of a
-- Category.
-- Show that permutation is symmetric.
symP : {X : Set}{xs ys : List X} -> xs ~ ys -> ys ~ xs
symP p = {!!}
-- A category where all morphisms are invertible is called a "groupoid".
--??--------------------------------------------------------------------------
--??--3.7---------------------------------------------------------------------
-- Make permutations act on All.
permute : {X : Set}{xs ys : List X} -> xs ~ ys ->
{Q : X -> Set} -> All Q xs -> All Q ys
permute p qs = {!!}
--??--------------------------------------------------------------------------
-- MORE TO FOLLOW
| {
"alphanum_fraction": 0.3972560976,
"avg_line_length": 32.6368159204,
"ext": "agda",
"hexsha": "3534de0eff1bef19987253152ef623b54cec9593",
"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": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "m-schmidt/CS410-17-Exercises",
"max_forks_repo_path": "Ex3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c",
"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": "m-schmidt/CS410-17-Exercises",
"max_issues_repo_path": "Ex3.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "m-schmidt/CS410-17-Exercises",
"max_stars_repo_path": "Ex3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1503,
"size": 6560
} |
------------------------------------------------------------------------------
-- Totality properties for Forest
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Mirror.Forest.TotalityI where
open import FOTC.Base
open import FOTC.Data.List
open import FOTC.Program.Mirror.Type
------------------------------------------------------------------------------
++-Forest : ∀ {xs ys} → Forest xs → Forest ys → Forest (xs ++ ys)
++-Forest {ys = ys} fnil Fys = subst Forest (sym (++-[] ys)) Fys
++-Forest {ys = ys} (fcons {x} {xs} Tx Fxs) Fys =
subst Forest (sym (++-∷ x xs ys)) (fcons Tx (++-Forest Fxs Fys))
map-Forest : ∀ {xs} f → (∀ {x} → Tree x → Tree (f · x)) →
Forest xs → Forest (map f xs)
map-Forest f fTree fnil = subst Forest (sym (map-[] f)) fnil
map-Forest f fTree (fcons {x} {xs} Tx Fxs) =
subst Forest
(sym (map-∷ f x xs))
(fcons (fTree Tx) (map-Forest f fTree Fxs))
rev-Forest : ∀ {xs ys} → Forest xs → Forest ys → Forest (rev xs ys)
rev-Forest {ys = ys} fnil Fys = subst Forest (sym (rev-[] ys)) Fys
rev-Forest {ys = ys} (fcons {x} {xs} Tx Fxs) Fys =
subst Forest (sym (rev-∷ x xs ys)) (rev-Forest Fxs (fcons Tx Fys))
reverse-Forest : ∀ {xs} → Forest xs → Forest (reverse xs)
reverse-Forest Fxs = rev-Forest Fxs fnil
| {
"alphanum_fraction": 0.5013404826,
"avg_line_length": 39.2631578947,
"ext": "agda",
"hexsha": "906620f8d04eaa7222d37f213be197c257482bab",
"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/FOTC/Program/Mirror/Forest/TotalityI.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/FOTC/Program/Mirror/Forest/TotalityI.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/FOTC/Program/Mirror/Forest/TotalityI.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": 424,
"size": 1492
} |
module Oscar.Builtin.Objectevel where
open import Agda.Primitive public
using ()
renaming (Level to Ł̂; lzero to Ø̂; lsuc to ↑̂_; _⊔_ to _∙̂_)
infix 0 Ø_
Ø_ : ∀ 𝔬 → Set (↑̂ 𝔬)
Ø_ 𝔬 = Set 𝔬
| {
"alphanum_fraction": 0.6428571429,
"avg_line_length": 17.8181818182,
"ext": "agda",
"hexsha": "5dc99b883f43830377e9a6fbe1aa6623d6dc0c25",
"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/Builtin/Objectevel.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/Builtin/Objectevel.agda",
"max_line_length": 63,
"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/Builtin/Objectevel.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 94,
"size": 196
} |
module DigitsInNames where
data 1D : Set where
1d : 1D
2d : 1D -> 1D
| {
"alphanum_fraction": 0.6315789474,
"avg_line_length": 9.5,
"ext": "agda",
"hexsha": "b3153ba05e982eb92c14339ffb24455054fba85c",
"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/DigitsInNames.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/DigitsInNames.agda",
"max_line_length": 26,
"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/DigitsInNames.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": 38,
"size": 76
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Consequences of a monomorphism between monoid-like structures
------------------------------------------------------------------------
-- See Data.Nat.Binary.Properties for examples of how this and similar
-- modules can be used to easily translate properties between types.
{-# OPTIONS --without-K --safe #-}
open import Algebra.Bundles
open import Algebra.Morphism.Structures
open import Relation.Binary.Core
module Algebra.Morphism.MonoidMonomorphism
{a b ℓ₁ ℓ₂} {M₁ : RawMonoid a ℓ₁} {M₂ : RawMonoid b ℓ₂} {⟦_⟧}
(isMonoidMonomorphism : IsMonoidMonomorphism M₁ M₂ ⟦_⟧)
where
open IsMonoidMonomorphism isMonoidMonomorphism
open RawMonoid M₁ renaming (Carrier to A; _≈_ to _≈₁_; _∙_ to _∙_; ε to ε₁)
open RawMonoid M₂ renaming (Carrier to B; _≈_ to _≈₂_; _∙_ to _◦_; ε to ε₂)
open import Algebra.Definitions
open import Algebra.Structures
open import Data.Product using (map)
import Relation.Binary.Reasoning.Setoid as SetoidReasoning
------------------------------------------------------------------------
-- Re-export all properties of magma monomorphisms
open import Algebra.Morphism.MagmaMonomorphism
isMagmaMonomorphism public
------------------------------------------------------------------------
-- Properties
module _ (◦-isMagma : IsMagma _≈₂_ _◦_) where
open IsMagma ◦-isMagma renaming (∙-cong to ◦-cong)
open SetoidReasoning setoid
identityˡ : LeftIdentity _≈₂_ ε₂ _◦_ → LeftIdentity _≈₁_ ε₁ _∙_
identityˡ idˡ x = injective (begin
⟦ ε₁ ∙ x ⟧ ≈⟨ homo ε₁ x ⟩
⟦ ε₁ ⟧ ◦ ⟦ x ⟧ ≈⟨ ◦-cong ε-homo refl ⟩
ε₂ ◦ ⟦ x ⟧ ≈⟨ idˡ ⟦ x ⟧ ⟩
⟦ x ⟧ ∎)
identityʳ : RightIdentity _≈₂_ ε₂ _◦_ → RightIdentity _≈₁_ ε₁ _∙_
identityʳ idʳ x = injective (begin
⟦ x ∙ ε₁ ⟧ ≈⟨ homo x ε₁ ⟩
⟦ x ⟧ ◦ ⟦ ε₁ ⟧ ≈⟨ ◦-cong refl ε-homo ⟩
⟦ x ⟧ ◦ ε₂ ≈⟨ idʳ ⟦ x ⟧ ⟩
⟦ x ⟧ ∎)
identity : Identity _≈₂_ ε₂ _◦_ → Identity _≈₁_ ε₁ _∙_
identity = map identityˡ identityʳ
zeroˡ : LeftZero _≈₂_ ε₂ _◦_ → LeftZero _≈₁_ ε₁ _∙_
zeroˡ zeˡ x = injective (begin
⟦ ε₁ ∙ x ⟧ ≈⟨ homo ε₁ x ⟩
⟦ ε₁ ⟧ ◦ ⟦ x ⟧ ≈⟨ ◦-cong ε-homo refl ⟩
ε₂ ◦ ⟦ x ⟧ ≈⟨ zeˡ ⟦ x ⟧ ⟩
ε₂ ≈˘⟨ ε-homo ⟩
⟦ ε₁ ⟧ ∎)
zeroʳ : RightZero _≈₂_ ε₂ _◦_ → RightZero _≈₁_ ε₁ _∙_
zeroʳ zeʳ x = injective (begin
⟦ x ∙ ε₁ ⟧ ≈⟨ homo x ε₁ ⟩
⟦ x ⟧ ◦ ⟦ ε₁ ⟧ ≈⟨ ◦-cong refl ε-homo ⟩
⟦ x ⟧ ◦ ε₂ ≈⟨ zeʳ ⟦ x ⟧ ⟩
ε₂ ≈˘⟨ ε-homo ⟩
⟦ ε₁ ⟧ ∎)
zero : Zero _≈₂_ ε₂ _◦_ → Zero _≈₁_ ε₁ _∙_
zero = map zeroˡ zeroʳ
------------------------------------------------------------------------
-- Structures
isMonoid : IsMonoid _≈₂_ _◦_ ε₂ → IsMonoid _≈₁_ _∙_ ε₁
isMonoid isMonoid = record
{ isSemigroup = isSemigroup M.isSemigroup
; identity = identity M.isMagma M.identity
} where module M = IsMonoid isMonoid
isCommutativeMonoid : IsCommutativeMonoid _≈₂_ _◦_ ε₂ →
IsCommutativeMonoid _≈₁_ _∙_ ε₁
isCommutativeMonoid isCommMonoid = record
{ isMonoid = isMonoid C.isMonoid
; comm = comm C.isMagma C.comm
} where module C = IsCommutativeMonoid isCommMonoid
| {
"alphanum_fraction": 0.5577578198,
"avg_line_length": 33.9894736842,
"ext": "agda",
"hexsha": "416a17bc3b54abca550f946407c1d970286d21c7",
"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/Morphism/MonoidMonomorphism.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/Morphism/MonoidMonomorphism.agda",
"max_line_length": 75,
"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/Morphism/MonoidMonomorphism.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": 1227,
"size": 3229
} |
------------------------------------------------------------------------------
-- Testing the --without-K flag
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
-- {-# OPTIONS --without-K #-}
module WithoutK where
-- The following code fails with the --without-K flag.
data _≡_ {A : Set} : A → A → Set where
refl : ∀ x → x ≡ x
K : {A : Set} (P : {x : A} → x ≡ x → Set) →
(∀ x → P (refl x)) →
∀ {x} (x≡x : x ≡ x) → P x≡x
K P p (refl x) = p x
| {
"alphanum_fraction": 0.3593004769,
"avg_line_length": 29.9523809524,
"ext": "agda",
"hexsha": "06f274ec2d12407a86246b55d530928a3f04b894",
"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/k-axiom/WithoutK.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/k-axiom/WithoutK.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/k-axiom/WithoutK.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": 165,
"size": 629
} |
open import Level
open import Data.Unit
open import Data.Bool
open import Data.Nat
open import Data.Fin
open import Data.Sum
open import Data.Maybe
open import Data.Product
open import Data.Vec using (Vec; _∷_; [])
import Data.Vec as Vec
open import Data.List
open import Relation.Binary.PropositionalEquality
--------------- lenses
Lens : Set → Set → Set
Lens A B = A → B × (B → A)
idₗ : {A : Set} → Lens A A
idₗ = λ z → z , λ x → x
_∘ₗ_ : {A B C : Set} → Lens A B → Lens B C → Lens A C
l ∘ₗ k = λ a → let (l₁ , l₂) = l a; (k₁ , k₂) = k l₁ in k₁ , λ x → l₂ (k₂ x)
infixl 9 _∘ₗ_
--- composition laws
_≡ₗ_ : {A B : Set} (k l : Lens A B) → Set
_≡ₗ_ {A} {B} k l = (a : A) → let (k₁ , k₂) = k a; (l₁ , l₂) = l a in k₁ ≡ l₁ × ((b : B) → k₂ b ≡ l₂ b)
infix 4 _≡ₗ_
id-left : {A B : Set} (k : Lens A B) → idₗ ∘ₗ k ≡ₗ k
id-left k a = refl , λ b → refl
id-right : {A B : Set} (k : Lens A B) → k ≡ₗ idₗ ∘ₗ k
id-right k a = refl , λ b → refl
comp-assoc : {A B C D : Set} (k : Lens A B) (l : Lens B C) (m : Lens C D) → k ∘ₗ (l ∘ₗ m) ≡ₗ (k ∘ₗ l) ∘ₗ m
comp-assoc k l m a = refl , λ b → refl
--------------- heterogeneous lists
TList : Set₁
TList = List Set
data HList : TList → Set where
[] : HList []
_∷_ : ∀ {t : Set} {ts : TList} → (v : t) → HList ts → HList (t ∷ ts)
--- operations
_+++_ : ∀ {ts xs : TList} → HList ts → HList xs → HList (ts ++ xs)
[] +++ y = y
(v ∷ x) +++ y = v ∷ (x +++ y)
splitH : ∀ {ts xs : TList} → HList (ts ++ xs) → HList ts × HList xs
splitH {ts = []} xs₁ = [] , xs₁
splitH {ts = x ∷ ts} (v ∷ xs₁) = let (r₁ , r₂) = splitH {ts = ts} xs₁ in v ∷ r₁ , r₂
---------------- auxiliary stuff
TList′ : ℕ → Set₁
TList′ = Vec Set
data HList′ : {n : ℕ} → TList′ n → Set where
[] : HList′ []
_∷_ : ∀ {n} {t : Set} {ts : TList′ n} → (v : t) → HList′ ts → HList′ (t ∷ ts)
pattern ex a = ._ , a
toVec : ∀ {ℓ} {A : Set ℓ} (as : List A) → Σ ℕ λ n → (n ≡ length as) × Vec A n
toVec [] = 0 , refl , []
toVec (x ∷ as) with toVec as
toVec (x ∷ as) | ex (refl , as′) = _ , refl , x ∷ as′
toVec′ : ∀ {ts : TList} → HList ts → let (_ , _ , ts′) = toVec ts in HList′ ts′ × (HList′ ts′ → HList ts)
toVec′ {[]} [] = [] , (λ _ → [])
toVec′ {x ∷ ts} (v ∷ xs) with toVec ts | toVec′ xs
toVec′ {x ∷ ts} (v ∷ xs) | ex (refl , _) | xs′ , f = v ∷ xs′ , λ { (v₁ ∷ x₁) → v₁ ∷ f x₁ }
----------
lookup : (ts : TList) → Fin (length ts) → Set
lookup x i with toVec x
lookup x i | ex (refl , v) = Vec.lookup i v
---------------------------------------------- signals
Signal : ∀ {ℓ} → TList → Set ℓ → Set ℓ
Signal ts A = HList ts → A
widenSignal : ∀ {ts xs : TList} {A : Set} → Signal ts A → Signal (ts ++ xs) A
widenSignal s vs = s (proj₁ (splitH vs))
sig : ∀ {ts : TList} (i : Fin (length ts)) → Signal ts (lookup ts i)
sig {ts} i st with toVec ts | toVec′ st
sig i st | ex (refl , v) | z , _ = sig′ i z
where
sig′ : ∀ {n} {ts : Vec Set n} (i : Fin n) → HList′ ts → Vec.lookup i ts
sig′ zero (v ∷ x) = v
sig′ (suc i) (v ∷ x) = sig′ i x
join : ∀ {ts : TList} {A : Set} → Signal ts (Signal ts A) → Signal ts A
join s vs = s vs vs
ret : ∀ {ts : TList} {A : Set} → A → Signal ts A
ret a _ = a
-- TODO: ret + join monad laws
------------------------------------ references
Ref : TList → Set → Set
Ref ts = Lens (HList ts)
widenRef : {ts xs : TList} {A : Set} → Ref ts A → Ref (ts ++ xs) A
widenRef r vs = let (vs₁ , vs₂) = splitH vs; (r₁ , r₂) = r vs₁ in r₁ , λ x → r₂ x +++ vs₂
ref : {ts : TList} (i : Fin (length ts)) → Ref ts (lookup ts i)
ref {ts} i st with toVec ts | toVec′ st
ref {ts} i st | ex (refl , v) | z , tr = let (r₁ , r₂) = ref′ i z in r₁ , λ x → tr (r₂ x)
where
ref′ : ∀ {n} {ts : TList′ n} (i : Fin n) → Lens (HList′ ts) (Vec.lookup i ts)
ref′ zero (v ∷ x) = v , λ v → v ∷ x
ref′ (suc i) (v ∷ x) with ref′ i x
ref′ (suc i) (v ∷ x) | z , f = z , λ z → v ∷ f z
unitRef : ∀ {ts : TList} → Ref ts ⊤
unitRef st = tt , λ tt → st
joinRef : ∀ {ts : TList} {A : Set} → Signal ts (Ref ts A) → Ref ts A
joinRef s st = s st st
lensMap : ∀ {ts : TList} {A B : Set} → Ref ts A → Lens A B → Ref ts B
lensMap = _∘ₗ_
readRef : ∀ {ts : TList} {A : Set} → Ref ts A → Signal ts A
readRef r st = proj₁ (r st)
---------------------------------- programs
open import Coinduction
Event : TList → Set
Event ts = Σ (Fin (length ts)) λ i → lookup ts i
mutual
data R (ts : TList) : Set₁ where
step : HList ts → (Event ts → ∞ (W ts)) → R ts
W : TList → Set₁
W ts = Σ TList λ vs → R (ts ++ vs)
Prog : Set₁
Prog = W []
-----------------------------------------
Gen : TList → TList → Set → Set
Gen ts xs A = HList ts → A × HList (ts ++ xs)
Gen′ : TList → Set → Set₁
Gen′ ts A = HList ts → A × Σ TList λ xs → HList (ts ++ xs)
-- TODO: widenGen
data Trigger (ts : TList) (A : Set) : Set₁ where
extend : {B : Set} → Ref ts B → Lens A B → Trigger ts A
stabilize : (A → A → Bool) → Signal ts A → Trigger ts A
onChange : Signal ts (Gen′ ts A) → Trigger ts A
runTrigger : ∀ {ts : TList} {A : Set} → Trigger ts A → Gen′ ts A
runTrigger (extend x x₁) x₂ = {!!}
runTrigger (stabilize x x₁) x₂ = {!!}
runTrigger (onChange x) x₁ = {!!}
-- ...
| {
"alphanum_fraction": 0.5130162458,
"avg_line_length": 27.6162162162,
"ext": "agda",
"hexsha": "14ba1d374f6f57726a96da105ab6ecb4b4fa9235",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-04-01T04:10:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-16T10:01:44.000Z",
"max_forks_repo_head_hexsha": "2f0b9a36ac8853780e2b09ad0769464dd3837dab",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "silky/lensref",
"max_forks_repo_path": "Model.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2f0b9a36ac8853780e2b09ad0769464dd3837dab",
"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": "silky/lensref",
"max_issues_repo_path": "Model.agda",
"max_line_length": 106,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "2f0b9a36ac8853780e2b09ad0769464dd3837dab",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "divipp/lensref",
"max_stars_repo_path": "Model.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-06T18:57:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-02-14T22:51:43.000Z",
"num_tokens": 2096,
"size": 5109
} |
module Binding where
open import Agda.Primitive
data Freer {ℓ} (F : Set ℓ → Set (lsuc ℓ)) (A : Set (lsuc ℓ)) : Set (lsuc ℓ) where
pure : A → Freer F A
free : ∀ {a : Set ℓ} → (a → Freer F A) → F a → Freer F A
| {
"alphanum_fraction": 0.576744186,
"avg_line_length": 23.8888888889,
"ext": "agda",
"hexsha": "e98506e20e19a5e13d38c5d7de6601bf5ecc76d8",
"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-1/Binding.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-1/Binding.agda",
"max_line_length": 81,
"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-1/Binding.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 92,
"size": 215
} |
{- LEMMAS FOR BOUNDING THEOREM WITH NEW COMPLEXITY LANGUAGE -}
open import Preliminaries
open import Source
open import Pilot
open import Translation-New
module Bounding-Lemmas-New where
mutual
valBound : ∀{τ} → (e : [] Source.|- τ) → val e → [] Pilot.|- ⟨⟨ τ ⟩⟩ → Set
valBound .z z-isval E = z ≤s E
valBound .(suc e) (suc-isval e v) E = Σ (λ E' → valBound e v E' × s E' ≤s E)
valBound .(prod e1 e2) (pair-isval e1 e2 v1 v2) E = valBound e1 v1 (l-proj E) × valBound e2 v2 (r-proj E)
valBound {τ1 ->s τ2} .(lam e) (lam-isval e) E = (v₁ : [] Source.|- τ1) (vv : val v₁)
(E1 : [] Pilot.|- ⟨⟨ τ1 ⟩⟩) →
valBound v₁ vv E1 →
expBound (Source.subst e (Source.q v₁)) (app E E1)
valBound .unit unit-isval E = Unit
valBound .(delay e) (delay-isval e) E = expBound e E
valBound .nil nil-isval E = nil ≤s E
valBound .(x ::s xs) (cons-isval x xs v v₁) E = Σ (λ E' → Σ (λ E'' → (valBound x v E' × valBound xs v₁ E'') × (E' ::c E'') ≤s E))
valBound .true true-isval E = true ≤s E
valBound .false false-isval E = false ≤s E
expBound : ∀{τ} → [] Source.|- τ → [] Pilot.|- || τ || → Set
expBound {τ} e b = (v₁ : [] Source.|- τ) (vv : val v₁) (n : Cost) →
evals e v₁ n → interp-Cost n ≤s l-proj b × valBound v₁ vv (r-proj b)
mutual
weakeningExp : ∀{τ} → (e : [] Source.|- τ) → (E E' : [] Pilot.|- || τ ||) → expBound e E → E ≤s E' → expBound e E'
weakeningExp e c1 c2 d c1≤c2 e' ve' n i = trans-s (fst (d e' ve' n i)) (cong-lproj c1≤c2) ,
weakeningVal e' ve' (r-proj c1) (r-proj c2) (snd (d e' ve' n i)) (cong-rproj c1≤c2)
weakeningVal : ∀{τ} → (v : [] Source.|- τ) → (vv : val v) → (E E' : [] Pilot.|- ⟨⟨ τ ⟩⟩) → valBound v vv E → E ≤s E' → valBound v vv E'
weakeningVal {unit} unit unit-isval E E' vb e≤e' = <>
weakeningVal {nat} .z z-isval E E' vb e≤e' = vb trans e≤e'
weakeningVal {nat} .(suc e) (suc-isval e vv) E E' (i , vbi , si≤se) e≤e' = i , (vbi , (trans-s si≤se e≤e'))
weakeningVal {susp τ} .(delay e) (delay-isval e) E E' vb e≤e' v₁ vv n x = weakeningExp e _ E' vb e≤e' v₁ vv n x
weakeningVal {τ ->s τ₁} .(lam e) (lam-isval e) E E' vb e≤e' v₁ vv c1 x v₂ vv₁ n x₁ = (λ a va a' vba b b' n₁ x₂ →
fst (vb a va a' vba b b' n₁ x₂) trans cong-lproj (cong-app e≤e') ,
weakeningVal b b' (r-proj (app E a')) (r-proj (app E' a'))
(snd (vb a va a' vba b b' n₁ x₂)) (cong-rproj (cong-app e≤e')))
v₁ vv c1 x v₂ vv₁ n x₁
weakeningVal {τ ×s τ₁} .(prod e1 e2) (pair-isval e1 e2 vv1 vv2) E E' vb e≤e' =
weakeningVal e1 vv1 (l-proj E) (l-proj E') (fst vb) (cong-lproj e≤e') ,
weakeningVal e2 vv2 (r-proj E) (r-proj E') (snd vb) (cong-rproj e≤e')
weakeningVal {list τ} .nil nil-isval E E' vb e≤e' = vb trans e≤e'
weakeningVal {list τ} .(x ::s xs) (cons-isval x xs vv vv₁) E E' (h , t , (hvb , tvb) , steps) e≤e' = h , (t , ((hvb , tvb) , (steps trans e≤e')))
weakeningVal {bool} .true true-isval E E' vb e≤e' = vb trans e≤e'
weakeningVal {bool} .false false-isval E E' vb e≤e' = vb trans e≤e'
weakeningExp' : ∀{τ} {e : [] Source.|- τ} {E E' : [] Pilot.|- || τ ||} → expBound e E → E ≤s E' → expBound e E'
weakeningExp' eb e≤ = weakeningExp _ _ _ eb e≤
weakeningVal' : ∀{τ} { v : [] Source.|- τ} (vv : val v) {E E' : [] Pilot.|- ⟨⟨ τ ⟩⟩}
→ valBound v vv E → E ≤s E' → valBound v vv E'
weakeningVal' vv v e = weakeningVal _ vv _ _ v e
substVal : ∀{Γ} → (Θ : Source.sctx [] Γ) → Set
substVal {Γ} Θ = {τ : _} (x : τ Source.∈ Γ) → val (Θ x)
extend-substVal : ∀ {Γ' τ} {Θ : Source.sctx [] Γ'} {e : [] Source.|- τ}
→ substVal Θ
→ val e
→ substVal (Source.lem3' Θ e)
extend-substVal sv vv i0 = vv
extend-substVal sv vv (iS x) = sv x
extend-substVal2 : ∀ {Γ' τ1 τ2} {Θ : Source.sctx [] Γ'} {e : [] Source.|- τ1} {e' : [] Source.|- τ2}
→ substVal Θ
→ val e → val e'
→ substVal (Source.lem4' Θ e e')
extend-substVal2 sv vv vv' i0 = vv
extend-substVal2 sv vv vv' (iS i0) = vv'
extend-substVal2 sv vv vv' (iS (iS x)) = sv x
extend-substVal3 : ∀ {Γ' τ1 τ2 τ3} {Θ : Source.sctx [] Γ'} {e : [] Source.|- τ1} {e' : [] Source.|- τ2} {e'' : [] Source.|- τ3}
→ substVal Θ
→ val e → val e' → val e''
→ substVal (Source.lem5' Θ e e' e'')
extend-substVal3 sv vv vv' vv'' i0 = vv
extend-substVal3 sv vv vv' vv'' (iS i0) = vv'
extend-substVal3 sv vv vv' vv'' (iS (iS i0)) = vv''
extend-substVal3 sv vv vv' vv'' (iS (iS (iS x))) = sv x
substBound : ∀{Γ} → (Θ : Source.sctx [] Γ) → substVal Θ → (Θ' : Pilot.sctx [] ⟨⟨ Γ ⟩⟩c) → Set
substBound {Γ} Θ vΘ Θ' = {τ : _} (x : τ Source.∈ Γ) → valBound (Θ x) (vΘ x) (Θ' (lookup x))
extend-substBound : ∀{Γ τ} → {Θ : Source.sctx [] Γ} {vΘ : substVal Θ} {Θ' : Pilot.sctx [] ⟨⟨ Γ ⟩⟩c}
→ {e : [] Source.|- τ} {ve : val e} {E : [] Pilot.|- ⟨⟨ τ ⟩⟩}
→ substBound Θ vΘ Θ'
→ valBound e ve E
→ substBound (Source.lem3' Θ e) (extend-substVal vΘ ve) (Pilot.lem3' Θ' E)
extend-substBound sb vb i0 = vb
extend-substBound sb vb (iS x) = sb x
extend-substBound2 : ∀{Γ τ1 τ2} → {Θ : Source.sctx [] Γ} {vΘ : substVal Θ} {Θ' : Pilot.sctx [] ⟨⟨ Γ ⟩⟩c}
→ {e : [] Source.|- τ1} {ve : val e} {e' : [] Source.|- τ2} {ve' : val e'}
{E : [] Pilot.|- ⟨⟨ τ1 ⟩⟩} {E' : [] Pilot.|- ⟨⟨ τ2 ⟩⟩}
→ substBound Θ vΘ Θ'
→ valBound e ve E → valBound e' ve' E'
→ substBound (Source.lem4' Θ e e') (extend-substVal2 vΘ ve ve') (Pilot.lem4' Θ' E E')
extend-substBound2 sb vbE vbE' i0 = vbE
extend-substBound2 sb vbE vbE' (iS i0) = vbE'
extend-substBound2 sb vbE vbE' (iS (iS x)) = sb x
extend-substBound3 : ∀{Γ τ1 τ2 τ3} → {Θ : Source.sctx [] Γ} {vΘ : substVal Θ} {Θ' : Pilot.sctx [] ⟨⟨ Γ ⟩⟩c}
→ {e : [] Source.|- τ1} {ve : val e} {e' : [] Source.|- τ2} {ve' : val e'} {e'' : [] Source.|- τ3} {ve'' : val e''}
{E : [] Pilot.|- ⟨⟨ τ1 ⟩⟩} {E' : [] Pilot.|- ⟨⟨ τ2 ⟩⟩} {E'' : [] Pilot.|- ⟨⟨ τ3 ⟩⟩}
→ substBound Θ vΘ Θ'
→ valBound e ve E → valBound e' ve' E' → valBound e'' ve'' E''
→ substBound (Source.lem5' Θ e e' e'') (extend-substVal3 vΘ ve ve' ve'') (Pilot.lem5' Θ' E E' E'')
extend-substBound3 sb vbE vbE' vbE'' i0 = vbE
extend-substBound3 sb vbE vbE' vbE'' (iS i0) = vbE'
extend-substBound3 sb vbE vbE' vbE'' (iS (iS i0)) = vbE''
extend-substBound3 sb vbE vbE' vbE'' (iS (iS (iS x))) = sb x
-- inversion lemma
inv1 : ∀ {τ} {v v' : [] Source.|- τ} {n : Cost} → val v → evals v v' n → _≤s_{[]} (interp-Cost n) 0C
inv1 z-isval z-evals = refl-s
inv1 (suc-isval e v) (s-evals evals) = inv1 v evals
inv1 (pair-isval e1 e2 v v₁) (pair-evals evals evals₁) = cong-+ (inv1 v evals) (inv1 v₁ evals₁) trans +-unit-l trans refl-s
inv1 (lam-isval e) lam-evals = refl-s
inv1 unit-isval unit-evals = refl-s
inv1 (delay-isval e) delay-evals = refl-s
inv1 nil-isval nil-evals = refl-s
inv1 (cons-isval x xs v v₁) (cons-evals evals evals₁) = cong-+ (inv1 v evals) (inv1 v₁ evals₁) trans +-unit-l
inv1 true-isval true-evals = refl-s
inv1 false-isval false-evals = refl-s
inv2 : ∀ {τ} {v e : [] Source.|- τ} {n : Cost} -> val v → evals v e n → v == e
inv2 z-isval z-evals = Refl
inv2 (suc-isval e₁ v) (s-evals evals) = ap suc (inv2 v evals)
inv2 (pair-isval e1 e2 v v₁) (pair-evals evals evals₁) = ap2 prod (inv2 v evals) (inv2 v₁ evals₁)
inv2 (lam-isval e₁) lam-evals = Refl
inv2 unit-isval unit-evals = Refl
inv2 (delay-isval e₁) delay-evals = Refl
inv2 nil-isval nil-evals = Refl
inv2 (cons-isval x xs v v₁) (cons-evals evals evals₁) = ap2 _::s_ (inv2 v evals) (inv2 v₁ evals₁)
inv2 true-isval true-evals = Refl
inv2 false-isval false-evals = Refl
val-hprop : ∀ {τ} {v : [] Source.|- τ} → (d1 d2 : val v) → d1 == d2
val-hprop z-isval z-isval = Refl
val-hprop (suc-isval e d1) (suc-isval .e d2) = ap (suc-isval e) (val-hprop d1 d2)
val-hprop (pair-isval e1 e2 d1 d2) (pair-isval .e1 .e2 d3 d4) = ap2 (pair-isval e1 e2) (val-hprop d1 d3) (val-hprop d2 d4)
val-hprop (lam-isval e) (lam-isval .e) = Refl
val-hprop unit-isval unit-isval = Refl
val-hprop (delay-isval e) (delay-isval .e) = Refl
val-hprop nil-isval nil-isval = Refl
val-hprop (cons-isval x xs d1 d2) (cons-isval .x .xs d3 d4) = ap2 (cons-isval x xs) (val-hprop d1 d3) (val-hprop d2 d4)
val-hprop true-isval true-isval = Refl
val-hprop false-isval false-isval = Refl
transport-valBound : ∀{τ} {e e' : [] Source.|- τ} {d : val e} {d' : val e'}
→ (α : e == e')
→ transport val α d == d'
→ (E : [] Pilot.|- ⟨⟨ τ ⟩⟩)
→ valBound e d E → valBound e' d' E
transport-valBound Refl Refl E vb = vb
Eq0C-≤0 : ∀ {n} → Equals0c n → _≤s_{[]} (interp-Cost n) 0C
Eq0C-≤0 Eq0-0c = refl-s
Eq0C-≤0 (Eq0-+c e e₁) = cong-+ (Eq0C-≤0 e) (Eq0C-≤0 e₁) trans +-unit-l
| {
"alphanum_fraction": 0.503139475,
"avg_line_length": 58.5240963855,
"ext": "agda",
"hexsha": "61f6c25b212db34454376e197191e5aa45361446",
"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": "2404a6ef2688f879bda89860bb22f77664ad813e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "benhuds/Agda",
"max_forks_repo_path": "complexity/Bounding-Lemmas-New.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e",
"max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "benhuds/Agda",
"max_issues_repo_path": "complexity/Bounding-Lemmas-New.agda",
"max_line_length": 160,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "benhuds/Agda",
"max_stars_repo_path": "complexity/Bounding-Lemmas-New.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z",
"num_tokens": 3835,
"size": 9715
} |
module StateSizedIO.Object where
open import Data.Product
open import StateSizedIO.Base public
{-
-- This definition was probably moved to StateSizedIO.Base
-- and by accident left here. Delete this.
record Interfaceˢ : Set₁ where
field
Stateˢ : Set
Methodˢ : Stateˢ → Set
Resultˢ : (s : Stateˢ) → (m : Methodˢ s) → Set
nextˢ : (s : Stateˢ) → (m : Methodˢ s) → Resultˢ s m → Stateˢ
open Interfaceˢ public
-}
module _ (I : Interfaceˢ)(let S = Stateˢ I) (let M = Methodˢ I)
(let R = Resultˢ I) (let next = nextˢ I) where
-- A simple object just returns for a method the response
-- and the object itself
record Objectˢ (s : S) : Set where
coinductive
field
objectMethod : (m : M s) → Σ[ r ∈ R s m ] Objectˢ (next s m r)
open Objectˢ public
_▹_ : {A : Set } → { B : Set } → A → (A → B) → B
a ▹ f = f a
-- Bisimilation for Objectˢ
module Bisim (I : Interfaceˢ)
(let S = Stateˢ I)
(let M = Methodˢ I)
(let R = Resultˢ I)
(let next = nextˢ I)
(let O = Objectˢ I)
where
mutual
record _≅_ {s : S} (o o' : O s) : Set where
coinductive
field bisimMethod : (m : M s) → objectMethod o m ≡×≅ objectMethod o' m
data _≡×≅_ {s m} : (p p' : Σ[ r ∈ R s m ] O (next s m r)) → Set where
bisim : ∀{r} (let s' = next s m r) {o o' : O s'} (p : o ≅ o')
→ (r , o) ≡×≅ (r , o')
open _≅_ public
refl≅ : ∀{s} (o : O s) → o ≅ o
bisimMethod (refl≅ o) m = bisim (refl≅ (proj₂ (objectMethod o m)))
| {
"alphanum_fraction": 0.560546875,
"avg_line_length": 26.4827586207,
"ext": "agda",
"hexsha": "99d4fead9ced15eb0003ea05501847ef01be07a1",
"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": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "stephanadls/state-dependent-gui",
"max_forks_repo_path": "src/StateSizedIO/Object.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"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": "stephanadls/state-dependent-gui",
"max_issues_repo_path": "src/StateSizedIO/Object.agda",
"max_line_length": 78,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "stephanadls/state-dependent-gui",
"max_stars_repo_path": "src/StateSizedIO/Object.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z",
"num_tokens": 595,
"size": 1536
} |
{-# OPTIONS --type-in-type #-}
open import Data.Unit
open import Data.Product
open import Data.List hiding ( concat )
open import Data.String
open import Relation.Binary.PropositionalEquality
module Spire.Examples.InferredPropositionalDesc where
----------------------------------------------------------------------
elimEq : {A : Set} (x : A) (P : (y : A) → x ≡ y → Set)
→ P x refl
→ (y : A) (p : x ≡ y) → P y p
elimEq .x P prefl x refl = prefl
----------------------------------------------------------------------
Label : Set
Label = String
Enum : Set
Enum = List Label
data Tag : Enum → Set where
here : ∀{l E} → Tag (l ∷ E)
there : ∀{l E} → Tag E → Tag (l ∷ E)
Cases : {E : Enum} (P : Tag E → Set) → Set
Cases {[]} P = ⊤
Cases {l ∷ E} P = P here × Cases λ t → P (there t)
case : {E : Enum} (P : Tag E → Set) (cs : Cases P) (t : Tag E) → P t
case {l ∷ E} P (c , cs) here = c
case {l ∷ E} P (c , cs) (there t) = case (λ t → P (there t)) cs t
----------------------------------------------------------------------
data Desc (I : Set) : Set₁ where
`End : (i : I) → Desc I
`Rec : (i : I) (D : Desc I) → Desc I
`Arg : (A : Set) (B : A → Desc I) → Desc I
`RecFun : (A : Set) (B : A → I) (D : Desc I) → Desc I
ISet : Set → Set₁
ISet I = I → Set
El : {I : Set} (D : Desc I) (X : ISet I) → ISet I
El (`End j) X i = j ≡ i
El (`Rec j D) X i = X j × El D X i
El (`Arg A B) X i = Σ A (λ a → El (B a) X i)
El (`RecFun A B D) X i = ((a : A) → X (B a)) × El D X i
data μ {I : Set} (D : Desc I) (i : I) : Set where
con : El D (μ D) i → μ D i
All : {I : Set} (D : Desc I) {X : ISet I} (P : (i : I) → X i → Set) (i : I) (xs : El D X i) → Set
All (`End j) P i q = ⊤
All (`Rec j D) P i (x , xs) = P j x × All D P i xs
All (`Arg A B) P i (a , b) = All (B a) P i b
All (`RecFun A B D) P i (f , xs) = ((a : A) → P (B a) (f a)) × All D P i xs
caseD : (E : Enum) (I : Set) (cs : Cases (λ _ → Desc I)) (t : Tag E) → Desc I
caseD E I cs t = case (λ _ → Desc I) cs t
----------------------------------------------------------------------
ind :
{I : Set}
(D : Desc I)
(P : (i : I) → μ D i → Set)
(pcon : (i : I) (xs : El D (μ D) i) → All D P i xs → P i (con xs))
{i : I}
(x : μ D i)
→ P i x
hyps :
{I : Set}
(D₁ : Desc I)
(P : (i : I) → μ D₁ i → Set)
(pcon : (i : I) (xs : El D₁ (μ D₁) i) → All D₁ P i xs → P i (con xs))
(D₂ : Desc I)
{i : I}
(xs : El D₂ (μ D₁) i)
→ All D₂ P i xs
ind D P pcon (con xs) = pcon _ xs (hyps D P pcon D xs)
hyps D P pcon (`End j) q = tt
hyps D P pcon (`Rec j A) (x , xs) = ind D P pcon x , hyps D P pcon A xs
hyps D P pcon (`Arg A B) (a , b) = hyps D P pcon (B a) b
hyps D P pcon (`RecFun A B E) (f , xs) = (λ a → ind D P pcon (f a)) , hyps D P pcon E xs
----------------------------------------------------------------------
module Desugared where
ℕT : Enum
ℕT = "zero" ∷ "suc" ∷ []
VecT : Enum
VecT = "nil" ∷ "cons" ∷ []
ℕC : Tag ℕT → Desc ⊤
ℕC = caseD ℕT ⊤
( `End tt
, `Rec tt (`End tt)
, tt
)
ℕD : Desc ⊤
ℕD = `Arg (Tag ℕT) ℕC
ℕ : ⊤ → Set
ℕ = μ ℕD
zero : ℕ tt
zero = con (here , refl)
suc : ℕ tt → ℕ tt
suc n = con (there here , n , refl)
VecC : (A : Set) → Tag VecT → Desc (ℕ tt)
VecC A = caseD VecT (ℕ tt)
( `End zero
, `Arg (ℕ tt) (λ n → `Arg A λ _ → `Rec n (`End (suc n)))
, tt
)
VecD : (A : Set) → Desc (ℕ tt)
VecD A = `Arg (Tag VecT) (VecC A)
Vec : (A : Set) (n : ℕ tt) → Set
Vec A n = μ (VecD A) n
nil : (A : Set) → Vec A zero
nil A = con (here , refl)
cons : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n)
cons A n x xs = con (there here , n , x , xs , refl)
----------------------------------------------------------------------
module Induction where
add : ℕ tt → ℕ tt → ℕ tt
add = ind ℕD (λ _ _ → ℕ tt → ℕ tt)
(λ u t,c → case
(λ t → (c : El (ℕC t) ℕ u)
(ih : All ℕD (λ u n → ℕ u → ℕ u) u (t , c))
→ ℕ u → ℕ u
)
( (λ q ih n → n)
, (λ m,q ih,tt n → suc (proj₁ ih,tt n))
, tt
)
(proj₁ t,c)
(proj₂ t,c)
)
mult : ℕ tt → ℕ tt → ℕ tt
mult = ind ℕD (λ _ _ → ℕ tt → ℕ tt)
(λ u t,c → case
(λ t → (c : El (ℕC t) ℕ u)
(ih : All ℕD (λ u n → ℕ u → ℕ u) u (t , c))
→ ℕ u → ℕ u
)
( (λ q ih n → zero)
, (λ m,q ih,tt n → add n (proj₁ ih,tt n))
, tt
)
(proj₁ t,c)
(proj₂ t,c)
)
append : (A : Set) (m : ℕ tt) (xs : Vec A m) (n : ℕ tt) (ys : Vec A n) → Vec A (add m n)
append A m = ind (VecD A) (λ m xs → (n : ℕ tt) (ys : Vec A n) → Vec A (add m n))
(λ m t,c → case
(λ t → (c : El (VecC A t) (Vec A) m)
(ih : All (VecD A) (λ m xs → (n : ℕ tt) (ys : Vec A n) → Vec A (add m n)) m (t , c))
(n : ℕ tt) (ys : Vec A n) → Vec A (add m n)
)
( (λ q ih n ys → subst (λ m → Vec A (add m n)) q ys)
, (λ m',x,xs,q ih,tt n ys →
let m' = proj₁ m',x,xs,q
x = proj₁ (proj₂ m',x,xs,q)
q = proj₂ (proj₂ (proj₂ m',x,xs,q))
ih = proj₁ ih,tt
in
subst (λ m → Vec A (add m n)) q (cons A (add m' n) x (ih n ys))
)
, tt
)
(proj₁ t,c)
(proj₂ t,c)
)
concat : (A : Set) (m n : ℕ tt) (xss : Vec (Vec A m) n) → Vec A (mult n m)
concat A m n = ind (VecD (Vec A m)) (λ n xss → Vec A (mult n m))
(λ n t,c → case
(λ t → (c : El (VecC (Vec A m) t) (Vec (Vec A m)) n)
(ih : All (VecD (Vec A m)) (λ n xss → Vec A (mult n m)) n (t , c))
→ Vec A (mult n m)
)
( (λ q ih → subst (λ n → Vec A (mult n m)) q (nil A))
, (λ n',xs,xss,q ih,tt →
let n' = proj₁ n',xs,xss,q
xs = proj₁ (proj₂ n',xs,xss,q)
q = proj₂ (proj₂ (proj₂ n',xs,xss,q))
ih = proj₁ ih,tt
in
subst (λ n → Vec A (mult n m)) q (append A m xs (mult n' m) ih)
)
, tt
)
(proj₁ t,c)
(proj₂ t,c)
)
----------------------------------------------------------------------
module Eliminator where
elimℕ : (P : (ℕ tt) → Set)
(pzero : P zero)
(psuc : (m : ℕ tt) → P m → P (suc m))
(n : ℕ tt)
→ P n
elimℕ P pzero psuc = ind ℕD (λ u n → P n)
(λ u t,c → case
(λ t → (c : El (ℕC t) ℕ u)
(ih : All ℕD (λ u n → P n) u (t , c))
→ P (con (t , c))
)
( (λ q ih →
elimEq tt (λ u q → P (con (here , q)))
pzero
u q
)
, (λ n,q ih,tt →
elimEq tt (λ u q → P (con (there here , proj₁ n,q , q)))
(psuc (proj₁ n,q) (proj₁ ih,tt))
u (proj₂ n,q)
)
, tt
)
(proj₁ t,c)
(proj₂ t,c)
)
elimVec : (A : Set) (P : (n : ℕ tt) → Vec A n → Set)
(pnil : P zero (nil A))
(pcons : (n : ℕ tt) (a : A) (xs : Vec A n) → P n xs → P (suc n) (cons A n a xs))
(n : ℕ tt)
(xs : Vec A n)
→ P n xs
elimVec A P pnil pcons n = ind (VecD A) (λ n xs → P n xs)
(λ n t,c → case
(λ t → (c : El (VecC A t) (Vec A) n)
(ih : All (VecD A) (λ n xs → P n xs) n (t , c))
→ P n (con (t , c))
)
( (λ q ih →
elimEq zero (λ n q → P n (con (here , q)))
pnil
n q
)
, (λ n',x,xs,q ih,tt →
let n' = proj₁ n',x,xs,q
x = proj₁ (proj₂ n',x,xs,q)
xs = proj₁ (proj₂ (proj₂ n',x,xs,q))
q = proj₂ (proj₂ (proj₂ n',x,xs,q))
ih = proj₁ ih,tt
in
elimEq (suc n') (λ n q → P n (con (there here , n' , x , xs , q)))
(pcons n' x xs ih )
n q
)
, tt
)
(proj₁ t,c)
(proj₂ t,c)
)
----------------------------------------------------------------------
add : ℕ tt → ℕ tt → ℕ tt
add = elimℕ (λ _ → ℕ tt → ℕ tt)
(λ n → n)
(λ m ih n → suc (ih n))
mult : ℕ tt → ℕ tt → ℕ tt
mult = elimℕ (λ _ → ℕ tt → ℕ tt)
(λ n → zero)
(λ m ih n → add n (ih n))
append : (A : Set) (m : ℕ tt) (xs : Vec A m) (n : ℕ tt) (ys : Vec A n) → Vec A (add m n)
append A = elimVec A (λ m xs → (n : ℕ tt) (ys : Vec A n) → Vec A (add m n))
(λ n ys → ys)
(λ m x xs ih n ys → cons A (add m n) x (ih n ys))
concat : (A : Set) (m n : ℕ tt) (xss : Vec (Vec A m) n) → Vec A (mult n m)
concat A m = elimVec (Vec A m) (λ n xss → Vec A (mult n m))
(nil A)
(λ n xs xss ih → append A m xs (mult n m) ih)
----------------------------------------------------------------------
| {
"alphanum_fraction": 0.381273914,
"avg_line_length": 28.9446254072,
"ext": "agda",
"hexsha": "651eb44520f5e0a6b00974b668efe1cdb063af68",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z",
"max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "spire/spire",
"max_forks_repo_path": "formalization/agda/Spire/Examples/InferredPropositionalDesc.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
"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": "spire/spire",
"max_issues_repo_path": "formalization/agda/Spire/Examples/InferredPropositionalDesc.agda",
"max_line_length": 99,
"max_stars_count": 43,
"max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "spire/spire",
"max_stars_repo_path": "formalization/agda/Spire/Examples/InferredPropositionalDesc.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z",
"num_tokens": 3355,
"size": 8886
} |
{-# OPTIONS --without-K #-}
module Midi where
open import Agda.Builtin.String using (String)
open import Data.Fin using (toℕ)
open import Data.Nat using (ℕ)
open import Data.List
open import Data.Product using (_,_)
open import Note
open import Pitch
open import MidiEvent
open import Music
{-# FOREIGN GHC
import Codec.Midi
import Data.Text (Text, unpack)
import Data.List (sort)
type HsTicksPerBeat = Integer
type HsTicks = Integer
type HsKey = Integer
type HsVelocity = Integer
type HsPreset = Integer
type HsChannel = Integer
type HsTempo = Integer
type HsAbsTime = Integer
type HsTrackName = Text
-- convert beats per minute to microseconds per beat
bpmToTempo :: Int -> Tempo
bpmToTempo bpm = round $ 1000000 * 60 / fromIntegral bpm
data HsMidiMessage = HsNoteOn HsVelocity HsTicks HsKey | HsNoteOff HsVelocity HsTicks HsKey
deriving Eq
getTicks :: HsMidiMessage -> HsTicks
getTicks (HsNoteOn _ t _) = t
getTicks (HsNoteOff _ t _) = t
instance Ord HsMidiMessage where
a <= b = getTicks a <= getTicks b
data HsMidiTrack = HsMidiTrack HsTrackName HsPreset HsChannel HsTempo [HsMidiMessage]
fi = fromInteger
makeTrack :: Channel -> HsAbsTime -> [HsMidiMessage] -> (Track Ticks , HsAbsTime)
makeTrack c t [] = ([(0, TrackEnd)], t)
makeTrack c t (HsNoteOn v t' k : ms) = let (rest, t'') = makeTrack c t' ms
in ((fi (t' - t), NoteOn c (fi k) (fi v)) : rest, t'')
makeTrack c t (HsNoteOff v t' k : ms) = let (rest, t'') = makeTrack c t' ms
in ((fi (t' - t), NoteOff c (fi k) (fi v)) : rest, t'')
toTrack :: HsMidiTrack -> Track Ticks
toTrack (HsMidiTrack name preset channel tempo messages) =
(0, TrackName (unpack name)) :
(0, ProgramChange (fi channel) (fi preset)) :
(0, TempoChange (bpmToTempo (fi tempo))) :
fst (makeTrack (fi channel) 0 (sort messages))
toMidi :: HsTicksPerBeat -> [HsMidiTrack] -> Midi
toMidi ticks tracks = let mtracks = map toTrack tracks
in Midi MultiTrack (TicksPerBeat (fi ticks)) mtracks
exportTracks :: Text -> HsTicksPerBeat -> [HsMidiTrack] -> IO ()
exportTracks filePath ticksPerBeat tracks = do
let path = unpack filePath
putStrLn $ "Writing file " ++ path
-- putStrLn $ show $ toMidi ticksPerBeat tracks
exportFile path (toMidi ticksPerBeat tracks)
#-}
data Unit : Set where
unit : Unit
{-# COMPILE GHC Unit = data () (()) #-}
postulate
IO : Set → Set
{-# BUILTIN IO IO #-}
{-# COMPILE GHC IO = type IO #-}
FilePath = String
data Pair (A : Set) (B : Set) : Set where
pair : A → B → Pair A B
{-# COMPILE GHC Pair = data (,) ((,)) #-}
HInstrument HPitch HVelocity : Set
HInstrument = ℕ
HPitch = ℕ
HVelocity = ℕ
HChannel = ℕ
HTempo = ℕ
data MidiMessage : Set where
noteOn : HVelocity → Tick → HPitch → MidiMessage
noteOff : HVelocity → Tick → HPitch → MidiMessage
{-# COMPILE GHC MidiMessage = data HsMidiMessage (HsNoteOn | HsNoteOff) #-}
event→messages : MidiEvent → List MidiMessage
event→messages (midiEvent p start stop v) =
let v' = toℕ v
p' = unpitch p
in noteOn v' start p' ∷ noteOff v' stop p' ∷ []
data HMidiTrack : Set where
htrack : String → HInstrument → HChannel → HTempo → List MidiMessage → HMidiTrack
{-# COMPILE GHC HMidiTrack = data HsMidiTrack (HsMidiTrack) #-}
track→htrack : MidiTrack → HMidiTrack
track→htrack (track n i c t m) = htrack n (toℕ i) (toℕ c) t (concatMap event→messages m)
postulate
exportTracks : FilePath → -- path to the file to save the MIDI data to
ℕ → -- number of ticks per beat (by default a beat is a quarter note)
List HMidiTrack → -- tracks, one per instrument
IO Unit
{-# COMPILE GHC exportTracks = exportTracks #-}
| {
"alphanum_fraction": 0.6354140127,
"avg_line_length": 30.4263565891,
"ext": "agda",
"hexsha": "4120fe3ca782570d97aab9ac072947b841139e5c",
"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": "doc/icfp20/code/Midi.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": "doc/icfp20/code/Midi.agda",
"max_line_length": 100,
"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": "doc/icfp20/code/Midi.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": 1188,
"size": 3925
} |
-- | In this module we show that the substream relation is transitive.
open import Size
open import Streams
open import Relation.Binary.PropositionalEquality as P
open import Data.Product
open import Function
tl' : ∀{A} → Stream A → Stream A
tl' s = tl s {∞}
{-
data Reachable {A : Set} (P : A → Set) : Stream A → Set where
nowR : (s : Stream A) → P (hd s) → Reachable P s
laterR : (s : Stream A) → Reachable P (tl s) → Reachable P (tl s)
-}
{-
data Eventually {A : Set} (P : A → Set) (s : Stream A) : Set where
now : P (hd s) → Eventually P s
later : Eventually P (tl s) → Eventually P s
-}
record Always {A : Set} (P : A → Set) (s : Stream A) : Set where
coinductive
field
hd-valid : P (hd s)
tl-valid : Always P (tl s)
open Always public
Always-coiter : ∀{A} {P : A → Set} {B : Stream A → Set}
(hv : ∀ s → B s → P (hd s))
(tv : ∀ s → B s → B (tl s)) →
∀ s → B s → Always P s
hd-valid (Always-coiter hv tv s b) = hv s b
tl-valid (Always-coiter hv tv s b) = Always-coiter hv tv (tl s) (tv s b)
data E {A : Set} (P : A → Set) (F : Stream A → Set) (s : Stream A) : Set where
now : P (hd s) → F (tl s) → E P F s
later : E P F (tl s) → E P F s
record Fair {A : Set} (P : A → Set) (s : Stream A) : Set where
coinductive
field
step : E P (Fair P) s
open Fair public
Eventually : ∀{A} → (P : A → Set) → Stream A → Set
Eventually P = E P (Fair P)
Fair-coiter : ∀{A} {P : A → Set} {B : Stream A → Set}
(st : ∀ s → B s → E P B s) →
∀ s → B s → Fair P s
xFair-coiter : ∀{A} {P : A → Set} {B : Stream A → Set}
(st : ∀ s → B s → E P B s) →
∀ s → E P B s → Eventually P s
step (Fair-coiter st s b) = xFair-coiter st s (st s b)
xFair-coiter st s (now p b) = now p (Fair-coiter st (tl s) b)
xFair-coiter st s (later e) = later (xFair-coiter st (tl s) e)
Stream-coiter : ∀{A B : Set} → (B → A) → (B → B) → B → Stream A
hd (Stream-coiter h t b) = h b
tl (Stream-coiter h t b) = Stream-coiter h t (t b)
∃-elim : ∀{A : Set} {B : A → Set} {C : Set} →
((a : A) → B a → C) →
Σ A B → C
∃-elim f (a , b) = f a b
≡-elim : ∀{A : Set} {B : A → A → Set} →
((x : A) → B x x) →
{x y : A} → x ≡ y → B x y
≡-elim f {x = x} refl = f x
Always-coind : ∀{A} {P : A → Set} {B : Set} -- {C : Stream A → Set}
{h : B → A} {t : B → B}
(hv : ∀ b → P (h b))
→ ∀ b → Always P (Stream-coiter h t b)
Always-coind {A} {P = P} {B} {h} {t} hv b =
Always-coiter {B = λ s → ∃ λ b → s ≡ Stream-coiter h t b}
f g (Stream-coiter h t b) (b , refl)
where
f : (s : Stream A) → ∃ (λ b → s ≡ Stream-coiter h t b) → P (hd s)
f s = ∃-elim u
where
u : (b : B) → s ≡ Stream-coiter h t b → P (hd s)
u b p = subst P (sym (cong hd p)) (hv b)
g : (s : Stream A) →
∃ (λ b → s ≡ Stream-coiter h t b) →
∃ (λ b → tl s ≡ Stream-coiter h t b)
g s = ∃-elim u
where
u : (b : B) → s ≡ Stream-coiter h t b →
∃ (λ b₁ → tl s ≡ Stream-coiter h t b₁)
u b p = (t b , cong tl' p)
{-
hd-valid (Always-coind h t hv b) = hv b
tl-valid (Always-coind h t hv b) = Always-coind h t hv (t b)
-}
dcoiter-Fair : ∀{A} {P : A → Set} {B : Set} {C : Stream A → Set}
{h : B → A} {t : B → B}
(st : ∀ b → C (Stream-coiter h t b) → E P C (Stream-coiter h t b)) →
∀ b → C (Stream-coiter h t b) → Fair P (Stream-coiter h t b)
xdcoiter-Fair : ∀{A} {P : A → Set} {B : Set} {C : Stream A → Set}
{h : B → A} {t : B → B}
(st : ∀ b → C (Stream-coiter h t b) → E P C (Stream-coiter h t b)) →
∀ b → E P C (Stream-coiter h t b) → Eventually P (Stream-coiter h t b)
step (dcoiter-Fair st b c) = xdcoiter-Fair st b (st b c)
xdcoiter-Fair st b (now p c) = now p (dcoiter-Fair st _ c)
xdcoiter-Fair st b (later e) = later (xdcoiter-Fair st _ e)
E-iter : ∀{A} {P : A → Set} {F : Stream A → Set} {B : Stream A → Set}
(n : ∀ s → P (hd s) → F (tl s) → B s)
(l : ∀ s → B (tl s) → B s) →
∀ s → E P F s → B s
E-iter n l s (now p f) = n s p f
E-iter n l s (later e) = l s (E-iter n l (tl s) e)
{-
Ev-iter : ∀{A} {P : A → Set} {F : Stream A → Set} {B : Stream A → Set}
(st : ∀ s → Fair P s → F s)
(n : ∀ s → F (tl s) → B s)
(l : ∀ s → B (tl s) → B s) →
∀ s → Eventually P s → B s
Ev-iter st n l s (now p f) = n s (st (tl s) f)
Ev-iter st n l s (later e) = l s (Ev-iter st n l (tl s) e)
-}
{-
Ev-iter : ∀{A} {P : A → Set} {B : Stream A → Set}
(n : ∀ s → Fair P (tl s) → B s)
(l : ∀ s → B (tl s) → B s) →
∀ s → Eventually P s → B s
Ev-iter n l s (now p f) = n s f
Ev-iter n l s (later e) = l s (Ev-iter n l (tl s) e)
-}
{-
Ev-ind : ∀{A} {P : A → Set} (F : (t : Stream A) → Set)
(B : (t : Stream A) → Eventually P t → Set)
(st : ∀{t} → Fair P t → F t)
(n : ∀{t} → (p : P (hd t)) → (f : F (tl t)) → B t (now p f)) →
(l : ∀{t e} → B (tl t) e → B t (later e)) →
(s : Stream A) → (e : Eventually P s) → B s e
Ev-ind F B st n l s (now p f) =
let r = n p {!st!}
in {!!}
Ev-ind F B st n l s (later e) = l (Ev-ind F B st n l (tl s) e)
-}
filter : ∀{A} {P : A → Set} (s : Stream A) → Fair P s → Stream A
xfilter : ∀{A} {P : A → Set} (s : Stream A) → Eventually P s → Stream A
filter s p = xfilter s (step p)
hd (xfilter s (now p q)) = hd s
tl (xfilter s (now p q)) = filter (tl s) q
xfilter s (later p) = xfilter (tl s) p
filter-find : ∀{A} {P : A → Set} (s : Stream A) →
Eventually P s → A × ∃ (Fair P)
filter-find = E-iter (λ s p f → (hd s , tl s , f)) (λ s → id)
filter-h : ∀{A} {P : A → Set} → ∃ (Fair P) → A
filter-h (s , f) = proj₁ (filter-find s (step f))
filter-t : ∀{A} {P : A → Set} → ∃ (Fair P) → ∃ (Fair P)
filter-t {A} {P} (s , f) = proj₂ (filter-find s (step f))
filter' : ∀{A} {P : A → Set} → ∃ (Fair P) → Stream A
filter' = Stream-coiter filter-h filter-t
-- filter' : ∀{A} {P : A → Set} (s : Stream A) → Fair P s → Stream A
-- filter' s f = filter'' (s , f)
{-
filter-pres-fair : ∀{A} {P : A → Set} (u : ∃ (Fair P)) →
Fair P (filter' u)
filter-pres-fair u = {!!}
filter-always' : ∀{A} {P : A → Set} (u : ∃ (Fair P)) →
Always P (filter' u)
filter-always' {A} {P} (s , f) = Always-coiter {B = Fair P} {!!} {!!} (filter' (s , f)) {!!}
-}
filter-always' : ∀{A} {P : A → Set} (u : ∃ (Fair P)) →
Always P (filter' u)
filter-always' {A} {P} = Always-coind f
where
xf : (s : Stream A) (e : Eventually P s) → P (proj₁ (filter-find s e))
xf s (now p _) = p
xf s (later e) = xf (tl s) e
f : (u : ∃ (Fair P)) → P (filter-h u)
f (s , f) = xf s (step f)
filter-always : ∀{A} {P : A → Set} (s : Stream A) → (f : Fair P s) →
Always P (filter s f)
xfilter-always : ∀{A} {P : A → Set} (s : Stream A) → (e : Eventually P s) →
Always P (xfilter s e)
filter-always s f = xfilter-always s (step f)
hd-valid (xfilter-always s (now p f)) = p
tl-valid (xfilter-always s (now p f)) = filter-always (tl s) f
xfilter-always s (later e) = xfilter-always (tl s) e
{-
filter-pres : ∀{A} {P Q : A → Set} (s : Stream A) → (f : Fair P s) →
Always Q s → Always Q (filter s f)
xfilter-pres : ∀{A} {P Q : A → Set} (s : Stream A) → (e : Eventually P s) →
Always Q s → Always Q (xfilter s e)
filter-pres s f a = xfilter-pres s (step f) a
xfilter-pres = {!!}
-}
-- xfilter-pres {Q = Q} s e a =
-- Ev-ind (λ t e → Always Q (xfilter t e))
-- (λ p f → record { hd-valid = {!hd-valid a!} ; tl-valid = {!!} })
-- {!!}
-- s
-- e
{-
hd-valid (xfilter-pres s (now p f) a) = hd-valid a
tl-valid (xfilter-pres s (now p f) a) = filter-pres (tl s) f (tl-valid a)
xfilter-pres s (later e) a = xfilter-pres (tl s) e (tl-valid a)
-}
| {
"alphanum_fraction": 0.4817629179,
"avg_line_length": 32.7634854772,
"ext": "agda",
"hexsha": "74db0fbdf823a5768069780fa37ea088598d12bb",
"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": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "Streams/PredFilter.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"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": "hbasold/Sandbox",
"max_issues_repo_path": "Streams/PredFilter.agda",
"max_line_length": 92,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "Streams/PredFilter.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3124,
"size": 7896
} |
module Bools where
open import Agda.Builtin.Bool public
renaming (Bool to 𝔹)
not : 𝔹 → 𝔹
not true = false
not false = true
-- T : 𝔹 → Set
-- T true = ⊤
-- T false = ⊥
if_then_else_ : ∀ {a} {A : Set a} → 𝔹 → A → A → A
if true then t else _ = t
if false then _ else f = f
_∧_ : 𝔹 → 𝔹 → 𝔹
true ∧ b = b
false ∧ _ = false
_∨_ : 𝔹 → 𝔹 → 𝔹
true ∨ _ = true
false ∨ b = b
_xor_ : 𝔹 → 𝔹 → 𝔹
true xor b = not b
false xor b = b
| {
"alphanum_fraction": 0.5522041763,
"avg_line_length": 14.8620689655,
"ext": "agda",
"hexsha": "29f8cd23911db7cc8a26eeb8ac4916657e32c114",
"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/Bools.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/Bools.agda",
"max_line_length": 49,
"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/Bools.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": 204,
"size": 431
} |
{-
Definition of finitely indexed types
A type is finitely indexed if, for some `n`, there merely exists a
surjective function from `Fin n` to it. Note that a type doesn't need
to be a set in order for it to be finitely indexed. For example, the
circle is finitely indexed.
This definition is weaker than `isFinSet`.
-}
{-# OPTIONS --safe #-}
module Cubical.Data.FinInd where
open import Cubical.Data.Nat
open import Cubical.Data.SumFin
open import Cubical.Data.Sigma
open import Cubical.Data.FinSet
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Functions.Surjection
open import Cubical.HITs.PropositionalTruncation as PT
open import Cubical.HITs.S1
private
variable
ℓ : Level
A : Type ℓ
isFinInd : Type ℓ → Type ℓ
isFinInd A = ∃[ n ∈ ℕ ] Fin n ↠ A
isFinSet→isFinInd : isFinSet A → isFinInd A
isFinSet→isFinInd h = PT.elim
(λ _ → squash)
(λ equiv →
∣ _ , invEq equiv , section→isSurjection (retEq equiv) ∣) (h .snd)
isFinInd-S¹ : isFinInd S¹
isFinInd-S¹ = ∣ 1 , f , isSurjection-f ∣
where
f : Fin 1 → S¹
f _ = base
isSurjection-f : isSurjection f
isSurjection-f b = PT.map (λ base≡b → fzero , base≡b) (isConnectedS¹ b)
| {
"alphanum_fraction": 0.7192118227,
"avg_line_length": 24.8571428571,
"ext": "agda",
"hexsha": "cebab1042025dbd929b5c10cca5730571d3ae99a",
"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": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Data/FinInd.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"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": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Data/FinInd.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Data/FinInd.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 402,
"size": 1218
} |
{-# OPTIONS --without-K #-}
module higher.circle.core where
open import equality
data S¹ : Set where
base : S¹
postulate loop : base ≡ base
private
module Eliminators' {i}(B : S¹ → Set i)
(m : B base)
(l : subst B loop m ≡ m) where
elim' : (x : S¹) → B x
elim' base = m
β-base' : elim' base ≡ m
β-base' = refl
postulate β-loop' : ap' elim' loop ≡ l
private
module Eliminators {i} {B : Set i}
(m : B) (l : m ≡ m) where
open Eliminators' (λ _ → B) m (subst-const loop m · l)
elim : S¹ → B
elim = elim'
β-base : elim base ≡ m
β-base = refl
postulate β-loop : ap elim loop ≡ l
open Eliminators public
open Eliminators' public
| {
"alphanum_fraction": 0.5387700535,
"avg_line_length": 19.6842105263,
"ext": "agda",
"hexsha": "70f37ae039250b60fceea25a09afc60a2de2f83e",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/higher/circle/core.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/higher/circle/core.agda",
"max_line_length": 58,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/higher/circle/core.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 243,
"size": 748
} |
open import Type
open import Logic.Classical as Logic using (Classical)
open import Logic.Predicate as Logic using ()
module Formalization.ClassicalPropositionalLogic.SequentCalculus ⦃ classical : ∀{ℓ} → Logic.∀ₗ(Classical{ℓ}) ⦄ where
import Lvl
open import Data
open import Data.Boolean
import Data.Boolean.Operators
open import Data.Boolean.Stmt
open import Data.Either as Either using (_‖_ ; Left ; Right)
open import Data.List
open import Data.List.Functions using () renaming (singleton to · ; _++_ to _∪_)
open import Data.List.Relation.Permutation
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
private module BoolOp = Data.Boolean.Operators.Logic
open import Functional as Fn
open import Function.Names using (_⊜_)
open import Logic
open import Logic.Propositional as Logic using (_←_)
open import Logic.Propositional.Theorems as Logic using ()
open import Logic.Predicate.Theorems as Logic using ()
open import Relator.Equals renaming (_≡_ to _≡ₑ_)
open import Relator.Equals.Proofs
open import Relator.Equals.Proofs.Equiv
open import Structure.Relator.Properties
open import Syntax.Function
open import Syntax.Type
open import Syntax.Implication hiding (_⇒_)
open import Type.Size.Countable
private variable ℓₚ ℓ ℓ₁ ℓ₂ : Lvl.Level
open import Formalization.ClassicalPropositionalLogic.Syntax
open import Formalization.ClassicalPropositionalLogic.Syntax.Proofs
open import Formalization.ClassicalPropositionalLogic.Semantics
open import Formalization.ClassicalPropositionalLogic.Semantics.Proofs
import Formalization.ClassicalPropositionalLogic.TruthTable as TruthTable
_∪·_ : ∀{T : Type{ℓ}} → List(T) → T → List(T)
_∪·_ = Fn.swap(_⊰_)
infixl 1000 _∪·_
module _ {ℓₚ} {P : Type{ℓₚ}} where
private variable Γ Γ₁ Γ₂ Γ₃ Δ Δ₁ Δ₂ Δ₃ : List(Formula(P))
private variable φ φ₁ φ₂ ψ A B C : Formula(P)
private variable p : P
data _⇒_ : List(Formula(P)) → List(Formula(P)) → Stmt{Lvl.𝐒(ℓₚ)} where
axiom : ((·(• p)) ⇒ (·(• p)))
weakenₗ : (Γ ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)
permuteₗ : .(Γ₁ permutes Γ₂) → (Γ₁ ⇒ Δ) → (Γ₂ ⇒ Δ)
contractₗ : ((Γ ∪· A ∪· A) ⇒ Δ) → ((Γ ∪· A) ⇒ Δ)
⊥ₗ : (Γ ∪· ⊥) ⇒ ∅
∧ₗₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)
∧ₗᵣ : ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∧ B)) ⇒ Δ)
∨ₗ : ((Γ ∪· A) ⇒ Δ) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ∨ B)) ⇒ Δ)
⟶ₗ : (Γ ⇒ (Δ ∪· A)) → ((Γ ∪· B) ⇒ Δ) → ((Γ ∪· (A ⟶ B)) ⇒ Δ)
¬ₗ : (Γ ⇒ (Δ ∪· A)) → ((Γ ∪· (¬ A)) ⇒ Δ)
weakenᵣ : (Γ ⇒ Δ) → (Γ ⇒ (Δ ∪· A))
permuteᵣ : .(Δ₁ permutes Δ₂) → (Γ ⇒ Δ₁) → (Γ ⇒ Δ₂)
contractᵣ : (Γ ⇒ (Δ ∪· A ∪· A)) → (Γ ⇒ (Δ ∪· A))
⊤ᵣ : ∅ ⇒ (Δ ∪· ⊤)
∧ᵣ : (Γ ⇒ (Δ ∪· A)) → (Γ ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ∧ B)))
∨ᵣₗ : (Γ ⇒ (Δ ∪· A)) → (Γ ⇒ (Δ ∪· (A ∨ B)))
∨ᵣᵣ : (Γ ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ∨ B)))
⟶ᵣ : ((Γ ∪· A) ⇒ (Δ ∪· B)) → (Γ ⇒ (Δ ∪· (A ⟶ B)))
¬ᵣ : ((Γ ∪· A) ⇒ Δ) → (Γ ⇒ (Δ ∪· (¬ A)))
permute : .(Γ₁ permutes Γ₂) → .(Δ₁ permutes Δ₂) → (Γ₁ ⇒ Δ₁) → (Γ₂ ⇒ Δ₂)
permute permΓ permΔ ΓΔ = permuteₗ permΓ (permuteᵣ permΔ ΓΔ)
open import Data.List.Equiv.Id
open import Data.List.Relation.Membership
open import Data.List.Proofs
open import Structure.Operator.Properties
refl : (· A) ⇒ (· A)
refl {• x} = axiom
refl {⊤} = weakenₗ ⊤ᵣ
refl {⊥} = weakenᵣ ⊥ₗ
refl {¬ A} = ¬ᵣ (permuteₗ(_permutes_.swap) (¬ₗ refl))
refl {A ∧ B} = ∧ᵣ (∧ₗₗ refl) (∧ₗᵣ refl)
refl {A ∨ B} = ∨ₗ (∨ᵣₗ refl) (∨ᵣᵣ refl)
refl {A ⟶ B} = ⟶ᵣ (permuteₗ(_permutes_.swap) (⟶ₗ (permuteᵣ(_permutes_.swap) (weakenᵣ refl)) (permuteₗ(_permutes_.swap) (weakenₗ refl))))
refl {A ⟷ B} = {!!}
--[⇒]-trans : (Γ₁ ⇒ Γ₂) → (Γ₂ ⇒ Γ₃) → (Γ₁ ⇒ Γ₃)
--[⇒]-trans p12 p23 = {!-c -t 10!}
[⇒][++]ᵣ-weakenₗ : (Γ₂ ⇒ Δ) → ((Γ₁ ∪ Γ₂) ⇒ Δ)
[⇒][++]ᵣ-weakenₗ {Γ₁ = ∅} p = p
[⇒][++]ᵣ-weakenₗ {Γ₁ = φ₁ ⊰ Γ₁} p = weakenₗ([⇒][++]ᵣ-weakenₗ {Γ₁ = Γ₁} p)
[⇒][++]ₗ-weakenₗ : (Γ₁ ⇒ Δ) → ((Γ₁ ∪ Γ₂) ⇒ Δ)
[⇒][++]ₗ-weakenₗ {Γ₁ = Γ₁}{Δ = Δ}{Γ₂ = Γ₂} Γ₁Δ = permuteₗ (sub₂(_≡ₑ_)(_permutes_) (commutativity(_∪_) ⦃ {!!} ⦄ {Γ₂}{Γ₁})) ([⇒][++]ᵣ-weakenₗ {Γ₁ = Γ₂} Γ₁Δ)
[⇒][++]-weakenᵣ : (Γ ⇒ Δ₂) → (Γ ⇒ (Δ₁ ∪ Δ₂))
[⇒][++]-weakenᵣ {Δ₁ = ∅} p = p
[⇒][++]-weakenᵣ {Δ₁ = φ₁ ⊰ Δ₁} p = weakenᵣ([⇒][++]-weakenᵣ {Δ₁ = Δ₁} p)
[⇒][⊥]-arbitrary : ((Γ ∪· ⊥) ⇒ Δ)
[⇒][⊥]-arbitrary {Γ = Γ}{Δ = Δ} = permuteᵣ (sub₂(_≡ₑ_)(_permutes_) (identityᵣ(_∪_)(∅))) ([⇒][++]-weakenᵣ{Δ₂ = ∅}{Δ} ⊥ₗ)
[⇒]-nonempty-reflexivity : ((φ ⊰ Γ) ⇒ (φ ⊰ Γ))
[⇒]-nonempty-reflexivity {Γ = ∅} = refl
[⇒]-nonempty-reflexivity {Γ = φ ⊰ Γ} = weakenₗ (weakenᵣ ([⇒]-nonempty-reflexivity {Γ = Γ}))
{- TODO: Maybe not
[⇒]-symmetric-by-side : ((Γ₁ ⇒ Δ) → (Γ₂ ⇒ Δ)) → ((Δ ⇒ Γ₂) → (Δ ⇒ Γ₁))
[⇒]-symmetric-by-side p axiom = {!!}
[⇒]-symmetric-by-side p (weakenₗ q) = {!!}
[⇒]-symmetric-by-side p (permuteₗ x q) = {!!}
[⇒]-symmetric-by-side p (contractₗ q) = {!!}
[⇒]-symmetric-by-side p ⊥ₗ = [⇒][⊥]-arbitrary
[⇒]-symmetric-by-side p (∧ₗₗ q) = {!!}
[⇒]-symmetric-by-side p (∧ₗᵣ q) = {!!}
[⇒]-symmetric-by-side p (∨ₗ q q₁) = {!!}
[⇒]-symmetric-by-side p (⟶ₗ q q₁) = {!!}
[⇒]-symmetric-by-side p (weakenᵣ q) = {!!}
[⇒]-symmetric-by-side p (permuteᵣ x q) = {!!}
[⇒]-symmetric-by-side p (contractᵣ q) = [⇒]-symmetric-by-side (weakenₗ ∘ p) q
[⇒]-symmetric-by-side p (∧ᵣ q q₁) = {!!}
[⇒]-symmetric-by-side p (∨ᵣₗ q) = {!!}
[⇒]-symmetric-by-side p (∨ᵣᵣ q) = {!!}
[⇒]-symmetric-by-side p (⟶ᵣ q) = {!!}
-}
open import Structure.Function
[⇒]-super : ((Γ₁ ∪· φ₁) ⊇ (Γ₂ ∪· φ₂)) → ((Γ₁ ∪· φ₁) ⇒ (Γ₂ ∪· φ₂))
[⇒]-super {Γ₁ = Γ₁} {Γ₂ = φ₂ ⊰ Γ₂} p = weakenᵣ ([⇒]-super {Γ₁ = Γ₁} {Γ₂ = Γ₂} (p ∘ skip))
[⇒]-super {Γ₁ = ∅} {Γ₂ = ∅} p with use [≡]-intro ← p (use [≡]-intro) = refl
[⇒]-super {Γ₁ = φ₁ ⊰ Γ₁} {Γ₂ = ∅}{φ₂ = φ₂} p with p (use [≡]-intro)
... | use [≡]-intro = permuteₗ Proofs.postpend-prepend-permutes (permuteₗ(sub₂(_≡ₑ_)(_permutes_) (symmetry(_≡ₑ_) (congruence₁(φ₁ ⊰_) (postpend-[++] {a = φ₂}{l = Γ₁})))) (weakenₗ ([⇒][++]ᵣ-weakenₗ{Γ₁ = Γ₁} refl)))
... | skip q = weakenₗ([⇒]-super {Γ₁ = Γ₁} {Γ₂ = ∅} \{(use [≡]-intro) → q ; (skip ())})
[⇒]-membership : (φ ∈ Γ) → (Γ ⇒ (· φ))
[⇒]-membership (use [≡]-intro) = [⇒][++]ₗ-weakenₗ refl
[⇒]-membership (skip p) = weakenₗ([⇒]-membership p)
Inconsistent : List(Formula(P)) → Type
Inconsistent(Γ) = Γ ⇒ ∅
test : ∅ ⇒ ·((A ∧ B) ⟶ A)
test {A = A}{B = B} =
refl ⇒-start
((· A) ⇒ (· A)) ⇒-[ ∧ₗₗ ]
(·(A ∧ B) ⇒ (· A)) ⇒-[ ⟶ᵣ ]
(∅ ⇒ ·((A ∧ B) ⟶ A)) ⇒-end
--test2 : ∅ ⇒ ·(A ∨ (¬ A))
test3 : ∅ ⇒ ·(((¬ ¬ A) ⟶ (¬ ¬ B)) ⟶ (¬ ¬(A ⟶ B)))
test3{A = A}{B = B} =
• (
refl ⇒-start
((· A) ⇒ (· A)) ⇒-[ weakenᵣ ]
((· A) ⇒ ((· A) ∪· B)) ⇒-[ permuteᵣ _permutes_.swap ]
((· A) ⇒ ((· B) ∪· A)) ⇒-[ ¬ₗ ]
(((· A) ∪· (¬ A)) ⇒ (· B)) ⇒-[ permuteₗ _permutes_.swap ]
((·(¬ A) ∪· A) ⇒ (· B)) ⇒-[ ⟶ᵣ ]
(·(¬ A) ⇒ ·(A ⟶ B)) ⇒-[ ¬ₗ ]
((·(¬ A) ∪· ¬(A ⟶ B)) ⇒ ∅) ⇒-[ permuteₗ _permutes_.swap ]
((·(¬(A ⟶ B)) ∪· (¬ A)) ⇒ ∅) ⇒-[ ¬ᵣ ]
(·(¬(A ⟶ B)) ⇒ (∅ ∪· (¬ ¬ A))) ⇒-end
)
• (
refl ⇒-start
((· B) ⇒ (· B)) ⇒-[ weakenₗ ]
(((· B) ∪· A) ⇒ (· B)) ⇒-[ ⟶ᵣ ]
((· B) ⇒ ·(A ⟶ B)) ⇒-[ ¬ₗ ]
(((· B) ∪· ¬(A ⟶ B)) ⇒ ∅) ⇒-[ permuteₗ _permutes_.swap ]
((·(¬(A ⟶ B)) ∪· B) ⇒ ∅) ⇒-[ ¬ᵣ ]
(·(¬(A ⟶ B)) ⇒ ·(¬ B)) ⇒-[ ¬ₗ ]
((·(¬(A ⟶ B)) ∪· (¬ ¬ B)) ⇒ ∅) ⇒-end
)
⇒₂-[ ⟶ₗ ]
((·(¬(A ⟶ B)) ∪· ((¬ ¬ A) ⟶ (¬ ¬ B))) ⇒ ∅) ⇒-[ permuteₗ _permutes_.swap ]
((·((¬ ¬ A) ⟶ (¬ ¬ B)) ∪· ¬(A ⟶ B)) ⇒ ∅) ⇒-[ ¬ᵣ ]
(·((¬ ¬ A) ⟶ (¬ ¬ B)) ⇒ ·(¬ ¬(A ⟶ B))) ⇒-[ ⟶ᵣ ]
(∅ ⇒ ·(((¬ ¬ A) ⟶ (¬ ¬ B)) ⟶ (¬ ¬(A ⟶ B)))) ⇒-end
test4 : (∅ ⇒ ·(((A ⟶ B) ⟶ A) ⟶ A))
test4 {A = A}{B = B} =
• (
refl ⇒-start
((· A) ⇒ (· A)) ⇒-[ weakenᵣ ]
((· A) ⇒ ((· A) ∪· B)) ⇒-[ ⟶ᵣ ]
(∅ ⇒ ((· A) ∪· (A ⟶ B))) ⇒-end
)
• ((· A) ⇒ (· A)) :-[ refl ]
⇒₂-[ ⟶ₗ ]
((∅ ∪· ((A ⟶ B) ⟶ A)) ⇒ (∅ ∪· A)) ⇒-[ ⟶ᵣ ]
(∅ ⇒ ·(((A ⟶ B) ⟶ A) ⟶ A)) ⇒-end
-- ⟶ᵣ (¬ᵣ (permuteₗ _permutes_.swap (⟶ₗ (¬ᵣ (permuteₗ _permutes_.swap (¬ₗ (⟶ᵣ (permuteₗ _permutes_.swap (¬ₗ (permuteᵣ _permutes_.swap (weakenᵣ axiom)))))))) (¬ₗ (¬ᵣ (permuteₗ _permutes_.swap (¬ₗ (⟶ᵣ (weakenₗ axiom)))))))))
{-
[∧]-intro : ((Γ ∪· A ∪· B) ⇒ (Γ ∪· (A ∧ B)))
[∧]-intro = ∧ᵣ ([⇒]-super skip) ([⇒]-super (p ↦ {!!}))
[∧]-elimₗ : ((Γ ∪· (A ∧ B)) ⇒ (Γ ∪· A))
[∧]-elimₗ = {!!}
-}
{-
test : (Γ ⇒ Δ₁) → .(Δ₁ permutes Δ₂) → (Δ₂ ⇒ Δ₃) → (Γ ⇒ Δ₃)
[∧]-intro : (Γ ⇒ ·(A)) → (Γ ⇒ ·(B)) → (Γ ⇒ ·(A ∧ B))
[∧]-intro = ∧ᵣ
[∧]-elimₗ : (Γ ⇒ Δ ∪· (A ∧ B)) → (Γ ⇒ (Δ ∪· A))
[∧]-elimₗ axiom = ∧ₗₗ axiom
[∧]-elimₗ (weakenₗ p) = weakenₗ ([∧]-elimₗ p)
[∧]-elimₗ (permuteₗ x p) = permuteₗ x ([∧]-elimₗ p)
[∧]-elimₗ (contractₗ p) = contractₗ ([∧]-elimₗ p)
[∧]-elimₗ (∧ₗₗ p) = ∧ₗₗ ([∧]-elimₗ p)
[∧]-elimₗ (∧ₗᵣ p) = ∧ₗᵣ ([∧]-elimₗ p)
[∧]-elimₗ (∨ₗ p q) = ∨ₗ ([∧]-elimₗ p) ([∧]-elimₗ q)
[∧]-elimₗ (⟶ₗ p q) = ⟶ₗ (permuteᵣ _permutes_.swap ([∧]-elimₗ(permuteᵣ _permutes_.swap p))) ([∧]-elimₗ q)
[∧]-elimₗ (weakenᵣ p) = weakenᵣ p
[∧]-elimₗ (permuteᵣ x p) = test p x {!!}
[∧]-elimₗ (contractᵣ p) = contractᵣ([∧]-elimₗ(permuteᵣ _permutes_.swap ([∧]-elimₗ p)))
[∧]-elimₗ (∧ᵣ p q) = p
-}
{-
soundness : (Γ ⇒ Δ) → ((_∈ Γ) ⊨₊ (_∈ Δ))
soundness axiom 𝔐Γ = 𝔐Γ
soundness (weakenₗ p) 𝔐Γ = soundness p (𝔐Γ ∘ skip)
soundness (permuteₗ x p) 𝔐Γ = {!!}
soundness (contractₗ p) 𝔐Γ = {!!}
soundness ⊥ₗ 𝔐Γ ()
soundness (∧ₗₗ p) 𝔐Γ {elem} (use [≡]-intro) = soundness p (q ↦ 𝔐Γ {!!}) (use [≡]-intro)
-- 𝔐Γ{elem} {!soundness p ? ?!}
-- soundness p {!!} (use {!!})
soundness (∧ₗₗ p) 𝔐Γ (skip q) = {!!}
soundness (∧ₗᵣ p) 𝔐Γ = {!!}
soundness (∨ₗ p q) 𝔐Γ = {!!}
soundness (⟶ₗ p q) 𝔐Γ = soundness p (𝔐Γ ∘ skip) ∘ skip
soundness (weakenᵣ p) 𝔐Γ = {!!}
soundness (permuteᵣ x p) 𝔐Γ = {!!}
soundness (contractᵣ p) 𝔐Γ = soundness p 𝔐Γ ∘ skip
soundness (∧ᵣ p q) 𝔐Γ = {!!}
soundness (∨ᵣₗ p) 𝔐Γ = {!!}
soundness (∨ᵣᵣ p) 𝔐Γ = {!!}
soundness (⟶ᵣ p) 𝔐Γ = {!!}
-}
{-
excluded-middle : Γ ⇒ (Δ ∪ ·(A ∨ (¬ A)))
excluded-middle = ∨ᵣₗ {!!}
soundness : (Γ ⇒ Δ) → (Γ ⊨₊ Δ)
soundness axiom = id
soundness (weakenₗ p) 𝔐Γ = soundness p (𝔐Γ ∘ Left)
soundness (∧ₗₗ p) 𝔐Γ e = soundness p (\{(Left Γelem) → 𝔐Γ(Left Γelem) ; (Right [≡]-intro) → 𝔐Γ (Right {!!})}) e
soundness (∧ₗᵣ p) 𝔐Γ e = soundness p (\{(Left Γelem) → 𝔐Γ (Left Γelem) ; (Right [≡]-intro) → 𝔐Γ (Right {!!})}) e
soundness (∨ₗ p q) 𝔐Γ e = soundness p (\{(Left r) → 𝔐Γ (Left r) ; (Right r) → {!!}}) e
soundness (⟶ₗ p q) 𝔐Γ = soundness p (𝔐Γ ∘ Left) ∘ Left
soundness (weakenᵣ p) 𝔐Γ (Left Δelem) = soundness p 𝔐Γ Δelem
soundness (weakenᵣ p) 𝔐Γ (Right [≡]-intro) = {!!}
soundness (∧ᵣ p q) 𝔐Γ (Left Δelem) = soundness p 𝔐Γ (Left Δelem)
soundness (∧ᵣ p q) 𝔐Γ (Right [≡]-intro) = Logic.[∧]-intro (soundness p 𝔐Γ (Right [≡]-intro)) (soundness q 𝔐Γ (Right [≡]-intro))
soundness (∨ᵣₗ p) 𝔐Γ e = {!!}
soundness (∨ᵣᵣ p) 𝔐Γ e = {!!}
soundness (⟶ᵣ p) 𝔐Γ (Left x) = {!!}
soundness (⟶ᵣ p) 𝔐Γ (Right [≡]-intro) = {!soundness p ? ?!}
-}
module _ (cut : ∀{Γ₁ Γ₂ Δ₁ Δ₂}{φ} → (Γ₁ ⇒ (Δ₁ ∪· φ)) → ((Γ₂ ∪· φ) ⇒ Δ₂) → ((Γ₁ ∪ Γ₂) ⇒ (Δ₁ ∪ Δ₂))) where
open import Formalization.ClassicalPropositionalLogic.NaturalDeduction
open import Data.List.Relation.Quantification
open import Lang.Instance
open import Sets.PredicateSet as PredSet using (PredSet)
open import Sets.PredicateSet.Listable
open import Type.Properties.MereProposition
¬ᵣ-⊥ : ((Γ ∪· A) ⇒ (· ⊥)) → (Γ ⇒ (Δ ∪· (¬ A)))
¬ᵣ-⊥ {Γ = Γ}{A = A}{Δ = Δ} p = permute{Γ₁ = Γ ∪ Γ}{Γ₂ = Γ} {!!} {!!} (cut{Γ₁ = Γ}{Γ₂ = Γ}{Δ₁ = Δ}{Δ₂ = ·(¬ A)} {!!} {!!})
from-naturalDeduction : ∀{Γ} ⦃ _ : Listable{ℓ}(Γ) ⦄ → (Γ ⊢ φ) → (list(Γ) ⇒ (· φ))
to-naturalDeduction : (Γ ⇒ (· φ)) → ((_∈ Γ) ⊢ φ)
from-naturalDeduction (direct x) = [⇒]-membership(Listable.proof infer x)
from-naturalDeduction [⊤]-intro = [⇒][++]ₗ-weakenₗ ⊤ᵣ
from-naturalDeduction ([⊥]-intro p q) = {!!}
from-naturalDeduction ([⊥]-elim p) = {!from-naturalDeduction p!}
from-naturalDeduction {Γ = Γ} ([¬]-intro p) = {!(permuteₗ (list-[∪·] {Γ = Γ}) (from-naturalDeduction ⦃ ? ⦄ p))!}
from-naturalDeduction ([¬]-elim p) = {!!}
from-naturalDeduction ([∧]-intro p q) = ∧ᵣ (from-naturalDeduction p) (from-naturalDeduction q)
from-naturalDeduction ([∧]-elimₗ p) = permute permₗ permᵣ (cut (from-naturalDeduction p) (∧ₗₗ refl)) where
permₗ = sub₂(_≡ₑ_)(_permutes_) (identityᵣ(_∪_)(∅))
permᵣ = sub₂(_≡ₑ_)(_permutes_) (identityₗ(_∪_)(∅))
from-naturalDeduction ([∧]-elimᵣ p) = permute permₗ permᵣ (cut (from-naturalDeduction p) (∧ₗᵣ refl)) where
permₗ = sub₂(_≡ₑ_)(_permutes_) (identityᵣ(_∪_)(∅))
permᵣ = sub₂(_≡ₑ_)(_permutes_) (identityₗ(_∪_)(∅))
from-naturalDeduction ([∨]-introₗ p) = ∨ᵣₗ (from-naturalDeduction p)
from-naturalDeduction ([∨]-introᵣ p) = ∨ᵣᵣ (from-naturalDeduction p)
from-naturalDeduction ([∨]-elim p q r) = {!!}
from-naturalDeduction {Γ = Γ} ([⟶]-intro p) = ⟶ᵣ (permuteₗ (list-[∪·] {S = Γ}) (from-naturalDeduction ⦃ {!!} ⦄ p))
from-naturalDeduction ([⟶]-elim p q) = {!!} -- permute {!!} {!!} (cut (from-naturalDeduction p) {!cut (from-naturalDeduction q) ?!})
from-naturalDeduction ([⟷]-intro p q) = {!!}
from-naturalDeduction ([⟷]-elimₗ p q) = {!!}
from-naturalDeduction ([⟷]-elimᵣ p q) = {!!}
{-
from-naturalDeduction : ((_∈ Γ) ⊢ φ) → (Γ ⇒ (· φ))
from-naturalDeduction (direct (use {x = x}{l = l} [≡]-intro)) = [⇒][++]ₗ-weakenₗ {Γ₁ = · x}{Γ₂ = l} axiom
from-naturalDeduction (direct (skip x)) = weakenₗ(from-naturalDeduction (direct x))
from-naturalDeduction [⊤]-intro = [⇒][++]ₗ-weakenₗ ⊤ᵣ
from-naturalDeduction ([⊥]-intro p q) = {!!}
from-naturalDeduction ([⊥]-elim p) = {!!}
from-naturalDeduction ([¬]-intro p) = {!!}
from-naturalDeduction ([¬]-elim p) = {!!}
from-naturalDeduction ([∧]-intro p q) = ∧ᵣ (from-naturalDeduction p) (from-naturalDeduction q)
from-naturalDeduction ([∧]-elimₗ p) = permute permₗ permᵣ (cut (from-naturalDeduction p) (∧ₗₗ axiom)) where
permₗ = sub₂(_≡ₑ_)(_permutes_) (identityᵣ(_∪_)(∅))
permᵣ = sub₂(_≡ₑ_)(_permutes_) (identityₗ(_∪_)(∅))
from-naturalDeduction ([∧]-elimᵣ p) = permute permₗ permᵣ (cut (from-naturalDeduction p) (∧ₗᵣ axiom)) where
permₗ = sub₂(_≡ₑ_)(_permutes_) (identityᵣ(_∪_)(∅))
permᵣ = sub₂(_≡ₑ_)(_permutes_) (identityₗ(_∪_)(∅))
from-naturalDeduction ([∨]-introₗ p) = ∨ᵣₗ (from-naturalDeduction p)
from-naturalDeduction ([∨]-introᵣ p) = ∨ᵣᵣ (from-naturalDeduction p)
from-naturalDeduction ([∨]-elim p q r) = {!!}
from-naturalDeduction ([⟶]-intro p) = ⟶ᵣ {!from-naturalDeduction p!}
from-naturalDeduction ([⟶]-elim p q) = {!!}
from-naturalDeduction ([⟷]-intro p q) = {!!}
from-naturalDeduction ([⟷]-elimₗ p q) = {!!}
from-naturalDeduction ([⟷]-elimᵣ p q) = {!!}
-}
{- to-naturalDeduction axiom = direct (use [≡]-intro)
to-naturalDeduction (weakenₗ p) = {!!}
to-naturalDeduction (permuteₗ x p) = {!!}
to-naturalDeduction (contractₗ p) = {!!}
to-naturalDeduction (∧ₗₗ p) = {!!}
to-naturalDeduction (∧ₗᵣ p) = {!!}
to-naturalDeduction (∨ₗ p p₁) = {!!}
to-naturalDeduction (⟶ₗ p p₁) = {!!}
to-naturalDeduction (weakenᵣ p) = {!!}
to-naturalDeduction (permuteᵣ x p) = {!!}
to-naturalDeduction (contractᵣ p) = {!!}
to-naturalDeduction (∧ᵣ p p₁) = [∧]-intro (to-naturalDeduction p) (to-naturalDeduction p₁)
to-naturalDeduction (∨ᵣₗ p) = [∨]-introₗ (to-naturalDeduction p)
to-naturalDeduction (∨ᵣᵣ p) = [∨]-introᵣ (to-naturalDeduction p)
to-naturalDeduction (⟶ᵣ p) = [⟶]-intro {!to-naturalDeduction p!}
-}
| {
"alphanum_fraction": 0.5004937662,
"avg_line_length": 45.6394366197,
"ext": "agda",
"hexsha": "8d5467c2a0107817fe804694bac671c6088dacd8",
"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/SequentCalculus.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/SequentCalculus.agda",
"max_line_length": 224,
"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/SequentCalculus.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": 7771,
"size": 16202
} |
open import Prelude
module Bij where
record bij (From To : Set) : Set where
field
convert : From → To
inj : ∀{f1 f2} → convert f1 == convert f2 → f1 == f2
surj : (t : To) → Σ[ f ∈ From ] (convert f == t)
convert-inv : ∀{F T : Set} {{bijFT : bij F T}} → T → F
convert-inv {{bijFT}} t with bij.surj bijFT t
... | f , _ = f
convert-inv-inj : ∀{F T : Set} {{bijFT : bij F T}} {t1 t2 : T} →
convert-inv {{bijFT}} t1 == convert-inv {{bijFT}} t2 →
t1 == t2
convert-inv-inj ⦃ bijFT = bijFT ⦄ {t1} {t2} eq
with bij.surj bijFT t1 | bij.surj bijFT t2
... | _ , p1 | _ , p2
rewrite eq = ! p1 · p2
convert-inv-surj : ∀{F T : Set} {{bijFT : bij F T}} (f : F) →
Σ[ t ∈ T ] (convert-inv {{bijFT}} t == f)
convert-inv-surj ⦃ bijFT = bijFT ⦄ f with expr-eq (λ _ → bij.convert bijFT f)
... | t , teq with expr-eq (λ _ → bij.surj bijFT t)
... | (_ , seq) , refl = _ , bij.inj bijFT (seq · teq)
convert-bij1 : ∀{F T : Set} {{bijFT : bij F T}} {f : F} →
convert-inv (bij.convert bijFT f) == f
convert-bij1 ⦃ bijFT = bijFT ⦄ {f} with expr-eq (λ _ → convert-inv-surj f)
... | (_ , eq) , refl = eq
convert-bij2 : ∀{F T : Set} {{bijFT : bij F T}} {t : T} →
bij.convert bijFT (convert-inv t) == t
convert-bij2 ⦃ bijFT = bijFT ⦄ {t} with expr-eq (λ _ → bij.surj bijFT t)
... | (_ , eq) , refl = eq
| {
"alphanum_fraction": 0.4979338843,
"avg_line_length": 39.2432432432,
"ext": "agda",
"hexsha": "7926a1a134772d4cf56c2f0f2ba8b487d92a658b",
"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": "db857f3e7dc9a4793f68504e6365d93ed75d7f88",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nickcollins/dependent-dicts-agda",
"max_forks_repo_path": "Bij.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88",
"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": "nickcollins/dependent-dicts-agda",
"max_issues_repo_path": "Bij.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nickcollins/dependent-dicts-agda",
"max_stars_repo_path": "Bij.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 557,
"size": 1452
} |
module Control.Monad.Identity where
open import Prelude
open import Container.Foldable
open import Container.Traversable
record Identity {a} (A : Set a) : Set a where
constructor mkIdentity
field
runIdentity : A
open Identity public
instance
FunctorId : ∀ {a} → Functor (Identity {a})
runIdentity (fmap {{FunctorId}} f m) = f (runIdentity m)
ApplicativeId : ∀ {a} → Applicative (Identity {a})
runIdentity (pure {{ApplicativeId}} x) = x
runIdentity (_<*>_ {{ApplicativeId}} mf mx) = runIdentity mf (runIdentity mx)
MonadId : ∀ {a} → Monad (Identity {a})
_>>=_ {{MonadId}} m f = f (runIdentity m)
FunctorId′ : ∀ {a b} → Functor′ {a} {b} Identity
runIdentity (fmap′ {{FunctorId′}} f m) = f (runIdentity m)
ApplicativeId′ : ∀ {a b} → Applicative′ {a} {b} Identity
runIdentity (_<*>′_ {{ApplicativeId′}} mf mx) = runIdentity mf (runIdentity mx)
MonadId′ : ∀ {a b} → Monad′ {a} {b} Identity
_>>=′_ {{MonadId′}} m f = f (runIdentity m)
FoldableId : ∀ {a w} → Foldable {w = w} (Identity {a})
foldMap {{FoldableId}} f m = f (runIdentity m)
TraversableId : ∀ {a} → Traversable (Identity {a})
traverse {{TraversableId}} f m = pure mkIdentity <*> f (runIdentity m)
| {
"alphanum_fraction": 0.6487158244,
"avg_line_length": 30.175,
"ext": "agda",
"hexsha": "861ceac126452c5a7272fad4afb1f3d65a9890ac",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Control/Monad/Identity.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Control/Monad/Identity.agda",
"max_line_length": 81,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Control/Monad/Identity.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 395,
"size": 1207
} |
------------------------------------------------------------------------
-- Well-typed substitutions
-- From
------------------------------------------------------------------------
module Extensions.Fin.TypedSubstitution where
import Category.Applicative.Indexed as Applicative
open import Data.Fin using (Fin; zero; suc)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas
open import Data.Fin.Substitution.ExtraLemmas
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Vec as Vec using (Vec; []; _∷_; map)
open import Data.Vec.All using (All₂; []; _∷_; map₂; gmap₂; gmap₂₁; gmap₂₂)
open import Data.Vec.Properties using (lookup-morphism)
open import Function using (_∘_; flip)
open import Relation.Binary.PropositionalEquality as PropEq hiding (trans)
open PropEq.≡-Reasoning
------------------------------------------------------------------------
-- Abstract typing contexts and well-typedness relations
-- Abstract typing contexts over T-types.
--
-- A typing context Ctx n maps n free variables to types containing up
-- to n free variables each.
module Context where
infixr 5 _∷_
-- Typing contexts.
data Ctx (T : ℕ → Set) : ℕ → Set where
[] : Ctx T 0
_∷_ : ∀ {n} → T (1 + n) → Ctx T n → Ctx T (1 + n)
-- Operations on context that require weakening of types.
record WeakenOps (T : ℕ → Set) : Set where
-- Weakening of types.
field weaken : ∀ {n} → T n → T (1 + n)
infixr 5 _i∷_
-- Convert a context to its vector representation.
toVec : ∀ {n} → Ctx T n → Vec (T n) n
toVec [] = []
toVec (a ∷ Γ) = a ∷ map weaken (toVec Γ)
-- Shorthand for extending contexts with variables that are typed
-- independently of themselves.
_i∷_ : ∀ {n} → T n → Ctx T n → Ctx T (1 + n)
a i∷ Γ = weaken a ∷ Γ
-- Lookup the type of a variable in a context.
lookup : ∀ {n} → Fin n → Ctx T n → T n
lookup x = Vec.lookup x ∘ toVec
open Context
-- Abstract typings.
--
-- An abtract typing _⊢_∈_ : Typing Tp₁ Tm Tp₂ is a ternary relation
-- which, in a given Tp₂-context, relates Tm-terms to their Tp₁-types.
Typing : (ℕ → Set) → (ℕ → Set) → (ℕ → Set) → Set₁
Typing Tp₁ Tm Tp₂ = ∀ {n} → Ctx Tp₁ n → Tm n → Tp₂ n → Set
------------------------------------------------------------------------
-- Abstract well-typed substitutions (i.e. substitution lemmas)
-- Abstract typed substitutions.
record TypedSub (Tp₁ Tp₂ Tm : ℕ → Set) : Set₁ where
infix 4 _⊢_∈_
field
_⊢_∈_ : Typing Tp₂ Tm Tp₁ -- the associated typing
-- Application of Tm-substitutions to (source) Tp₁-types
application : Application Tp₁ Tm
-- Operations on the (source) Tp₁-context.
weakenOps : WeakenOps Tp₁
open Application application public using (_/_)
open WeakenOps weakenOps using (toVec)
infix 4 _⇒_⊢_
-- Typed substitutions.
--
-- A typed substitution Γ ⇒ Δ ⊢ σ is a substitution σ which, when
-- applied to something that is well-typed in a source context Γ,
-- yields something well-typed in a target context Δ.
_⇒_⊢_ : ∀ {m n} → Ctx Tp₁ m → Ctx Tp₂ n → Sub Tm m n → Set
Γ ⇒ Δ ⊢ σ = All₂ (λ t a → Δ ⊢ t ∈ (a / σ)) σ (toVec Γ)
-- Abstract extensions of substitutions.
record ExtensionTyped {Tp₁ Tp₂ Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp₁ Tp₂ Tm) : Set where
open TypedSub typedSub
private
module S = SimpleExt simple
module L₀ = Lemmas₀ (record { simple = simple })
module C = WeakenOps weakenOps
open C using (_i∷_)
field
-- Weakens well-typed Ts.
weaken : ∀ {n} {Δ : Ctx Tp₂ n} {t a b} → Δ ⊢ t ∈ a →
b ∷ Δ ⊢ S.weaken t ∈ C.weaken a
-- Weakening commutes with other substitutions.
wk-commutes : ∀ {m n} {σ : Sub Tm m n} {t} a →
a / σ / S.wk ≡ a / S.wk / (t S./∷ σ)
-- Relates weakening of types to weakening of Ts.
/-wk : ∀ {n} {a : Tp₁ n} → a / S.wk ≡ C.weaken a
-- A helper lemma.
weaken-/ : ∀ {m n} {σ : Sub Tm m n} {t} a →
C.weaken (a / σ) ≡ C.weaken a / (t S./∷ σ)
weaken-/ {σ = σ} {t} a = begin
C.weaken (a / σ) ≡⟨ sym /-wk ⟩
a / σ / S.wk ≡⟨ wk-commutes a ⟩
a / S.wk / (t S./∷ σ) ≡⟨ cong₂ _/_ /-wk refl ⟩
C.weaken a / (t S./∷ σ) ∎
infixr 5 _/∷_ _/i∷_
-- Extension.
_/∷_ : ∀ {m n} {Γ : Ctx Tp₁ m} {Δ : Ctx Tp₂ n} {t a b σ} →
b ∷ Δ ⊢ t ∈ a / (t S./∷ σ) → Γ ⇒ Δ ⊢ σ → a ∷ Γ ⇒ b ∷ Δ ⊢ (t S./∷ σ)
t∈a/t∷σ /∷ σ-wt =
t∈a/t∷σ ∷ gmap₂ (subst (_⊢_∈_ _ _) (weaken-/ _) ∘ weaken) σ-wt
-- A variant of extension tailored to _i∷_.
_/i∷_ : ∀ {m n} {Γ : Ctx Tp₁ m} {Δ : Ctx Tp₂ n} {t a b σ} →
b ∷ Δ ⊢ t ∈ C.weaken (a / σ) → Γ ⇒ Δ ⊢ σ → a i∷ Γ ⇒ b ∷ Δ ⊢ (t S./∷ σ)
t∈a/σ /i∷ σ-wt =
(subst (_⊢_∈_ _ _) (weaken-/ _) t∈a/σ) /∷ σ-wt
-- Abstract simple typed substitutions.
record SimpleTyped {Tp Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp Tp Tm) : Set where
field extensionTyped : ExtensionTyped simple typedSub
open TypedSub typedSub
open ExtensionTyped extensionTyped public
private
module S = SimpleExt simple
module L₀ = Lemmas₀ (record { simple = simple })
module C = WeakenOps weakenOps
open C using (_i∷_)
field
-- Takes variables to well-typed Ts.
var : ∀ {n} {Γ : Ctx Tp n} (x : Fin n) → Γ ⊢ S.var x ∈ C.lookup x Γ
-- Types are invariant under the identity substitution.
id-vanishes : ∀ {n} (a : Tp n) → a / S.id ≡ a
-- Single-variable substitution is a left-inverse of weakening.
wk-sub-vanishes : ∀ {n b} (a : Tp n) → a / S.wk / S.sub b ≡ a
infix 10 _↑ _↑i
-- Lifting.
_↑ : ∀ {m n} {Γ : Ctx Tp m} {Δ : Ctx Tp n} {σ} → Γ ⇒ Δ ⊢ σ → ∀ {a} →
a ∷ Γ ⇒ a / σ S.↑ ∷ Δ ⊢ (σ S.↑)
σ-wt ↑ = var zero /∷ σ-wt
-- A variant of lifting tailored to _i∷_.
_↑i : ∀ {m n} {Γ : Ctx Tp m} {Δ : Ctx Tp n} {σ} → Γ ⇒ Δ ⊢ σ → ∀ {a} →
a i∷ Γ ⇒ a / σ i∷ Δ ⊢ σ S.↑
σ-wt ↑i = var zero /i∷ σ-wt
-- The identity substitution.
id : ∀ {n} {Γ : Ctx Tp n} → Γ ⇒ Γ ⊢ S.id
id {zero} = []
id {suc n} {a ∷ Γ} =
subst₂ (λ Δ σ → a ∷ Γ ⇒ Δ ⊢ σ)
(cong (flip _∷_ Γ) (id-vanishes a)) (L₀.id-↑⋆ 1) (id ↑)
where
id-vanishes′ : ∀ {n} (a : Tp (1 + n)) → a / S.id S.↑ ≡ a
id-vanishes′ a = begin
a / S.id S.↑ ≡⟨ cong (_/_ a) (L₀.id-↑⋆ 1) ⟩
a / S.id ≡⟨ id-vanishes a ⟩
a ∎
-- Weakening.
wk : ∀ {n} {Γ : Ctx Tp n} {a} → Γ ⇒ a ∷ Γ ⊢ S.wk
wk {n} {Γ = Γ} {a = a} =
gmap₂₁ (weaken′ ∘ subst (_⊢_∈_ _ _) (id-vanishes _)) id
where
weaken′ : ∀ {n} {Γ : Ctx Tp n} {t a b} → Γ ⊢ t ∈ a →
b ∷ Γ ⊢ S.weaken t ∈ a / S.wk
weaken′ = subst (_⊢_∈_ _ _) (sym /-wk) ∘ weaken
private
wk-sub-vanishes′ : ∀ {n a} {t : Tm n} → a ≡ C.weaken a / S.sub t
wk-sub-vanishes′ {a = a} {t} = begin
a ≡⟨ sym (wk-sub-vanishes a) ⟩
a / S.wk / S.sub t ≡⟨ cong (flip _/_ _) /-wk ⟩
C.weaken a / S.sub t ∎
id-wk-sub-vanishes : ∀ {n a} {t : Tm n} →
a / S.id ≡ C.weaken a / S.sub t
id-wk-sub-vanishes {a = a} {t} = begin
a / S.id ≡⟨ id-vanishes a ⟩
a ≡⟨ wk-sub-vanishes′ ⟩
C.weaken a / S.sub t ∎
-- A substitution which only replaces the first variable.
sub : ∀ {n} {Γ : Ctx Tp n} {t a} → Γ ⊢ t ∈ a → a i∷ Γ ⇒ Γ ⊢ S.sub t
sub t∈a = t∈a′ ∷ gmap₂₂ (subst (_⊢_∈_ _ _) id-wk-sub-vanishes) id
where
t∈a′ = subst (_⊢_∈_ _ _) wk-sub-vanishes′ t∈a
-- A variant of single-variable substitution that handles
-- self-dependently typed variables.
sub′ : ∀ {n} {Γ : Ctx Tp n} {t a} → Γ ⊢ t ∈ a / S.sub t →
a ∷ Γ ⇒ Γ ⊢ S.sub t
sub′ t∈a[/t] = t∈a[/t] ∷ gmap₂₂ (subst (_⊢_∈_ _ _) id-wk-sub-vanishes) id
-- A substitution which only changes the type of the first variable.
tsub : ∀ {n} {Γ : Ctx Tp n} {a b} → b ∷ Γ ⊢ S.var zero ∈ a →
a ∷ Γ ⇒ b ∷ Γ ⊢ S.id
tsub z∈a = z∈a′ ∷ gmap₂ (subst (_⊢_∈_ _ _) (weaken-/ _) ∘ weaken) id
where
z∈a′ = subst (_⊢_∈_ _ _) (sym (id-vanishes _)) z∈a
-- Abstract typed liftings from Tm₁ to Tm₂.
record LiftTyped {Tp Tm₁ Tm₂} (l : Lift Tm₁ Tm₂)
(typedSub : TypedSub Tp Tp Tm₁)
(_⊢₂_∈_ : Typing Tp Tm₂ Tp) : Set where
open TypedSub typedSub renaming (_⊢_∈_ to _⊢₁_∈_)
private module L = Lift l
-- The underlying well-typed simple Tm₁-substitutions.
field simpleTyped : SimpleTyped L.simple typedSub
open SimpleTyped simpleTyped public
-- Lifts well-typed Tm₁-terms to well-typed Tm₂-terms.
field lift : ∀ {n} {Γ : Ctx Tp n} {t a} → Γ ⊢₁ t ∈ a → Γ ⊢₂ (L.lift t) ∈ a
-- Abstract variable typings.
module VarTyping {Tp} (weakenOps : Context.WeakenOps Tp) where
open WeakenOps weakenOps
infix 4 _⊢Var_∈_
-- Abstract variable typings.
data _⊢Var_∈_ {n} (Γ : Ctx Tp n) : Fin n → Tp n → Set where
var : ∀ x → Γ ⊢Var x ∈ lookup x Γ
-- Abstract typed variable substitutions (α-renamings).
record TypedVarSubst (Tp : ℕ → Set) : Set where
field
application : Application Tp Fin
weakenOps : WeakenOps Tp
open VarTyping weakenOps public
typedSub : TypedSub Tp Tp Fin
typedSub = record
{ _⊢_∈_ = _⊢Var_∈_
; application = application
; weakenOps = weakenOps
}
open TypedSub typedSub public using () renaming (_⇒_⊢_ to _⇒_⊢α_)
open Application application using (_/_)
open Lemmas₄ VarLemmas.lemmas₄ using (id; wk; _⊙_)
private module C = WeakenOps weakenOps
field
/-wk : ∀ {n} {a : Tp n} → a / wk ≡ C.weaken a
id-vanishes : ∀ {n} (a : Tp n) → a / id ≡ a
/-⊙ : ∀ {m n k} {σ₁ : Sub Fin m n} {σ₂ : Sub Fin n k} a →
a / σ₁ ⊙ σ₂ ≡ a / σ₁ / σ₂
appLemmas : AppLemmas Tp Fin
appLemmas = record
{ application = application
; lemmas₄ = VarLemmas.lemmas₄
; id-vanishes = id-vanishes
; /-⊙ = /-⊙
}
open ExtAppLemmas appLemmas hiding (var; weaken; /-wk; id-vanishes; subst)
-- Extensions of renamings.
extensionTyped : ExtensionTyped VarLemmas.simple typedSub
extensionTyped = record
{ weaken = weaken
; wk-commutes = wk-commutes
; /-wk = /-wk
}
where
open Applicative.Morphism using (op-<$>)
weaken : ∀ {n} {Γ : Ctx Tp n} {x a b} → Γ ⊢Var x ∈ a →
b ∷ Γ ⊢Var suc x ∈ C.weaken a
weaken (var x) =
subst (_⊢Var_∈_ _ _) (op-<$> (lookup-morphism x) _ _) (var (suc x))
-- Simple typed renamings.
simpleTyped : SimpleTyped VarLemmas.simple typedSub
simpleTyped = record
{ extensionTyped = extensionTyped
; var = var
; id-vanishes = id-vanishes
; wk-sub-vanishes = wk-sub-vanishes
}
open SimpleTyped simpleTyped public
hiding (extensionTyped; var; /-wk; id-vanishes; wk-sub-vanishes)
-- Context-replacing substitutions.
record ContextSub (Tp₁ Tp₂ Tm : ℕ → Set) : Set₁ where
infix 4 _⊢_∈_
field
_⊢_∈_ : Typing Tp₂ Tm Tp₁ -- the associated typing
-- Simple Tm-substitutions (e.g. id).
simple : Simple Tm
-- Operations on the (source) Tp₁-context.
weakenOps : WeakenOps Tp₁
open Simple simple using (id)
open WeakenOps weakenOps using (toVec)
infix 4 _⇒_⊢-id
-- Context-replacing substitutions.
--
-- An alternative representation for substitutions that only change
-- the context of a well-typed Tm-term, i.e. where the underlying
-- untyped substitution is the identity.
_⇒_⊢-id : ∀ {n} → Ctx Tp₁ n → Ctx Tp₂ n → Set
Γ ⇒ Δ ⊢-id = All₂ (λ t a → Δ ⊢ t ∈ a) id (toVec Γ)
-- Equivalences between (simple) typed substitutions and their
-- context-replacing counterparts.
record Equivalence {Tp₁ Tp₂ Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp₁ Tp₂ Tm) : Set where
open Simple simple
open TypedSub typedSub
-- The type of context substitutions participating in this
-- equivalence.
contextSub : ContextSub Tp₁ Tp₂ Tm
contextSub = record
{ _⊢_∈_ = _⊢_∈_
; simple = simple
; weakenOps = weakenOps
}
open ContextSub contextSub hiding (_⊢_∈_; simple)
-- Types are invariant under the identity substitution.
field id-vanishes : ∀ {n} (a : Tp₁ n) → a / id ≡ a
-- There is a context substitution for every typed identity
-- substitution.
sound : ∀ {n} {Γ : Ctx Tp₁ n} {Δ : Ctx Tp₂ n} → Γ ⇒ Δ ⊢-id → Γ ⇒ Δ ⊢ id
sound ρ = map₂ (subst (_⊢_∈_ _ _) (sym (id-vanishes _))) ρ
-- There is a context substitution for every typed identity
-- substitution.
complete : ∀ {n} {Γ : Ctx Tp₁ n} {Δ : Ctx Tp₂ n} → Γ ⇒ Δ ⊢ id → Γ ⇒ Δ ⊢-id
complete σ-wt = map₂ (subst (_⊢_∈_ _ _) (id-vanishes _)) σ-wt
-- Variants of some simple typed substitutions.
record ContextSimple {Tp Tm} (simple : Simple Tm)
(typedSub : TypedSub Tp Tp Tm) : Set where
field simpleTyped : SimpleTyped simple typedSub
open TypedSub typedSub hiding (_⊢_∈_)
private
module U = SimpleExt simple
module C = WeakenOps weakenOps
module S = SimpleTyped simpleTyped
open C using (_i∷_)
equivalence : Equivalence simple typedSub
equivalence = record { id-vanishes = S.id-vanishes }
open Equivalence equivalence public
open ContextSub contextSub public
infixr 5 _/∷_
infix 10 _↑
-- Extension.
_/∷_ : ∀ {n} {Γ : Ctx Tp n} {Δ : Ctx Tp n} {a b} →
b ∷ Δ ⊢ U.var zero ∈ a → Γ ⇒ Δ ⊢-id → a ∷ Γ ⇒ b ∷ Δ ⊢-id
z∈a /∷ σ-wt = z∈a ∷ gmap₂ S.weaken σ-wt
-- Lifting.
_↑ : ∀ {n} {Γ : Ctx Tp n} {Δ : Ctx Tp n} → Γ ⇒ Δ ⊢-id → ∀ {a} →
a ∷ Γ ⇒ a ∷ Δ ⊢-id
ρ ↑ = S.var zero /∷ ρ
-- The identity substitution.
id : ∀ {n} {Γ : Ctx Tp n} → Γ ⇒ Γ ⊢-id
id = complete S.id
| {
"alphanum_fraction": 0.5604571595,
"avg_line_length": 32.5521327014,
"ext": "agda",
"hexsha": "27756f8de22e2fb335ceaed1131032e49e827418",
"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/Fin/TypedSubstitution.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/Fin/TypedSubstitution.agda",
"max_line_length": 80,
"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/Fin/TypedSubstitution.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": 5119,
"size": 13737
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed applicative functors
------------------------------------------------------------------------
-- Note that currently the applicative functor laws are not included
-- here.
{-# OPTIONS --without-K --safe #-}
module Category.Applicative.Indexed where
open import Category.Functor using (RawFunctor)
open import Data.Product using (_×_; _,_)
open import Function
open import Level
open import Relation.Binary.PropositionalEquality as P using (_≡_)
private
variable
a b c i f : Level
A : Set a
B : Set b
C : Set c
IFun : Set i → (ℓ : Level) → Set (i ⊔ suc ℓ)
IFun I ℓ = I → I → Set ℓ → Set ℓ
------------------------------------------------------------------------
-- Type, and usual combinators
record RawIApplicative {I : Set i} (F : IFun I f) :
Set (i ⊔ suc f) where
infixl 4 _⊛_ _<⊛_ _⊛>_
infix 4 _⊗_
field
pure : ∀ {i} → A → F i i A
_⊛_ : ∀ {i j k} → F i j (A → B) → F j k A → F i k B
rawFunctor : ∀ {i j} → RawFunctor (F i j)
rawFunctor = record
{ _<$>_ = λ g x → pure g ⊛ x
}
private
open module RF {i j : I} =
RawFunctor (rawFunctor {i = i} {j = j})
public
_<⊛_ : ∀ {i j k} → F i j A → F j k B → F i k A
x <⊛ y = const <$> x ⊛ y
_⊛>_ : ∀ {i j k} → F i j A → F j k B → F i k B
x ⊛> y = flip const <$> x ⊛ y
_⊗_ : ∀ {i j k} → F i j A → F j k B → F i k (A × B)
x ⊗ y = (_,_) <$> x ⊛ y
zipWith : ∀ {i j k} → (A → B → C) → F i j A → F j k B → F i k C
zipWith f x y = f <$> x ⊛ y
zip : ∀ {i j k} → F i j A → F j k B → F i k (A × B)
zip = zipWith _,_
------------------------------------------------------------------------
-- Applicative with a zero
record RawIApplicativeZero
{I : Set i} (F : IFun I f) :
Set (i ⊔ suc f) where
field
applicative : RawIApplicative F
∅ : ∀ {i j} → F i j A
open RawIApplicative applicative public
------------------------------------------------------------------------
-- Alternative functors: `F i j A` is a monoid
record RawIAlternative
{I : Set i} (F : IFun I f) :
Set (i ⊔ suc f) where
infixr 3 _∣_
field
applicativeZero : RawIApplicativeZero F
_∣_ : ∀ {i j} → F i j A → F i j A → F i j A
open RawIApplicativeZero applicativeZero public
------------------------------------------------------------------------
-- Applicative functor morphisms, specialised to propositional
-- equality.
record Morphism {I : Set i} {F₁ F₂ : IFun I f}
(A₁ : RawIApplicative F₁)
(A₂ : RawIApplicative F₂) : Set (i ⊔ suc f) where
module A₁ = RawIApplicative A₁
module A₂ = RawIApplicative A₂
field
op : ∀ {i j} → F₁ i j A → F₂ i j A
op-pure : ∀ {i} (x : A) → op (A₁.pure {i = i} x) ≡ A₂.pure x
op-⊛ : ∀ {i j k} (f : F₁ i j (A → B)) (x : F₁ j k A) →
op (f A₁.⊛ x) ≡ (op f A₂.⊛ op x)
op-<$> : ∀ {i j} (f : A → B) (x : F₁ i j A) →
op (f A₁.<$> x) ≡ (f A₂.<$> op x)
op-<$> f x = begin
op (A₁._⊛_ (A₁.pure f) x) ≡⟨ op-⊛ _ _ ⟩
A₂._⊛_ (op (A₁.pure f)) (op x) ≡⟨ P.cong₂ A₂._⊛_ (op-pure _) P.refl ⟩
A₂._⊛_ (A₂.pure f) (op x) ∎
where open P.≡-Reasoning
| {
"alphanum_fraction": 0.4531438936,
"avg_line_length": 28.7652173913,
"ext": "agda",
"hexsha": "816d31c502b9cf18d899de5523963de9af8644a6",
"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/Category/Applicative/Indexed.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/Category/Applicative/Indexed.agda",
"max_line_length": 74,
"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/Category/Applicative/Indexed.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": 1185,
"size": 3308
} |
import Fragment.Algebra.Algebra
import Fragment.Algebra.Free
import Fragment.Algebra.Free.Atoms
import Fragment.Algebra.Free.Base
import Fragment.Algebra.Free.Evaluation
import Fragment.Algebra.Free.Monad
import Fragment.Algebra.Free.Properties
import Fragment.Algebra.Free.Syntax
import Fragment.Algebra.Homomorphism
import Fragment.Algebra.Homomorphism.Base
import Fragment.Algebra.Homomorphism.Definitions
import Fragment.Algebra.Homomorphism.Equivalence
import Fragment.Algebra.Homomorphism.Properties
import Fragment.Algebra.Homomorphism.Setoid
import Fragment.Algebra.Properties
import Fragment.Algebra.Quotient
import Fragment.Algebra.Signature
import Fragment.Equational.Coproduct
import Fragment.Equational.FreeExtension
import Fragment.Equational.FreeExtension.Base
import Fragment.Equational.FreeExtension.Properties
import Fragment.Equational.FreeExtension.Synthetic
import Fragment.Equational.Model
import Fragment.Equational.Model.Base
import Fragment.Equational.Model.Properties
import Fragment.Equational.Model.Satisfaction
import Fragment.Equational.Model.Synthetic
import Fragment.Equational.Structures
import Fragment.Equational.Theory
import Fragment.Equational.Theory.Base
import Fragment.Equational.Theory.Bundles
import Fragment.Equational.Theory.Combinators
import Fragment.Equational.Theory.Laws
import Fragment.Examples.CSemigroup.Arith.Atomic
import Fragment.Examples.CSemigroup.Arith.Base
import Fragment.Examples.CSemigroup.Arith.Functions
import Fragment.Examples.CSemigroup.Arith.Reasoning
import Fragment.Examples.CSemigroup.Types
import Fragment.Examples.Semigroup.Arith.Atomic
import Fragment.Examples.Semigroup.Arith.Base
import Fragment.Examples.Semigroup.Arith.Functions
import Fragment.Examples.Semigroup.Arith.Reasoning
import Fragment.Examples.Semigroup.Types
import Fragment.Extensions.CSemigroup
import Fragment.Extensions.CSemigroup.Base
import Fragment.Extensions.CSemigroup.Monomial
import Fragment.Extensions.CSemigroup.Nat
-- import Fragment.Extensions.Combinators
import Fragment.Extensions.Semigroup
import Fragment.Prelude
import Fragment.Setoid.Morphism
import Fragment.Setoid.Morphism.Base
import Fragment.Setoid.Morphism.Properties
import Fragment.Setoid.Morphism.Setoid
import Fragment.Tactic.Fragment
import Fragment.Tactic.Utils
| {
"alphanum_fraction": 0.8809628009,
"avg_line_length": 40.0877192982,
"ext": "agda",
"hexsha": "0f54c52465b70d31a0748d789a66f4c6b5a8ff52",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z",
"max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "yallop/agda-fragment",
"max_forks_repo_path": "Everything.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "yallop/agda-fragment",
"max_issues_repo_path": "Everything.agda",
"max_line_length": 51,
"max_stars_count": 18,
"max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yallop/agda-fragment",
"max_stars_repo_path": "Everything.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z",
"num_tokens": 498,
"size": 2285
} |
open import Agda.Builtin.Bool
open import Agda.Builtin.List
data Singleton : List Bool → Set where
singleton : ∀ b → Singleton (b ∷ [])
Works : (bs : List Bool) → Singleton bs → Set₁
Works bs s with s
... | singleton b with Set
Works .(b ∷ []) s | singleton b | _ = Set
Fails : (bs : List Bool) → Singleton bs → Set₁
Fails bs s with singleton b ← s with Set
Fails .(b ∷ []) s | _ = Set
| {
"alphanum_fraction": 0.6306532663,
"avg_line_length": 26.5333333333,
"ext": "agda",
"hexsha": "c9a1814151fe64ccb62f3f159a0e86d66ca365e5",
"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/Issue4079.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/Issue4079.agda",
"max_line_length": 47,
"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/Issue4079.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": 124,
"size": 398
} |
{-# OPTIONS --without-K --safe #-}
open import Level
open import Categories.Category using (Category; _[_,_])
-- Various conclusions that can be drawn from Yoneda
-- over a particular Category C
module Categories.Yoneda.Properties {o ℓ e : Level} (C : Category o ℓ e) where
open import Function.Base using (_$_)
open import Function.Bundles using (Inverse)
open import Function.Equality using (Π; _⟨$⟩_; cong)
open import Relation.Binary.Bundles using (module Setoid)
import Relation.Binary.Reasoning.Setoid as SetoidR
open import Data.Product using (_,_; Σ)
open import Categories.Category.Product
open import Categories.Category.Construction.Presheaves
open import Categories.Category.Construction.Functors
open import Categories.Category.Instance.Setoids
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Properties using (Full; Faithful; FullyFaithful)
open import Categories.Functor.Hom using (module Hom; Hom[_][-,_]; Hom[_][-,-])
open import Categories.Functor.Bifunctor
open import Categories.Functor.Presheaf
open import Categories.Functor.Construction.LiftSetoids
open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) renaming (id to idN)
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)
open import Categories.Yoneda
import Categories.Morphism as Mor
import Categories.Morphism.Reasoning as MR
import Categories.NaturalTransformation.Hom as NT-Hom
open Category C using (module HomReasoning; id; _∘_; identityˡ; identityʳ; Obj; ∘-resp-≈ˡ; ∘-resp-≈ʳ)
open HomReasoning
open NaturalTransformation using (η; commute)
open Yoneda C using (embed; yoneda-inverse; module yoneda)
private
module CE = Category.Equiv C using (refl)
module C = Category C using (op; id)
YoFull : Full embed
YoFull {X} {Y} = record
{ from = record { _⟨$⟩_ = λ ε → η ε X ⟨$⟩ id ; cong = λ i≈j → i≈j CE.refl }
; right-inverse-of = λ ε {x} {z} {y} z≈y →
begin
(η ε X ⟨$⟩ id) ∘ z ≈˘⟨ identityˡ ⟩
id ∘ (η ε X ⟨$⟩ id) ∘ z ≈˘⟨ commute ε z CE.refl ⟩
η ε x ⟨$⟩ id ∘ id ∘ z ≈⟨ cong (η ε x) (identityˡ ○ identityˡ ○ z≈y) ⟩
η ε x ⟨$⟩ y ∎
}
YoFaithful : Faithful embed
YoFaithful f g pres-≈ = begin
f ≈˘⟨ identityʳ ⟩
f ∘ id ≈⟨ pres-≈ CE.refl ⟩
g ∘ id ≈⟨ identityʳ ⟩
g ∎
YoFullyFaithful : FullyFaithful embed
YoFullyFaithful = YoFull , YoFaithful
open Mor C using (_≅_)
yoneda-iso : ∀ {A B : Obj} → NaturalIsomorphism Hom[ C ][-, A ] Hom[ C ][-, B ] → A ≅ B
yoneda-iso {A} {B} niso = record
{ from = ⇒.η A ⟨$⟩ id
; to = ⇐.η B ⟨$⟩ id
; iso = record
{ isoˡ = begin
(⇐.η B ⟨$⟩ id) ∘ (⇒.η A ⟨$⟩ id) ≈˘⟨ identityˡ ⟩
id ∘ (⇐.η B ⟨$⟩ id) ∘ (⇒.η A ⟨$⟩ id) ≈⟨ B⇒A.inverseʳ F⇐G CE.refl ⟩
⇐.η A ⟨$⟩ (⇒.η A ⟨$⟩ id) ≈⟨ isoX.isoˡ CE.refl ⟩
id ∎
; isoʳ = begin
(⇒.η A ⟨$⟩ id) ∘ (⇐.η B ⟨$⟩ id) ≈˘⟨ identityˡ ⟩
id ∘ (⇒.η A ⟨$⟩ id) ∘ (⇐.η B ⟨$⟩ id) ≈⟨ A⇒B.inverseʳ F⇒G CE.refl ⟩
⇒.η B ⟨$⟩ (⇐.η B ⟨$⟩ id) ≈⟨ isoX.isoʳ CE.refl ⟩
id ∎
}
}
where
open NaturalIsomorphism niso
A⇒B = yoneda-inverse A (Functor.F₀ embed B)
B⇒A = yoneda-inverse B (Functor.F₀ embed A)
module A⇒B = Inverse A⇒B using (inverseʳ)
module B⇒A = Inverse B⇒A using (inverseʳ)
module isoX {X} = Mor.Iso (iso X) using (isoʳ; isoˡ)
module _ {o′ ℓ′ e′} {D : Category o′ ℓ′ e′} where
private
module D = Category D using (id)
module _ {F G : Functor D C} where
private
module F = Functor F using (₀; ₁; identity)
module G = Functor G using (₀; ₁; identity)
Hom[-,F-] : Bifunctor C.op D (Setoids ℓ e)
Hom[-,F-] = Hom[ C ][-,-] ∘F (idF ⁂ F)
Hom[-,G-] : Bifunctor C.op D (Setoids ℓ e)
Hom[-,G-] = Hom[ C ][-,-] ∘F (idF ⁂ G)
nat-appʳ : ∀ X → NaturalTransformation Hom[-,F-] Hom[-,G-] →
NaturalTransformation Hom[ C ][-, F.₀ X ] Hom[ C ][-, G.₀ X ]
nat-appʳ X α = ntHelper record
{ η = λ Y → η α (Y , X)
; commute = λ {_ Y} f eq → cong (η α (Y , X)) (∘-resp-≈ˡ (⟺ F.identity)) ○ commute α (f , D.id) eq ○ ∘-resp-≈ˡ G.identity
}
transform : NaturalTransformation Hom[-,F-] Hom[-,G-] → NaturalTransformation F G
transform α = ntHelper record
{ η = λ X → η α (F.₀ X , X) ⟨$⟩ id
; commute = λ {X Y} f → begin
(η α (F.₀ Y , Y) ⟨$⟩ id) ∘ F.₁ f ≈˘⟨ identityˡ ⟩
id ∘ (η α (F.₀ Y , Y) ⟨$⟩ id) ∘ F.₁ f ≈˘⟨ lower (yoneda.⇒.commute {Y = Hom[ C ][-, G.₀ Y ] , _} (idN , F.₁ f) {nat-appʳ Y α} {nat-appʳ Y α} (cong (η α _))) ⟩
η α (F.₀ X , Y) ⟨$⟩ F.₁ f ∘ id ≈⟨ cong (η α (F.₀ X , Y)) (∘-resp-≈ʳ (⟺ identityˡ)) ⟩
η α (F.₀ X , Y) ⟨$⟩ F.₁ f ∘ id ∘ id ≈⟨ commute α (id , f) CE.refl ⟩
G.₁ f ∘ (η α (F.₀ X , X) ⟨$⟩ id) ∘ id ≈⟨ refl⟩∘⟨ identityʳ ⟩
G.₁ f ∘ (η α (F.₀ X , X) ⟨$⟩ id) ∎
}
module _ (F G : Functor D C) where
private
module F = Functor F using (₀)
module G = Functor G using (₀)
Hom[-,F-] : Bifunctor C.op D (Setoids ℓ e)
Hom[-,F-] = Hom[ C ][-,-] ∘F (idF ⁂ F)
Hom[-,G-] : Bifunctor C.op D (Setoids ℓ e)
Hom[-,G-] = Hom[ C ][-,-] ∘F (idF ⁂ G)
-- The implicits given below are sometimes needed (yellow), sometimes make an enormous difference in
-- typechecking time. For example, in yoneda.⇒.commute, "nat-appʳ X F⇐G" is needed, while
-- nat-appʳ {F = G} {F} X F⇐G makes a huge difference in checking time.
yoneda-NI : NaturalIsomorphism Hom[-,F-] Hom[-,G-] → NaturalIsomorphism F G
yoneda-NI ni = record
{ F⇒G = transform F⇒G
; F⇐G = transform F⇐G
; iso = λ X → record
{ isoˡ = begin
(⇐.η (G.₀ X , X) ⟨$⟩ id) ∘ (⇒.η (F.₀ X , X) ⟨$⟩ id) ≈⟨ introˡ CE.refl ⟩
id ∘ (⇐.η (G.₀ X , X) ⟨$⟩ id) ∘ (⇒.η (F.₀ X , X) ⟨$⟩ id) ≈˘⟨ lower {e} (yoneda.⇒.commute {Y = Hom[ C ][-, F.₀ X ] , _}
(idN , (⇒.η (F.₀ X , X) ⟨$⟩ id))
{nat-appʳ {F = G} {F} X F⇐G}
{nat-appʳ {F = G} {F} X F⇐G}
(cong (⇐.η (_ , X) ))) ⟩
⇐.η (F.₀ X , X) ⟨$⟩ (⇒.η (F.₀ X , X) ⟨$⟩ id) ∘ id ≈⟨ cong (⇐.η _) identityʳ ⟩
⇐.η (F.₀ X , X) ⟨$⟩ (⇒.η (F.₀ X , X) ⟨$⟩ id) ≈⟨ iso.isoˡ _ CE.refl ⟩
id ∎
; isoʳ = begin
(⇒.η (F.₀ X , X) ⟨$⟩ id) ∘ (⇐.η (G.₀ X , X) ⟨$⟩ id) ≈⟨ introˡ CE.refl ⟩
id ∘ (⇒.η (F.₀ X , X) ⟨$⟩ id) ∘ (⇐.η (G.₀ X , X) ⟨$⟩ id) ≈˘⟨ lower {e} (yoneda.⇒.commute {Y = Hom[ C ][-, G.₀ X ] , _}
(idN , (⇐.η (G.₀ X , X) ⟨$⟩ C.id))
{nat-appʳ {F = F} {G} X F⇒G}
{nat-appʳ {F = F} {G} X F⇒G}
(cong (⇒.η _))) ⟩
⇒.η (G.₀ X , X) ⟨$⟩ (⇐.η (G.₀ X , X) ⟨$⟩ id) ∘ id ≈⟨ cong (⇒.η _) identityʳ ⟩
⇒.η (G.₀ X , X) ⟨$⟩ (⇐.η (G.₀ X , X) ⟨$⟩ id) ≈⟨ iso.isoʳ _ CE.refl ⟩
id ∎
}
}
where
open NaturalIsomorphism ni using (F⇒G; F⇐G; module ⇐; module ⇒; module iso)
open MR C using (introˡ)
| {
"alphanum_fraction": 0.4813155874,
"avg_line_length": 46.7904191617,
"ext": "agda",
"hexsha": "b33ccec73863a338f559cc8cfdc5d2e36ab27b1c",
"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/Yoneda/Properties.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/Yoneda/Properties.agda",
"max_line_length": 168,
"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/Yoneda/Properties.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": 2979,
"size": 7814
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category; module Commutation)
open import Categories.Category.Cartesian using (Cartesian)
-- Defines the following properties of a Category:
-- Cartesian.SymmetricMonoidal
-- a Cartesian category is Symmetric Monoidal if its induced monoidal structure is symmetric
module Categories.Category.Cartesian.SymmetricMonoidal {o ℓ e} (𝒞 : Category o ℓ e) (cartesian : Cartesian 𝒞) where
open import Data.Product using (_,_)
open Category 𝒞
open Commutation 𝒞
open HomReasoning
open import Categories.Category.BinaryProducts 𝒞 using (module BinaryProducts)
open import Categories.Category.Cartesian.Monoidal using (module CartesianMonoidal)
open import Categories.Category.Monoidal using (Monoidal)
import Categories.Category.Monoidal.Symmetric as Sym
open import Categories.NaturalTransformation using (ntHelper)
private
variable
W X Y Z : Obj
open Cartesian cartesian using (products)
open CartesianMonoidal cartesian using (monoidal)
open Sym monoidal using (Symmetric; symmetricHelper)
open Monoidal monoidal using (_⊗₀_; _⊗₁_; module associator)
open BinaryProducts products
private
B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X
B = swap
hexagon : [ (X ⊗₀ Y) ⊗₀ Z ⇒ Y ⊗₀ Z ⊗₀ X ]⟨
B ⊗₁ id ⇒⟨ (Y ⊗₀ X) ⊗₀ Z ⟩
associator.from ⇒⟨ Y ⊗₀ X ⊗₀ Z ⟩
id ⊗₁ B
≈ associator.from ⇒⟨ X ⊗₀ Y ⊗₀ Z ⟩
B ⇒⟨ (Y ⊗₀ Z) ⊗₀ X ⟩
associator.from
⟩
hexagon = begin
id ⊗₁ swap ∘ assocˡ ∘ swap ⊗₁ id ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩
id ⊗₁ swap ∘ assocˡ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₁ ∘ π₁ ⟩ , id ∘ π₂ ⟩ ≈⟨ refl⟩∘⟨ assocˡ∘⟨⟩ ⟩
id ⊗₁ swap ∘ ⟨ π₂ ∘ π₁ , ⟨ π₁ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⁂∘⟨⟩ ⟩
⟨ id ∘ π₂ ∘ π₁ , swap ∘ ⟨ π₁ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ swap∘⟨⟩ ⟩
⟨ π₂ ∘ π₁ , ⟨ id ∘ π₂ , π₁ ∘ π₁ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (⟨⟩-congʳ identityˡ) ⟩
⟨ π₂ ∘ π₁ , ⟨ π₂ , π₁ ∘ π₁ ⟩ ⟩ ≈˘⟨ assocˡ∘⟨⟩ ⟩
assocˡ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ , π₁ ∘ π₁ ⟩ ≈˘⟨ refl⟩∘⟨ swap∘⟨⟩ ⟩
assocˡ ∘ swap ∘ assocˡ ∎
symmetric : Symmetric
symmetric = symmetricHelper record
{ braiding = record
{ F⇒G = ntHelper record
{ η = λ _ → swap
; commute = λ _ → swap∘⁂
}
; F⇐G = ntHelper record
{ η = λ _ → swap
; commute = λ _ → swap∘⁂
}
; iso = λ _ → record
{ isoˡ = swap∘swap
; isoʳ = swap∘swap
}
}
; commutative = swap∘swap
; hexagon = hexagon
}
| {
"alphanum_fraction": 0.5506542056,
"avg_line_length": 35.1973684211,
"ext": "agda",
"hexsha": "84670dfe26bfc2a8bbc07778e7d9a42794ef26cc",
"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/Category/Cartesian/SymmetricMonoidal.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/Category/Cartesian/SymmetricMonoidal.agda",
"max_line_length": 115,
"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/Category/Cartesian/SymmetricMonoidal.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": 951,
"size": 2675
} |
module plfa-exercises.Practice4 where
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_×_ ; ∃-syntax; ∃; _,_) -- renaming (_,_ to ⟨_,_⟩)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _≤_; _≤?_; _≟_; s≤s; z≤n)
open import Data.Nat.Binary.Properties using (≰⇒>)
open import Data.Nat.Properties using (≤-refl; ≤-trans; ≤-antisym; ≤-total)
open import Data.Maybe using (Maybe; just; nothing; maybe; _>>=_; from-just; From-just)
open import Data.Bool using (Bool; true; false; T; _∧_; _∨_; not)
open import Relation.Nullary.Decidable using (⌊_⌋; toWitness; fromWitness; from-yes; From-yes)
open import Relation.Nullary using (¬_; Dec; yes; no)
open import Data.Unit using (⊤; tt)
--data OrderedTree (A : Set) : (smallest middle biggest : ℕ) → Set where
-- leaf : ∀ (n : ℕ) → A → OrderedTree A n n
-- node : ∀ {s₁ m₁ b₁ s₂ m₂ b₂ : ℕ}
-- → (m : ℕ)
-- → b₁ ≤ m
-- → m ≤ s₂
-- → OrderedTree A s₁ m₁ b₁
-- → OrderedTree A s₂ m₂ b₂
-- → OrderedTree A s₁ m b₂
--
---- node 7 _ _ (leaf 5 300) (leaf 10 200)
----middle_values_in_node_are_smaller :
--
--insert_left : ∀ {s m b : ℕ} → (n : ℕ) → A → OrderedTree A s m b
data BST : ℕ → ℕ → Set where
leaf : ∀ {l u : ℕ} → l ≤ u → BST l u
node : ∀ {l l₀ u₁ u : ℕ} (d : ℕ)
→ BST l₀ d
→ BST d u₁
→ l ≤ l₀ -- This overcomplicates some stuff in later code. Better get rid off it
→ u₁ ≤ u
→ BST l u
-- node {l = 0} {u = 30} 5 (leaf {2} {5} _) (leaf {5} {6} _)
-- If we use the long definition of BST this function gets short, otherwise it's quite complicated
widen : ∀ {l l' u u' : ℕ}
→ BST l' u'
→ l ≤ l'
→ u' ≤ u
→ BST l u
widen (leaf l'≤u') l≤l' u'≤u = leaf (≤-trans l≤l' (≤-trans l'≤u' u'≤u))
widen (node d left right l'≤l₀ u₁≤u') l≤l' u'≤u = node d left right (≤-trans l≤l' l'≤l₀) (≤-trans u₁≤u' u'≤u)
-- node {l = 0} {u = 30} 5 (leaf {2} {5} _) (widen (leaf {23} {29} _) _ _) z≤n _
a-tree : BST 0 30 -- A tree with a single node!!
--a-tree = node 5 (leaf 2≤5) (leaf 5≤30) z≤n 30≤30
a-tree = node 5 (leaf 2≤5) (widen (leaf 23≤29) 5≤23 29≤30) z≤n 30≤30
--a-tree = node {l = 0} {u = 30} 5 (leaf {2} {5} 2≤5) (widen (leaf {23} {29} 23≤29) 5≤23 29≤30) z≤n 30≤30
where
--2≤5 = toWitness {Q = 2 ≤? 5} tt
2≤5 = from-yes ( 2 ≤? 5)
23≤29 = from-yes (23 ≤? 29)
5≤23 = from-yes ( 5 ≤? 23)
29≤30 = from-yes (29 ≤? 30)
30≤30 = from-yes (30 ≤? 30)
binary-search : ∀ {l u : ℕ} → (n : ℕ) → l ≤ n → n ≤ u → BST l u → Maybe (∃[ l' ] (∃[ u' ] (BST l' u')))
binary-search _ _ _ (leaf _) = nothing
binary-search n l≤n n≤u (node {l'} {l₀} {u₁} {u'} d left right l'≤l₀ u₁≤u') with d ≟ n
--binary-search n _ _ (node {_} {l} {_} {u} d left right l≤l₀ u₁≤u) with d ≟ n
... | yes d=n = just (l' , u' , node d left right l'≤l₀ u₁≤u')
... | no d≠n with ≤-total n d | l₀ ≤? n | n ≤? u₁
... | inj₁ n≤d | yes l₀≤n | _ = binary-search n l₀≤n n≤d left
... | inj₁ n≤d | no ¬l₀≤n | _ = nothing -- This shouldn't exist if the definition of BST wasn't so overcomcomplicated
... | inj₂ d≤n | _ | yes n≤u₁ = binary-search n d≤n n≤u₁ right
... | inj₂ d≤n | _ | no ¬n≤u₁ = nothing
smaller : ℕ → ℕ → Bool
smaller m n with m ≤? n
... | yes m≤n = true
... | _ = false
_≤ℕ_ : ∀ (m n : ℕ) → From-yes (m ≤? n)
m ≤ℕ n = from-yes (m ≤? n)
--_ : Maybe (∃ (λ l' → ∃ (BST l')))
--_ = binary-search 5 _ _ a-tree ≡ nothing
--where
--5≤30 = from-yes (5 ≤? 30)
_ : binary-search 2 z≤n (2 ≤ℕ 30) a-tree ≡ nothing
_ = refl
_ : binary-search 5 z≤n (5 ≤ℕ 30) a-tree ≡ just (0 , 30 , node 5 _ _ _ _)
_ = refl
insert : ∀ {l u} (d : ℕ) → l ≤ d → d ≤ u → BST l u → BST l u
insert d l≤d d≤u (leaf _) = node d (leaf l≤d) (leaf d≤u) ≤-refl ≤-refl
insert d l≤d d≤u (node {_} {l₀} m left right l≤m m≤u) with ≤-total m d
... | inj₁ m≤d = node m (insert d ? ? left) right l≤m m≤u -- This shouldn't exist if the definition of BST wasn't so overcomcomplicated
... | inj₂ d≤m = ?
-- ≰⇒> ¬3≤4
| {
"alphanum_fraction": 0.5249764373,
"avg_line_length": 42.44,
"ext": "agda",
"hexsha": "c779329ec21b3ea8b5f2ffc87a4f23c6b53e6a6f",
"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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "helq/old_code",
"max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice4.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z",
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "helq/old_code",
"max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice4.agda",
"max_line_length": 151,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "helq/old_code",
"max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice4.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1807,
"size": 4244
} |
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇.
-- Translation between different formalisations of syntax.
module BasicIS4.Syntax.Translation where
open import BasicIS4.Syntax.Common public
import BasicIS4.Syntax.ClosedHilbertSequential as CHS
import BasicIS4.Syntax.ClosedHilbert as CH
import BasicIS4.Syntax.HilbertSequential as HS
import BasicIS4.Syntax.Hilbert as H
import BasicIS4.Syntax.Gentzen as G
import BasicIS4.Syntax.DyadicHilbertSequential as DHS
import BasicIS4.Syntax.DyadicHilbert as DH
import BasicIS4.Syntax.DyadicGentzen as DG
import BasicIS4.Syntax.LabelledGentzen as LG
open HS using () renaming (_⊦⊢_ to HS⟨_⊦⊢_⟩ ; _⊢_ to HS⟨_⊢_⟩) public
open H using () renaming (_⊢_ to H⟨_⊢_⟩ ; _⊢⋆_ to H⟨_⊢⋆_⟩) public
open G using () renaming (_⊢_ to G⟨_⊢_⟩ ; _⊢⋆_ to G⟨_⊢⋆_⟩) public
open DHS using () renaming (_⊦⊢_ to DHS⟨_⊦⊢_⟩ ; _⊢_ to DHS⟨_⊢_⟩) public
open DH using () renaming (_⊢_ to DH⟨_⊢_⟩) public
open DG using () renaming (_⊢_ to DG⟨_⊢_⟩ ; _⊢⋆_ to DG⟨_⊢⋆_⟩) public
open LG using (_↝_ ; _◎_ ; _◎⋆_) renaming (_⊢_ to LG⟨_⊢_⟩ ; _⊢⋆_ to LG⟨_⊢⋆_⟩) public
-- Available translations.
--
-- ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
-- │ CHS │ CH │ HS │ H │ G │ DHS │ DH │ DG │ LG │
-- ┌─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ CHS │ │ d │ d │ ∘ │ ∘ │ ∘ │ ∘ │ ∘ │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ CH │ d │ │ ∘ │ d │ ∘ │ ∘ │ ∘ │ ∘ │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ HS │ d │ ∘ │ │ d │ ∘ │ d │ ∘ │ ∘ │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ H │ ∘ │ d │ d │ │ d │ ∘ │ d │ ∘ │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ G │ ∘ │ ∘ │ ∘ │ d │ │ ∘ │ ∘ │ d │ d │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ DHS │ ∘ │ ∘ │ d │ ∘ │ ∘ │ │ d │ ∘ │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ DH │ ∘ │ ∘ │ ∘ │ d │ ∘ │ d │ │ d │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ DG │ ∘ │ ∘ │ ∘ │ ∘ │ ∘! │ ∘ │ d │ │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
-- │ LG │ ∘ │ ∘ │ ∘ │ WIP │ WIP │ ∘ │ ∘ │ ∘ │ │
-- └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
--
-- d : Direct translation.
-- ∘ : Composition of translations.
-- ∘! : Composition; direct translation fails the termination check.
-- WIP : Work in progress.
-- Translation from closed Hilbert-style sequential to closed Hilbert-style.
chs→ch : ∀ {A} → CHS.⊢ A → CH.⊢ A
chs→ch (Ξ , ts) = chs⊦→ch ts top
where
chs⊦→ch : ∀ {A Ξ} → CHS.⊦⊢ Ξ → A ∈ Ξ → CH.⊢ A
chs⊦→ch (CHS.mp i j ts) top = CH.app (chs⊦→ch ts i) (chs⊦→ch ts j)
chs⊦→ch (CHS.ci ts) top = CH.ci
chs⊦→ch (CHS.ck ts) top = CH.ck
chs⊦→ch (CHS.cs ts) top = CH.cs
chs⊦→ch (CHS.nec ss ts) top = CH.box (chs⊦→ch ss top)
chs⊦→ch (CHS.cdist ts) top = CH.cdist
chs⊦→ch (CHS.cup ts) top = CH.cup
chs⊦→ch (CHS.cdown ts) top = CH.cdown
chs⊦→ch (CHS.cpair ts) top = CH.cpair
chs⊦→ch (CHS.cfst ts) top = CH.cfst
chs⊦→ch (CHS.csnd ts) top = CH.csnd
chs⊦→ch (CHS.unit ts) top = CH.unit
chs⊦→ch (CHS.mp i j ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.ci ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.ck ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cs ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.nec ss ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cdist ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cup ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cdown ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cpair ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cfst ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.csnd ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.unit ts) (pop k) = chs⊦→ch ts k
-- Translation from closed Hilbert-style to closed Hilbert-style sequential.
ch→chs : ∀ {A} → CH.⊢ A → CHS.⊢ A
ch→chs (CH.app t u) = CHS.app (ch→chs t) (ch→chs u)
ch→chs CH.ci = ∅ , CHS.ci CHS.nil
ch→chs CH.ck = ∅ , CHS.ck CHS.nil
ch→chs CH.cs = ∅ , CHS.cs CHS.nil
ch→chs (CH.box t) = CHS.box (ch→chs t)
ch→chs CH.cdist = ∅ , CHS.cdist CHS.nil
ch→chs CH.cup = ∅ , CHS.cup CHS.nil
ch→chs CH.cdown = ∅ , CHS.cdown CHS.nil
ch→chs CH.cpair = ∅ , CHS.cpair CHS.nil
ch→chs CH.cfst = ∅ , CHS.cfst CHS.nil
ch→chs CH.csnd = ∅ , CHS.csnd CHS.nil
ch→chs CH.unit = ∅ , CHS.unit CHS.nil
-- Translation from Hilbert-style sequential to Hilbert-style.
hs→h : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → H⟨ Γ ⊢ A ⟩
hs→h (Ξ , ts) = hs⊦→h ts top
where
hs⊦→h : ∀ {A Ξ Γ} → HS⟨ Γ ⊦⊢ Ξ ⟩ → A ∈ Ξ → H⟨ Γ ⊢ A ⟩
hs⊦→h (HS.var i ts) top = H.var i
hs⊦→h (HS.mp i j ts) top = H.app (hs⊦→h ts i) (hs⊦→h ts j)
hs⊦→h (HS.ci ts) top = H.ci
hs⊦→h (HS.ck ts) top = H.ck
hs⊦→h (HS.cs ts) top = H.cs
hs⊦→h (HS.nec ss ts) top = H.box (hs⊦→h ss top)
hs⊦→h (HS.cdist ts) top = H.cdist
hs⊦→h (HS.cup ts) top = H.cup
hs⊦→h (HS.cdown ts) top = H.cdown
hs⊦→h (HS.cpair ts) top = H.cpair
hs⊦→h (HS.cfst ts) top = H.cfst
hs⊦→h (HS.csnd ts) top = H.csnd
hs⊦→h (HS.unit ts) top = H.unit
hs⊦→h (HS.var i ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.mp i j ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.ci ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.ck ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cs ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.nec ss ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cdist ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cup ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cdown ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cpair ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cfst ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.csnd ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.unit ts) (pop k) = hs⊦→h ts k
-- Translation from Hilbert-style to Hilbert-style sequential.
h→hs : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩
h→hs (H.var i) = ∅ , HS.var i HS.nil
h→hs (H.app t u) = HS.app (h→hs t) (h→hs u)
h→hs H.ci = ∅ , HS.ci HS.nil
h→hs H.ck = ∅ , HS.ck HS.nil
h→hs H.cs = ∅ , HS.cs HS.nil
h→hs (H.box t) = HS.box (h→hs t)
h→hs H.cdist = ∅ , HS.cdist HS.nil
h→hs H.cup = ∅ , HS.cup HS.nil
h→hs H.cdown = ∅ , HS.cdown HS.nil
h→hs H.cpair = ∅ , HS.cpair HS.nil
h→hs H.cfst = ∅ , HS.cfst HS.nil
h→hs H.csnd = ∅ , HS.csnd HS.nil
h→hs H.unit = ∅ , HS.unit HS.nil
-- Translation from dyadic Hilbert-style sequential to dyadic Hilbert-style.
dhs→dh : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → DH⟨ Γ ⁏ Δ ⊢ A ⟩
dhs→dh (Ξ , ts) = dhs⊦→dh ts top
where
dhs⊦→dh : ∀ {A Ξ Γ Δ} → DHS⟨ Γ ⁏ Δ ⊦⊢ Ξ ⟩ → A ∈ Ξ → DH⟨ Γ ⁏ Δ ⊢ A ⟩
dhs⊦→dh (DHS.var i ts) top = DH.var i
dhs⊦→dh (DHS.mp i j ts) top = DH.app (dhs⊦→dh ts i) (dhs⊦→dh ts j)
dhs⊦→dh (DHS.ci ts) top = DH.ci
dhs⊦→dh (DHS.ck ts) top = DH.ck
dhs⊦→dh (DHS.cs ts) top = DH.cs
dhs⊦→dh (DHS.mvar i ts) top = DH.mvar i
dhs⊦→dh (DHS.nec ss ts) top = DH.box (dhs⊦→dh ss top)
dhs⊦→dh (DHS.cdist ts) top = DH.cdist
dhs⊦→dh (DHS.cup ts) top = DH.cup
dhs⊦→dh (DHS.cdown ts) top = DH.cdown
dhs⊦→dh (DHS.cpair ts) top = DH.cpair
dhs⊦→dh (DHS.cfst ts) top = DH.cfst
dhs⊦→dh (DHS.csnd ts) top = DH.csnd
dhs⊦→dh (DHS.unit ts) top = DH.unit
dhs⊦→dh (DHS.var i ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.mp i j ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.ci ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.ck ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.cs ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.mvar i ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.nec ss ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.cdist ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.cup ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.cdown ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.cpair ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.cfst ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.csnd ts) (pop k) = dhs⊦→dh ts k
dhs⊦→dh (DHS.unit ts) (pop k) = dhs⊦→dh ts k
-- Translation from dyadic Hilbert-style to dyadic Hilbert-style sequential
dh→dhs : ∀ {A Γ Δ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
dh→dhs (DH.var i) = ∅ , DHS.var i DHS.nil
dh→dhs (DH.app t u) = DHS.app (dh→dhs t) (dh→dhs u)
dh→dhs DH.ci = ∅ , DHS.ci DHS.nil
dh→dhs DH.ck = ∅ , DHS.ck DHS.nil
dh→dhs DH.cs = ∅ , DHS.cs DHS.nil
dh→dhs (DH.mvar i) = ∅ , DHS.mvar i DHS.nil
dh→dhs (DH.box t) = DHS.box (dh→dhs t)
dh→dhs DH.cdist = ∅ , DHS.cdist DHS.nil
dh→dhs DH.cup = ∅ , DHS.cup DHS.nil
dh→dhs DH.cdown = ∅ , DHS.cdown DHS.nil
dh→dhs DH.cpair = ∅ , DHS.cpair DHS.nil
dh→dhs DH.cfst = ∅ , DHS.cfst DHS.nil
dh→dhs DH.csnd = ∅ , DHS.csnd DHS.nil
dh→dhs DH.unit = ∅ , DHS.unit DHS.nil
-- Deduction and detachment theorems for Hilbert-style sequential.
hs-lam : ∀ {A B Γ} → HS⟨ Γ , A ⊢ B ⟩ → HS⟨ Γ ⊢ A ▻ B ⟩
hs-lam = h→hs ∘ H.lam ∘ hs→h
hs-lam⋆₀ : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → HS⟨ ∅ ⊢ Γ ▻⋯▻ A ⟩
hs-lam⋆₀ = h→hs ∘ H.lam⋆₀ ∘ hs→h
hs-det : ∀ {A B Γ} → HS⟨ Γ ⊢ A ▻ B ⟩ → HS⟨ Γ , A ⊢ B ⟩
hs-det = h→hs ∘ H.det ∘ hs→h
hs-det⋆₀ : ∀ {A Γ} → HS⟨ ∅ ⊢ Γ ▻⋯▻ A ⟩ → HS⟨ Γ ⊢ A ⟩
hs-det⋆₀ = h→hs ∘ H.det⋆₀ ∘ hs→h
-- Deduction and detachment theorems for dyadic Hilbert-style sequential.
dhs-lam : ∀ {A B Γ Δ} → DHS⟨ Γ , A ⁏ Δ ⊢ B ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ▻ B ⟩
dhs-lam = dh→dhs ∘ DH.lam ∘ dhs→dh
dhs-lam⋆₀ : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → DHS⟨ ∅ ⁏ Δ ⊢ Γ ▻⋯▻ A ⟩
dhs-lam⋆₀ = dh→dhs ∘ DH.lam⋆₀ ∘ dhs→dh
dhs-mlam : ∀ {A B Γ Δ} → DHS⟨ Γ ⁏ Δ , A ⊢ B ⟩ → DHS⟨ Γ ⁏ Δ ⊢ □ A ▻ B ⟩
dhs-mlam = dh→dhs ∘ DH.mlam ∘ dhs→dh
dhs-mlam⋆₀ : ∀ {Δ A Γ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → DHS⟨ Γ ⁏ ∅ ⊢ □⋆ Δ ▻⋯▻ A ⟩
dhs-mlam⋆₀ = dh→dhs ∘ DH.mlam⋆₀ ∘ dhs→dh
dhs-det : ∀ {A B Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ▻ B ⟩ → DHS⟨ Γ , A ⁏ Δ ⊢ B ⟩
dhs-det = dh→dhs ∘ DH.det ∘ dhs→dh
dhs-det⋆₀ : ∀ {A Γ Δ} → DHS⟨ ∅ ⁏ Δ ⊢ Γ ▻⋯▻ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
dhs-det⋆₀ = dh→dhs ∘ DH.det⋆₀ ∘ dhs→dh
dhs-mdet : ∀ {A B Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ □ A ▻ B ⟩ → DHS⟨ Γ ⁏ Δ , A ⊢ B ⟩
dhs-mdet = dh→dhs ∘ DH.mdet ∘ dhs→dh
dhs-mdet⋆₀ : ∀ {Δ A Γ} → DHS⟨ Γ ⁏ ∅ ⊢ □⋆ Δ ▻⋯▻ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
dhs-mdet⋆₀ = dh→dhs ∘ DH.mdet⋆₀ ∘ dhs→dh
-- Context manipulation for dyadic Hilbert-style sequential.
dhs-merge : ∀ {Δ A Γ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → DHS⟨ Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢ A ⟩
dhs-merge {Δ} = dh→dhs ∘ DH.merge ∘ dhs→dh
dhs-split : ∀ {Δ A Γ} → DHS⟨ Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
dhs-split {Δ} = dh→dhs ∘ DH.split ∘ dhs→dh
-- Translation from closed Hilbert-style sequential to Hilbert-style sequential.
chs→hs₀ : ∀ {A} → CHS.⊢ A → HS⟨ ∅ ⊢ A ⟩
chs→hs₀ (Ξ , ts) = Ξ , chs⊦→hs⊦ ts
where
chs⊦→hs⊦ : ∀ {Ξ} → CHS.⊦⊢ Ξ → HS⟨ ∅ ⊦⊢ Ξ ⟩
chs⊦→hs⊦ CHS.nil = HS.nil
chs⊦→hs⊦ (CHS.mp i j ts) = HS.mp i j (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.ci ts) = HS.ci (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.ck ts) = HS.ck (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.cs ts) = HS.cs (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.cpair ts) = HS.cpair (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.cfst ts) = HS.cfst (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.csnd ts) = HS.csnd (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.unit ts) = HS.unit (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.nec ss ts) = HS.nec (chs⊦→hs⊦ ss) (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.cdist ts) = HS.cdist (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.cup ts) = HS.cup (chs⊦→hs⊦ ts)
chs⊦→hs⊦ (CHS.cdown ts) = HS.cdown (chs⊦→hs⊦ ts)
chs→hs : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → HS⟨ Γ ⊢ A ⟩
chs→hs t = hs-det⋆₀ (chs→hs₀ t)
-- Translation from Hilbert-style sequential to closed Hilbert-style sequential.
hs₀→chs : ∀ {A} → HS⟨ ∅ ⊢ A ⟩ → CHS.⊢ A
hs₀→chs (Ξ , ts) = Ξ , hs₀⊦→chs⊦ ts
where
hs₀⊦→chs⊦ : ∀ {Ξ} → HS⟨ ∅ ⊦⊢ Ξ ⟩ → CHS.⊦⊢ Ξ
hs₀⊦→chs⊦ HS.nil = CHS.nil
hs₀⊦→chs⊦ (HS.var () ts)
hs₀⊦→chs⊦ (HS.mp i j ts) = CHS.mp i j (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.ci ts) = CHS.ci (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.ck ts) = CHS.ck (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cs ts) = CHS.cs (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cpair ts) = CHS.cpair (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cfst ts) = CHS.cfst (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.csnd ts) = CHS.csnd (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.unit ts) = CHS.unit (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.nec ss ts) = CHS.nec (hs₀⊦→chs⊦ ss) (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cdist ts) = CHS.cdist (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cup ts) = CHS.cup (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cdown ts) = CHS.cdown (hs₀⊦→chs⊦ ts)
hs→chs : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
hs→chs t = hs₀→chs (hs-lam⋆₀ t)
-- Translation from dyadic Hilbert-style sequential to Hilbert-style sequential.
dhs₀→hs : ∀ {A Γ} → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩
dhs₀→hs (Ξ , ts) = Ξ , dhs₀⊦→hs⊦ ts
where
dhs₀⊦→hs⊦ : ∀ {Ξ Γ} → DHS⟨ Γ ⁏ ∅ ⊦⊢ Ξ ⟩ → HS⟨ Γ ⊦⊢ Ξ ⟩
dhs₀⊦→hs⊦ DHS.nil = HS.nil
dhs₀⊦→hs⊦ (DHS.var i ts) = HS.var i (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.mp i j ts) = HS.mp i j (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.ci ts) = HS.ci (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.ck ts) = HS.ck (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.cs ts) = HS.cs (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.mvar () ts)
dhs₀⊦→hs⊦ (DHS.nec ss ts) = HS.nec (dhs₀⊦→hs⊦ ss) (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.cdist ts) = HS.cdist (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.cup ts) = HS.cup (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.cdown ts) = HS.cdown (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.cpair ts) = HS.cpair (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.cfst ts) = HS.cfst (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.csnd ts) = HS.csnd (dhs₀⊦→hs⊦ ts)
dhs₀⊦→hs⊦ (DHS.unit ts) = HS.unit (dhs₀⊦→hs⊦ ts)
dhs→hs : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → HS⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dhs→hs = dhs₀→hs ∘ dhs-merge
-- Translation from Hilbert-style sequential to dyadic Hilbert-style sequential.
hs→dhs₀ : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩
hs→dhs₀ (Ξ , ts) = Ξ , hs⊦→dhs₀⊦ ts
where
hs⊦→dhs₀⊦ : ∀ {Ξ Γ} → HS⟨ Γ ⊦⊢ Ξ ⟩ → DHS⟨ Γ ⁏ ∅ ⊦⊢ Ξ ⟩
hs⊦→dhs₀⊦ HS.nil = DHS.nil
hs⊦→dhs₀⊦ (HS.var i ts) = DHS.var i (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.mp i j ts) = DHS.mp i j (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.ci ts) = DHS.ci (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.ck ts) = DHS.ck (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.cs ts) = DHS.cs (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.nec ss ts) = DHS.nec (hs⊦→dhs₀⊦ ss) (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.cdist ts) = DHS.cdist (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.cup ts) = DHS.cup (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.cdown ts) = DHS.cdown (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.cpair ts) = DHS.cpair (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.cfst ts) = DHS.cfst (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.csnd ts) = DHS.csnd (hs⊦→dhs₀⊦ ts)
hs⊦→dhs₀⊦ (HS.unit ts) = DHS.unit (hs⊦→dhs₀⊦ ts)
hs→dhs : ∀ {A Γ Δ} → HS⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
hs→dhs = dhs-split ∘ hs→dhs₀
-- Translation from closed Hilbert-style to Hilbert-style.
ch→h₀ : ∀ {A} → CH.⊢ A → H⟨ ∅ ⊢ A ⟩
ch→h₀ (CH.app t u) = H.app (ch→h₀ t) (ch→h₀ u)
ch→h₀ CH.ci = H.ci
ch→h₀ CH.ck = H.ck
ch→h₀ CH.cs = H.cs
ch→h₀ CH.cpair = H.cpair
ch→h₀ CH.cfst = H.cfst
ch→h₀ CH.csnd = H.csnd
ch→h₀ CH.unit = H.unit
ch→h₀ (CH.box t) = H.box (ch→h₀ t)
ch→h₀ CH.cdist = H.cdist
ch→h₀ CH.cup = H.cup
ch→h₀ CH.cdown = H.cdown
ch→h : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → H⟨ Γ ⊢ A ⟩
ch→h t = H.det⋆₀ (ch→h₀ t)
-- Translation from Hilbert-style to closed Hilbert-style.
h₀→ch : ∀ {A} → H⟨ ∅ ⊢ A ⟩ → CH.⊢ A
h₀→ch (H.var ())
h₀→ch (H.app t u) = CH.app (h₀→ch t) (h₀→ch u)
h₀→ch H.ci = CH.ci
h₀→ch H.ck = CH.ck
h₀→ch H.cs = CH.cs
h₀→ch H.cpair = CH.cpair
h₀→ch H.cfst = CH.cfst
h₀→ch H.csnd = CH.csnd
h₀→ch H.unit = CH.unit
h₀→ch (H.box t) = CH.box (h₀→ch t)
h₀→ch H.cdist = CH.cdist
h₀→ch H.cup = CH.cup
h₀→ch H.cdown = CH.cdown
h→ch : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
h→ch t = h₀→ch (H.lam⋆₀ t)
-- Translation from dyadic Hilbert-style to Hilbert-style.
dh₀→h : ∀ {A Γ} → DH⟨ Γ ⁏ ∅ ⊢ A ⟩ → H⟨ Γ ⊢ A ⟩
dh₀→h (DH.var i) = H.var i
dh₀→h (DH.app t u) = H.app (dh₀→h t) (dh₀→h u)
dh₀→h DH.ci = H.ci
dh₀→h DH.ck = H.ck
dh₀→h DH.cs = H.cs
dh₀→h (DH.mvar ())
dh₀→h (DH.box t) = H.box (dh₀→h t)
dh₀→h DH.cdist = H.cdist
dh₀→h DH.cup = H.cup
dh₀→h DH.cdown = H.cdown
dh₀→h DH.cpair = H.cpair
dh₀→h DH.cfst = H.cfst
dh₀→h DH.csnd = H.csnd
dh₀→h DH.unit = H.unit
dh→h : ∀ {A Γ Δ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → H⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dh→h = dh₀→h ∘ DH.merge
-- Translation from Hilbert-style to dyadic Hilbert-style.
h→dh₀ : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → DH⟨ Γ ⁏ ∅ ⊢ A ⟩
h→dh₀ (H.var i) = DH.var i
h→dh₀ (H.app t u) = DH.app (h→dh₀ t) (h→dh₀ u)
h→dh₀ H.ci = DH.ci
h→dh₀ H.ck = DH.ck
h→dh₀ H.cs = DH.cs
h→dh₀ (H.box t) = DH.box (h→dh₀ t)
h→dh₀ H.cdist = DH.cdist
h→dh₀ H.cup = DH.cup
h→dh₀ H.cdown = DH.cdown
h→dh₀ H.cpair = DH.cpair
h→dh₀ H.cfst = DH.cfst
h→dh₀ H.csnd = DH.csnd
h→dh₀ H.unit = DH.unit
h→dh : ∀ {A Γ Δ} → H⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DH⟨ Γ ⁏ Δ ⊢ A ⟩
h→dh = DH.split ∘ h→dh₀
-- Translation from Hilbert-style to Gentzen-style.
h→g : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩
h→g (H.var i) = G.var i
h→g (H.app t u) = G.app (h→g t) (h→g u)
h→g H.ci = G.ci
h→g H.ck = G.ck
h→g H.cs = G.cs
h→g (H.box t) = G.box (h→g t)
h→g H.cdist = G.cdist
h→g H.cup = G.cup
h→g H.cdown = G.cdown
h→g H.cpair = G.cpair
h→g H.cfst = G.cfst
h→g H.csnd = G.csnd
h→g H.unit = G.unit
-- Translation from Gentzen-style to Hilbert-style.
mutual
g→h : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → H⟨ Γ ⊢ A ⟩
g→h (G.var i) = H.var i
g→h (G.lam t) = H.lam (g→h t)
g→h (G.app t u) = H.app (g→h t) (g→h u)
g→h (G.multibox ts u) = H.multibox (g→h⋆ ts) (g→h u)
g→h (G.down t) = H.down (g→h t)
g→h (G.pair t u) = H.pair (g→h t) (g→h u)
g→h (G.fst t) = H.fst (g→h t)
g→h (G.snd t) = H.snd (g→h t)
g→h G.unit = H.unit
g→h⋆ : ∀ {Ξ Γ} → G⟨ Γ ⊢⋆ Ξ ⟩ → H⟨ Γ ⊢⋆ Ξ ⟩
g→h⋆ {∅} ∙ = ∙
g→h⋆ {Ξ , A} (ts , t) = g→h⋆ ts , g→h t
-- Translation from dyadic Hilbert-style to dyadic Gentzen-style.
dh→dg : ∀ {A Γ Δ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → DG⟨ Γ ⁏ Δ ⊢ A ⟩
dh→dg (DH.var i) = DG.var i
dh→dg (DH.app t u) = DG.app (dh→dg t) (dh→dg u)
dh→dg DH.ci = DG.ci
dh→dg DH.ck = DG.ck
dh→dg DH.cs = DG.cs
dh→dg (DH.mvar i) = DG.mvar i
dh→dg (DH.box t) = DG.box (dh→dg t)
dh→dg DH.cdist = DG.cdist
dh→dg DH.cup = DG.cup
dh→dg DH.cdown = DG.cdown
dh→dg DH.cpair = DG.cpair
dh→dg DH.cfst = DG.cfst
dh→dg DH.csnd = DG.csnd
dh→dg DH.unit = DG.unit
-- Translation from dyadic Gentzen-style to dyadic Hilbert-style.
dg→dh : ∀ {A Γ Δ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → DH⟨ Γ ⁏ Δ ⊢ A ⟩
dg→dh (DG.var i) = DH.var i
dg→dh (DG.lam t) = DH.lam (dg→dh t)
dg→dh (DG.app t u) = DH.app (dg→dh t) (dg→dh u)
dg→dh (DG.mvar i) = DH.mvar i
dg→dh (DG.box t) = DH.box (dg→dh t)
dg→dh (DG.unbox t u) = DH.unbox (dg→dh t) (dg→dh u)
dg→dh (DG.pair t u) = DH.pair (dg→dh t) (dg→dh u)
dg→dh (DG.fst t) = DH.fst (dg→dh t)
dg→dh (DG.snd t) = DH.snd (dg→dh t)
dg→dh DG.unit = DH.unit
-- Translation from Gentzen-style to dyadic Gentzen-style.
mutual
g→dg₀ : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → DG⟨ Γ ⁏ ∅ ⊢ A ⟩
g→dg₀ (G.var i) = DG.var i
g→dg₀ (G.lam t) = DG.lam (g→dg₀ t)
g→dg₀ (G.app t u) = DG.app (g→dg₀ t) (g→dg₀ u)
g→dg₀ (G.multibox ts u) = DG.multibox (g→dg₀⋆ ts) (g→dg₀ u)
g→dg₀ (G.down t) = DG.down (g→dg₀ t)
g→dg₀ (G.pair t u) = DG.pair (g→dg₀ t) (g→dg₀ u)
g→dg₀ (G.fst t) = DG.fst (g→dg₀ t)
g→dg₀ (G.snd t) = DG.snd (g→dg₀ t)
g→dg₀ G.unit = DG.unit
g→dg₀⋆ : ∀ {Ξ Γ} → G⟨ Γ ⊢⋆ Ξ ⟩ → DG⟨ Γ ⁏ ∅ ⊢⋆ Ξ ⟩
g→dg₀⋆ {∅} ∙ = ∙
g→dg₀⋆ {Ξ , A} (ts , t) = g→dg₀⋆ ts , g→dg₀ t
g→dg : ∀ {A Γ Δ} → G⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DG⟨ Γ ⁏ Δ ⊢ A ⟩
g→dg = DG.split ∘ g→dg₀
-- Translation from Hilbert-style to labelled Gentzen-style.
h→lg : ∀ {x A Γ Λ} → H⟨ Γ ⊢ A ⟩ → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
h→lg (H.var i) = LG.var i
h→lg (H.app t u) = LG.app (h→lg t) (h→lg u)
h→lg H.ci = LG.ci
h→lg H.ck = LG.ck
h→lg H.cs = LG.cs
h→lg (H.box t) = LG.box (h→lg t)
h→lg H.cdist = LG.cdist
h→lg H.cup = LG.cup
h→lg H.cdown = LG.cdown
h→lg H.cpair = LG.cpair
h→lg H.cfst = LG.cfst
h→lg H.csnd = LG.csnd
h→lg H.unit = LG.unit
-- Translation from labelled Gentzen-style to Hilbert-style.
-- FIXME: Stronger hypothesis?
postulate
h-oops : ∀ {x A Γ Λ} → (∀ {y} → LG⟨ Γ ⁏ Λ , x ↝ y ⊢ A ◎ y ⟩) → H⟨ Γ ⊢ □ A ⟩
lg→h : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → H⟨ Γ ⊢ A ⟩
lg→h (LG.var i) = H.var i
lg→h (LG.lam t) = H.lam (lg→h t)
lg→h (LG.app t u) = H.app (lg→h t) (lg→h u)
lg→h (LG.scan t) = h-oops t
lg→h (LG.move t u) = H.down (lg→h t)
lg→h (LG.pair t u) = H.pair (lg→h t) (lg→h u)
lg→h (LG.fst t) = H.fst (lg→h t)
lg→h (LG.snd t) = H.snd (lg→h t)
lg→h LG.unit = H.unit
-- Translation from Gentzen-style to labelled Gentzen-style.
mutual
g→lg : ∀ {x A Γ Λ} → G⟨ Γ ⊢ A ⟩ → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
g→lg (G.var i) = LG.var i
g→lg (G.lam t) = LG.lam (g→lg t)
g→lg (G.app t u) = LG.app (g→lg t) (g→lg u)
g→lg (G.multibox ts u) = LG.multibox (g→lg⋆ ts) (g→lg u)
g→lg (G.down t) = LG.move (g→lg t) LG.rrefl
g→lg (G.pair t u) = LG.pair (g→lg t) (g→lg u)
g→lg (G.fst t) = LG.fst (g→lg t)
g→lg (G.snd t) = LG.snd (g→lg t)
g→lg G.unit = LG.unit
g→lg⋆ : ∀ {x Ξ Γ Λ} → G⟨ Γ ⊢⋆ Ξ ⟩ → LG⟨ Γ ⁏ Λ ⊢⋆ Ξ ◎⋆ x ⟩
g→lg⋆ {x} {∅} ∙ = ∙
g→lg⋆ {x} {Ξ , A} (ts , t) = g→lg⋆ ts , g→lg t
-- Translation from labelled Gentzen-style to Gentzen-style.
-- FIXME: Stronger hypothesis?
postulate
g-oops : ∀ {x A Γ Λ} → (∀ {y} → LG⟨ Γ ⁏ Λ , x ↝ y ⊢ A ◎ y ⟩) → G⟨ Γ ⊢ □ A ⟩
lg→g : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → G⟨ Γ ⊢ A ⟩
lg→g (LG.var i) = G.var i
lg→g (LG.lam t) = G.lam (lg→g t)
lg→g (LG.app t u) = G.app (lg→g t) (lg→g u)
lg→g (LG.scan t) = g-oops t
lg→g (LG.move t u) = G.down (lg→g t)
lg→g (LG.pair t u) = G.pair (lg→g t) (lg→g u)
lg→g (LG.fst t) = G.fst (lg→g t)
lg→g (LG.snd t) = G.snd (lg→g t)
lg→g LG.unit = G.unit
-- Additional translations from closed Hilbert-style sequential.
chs→h₀ : ∀ {A} → CHS.⊢ A → H⟨ ∅ ⊢ A ⟩
chs→h₀ = ch→h₀ ∘ chs→ch
chs→h : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → H⟨ Γ ⊢ A ⟩
chs→h = ch→h ∘ chs→ch
chs→g₀ : ∀ {A} → CHS.⊢ A → G⟨ ∅ ⊢ A ⟩
chs→g₀ = h→g ∘ chs→h₀
chs→g : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → G⟨ Γ ⊢ A ⟩
chs→g = h→g ∘ chs→h
chs→dhs₀₀ : ∀ {A} → CHS.⊢ A → DHS⟨ ∅ ⁏ ∅ ⊢ A ⟩
chs→dhs₀₀ = hs→dhs₀ ∘ chs→hs₀
chs→dhs₀ : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩
chs→dhs₀ = hs→dhs₀ ∘ chs→hs
chs→dhs : ∀ {A Γ Δ} → CHS.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
chs→dhs = hs→dhs ∘ chs→hs
chs→dh₀₀ : ∀ {A} → CHS.⊢ A → DH⟨ ∅ ⁏ ∅ ⊢ A ⟩
chs→dh₀₀ = h→dh₀ ∘ chs→h₀
chs→dh₀ : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → DH⟨ Γ ⁏ ∅ ⊢ A ⟩
chs→dh₀ = h→dh₀ ∘ chs→h
chs→dh : ∀ {A Γ Δ} → CHS.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A → DH⟨ Γ ⁏ Δ ⊢ A ⟩
chs→dh = h→dh ∘ chs→h
chs→dg₀₀ : ∀ {A} → CHS.⊢ A → DG⟨ ∅ ⁏ ∅ ⊢ A ⟩
chs→dg₀₀ = g→dg₀ ∘ chs→g₀
chs→dg₀ : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → DG⟨ Γ ⁏ ∅ ⊢ A ⟩
chs→dg₀ = g→dg₀ ∘ chs→g
chs→dg : ∀ {A Γ Δ} → CHS.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A → DG⟨ Γ ⁏ Δ ⊢ A ⟩
chs→dg = g→dg ∘ chs→g
chs→lg₀ : ∀ {x A Λ} → CHS.⊢ A → LG⟨ ∅ ⁏ Λ ⊢ A ◎ x ⟩
chs→lg₀ = g→lg ∘ chs→g₀
chs→lg : ∀ {x A Γ Λ} → CHS.⊢ Γ ▻⋯▻ A → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
chs→lg = g→lg ∘ chs→g
-- Additional translations from closed Hilbert-style.
ch→hs₀ : ∀ {A} → CH.⊢ A → HS⟨ ∅ ⊢ A ⟩
ch→hs₀ = chs→hs ∘ ch→chs
ch→hs : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → HS⟨ Γ ⊢ A ⟩
ch→hs = chs→hs ∘ ch→chs
ch→g₀ : ∀ {A} → CH.⊢ A → G⟨ ∅ ⊢ A ⟩
ch→g₀ = h→g ∘ ch→h₀
ch→g : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → G⟨ Γ ⊢ A ⟩
ch→g = h→g ∘ ch→h
ch→dhs₀₀ : ∀ {A} → CH.⊢ A → DHS⟨ ∅ ⁏ ∅ ⊢ A ⟩
ch→dhs₀₀ = hs→dhs₀ ∘ ch→hs₀
ch→dhs₀ : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩
ch→dhs₀ = hs→dhs₀ ∘ ch→hs
ch→dhs : ∀ {A Γ Δ} → CH.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
ch→dhs = hs→dhs ∘ ch→hs
ch→dh₀₀ : ∀ {A} → CH.⊢ A → DH⟨ ∅ ⁏ ∅ ⊢ A ⟩
ch→dh₀₀ = h→dh₀ ∘ ch→h₀
ch→dh₀ : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → DH⟨ Γ ⁏ ∅ ⊢ A ⟩
ch→dh₀ = h→dh₀ ∘ ch→h
ch→dh : ∀ {A Γ Δ} → CH.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A → DH⟨ Γ ⁏ Δ ⊢ A ⟩
ch→dh = h→dh ∘ ch→h
ch→dg₀₀ : ∀ {A} → CH.⊢ A → DG⟨ ∅ ⁏ ∅ ⊢ A ⟩
ch→dg₀₀ = g→dg₀ ∘ ch→g₀
ch→dg₀ : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → DG⟨ Γ ⁏ ∅ ⊢ A ⟩
ch→dg₀ = g→dg₀ ∘ ch→g
ch→dg : ∀ {A Γ Δ} → CH.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A → DG⟨ Γ ⁏ Δ ⊢ A ⟩
ch→dg = g→dg ∘ ch→g
ch→lg₀ : ∀ {x A Λ} → CH.⊢ A → LG⟨ ∅ ⁏ Λ ⊢ A ◎ x ⟩
ch→lg₀ = g→lg ∘ ch→g₀
ch→lg : ∀ {x A Γ Λ} → CH.⊢ Γ ▻⋯▻ A → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
ch→lg = g→lg ∘ ch→g
-- Additional translations from Hilbert-style sequential.
hs₀→ch : ∀ {A} → HS⟨ ∅ ⊢ A ⟩ → CH.⊢ A
hs₀→ch = chs→ch ∘ hs₀→chs
hs→ch : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
hs→ch = chs→ch ∘ hs→chs
hs→g : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩
hs→g = h→g ∘ hs→h
hs→dh₀ : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → DH⟨ Γ ⁏ ∅ ⊢ A ⟩
hs→dh₀ = h→dh₀ ∘ hs→h
hs→dh : ∀ {A Γ Δ} → HS⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DH⟨ Γ ⁏ Δ ⊢ A ⟩
hs→dh = h→dh ∘ hs→h
hs→dg₀ : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → DG⟨ Γ ⁏ ∅ ⊢ A ⟩
hs→dg₀ = dh→dg ∘ hs→dh₀
hs→dg : ∀ {A Γ Δ} → HS⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DG⟨ Γ ⁏ Δ ⊢ A ⟩
hs→dg = dh→dg ∘ hs→dh
hs→lg : ∀ {x A Γ Λ} → HS⟨ Γ ⊢ A ⟩ → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
hs→lg = h→lg ∘ hs→h
-- Additional translations from Hilbert-style.
h₀→chs : ∀ {A} → H⟨ ∅ ⊢ A ⟩ → CHS.⊢ A
h₀→chs = ch→chs ∘ h₀→ch
h→chs : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
h→chs = ch→chs ∘ h→ch
h→dhs₀ : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩
h→dhs₀ = hs→dhs₀ ∘ h→hs
h→dhs : ∀ {A Γ Δ} → H⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
h→dhs = hs→dhs ∘ h→hs
h→dg₀ : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → DG⟨ Γ ⁏ ∅ ⊢ A ⟩
h→dg₀ = dh→dg ∘ h→dh₀
h→dg : ∀ {A Γ Δ} → H⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DG⟨ Γ ⁏ Δ ⊢ A ⟩
h→dg = dh→dg ∘ h→dh
-- Additional translations from Gentzen-style.
g₀→chs : ∀ {A} → G⟨ ∅ ⊢ A ⟩ → CHS.⊢ A
g₀→chs = h₀→chs ∘ g→h
g→chs : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
g→chs = h→chs ∘ g→h
g₀→ch : ∀ {A} → G⟨ ∅ ⊢ A ⟩ → CH.⊢ A
g₀→ch = h₀→ch ∘ g→h
g→ch : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
g→ch = h→ch ∘ g→h
g→hs : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩
g→hs = h→hs ∘ g→h
g→dhs₀ : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩
g→dhs₀ = h→dhs₀ ∘ g→h
g→dhs : ∀ {A Γ Δ} → G⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
g→dhs = h→dhs ∘ g→h
g→dh₀ : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → DH⟨ Γ ⁏ ∅ ⊢ A ⟩
g→dh₀ = h→dh₀ ∘ g→h
g→dh : ∀ {A Γ Δ} → G⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩ → DH⟨ Γ ⁏ Δ ⊢ A ⟩
g→dh = h→dh ∘ g→h
-- Additional translations from dyadic Hilbert-style sequential.
dhs₀₀→chs : ∀ {A} → DHS⟨ ∅ ⁏ ∅ ⊢ A ⟩ → CHS.⊢ A
dhs₀₀→chs = hs₀→chs ∘ dhs₀→hs
dhs₀→chs : ∀ {A Γ} → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
dhs₀→chs = hs→chs ∘ dhs₀→hs
dhs→chs : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → CHS.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A
dhs→chs = hs→chs ∘ dhs→hs
dhs₀₀→ch : ∀ {A} → DHS⟨ ∅ ⁏ ∅ ⊢ A ⟩ → CH.⊢ A
dhs₀₀→ch = hs₀→ch ∘ dhs₀→hs
dhs₀→ch : ∀ {A Γ} → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
dhs₀→ch = hs→ch ∘ dhs₀→hs
dhs→ch : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → CH.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A
dhs→ch = hs→ch ∘ dhs→hs
dhs₀→h : ∀ {A Γ} → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩ → H⟨ Γ ⊢ A ⟩
dhs₀→h = hs→h ∘ dhs₀→hs
dhs→h : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → H⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dhs→h = hs→h ∘ dhs→hs
dhs₀→g : ∀ {A Γ} → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩
dhs₀→g = hs→g ∘ dhs₀→hs
dhs→g : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → G⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dhs→g = hs→g ∘ dhs→hs
dhs→dg : ∀ {A Γ Δ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → DG⟨ Γ ⁏ Δ ⊢ A ⟩
dhs→dg = dh→dg ∘ dhs→dh
dhs₀→lg : ∀ {x A Γ Λ} → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩ → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
dhs₀→lg = hs→lg ∘ dhs₀→hs
dhs→lg : ∀ {x A Γ Δ Λ} → DHS⟨ Γ ⁏ Δ ⊢ A ⟩ → LG⟨ Γ ⧺ (□⋆ Δ) ⁏ Λ ⊢ A ◎ x ⟩
dhs→lg = hs→lg ∘ dhs→hs
-- Additional translations from dyadic Hilbert-style.
dh₀₀→chs : ∀ {A} → DH⟨ ∅ ⁏ ∅ ⊢ A ⟩ → CHS.⊢ A
dh₀₀→chs = h₀→chs ∘ dh₀→h
dh₀→chs : ∀ {A Γ} → DH⟨ Γ ⁏ ∅ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
dh₀→chs = h→chs ∘ dh₀→h
dh→chs : ∀ {A Γ Δ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → CHS.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A
dh→chs = h→chs ∘ dh→h
dh₀₀→ch : ∀ {A} → DH⟨ ∅ ⁏ ∅ ⊢ A ⟩ → CH.⊢ A
dh₀₀→ch = h₀→ch ∘ dh₀→h
dh₀→ch : ∀ {A Γ} → DH⟨ Γ ⁏ ∅ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
dh₀→ch = h→ch ∘ dh₀→h
dh→ch : ∀ {A Γ Δ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → CH.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A
dh→ch = h→ch ∘ dh→h
dh₀→hs : ∀ {A Γ} → DH⟨ Γ ⁏ ∅ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩
dh₀→hs = h→hs ∘ dh₀→h
dh→hs : ∀ {A Γ Δ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → HS⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dh→hs = h→hs ∘ dh→h
dh₀→g : ∀ {A Γ} → DH⟨ Γ ⁏ ∅ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩
dh₀→g = h→g ∘ dh₀→h
dh→g : ∀ {A Γ Δ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → G⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dh→g = h→g ∘ dh→h
dh₀→lg : ∀ {x A Γ Λ} → DH⟨ Γ ⁏ ∅ ⊢ A ⟩ → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
dh₀→lg = h→lg ∘ dh₀→h
dh→lg : ∀ {x A Γ Δ Λ} → DH⟨ Γ ⁏ Δ ⊢ A ⟩ → LG⟨ Γ ⧺ (□⋆ Δ) ⁏ Λ ⊢ A ◎ x ⟩
dh→lg = h→lg ∘ dh→h
-- Additional translations from dyadic Gentzen-style.
dg₀₀→chs : ∀ {A} → DG⟨ ∅ ⁏ ∅ ⊢ A ⟩ → CHS.⊢ A
dg₀₀→chs = dh₀→chs ∘ dg→dh
dg₀→chs : ∀ {A Γ} → DG⟨ Γ ⁏ ∅ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
dg₀→chs = dh→chs ∘ dg→dh
dg→chs : ∀ {A Γ Δ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → CHS.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A
dg→chs = dh→chs ∘ dg→dh
dg₀₀→ch : ∀ {A} → DG⟨ ∅ ⁏ ∅ ⊢ A ⟩ → CH.⊢ A
dg₀₀→ch = dh₀→ch ∘ dg→dh
dg₀→ch : ∀ {A Γ} → DG⟨ Γ ⁏ ∅ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
dg₀→ch = dh→ch ∘ dg→dh
dg→ch : ∀ {A Γ Δ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → CH.⊢ Γ ⧺ (□⋆ Δ) ▻⋯▻ A
dg→ch = dh→ch ∘ dg→dh
dg₀→hs : ∀ {A Γ} → DG⟨ Γ ⁏ ∅ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩
dg₀→hs = dh₀→hs ∘ dg→dh
dg→hs : ∀ {A Γ Δ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → HS⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dg→hs = dh→hs ∘ dg→dh
dg₀→h : ∀ {A Γ} → DG⟨ Γ ⁏ ∅ ⊢ A ⟩ → H⟨ Γ ⊢ A ⟩
dg₀→h = dh₀→h ∘ dg→dh
dg→h : ∀ {A Γ Δ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → H⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dg→h = dh→h ∘ dg→dh
-- NOTE: Direct translation fails the termination check.
dg₀→g : ∀ {A Γ} → DG⟨ Γ ⁏ ∅ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩
dg₀→g = h→g ∘ dg₀→h
dg→g : ∀ {A Γ Δ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → G⟨ Γ ⧺ (□⋆ Δ) ⊢ A ⟩
dg→g = h→g ∘ dg→h
dg→dhs : ∀ {A Γ Δ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
dg→dhs = dh→dhs ∘ dg→dh
dg₀→lg : ∀ {x A Γ Λ} → DG⟨ Γ ⁏ ∅ ⊢ A ⟩ → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩
dg₀→lg = g→lg ∘ dg₀→g
dg→lg : ∀ {x A Γ Δ Λ} → DG⟨ Γ ⁏ Δ ⊢ A ⟩ → LG⟨ Γ ⧺ (□⋆ Δ) ⁏ Λ ⊢ A ◎ x ⟩
dg→lg = g→lg ∘ dg→g
-- Additional translations from labelled Gentzen-style.
lg₀→chs : ∀ {x A Λ} → LG⟨ ∅ ⁏ Λ ⊢ A ◎ x ⟩ → CHS.⊢ A
lg₀→chs = h₀→chs ∘ lg→h
lg→chs : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → CHS.⊢ Γ ▻⋯▻ A
lg→chs = h→chs ∘ lg→h
lg₀→ch : ∀ {x A Λ} → LG⟨ ∅ ⁏ Λ ⊢ A ◎ x ⟩ → CH.⊢ A
lg₀→ch = h₀→ch ∘ lg→h
lg→ch : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → CH.⊢ Γ ▻⋯▻ A
lg→ch = h→ch ∘ lg→h
lg→hs : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → HS⟨ Γ ⊢ A ⟩
lg→hs = h→hs ∘ lg→h
lg→dhs₀ : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → DHS⟨ Γ ⁏ ∅ ⊢ A ⟩
lg→dhs₀ = h→dhs₀ ∘ lg→h
lg→dhs : ∀ {x A Γ Δ Λ} → LG⟨ Γ ⧺ (□⋆ Δ) ⁏ Λ ⊢ A ◎ x ⟩ → DHS⟨ Γ ⁏ Δ ⊢ A ⟩
lg→dhs = h→dhs ∘ lg→h
lg→dh₀ : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → DH⟨ Γ ⁏ ∅ ⊢ A ⟩
lg→dh₀ = h→dh₀ ∘ lg→h
lg→dh : ∀ {x A Γ Δ Λ} → LG⟨ Γ ⧺ (□⋆ Δ) ⁏ Λ ⊢ A ◎ x ⟩ → DH⟨ Γ ⁏ Δ ⊢ A ⟩
lg→dh = h→dh ∘ lg→h
lg→dg₀ : ∀ {x A Γ Λ} → LG⟨ Γ ⁏ Λ ⊢ A ◎ x ⟩ → DG⟨ Γ ⁏ ∅ ⊢ A ⟩
lg→dg₀ = h→dg₀ ∘ lg→h
lg→dg : ∀ {x A Γ Δ Λ} → LG⟨ Γ ⧺ (□⋆ Δ) ⁏ Λ ⊢ A ◎ x ⟩ → DG⟨ Γ ⁏ Δ ⊢ A ⟩
lg→dg = h→dg ∘ lg→h
| {
"alphanum_fraction": 0.4593860188,
"avg_line_length": 32.4716386555,
"ext": "agda",
"hexsha": "96dde4e78f44c97e8484e06dd3eb81efcf74cf51",
"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": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIS4/Syntax/Translation.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIS4/Syntax/Translation.agda",
"max_line_length": 84,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIS4/Syntax/Translation.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 17975,
"size": 30913
} |
module PiQ.AuxLemmas where
open import Data.Empty
open import Data.Unit hiding (_≟_)
open import Data.Sum
open import Data.Product
open import Data.Maybe
open import Relation.Binary.Core
open import Relation.Binary
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import PiQ.Syntax
open import PiQ.Opsem
Lemma₁ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c' ∣ v' ∣ κ' ⟩◁
→ A ≡ C × B ≡ D
Lemma₁ ↦⃖₁ = refl , refl
Lemma₁ ↦⃖₂ = refl , refl
Lemma₁ ↦⃖ηₓ₁ = refl , refl
Lemma₁ ↦⃖εₓ = refl , refl
Lemma₂ : ∀ {A B v v' κ κ'} {c c' : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c' ∣ v' ∣ κ' ⟩◁
→ c ≡ c' × κ ≡ κ'
Lemma₂ ↦⃖₁ = refl , refl
Lemma₂ ↦⃖₂ = refl , refl
Lemma₂ ↦⃖ηₓ₁ = refl , refl
Lemma₂ ↦⃖εₓ = refl , refl
Lemma₃ : ∀ {A B v v' κ} {c : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁
→ base c ⊎ dual c ⊎ A ≡ B
Lemma₃ (↦⃖₁ {b = b}) = inj₁ b
Lemma₃ ↦⃖₂ = inj₂ (inj₂ refl)
Lemma₃ ↦⃖ηₓ₁ = inj₂ (inj₁ tt)
Lemma₃ ↦⃖εₓ = inj₂ (inj₁ tt)
Lemma₄ : ∀ {A v v' κ} {c : A ↔ A}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁
→ base c ⊎ c ≡ id↔
Lemma₄ (↦⃖₁ {b = b}) = inj₁ b
Lemma₄ ↦⃖₂ = inj₂ refl
Lemma₅ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D}
→ [ c ∣ v ∣ κ ]◁ ↦ [ c' ∣ v' ∣ κ' ]▷
→ A ≡ C × B ≡ D
Lemma₅ ↦η₊₁ = refl , refl
Lemma₅ ↦η₊₂ = refl , refl
Lemma₆ : ∀ {A B v v' κ κ'} {c c' : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ [ c' ∣ v' ∣ κ' ]▷
→ c ≡ c' × κ ≡ κ'
Lemma₆ ↦η₊₁ = refl , refl
Lemma₆ ↦η₊₂ = refl , refl
Lemma₇ : ∀ {A B v v' κ} {c : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ [ c ∣ v' ∣ κ ]▷
→ A ≡ 𝟘
Lemma₇ ↦η₊₁ = refl
Lemma₇ ↦η₊₂ = refl
Lemma₈ : ∀ {A B v κ} {c : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ ⊠
→ ¬ (base c)
Lemma₈ ↦⃖ηₓ₂ ()
Lemma₉ : ∀ {A B} {κ : Context} {v : ⟦ B ⟧} {v' : ⟦ A ⟧} {c : A ↔ B}
→ [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁
→ [ c ∣ v ∣ κ ]◁ ↦ ⊠
→ ⊥
Lemma₉ r' r with Lemma₈ r
Lemma₉ (↦⃖₁ {b = b}) r | nb = nb b
Lemma₉ (↦⃖ηₓ₁ {eq = eq}) (↦⃖ηₓ₂ {neq = neq}) | _ = ⊥-elim (neq eq)
Lemma₁₀ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D}
→ ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c' ∣ v' ∣ κ' ]▷
→ (A ≡ C × B ≡ D)
Lemma₁₀ ↦⃗₁ = refl , refl
Lemma₁₀ ↦⃗₂ = refl , refl
Lemma₁₀ ↦⃗ηₓ = refl , refl
Lemma₁₀ ↦⃗εₓ₁ = refl , refl
Lemma₁₁ : ∀ {A B v v' κ κ'} {c c' : A ↔ B}
→ ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c' ∣ v' ∣ κ' ]▷
→ c ≡ c' × κ ≡ κ'
Lemma₁₁ ↦⃗₁ = refl , refl
Lemma₁₁ ↦⃗₂ = refl , refl
Lemma₁₁ ↦⃗ηₓ = refl , refl
Lemma₁₁ ↦⃗εₓ₁ = refl , refl
Lemma₁₂ : ∀ {A B v v' κ} {c : A ↔ B}
→ (r : ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c ∣ v' ∣ κ ]▷)
→ base c ⊎ dual c ⊎ A ≡ B
Lemma₁₂ (↦⃗₁ {b = b}) = inj₁ b
Lemma₁₂ ↦⃗₂ = inj₂ (inj₂ refl)
Lemma₁₂ ↦⃗ηₓ = inj₂ (inj₁ tt)
Lemma₁₂ ↦⃗εₓ₁ = inj₂ (inj₁ tt)
Lemma₁₃ : ∀ {A v v' κ} {c : A ↔ A}
→ (r : ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c ∣ v' ∣ κ ]▷)
→ base c ⊎ c ≡ id↔
Lemma₁₃ (↦⃗₁ {b = b}) = inj₁ b
Lemma₁₃ ↦⃗₂ = inj₂ refl
| {
"alphanum_fraction": 0.4428274428,
"avg_line_length": 27.75,
"ext": "agda",
"hexsha": "5e604565ef449a0e64f91ff94f01063170b0634c",
"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": "PiQ/AuxLemmas.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": "PiQ/AuxLemmas.agda",
"max_line_length": 67,
"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": "PiQ/AuxLemmas.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": 1621,
"size": 2886
} |
{-# OPTIONS --universe-polymorphism #-}
module NiceGoals where
------------------------------------------------------------------------
postulate
Level : Set
zero : Level
suc : (i : Level) → Level
_⊔_ : Level → Level → Level
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO zero #-}
{-# BUILTIN LEVELSUC suc #-}
{-# BUILTIN LEVELMAX _⊔_ #-}
------------------------------------------------------------------------
record RawMonoid c ℓ : Set (suc (c ⊔ ℓ)) where
infixl 7 _∙_
infix 4 _≈_
field
Carrier : Set c
_≈_ : Carrier → Carrier → Set ℓ
_∙_ : Carrier → Carrier → Carrier
ε : Carrier
module M (rm : RawMonoid zero zero) where
open RawMonoid rm
thm : ∀ x → x ∙ ε ≈ x
thm = {!!}
-- agda2-goal-and-context:
-- rm : RawMonoid zero zero
-- ------------------------
-- Goal: (x : RawMonoid.Carrier rm) →
-- RawMonoid._≈_ rm (RawMonoid._∙_ rm x (RawMonoid.ε rm)) x
------------------------------------------------------------------------
record RawMonoid′ : Set₁ where
infixl 7 _∙_
infix 4 _≈_
field
Carrier : Set
_≈_ : Carrier → Carrier → Set
_∙_ : Carrier → Carrier → Carrier
ε : Carrier
module M′ (rm : RawMonoid′) where
open RawMonoid′ rm
thm′ : ∀ x → x ∙ ε ≈ x
thm′ = {!!}
-- agda2-goal-and-context:
-- rm : RawMonoid′
-- ---------------
-- Goal: (x : Carrier) → x ∙ ε ≈ x
------------------------------------------------------------------------
-- UP isn't relevant.
record RawMonoid″ (Carrier : Set) : Set₁ where
infixl 7 _∙_
infix 4 _≈_
field
_≈_ : Carrier → Carrier → Set
_∙_ : Carrier → Carrier → Carrier
ε : Carrier
data Bool : Set where
true false : Bool
data List (A : Set) : Set where
[] : List A
_∷_ : (x : A)(xs : List A) → List A
module M″ (rm : RawMonoid″ (List Bool)) where
open RawMonoid″ rm
thm″ : ∀ x → x ∙ ε ≈ x
thm″ = {!!}
-- agda2-goal-and-context:
-- rm : RawMonoid″ (List Bool)
-- ---------------------------
-- Goal: (x : List Bool) →
-- RawMonoid″._≈_ rm (RawMonoid″._∙_ rm x (RawMonoid″.ε rm)) x
module M₁ (Z : Set₁) where
postulate
P : Set
Q : Set → Set
module M₂ (X Y : Set) where
module M₁′ = M₁ Set
open M₁′
p : P
p = {!!}
q : Q X
q = {!!}
postulate X : Set
pp : M₂.M₁′.P X X
pp = {!!} | {
"alphanum_fraction": 0.4560301508,
"avg_line_length": 19.4146341463,
"ext": "agda",
"hexsha": "ad6aab2d832e215aa20babe8e8dc074875b572fe",
"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/NiceGoals.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/NiceGoals.agda",
"max_line_length": 72,
"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": "test/interaction/NiceGoals.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": 782,
"size": 2388
} |
open import FRP.JS.Nat using ( ℕ ; suc ; _+_ ; _≟_ ; _<_ )
open import FRP.JS.Array using ( Array ; IArray ; [] ; _∷_ ; array ; ⟨⟩ ; ⟨_ ; _,_ ; _⟩ ; lookup ; lookup? ; map ; filter ; _≟[_]_ ; _⊆[_]_ ; _++_ )
open import FRP.JS.Bool using ( Bool ; not )
open import FRP.JS.Maybe using ( Maybe ; just ; nothing ) renaming ( _≟[_]_ to _≟?[_]_ )
open import FRP.JS.QUnit using ( TestSuite ; ok ; test ; _,_ )
module FRP.JS.Test.Array where
infixr 2 _≟*_
_≟*_ : Array ℕ → Array ℕ → Bool
xs ≟* ys = xs ≟[ _≟_ ] ys
_⊆*_ : Array ℕ → Array ℕ → Bool
xs ⊆* ys = xs ⊆[ _≟_ ] ys
_≟?_ : Maybe ℕ → Maybe ℕ → Bool
xs ≟? ys = xs ≟?[ _≟_ ] ys
iincr : ∀ {m n} → IArray ℕ m n → IArray ℕ m n
iincr [] = []
iincr (n ∷ ns) = suc n ∷ iincr ns
incr : Array ℕ → Array ℕ
incr (array ns) = array (iincr ns)
⟨0⟩ = ⟨ 0 ⟩
⟨1⟩ = ⟨ 1 ⟩
⟨2⟩ = ⟨ 2 ⟩
⟨3⟩ = ⟨ 3 ⟩
⟨0,1⟩ = ⟨ 0 , 1 ⟩
⟨0,2⟩ = ⟨ 0 , 2 ⟩
⟨1,2⟩ = ⟨ 1 , 2 ⟩
⟨2,3⟩ = ⟨ 2 , 3 ⟩
⟨0,1,2⟩ = ⟨ 0 , 1 , 2 ⟩
tests : TestSuite
tests =
( test "≟"
( ok "⟨⟩ ≟ ⟨⟩" (⟨⟩ ≟* ⟨⟩)
, ok "⟨⟩ ≟ ⟨0⟩" (not (⟨⟩ ≟* ⟨0⟩))
, ok "⟨0⟩ ≟ ⟨⟩" (not (⟨0⟩ ≟* ⟨⟩))
, ok "⟨0⟩ ≟ ⟨0⟩" (⟨0⟩ ≟* ⟨0⟩)
, ok "⟨⟩ ≟ ⟨0,1⟩" (not (⟨⟩ ≟* ⟨0,1⟩))
, ok "⟨0,1⟩ ≟ ⟨⟩" (not (⟨0,1⟩ ≟* ⟨⟩))
, ok "⟨1⟩ ≟ ⟨0,1⟩" (not (⟨1⟩ ≟* ⟨0,1⟩))
, ok "⟨0⟩ ≟ ⟨0,1⟩" (not (⟨0⟩ ≟* ⟨0,1⟩))
, ok "⟨0,1⟩ ≟ ⟨0,1⟩" (⟨0,1⟩ ≟* ⟨0,1⟩)
, ok "⟨0,1⟩ ≟ ⟨0,2⟩" (not (⟨0,1⟩ ≟* ⟨0,2⟩))
, ok "⟨0,1⟩ ≟ ⟨1,2⟩" (not (⟨0,1⟩ ≟* ⟨1,2⟩)) )
, test "⊆"
( ok "⟨⟩ ⊆ ⟨⟩" (⟨⟩ ⊆* ⟨⟩)
, ok "⟨⟩ ⊆ ⟨0⟩" (⟨⟩ ⊆* ⟨0⟩)
, ok "⟨0⟩ ⊆ ⟨⟩" (not (⟨0⟩ ⊆* ⟨⟩))
, ok "⟨0⟩ ⊆ ⟨0⟩" (⟨0⟩ ⊆* ⟨0⟩)
, ok "⟨⟩ ⊆ ⟨0,1⟩" (⟨⟩ ⊆* ⟨0,1⟩)
, ok "⟨0,1⟩ ⊆ ⟨⟩" (not (⟨0,1⟩ ⊆* ⟨⟩))
, ok "⟨1⟩ ⊆ ⟨0,1⟩" (not (⟨1⟩ ⊆* ⟨0,1⟩))
, ok "⟨0⟩ ⊆ ⟨0,1⟩" (⟨0⟩ ⊆* ⟨0,1⟩)
, ok "⟨0,1⟩ ⊆ ⟨0,1⟩" (⟨0,1⟩ ⊆* ⟨0,1⟩)
, ok "⟨0,1⟩ ⊆ ⟨0,2⟩" (not (⟨0,1⟩ ⊆* ⟨0,2⟩))
, ok "⟨0,1⟩ ⊆ ⟨1,2⟩" (not (⟨0,1⟩ ⊆* ⟨1,2⟩)) )
, test "++"
( ok "⟨⟩ ++ ⟨⟩" (⟨⟩ ++ ⟨⟩ ≟* ⟨⟩)
, ok "⟨⟩ ++ ⟨2⟩" (⟨⟩ ++ ⟨2⟩ ≟* ⟨2⟩)
, ok "⟨⟩ ++ ⟨1,2⟩" (⟨⟩ ++ ⟨1,2⟩ ≟* ⟨1,2⟩)
, ok "⟨0⟩ ++ ⟨⟩" (⟨0⟩ ++ ⟨⟩ ≟* ⟨0⟩)
, ok "⟨0⟩ ++ ⟨2⟩" (⟨0⟩ ++ ⟨2⟩ ≟* ⟨0,2⟩)
, ok "⟨0⟩ ++ ⟨1,2⟩" (⟨0⟩ ++ ⟨1,2⟩ ≟* ⟨0,1,2⟩)
, ok "⟨0,1⟩ ++ ⟨⟩" (⟨0,1⟩ ++ ⟨⟩ ≟* ⟨0,1⟩)
, ok "⟨0,1⟩ ++ ⟨2⟩" (⟨0,1⟩ ++ ⟨2⟩ ≟* ⟨0,1,2⟩) )
, test "lookup"
( ok "lookup? ⟨1,2⟩ 0" (lookup? ⟨1,2⟩ 0 ≟? just 1)
, ok "lookup? ⟨1,2⟩ 1" (lookup? ⟨1,2⟩ 1 ≟? just 2)
, ok "lookup? ⟨1,2⟩ 2" (lookup? ⟨1,2⟩ 2 ≟? nothing)
, ok "lookup ⟨1,2⟩ 0" (lookup ⟨1,2⟩ 0 ≟ 1)
, ok "lookup ⟨1,2⟩ 1" (lookup ⟨1,2⟩ 1 ≟ 2) )
, test "map"
( ok "map suc ⟨⟩" (map suc ⟨⟩ ≟* ⟨⟩)
, ok "map suc ⟨1⟩" (map suc ⟨1⟩ ≟* ⟨2⟩)
, ok "map suc ⟨1,2⟩" (map suc ⟨1,2⟩ ≟* ⟨2,3⟩)
, ok "incr ⟨⟩" (map suc ⟨⟩ ≟* incr ⟨⟩)
, ok "incr ⟨1⟩" (map suc ⟨1⟩ ≟* incr ⟨1⟩)
, ok "incr ⟨1,2⟩" (map suc ⟨1,2⟩ ≟* incr ⟨1,2⟩) )
, test "filter"
( ok "filter 0< ⟨1,2⟩" (filter (_<_ 0) ⟨1,2⟩ ≟* ⟨1,2⟩)
, ok "filter 1< ⟨1,2⟩" (filter (_<_ 1) ⟨1,2⟩ ≟* ⟨2⟩)
, ok "filter 2< ⟨1,2⟩" (filter (_<_ 2) ⟨1,2⟩ ≟* ⟨⟩) ) )
| {
"alphanum_fraction": 0.3555114201,
"avg_line_length": 33.9438202247,
"ext": "agda",
"hexsha": "87aef6fb9b6801059c78b16edd74ffeed2185bb5",
"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/Array.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/Array.agda",
"max_line_length": 148,
"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/Array.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": 1811,
"size": 3021
} |
variable
S : Set
data D (A : Set) : Set1 where
d : S → D A
| {
"alphanum_fraction": 0.53125,
"avg_line_length": 10.6666666667,
"ext": "agda",
"hexsha": "9804b1c79841a6e1412448dfe80adc6a262c17b4",
"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/GeneralizeIssue1.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/GeneralizeIssue1.agda",
"max_line_length": 29,
"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/GeneralizeIssue1.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": 27,
"size": 64
} |
-- Andreas, 2020-04-19, issue #4560, raised by Andrea
-- Having both matching on constructor and copattern matching
-- for non-eta records leads to loss of subject reduction.
open import Agda.Builtin.Equality
postulate
A : Set
a : A
record R : Set where
constructor con
no-eta-equality
field
X Y : A
foo : R → A
foo (con x y) = x
-- Expected error here:
-- Pattern matching on no-eta record types is by default not allowed
-- when checking that the pattern con x y has type R
bar : R
bar .R.X = a
bar .R.Y = a
test : foo bar ≡ a
test = refl
-- Problem was:
-- foo bar != a of type A
-- when checking that the expression refl has type foo bar ≡ a
| {
"alphanum_fraction": 0.6856287425,
"avg_line_length": 19.6470588235,
"ext": "agda",
"hexsha": "c727eb2b2cd9f7d6821989ca97ce06f484f8dd6e",
"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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue4560NoPatternMatchingWithoutEta.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2020-05-29T19:45:38.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-05-29T19:45:38.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue4560NoPatternMatchingWithoutEta.agda",
"max_line_length": 68,
"max_stars_count": 1,
"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/Issue4560NoPatternMatchingWithoutEta.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-14T11:08:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-14T11:08:59.000Z",
"num_tokens": 198,
"size": 668
} |
open import Prelude
open import core
open import contexts
module lemmas-freshG where
-- the def above buries the sort of obvious pattern matching we'd like to
-- do on the freshness in the conclusion, so we need lemmas that extract
-- it for each constructor
freshΓ-asc : {A : Set} → {Γ : A ctx} → ∀{e τ} → freshΓ Γ (e ·: τ) → freshΓ Γ e
freshΓ-asc fr x x₁ with fr x x₁
freshΓ-asc fr x x₁ | FRHAsc qq = qq
freshΓ-ap1 : {A : Set} → {Γ : A ctx} → ∀{e1 e2} → freshΓ Γ (e1 ∘ e2) → freshΓ Γ e1
freshΓ-ap1 fr x y with fr x y
freshΓ-ap1 fr x y | FRHAp qq qq₁ = qq
freshΓ-ap2 : {A : Set} → {Γ : A ctx} → ∀{e1 e2} → freshΓ Γ (e1 ∘ e2) → freshΓ Γ e2
freshΓ-ap2 fr x y with fr x y
freshΓ-ap2 fr x y | FRHAp qq qq₁ = qq₁
freshΓ-nehole : {A : Set} → {Γ : A ctx} → ∀{e u} → freshΓ Γ (⦇⌜ e ⌟⦈[ u ]) → freshΓ Γ e
freshΓ-nehole fr x y with fr x y
freshΓ-nehole fr x y | FRHNEHole qq = qq
freshΓ-lam1 : {A : Set} → {Γ : A ctx} → ∀{e x} → freshΓ Γ (·λ x e) → freshΓ Γ e
freshΓ-lam1 fr x y with fr x y
freshΓ-lam1 fr x y | FRHLam1 x₂ qq = qq
freshΓ-lam2 : {A : Set} → {Γ : A ctx} → ∀{e τ x} → freshΓ Γ (·λ_[_]_ x τ e) → freshΓ Γ e
freshΓ-lam2 fr x y with fr x y
freshΓ-lam2 fr x y | FRHLam2 x₂ qq = qq
lem-fresh-lam1 : ∀{x e} → freshe x (·λ x e) → ⊥
lem-fresh-lam1 (FRHLam1 x₁ f) = x₁ refl
lem-fresh-lam2 : ∀{x τ e} → freshe x (·λ x [ τ ] e) → ⊥
lem-fresh-lam2 (FRHLam2 x₁ f) = x₁ refl
freshΓ-pair1 : {A : Set} → {Γ : A ctx} → ∀{e1 e2} → freshΓ Γ ⟨ e1 , e2 ⟩ → freshΓ Γ e1
freshΓ-pair1 fr x y with fr x y
freshΓ-pair1 fr x y | FRHPair qq qq₁ = qq
freshΓ-pair2 : {A : Set} → {Γ : A ctx} → ∀{e1 e2} → freshΓ Γ ⟨ e1 , e2 ⟩ → freshΓ Γ e2
freshΓ-pair2 fr x y with fr x y
freshΓ-pair2 fr x y | FRHPair qq qq₁ = qq₁
freshΓ-fst : {A : Set} → {Γ : A ctx} → ∀{e} → freshΓ Γ (fst e) → freshΓ Γ e
freshΓ-fst fr x x₁ with fr x x₁
freshΓ-fst fr x x₁ | FRHFst qq = qq
freshΓ-snd : {A : Set} → {Γ : A ctx} → ∀{e} → freshΓ Γ (snd e) → freshΓ Γ e
freshΓ-snd fr x x₁ with fr x x₁
freshΓ-snd fr x x₁ | FRHSnd qq = qq
fresh-freshΓ : {A : Set} {τ : A} → ∀{x e} → freshe x e → freshΓ (■ (x , τ)) e
fresh-freshΓ fr x y with lem-dom-eq y
fresh-freshΓ fr x y | refl = fr
| {
"alphanum_fraction": 0.5834084761,
"avg_line_length": 38.2413793103,
"ext": "agda",
"hexsha": "2dc307cf6ccda23a09c4417566547145a2521c54",
"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": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda",
"max_forks_repo_path": "lemmas-freshG.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazel-palette-agda",
"max_issues_repo_path": "lemmas-freshG.agda",
"max_line_length": 90,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazel-palette-agda",
"max_stars_repo_path": "lemmas-freshG.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z",
"num_tokens": 1056,
"size": 2218
} |
open import Data.Nat --using (ℕ; suc; zero; _≤?_; _≤_; s≤s; z≤n)
open import Data.Bool using (true; false)
--open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Relation.Nullary -- using (Dec; yes; no; _because_)
open import Relation.Nullary.Decidable --using (True; fromWitness)
--open import Data.Unit using (tt)
-- stack exec -- agda -c --ghc-dont-call-ghc --no-main nats.agda
data Maybe (A : Set) : Set where
nothing : Maybe A
just : (x : A) → Maybe A
{-# COMPILE GHC Maybe = data Maybe (Nothing | Just) #-}
n-3 : (n : ℕ) → .{3≤n : True (3 ≤? n)} → ℕ
n-3 (suc (suc (suc n))) = n
exportFunc : ℕ → Maybe ℕ
exportFunc n with 3 ≤? n
... | yes 3≤n = just (n-3 n {fromWitness 3≤n})
... | no ¬3≤n = nothing
{-# COMPILE GHC exportFunc as exportFunc #-}
| {
"alphanum_fraction": 0.6383248731,
"avg_line_length": 34.2608695652,
"ext": "agda",
"hexsha": "7320e15cd6531ced0cf4018986523d96eadb5b0c",
"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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "helq/old_code",
"max_forks_repo_path": "proglangs-learning/Agda/reals-with-restrictions/nats.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z",
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "helq/old_code",
"max_issues_repo_path": "proglangs-learning/Agda/reals-with-restrictions/nats.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "helq/old_code",
"max_stars_repo_path": "proglangs-learning/Agda/reals-with-restrictions/nats.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 277,
"size": 788
} |
module dependentProduct2 where
postulate A : Set
postulate B : A -> Set
data AB : Set where
p : (a : A) -> B a -> AB
π0 : AB -> A
π0 (p a b) = a
π1 : (ab : AB) -> B (π0 ab)
π1 (p a b) = b
postulate a : A
postulate b : B a
ab : AB
ab = p a b
postulate ab' : AB
a' : A
a' = π0 ab'
b' : B a'
b' = π1 ab'
| {
"alphanum_fraction": 0.5125,
"avg_line_length": 9.4117647059,
"ext": "agda",
"hexsha": "ff32294fc938a8e290823b71bcb7e671ff96293d",
"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": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/dependentProduct2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"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": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/dependentProduct2.agda",
"max_line_length": 30,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/dependentProduct2.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 137,
"size": 320
} |
------------------------------------------------------------------------
-- M-types for indexed containers, defined coinductively (in Cubical
-- Agda)
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe --guardedness #-}
import Equality.Path as P
module Container.Indexed.M.Codata
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection equality-with-J using (_↔_)
open import Container.Indexed equality-with-J
import Container.Indexed.M.Function equality-with-J as F
import Container.Indexed.Variant equality-with-J as V
open import Container.Indexed.Variant.M.Codata eq as VM using (out-M)
open import Equality.Path.Isomorphisms eq
open import Equivalence equality-with-J as Eq using (_≃_)
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 Univalence-axiom equality-with-J
private
variable
a iℓ s p : Level
A I : Type a
i x : A
C : Container I s p
n : ℕ
------------------------------------------------------------------------
-- The M-type and some basic results
-- An M-type for a given container.
--
-- This definition is similar to one in "Indexed containers" by
-- Altenkirch, Ghani, Hancock, McBride and Morris.
record M {I : Type iℓ} (C : Container I s p) (i : I) :
Type (iℓ ⊔ s ⊔ p) where
coinductive
constructor in-M
field
out-M : ⟦ C ⟧ (M C) i
open M public
-- An η-law.
η : in-M (out-M x) ≡ x
η = _↔_.from ≡↔≡ η′
where
η′ : in-M (out-M x) P.≡ x
η′ {x = x} _ .out-M = x .out-M
-- M C is, in a certain sense, a fixpoint of ⟦ C ⟧.
M-fixpoint : ⟦ C ⟧ (M C) i ≃ M C i
M-fixpoint = Eq.↔→≃ in-M out-M (λ _ → η) refl
-- A coalgebra defined using M and out-M.
M-coalgebra : (C : Container I s p) → Coalgebra C
M-coalgebra C = M C , λ _ → out-M
------------------------------------------------------------------------
-- Some conversion lemmas
-- One can convert between M and VM.M.
M≃M :
∀ p {I : Type i} {C : V.Container I s (i ⊔ p)} {i} →
M (_⇔_.to (V.Container⇔Container p) C) i ≃ VM.M C i
M≃M p {C = C} =
Eq.↔→≃ to from
(λ c → _↔_.from ≡↔≡ (to-from c))
(λ c → _↔_.from ≡↔≡ (from-to c))
where
to : M (_⇔_.to (V.Container⇔Container p) C) i → VM.M C i
to x .out-M .proj₁ = x .out-M .proj₁
to x .out-M .proj₂ i p = to (x .out-M .proj₂ (i , p))
from : VM.M C i → M (_⇔_.to (V.Container⇔Container p) C) i
from x .out-M .proj₁ = x .out-M .proj₁
from x .out-M .proj₂ (i , p) = from (x .out-M .proj₂ i p)
to-from : (x : VM.M C i) → to (from x) P.≡ x
to-from x i .out-M .proj₁ = x .out-M .proj₁
to-from x i .out-M .proj₂ j p = to-from (x .out-M .proj₂ j p) i
from-to :
(x : M (_⇔_.to (V.Container⇔Container p) C) i) →
from (to x) P.≡ x
from-to x i .out-M .proj₁ = x .out-M .proj₁
from-to x i .out-M .proj₂ p = from-to (x .out-M .proj₂ p) i
-- M-coalgebra is related to VM.M-coalgebra (assuming univalence).
M-coalgebra≡M-coalgebra :
∀ p {I : Type i} (C : V.Container I s (i ⊔ p)) →
Univalence (i ⊔ s ⊔ p) →
M-coalgebra (_⇔_.to (V.Container⇔Container p) C) ≡
_≃_.to (V.Coalgebra≃Coalgebra p C ext) (VM.M-coalgebra C)
M-coalgebra≡M-coalgebra p C univ =
Σ-≡,≡→≡
(⟨ext⟩ lemma₁)
(⟨ext⟩ λ i → ⟨ext⟩ λ x →
subst (λ P → P ⇾ ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P)
(⟨ext⟩ lemma₁) (λ _ → out-M) i x ≡⟨ cong (_$ x) $ sym $
push-subst-application _ _ ⟩
subst (λ P → P i → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i)
(⟨ext⟩ lemma₁) out-M x ≡⟨ subst-→ ⟩
subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i)
(⟨ext⟩ lemma₁)
(subst (_$ i) (sym (⟨ext⟩ lemma₁)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i) _) $
cong out-M $
cong (flip (subst (_$ i)) _) $ sym $
ext-sym lemma₁ ⟩
subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i)
(⟨ext⟩ lemma₁)
(subst (_$ i) (⟨ext⟩ (sym ∘ lemma₁)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i) _) $
cong out-M $
subst-ext id (sym ∘ lemma₁) ⟩
subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i)
(⟨ext⟩ lemma₁)
(subst id (sym (lemma₁ i)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i) _) $
cong out-M $
subst-id-in-terms-of-inverse∘≡⇒↝ equivalence {A≡B = lemma₁ i} ⟩
subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i)
(⟨ext⟩ lemma₁)
(_≃_.from (≡⇒≃ (lemma₁ i)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i) _) $
cong (λ (eq : M (_⇔_.to (V.Container⇔Container p) C) i ≃ VM.M C i) →
_≃_.from eq x .out-M) $
_≃_.right-inverse-of (≡≃≃ univ) _ ⟩
subst (λ P → ⟦ _⇔_.to (V.Container⇔Container p) C ⟧ P i)
(⟨ext⟩ lemma₁)
(_≃_.from (M≃M p {i = i}) x .out-M) ≡⟨⟩
subst (λ P → ∃ λ (s : V.Shape C i) →
((i , _) : ∃ (V.Position C s)) → P i)
(⟨ext⟩ lemma₁)
(_≃_.from (M≃M p {i = i}) x .out-M) ≡⟨ push-subst-pair-× _ _ ⟩
( x .out-M .proj₁
, subst (λ P → ((i , _) : ∃ (V.Position C (x .out-M .proj₁))) →
P i)
(⟨ext⟩ lemma₁)
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂)
) ≡⟨ cong (x .out-M .proj₁ ,_) $
⟨ext⟩ (lemma₃ i x) ⟩∎
Σ-map id uncurry (x .out-M) ∎)
where
lemma₁ = λ _ → ≃⇒≡ univ (M≃M p)
lemma₂ : ∀ _ _ _ → _
lemma₂ _ _ p =
sym (Σ-≡,≡→≡ (sym (⟨ext⟩ lemma₁)) (refl p′)) ≡⟨ cong sym $ cong (Σ-≡,≡→≡ (sym (⟨ext⟩ lemma₁))) $ sym $
trans-symʳ _ ⟩
sym (Σ-≡,≡→≡ (sym (⟨ext⟩ lemma₁))
(trans (subst-const _) (sym (subst-const _)))) ≡⟨ cong sym $ Σ-≡,≡→≡-subst-const _ _ ⟩
sym (cong₂ _,_ (sym (⟨ext⟩ lemma₁)) (sym (subst-const _))) ≡⟨ cong sym cong₂-sym ⟩
sym (sym (cong₂ _,_ (⟨ext⟩ lemma₁) (subst-const _))) ≡⟨ sym-sym _ ⟩∎
cong₂ _,_ (⟨ext⟩ lemma₁) (subst-const _) ∎
where
p′ = subst (const _) (sym (⟨ext⟩ lemma₁)) p
lemma₃ : ∀ _ _ _ → _
lemma₃ i x (i′ , p′) =
subst (λ P → ((i , _) : ∃ _) → P i)
(⟨ext⟩ lemma₁)
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂)
(i′ , p′) ≡⟨ subst-∀ ⟩
subst (λ ((P , i , _) : _ × ∃ _) → P i)
(sym $ Σ-≡,≡→≡ (sym (⟨ext⟩ lemma₁)) (refl _))
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ $
subst (const _) (sym (⟨ext⟩ lemma₁)) (i′ , p′)) ≡⟨ cong (flip (subst (λ ((P , i , _) : _ × ∃ _) → P i)) _) $
lemma₂ i x _ ⟩
subst (λ ((P , i , _) : _ × ∃ _) → P i)
(cong₂ _,_ (⟨ext⟩ lemma₁) (subst-const _))
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ $
subst (const _) (sym (⟨ext⟩ lemma₁)) (i′ , p′)) ≡⟨ elim₁
(λ {q} eq →
subst (λ ((P , i , _) : _ × ∃ _) → P i)
(cong₂ _,_ (⟨ext⟩ lemma₁) eq)
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ q) ≡
subst (λ ((P , i , _) : _ × ∃ (V.Position C (x .out-M .proj₁))) → P i)
(cong₂ {u = i′ , p′} _,_ (⟨ext⟩ lemma₁) (refl _))
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ (i′ , p′)))
(refl _)
_ ⟩
subst (λ ((P , i , _) : _ × ∃ _) → P i)
(cong₂ _,_ (⟨ext⟩ lemma₁) (refl _))
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ (i′ , p′)) ≡⟨ cong (flip (subst (λ ((P , i , _) : _ × ∃ _) → P i)) _) $
cong₂-reflʳ _ ⟩
subst (λ ((P , i , _) : _ × ∃ _) → P i)
(cong (_, i′ , p′) (⟨ext⟩ lemma₁))
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ (i′ , p′)) ≡⟨ sym $ subst-∘ _ _ _ ⟩
subst (_$ i′) (⟨ext⟩ lemma₁)
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ (i′ , p′)) ≡⟨ subst-ext _ _ ⟩
subst id (lemma₁ i′)
(_≃_.from (M≃M p {i = i}) x .out-M .proj₂ (i′ , p′)) ≡⟨⟩
subst id (≃⇒≡ univ (M≃M p {i = i′}))
(_≃_.from (M≃M p {i = i′}) (x .out-M .proj₂ i′ p′)) ≡⟨ subst-id-in-terms-of-≡⇒↝ equivalence ⟩
_≃_.to (≡⇒≃ (≃⇒≡ univ (M≃M p {i = i′})))
(_≃_.from (M≃M p {i = i′}) (x .out-M .proj₂ i′ p′)) ≡⟨ cong (λ eq → _≃_.to eq (_≃_.from (M≃M p {i = i′}) (x .out-M .proj₂ i′ p′))) $
_≃_.right-inverse-of (≡≃≃ univ) _ ⟩
_≃_.to (M≃M p {i = i′})
(_≃_.from (M≃M p {i = i′}) (x .out-M .proj₂ i′ p′)) ≡⟨ _≃_.right-inverse-of (M≃M p {i = i′}) _ ⟩
x .out-M .proj₂ i′ p′ ≡⟨⟩
Σ-map id uncurry (x .out-M) .proj₂ (i′ , p′) ∎
------------------------------------------------------------------------
-- Lemmas related to lift-positions
-- Lifting the position type family using lift-positions does not
-- affect the resulting M type (up to pointwise equivalence).
M≃M-lift-positions : M C i ≃ M (lift-positions C) i
M≃M-lift-positions =
Eq.↔→≃ to from
(λ c → _↔_.from ≡↔≡ (to-from c))
(λ c → _↔_.from ≡↔≡ (from-to c))
where
to : M C i → M (lift-positions C) i
to x .out-M .proj₁ = x .out-M .proj₁
to x .out-M .proj₂ (lift p) = to (x .out-M .proj₂ p)
from : M (lift-positions C) i → M C i
from x .out-M .proj₁ = x .out-M .proj₁
from x .out-M .proj₂ p = from (x .out-M .proj₂ (lift p))
to-from : (x : M (lift-positions C) i) → to (from x) P.≡ x
to-from x i .out-M .proj₁ = x .out-M .proj₁
to-from x i .out-M .proj₂ p = to-from (x .out-M .proj₂ p) i
from-to : (x : M C i) → from (to x) P.≡ x
from-to x i .out-M .proj₁ = x .out-M .proj₁
from-to x i .out-M .proj₂ p = from-to (x .out-M .proj₂ p) i
-- M-coalgebra C is related to M-coalgebra (lift-positions C)
-- (assuming univalence).
≡M-coalgebra-lift-positions :
{I : Type i} {C : Container I s p} →
Univalence (i ⊔ s ⊔ p) →
Coalgebra≃Coalgebra-lift-positions _ (M-coalgebra C) ≡
M-coalgebra (lift-positions C)
≡M-coalgebra-lift-positions {C = C} univ =
Σ-≡,≡→≡
(⟨ext⟩ lemma)
(⟨ext⟩ λ i → ⟨ext⟩ λ x →
subst (λ P → P ⇾ ⟦ lift-positions C ⟧ P)
(⟨ext⟩ lemma)
((Σ-map id (_∘ lower) ∘_) ∘ (λ _ → out-M))
i x ≡⟨ cong (_$ x) $ sym $
push-subst-application _ _ ⟩
subst (λ P → P i → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma) (Σ-map id (_∘ lower) ∘ out-M) x ≡⟨ subst-→ ⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
(Σ-map id (_∘ lower) $
subst (_$ i) (sym (⟨ext⟩ lemma)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ lift-positions C ⟧ P i) _) $
cong (Σ-map id (_∘ lower)) $ cong out-M $
cong (flip (subst (_$ i)) _) $ sym $
ext-sym lemma ⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
(Σ-map id (_∘ lower) $
subst (_$ i) (⟨ext⟩ (sym ∘ lemma)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ lift-positions C ⟧ P i) _) $
cong (Σ-map id (_∘ lower)) $ cong out-M $
subst-ext id (sym ∘ lemma) ⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
(Σ-map id (_∘ lower) $
subst id (sym (lemma i)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ lift-positions C ⟧ P i) _) $
cong (Σ-map id (_∘ lower)) $ cong out-M $
subst-id-in-terms-of-inverse∘≡⇒↝ equivalence {A≡B = lemma i} ⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
(Σ-map id (_∘ lower) $
_≃_.from (≡⇒≃ (lemma i)) x .out-M) ≡⟨ cong (subst (λ P → ⟦ lift-positions C ⟧ P i) _) $
cong (λ (eq : M C i ≃ M (lift-positions C) i) →
Σ-map id (_∘ lower) (_≃_.from eq x .out-M)) $
_≃_.right-inverse-of (≡≃≃ univ) _ ⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
(Σ-map id (_∘ lower) $
_≃_.from M≃M-lift-positions x .out-M) ≡⟨⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
( x .out-M .proj₁
, _≃_.from M≃M-lift-positions ∘ x .out-M .proj₂
) ≡⟨ (cong (subst (λ P → ⟦ lift-positions C ⟧ P i) _) $ cong (_ ,_) $
⟨ext⟩ λ p →
cong (λ eq → _≃_.from eq (x .out-M .proj₂ p)) $ sym $
_≃_.right-inverse-of (≡≃≃ univ) _) ⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
( x .out-M .proj₁
, _≃_.from (≡⇒≃ (lemma _)) ∘ x .out-M .proj₂
) ≡⟨ (cong (subst (λ P → ⟦ lift-positions C ⟧ P i) _) $ cong (_ ,_) $
⟨ext⟩ λ p →
cong (λ (f : ∀ i → M C i ≡ M (lift-positions C) i) →
_≃_.from (≡⇒≃ (f _)) (x .out-M .proj₂ p)) $ sym $
_≃_.left-inverse-of (Eq.extensionality-isomorphism bad-ext) _) ⟩
subst (λ P → ⟦ lift-positions C ⟧ P i)
(⟨ext⟩ lemma)
( x .out-M .proj₁
, _≃_.from (≡⇒≃ (ext⁻¹ (⟨ext⟩ lemma) _)) ∘ x .out-M .proj₂
) ≡⟨ elim₁
(λ eq →
subst (λ P → ⟦ lift-positions C ⟧ P i)
eq
( x .out-M .proj₁
, _≃_.from (≡⇒≃ (ext⁻¹ eq _)) ∘ x .out-M .proj₂
) ≡
x .out-M)
(
subst (λ P → ⟦ lift-positions C ⟧ P i)
(refl _)
( x .out-M .proj₁
, _≃_.from (≡⇒≃ (ext⁻¹ (refl (M (lift-positions C))) _)) ∘
x .out-M .proj₂
) ≡⟨ subst-refl _ _ ⟩
x .out-M .proj₁
, _≃_.from (≡⇒≃ (ext⁻¹ (refl (M (lift-positions C))) _)) ∘
x .out-M .proj₂ ≡⟨ (cong (_ ,_) $ ⟨ext⟩ λ p →
cong (λ eq → _≃_.from eq (x .out-M .proj₂ p)) $
trans (cong ≡⇒≃ $ ext⁻¹-refl (M (lift-positions C))) $
≡⇒↝-refl) ⟩∎
x .out-M ∎)
(⟨ext⟩ lemma) ⟩∎
x .out-M ∎)
where
lemma = λ _ → ≃⇒≡ univ M≃M-lift-positions
------------------------------------------------------------------------
-- Finality
private
-- M-coalgebra C is sometimes a final coalgebra (assuming
-- univalence). Note that the last index argument of C is not
-- unrestricted.
M-final′ :
∀ p {I : Type i} {C : Container I s (i ⊔ p)} →
Univalence (i ⊔ s ⊔ p) →
Univalence (i ⊔ p) →
Final′ (M-coalgebra C)
M-final′ p {C = C} univ₁ univ₂ = $⟨ VM.M-final′ C′ ⟩
V.Final′ (VM.M-coalgebra C′) ↝⟨ subst V.Final′ $ sym $ _≃_.to-from C≃C $ sym $
M-coalgebra≡M-coalgebra p C′ univ₁ ⟩
V.Final′ (_≃_.from C≃C (M-coalgebra (_⇔_.to C⇔C C′))) ↔⟨ V.Final′≃Final′ p C′ ext ext
(_≃_.from C≃C (M-coalgebra (_⇔_.to C⇔C C′))) ⟩
Final′ (_≃_.to C≃C $ _≃_.from C≃C $ M-coalgebra (_⇔_.to C⇔C C′)) ↝⟨ subst Final′ (_≃_.right-inverse-of C≃C (M-coalgebra (_⇔_.to C⇔C C′))) ⟩
Final′ (M-coalgebra (_⇔_.to C⇔C C′)) ↝⟨ subst (Final′ ∘ M-coalgebra) $
_≃_.right-inverse-of (V.Container≃Container p ext univ₂) _ ⟩□
Final′ (M-coalgebra C) □
where
C⇔C = V.Container⇔Container p
C′ = _⇔_.from C⇔C C
C≃C = V.Coalgebra≃Coalgebra p C′ ext
-- M-coalgebra C is sometimes a final coalgebra (assuming univalence).
-- Note that the last index argument of C is not unrestricted.
M-final″ :
∀ p {I : Type i} {C : Container I s (i ⊔ p)} →
Univalence (i ⊔ s ⊔ p) →
Univalence (i ⊔ p) →
Final (M-coalgebra C)
M-final″ p {C = C} univ₁ univ₂ =
block λ b →
Final′→Final
ext
( F.M-coalgebra b ext C
, F.M-final b ext ext
)
( M-coalgebra C
, M-final′ p univ₁ univ₂
)
-- M-coalgebra C is a final coalgebra (assuming univalence).
--
-- TODO: Can this be proved directly, without using VM.M-final′ or
-- univalence?
M-final :
{I : Type i} {C : Container I s p} →
Univalence (i ⊔ s ⊔ p) →
Univalence (i ⊔ p) →
Final (M-coalgebra C)
M-final {p = p} {C = C} univ₁ univ₂ = $⟨ M-final″ p univ₁ univ₂ ⟩
Final (M-coalgebra (lift-positions C)) ↔⟨⟩
(∀ Y → Contractible (Y ⇨ M-coalgebra (lift-positions C))) ↝⟨ (Π-cong-contra-→ (Coalgebra≃Coalgebra-lift-positions _) λ Y →
H-level-cong _ 0 (
Coalgebra≃Coalgebra-lift-positions _ Y ⇨
M-coalgebra (lift-positions C) ↝⟨ ≡⇒↝ _ $ cong (Coalgebra≃Coalgebra-lift-positions _ Y ⇨_) $ sym $
≡M-coalgebra-lift-positions univ₁ ⟩
Coalgebra≃Coalgebra-lift-positions _ Y ⇨
Coalgebra≃Coalgebra-lift-positions _ (M-coalgebra C) ↝⟨ inverse $ ⇨≃⇨-lift-positions ext _ (M-coalgebra C) ⟩□
Y ⇨ M-coalgebra C □)) ⟩
(∀ Y → Contractible (Y ⇨ M-coalgebra C)) ↔⟨⟩
Final (M-coalgebra C) □
------------------------------------------------------------------------
-- H-levels
-- If the shape types of C have h-level n, then M C i has h-level n
-- (assuming univalence).
H-level-M :
{I : Type i} {C : Container I s p} →
Univalence (i ⊔ s ⊔ p) →
Univalence (i ⊔ p) →
(∀ i → H-level n (Shape C i)) →
∀ {i} → H-level n (M C i)
H-level-M {C = C} univ₁ univ₂ h =
F.H-level-final-coalgebra
ext
(M-coalgebra C , M-final univ₁ univ₂)
h
| {
"alphanum_fraction": 0.3775556982,
"avg_line_length": 48.3680709534,
"ext": "agda",
"hexsha": "f576746780015e274a6cf4b7789ee97ae471cfdf",
"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/Container/Indexed/M/Codata.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/Container/Indexed/M/Codata.agda",
"max_line_length": 144,
"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/Container/Indexed/M/Codata.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": 6907,
"size": 21814
} |
module Data.Strict.Primitive where
data Strict (A : Set) : Set where
! : A → Strict A
{-# IMPORT Data.Strict.AgdaFFI #-}
{-# COMPILED_DATA Strict Data.Strict.AgdaFFI.Strict Data.Strict.AgdaFFI.Strict #-}
| {
"alphanum_fraction": 0.7115384615,
"avg_line_length": 26,
"ext": "agda",
"hexsha": "d559b17c69c1a391aa4928d9a07f5182415a0b01",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/Data/Strict/Primitive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"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": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/Data/Strict/Primitive.agda",
"max_line_length": 82,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/Data/Strict/Primitive.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z",
"num_tokens": 56,
"size": 208
} |
------------------------------------------------------------------------------
-- Definition of FOTC streams using the Agda co-inductive combinators
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Data.Stream.TypeSL where
open import Codata.Musical.Notation
open import Data.Product renaming ( _×_ to _∧_ )
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------------
-- We add 3 to the fixities of the Agda standard library 0.8.1 (see
-- Data/List.agda).
infixr 8 _∷_
data D : Set where
_∷_ : D → D → D
data Stream : D → Set where
consS : ∀ x {xs} → ∞ (Stream xs) → Stream (x ∷ xs)
Stream-out : ∀ {xs} → Stream xs →
∃ λ x' → ∃ λ xs' → Stream xs' ∧ xs ≡ x' ∷ xs'
Stream-out (consS x' {xs'} Sxs') = x' , xs' , ♭ Sxs' , refl
{-# NON_TERMINATING #-}
Stream-coind :
(A : D → Set) →
(∀ {xs} → A xs → ∃ λ x' → ∃ λ xs' → xs ≡ x' ∷ xs' ∧ A xs') →
∀ {xs} → A xs → Stream xs
Stream-coind A h Axs with h Axs
... | x' , xs' , prf₁ , Axs' = subst Stream (sym prf₁) prf₂
where
prf₂ : Stream (x' ∷ xs')
prf₂ = consS x' (♯ Stream-coind A h Axs')
| {
"alphanum_fraction": 0.4745387454,
"avg_line_length": 32.2619047619,
"ext": "agda",
"hexsha": "1e842938634c7b6ccbd0a017609fd36e183bf89f",
"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/FOT/FOTC/Data/Stream/TypeSL.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/FOT/FOTC/Data/Stream/TypeSL.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/FOT/FOTC/Data/Stream/TypeSL.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": 400,
"size": 1355
} |
module Numeral.Rational.SternBrocot where
| {
"alphanum_fraction": 0.880952381,
"avg_line_length": 21,
"ext": "agda",
"hexsha": "bca2a332538552a4c5f0610e1b30417574abcd30",
"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": "Numeral/Rational/SternBrocot.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": "Numeral/Rational/SternBrocot.agda",
"max_line_length": 41,
"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": "Numeral/Rational/SternBrocot.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": 11,
"size": 42
} |
module FFI.Data.Aeson where
open import Agda.Builtin.Bool using (Bool)
open import Agda.Builtin.String using (String)
open import FFI.Data.ByteString using (ByteString)
open import FFI.Data.HaskellString using (HaskellString; pack)
open import FFI.Data.Maybe using (Maybe)
open import FFI.Data.Either using (Either; mapLeft)
open import FFI.Data.Scientific using (Scientific)
open import FFI.Data.Vector using (Vector)
{-# FOREIGN GHC import qualified Data.Aeson #-}
{-# FOREIGN GHC import qualified Data.Aeson.Key #-}
{-# FOREIGN GHC import qualified Data.Aeson.KeyMap #-}
postulate
KeyMap : Set → Set
Key : Set
fromString : String → Key
toString : Key → String
lookup : ∀ {A} → Key -> KeyMap A -> Maybe A
{-# POLARITY KeyMap ++ #-}
{-# COMPILE GHC KeyMap = type Data.Aeson.KeyMap.KeyMap #-}
{-# COMPILE GHC Key = type Data.Aeson.Key.Key #-}
{-# COMPILE GHC fromString = Data.Aeson.Key.fromText #-}
{-# COMPILE GHC toString = Data.Aeson.Key.toText #-}
{-# COMPILE GHC lookup = \_ -> Data.Aeson.KeyMap.lookup #-}
data Value : Set where
object : KeyMap Value → Value
array : Vector Value → Value
string : String → Value
number : Scientific → Value
bool : Bool → Value
null : Value
{-# COMPILE GHC Value = data Data.Aeson.Value (Data.Aeson.Object|Data.Aeson.Array|Data.Aeson.String|Data.Aeson.Number|Data.Aeson.Bool|Data.Aeson.Null) #-}
Object = KeyMap Value
Array = Vector Value
postulate
decode : ByteString → Maybe Value
eitherHDecode : ByteString → Either HaskellString Value
{-# COMPILE GHC decode = Data.Aeson.decodeStrict #-}
{-# COMPILE GHC eitherHDecode = Data.Aeson.eitherDecodeStrict #-}
eitherDecode : ByteString → Either String Value
eitherDecode bytes = mapLeft pack (eitherHDecode bytes)
| {
"alphanum_fraction": 0.7263824885,
"avg_line_length": 34.0392156863,
"ext": "agda",
"hexsha": "a9082d31a25cf0900a184f054857e998bca8e252",
"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": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FreakingBarbarians/luau",
"max_forks_repo_path": "prototyping/FFI/Data/Aeson.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"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": "FreakingBarbarians/luau",
"max_issues_repo_path": "prototyping/FFI/Data/Aeson.agda",
"max_line_length": 154,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Tr4shh/Roblox-Luau",
"max_stars_repo_path": "prototyping/FFI/Data/Aeson.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z",
"num_tokens": 438,
"size": 1736
} |
------------------------------------------------------------------------
-- Various utility functions
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Utilities where
open import Data.Bool
open import Data.Bool.Properties using (T-∧)
open import Data.Char
import Data.Char.Properties as Char
open import Data.List
open import Data.List.NonEmpty as List⁺
open import Data.Nat
import Data.Nat.Properties as NP
open import Data.Product
open import Data.String as String using (String)
open import Function
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence
using () renaming (module Equivalence to Eq)
open import Relation.Binary
import Relation.Binary.Properties.StrictTotalOrder as STO
open import Relation.Nullary.Decidable
------------------------------------------------------------------------
-- Some comparison operators
-- Is one number strictly smaller than another?
_<?ℕ_ : ℕ → ℕ → Bool
n₁ <?ℕ n₂ = ⌊ n₁ NP.<? n₂ ⌋
-- Is one character smaller than or equal to another?
_≤?C_ : Char → Char → Bool
c₁ ≤?C c₂ = ⌊ DecTotalOrder._≤?_
(STO.decTotalOrder Char.<-strictTotalOrder)
c₁ c₂ ⌋
------------------------------------------------------------------------
-- Conversion of strings satisfying given predicates to annotated
-- lists
private
mutual
str′ : {p : Char → Bool}
(s : List Char) → T (all p s) → List (∃ (T ∘ p))
str′ [] _ = []
str′ (t ∷ ts) ok = List⁺.toList (str⁺′ (t ∷ ts) ok)
str⁺′ : {p : Char → Bool}
(s : List⁺ Char) → T (all p (List⁺.toList s)) →
List⁺ (∃ (T ∘ p))
str⁺′ (t ∷ ts) ok =
let (ok₁ , ok₂) = Eq.to T-∧ ⟨$⟩ ok in
(t , ok₁) ∷ str′ ts ok₂
str : {p : Char → Bool}
(s : String)
{ok : T (all p $ String.toList s)} →
List (∃ (T ∘ p))
str s {ok} = str′ (String.toList s) ok
str⁺ : {p : Char → Bool}
(s : String)
{ok₁ : T (all p $ String.toList s)}
{ok₂ : T (not $ null $ String.toList s)} →
List⁺ (∃ (T ∘ p))
str⁺ s {ok₂ = _} with String.toList s
str⁺ s {ok₂ = ()} | []
str⁺ s {ok₁ = ok} | c ∷ cs = str⁺′ (c ∷ cs) ok
| {
"alphanum_fraction": 0.5190735695,
"avg_line_length": 29.36,
"ext": "agda",
"hexsha": "f1ab593bfde7dfab97cad404bda580ba9983b8fe",
"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": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/pretty",
"max_forks_repo_path": "Utilities.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"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/pretty",
"max_issues_repo_path": "Utilities.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/pretty",
"max_stars_repo_path": "Utilities.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 630,
"size": 2202
} |
------------------------------------------------------------------------
-- Booleans
------------------------------------------------------------------------
{-# OPTIONS --guardedness #-}
module Examples.Bool where
open import Codata.Musical.Notation
open import Data.Bool
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Grammar.Infinite using (Grammar)
import Pretty
open import Renderer
module _ where
open Grammar.Infinite
bool : Grammar Bool
bool = true <$ string′ "true"
∣ false <$ string′ "false"
open Pretty
bool-printer : Pretty-printer bool
bool-printer true = left (<$ text)
bool-printer false = right (<$ text)
test₁ : render 4 (bool-printer true) ≡ "true"
test₁ = refl
test₂ : render 0 (bool-printer false) ≡ "false"
test₂ = refl
| {
"alphanum_fraction": 0.5855181024,
"avg_line_length": 22.25,
"ext": "agda",
"hexsha": "0e9b67207f7b2bccce6d43c696efcb23b9f508d6",
"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": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/pretty",
"max_forks_repo_path": "Examples/Bool.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"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/pretty",
"max_issues_repo_path": "Examples/Bool.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/pretty",
"max_stars_repo_path": "Examples/Bool.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 180,
"size": 801
} |
{-# OPTIONS --safe #-}
module Cubical.Categories.Additive.Instances.Terminal where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Categories.Category
open import Cubical.Categories.Additive.Base
open import Cubical.Categories.Instances.Discrete
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.AbGroup.Instances.Unit
open import Cubical.Data.Unit
private
variable
ℓ ℓ' : Level
open PreaddCategory
open PreaddCategoryStr
open AdditiveCategory
open AdditiveCategoryStr
private
terminalCategory : Category ℓ ℓ
terminalCategory = DiscreteCategory (Unit* , isOfHLevelUnit* 3)
terminalAbGroupStr : AbGroupStr {ℓ = ℓ} Unit*
terminalAbGroupStr = snd UnitAbGroup
homProp : (x y : Category.ob {ℓ = ℓ} terminalCategory) → isProp (terminalCategory [ x , y ])
homProp x y = isOfHLevelUnit* 2 x y
homContr : (x y : Category.ob {ℓ = ℓ} terminalCategory) → isContr (terminalCategory [ x , y ])
homContr x y = isProp→isContrPath (isOfHLevelUnit* 1) x y
terminalPreAdd : PreaddCategory ℓ ℓ
cat terminalPreAdd = terminalCategory
homAbStr (preadd terminalPreAdd) =
λ x y →
subst
AbGroupStr
(sym (isContr→≡Unit* (homContr x y)))
terminalAbGroupStr
⋆distl+ (preadd terminalPreAdd) = λ _ _ _ _ → refl
⋆distr+ (preadd terminalPreAdd) = λ _ _ _ → refl
terminalAdditiveCategory : AdditiveCategory ℓ ℓ
preaddcat terminalAdditiveCategory = terminalPreAdd
ZeroObject.z (zero (addit terminalAdditiveCategory)) = tt*
ZeroObject.zInit (zero (addit terminalAdditiveCategory)) y = homContr _ _
ZeroObject.zTerm (zero (addit terminalAdditiveCategory)) y = homContr _ _
biprod (addit terminalAdditiveCategory) x y = trivProd
where trivProd : Biproduct terminalPreAdd x y
Biproduct.x⊕y trivProd = tt*
Biproduct.i₁ trivProd = refl
Biproduct.i₂ trivProd = refl
Biproduct.π₁ trivProd = refl
Biproduct.π₂ trivProd = refl
IsBiproduct.i₁⋆π₁ (Biproduct.isBipr trivProd) = homProp _ _ _ _
IsBiproduct.i₁⋆π₂ (Biproduct.isBipr trivProd) = homProp _ _ _ _
IsBiproduct.i₂⋆π₁ (Biproduct.isBipr trivProd) = homProp _ _ _ _
IsBiproduct.i₂⋆π₂ (Biproduct.isBipr trivProd) = homProp _ _ _ _
IsBiproduct.∑π⋆i (Biproduct.isBipr trivProd) = homProp _ _ _ _
| {
"alphanum_fraction": 0.7345360825,
"avg_line_length": 34.7462686567,
"ext": "agda",
"hexsha": "3db94f28f40c5c1591aed1deab022e532f43ddfc",
"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/Additive/Instances/Terminal.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/Additive/Instances/Terminal.agda",
"max_line_length": 96,
"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/Additive/Instances/Terminal.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": 743,
"size": 2328
} |
------------------------------------------------------------------------
-- A view of the syntax
------------------------------------------------------------------------
module RecursiveTypes.Syntax.UnfoldedOrFixpoint where
open import RecursiveTypes.Syntax
open import RecursiveTypes.Substitution
-- Unfolded types, i.e. types where the outermost construction is
-- not a fixpoint.
infixr 10 _⟶_
data Unfolded {n} : Ty n → Set where
⊥ : Unfolded ⊥
⊤ : Unfolded ⊤
var : ∀ x → Unfolded (var x)
_⟶_ : (τ₁ τ₂ : Ty n) → Unfolded (τ₁ ⟶ τ₂)
-- A view of types as either unfolded (U) or fixpoints (Μ).
data U∨Μ {n} : Ty n → Set where
unfolded : ∀ {σ} (u : Unfolded σ) → U∨Μ σ
fixpoint : ∀ {τ₁ τ₂} (u : U∨Μ unfold[μ τ₁ ⟶ τ₂ ]) → U∨Μ (μ τ₁ ⟶ τ₂)
u∨μ : ∀ {n} (σ : Ty n) → U∨Μ σ
u∨μ ⊥ = unfolded ⊥
u∨μ ⊤ = unfolded ⊤
u∨μ (var x) = unfolded (var x)
u∨μ (τ₁ ⟶ τ₂) = unfolded (τ₁ ⟶ τ₂)
u∨μ (μ τ₁ ⟶ τ₂) =
fixpoint (unfolded ((τ₁ [0≔ μ τ₁ ⟶ τ₂ ]) ⟶ (τ₂ [0≔ μ τ₁ ⟶ τ₂ ])))
u∨μ⁻¹ : ∀ {n} {σ : Ty n} → U∨Μ σ → Ty n
u∨μ⁻¹ {σ = σ} _ = σ
| {
"alphanum_fraction": 0.4873713751,
"avg_line_length": 28.8918918919,
"ext": "agda",
"hexsha": "c8e465c80b712608906a8d829f5ae9ff4507dfff",
"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": "RecursiveTypes/Syntax/UnfoldedOrFixpoint.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": "RecursiveTypes/Syntax/UnfoldedOrFixpoint.agda",
"max_line_length": 72,
"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": "RecursiveTypes/Syntax/UnfoldedOrFixpoint.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": 428,
"size": 1069
} |
-- We define ZigZag-complete relations and prove that quasi equivalence relations
-- give rise to equivalences on the set quotients.
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.ZigZag.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.HITs.SetQuotients
open import Cubical.HITs.PropositionalTruncation as Trunc
open import Cubical.Relation.Binary.Base
open BinaryRelation
open isEquivRel
private
variable
ℓ ℓ' : Level
isZigZagComplete : {A B : Type ℓ} (R : A → B → Type ℓ') → Type (ℓ-max ℓ ℓ')
isZigZagComplete R = ∀ {a b a' b'} → R a b → R a' b → R a' b' → R a b'
ZigZagRel : (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
ZigZagRel A B ℓ' = Σ[ R ∈ (A → B → Type ℓ') ] (isZigZagComplete R)
record isQuasiEquivRel {A B : Type ℓ} (R : A → B → Type ℓ') : Type (ℓ-max ℓ ℓ') where
field
zigzag : isZigZagComplete R
fwd : A → B
fwdRel : (a : A) → R a (fwd a)
bwd : B → A
bwdRel : (b : B) → R (bwd b) b
open isQuasiEquivRel
QuasiEquivRel : (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
QuasiEquivRel A B ℓ' =
Σ[ R ∈ PropRel A B ℓ' ] isQuasiEquivRel (R .fst)
invQER : {A B : Type ℓ} {ℓ' : Level} → QuasiEquivRel A B ℓ' → QuasiEquivRel B A ℓ'
invQER (R , qer) .fst = invPropRel R
invQER (R , qer) .snd .zigzag aRb aRb' a'Rb' = qer .zigzag a'Rb' aRb' aRb
invQER (R , qer) .snd .fwd = qer .bwd
invQER (R , qer) .snd .fwdRel = qer .bwdRel
invQER (R , qer) .snd .bwd = qer .fwd
invQER (R , qer) .snd .bwdRel = qer .fwdRel
QER→EquivRel : {A B : Type ℓ}
→ QuasiEquivRel A B ℓ' → EquivPropRel A ℓ'
QER→EquivRel (R , sim) .fst .fst a₀ a₁ = R .fst a₀ (sim .fwd a₁)
QER→EquivRel (R , sim) .fst .snd _ _ = R .snd _ _
QER→EquivRel (R , sim) .snd .reflexive a = sim .fwdRel a
QER→EquivRel (R , sim) .snd .symmetric a₀ a₁ r =
sim .zigzag (sim .fwdRel a₁) r (sim .fwdRel a₀)
QER→EquivRel (R , sim) .snd .transitive a₀ a₁ a₂ r s =
sim .zigzag r (sim .fwdRel a₁) s
-- The following result is due to Carlo Angiuli
module QER→Equiv {A B : Type ℓ} (R : QuasiEquivRel A B ℓ') where
private
sim = R .snd
f = sim .fwd
g = sim .bwd
Rᴸ = QER→EquivRel R .fst .fst
Rᴿ = QER→EquivRel (invQER R) .fst .fst
Thm : (A / Rᴸ) ≃ (B / Rᴿ)
Thm = isoToEquiv (iso φ ψ η ε)
where
φ : _
φ [ a ] = [ f a ]
φ (eq/ a₀ a₁ r i) = eq/ _ _ (sim .zigzag (sim .bwdRel (f a₁)) r (sim .fwdRel a₀)) i
φ (squash/ _ _ p q j i) = squash/ _ _ (cong φ p) (cong φ q) j i
ψ : _
ψ [ b ] = [ g b ]
ψ (eq/ b₀ b₁ s i) = eq/ _ _ (sim .zigzag (sim .bwdRel b₀) s (sim .fwdRel (g b₁))) i
ψ (squash/ _ _ p q j i) = squash/ _ _ (cong ψ p) (cong ψ q) j i
η = elimProp (λ _ → squash/ _ _) (λ b → eq/ _ _ (sim .fwdRel (g b)))
ε = elimProp (λ _ → squash/ _ _) (λ a → eq/ _ _ (sim .bwdRel (f a)))
| {
"alphanum_fraction": 0.6133561644,
"avg_line_length": 33.9534883721,
"ext": "agda",
"hexsha": "d85d5c671eb090d7c44bea9a6bb885389a2ce0b1",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "RobertHarper/cubical",
"max_forks_repo_path": "Cubical/Relation/ZigZag/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"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": "RobertHarper/cubical",
"max_issues_repo_path": "Cubical/Relation/ZigZag/Base.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "RobertHarper/cubical",
"max_stars_repo_path": "Cubical/Relation/ZigZag/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1283,
"size": 2920
} |
{-# OPTIONS --without-K #-}
module equality where
open import equality.core public
open import equality.reasoning public
open import equality.groupoid public
open import equality.calculus public
open import equality.inspect public
| {
"alphanum_fraction": 0.8189655172,
"avg_line_length": 25.7777777778,
"ext": "agda",
"hexsha": "f053b23b05267ae56bd73fd61c2e82f5fd6fc0cf",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/equality.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/equality.agda",
"max_line_length": 37,
"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": "equality.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": 43,
"size": 232
} |
module Productivity (char : Set) where
open import Common.Coinduction
infix 50 _⋆ _+
infixl 40 _⊛_
infixl 30 _∣_
data P : Set where
ε : P
sym : char -> P
_⊛_ : ∞ P -> ∞ P -> P
_∣_ : ∞ P -> ∞ P -> P
mutual
_⋆ : P -> P
p ⋆ = ♯ ε ∣ ♯ (p +)
_+ : P -> P
p + = ♯ p ⊛ ♯ (p ⋆)
_sepBy_ : P -> P -> P
p sepBy sep = ♯ p ⊛ ♯ ((♯ sep ⊛ ♯ p) ⋆)
postulate
addOp : P
mulOp : P
number : P
openP : char
closeP : char
-- Not guarded:
mutual
expr = term sepBy addOp
term = factor sepBy mulOp
factor = ♯ number ∣ ♯ (♯ (♯ sym openP ⊛ ♯ expr) ⊛ ♯ sym closeP)
-- Guarded and incomprehensible:
mutual
expr₁ = ♯ term₁ ⊛ ♯ expr₂
expr₂ = ♯ ε ∣ ♯ expr₃
expr₃ = ♯ (♯ addOp ⊛ ♯ term₁) ⊛ ♯ expr₂
term₁ = ♯ factor₁ ⊛ ♯ term₂
term₂ = ♯ ε ∣ ♯ term₃
term₃ = ♯ (♯ mulOp ⊛ ♯ factor₁) ⊛ ♯ term₂
factor₁ = ♯ number ∣ ♯ (♯ (♯ sym openP ⊛ ♯ expr₁) ⊛ ♯ sym closeP)
| {
"alphanum_fraction": 0.4751037344,
"avg_line_length": 18.5384615385,
"ext": "agda",
"hexsha": "8aeb24e9452230156ee73d125bc040972413a125",
"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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Fail/Productivity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"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": "alhassy/agda",
"max_issues_repo_path": "test/Fail/Productivity.agda",
"max_line_length": 69,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Fail/Productivity.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": 451,
"size": 964
} |
-- 2012-10-20 Andreas
module Issue721a where
data Bool : Set where
false true : Bool
record Foo (b : Bool) : Set where
field
_*_ : Bool → Bool → Bool
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
test : (F : Foo false) (x : Bool) → let open Foo F in _*_ x ≡ (λ x → x)
test F x = x
-- Don't want to see .Issue632._.* in the error message
| {
"alphanum_fraction": 0.595567867,
"avg_line_length": 21.2352941176,
"ext": "agda",
"hexsha": "a6e9e537bdfd95e83f077a0a3793a07e6e08f607",
"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/Issue721a.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/Issue721a.agda",
"max_line_length": 71,
"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/Issue721a.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": 133,
"size": 361
} |
module ExtractCaseSplit where
open import Data.Maybe
open import Agda.Builtin.Bool
not : Bool -> Bool
not true = false
not false = true
func : Maybe Bool -> Bool
func nothing = false
func (just x) = not x
open import Data.List
func2 : List Bool -> Bool
func2 [] = true
func2 (x ∷ x₁) = not (func2 x₁)
| {
"alphanum_fraction": 0.6948051948,
"avg_line_length": 14.6666666667,
"ext": "agda",
"hexsha": "f9bed5f6eeadbb3ee4bf92cb250aa85f34257637",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "omega12345/RefactorAgda",
"max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/ExtractCaseSplit.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "omega12345/RefactorAgda",
"max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/ExtractCaseSplit.agda",
"max_line_length": 31,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "omega12345/RefactorAgda",
"max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/ExtractCaseSplit.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z",
"num_tokens": 92,
"size": 308
} |
open import Data.Product using ( ∃ ; _×_ ; _,_ )
open import Relation.Binary.PropositionalEquality using
( _≡_ ; refl ; trans ; cong₂ )
open import Relation.Unary using ( ∅ ; _∪_ )
open import Web.Semantic.DL.Signature using ( Signature ; CN ; RN )
open import Web.Semantic.Util using ( id ; _∘_ ; Subset ; ⁅_⁆ )
module Web.Semantic.DL.ABox where
infixr 5 _∼_ _∈₁_ _∈₂_
infixr 4 _,_
data ABox (Σ : Signature) (X : Set) : Set where
ε : ABox Σ X
_,_ : (A B : ABox Σ X) → ABox Σ X
_∼_ : (x y : X) → ABox Σ X
_∈₁_ : (x : X) → (c : CN Σ) → ABox Σ X
_∈₂_ : (xy : X × X) → (r : RN Σ) → ABox Σ X
⟨ABox⟩ : ∀ {Σ X Y} → (X → Y) → ABox Σ X → ABox Σ Y
⟨ABox⟩ f ε = ε
⟨ABox⟩ f (A , B) = (⟨ABox⟩ f A , ⟨ABox⟩ f B)
⟨ABox⟩ f (x ∼ y) = (f x ∼ f y)
⟨ABox⟩ f (x ∈₁ C) = (f x ∈₁ C)
⟨ABox⟩ f ((x , y) ∈₂ R) = ((f x , f y) ∈₂ R)
⟨ABox⟩-resp-id : ∀ {Σ X} (A : ABox Σ X) → (⟨ABox⟩ id A ≡ A)
⟨ABox⟩-resp-id ε = refl
⟨ABox⟩-resp-id (A , B) = cong₂ _,_ (⟨ABox⟩-resp-id A) (⟨ABox⟩-resp-id B)
⟨ABox⟩-resp-id (x ∼ y) = refl
⟨ABox⟩-resp-id (x ∈₁ c) = refl
⟨ABox⟩-resp-id ((x , y) ∈₂ r) = refl
⟨ABox⟩-resp-∘ : ∀ {Σ X Y Z} (f : Y → Z) (g : X → Y) (A : ABox Σ X) → (⟨ABox⟩ f (⟨ABox⟩ g A) ≡ ⟨ABox⟩ (f ∘ g) A)
⟨ABox⟩-resp-∘ f g ε = refl
⟨ABox⟩-resp-∘ f g (A , B) = cong₂ _,_ (⟨ABox⟩-resp-∘ f g A) (⟨ABox⟩-resp-∘ f g B)
⟨ABox⟩-resp-∘ f g (x ∼ y) = refl
⟨ABox⟩-resp-∘ f g (x ∈₁ c) = refl
⟨ABox⟩-resp-∘ f g ((x , y) ∈₂ r) = refl
⟨ABox⟩-resp-∘² : ∀ {Σ W X Y Z} (f : Y → Z) (g : X → Y) (h : W → X) →
∀ (A : ABox Σ W) → (⟨ABox⟩ f (⟨ABox⟩ g (⟨ABox⟩ h A)) ≡ ⟨ABox⟩ (f ∘ g ∘ h) A)
⟨ABox⟩-resp-∘² f g h A =
trans (⟨ABox⟩-resp-∘ f g (⟨ABox⟩ h A)) (⟨ABox⟩-resp-∘ (f ∘ g) h A)
Assertions : ∀ {Σ X} → ABox Σ X → Subset (ABox Σ X)
Assertions ε = ∅
Assertions (A , B) = (Assertions A) ∪ (Assertions B)
Assertions (x ∼ y) = ⁅ x ∼ y ⁆
Assertions (x ∈₁ c) = ⁅ x ∈₁ c ⁆
Assertions (xy ∈₂ r) = ⁅ xy ∈₂ r ⁆
| {
"alphanum_fraction": 0.4986972381,
"avg_line_length": 36.9038461538,
"ext": "agda",
"hexsha": "7edca738a30be61b3ceb81c167424b84a37d682a",
"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/ABox.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/ABox.agda",
"max_line_length": 111,
"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/ABox.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": 1007,
"size": 1919
} |
-- Andreas, 2014-05-02 Negative fixities allow now.
module _ where
infix -1 _+_
infix 0 _*_
postulate
_+_ : Set1 → Set2 → Set1
_*_ : Set2 → Set2 → Set2
test = Set + Set1 * Set1
| {
"alphanum_fraction": 0.6363636364,
"avg_line_length": 14.3846153846,
"ext": "agda",
"hexsha": "c51ff8f647e1390819c6c6e15cf7ecb74c60c87b",
"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/Issue1109.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/Issue1109.agda",
"max_line_length": 52,
"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/Issue1109.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": 75,
"size": 187
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.