Search is not available for this dataset
text
string | meta
dict |
---|---|
open import Nat
open import Prelude
open import core
open import contexts
open import progress
open import preservation
open import elaborability
open import typed-elaboration
module continuity where
-- we take the sensibilty theorem as a postulate; for a proof, refer to
-- the POPL17 mechanization. we also postulate some glue that allows us
-- to use our theorems here on the shape of results from that work.
postulate
action : Set
zexp : Set
_◆ : zexp → hexp
_⊢_=>_~_~>_=>_ : (Γ : tctx) → (e1 : zexp) → (t1 : htyp)
→ (α : action) → (e2 : zexp) → (t2 : htyp) → Set
sensibility : {Γ : tctx} {e e' : zexp} {τ τ' : htyp} {α : action} →
Γ ⊢ (e ◆) => τ →
Γ ⊢ e => τ ~ α ~> e' => τ' →
Γ ⊢ (e' ◆) => τ'
binders-unique-h : hexp → Set
binders-unique-z : zexp → Set
binders-unique-cursor1 : ∀{e} → binders-unique-z e → binders-unique-h (e ◆)
binders-unique-cursor2 : ∀{e} → binders-unique-h (e ◆) → binders-unique-z e
binders-unique-sensibility : {Γ : tctx} {e e' : zexp} {τ τ' : htyp} {α : action} →
binders-unique-z e →
Γ ⊢ e => τ ~ α ~> e' => τ' →
binders-unique-z e'
expansion-unique : ∀{Γ e τ d Δ} →
binders-unique-h e →
Γ ⊢ e ⇒ τ ~> d ⊣ Δ →
binders-unique d
continuity : ∀{ e τ α e' τ' }
→ binders-unique-z e
→ ∅ ⊢ (e ◆) => τ
→ ∅ ⊢ e => τ ~ α ~> e' => τ'
→ Σ[ Δ ∈ hctx ] Σ[ d ∈ ihexp ]
( ∅ ⊢ (e' ◆) ⇒ τ' ~> d ⊣ Δ
× Δ , ∅ ⊢ d :: τ'
× ( (Σ[ d' ∈ ihexp ]( d ↦ d' × Δ , ∅ ⊢ d' :: τ' ))
+ d boxedval
+ d indet
)
)
continuity bu wt action with sensibility wt action
... | sense with elaborability-synth sense
... | d , Δ , exp with typed-elaboration-synth exp
... | d::τ' with progress d::τ'
... | (S (d' , stp)) = Δ , d , exp , d::τ' , Inl (d' , stp , preservation (expansion-unique (binders-unique-cursor1 (binders-unique-sensibility bu action)) exp) d::τ' stp)
... | (I ind) = Δ , d , exp , d::τ' , Inr (Inr ind)
... | (BV boxed) = Δ , d , exp , d::τ' , Inr (Inl boxed)
| {
"alphanum_fraction": 0.4737521515,
"avg_line_length": 40.0689655172,
"ext": "agda",
"hexsha": "5e799f58d0519454009394fa94aedb9823cea24b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z",
"max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_forks_repo_path": "continuity.agda",
"max_issues_count": 54,
"max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_issues_repo_path": "continuity.agda",
"max_line_length": 174,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_stars_repo_path": "continuity.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z",
"num_tokens": 796,
"size": 2324
} |
record R : Set₁ where
X = Set Set -- should get error here
field A : Set
| {
"alphanum_fraction": 0.625,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "75d5de6caa3cd8551adbfd7328fb1781dd6ef0a4",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue783b.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue783b.agda",
"max_line_length": 40,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue783b.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": 26,
"size": 80
} |
{-# OPTIONS --erased-cubical #-}
module Erased-cubical-Open-public.Erased (_ : Set₁) where
postulate
A : Set
| {
"alphanum_fraction": 0.6902654867,
"avg_line_length": 16.1428571429,
"ext": "agda",
"hexsha": "e76e9e6f15f56b74fafe29c7312a4ab990e812ad",
"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/Erased-cubical-Open-public/Erased.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/Erased-cubical-Open-public/Erased.agda",
"max_line_length": 57,
"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/Erased-cubical-Open-public/Erased.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": 36,
"size": 113
} |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Coproduct
open import lib.types.Fin
open import lib.types.Int
open import lib.types.Nat
open import lib.types.Pi
module lib.types.Group where
-- 1-approximation of groups without higher coherence conditions.
record GroupStructure {i} (El : Type i) --(El-level : has-level 0 El)
: Type i where
constructor group-structure
field
ident : El
inv : El → El
comp : El → El → El
unit-l : ∀ a → comp ident a == a
assoc : ∀ a b c → comp (comp a b) c == comp a (comp b c)
inv-l : ∀ a → (comp (inv a) a) == ident
⊙El : Ptd i
⊙El = ⊙[ El , ident ]
private
infix 80 _⊙_
_⊙_ = comp
abstract
inv-r : ∀ g → g ⊙ inv g == ident
inv-r g =
g ⊙ inv g =⟨ ! $ unit-l (g ⊙ inv g) ⟩
ident ⊙ (g ⊙ inv g) =⟨ ! $ inv-l (inv g) |in-ctx _⊙ (g ⊙ inv g) ⟩
(inv (inv g) ⊙ inv g) ⊙ (g ⊙ inv g) =⟨ assoc (inv (inv g)) (inv g) (g ⊙ inv g) ⟩
inv (inv g) ⊙ (inv g ⊙ (g ⊙ inv g)) =⟨ ! $ assoc (inv g) g (inv g) |in-ctx inv (inv g) ⊙_ ⟩
inv (inv g) ⊙ ((inv g ⊙ g) ⊙ inv g) =⟨ inv-l g |in-ctx (λ h → inv (inv g) ⊙ (h ⊙ inv g)) ⟩
inv (inv g) ⊙ (ident ⊙ inv g) =⟨ unit-l (inv g) |in-ctx inv (inv g) ⊙_ ⟩
inv (inv g) ⊙ inv g =⟨ inv-l (inv g) ⟩
ident =∎
unit-r : ∀ g → g ⊙ ident == g
unit-r g =
g ⊙ ident =⟨ ! (inv-l g) |in-ctx g ⊙_ ⟩
g ⊙ (inv g ⊙ g) =⟨ ! $ assoc g (inv g) g ⟩
(g ⊙ inv g) ⊙ g =⟨ inv-r g |in-ctx _⊙ g ⟩
ident ⊙ g =⟨ unit-l g ⟩
g =∎
inv-unique-l : (g h : El) → (g ⊙ h == ident) → inv h == g
inv-unique-l g h p =
inv h =⟨ ! (unit-l (inv h)) ⟩
ident ⊙ inv h =⟨ ! p |in-ctx (λ w → w ⊙ inv h) ⟩
(g ⊙ h) ⊙ inv h =⟨ assoc g h (inv h) ⟩
g ⊙ (h ⊙ inv h) =⟨ inv-r h |in-ctx (λ w → g ⊙ w) ⟩
g ⊙ ident =⟨ unit-r g ⟩
g =∎
inv-unique-r : (g h : El) → (g ⊙ h == ident) → inv g == h
inv-unique-r g h p =
inv g =⟨ ! (unit-r (inv g)) ⟩
inv g ⊙ ident =⟨ ! p |in-ctx (λ w → inv g ⊙ w) ⟩
inv g ⊙ (g ⊙ h) =⟨ ! (assoc (inv g) g h) ⟩
(inv g ⊙ g) ⊙ h =⟨ inv-l g |in-ctx (λ w → w ⊙ h) ⟩
ident ⊙ h =⟨ unit-l h ⟩
h =∎
inv-ident : inv ident == ident
inv-ident = inv-unique-l ident ident (unit-l ident)
inv-comp : (g₁ g₂ : El) → inv (g₁ ⊙ g₂) == inv g₂ ⊙ inv g₁
inv-comp g₁ g₂ =
inv-unique-r (g₁ ⊙ g₂) (inv g₂ ⊙ inv g₁) $
(g₁ ⊙ g₂) ⊙ (inv g₂ ⊙ inv g₁)
=⟨ assoc g₁ g₂ (inv g₂ ⊙ inv g₁) ⟩
g₁ ⊙ (g₂ ⊙ (inv g₂ ⊙ inv g₁))
=⟨ ! (assoc g₂ (inv g₂) (inv g₁)) |in-ctx (λ w → g₁ ⊙ w) ⟩
g₁ ⊙ ((g₂ ⊙ inv g₂) ⊙ inv g₁)
=⟨ inv-r g₂ |in-ctx (λ w → g₁ ⊙ (w ⊙ inv g₁)) ⟩
g₁ ⊙ (ident ⊙ inv g₁)
=⟨ unit-l (inv g₁) |in-ctx (λ w → g₁ ⊙ w) ⟩
g₁ ⊙ inv g₁
=⟨ inv-r g₁ ⟩
ident =∎
inv-inv : (g : El) → inv (inv g) == g
inv-inv g = inv-unique-r (inv g) g (inv-l g)
inv-is-inj : is-inj inv
inv-is-inj g₁ g₂ p = ! (inv-inv g₁) ∙ ap inv p ∙ inv-inv g₂
cancel-l : (g : El) {h k : El} → g ⊙ h == g ⊙ k → h == k
cancel-l g {h} {k} p =
h =⟨ ! (unit-l h) ⟩
ident ⊙ h =⟨ ap (λ w → w ⊙ h) (! (inv-l g)) ⟩
(inv g ⊙ g) ⊙ h =⟨ assoc (inv g) g h ⟩
inv g ⊙ (g ⊙ h) =⟨ ap (λ w → inv g ⊙ w) p ⟩
inv g ⊙ (g ⊙ k) =⟨ ! (assoc (inv g) g k) ⟩
(inv g ⊙ g) ⊙ k =⟨ ap (λ w → w ⊙ k) (inv-l g) ⟩
ident ⊙ k =⟨ unit-l k ⟩
k =∎
cancel-r : (g : El) {h k : El} → h ⊙ g == k ⊙ g → h == k
cancel-r g {h} {k} p =
h =⟨ ! (unit-r h) ⟩
h ⊙ ident =⟨ ap (λ w → h ⊙ w) (! (inv-r g)) ⟩
h ⊙ (g ⊙ inv g) =⟨ ! (assoc h g (inv g)) ⟩
(h ⊙ g) ⊙ inv g =⟨ ap (λ w → w ⊙ inv g) p ⟩
(k ⊙ g) ⊙ inv g =⟨ assoc k g (inv g) ⟩
k ⊙ (g ⊙ inv g) =⟨ ap (λ w → k ⊙ w) (inv-r g) ⟩
k ⊙ ident =⟨ unit-r k ⟩
k =∎
conj : El → El → El
conj g₁ g₂ = (g₁ ⊙ g₂) ⊙ inv g₁
abstract
conj-ident-r : ∀ g → conj g ident == ident
conj-ident-r g = ap (_⊙ inv g) (unit-r _) ∙ inv-r g
{- NOT USED
abstract
conj-unit-l : ∀ g → conj ident g == g
conj-unit-l g = ap2 _⊙_ (unit-l _) inv-ident ∙ unit-r _
conj-comp-l : ∀ g₁ g₂ g₃ → conj (g₁ ⊙ g₂) g₃ == conj g₁ (conj g₂ g₃)
conj-comp-l g₁ g₂ g₃ =
((g₁ ⊙ g₂) ⊙ g₃) ⊙ inv (g₁ ⊙ g₂)
=⟨ ap2 _⊙_ (assoc g₁ g₂ g₃) (inv-comp g₁ g₂) ⟩
(g₁ ⊙ (g₂ ⊙ g₃)) ⊙ (inv g₂ ⊙ inv g₁)
=⟨ ! $ assoc (g₁ ⊙ (g₂ ⊙ g₃)) (inv g₂) (inv g₁) ⟩
((g₁ ⊙ (g₂ ⊙ g₃)) ⊙ inv g₂) ⊙ inv g₁
=⟨ assoc g₁ (g₂ ⊙ g₃) (inv g₂) |in-ctx _⊙ inv g₁ ⟩
(g₁ ⊙ ((g₂ ⊙ g₃) ⊙ inv g₂)) ⊙ inv g₁
=∎
inv-conj : ∀ g₁ g₂ → inv (conj g₁ g₂) == conj g₁ (inv g₂)
inv-conj g₁ g₂ = inv-comp (g₁ ⊙ g₂) (inv g₁)
∙ ap2 _⊙_ (inv-inv g₁) (inv-comp g₁ g₂)
∙ ! (assoc g₁ (inv g₂) (inv g₁))
-}
exp : El → ℤ → El
exp g (pos 0) = ident
exp g (pos 1) = g
exp g (pos (S (S n))) = comp g (exp g (pos (S n)))
exp g (negsucc 0) = inv g
exp g (negsucc (S n)) = comp (inv g) (exp g (negsucc n))
abstract
exp-succ : ∀ g z → exp g (succ z) == comp g (exp g z)
exp-succ g (pos 0) = ! (unit-r g)
exp-succ g (pos 1) = idp
exp-succ g (pos (S (S n))) = idp
exp-succ g (negsucc 0) = ! (inv-r g)
exp-succ g (negsucc (S n)) =
! (unit-l (exp g (negsucc n)))
∙ ap (λ h → comp h (exp g (negsucc n))) (! (inv-r g))
∙ assoc g (inv g) (exp g (negsucc n))
exp-pred : ∀ g z → exp g (pred z) == comp (inv g) (exp g z)
exp-pred g (pos 0) = ! (unit-r (inv g))
exp-pred g (pos 1) = ! (inv-l g)
exp-pred g (pos (S (S n))) =
! (unit-l (exp g (pos (S n))))
∙ ap (λ h → comp h (exp g (pos (S n)))) (! (inv-l g))
∙ assoc (inv g) g (exp g (pos (S n)))
exp-pred g (negsucc 0) = idp
exp-pred g (negsucc (S n)) = idp
exp-+ : ∀ g z₁ z₂ → exp g (z₁ ℤ+ z₂) == comp (exp g z₁) (exp g z₂)
exp-+ g (pos 0) z₂ = ! (unit-l _)
exp-+ g (pos 1) z₂ = exp-succ g z₂
exp-+ g (pos (S (S n))) z₂ =
exp-succ g (pos (S n) ℤ+ z₂)
∙ ap (comp g) (exp-+ g (pos (S n)) z₂)
∙ ! (assoc g (exp g (pos (S n))) (exp g z₂))
exp-+ g (negsucc 0) z₂ = exp-pred g z₂
exp-+ g (negsucc (S n)) z₂ =
exp-pred g (negsucc n ℤ+ z₂)
∙ ap (comp (inv g)) (exp-+ g (negsucc n) z₂)
∙ ! (assoc (inv g) (exp g (negsucc n)) (exp g z₂))
exp-ident : ∀ z → exp ident z == ident
exp-ident (pos 0) = idp
exp-ident (pos 1) = idp
exp-ident (pos (S (S n))) = unit-l _ ∙ exp-ident (pos (S n))
exp-ident (negsucc 0) = inv-ident
exp-ident (negsucc (S n)) = ap2 comp inv-ident (exp-ident (negsucc n)) ∙ unit-l _
diff : El → El → El
diff g h = g ⊙ inv h
abstract
zero-diff-same : (g h : El) → diff g h == ident → g == h
zero-diff-same g h p = inv-is-inj g h $ inv-unique-r g (inv h) p
inv-diff : (g h : El) → inv (diff g h) == diff h g
inv-diff g h = inv-comp g (inv h) ∙ ap (_⊙ inv g) (inv-inv h)
sum : ∀ {I : ℕ} → (Fin I → El) → El
sum {I = O} f = ident
sum {I = S n} f = comp (sum (f ∘ Fin-S)) (f (n , ltS))
subsum-r : ∀ {j k} {I : ℕ} {A : Type j} {B : Type k}
→ (Fin I → Coprod A B) → (B → El) → El
subsum-r p f = sum (λ x → ⊔-rec (λ _ → ident) f (p x))
record Group i : Type (lsucc i) where
constructor group
field
El : Type i
{{El-level}} : has-level 0 El
group-struct : GroupStructure El
open GroupStructure group-struct public
Group₀ : Type (lsucc lzero)
Group₀ = Group lzero
is-abelian : ∀ {i} → Group i → Type i
is-abelian G = (a b : Group.El G) → Group.comp G a b == Group.comp G b a
AbGroup : ∀ i → Type (lsucc i)
AbGroup i = Σ (Group i) is-abelian
AbGroup₀ : Type (lsucc lzero)
AbGroup₀ = AbGroup lzero
module AbGroup {i} (G : AbGroup i) where
grp = fst G
comm = snd G
open Group grp public
abstract
interchange : (g₁ g₂ g₃ g₄ : El) →
comp (comp g₁ g₂) (comp g₃ g₄)
== comp (comp g₁ g₃) (comp g₂ g₄)
interchange g₁ g₂ g₃ g₄ =
comp (comp g₁ g₂) (comp g₃ g₄)
=⟨ assoc g₁ g₂ (comp g₃ g₄) ⟩
comp g₁ (comp g₂ (comp g₃ g₄))
=⟨ comm g₃ g₄ |in-ctx (λ g → (comp g₁ (comp g₂ g))) ⟩
comp g₁ (comp g₂ (comp g₄ g₃))
=⟨ ! (assoc g₂ g₄ g₃) |in-ctx comp g₁ ⟩
comp g₁ (comp (comp g₂ g₄) g₃)
=⟨ comm (comp g₂ g₄) g₃ |in-ctx comp g₁ ⟩
comp g₁ (comp g₃ (comp g₂ g₄))
=⟨ ! (assoc g₁ g₃ (comp g₂ g₄)) ⟩
comp (comp g₁ g₃) (comp g₂ g₄)
=∎
inv-comp' : ∀ g₁ g₂ → inv (comp g₁ g₂) == comp (inv g₁) (inv g₂)
inv-comp' g₁ g₂ = inv-comp g₁ g₂ ∙ comm (inv g₂) (inv g₁)
diff-comp : (g₁ g₂ g₃ g₄ : El) →
diff (comp g₁ g₂) (comp g₃ g₄)
== comp (diff g₁ g₃) (diff g₂ g₄)
diff-comp g₁ g₂ g₃ g₄ =
diff (comp g₁ g₂) (comp g₃ g₄)
=⟨ ap (comp (comp g₁ g₂)) (inv-comp' g₃ g₄) ⟩
comp (comp g₁ g₂) (comp (inv g₃) (inv g₄))
=⟨ interchange g₁ g₂ (inv g₃) (inv g₄) ⟩
comp (diff g₁ g₃) (diff g₂ g₄)
=∎
sum-comp : ∀ {I} (f g : Fin I → El)
→ sum (λ x → comp (f x) (g x)) == comp (sum f) (sum g)
sum-comp {I = O} f g = ! (unit-l _)
sum-comp {I = S I} f g =
ap (λ x → comp x (comp (f (I , ltS)) (g (I , ltS)))) (sum-comp (f ∘ Fin-S) (g ∘ Fin-S))
∙ interchange (sum (f ∘ Fin-S)) (sum (g ∘ Fin-S)) (f (I , ltS)) (g (I , ltS))
exp-comp : ∀ g₁ g₂ z → exp (comp g₁ g₂) z == comp (exp g₁ z) (exp g₂ z)
exp-comp g₁ g₂ (pos O) = ! (unit-l _)
exp-comp g₁ g₂ (pos (S O)) = idp
exp-comp g₁ g₂ (pos (S (S n))) =
ap (comp (comp g₁ g₂)) (exp-comp g₁ g₂ (pos (S n)))
∙ interchange g₁ g₂ (exp g₁ (pos (S n))) (exp g₂ (pos (S n)))
exp-comp g₁ g₂ (negsucc O) = inv-comp' g₁ g₂
exp-comp g₁ g₂ (negsucc (S n)) =
ap2 comp (inv-comp' g₁ g₂) (exp-comp g₁ g₂ (negsucc n))
∙ interchange (inv g₁) (inv g₂) (exp g₁ (negsucc n)) (exp g₂ (negsucc n))
is-trivialᴳ : ∀ {i} (G : Group i) → Type i
is-trivialᴳ G = ∀ g → g == Group.ident G
contr-is-trivialᴳ : ∀ {i} (G : Group i)
{{_ : is-contr (Group.El G)}} → is-trivialᴳ G
contr-is-trivialᴳ G g =
contr-has-all-paths _ _
{- group-structure= -}
module _ where
open GroupStructure
abstract
group-structure= : ∀ {i} {A : Type i} {{_ : is-set A}}
{id₁ id₂ : A} {inv₁ inv₂ : A → A} {comp₁ comp₂ : A → A → A}
→ ∀ {unit-l₁ unit-l₂ assoc₁ assoc₂ inv-l₁ inv-l₂}
→ (id₁ == id₂) → (inv₁ == inv₂) → (comp₁ == comp₂)
→ Path {A = GroupStructure A}
(group-structure id₁ inv₁ comp₁ unit-l₁ assoc₁ inv-l₁)
(group-structure id₂ inv₂ comp₂ unit-l₂ assoc₂ inv-l₂)
group-structure= {id₁ = id₁} {inv₁ = inv₁} {comp₁ = comp₁} idp idp idp =
ap3 (group-structure id₁ inv₁ comp₁)
(prop-has-all-paths _ _)
(prop-has-all-paths _ _)
(prop-has-all-paths _ _)
↓-group-structure= : ∀ {i} {A B : Type i}
{{_ : has-level 0 A}}
{GS : GroupStructure A} {HS : GroupStructure B} (p : A == B)
→ (ident GS == ident HS [ (λ C → C) ↓ p ])
→ (inv GS == inv HS [ (λ C → C → C) ↓ p ])
→ (comp GS == comp HS [ (λ C → C → C → C) ↓ p ])
→ GS == HS [ GroupStructure ↓ p ]
↓-group-structure= idp = group-structure=
| {
"alphanum_fraction": 0.4698091836,
"avg_line_length": 35.9780564263,
"ext": "agda",
"hexsha": "4367aa22bfa8b042b8e76ea90f8208854d950733",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Group.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Group.agda",
"max_line_length": 97,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Group.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4947,
"size": 11477
} |
module Cats.Category.Mon where
open import Data.Unit using (⊤)
open import Relation.Binary using (Setoid ; _Preserves₂_⟶_⟶_ ; IsEquivalence)
open import Level
open import Cats.Category
open import Cats.Category.Setoids using (Setoids)
open import Cats.Util.Conv
import Cats.Util.Function as Fun
record Monoid l l≈ : Set (suc (l ⊔ l≈)) where
infixr 9 _⊕_
field
Universe : Setoid l l≈
open Setoid Universe public
field
_⊕_ : Carrier → Carrier → Carrier
unit : Carrier
⊕-resp : _⊕_ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_
assoc : ∀ {a b c} → (a ⊕ b) ⊕ c ≈ a ⊕ (b ⊕ c)
id-l : ∀ {a} → unit ⊕ a ≈ a
id-r : ∀ {a} → a ⊕ unit ≈ a
module ≈ = IsEquivalence isEquivalence
module _ (l l≈ : Level) where
infixr 9 _∘_
infixr 4 _≈_
module Setoids = Category (Setoids l l≈)
Obj : Set (suc (l ⊔ l≈))
Obj = Monoid l l≈
record _⇒_ (M N : Obj) : Set (l ⊔ l≈) where
private
module M = Monoid M
module N = Monoid N
field
arr : M.Universe Setoids.⇒ N.Universe
unit : (arr ⃗) M.unit N.≈ N.unit
commute : ∀ {n m} → (arr ⃗) (n M.⊕ m) N.≈ (arr ⃗) n N.⊕ (arr ⃗) m
open Cats.Category.Setoids._⇒_ arr public using (resp)
open _⇒_ using (unit ; commute ; resp)
instance
HasArrow-⇒ : ∀ M N → HasArrow (M ⇒ N) _ _ _
HasArrow-⇒ M N = record { Cat = Setoids l l≈ ; _⃗ = _⇒_.arr }
id : ∀ {M} → M ⇒ M
id {M} = record
{ arr = Setoids.id
; unit = refl
; commute = refl
}
where
open Monoid M using (refl)
_≈_ : ∀ {M N} (f g : M ⇒ N) → Set (l≈ ⊔ l)
_≈_ = Setoids._≈_ Fun.on _⃗
_∘_ : ∀ {M N O} → (N ⇒ O) → (M ⇒ N) → (M ⇒ O)
_∘_ {M} {N} {O} f g = record
{ arr = f ⃗ Setoids.∘ g ⃗
; unit = trans (resp f (unit g)) (unit f)
; commute = trans (resp f (commute g)) (commute f)
}
where
open Monoid O using (trans)
Mon : Category (suc (l≈ ⊔ l)) (l≈ ⊔ l) (l≈ ⊔ l)
Mon = record
{ Obj = Obj
; _⇒_ = _⇒_
; _≈_ = _≈_
; id = id
; _∘_ = _∘_
; equiv = Fun.on-isEquivalence _⃗ Setoids.equiv
; ∘-resp = Setoids.∘-resp
; id-r = Setoids.id-r
; id-l = Setoids.id-l
; assoc = λ { {f = f} {g} {h} → Setoids.assoc {f = f ⃗} {g ⃗} {h ⃗} }
}
monoidAsCategory : ∀ {l l≈} → Monoid l l≈ → Category zero l l≈
monoidAsCategory M = record
{ Obj = ⊤
; _⇒_ = λ _ _ → M.Carrier
; _≈_ = M._≈_
; id = M.unit
; _∘_ = M._⊕_
; equiv = M.isEquivalence
; ∘-resp = M.⊕-resp
; id-r = M.id-r
; id-l = M.id-l
; assoc = M.assoc
}
where
module M = Monoid M
| {
"alphanum_fraction": 0.5185185185,
"avg_line_length": 21.4214876033,
"ext": "agda",
"hexsha": "822b26ef57992d9d5d2f882d1160219f0d767303",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Category/Mon.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Mon.agda",
"max_line_length": 77,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Mon.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1094,
"size": 2592
} |
module Prelude.Semiring where
open import Agda.Builtin.Nat using (Nat; zero; suc)
open import Prelude.Function
record Semiring {a} (A : Set a) : Set a where
infixl 6 _+_
infixl 7 _*_
field zro one : A
_+_ _*_ : A → A → A
open Semiring {{...}} public
{-# DISPLAY Semiring.zro _ = zro #-}
{-# DISPLAY Semiring.one _ = one #-}
{-# DISPLAY Semiring._+_ _ a b = a + b #-}
{-# DISPLAY Semiring._*_ _ a b = a * b #-}
infixr 8 _^_
_^_ : ∀ {a} {A : Set a} {{_ : Semiring A}} → A → Nat → A
n ^ zero = one
n ^ suc m = n ^ m * n
record Subtractive {a} (A : Set a) : Set a where
infixl 6 _-_
field _-_ : A → A → A
negate : A → A
open Subtractive {{...}} public
{-# DISPLAY Subtractive._-_ _ a b = a - b #-}
{-# DISPLAY Subtractive.negate _ = negate #-}
| {
"alphanum_fraction": 0.5725288832,
"avg_line_length": 22.9117647059,
"ext": "agda",
"hexsha": "d990fb42e13a36dcff1e70bf96f37e2b3d95ab0c",
"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/Prelude/Semiring.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/Prelude/Semiring.agda",
"max_line_length": 56,
"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/Prelude/Semiring.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": 267,
"size": 779
} |
-- There are no level literals in the concrete syntax. This file tests
-- if type errors use level literals.
{-# OPTIONS --universe-polymorphism #-}
module LevelLiterals where
open import Imports.Level
data ⊥ : Set₁ where
DoubleNegated : ∀ {ℓ} → Set ℓ → Set
DoubleNegated A = (A → ⊥) → ⊥
| {
"alphanum_fraction": 0.6996587031,
"avg_line_length": 20.9285714286,
"ext": "agda",
"hexsha": "35388afa46b9a0644d931dddc907996ce6922d30",
"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/fail/LevelLiterals.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/fail/LevelLiterals.agda",
"max_line_length": 70,
"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/LevelLiterals.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": 82,
"size": 293
} |
------------------------------------------------------------------------------
-- All the FOTC modules
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Everything where
open import FOTC.Base
open import FOTC.Base.Consistency.Axioms
open import FOTC.Base.Consistency.IfInjective
open import FOTC.Base.List
open import FOTC.Base.List.Consistency.Axioms
open import FOTC.Base.List.PropertiesATP
open import FOTC.Base.List.PropertiesI
open import FOTC.Base.Loop
open import FOTC.Base.PropertiesATP
open import FOTC.Base.PropertiesI
open import FOTC.Data.Bool
open import FOTC.Data.Bool.PropertiesATP
open import FOTC.Data.Bool.PropertiesI
open import FOTC.Data.Bool.Type
open import FOTC.Data.Colist
open import FOTC.Data.Colist.PropertiesATP
open import FOTC.Data.Colist.PropertiesI
open import FOTC.Data.Colist.Type
open import FOTC.Data.Colist.Type.Consistency.Axioms
open import FOTC.Data.Conat
open import FOTC.Data.Conat.Equality.Consistency.Axioms
open import FOTC.Data.Conat.Equality.PropertiesATP
open import FOTC.Data.Conat.Equality.PropertiesI
open import FOTC.Data.Conat.Equality.Type
open import FOTC.Data.Conat.PropertiesATP
open import FOTC.Data.Conat.PropertiesI
open import FOTC.Data.Conat.Type
open import FOTC.Data.Conat.Type.Consistency.Axioms
open import FOTC.Data.List
open import FOTC.Data.List.Consistency.Axioms
open import FOTC.Data.List.PropertiesATP
open import FOTC.Data.List.PropertiesByInductionI
open import FOTC.Data.List.PropertiesByInductionATP
open import FOTC.Data.List.PropertiesI
open import FOTC.Data.List.Type
open import FOTC.Data.List.WF-Relation.LT-Cons
open import FOTC.Data.List.WF-Relation.LT-Cons.Induction.Acc.WF-I
open import FOTC.Data.List.WF-Relation.LT-Cons.PropertiesI
open import FOTC.Data.List.WF-Relation.LT-Length
open import FOTC.Data.List.WF-Relation.LT-Length.Induction.Acc.WF-I
open import FOTC.Data.List.WF-Relation.LT-Length.PropertiesI
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Consistency.Axioms
open import FOTC.Data.Nat.Divisibility.By0
open import FOTC.Data.Nat.Divisibility.By0.PropertiesATP
open import FOTC.Data.Nat.Divisibility.By0.PropertiesI
open import FOTC.Data.Nat.Divisibility.NotBy0
open import FOTC.Data.Nat.Divisibility.NotBy0.PropertiesATP
open import FOTC.Data.Nat.Divisibility.NotBy0.PropertiesI
open import FOTC.Data.Nat.Induction.Acc.WF-ATP
open import FOTC.Data.Nat.Induction.Acc.WF-I
open import FOTC.Data.Nat.Induction.NonAcc.LexicographicATP
open import FOTC.Data.Nat.Induction.NonAcc.LexicographicI
open import FOTC.Data.Nat.Induction.NonAcc.WF-ATP
open import FOTC.Data.Nat.Induction.NonAcc.WF-I
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Inequalities.Consistency.Axioms
open import FOTC.Data.Nat.Inequalities.EliminationPropertiesATP
open import FOTC.Data.Nat.Inequalities.EliminationPropertiesI
open import FOTC.Data.Nat.Inequalities.PropertiesATP
open import FOTC.Data.Nat.Inequalities.PropertiesI
open import FOTC.Data.Nat.List
open import FOTC.Data.Nat.List.PropertiesATP
open import FOTC.Data.Nat.List.PropertiesI
open import FOTC.Data.Nat.List.Type
open import FOTC.Data.Nat.PropertiesATP
open import FOTC.Data.Nat.PropertiesByInductionATP
open import FOTC.Data.Nat.PropertiesByInductionI
open import FOTC.Data.Nat.PropertiesI
open import FOTC.Data.Nat.Type
open import FOTC.Data.Nat.UnaryNumbers
open import FOTC.Data.Nat.UnaryNumbers.Inequalities.PropertiesATP
open import FOTC.Data.Nat.UnaryNumbers.TotalityATP
open import FOTC.Data.Nat.UnaryNumbers.TotalityI
open import FOTC.Data.Stream
open import FOTC.Data.Stream.Equality.PropertiesATP
open import FOTC.Data.Stream.Equality.PropertiesI
open import FOTC.Data.Stream.PropertiesATP
open import FOTC.Data.Stream.PropertiesI
open import FOTC.Data.Stream.Type
open import FOTC.Data.Stream.Type.Consistency.Axioms
open import FOTC.Induction.WF
open import FOTC.Program.ABP.ABP
open import FOTC.Program.ABP.ABP.Consistency.Axioms
open import FOTC.Program.ABP.CorrectnessProofATP
open import FOTC.Program.ABP.CorrectnessProofI
open import FOTC.Program.ABP.Fair.Type
open import FOTC.Program.ABP.Fair.Consistency.Axioms
open import FOTC.Program.ABP.Fair.PropertiesATP
open import FOTC.Program.ABP.Fair.PropertiesI
open import FOTC.Program.ABP.Lemma1ATP
open import FOTC.Program.ABP.Lemma1I
open import FOTC.Program.ABP.Lemma2ATP
open import FOTC.Program.ABP.Lemma2I
open import FOTC.Program.ABP.PropertiesI
open import FOTC.Program.ABP.Terms
open import FOTC.Program.Collatz.Collatz
open import FOTC.Program.Collatz.Collatz.Consistency.Axioms
open import FOTC.Program.Collatz.Data.Nat
open import FOTC.Program.Collatz.Data.Nat.Consistency.Axioms
open import FOTC.Program.Collatz.Data.Nat.PropertiesATP
open import FOTC.Program.Collatz.Data.Nat.PropertiesI
open import FOTC.Program.Collatz.PropertiesI
open import FOTC.Program.Collatz.PropertiesATP
open import FOTC.Program.Division.ConversionRulesATP
open import FOTC.Program.Division.ConversionRulesI
open import FOTC.Program.Division.CorrectnessProofATP
open import FOTC.Program.Division.CorrectnessProofI
open import FOTC.Program.Division.Division
open import FOTC.Program.Division.ResultATP
open import FOTC.Program.Division.ResultI
open import FOTC.Program.Division.Specification
open import FOTC.Program.Division.TotalityATP
open import FOTC.Program.Division.TotalityI
open import FOTC.Program.GCD.Partial.CommonDivisorATP
open import FOTC.Program.GCD.Partial.CommonDivisorI
open import FOTC.Program.GCD.Partial.ConversionRulesATP
open import FOTC.Program.GCD.Partial.ConversionRulesI
open import FOTC.Program.GCD.Partial.CorrectnessProofATP
open import FOTC.Program.GCD.Partial.CorrectnessProofI
open import FOTC.Program.GCD.Partial.Definitions
open import FOTC.Program.GCD.Partial.DivisibleATP
open import FOTC.Program.GCD.Partial.DivisibleI
open import FOTC.Program.GCD.Partial.GCD
open import FOTC.Program.GCD.Partial.GCD.Consistency.Axioms
open import FOTC.Program.GCD.Partial.GreatestAnyCommonDivisor
open import FOTC.Program.GCD.Partial.TotalityATP
open import FOTC.Program.GCD.Partial.TotalityI
open import FOTC.Program.GCD.Total.CommonDivisorATP
open import FOTC.Program.GCD.Total.CommonDivisorI
open import FOTC.Program.GCD.Total.ConversionRulesATP
open import FOTC.Program.GCD.Total.ConversionRulesI
open import FOTC.Program.GCD.Total.CorrectnessProofATP
open import FOTC.Program.GCD.Total.CorrectnessProofI
open import FOTC.Program.GCD.Total.Definitions
open import FOTC.Program.GCD.Total.DivisibleATP
open import FOTC.Program.GCD.Total.DivisibleI
open import FOTC.Program.GCD.Total.GCD
open import FOTC.Program.GCD.Total.GCD.Consistency.Axioms
open import FOTC.Program.GCD.Total.TotalityATP
open import FOTC.Program.GCD.Total.TotalityI
open import FOTC.Program.Iter0.Iter0
open import FOTC.Program.Iter0.PropertiesATP
open import FOTC.Program.Iter0.PropertiesI
open import FOTC.Program.MapIterate.MapIterateATP
open import FOTC.Program.MapIterate.MapIterateI
open import FOTC.Program.McCarthy91.ArithmeticATP
open import FOTC.Program.McCarthy91.AuxiliaryPropertiesATP
open import FOTC.Program.McCarthy91.McCarthy91.Consistency.Axioms
open import FOTC.Program.McCarthy91.McCarthy91
open import FOTC.Program.McCarthy91.PropertiesATP
open import FOTC.Program.McCarthy91.WF-Relation
open import FOTC.Program.McCarthy91.WF-Relation.LT2WF-RelationATP
open import FOTC.Program.McCarthy91.WF-Relation.PropertiesATP
open import FOTC.Program.McCarthy91.WF-Relation.Induction.Acc.WF-ATP
open import FOTC.Program.Mirror.Example
open import FOTC.Program.Mirror.Forest.PropertiesATP
open import FOTC.Program.Mirror.Forest.PropertiesI
open import FOTC.Program.Mirror.Forest.TotalityATP
open import FOTC.Program.Mirror.Forest.TotalityI
open import FOTC.Program.Mirror.Mirror.Consistency.Axioms
open import FOTC.Program.Mirror.Mirror
open import FOTC.Program.Mirror.PropertiesATP
open import FOTC.Program.Mirror.PropertiesI
open import FOTC.Program.Mirror.Tree.TotalityATP
open import FOTC.Program.Mirror.Tree.TotalityI
open import FOTC.Program.Mirror.Type
open import FOTC.Program.Nest.Nest
open import FOTC.Program.Nest.Nest.Consistency.Axioms
open import FOTC.Program.Nest.PropertiesATP
open import FOTC.Program.SortList.CorrectnessProofATP
open import FOTC.Program.SortList.CorrectnessProofI
open import FOTC.Program.SortList.Properties.MiscellaneousATP
open import FOTC.Program.SortList.Properties.MiscellaneousI
open import FOTC.Program.SortList.Properties.Totality.BoolATP
open import FOTC.Program.SortList.Properties.Totality.BoolI
open import FOTC.Program.SortList.Properties.Totality.ListN-ATP
open import FOTC.Program.SortList.Properties.Totality.ListN-I
open import FOTC.Program.SortList.Properties.Totality.OrdList.FlattenI
open import FOTC.Program.SortList.Properties.Totality.OrdList.FlattenATP
open import FOTC.Program.SortList.Properties.Totality.OrdListATP
open import FOTC.Program.SortList.Properties.Totality.OrdListI
open import FOTC.Program.SortList.Properties.Totality.OrdTreeATP
open import FOTC.Program.SortList.Properties.Totality.OrdTreeI
open import FOTC.Program.SortList.Properties.Totality.TreeATP
open import FOTC.Program.SortList.Properties.Totality.TreeI
open import FOTC.Program.SortList.PropertiesI
open import FOTC.Program.SortList.PropertiesATP
open import FOTC.Program.SortList.SortList
open import FOTC.Program.SortList.SortList.Consistency.Axioms
open import FOTC.Relation.Binary.Bisimilarity.Bisimulation
open import FOTC.Relation.Binary.Bisimilarity.Consistency.Axioms
open import FOTC.Relation.Binary.Bisimilarity.PropertiesATP
open import FOTC.Relation.Binary.Bisimilarity.PropertiesI
open import FOTC.Relation.Binary.Bisimilarity.Type
| {
"alphanum_fraction": 0.8342137343,
"avg_line_length": 43.5575221239,
"ext": "agda",
"hexsha": "3f24a1b9dc5d6f5fa432fb2abea66d2f9230f7bf",
"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/Everything.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/Everything.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/Everything.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": 2756,
"size": 9844
} |
{-# OPTIONS --safe #-}
module Data.Nat.AbsoluteDifference where
open import Data.Nat.Base
open import Path
open import Prelude
open import Algebra
∣_-_∣ : ℕ → ℕ → ℕ
∣ 0 - m ∣ = m
∣ n@(suc _) - 0 ∣ = n
∣ suc n - suc m ∣ = ∣ n - m ∣
_ : ∣ 5 - 3 ∣ ≡ 2
_ = refl
_ : ∣ 3 - 5 ∣ ≡ 2
_ = refl
∣-∣‿comm : Commutative ∣_-_∣
∣-∣‿comm zero zero = refl
∣-∣‿comm zero (suc y) = refl
∣-∣‿comm (suc x) zero = refl
∣-∣‿comm (suc x) (suc y) = ∣-∣‿comm x y
| {
"alphanum_fraction": 0.5084033613,
"avg_line_length": 18.3076923077,
"ext": "agda",
"hexsha": "ab6bf8cfe03e0c84c93e88815db05d0e2c94206e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Nat/AbsoluteDifference.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/Nat/AbsoluteDifference.agda",
"max_line_length": 40,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Nat/AbsoluteDifference.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 231,
"size": 476
} |
open import Agda.Primitive using (lzero; lsuc; _⊔_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; subst; setoid)
open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap)
import Function.Equality
open import Relation.Binary using (Setoid)
import Relation.Binary.Reasoning.Setoid as SetoidR
import SecondOrder.Arity
import SecondOrder.Signature
import SecondOrder.Metavariable
import SecondOrder.VRenaming
import SecondOrder.MRenaming
import SecondOrder.Term
import SecondOrder.Substitution
import SecondOrder.RelativeMonadMorphism
import SecondOrder.Instantiation
import SecondOrder.IndexedCategory
import SecondOrder.RelativeKleisli
import SecondOrder.Mslot
import SecondOrder.MRelativeMonad
import SecondOrder.VRelativeMonad
module SecondOrder.MRelMonMorphism
{ℓ}
{𝔸 : SecondOrder.Arity.Arity}
(Σ : SecondOrder.Signature.Signature ℓ 𝔸)
where
open SecondOrder.Signature.Signature Σ
open SecondOrder.Metavariable Σ
open SecondOrder.Term Σ
open SecondOrder.VRenaming Σ
open SecondOrder.MRenaming Σ
open SecondOrder.Mslot Σ
open SecondOrder.Substitution Σ
open SecondOrder.Instantiation Σ
open SecondOrder.MRelativeMonad Σ
open SecondOrder.VRelativeMonad Σ
open SecondOrder.RelativeMonadMorphism
module MRelMonMorph {Γ Γ′ : VContext} where
open MTerm {Γ} renaming (MMonad to M_Γ)
open MTerm {Γ′} renaming (MMonad to M_Γ′)
Fᴹ : ∀ (ρ : Γ ⇒ᵛ Γ′) → RMonadMorph (M_Γ) (M_Γ′)
Fᴹ ρ = record
{ morph = λ Γᴹ Aᴹ →
record
{ _⟨$⟩_ = [ ⇑ᵛ ρ ]ᵛ_
; cong = λ M≈N → []ᵛ-resp-≈ M≈N
}
; law-unit = λ Γᴹ Aᴹ M≡N → ≈-≡
(I-resp-≡
{I = λ M → tm-meta M λ i → tm-var (var-inr i) }
M≡N)
; law-extend = λ {Θ} {Ω} {k} Γᴹ Aᴹ {s} {t} s≈t →
≈-trans
([ᵛ∘ⁱ] s)
(≈-trans
([]ⁱ-resp-≈
(⇑ᵛ ρ ᵛ∘ⁱ ⇑ⁱ (λ {Λ} {B} →
Function.Equality._⟨$⟩_ (k Λ B)))
([]ᵛ-resp-≈ s≈t))
([]ⁱ-resp-≈ⁱ ([ (⇑ᵛ ρ) ]ᵛ t) λ M →
(≈-trans
(≈-sym [∘ᵛ])
(≈-trans
([]ᵛ-resp-≡ᵛ extend-aux)
[∘ᵛ]))))
}
where
extend-aux : ∀ {Ξ Λ} → ⇑ᵛ {Ξ = Ξ} (⇑ᵛ {Ξ = Λ} ρ) ∘ᵛ (⇑ᵛ var-inl) ≡ᵛ ⇑ᵛ var-inl ∘ᵛ (⇑ᵛ ρ)
extend-aux (var-inl x) = refl
extend-aux (var-inr x) = refl
-- Attempt with substitutions instead of renamings : not sure it works
-- hat : (f : (Θ : MContext) → Θ ⊕ Γ ⇒ˢ Γ') → RMonadMorph M_Γ M_Γ'
-- hat f =
-- let open Function.Equality using (_⟨$⟩_) renaming (cong to func-cong) in
-- record
-- { morph = λ {Θ} Δ A → record { _⟨$⟩_ = λ t → [ ⇑ˢ (f Θ) ]ˢ t ; cong = []ˢ-resp-≈ (⇑ˢ (f Θ))}
-- ; law-unit = λ Δ A {t} {s} t≡s → ≈-≡ (cong tm-meta-generic t≡s)
-- ; law-extend = λ {Θ} {Ψ} {I} Δ A {t} {s} t≈s →
-- let open SetoidR (Term-setoid Ψ (Γ' ,, Δ) A) in
-- begin
-- ([ ⇑ˢ (f Ψ) ]ˢ ([ ⇑ⁱ (λ {Λ} {B} M → (I Λ B ⟨$⟩ M) ) ]ⁱ t) )
-- ≈⟨ {!!} ⟩ -- this is the crucial step
-- ([ ⇑ⁱ (λ {Λ} {B} M → [ ⇑ˢ (f Ψ) ]ˢ (I Λ B ⟨$⟩ M)) ]ⁱ ([ ⇑ˢ (f Θ) ]ˢ t))
-- ≈⟨ []ⁱ-resp-≈ (⇑ⁱ (λ {Λ} {B} M → [ ⇑ˢ (f Ψ) ]ˢ (I Λ B ⟨$⟩ M))) ([]ˢ-resp-≈ (⇑ˢ (f Θ)) t≈s) ⟩
-- ([ ⇑ⁱ (λ {Λ} {B} M → [ ⇑ˢ (f Ψ) ]ˢ (I Λ B ⟨$⟩ M)) ]ⁱ ([ ⇑ˢ (f Θ) ]ˢ s))
-- ∎
-- }
| {
"alphanum_fraction": 0.455126629,
"avg_line_length": 35.3652173913,
"ext": "agda",
"hexsha": "ddebd1e1042b52800bc99ee07f96f86094dd346b",
"lang": "Agda",
"max_forks_count": 6,
"max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z",
"max_forks_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cilinder/formaltt",
"max_forks_repo_path": "src/SecondOrder/MRelMonMorphism.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb",
"max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cilinder/formaltt",
"max_issues_repo_path": "src/SecondOrder/MRelMonMorphism.agda",
"max_line_length": 107,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cilinder/formaltt",
"max_stars_repo_path": "src/SecondOrder/MRelMonMorphism.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z",
"num_tokens": 1462,
"size": 4067
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.CommRing.Instances.MultivariatePoly where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat renaming(_+_ to _+n_; _·_ to _·n_)
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Instances.Int
open import Cubical.Algebra.Polynomials.Multivariate.Base
open import Cubical.Algebra.Polynomials.Multivariate.Properties
private variable
ℓ : Level
-----------------------------------------------------------------------------
-- General Nth polynome
module _
(A : CommRing ℓ)
(n : ℕ)
where
open CommRingStr
open RingTheory (CommRing→Ring A)
open Nth-Poly-structure A n
PolyCommRing : CommRing ℓ
fst PolyCommRing = Poly A n
0r (snd PolyCommRing) = 0P
1r (snd PolyCommRing) = 1P
_+_ (snd PolyCommRing) = _poly+_
_·_ (snd PolyCommRing) = _poly*_
- snd PolyCommRing = polyInv
isCommRing (snd PolyCommRing) = makeIsCommRing
trunc
poly+Assoc
poly+IdR
poly+InvR
poly+Comm
poly*Assoc
poly*IdR
poly*DistR
poly*Comm
-----------------------------------------------------------------------------
-- Notation and syntax in the case 1,2,3 and ℤ
module _
(Ar@(A , Astr) : CommRing ℓ)
(n : ℕ)
where
A[X1,···,Xn] : CommRing ℓ
A[X1,···,Xn] = PolyCommRing Ar n
A[x1,···,xn] : Type ℓ
A[x1,···,xn] = fst (A[X1,···,Xn])
| {
"alphanum_fraction": 0.5231129315,
"avg_line_length": 27.564516129,
"ext": "agda",
"hexsha": "212fc7ba5ed41946e952dedb5d481c8ffcd09c81",
"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": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guilhermehas/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/MultivariatePoly.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"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": "guilhermehas/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/MultivariatePoly.agda",
"max_line_length": 77,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guilhermehas/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/MultivariatePoly.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": 452,
"size": 1709
} |
-- 2013-02-18 reported by rotsor
module Issue796 where
data U : Set where
a b : U
data A : Set where
data B : Set where
module Abs where
abstract
A' B' : Set
A' = A
B' = B
module Conc where
open Abs
-- Andreas, 2013-02-19
-- this function should not be injective, since here
-- it is not known whether A' and B' are actually different
[_] : U → Set
[_] a = A'
[_] b = B'
f : ∀ u → [ u ] → U
f u _ = u
postulate x : A'
zzz = f _ x
| {
"alphanum_fraction": 0.5805084746,
"avg_line_length": 13.4857142857,
"ext": "agda",
"hexsha": "60e5d505af6e71fbaa0e18b872296bccece1cd5c",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue796.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue796.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": "test/Fail/Issue796.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": 174,
"size": 472
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Functions.Involution where
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
isInvolution : ∀{ℓ} {A : Type ℓ} → (A → A) → Type _
isInvolution f = ∀ x → f (f x) ≡ x
module _ {ℓ} {A : Type ℓ} {f : A → A} (invol : isInvolution f) where
open Iso
involIso : Iso A A
involIso .fun = f
involIso .inv = f
involIso .rightInv = invol
involIso .leftInv = invol
involIsEquiv : isEquiv f
involIsEquiv = isoToIsEquiv involIso
involEquiv : A ≃ A
involEquiv = f , involIsEquiv
involPath : A ≡ A
involPath = ua involEquiv
involEquivComp : compEquiv involEquiv involEquiv ≡ idEquiv A
involEquivComp
= equivEq (λ i x → invol x i)
involPathComp : involPath ∙ involPath ≡ refl
involPathComp
= sym (uaCompEquiv involEquiv involEquiv) ∙∙ cong ua involEquivComp ∙∙ uaIdEquiv
involPath² : Square involPath refl refl involPath
involPath²
= subst (λ s → Square involPath s refl involPath)
involPathComp (compPath-filler involPath involPath)
| {
"alphanum_fraction": 0.7117039587,
"avg_line_length": 27.023255814,
"ext": "agda",
"hexsha": "b1240a11782e96ecf5e024d725f3b183dc9d6627",
"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/Functions/Involution.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/Functions/Involution.agda",
"max_line_length": 84,
"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/Functions/Involution.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 390,
"size": 1162
} |
open import Agda.Builtin.List
foldr : {A B : Set} → (A → B → B) → B → List A → B
foldr _⊕_ ε [] = ε
foldr _⊕_ ε (x ∷ xs) = x ⊕ foldr _⊕_ ε xs
infixr 5 _++_
_++_ : {A : Set} → List A → List A → List A
xs ++ ys = foldr _∷_ ys xs
record R (F : Set → Set) : Set₁ where
field
f : {A : Set} → A → F A → F A
open R ⦃ … ⦄ public
postulate
D : {A : Set} → List A → Set
easy : {A : Set} {@0 xs : List A} → D xs
record Q (A : Set) : Set where
field
@0 index : List A
d : D index
g : {A : Set} → A → Q A → Q A
g x q .Q.index = q .Q.index ++ x ∷ []
g x q .Q.d = easy
record _×_ (A B : Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A
postulate
m₁ : {A : Set} {B : Maybe A → Set} →
((x : A) → B (just x)) → (x : Maybe A) → B x
m₂ : {A B : Set} → (A → Maybe B) → Maybe A → Maybe B
m₂ f x = m₁ f x
postulate
P : {A : Set} → A → Set
p : {A : Set} (x : A) → P x
A : Set
x : Maybe (A × Q A)
instance
_ : R Q
_ = record { f = g }
_ : P (m₂ (λ { (x , q) → just (f x q) }) x)
_ = p (m₁ (λ { (x , q) → just (f x q) }) x)
| {
"alphanum_fraction": 0.4693356048,
"avg_line_length": 19.2459016393,
"ext": "agda",
"hexsha": "6ed34526b6025c220aef420bbedb0e9cad0b5a19",
"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/Issue4137.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/Issue4137.agda",
"max_line_length": 52,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue4137.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": 518,
"size": 1174
} |
{-# OPTIONS --without-K #-}
-- The core types behind exploration functions
module Explore.Core where
open import Level.NP
open import Algebra
open import Type hiding (★)
open import Function using (id; _∘_; _∘′_)
open import Data.Nat.NP using (ℕ)
open import Data.Two using (𝟚)
open import Data.Maybe.NP using (_→?_)
open import Relation.Unary.Logical
open import Relation.Binary.Logical
module _ {a} where
BigOp : ∀ {ℓ} → ★ ℓ → ★ a → ★ (a ⊔ ℓ)
BigOp M A = (A → M) → M
Explore : ∀ ℓ → ★_ a → ★ (a ⊔ ₛ ℓ)
Explore ℓ A = ∀ {M : ★ ℓ} (ε : M) (_∙_ : M → M → M) → BigOp M A
BigOpMon : ∀ {c ℓ} → Monoid c ℓ → ★ a → ★ _
BigOpMon M A = BigOp (Monoid.Carrier M) A
ExploreMon : ∀ c ℓ → ★ a → ★ _
ExploreMon c ℓ A = (M : Monoid c ℓ) → BigOpMon M A
Explore₀ : ★ a → ★(a ⊔ ₁)
Explore₀ = Explore ₀
Explore₁ : ★ a → ★(a ⊔ ₂)
Explore₁ = Explore ₁
Sum : ★ a → ★ a
Sum = BigOp ℕ
Product : ★ a → ★ a
Product = BigOp ℕ
Count : ★ a → ★ a
Count A = (A → 𝟚) → ℕ
Find? : ∀ {b} → ★ a → ★(ₛ b ⊔ a)
Find? {b} A = ∀ {B : ★ b} → (A →? B) →? B
FindKey : ★ a → ★ a
FindKey A = (A → 𝟚) →? A
-- These three basic combinators are defined here
-- since they are used to define ExploreInd
module _ {ℓ} {A : ★ a} where
merge-explore : Explore ℓ A → Explore ℓ A → Explore ℓ A
merge-explore e₀ e₁ ε _∙_ f = e₀ ε _∙_ f ∙ e₁ ε _∙_ f
empty-explore : Explore ℓ A
empty-explore ε _ _ = ε
point-explore : A → Explore ℓ A
point-explore x _ _ f = f x
[Explore] : ∀ {a aₚ} → ([★₀] [→] [★] (ₛ (a ⊔ aₚ))) (Explore a)
[Explore] {a} {aₚ} Aₚ = ∀⟨ Mₚ ∶ [★] (a ⊔ aₚ)⟩[→] Mₚ [→] [Op₂] {_} {aₚ} Mₚ [→] (Aₚ [→] Mₚ) [→] Mₚ
module _ {ℓ₁ ℓ₂} ℓᵣ {a₁ a₂ aᵣ} where
⟦Explore⟧ : (⟦★⟧ {a₁} {a₂} aᵣ ⟦→⟧ ⟦★⟧ (a₁ ⊔ a₂ ⊔ aᵣ ⊔ ₛ (ℓ₁ ⊔ ℓ₂ ⊔ ℓᵣ))) (Explore ℓ₁) (Explore ℓ₂)
⟦Explore⟧ Aᵣ = ∀⟨ Mᵣ ∶ ⟦★⟧ (ℓ₁ ⊔ ℓ₂ ⊔ ℓᵣ) ⟩⟦→⟧ Mᵣ ⟦→⟧ ⟦Op₂⟧ {_} {_} {ℓᵣ} Mᵣ ⟦→⟧ (Aᵣ ⟦→⟧ Mᵣ) ⟦→⟧ Mᵣ
⟦Explore⟧₀ : (⟦★₀⟧ ⟦→⟧ ⟦★₁⟧) (Explore _) (Explore _)
⟦Explore⟧₀ = ⟦Explore⟧ _
-- -}
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.5055636188,
"avg_line_length": 27.56,
"ext": "agda",
"hexsha": "f79d9da0632eea0c8e3f22e2948f21a343558b4d",
"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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crypto-agda/explore",
"max_forks_repo_path": "lib/Explore/Core.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "crypto-agda/explore",
"max_issues_repo_path": "lib/Explore/Core.agda",
"max_line_length": 102,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crypto-agda/explore",
"max_stars_repo_path": "lib/Explore/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
"num_tokens": 985,
"size": 2067
} |
module L.Base.Nat.Core where
-- Introducing Nat type with constructors zero and succ
data Nat : Set where
zero : Nat
succ : Nat → Nat
-- Enabling the usage of numerals in code.
{-# BUILTIN NATURAL Nat #-}
ind : ∀{c} (C : Nat → Set c)
→ C zero → ((x : Nat) → C x → C (succ x))
→ (n : Nat) → C n
ind C cₒ cₛ zero = cₒ
ind C cₒ cₛ (succ n) = cₛ n (ind C cₒ cₛ n)
| {
"alphanum_fraction": 0.5946666667,
"avg_line_length": 23.4375,
"ext": "agda",
"hexsha": "b05fbeb156a9e06a7d321a2f255dc1ad33674df9",
"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": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "borszag/smallib",
"max_forks_repo_path": "src/L/Base/Nat/Core.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "borszag/smallib",
"max_issues_repo_path": "src/L/Base/Nat/Core.agda",
"max_line_length": 55,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "borszag/smallib",
"max_stars_repo_path": "src/L/Base/Nat/Core.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 143,
"size": 375
} |
module Load where
data Bool : Set where
tt : Bool
ff : Bool
| {
"alphanum_fraction": 0.6615384615,
"avg_line_length": 10.8333333333,
"ext": "agda",
"hexsha": "69ebbaf8a6775352b196f0600e8573b4f021cbce",
"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/Interactive/Load.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/Interactive/Load.agda",
"max_line_length": 21,
"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/Interactive/Load.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": 20,
"size": 65
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.MorphismProperties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Functions.Embedding
open import Cubical.Data.Sigma
open import Cubical.Structures.Axioms
open import Cubical.Structures.Pointed
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Morphism
open import Cubical.Reflection.StrictEquiv
private
variable
ℓ ℓ' ℓ'' : Level
open Iso
open GroupStr
open GroupHom
isPropIsGroupHom : (G : Group {ℓ}) (H : Group {ℓ'}) {f : ⟨ G ⟩ → ⟨ H ⟩} → isProp (isGroupHom G H f)
isPropIsGroupHom G H {f} = isPropΠ2 λ a b → GroupStr.is-set (snd H) _ _
isSetGroupHom : {G : Group {ℓ}} {H : Group {ℓ'}} → isSet (GroupHom G H)
isSetGroupHom {G = G} {H = H} = isOfHLevelRespectEquiv 2 equiv (isSetΣ (isSetΠ λ _ → is-set (snd H)) λ _ → isProp→isSet (isPropIsGroupHom G H)) where
equiv : (Σ[ g ∈ (⟨ G ⟩ → ⟨ H ⟩) ] (isGroupHom G H g)) ≃ (GroupHom G H)
equiv = isoToEquiv (iso (λ (g , m) → grouphom g m) (λ hom → fun hom , isHom hom) (λ _ → refl) λ _ → refl)
-- Morphism composition
isGroupHomComp : {F : Group {ℓ}} {G : Group {ℓ'}} {H : Group {ℓ''}} →
(f : GroupHom F G) → (g : GroupHom G H) → isGroupHom F H (fun g ∘ fun f)
isGroupHomComp f g x y = cong (fun g) (isHom f _ _) ∙ isHom g _ _
compGroupHom : {F : Group {ℓ}} {G : Group {ℓ'}} {H : Group {ℓ''}} → GroupHom F G → GroupHom G H → GroupHom F H
fun (compGroupHom f g) = fun g ∘ fun f
isHom (compGroupHom f g) = isGroupHomComp f g
open GroupEquiv
compGroupEquiv : {F : Group {ℓ}} {G : Group {ℓ'}} {H : Group {ℓ''}} → GroupEquiv F G → GroupEquiv G H → GroupEquiv F H
eq (compGroupEquiv f g) = compEquiv (eq f) (eq g)
isHom (compGroupEquiv f g) = isHom (compGroupHom (hom f) (hom g))
idGroupEquiv : (G : Group {ℓ}) → GroupEquiv G G
eq (idGroupEquiv G) = idEquiv ⟨ G ⟩
isHom (idGroupEquiv G) = λ _ _ → refl
-- Isomorphism inversion
isGroupHomInv : {G : Group {ℓ}} {H : Group {ℓ'}} (f : GroupEquiv G H) → isGroupHom H G (invEq (GroupEquiv.eq f))
isGroupHomInv {G = G} {H = H} f h h' = isInj-f _ _ (
f' (g (h ⋆² h')) ≡⟨ retEq (eq f) _ ⟩
(h ⋆² h') ≡⟨ sym (cong₂ _⋆²_ (retEq (eq f) h) (retEq (eq f) h')) ⟩
(f' (g h) ⋆² f' (g h')) ≡⟨ sym (isHom (hom f) _ _) ⟩
f' (g h ⋆¹ g h') ∎)
where
f' = fst (eq f)
_⋆¹_ = _+_ (snd G)
_⋆²_ = _+_ (snd H)
g = invEq (eq f)
isInj-f : (x y : ⟨ G ⟩) → f' x ≡ f' y → x ≡ y
isInj-f x y = invEq (_ , isEquiv→isEmbedding (snd (eq f)) x y)
invGroupEquiv : {G : Group {ℓ}} {H : Group {ℓ'}} → GroupEquiv G H → GroupEquiv H G
eq (invGroupEquiv f) = invEquiv (eq f)
isHom (invGroupEquiv f) = isGroupHomInv f
dirProdEquiv : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Group {ℓ}} {B : Group {ℓ'}} {C : Group {ℓ''}} {D : Group {ℓ'''}}
→ GroupEquiv A C → GroupEquiv B D
→ GroupEquiv (dirProd A B) (dirProd C D)
eq (dirProdEquiv eq1 eq2) = ≃-× (eq eq1) (eq eq2)
isHom (dirProdEquiv eq1 eq2) = isHom (×hom (GroupEquiv.hom eq1) (GroupEquiv.hom eq2))
groupHomEq : {G : Group {ℓ}} {H : Group {ℓ'}} {f g : GroupHom G H} → (fun f ≡ fun g) → f ≡ g
fun (groupHomEq p i) = p i
isHom (groupHomEq {G = G} {H = H} {f = f} {g = g} p i) = p-hom i
where
p-hom : PathP (λ i → isGroupHom G H (p i)) (isHom f) (isHom g)
p-hom = toPathP (isPropIsGroupHom G H _ _)
groupEquivEq : {G : Group {ℓ}} {H : Group {ℓ'}} {f g : GroupEquiv G H} → (eq f ≡ eq g) → f ≡ g
eq (groupEquivEq {G = G} {H = H} {f} {g} p i) = p i
isHom (groupEquivEq {G = G} {H = H} {f} {g} p i) = p-hom i
where
p-hom : PathP (λ i → isGroupHom G H (p i .fst)) (isHom f) (isHom g)
p-hom = toPathP (isPropIsGroupHom G H _ _)
module GroupΣTheory {ℓ} where
RawGroupStructure : Type ℓ → Type ℓ
RawGroupStructure = SemigroupΣTheory.RawSemigroupStructure
RawGroupEquivStr : StrEquiv RawGroupStructure _
RawGroupEquivStr = SemigroupΣTheory.RawSemigroupEquivStr
rawGroupUnivalentStr : UnivalentStr RawGroupStructure _
rawGroupUnivalentStr = SemigroupΣTheory.rawSemigroupUnivalentStr
-- The neutral element and the inverse function will be derived from the
-- axioms, instead of being defined in the RawGroupStructure in order
-- to have that group equivalences are equivalences that preserves
-- multiplication (so we don't have to show that they also preserve inversion
-- and neutral element, although they will preserve them).
GroupAxioms : (G : Type ℓ) → RawGroupStructure G → Type ℓ
GroupAxioms G _·_ =
IsSemigroup _·_
× (Σ[ e ∈ G ] ((x : G) → (x · e ≡ x) × (e · x ≡ x))
× ((x : G) → Σ[ x' ∈ G ] (x · x' ≡ e) × (x' · x ≡ e)))
GroupStructure : Type ℓ → Type ℓ
GroupStructure = AxiomsStructure RawGroupStructure GroupAxioms
GroupΣ : Type (ℓ-suc ℓ)
GroupΣ = TypeWithStr ℓ GroupStructure
-- Structured equivalences for groups are those for monoids (but different axioms)
GroupEquivStr : StrEquiv GroupStructure ℓ
GroupEquivStr = AxiomsEquivStr RawGroupEquivStr GroupAxioms
open MonoidTheory
isSetGroupΣ : (G : GroupΣ)
→ isSet _
isSetGroupΣ (_ , _ , (isSemigroup-G , _ , _)) = IsSemigroup.is-set isSemigroup-G
isPropGroupAxioms : (G : Type ℓ)
→ (s : RawGroupStructure G)
→ isProp (GroupAxioms G s)
isPropGroupAxioms G _+_ = isPropΣ (isPropIsSemigroup _) γ
where
γ : (h : IsSemigroup _+_) →
isProp (Σ[ e ∈ G ] ((x : G) → (x + e ≡ x) × (e + x ≡ x))
× ((x : G) → Σ[ x' ∈ G ] (x + x' ≡ e) × (x' + x ≡ e)))
γ h (e , P , _) (e' , Q , _) =
Σ≡Prop (λ x → isPropΣ (isPropΠ λ _ → isProp× ((IsSemigroup.is-set h) _ _) ((IsSemigroup.is-set h) _ _)) (β x))
(sym (fst (Q e)) ∙ snd (P e'))
where
β : (e : G) → ((x : G) → (x + e ≡ x) × (e + x ≡ x))
→ isProp ((x : G) → Σ[ x' ∈ G ] (x + x' ≡ e) × (x' + x ≡ e))
β e He =
isPropΠ λ { x (x' , _ , P) (x'' , Q , _) →
Σ≡Prop (λ _ → isProp× ((IsSemigroup.is-set h) _ _) ((IsSemigroup.is-set h) _ _))
(inv-lemma ℳ x x' x'' P Q) }
where
ℳ : Monoid
ℳ = makeMonoid e _+_ (IsSemigroup.is-set h) (IsSemigroup.assoc h) (λ x → He x .fst) (λ x → He x .snd)
Group→GroupΣ : Group → GroupΣ
Group→GroupΣ (G , GS) = _ , _ , (isSemigroup GS , _ , identity GS , λ x → (- GS) x , inverse GS x)
GroupΣ→Group : GroupΣ → Group
GroupΣ→Group (G , _ , SG , _ , H0g , invertible ) =
group _ _ _ (λ x → invertible x .fst) (isgroup (ismonoid SG H0g) λ x → invertible x .snd)
GroupIsoGroupΣ : Iso Group GroupΣ
GroupIsoGroupΣ = iso Group→GroupΣ GroupΣ→Group (λ _ → refl) (λ _ → refl)
groupUnivalentStr : UnivalentStr GroupStructure GroupEquivStr
groupUnivalentStr = axiomsUnivalentStr _ isPropGroupAxioms rawGroupUnivalentStr
GroupΣPath : (G H : GroupΣ) → (G ≃[ GroupEquivStr ] H) ≃ (G ≡ H)
GroupΣPath = SIP groupUnivalentStr
GroupEquivΣ : (G H : Group) → Type ℓ
GroupEquivΣ G H = Group→GroupΣ G ≃[ GroupEquivStr ] Group→GroupΣ H
GroupIsoΣPath : {G H : Group} → Iso (GroupEquiv G H) (GroupEquivΣ G H)
fun GroupIsoΣPath f = (eq f) , isHom f
inv GroupIsoΣPath (e , h) = groupequiv e h
rightInv GroupIsoΣPath _ = refl
leftInv GroupIsoΣPath _ = refl
GroupPath : (G H : Group) → (GroupEquiv G H) ≃ (G ≡ H)
GroupPath G H =
GroupEquiv G H ≃⟨ strictIsoToEquiv GroupIsoΣPath ⟩
GroupEquivΣ G H ≃⟨ GroupΣPath _ _ ⟩
Group→GroupΣ G ≡ Group→GroupΣ H ≃⟨ isoToEquiv (invIso (congIso GroupIsoGroupΣ)) ⟩
G ≡ H ■
RawGroupΣ : Type (ℓ-suc ℓ)
RawGroupΣ = TypeWithStr ℓ RawGroupStructure
Group→RawGroupΣ : Group → RawGroupΣ
Group→RawGroupΣ (G , GS) = G , _+_ GS
InducedGroup : (G : Group) (H : RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
→ RawGroupEquivStr (Group→RawGroupΣ G) H e → Group
InducedGroup G H e r =
GroupΣ→Group (inducedStructure rawGroupUnivalentStr (Group→GroupΣ G) H (e , r))
InducedGroupPath : (G : Group {ℓ}) (H : RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
(E : RawGroupEquivStr (Group→RawGroupΣ G) H e)
→ G ≡ InducedGroup G H e E
InducedGroupPath G H e E =
GroupPath G (InducedGroup G H e E) .fst (groupequiv e E)
-- Extract the characterization of equality of groups
GroupPath : (G H : Group {ℓ}) → (GroupEquiv G H) ≃ (G ≡ H)
GroupPath = GroupΣTheory.GroupPath
InducedGroup : (G : Group {ℓ}) (H : GroupΣTheory.RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
→ GroupΣTheory.RawGroupEquivStr (GroupΣTheory.Group→RawGroupΣ G) H e
→ Group
InducedGroup = GroupΣTheory.InducedGroup
InducedGroupPath : (G : Group {ℓ}) (H : GroupΣTheory.RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
(E : GroupΣTheory.RawGroupEquivStr (GroupΣTheory.Group→RawGroupΣ G) H e)
→ G ≡ InducedGroup G H e E
InducedGroupPath = GroupΣTheory.InducedGroupPath
uaGroup : {G H : Group {ℓ}} → GroupEquiv G H → G ≡ H
uaGroup {G = G} {H = H} = equivFun (GroupPath G H)
carac-uaGroup : {G H : Group {ℓ}} (f : GroupEquiv G H) → cong ⟨_⟩ (uaGroup f) ≡ ua (GroupEquiv.eq f)
carac-uaGroup f = ua (eq f) ∙ refl ≡⟨ sym (rUnit _) ⟩
ua (eq f) ∎
-- Group-ua functoriality
Group≡ : (G H : Group {ℓ}) → (
Σ[ p ∈ ⟨ G ⟩ ≡ ⟨ H ⟩ ]
Σ[ q ∈ PathP (λ i → p i) (0g (snd G)) (0g (snd H)) ]
Σ[ r ∈ PathP (λ i → p i → p i → p i) (_+_ (snd G)) (_+_ (snd H)) ]
Σ[ s ∈ PathP (λ i → p i → p i) (- snd G) (- 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 (0g ∘ snd) x , cong (_+_ ∘ snd) x , cong (-_ ∘ 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) ≡ refl
uaGroupId G = caracGroup≡ _ _ (carac-uaGroup (idGroupEquiv G) ∙ 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))
≡⟨ carac-uaGroup (compGroupEquiv f g) ⟩
ua (eq (compGroupEquiv f g))
≡⟨ uaCompEquiv _ _ ⟩
ua (eq f) ∙ ua (eq g)
≡⟨ cong (_∙ ua (eq g)) (sym (carac-uaGroup f)) ⟩
cong ⟨_⟩ (uaGroup f) ∙ ua (eq g)
≡⟨ cong (cong ⟨_⟩ (uaGroup f) ∙_) (sym (carac-uaGroup g)) ⟩
cong ⟨_⟩ (uaGroup f) ∙ cong ⟨_⟩ (uaGroup g)
≡⟨ sym (cong-∙ ⟨_⟩ (uaGroup f) (uaGroup g)) ⟩
cong ⟨_⟩ (uaGroup f ∙ uaGroup g) ∎) where
open GroupEquiv
| {
"alphanum_fraction": 0.6013763008,
"avg_line_length": 41.9577464789,
"ext": "agda",
"hexsha": "6883ff74f2ef6371fdc5868be7389bfd5204b5ac",
"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/Algebra/Group/MorphismProperties.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/Algebra/Group/MorphismProperties.agda",
"max_line_length": 149,
"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/Algebra/Group/MorphismProperties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4649,
"size": 11916
} |
module WrongHidingInLHS where
f : Set -> Set
f {x} = x
| {
"alphanum_fraction": 0.6379310345,
"avg_line_length": 8.2857142857,
"ext": "agda",
"hexsha": "d12e87376a5600992d99bd9e5c071cbd1b99cdd1",
"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/WrongHidingInLHS.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/WrongHidingInLHS.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/Fail/WrongHidingInLHS.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": 23,
"size": 58
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Monads
------------------------------------------------------------------------
-- Note that currently the monad laws are not included here.
{-# OPTIONS --without-K --safe #-}
module Category.Monad where
open import Function
open import Category.Monad.Indexed
open import Data.Unit
RawMonad : ∀ {f} → (Set f → Set f) → Set _
RawMonad M = RawIMonad {I = ⊤} (λ _ _ → M)
RawMonadT : ∀ {f} (T : (Set f → Set f) → (Set f → Set f)) → Set _
RawMonadT T = RawIMonadT {I = ⊤} (λ M _ _ → T (M _ _))
RawMonadZero : ∀ {f} → (Set f → Set f) → Set _
RawMonadZero M = RawIMonadZero {I = ⊤} (λ _ _ → M)
RawMonadPlus : ∀ {f} → (Set f → Set f) → Set _
RawMonadPlus M = RawIMonadPlus {I = ⊤} (λ _ _ → M)
module RawMonad {f} {M : Set f → Set f}
(Mon : RawMonad M) where
open RawIMonad Mon public
module RawMonadZero {f} {M : Set f → Set f}
(Mon : RawMonadZero M) where
open RawIMonadZero Mon public
module RawMonadPlus {f} {M : Set f → Set f}
(Mon : RawMonadPlus M) where
open RawIMonadPlus Mon public
| {
"alphanum_fraction": 0.5270851247,
"avg_line_length": 29.075,
"ext": "agda",
"hexsha": "f627b736ce1cf9f480177e31d541252faf95f3e9",
"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/Category/Monad.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/Category/Monad.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Category/Monad.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 346,
"size": 1163
} |
{-# OPTIONS --without-K --safe #-}
module Instance where
open import Level
it : ∀ {a} {A : Type a} → ⦃ _ : A ⦄ → A
it ⦃ x ⦄ = x
| {
"alphanum_fraction": 0.5267175573,
"avg_line_length": 14.5555555556,
"ext": "agda",
"hexsha": "bfee23f5887601c07a9362918d10449e339806fb",
"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": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Instance.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Instance.agda",
"max_line_length": 39,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Instance.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 52,
"size": 131
} |
-- Example, ℤ is an Euclidean Domain. Here all the properties needed
-- are already proved in Data.Integer.Properties. However, we will
-- prove there is another divmod pair such that the rank estimation
-- is more precise, see EucDomain2.agda.
{-# OPTIONS --without-K --safe #-}
module Integer.EucDomain where
-- imports from stdlib.
open import Relation.Nullary using (¬_)
open import Relation.Binary.PropositionalEquality using (refl ; _≡_)
open import Data.Nat using (_<_)
open import Data.Integer
using (_+_ ; _*_ ; -_ ; ℤ ; 0ℤ ; 1ℤ ; ∣_∣ ; +[1+_] ; -[1+_] ; +_)
open import Data.Integer.DivMod
renaming (_div_ to _divℤ_; _mod_ to _modℤ_ ; n%d<d to euc-rankℤ; a≡a%n+[a/n]*n to euc-eqℤ)
open import Data.Integer.Properties
using (+-*-isCommutativeRing ; *-cancelˡ-≡)
open import Algebra.Definitions (_≡_ {A = ℤ}) using (AlmostLeftCancellative)
-- imports from local.
import EuclideanDomain
open EuclideanDomain.Structures (_≡_ {A = ℤ})
open EuclideanDomain.Bundles
-- You will notice the recurring pattern that I have to split on
-- the divisor d, and use ¬ d ≡ 0ℤ to exclude the zero divisor
-- case. And addtionally, I have to repeat similary codes
-- twice. This is the price of the translation from ¬ a ≡ 0ℤ to
-- NonZero a. I don't have a good way to avoid this. This become
-- even more awkward when dealing with Gaussian integers since we
-- have more constructor there (meaning more cases and more
-- repeatitions).
-- On the other hand, a translation from NonZero predicate to
-- non-equaity ¬ d ≡ 0ℤ is quite easy. We will use this to define
-- div and mod with instance predicate argument for 𝔾.
-- I could use NonZero predicate in the definition of Euclidean
-- Domain, but that will make the definition more complicated. Also
-- the file "Algebra.Definition" using the same method as here to
-- exclude zero, for example the definition of
-- "AlmostLeftCancellative", so we also comply this convention.
-- div with irrelevant instance argument replaced by non-equality
-- argument.
div : ∀ (n d : ℤ) -> ¬ d ≡ 0ℤ -> ℤ
div n (+ 0) n0 with n0 refl
... | ()
div n d@(+[1+ n₁ ]) n0 = n divℤ d
div n d@(-[1+_] n₁) n0 = n divℤ d
-- mod with irrelevant instance argument replaced by non-equality
-- argument.
mod : ∀ (n d : ℤ) -> ¬ d ≡ 0ℤ -> ℤ
mod n (+ 0) n0 with n0 refl
... | ()
mod n d@(+[1+ n₁ ]) n0 = + (n modℤ d)
mod n d@(-[1+_] n₁) n0 = + (n modℤ d)
-- Divident = reminder + quotient * divisor.
euc-eq : ∀ (n d : ℤ) (n0 : ¬ d ≡ 0ℤ) ->
let r = mod n d n0 in let q = div n d n0 in
n ≡ r + q * d
euc-eq n (+ 0) n0 with n0 refl
... | ()
euc-eq n d@(+[1+ n₁ ]) n0 = euc-eqℤ n d
euc-eq n d@(-[1+_] n₁) n0 = euc-eqℤ n d
-- The rank of the reminder is strictly smaller than the rank of the
-- divisor.
euc-rank : ∀ (n d : ℤ) (n0 : ¬ d ≡ 0ℤ) ->
let r = mod n d n0 in let q = div n d n0 in
∣ r ∣ < ∣ d ∣
euc-rank n (+ 0) n0 with n0 refl
... | ()
euc-rank n d@(+[1+ n₁ ]) n0 = euc-rankℤ n d
euc-rank n d@(-[1+_] n₁) n0 = euc-rankℤ n d
-- Multiplication is left cancellative.
*-alc-ℤ : AlmostLeftCancellative 0ℤ _*_
*-alc-ℤ {+ 0} j k n0 with n0 refl
... | ()
*-alc-ℤ {i@(+[1+ n ])} j k n0 = *-cancelˡ-≡ i j k
*-alc-ℤ { i@(-[1+ n ])} j k n0 = *-cancelˡ-≡ i j k
-- ℤ is an Euclidean Domain.
+-*-isEuclideanDomain : IsEuclideanDomain _+_ _*_ -_ 0ℤ 1ℤ
+-*-isEuclideanDomain = record
{ isCommutativeRing = +-*-isCommutativeRing
; *-alc = *-alc-ℤ
; div = div
; mod = mod
; rank = ∣_∣
; euc-eq = euc-eq
; euc-rank = euc-rank
}
-- Bundle.
+-*-euclideanDomain : EuclideanDomainBundle _ _
+-*-euclideanDomain = record
{ isEuclideanDomain = +-*-isEuclideanDomain
}
| {
"alphanum_fraction": 0.5862068966,
"avg_line_length": 36.3153153153,
"ext": "agda",
"hexsha": "f9a36ce8c59129d5c9a453f42e356a342c4aaf1c",
"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": "7e268e8354065fde734c9c2d9998d2cfd4a21f71",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "onestruggler/EucDomain",
"max_forks_repo_path": "Integer/EucDomain.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71",
"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": "onestruggler/EucDomain",
"max_issues_repo_path": "Integer/EucDomain.agda",
"max_line_length": 94,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7e268e8354065fde734c9c2d9998d2cfd4a21f71",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "onestruggler/EucDomain",
"max_stars_repo_path": "Integer/EucDomain.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1372,
"size": 4031
} |
------------------------------------------------------------------------------
-- The gcd program is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module proves the correctness of the gcd program using
-- the Euclid's algorithm.
module LTC-PCF.Program.GCD.Partial.CorrectnessProof where
open import LTC-PCF.Base
open import LTC-PCF.Data.Nat.Divisibility.NotBy0.Properties
using ( 0∤x ; x∣S→x≤S )
open import LTC-PCF.Data.Nat.Type
open import LTC-PCF.Program.GCD.Partial.CommonDivisor using ( gcdCD )
open import LTC-PCF.Program.GCD.Partial.Definitions using ( x≢0≢y ; gcdSpec )
open import LTC-PCF.Program.GCD.Partial.Divisible using ( gcdDivisible )
open import LTC-PCF.Program.GCD.Partial.GCD using ( gcd )
import LTC-PCF.Program.GCD.Partial.GreatestAnyCommonDivisor
open module GreatestAnyCommonDivisor =
LTC-PCF.Program.GCD.Partial.GreatestAnyCommonDivisor x∣S→x≤S 0∤x
using ( gcdGACD )
open import LTC-PCF.Program.GCD.Partial.Totality using ( gcd-N )
------------------------------------------------------------------------------
-- The gcd is correct
gcdCorrect : ∀ {m n} → N m → N n → x≢0≢y m n → gcdSpec m n (gcd m n)
gcdCorrect Nm Nn m≢0≢n = gcdCD Nm Nn m≢0≢n
, gcdGACD (gcd-N Nm Nn m≢0≢n)
(gcdCD Nm Nn m≢0≢n)
(gcdDivisible Nm Nn m≢0≢n)
| {
"alphanum_fraction": 0.557106599,
"avg_line_length": 40.4102564103,
"ext": "agda",
"hexsha": "a229b9c0a1d2902daa6d004aa8423d0bd6a6f414",
"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/LTC-PCF/Program/GCD/Partial/CorrectnessProof.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/LTC-PCF/Program/GCD/Partial/CorrectnessProof.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/LTC-PCF/Program/GCD/Partial/CorrectnessProof.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": 421,
"size": 1576
} |
module Structure.Operator.Monoid where
import Lvl
open import Logic
open import Logic.Predicate
open import Structure.Setoid
open import Structure.Operator.Properties hiding (associativity ; identityₗ ; identityᵣ)
open import Structure.Operator
open import Type
-- A type and a binary operator using this type is a monoid when:
-- • The operator is associative.
-- • The operator have an identity in both directions.
record Monoid {ℓ ℓₑ} {T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) : Stmt{ℓ Lvl.⊔ ℓₑ} where
constructor intro
field
⦃ binary-operator ⦄ : BinaryOperator(_▫_)
⦃ associativity ⦄ : Associativity(_▫_)
⦃ identity-existence ⦄ : ∃(Identity(_▫_))
id = [∃]-witness identity-existence
identity : Identity (_▫_) id
identity = [∃]-proof identity-existence
identityₗ : Identityₗ (_▫_) id
identityₗ = Identity.left(identity)
identityᵣ : Identityᵣ (_▫_) id
identityᵣ = Identity.right(identity)
identity-existenceₗ : ∃(Identityₗ(_▫_))
identity-existenceₗ = [∃]-intro id ⦃ identityₗ ⦄
identity-existenceᵣ : ∃(Identityᵣ(_▫_))
identity-existenceᵣ = [∃]-intro id ⦃ identityᵣ ⦄
record MonoidObject {ℓ ℓₑ} : Stmt{Lvl.𝐒(ℓ Lvl.⊔ ℓₑ)} where
constructor intro
field
{T} : Type{ℓ}
⦃ equiv ⦄ : Equiv{ℓₑ}(T)
_▫_ : T → T → T
⦃ monoid ⦄ : Monoid(_▫_)
open Monoid(monoid) public
| {
"alphanum_fraction": 0.6784922395,
"avg_line_length": 29.4130434783,
"ext": "agda",
"hexsha": "a987c79e594417d13d3cff69c1d7d1b7144668e3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Operator/Monoid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Operator/Monoid.agda",
"max_line_length": 98,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Operator/Monoid.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": 496,
"size": 1353
} |
module _ where
open import Agda.Builtin.Equality
postulate
A : Set
P : A → Set
data Id (A : Set) : Set where
id : A → Id A
data Flat (@♭ A : Set) : Set where
con : (@♭ x : A) → Flat A
counit : {@♭ A : Set} → Flat A → A
counit (con x) = x
test2 : (@♭ x : Id A) → Flat A
test2 (id x) = con x
test3 : (@♭ x : A) (@♭ y : A) (@♭ p : x ≡ y) → P x → P y
test3 x y refl p = p
test4 : (@♭ x : A) (@♭ y : A) → Flat (x ≡ y) → P x → P y
test4 x y (con refl) p = p
test6 : (@♭ x y : A) → (eq : con x ≡ con y) → P x → P y
test6 x .x refl p = p
| {
"alphanum_fraction": 0.4844606947,
"avg_line_length": 18.8620689655,
"ext": "agda",
"hexsha": "5ad1c8a05c63c5a243f80e74b028fcc6a5209eb7",
"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/FlatSplit.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/FlatSplit.agda",
"max_line_length": 56,
"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/FlatSplit.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": 252,
"size": 547
} |
-- {-# OPTIONS -v 10 #-}
-- {-# OPTIONS -v auto:100 #-}
postulate A : Set
X : Set₂
X = (P : Set₁) → (A → P) → P
foo : X → X
foo x P f = {!!}
-- Invoke Agsy in the hole above. Result:
--
-- Set != Set₁
-- when checking that the expression A has type Set₁
--
-- The error message points to A in the definition of X.
-- x : (P : Set₁) → (A → P) → P
-- P : Set₁
-- f : A → P
-- ? : P
-- Agsy constructs f (x A (λ z → z)) which is ill-typed
-- as A is in the wrong universe.
-- It should take universe levels into account.
-- Temporary fix: discard wrong solution, Agsy returns nothing.
| {
"alphanum_fraction": 0.581512605,
"avg_line_length": 20.5172413793,
"ext": "agda",
"hexsha": "a7ff9eacc3a1efe1e7d5b094ed7e2ea6fc7fc002",
"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/interaction/Issue1504.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/interaction/Issue1504.agda",
"max_line_length": 63,
"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/interaction/Issue1504.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": 195,
"size": 595
} |
module sv20.assign2.Second where
-- The solution for the second task starts in line 53
open import Data.Unit using (⊤; tt)
open import Data.Product using (_×_ ; ∃) renaming (_,_ to ⟨_,_⟩)
open import Relation.Nullary using (¬_)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Function using (_∘_)
-- For the second task. We took one common definition of Subset mentioned in
-- https://stackoverflow.com/q/34183349
-- Notice that this definition is equivalent to the definition presented in the
-- Standard Library where Subset is a "record".
Subset : (A : Set) -> Set _
Subset A = A → Set
-- Because, we are using a different definition from the standard library, we
-- need to define what it means to be included in a subset, what is a relation,
-- what is the range and domain of a relation, and so forth.
_∈_ : ∀ {A} → A → Subset A → Set
a ∈ P = P a
Relation : ∀ A B → Set₁
Relation A B = Subset (A × B)
Range : ∀ {A B} → Relation A B → Subset B
Range R b = ∃ (R ∘ ⟨_, b ⟩) -- equivalent to ∃ \a → R ⟨ a , b ⟩
Dom : ∀ {A B} → Relation A B → Subset A
Dom R a = ∃ (R ∘ ⟨ a ,_⟩) -- equivalent to ∃ \b → R ⟨ a , b ⟩
_⊆_ : ∀ {A} → Subset A → Subset A → Set
A ⊆ B = ∀ x → x ∈ A → x ∈ B
_∩_ : ∀ {A} → Subset A → Subset A → Subset A
A ∩ B = λ x → x ∈ A × x ∈ B
_∪_ : ∀ {A} → Subset A → Subset A → Subset A
A ∪ B = λ x → x ∈ A ⊎ x ∈ B
_/_ : ∀ {A} → Subset A → Subset A → Subset A
A / B = λ x → x ∈ A × ¬ (x ∈ B)
-- Practice theorem
∪-range-⊆ : ∀ {A B} {F G : Relation A B}
→ (Range F ∪ Range G) ⊆ Range (F ∪ G)
∪-range-⊆ _ (inj₁ ⟨ a , fab ⟩) = ⟨ a , inj₁ fab ⟩
∪-range-⊆ _ (inj₂ ⟨ a , gab ⟩) = ⟨ a , inj₂ gab ⟩
-- =========== SOLUTION TO TASK 2 STARTS HERE ===========
-- range-theorem-2
range-∩-⊆ : ∀ {A B} {F G : Relation A B}
→ Range (F ∩ G) ⊆ (Range F ∩ Range G)
range-∩-⊆ b b∈RangeF∩G = -- Given "b ∈ Range (F ∩ G)", we need to prove that "b ∈ (Range F ∩ Range G)"
let
⟨ a , a,b∈F∩G ⟩ = b∈RangeF∩G -- (1) if "b ∈ Range (F ∩ G)" then there exists 'a' such that "(a,b) ∈ (F ∩ G)"
⟨ a,b∈F , a,b∈G ⟩ = a,b∈F∩G -- (2) per definition of intersection, if "(a,b) ∈ (F ∩ G)" then "(a,b) ∈ F" and "(a,b) ∈ G"
b∈RangeF = ⟨ a , a,b∈F ⟩ -- (3) from (1) we know there is an 'a' such that "(a,b) ∈ F" (2), so "b ∈ Range F", per definition of Range
b∈RangeG = ⟨ a , a,b∈G ⟩ -- (4) as above, "b ∈ Range G" because of 'a' (1) and "(a,b) ∈ F" (2)
b∈RangeF∩RangeG = ⟨ b∈RangeF , b∈RangeG ⟩ -- (5) given "b ∈ Range F" (3) and "b ∈ Range G" (4), and definition of ∩ "b ∈ Range F ∩ Range G". QED
in b∈RangeF∩RangeG
-- dom-theorem-3
dom-/-⊆ : ∀ {A B} {F G : Relation A B}
→ (Dom F / Dom G) ⊆ Dom (F / G)
dom-/-⊆ a a∈DomF/DomG = -- Given "a ∈ (Dom F / Dom G)", we need to prove that "a ∈ Dom (F / G)"
let
⟨ a∈DomF , ¬a∈DomG ⟩ = a∈DomF/DomG -- (1) per definition of '/', "a ∈ (Dom F / Dom G)" is the same as "a ∈ Dom F" and "¬ a ∈ Dom G"
⟨ b , a,b∈F ⟩ = a∈DomF -- (2) per definition of 'Dom', if "a ∈ Dom F" then there exists 'b' such that "(a,b) ∈ F"
¬a,b∈G = -- (3) From "¬ a ∈ Dom G" we can prove that "¬ (a, b₁) ∈ G" for any 'b₁'
λ{ a,b∈G → -- (a) By contradiction, suposse that "(a, b₁) ∈ G" for some 'b₁'
let a∈DomG = ⟨ _ , a,b∈G ⟩ -- (b) per definition of 'Dom', "a ∈ Dom G"
in ¬a∈DomG a∈DomG } -- We know that "¬ a ∈ Dom G" (3) and "a ∈ Dom G" (b). Nonesense! So, "¬ (a, b₁) ∈ G" for all 'b₁'
a,b∈F/G = ⟨ a,b∈F , ¬a,b∈G ⟩ -- (4) per definition of '/' and given (2) and (3), "(a, b) ∈ F/G"
a∈DomF/G = ⟨ b , a,b∈F/G ⟩ -- (5) per definition of 'Dom' and given (4) and 'b', we have that "a ∈ Dom (F / G)". QED
in a∈DomF/G
-- range-theorem-3
/-range-⊆ : ∀ {A B} {F G : Relation A B}
→ (Range F / Range G) ⊆ Range (F / G)
/-range-⊆ b b∈RangeF/RangeG = -- Given "b ∈ (Range F / Range G)", we need to prove that "b ∈ Range (F / G)"
let
⟨ b∈RangeF , ¬b∈RangeG ⟩ = b∈RangeF/RangeG -- (1) per definition of '/', "b ∈ Range F" and "¬ b ∈ Range G"
⟨ a , a,b∈F ⟩ = b∈RangeF -- (2) per definition of 'Range', there exists 'a' such that "(a,b) ∈ F"
¬a,b∈G = -- (3) by contradiction, we will prove that "¬ (a, b) ∈ G" given (1)
λ{ a,b∈G → -- (a) suppose that there exists 'a₁' such that "(a₁, b) ∈ G"
let b∈RangeG = ⟨ _ , a,b∈G ⟩ -- (b) per definition of Range and given (a), "b ∈ Range G"
in ¬b∈RangeG b∈RangeG } -- (c) we know from (1) that "¬ b ∈ Range G" but (b) says "b ∈ Range G". Nonesense!
a,b∈F/G = ⟨ a,b∈F , ¬a,b∈G ⟩ -- (4) per definition of '/' and given (2) and (3), then "(a, b) ∈ F / G"
b∈RangeF/G = ⟨ a , a,b∈F/G ⟩ -- (5) per definition of 'Range' and given 'a' and (4), we know that "b ∈ Range (F / G)". QED
in b∈RangeF/G
-- Class exercise
-- This is not really an exercise at all because this is the definition of `⊆`!
exercise103a : ∀ {a} {A B : Subset a}
→ (∀ x → x ∈ A → x ∈ B)
→ A ⊆ B
exercise103a x→x∈A→x∈B = x→x∈A→x∈B
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong)
exercise103id→ : ∀ {a} {A B : Subset a}
→ A ≡ B → A ⊆ B × B ⊆ A
exercise103id→ refl = ⟨ (λ{_ p → p}) , (λ{_ p → p}) ⟩
--exercise103id← : ∀ {a} {A B : Subset a}
-- → A ⊆ B × B ⊆ A → A ≡ B
--exercise103id← ⟨ A⊆B , B⊆A ⟩ = ? -- Probably impossible to prove without unification. Possibly, impossible to prove. Needs `postulate`
exercise108a : ∀ {a} {A B : Subset a} (z : a)
→ (z ∈ A) × (z ∈ B) → z ∈ (A ∩ B)
exercise108a _ ⟨ z∈A , z∈B ⟩ = ⟨ z∈A , z∈B ⟩ -- How to explain this?
| {
"alphanum_fraction": 0.5084011779,
"avg_line_length": 49.3418803419,
"ext": "agda",
"hexsha": "991d20417ec37f543576c568e56e2425f33025b2",
"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/sv20/assign2/Second.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/sv20/assign2/Second.agda",
"max_line_length": 148,
"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/sv20/assign2/Second.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2263,
"size": 5773
} |
module NatTactic where
module _ where
open import Agda.Builtin.Nat
open import Agda.Builtin.List
-- n .. 1
downFrom : Nat → List Nat
downFrom zero = []
downFrom (suc n) = suc n ∷ downFrom n
module AgdaPreludeTest where
open import Prelude
open import Tactic.Nat
-- All tactics know about addition, multiplication and subtraction
-- of natural numbers, and can prove equalities and inequalities (_<_).
-- The available tactics are:
{-
auto
Prove an equation or inequality.
-}
auto-example₁ : (a b : Nat) → (a - b) * (a + b) ≡ a ^ 2 - b ^ 2
auto-example₁ a b = auto
auto-example₂ : (a b : Nat) → (a + b) ^ 2 ≥ a ^ 2 + b ^ 2
auto-example₂ a b = auto
{-
by eq
Prove the goal using the given assumption. For equalities it simplifies
the goal and the assumption and checks if they match any of the following
forms (up to symmetry):
a ≡ b → a ≡ b
a + b ≡ 0 → a ≡ 0
For inequalities, to prove a < b -> c < d, it simplifies the assumption and
goal and then tries to prove c′ ≤ a′ and b′ ≤ d′.
When proving that an inequality follows from an equality a ≡ b, the equality
is weakened to a ≤ b before applying the above procedure.
Proving an equality from an inequality works if the inequality simplifies to
a ≤ 0 (or a < 0 in which case it's trivial). It then reduces that to a ≡ 0
and tries to prove the goal from that.
-}
by-example₁ : (xs ys : List Nat) → sum (xs ++ ys) ≡ sum ys + sum xs
by-example₁ [] ys = auto
by-example₁ (x ∷ xs) ys = by (by-example₁ xs ys)
by-example₂ : (a b c : Nat) → a + c < b + c → a < b
by-example₂ a b c lt = by lt
by-example₃ : (a b : Nat) → a ≡ b * 2 → a + b < (b + 1) * 3
by-example₃ a b eq = by eq
by-example₄ : (a b c : Nat) → a + b + c ≤ b → 2 * c ≡ c
by-example₄ a b c lt = by lt
by-example₅ : (a b c : Nat) → a + b ≡ b + c → 2 + a ≡ 1 + c + 1
by-example₅ a b c eq = by eq
{-
refute eq
Proves an arbitrary proposition given a false equation. Works for equations
that simplify to 0 ≡ suc n (or symmetric) or n < 0, for some n.
-}
refute-example₁ : {Anything : Set} (a : Nat) → a ≡ 2 * a + 1 → Anything
refute-example₁ a eq = refute eq
refute-example₂ : {Anything : Set} (a b : Nat) → a + b < a → Anything
refute-example₂ a b lt = refute lt
{-
simplify-goal ?
Simplify the current goal and let you keep working on the new goal.
In most cases 'by prf' works better than
'simplify-goal => prf' since it will also simplify prf. The advantage
of simplify-goal is that it allows holes in prf.
-}
simplify-goal-example₁ : (a b : Nat) → a - b ≡ b - a → a ≡ b
simplify-goal-example₁ zero b eq = by eq
simplify-goal-example₁ (suc a) zero eq = refute eq
simplify-goal-example₁ (suc a) (suc b) eq =
simplify-goal (simplify-goal-example₁ a b eq)
-- Old goal: suc a ≡ suc b
-- New goal: a ≡ b
simplify-goal-example₂ : (a b : Nat) → a - b ≡ b - a → a < suc b
simplify-goal-example₂ zero b eq = by eq
simplify-goal-example₂ (suc a) zero eq = refute eq
simplify-goal-example₂ (suc a) (suc b) eq =
simplify-goal (simplify-goal-example₂ a b eq)
-- Old goal: suc a ≤ suc b
-- New goal: a ≤ b
simplify-goal-example₃ : (a b c : Nat) → a ≡ c → a + b ≡ b + c
simplify-goal-example₃ a b c eq = simplify-goal eq
{-
simplify eq λ x → ?
Simplify the given equation (and the current goal) and bind the simplified
equation to x in the new goal.
-}
lemma₁ : (a b : Nat) → a + b ≡ 0 → a ≡ 0
lemma₁ zero b eq = refl
lemma₁ (suc a) b eq = refute eq
simplify-example₁ : ∀ a b → (a + 1) * (b + 1) ≡ a * b + 1 → a ≡ 0
simplify-example₁ a b eq = simplify eq λ eq′ → lemma₁ a b eq′
lemma₂ : (a b : Nat) → a + b ≡ 0 → a < suc 0
lemma₂ zero b eq = auto
lemma₂ (suc a) b eq = refute eq
simplify-example₂ : ∀ a b → (a + 1) * (b + 1) ≡ a * b + 1 → a < suc 0
simplify-example₂ a b eq = simplify eq λ eq′ → by (lemma₂ a b eq′)
simplify-example₃ : (a b c : Nat) → a + b ≡ b + c → 2 + a ≡ 1 + c + 1
simplify-example₃ a b c eq = simplify eq λ eq′ → eq′
{-
induction
Prove a goal ∀ n → P n using induction. Applies 'auto' in the base case
and 'by IH' in the step case.
-}
induction-example₁ : ∀ n → sum (downFrom n) * 2 ≡ n * (n + 1)
induction-example₁ = induction
induction-example₂ : ∀ n → sum (downFrom n) * 2 < suc (n * (n + 1))
induction-example₂ = induction
-- some equivalences needed to adapt Tactic.Nat to the standard library
module EquivalenceOf≤ where
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat
open import Data.Nat using (less-than-or-equal) renaming (_≤_ to _≤s_)
open import Data.Nat.Properties using (≤⇒≤″; ≤″⇒≤)
open import Prelude using (diff; id) renaming (_≤_ to _≤p_)
open import Tactic.Nat.Generic (quote _≤p_) (quote id) (quote id) using (by)
≤p→≤s : ∀ {a b} → a ≤p b → a ≤s b
≤p→≤s (diff k b₊₁≡k₊₁+a) = ≤″⇒≤ (less-than-or-equal {k = k} (by b₊₁≡k₊₁+a))
≤s→≤p : ∀ {a b} → a ≤s b → a ≤p b
≤s→≤p a≤sb with ≤⇒≤″ a≤sb
≤s→≤p _ | less-than-or-equal {k = k} a+k≡b = diff k (by a+k≡b)
module StandardLibraryTest where
open import Agda.Builtin.Equality
open import Data.Nat
open import Data.List hiding (downFrom)
open import Function
private
infixr 8 _^_
_^_ : ℕ → ℕ → ℕ
n ^ zero = 1
n ^ suc m = n ^ m * n
open EquivalenceOf≤
open import Tactic.Nat.Generic (quote _≤_) (quote ≤s→≤p) (quote ≤p→≤s)
auto-example₁ : (a b : ℕ) → (a ∸ b) * (a + b) ≡ a ^ 2 ∸ b ^ 2
auto-example₁ a b = auto
auto-example₂ : (a b : ℕ) → (a + b) ^ 2 ≥ a ^ 2 + b ^ 2
auto-example₂ a b = auto
by-example₁ : (xs ys : List ℕ) → sum (xs ++ ys) ≡ sum ys + sum xs
by-example₁ [] ys = auto
by-example₁ (x ∷ xs) ys = by (by-example₁ xs ys)
by-example₂ : (a b c : ℕ) → a + c < b + c → a < b
by-example₂ a b c lt = by lt
by-example₃ : (a b : ℕ) → a ≡ b * 2 → a + b < (b + 1) * 3
by-example₃ a b eq = by eq
by-example₄ : (a b c : ℕ) → a + b + c ≤ b → 2 * c ≡ c
by-example₄ a b c lt = by lt
by-example₅ : (a b c : ℕ) → a + b ≡ b + c → 2 + a ≡ 1 + c + 1
by-example₅ a b c eq = by eq
refute-example₁ : {Anything : Set} (a : ℕ) → a ≡ 2 * a + 1 → Anything
refute-example₁ a eq = refute eq
refute-example₂ : {Anything : Set} (a b : ℕ) → a + b < a → Anything
refute-example₂ a b lt = refute lt
simplify-goal-example₁ : (a b : ℕ) → a ∸ b ≡ b ∸ a → a ≡ b
simplify-goal-example₁ zero b eq = by eq
simplify-goal-example₁ (suc a) zero eq = refute eq
simplify-goal-example₁ (suc a) (suc b) eq =
simplify-goal (simplify-goal-example₁ a b eq)
simplify-goal-example₂ : (a b : ℕ) → a ∸ b ≡ b ∸ a → a < suc b
simplify-goal-example₂ zero b eq = by eq
simplify-goal-example₂ (suc a) zero eq = refute eq
simplify-goal-example₂ (suc a) (suc b) eq =
simplify-goal (by (simplify-goal-example₂ a b eq))
simplify-goal-example₃ : (a b c : ℕ) → a ≡ c → a + b ≡ b + c
simplify-goal-example₃ a b c eq = simplify-goal eq
lemma₁ : (a b : ℕ) → a + b ≡ 0 → a ≡ 0
lemma₁ zero b eq = refl
lemma₁ (suc a) b eq = refute eq
simplify-example₁ : ∀ a b → (a + 1) * (b + 1) ≡ a * b + 1 → a ≡ 0
simplify-example₁ a b eq = simplify eq λ eq′ → lemma₁ a b eq′
lemma₂ : (a b : ℕ) → a + b ≡ 0 → a < suc 0
lemma₂ zero b eq = s≤s z≤n
lemma₂ (suc a) b eq = refute eq
simplify-example₂ : ∀ a b → (a + 1) * (b + 1) ≡ a * b + 1 → a < suc 0
simplify-example₂ a b eq = simplify eq λ eq′ → by (lemma₂ a b eq′)
simplify-example₃ : (a b c : ℕ) → a + b ≡ b + c → 2 + a ≡ 1 + c + 1
simplify-example₃ a b c eq = simplify eq λ eq′ → eq′
induction-example₁ : ∀ n → sum (downFrom n) * 2 ≡ n * (n + 1)
induction-example₁ = induction
induction-example₂ : ∀ n → sum (downFrom n) * 2 < suc (n * (n + 1))
induction-example₂ = induction
| {
"alphanum_fraction": 0.5689019897,
"avg_line_length": 33.2326530612,
"ext": "agda",
"hexsha": "7e1fc861f448b2c8ad70a5515d4e3a4ade20ccaa",
"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": "test/NatTactic.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": "test/NatTactic.agda",
"max_line_length": 80,
"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": "test/NatTactic.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": 2938,
"size": 8142
} |
module Issue326 where
open import Common.Prelude
open import Common.MAlonzo using () -- see issue 561
postulate
QName : Set
printBool : Bool → IO Unit
{-# BUILTIN QNAME QName #-}
{-# COMPILED printBool print #-}
primitive primQNameEquality : QName → QName → Bool
main : IO Unit
main = printBool (primQNameEquality (quote Unit) (quote IO))
| {
"alphanum_fraction": 0.7220630372,
"avg_line_length": 19.3888888889,
"ext": "agda",
"hexsha": "2fe6d82a62d32884cf4edc2458f071cfb5f07de8",
"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/Issue326.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/Issue326.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/Issue326.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": 93,
"size": 349
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- we use duality to prove properties about coequalizer
module Categories.Diagram.Coequalizer.Properties {o ℓ e} (C : Category o ℓ e) where
open Category C
open import Categories.Diagram.Coequalizer C
open import Categories.Morphism C
open import Categories.Diagram.Equalizer op
open import Categories.Diagram.Duality C
private
variable
A B : Obj
f g : A ⇒ B
module _ (coe : Coequalizer f g) where
open Coequalizer coe
private
equalizer : Equalizer f g
equalizer = Coequalizer⇒coEqualizer coe
open Equalizer equalizer
using (unique′; equality-∘; unique-diagram)
renaming ( id-equalize to id-coequalize
; equalize-resp-≈ to coequalize-resp-≈
; equalize-resp-≈′ to coequalize-resp-≈′
)
public
Coequalizer⇒Epi : Epi arr
Coequalizer⇒Epi = Equalizer⇒Mono equalizer
| {
"alphanum_fraction": 0.6950431034,
"avg_line_length": 24.4210526316,
"ext": "agda",
"hexsha": "db8ace34fa275a525f1ffe3b25b7118b289c492e",
"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": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-categories",
"max_forks_repo_path": "src/Categories/Diagram/Coequalizer/Properties.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"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": "bblfish/agda-categories",
"max_issues_repo_path": "src/Categories/Diagram/Coequalizer/Properties.agda",
"max_line_length": 83,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bblfish/agda-categories",
"max_stars_repo_path": "src/Categories/Diagram/Coequalizer/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": 275,
"size": 928
} |
------------------------------------------------------------------------
-- A lookahead operator cannot be defined
------------------------------------------------------------------------
-- In "Parsing with First-Class Derivatives" Brachthäuser, Rendel and
-- Ostermann state that "Lookahead and [...] cannot be expressed as
-- user defined combinators". Here I give a formal proof of a variant
-- of this statement (in the present setting).
module TotalParserCombinators.NoLookahead where
open import Data.List
open import Data.List.Properties
open import Data.Product
open import Data.Unit
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence using (Equivalence; _⇔_)
open import Relation.Binary.PropositionalEquality as PE using (_≡_)
open import Relation.Nullary
open import TotalParserCombinators.Lib
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics.Continuation
-- It is impossible to define a lookahead operator satisfying a
-- certain specification (without changing the interface of the parser
-- combinator library).
no-lookahead :
¬ ∃ λ (look : ∀ {Tok R} {f-bag : List Tok → List R} →
((s : List Tok) → Parser Tok R (f-bag s)) →
Parser Tok R (f-bag [])) →
∀ {Tok R x s₁ s₂} {f-bag : List Tok → List R}
{f : (s : List Tok) → Parser Tok R (f-bag s)} →
x ⊕ s₂ ∈ look f · s₁ ⇔ x ⊕ s₂ ∈ f s₁ · s₁
no-lookahead (look , correct) = ¬f[-]·[-] f[-]·[-]
where
f-bag : List ⊤ → List ⊤
f-bag [] = [ _ ]
f-bag (_ ∷ _) = []
f : (s : List ⊤) → Parser ⊤ ⊤ (f-bag s)
f [] = return _
f (_ ∷ _) = fail
f[]·[] : _ ⊕ [] ∈ f [] · []
f[]·[] = return
look-f·[] : _ ⊕ [] ∈ look f · []
look-f·[] = Equivalence.from correct ⟨$⟩ f[]·[]
look-f·[-] : _ ⊕ [ _ ] ∈ look f · [ _ ]
look-f·[-] = extend look-f·[]
f[-]·[-] : _ ⊕ [ _ ] ∈ f [ _ ] · [ _ ]
f[-]·[-] = Equivalence.to correct ⟨$⟩ look-f·[-]
¬f[-]·[-] : ¬ _ ⊕ [ _ ] ∈ f [ _ ] · [ _ ]
¬f[-]·[-] ()
| {
"alphanum_fraction": 0.5561576355,
"avg_line_length": 33.2786885246,
"ext": "agda",
"hexsha": "2a88c0f78865c21c69e73f67a39d7d65f48cfc54",
"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": "TotalParserCombinators/NoLookahead.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"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/parser-combinators",
"max_issues_repo_path": "TotalParserCombinators/NoLookahead.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalParserCombinators/NoLookahead.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 619,
"size": 2030
} |
------------------------------------------------------------------------------
-- Agda-Prop Library.
-- Theorems of ⇔ connective.
------------------------------------------------------------------------------
open import Data.Nat using ( ℕ )
module Data.PropFormula.Theorems.Biimplication ( n : ℕ ) where
------------------------------------------------------------------------------
open import Data.PropFormula.Theorems.Classical n
open import Data.PropFormula.Theorems.Implication n
using ( ⊃-to-¬∨; ⊃⊃-to-∧⊃; ∧⊃-to-⊃⊃ )
open import Data.PropFormula.Theorems.Negation n
using ( ¬-equiv₁ ; ¬-equiv₂; ¬∨-to-⊃; ¬¬-equiv₁; ¬¬-equiv₂ )
open import Data.PropFormula.Syntax n
open import Function using ( _$_ )
------------------------------------------------------------------------------
-- Theorem.
⇔-equiv₁
: ∀ {Γ} {φ ψ}
→ Γ ⊢ φ ⇔ ψ
→ Γ ⊢ (φ ⊃ ψ) ∧ (ψ ⊃ φ)
-- Proof.
⇔-equiv₁ {Γ}{φ}{ψ} Γ⊢φ⇔ψ =
∧-intro
(⊃-intro
(⇔-elim₁
(assume φ)
(weaken φ Γ⊢φ⇔ψ)))
(⊃-intro
(⇔-elim₂
(assume ψ)
(weaken ψ Γ⊢φ⇔ψ)))
-------------------------------------------------------------------------- ∎
-- Theorem.
⇔-equiv₂
: ∀ {Γ} {φ ψ}
→ Γ ⊢ (φ ⊃ ψ) ∧ (ψ ⊃ φ)
→ Γ ⊢ φ ⇔ ψ
-- Proof.
⇔-equiv₂ {φ = φ}{ψ} Γ⊢⟪φ⊃ψ⟫∧⟪ψ⊃φ⟫ =
⇔-intro
(⊃-elim
(weaken φ (∧-proj₁ Γ⊢⟪φ⊃ψ⟫∧⟪ψ⊃φ⟫))
(assume φ))
(⊃-elim
(weaken ψ (∧-proj₂ Γ⊢⟪φ⊃ψ⟫∧⟪ψ⊃φ⟫))
(assume ψ))
-------------------------------------------------------------------------- ∎
-- Theorem.
⇔-equiv
: ∀ {Γ} {φ ψ}
→ Γ ⊢ (φ ⇔ ψ) ⇔ ((φ ⊃ ψ) ∧ (ψ ⊃ φ))
-- Proof.
⇔-equiv {Γ}{φ}{ψ} =
⇔-intro
(⇔-equiv₁
(assume (φ ⇔ ψ)))
(⇔-equiv₂
(assume ((φ ⊃ ψ) ∧ (ψ ⊃ φ))))
-------------------------------------------------------------------------- ∎
-- Theorem.
⇔-assoc₁
: ∀ {Γ} {φ ψ γ}
→ Γ ⊢ φ ⇔ (ψ ⇔ γ)
→ Γ ⊢ (φ ⇔ ψ) ⇔ γ
-- Proof.
⇔-assoc₁ {Γ}{φ = φ}{ψ}{γ} thm =
⇔-intro
(RAA
(¬-elim
(¬-intro
(¬-elim
(¬-intro
(¬-elim
(weaken φ $ weaken (ψ ⇔ γ) $ assume {Γ = Γ , φ ⇔ ψ} (¬ γ))
(⇔-elim₁
(⇔-elim₁
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ ⇔ γ} φ)
(weaken φ $ weaken (ψ ⇔ γ)
(weaken (¬ γ) $ assume (φ ⇔ ψ))))
(⇔-elim₁
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ ⇔ γ} φ)
(weaken φ $ weaken (ψ ⇔ γ) $ weaken (¬ γ) $
weaken (φ ⇔ ψ) thm)))))
(⇔-elim₂
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ} (ψ ⇔ γ))
(weaken (ψ ⇔ γ) $ weaken (¬ γ) $ weaken (φ ⇔ ψ) thm))))
(⇔-intro
(⊥-elim γ
(¬-elim
(⊥-elim (¬ ψ)
(¬-elim
(¬-intro -- ¬ φ
(¬-elim
(weaken φ $ weaken ψ $ assume {Γ = Γ , φ ⇔ ψ} (¬ γ))
(⇔-elim₁
(⇔-elim₁
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ} φ)
(weaken φ
(weaken ψ
(weaken (¬ γ)
(assume (φ ⇔ ψ))))))
(⇔-elim₁
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ , ψ} φ)
(weaken φ $
weaken ψ $ weaken (¬ γ) $ weaken (φ ⇔ ψ) thm)))))
(⇔-elim₂ -- φ
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ} ψ)
(weaken ψ (weaken (¬ γ) (assume (φ ⇔ ψ)))))))
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ} ψ)))
(⊥-elim ψ
(¬-elim
(weaken γ $ assume {Γ = Γ , φ ⇔ ψ} (¬ γ))
(assume {Γ = Γ , φ ⇔ ψ , ¬ γ} γ))))))
(⇔-intro
(⇔-elim₂
(weaken φ $ assume γ)
(⇔-elim₁
(assume {Γ = Γ , γ} φ)
(weaken φ $ weaken γ thm)))
(⇔-elim₂
(⇔-intro
(weaken ψ $ weaken ψ $ assume γ)
(weaken γ $ assume {Γ = Γ , γ} ψ))
(weaken ψ $ weaken γ thm)))
-------------------------------------------------------------------------- ∎
-- Theorem.
⇔-assoc₂
: ∀ {Γ} {φ ψ γ}
→ Γ ⊢ (φ ⇔ ψ) ⇔ γ
→ Γ ⊢ φ ⇔ (ψ ⇔ γ)
-- Proof.
⇔-assoc₂ {Γ}{φ}{ψ}{γ} thm =
⇔-intro
(⇔-intro
(⇔-elim₁
(⇔-intro
(weaken φ (assume {Γ = Γ , φ} ψ))
(weaken ψ (weaken ψ (assume φ))))
(weaken ψ (weaken φ thm)))
(⇔-elim₁
(weaken γ (assume φ))
(⇔-elim₂
(assume {Γ = Γ , φ} γ)
(weaken γ (weaken φ thm)))))
(RAA
(¬-elim
(¬-intro
(¬-elim
(¬-intro
(¬-elim
(weaken γ $ weaken (φ ⇔ ψ) $ assume {Γ = Γ , ψ ⇔ γ} (¬ φ))
(⇔-elim₂
(⇔-elim₂
(assume {Γ = Γ , ψ ⇔ γ , ¬ φ , (φ ⇔ ψ)} γ)
(weaken γ $ weaken (φ ⇔ ψ) $ weaken (¬ φ) $
assume (ψ ⇔ γ)))
(⇔-elim₂
(assume {Γ = Γ , ψ ⇔ γ , ¬ φ , (φ ⇔ ψ)} γ)
(weaken γ $ weaken (φ ⇔ ψ) $ weaken (¬ φ) $
weaken (ψ ⇔ γ) thm)))))
(⇔-elim₁
(assume {Γ = Γ , ψ ⇔ γ , ¬ φ} (φ ⇔ ψ))
(weaken (φ ⇔ ψ) (weaken (¬ φ) (weaken (ψ ⇔ γ) thm))))))
(⇔-intro
(⊥-elim ψ
(¬-elim
(weaken φ $ assume {Γ = Γ , ψ ⇔ γ} (¬ φ))
(assume {Γ = Γ , ψ ⇔ γ , ¬ φ} φ)))
(⊥-elim φ
(¬-elim
(⊥-elim (¬ ψ)
(¬-elim
(¬-intro
(¬-elim
(weaken γ $ weaken ψ $ assume {Γ = Γ , ψ ⇔ γ} (¬ φ))
(⇔-elim₂
(weaken γ $ assume {Γ = Γ , ψ ⇔ γ , ¬ φ} ψ)
(⇔-elim₂
(assume {Γ = Γ , ψ ⇔ γ , ¬ φ , ψ} γ)
(weaken γ $ weaken ψ $ weaken (¬ φ) $
weaken (ψ ⇔ γ) thm)))))
(⇔-elim₁
(assume {Γ = Γ , ψ ⇔ γ , ¬ φ} ψ)
(weaken ψ (weaken (¬ φ) (assume (ψ ⇔ γ)))))))
(assume {Γ = Γ , ψ ⇔ γ , ¬ φ} ψ))))))
-------------------------------------------------------------------------- ∎
-- Theorem.
⇔-assoc
: ∀ {Γ} {φ ψ γ}
→ Γ ⊢ (φ ⇔ (ψ ⇔ γ)) ⇔ ((φ ⇔ ψ) ⇔ γ)
-- Proof.
⇔-assoc {φ = φ}{ψ}{γ} =
⇔-intro
(⇔-assoc₁ (assume (φ ⇔ ψ ⇔ γ)))
(⇔-assoc₂ (assume ((φ ⇔ ψ) ⇔ γ)))
-------------------------------------------------------------------------- ∎
-- Theorem.
⇔-comm
: ∀ {Γ} {φ ψ}
→ Γ ⊢ φ ⇔ ψ
→ Γ ⊢ ψ ⇔ φ
-- Proof.
⇔-comm {Γ}{φ}{ψ} Γ⊢φ⇔ψ =
⇔-intro
(⇔-elim₂ (assume ψ) (weaken ψ Γ⊢φ⇔ψ))
(⇔-elim₁ (assume φ) (weaken φ Γ⊢φ⇔ψ))
-------------------------------------------------------------------------- ∎
-- Theorem.
⊃-⇔-¬∨
: ∀ {Γ} {φ ψ}
→ Γ ⊢ (φ ⊃ ψ) ⇔ (¬ φ ∨ ψ)
-- Proof.
⊃-⇔-¬∨ {Γ}{φ}{ψ} =
⇔-intro
(⊃-to-¬∨ (assume (φ ⊃ ψ)))
(¬∨-to-⊃ (assume (¬ φ ∨ ψ)))
-------------------------------------------------------------------------- ∎
-- Theorem.
bicon₀-thm
: ∀ {Γ} {φ ψ}
→ Γ ⊢ φ ⇔ ψ → Γ ⊢ ¬ φ
→ Γ ⊢ ¬ ψ
⇔-¬-to-¬ = bicon₀-thm
-- Proof.
bicon₀-thm {Γ}{φ}{ψ} Γ⊢φ⇔ψ Γ⊢¬ψ =
¬-equiv₂
(⊃-intro
(¬-elim
(weaken ψ Γ⊢¬ψ)
(⇔-elim₂
(assume ψ)
(weaken ψ Γ⊢φ⇔ψ))))
-------------------------------------------------------------------------- ∎
-- Theorem.
bicon₁-thm
: ∀ {Γ} {φ ψ}
→ Γ ⊢ ¬ φ ⇔ ψ → Γ ⊢ φ
→ Γ ⊢ ¬ ψ
¬⇔-to-¬ = bicon₁-thm
-- Proof.
bicon₁-thm {Γ}{φ}{ψ} Γ⊢¬φ⇔ψ Γ⊢φ =
¬-equiv₂
(⊃-intro
(¬-elim
(⇔-elim₂
(assume ψ)
(weaken ψ Γ⊢¬φ⇔ψ))
(weaken ψ Γ⊢φ)))
-------------------------------------------------------------------------- ∎
-- Theorem.
¬-equiv
: ∀ {Γ} {φ}
→ Γ ⊢ ¬ φ ⇔ (φ ⊃ ⊥)
-- Proof.
¬-equiv {Γ}{φ} =
⇔-intro
(¬-equiv₁ (assume (¬ φ)))
(¬-equiv₂ (assume (φ ⊃ ⊥)))
-------------------------------------------------------------------------- ∎
-- Theorem.
¬¬-equiv
: ∀ {Γ} {φ}
→ Γ ⊢ ¬ (¬ φ) ⇔ φ
-- Proof.
¬¬-equiv {Γ}{φ} =
⇔-intro
(¬¬-equiv₁ (assume (¬ (¬ φ))))
(¬¬-equiv₂ (assume φ))
-------------------------------------------------------------------------- ∎
-- Theorem.
⊃⊃-⇔-∧⊃
: ∀ {Γ} {φ ψ γ}
→ Γ ⊢ (φ ⊃ (ψ ⊃ γ)) ⇔ ((φ ∧ ψ) ⊃ γ)
-- Proof.
⊃⊃-⇔-∧⊃ {φ = φ}{ψ}{γ} =
⇔-intro
(⊃⊃-to-∧⊃ (assume (φ ⊃ ψ ⊃ γ)))
(∧⊃-to-⊃⊃ (assume (φ ∧ ψ ⊃ γ)))
-------------------------------------------------------------------------- ∎
-- Theorem.
⇔-trans
: ∀ {Γ} {φ ψ γ}
→ Γ ⊢ γ ⇔ φ
→ Γ ⊢ φ ⇔ ψ
→ Γ ⊢ γ ⇔ ψ
subst⊢⇔₁ = ⇔-trans
-- Proof.
⇔-trans {φ = φ}{ψ}{γ} Γ⊢γ⇔φ Γ⊢φ⇔ψ =
⇔-intro
(⇔-elim₁
(⇔-elim₁
(assume γ)
(weaken γ Γ⊢γ⇔φ))
(weaken γ Γ⊢φ⇔ψ))
(⇔-elim₂
(⇔-elim₂
(assume ψ)
(weaken ψ Γ⊢φ⇔ψ))
(weaken ψ Γ⊢γ⇔φ))
-------------------------------------------------------------------------- ∎
| {
"alphanum_fraction": 0.2850744597,
"avg_line_length": 26.5803571429,
"ext": "agda",
"hexsha": "5e9d0d01f978a72e36610da8e2d7f93474598338",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z",
"max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jonaprieto/agda-prop",
"max_forks_repo_path": "src/Data/PropFormula/Theorems/Biimplication.agda",
"max_issues_count": 18,
"max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jonaprieto/agda-prop",
"max_issues_repo_path": "src/Data/PropFormula/Theorems/Biimplication.agda",
"max_line_length": 78,
"max_stars_count": 13,
"max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jonaprieto/agda-prop",
"max_stars_repo_path": "src/Data/PropFormula/Theorems/Biimplication.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z",
"num_tokens": 3602,
"size": 8931
} |
module Logic.ChainReasoning where
module Mono where
module Homogenous
{ A : Set }
( _==_ : A -> A -> Set )
(refl : (x : A) -> x == x)
(trans : (x y z : A) -> x == y -> y == z -> x == z)
where
infix 2 chain>_
infixl 2 _===_
infix 3 _by_
chain>_ : (x : A) -> x == x
chain> x = refl _
_===_ : {x y z : A} -> x == y -> y == z -> x == z
xy === yz = trans _ _ _ xy yz
_by_ : {x : A}(y : A) -> x == y -> x == y
y by eq = eq
module Poly where
module Homogenous
( _==_ : {A : Set} -> A -> A -> Set )
(refl : {A : Set}(x : A) -> x == x)
(trans : {A : Set}(x y z : A) -> x == y -> y == z -> x == z)
where
infix 2 chain>_
infixl 2 _===_
infix 3 _by_
chain>_ : {A : Set}(x : A) -> x == x
chain> x = refl _
_===_ : {A : Set}{x y z : A} -> x == y -> y == z -> x == z
xy === yz = trans _ _ _ xy yz
_by_ : {A : Set}{x : A}(y : A) -> x == y -> x == y
y by eq = eq
module Heterogenous
( _==_ : {A B : Set} -> A -> B -> Set )
(refl : {A : Set}(x : A) -> x == x)
(trans : {A B C : Set}(x : A)(y : B)(z : C) -> x == y -> y == z -> x == z)
where
infix 2 chain>_
infixl 2 _===_
infix 3 _by_
chain>_ : {A : Set}(x : A) -> x == x
chain> x = refl _
_===_ : {A B C : Set}{x : A}{y : B}{z : C} -> x == y -> y == z -> x == z
xy === yz = trans _ _ _ xy yz
_by_ : {A B : Set}{x : A}(y : B) -> x == y -> x == y
y by eq = eq
module Heterogenous1
( _==_ : {A B : Set1} -> A -> B -> Set1 )
(refl : {A : Set1}(x : A) -> x == x)
(trans : {A B C : Set1}(x : A)(y : B)(z : C) -> x == y -> y == z -> x == z)
where
infix 2 chain>_
infixl 2 _===_
infix 3 _by_
chain>_ : {A : Set1}(x : A) -> x == x
chain> x = refl _
_===_ : {A B C : Set1}{x : A}{y : B}{z : C} -> x == y -> y == z -> x == z
xy === yz = trans _ _ _ xy yz
_by_ : {A B : Set1}{x : A}(y : B) -> x == y -> x == y
y by eq = eq
| {
"alphanum_fraction": 0.3855421687,
"avg_line_length": 23.4352941176,
"ext": "agda",
"hexsha": "f062f9acfcb326a7ad76ee299539caced099fa08",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/iird/Logic/ChainReasoning.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/iird/Logic/ChainReasoning.agda",
"max_line_length": 79,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/iird/Logic/ChainReasoning.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": 834,
"size": 1992
} |
{-# OPTIONS --without-K --no-pattern-matching #-}
module Ch2-7 where
open import Level hiding (lift)
open import Ch2-1
open import Ch2-2
open import Ch2-3
open import Ch2-4
open import Ch2-5
open import Ch2-6
open import Data.Product
open import Function using (id; _∘_)
Definition-2-7-2-i : ∀ {a b} {A : Set a} {P : A → Set b}
→ (w w' : Σ[ x ∈ A ] P x)
→ (w ≡ w')
→ (Σ[ p ∈ proj₁ w ≡ proj₁ w' ] transport P p (proj₂ w) ≡ proj₂ w')
Definition-2-7-2-i {_} {_} {A} {P} w w' p = J (Σ-syntax A P) D d w w' p
where
D : (w w' : Σ[ x ∈ A ] P x) (p : w ≡ w') → Set _
D w w' p = Σ[ p ∈ proj₁ w ≡ proj₁ w' ] transport P p (proj₂ w) ≡ proj₂ w'
d : (x : Σ[ x ∈ A ] P x) → D x x refl
d x = refl , refl
Definition-2-7-2-ii : ∀ {a b} {A : Set a} {P : A → Set b}
→ (w w' : Σ[ x ∈ A ] P x)
→ (Σ[ p ∈ proj₁ w ≡ proj₁ w' ] transport P p (proj₂ w) ≡ proj₂ w')
→ (w ≡ w')
Definition-2-7-2-ii {_} {_} {A} {P} w w' p = J A D d (proj₁ w) (proj₁ w') (proj₁ p) (proj₂ w) (proj₂ w') (proj₂ p)
-- J A D d w1 w1' fst w2 w2' snd
where
D : (w1 w1' : A) (p : w1 ≡ w1') → Set _
D w1 w1' p = (w2 : P w1) (w2' : P w1') (q : transport P p w2 ≡ w2') → (w1 , w2) ≡ (w1' , w2')
d : (x : A) → D x x refl
d x w2 w2' snd = J (P x) E e w2 w2' snd
where
E : (w2 w2' : P x) (q : w2 ≡ w2') → Set _
E w2 w2' q = (x , w2) ≡ (x , w2')
e : (y : P x) → E y y refl
e y = refl
Lemma-2-7-2-iii : ∀ {a b} {A : Set a} {P : A → Set b}
→ (w w' : Σ[ x ∈ A ] P x)
→ isequiv (Definition-2-7-2-i w w')
Lemma-2-7-2-iii {_} {_} {A} {P} w w' = (Definition-2-7-2-ii w w' , α) , (Definition-2-7-2-ii w w' , β)
where
α : Definition-2-7-2-i w w' ∘ Definition-2-7-2-ii w w' ~ id
α p = J A D d (proj₁ w) (proj₁ w') (proj₁ p) (proj₂ w) (proj₂ w') (proj₂ p)
where
D : (x y : A) (p : x ≡ y) → Set _
D x y p = (x' : P x) (y' : P y) (q : transport P p x' ≡ y')
→ (Definition-2-7-2-i (x , x') (y , y')
∘ Definition-2-7-2-ii (x , x') (y , y')) (p , q) ≡ id (p , q)
d : (s : A) → D s s refl
d s x' y' q = J (P s) E e x' y' q
where
E : (x' y' : P s) (q : x' ≡ y') → Set _
E x' y' q =
(Definition-2-7-2-i (s , x') (s , y')
∘ Definition-2-7-2-ii (s , x') (s , y')) (refl , q) ≡ id (refl , q)
e : (t : P s) → E t t refl
e t = refl
β : Definition-2-7-2-ii w w' ∘ Definition-2-7-2-i w w' ~ id
β p = J (Σ[ x ∈ A ] P x) D d w w' p
where
D : (w w' : Σ[ x ∈ A ] P x) (p : w ≡ w') → Set _
D w w' p = (Definition-2-7-2-ii w w' ∘ Definition-2-7-2-i w w') p ≡ id p
d : (x : Σ[ x ∈ A ] P x) → D x x refl
d x = refl
-- Theorem 2.7.2
Theorem-2-7-2 : ∀ {a b} {A : Set a} {P : A → Set b}
→ (w w' : Σ[ x ∈ A ] P x)
→ (w ≡ w') ≅ (Σ[ p ∈ proj₁ w ≡ proj₁ w' ] transport P p (proj₂ w) ≡ proj₂ w')
Theorem-2-7-2 {_} {_} {A} {P} w w' = Definition-2-7-2-i w w' , Lemma-2-7-2-iii w w'
-- Corollary 2.7.3
Corollary-2-7-3 : ∀ {a b} {A : Set a} {P : A → Set b}
→ (z : Σ[ x ∈ A ] P x)
→ z ≡ (proj₁ z , proj₂ z)
Corollary-2-7-3 {a} {b} {A} {P} z
= ←≅ (Theorem-2-7-2 z z) (refl , refl)
-- Theorem 2.7.4
Theorem-2-7-4 : ∀ {a b} {A : Set a}
→ {P : A → Set b}
→ {Q : Σ[ x ∈ A ] P x → Set b}
→ {x y : A}
→ (p : x ≡ y)
→ (f : Σ[ u ∈ P x ] Q (x , u))
→ transport (λ w → Σ[ u ∈ P w ] Q (w , u)) p f
≡ (transport P p (proj₁ f) , transport Q
(←≅ (Theorem-2-7-2 (x , (proj₁ f))
(y , (transport P p (proj₁ f)))) (p , refl)) (proj₂ f))
Theorem-2-7-4 {a} {b} {A} {P} {Q} {x} {y} p f = J A D d x y p f
where
D : (x y : A) (p : x ≡ y) → Set _
D x y p = (f : Σ[ u ∈ P x ] Q (x , u))
→ transport (λ w → Σ-syntax (P w) (λ u → Q (w , u))) p f ≡
(transport P p (proj₁ f) ,
transport Q
(←≅ (Theorem-2-7-2 (x , proj₁ f) (y , transport P p (proj₁ f)))
(p , refl))
(proj₂ f))
d : (x : A) → D x x refl
d x f = refl
| {
"alphanum_fraction": 0.4353792415,
"avg_line_length": 32.3225806452,
"ext": "agda",
"hexsha": "f4f002bfed1dc71a63de768e7941112d1524359c",
"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": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/hott",
"max_forks_repo_path": "src/Ch2-7.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/hott",
"max_issues_repo_path": "src/Ch2-7.agda",
"max_line_length": 114,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/hott",
"max_stars_repo_path": "src/Ch2-7.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1899,
"size": 4008
} |
-- In a mutual block, either all or none must have a MEASURE declaration.
module _ where
open import Common.Prelude
mutual
{-# MEASURE n #-}
f : (n : Nat) → Nat
f zero = zero
f (suc n) = g n
{-# MEASURE n #-}
g : (n : Nat) → Nat
g zero = zero
g (suc n) = suc (f n)
| {
"alphanum_fraction": 0.5694444444,
"avg_line_length": 14.4,
"ext": "agda",
"hexsha": "0fa05b7e8cf45373d3e3c54ab6f18958b70d47f4",
"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/succeed/MeasureMutual.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/MeasureMutual.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "masondesu/agda",
"max_stars_repo_path": "test/succeed/MeasureMutual.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": 102,
"size": 288
} |
{-# OPTIONS --without-K --safe #-}
module README where
-- Formalization for "Decidability of Conversion for Type Theory in Type Theory"
-- Git repository: https://github.com/mr-ohman/logrel-mltt
------------------
-- INTRODUCTION --
------------------
-- A minimal library necessary for formalization:
-- Embedding types into larger universes
import Tools.Embedding
-- The empty type and its elimination rule.
import Tools.Empty
-- The unit type.
import Tools.Unit
-- Sum type.
import Tools.Sum
-- Product type.
import Tools.Product
-- Identity function and composition.
import Tools.Function
-- Negation and decidability type.
import Tools.Nullary
-- Propositional equality and its properties.
import Tools.PropositionalEquality
-- Natural numbers and decidability of equality.
import Tools.Nat
---------------------------
-- LANGUAGE INTRODUCTION --
---------------------------
-- Syntax and semantics of weakening and substitution.
import Definition.Untyped
-- Propositional equality properties: Equalities between expressions,
-- weakenings, substitutions and their combined composition.
-- (These lemmas are not in the paper.)
import Definition.Untyped.Properties
-- Judgements: Typing rules, conversion, reduction rules
-- and well-formed substitutions and respective equality.
import Definition.Typed
-- Well-formed context extraction and reduction properties.
import Definition.Typed.Properties
-- Well-formed weakening and its properties.
import Definition.Typed.Weakening
------------------------------
-- KRIPKE LOGICAL RELATIONS --
------------------------------
-- Generic equality relation definition.
import Definition.Typed.EqualityRelation
-- The judgemental instance of the generic equality.
import Definition.Typed.EqRelInstance
-- Logical relations definitions.
import Definition.LogicalRelation
-- Properties of logical relation:
-- Reflexivity of the logical relation.
import Definition.LogicalRelation.Properties.Reflexivity
-- Escape lemma for the logical relation.
import Definition.LogicalRelation.Properties.Escape
-- Shape view of two or more types.
import Definition.LogicalRelation.ShapeView
-- Proof irrelevance for the logical relation.
import Definition.LogicalRelation.Irrelevance
-- Weakening of logical relation judgements.
import Definition.LogicalRelation.Weakening
-- Conversion of the logical relation.
import Definition.LogicalRelation.Properties.Conversion
-- Symmetry of the logical relation.
import Definition.LogicalRelation.Properties.Symmetry
-- Transitvity of the logical relation.
import Definition.LogicalRelation.Properties.Transitivity
-- Neutral introduction in the logical relation.
import Definition.LogicalRelation.Properties.Neutral
-- Weak head expansion of the logical relation.
import Definition.LogicalRelation.Properties.Reduction
-- Application in the logical relation.
import Definition.LogicalRelation.Application
-- Validity judgements definitions
import Definition.LogicalRelation.Substitution
-- Properties of validity judgements:
-- Proof irrelevance for the validity judgements.
import Definition.LogicalRelation.Substitution.Irrelevance
-- Properties about valid substitutions:
-- * Substitution well-formedness.
-- * Substitution weakening.
-- * Substitution lifting.
-- * Identity substitution.
-- * Reflexivity, symmetry and transitivity of substitution equality.
import Definition.LogicalRelation.Substitution.Properties
-- Single term substitution of validity judgements.
import Definition.LogicalRelation.Substitution.Introductions.SingleSubst
-- The fundamental theorem.
import Definition.LogicalRelation.Fundamental
-- Certain cases of the logical relation:
-- Validity of Π-types.
import Definition.LogicalRelation.Substitution.Introductions.Pi
-- Validity of applications.
import Definition.LogicalRelation.Substitution.Introductions.Application
-- Validity of λ-terms.
import Definition.LogicalRelation.Substitution.Introductions.Lambda
-- Validity of natural recursion of natural numbers.
import Definition.LogicalRelation.Substitution.Introductions.Natrec
-- Reducibility of well-formedness.
import Definition.LogicalRelation.Fundamental.Reducibility
-- Consequences of the fundamental theorem:
-- Canonicity of the system.
import Definition.Typed.Consequences.Canonicity
-- Injectivity of Π-types.
import Definition.Typed.Consequences.Injectivity
-- Syntactic validitiy of the system.
import Definition.Typed.Consequences.Syntactic
-- All types and terms fully reduce to WHNF.
import Definition.Typed.Consequences.Reduction
-- Strong equality of types.
import Definition.Typed.Consequences.Equality
-- Substiution in judgements and substitution composition.
import Definition.Typed.Consequences.Substitution
-- Uniqueness of the types of neutral terms.
import Definition.Typed.Consequences.NeTypeEq
-- Universe membership of types.
import Definition.Typed.Consequences.InverseUniv
-- Consistency of the type theory.
import Definition.Typed.Consequences.Consistency
| {
"alphanum_fraction": 0.7906605468,
"avg_line_length": 27.532967033,
"ext": "agda",
"hexsha": "1a6df4c66394435539f2e6639e27be43b8278948",
"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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "loic-p/logrel-mltt",
"max_forks_repo_path": "README.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"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": "loic-p/logrel-mltt",
"max_issues_repo_path": "README.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "loic-p/logrel-mltt",
"max_stars_repo_path": "README.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 950,
"size": 5011
} |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Base
open import lib.PathFunctor
open import lib.PathGroupoid
open import lib.path-seq.Reasoning
module lib.path-seq.Ap where
module _ {i j} {A : Type i} {B : Type j} (f : A → B) where
ap-seq : {a a' : A} → a =-= a' → f a =-= f a'
ap-seq [] = []
ap-seq (p ◃∙ s) = ap f p ◃∙ ap-seq s
private
ap-seq-∙-= : {a a' : A} → (s : a =-= a')
→ ap f (↯ s) == ↯ (ap-seq s)
ap-seq-∙-= [] = idp
ap-seq-∙-= (p ◃∙ []) = idp
ap-seq-∙-= (idp ◃∙ s@(_ ◃∙ _)) = ap-seq-∙-= s
ap-seq-∙ : {a a' : A} (s : a =-= a')
→ (ap f (↯ s) ◃∎) =ₛ ap-seq s
ap-seq-∙ s = =ₛ-in (ap-seq-∙-= s)
∙-ap-seq : {a a' : A} (s : a =-= a')
→ ap-seq s =ₛ (ap f (↯ s) ◃∎)
∙-ap-seq s = !ₛ (ap-seq-∙ s)
ap-seq-=ₛ : {a a' : A} {s t : a =-= a'}
→ s =ₛ t
→ ap-seq s =ₛ ap-seq t
ap-seq-=ₛ {s = s} {t = t} (=ₛ-in p) =
ap-seq s
=ₛ⟨ ∙-ap-seq s ⟩
ap f (↯ s) ◃∎
=ₛ₁⟨ ap (ap f) p ⟩
ap f (↯ t) ◃∎
=ₛ⟨ ap-seq-∙ t ⟩
ap-seq t ∎ₛ
module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A → B → C) where
ap2-seq : {a a' : A} {b b' : B} → a =-= a' → b =-= b' → f a b =-= f a' b'
ap2-seq [] [] = []
ap2-seq {a = a} [] t@(_ ◃∙ _) = ap-seq (f a) t
ap2-seq {b = b} s@(_ ◃∙ _) [] = ap-seq (λ a → f a b) s
ap2-seq (p ◃∙ s) (q ◃∙ t) = ap2 f p q ◃∙ ap2-seq s t
private
ap2-seq-∙-= : {a a' : A} {b b' : B}
(s : a =-= a') (t : b =-= b')
→ ap2 f (↯ s) (↯ t) == ↯ (ap2-seq s t)
ap2-seq-∙-= [] [] = idp
ap2-seq-∙-= {a = a} [] t@(_ ◃∙ _) =
ap2 f idp (↯ t)
=⟨ ap2-idp-l f (↯ t) ⟩
ap (f a) (↯ t)
=⟨ =ₛ-out (ap-seq-∙ (f a) t) ⟩
↯ (ap-seq (f a) t) =∎
ap2-seq-∙-= {b = b} s@(_ ◃∙ _) [] =
ap2 f (↯ s) idp
=⟨ ap2-idp-r f (↯ s) ⟩
ap (λ a → f a b) (↯ s)
=⟨ =ₛ-out (ap-seq-∙ (λ a → f a b) s ) ⟩
↯ (ap-seq (λ a → f a b) s) =∎
ap2-seq-∙-= (p ◃∙ []) (q ◃∙ []) = idp
ap2-seq-∙-= {a' = a'} (p ◃∙ []) (q ◃∙ t@(_ ◃∙ _)) =
ap2 f p (q ∙ ↯ t)
=⟨ ap (λ r → ap2 f r (q ∙ ↯ t)) (! (∙-unit-r p)) ⟩
ap2 f (p ∙ idp) (q ∙ ↯ t)
=⟨ ap2-∙ f p idp q (↯ t) ⟩
ap2 f p q ∙ ap2 f idp (↯ t)
=⟨ ap (ap2 f p q ∙_) (ap2-idp-l f (↯ t)) ⟩
ap2 f p q ∙ ap (f a') (↯ t)
=⟨ ap (ap2 f p q ∙_) (=ₛ-out (ap-seq-∙ (f a') t)) ⟩
ap2 f p q ∙ ↯ (ap-seq (f a') t) =∎
ap2-seq-∙-= {b' = b'} (p ◃∙ s@(_ ◃∙ _)) (q ◃∙ []) =
ap2 f (p ∙ ↯ s) q
=⟨ ap (ap2 f (p ∙ ↯ s)) (! (∙-unit-r q)) ⟩
ap2 f (p ∙ ↯ s) (q ∙ idp)
=⟨ ap2-∙ f p (↯ s) q idp ⟩
ap2 f p q ∙ ap2 f (↯ s) idp
=⟨ ap (ap2 f p q ∙_) (ap2-idp-r f (↯ s)) ⟩
ap2 f p q ∙ ap (λ a → f a b') (↯ s)
=⟨ ap (ap2 f p q ∙_) (=ₛ-out (ap-seq-∙ (λ a → f a b') s)) ⟩
ap2 f p q ∙ ↯ (ap-seq (λ a → f a b') s) =∎
ap2-seq-∙-= (p ◃∙ s@(_ ◃∙ _)) (q ◃∙ t@(_ ◃∙ _)) =
ap2 f (p ∙ ↯ s) (q ∙ ↯ t)
=⟨ ap2-∙ f p (↯ s) q (↯ t) ⟩
ap2 f p q ∙ ap2 f (↯ s) (↯ t)
=⟨ ap (ap2 f p q ∙_) (ap2-seq-∙-= s t) ⟩
ap2 f p q ∙ ↯ (ap2-seq s t) =∎
ap2-seq-∙ : {a a' : A} {b b' : B}
(s : a =-= a') (t : b =-= b')
→ ap2 f (↯ s) (↯ t) ◃∎ =ₛ ap2-seq s t
ap2-seq-∙ s t = =ₛ-in (ap2-seq-∙-= s t)
∙-ap2-seq : {a a' : A} {b b' : B}
(s : a =-= a') (t : b =-= b')
→ ap2-seq s t =ₛ ap2 f (↯ s) (↯ t) ◃∎
∙-ap2-seq s t = !ₛ (ap2-seq-∙ s t)
| {
"alphanum_fraction": 0.3513674197,
"avg_line_length": 32.0380952381,
"ext": "agda",
"hexsha": "f6946648b44c322e7c9402983c5e3507566d2ff4",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "core/lib/path-seq/Ap.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "core/lib/path-seq/Ap.agda",
"max_line_length": 77,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "core/lib/path-seq/Ap.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 1912,
"size": 3364
} |
{-# OPTIONS --without-K #-}
--open import HoTT
open import homotopy.3x3.PushoutPushout
open import homotopy.3x3.Transpose
import homotopy.3x3.To as To
import homotopy.3x3.From as From
open import homotopy.3x3.Common
module homotopy.3x3.ToFrom2 {i} (d : Span^2 {i}) where
open Span^2 d
open M d hiding (Pushout^2)
open M (transpose d) using () renaming (A₀∙ to A∙₀; A₂∙ to A∙₂; A₄∙ to A∙₄;
module F₁∙ to F∙₁; f₁∙ to f∙₁;
module F₃∙ to F∙₃; f₃∙ to f∙₃;
v-h-span to h-v-span)
open M using (Pushout^2)
open To d
open From d
open import homotopy.3x3.ToFromInit d
module M2 (c : A₂₂) where
coh : ∀ {i} {A : Type i} {a b c d : A}
{p q : a == b} (α : p == q)
{v w : b == d} {β β' : w == v} (eqβ : β == β')
{t u : a == c} {ε ε' : u == t} (eqε : ε == ε')
{r s : c == d} (ζ : r == s)
(γ : (q , v =□ t , s))
(δ : (p , w =□ u , r))
(eq : γ == δ ∙□-i/ ! β' / ε' / ∙□-o/ ! α / ζ /)
→ (α , β , γ =□□ δ , ε , ζ)
coh idp {β = idp} idp {ε = idp} idp idp _ _ x = x
end-lemma1 : ap (right ∘ f∙₃) (glue c) == ap (to ∘ i∙₄ ∘ f∙₃) (glue c) :> E₂∙Red.T-lhs c
end-lemma1 =
ap (right ∘ f∙₃) (glue c)
=⟨ ap-∘ right f∙₃ (glue c) ⟩
ap right (ap f∙₃ (glue c))
=⟨ ap (ap right) (F∙₃.glue-β c) ⟩
ap right (ap left (H₁₃ c) ∙ glue (f₂₃ c) ∙ ap right (! (H₃₃ c)))
=⟨ ap-∙∙`∘`∘ right left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c)) ⟩
ap (right ∘ left) (H₁₃ c) ∙ ap right (glue (f₂₃ c)) ∙ ap (right ∘ right) (! (H₃₃ c))
=⟨ ! (to-from-r-g (f₂₃ c)) |in-ctx (λ u → ap (right ∘ left) (H₁₃ c) ∙ u ∙ ap (right ∘ right) (! (H₃₃ c))) ⟩
ap (right ∘ left) (H₁₃ c) ∙ (ap (to ∘ i∙₄) (glue (f₂₃ c))) ∙ ap (right ∘ right) (! (H₃₃ c))
=⟨ ! (ap-∙∙`∘`∘ (to ∘ i∙₄) left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c))) ⟩
ap (to ∘ i∙₄) (ap left (H₁₃ c) ∙ glue (f₂₃ c) ∙ ap right (! (H₃₃ c)))
=⟨ ! (ap (ap (to ∘ i∙₄)) (F∙₃.glue-β c)) ⟩
ap (to ∘ i∙₄) (ap f∙₃ (glue c))
=⟨ ∘-ap (to ∘ i∙₄) f∙₃ (glue c) ⟩
ap (to ∘ i∙₄ ∘ f∙₃) (glue c) ∎
abstract
lemma1 : ↓-='-out (apd (to-from-r ∘ f∙₃) (glue c)) == end-lemma1
lemma1 =
↓-='-out (apd (to-from-r ∘ f∙₃) (glue c))
=⟨ apd-∘'' to-from-r f∙₃ (glue c) (F∙₃.glue-β c) |in-ctx ↓-='-out ⟩
↓-='-out (↓-ap-out= (λ b → to (from (right b)) == right b) f∙₃ (glue c) (F∙₃.glue-β c) (apd to-from-r (ap left (H₁₃ c) ∙ glue (f₂₃ c) ∙ ap right (! (H₃₃ c)))))
=⟨ apd-∙∙`∘`∘ to-from-r left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c)) |in-ctx (λ u → ↓-='-out (↓-ap-out= (λ b → to (from (right b)) == right b) f∙₃ (glue c) (F∙₃.glue-β c) u)) ⟩
↓-='-out (↓-ap-out= (λ b → to (from (right b)) == right b) f∙₃ (glue c) (F∙₃.glue-β c) (↓-ap-in _ _ (apd (λ _ → idp) (H₁₃ c)) ∙ᵈ apd to-from-r (glue (f₂₃ c)) ∙ᵈ ↓-ap-in _ _ (apd (λ _ → idp) (! (H₃₃ c)))))
=⟨ ToFromR.glue-β (f₂₃ c) |in-ctx (λ u → ↓-='-out (↓-ap-out= (λ b → to (from (right b)) == right b) f∙₃ (glue c) (F∙₃.glue-β c)
(↓-ap-in _ _ (apd (λ _ → idp) (H₁₃ c)) ∙ᵈ u ∙ᵈ ↓-ap-in _ _ (apd (λ _ → idp) (! (H₃₃ c)))))) ⟩
↓-='-out (↓-ap-out= (λ b → to (from (right b)) == right b) f∙₃ (glue c) (F∙₃.glue-β c)
(↓-ap-in _ _ (apd (λ _ → idp) (H₁₃ c)) ∙ᵈ ↓-='-in (! (to-from-r-g (f₂₃ c))) ∙ᵈ ↓-ap-in _ _ (apd (λ _ → idp) (! (H₃₃ c)))))
=⟨ lemma-a _ f∙₃ (glue c) (F∙₃.glue-β c) _ ⟩
↓-='-out (↓-ap-in _ _ (apd (λ x → idp {a = right (left x)}) (H₁₃ c)) ∙ᵈ ↓-='-in (! (to-from-r-g (f₂₃ c))) ∙ᵈ ↓-ap-in _ _ (apd (λ _ → idp) (! (H₃₃ c))))
∙□-i/ ap-∘ right f∙₃ (glue c) ∙ ap (ap right) (F∙₃.glue-β c)
/ ! (ap (ap (to ∘ i∙₄)) (F∙₃.glue-β c)) ∙ ∘-ap (to ∘ i∙₄) f∙₃ (glue c) /
=⟨ lemma-b (glue (f₂₃ c)) (apd (λ _ → idp) (H₁₃ c)) (! (to-from-r-g (f₂₃ c))) (apd (λ _ → idp) (! (H₃₃ c))) |in-ctx (λ u → u ∙□-i/ ap-∘ right f∙₃ (glue c) ∙ ap (ap right) (F∙₃.glue-β c)
/ ! (ap (ap (to ∘ i∙₄)) (F∙₃.glue-β c)) ∙ ∘-ap (to ∘ i∙₄) f∙₃ (glue c) /) ⟩
(↓-='-out (apd (λ x → idp {a = right (left x)}) (H₁₃ c))
∙□h ((! (to-from-r-g (f₂₃ c)))
∙□h (↓-='-out (apd (λ _ → idp) (! (H₃₃ c))))))
∙□-i/ ap-∙∙`∘`∘ right left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c))
/ ! (ap-∙∙`∘`∘ (to ∘ i∙₄) left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c))) /
∙□-i/ ap-∘ right f∙₃ (glue c) ∙ ap (ap right) (F∙₃.glue-β c)
/ ! (ap (ap (to ∘ i∙₄)) (F∙₃.glue-β c)) ∙ ∘-ap (to ∘ i∙₄) f∙₃ (glue c) /
=⟨ coh3 |in-ctx (λ u → u
∙□-i/ ap-∙∙`∘`∘ right left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c))
/ ! (ap-∙∙`∘`∘ (to ∘ i∙₄) left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c))) /
∙□-i/ ap-∘ right f∙₃ (glue c) ∙ ap (ap right) (F∙₃.glue-β c)
/ ! (ap (ap (to ∘ i∙₄)) (F∙₃.glue-β c)) ∙ ∘-ap (to ∘ i∙₄) f∙₃ (glue c) /) ⟩
((! (to-from-r-g (f₂₃ c))) |in-ctx (λ u → ap (right ∘ left) (H₁₃ c) ∙ u ∙ ap (right ∘ right) (! (H₃₃ c))))
∙□-i/ ap-∙∙`∘`∘ right left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c))
/ ! (ap-∙∙`∘`∘ (to ∘ i∙₄) left right (H₁₃ c) (glue (f₂₃ c)) (! (H₃₃ c))) /
∙□-i/ ap-∘ right f∙₃ (glue c) ∙ ap (ap right) (F∙₃.glue-β c)
/ ! (ap (ap (to ∘ i∙₄)) (F∙₃.glue-β c)) ∙ ∘-ap (to ∘ i∙₄) f∙₃ (glue c) /
=⟨ coh' ⟩
end-lemma1 ∎ where
coh' : ∀ {i} {A : Type i} {x y : A} {a b c d e f g h : x == y} {p : a == b} {q : b == c}
{r : c == d} {s : d == e} {t : e == f} {u : f == g} {v : g == h}
→ (s ∙□-i/ r / t / ∙□-i/ p ∙ q / u ∙ v /) == (a =⟨ p ⟩ b =⟨ q ⟩ c =⟨ r ⟩ d =⟨ s ⟩ e =⟨ t ⟩ f =⟨ u ⟩ g =⟨ v ⟩ h ∎)
coh' {p = idp} {idp} {idp} {idp} {idp} {idp} {idp} = idp
coh2 : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} {x y : A} {p : x == y}
→ ↓-='-out (apd (λ x → idp {a = f x}) p) == idp {a = ap f p}
coh2 {p = idp} = idp
coh3 : (↓-='-out (apd (λ x → idp {a = right (left x)}) (H₁₃ c))
∙□h ((! (to-from-r-g (f₂₃ c)))
∙□h (↓-='-out (apd (λ _ → idp) (! (H₃₃ c)))))) == ((! (to-from-r-g (f₂₃ c))) |in-ctx (λ u → ap (right ∘ left) (H₁₃ c) ∙ u ∙ ap (right ∘ right) (! (H₃₃ c))))
coh3 =
↓-='-out (apd (λ x → idp {a = right (left x)}) (H₁₃ c))
∙□h ((! (to-from-r-g (f₂₃ c)))
∙□h (↓-='-out (apd (λ _ → idp) (! (H₃₃ c)))))
=⟨ coh2 {f = right ∘ left} {p = H₁₃ c} |in-ctx (λ u → u ∙□h ((! (to-from-r-g (f₂₃ c))) ∙□h (↓-='-out (apd (λ _ → idp) (! (H₃₃ c)))))) ⟩
idp {a = ap (right ∘ left) (H₁₃ c)} ∙□h ((! (to-from-r-g (f₂₃ c)))
∙□h (↓-='-out (apd (λ _ → idp) (! (H₃₃ c)))))
=⟨ coh2 {f = right ∘ right} {p = ! (H₃₃ c)} |in-ctx (λ u → idp {a = ap (right ∘ left) (H₁₃ c)} ∙□h ((! (to-from-r-g (f₂₃ c))) ∙□h u)) ⟩
idp {a = ap (right ∘ left) (H₁₃ c)} ∙□h ((! (to-from-r-g (f₂₃ c))) ∙□h idp {a = ap (right ∘ right) (! (H₃₃ c))})
=⟨ coh4 (ap (right ∘ left) (H₁₃ c)) (ap (right ∘ right) (! (H₃₃ c))) (! (to-from-r-g (f₂₃ c))) ⟩
((! (to-from-r-g (f₂₃ c))) |in-ctx (λ u → ap (right ∘ left) (H₁₃ c) ∙ u ∙ ap (right ∘ right) (! (H₃₃ c)))) ∎ where
coh4 : ∀ {i} {A : Type i} {x y z t : A} (p : x == y) (q : z == t) {s t : y == z} (r : s == t)
→ (idp {a = p} ∙□h (r ∙□h idp {a = q})) == (r |in-ctx (λ u → p ∙ u ∙ q))
coh4 idp idp idp = idp
end-lemma3 : ap (left ∘ f∙₁) (glue c) == ap (to ∘ i∙₀ ∘ f∙₁) (glue c)
end-lemma3 =
ap (left ∘ f∙₁) (glue c)
=⟨ ap-∘ left f∙₁ (glue c) ⟩
ap left (ap f∙₁ (glue c))
=⟨ ap (ap left) (F∙₁.glue-β c) ⟩
ap left (ap left (! (H₁₁ c)) ∙ glue (f₂₁ c) ∙ ap right (H₃₁ c))
=⟨ ap-∙∙`∘`∘ left left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c) ⟩
ap (left ∘ left) (! (H₁₁ c)) ∙ ap left (glue (f₂₁ c)) ∙ ap (left ∘ right) (H₃₁ c)
=⟨ ! (to-from-l-g (f₂₁ c)) |in-ctx (λ u → ap (left ∘ left) (! (H₁₁ c)) ∙ u ∙ ap (left ∘ right) (H₃₁ c)) ⟩
ap (left ∘ left) (! (H₁₁ c)) ∙ (ap (to ∘ i∙₀) (glue (f₂₁ c))) ∙ ap (left ∘ right) (H₃₁ c)
=⟨ ! (ap-∙∙`∘`∘ (to ∘ i∙₀) left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c)) ⟩
ap (to ∘ i∙₀) (ap left (! (H₁₁ c)) ∙ glue (f₂₁ c) ∙ ap right (H₃₁ c))
=⟨ ! (ap (ap (to ∘ i∙₀)) (F∙₁.glue-β c)) ⟩
ap (to ∘ i∙₀) (ap f∙₁ (glue c))
=⟨ ∘-ap (to ∘ i∙₀) f∙₁ (glue c) ⟩
ap (to ∘ i∙₀ ∘ f∙₁) (glue c) ∎
lemma3 : ↓-='-out (apd (to-from-l ∘ f∙₁) (glue c)) == end-lemma3
lemma3 =
↓-='-out (apd (to-from-l ∘ f∙₁) (glue c))
=⟨ apd-∘'' to-from-l f∙₁ (glue c) (F∙₁.glue-β c) |in-ctx ↓-='-out ⟩
↓-='-out (↓-ap-out= (λ b → to (from (left b)) == left b) f∙₁ (glue c) (F∙₁.glue-β c) (apd to-from-l (ap left (! (H₁₁ c)) ∙ glue (f₂₁ c) ∙ ap right (H₃₁ c))))
=⟨ lemma-a _ f∙₁ (glue c) (F∙₁.glue-β c) (apd to-from-l (ap left (! (H₁₁ c)) ∙ glue (f₂₁ c) ∙ ap right (H₃₁ c))) ⟩
↓-='-out (apd to-from-l (ap left (! (H₁₁ c)) ∙ glue (f₂₁ c) ∙ ap right (H₃₁ c)))
∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /
=⟨ apd-∙∙`∘`∘ to-from-l left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c) |in-ctx
(λ u → ↓-='-out u ∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /) ⟩
↓-='-out (↓-ap-in _ _ (apd (λ _ → idp) (! (H₁₁ c))) ∙ᵈ apd to-from-l (glue (f₂₁ c)) ∙ᵈ ↓-ap-in _ _ (apd (λ _ → idp) (H₃₁ c)))
∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /
=⟨ ToFromL.glue-β (f₂₁ c) |in-ctx (λ u → ↓-='-out (↓-ap-in _ _ (apd (λ _ → idp) (! (H₁₁ c))) ∙ᵈ u ∙ᵈ ↓-ap-in _ _ (apd (λ _ → idp) (H₃₁ c)))
∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /) ⟩
↓-='-out (↓-ap-in _ _ (apd (λ _ → idp) (! (H₁₁ c))) ∙ᵈ ↓-='-in (! (to-from-l-g (f₂₁ c))) ∙ᵈ ↓-ap-in _ _ (apd (λ _ → idp) (H₃₁ c)))
∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /
=⟨ lemma-b (glue (f₂₁ c)) (apd (λ _ → idp) (! (H₁₁ c))) (! (to-from-l-g (f₂₁ c))) (apd (λ _ → idp) (H₃₁ c))
|in-ctx (λ u → u ∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /) ⟩
(↓-='-out (apd (λ _ → idp) (! (H₁₁ c))) ∙□h ((! (to-from-l-g (f₂₁ c))) ∙□h ↓-='-out (apd (λ _ → idp) (H₃₁ c))))
∙□-i/ ap-∙∙`∘`∘ left left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c) / ! (ap-∙∙`∘`∘ (to ∘ i∙₀) left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c)) /
∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /
=⟨ coh2 (left ∘ left) (left ∘ right) (! (H₁₁ c)) (! (to-from-l-g (f₂₁ c))) (H₃₁ c) |in-ctx (λ u →
u ∙□-i/ ap-∙∙`∘`∘ left left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c) / ! (ap-∙∙`∘`∘ (to ∘ i∙₀) left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c)) /
∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /) ⟩
((! (to-from-l-g (f₂₁ c))) |in-ctx (λ u → ap (left ∘ left) (! (H₁₁ c)) ∙ u ∙ ap (left ∘ right) (H₃₁ c)))
∙□-i/ ap-∙∙`∘`∘ left left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c) / ! (ap-∙∙`∘`∘ (to ∘ i∙₀) left right (! (H₁₁ c)) (glue (f₂₁ c)) (H₃₁ c)) /
∙□-i/ ap-∘ left f∙₁ (glue c) ∙ ap (ap left) (F∙₁.glue-β c) / ! (ap (ap (to ∘ from ∘ left)) (F∙₁.glue-β c)) ∙ ∘-ap (to ∘ from ∘ left) f∙₁ (glue c) /
=⟨ coh3 ⟩
end-lemma3 ∎ where
coh2 : ∀ {i i' j} {A : Type i} {A' : Type i'} {B : Type j} (f : A → B) (f' : A' → B)
{a b : A} {a' b' : A'} (p : a == b) {s s' : f b == f' a'} (q : s == s') (r : a' == b')
→ (↓-='-out (apd (λ x → idp) p) ∙□h (q ∙□h (↓-='-out (apd (λ _ → idp) r))))
== (q |in-ctx (λ u → ap f p ∙ u ∙ ap f' r))
coh2 f f' idp idp idp = idp
coh3 : ∀ {i} {A : Type i} {x y : A} {a b c d e f g h : x == y} {p : a == b} {q : b == c}
{r : c == d} {s : d == e} {t : e == f} {u : f == g} {v : g == h}
→ (s ∙□-i/ r / t / ∙□-i/ p ∙ q / u ∙ v /) == (a =⟨ p ⟩ b =⟨ q ⟩ c =⟨ r ⟩ d =⟨ s ⟩ e =⟨ t ⟩ f =⟨ u ⟩ g =⟨ v ⟩ h ∎)
coh3 {p = idp} {idp} {idp} {idp} {idp} {idp} {idp} = idp
{- Lemma 2 -}
lemma2-7 =
↓-='-out (ap↓ (ap to) (apd (glue {d = v-h-span}) (glue c)))
=⟨ to-glue-glue-β c |in-ctx ↓-='-out ⟩
↓-='-out (↓-='-in (E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-i/ E₂∙Red.lhs-o c / E₂∙Red.rhs-o c /)
◃/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /)
=⟨ thing _ (To.glue-β (left (f₂₁ c))) _ ⟩
E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-i/ E₂∙Red.lhs-o c / E₂∙Red.rhs-o c /
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) / ∎
lemma2-6 =
ap□ to (↓-='-out (apd (glue {d = v-h-span}) (glue c)))
=⟨ ap□-↓-='-out-β _ _ to (apd (glue {d = v-h-span}) (glue c)) ⟩
↓-='-out (ap↓ (ap to) (apd (glue {d = v-h-span}) (glue c)))
∙□-i/ ∘-ap to (right ∘ f₃∙) (glue c) / ap-∘ to (left ∘ f₁∙) (glue c) /
=⟨ lemma2-7 |in-ctx (λ u → (u ∙□-i/ ∘-ap to (right ∘ f₃∙) (glue c) / ap-∘ to (left ∘ f₁∙) (glue c) /)) ⟩
E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-i/ E₂∙Red.lhs-o c / E₂∙Red.rhs-o c /
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /
∙□-i/ ∘-ap to (right ∘ f₃∙) (glue c) / ap-∘ to (left ∘ f₁∙) (glue c) / ∎
lemma2-5 =
ap□ to (↓-='-out (apd (glue {d = v-h-span}) (glue c))
∙□-i/ E∙₂Red.lhs-i c / E∙₂Red.rhs-i c /)
=⟨ ap□-∙□-i/ to _ (E∙₂Red.lhs-i c) _ ⟩
ap□ to (↓-='-out (apd (glue {d = v-h-span}) (glue c)))
∙□-i/ ap (ap to) (E∙₂Red.lhs-i c) / ap (ap to) (E∙₂Red.rhs-i c) /
=⟨ lemma2-6 |in-ctx (λ u → u ∙□-i/ ap (ap to) (E∙₂Red.lhs-i c) / ap (ap to) (E∙₂Red.rhs-i c) /) ⟩
E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-i/ E₂∙Red.lhs-o c / E₂∙Red.rhs-o c /
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /
∙□-i/ ∘-ap to (right ∘ f₃∙) (glue c) / ap-∘ to (left ∘ f₁∙) (glue c) /
∙□-i/ ap (ap to) (E∙₂Red.lhs-i c) / ap (ap to) (E∙₂Red.rhs-i c) / ∎
lemma2'-1 =
E∙₂Red.ap-ap-coh!-lhs-i c to ∙ ap (ap to) (E∙₂Red.lhs-i c) ∙ ∘-ap to (right ∘ f₃∙) (glue c) ∙ E₂∙Red.lhs-o c
=⟨ eq1 {f = ap to}
{q = ! (ap-∙∙`∘`∘ right left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c))}
{ ! (ap (ap right) (F₃∙.glue-β c))}
{ ! (F₃∙.glue-β c) |in-ctx (ap right)}
(!-ap (ap right) (F₃∙.glue-β c))
{∘-ap right f₃∙ (glue c)}
{p = E∙₂Red.ap-ap-coh!-lhs-i c to}
{∘-ap to (right ∘ f₃∙) (glue c)}
{ap-∘ i₄∙ f₃∙ (glue c)}
{F₃∙.glue-β c |in-ctx (ap i₄∙)}
{ap-∙∙`∘`∘ i₄∙ left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c)}
{I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c))}
⟩
(! (ap-∙∙`∘`∘ to (right ∘ left) (right ∘ right) (H₃₁ c) (ap right (glue (f₃₂ c))) (H₃₃ c))
∙ ap (ap to) (! (ap-∙∙`∘`∘ right left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c)))
∙ (ap (ap to) (! (F₃∙.glue-β c) |in-ctx (ap right))
∙ (ap (ap to) (∘-ap right f₃∙ (glue c))
∙ ∘-ap to (right ∘ f₃∙) (glue c)
∙ ap-∘ i₄∙ f₃∙ (glue c))
∙ (F₃∙.glue-β c |in-ctx (ap i₄∙)))
∙ ap-∙∙`∘`∘ i₄∙ left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c))
∙ (I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)))
=⟨ ap-∘^3-coh to right f₃∙ (glue c) |in-ctx (λ u →
(! (ap-∙∙`∘`∘ to (right ∘ left) (right ∘ right) (H₃₁ c) (ap right (glue (f₃₂ c))) (H₃₃ c))
∙ ap (ap to) (! (ap-∙∙`∘`∘ right left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c)))
∙ (ap (ap to) (! (F₃∙.glue-β c) |in-ctx (ap right))
∙ u
∙ (F₃∙.glue-β c |in-ctx (ap i₄∙)))
∙ ap-∙∙`∘`∘ i₄∙ left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c))
∙ (I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c))))
⟩
(! (ap-∙∙`∘`∘ to (right ∘ left) (right ∘ right) (H₃₁ c) (ap right (glue (f₃₂ c))) (H₃₃ c))
∙ ap (ap to) (! (ap-∙∙`∘`∘ right left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c)))
∙ (ap (ap to) (! (F₃∙.glue-β c) |in-ctx (ap right))
∙ ∘-ap to right (ap f₃∙ (glue c))
∙ (F₃∙.glue-β c |in-ctx (ap i₄∙)))
∙ ap-∙∙`∘`∘ i₄∙ left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c))
∙ (I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)))
=⟨ ap-∘-ap-coh to right (F₃∙.glue-β c) |in-ctx (λ u →
(! (ap-∙∙`∘`∘ to (right ∘ left) (right ∘ right) (H₃₁ c) (ap right (glue (f₃₂ c))) (H₃₃ c))
∙ ap (ap to) (! (ap-∙∙`∘`∘ right left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c)))
∙ u
∙ ap-∙∙`∘`∘ i₄∙ left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c))
∙ (I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)))) ⟩
(! (ap-∙∙`∘`∘ to (right ∘ left) (right ∘ right) (H₃₁ c) (ap right (glue (f₃₂ c))) (H₃₃ c))
∙ ap (ap to) (! (ap-∙∙`∘`∘ right left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c)))
∙ ∘-ap to right (ap left (H₃₁ c) ∙ glue (f₃₂ c) ∙ ap right (H₃₃ c))
∙ ap-∙∙`∘`∘ i₄∙ left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c))
∙ (I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)))
=⟨ ap-∘-ap-∙∙3`∘`∘-coh to right left right (H₃₁ c) (glue (f₃₂ c)) (H₃₃ c) |in-ctx (λ u →
u ∙ (I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)))) ⟩
(∘-ap to right (glue (f₃₂ c)) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)))
∙ (I₄∙.glue-β (f₃₂ c) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)))
=⟨ ∙-|in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c)) (∘-ap to right (glue (f₃₂ c))) (I₄∙.glue-β (f₃₂ c)) ⟩
((∘-ap to right (glue (f₃₂ c)) ∙ I₄∙.glue-β (f₃₂ c)) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c))) ∎
where
eq1 : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} {a b c d : A}
{q : a == b} {r r' : b == c} (e : r == r') {s : c == d}
{g h k l m n : B} {p : g == f a} {t : f d == h} {u : h == k}
{v : k == l} {w : l == m} {x : m == n}
→ p ∙ ap f (_ =⟨ q ⟩ _ =⟨ r ⟩ _ =⟨ s ⟩ _ ∎) ∙ t
∙ (_ =⟨ u ⟩ _ =⟨ v ⟩ _ =⟨ w ⟩ _ =⟨ x ⟩ _ ∎)
== (p ∙ ap f q ∙ (ap f r' ∙ (ap f s ∙ t ∙ u) ∙ v) ∙ w) ∙ x
eq1 {q = idp} {idp} {.idp} idp {idp} {p = p} {idp} {idp} {idp} {idp} {idp} = ! (∙-unit-r (p ∙ idp))
lemma2'-2 :
E₂∙Red.rhs-o c
∙ ap-∘ to (left ∘ f₁∙) (glue c)
∙ ap (ap to) (E∙₂Red.rhs-i c)
∙ E∙₂Red.ap-ap-coh!-rhs-i c to
== (! (∘-ap to left (glue (f₁₂ c)) ∙ I₀∙.glue-β (f₁₂ c)) |in-ctx (λ u → ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))
lemma2'-2 =
E₂∙Red.rhs-o c ∙ ap-∘ to (left ∘ f₁∙) (glue c) ∙ ap (ap to) (E∙₂Red.rhs-i c) ∙ E∙₂Red.ap-ap-coh!-rhs-i c to
=⟨ eq1 {f = ap to}
{p = ! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c))))}
{ ! (ap-∙∙`∘`∘ i₀∙ left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c))}
{ ! (F₁∙.glue-β c |in-ctx ap i₀∙)}
{∘-ap i₀∙ f₁∙ (glue c)}
{ap-∘ to (left ∘ f₁∙) (glue c)}
{ap-∘ left f₁∙ (glue c)}
{F₁∙.glue-β c |in-ctx (ap left)}
{ap-∙∙`∘`∘ left left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c)}
{ap-∙∙`∘`∘ to (left ∘ left) (left ∘ right) (H₁₁ c) (ap left (glue (f₁₂ c))) (H₁₃ c)}
⟩
(! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))))
∙ ((! (ap-∙∙`∘`∘ i₀∙ left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c)))
∙ ((! (F₁∙.glue-β c |in-ctx (λ u → ap i₀∙ u)))
∙ (∘-ap i₀∙ f₁∙ (glue c)
∙ ap-∘ to (left ∘ f₁∙) (glue c)
∙ ap (ap to) (ap-∘ left f₁∙ (glue c)))
∙ ap (ap to) (F₁∙.glue-β c |in-ctx (ap left)))
∙ ap (ap to) (ap-∙∙`∘`∘ left left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c))
∙ ap-∙∙`∘`∘ to (left ∘ left) (left ∘ right) (H₁₁ c) (ap left (glue (f₁₂ c))) (H₁₃ c))
=⟨ ap-∘^3-coh' to left f₁∙ (glue c)
|in-ctx (λ u → (! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))))
∙ ((! (ap-∙∙`∘`∘ i₀∙ left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c)))
∙ ((! (F₁∙.glue-β c |in-ctx (λ u → ap i₀∙ u)))
∙ u
∙ ap (ap to) (F₁∙.glue-β c |in-ctx (ap left)))
∙ ap (ap to) (ap-∙∙`∘`∘ left left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c))
∙ ap-∙∙`∘`∘ to (left ∘ left) (left ∘ right) (H₁₁ c) (ap left (glue (f₁₂ c))) (H₁₃ c))) ⟩
(! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))))
∙ ((! (ap-∙∙`∘`∘ i₀∙ left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c)))
∙ ((! (F₁∙.glue-β c |in-ctx (ap i₀∙)))
∙ ap-∘ to left (ap f₁∙ (glue c))
∙ ap (ap to) (F₁∙.glue-β c |in-ctx (ap left)))
∙ ap (ap to) (ap-∙∙`∘`∘ left left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c))
∙ ap-∙∙`∘`∘ to (left ∘ left) (left ∘ right) (H₁₁ c) (ap left (glue (f₁₂ c))) (H₁₃ c))
=⟨ ap-∘-ap-coh'2 to left (F₁∙.glue-β c)
|in-ctx (λ u → (! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))))
∙ ((! (ap-∙∙`∘`∘ i₀∙ left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c)))
∙ u
∙ ap (ap to) (ap-∙∙`∘`∘ left left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c))
∙ ap-∙∙`∘`∘ to (left ∘ left) (left ∘ right) (H₁₁ c) (ap left (glue (f₁₂ c))) (H₁₃ c))) ⟩
(! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))))
∙ ((! (ap-∙∙`∘`∘ i₀∙ left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c)))
∙ ap-∘ to left (ap left (H₁₁ c) ∙ glue (f₁₂ c) ∙ ap right (H₁₃ c))
∙ ap (ap to) (ap-∙∙`∘`∘ left left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c))
∙ ap-∙∙`∘`∘ to (left ∘ left) (left ∘ right) (H₁₁ c) (ap left (glue (f₁₂ c))) (H₁₃ c))
=⟨ ap-∘-ap-∙∙2`∘`∘-coh to left left right (H₁₁ c) (glue (f₁₂ c)) (H₁₃ c)
|in-ctx (λ u → (! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))) ∙ u)) ⟩
(! (I₀∙.glue-β (f₁₂ c) |in-ctx (λ u → (ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))))
∙ (ap-∘ to left (glue (f₁₂ c)) |in-ctx (λ u → ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)))
=⟨ coh2 (glue (f₁₂ c)) (I₀∙.glue-β (f₁₂ c)) ⟩
(! (∘-ap to left (glue (f₁₂ c)) ∙ I₀∙.glue-β (f₁₂ c)) |in-ctx (λ u → ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c))) ∎
where
eq1 : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} {a b c d e : B} {k l m n : A} {o : B}
{p : a == b} {q : b == c} {r : c == d} {s : d == e} {t : e == f k} {u : k == l}
{v : l == m} {w : m == n} {x : f n == o}
→ (_ =⟨ p ⟩ _ =⟨ q ⟩ _ =⟨ r ⟩ _ =⟨ s ⟩ _ ∎) ∙ t ∙ ap f (_ =⟨ u ⟩ _ =⟨ v ⟩ _ =⟨ w ⟩ _ ∎) ∙ x
== (p ∙ (q ∙ ((r ∙ (s ∙ t ∙ ap f u) ∙ ap f v) ∙ ap f w ∙ x)))
eq1 {p = idp} {idp} {idp} {idp} {t = t} {idp} {idp} {idp} {idp} = ! (∙-unit-r (t ∙ idp)) ∙ ! (∙-unit-r ((t ∙ idp) ∙ idp))
coh2 : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l}
{a a' : A} (q : a == a') {h : A → B} {g : B → C} {f : (g (h a) == g (h a')) → D} {r : g (h a) == g (h a')} (p : ap (g ∘ h) q == r)
→ (! (p |in-ctx f)) ∙ (ap-∘ g h q |in-ctx f) == (! (∘-ap g h q ∙ p) |in-ctx f)
coh2 idp idp = idp
lemma2-4' =
ap□ to (↓-='-out (apd (glue {d = v-h-span}) (glue c))
∙□-i/ E∙₂Red.lhs-i c / E∙₂Red.rhs-i c /)
∙□-i/ E∙₂Red.ap-ap-coh!-lhs-i c to / E∙₂Red.ap-ap-coh!-rhs-i c to /
=⟨ lemma2-5 |in-ctx (λ u → u ∙□-i/ E∙₂Red.ap-ap-coh!-lhs-i c to / E∙₂Red.ap-ap-coh!-rhs-i c to /) ⟩
E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-i/ E₂∙Red.lhs-o c / E₂∙Red.rhs-o c /
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /
∙□-i/ ∘-ap to (right ∘ f₃∙) (glue c) / ap-∘ to (left ∘ f₁∙) (glue c) /
∙□-i/ ap (ap to) (E∙₂Red.lhs-i c) / ap (ap to) (E∙₂Red.rhs-i c) /
∙□-i/ E∙₂Red.ap-ap-coh!-lhs-i c to / E∙₂Red.ap-ap-coh!-rhs-i c to /
=⟨ assoc (E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /))
(E₂∙Red.lhs-o c) (∘-ap to (right ∘ f₃∙) (glue c)) (ap (ap to) (E∙₂Red.lhs-i c))
(E∙₂Red.ap-ap-coh!-lhs-i c to) _ _ _ _ (To.glue-β (left (f₂₁ c))) _ ⟩
E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /
∙□-i/ E∙₂Red.ap-ap-coh!-lhs-i c to ∙ ap (ap to) (E∙₂Red.lhs-i c) ∙ ∘-ap to (right ∘ f₃∙) (glue c) ∙ E₂∙Red.lhs-o c
/ E₂∙Red.rhs-o c ∙ ap-∘ to (left ∘ f₁∙) (glue c) ∙ ap (ap to) (E∙₂Red.rhs-i c) ∙ E∙₂Red.ap-ap-coh!-rhs-i c to /
=⟨ ∙□-i/-rewrite (E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /) lemma2'-1 lemma2'-2 ⟩
E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /
∙□-i/ (∘-ap to right (glue (f₃₂ c)) ∙ I₄∙.glue-β (f₃₂ c)) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c))
/ (! (∘-ap to left (glue (f₁₂ c)) ∙ I₀∙.glue-β (f₁₂ c))) |in-ctx (λ u → ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c)) / ∎ where
assoc : ∀ {i} {A : Type i} {a b b' c : A} {u u' : a == b} {v v1 v2 v3 v4 : b == c}
{w w1 w2 w3 w4 : a == b'} {x x' : b' == c} (α : (u , v =□ w , x))
(p1 : v1 == v) (p2 : v2 == v1) (p3 : v3 == v2) (p4 : v4 == v3)
(q1 : w == w1) (q2 : w1 == w2) (q3 : w2 == w3) (q4 : w3 == w4)
(r : u' == u) (s : x == x')
→ α ∙□-i/ p1 / q1 / ∙□-o/ r / s / ∙□-i/ p2 / q2 / ∙□-i/ p3 / q3 / ∙□-i/ p4 / q4 /
== α ∙□-o/ r / s / ∙□-i/ p4 ∙ p3 ∙ p2 ∙ p1 / q1 ∙ q2 ∙ q3 ∙ q4 /
assoc α idp idp idp idp idp idp idp idp idp idp = idp
lemma2-4'' =
E∙₂Red.ap-ap-coh! c to (ap□ to (↓-='-out (apd (glue {d = v-h-span}) (glue c))
∙□-i/ E∙₂Red.lhs-i c / E∙₂Red.rhs-i c /)
∙□-i/ E∙₂Red.ap-ap-coh!-lhs-i c to / E∙₂Red.ap-ap-coh!-rhs-i c to /)
=⟨ lemma2-4' |in-ctx (E∙₂Red.ap-ap-coh! c to) ⟩
E∙₂Red.ap-ap-coh! c to (E₂∙Red.coh c (↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /)
∙□-o/ To.glue-β (left (f₂₁ c)) / ! (To.glue-β (right (f₂₃ c))) /
∙□-i/ (∘-ap to right (glue (f₃₂ c)) ∙ I₄∙.glue-β (f₃₂ c)) |in-ctx (λ u → ap (left ∘ right) (H₃₁ c) ∙ u ∙ ap (right ∘ right) (H₃₃ c))
/ (! (∘-ap to left (glue (f₁₂ c)) ∙ I₀∙.glue-β (f₁₂ c))) |in-ctx (λ u → ap (left ∘ left) (H₁₁ c) ∙ u ∙ ap (right ∘ left) (H₁₃ c))/)
=⟨ lemma! (∘-ap to left (glue (f₁₂ c)) ∙ I₀∙.glue-β (f₁₂ c)) (To.glue-β (right (f₂₃ c))) (To.glue-β (left (f₂₁ c))) (∘-ap to right (glue (f₃₂ c)) ∙ I₄∙.glue-β (f₃₂ c))
(↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /) ⟩
↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /
∙□-o/ ∘-ap to left (glue (f₁₂ c)) ∙ I₀∙.glue-β (f₁₂ c) / ! (∘-ap to right (glue (f₃₂ c)) ∙ I₄∙.glue-β (f₃₂ c)) /
∙□-i/ (To.glue-β (right (f₂₃ c))) |in-ctx (λ u → ap (right ∘ left) (H₁₃ c) ∙ u ∙ ! (ap (right ∘ right) (H₃₃ c)))
/ (! (To.glue-β (left (f₂₁ c)))) |in-ctx (λ u → ! (ap (left ∘ left) (H₁₁ c)) ∙ u ∙ ap (left ∘ right) (H₃₁ c)) / ∎
lemma2-4 =
ap□ to (E∙₂Red.coh! c (↓-='-out (apd (glue {d = v-h-span}) (glue c))
∙□-i/ E∙₂Red.lhs-i c / E∙₂Red.rhs-i c /))
=⟨ E∙₂Red.ap-ap-coh!-β c to (↓-='-out (apd (glue {d = v-h-span}) (glue c)) ∙□-i/ E∙₂Red.lhs-i c / E∙₂Red.rhs-i c /) ⟩
E∙₂Red.ap-ap-coh! c to (ap□ to (↓-='-out (apd (glue {d = v-h-span}) (glue c))
∙□-i/ E∙₂Red.lhs-i c / E∙₂Red.rhs-i c /)
∙□-i/ E∙₂Red.ap-ap-coh!-lhs-i c to / E∙₂Red.ap-ap-coh!-rhs-i c to /)
∙□-i/ E∙₂Red.ap-ap-coh!-lhs-o c to / E∙₂Red.ap-ap-coh!-rhs-o c to /
=⟨ lemma2-4'' |in-ctx (λ u → u ∙□-i/ E∙₂Red.ap-ap-coh!-lhs-o c to / E∙₂Red.ap-ap-coh!-rhs-o c to /) ⟩
↓-='-out (apd (glue {d = h-v-span}) (glue c))
∙□-i/ E₂∙Red.lhs-i c / E₂∙Red.rhs-i c /
∙□-o/ ∘-ap to left (glue (f₁₂ c)) ∙ I₀∙.glue-β (f₁₂ c) / ! (∘-ap to right (glue (f₃₂ c)) ∙ I₄∙.glue-β (f₃₂ c)) /
∙□-i/ (To.glue-β (right (f₂₃ c))) |in-ctx (λ u → ap (right ∘ left) (H₁₃ c) ∙ u ∙ ! (ap (right ∘ right) (H₃₃ c)))
/ (! (To.glue-β (left (f₂₁ c)))) |in-ctx (λ u → ! (ap (left ∘ left) (H₁₁ c)) ∙ u ∙ ap (left ∘ right) (H₃₁ c)) /
∙□-i/ E∙₂Red.ap-ap-coh!-lhs-o c to / E∙₂Red.ap-ap-coh!-rhs-o c to / ∎
| {
"alphanum_fraction": 0.4192809481,
"avg_line_length": 57.9288461538,
"ext": "agda",
"hexsha": "c80cba3f7f1fa4bd7ff5922cb996176226848d43",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "homotopy/3x3/ToFrom2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "homotopy/3x3/ToFrom2.agda",
"max_line_length": 209,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "homotopy/3x3/ToFrom2.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 16558,
"size": 30123
} |
open import Common
open import Global
open import Projection
open import Local
open import Data.Fin
open import Data.Product
open import Data.Vec
open import Relation.Binary.PropositionalEquality
n = 4
Role = Fin n
p : Role
p = zero
q : Role
q = suc zero
r : Role
r = suc (suc zero)
s : Role
s = suc (suc (suc zero))
l : Label
l = 0
l′ : Label
l′ = 1
g₁ : Global n
g₁ = msgSingle′ p q l endG
lp : Local n
lp = sendSingle q l endL
g₁-proj-p-is-lp : project g₁ p ≡ lp
g₁-proj-p-is-lp = refl
lq : Local n
lq = recvSingle p l endL
g₁-proj-q-is-lq : project g₁ q ≡ lq
g₁-proj-q-is-lq = refl
p→q : Action n
p→q = action′ p q l
r→s : Action n
r→s = action′ r s l′
g₂ : Global n
g₂ = msgSingle′ r s l′ g₁
g₂′ : Global n
g₂′ = msgSingle′ r s l′ endG
g₁→end : g₁ - p→q →g endG
g₁→end = →g-prefix
g₂→g₁ : g₂ - r→s →g g₁
g₂→g₁ = →g-prefix
g₂→g₂′ : g₂ - p→q →g g₂′
g₂→g₂′ = →g-cont g₁→end (λ ()) (λ ()) (λ ()) (λ ())
g₁-proj-p→end : (p , project g₁ p) - p→q →l (p , endL)
g₁-proj-p→end = →l-send p refl λ ()
g₁-proj-q→end : (q , project g₁ q) - p→q →l (q , endL)
g₁-proj-q→end = →l-recv q refl λ ()
g₂-proj-p→g₂′-proj-p : (p , project g₂ p) - p→q →l (p , project g₂′ p)
g₂-proj-p→g₂′-proj-p = →l-send p refl λ ()
g₂-proj-q→g₂′-proj-q : (q , project g₂ q) - p→q →l (q , project g₂′ q)
g₂-proj-q→g₂′-proj-q = →l-recv q refl λ ()
c₁ : Configuration n
c₁ = lp ∷ lq ∷ endL ∷ endL ∷ []
cEnd : Configuration n
cEnd = endL ∷ endL ∷ endL ∷ endL ∷ []
c₁→cEnd : c₁ - p→q →c cEnd
c₁→cEnd = →c-comm c₁ (λ ()) refl refl refl g₁-proj-p→end g₁-proj-q→end
g₁↔c₁ : g₁ ↔ c₁
g₁↔c₁ = record { isProj = refls }
where
refls : (p : Fin n) -> lookup c₁ p ≡ project g₁ p
refls zero = refl
refls (suc zero) = refl
refls (suc (suc zero)) = refl
refls (suc (suc (suc zero))) = refl
| {
"alphanum_fraction": 0.594639866,
"avg_line_length": 18.2755102041,
"ext": "agda",
"hexsha": "a0c973623a96e11509362b262594d514c467d462",
"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": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "fangyi-zhou/mpst-in-agda",
"max_forks_repo_path": "Example.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T11:30:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-08-31T10:15:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "fangyi-zhou/mpst-in-agda",
"max_issues_repo_path": "Example.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "fangyi-zhou/mpst-in-agda",
"max_stars_repo_path": "Example.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-14T17:36:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-08-14T17:36:53.000Z",
"num_tokens": 796,
"size": 1791
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Numbers.Integers.RingStructure.Ring
open import Semirings.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Orders.Total.Definition
open import Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
module Numbers.Integers.Order where
infix 5 _<Z_
record _<Z_ (a : ℤ) (b : ℤ) : Set where
constructor le
field
x : ℕ
proof : (nonneg (succ x)) +Z a ≡ b
lessLemma : (a x : ℕ) → succ x +N a ≡ a → False
lessLemma zero x pr = naughtE (equalityCommutative pr)
lessLemma (succ a) x pr = lessLemma a x q
where
q : succ x +N a ≡ a
q rewrite Semiring.commutative ℕSemiring a (succ x) | Semiring.commutative ℕSemiring x a | Semiring.commutative ℕSemiring (succ a) x = succInjective pr
irreflexive : (x : ℤ) → x <Z x → False
irreflexive (nonneg x) record { x = y ; proof = proof } = lessLemma x y (nonnegInjective proof)
irreflexive (negSucc a) record { x = x ; proof = proof } = naughtE (equalityCommutative q)
where
pr' : nonneg (succ x) +Z (negSucc a +Z nonneg (succ a)) ≡ negSucc a +Z nonneg (succ a)
pr' rewrite +ZAssociative (nonneg (succ x)) (negSucc a) (nonneg (succ a)) = applyEquality (λ t → t +Z nonneg (succ a)) proof
pr'' : nonneg (succ x) +Z nonneg 0 ≡ nonneg 0
pr'' rewrite equalityCommutative (additiveInverseExists a) = identityOfIndiscernablesLeft _≡_ pr' q
where
q : nonneg (succ x) +Z (negSucc a +Z nonneg (succ a)) ≡ nonneg (succ (x +N 0))
q rewrite Semiring.commutative ℕSemiring x 0 | additiveInverseExists a | Semiring.commutative ℕSemiring x 0 = refl
pr''' : succ x +N 0 ≡ 0
pr''' = nonnegInjective pr''
q : succ x ≡ 0
q rewrite Semiring.commutative ℕSemiring 0 (succ x) = pr'''
lessZTransitive : {a b c : ℤ} → (a <Z b) → (b <Z c) → (a <Z c)
lessZTransitive {a} {b} {c} (le d1 pr1) (le d2 pr2) rewrite equalityCommutative pr1 = le (d1 +N succ d2) pr
where
pr : nonneg (succ (d1 +N succ d2)) +Z a ≡ c
pr rewrite +ZAssociative (nonneg (succ d2)) (nonneg (succ d1)) a | Semiring.commutative ℕSemiring (succ d2) (succ d1) = pr2
lessInherits : {a b : ℕ} → (a <N b) → ((nonneg a) <Z (nonneg b))
_<Z_.x (lessInherits {a} {b} (le x proof)) = x
_<Z_.proof (lessInherits {a} {.(succ (x +N a))} (le x refl)) = refl
lessInheritsNegsucc : {a b : ℕ} → (a <N b) → ((negSucc b) <Z negSucc a)
_<Z_.x (lessInheritsNegsucc {a} {b} (le x proof)) = x
_<Z_.proof (lessInheritsNegsucc {a} {b} (le x proof)) rewrite equalityCommutative proof = transitivity (transitivity (+ZCommutative (nonneg x) (negSucc (x +N a))) (applyEquality (λ i → negSucc i +Z nonneg x) (Semiring.commutative ℕSemiring x a))) (equalityCommutative (negSucc+Nonneg a x))
lessNegsuccNonneg : {a b : ℕ} → (negSucc a <Z nonneg b)
_<Z_.x (lessNegsuccNonneg {a} {b}) = a +N b
_<Z_.proof (lessNegsuccNonneg {zero} {b}) = refl
_<Z_.proof (lessNegsuccNonneg {succ a} {b}) = _<Z_.proof (lessNegsuccNonneg {a} {b})
lessThanTotalZ : {a b : ℤ} → ((a <Z b) || (b <Z a)) || (a ≡ b)
lessThanTotalZ {nonneg a} {nonneg b} with TotalOrder.totality ℕTotalOrder a b
lessThanTotalZ {nonneg a} {nonneg b} | inl (inl a<b) = inl (inl (lessInherits a<b))
lessThanTotalZ {nonneg a} {nonneg b} | inl (inr b<a) = inl (inr (lessInherits b<a))
lessThanTotalZ {nonneg a} {nonneg b} | inr a=b = inr (applyEquality nonneg a=b)
lessThanTotalZ {nonneg a} {negSucc b} = inl (inr (lessNegsuccNonneg {b} {a}))
lessThanTotalZ {negSucc a} {nonneg x} = inl (inl (lessNegsuccNonneg {a} {x}))
lessThanTotalZ {negSucc a} {negSucc b} with TotalOrder.totality ℕTotalOrder a b
... | inl (inl a<b) = inl (inr (lessInheritsNegsucc a<b))
... | inl (inr b<a) = inl (inl (lessInheritsNegsucc b<a))
lessThanTotalZ {negSucc a} {negSucc .a} | inr refl = inr refl
ℤOrder : TotalOrder ℤ
PartialOrder._<_ (TotalOrder.order ℤOrder) = _<Z_
PartialOrder.irreflexive (TotalOrder.order ℤOrder) {a} = irreflexive a
PartialOrder.<Transitive (TotalOrder.order ℤOrder) = lessZTransitive
TotalOrder.totality ℤOrder a b = lessThanTotalZ {a} {b}
orderRespectsAddition : (a b : ℤ) → a <Z b → (c : ℤ) → a +Z c <Z b +Z c
orderRespectsAddition (nonneg a) (nonneg b) (le x proof) (nonneg c) = le x (transitivity (+ZAssociative (nonneg (succ x)) (nonneg a) (nonneg c)) (applyEquality (_+Z nonneg c) proof))
orderRespectsAddition (nonneg a) (nonneg b) (le x proof) (negSucc c) = le x (transitivity (+ZAssociative (nonneg (succ x)) (nonneg a) (negSucc c)) (applyEquality (_+Z negSucc c) proof))
orderRespectsAddition (negSucc a) (nonneg b) (le x proof) (nonneg c) = le x (transitivity (+ZAssociative (nonneg (succ x)) (negSucc a) (nonneg c)) (applyEquality (_+Z nonneg c) proof))
orderRespectsAddition (negSucc a) (nonneg b) (le x proof) (negSucc c) = le x (transitivity (+ZAssociative (nonneg (succ x)) (negSucc a) (negSucc c)) (applyEquality (_+Z negSucc c) proof))
orderRespectsAddition (negSucc a) (negSucc b) (le x proof) (nonneg c) = le x (transitivity (+ZAssociative (nonneg (succ x)) (negSucc a) (nonneg c)) (applyEquality (_+Z nonneg c) proof))
orderRespectsAddition (negSucc a) (negSucc b) (le x proof) (negSucc c) = le x (transitivity (+ZAssociative (nonneg (succ x)) (negSucc a) (negSucc c)) (applyEquality (_+Z negSucc c) proof))
orderRespectsMultiplication : (a b : ℤ) → nonneg 0 <Z a → nonneg 0 <Z b → nonneg 0 <Z a *Z b
orderRespectsMultiplication (nonneg (succ a)) (nonneg (succ b)) 0<a 0<b = lessInherits (succIsPositive (b +N a *N succ b))
ℤPOrderedRing : PartiallyOrderedRing ℤRing (SetoidTotalOrder.partial (totalOrderToSetoidTotalOrder ℤOrder))
PartiallyOrderedRing.orderRespectsAddition ℤPOrderedRing {a} {b} = orderRespectsAddition a b
PartiallyOrderedRing.orderRespectsMultiplication ℤPOrderedRing {a} {b} = orderRespectsMultiplication a b
ℤOrderedRing : TotallyOrderedRing ℤPOrderedRing
TotallyOrderedRing.total ℤOrderedRing = totalOrderToSetoidTotalOrder ℤOrder
| {
"alphanum_fraction": 0.6991518377,
"avg_line_length": 60.13,
"ext": "agda",
"hexsha": "599b55f2c579fd64a6831a1b72a236df4594798e",
"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/Integers/Order.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/Integers/Order.agda",
"max_line_length": 289,
"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/Integers/Order.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": 2190,
"size": 6013
} |
module Data.Option where
import Lvl
open import Data
open import Type
private variable ℓ ℓ₁ ℓ₂ : Lvl.Level
private variable T : Type{ℓ}
data Option (T : Type{ℓ}) : Type{ℓ} where
None : Option(T)
Some : T → Option(T)
elim : ∀{A : Type{ℓ₁}}{B : Option(A) → Type{ℓ₂}} → B(None) → ((a : A) → B(Some a)) → ((o : Option(A)) → B(o))
elim b _ None = b
elim b ab (Some a) = ab a
| {
"alphanum_fraction": 0.5927835052,
"avg_line_length": 22.8235294118,
"ext": "agda",
"hexsha": "26c6cdeb8fe12e17c5a6c27692f06d77b508bd94",
"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": "Data/Option.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": "Data/Option.agda",
"max_line_length": 109,
"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": "Data/Option.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": 145,
"size": 388
} |
{-# OPTIONS --universe-polymorphism #-}
module IDesc where
--********************************************
-- Prelude
--********************************************
-- Some preliminary stuffs, to avoid relying on the stdlib
--****************
-- Universe polymorphism
--****************
data Level : Set where
zero : Level
suc : Level -> Level
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO zero #-}
{-# BUILTIN LEVELSUC suc #-}
max : Level -> Level -> Level
max zero m = m
max (suc n) zero = suc n
max (suc n) (suc m) = suc (max n m)
{-# BUILTIN LEVELMAX max #-}
data Lifted {l : Level} (A : Set l) : Set (suc l) where
lifter : A → Lifted A
lift : {i : Level} -> Set i -> Set (suc i)
lift x = Lifted x
unlift : {l : Level}{A : Set l} -> Lifted A -> A
unlift (lifter a) = a
--****************
-- Sigma and friends
--****************
data Sigma {i j : Level}(A : Set i) (B : A -> Set j) : Set (max i j) where
_,_ : (x : A) (y : B x) -> Sigma A B
pair : {i j : Level}{A : Set i}{B : A -> Set j} ->
(x : A) (y : B x) -> Sigma {i = i}{j = j} A B
pair x y = x , y
_*_ : {i j : Level}(A : Set i)(B : Set j) -> Set (max i j)
A * B = Sigma A \_ -> B
fst : {i j : Level}{A : Set i}{B : A -> Set j} -> Sigma A B -> A
fst (a , _) = a
snd : {i j : Level}{A : Set i}{B : A -> Set j} (p : Sigma A B) -> B (fst p)
snd (a , b) = b
data Zero {i : Level} : Set i where
data Unit {i : Level} : Set i where
Void : Unit
--****************
-- Sum and friends
--****************
data _+_ {i j : Level}(A : Set i)(B : Set j) : Set (max i j) where
l : A -> A + B
r : B -> A + B
--****************
-- Equality
--****************
data _==_ {l : Level}{A : Set l}(x : A) : A -> Set l where
refl : x == x
cong : {l m : Level}{A : Set l}{B : Set m}
(f : A -> B){x y : A} -> x == y -> f x == f y
cong f refl = refl
cong2 : {l m n : Level}{A : Set l}{B : Set m}{C : Set n}
(f : A -> B -> C){x y : A}{z t : B} ->
x == y -> z == t -> f x z == f y t
cong2 f refl refl = refl
trans : {l : Level}{A : Set l}{x y z : A} -> x == y -> y == z -> x == z
trans refl refl = refl
proof-lift-unlift-eq : {l : Level}{A : Set l}(x : Lifted A) -> lifter (unlift x) == x
proof-lift-unlift-eq (lifter a) = refl
postulate
reflFun : {l m : Level}{A : Set l}{B : Set m}(f : A -> B)(g : A -> B)-> ((a : A) -> f a == g a) -> f == g
--********************************************
-- Desc code
--********************************************
data IDesc {l : Level}(I : Set (suc l)) : Set (suc l) where
var : I -> IDesc I
const : Set l -> IDesc I
prod : IDesc I -> IDesc I -> IDesc I
sigma : (S : Set l) -> (S -> IDesc I) -> IDesc I
pi : (S : Set l) -> (S -> IDesc I) -> IDesc I
--********************************************
-- Desc interpretation
--********************************************
desc : {l : Level}{I : Set (suc l)} -> IDesc I -> (I -> Set l) -> Set l
desc (var i) P = P i
desc (const X) P = X
desc (prod D D') P = desc D P * desc D' P
desc (sigma S T) P = Sigma S (\s -> desc (T s) P)
desc (pi S T) P = (s : S) -> desc (T s) P
--********************************************
-- Fixpoint construction
--********************************************
data IMu {l : Level}{I : Set (suc l)}(R : I -> IDesc {l = l} I)(i : I) : Set l where
con : desc (R i) (\j -> IMu R j) -> IMu R i
--********************************************
-- Predicate: Box
--********************************************
box : {l : Level}{I : Set (suc l)}(D : IDesc I)(X : I -> Set l) -> desc D X -> IDesc (Sigma I X)
box (var i) X x = var (i , x)
box (const _) X x = const Unit
box (prod D D') X (d , d') = prod (box D X d) (box D' X d')
box (sigma S T) X (a , b) = box (T a) X b
box (pi S T) X f = pi S (\s -> box (T s) X (f s))
--********************************************
-- Elimination principle: induction
--********************************************
module Elim {l : Level}
{I : Set (suc l)}
(R : I -> IDesc I)
(P : Sigma I (IMu R) -> Set l)
(m : (i : I)
(xs : desc (R i) (IMu R))
(hs : desc (box (R i) (IMu R) xs) P) ->
P ( i , con xs ))
where
mutual
induction : (i : I)(x : IMu R i) -> P (i , x)
induction i (con xs) = m i xs (hyps (R i) xs)
hyps : (D : IDesc I) ->
(xs : desc D (IMu R)) ->
desc (box D (IMu R) xs) P
hyps (var i) x = induction i x
hyps (const X) x = Void
hyps (prod D D') (d , d') = hyps D d , hyps D' d'
hyps (pi S R) f = \ s -> hyps (R s) (f s)
hyps (sigma S R) ( a , b ) = hyps (R a) b
induction : {l : Level}
{I : Set (suc l)}
(R : I -> IDesc I)
(P : Sigma I (IMu R) -> Set l)
(m : (i : I)
(xs : desc (R i) (IMu R))
(hs : desc (box (R i) (IMu R) xs) P) ->
P ( i , con xs)) ->
(i : I)(x : IMu R i) -> P ( i , x )
induction = Elim.induction
--********************************************
-- DescD
--********************************************
data DescDConst {l : Level} : Set l where
lvar : DescDConst
lconst : DescDConst
lprod : DescDConst
lpi : DescDConst
lsigma : DescDConst
descDChoice : {l : Level} -> Set (suc l) -> DescDConst -> IDesc Unit
descDChoice I lvar = const I
descDChoice _ lconst = const (Set _)
descDChoice _ lprod = prod (var Void) (var Void)
descDChoice _ lpi = sigma (Set _) (\S -> pi (lift S) (\s -> var Void))
descDChoice _ lsigma = sigma (Set _) (\S -> pi (lift S) (\s -> var Void))
IDescD : {l : Level}(I : Set (suc l)) -> IDesc {l = suc l} Unit
IDescD I = sigma DescDConst (descDChoice I)
IDescl0 : {l : Level}(I : Set (suc l)) -> Unit -> Set (suc l)
IDescl0 {x} I = IMu {l = suc x} (\_ -> IDescD {l = x} I)
IDescl : {l : Level}(I : Set (suc l)) -> Set (suc l)
IDescl I = IDescl0 I Void
varl : {l : Level}{I : Set (suc l)}(i : I) -> IDescl I
varl {x} i = con (lvar {l = suc x} , i)
constl : {l : Level}{I : Set (suc l)}(X : Set l) -> IDescl I
constl {x} X = con (lconst {l = suc x} , X)
prodl : {l : Level}{I : Set (suc l)}(D D' : IDescl I) -> IDescl I
prodl {x} D D' = con (lprod {l = suc x} , (D , D'))
pil : {l : Level}{I : Set (suc l)}(S : Set l)(T : S -> IDescl I) -> IDescl I
pil {x} S T = con (lpi {l = suc x} , pair {i = suc x}{j = suc x} S (\s -> T (unlift s)))
sigmal : {l : Level}{I : Set (suc l)}(S : Set l)(T : S -> IDescl I) -> IDescl I
sigmal {x} S T = con (lsigma {l = suc x} , pair {i = suc x}{j = suc x} S (\s -> T (unlift s)))
--********************************************
-- From the embedding to the host
--********************************************
cases : {l : Level}
{I : Set (suc l)}
(xs : desc (IDescD I) (IMu (λ _ -> IDescD I)))
(hs : desc (box (IDescD I) (IMu (λ _ -> IDescD I)) xs) (λ _ -> IDesc I)) ->
IDesc I
cases ( lvar , i ) hs = var i
cases ( lconst , X ) hs = const X
cases ( lprod , (D , D') ) ( d , d' ) = prod d d'
cases ( lpi , ( S , T ) ) hs = pi S (\s -> hs (lifter s) )
cases ( lsigma , ( S , T ) ) hs = sigma S (\s -> hs (lifter s))
phi : {l : Level}{I : Set (suc l)} -> IDescl I -> IDesc I
phi {x} {I} d = induction (\_ -> IDescD I) (\_ -> IDesc I) (\_ -> cases) Void d
--********************************************
-- From the host to the embedding
--********************************************
psi : {l : Level}{I : Set (suc l)} -> IDesc I -> IDescl I
psi (var i) = varl i
psi (const X) = constl X
psi (prod D D') = prodl (psi D) (psi D')
psi (pi S T) = pil S (\s -> psi (T s))
psi (sigma S T) = sigmal S (\s -> psi (T s))
--********************************************
-- Isomorphism proof
--********************************************
-- From host to host
proof-phi-psi : {l : Level}{I : Set (suc l)} -> (D : IDesc I) -> phi (psi D) == D
proof-phi-psi (var i) = refl
proof-phi-psi (const x) = refl
proof-phi-psi (prod D D') with proof-phi-psi D | proof-phi-psi D'
... | p | q = cong2 prod p q
proof-phi-psi {x} (pi S T) = cong (pi S)
(reflFun (\s -> phi (psi (T s)))
T
(\s -> proof-phi-psi (T s)))
proof-phi-psi (sigma S T) = cong (sigma S)
(reflFun (\ s -> phi (psi (T s)))
T
(\s -> proof-phi-psi (T s)))
-- From embedding to embedding
proof-psi-phi : {l : Level}(I : Set (suc l)) -> (D : IDescl I) -> psi (phi D) == D
proof-psi-phi {x} I D = induction (\ _ -> IDescD I)
P
proof-psi-phi-cases
Void
D
where P : Sigma Unit (IMu (\ x -> IDescD I)) -> Set (suc x)
P ( Void , D ) = psi (phi D) == D
proof-psi-phi-cases : (i : Unit)
(xs : desc (IDescD I) (IDescl0 I))
(hs : desc (box (IDescD I) (IDescl0 I) xs) P)
-> P (i , con xs)
proof-psi-phi-cases Void (lvar , i) hs = refl
proof-psi-phi-cases Void (lconst , x) hs = refl
proof-psi-phi-cases Void (lprod , ( D , D' )) ( p , q ) = cong2 prodl p q
proof-psi-phi-cases Void (lpi , ( S , T )) hs = cong (\T -> con (lpi {l = suc x} , ( S , T ) ))
(trans (reflFun (\ s -> psi (phi (T (lifter (unlift s)))))
(\ s -> psi (phi (T (s))))
(\s -> cong (\ s -> psi (phi (T (s))))
(proof-lift-unlift-eq s)))
(reflFun (\s -> psi (phi (T s)))
T
hs))
proof-psi-phi-cases Void (lsigma , ( S , T )) hs = cong (\T -> con (lsigma {l = suc x} , ( S , T ) ))
(trans (reflFun (\ s → psi (phi (T (lifter (unlift s)))))
(\ s → psi (phi (T (s))))
(\s -> cong (\ s -> psi (phi (T (s))))
(proof-lift-unlift-eq s)))
(reflFun (\s -> psi (phi (T s)))
T
hs)) | {
"alphanum_fraction": 0.3768246531,
"avg_line_length": 36.7483443709,
"ext": "agda",
"hexsha": "2f91bfc1ebee8aaec7d5d1329fc8110225006276",
"lang": "Agda",
"max_forks_count": 12,
"max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z",
"max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mietek/epigram",
"max_forks_repo_path": "models/IDesc.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"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": "mietek/epigram",
"max_issues_repo_path": "models/IDesc.agda",
"max_line_length": 123,
"max_stars_count": 48,
"max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mietek/epigram",
"max_stars_repo_path": "models/IDesc.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z",
"num_tokens": 3453,
"size": 11098
} |
open import OutsideIn.Prelude
open import OutsideIn.X
module OutsideIn.Instantiations.Simple where
open import Data.Fin hiding (_+_)
data Type ( n : Set) : Set where
funTy : Type n
_·_ : Type n → Type n → Type n
Var : n → Type n
private
fmap-τ : ∀ {a b} → (a → b) → Type a → Type b
fmap-τ f (funTy) = funTy
fmap-τ f (x · y) = fmap-τ f x · fmap-τ f y
fmap-τ f (Var v) = Var (f v)
fmap-τ-id : ∀ {A : Set} {f : A → A} → isIdentity f → isIdentity (fmap-τ f)
fmap-τ-id {f = f} isid {funTy} = refl
fmap-τ-id {f = f} isid {α · β} = cong₂ _·_ (fmap-τ-id isid) (fmap-τ-id isid)
fmap-τ-id {f = f} isid {Var v} = cong Var isid
fmap-τ-comp : {A B C : Set} {f : A → B} {g : B → C} {x : Type A}
→ fmap-τ (g ∘ f) x ≡ fmap-τ g (fmap-τ f x)
fmap-τ-comp {x = funTy} = refl
fmap-τ-comp {x = α · β} = cong₂ _·_ fmap-τ-comp fmap-τ-comp
fmap-τ-comp {x = Var v} = cong Var refl
type-is-functor : Functor Type
type-is-functor = record { map = fmap-τ
; identity = fmap-τ-id
; composite = fmap-τ-comp
}
type-is-monad : Monad Type
type-is-monad = record { is-functor = type-is-functor
; point = Var
; join = join-τ
; is-left-ident = left-id
; is-right-ident = refl
; >=>-assoc = λ {_}{_}{_}{_}{_}{_}{c}{v} → assoc {τ = c v}
}
where join-τ :{a : Set} → Type (Type a) → Type a
join-τ (funTy) = funTy
join-τ (x · y) = join-τ x · join-τ y
join-τ (Var v) = v
open Functor (type-is-functor)
assoc : ∀{A B C}{a : B → Type C}{b : A → Type B}{τ : Type A}
→ join-τ (fmap-τ a (join-τ (fmap-τ b τ)))
≡ join-τ (fmap-τ (λ v' → join-τ (fmap-τ a (b v'))) τ)
assoc {a = a}{b}{funTy} = refl
assoc {a = a}{b}{α · β} = cong₂ _·_ (assoc {τ = α}) (assoc {τ = β})
assoc {a = a}{b}{Var v} = refl
left-id : ∀ {a}{τ : Type a} → join-τ (Var <$> τ) ≡ τ
left-id {_}{funTy} = refl
left-id {_}{α · β} = cong₂ _·_ (left-id {τ = α}) (left-id {τ = β})
left-id {_}{Var v} = refl
data SConstraint (x : Set) : Set where
_∼_ : Type x → Type x → SConstraint x
_∧′_ : SConstraint x → SConstraint x → SConstraint x
ε : SConstraint x
sconstraint-is-functor : Functor SConstraint
sconstraint-is-functor = record { map = s-map; identity = s-ident; composite = s-comp }
where open Functor (type-is-functor)
s-map : {A B : Set} → (A → B) → SConstraint A → SConstraint B
s-map f (ε) = ε
s-map f (a ∼ b) = map f a ∼ map f b
s-map f (a ∧′ b) = s-map f a ∧′ s-map f b
s-ident : {A : Set} {f : A → A} → isIdentity f → isIdentity (s-map f)
s-ident isid {ε} = refl
s-ident isid {a ∼ b} = cong₂ _∼_ (identity isid) (identity isid)
s-ident isid {a ∧′ b} = cong₂ _∧′_ (s-ident isid) (s-ident isid)
s-comp : {A B C : Set} {f : A → B} {g : B → C} {x : SConstraint A}
→ s-map (g ∘ f) x ≡ s-map g (s-map f x)
s-comp {x = ε} = refl
s-comp {x = a ∼ b} = cong₂ _∼_ composite composite
s-comp {x = a ∧′ b} = cong₂ _∧′_ s-comp s-comp
_⟶_ : ∀ {n} → Type n → Type n → Type n
a ⟶ b = (funTy · a) · b
types : Types
types = record { Type = Type
; type-is-monad = type-is-monad
; funType = _⟶_; appType = _·_
}
data SVar (tc : Set)(n : ℕ) : Set where
base : tc → SVar tc n
unification : Fin n → SVar tc n
thin : {n : ℕ} → Fin (suc n) → Fin n → Fin (suc n)
thin zero y = suc y
thin (suc x) zero = zero
thin (suc x) (suc y) = suc (thin x y)
thick : ∀ {n} → (x y : Fin (suc n)) → Ⓢ (Fin n)
thick zero zero = zero
thick zero (suc y) = suc y
thick {zero } (suc ()) _
thick {suc _} (suc x) zero = suc zero
thick {suc _} (suc x) (suc y) with thick x y
... | zero = zero
... | suc n = suc (suc n)
check : ∀ {tc}{n} → Fin (suc n) → Type (SVar tc (suc n)) → Ⓢ (Type (SVar tc n))
check x (funTy) = suc funTy
check x (Var (base v)) = suc (Var (base v))
check x (Var (unification n)) = map (Var ∘ unification) (thick x n)
where open Functor (Monad.is-functor Ⓢ-is-monad)
check x (a · b) = check x a >>= λ a′ →
check x b >>= λ b′ →
unit (a′ · b′)
where open Monad (Ⓢ-is-monad)
data AList (tc : Set) : ℕ → ℕ → Set where
anil : ∀ {n} → AList tc n n
_asnoc_/_ : ∀ {m n} → AList tc m n → Type (SVar tc m) → Fin (suc m) → AList tc (suc m) n
_∃asnoc_/_ : ∀ {tc}{m} (a : ∃ (AList tc m)) (t' : Type (SVar tc m)) (x : Fin (suc m))
→ ∃ (AList tc (suc m))
(n , σ) ∃asnoc t' / x = n , σ asnoc t' / x
_for_ : ∀{tc}{n} → (Type (SVar tc n)) → Fin (suc n)
→ SVar tc (suc n) → Type (SVar tc n)
(t′ for x) (base y) = Var (base y)
(t′ for x) (unification y) with thick x y
... | suc y′ = Var (unification y′)
... | zero = t′
sub : ∀ {m n}{tc} → AList tc m n → SVar tc m → Type (SVar tc n)
sub anil = Var
sub (σ asnoc t / x) = sub σ >=> (t for x)
where open Monad (type-is-monad)
flexFlex : ∀ {tc}{m} (x y : Fin m) → ∃ (AList tc m)
flexFlex {_}{suc m} x y with thick x y
... | suc y′ = m , anil asnoc Var (unification y′) / x
... | zero = suc m , anil
flexFlex {_}{zero} () _
flexRigid : ∀ {tc}{m} (x : Fin m) (t : Type (SVar tc m)) -> Ⓢ (∃(AList tc m))
flexRigid {_}{suc m} x t with check x t
... | suc t′ = suc (m , anil asnoc t′ / x)
... | zero = zero
flexRigid {_}{zero} () _
amgu : ∀{tc}{m} → (Eq tc) → (s t : Type (SVar tc m)) → ∃ (AList tc m) → Ⓢ (∃ (AList tc m))
amgu eq (funTy) (funTy) acc = suc acc
amgu eq (Var (base a)) (Var (base b)) acc with eq a b
... | true = suc acc
... | false = zero
amgu eq (Var (base a)) (funTy) acc = zero
amgu eq (funTy) (Var (base b)) acc = zero
amgu eq (funTy) (a · b) acc = zero
amgu eq (Var (base _)) (a · b) acc = zero
amgu eq (a · b) (funTy) acc = zero
amgu eq (a · b) (Var (base _)) acc = zero
amgu eq (a · b) (a′ · b′) acc = amgu eq a a′ acc >>= amgu eq b b′
where open Monad (Ⓢ-is-monad)
amgu eq (Var (unification x)) (Var (unification y)) (m , anil) = suc (flexFlex x y)
amgu eq (Var (unification x)) t (m , anil) = flexRigid x t
amgu eq t (Var (unification x)) (m , anil) = flexRigid x t
amgu eq s t (n , σ asnoc r / z) = Ⓢ-f.map (λ σ → σ ∃asnoc r / z) (amgu eq (s >>= (r for z))
(t >>= (r for z))
(n , σ))
where module Ⓢ-f = Functor (Monad.is-functor Ⓢ-is-monad)
open Monad (type-is-monad)
mgu : ∀{tc}{m}(eq : Eq tc)(s t : Type (SVar tc m)) → Ⓢ (∃ (AList tc m))
mgu {m = m} eq s t = amgu eq s t (m , anil)
prf : ∀ {m n} → m + suc n ≡ suc m + n
prf {zero} = refl
prf {suc n} = cong suc (prf {n})
prf₂ : ∀ {m} → m + zero ≡ m
prf₂ {zero} = refl
prf₂ {suc n} = cong suc prf₂
svar-iso₁′ : ∀{m n}{tc} → SVar tc n ⨁ m → SVar tc (m + n)
svar-iso₁′ {zero} x = x
svar-iso₁′ {suc m}{n}{tc} v = subst (SVar tc) (prf {m}{n}) (svar-iso₁′ {m}{suc n} (pm-f.map ind v))
where module pm-f = Functor (Monad.is-functor (PlusN-is-monad {m}))
ind : ∀{tc}{m} → Ⓢ (SVar tc m) → SVar tc (suc m)
ind zero = unification zero
ind (suc n) with n
... | base v = base v
... | unification x = unification (suc x)
svar-iso₂′ : ∀{m}{tc} → Fin m → tc ⨁ m
svar-iso₂′ {zero} ()
svar-iso₂′ {suc n} zero = pn-m.unit zero
where module pn-m = Monad (PlusN-is-monad {n})
svar-iso₂′ {suc n} (suc v) = pm-f.map suc (svar-iso₂′ {n} v)
where module pm-f = Functor (Monad.is-functor (PlusN-is-monad {n}))
svar-iso₁ : ∀{m}{tc} → tc ⨁ m → SVar tc m
svar-iso₁ {m}{tc} v = subst (SVar tc) prf₂ (svar-iso₁′ {m}{zero}{tc} (pm-f.map base v))
where module pm-f = Functor (Monad.is-functor (PlusN-is-monad {m}))
svar-iso₂ : ∀{m}{tc} → SVar tc m → tc ⨁ m
svar-iso₂ {m}{tc} (base v) = pm-m.unit v
where module pm-m = Monad (PlusN-is-monad {m})
svar-iso₂ {m}{tc} (unification v) = svar-iso₂′ v
open Functor (Monad.is-functor type-is-monad) using () renaming (map to τ-map)
mgu′ : ∀{tc}{m}(eq : Eq tc)(s t : Type (tc ⨁ m)) → Ⓢ (∃ (λ n → tc ⨁ m → Type (tc ⨁ n)))
mgu′ {tc}{m} eq s t with mgu {tc}{m} eq (τ-map svar-iso₁ s) (τ-map svar-iso₁ t)
... | zero = zero
... | suc (n , al) = suc (n , τ-map svar-iso₂ ∘ sub al ∘ svar-iso₁)
data SConstraintShape (x : Set) : Shape → Set where
_∼_ : Type x → Type x → SConstraintShape x Nullary
ε : SConstraintShape x Nullary
_∧′_ : ∀ {a b} → SConstraintShape x a → SConstraintShape x b → SConstraintShape x (Binary a b)
applySubst : ∀ {a b}{s} → (a → Type b) → SConstraintShape a s → SConstraintShape b s
applySubst f (a ∼ b) = (a >>= f) ∼ (b >>= f)
where open Monad (type-is-monad)
applySubst f (a ∧′ b) = applySubst f a ∧′ applySubst f b
applySubst f (ε) = ε
constraint-types : ∀{a b} → (Type a → Type b) → (SConstraint a → SConstraint b)
constraint-types f ε = ε
constraint-types f (a ∧′ b) = constraint-types f a ∧′ constraint-types f b
constraint-types f (a ∼ b) = f a ∼ f b
applySubst′ : ∀ {a b} → (a → Type b) → SConstraint a → SConstraint b
applySubst′ f (a ∼ b) = (a >>= f) ∼ (b >>= f)
where open Monad (type-is-monad)
applySubst′ f (a ∧′ b) = applySubst′ f a ∧′ applySubst′ f b
applySubst′ f (ε) = ε
data AxiomScheme (n : Set) : Set where
ax : AxiomScheme n
coerceAxioms : ∀ {a b} → AxiomScheme a → AxiomScheme b
coerceAxioms ax = ax
coerceId : ∀ {x} → isIdentity (coerceAxioms {x} {x})
coerceId {_}{ax} = refl
axiom-schemes : AxiomSchemes
axiom-schemes = record { AxiomScheme = AxiomScheme
; axiomscheme-types = λ f → coerceAxioms
; axiomscheme-is-functor = record { map = λ f → coerceAxioms; identity = λ f → coerceId; composite = λ { {x = ax} → refl }}
}
is-ε : ∀ {m} (x : SConstraint m) → Dec (x ≡ ε)
is-ε ε = yes refl
is-ε (a ∧′ b) = no (λ ())
is-ε (a ∼ b) = no (λ ())
qconstraints : QConstraints
qconstraints = record { QConstraint = SConstraint
; qconstraint-is-functor = sconstraint-is-functor
; constraint-types = constraint-types
; _∼_ = _∼_; _∧_ = _∧′_; ε = ε; is-ε = is-ε
}
open Monad (type-is-monad) hiding (_>=>_)
open Functor (type-is-functor)
data _,_⊩_ {n : Set}(Q : AxiomScheme n) : SConstraint n → SConstraint n → Set where
ent-refl : ∀ {q q′} → Q , (q ∧′ q′) ⊩ q′
ent-trans : ∀ {q q₁ q₂ q₃} → Q , (q ∧′ q₁) ⊩ q₂ → Q , (q ∧′ q₂) ⊩ q₃ → Q , (q ∧′ q₁) ⊩ q₃
ent-typeq-refl : ∀ {q}{τ} → Q , q ⊩ (τ ∼ τ)
ent-typeq-sym : ∀ {q}{τ₁ τ₂} → Q , q ⊩ (τ₁ ∼ τ₂) → Q , q ⊩ (τ₂ ∼ τ₁)
ent-typeq-trans : ∀ {q}{τ₁ τ₂ τ₃} → Q , q ⊩ (τ₁ ∼ τ₂) → Q , q ⊩ (τ₂ ∼ τ₃) → Q , q ⊩ (τ₁ ∼ τ₃)
ent-conj : ∀ {q q₁ q₂} → Q , q ⊩ q₁ → Q , q ⊩ q₂ → Q , q ⊩ (q₁ ∧′ q₂)
ent-subst : ∀ {a b}{θ : a → Type b}{Q : AxiomScheme a}{q q₁ q₂ : SConstraint a} → Q , (q ∧′ q₁) ⊩ q₂ → coerceAxioms Q , constraint-types (join ∘ map θ) (q ∧′ q₁) ⊩ constraint-types (join ∘ map θ) q₂
ent-subst ent-refl = ent-refl
ent-subst (ent-trans a b) = ent-trans (ent-subst a) (ent-subst b)
ent-subst (ent-typeq-refl) = ent-typeq-refl
ent-subst (ent-typeq-sym a) = ent-typeq-sym (ent-subst a)
ent-subst (ent-typeq-trans a b) = ent-typeq-trans (ent-subst a) (ent-subst b)
ent-subst (ent-conj a b) = ent-conj (ent-subst a) (ent-subst b)
ent-typeq-subst : ∀ {a b}{Q : AxiomScheme a}{q : SConstraint a}{τ₁ τ₂ : Type a}{θ : a → Type b}
→ Q , q ⊩ (τ₁ ∼ τ₂) → coerceAxioms Q , constraint-types (join ∘ map θ) q
⊩ ((join ∘ map θ) τ₁ ∼ (join ∘ map θ) τ₂)
ent-typeq-subst ent-refl = ent-refl
ent-typeq-subst (ent-trans a b) = ent-trans (ent-subst a) (ent-typeq-subst b)
ent-typeq-subst (ent-typeq-refl) = ent-typeq-refl
ent-typeq-subst (ent-typeq-sym a) = ent-typeq-sym (ent-typeq-subst a)
ent-typeq-subst (ent-typeq-trans a b) = ent-typeq-trans (ent-typeq-subst a) (ent-typeq-subst b)
shapify : ∀ {a} → SConstraint a → ∃ (SConstraintShape a)
shapify (a ∼ b) = Nullary , a ∼ b
shapify (a ∧′ b) with shapify a | shapify b
... | r₁ , a′ | r₂ , b′ = Binary r₁ r₂ , a′ ∧′ b′
shapify (ε) = Nullary , ε
entailment : Entailment
entailment = record { _,_⊩_ = _,_⊩_
; ent-refl = ent-refl
; ent-trans = ent-trans
; ent-subst = ent-subst
; ent-typeq-refl = ent-typeq-refl
; ent-typeq-sym = ent-typeq-sym
; ent-typeq-trans = ent-typeq-trans
; ent-typeq-subst = ent-typeq-subst
; ent-conj = ent-conj
}
open SimplificationPrelude ⦃ types ⦄ ⦃ axiom-schemes ⦄ ⦃ qconstraints ⦄ ⦃ entailment ⦄
constraint : ∀{s}{tc}{m} → Eq tc → SConstraintShape (tc ⨁ m) s → SimplifierResult tc m
constraint {Unary _} _ ()
constraint {Nullary}{m = m} _ ε = m , ε , solved ε Var
constraint {Nullary}{tc}{m} eq (a ∼ b) = convert (mgu′ {tc}{m} eq a b)
where
convert : Ⓢ (∃ (λ n → tc ⨁ m → Type (tc ⨁ n))) → SimplifierResult tc m
convert (suc (n , θ)) = n , ε , solved ε θ
convert zero = m , (a ∼ b) , solved _ Var
constraint {Binary r₁ r₂}{tc}{m} eq (a ∧′ b) = convert (constraint {r₁}{tc}{m} eq a)
where open Monad (type-is-monad)
_special-∧_ : ∀ {n} → SConstraint n → SConstraint n → SConstraint n
ε special-∧ n = n
n special-∧ ε = n
n special-∧ m = n ∧′ m
convert : SimplifierResult tc m → SimplifierResult tc m
convert (n , Qr , solved .Qr θ) = convert′ ( constraint {r₂}{tc}{n} eq (applySubst θ b))
where convert′ : SimplifierResult tc n → SimplifierResult tc m
convert′ (n′ , Qr′ , solved .Qr′ θ′) = n′ , Qr′ special-∧ applySubst′ θ′ Qr , solved _ (θ′ >=> θ)
simplifier : {x : Set} → Eq x → (n : ℕ) → AxiomScheme x → SConstraint x
→ SConstraint (x ⨁ n) → SimplifierResult x n
simplifier {x} eq n ax con₁ con₂ with shapify con₂
... | r , v = constraint {r}{x}{n} eq v
postulate simplifier-sound : {x : Set} {n : ℕ} {eq : Eq x} (Q : AxiomScheme x) (Qg : SConstraint x) (Qw : SConstraint (x ⨁ n))
→ IsSound Q Qg Qw (simplifier eq n Q Qg Qw)
simplification : Simplification
simplification = record {simplifier = simplifier; simplifier-sound = λ {x}{n}{eq} → simplifier-sound {x}{n}{eq} }
Simple : (ℕ → Set) → X
Simple dc = record { dc = dc
; types = types
; axiom-schemes = axiom-schemes
; qconstraints = qconstraints
; entailment = entailment
; simplification = simplification
}
| {
"alphanum_fraction": 0.504001549,
"avg_line_length": 41.2074468085,
"ext": "agda",
"hexsha": "68761acb11bb8328f5cdf199d0e8f6713d408cb8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "liamoc/outside-in",
"max_forks_repo_path": "OutsideIn/Instantiations/Simple.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "liamoc/outside-in",
"max_issues_repo_path": "OutsideIn/Instantiations/Simple.agda",
"max_line_length": 200,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "liamoc/outside-in",
"max_stars_repo_path": "OutsideIn/Instantiations/Simple.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z",
"num_tokens": 5840,
"size": 15494
} |
{-# OPTIONS --without-K #-}
module Library where
open import Data.Product
using ( Σ ; Σ-syntax ; _×_ )
public
open import Function
using ()
renaming ( id to λ-id
; _∘_ to λ-comp
; flip to λ-flip )
public
open import Level
using ( Level )
renaming ( zero to ℓ-zero
; suc to ℓ-suc
; _⊔_ to ℓ-max )
public
open import Relation.Binary.Core
using ( Rel )
public
open import Relation.Unary
using ( Pred )
public
open import Relation.Binary.PropositionalEquality
using ( _≡_ ; module ≡-Reasoning )
renaming ( refl to ≡-refl
; sym to ≡-sym
; trans to ≡-trans)
public
open ≡-Reasoning
using ( _≡⟨_⟩_ )
renaming ( begin_ to ≡-proof_
; _∎ to _≡-qed )
public
| {
"alphanum_fraction": 0.5655430712,
"avg_line_length": 18.6279069767,
"ext": "agda",
"hexsha": "1ea56a263b5a1acd8c76378f831cfb3659b6b2c4",
"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": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "gunpinyo/agda-cat",
"max_forks_repo_path": "src/Library.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3",
"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": "gunpinyo/agda-cat",
"max_issues_repo_path": "src/Library.agda",
"max_line_length": 49,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "gunpinyo/agda-cat",
"max_stars_repo_path": "src/Library.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 253,
"size": 801
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Sublist-related properties
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Binary.Sublist.Propositional.Properties
{a} {A : Set a} where
open import Data.List.Base using (List; []; _∷_; map)
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Relation.Unary.All using (All; []; _∷_)
open import Data.List.Relation.Unary.Any using (Any; here; there)
open import Data.List.Relation.Unary.Any.Properties
using (here-injective; there-injective)
open import Data.List.Relation.Binary.Sublist.Propositional
hiding (map)
import Data.List.Relation.Binary.Sublist.Setoid.Properties
as SetoidProperties
open import Data.Product using (∃; _,_; proj₂)
open import Function.Base
open import Level using (Level)
open import Relation.Binary using (_Respects_)
open import Relation.Binary.PropositionalEquality
open import Relation.Unary using (Pred)
private
variable
b ℓ : Level
B : Set b
------------------------------------------------------------------------
-- Re-exporting setoid properties
open SetoidProperties (setoid A) public
hiding (map⁺)
map⁺ : ∀ {as bs} (f : A → B) → as ⊆ bs → map f as ⊆ map f bs
map⁺ {B = B} f = SetoidProperties.map⁺ (setoid A) (setoid B) (cong f)
------------------------------------------------------------------------
-- Category laws for _⊆_
⊆-trans-idˡ : ∀ {xs ys : List A} {τ : xs ⊆ ys} →
⊆-trans ⊆-refl τ ≡ τ
⊆-trans-idˡ {_} {τ = [] } = refl
⊆-trans-idˡ {_} {τ = _ ∷ _} = cong (_ ∷_ ) ⊆-trans-idˡ
⊆-trans-idˡ {[]} {τ = _ ∷ʳ _} = cong (_ ∷ʳ_) ⊆-trans-idˡ
⊆-trans-idˡ {_ ∷ _} {τ = _ ∷ʳ _} = cong (_ ∷ʳ_) ⊆-trans-idˡ
⊆-trans-idʳ : ∀ {xs ys : List A} {τ : xs ⊆ ys} →
⊆-trans τ ⊆-refl ≡ τ
⊆-trans-idʳ {τ = [] } = refl
⊆-trans-idʳ {τ = _ ∷ʳ _ } = cong (_ ∷ʳ_ ) ⊆-trans-idʳ
⊆-trans-idʳ {τ = refl ∷ _} = cong (refl ∷_) ⊆-trans-idʳ
-- Note: The associativity law is oriented such that rewriting with it
-- may trigger reductions of ⊆-trans, which matches first on its
-- second argument and then on its first argument.
⊆-trans-assoc : ∀ {ws xs ys zs : List A}
{τ₁ : ws ⊆ xs} {τ₂ : xs ⊆ ys} {τ₃ : ys ⊆ zs} →
⊆-trans τ₁ (⊆-trans τ₂ τ₃) ≡ ⊆-trans (⊆-trans τ₁ τ₂) τ₃
⊆-trans-assoc {τ₁ = _} {_} {_ ∷ʳ _} = cong (_ ∷ʳ_) ⊆-trans-assoc
⊆-trans-assoc {τ₁ = _} {_ ∷ʳ _} {_ ∷ _} = cong (_ ∷ʳ_) ⊆-trans-assoc
⊆-trans-assoc {τ₁ = _ ∷ʳ _ } {_ ∷ _} {_ ∷ _} = cong (_ ∷ʳ_) ⊆-trans-assoc
⊆-trans-assoc {τ₁ = refl ∷ _} {_ ∷ _} {_ ∷ _} = cong (_ ∷_ ) ⊆-trans-assoc
⊆-trans-assoc {τ₁ = []} {[]} {[]} = refl
------------------------------------------------------------------------
-- Laws concerning ⊆-trans and ∷ˡ⁻
⊆-trans-∷ˡ⁻ᵣ : ∀ {y} {xs ys zs : List A} {τ : xs ⊆ ys} {σ : (y ∷ ys) ⊆ zs} →
⊆-trans τ (∷ˡ⁻ σ) ≡ ⊆-trans (y ∷ʳ τ) σ
⊆-trans-∷ˡ⁻ᵣ {σ = x ∷ σ} = refl
⊆-trans-∷ˡ⁻ᵣ {σ = y ∷ʳ σ} = cong (y ∷ʳ_) ⊆-trans-∷ˡ⁻ᵣ
⊆-trans-∷ˡ⁻ₗ : ∀ {x} {xs ys zs : List A} {τ : (x ∷ xs) ⊆ ys} {σ : ys ⊆ zs} →
⊆-trans (∷ˡ⁻ τ) σ ≡ ∷ˡ⁻ (⊆-trans τ σ)
⊆-trans-∷ˡ⁻ₗ {σ = y ∷ʳ σ} = cong (y ∷ʳ_) ⊆-trans-∷ˡ⁻ₗ
⊆-trans-∷ˡ⁻ₗ {τ = y ∷ʳ τ} {σ = refl ∷ σ} = cong (y ∷ʳ_) ⊆-trans-∷ˡ⁻ₗ
⊆-trans-∷ˡ⁻ₗ {τ = refl ∷ τ} {σ = refl ∷ σ} = refl
⊆-∷ˡ⁻trans-∷ : ∀ {y} {xs ys zs : List A} {τ : xs ⊆ ys} {σ : (y ∷ ys) ⊆ zs} →
∷ˡ⁻ (⊆-trans (refl ∷ τ) σ) ≡ ⊆-trans (y ∷ʳ τ) σ
⊆-∷ˡ⁻trans-∷ {σ = y ∷ʳ σ} = cong (y ∷ʳ_) ⊆-∷ˡ⁻trans-∷
⊆-∷ˡ⁻trans-∷ {σ = refl ∷ σ} = refl
------------------------------------------------------------------------
-- Relationships to other predicates
-- All P is a contravariant functor from _⊆_ to Set.
All-resp-⊆ : {P : Pred A ℓ} → (All P) Respects _⊇_
All-resp-⊆ [] [] = []
All-resp-⊆ (_ ∷ʳ p) (_ ∷ xs) = All-resp-⊆ p xs
All-resp-⊆ (refl ∷ p) (x ∷ xs) = x ∷ All-resp-⊆ p xs
-- Any P is a covariant functor from _⊆_ to Set.
Any-resp-⊆ : {P : Pred A ℓ} → (Any P) Respects _⊆_
Any-resp-⊆ = lookup
------------------------------------------------------------------------
-- Functor laws for All-resp-⊆
-- First functor law: identity.
All-resp-⊆-refl : ∀ {P : Pred A ℓ} {xs : List A} →
All-resp-⊆ ⊆-refl ≗ id {A = All P xs}
All-resp-⊆-refl [] = refl
All-resp-⊆-refl (p ∷ ps) = cong (p ∷_) (All-resp-⊆-refl ps)
-- Second functor law: composition.
All-resp-⊆-trans : ∀ {P : Pred A ℓ} {xs ys zs} {τ : xs ⊆ ys} (τ′ : ys ⊆ zs) →
All-resp-⊆ {P = P} (⊆-trans τ τ′) ≗ All-resp-⊆ τ ∘ All-resp-⊆ τ′
All-resp-⊆-trans (_ ∷ʳ τ′) (p ∷ ps) = All-resp-⊆-trans τ′ ps
All-resp-⊆-trans {τ = _ ∷ʳ _ } (refl ∷ τ′) (p ∷ ps) = All-resp-⊆-trans τ′ ps
All-resp-⊆-trans {τ = refl ∷ _} (refl ∷ τ′) (p ∷ ps) = cong (p ∷_) (All-resp-⊆-trans τ′ ps)
All-resp-⊆-trans {τ = [] } ([] ) [] = refl
------------------------------------------------------------------------
-- Functor laws for Any-resp-⊆ / lookup
-- First functor law: identity.
Any-resp-⊆-refl : ∀ {P : Pred A ℓ} {xs} →
Any-resp-⊆ ⊆-refl ≗ id {A = Any P xs}
Any-resp-⊆-refl (here p) = refl
Any-resp-⊆-refl (there i) = cong there (Any-resp-⊆-refl i)
lookup-⊆-refl = Any-resp-⊆-refl
-- Second functor law: composition.
Any-resp-⊆-trans : ∀ {P : Pred A ℓ} {xs ys zs} {τ : xs ⊆ ys} (τ′ : ys ⊆ zs) →
Any-resp-⊆ {P = P} (⊆-trans τ τ′) ≗ Any-resp-⊆ τ′ ∘ Any-resp-⊆ τ
Any-resp-⊆-trans (_ ∷ʳ τ′) i = cong there (Any-resp-⊆-trans τ′ i)
Any-resp-⊆-trans {τ = _ ∷ʳ _} (_ ∷ τ′) i = cong there (Any-resp-⊆-trans τ′ i)
Any-resp-⊆-trans {τ = _ ∷ _} (_ ∷ τ′) (there i) = cong there (Any-resp-⊆-trans τ′ i)
Any-resp-⊆-trans {τ = refl ∷ _} (_ ∷ τ′) (here _) = refl
Any-resp-⊆-trans {τ = [] } [] ()
lookup-⊆-trans = Any-resp-⊆-trans
------------------------------------------------------------------------
-- The `lookup` function for `xs ⊆ ys` is injective.
--
-- Note: `lookup` can be seen as a strictly increasing reindexing function
-- for indices into `xs`, producing indices into `ys`.
lookup-injective : ∀ {P : Pred A ℓ} {xs ys} {τ : xs ⊆ ys} {i j : Any P xs} →
lookup τ i ≡ lookup τ j → i ≡ j
lookup-injective {τ = _ ∷ʳ _} = lookup-injective ∘′ there-injective
lookup-injective {τ = x≡y ∷ _} {here _} {here _} = cong here ∘′ subst-injective x≡y ∘′ here-injective
-- Note: instead of using subst-injective, we could match x≡y against refl on the lhs.
-- However, this turns the following clause into a non-strict match.
lookup-injective {τ = _ ∷ _} {there _} {there _} = cong there ∘′ lookup-injective ∘′ there-injective
-------------------------------------------------------------------------
-- from∈ ∘ to∈ turns a sublist morphism τ : x∷xs ⊆ ys into a morphism
-- [x] ⊆ ys. The same morphism is obtained by pre-composing τ with
-- the canonial morphism [x] ⊆ x∷xs.
--
-- Note: This lemma does not hold for Sublist.Setoid, but could hold for
-- a hypothetical Sublist.Groupoid where trans refl = id.
from∈∘to∈ : ∀ {x : A} {xs ys} (τ : x ∷ xs ⊆ ys) →
from∈ (to∈ τ) ≡ ⊆-trans (refl ∷ minimum xs) τ
from∈∘to∈ (x≡y ∷ τ) = cong (x≡y ∷_) ([]⊆-irrelevant _ _)
from∈∘to∈ (y ∷ʳ τ) = cong (y ∷ʳ_) (from∈∘to∈ τ)
from∈∘lookup : ∀{x : A} {xs ys} (τ : xs ⊆ ys) (i : x ∈ xs) →
from∈ (lookup τ i) ≡ ⊆-trans (from∈ i) τ
from∈∘lookup (y ∷ʳ τ) i = cong (y ∷ʳ_) (from∈∘lookup τ i)
from∈∘lookup (_ ∷ τ) (there i) = cong (_ ∷ʳ_) (from∈∘lookup τ i)
from∈∘lookup (refl ∷ τ) (here refl) = cong (refl ∷_) ([]⊆-irrelevant _ _)
------------------------------------------------------------------------
-- Weak pushout (wpo)
-- A raw pushout is a weak pushout if the pushout square commutes.
IsWeakPushout : ∀{xs ys zs : List A} {τ : xs ⊆ ys} {σ : xs ⊆ zs} →
RawPushout τ σ → Set a
IsWeakPushout {τ = τ} {σ = σ} rpo =
⊆-trans τ (RawPushout.leg₁ rpo) ≡
⊆-trans σ (RawPushout.leg₂ rpo)
-- Joining two list extensions with ⊆-pushout produces a weak pushout.
⊆-pushoutˡ-is-wpo : ∀{xs ys zs : List A} (τ : xs ⊆ ys) (σ : xs ⊆ zs) →
IsWeakPushout (⊆-pushoutˡ τ σ)
⊆-pushoutˡ-is-wpo [] σ
rewrite ⊆-trans-idʳ {τ = σ}
= ⊆-trans-idˡ {xs = []}
⊆-pushoutˡ-is-wpo (y ∷ʳ τ) σ = cong (y ∷ʳ_) (⊆-pushoutˡ-is-wpo τ σ)
⊆-pushoutˡ-is-wpo (x≡y ∷ τ) (z ∷ʳ σ) = cong (z ∷ʳ_) (⊆-pushoutˡ-is-wpo (x≡y ∷ τ) σ)
⊆-pushoutˡ-is-wpo (refl ∷ τ) (refl ∷ σ) = cong (refl ∷_) (⊆-pushoutˡ-is-wpo τ σ)
------------------------------------------------------------------------
-- Properties of disjointness
-- From τ₁ ⊎ τ₂ = τ, compute the injection ι₁ such that τ₁ = ⊆-trans ι₁ τ.
DisjointUnion-inj₁ : ∀ {xs ys zs xys : List A} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} {τ : xys ⊆ zs} →
DisjointUnion τ₁ τ₂ τ → ∃ λ (ι₁ : xs ⊆ xys) → ⊆-trans ι₁ τ ≡ τ₁
DisjointUnion-inj₁ [] = [] , refl
DisjointUnion-inj₁ (y ∷ₙ d) = _ , cong (y ∷ʳ_) (proj₂ (DisjointUnion-inj₁ d))
DisjointUnion-inj₁ (x≈y ∷ₗ d) = refl ∷ _ , cong (x≈y ∷_) (proj₂ (DisjointUnion-inj₁ d))
DisjointUnion-inj₁ (x≈y ∷ᵣ d) = _ ∷ʳ _ , cong (_ ∷ʳ_) (proj₂ (DisjointUnion-inj₁ d))
-- From τ₁ ⊎ τ₂ = τ, compute the injection ι₂ such that τ₂ = ⊆-trans ι₂ τ.
DisjointUnion-inj₂ : ∀ {xs ys zs xys : List A} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} {τ : xys ⊆ zs} →
DisjointUnion τ₁ τ₂ τ → ∃ λ (ι₂ : ys ⊆ xys) → ⊆-trans ι₂ τ ≡ τ₂
DisjointUnion-inj₂ [] = [] , refl
DisjointUnion-inj₂ (y ∷ₙ d) = _ , cong (y ∷ʳ_) (proj₂ (DisjointUnion-inj₂ d))
DisjointUnion-inj₂ (x≈y ∷ᵣ d) = refl ∷ _ , cong (x≈y ∷_) (proj₂ (DisjointUnion-inj₂ d))
DisjointUnion-inj₂ (x≈y ∷ₗ d) = _ ∷ʳ _ , cong (_ ∷ʳ_) (proj₂ (DisjointUnion-inj₂ d))
-- A sublist σ disjoint to both τ₁ and τ₂ is an equalizer
-- for the separators of τ₁ and τ₂.
equalize-separators : ∀ {us xs ys zs : List A}
{σ : us ⊆ zs} {τ₁ : xs ⊆ zs} {τ₂ : ys ⊆ zs} (let s = separateˡ τ₁ τ₂) →
Disjoint σ τ₁ → Disjoint σ τ₂ →
⊆-trans σ (Separation.separator₁ s) ≡
⊆-trans σ (Separation.separator₂ s)
equalize-separators [] [] = refl
equalize-separators (y ∷ₙ d₁) (.y ∷ₙ d₂) = cong (y ∷ʳ_) (equalize-separators d₁ d₂)
equalize-separators (y ∷ₙ d₁) (refl ∷ᵣ d₂) = cong (y ∷ʳ_) (equalize-separators d₁ d₂)
equalize-separators (refl ∷ᵣ d₁) (y ∷ₙ d₂) = cong (y ∷ʳ_) (equalize-separators d₁ d₂)
equalize-separators {τ₁ = refl ∷ _} {τ₂ = refl ∷ _} -- match here to work around deficiency of Agda's forcing translation
(_ ∷ᵣ d₁) (_ ∷ᵣ d₂) = cong (_ ∷ʳ_) (cong (_ ∷ʳ_) (equalize-separators d₁ d₂))
equalize-separators (x≈y ∷ₗ d₁) (.x≈y ∷ₗ d₂) = cong (trans x≈y refl ∷_) (equalize-separators d₁ d₂)
| {
"alphanum_fraction": 0.5119343839,
"avg_line_length": 45.2125,
"ext": "agda",
"hexsha": "eccafee9250b34bd01e863c0bd8605981181c9e1",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Sublist/Propositional/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Sublist/Propositional/Properties.agda",
"max_line_length": 122,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Sublist/Propositional/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 4506,
"size": 10851
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Numbers.ClassicalReals.RealField
open import LogicalFormulae
open import Setoids.Subset
open import Setoids.Setoids
open import Setoids.Orders.Partial.Definition
open import Sets.EquivalenceRelations
open import Rings.Orders.Partial.Definition
open import Rings.Definition
open import Fields.Fields
open import Groups.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Functions.Definition
module Numbers.Intervals.Arithmetic {a b c : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {_<_ : Rel {_} {c} A} {R : Ring S _+_ _*_} {pOrder : SetoidPartialOrder S _<_} (pRing : PartiallyOrderedRing R pOrder) where
open import Numbers.Intervals.Definition pRing
open import Rings.Orders.Partial.Lemmas pRing
open Ring R
open Group additiveGroup
open PartiallyOrderedRing pRing
open Setoid S
open Equivalence eq
open SetoidPartialOrder pOrder
intervalSum : OpenInterval → OpenInterval → OpenInterval
intervalSum record { minBound = a ; maxBound = b } record { minBound = c ; maxBound = d } = record { minBound = a + c ; maxBound = b + d }
intervalConstantSum : OpenInterval → A → OpenInterval
intervalConstantSum record { minBound = x ; maxBound = y } a = record { minBound = x + a ; maxBound = y + a }
intervalSumContains : {a b : A} → {i j : OpenInterval} → isInInterval a i → isInInterval b j → isInInterval (a + b) (intervalSum i j)
intervalSumContains (fst1 ,, snd1) (fst2 ,, snd2) = ringAddInequalities fst1 fst2 ,, ringAddInequalities snd1 snd2
intervalConstantProduct : OpenInterval → (a : A) → (0R < a) → OpenInterval
intervalConstantProduct record { minBound = minBound ; maxBound = maxBound } a 0<a = record { minBound = minBound * a ; maxBound = maxBound * a }
intervalInverse : OpenInterval → OpenInterval
intervalInverse record { minBound = b ; maxBound = c } = record { minBound = inverse c ; maxBound = inverse b }
intervalConstantSumContains : {a : A} {i : OpenInterval} (c : A) → isInInterval a i → isInInterval (a + c) (intervalConstantSum i c)
intervalConstantSumContains c (fst ,, snd) = orderRespectsAddition fst c ,, orderRespectsAddition snd c
intervalConstantProductContains : {a : A} {i : OpenInterval} {c : A} → (0<c : 0R < c) → isInInterval a i → isInInterval (a * c) (intervalConstantProduct i c 0<c)
intervalConstantProductContains {a} {i} 0<c ai = ringCanMultiplyByPositive 0<c (_&&_.fst ai) ,, ringCanMultiplyByPositive 0<c (_&&_.snd ai)
intervalInverseContains : {a : A} {i : OpenInterval} → isInInterval a i → isInInterval (inverse a) (intervalInverse i)
intervalInverseContains (less ,, greater) = ringSwapNegatives' greater ,, ringSwapNegatives' less
intervalEquality : OpenInterval → OpenInterval → Set b
intervalEquality record { minBound = minBound1 ; maxBound = maxBound1 } record { minBound = minBound ; maxBound = maxBound } = (minBound1 ∼ minBound) && (maxBound1 ∼ maxBound)
intervalWellDefined : {a : A} {i j : OpenInterval} → intervalEquality i j → isInInterval a i → isInInterval a j
intervalWellDefined (eq1 ,, eq2) (fst ,, snd) = <WellDefined eq1 reflexive fst ,, <WellDefined reflexive eq2 snd
intervalWellDefined' : {a b : A} {i : OpenInterval} → a ∼ b → isInInterval a i → isInInterval b i
intervalWellDefined' a=b (fst ,, snd) = <WellDefined reflexive a=b fst ,, <WellDefined a=b reflexive snd
increaseBoundAbove : {a minB maxB : A} → isInInterval a record { minBound = minB ; maxBound = maxB } → {bigger : A} → maxB < bigger → isInInterval a record { minBound = minB ; maxBound = bigger }
increaseBoundAbove (fst ,, snd) m<b = fst ,, <Transitive snd m<b
| {
"alphanum_fraction": 0.7336268575,
"avg_line_length": 57.6825396825,
"ext": "agda",
"hexsha": "95198cbeeb3b6095e95aaed35ceb50296a0857fa",
"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/Intervals/Arithmetic.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/Intervals/Arithmetic.agda",
"max_line_length": 229,
"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/Intervals/Arithmetic.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": 1033,
"size": 3634
} |
module SystemF.BigStep.Extrinsic where
open import SystemF.BigStep.Types
open import SystemF.BigStep.Extrinsic.Terms
open import SystemF.BigStep.Extrinsic.Welltyped
open import SystemF.BigStep.Extrinsic.Semantics
| {
"alphanum_fraction": 0.8644859813,
"avg_line_length": 30.5714285714,
"ext": "agda",
"hexsha": "25a0e3ab36f78d889a31d1775334c1fdb61dce88",
"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": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "metaborg/ts.agda",
"max_forks_repo_path": "src/SystemF/BigStep/Extrinsic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"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": "metaborg/ts.agda",
"max_issues_repo_path": "src/SystemF/BigStep/Extrinsic.agda",
"max_line_length": 47,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "metaborg/ts.agda",
"max_stars_repo_path": "src/SystemF/BigStep/Extrinsic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 53,
"size": 214
} |
open import Nat
open import Prelude
open import contexts
open import core
open import canonical-value-forms
module canonical-boxed-forms where
canonical-boxed-forms-b : ∀{Δ d} →
Δ , ∅ ⊢ d :: b →
d boxedval →
d == c
canonical-boxed-forms-b (TAVar _) (BVVal ())
canonical-boxed-forms-b wt (BVVal v) = canonical-value-forms-b wt v
-- this type gives somewhat nicer syntax for the output of the canonical
-- forms lemma for boxed values at arrow type
data cbf-arr : (Δ : hctx) (d : iexp) (τ1 τ2 : typ) → Set where
CBFLam : ∀{Δ d τ1 τ2} →
(Σ[ x ∈ Nat ] Σ[ d' ∈ iexp ]
(d == (·λ x [ τ1 ] d') × Δ , ■ (x , τ1) ⊢ d' :: τ2))
→ cbf-arr Δ d τ1 τ2
CBFCastArr : ∀{Δ d τ1 τ2} →
(Σ[ d' ∈ iexp ] Σ[ τ1' ∈ typ ] Σ[ τ2' ∈ typ ]
(d == (d' ⟨ τ1' ==> τ2' ⇒ τ1 ==> τ2 ⟩) ×
(τ1' ==> τ2' ≠ τ1 ==> τ2) ×
(Δ , ∅ ⊢ d' :: τ1' ==> τ2')))
→ cbf-arr Δ d τ1 τ2
data cbf-prod : (Δ : hctx) (d : iexp) (τ1 τ2 : typ) → Set where
CBFPairVal : ∀{Δ d τ1 τ2} →
(Σ[ d1 ∈ iexp ] Σ[ d2 ∈ iexp ]
(d == ⟨ d1 , d2 ⟩ ×
Δ , ∅ ⊢ d1 :: τ1 ×
Δ , ∅ ⊢ d2 :: τ2 ×
d1 val ×
d2 val))
→ cbf-prod Δ d τ1 τ2
CBFPairBV : ∀{Δ d τ1 τ2} →
(Σ[ d1 ∈ iexp ] Σ[ d2 ∈ iexp ]
(d == ⟨ d1 , d2 ⟩ ×
Δ , ∅ ⊢ d1 :: τ1 ×
Δ , ∅ ⊢ d2 :: τ2 ×
d1 boxedval ×
d2 boxedval ))
→ cbf-prod Δ d τ1 τ2
CBFCastProd : ∀{Δ d τ1 τ2} →
(Σ[ d' ∈ iexp ] Σ[ τ1' ∈ typ ] Σ[ τ2' ∈ typ ]
(d == (d' ⟨ τ1' ⊗ τ2' ⇒ τ1 ⊗ τ2 ⟩) ×
(τ1' ⊗ τ2' ≠ τ1 ⊗ τ2) ×
(τ1' ⊗ τ2' ~ τ1 ⊗ τ2) ×
(d' boxedval) ×
(Δ , ∅ ⊢ d' :: τ1' ⊗ τ2')))
→ cbf-prod Δ d τ1 τ2
canonical-boxed-forms-arr : ∀{Δ d τ1 τ2 } →
Δ , ∅ ⊢ d :: (τ1 ==> τ2) →
d boxedval →
cbf-arr Δ d τ1 τ2
canonical-boxed-forms-arr (TAVar x₁) (BVVal ())
canonical-boxed-forms-arr (TALam f wt) (BVVal v) = CBFLam (canonical-value-forms-arr (TALam f wt) v)
canonical-boxed-forms-arr (TAAp wt wt₁) (BVVal ())
canonical-boxed-forms-arr (TAEHole x x₁) (BVVal ())
canonical-boxed-forms-arr (TANEHole x wt x₁) (BVVal ())
canonical-boxed-forms-arr (TACast wt x) (BVVal ())
canonical-boxed-forms-arr (TACast wt x) (BVArrCast x₁ bv) = CBFCastArr (_ , _ , _ , refl , x₁ , wt)
canonical-boxed-forms-arr (TAFailedCast x x₁ x₂ x₃) (BVVal ())
canonical-boxed-forms-arr (TAFst wt) (BVVal ())
canonical-boxed-forms-arr (TASnd wt) (BVVal ())
canonical-boxed-forms-hole : ∀{Δ d} →
Δ , ∅ ⊢ d :: ⦇·⦈ →
d boxedval →
Σ[ d' ∈ iexp ] Σ[ τ' ∈ typ ]
((d == d' ⟨ τ' ⇒ ⦇·⦈ ⟩) ×
(τ' ground) ×
(Δ , ∅ ⊢ d' :: τ'))
canonical-boxed-forms-hole (TAVar x₁) (BVVal ())
canonical-boxed-forms-hole (TAAp wt wt₁) (BVVal ())
canonical-boxed-forms-hole (TAEHole x x₁) (BVVal ())
canonical-boxed-forms-hole (TANEHole x wt x₁) (BVVal ())
canonical-boxed-forms-hole (TACast wt x) (BVVal ())
canonical-boxed-forms-hole (TACast wt x) (BVHoleCast x₁ bv) = _ , _ , refl , x₁ , wt
canonical-boxed-forms-hole (TAFailedCast x x₁ x₂ x₃) (BVVal ())
canonical-boxed-forms-hole (TAFst wt) (BVVal ())
canonical-boxed-forms-hole (TASnd wt) (BVVal ())
canonical-boxed-forms-prod : ∀{Δ d τ1 τ2 } →
Δ , ∅ ⊢ d :: (τ1 ⊗ τ2) →
d boxedval →
cbf-prod Δ d τ1 τ2
canonical-boxed-forms-prod (TAVar x₁) (BVVal ())
canonical-boxed-forms-prod (TAAp wt wt₁) (BVVal ())
canonical-boxed-forms-prod (TAEHole x x₁) (BVVal ())
canonical-boxed-forms-prod (TANEHole x wt x₁) (BVVal ())
canonical-boxed-forms-prod (TACast wt x) (BVVal ())
canonical-boxed-forms-prod (TACast wt x) (BVProdCast x₁ bv) = CBFCastProd (_ , _ , _ , refl , x₁ , x , bv , wt)
canonical-boxed-forms-prod (TAFailedCast wt x x₁ x₂) (BVVal ())
canonical-boxed-forms-prod (TAFst wt) (BVVal ())
canonical-boxed-forms-prod (TASnd wt) (BVVal ())
canonical-boxed-forms-prod (TAPair wt wt₁) (BVVal (VPair x x₁)) = CBFPairVal (_ , _ , refl , wt , wt₁ , x , x₁)
canonical-boxed-forms-prod (TAPair wt wt₁) (BVPair bv bv₁) = CBFPairBV (_ , _ , refl , wt , wt₁ , bv , bv₁)
canonical-boxed-forms-coverage : ∀{Δ d τ} →
Δ , ∅ ⊢ d :: τ →
d boxedval →
τ ≠ b →
((τ1 : typ) (τ2 : typ) → τ ≠ (τ1 ==> τ2)) →
τ ≠ ⦇·⦈ →
((τ1 : typ) (τ2 : typ) → τ ≠ (τ1 ⊗ τ2)) →
⊥
canonical-boxed-forms-coverage TAConst (BVVal x) nb na nh = λ _ → nb refl
canonical-boxed-forms-coverage (TAVar x₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TALam _ wt) (BVVal x₁) nb na nh = λ _ → na _ _ refl
canonical-boxed-forms-coverage (TAAp wt wt₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TAEHole x x₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TANEHole x wt x₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TACast wt x) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TACast wt x) (BVArrCast x₁ bv) nb na nh = λ _ → na _ _ refl
canonical-boxed-forms-coverage (TACast wt x) (BVHoleCast x₁ bv) nb na nh = λ _ → nh refl
canonical-boxed-forms-coverage (TAFailedCast x x₁ x₂ x₃) (BVVal ())
canonical-boxed-forms-coverage (TACast wt x) (BVProdCast x₁ bv) nb na nh = λ z → z _ _ refl
canonical-boxed-forms-coverage (TAFst wt) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TASnd wt) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TAPair wt wt₁) (BVVal x) nb na nh = λ z → z _ _ refl
canonical-boxed-forms-coverage (TAPair wt wt₁) (BVPair bv bv₁) nb na nh = λ z → z _ _ refl
| {
"alphanum_fraction": 0.5002402691,
"avg_line_length": 49.157480315,
"ext": "agda",
"hexsha": "4a6b6f7977435f850e3fdcc0f63ee0ef18c27d40",
"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": "canonical-boxed-forms.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": "canonical-boxed-forms.agda",
"max_line_length": 113,
"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": "canonical-boxed-forms.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": 2246,
"size": 6243
} |
module Languages.FILL.Intermediate where
open import Utils.HaskellTypes
open import Languages.FILL.TypeSyntax
{-# IMPORT Languages.FILL.Intermediate #-}
data IPattern : Set where
PTriv : IPattern
PVar : String → IPattern
PTensor : IPattern → IPattern → IPattern
PPar : IPattern → IPattern → IPattern
{-# COMPILED_DATA IPattern Languages.FILL.Intermediate.IPattern
Languages.FILL.Intermediate.PTriv
Languages.FILL.Intermediate.PVar
Languages.FILL.Intermediate.PTensor
Languages.FILL.Intermediate.PPar #-}
data ITerm : Set where
Var : String → ITerm
Triv : ITerm
Void : ITerm
TTensor : ITerm → ITerm → ITerm
TPar : ITerm → ITerm → ITerm
Lam : String → Type → ITerm → ITerm
Let : ITerm → Type → IPattern → ITerm → ITerm
App : ITerm → ITerm → ITerm
{-# COMPILED_DATA ITerm Languages.FILL.Intermediate.ITerm
Languages.FILL.Intermediate.Var
Languages.FILL.Intermediate.Triv
Languages.FILL.Intermediate.Void
Languages.FILL.Intermediate.TTensor
Languages.FILL.Intermediate.TPar
Languages.FILL.Intermediate.Lam
Languages.FILL.Intermediate.Let
Languages.FILL.Intermediate.App #-}
| {
"alphanum_fraction": 0.60397445,
"avg_line_length": 38.0810810811,
"ext": "agda",
"hexsha": "2d1fc5b2d83ee88a7b16b7a8fc932149bbdcc87a",
"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": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "heades/Agda-LLS",
"max_forks_repo_path": "Source/ALL/Languages/FILL/Intermediate.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_issues_repo_issues_event_max_datetime": "2017-04-05T17:30:16.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-03-27T14:52:46.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "heades/Agda-LLS",
"max_issues_repo_path": "Source/ALL/Languages/FILL/Intermediate.agda",
"max_line_length": 64,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "heades/Agda-LLS",
"max_stars_repo_path": "Source/ALL/Languages/FILL/Intermediate.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-02T23:41:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-09T20:53:53.000Z",
"num_tokens": 296,
"size": 1409
} |
module BTree.Complete.Alternative {A : Set} where
open import BTree {A}
open import BTree.Equality {A}
data _⋗_ : BTree → BTree → Set where
⋗lf : (x : A)
→ (node x leaf leaf) ⋗ leaf
⋗nd : {l r l' r' : BTree}
→ (x x' : A)
→ l ≃ r
→ l' ≃ r'
→ l ⋗ l'
→ (node x l r) ⋗ (node x' l' r')
mutual
data _⋘_ : BTree → BTree → Set where
lf⋘ : leaf ⋘ leaf
ll⋘ : {l r l' r' : BTree}
→ (x x' : A)
→ (l⋘r : l ⋘ r)
→ (l'≃r' : l' ≃ r')
→ r ≃ l'
→ (node x l r) ⋘ (node x' l' r')
lr⋘ : {l r l' r' : BTree}
→ (x x' : A)
→ (l⋙r : l ⋙ r)
→ (l'≃r' : l' ≃ r')
→ l ⋗ l'
→ (node x l r) ⋘ (node x' l' r')
data _⋙_ : BTree → BTree → Set where
⋙lf : (x : A)
→ (node x leaf leaf) ⋙ leaf
⋙rl : {l r l' r' : BTree}
→ (x x' : A)
→ (l≃r : l ≃ r)
→ (l'⋘r' : l' ⋘ r')
→ l ⋗ r'
→ (node x l r) ⋙ (node x' l' r')
⋙rr : {l r l' r' : BTree}
→ (x x' : A)
→ (l≃r : l ≃ r)
→ (l'⋙r' : l' ⋙ r')
→ l ≃ l'
→ (node x l r) ⋙ (node x' l' r')
data Complete : BTree → Set where
leaf : Complete leaf
left : {l r : BTree}
(x : A)
→ Complete l
→ Complete r
→ l ⋘ r
→ Complete (node x l r)
right : {l r : BTree}
(x : A)
→ Complete l
→ Complete r
→ l ⋙ r
→ Complete (node x l r)
| {
"alphanum_fraction": 0.2926963207,
"avg_line_length": 28.9047619048,
"ext": "agda",
"hexsha": "909742cf69f8428d78f31b86a5eda63942d6f764",
"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/BTree/Complete/Alternative.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/BTree/Complete/Alternative.agda",
"max_line_length": 50,
"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/BTree/Complete/Alternative.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": 654,
"size": 1821
} |
------------------------------------------------------------------------------
-- The types used by the mirror function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Mirror.Type where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.List
------------------------------------------------------------------------------
-- Tree terms.
postulate node : D → D → D
-- The mutually totality predicates
data Forest : D → Set -- The list of rose trees (called forest).
data Tree : D → Set -- The rose tree type.
data Forest where
fnil : Forest []
fcons : ∀ {t ts} → Tree t → Forest ts → Forest (t ∷ ts)
{-# ATP axioms fnil fcons #-}
data Tree where
tree : ∀ d {ts} → Forest ts → Tree (node d ts)
{-# ATP axiom tree #-}
------------------------------------------------------------------------------
-- Mutual induction for Tree and Forest
-- Adapted from the mutual induction principles generate from Coq
-- 8.4pl4 using the command (see Coq'Art p. 401).
--
-- Scheme Tree_mutual_ind :=
-- Minimality for Tree Sort Prop
-- with Forest_mutual_ind :=
-- Minimality for Forest Sort Prop.
Tree-mutual-ind :
{A B : D → Set} →
(∀ d {ts} → Forest ts → B ts → A (node d ts)) →
B [] →
(∀ {t ts} → Tree t → A t → Forest ts → B ts → B (t ∷ ts)) →
∀ {t} → Tree t → A t
Forest-mutual-ind :
{A B : D → Set} →
(∀ d {ts} → Forest ts → B ts → A (node d ts)) →
B [] →
(∀ {t ts} → Tree t → A t → Forest ts → B ts → B (t ∷ ts)) →
∀ {ts} → Forest ts → B ts
Tree-mutual-ind hA B[] _ (tree d fnil) = hA d fnil B[]
Tree-mutual-ind hA B[] hB (tree d (fcons Tt Fts)) =
hA d (fcons Tt Fts) (hB Tt (Tree-mutual-ind hA B[] hB Tt)
Fts (Forest-mutual-ind hA B[] hB Fts))
Forest-mutual-ind _ B[] _ fnil = B[]
Forest-mutual-ind hA B[] hB (fcons Tt Fts) =
hB Tt (Tree-mutual-ind hA B[] hB Tt) Fts (Forest-mutual-ind hA B[] hB Fts)
| {
"alphanum_fraction": 0.4995269631,
"avg_line_length": 31.552238806,
"ext": "agda",
"hexsha": "2d9c846c7f53a6e2c9af232f6fc5b29fd2bf43ce",
"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/Type.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/Type.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/Type.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": 620,
"size": 2114
} |
-- Sometimes we can't infer a record type
module InferRecordTypes-1 where
bad = record { } | {
"alphanum_fraction": 0.7391304348,
"avg_line_length": 18.4,
"ext": "agda",
"hexsha": "5550f3921a6f4b56f682780fb9fccbae7ab66986",
"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/InferRecordTypes-1.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/InferRecordTypes-1.agda",
"max_line_length": 41,
"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/InferRecordTypes-1.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": 23,
"size": 92
} |
{-# OPTIONS --without-K --safe #-}
open import Algebra.Structures.Bundles.Field
module Algebra.Linear.Construct.Matrix.Square
{k ℓ} (K : Field k ℓ)
where
open import Level using (_⊔_)
open import Data.Nat using (ℕ)
open import Data.Fin
open import Data.Product
open import Algebra.Structures.Field.Utils K
open import Algebra.Linear.Construct.Matrix K public
module F = Field K
private
M : ℕ -> Set k
M n = Matrix n n
K' : Set k
K' = F.Carrier
UpperTriangular : ℕ -> Set (k ⊔ ℓ)
UpperTriangular n = ∃ λ (A : M n) -> ∀ {i j} -> j ≤ i -> (A ⟪ i , j ⟫) F.≈ F.0#
LowerTriangular : ℕ -> Set (k ⊔ ℓ)
LowerTriangular n = ∃ λ (A : M n) -> ∀ {i j} -> i ≤ j -> (A ⟪ i , j ⟫) F.≈ F.0#
Invertible : ℕ -> Set (k ⊔ ℓ)
Invertible n = ∃₂ λ (A B : M n) -> (A * B) ≈ I n × (B * A) ≈ I n
trace : ∀ {n} -> M n n -> K'
trace A = vsum (V.tabulate λ i → A ⟪ i , i ⟫)
det : ∀ {n} -> M n -> K'
det A = {!!}
| {
"alphanum_fraction": 0.5700110254,
"avg_line_length": 22.675,
"ext": "agda",
"hexsha": "72d7c578d34587d27563735bf548e88e83941230",
"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": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "felko/linear-algebra",
"max_forks_repo_path": "src/Algebra/Linear/Construct/Matrix/Square.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"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": "felko/linear-algebra",
"max_issues_repo_path": "src/Algebra/Linear/Construct/Matrix/Square.agda",
"max_line_length": 79,
"max_stars_count": 15,
"max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "felko/linear-algebra",
"max_stars_repo_path": "src/Algebra/Linear/Construct/Matrix/Square.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z",
"num_tokens": 348,
"size": 907
} |
module Dave.Algebra.Naturals.Monus where
open import Dave.Algebra.Naturals.Definition
open import Dave.Algebra.Naturals.Addition
_∸_ : ℕ → ℕ → ℕ
m ∸ zero = m
zero ∸ suc n = zero
suc m ∸ suc n = m ∸ n
infixl 6 _∸_
∸-zero : ∀ (n : ℕ) → 0 ∸ n ≡ 0
∸-zero zero = refl
∸-zero (suc n) = refl
∸-assoc-+ : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p)
∸-assoc-+ m zero p = refl
∸-assoc-+ zero (suc n) p = ∸-zero p
∸-assoc-+ (suc m) (suc n) p = begin
suc m ∸ suc n ∸ p ≡⟨⟩
m ∸ n ∸ p ≡⟨ ∸-assoc-+ m n p ⟩
m ∸ (n + p) ≡⟨⟩
suc m ∸ suc (n + p) ≡⟨⟩
suc m ∸ (suc n + p) ∎ | {
"alphanum_fraction": 0.4545454545,
"avg_line_length": 27.0416666667,
"ext": "agda",
"hexsha": "56c527e96912c247c843858b46f1d092ea951c59",
"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": "05213fb6ab1f51f770f9858b61526ba950e06232",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DavidStahl97/formal-proofs",
"max_forks_repo_path": "Dave/Algebra/Naturals/Monus.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232",
"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": "DavidStahl97/formal-proofs",
"max_issues_repo_path": "Dave/Algebra/Naturals/Monus.agda",
"max_line_length": 55,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DavidStahl97/formal-proofs",
"max_stars_repo_path": "Dave/Algebra/Naturals/Monus.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 306,
"size": 649
} |
{-# OPTIONS --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Introductions.CastPi {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped as U hiding (wk)
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm)
open import Definition.Typed.RedSteps
open import Definition.LogicalRelation
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.Weakening
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Application
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Properties
open import Definition.LogicalRelation.Substitution.Irrelevance as S
open import Definition.LogicalRelation.Substitution.Reflexivity
open import Definition.LogicalRelation.Substitution.Introductions.Sigma
open import Definition.LogicalRelation.Substitution.Introductions.Fst
open import Definition.LogicalRelation.Substitution.Introductions.Snd
open import Definition.LogicalRelation.Substitution.Introductions.Pi
open import Definition.LogicalRelation.Substitution.Introductions.Lambda
open import Definition.LogicalRelation.Substitution.Introductions.Application
open import Definition.LogicalRelation.Substitution.Introductions.Cast
open import Definition.LogicalRelation.Substitution.Introductions.Id
open import Definition.LogicalRelation.Substitution.Introductions.IdUPiPi
open import Definition.LogicalRelation.Substitution.Introductions.Transp
open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst
open import Definition.LogicalRelation.Substitution.MaybeEmbed
open import Definition.LogicalRelation.Substitution.Introductions.Universe
open import Definition.LogicalRelation.Substitution.Reduction
open import Definition.LogicalRelation.Substitution.Weakening
open import Definition.LogicalRelation.Substitution.Conversion
open import Definition.LogicalRelation.Substitution.ProofIrrelevance
open import Definition.LogicalRelation.Fundamental.Variable
open import Tools.Product
import Tools.PropositionalEquality as PE
wk2d : Term → Term
wk2d = U.wk (lift (lift (step id)))
wk1f-cast-subst : ∀ σ f A' A rA e →
(wk1 (subst σ f) ∘ cast ⁰ (wk1 (subst σ A')) (wk1 (subst σ A)) (Idsym (Univ rA ⁰) (wk1 (subst σ A)) (wk1 (subst σ A')) (fst (wk1 (subst σ e)))) (var 0) ^ ⁰)
PE.≡
subst (repeat liftSubst (repeat liftSubst σ 1) 0) (wk1 f ∘ cast ⁰ (wk1 A') (wk1 A) (Idsym (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) ^ ⁰)
wk1f-cast-subst σ f A' A rA e = PE.cong₂ (λ X Y → X ∘ Y ^ ⁰) (PE.sym (Idsym-subst-lemma σ f))
(PE.cong₃ (λ X Y Z → cast ⁰ X Y Z (var 0)) (PE.sym (Idsym-subst-lemma σ A')) (PE.sym (Idsym-subst-lemma σ A))
(PE.trans (PE.cong₃ (λ X Y Z → Idsym (Univ rA ⁰) X Y Z) (PE.sym (Idsym-subst-lemma σ A)) (PE.sym (Idsym-subst-lemma σ A')) (PE.sym (Idsym-subst-lemma σ (fst e))))
(PE.sym (subst-Idsym (liftSubst σ) (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e))))))
B-cast-subst : ∀ σ A' A rA e B →
subst (liftSubst σ) B [ cast ⁰ (wk1 (subst σ A')) (wk1 (subst σ A)) (Idsym (Univ rA ⁰) (wk1 (subst σ A)) (wk1 (subst σ A')) (fst (wk1 (subst σ e)))) (var 0) ]↑
PE.≡
subst (repeat liftSubst (repeat liftSubst σ 1) 0) (B [ cast ⁰ (wk1 A') (wk1 A) (Idsym (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) ]↑)
B-cast-subst σ A′ A rA e B = PE.trans (PE.cong (λ X → (subst (liftSubst σ) B) [ X ]↑)
(PE.cong₃ (λ X Y Z → cast ⁰ X Y Z (var 0)) (PE.sym (Idsym-subst-lemma σ A′)) (PE.sym (Idsym-subst-lemma σ A))
(PE.trans (PE.cong₃ (λ X Y Z → Idsym (Univ rA ⁰) X Y Z) (PE.sym (Idsym-subst-lemma σ A)) (PE.sym (Idsym-subst-lemma σ A′)) (PE.sym (Idsym-subst-lemma σ (fst e))))
(PE.sym (subst-Idsym (liftSubst σ) (Univ rA ⁰) (wk1 A) (wk1 A′) (fst (wk1 e)))))))
(PE.sym ((singleSubstLift↑ σ B _)))
wk2d11-111 : ∀ A → wk2d (wk1 (wk1 A)) PE.≡ wk1 (wk1 (wk1 A))
wk2d11-111 A = PE.trans (wk-comp (lift (lift (step id))) (step id) (wk1 A))
(PE.trans (wk-comp (step (lift (step id))) (step id) A)
(PE.trans (PE.sym (wk-comp (step (step id)) (step id) A)) (PE.sym (wk-comp (step id) (step id) (wk1 A)))))
wk2d1d-1d1d : ∀ A → wk2d (wk1d A) PE.≡ wk1d (wk1d A)
wk2d1d-1d1d A = PE.trans (wk-comp (lift (lift (step id))) (lift (step id)) A)
(PE.trans PE.refl (PE.sym (wk-comp (lift (step id)) (lift (step id)) A)))
wk1∃-aux : ∀ A A' rA B B' → wk1 (∃ Id (Univ rA ⁰) A A' ▹ (Π wk1 A' ^ rA ° ⁰ ▹
Id (U ⁰) (wk1d B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A))
(Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹))
PE.≡
∃ Id (Univ rA ⁰) (wk1 A) (wk1 A') ▹ (Π wk1 (wk1 A') ^ rA ° ⁰ ▹
Id (U ⁰) (wk2d (wk1d B) [ cast ⁰ (wk2d (wk1 (wk1 A'))) (wk2d (wk1 (wk1 A)))
(Idsym (Univ rA ⁰) (wk2d (wk1 (wk1 A))) (wk2d (wk1 (wk1 A'))) (var 1)) (var 0) ]↑)
(wk1d (wk1d B')) ° ¹ ° ¹)
wk1∃-aux A A' rA B B' = PE.cong₃ (λ X Y Z → ∃ Id (Univ rA ⁰) (wk1 A) (wk1 A') ▹ Π X ^ rA ° ⁰ ▹ Id (U ⁰) Y Z ° ¹ ° ¹)
(PE.trans (wk-comp (lift (step id)) (step id) A') (PE.sym (wk-comp (step id) (step id) A')))
(PE.trans (wk-β↑ (wk1d B)) (PE.cong₃ (λ X Y Z → wk2d (wk1d B) [ cast ⁰ X Y Z (var 0) ]↑)
PE.refl PE.refl (wk-Idsym (lift (lift (step id))) (Univ rA ⁰) _ _ (var 1)) ))
(wk2d1d-1d1d B')
wk1∃ : ∀ A A' rA B B' → wk1 (∃ Id (Univ rA ⁰) A A' ▹ (Π wk1 A' ^ rA ° ⁰ ▹
Id (U ⁰) (wk1d B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A))
(Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹))
PE.≡
∃ Id (Univ rA ⁰) (wk1 A) (wk1 A') ▹ (Π wk1 (wk1 A') ^ rA ° ⁰ ▹
Id (U ⁰) (wk1d (wk1d B) [ cast ⁰ (wk1 (wk1 (wk1 A'))) (wk1 (wk1 (wk1 A)))
(Idsym (Univ rA ⁰) (wk1 (wk1 (wk1 A))) (wk1 (wk1 (wk1 A'))) (var 1)) (var 0) ]↑)
(wk1d (wk1d B')) ° ¹ ° ¹)
wk1∃ A A' rA B B' = PE.trans (wk1∃-aux A A' rA B B') (PE.cong₃ (λ X Y Z → ∃ Id (Univ rA ⁰) (wk1 A) (wk1 A') ▹ Π (wk1 (wk1 A')) ^ rA ° ⁰ ▹ Id (U ⁰) (X [ Y ]↑) Z ° ¹ ° ¹)
(wk2d1d-1d1d B) (PE.cong₃ (λ X Y Z → cast ⁰ X Y Z (var 0)) (wk2d11-111 A') (wk2d11-111 A)
(PE.cong₂ (λ X Y → Idsym (Univ rA ⁰) X Y (var 1)) (wk2d11-111 A) (wk2d11-111 A'))) PE.refl )
snd-cast-subst : ∀ A A' rA B B' e → Π wk1 (wk1 A') ^ rA ° ⁰ ▹
Id (U ⁰) (wk1d (wk1d B) [ cast ⁰ (wk1 (wk1 (wk1 A'))) (wk1 (wk1 (wk1 A))) (Idsym (Univ rA ⁰) (wk1 (wk1 (wk1 A))) (wk1 (wk1 (wk1 A'))) (var 1)) (var 0) ]↑)
(wk1d (wk1d B')) ° ¹ ° ¹ [ fst (wk1 e) ]
PE.≡
Π (wk1 A') ^ rA ° ⁰ ▹
Id (U ⁰) (wk1d B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹
snd-cast-subst A A' rA B B' e = PE.cong₃ (λ X Y Z → Π X ^ rA ° ⁰ ▹ Id (U ⁰) Y Z ° ¹ ° ¹)
(wk1-singleSubst (wk1 A') _)
(PE.trans (singleSubstLift↑ (sgSubst (fst (wk1 e))) (wk1d (wk1d B)) _)
(PE.cong₂ (λ X Y → X [ Y ]↑) (wk1d-singleSubst (wk1d B) (fst (wk1 e)))
(PE.cong₃ (λ X Y Z → cast ⁰ X Y Z (var 0)) (subst3wk A' (fst (wk1 e))) (subst3wk A (fst (wk1 e)))
(PE.trans (subst-Idsym (liftSubst (sgSubst (fst (wk1 e)))) (Univ rA ⁰) (wk1 (wk1 (wk1 A))) (wk1 (wk1 (wk1 A'))) (var 1))
(PE.cong₂ (λ X Y → Idsym (Univ rA ⁰) X Y (fst (wk1 (wk1 e)))) (subst3wk A (fst (wk1 e))) (subst3wk A' (fst (wk1 e))))))))
(wk1d-singleSubst (wk1d B') (fst (wk1 e)))
where
subst3wk : ∀ t u → subst (liftSubst (sgSubst u)) (wk1 (wk1 (wk1 t))) PE.≡ wk1 (wk1 t)
subst3wk t u = PE.trans (Idsym-subst-lemma (sgSubst u) (wk1 (wk1 t))) (PE.cong wk1 (wk1-singleSubst (wk1 t) u))
Id-cast-subst : ∀ A A' rA B B' e → Id (U ⁰) (wk1d B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]↑)
(wk1d B')
[ var 0 ]
PE.≡
Id (U ⁰) (B [ cast ⁰ (wk1 A') (wk1 A) (Idsym (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) ]↑)
B'
Id-cast-subst A A' rA B B' e = PE.cong₂ (Id (U ⁰))
(PE.trans
(PE.cong (λ X → X [ var 0 ]) (wk1d[]-[]↑ (wk1d B) _))
(PE.trans aux (PE.sym (wk1d[]-[]↑ B _))) )
(wkSingleSubstId B')
where
aux : (wk1d (wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]) [ var 0 ]
PE.≡ wk1d B [ cast ⁰ (wk1 A') (wk1 A) (Idsym (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) ]
aux = PE.trans (singleSubstLift (wk1d (wk1d B)) _)
(PE.cong₄ (λ X Y Z T → X [ cast ⁰ Y Z T (var 0) ])
(wk1d-singleSubst (wk1d B) (var 0)) (wk1-singleSubst (wk1 A') (var 0)) (wk1-singleSubst (wk1 A) (var 0))
(PE.trans (subst-Idsym _ (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (wk1 (wk1 (fst e))))
(PE.cong₃ (λ X Y Z → Idsym (Univ rA ⁰) X Y Z) (wk1-singleSubst (wk1 A) (var 0)) (wk1-singleSubst (wk1 A') (var 0)) (wk1-singleSubst (wk1 (fst e)) (var 0)))))
cast-Πᵗᵛ-aux : ∀ {A B A' B' rA Γ e f} ([Γ] : ⊩ᵛ Γ) →
let l = ∞
lΠ = ⁰
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ])
in
([A] : Γ ⊩ᵛ⟨ l ⟩ A ^ [ rA , ι lΠ ] / [Γ])
([A'] : Γ ⊩ᵛ⟨ l ⟩ A' ^ [ rA , ι lΠ ] / [Γ])
([UB] : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A])
([UB'] : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'])
([A]ₜ : Γ ⊩ᵛ⟨ l ⟩ A ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B]ₜ : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A] / (λ {Δ} {σ} → [UB] {Δ} {σ}))
([A']ₜ : Γ ⊩ᵛ⟨ l ⟩ A' ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B']ₜ : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B' ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'] / (λ {Δ} {σ} → [UB'] {Δ} {σ}))
([Id] : Γ ⊩ᵛ⟨ l ⟩ Id (U lΠ) (Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ) (Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ) ^ [ % , next lΠ ] / [Γ])
([e]ₜ : Γ ⊩ᵛ⟨ l ⟩ e ∷ Id (U lΠ) (Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ) (Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ) ^ [ % , next lΠ ] / [Γ] / [Id])
([ΠAB] : Γ ⊩ᵛ⟨ l ⟩ Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ ^ [ ! , ι lΠ ] / [Γ])
([f]ₜ : Γ ⊩ᵛ⟨ l ⟩ f ∷ Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ ^ [ ! , ι lΠ ] / [Γ] / [ΠAB]) →
([Id-U-ΠΠ] : [ Γ ⊩ᵛ⟨ l ⟩ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° lΠ) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° lΠ))
≡ ∃ (Id (Univ rA ⁰) A A') ▹
(Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(U.wk (lift (step id)) B') ° ¹ ° ¹)
∷ SProp ¹ ^ [ ! , next ¹ ] / [Γ] ] )
→
let [IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ
[ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA']
[wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ
[wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A']
[wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A]
[wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ
[ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']'
[wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']'
[wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA']
[wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA]
[wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ}
[wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA']
[ΓA'] = (_∙_ {Γ} {A'} [Γ] [A'])
[w'A] = wk1ᵗᵛ {F = A'} {G = A} {lG = ⁰} [Γ] [A'] [A]ₜ
[w'A'] = wk1ᵗᵛ {F = A'} {G = A'} {lG = ⁰} [Γ] [A'] [A']ₜ
[w'A']' = wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']
[wUA] = maybeEmbᵛ {A = Univ rA _} [ΓA'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'] {Δ} {σ})
[wIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 A} {u = wk1 A'} [ΓA'] (λ {Δ} {σ} → [wUA] {Δ} {σ}) [w'A] [w'A']
[ww'A']' = wk1ᵛ {A = wk1 A'} {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} [ΓA'] [wIdAA'] [w'A']'
[ww'A'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1 A'} {lG = ⁰} [ΓA'] [wIdAA'] [w'A']
[ΓA'Id] = _∙_ {A = Id (Univ rA ⁰) (wk1 A) (wk1 A')} [ΓA'] [wIdAA']
[ΓA'IdA'] = _∙_ {A = wk1 (wk1 A')} [ΓA'Id] [ww'A']'
[wwwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'IdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'IdA'] {Δ} {σ}) {Δ} {σ}
[www'A'] = wk1ᵗᵛ {F = wk1 (wk1 A')} {G = wk1 (wk1 A')} {lG = ⁰} [ΓA'Id] [ww'A']' [ww'A']
[ww'A] = wk1ᵗᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1 A} {lG = ⁰} [ΓA'] [wIdAA'] [w'A]
[www'A] = wk1ᵗᵛ {F = wk1 (wk1 A')} {G = wk1 (wk1 A)} {lG = ⁰} [ΓA'Id] [ww'A']' [ww'A]
[wwwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 (wk1 A))} {u = wk1 (wk1 (wk1 A'))} [ΓA'IdA'] (λ {Δ} {σ} → [wwwUA'] {Δ} {σ} rA) [www'A] [www'A']
[wwwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓA'Id] {Δ} {σ}
Id-U-ΠΠ-res-end A A' B B' = Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
((wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹
in
([Id-U-ΠΠ-res-end] : Γ ∙ A' ^ [ rA , ι ⁰ ] ∙ Id (Univ rA ⁰) (wk1 A) (wk1 A') ^ [ % , ι ¹ ] ⊩ᵛ⟨ ∞ ⟩
Id-U-ΠΠ-res-end (wk1 A) (wk1 A') (wk1d B) (wk1d B') ∷ SProp ¹ ^ [ ! , ∞ ] / [ΓA'Id] / (λ {Δ} {σ} → [wwwU¹] {Δ} {σ} %))
([var]ₜ : Γ ∙ A' ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ var 0 ∷ wk1 A' ^ [ rA , ι ⁰ ] / [ΓA'] / wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A'])
([var0']ₜ : Γ ∙ A' ^ [ rA , ι ⁰ ] ∙ Id (Univ rA ⁰) (wk1 A) (wk1 A') ^ [ % , ι ¹ ] ∙ wk1 (wk1 A') ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ var 0 ∷
wk1 (wk1 (wk1 A')) ^ [ rA , ι ⁰ ] / [ΓA'IdA'] / wk1ᵛ {A = wk1 (wk1 A')} {F = wk1 (wk1 A')} [ΓA'Id] [ww'A']' [ww'A']')
([var1']ₜ : Γ ∙ A' ^ [ rA , ι ⁰ ] ∙ Id (Univ rA ⁰) (wk1 A) (wk1 A') ^ [ % , ι ¹ ] ∙ wk1 (wk1 A') ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ var 1 ∷
Id (Univ rA ⁰) (wk1 (wk1 (wk1 A))) (wk1 (wk1 (wk1 A'))) ^ [ % , ι ¹ ] / [ΓA'IdA'] / [wwwIdAA'])
→ [ Γ ⊩ᵛ⟨ l ⟩ (cast lΠ (Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ) (Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ) e f) ≡
(lam A' ▹
(let a = cast lΠ (wk1 A') (wk1 A) (Idsym (Univ rA lΠ) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) in
cast lΠ (B [ a ]↑) B' ((snd (wk1 e)) ∘ (var 0) ^ ¹) ((wk1 f) ∘ a ^ lΠ)) ^ ⁰)
∷ Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ ^ [ ! , ι lΠ ] / [Γ] ]
cast-Πᵗᵛ-aux {A} {B} {A'} {B'} {rA} {Γ} {e} {f}
[Γ] [A] [A'] [UB] [UB'] [A]ₜ [B]ₜ [A']ₜ [B']ₜ [Id] [e]ₜ [ΠAB] [f]ₜ [Id-U-ΠΠ] [Id-U-ΠΠ-res-end] [var]ₜ [var0']ₜ [var1']ₜ =
let l = ∞
lΠ = ⁰
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ])
⊢AΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A]ₜ ⊢Δ [σ]))
⊢A'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A']ₜ ⊢Δ [σ]))
⊢A = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A] {Δ} {σ} ⊢Δ [σ]))
⊢A' = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A'] {Δ} {σ} ⊢Δ [σ]))
[ΓA] = (_∙_ {Γ} {A} [Γ] [A])
[ΓA'] = (_∙_ {Γ} {A'} [Γ] [A'])
⊢BΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B]ₜ {Δ} {σ} ⊢Δ [σ]))
[A]' = univᵛ {A = A} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ
[A']' = univᵛ {A = A'} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A']ₜ
[B]' = univᵛ {A = B} [ΓA] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB] {Δ} {σ}) [B]ₜ
[B] = maybeEmbᵛ {A = B} [ΓA] [B]'
[B']' = univᵛ {A = B'} [ΓA'] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [B']ₜ
[B'] = maybeEmbᵛ {A = B'} [ΓA'] [B']'
⊢B'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB'] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B']ₜ {Δ} {σ} ⊢Δ [σ]))
[liftσ] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A] [σ]
[liftσ'] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A'} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A'] [σ]
⊢e = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([Id] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([e]ₜ {Δ} {σ} ⊢Δ [σ]))
⊢f = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([ΠAB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([f]ₜ {Δ} {σ} ⊢Δ [σ]))
[ΠAB'] = Πᵛ {A'} {B'} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A'] [B']
[ΓA'] = _∙_ {A = A'} [Γ] [A']
[wUA] = maybeEmbᵛ {A = Univ rA _} [ΓA'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'] {Δ} {σ})
[wUA]ᵗ = Uᵗᵛ [ΓA']
[IdAA']ₜ = Idᵗᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ (Uᵗᵛ [Γ])
[IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ
[ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA']
[wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ
[wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A']
[wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A]
[wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ
[ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']'
[wwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓIdA'] {Δ} {σ}
[wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ}
[ΓIdA] = _∙_ {A = wk1 A} [ΓId] [wA]'
[wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA']
[wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA]
[wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']'
[wwA]' = wk1ᵛ {A = wk1 A} {F = wk1 A'} [ΓId] [wA']' [wA]'
[wwU0A] = maybeEmbᵛ {A = Univ ! _ } [ΓIdA] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA] {Δ} {σ})
[wB'] = wk1dᵗᵛ {F = A'} {F' = Id (Univ rA ⁰) A A'} {G = B'} [Γ] [A'] [IdAA'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) [B']ₜ
[wB] = wk1dᵗᵛ {F = A} {F' = Id (Univ rA ⁰) A A'} {G = B} [Γ] [A] [IdAA'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [wwU0A] {Δ} {σ}) [B]ₜ
[wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA']
[wwIdA'A] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A')} {u = wk1 (wk1 A)} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA]
Id-U-ΠΠ-res-end A A' B B' = Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
((wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹
Id-U-ΠΠ-left = Id (U lΠ) (Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ) (Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ)
Id-U-ΠΠ-res A A' B B' = ∃ (Id (Univ rA ⁰) A A') ▹ Id-U-ΠΠ-res-end A A' B B'
[wU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓA'] {Δ} {σ}
modelsTermEq [SProp] _ [Id-U-ΠΠ-res] [eq] = [Id-U-ΠΠ]
[Id-U-ΠΠ-res]' = maybeEmbᵛ {A = Id-U-ΠΠ-res A A' B B'} [Γ] (univᵛ {A = Id-U-ΠΠ-res A A' B B'} [Γ] (≡is≤ PE.refl) [SProp] [Id-U-ΠΠ-res])
[conve]ₜ = convᵛ {t = e} {A = Id-U-ΠΠ-left} {B = Id-U-ΠΠ-res A A' B B'}
[Γ] [Id] [Id-U-ΠΠ-res]'
(univEqᵛ {A = Id-U-ΠΠ-left} {B = Id-U-ΠΠ-res A A' B B'} [Γ] [SProp] [Id] [eq]) [e]ₜ
[we] = wk1Termᵛ {F = A'} {G = Id-U-ΠΠ-res A A' B B'} {t = e} [Γ] [A'] [Id-U-ΠΠ-res]' [conve]ₜ
[w'A] = wk1ᵗᵛ {F = A'} {G = A} {lG = ⁰} [Γ] [A'] [A]ₜ
[w'A]' = wk1ᵛ {A = A} {F = A'} [Γ] [A'] [A]
[w'A]⁰ = wk1ᵛ {A = A} {F = A'} [Γ] [A'] [A]'
[w'A'] = wk1ᵗᵛ {F = A'} {G = A'} {lG = ⁰} [Γ] [A'] [A']ₜ
[w'A']' = wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']
[w'A']⁰ = wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']'
[wIdA'A] = Idᵛ {A = Univ rA ⁰} {t = wk1 A'} {u = wk1 A} [ΓA'] (λ {Δ} {σ} → [wUA] {Δ} {σ}) [w'A'] [w'A]
[wIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 A} {u = wk1 A'} [ΓA'] (λ {Δ} {σ} → [wUA] {Δ} {σ}) [w'A] [w'A']
[wIdAA']ᵗ = Idᵗᵛ {A = Univ rA ⁰} {t = wk1 A} {u = wk1 A'} [ΓA'] (λ {Δ} {σ} → [wUA] {Δ} {σ}) [w'A] [w'A'] (λ {Δ} {σ} → Uᵗᵛ [ΓA'] {Δ} {σ})
[wIdAA']ₜ = Idᵗᵛ {A = Univ rA ⁰} {t = wk1 A} {u = wk1 A'} [ΓA'] (λ {Δ} {σ} → [wUA] {Δ} {σ}) [w'A] [w'A'] (λ {Δ} {σ} → Uᵗᵛ [ΓA'] {Δ} {σ})
[ww'A']' = wk1ᵛ {A = wk1 A'} {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} [ΓA'] [wIdAA'] [w'A']'
[ww'A'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1 A'} {lG = ⁰} [ΓA'] [wIdAA'] [w'A']
[ww'A]' = wk1ᵛ {A = wk1 A} {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} [ΓA'] [wIdAA'] [w'A]'
[ww'A] = wk1ᵗᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1 A} {lG = ⁰} [ΓA'] [wIdAA'] [w'A]
[ΓA'A'] = _∙_ {A = wk1 A'} [ΓA'] [w'A']'
[ww'UA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'A'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'A'] {Δ} {σ}) {Δ} {σ}
[ΓA'A] = _∙_ {A = wk1 A} [ΓA'] [w'A]'
[ww'UA] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'A] (λ {Δ} {σ} → Uᵛ emb< [ΓA'A] {Δ} {σ}) {Δ} {σ}
[ΓA'Id] = _∙_ {A = Id (Univ rA ⁰) (wk1 A) (wk1 A')} [ΓA'] [wIdAA']
[ΓA'IdA'] = _∙_ {A = wk1 (wk1 A')} [ΓA'Id] [ww'A']'
[www'UA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'IdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'IdA'] {Δ} {σ}) {Δ} {σ}
[ΓA'IdA] = _∙_ {A = wk1 (wk1 A)} [ΓA'Id] [ww'A]'
[www'UA] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'IdA] (λ {Δ} {σ} → Uᵛ emb< [ΓA'IdA] {Δ} {σ}) {Δ} {σ}
[w'B'] = wk1dᵗᵛ {F = A'} {F' = A'} {G = B'} [Γ] [A'] [A'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) ((λ {Δ} {σ} → [ww'UA'] {Δ} {σ} !)) [B']ₜ
[ww'B'] = wk1dᵗᵛ {F = wk1 A'} {F' = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1d B'} [ΓA'] [w'A']' [wIdAA'] (λ {Δ} {σ} → [ww'UA'] {Δ} {σ} !) (λ {Δ} {σ} → [www'UA'] {Δ} {σ} !) [w'B']
[w'B] = wk1dᵗᵛ {F = A} {F' = A'} {G = B} [Γ] [A] [A'] (λ {Δ} {σ} → [UB] {Δ} {σ}) ((λ {Δ} {σ} → [ww'UA] {Δ} {σ} !)) [B]ₜ
[ww'B] = wk1dᵗᵛ {F = wk1 A} {F' = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1d B} [ΓA'] [w'A]' [wIdAA'] (λ {Δ} {σ} → [ww'UA] {Δ} {σ} !) (λ {Δ} {σ} → [www'UA] {Δ} {σ} !) [w'B]
[www'A']' = wk1ᵛ {A = wk1 (wk1 A')} {F = wk1 (wk1 A') } [ΓA'Id] [ww'A']' [ww'A']'
[www'A'] = wk1ᵗᵛ {F = wk1 (wk1 A')} {G = wk1 (wk1 A')} {lG = ⁰} [ΓA'Id] [ww'A']' [ww'A']
[www'A]' = wk1ᵛ {A = wk1 (wk1 A)} {F = wk1 (wk1 A')} [ΓA'Id] [ww'A']' [ww'A]'
[www'A] = wk1ᵗᵛ {F = wk1 (wk1 A')} {G = wk1 (wk1 A)} {lG = ⁰} [ΓA'Id] [ww'A']' [ww'A]
[wwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓA'A'] {Δ} {σ}
[wwwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓA'Id] {Δ} {σ}
Id-U-ΠΠ-res-end-wk1d = Id-U-ΠΠ-res-end (wk1 A) (wk1 A') (wk1d B) (wk1d B')
Id-U-ΠΠ-res-wk1d = Id-U-ΠΠ-res (wk1 A) (wk1 A') (wk1d B) (wk1d B')
[Id-U-ΠΠ-res-end]' = maybeEmbᵛ {A = Id-U-ΠΠ-res-end-wk1d} [ΓA'Id]
(univᵛ {A = Id-U-ΠΠ-res-end-wk1d} [ΓA'Id] (≡is≤ PE.refl)
(λ {Δ} {σ} → [wwwU¹] {Δ} {σ} %) [Id-U-ΠΠ-res-end])
[we]' = S.irrelevanceTerm′ {A = wk1 (Id-U-ΠΠ-res A A' B B')} {A′ = Id-U-ΠΠ-res-wk1d} {t = wk1 e}
(wk1∃ A A' rA B B')
PE.refl [ΓA'] [ΓA'] (wk1ᵛ {A = Id-U-ΠΠ-res A A' B B'} {F = A'} [Γ] [A'] [Id-U-ΠΠ-res]')
(∃ᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = Id-U-ΠΠ-res-end-wk1d} [ΓA'] [wIdAA']
[Id-U-ΠΠ-res-end]') [we]
[fst] = fstᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = Id-U-ΠΠ-res-end-wk1d} {tu = wk1 e}
[ΓA'] [wIdAA'] [Id-U-ΠΠ-res-end]'
(λ {Δ} {σ} → [wwwU¹] {Δ} {σ} %) [wIdAA']ᵗ [Id-U-ΠΠ-res-end]
[we]'
[wfste] : Γ ∙ A' ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ Idsym (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e)) ∷ Id (Univ rA ⁰) (wk1 A') (wk1 A) ^ [ % , ι ¹ ] / [ΓA'] / [wIdA'A]
[wfste] = IdSymᵗᵛ {A = Univ rA ⁰} {t = wk1 A} {u = wk1 A'} {e = fst (wk1 e)} [ΓA'] (λ {Δ} {σ} → [wU¹] {Δ} {σ} !)
(λ {Δ} {σ} → [wUA]ᵗ {Δ} {σ}) (λ {Δ} {σ} → [wUA] {Δ} {σ})
[w'A] [w'A'] [wIdAA'] [wIdA'A] [fst]
cast-Π-a A A' e = cast ⁰ (wk1 A') (wk1 A) (Idsym (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0)
[cast-Π-a] : Γ ∙ A' ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ cast-Π-a A A' e ∷ wk1 A ^ [ rA , ι ⁰ ] / [ΓA'] / wk1ᵛ {A = A} {F = A'} [Γ] [A'] [A]
[cast-Π-a] = castᵗᵛ {wk1 A'} {wk1 A} {t = var 0} {e = Idsym (Univ rA ⁰) (wk1 A) (wk1 A') (fst (wk1 e))} [ΓA']
(λ {Δ} {σ} → [wUA] {Δ} {σ}) [w'A'] [w'A]
(wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']) (wk1ᵛ {A = A} {F = A'} [Γ] [A'] [A])
[var]ₜ [wIdA'A] [wfste]
B[cast-Π-a]↑ₜ = subst↑STerm {F = A'} {F' = A} {G = B} {t = cast-Π-a A A' e} [Γ] [A'] [A]
(λ {Δ} {σ} → [UB'] {Δ} {σ}) (λ {Δ} {σ} → [UB] {Δ} {σ}) [B]ₜ [cast-Π-a]
[f°cast-Π-a] = appᵛ↑ {F = A} {F' = A'} {G = B} {t = wk1 f} {u = cast-Π-a A A' e} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A] [A'] [B] [ΠAB]
(wk1Termᵛ {F = A'} {G = Π A ^ rA ° ⁰ ▹ B ° ⁰ ° lΠ} {t = f} [Γ] [A'] [ΠAB] [f]ₜ)
[cast-Π-a]
[wIdBB'] : Γ ∙ A' ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ Id (Univ ! ⁰) (B [ cast-Π-a A A' e ]↑) B' ^ [ % , ι ¹ ] / [ΓA']
[wIdBB'] = Idᵛ {A = Univ ! ⁰} {t = B [ cast-Π-a A A' e ]↑} {u = B'} [ΓA'] (λ {Δ} {σ} → [UB'] {Δ} {σ})
B[cast-Π-a]↑ₜ [B']ₜ
[snd] = sndᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = Id-U-ΠΠ-res-end-wk1d} {tu = wk1 e}
[ΓA'] [wIdAA'] [Id-U-ΠΠ-res-end]'
(λ {Δ} {σ} → [wwwU¹] {Δ} {σ} %) [wIdAA']ᵗ [Id-U-ΠΠ-res-end]
[we]'
[sndType]' = S.irrelevance′ {A = Id-U-ΠΠ-res-end-wk1d [ fst (wk1 e) ]}
{A′ = Π (wk1 A') ^ rA ° ⁰ ▹
Id (U ⁰) ((wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹}
(snd-cast-subst A A' rA B B' e) [ΓA'] [ΓA']
(substS {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = Id-U-ΠΠ-res-end-wk1d} {fst (wk1 e)} [ΓA']
[wIdAA'] [Id-U-ΠΠ-res-end]' [fst])
[snd]' = S.irrelevanceTerm′ {A = Id-U-ΠΠ-res-end-wk1d [ fst (wk1 e) ]}
{A′ = Π (wk1 A') ^ rA ° ⁰ ▹
Id (U ⁰) ((wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹}
{t = snd (wk1 e)}
(snd-cast-subst A A' rA B B' e) PE.refl [ΓA'] [ΓA']
(substS {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = Id-U-ΠΠ-res-end-wk1d} {fst (wk1 e)} [ΓA']
[wIdAA'] [Id-U-ΠΠ-res-end]' [fst])
[sndType]' [snd]
[wsnde] : Γ ∙ A' ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ (snd (wk1 e)) ∘ (var 0) ^ ¹ ∷ Id (Univ ! ⁰) (B [ cast-Π-a A A' e ]↑) B' ^ [ % , ι ¹ ] / [ΓA'] / [wIdBB']
[wsnde] = let X = appᵛ {F = wk1 A'}
{G = Id (U ⁰)
((wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]↑)
(wk1d B')}
{t = snd (wk1 e)} {u = var 0} [ΓA'] [w'A']'
[sndType]' [snd]' [var]ₜ
in S.irrelevanceTerm′ {A = (Id (U ⁰) ((wk1d B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]↑)
(wk1d B')) [ var 0 ]}
{A′ = Id (Univ ! ⁰) (B [ cast-Π-a A A' e ]↑) B'}
{t = (snd (wk1 e)) ∘ (var 0) ^ ¹}
(Id-cast-subst A A' rA B B' e) PE.refl [ΓA'] [ΓA']
(substSΠ {wk1 A'}
{Id (U ⁰) (wk1d B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (fst (wk1 (wk1 e)))) (var 0) ]↑)
(wk1d B')}
{var 0} [ΓA'] [w'A']'
[sndType]' [var]ₜ )
[wIdBB'] X
cast-Π-res A A' B B' e f =
cast ⁰ (B [ cast-Π-a A A' e ]↑) B' ((snd (wk1 e)) ∘ (var 0) ^ ¹) ((wk1 f) ∘ cast-Π-a A A' e ^ ⁰)
[cast-Π-res] : Γ ⊩ᵛ⟨ ∞ ⟩ lam A' ▹ cast-Π-res A A' B B' e f ^ ⁰ ∷ Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ] / [Γ] / [ΠAB']
[cast-Π-res] = lamᵛ {F = A'} {G = B'} {t = cast-Π-res A A' B B' e f} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A'] [B']
(castᵗᵛ {B [ cast-Π-a A A' e ]↑} {B'} {t = (wk1 f) ∘ cast-Π-a A A' e ^ ⁰} {e = (snd (wk1 e)) ∘ (var 0) ^ ¹}
[ΓA'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) B[cast-Π-a]↑ₜ [B']ₜ (subst↑S {F = A'} {G = B} {F' = A} [Γ] [A'] [A] [B] [cast-Π-a]) [B']
[f°cast-Π-a] [wIdBB'] [wsnde])
[cast-Π] : Γ ⊩ᵛ cast ⁰ (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰) e f ⇒ lam A' ▹ cast-Π-res A A' B B' e f ^ ⁰ ∷ Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰ ^ ι ⁰ / [Γ]
[cast-Π] = λ {Δ} {σ} ⊢Δ [σ] → let Aσ = ⊢AΔ {Δ} {σ} ⊢Δ [σ]
Bσ = ⊢BΔ {Δ ∙ subst σ A ^ _} {liftSubst σ} (⊢Δ ∙ ⊢A {Δ} {σ} ⊢Δ [σ]) ([liftσ] {Δ} {σ} ⊢Δ [σ])
A'σ = ⊢A'Δ {Δ} {σ} ⊢Δ [σ]
B'σ = ⊢B'Δ {Δ ∙ subst σ A' ^ _} {liftSubst σ} (⊢Δ ∙ ⊢A' {Δ} {σ} ⊢Δ [σ]) ([liftσ'] {Δ} {σ} ⊢Δ [σ])
eσ = ⊢e {Δ} {σ} ⊢Δ [σ]
fσ = ⊢f {Δ} {σ} ⊢Δ [σ]
X : Δ ⊢ (cast ⁰ (Π (subst σ A) ^ rA ° ⁰ ▹ (subst (liftSubst σ) B) ° ⁰ ° ⁰) (Π (subst σ A') ^ rA ° ⁰ ▹ (subst (liftSubst σ) B') ° ⁰ ° ⁰) (subst σ e) (subst σ f))
⇒ lam (subst σ A') ▹ cast-Π-res (subst σ A) (subst σ A') (subst (liftSubst σ) B) (subst (liftSubst σ) B') (subst σ e) (subst σ f) ^ ⁰
∷ Π (subst σ A') ^ rA ° ⁰ ▹ (subst (liftSubst σ) B') ° ⁰ ° ⁰ ^ ι ⁰
X = cast-Π {Δ} {subst σ A} {subst σ A'} {rA} {subst (liftSubst σ) B} {subst (liftSubst σ) B'} {subst σ e} {subst σ f} Aσ Bσ A'σ B'σ eσ fσ
in PE.subst (λ BB → Δ ⊢ subst σ (cast ⁰ (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰) e f) ⇒ lam subst σ A' ▹ BB ^ ⁰ ∷ subst σ (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰) ^ ι ⁰ )
(PE.cong₄ (cast ⁰)
(B-cast-subst σ A' A rA e B)
PE.refl (PE.cong₂ (λ X Y → snd X ∘ Y ^ ¹) (PE.sym (Idsym-subst-lemma σ e)) PE.refl) (wk1f-cast-subst σ f A' A rA e)) X
[id] , [eq] = redSubstTermᵛ {Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰} {cast ⁰ (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰) e f} {lam A' ▹ cast-Π-res A A' B B' e f ^ ⁰}
[Γ] (λ {Δ} {σ} ⊢Δ [σ] → [cast-Π] {Δ} {σ} ⊢Δ [σ])
[ΠAB'] [cast-Π-res]
in modelsTermEq [ΠAB'] [id] [cast-Π-res] [eq]
cast-Πᵗᵛ : ∀ {A B A' B' rA Γ e f} ([Γ] : ⊩ᵛ Γ) →
let l = ∞
lΠ = ⁰
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ])
in
([A] : Γ ⊩ᵛ⟨ l ⟩ A ^ [ rA , ι lΠ ] / [Γ])
([A'] : Γ ⊩ᵛ⟨ l ⟩ A' ^ [ rA , ι lΠ ] / [Γ])
([UB] : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A])
([UB'] : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'])
([A]ₜ : Γ ⊩ᵛ⟨ l ⟩ A ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B]ₜ : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A] / (λ {Δ} {σ} → [UB] {Δ} {σ}))
([A']ₜ : Γ ⊩ᵛ⟨ l ⟩ A' ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B']ₜ : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B' ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'] / (λ {Δ} {σ} → [UB'] {Δ} {σ}))
([Id] : Γ ⊩ᵛ⟨ l ⟩ Id (U lΠ) (Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ) (Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ) ^ [ % , next lΠ ] / [Γ])
([e]ₜ : Γ ⊩ᵛ⟨ l ⟩ e ∷ Id (U lΠ) (Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ) (Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ) ^ [ % , next lΠ ] / [Γ] / [Id])
([ΠAB] : Γ ⊩ᵛ⟨ l ⟩ Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ ^ [ ! , ι lΠ ] / [Γ])
([f]ₜ : Γ ⊩ᵛ⟨ l ⟩ f ∷ Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ ^ [ ! , ι lΠ ] / [Γ] / [ΠAB]) →
[ Γ ⊩ᵛ⟨ l ⟩ (cast lΠ (Π A ^ rA ° lΠ ▹ B ° lΠ ° lΠ) (Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ) e f) ≡
(lam A' ▹
(let a = cast lΠ (wk1 A') (wk1 A) (Idsym (Univ rA lΠ) (wk1 A) (wk1 A') (fst (wk1 e))) (var 0) in
cast lΠ (B [ a ]↑) B' ((snd (wk1 e)) ∘ (var 0) ^ ¹) ((wk1 f) ∘ a ^ ⁰)) ^ ⁰)
∷ Π A' ^ rA ° lΠ ▹ B' ° lΠ ° lΠ ^ [ ! , ι lΠ ] / [Γ] ]
abstract
cast-Πᵗᵛ {A} {B} {A'} {B'} {rA} {Γ} {e} {f}
[Γ] [A] [A'] [UB] [UB'] [A]ₜ [B]ₜ [A']ₜ [B']ₜ [Id] [e]ₜ [ΠAB] [f]ₜ =
let l = ∞
lΠ = ⁰
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ
[ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA']
[wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ
[wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A']
[wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A]
[wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ
[ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']'
[wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']'
[wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA']
[wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA]
[wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ}
[wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA']
[ΓA'] = (_∙_ {Γ} {A'} [Γ] [A'])
[w'A] = wk1ᵗᵛ {F = A'} {G = A} {lG = ⁰} [Γ] [A'] [A]ₜ
[w'A'] = wk1ᵗᵛ {F = A'} {G = A'} {lG = ⁰} [Γ] [A'] [A']ₜ
[w'A']' = wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']
[wUA] = maybeEmbᵛ {A = Univ rA _} [ΓA'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'] {Δ} {σ})
[wIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 A} {u = wk1 A'} [ΓA'] (λ {Δ} {σ} → [wUA] {Δ} {σ}) [w'A] [w'A']
[ww'A']' = wk1ᵛ {A = wk1 A'} {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} [ΓA'] [wIdAA'] [w'A']'
[ww'A'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1 A'} {lG = ⁰} [ΓA'] [wIdAA'] [w'A']
[ΓA'Id] = _∙_ {A = Id (Univ rA ⁰) (wk1 A) (wk1 A')} [ΓA'] [wIdAA']
[ΓA'IdA'] = _∙_ {A = wk1 (wk1 A')} [ΓA'Id] [ww'A']'
[wwwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'IdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'IdA'] {Δ} {σ}) {Δ} {σ}
[www'A'] = wk1ᵗᵛ {F = wk1 (wk1 A')} {G = wk1 (wk1 A')} {lG = ⁰} [ΓA'Id] [ww'A']' [ww'A']
[ww'A] = wk1ᵗᵛ {F = Id (Univ rA ⁰) (wk1 A) (wk1 A')} {G = wk1 A} {lG = ⁰} [ΓA'] [wIdAA'] [w'A]
[www'A] = wk1ᵗᵛ {F = wk1 (wk1 A')} {G = wk1 (wk1 A)} {lG = ⁰} [ΓA'Id] [ww'A']' [ww'A]
[wwwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 (wk1 A))} {u = wk1 (wk1 (wk1 A'))} [ΓA'IdA'] (λ {Δ} {σ} → [wwwUA'] {Δ} {σ} rA) [www'A] [www'A']
[wA]ₜ = wk1ᵗᵛ {F = A'} {G = A} {lG = ⁰} [Γ] [A'] [A]ₜ
[wA] = wk1ᵛ {A = A} {F = A'} [Γ] [A'] [A]
[wA']ₜ = wk1ᵗᵛ {F = A'} {G = A'} {lG = ⁰} [Γ] [A'] [A']ₜ
[wA'] = wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']
[wA']' = wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']
[wA]' = wk1ᵛ {A = A} {F = A'} [Γ] [A'] [A]
[ΓA'A'] = _∙_ {A = wk1 A'} [ΓA'] [wA']'
[ΓA'A] = _∙_ {A = wk1 A} [ΓA'] [wA]'
[wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'A'] (λ {Δ} {σ} → Uᵛ emb< [ΓA'A'] {Δ} {σ}) {Δ} {σ}
[wwUA] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓA'A] (λ {Δ} {σ} → Uᵛ emb< [ΓA'A] {Δ} {σ}) {Δ} {σ}
[wB']ₜ = wk1dᵗᵛ {F = A'} {F' = A'} {G = B'} [Γ] [A'] [A'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) ((λ {Δ} {σ} → [wwUA'] {Δ} {σ} !)) [B']ₜ
[wB]ₜ = wk1dᵗᵛ {F = A} {F' = A'} {G = B} [Γ] [A] [A'] (λ {Δ} {σ} → [UB] {Δ} {σ}) ((λ {Δ} {σ} → [wwUA] {Δ} {σ} !)) [B]ₜ
[var]ₜ : Γ ∙ A' ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ var 0 ∷ wk1 A' ^ [ rA , ι ⁰ ] / [ΓA'] / wk1ᵛ {A = A'} {F = A'} [Γ] [A'] [A']
[var]ₜ = proj₂ (fundamentalVar here [ΓA'])
[var0']ₜ : Γ ∙ A' ^ [ rA , ι ⁰ ] ∙ Id (Univ rA ⁰) (wk1 A) (wk1 A') ^ [ % , ι ¹ ] ∙ wk1 (wk1 A') ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ var 0 ∷
wk1 (wk1 (wk1 A')) ^ [ rA , ι ⁰ ] / [ΓA'IdA'] / wk1ᵛ {A = wk1 (wk1 A')} {F = wk1 (wk1 A')} [ΓA'Id] [ww'A']' [ww'A']'
[var0']ₜ = proj₂ (fundamentalVar here [ΓA'IdA'])
[var1']ₜ : Γ ∙ A' ^ [ rA , ι ⁰ ] ∙ Id (Univ rA ⁰) (wk1 A) (wk1 A') ^ [ % , ι ¹ ] ∙ wk1 (wk1 A') ^ [ rA , ι ⁰ ] ⊩ᵛ⟨ ∞ ⟩ var 1 ∷
Id (Univ rA ⁰) (wk1 (wk1 (wk1 A))) (wk1 (wk1 (wk1 A'))) ^ [ % , ι ¹ ] / [ΓA'IdA'] / [wwwIdAA']
[var1']ₜ = let X = fundamentalVar (there here) [ΓA'IdA'] in S.irrelevanceTerm {A = Id (Univ rA ⁰) (wk1 (wk1 (wk1 A))) (wk1 (wk1 (wk1 A')))} {t = var 1}
[ΓA'IdA'] [ΓA'IdA'] (proj₁ X) [wwwIdAA'] (proj₂ X)
in cast-Πᵗᵛ-aux {A} {B} {A'} {B'} {rA} {Γ} {e} {f}
[Γ] [A] [A'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A]ₜ [B]ₜ [A']ₜ [B']ₜ [Id] [e]ₜ [ΠAB] [f]ₜ
(Id-U-ΠΠᵗᵛ {A} {B} {A'} {B'} {rA} {Γ}
[Γ] [A] [A'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A]ₜ [B]ₜ [A']ₜ [B']ₜ)
(Id-U-ΠΠ-resᵗᵛ {wk1 A} {wk1d B} {wk1 A'} {wk1d B'}
[ΓA'] [wA] [wA'] (λ {Δ} {σ} → [wwUA] {Δ} {σ} !) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) [wA]ₜ [wB]ₜ [wA']ₜ [wB']ₜ [var0']ₜ [var1']ₜ)
[var]ₜ [var0']ₜ [var1']ₜ
| {
"alphanum_fraction": 0.3893316067,
"avg_line_length": 80.4729458918,
"ext": "agda",
"hexsha": "14435461c35e8cdeb1157a0b492e95dd516cdf3f",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/CastPi.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"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": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/CastPi.agda",
"max_line_length": 210,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/CastPi.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 20823,
"size": 40156
} |
-- Be afraid… Type as type Type
{-# OPTIONS --type-in-type #-}
{-
Be really afraid: this module is a hack to give definitional equalities
to ▹. This is done by introducing an 'evil' function called 'run' that
should not appear in user code. Is this safe to do? This remains to be
explored.
By the same token we give a definitional equalities to fix as well.
Beware of non-termination!
-}
open import guarded-recursion.prelude
renaming (O to zero; S to suc)
module guarded-recursion.compute where
-- Same as in prelude but type-in-type
module Coe₀ where
coe : {A B : Type} → A ≡ B → A → B
coe = transport id
coe! : {A B : Type} → A ≡ B → B → A
coe! = transport id ∘ !
module _ {A : Type} {P Q : A → Type} (p : P ≡ Q) {x} where
coe₁ : P x → Q x
coe₁ = transport (λ P → P x) p
coe₁! : Q x → P x
coe₁! = transport (λ P → P x) (! p)
module _ {A : Type} {B : Type} {R S : A → B → Type} (p : R ≡ S) {x y} where
coe₂ : R x y → S x y
coe₂ = transport (λ R → R x y) p
coe₂! : S x y → R x y
coe₂! = transport (λ R → R x y) (! p)
open Coe₀
infixl 6 _⊛_
data ▹_ : Type → Type
private
-- 'run' should not appear in user code
run : ∀ {A} → ▹ A → A
-- User code should not pattern-match on ▹_...
data ▹_ where
next : ∀ {A} → A → ▹ A
_⊛_ : ∀ {A} {B : A → Type} → ▹ ((x : A) → B x) → (x : ▹ A) → ▹ (B (run x))
run (next x) = x
run (f ⊛ x) = run f (run x)
▸ : ▹ Type → Type
▸ x = ▹ (run x)
▸F : ∀ {A} → (A → Type) → ▹ A → Type
▸F F x = ▸ (next F ⊛ x)
map▹ : ∀ {A} {B : A → Type} → ((x : A) → B x) → (x : ▹ A) → ▸F B x
map▹ f x = next f ⊛ x
private
module Unused where
by-computation : ∀ {A} {B : A → Type} {x} → ▸ (next B ⊛ x) ≡ ▹ (B (run x))
by-computation = idp
const⊛ : ∀ {A} {X : Type} {x : ▹ X} → ▸ (next (λ _ → A) ⊛ x) ≡ ▹ A
const⊛ = idp
-- useless: the dependent version is just as fine
_⊛′_ : ∀ {A B} → ▹ (A → B) → ▹ A → ▹ B
_⊛′_ = _⊛_
-- useless: the dependent version is just as fine
map▹′ : ∀ {A B} → (A → B) → ▹ A → ▹ B
map▹′ = map▹
zip : ∀ {A} {B : A → Type} → Σ (▹ A) (▸F B) → ▹ Σ A B
zip (x , y) = map▹ _,_ x ⊛ y
unzip : ∀ {A} {B : A → Type} → ▹ Σ A B → Σ (▹ A) (▸F B)
unzip p = map▹ fst p , map▹ snd p
module M
(fix : ∀ {A} → (▹ A → A) → A)
(fix-rule : ∀ {A} (f : ▹ A → A) → fix f ≡ f (next (fix f))) where
-- Streams of 'A's
S : Type → Type
S A = fix (λ X → A × ▸ X)
rollS : ∀ {A} → A × ▹ (S A) → S A
rollS = coe! (fix-rule _)
unS : ∀ {A} → S A → A × ▹ (S A)
unS = coe (fix-rule _)
hd : ∀ {A} → S A → A
hd = fst ∘ unS
tl : ∀ {A} → S A → ▹ S A
tl = snd ∘ unS
infixl 4 _∷_
_∷_ : ∀ {A} → A → ▹ S A → S A
x ∷ xs = rollS (x , xs)
BF : ∀ {A} → ▹ (S A → S A → Type) → S A → S A → Type
BF ▹B xs ys = (hd xs ≡ hd ys) × ▸ (▹B ⊛ tl xs ⊛ tl ys)
B : ∀ {A} → S A → S A → Type
B = fix BF
rollB : ∀ {A} {xs ys : S A} → BF (next B) xs ys → B xs ys
rollB = coe₂! (fix-rule BF)
B-reflF : ∀ {A} → ▹((xs : S A) → B xs xs) → (xs : S A) → B xs xs
B-reflF ▹BR xs = rollB (idp , ▹BR ⊛ tl xs)
-- Reflexivity of the Bisimilarity relation
-- Thanks to computation at the level of types this definition nicely
-- goes through.
B-refl : ∀ {A} (xs : S A) → B xs xs
B-refl = fix B-reflF
repeatS : ∀ {A} → A → S A
repeatS x = fix (_∷_ x)
zapSf : ∀ {A B} → ▹ (S (A → B) → S A → S B)
→ S (A → B) → S A → S B
zapSf zapS fs xs = hd fs (hd xs) ∷ zapS ⊛ tl fs ⊛ tl xs
zapS : ∀ {A B} → S (A → B) → S A → S B
zapS = fix zapSf
-- repeatS and zapS form an applicative functor
iterateS : ∀ {A} → (A → A) → A → S A
iterateS f = fix λ iterateS x → x ∷ iterateS ⊛ next (f x)
mapSf : ∀ {A B} → (A → B) → ▹(S A → S B) → S A → S B
mapSf f mapS xs = f (hd xs) ∷ mapS ⊛ tl xs
mapS : ∀ {A B} → (A → B) → S A → S B
mapS f = fix (mapSf f)
nats : S ℕ
nats = fix (λ nats → 0 ∷ map▹ (mapS suc) nats)
▹^ : ∀ ℕ → Type → Type
▹^ zero A = A
▹^ (suc n) A = ▹ ▹^ n A
next^ : ∀ {A} n → A → ▹^ n A
next^ zero x = x
next^ (suc n) x = next (next^ n x)
map▹^ : ∀ {A B} n → (A → B) → ▹^ n A → ▹^ n B
map▹^ zero f = f
map▹^ (suc n) f = map▹ (map▹^ n f)
run^ : ∀ {A} n → ▹^ n A → A
run^ zero = id
run^ (suc n) = run^ n ∘ run
‼ : ∀ {A} → (n : ℕ) → S A → ▹^ n A
‼ zero = hd
‼ (suc n) = map▹ (‼ n) ∘ tl
run‼ : ∀ {A} → ℕ → S A → A
run‼ n = run^ n ∘ ‼ n
module HiddenFix {A} (f : ▹ A → A) where
-- This definition is not intended to termination-check.
-- Use with care it's really easy to make the type-checker loop.
{-# TERMINATING #-}
fix : Hidden A
fix = hide f (next (reveal fix))
fix-rule : reveal fix ≡ f (next (reveal fix))
fix-rule = idp {_} {A} {reveal fix}
open HiddenFix
open M (reveal ∘ fix) fix-rule
-- -}
-- -}
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.4765432099,
"avg_line_length": 24.7959183673,
"ext": "agda",
"hexsha": "6c839840524409d86990b62edcd3ba5d0c33434c",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-11-16T16:21:54.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-08-19T12:37:53.000Z",
"max_forks_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "np/guarded-recursion",
"max_forks_repo_path": "guarded-recursion/compute.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0",
"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": "np/guarded-recursion",
"max_issues_repo_path": "guarded-recursion/compute.agda",
"max_line_length": 79,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "np/guarded-recursion",
"max_stars_repo_path": "guarded-recursion/compute.agda",
"max_stars_repo_stars_event_max_datetime": "2016-12-06T23:04:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-06T23:04:56.000Z",
"num_tokens": 2156,
"size": 4860
} |
module Prelude.Char where
open import Prelude.Bool
open import Prelude.Nat
open import Prelude.Equality
open import Prelude.Equality.Unsafe
open import Prelude.Decidable
open import Prelude.Function
open import Prelude.Ord
open import Agda.Builtin.Char
open Agda.Builtin.Char public using (Char)
isLower = primIsLower
isDigit = primIsDigit
isSpace = primIsSpace
isAscii = primIsAscii
isLatin1 = primIsLatin1
isPrint = primIsPrint
isHexDigit = primIsHexDigit
isAlpha = primIsAlpha
toUpper = primToUpper
toLower = primToLower
isAlphaNum : Char → Bool
isAlphaNum c = isAlpha c || isDigit c
charToNat = primCharToNat
natToChar = primNatToChar
charToNat-inj : ∀ {x y} → charToNat x ≡ charToNat y → x ≡ y
charToNat-inj {x} p with charToNat x
charToNat-inj refl | ._ = unsafeEqual -- need to be strict in the proof!
--- Equality --
eqChar : Char → Char → Bool
eqChar = eqNat on charToNat
instance
EqChar : Eq Char
_==_ {{EqChar}} x y with eqChar x y
... | false = no unsafeNotEqual
... | true = yes unsafeEqual
-- Missing primitive isUpper
isUpper : Char → Bool
isUpper c = isNo (toLower c == c)
--- Ord ---
instance
OrdChar : Ord Char
OrdChar = OrdBy charToNat-inj
OrdLawsChar : Ord/Laws Char
OrdLawsChar = OrdLawsBy charToNat-inj
| {
"alphanum_fraction": 0.7249417249,
"avg_line_length": 21.45,
"ext": "agda",
"hexsha": "5eeabf3420c904053d139410b8ff1d08517e75e2",
"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/Prelude/Char.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/Prelude/Char.agda",
"max_line_length": 73,
"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/Prelude/Char.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": 399,
"size": 1287
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed where
open import Definition.Untyped hiding (_∷_)
open import Tools.Fin
open import Tools.Nat
open import Tools.Product
infixl 30 _∙_
infix 30 Πⱼ_▹_
infix 30 Σⱼ_▹_
infix 30 ⟦_⟧ⱼ_▹_
private
variable
n m : Nat
Γ : Con Term n
A B F : Term n
G : Term (1+ n)
x : Fin n
-- Well-typed variables
data _∷_∈_ : (x : Fin n) (A : Term n) (Γ : Con Term n) → Set where
here : x0 ∷ wk1 A ∈ (Γ ∙ A)
there : (h : x ∷ A ∈ Γ) → (x +1) ∷ wk1 A ∈ (Γ ∙ B)
mutual
-- Well-formed context
data ⊢_ : Con Term n → Set where
ε : ⊢ ε
_∙_ : ⊢ Γ
→ Γ ⊢ A
→ ⊢ Γ ∙ A
-- Well-formed type
data _⊢_ (Γ : Con Term n) : Term n → Set where
Uⱼ : ⊢ Γ → Γ ⊢ U
ℕⱼ : ⊢ Γ → Γ ⊢ ℕ
Emptyⱼ : ⊢ Γ → Γ ⊢ Empty
Unitⱼ : ⊢ Γ → Γ ⊢ Unit
Πⱼ_▹_ : Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ Π F ▹ G
Σⱼ_▹_ : Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ Σ F ▹ G
univ : Γ ⊢ A ∷ U
→ Γ ⊢ A
-- Well-formed term of a type
data _⊢_∷_ (Γ : Con Term n) : Term n → Term n → Set where
Πⱼ_▹_ : ∀ {F G}
→ Γ ⊢ F ∷ U
→ Γ ∙ F ⊢ G ∷ U
→ Γ ⊢ Π F ▹ G ∷ U
Σⱼ_▹_ : ∀ {F G}
→ Γ ⊢ F ∷ U
→ Γ ∙ F ⊢ G ∷ U
→ Γ ⊢ Σ F ▹ G ∷ U
ℕⱼ : ⊢ Γ → Γ ⊢ ℕ ∷ U
Emptyⱼ : ⊢ Γ → Γ ⊢ Empty ∷ U
Unitⱼ : ⊢ Γ → Γ ⊢ Unit ∷ U
var : ∀ {A x}
→ ⊢ Γ
→ x ∷ A ∈ Γ
→ Γ ⊢ var x ∷ A
lamⱼ : ∀ {F G t}
→ Γ ⊢ F
→ Γ ∙ F ⊢ t ∷ G
→ Γ ⊢ lam t ∷ Π F ▹ G
_∘ⱼ_ : ∀ {g a F G}
→ Γ ⊢ g ∷ Π F ▹ G
→ Γ ⊢ a ∷ F
→ Γ ⊢ g ∘ a ∷ G [ a ]
prodⱼ : ∀ {F G t u}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ∷ F
→ Γ ⊢ u ∷ G [ t ]
→ Γ ⊢ prod t u ∷ Σ F ▹ G
fstⱼ : ∀ {F G t}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ∷ Σ F ▹ G
→ Γ ⊢ fst t ∷ F
sndⱼ : ∀ {F G t}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ∷ Σ F ▹ G
→ Γ ⊢ snd t ∷ G [ fst t ]
zeroⱼ : ⊢ Γ
→ Γ ⊢ zero ∷ ℕ
sucⱼ : ∀ {n}
→ Γ ⊢ n ∷ ℕ
→ Γ ⊢ suc n ∷ ℕ
natrecⱼ : ∀ {G s z n}
→ Γ ∙ ℕ ⊢ G
→ Γ ⊢ z ∷ G [ zero ]
→ Γ ⊢ s ∷ Π ℕ ▹ (G ▹▹ G [ suc (var x0) ]↑)
→ Γ ⊢ n ∷ ℕ
→ Γ ⊢ natrec G z s n ∷ G [ n ]
Emptyrecⱼ : ∀ {A e}
→ Γ ⊢ A → Γ ⊢ e ∷ Empty → Γ ⊢ Emptyrec A e ∷ A
starⱼ : ⊢ Γ → Γ ⊢ star ∷ Unit
conv : ∀ {t A B}
→ Γ ⊢ t ∷ A
→ Γ ⊢ A ≡ B
→ Γ ⊢ t ∷ B
-- Type equality
data _⊢_≡_ (Γ : Con Term n) : Term n → Term n → Set where
univ : ∀ {A B}
→ Γ ⊢ A ≡ B ∷ U
→ Γ ⊢ A ≡ B
refl : ∀ {A}
→ Γ ⊢ A
→ Γ ⊢ A ≡ A
sym : ∀ {A B}
→ Γ ⊢ A ≡ B
→ Γ ⊢ B ≡ A
trans : ∀ {A B C}
→ Γ ⊢ A ≡ B
→ Γ ⊢ B ≡ C
→ Γ ⊢ A ≡ C
Π-cong : ∀ {F H G E}
→ Γ ⊢ F
→ Γ ⊢ F ≡ H
→ Γ ∙ F ⊢ G ≡ E
→ Γ ⊢ Π F ▹ G ≡ Π H ▹ E
Σ-cong : ∀ {F H G E}
→ Γ ⊢ F
→ Γ ⊢ F ≡ H
→ Γ ∙ F ⊢ G ≡ E
→ Γ ⊢ Σ F ▹ G ≡ Σ H ▹ E
-- Term equality
data _⊢_≡_∷_ (Γ : Con Term n) : Term n → Term n → Term n → Set where
refl : ∀ {t A}
→ Γ ⊢ t ∷ A
→ Γ ⊢ t ≡ t ∷ A
sym : ∀ {t u A}
→ Γ ⊢ t ≡ u ∷ A
→ Γ ⊢ u ≡ t ∷ A
trans : ∀ {t u r A}
→ Γ ⊢ t ≡ u ∷ A
→ Γ ⊢ u ≡ r ∷ A
→ Γ ⊢ t ≡ r ∷ A
conv : ∀ {A B t u}
→ Γ ⊢ t ≡ u ∷ A
→ Γ ⊢ A ≡ B
→ Γ ⊢ t ≡ u ∷ B
Π-cong : ∀ {E F G H}
→ Γ ⊢ F
→ Γ ⊢ F ≡ H ∷ U
→ Γ ∙ F ⊢ G ≡ E ∷ U
→ Γ ⊢ Π F ▹ G ≡ Π H ▹ E ∷ U
Σ-cong : ∀ {E F G H}
→ Γ ⊢ F
→ Γ ⊢ F ≡ H ∷ U
→ Γ ∙ F ⊢ G ≡ E ∷ U
→ Γ ⊢ Σ F ▹ G ≡ Σ H ▹ E ∷ U
app-cong : ∀ {a b f g F G}
→ Γ ⊢ f ≡ g ∷ Π F ▹ G
→ Γ ⊢ a ≡ b ∷ F
→ Γ ⊢ f ∘ a ≡ g ∘ b ∷ G [ a ]
β-red : ∀ {a t F G}
→ Γ ⊢ F
→ Γ ∙ F ⊢ t ∷ G
→ Γ ⊢ a ∷ F
→ Γ ⊢ (lam t) ∘ a ≡ t [ a ] ∷ G [ a ]
η-eq : ∀ {f g F G}
→ Γ ⊢ F
→ Γ ⊢ f ∷ Π F ▹ G
→ Γ ⊢ g ∷ Π F ▹ G
→ Γ ∙ F ⊢ wk1 f ∘ var x0 ≡ wk1 g ∘ var x0 ∷ G
→ Γ ⊢ f ≡ g ∷ Π F ▹ G
fst-cong : ∀ {t t' F G}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ≡ t' ∷ Σ F ▹ G
→ Γ ⊢ fst t ≡ fst t' ∷ F
snd-cong : ∀ {t t' F G}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ≡ t' ∷ Σ F ▹ G
→ Γ ⊢ snd t ≡ snd t' ∷ G [ fst t ]
Σ-β₁ : ∀ {F G t u}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ∷ F
→ Γ ⊢ u ∷ G [ t ]
→ Γ ⊢ fst (prod t u) ≡ t ∷ F
Σ-β₂ : ∀ {F G t u}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ∷ F
→ Γ ⊢ u ∷ G [ t ]
→ Γ ⊢ snd (prod t u) ≡ u ∷ G [ fst (prod t u) ]
Σ-η : ∀ {p r F G}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ p ∷ Σ F ▹ G
→ Γ ⊢ r ∷ Σ F ▹ G
→ Γ ⊢ fst p ≡ fst r ∷ F
→ Γ ⊢ snd p ≡ snd r ∷ G [ fst p ]
→ Γ ⊢ p ≡ r ∷ Σ F ▹ G
suc-cong : ∀ {m n}
→ Γ ⊢ m ≡ n ∷ ℕ
→ Γ ⊢ suc m ≡ suc n ∷ ℕ
natrec-cong : ∀ {z z′ s s′ n n′ F F′}
→ Γ ∙ ℕ ⊢ F ≡ F′
→ Γ ⊢ z ≡ z′ ∷ F [ zero ]
→ Γ ⊢ s ≡ s′ ∷ Π ℕ ▹ (F ▹▹ F [ suc (var x0) ]↑)
→ Γ ⊢ n ≡ n′ ∷ ℕ
→ Γ ⊢ natrec F z s n ≡ natrec F′ z′ s′ n′ ∷ F [ n ]
natrec-zero : ∀ {z s F}
→ Γ ∙ ℕ ⊢ F
→ Γ ⊢ z ∷ F [ zero ]
→ Γ ⊢ s ∷ Π ℕ ▹ (F ▹▹ F [ suc (var x0) ]↑)
→ Γ ⊢ natrec F z s zero ≡ z ∷ F [ zero ]
natrec-suc : ∀ {n z s F}
→ Γ ⊢ n ∷ ℕ
→ Γ ∙ ℕ ⊢ F
→ Γ ⊢ z ∷ F [ zero ]
→ Γ ⊢ s ∷ Π ℕ ▹ (F ▹▹ F [ suc (var x0) ]↑)
→ Γ ⊢ natrec F z s (suc n) ≡ (s ∘ n) ∘ (natrec F z s n)
∷ F [ suc n ]
Emptyrec-cong : ∀ {A A' e e'}
→ Γ ⊢ A ≡ A'
→ Γ ⊢ e ≡ e' ∷ Empty
→ Γ ⊢ Emptyrec A e ≡ Emptyrec A' e' ∷ A
η-unit : ∀ {e e'}
→ Γ ⊢ e ∷ Unit
→ Γ ⊢ e' ∷ Unit
→ Γ ⊢ e ≡ e' ∷ Unit
-- Term reduction
data _⊢_⇒_∷_ (Γ : Con Term n) : Term n → Term n → Term n → Set where
conv : ∀ {A B t u}
→ Γ ⊢ t ⇒ u ∷ A
→ Γ ⊢ A ≡ B
→ Γ ⊢ t ⇒ u ∷ B
app-subst : ∀ {A B t u a}
→ Γ ⊢ t ⇒ u ∷ Π A ▹ B
→ Γ ⊢ a ∷ A
→ Γ ⊢ t ∘ a ⇒ u ∘ a ∷ B [ a ]
β-red : ∀ {A B a t}
→ Γ ⊢ A
→ Γ ∙ A ⊢ t ∷ B
→ Γ ⊢ a ∷ A
→ Γ ⊢ (lam t) ∘ a ⇒ t [ a ] ∷ B [ a ]
fst-subst : ∀ {t t' F G}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ⇒ t' ∷ Σ F ▹ G
→ Γ ⊢ fst t ⇒ fst t' ∷ F
snd-subst : ∀ {t t' F G}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ⇒ t' ∷ Σ F ▹ G
→ Γ ⊢ snd t ⇒ snd t' ∷ G [ fst t ]
Σ-β₁ : ∀ {F G t u}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ∷ F
→ Γ ⊢ u ∷ G [ t ]
→ Γ ⊢ fst (prod t u) ⇒ t ∷ F
Σ-β₂ : ∀ {F G t u}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ t ∷ F
→ Γ ⊢ u ∷ G [ t ]
-- TODO(WN): Prove that 𝔍 ∷ G [ t ] is admissible
→ Γ ⊢ snd (prod t u) ⇒ u ∷ G [ fst (prod t u) ]
natrec-subst : ∀ {z s n n′ F}
→ Γ ∙ ℕ ⊢ F
→ Γ ⊢ z ∷ F [ zero ]
→ Γ ⊢ s ∷ Π ℕ ▹ (F ▹▹ F [ suc (var x0) ]↑)
→ Γ ⊢ n ⇒ n′ ∷ ℕ
→ Γ ⊢ natrec F z s n ⇒ natrec F z s n′ ∷ F [ n ]
natrec-zero : ∀ {z s F}
→ Γ ∙ ℕ ⊢ F
→ Γ ⊢ z ∷ F [ zero ]
→ Γ ⊢ s ∷ Π ℕ ▹ (F ▹▹ F [ suc (var x0) ]↑)
→ Γ ⊢ natrec F z s zero ⇒ z ∷ F [ zero ]
natrec-suc : ∀ {n z s F}
→ Γ ⊢ n ∷ ℕ
→ Γ ∙ ℕ ⊢ F
→ Γ ⊢ z ∷ F [ zero ]
→ Γ ⊢ s ∷ Π ℕ ▹ (F ▹▹ F [ suc (var x0) ]↑)
→ Γ ⊢ natrec F z s (suc n) ⇒ (s ∘ n) ∘ (natrec F z s n) ∷ F [ suc n ]
Emptyrec-subst : ∀ {n n′ A}
→ Γ ⊢ A
→ Γ ⊢ n ⇒ n′ ∷ Empty
→ Γ ⊢ Emptyrec A n ⇒ Emptyrec A n′ ∷ A
-- Type reduction
data _⊢_⇒_ (Γ : Con Term n) : Term n → Term n → Set where
univ : ∀ {A B}
→ Γ ⊢ A ⇒ B ∷ U
→ Γ ⊢ A ⇒ B
-- Term reduction closure
data _⊢_⇒*_∷_ (Γ : Con Term n) : Term n → Term n → Term n → Set where
id : ∀ {A t}
→ Γ ⊢ t ∷ A
→ Γ ⊢ t ⇒* t ∷ A
_⇨_ : ∀ {A t t′ u}
→ Γ ⊢ t ⇒ t′ ∷ A
→ Γ ⊢ t′ ⇒* u ∷ A
→ Γ ⊢ t ⇒* u ∷ A
-- Type reduction closure
data _⊢_⇒*_ (Γ : Con Term n) : Term n → Term n → Set where
id : ∀ {A}
→ Γ ⊢ A
→ Γ ⊢ A ⇒* A
_⇨_ : ∀ {A A′ B}
→ Γ ⊢ A ⇒ A′
→ Γ ⊢ A′ ⇒* B
→ Γ ⊢ A ⇒* B
-- Type reduction to whnf
_⊢_↘_ : (Γ : Con Term n) → Term n → Term n → Set
Γ ⊢ A ↘ B = Γ ⊢ A ⇒* B × Whnf B
-- Term reduction to whnf
_⊢_↘_∷_ : (Γ : Con Term n) → Term n → Term n → Term n → Set
Γ ⊢ t ↘ u ∷ A = Γ ⊢ t ⇒* u ∷ A × Whnf u
-- Type eqaulity with well-formed types
_⊢_:≡:_ : (Γ : Con Term n) → Term n → Term n → Set
Γ ⊢ A :≡: B = Γ ⊢ A × Γ ⊢ B × (Γ ⊢ A ≡ B)
-- Term equality with well-formed terms
_⊢_:≡:_∷_ : (Γ : Con Term n) → Term n → Term n → Term n → Set
Γ ⊢ t :≡: u ∷ A = (Γ ⊢ t ∷ A) × (Γ ⊢ u ∷ A) × (Γ ⊢ t ≡ u ∷ A)
-- Type reduction closure with well-formed types
record _⊢_:⇒*:_ (Γ : Con Term n) (A B : Term n) : Set where
constructor [_,_,_]
field
⊢A : Γ ⊢ A
⊢B : Γ ⊢ B
D : Γ ⊢ A ⇒* B
open _⊢_:⇒*:_ using () renaming (D to red; ⊢A to ⊢A-red; ⊢B to ⊢B-red) public
-- Term reduction closure with well-formed terms
record _⊢_:⇒*:_∷_ (Γ : Con Term n) (t u A : Term n) : Set where
constructor [_,_,_]
field
⊢t : Γ ⊢ t ∷ A
⊢u : Γ ⊢ u ∷ A
d : Γ ⊢ t ⇒* u ∷ A
open _⊢_:⇒*:_∷_ using () renaming (d to redₜ; ⊢t to ⊢t-redₜ; ⊢u to ⊢u-redₜ) public
-- Well-formed substitutions.
data _⊢ˢ_∷_ (Δ : Con Term m) : (σ : Subst m n) (Γ : Con Term n) → Set where
id : ∀ {σ} → Δ ⊢ˢ σ ∷ ε
_,_ : ∀ {A σ}
→ Δ ⊢ˢ tail σ ∷ Γ
→ Δ ⊢ head σ ∷ subst (tail σ) A
→ Δ ⊢ˢ σ ∷ Γ ∙ A
-- Conversion of well-formed substitutions.
data _⊢ˢ_≡_∷_ (Δ : Con Term m) : (σ σ′ : Subst m n) (Γ : Con Term n) → Set where
id : ∀ {σ σ′} → Δ ⊢ˢ σ ≡ σ′ ∷ ε
_,_ : ∀ {A σ σ′}
→ Δ ⊢ˢ tail σ ≡ tail σ′ ∷ Γ
→ Δ ⊢ head σ ≡ head σ′ ∷ subst (tail σ) A
→ Δ ⊢ˢ σ ≡ σ′ ∷ Γ ∙ A
-- Note that we cannot use the well-formed substitutions.
-- For that, we need to prove the fundamental theorem for substitutions.
⟦_⟧ⱼ_▹_ : (W : BindingType) → ∀ {F G}
→ Γ ⊢ F
→ Γ ∙ F ⊢ G
→ Γ ⊢ ⟦ W ⟧ F ▹ G
⟦ BΠ ⟧ⱼ ⊢F ▹ ⊢G = Πⱼ ⊢F ▹ ⊢G
⟦ BΣ ⟧ⱼ ⊢F ▹ ⊢G = Σⱼ ⊢F ▹ ⊢G
⟦_⟧ⱼᵤ_▹_ : (W : BindingType) → ∀ {F G}
→ Γ ⊢ F ∷ U
→ Γ ∙ F ⊢ G ∷ U
→ Γ ⊢ ⟦ W ⟧ F ▹ G ∷ U
⟦ BΠ ⟧ⱼᵤ ⊢F ▹ ⊢G = Πⱼ ⊢F ▹ ⊢G
⟦ BΣ ⟧ⱼᵤ ⊢F ▹ ⊢G = Σⱼ ⊢F ▹ ⊢G
| {
"alphanum_fraction": 0.2857257611,
"avg_line_length": 30.9676616915,
"ext": "agda",
"hexsha": "4b7a71fadcf7db3e1a1bd90d432683f7d08559bb",
"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": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "fhlkfy/logrel-mltt",
"max_forks_repo_path": "Definition/Typed.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"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": "fhlkfy/logrel-mltt",
"max_issues_repo_path": "Definition/Typed.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "fhlkfy/logrel-mltt",
"max_stars_repo_path": "Definition/Typed.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5318,
"size": 12449
} |
-- Binary coproducts
{-# OPTIONS --safe #-}
module Cubical.Categories.Limits.BinCoproduct where
open import Cubical.Categories.Category.Base
open import Cubical.Data.Sigma.Base
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Prelude
open import Cubical.HITs.PropositionalTruncation.Base
private
variable
ℓ ℓ' : Level
module _ (C : Category ℓ ℓ') where
open Category C
module _ {x y x+y : ob}
(i₁ : Hom[ x , x+y ])
(i₂ : Hom[ y , x+y ]) where
isBinCoproduct : Type (ℓ-max ℓ ℓ')
isBinCoproduct = ∀ {z : ob} (f₁ : Hom[ x , z ]) (f₂ : Hom[ y , z ]) →
∃![ f ∈ Hom[ x+y , z ] ] (i₁ ⋆ f ≡ f₁) × (i₂ ⋆ f ≡ f₂)
isPropIsBinCoproduct : isProp (isBinCoproduct)
isPropIsBinCoproduct = isPropImplicitΠ (λ _ → isPropΠ2 (λ _ _ → isPropIsContr))
record BinCoproduct (x y : ob) : Type (ℓ-max ℓ ℓ') where
field
binCoprodOb : ob
binCoprodInj₁ : Hom[ x , binCoprodOb ]
binCoprodInj₂ : Hom[ y , binCoprodOb ]
univProp : isBinCoproduct binCoprodInj₁ binCoprodInj₂
BinCoproducts : Type (ℓ-max ℓ ℓ')
BinCoproducts = (x y : ob) → BinCoproduct x y
hasBinCoproducts : Type (ℓ-max ℓ ℓ')
hasBinCoproducts = ∥ BinCoproducts ∥₁
| {
"alphanum_fraction": 0.647634584,
"avg_line_length": 27.8636363636,
"ext": "agda",
"hexsha": "68e65661fa100a709e5e93e6c9625c859a8752e4",
"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/Limits/BinCoproduct.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/Limits/BinCoproduct.agda",
"max_line_length": 83,
"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/Limits/BinCoproduct.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": 456,
"size": 1226
} |
{-# OPTIONS --without-K --safe #-}
-- Some properties of Restriction Categories
-- The first few lemmas are from Cocket & Lack, Lemma 2.1 and 2.2
module Categories.Category.Restriction.Properties where
open import Data.Product using (Σ; _,_)
open import Level using (Level; _⊔_)
open import Categories.Category.Core using (Category)
open import Categories.Category.Restriction using (Restriction)
open import Categories.Category.SubCategory
open import Categories.Morphism using (Mono)
open import Categories.Morphism.Idempotent using (Idempotent)
open import Categories.Morphism.Properties using (Mono-id)
import Categories.Morphism.Reasoning as MR
module _ {o ℓ e : Level} {𝒞 : Category o ℓ e} (R : Restriction 𝒞) where
open Category 𝒞
open Restriction R
open HomReasoning
open MR 𝒞 using (elimˡ; introʳ)
private
variable
A B C : Obj
f : A ⇒ B
g : B ⇒ C
↓f-idempotent : (A ⇒ B) → Idempotent 𝒞 A
↓f-idempotent f = record { idem = f ↓ ; idempotent = ⟺ ↓-denestʳ ○ ↓-cong pidʳ }
-- a special version of ↓ being a partial left identity
↓-pidˡ-gf : f ↓ ∘ (g ∘ f) ↓ ≈ (g ∘ f) ↓
↓-pidˡ-gf {f = f} {g = g} = begin
f ↓ ∘ (g ∘ f) ↓ ≈⟨ ↓-comm ⟩
(g ∘ f) ↓ ∘ f ↓ ≈˘⟨ ↓-denestʳ ⟩
((g ∘ f) ∘ f ↓) ↓ ≈⟨ ↓-cong assoc ⟩
(g ∘ (f ∘ f ↓)) ↓ ≈⟨ ↓-cong (∘-resp-≈ʳ pidʳ) ⟩
(g ∘ f) ↓ ∎
-- left denesting looks different in its conclusion
↓-denestˡ : (g ↓ ∘ f) ↓ ≈ (g ∘ f) ↓
↓-denestˡ {g = g} {f = f} = begin
(g ↓ ∘ f) ↓ ≈⟨ ↓-cong ↓-skew-comm ⟩
(f ∘ (g ∘ f) ↓) ↓ ≈⟨ ↓-denestʳ ⟩
f ↓ ∘ (g ∘ f) ↓ ≈⟨ ↓-pidˡ-gf ⟩
(g ∘ f) ↓ ∎
↓-idempotent : f ↓ ↓ ≈ f ↓
↓-idempotent {f = f} = begin
f ↓ ↓ ≈˘⟨ ↓-cong identityʳ ⟩
(f ↓ ∘ id) ↓ ≈⟨ ↓-denestˡ ⟩
(f ∘ id) ↓ ≈⟨ ↓-cong identityʳ ⟩
f ↓ ∎
↓↓denest : (g ↓ ∘ f ↓) ↓ ≈ g ↓ ∘ f ↓
↓↓denest {g = g} {f = f} = begin
(g ↓ ∘ f ↓) ↓ ≈⟨ ↓-denestʳ ⟩
g ↓ ↓ ∘ f ↓ ≈⟨ (↓-idempotent ⟩∘⟨refl) ⟩
g ↓ ∘ f ↓ ∎
Mono⇒f↓≈id : Mono 𝒞 f → f ↓ ≈ id
Mono⇒f↓≈id {f = f} mono = mono (f ↓) id (pidʳ ○ ⟺ identityʳ)
-- if the domain of g is at least that of f, then the restriction coincides
↓⊃⇒≈ : f ∘ g ↓ ≈ f → f ↓ ≈ f ↓ ∘ g ↓
↓⊃⇒≈ {f = f} {g = g} fg↓≈f = ⟺ (↓-cong fg↓≈f) ○ ↓-denestʳ
Mono⇒Total : Mono 𝒞 f → total f
Mono⇒Total = Mono⇒f↓≈id
∘-pres-total : {A B C : Obj} {f : B ⇒ C} {g : A ⇒ B} → total f → total g → total (f ∘ g)
∘-pres-total {f = f} {g = g} tf tg = begin
(f ∘ g) ↓ ≈˘⟨ ↓-denestˡ ⟩
(f ↓ ∘ g) ↓ ≈⟨ ↓-cong (elimˡ tf) ⟩
g ↓ ≈⟨ tg ⟩
id ∎
total-gf⇒total-f : total (g ∘ f) → total f
total-gf⇒total-f {g = g} {f = f} tgf = begin
f ↓ ≈⟨ introʳ tgf ⟩
f ↓ ∘ (g ∘ f) ↓ ≈⟨ ↓-pidˡ-gf ⟩
(g ∘ f) ↓ ≈⟨ tgf ⟩
id ∎
total-SubCat : SubCat 𝒞 Obj
total-SubCat = record
{ U = λ x → x
; R = total
; Rid = Mono⇒Total (Mono-id 𝒞)
; _∘R_ = ∘-pres-total
}
Total : Category o (ℓ ⊔ e) e
Total = SubCategory 𝒞 total-SubCat
| {
"alphanum_fraction": 0.5155987924,
"avg_line_length": 30.4183673469,
"ext": "agda",
"hexsha": "fd01c8ac1b18aaa6b7c8902a982753e94e1a8a1a",
"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/Restriction/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/Category/Restriction/Properties.agda",
"max_line_length": 90,
"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/Restriction/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": 1367,
"size": 2981
} |
------------------------------------------------------------------------
-- Lemmas about the initial bag index
------------------------------------------------------------------------
module TotalParserCombinators.InitialBag where
open import Category.Monad
open import Data.List
import Data.List.Categorical
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Membership.Propositional.Properties as M
hiding (⊛-∈↔)
open import Data.List.Relation.Binary.BagAndSetEquality
using () renaming (_∼[_]_ to _List-∼[_]_)
open import Data.List.Relation.Unary.Any
open import Data.List.Relation.Unary.Any.Properties
open import Data.Maybe hiding (_>>=_)
open import Data.Product
open import Data.Sum
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Inverse as Inv using (_↔_)
import Function.Related as Related
open import Level
open import Relation.Binary.PropositionalEquality as P
using (_≡_; refl)
open import Relation.Binary.HeterogeneousEquality as H
using (refl) renaming (_≅_ to _≅′_)
open Inv.Inverse
open RawMonadPlus {f = zero} Data.List.Categorical.monadPlus
using () renaming (_⊛_ to _⊛′_)
open Related using (SK-sym)
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics
------------------------------------------------------------------------
-- Optimisation
private
abstract
⊛-∈↔ : ∀ {A B : Set} (fs : List (A → B)) {xs y} →
(∃₂ λ f x → f ∈ fs × x ∈ xs × y ≡ f x) ↔ y ∈ (fs ⊛′ xs)
⊛-∈↔ = M.⊛-∈↔
------------------------------------------------------------------------
-- Sanity check: The initial set index is correctly defined
mutual
complete : ∀ {Tok R xs x} {p : Parser Tok R xs} →
x ∈ p · [] → x ∈ xs
complete x∈p = complete′ x∈p refl
private
complete′ : ∀ {Tok R xs x s} {p : Parser Tok R xs} →
x ∈ p · s → s ≡ [] → x ∈ xs
complete′ return refl = to return↔ ⟨$⟩ refl
complete′ (∣-left x∈p₁) refl = to ++↔ ⟨$⟩ inj₁ (complete x∈p₁)
complete′ (∣-right xs₁ x∈p₂) refl = to (++↔ {P = _≡_ _}
{xs = xs₁}) ⟨$⟩ inj₂ (complete x∈p₂)
complete′ (<$> x∈p) refl = to (map-∈↔ _) ⟨$⟩ (_ , complete x∈p , refl)
complete′ (_⊛_ {s₁ = []} {xs = just _} f∈p₁ x∈p₂) refl = to (⊛-∈↔ _) ⟨$⟩ (_ , _ , complete f∈p₁
, complete x∈p₂ , refl)
complete′ (_>>=_ {s₁ = []} {xs = just xs} {f = just _} x∈p₁ y∈p₂x) refl = to (>>=-∈↔ {xs = xs}) ⟨$⟩ (_ , complete x∈p₁
, complete y∈p₂x)
complete′ (cast {xs₁≈xs₂ = xs₁≈xs₂} x∈p) refl = to xs₁≈xs₂ ⟨$⟩ complete x∈p
complete′ (_⊛_ {s₁ = []} {xs = nothing} f∈p₁ x∈p₂) refl with complete x∈p₂
... | ()
complete′ (_>>=_ {s₁ = []} {xs = nothing} x∈p₁ y∈p₂x) refl with complete x∈p₁
... | ()
complete′ (_>>=_ {s₁ = []} {xs = just _} {f = nothing} x∈p₁ y∈p₂x) refl with complete y∈p₂x
... | ()
complete′ token ()
complete′ (_⊛_ {s₁ = _ ∷ _} _ _) ()
complete′ (_>>=_ {s₁ = _ ∷ _} _ _) ()
complete′ (nonempty _) ()
mutual
sound : ∀ {Tok R xs x} (p : Parser Tok R xs) →
x ∈ xs → x ∈ p · []
sound (return x) (here refl) = return
sound (_∣_ {xs₁ = xs₁} p₁ p₂) x∈xs with from (++↔ {P = _≡_ _} {xs = xs₁}) ⟨$⟩ x∈xs
... | inj₁ x∈xs₁ = ∣-left (sound p₁ x∈xs₁)
... | inj₂ x∈xs₂ = ∣-right xs₁ (sound p₂ x∈xs₂)
sound (f <$> p) x∈xs with from (map-∈↔ f) ⟨$⟩ x∈xs
... | (y , y∈xs , refl) = <$> sound p y∈xs
sound (_⊛_ {fs = fs} {just xs} p₁ p₂) y∈ys
with from (⊛-∈↔ (flatten fs) {xs = xs}) ⟨$⟩ y∈ys
sound (_⊛_ {fs = nothing} {just xs} p₁ p₂) y∈ys | (f′ , x′ , () , x′∈xs , refl)
sound (_⊛_ {fs = just fs} {just xs} p₁ p₂) y∈ys | (f′ , x′ , f′∈fs , x′∈xs , refl) =
_⊛_ {fs = ○} {xs = ○} (sound p₁ f′∈fs) (sound p₂ x′∈xs)
sound (_>>=_ {xs = zs} {f = just f} p₁ p₂) y∈ys
with from (>>=-∈↔ {xs = flatten zs} {f = f}) ⟨$⟩ y∈ys
... | (x , x∈zs , y∈fx) =
_>>=_ {xs = zs} {f = just f} (sound p₁ x∈zs) (sound′ (p₂ x) x∈zs y∈fx)
sound (cast xs₁≈xs₂ p) x∈xs = cast (sound p (from xs₁≈xs₂ ⟨$⟩ x∈xs))
sound (return _) (there ())
sound fail ()
sound token ()
sound (_⊛_ {xs = nothing} _ _) ()
sound (_>>=_ {f = nothing} _ _) ()
sound (nonempty _) ()
private
sound′ : ∀ {Tok R₁ R₂ x y xs} {zs : Maybe (List R₁)}
(p : ∞⟨ zs ⟩Parser Tok R₂ xs) →
x ∈ flatten zs → y ∈ xs → y ∈ ♭? p · []
sound′ {zs = just _} p _ = sound p
sound′ {zs = nothing} p ()
mutual
sound∘complete : ∀ {Tok R xs x} {p : Parser Tok R xs}
(x∈p : x ∈ p · []) →
sound p (complete x∈p) ≡ x∈p
sound∘complete x∈p = H.≅-to-≡ (sound∘complete′ x∈p refl)
private
sound∘complete′ : ∀ {Tok R xs x s} {p : Parser Tok R xs}
(x∈p : x ∈ p · s) (s≡[] : s ≡ []) →
sound p (complete′ x∈p s≡[]) ≅′ x∈p
sound∘complete′ return refl = refl
sound∘complete′ (∣-left {xs₁ = xs₁} {xs₂ = xs₂} x∈p₁) refl
rewrite left-inverse-of (++↔ {P = _≡_ _} {xs = xs₁} {ys = xs₂}) (inj₁ (complete x∈p₁)) =
H.cong _∈_·_.∣-left (sound∘complete′ x∈p₁ refl)
sound∘complete′ (∣-right xs₁ x∈p₂) refl
rewrite left-inverse-of (++↔ {P = _≡_ _} {xs = xs₁}) (inj₂ (complete x∈p₂)) =
H.cong (_∈_·_.∣-right xs₁) (sound∘complete′ x∈p₂ refl)
sound∘complete′ (<$>_ {f = f} x∈p) refl
rewrite left-inverse-of (map-∈↔ f) (_ , complete x∈p , refl) =
H.cong _∈_·_.<$>_ (sound∘complete′ x∈p refl)
sound∘complete′ (_⊛_ {s₁ = []} {fs = fs} {xs = just xs} f∈p₁ x∈p₂) refl
with complete f∈p₁ | complete x∈p₂
| from inv ⟨$⟩ (to inv ⟨$⟩ (_ , _ , complete f∈p₁ , complete x∈p₂ , refl))
| left-inverse-of inv (_ , _ , complete f∈p₁ , complete x∈p₂ , refl)
| sound∘complete f∈p₁ | sound∘complete x∈p₂
where inv = ⊛-∈↔ (flatten fs) {xs = xs}
sound∘complete′ (_⊛_ {s₁ = []} {fs = nothing} {xs = just xs} _ _) refl | () | _ | _ | _ | _ | _
sound∘complete′ (_⊛_ {s₁ = []} {fs = just fs} {xs = just xs} {p₁ = p₁} {p₂ = p₂}
.(sound p₁ ∈fs) .(sound p₂ ∈xs)) refl
| ∈fs | ∈xs | ._ | refl | refl | refl = refl
sound∘complete′ (_>>=_ {x = x} {y = y} {s₁ = []} {xs = just _} {f = just f} {p₁ = p₁} {p₂ = p₂} x∈p₁ y∈p₂x) refl
rewrite left-inverse-of (>>=-∈↔ {f = f}) (_ , complete x∈p₁ , complete y∈p₂x)
with sound p₁ (complete x∈p₁)
| sound∘complete x∈p₁
| sound′ (p₂ x) (complete x∈p₁) (complete y∈p₂x)
| helper (p₂ x) (complete x∈p₁) y∈p₂x
where
helper : ∀ {Tok R₁ R₂ x y ys} {xs : Maybe (List R₁)}
(p : ∞⟨ xs ⟩Parser Tok R₂ ys) →
(x∈xs : x ∈ flatten xs) (y∈p : y ∈ ♭? p · []) →
sound′ p x∈xs (complete y∈p) ≡ y∈p
helper {xs = nothing} p () _
helper {xs = just _} p _ y∈p = sound∘complete y∈p
... | ._ | refl | ._ | refl = refl
sound∘complete′ (cast {xs₁≈xs₂ = xs₁≈xs₂} x∈p) refl with complete x∈p | sound∘complete x∈p
sound∘complete′ (cast {xs₁≈xs₂ = xs₁≈xs₂} .(sound _ x∈xs)) refl | x∈xs | refl
rewrite left-inverse-of xs₁≈xs₂ x∈xs = refl
sound∘complete′ (_⊛_ {s₁ = []} {xs = nothing} _ x∈p₂) refl with complete x∈p₂
... | ()
sound∘complete′ (_>>=_ {s₁ = []} {xs = nothing} x∈p₁ y∈p₂x) refl with complete x∈p₁
... | ()
sound∘complete′ (_>>=_ {s₁ = []} {xs = just _} {f = nothing} x∈p₁ y∈p₂x) refl with complete y∈p₂x
... | ()
sound∘complete′ token ()
sound∘complete′ (_⊛_ {s₁ = _ ∷ _} _ _) ()
sound∘complete′ (_>>=_ {s₁ = _ ∷ _} _ _) ()
sound∘complete′ (nonempty _) ()
complete∘sound : ∀ {Tok R xs x}
(p : Parser Tok R xs) (x∈p : x ∈ xs) →
complete (sound p x∈p) ≡ x∈p
complete∘sound (return x) (here refl) = refl
complete∘sound (_∣_ {xs₁ = xs₁} p₁ p₂) x∈xs
with from (++↔ {P = _≡_ _} {xs = xs₁}) ⟨$⟩ x∈xs
| right-inverse-of (++↔ {P = _≡_ _} {xs = xs₁}) x∈xs
complete∘sound (_∣_ {xs₁ = xs₁} p₁ p₂) .(to ++↔ ⟨$⟩ inj₁ x∈xs₁) | inj₁ x∈xs₁ | refl =
P.cong (_⟨$⟩_ (to ++↔) ∘ inj₁) $ complete∘sound p₁ x∈xs₁
complete∘sound (_∣_ {xs₁ = xs₁} p₁ p₂) .(to (++↔ {P = _≡_ _} {xs = xs₁}) ⟨$⟩ inj₂ x∈xs₂) | inj₂ x∈xs₂ | refl =
P.cong (_⟨$⟩_ (to (++↔ {P = _≡_ _} {xs = xs₁})) ∘ inj₂) $ complete∘sound p₂ x∈xs₂
complete∘sound (f <$> p) x∈xs
with from (map-∈↔ f) ⟨$⟩ x∈xs
| right-inverse-of (map-∈↔ f) x∈xs
complete∘sound (f <$> p) .(to (map-∈↔ f) ⟨$⟩ (y , y∈xs , refl)) | (y , y∈xs , refl) | refl =
P.cong (λ y∈ → to (map-∈↔ _) ⟨$⟩ (y , y∈ , refl))
(complete∘sound p y∈xs)
complete∘sound (_⊛_ {fs = fs} {just xs} p₁ p₂) y∈ys
with from (⊛-∈↔ (flatten fs) {xs = xs}) ⟨$⟩ y∈ys
| right-inverse-of (⊛-∈↔ (flatten fs) {xs = xs}) y∈ys
complete∘sound (_⊛_ {fs = nothing} {xs = just xs} p₁ p₂)
y∈ys | (f′ , x′ , () , x′∈xs , refl) | _
complete∘sound (_⊛_ {fs = just fs} {xs = just xs} p₁ p₂)
.(to (⊛-∈↔ _) ⟨$⟩ (f′ , x′ , f′∈fs , x′∈xs , refl)) | (f′ , x′ , f′∈fs , x′∈xs , refl) | refl =
P.cong₂ (λ f′∈ x′∈ → to (⊛-∈↔ _) ⟨$⟩ (f′ , x′ , f′∈ , x′∈ , refl))
(complete∘sound p₁ f′∈fs)
(complete∘sound p₂ x′∈xs)
complete∘sound (_>>=_ {xs = zs} {just f} p₁ p₂) y∈ys
with from (>>=-∈↔ {xs = flatten zs} {f = f}) ⟨$⟩ y∈ys
| right-inverse-of (>>=-∈↔ {xs = flatten zs} {f = f}) y∈ys
complete∘sound (_>>=_ {xs = nothing} {just f} p₁ p₂) ._ | (x , () , y∈fx) | refl
complete∘sound (_>>=_ {xs = just zs} {just f} p₁ p₂) .(to (>>=-∈↔ {f = f}) ⟨$⟩ (x , x∈zs , y∈fx)) | (x , x∈zs , y∈fx) | refl =
P.cong₂ (λ x∈ y∈ → to (>>=-∈↔ {f = f}) ⟨$⟩ (x , x∈ , y∈))
(complete∘sound p₁ x∈zs)
(complete∘sound (p₂ x) y∈fx)
complete∘sound (cast xs₁≈xs₂ p) x∈xs
rewrite complete∘sound p (from xs₁≈xs₂ ⟨$⟩ x∈xs) =
right-inverse-of xs₁≈xs₂ x∈xs
complete∘sound (return _) (there ())
complete∘sound fail ()
complete∘sound token ()
complete∘sound (_⊛_ {xs = nothing} _ _) ()
complete∘sound (_>>=_ {f = nothing} _ _) ()
complete∘sound (nonempty _) ()
correct : ∀ {Tok R xs x} {p : Parser Tok R xs} → x ∈ p · [] ↔ x ∈ xs
correct {p = p} = record
{ to = P.→-to-⟶ complete
; from = P.→-to-⟶ $ sound p
; inverse-of = record
{ left-inverse-of = sound∘complete
; right-inverse-of = complete∘sound p
}
}
------------------------------------------------------------------------
-- Equal parsers have equal initial bags/sets
-- Note that this property holds also for the subbag and subset
-- relations.
cong : ∀ {k Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} →
p₁ ∼[ k ] p₂ → initial-bag p₁ List-∼[ k ] initial-bag p₂
cong {xs₁ = xs₁} {xs₂} {p₁} {p₂} p₁≈p₂ {x} =
(x ∈ xs₁) ↔⟨ SK-sym correct ⟩
x ∈ p₁ · [] ∼⟨ p₁≈p₂ ⟩
x ∈ p₂ · [] ↔⟨ correct ⟩
(x ∈ xs₂) ∎
where open Related.EquationalReasoning
| {
"alphanum_fraction": 0.4595206168,
"avg_line_length": 46.9763779528,
"ext": "agda",
"hexsha": "bb5a74737446a6719f2012f5a240af7ece7e99d2",
"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": "TotalParserCombinators/InitialBag.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"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/parser-combinators",
"max_issues_repo_path": "TotalParserCombinators/InitialBag.agda",
"max_line_length": 135,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalParserCombinators/InitialBag.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 4555,
"size": 11932
} |
-- 2012-03-16 Andreas, fixing shift/reduce conflict introduced by record update
module Issue549 where
record M.R { A } : Set where
-- gives: Not a valid identifier M.R
-- If you remove the A, you get: Not a valid pattern
-- since then it is parsed as a record update expression
| {
"alphanum_fraction": 0.7392857143,
"avg_line_length": 31.1111111111,
"ext": "agda",
"hexsha": "6f1e32e1159f91391a3483f8c447dae515784bcd",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue549.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue549.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/Fail/Issue549.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": 72,
"size": 280
} |
open import Spire.Type
module Spire.Denotational where
----------------------------------------------------------------------
data Term : Set → Set₁
eval : {A : Set} → Term A → A
----------------------------------------------------------------------
data Term where
{- Type introduction -}
`⊥ `⊤ `Bool `ℕ `Desc `Type : ∀{ℓ} → Term (Type ℓ)
`Π `Σ : ∀{ℓ}
(A : Term (Type ℓ))
(B : ⟦ ℓ ∣ eval A ⟧ → Term (Type ℓ))
→ Term (Type ℓ)
`⟦_⟧ : ∀{ℓ}
(A : Term (Type ℓ))
→ Term (Type (suc ℓ))
`⟦_⟧ᵈ : ∀{ℓ}
(D : Term (Desc ℓ))
(X : Term (Type ℓ))
→ Term (Type ℓ)
`μ : ∀{ℓ}
(D : Term (Desc ℓ))
→ Term (Type ℓ)
{- Type elimination -}
`elimType : ∀{ℓ}
(P : (n : ℕ) → Type n → Term (Type ℓ))
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `⊥) ⟧)
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `⊤) ⟧)
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `Bool) ⟧)
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `ℕ) ⟧)
→ ((n : ℕ) (A : Type n) (B : ⟦ n ∣ A ⟧ → Type n)
(rec₁ : ⟦ ℓ ∣ eval (P n A) ⟧)
(rec₂ : (a : ⟦ n ∣ A ⟧) → ⟦ ℓ ∣ eval (P n (B a)) ⟧)
→ Term ⟦ ℓ ∣ eval (P n (`Π A B)) ⟧)
→ ((n : ℕ) (A : Type n) (B : ⟦ n ∣ A ⟧ → Type n)
(rec₁ : ⟦ ℓ ∣ eval (P n A) ⟧)
(rec₂ : (a : ⟦ n ∣ A ⟧) → ⟦ ℓ ∣ eval (P n (B a)) ⟧)
→ Term ⟦ ℓ ∣ eval (P n (`Σ A B)) ⟧)
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `Desc) ⟧)
→ ((n : ℕ) (D : Desc n) (X : Type n)
(rec : ⟦ ℓ ∣ eval (P n X) ⟧)
→ Term ⟦ ℓ ∣ eval (P n (`⟦ D ⟧ᵈ X)) ⟧)
→ ((n : ℕ) (D : Desc n) → Term ⟦ ℓ ∣ eval (P n (`μ D)) ⟧)
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `Type) ⟧)
→ ((n : ℕ) (A : Type n)
(rec : ⟦ ℓ ∣ eval (P n A) ⟧)
→ Term ⟦ ℓ ∣ eval (P (suc n) `⟦ A ⟧) ⟧)
→ (n : Term ℕ)
(A : Term (Type (eval n)))
→ Term ⟦ ℓ ∣ eval (P (eval n) (eval A)) ⟧
{- Desc introduction -}
`⊤ᵈ `Xᵈ : ∀{ℓ} → Term (Desc ℓ)
`Πᵈ `Σᵈ : ∀{ℓ}
(A : Term (Type ℓ))
(B : ⟦ ℓ ∣ eval A ⟧ → Term (Desc (suc ℓ)))
→ Term (Desc (suc ℓ))
{- Desc elimination -}
`elimDesc : ∀{ℓ}
(P : (n : ℕ) → Desc n → Term (Type ℓ))
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `⊤) ⟧)
→ ((n : ℕ) → Term ⟦ ℓ ∣ eval (P n `X) ⟧)
→ ((n : ℕ) (A : Type n) (D : ⟦ n ∣ A ⟧ → Desc (suc n))
(rec : (a : ⟦ n ∣ A ⟧) → ⟦ ℓ ∣ eval (P (suc n) (D a)) ⟧)
→ Term ⟦ ℓ ∣ eval (P (suc n) (`Π A D)) ⟧)
→ ((n : ℕ) (A : Type n) (D : ⟦ n ∣ A ⟧ → Desc (suc n))
(rec : (a : ⟦ n ∣ A ⟧) → ⟦ ℓ ∣ eval (P (suc n) (D a)) ⟧)
→ Term ⟦ ℓ ∣ eval (P (suc n) (`Σ A D)) ⟧)
→ (n : Term ℕ)
(D : Term (Desc (eval n)))
→ Term ⟦ ℓ ∣ eval (P (eval n) (eval D)) ⟧
{- Value introduction -}
`tt : Term ⊤
`true `false : Term Bool
`zero : Term ℕ
`suc : Term ℕ → Term ℕ
`λ : ∀{A} {B : A → Set}
(f : (a : A) → Term (B a))
→ Term ((a : A) → B a)
_`,_ : ∀{A B}
(a : Term A)
(b : Term (B (eval a)))
→ Term (Σ A B)
`con : ∀{ℓ D}
(x : Term (⟦ ℓ ∣ D ⟧ᵈ (μ D)))
→ Term (μ D)
{- Value elimination -}
`elim⊥ : ∀{A}
→ Term ⊥
→ Term A
`elimBool : ∀{ℓ}
(P : Bool → Term (Type ℓ))
(pt : Term ⟦ ℓ ∣ eval (P true) ⟧)
(pf : Term ⟦ ℓ ∣ eval (P false) ⟧)
(b : Term Bool)
→ Term ⟦ ℓ ∣ eval (P (eval b)) ⟧
`elimℕ : ∀{ℓ}
(P : ℕ → Term (Type ℓ))
(pz : Term ⟦ ℓ ∣ eval (P zero) ⟧)
(ps : (n : ℕ) → ⟦ ℓ ∣ eval (P n) ⟧ → Term ⟦ ℓ ∣ eval (P (suc n)) ⟧)
(n : Term ℕ)
→ Term ⟦ ℓ ∣ eval (P (eval n)) ⟧
`proj₁ : ∀{A B}
(ab : Term (Σ A B))
→ Term A
`proj₂ : ∀{A B}
(ab : Term (Σ A B))
→ Term (B (proj₁ (eval ab)))
_`$_ : ∀{A} {B : A → Set}
(f : Term ((a : A) → B a))
(a : Term A)
→ Term (B (eval a))
`des : ∀{ℓ} {D : Desc ℓ}
→ (Term (μ D))
→ Term (⟦ ℓ ∣ D ⟧ᵈ (μ D))
----------------------------------------------------------------------
{- Type introduction -}
eval `⊥ = `⊥
eval `⊤ = `⊤
eval `Bool = `Bool
eval `ℕ = `ℕ
eval `Desc = `Desc
eval `Type = `Type
eval (`Π A B) = `Π (eval A) (λ a → eval (B a))
eval (`Σ A B) = `Σ (eval A) (λ a → eval (B a))
eval (`μ D) = `μ (eval D)
eval (`⟦ D ⟧ᵈ X) = `⟦ eval D ⟧ᵈ (eval X)
eval `⟦ A ⟧ = `⟦ eval A ⟧
{- Type elimination -}
eval (`elimType {ℓ = ℓ} P p⊥ p⊤ pBool pℕ pΠ pΣ pDesc p⟦D⟧ᵈ pμ pType p⟦A⟧ n A) =
elimType (λ n A → ⟦ ℓ ∣ eval (P n A) ⟧)
(λ n → eval (p⊥ n)) (λ n → eval (p⊤ n)) (λ n → eval (pBool n)) (λ n → eval (pℕ n))
(λ n A B rec₁ rec₂ → eval (pΠ n A B rec₁ rec₂))
(λ n A B rec₁ rec₂ → eval (pΣ n A B rec₁ rec₂))
(λ n → eval (pDesc n))
(λ n D X rec → eval (p⟦D⟧ᵈ n D X rec))
(λ n D → eval (pμ n D))
(λ n → eval (pType n))
(λ n A rec → eval (p⟦A⟧ n A rec))
(eval n)
(eval A)
{- Desc introduction -}
eval `⊤ᵈ = `⊤
eval `Xᵈ = `X
eval (`Πᵈ A D) = `Π (eval A) (λ a → eval (D a))
eval (`Σᵈ A D) = `Σ (eval A) (λ a → eval (D a))
{- Desc elimination -}
eval (`elimDesc {ℓ = ℓ} P p⊤ pX pΠ pΣ n D) =
elimDesc (λ n D → ⟦ ℓ ∣ eval (P n D) ⟧)
(λ n → eval (p⊤ n)) (λ n → eval (pX n))
(λ n A D rec → eval (pΠ n A D rec))
(λ n A D rec → eval (pΣ n A D rec))
(eval n)
(eval D)
{- Value introduction -}
eval `tt = tt
eval `true = true
eval `false = false
eval `zero = zero
eval (`suc n) = suc (eval n)
eval (`λ f) = λ a → eval (f a)
eval (a `, b) = eval a , eval b
eval (`con x) = con (eval x)
{- Value elimination -}
eval (`elim⊥ bot) = elim⊥ (eval bot)
eval (`elimBool {ℓ = ℓ} P pt pf b) =
elimBool (λ b → ⟦ ℓ ∣ eval (P b) ⟧)
(eval pt) (eval pf) (eval b)
eval (`elimℕ {ℓ = ℓ} P pz ps n) =
elimℕ (λ n → ⟦ ℓ ∣ eval (P n) ⟧)
(eval pz) (λ n pn → eval (ps n pn)) (eval n)
eval (`proj₁ ab) = proj₁ (eval ab)
eval (`proj₂ ab) = proj₂ (eval ab)
eval (f `$ a) = (eval f) (eval a)
eval (`des {ℓ = ℓ} x) = des {ℓ = ℓ} (eval x)
----------------------------------------------------------------------
| {
"alphanum_fraction": 0.4013937282,
"avg_line_length": 29.7409326425,
"ext": "agda",
"hexsha": "35fff44095c0ef1f64b18c460b455c6db3781b78",
"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/Denotational.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/Denotational.agda",
"max_line_length": 86,
"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/Denotational.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": 2698,
"size": 5740
} |
open import Coinduction using ( ∞ ; ♯_ ; ♭ )
open import Data.Product using ( _,_ )
open import FRP.LTL.ISet.Core using ( ISet ; M⟦_⟧ ; splitM⟦_⟧ ; ⟦_⟧ ; ⌈_⌉ ; [_] )
open import FRP.LTL.ISet.Product using ( _∧_ )
open import FRP.LTL.ISet.Stateless using ( _⇒_ )
open import FRP.LTL.Time.Bound using ( Time∞ ; fin ; +∞ ; _≼_ ; _≺_ ; ≼-refl ; ≺-impl-≼ ; ≺-impl-⋡ ; _≺-trans_ ; _≼-case_ ; lt ; eq ; gt ; t≺+∞ )
open import FRP.LTL.Time.Interval using ( [_⟩ )
open import FRP.LTL.Util using ( ⊥-elim ; ≡-relevant )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl )
module FRP.LTL.ISet.Decoupled where
data _∙_⊷_∙_ (A : ISet) (s : Time∞) (B : ISet) (u : Time∞) : Set where
inp : .(s ≺ u) → .(u ≺ +∞) →
(∀ {t} .(s≺t : s ≺ t) → M⟦ A ⟧ [ s≺t ⟩ → ∞ (A ∙ t ⊷ B ∙ u)) →
(A ∙ s ⊷ B ∙ u)
out : ∀ {v} .(u≺v : u ≺ v) →
M⟦ B ⟧ [ u≺v ⟩ → ∞ (A ∙ s ⊷ B ∙ v) →
(A ∙ s ⊷ B ∙ u)
done : .(u ≡ +∞) →
(A ∙ s ⊷ B ∙ u)
_▹_ : ISet → ISet → ISet
A ▹ B = ⌈ (λ t → A ∙ fin t ⊷ B ∙ fin t) ⌉
_/_/_ : ∀ {A B s t u} → (A ∙ s ⊷ B ∙ u) → .(s≺t : s ≺ t) → M⟦ A ⟧ [ s≺t ⟩ → (A ∙ t ⊷ B ∙ u)
inp s≺u u≺∞ P / s≺t / σ = ♭ (P s≺t σ)
out u≺v τ P / s≺t / σ = out u≺v τ (♯ (♭ P / s≺t / σ))
done u≡∞ / s≺t / σ = done u≡∞
mutual
≻-tr : ∀ {A B C s u} .(s≻u : u ≺ s) → M⟦ B ⟧ [ s≻u ⟩ →
((A ∧ B) ∙ u ⊷ (A ∧ C) ∙ u) → (B ∙ s ⊷ C ∙ u)
≻-tr s≻u σ (inp u≺u u≺∞ P) = ⊥-elim (≺-impl-⋡ u≺u ≼-refl)
≻-tr {A} {B} {C} {s} {u} s≻u σ (out {v} u≺v [ ρ , τ ] P)
with s ≼-case v
≻-tr {A} {B} {C} s≻u σ (out u≺v [ ρ , τ ] P) | lt s≺v
with splitM⟦ A ⟧ [ s≻u ⟩ [ s≺v ⟩ refl ρ
≻-tr {A} {B} {C} s≻u σ (out u≺v [ ρ , τ ] P) | lt s≺v | (ρ₁ , ρ₂) =
out u≺v τ (♯ ≺-tr s≺v ρ₂ (♭ P / s≻u / [ ρ₁ , σ ]))
≻-tr {A} {B} {C} s≻u σ (out u≺v [ ρ , τ ] P) | eq s≡v
with ≡-relevant s≡v
≻-tr {A} {B} {C} s≻u σ (out u≺v [ ρ , τ ] P) | eq s≡v | refl =
out u≺v τ (♯ tr (♭ P / s≻u / [ ρ , σ ]))
≻-tr {A} {B} {C} s≻u σ (out u≺v [ ρ , τ ] P) | gt s≻v
with splitM⟦ B ⟧ [ u≺v ⟩ [ s≻v ⟩ refl σ
≻-tr {A} {B} {C} s≻u σ (out u≺v [ ρ , τ ] P) | gt s≻v | (σ₁ , σ₂) =
out u≺v τ (♯ ≻-tr s≻v σ₂ (♭ P / u≺v / [ ρ , σ₁ ]))
≻-tr s≻u σ (done u≡∞) = done u≡∞
≺-tr : ∀ {A B C s u} .(s≺u : s ≺ u) → M⟦ A ⟧ [ s≺u ⟩ →
((A ∧ B) ∙ s ⊷ (A ∧ C) ∙ u) → (B ∙ s ⊷ C ∙ u)
≺-tr {A} {B} {C} {s} {+∞} s≺u ρ P = done refl
≺-tr {A} {B} {C} {s} {fin u} s≺u ρ P = inp s≺u t≺+∞ Q where
Q : ∀ {t} .(s≺t : s ≺ t) → M⟦ B ⟧ [ s≺t ⟩ → ∞ (B ∙ t ⊷ C ∙ fin u)
Q {t} s≺t σ with t ≼-case (fin u)
Q s≺t σ | lt t≺u with splitM⟦ _ ⟧ [ s≺t ⟩ [ t≺u ⟩ refl ρ
Q s≺t σ | lt t≺u | (ρ₁ , ρ₂) = ♯ ≺-tr t≺u ρ₂ (P / s≺t / [ ρ₁ , σ ])
Q s≺t σ | eq t≡u with ≡-relevant t≡u
Q s≺t σ | eq t≡u | refl = ♯ tr (P / s≺u / [ ρ , σ ])
Q s≺t σ | gt t≻u with splitM⟦ _ ⟧ [ s≺u ⟩ [ t≻u ⟩ refl σ
Q s≺t σ | gt t≻u | (σ₁ , σ₂) = ♯ (≻-tr t≻u σ₂ (P / s≺u / [ ρ , σ₁ ]))
tr : ∀ {A B C s} → ((A ∧ B) ∙ s ⊷ (A ∧ C) ∙ s) → (B ∙ s ⊷ C ∙ s)
tr (inp s≺s s≺∞ P) = ⊥-elim (≺-impl-⋡ s≺s ≼-refl)
tr (out s≺u [ ρ , τ ] P) = out s≺u τ (♯ ≺-tr s≺u ρ (♭ P))
tr (done s≡∞) = done s≡∞
loop : ∀ {A B C} → ⟦ ((A ∧ B) ▹ (A ∧ C)) ⇒ (B ▹ C) ⟧
loop [ [ f ] ] = [ (λ t t∈i → tr (f t t∈i)) ] | {
"alphanum_fraction": 0.3975640225,
"avg_line_length": 44.4722222222,
"ext": "agda",
"hexsha": "98024255a47e4145e0eb0876b8ed550b653c1568",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z",
"max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-frp-ltl",
"max_forks_repo_path": "src/FRP/LTL/ISet/Decoupled.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-frp-ltl",
"max_issues_repo_path": "src/FRP/LTL/ISet/Decoupled.agda",
"max_line_length": 146,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-frp-ltl",
"max_stars_repo_path": "src/FRP/LTL/ISet/Decoupled.agda",
"max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z",
"num_tokens": 1957,
"size": 3202
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Abstract.Types
open import LibraBFT.Abstract.Types.EpochConfig
open WithAbsVote
-- This module defines the notion of one Record r "extending" another
-- Record r' (denoted r' ← r), ensuring rules about rounds and that r
-- correctly identifies r'
module LibraBFT.Abstract.Records.Extends
(UID : Set)
(_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁))
(NodeId : Set)
(𝓔 : EpochConfig UID NodeId)
(𝓥 : VoteEvidence UID NodeId 𝓔)
where
open import LibraBFT.Abstract.Records UID _≟UID_ NodeId 𝓔 𝓥
-- Most of the conditions in section 4.2 of the paper (see
-- LibraBFT.Abstract.RecordChain.Properties) would be checked
-- by the implementation to validate data received.
--
-- In the Abstract model, however, we are only concerned with
-- proving the properties; only round numbers and identifiers
-- for previous records are actually critical to thm S5!
data _←_ : Record → Record → Set where
I←B : {b : Block}
→ 0 < getRound b
→ bPrevQC b ≡ nothing
→ I ← B b
Q←B : {q : QC} {b : Block}
→ getRound q < getRound b
→ just (qCertBlockId q) ≡ bPrevQC b
→ Q q ← B b
B←Q : {b : Block} {q : QC}
→ getRound q ≡ getRound b
→ bId b ≡ qCertBlockId q
→ B b ← Q q
-- Equivalent records extend equivalent records (modulo injectivity
-- failure of bId).
←-≈Rec : ∀{r₀ r₁ s₀ s₁} → s₀ ← r₀ → s₁ ← r₁
→ r₀ ≈Rec r₁
→ NonInjective-≡ bId ⊎ (s₀ ≈Rec s₁)
←-≈Rec (I←B x x₁) (I←B x₂ x₃) hyp = inj₂ eq-I
←-≈Rec (I←B x x₁) (Q←B x₂ x₃) (eq-B refl)
= ⊥-elim (maybe-⊥ (sym x₃) x₁)
←-≈Rec (Q←B x x₁) (I←B x₂ x₃) (eq-B refl)
= ⊥-elim (maybe-⊥ (sym x₁) x₃)
←-≈Rec (Q←B {q₀} x refl) (Q←B {q₁} x₂ refl) (eq-B refl)
= inj₂ (eq-Q refl) -- Here is where we wouldn't be able to
-- complete the proof if we required round equality
-- in eq-Q
←-≈Rec (B←Q {b₀} x refl) (B←Q {b₁} w refl) (eq-Q refl)
with b₀ ≟Block b₁
...| no hb = inj₁ ((b₀ , b₁) , (λ x → hb x) , refl)
...| yes prf = inj₂ (eq-B prf)
←-irrelevant : Irrelevant _←_
←-irrelevant (I←B r₁ h₁) (I←B r₂ h₂)
= cong₂ I←B (≤-irrelevant r₁ r₂) (≡-irrelevant h₁ h₂)
←-irrelevant (Q←B r₁ h₁) (Q←B r₂ h₂)
= cong₂ Q←B (≤-irrelevant r₁ r₂) (≡-irrelevant h₁ h₂)
←-irrelevant (B←Q r₁ h₁) (B←Q r₂ h₂)
= cong₂ B←Q (≡-irrelevant r₁ r₂) (≡-irrelevant h₁ h₂)
←-round-≤ : ∀{r₀ r₁} → r₀ ← r₁ → round r₀ ≤ round r₁
←-round-≤ (I←B r h) = z≤n
←-round-≤ (Q←B r h) = <⇒≤ r
←-round-≤ (B←Q refl h) = ≤-refl
←←-round-< : ∀{r r₀ r₁} → r ← r₀ → r₀ ← r₁
→ round r < round r₁
←←-round-< (I←B r h) (B←Q refl _) = r
←←-round-< (Q←B r h) rr = ≤-trans r (←-round-≤ rr)
←←-round-< (B←Q refl h) (Q←B prf _) = prf
-- LemmaS1, clause 2: injectivity of _←_
lemmaS1-2 : ∀{r₀ r₁ r₂ r₂'}
→ r₂ ≈Rec r₂'
→ r₀ ← r₂ → r₁ ← r₂'
→ uid r₀ ≡ uid r₁
lemmaS1-2 {i₀} {i₁} {b} hyp (I←B _ i₀←b) (I←B _ i₁←b) = refl
lemmaS1-2 {q} {i} {b} (eq-B refl) (Q←B _ ()) (I←B _ refl)
lemmaS1-2 {i} {q} {b} (eq-B refl) (I←B _ refl) (Q←B _ ())
lemmaS1-2 {q₀} {q₁} {b} (eq-B refl) (Q←B _ refl) (Q←B _ refl) = refl
lemmaS1-2 {b₀} {b₁} {q} (eq-Q refl) (B←Q _ refl) (B←Q _ refl) = refl
-- A better name for lemmaS1-2
←-inj : ∀{r₀ r₁ r₂}
→ r₀ ← r₂ → r₁ ← r₂
→ uid r₀ ≡ uid r₁
←-inj = lemmaS1-2 ≈Rec-refl
| {
"alphanum_fraction": 0.5626659586,
"avg_line_length": 37.2871287129,
"ext": "agda",
"hexsha": "962631d07a41778f3a5e20de4b9226a3006a61d3",
"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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "cwjnkins/bft-consensus-agda",
"max_forks_repo_path": "LibraBFT/Abstract/Records/Extends.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "cwjnkins/bft-consensus-agda",
"max_issues_repo_path": "LibraBFT/Abstract/Records/Extends.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "cwjnkins/bft-consensus-agda",
"max_stars_repo_path": "LibraBFT/Abstract/Records/Extends.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1569,
"size": 3766
} |
{-
This file contains:
- 3×3 lemma for pushouts
Written by: Loïc Pujet, April 2019
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Pushout.Properties where
open import Cubical.Core.Glue
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Data.Prod.Base
open import Cubical.Data.Unit
open import Cubical.HITs.Pushout.Base
{-
3×3 lemma for pushouts
Let Aᵢⱼ denote a type, fᵢⱼ a map and Hᵢⱼ a homotopy. Given a diagram of the following shape:
A00 ←—f01—— A02 ——f03—→ A04
↑ ↑ ↑
f10 H11 f12 H13 f14
| | |
A20 ←—f21—— A22 ——f23—→ A24
| | |
f30 H31 f32 H33 f34
↓ ↓ ↓
A40 ←—f41—— A42 ——f43—→ A44
one can build its colimit from pushouts in two ways:
- either build pushouts A□0, A□2, A□4 of the lines and then build the pushout A□○ of the resulting
diagram A□0 ←—f□1—— A□2 ——f□3—→ A□4 ;
- or build pushouts of the columns and build the pushout A○□ of the resulting diagram A0□ ← A2□ → A4□.
Then the lemma states there is an equivalence A□○ ≃ A○□.
-}
module 3x3-span
(A00 A02 A04 A20 A22 A24 A40 A42 A44 : Type₀)
(f10 : A20 → A00)
(f12 : A22 → A02)
(f14 : A24 → A04)
(f30 : A20 → A40)
(f32 : A22 → A42)
(f34 : A24 → A44)
(f01 : A02 → A00)
(f21 : A22 → A20)
(f41 : A42 → A40)
(f03 : A02 → A04)
(f23 : A22 → A24)
(f43 : A42 → A44)
(H11 : ∀ x → f01 (f12 x) ≡ f10 (f21 x))
(H13 : ∀ x → f03 (f12 x) ≡ f14 (f23 x))
(H31 : ∀ x → f41 (f32 x) ≡ f30 (f21 x))
(H33 : ∀ x → f43 (f32 x) ≡ f34 (f23 x))
where
-- pushouts of the lines
A□0 : Type₀
A□0 = Pushout f10 f30
A□2 : Type₀
A□2 = Pushout f12 f32
A□4 : Type₀
A□4 = Pushout f14 f34
-- maps between pushouts
f□1 : A□2 → A□0
f□1 (inl x) = inl (f01 x)
f□1 (inr x) = inr (f41 x)
f□1 (push a j) = ((λ i → inl (H11 a i))
∙∙ push (f21 a)
∙∙ (λ i → inr (H31 a (~ i)))) j
f□3 : A□2 → A□4
f□3 (inl x) = inl (f03 x)
f□3 (inr x) = inr (f43 x)
f□3 (push a j) = ((λ i → inl (H13 a i))
∙∙ push (f23 a)
∙∙ (λ i → inr (H33 a (~ i)))) j
-- total pushout
A□○ : Type₀
A□○ = Pushout f□1 f□3
-- pushouts of the columns
A0□ : Type₀
A0□ = Pushout f01 f03
A2□ : Type₀
A2□ = Pushout f21 f23
A4□ : Type₀
A4□ = Pushout f41 f43
-- maps between pushouts
f1□ : A2□ → A0□
f1□ (inl x) = inl (f10 x)
f1□ (inr x) = inr (f14 x)
f1□ (push a j) = ((λ i → inl (H11 a (~ i)))
∙∙ push (f12 a)
∙∙ (λ i → inr (H13 a i))) j
f3□ : A2□ → A4□
f3□ (inl x) = inl (f30 x)
f3□ (inr x) = inr (f34 x)
f3□ (push a j) = ((λ i → inl (H31 a (~ i)))
∙∙ push (f32 a)
∙∙ (λ i → inr (H33 a i))) j
-- total pushout
A○□ : Type₀
A○□ = Pushout f1□ f3□
-- forward map of the equivalence A□○ ≃ A○□
forward-l : A□0 → A○□
forward-l (inl x) = inl (inl x)
forward-l (inr x) = inr (inl x)
forward-l (push a i) = push (inl a) i
forward-r : A□4 → A○□
forward-r (inl x) = inl (inr x)
forward-r (inr x) = inr (inr x)
forward-r (push a i) = push (inr a) i
forward-filler : A22 → I → I → I → A○□
forward-filler a i j = hfill (λ t → λ { (i = i0) → inl (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) j (~ t))
; (i = i1) → inr (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) j (~ t))
; (j = i0) → forward-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) i t)
; (j = i1) → forward-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) i t) })
(inS (push (push a j) i))
A□○→A○□ : A□○ → A○□
A□○→A○□ (inl x) = forward-l x
A□○→A○□ (inr x) = forward-r x
A□○→A○□ (push (inl x) i) = inl (push x i)
A□○→A○□ (push (inr x) i) = inr (push x i)
A□○→A○□ (push (push a i) j) = forward-filler a i j i1
-- backward map
backward-l : A0□ → A□○
backward-l (inl x) = inl (inl x)
backward-l (inr x) = inr (inl x)
backward-l (push a i) = push (inl a) i
backward-r : A4□ → A□○
backward-r (inl x) = inl (inr x)
backward-r (inr x) = inr (inr x)
backward-r (push a i) = push (inr a) i
backward-filler : A22 → I → I → I → A□○
backward-filler a i j = hfill (λ t → λ { (i = i0) → inl (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) j (~ t))
; (i = i1) → inr (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) j (~ t))
; (j = i0) → backward-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) i t)
; (j = i1) → backward-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) i t) })
(inS (push (push a j) i))
A○□→A□○ : A○□ → A□○
A○□→A□○ (inl x) = backward-l x
A○□→A□○ (inr x) = backward-r x
A○□→A□○ (push (inl x) i) = inl (push x i)
A○□→A□○ (push (inr x) i) = inr (push x i)
A○□→A□○ (push (push a i) j) = backward-filler a i j i1
-- first homotopy
homotopy1-l : ∀ x → A□○→A○□ (backward-l x) ≡ inl x
homotopy1-l (inl x) = refl
homotopy1-l (inr x) = refl
homotopy1-l (push a i) = refl
homotopy1-r : ∀ x → A□○→A○□ (backward-r x) ≡ inr x
homotopy1-r (inl x) = refl
homotopy1-r (inr x) = refl
homotopy1-r (push a i) = refl
A○□→A□○→A○□ : ∀ x → A□○→A○□ (A○□→A□○ x) ≡ x
A○□→A□○→A○□ (inl x) = homotopy1-l x
A○□→A□○→A○□ (inr x) = homotopy1-r x
A○□→A□○→A○□ (push (inl x) i) k = push (inl x) i
A○□→A□○→A○□ (push (inr x) i) k = push (inr x) i
A○□→A□○→A○□ (push (push a i) j) k =
hcomp (λ t → λ { (i = i0) → forward-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) j (~ t))
; (i = i1) → forward-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) j (~ t))
; (j = i0) → homotopy1-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) i t) k
; (j = i1) → homotopy1-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) i t) k
; (k = i0) → A□○→A○□ (backward-filler a i j t)
; (k = i1) → forward-filler a j i (~ t) })
(forward-filler a j i i1)
-- second homotopy
homotopy2-l : ∀ x → A○□→A□○ (forward-l x) ≡ inl x
homotopy2-l (inl x) = refl
homotopy2-l (inr x) = refl
homotopy2-l (push a i) = refl
homotopy2-r : ∀ x → A○□→A□○ (forward-r x) ≡ inr x
homotopy2-r (inl x) = refl
homotopy2-r (inr x) = refl
homotopy2-r (push a i) = refl
A□○→A○□→A□○ : ∀ x → A○□→A□○ (A□○→A○□ x) ≡ x
A□○→A○□→A□○ (inl x) = homotopy2-l x
A□○→A○□→A□○ (inr x) = homotopy2-r x
A□○→A○□→A□○ (push (inl x) i) k = push (inl x) i
A□○→A○□→A□○ (push (inr x) i) k = push (inr x) i
A□○→A○□→A□○ (push (push a i) j) k =
hcomp (λ t → λ { (i = i0) → backward-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) j (~ t))
; (i = i1) → backward-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) j (~ t))
; (j = i0) → homotopy2-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) i t) k
; (j = i1) → homotopy2-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) i t) k
; (k = i0) → A○□→A□○ (forward-filler a i j t)
; (k = i1) → backward-filler a j i (~ t) })
(backward-filler a j i i1)
-- equivalence
Pushout3x3 : A□○ ≡ A○□
Pushout3x3 = isoToPath (iso A□○→A○□ A○□→A□○ A○□→A□○→A○□ A□○→A○□→A□○)
Pushout3x3 : ∀ A00 A02 A04 A20 A22 A24 A40 A42 A44 f10 f12 f14 f30 f32 f34 f01 f21 f41 f03 f23 f43 H11 H13 H31 H33 →
3x3-span.A□○ A00 A02 A04 A20 A22 A24 A40 A42 A44 f10 f12 f14 f30 f32 f34 f01 f21 f41 f03 f23 f43 H11 H13 H31 H33
≡ 3x3-span.A○□ A00 A02 A04 A20 A22 A24 A40 A42 A44 f10 f12 f14 f30 f32 f34 f01 f21 f41 f03 f23 f43 H11 H13 H31 H33
Pushout3x3 = 3x3-span.Pushout3x3
| {
"alphanum_fraction": 0.5,
"avg_line_length": 35,
"ext": "agda",
"hexsha": "cf99cf78dbd23c0684922a75b76e28e2a476b424",
"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": "48bd72e073b11d7501342d88eede05974a616977",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "loic-p/cubical",
"max_forks_repo_path": "Cubical/HITs/Pushout/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "48bd72e073b11d7501342d88eede05974a616977",
"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": "loic-p/cubical",
"max_issues_repo_path": "Cubical/HITs/Pushout/Properties.agda",
"max_line_length": 152,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "48bd72e073b11d7501342d88eede05974a616977",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "loic-p/cubical",
"max_stars_repo_path": "Cubical/HITs/Pushout/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4070,
"size": 8470
} |
-- Andreas, 2016-01-03, issue reported by mechvel
module _ where
-- With hidden parameter, things work
module Works0 {A : Set} where
postulate
P : (a : A) → Set
record Works (a : A) : Set where
f : P a → Set
f p with p
... | _ = A
-- With visible parameter, the error is triggered
-- because it is turned hidden inside the record section
module Fails (A : Set) where
postulate
P : (a : A) → Set
-- Modules do not touch visibility of parameters, so things work.
module Works (a : A) where
f : P a → Set
f p with p
... | _ = A
-- Records have some magic to make record parameters hidden
-- in record section.
-- This leads to an error in @checkInternal@.
record Fails (a : A) : Set where
f : P a → Set
f p with p
... | _ = A
-- ERROR WAS:
-- Expected a visible argument, but found a hidden argument
-- when checking that the type (w p : P a) → Set of the
-- generated with function is well-formed
-- Should succeed.
| {
"alphanum_fraction": 0.6266397578,
"avg_line_length": 20.6458333333,
"ext": "agda",
"hexsha": "e533f7de5c2eaed982ef5dad0e4b95ee56fbce2c",
"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/Issue1759.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/Issue1759.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/Issue1759.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": 289,
"size": 991
} |
-- Andreas, 2015-06-11
{-# OPTIONS --copatterns #-}
open import Common.Size
module _ {C : Set} {R : C → Set} where
mutual
record IO (i : Size) (A : Set) : Set where
coinductive
constructor delay
field
force : {j : Size< i} → IO' j A
data IO' (i : Size) (A : Set) : Set where
do : (c : C) (f : R c → IO i A) → IO' i A
return : (a : A) → IO' i A
open IO
module Works where
_>>=_ : ∀{i A B} (m : IO i A) (k : A → IO i B) → IO i B
force (m >>= k) with force m
force (m >>= k) {j} | do c f = do c λ x → f x >>= k
force (m >>= k) {j} | return a = force (k a)
_>>=_ : ∀{i A B} (m : IO i A) (k : A → IO i B) → IO i B
force (m >>= k) with force m
force (m >>= k) | do c f = do c λ x → f x >>= k
force (m >>= k) | return a = force (k a)
-- Error WAS:
-- Too few arguments given in with-clause
-- when checking that the clause
-- force (m >>= k) with force m
-- force (m >>= k) | do c f = do c (λ x → f x >>= k)
-- force (m >>= k) | return a = force (k a)
-- has type {i : Size} {A B : Set} → IO i A → (A → IO i B) → IO i B
| {
"alphanum_fraction": 0.4967259121,
"avg_line_length": 26.0731707317,
"ext": "agda",
"hexsha": "8785f61c475f7d2fd167dfa7b48b92b73fe1fade",
"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/Issue1551.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/Issue1551.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/Issue1551.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": 419,
"size": 1069
} |
module Test01 where
hoge : {A : Set} → A → A
hoge x = x
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; subst)
open import Function using (id)
lemma1 : {X Y : Set} → (X ≡ (X → Y)) → X
lemma1 p rewrite p = (λ x → let f = subst id p x in f x)
curry : {X Y : Set} → (X ≡ (X → Y)) → Y
curry p = (let f = subst id p (lemma1 p) in f (lemma1 p))
open import Data.Bool
open import Data.Nat
open import Data.Empty
postulate
First : ℕ → Set
All : ℕ → Set
fToA : ((n : ℕ) → First n) → ((n : ℕ) → All n)
fToA2 : (z : ℕ) → (First z → All z)
tekito : (z : ℕ) → ((All z → ⊥) → (First z → ⊥)) → First (suc z)
contra : (z : ℕ) → ((All z → ⊥) → (First z → ⊥)) → (First z → All z)
mutual
-- 失敗
contraFirstToAll : (z : ℕ) → ((All z → ⊥) → (First z → ⊥))
-- contraFirstToAll z allToVoid _ = let foo = (contra z (contraFirstToAll z)) (limitedDivSeq z) in allToVoid foo
contraFirstToAll z allToVoid _ = let foo = fToA (λ k → limitedDivSeq k) in allToVoid (foo z)
limitedDivSeq : (n : ℕ) → First n
limitedDivSeq zero = {! !}
limitedDivSeq (suc n) = let bar = contraFirstToAll n in tekito n bar
-- Idris
{-
postulate foo : (t : Nat) -> LT' t (S t)
contraFirstToAll :
(z : Nat) -> (((AllLimited . B.allDivSeq) z -> Void) -> ((FirstLimited . B.allDivSeq) z -> Void))
contraFirstToAll Z allToVoid _ = allToVoid IsAllLimited00
contraFirstToAll (S z) _ _ = wfInd {P=(\z=>Void)} {rel=LT'} step (S z) where
step : (x : Nat) -> ((y : Nat) -> LT' y x -> Void) -> Void
step Z _ = believe_me "ここには来ない"
step (S x) rs = rs x (foo x)
-- ?rhs1 が書けない!!
contraFirstToAll :
(z : Nat) -> (((AllLimited . B.allDivSeq) z -> Void) -> ((FirstLimited . B.allDivSeq) z -> Void))
contraFirstToAll Z allToVoid _ = allToVoid IsAllLimited00
contraFirstToAll (S z) _ _ = step (S z) SIsNotZ (wellFounded {rel=LT'} (S z)) where
step : (x : Nat) -> Not (x = Z) -> Accessible LT' x -> Void
step Z p _ = void (p Refl)
step (S x) p (Access rs) = step x ?rhs1 (rs x (foo x))
-} | {
"alphanum_fraction": 0.5824767499,
"avg_line_length": 37.1454545455,
"ext": "agda",
"hexsha": "65018fec56aa8bd1bee8a54723d6169cd91e062b",
"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": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "righ1113/Agda",
"max_forks_repo_path": "Test01.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"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": "righ1113/Agda",
"max_issues_repo_path": "Test01.agda",
"max_line_length": 115,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "righ1113/Agda",
"max_stars_repo_path": "Test01.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 781,
"size": 2043
} |
-- This demonstrates a known issue:
-- The parser is not aware of strings, thus,
-- a closing block comment delimiter inside a string
-- is taken as a closing block comment delimiter.
-- Without nested comments:
{- This is commented-out.
test = "A weird string with comment closing -} and other garbage @#$% that appears now as Agda code!"
-}
-- With nested comments:
{-
{- This is commented-out.
test = "A weird string with comment closing -} and other garbage @#$%!"
-- NB: this confuses even Agda (at the time of writing, version 2.6.1).
-}
This should be still commented-out. -}
-- The reverse situation:
test = "Never put comment opening {- inside a string!"
postulate
ThisShouldNotBeCommentedOut : Set
-- -} This should be text, not code!!
-- SNAFU.
| {
"alphanum_fraction": 0.704041721,
"avg_line_length": 24.7419354839,
"ext": "agda",
"hexsha": "02683829471e903cf9a9664d1c6d0a8cbc23f4c4",
"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": "93d317c87bddf973e3fa6abd5bf24dcfa9a797f0",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/agda2lagda",
"max_forks_repo_path": "test/ClosingCommentInString.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "93d317c87bddf973e3fa6abd5bf24dcfa9a797f0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/agda2lagda",
"max_issues_repo_path": "test/ClosingCommentInString.agda",
"max_line_length": 101,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "93d317c87bddf973e3fa6abd5bf24dcfa9a797f0",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/agda2lagda",
"max_stars_repo_path": "test/ClosingCommentInString.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-16T07:28:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-01T12:10:15.000Z",
"num_tokens": 189,
"size": 767
} |
open import Function
open import Relation.Nullary
open import Relation.Binary hiding (_⇒_)
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Data.Sum
open import Data.Product
delim : ∀ {α β} {A : Set α} {B : Dec A -> Set β}
-> (d : Dec A) -> (∀ x -> B (yes x)) -> (∀ c -> B (no c)) -> B d
delim (yes x) f g = f x
delim (no c) f g = g c
drec = λ {α β} {A : Set α} {B : Set β} -> delim {A = A} {B = λ _ -> B}
dcong₂ : ∀ {α β γ} {A : Set α} {B : Set β} {C : Set γ} {x y v w}
-> (f : A -> B -> C)
-> (∀ {x y} -> f x v ≡ f y w -> x ≡ y × v ≡ w)
-> Dec (x ≡ y)
-> Dec (v ≡ w)
-> Dec (f x v ≡ f y w)
dcong₂ f inj d₁ d₂ = drec d₁
(λ p₁ -> drec d₂
(λ p₂ -> yes (cong₂ f p₁ p₂))
(λ c -> no (c ∘ proj₂ ∘ inj)))
(λ c -> no (c ∘ proj₁ ∘ inj))
infixl 5 _▻_
infixr 6 _⇒_
infix 4 _≟ᵗ_ _≟ᶜ_ _∈_ _⊂[_]_ _⊂?_ _⊢_
infixr 6 vs_
infixr 5 ƛ_
infixl 7 _·_
data Type : Set where
⋆ : Type
_⇒_ : Type -> Type -> Type
data Con : Set where
ε : Con
_▻_ : Con -> Type -> Con
data _∈_ σ : Con -> Set where
vz : ∀ {Γ} -> σ ∈ Γ ▻ σ
vs_ : ∀ {Γ τ} -> σ ∈ Γ -> σ ∈ Γ ▻ τ
data _⊢_ Γ : Type -> Set where
var : ∀ {σ} -> σ ∈ Γ -> Γ ⊢ σ
ƛ_ : ∀ {σ τ} -> Γ ▻ σ ⊢ τ -> Γ ⊢ σ ⇒ τ
_·_ : ∀ {σ τ} -> Γ ⊢ σ ⇒ τ -> Γ ⊢ σ -> Γ ⊢ τ
⇒-inj : ∀ {σ₁ σ₂ τ₁ τ₂} -> σ₁ ⇒ τ₁ ≡ σ₂ ⇒ τ₂ -> σ₁ ≡ σ₂ × τ₁ ≡ τ₂
⇒-inj refl = refl , refl
▻-inj : ∀ {Γ₁ Γ₂ σ₁ σ₂} -> Γ₁ ▻ σ₁ ≡ Γ₂ ▻ σ₂ -> Γ₁ ≡ Γ₂ × σ₁ ≡ σ₂
▻-inj refl = refl , refl
_≟ᵗ_ : Decidable (_≡_ {A = Type})
⋆ ≟ᵗ ⋆ = yes refl
(σ₁ ⇒ τ₁) ≟ᵗ (σ₂ ⇒ τ₂) = dcong₂ _⇒_ ⇒-inj (σ₁ ≟ᵗ σ₂) (τ₁ ≟ᵗ τ₂)
⋆ ≟ᵗ (σ₂ ⇒ τ₂) = no λ()
(σ₁ ⇒ τ₁) ≟ᵗ ⋆ = no λ()
_≟ᶜ_ : Decidable (_≡_ {A = Con})
ε ≟ᶜ ε = yes refl
Γ ▻ σ ≟ᶜ Δ ▻ τ = dcong₂ _▻_ ▻-inj (Γ ≟ᶜ Δ) (σ ≟ᵗ τ)
ε ≟ᶜ Δ ▻ τ = no λ()
Γ ▻ σ ≟ᶜ ε = no λ()
data _⊂[_]_ : Con -> Type -> Con -> Set where
stop : ∀ {Γ σ} -> Γ ⊂[ σ ] Γ ▻ σ
skip : ∀ {Γ Δ σ τ} -> Γ ⊂[ σ ] Δ -> Γ ⊂[ σ ] Δ ▻ τ
sub : ∀ {Γ Δ σ} -> Γ ⊂[ σ ] Δ -> σ ∈ Δ
sub stop = vz
sub (skip p) = vs (sub p)
⊂-inj : ∀ {Γ Δ σ τ} -> Γ ⊂[ σ ] Δ ▻ τ -> Γ ⊂[ σ ] Δ ⊎ Γ ≡ Δ × σ ≡ τ
⊂-inj stop = inj₂ (refl , refl)
⊂-inj (skip p) = inj₁ p
_⊂?_ : ∀ {σ} -> Decidable _⊂[ σ ]_
_⊂?_ Γ ε = no λ()
_⊂?_ {σ} Γ (Δ ▻ τ) with λ c₁ -> drec (Γ ⊂? Δ) (yes ∘ skip) (λ c₂ -> no ([ c₂ , c₁ ] ∘ ⊂-inj))
... | r with σ ≟ᵗ τ
... | no c₁ = r (c₁ ∘ proj₂)
... | yes p₁ rewrite p₁ with Γ ≟ᶜ Δ
... | no c₁ = r (c₁ ∘ proj₁)
... | yes p₂ rewrite p₂ = yes stop
⊢_ : Type -> Set
⊢ σ = ∀ {Γ} -> Γ ⊢ σ
⟦_⟧ᵗ : Type -> Set
⟦ ⋆ ⟧ᵗ = ⊢ ⋆
⟦ σ ⇒ τ ⟧ᵗ = ⟦ σ ⟧ᵗ -> ⟦ τ ⟧ᵗ
mutual
↑ : ∀ {σ} -> ⊢ σ -> ⟦ σ ⟧ᵗ
↑ {⋆} t = t
↑ {σ ⇒ τ} f = λ x -> ↑ (f · ↓ x)
↓ : ∀ {σ} -> ⟦ σ ⟧ᵗ -> ⊢ σ
↓ {⋆} t = t
↓ {σ ⇒ τ} f = λ {Γ} -> ƛ (↓ (f (varˢ Γ σ)))
varˢ : ∀ Γ σ -> ⟦ σ ⟧ᵗ
varˢ Γ σ = ↑ (λ {Δ} -> var (diff Δ Γ σ)) where
diff : ∀ Δ Γ σ -> σ ∈ Δ
diff Δ Γ σ = drec (Γ ⊂? Δ) sub ⊥ where postulate ⊥ : _
data ⟦_⟧ᶜ : Con -> Set where
Ø : ⟦ ε ⟧ᶜ
_▷_ : ∀ {Γ σ} -> ⟦ Γ ⟧ᶜ -> ⟦ σ ⟧ᵗ -> ⟦ Γ ▻ σ ⟧ᶜ
lookupᵉ : ∀ {Γ σ} -> σ ∈ Γ -> ⟦ Γ ⟧ᶜ -> ⟦ σ ⟧ᵗ
lookupᵉ vz (ρ ▷ x) = x
lookupᵉ (vs v) (ρ ▷ x) = lookupᵉ v ρ
idᵉ : ∀ {Γ} -> ⟦ Γ ⟧ᶜ
idᵉ {ε} = Ø
idᵉ {Γ ▻ σ} = idᵉ ▷ varˢ Γ σ
⟦_⟧ : ∀ {Γ σ} -> Γ ⊢ σ -> ⟦ Γ ⟧ᶜ -> ⟦ σ ⟧ᵗ
⟦ var v ⟧ ρ = lookupᵉ v ρ
⟦ ƛ b ⟧ ρ = λ x -> ⟦ b ⟧ (ρ ▷ x)
⟦ f · x ⟧ ρ = ⟦ f ⟧ ρ (⟦ x ⟧ ρ)
eval : ∀ {Γ σ} -> Γ ⊢ σ -> ⟦ σ ⟧ᵗ
eval t = ⟦ t ⟧ idᵉ
norm : ∀ {Γ σ} -> Γ ⊢ σ -> Γ ⊢ σ
norm t = ↓ (eval t)
Term : Type -> Set
Term σ = ε ⊢ σ
I : Term (⋆ ⇒ ⋆)
I = ↓ id
K : Term (⋆ ⇒ ⋆ ⇒ ⋆)
K = ↓ const
S : Term ((⋆ ⇒ ⋆ ⇒ ⋆) ⇒ (⋆ ⇒ ⋆) ⇒ ⋆ ⇒ ⋆)
S = ↓ _ˢ_
B : Term ((⋆ ⇒ ⋆) ⇒ (⋆ ⇒ ⋆) ⇒ ⋆ ⇒ ⋆)
B = ↓ _∘′_
C : Term ((⋆ ⇒ ⋆ ⇒ ⋆) ⇒ ⋆ ⇒ ⋆ ⇒ ⋆)
C = ↓ flip
W : Term ((⋆ ⇒ ⋆ ⇒ ⋆) ⇒ ⋆ ⇒ ⋆)
W = ↓ λ f x -> f x x
P : Term ((⋆ ⇒ ⋆ ⇒ ⋆) ⇒ (⋆ ⇒ ⋆) ⇒ ⋆ ⇒ ⋆ ⇒ ⋆)
P = ↓ _on_
O : Term (((⋆ ⇒ ⋆) ⇒ ⋆) ⇒ (⋆ ⇒ ⋆) ⇒ ⋆)
O = ↓ λ g f -> f (g f)
test₁ : norm (ε ▻ ⋆ ⇒ ⋆ ▻ ⋆ ⊢ ⋆ ∋ (ƛ var (vs vs vz) · var vz) · var vz) ≡ var (vs vz) · var vz
test₁ = refl
test₂ : S ≡ ƛ ƛ ƛ var (vs vs vz) · var vz · (var (vs vz) · var vz)
test₂ = refl
| {
"alphanum_fraction": 0.3912302071,
"avg_line_length": 24.4345238095,
"ext": "agda",
"hexsha": "8de6b1c8ad908998d6061933e73d44558ee42e20",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "manikdv/plfa.github.io",
"max_forks_repo_path": "extra/extra/Liftable.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "manikdv/plfa.github.io",
"max_issues_repo_path": "extra/extra/Liftable.agda",
"max_line_length": 94,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "manikdv/plfa.github.io",
"max_stars_repo_path": "extra/extra/Liftable.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 2376,
"size": 4105
} |
open import Prelude
open import core
module lemmas-consistency where
-- type consistency is symmetric
~sym : {t1 t2 : htyp} → t1 ~ t2 → t2 ~ t1
~sym TCRefl = TCRefl
~sym TCHole1 = TCHole2
~sym TCHole2 = TCHole1
~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2)
-- type consistency isn't transitive
not-trans : ((t1 t2 t3 : htyp) → t1 ~ t2 → t2 ~ t3 → t1 ~ t3) → ⊥
not-trans t with t (b ==> b) ⦇-⦈ b TCHole1 TCHole2
... | ()
-- every pair of types is either consistent or not consistent
~dec : (t1 t2 : htyp) → ((t1 ~ t2) + (t1 ~̸ t2))
-- this takes care of all hole cases, so we don't consider them below
~dec _ ⦇-⦈ = Inl TCHole1
~dec ⦇-⦈ _ = Inl TCHole2
-- num cases
~dec b b = Inl TCRefl
~dec b (t2 ==> t3) = Inr ICBaseArr1
-- arrow cases
~dec (t1 ==> t2) b = Inr ICBaseArr2
~dec (t1 ==> t2) (t3 ==> t4) with ~dec t1 t3 | ~dec t2 t4
... | Inl x | Inl y = Inl (TCArr x y)
... | Inl _ | Inr y = Inr (ICArr2 y)
... | Inr x | _ = Inr (ICArr1 x)
-- no pair of types is both consistent and not consistent
~apart : {t1 t2 : htyp} → (t1 ~̸ t2) → (t1 ~ t2) → ⊥
~apart ICBaseArr1 ()
~apart ICBaseArr2 ()
~apart (ICArr1 x) TCRefl = ~apart x TCRefl
~apart (ICArr1 x) (TCArr y y₁) = ~apart x y
~apart (ICArr2 x) TCRefl = ~apart x TCRefl
~apart (ICArr2 x) (TCArr y y₁) = ~apart x y₁
| {
"alphanum_fraction": 0.5812917595,
"avg_line_length": 33.675,
"ext": "agda",
"hexsha": "84cc732f16923d5bda0d3539e401319110f01626",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z",
"max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_forks_repo_path": "lemmas-consistency.agda",
"max_issues_count": 54,
"max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_issues_repo_path": "lemmas-consistency.agda",
"max_line_length": 73,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_stars_repo_path": "lemmas-consistency.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z",
"num_tokens": 602,
"size": 1347
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lists defined in terms of Data.Star
------------------------------------------------------------------------
module Data.Star.List where
open import Data.Star
open import Data.Unit
open import Relation.Binary.Simple
open import Data.Star.Nat
-- Lists.
List : Set → Set
List a = Star (Const a) tt tt
-- Nil and cons.
[] : ∀ {a} → List a
[] = ε
infixr 5 _∷_
_∷_ : ∀ {a} → a → List a → List a
_∷_ = _◅_
-- The sum of the elements in a list containing natural numbers.
sum : List ℕ → ℕ
sum = fold (Star Always) _+_ zero
| {
"alphanum_fraction": 0.5063091483,
"avg_line_length": 19.2121212121,
"ext": "agda",
"hexsha": "54aeb1a40dbd71ccb4b4954a5d1740b296c10f9f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/Star/List.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/Star/List.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Data/Star/List.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 160,
"size": 634
} |
open import Agda.Builtin.Sigma
dup : ∀ {A : Set} → A → Σ A λ _ → A
dup x = x , x
postulate
A : Set
module M {x : A} where
y = x
data X : Set where
mkX : ∀ {x : A}
→ let
(_ , _) = dup x
open M {x}
in
X
| {
"alphanum_fraction": 0.4508196721,
"avg_line_length": 12.2,
"ext": "agda",
"hexsha": "bfee6d9cf9b8ddb3b7916387157f73972013c4b1",
"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/Succeed/Issue5584.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/Succeed/Issue5584.agda",
"max_line_length": 35,
"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/Succeed/Issue5584.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": 98,
"size": 244
} |
module MissingDefinition where
T : Set -> Set
| {
"alphanum_fraction": 0.7142857143,
"avg_line_length": 8.1666666667,
"ext": "agda",
"hexsha": "08b1d79d49da0ba2deb84248b0c64d8cb2e8d733",
"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": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/MissingDefinition.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/MissingDefinition.agda",
"max_line_length": 30,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/MissingDefinition.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": 12,
"size": 49
} |
{-# OPTIONS --without-K #-}
open import Base
module Spaces.WedgeCircles {i} (A : Set i) where
{-
The idea is
data wedge-circles : Set (suc i) where
base : wedge-circles
loops : A → base ≡ base
-}
private
data #wedge-circles : Set (suc i) where
#base : #wedge-circles
wedge-circles : Set (suc i)
wedge-circles = #wedge-circles
base : wedge-circles
base = #base
postulate -- HIT
loops : A → base ≡ base
wedge-circles-rec : ∀ {i} (P : wedge-circles → Set i) (x : P base)
(p : (t : A) → transport P (loops t) x ≡ x) → ((t : wedge-circles) → P t)
wedge-circles-rec P x p #base = x
postulate -- HIT
β : ∀ {i} (P : wedge-circles → Set i) (x : P base)
(p : (t : A) → transport P (loops t) x ≡ x) (t : A)
→ apd (wedge-circles-rec P x p) (loops t) ≡ p t
wedge-circles-rec-nondep : ∀ {i} (B : Set i) (x : B) (p : A → x ≡ x)
→ (wedge-circles → B)
wedge-circles-rec-nondep B x p #base = x
postulate -- HIT
β-nondep : ∀ {i} (B : Set i) (x : B) (p : A → x ≡ x) (t : A)
→ ap (wedge-circles-rec-nondep B x p) (loops t) ≡ p t
| {
"alphanum_fraction": 0.5692742696,
"avg_line_length": 24.1136363636,
"ext": "agda",
"hexsha": "2e7dd48d2e9d19e27bcd6fa04576f1139bc1e00c",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "old/Spaces/WedgeCircles.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "old/Spaces/WedgeCircles.agda",
"max_line_length": 75,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "old/Spaces/WedgeCircles.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 415,
"size": 1061
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- we use duality to prove properties about coequalizer
module Categories.Diagram.Coequalizer.Properties {o ℓ e} (C : Category o ℓ e) where
open Category C
open import Categories.Diagram.Coequalizer C using (Coequalizer; IsCoequalizer)
open import Categories.Morphism C
import Categories.Morphism.Reasoning as MR
open import Categories.Diagram.Equalizer op
open import Categories.Diagram.Equalizer.Properties op
open import Categories.Diagram.Duality C
open import Categories.Diagram.KernelPair C
open import Categories.Diagram.Pullback C
open import Categories.Morphism.Regular C
import Relation.Binary.Reasoning.Setoid as SR
open Pullback hiding (universal; unique)
private
variable
A B : Obj
f g : A ⇒ B
module _ (coe : Coequalizer f g) where
open Coequalizer coe
private
equalizer : Equalizer f g
equalizer = Coequalizer⇒coEqualizer coe
open Equalizer equalizer
using (unique′; unique-diagram)
renaming ( id-equalize to id-coequalize
; equalize-resp-≈ to coequalize-resp-≈
; equalize-resp-≈′ to coequalize-resp-≈′
)
public
-- a regular epi is a coequalizer of its kernel pair
regular-is-coeq-kp : {A B : Obj} (f : A ⇒ B) → RegularEpi f → (kp : KernelPair f) → IsCoequalizer (p₁ kp) (p₂ kp) f
regular-is-coeq-kp {A} {B} f record { C = D ; h = h ; g = g ; coequalizer = coeq } kp = record
{ equality = IsPullback.commute (isPullback kp)
; coequalize = λ {_}{u} u∘p₁≈u∘p₂ → coequalize (u∘h≈u∘g u u∘p₁≈u∘p₂)
; universal = universal
; unique = unique
}
where
open IsCoequalizer coeq
pb-univ : D ⇒ P kp
pb-univ = IsPullback.universal (isPullback kp) equality
u∘h≈u∘g : {X : Obj} → (u : A ⇒ X) → u ∘ (p₁ kp) ≈ u ∘ (p₂ kp) → u ∘ h ≈ u ∘ g
u∘h≈u∘g {X} u u∘p₁≈u∘p₂ = begin
u ∘ h ≈˘⟨ refl⟩∘⟨ p₁∘universal≈h₁ kp ⟩
u ∘ (p₁ kp ∘ pb-univ) ≈⟨ pullˡ u∘p₁≈u∘p₂ ⟩
(u ∘ p₂ kp) ∘ pb-univ ≈⟨ pullʳ (p₂∘universal≈h₂ kp) ⟩
u ∘ g ∎
where
open Category.HomReasoning C
open MR C
retract-coequalizer : ∀ {X Y} {f : Y ⇒ X} {g : X ⇒ Y} → f RetractOf g → IsCoequalizer (g ∘ f) id f
retract-coequalizer f∘g≈id = IscoEqualizer⇒IsCoequalizer (section-equalizer f∘g≈id)
| {
"alphanum_fraction": 0.6467554792,
"avg_line_length": 32.7746478873,
"ext": "agda",
"hexsha": "6acd0871f842b9a266d199e8c81eb83dfd59cd46",
"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/Diagram/Coequalizer/Properties.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/Diagram/Coequalizer/Properties.agda",
"max_line_length": 115,
"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/Diagram/Coequalizer/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 848,
"size": 2327
} |
------------------------------------------------------------------------------
-- Properties related with lists using instances of the induction principle
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Data.List.Induction.Instances.PropertiesATP where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.List
open import FOTC.Data.Nat.Type
------------------------------------------------------------------------------
-- Totality properties
lengthList-N-ind-instance :
N (length []) →
(∀ x {xs} → N (length xs) → N (length (x ∷ xs))) →
∀ {xs} → List xs → N (length xs)
lengthList-N-ind-instance = List-ind (λ as → N (length as))
postulate lengthList-N : ∀ {xs} → List xs → N (length xs)
{-# ATP prove lengthList-N lengthList-N-ind-instance #-}
++-List-ind-instance :
∀ {ys} →
List ([] ++ ys) →
(∀ x {xs} → List (xs ++ ys) → List ((x ∷ xs) ++ ys)) →
∀ {xs} → List xs → List (xs ++ ys)
++-List-ind-instance {ys} = List-ind (λ as → List (as ++ ys))
postulate ++-List : ∀ {xs ys} → List xs → List ys → List (xs ++ ys)
{-# ATP prove ++-List ++-List-ind-instance #-}
map-List-ind-instance :
∀ {f} →
List (map f []) →
(∀ x {xs} → List (map f xs) → List (map f (x ∷ xs))) →
∀ {xs} → List xs → List (map f xs)
map-List-ind-instance {f} = List-ind (λ as → List (map f as))
postulate map-List : ∀ f {xs} → List xs → List (map f xs)
{-# ATP prove map-List map-List-ind-instance #-}
------------------------------------------------------------------------------
++-assoc-ind-instance :
∀ {ys zs} →
([] ++ ys) ++ zs ≡ [] ++ ys ++ zs →
(∀ x {xs} →
(xs ++ ys) ++ zs ≡ xs ++ ys ++ zs →
((x ∷ xs) ++ ys) ++ zs ≡ (x ∷ xs) ++ ys ++ zs) →
∀ {xs} → List xs → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs
++-assoc-ind-instance {ys} {zs} =
List-ind (λ as → (as ++ ys) ++ zs ≡ as ++ ys ++ zs )
postulate
++-assoc : ∀ {xs} → List xs → ∀ ys zs → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs
{-# ATP prove ++-assoc ++-assoc-ind-instance #-}
map-++-ind-instance :
∀ {f} {ys} →
map f ([] ++ ys) ≡ map f [] ++ map f ys →
(∀ x {xs} → map f (xs ++ ys) ≡ map f xs ++ map f ys →
map f ((x ∷ xs) ++ ys) ≡ map f (x ∷ xs) ++ map f ys) →
∀ {xs} → List xs → map f (xs ++ ys) ≡ map f xs ++ map f ys
map-++-ind-instance {f} {ys} =
List-ind (λ as → map f (as ++ ys) ≡ map f as ++ map f ys)
postulate
map-++ : ∀ f {xs} → List xs → ∀ ys →
map f (xs ++ ys) ≡ map f xs ++ map f ys
{-# ATP prove map-++ map-++-ind-instance #-}
| {
"alphanum_fraction": 0.4599030213,
"avg_line_length": 34.3717948718,
"ext": "agda",
"hexsha": "685ac286f2834cc73a923d6380b64ceafcf26b8e",
"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/List/Induction/Instances/PropertiesATP.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/List/Induction/Instances/PropertiesATP.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/List/Induction/Instances/PropertiesATP.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": 838,
"size": 2681
} |
module plfa.part1.Bin where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong)
open import Data.Nat using (ℕ; zero; suc; _*_; _+_)
open import Data.Nat.Properties using (+-suc)
data Bin : Set where
⟨⟩ : Bin
_O : Bin → Bin
_I : Bin → Bin
inc : Bin → Bin
inc ⟨⟩ = ⟨⟩ I
inc (b O) = b I
inc (b I) = (inc b) O
to : ℕ → Bin
to zero = ⟨⟩ O
to (suc n) = inc (to n)
from : Bin → ℕ
from ⟨⟩ = 0
from (b O) = 2 * from b
from (b I) = suc (2 * from b)
inc-suc-law : ∀ b → from (inc b) ≡ suc (from b)
inc-suc-law ⟨⟩ = refl
inc-suc-law (b O) = refl
inc-suc-law (b I) rewrite
inc-suc-law b
| +-suc (suc (from b)) ((from b) + 0) = refl
from-to-identity : ∀ n → from (to n) ≡ n
from-to-identity zero = refl
from-to-identity (suc n) rewrite
inc-suc-law (to n)
| from-to-identity n = refl
| {
"alphanum_fraction": 0.5880239521,
"avg_line_length": 20.875,
"ext": "agda",
"hexsha": "4c1eae40d2fb2a16d8370a07ec18878b67746772",
"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": "75bef9bb35643160e2d2ab4221a3057f22eb3324",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "abolotina/plfa.github.io",
"max_forks_repo_path": "src/plfa/part1/Bin.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "abolotina/plfa.github.io",
"max_issues_repo_path": "src/plfa/part1/Bin.agda",
"max_line_length": 51,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "abolotina/plfa.github.io",
"max_stars_repo_path": "src/plfa/part1/Bin.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 326,
"size": 835
} |
module Oscar.Class.Equivalence where
open import Oscar.Class.Reflexivity
open import Oscar.Class.Symmetry
open import Oscar.Class.Transitivity
open import Oscar.Function
open import Oscar.Level
record Equivalence {a} {A : Set a} {ℓ} (_≋_ : A → A → Set ℓ) : Set (a ⊔ ℓ) where
field
⦃ ′reflexivity ⦄ : Reflexivity _≋_
⦃ ′symmetry ⦄ : Symmetry _≋_
⦃ ′transitivity ⦄ : Transitivity _≋_
open Equivalence ⦃ … ⦄ public hiding (′reflexivity; ′symmetry; ′transitivity)
instance
Equivalence⋆ : ∀
{a} {A : Set a} {ℓ} {_≋_ : A → A → Set ℓ}
⦃ _ : Reflexivity _≋_ ⦄
⦃ _ : Symmetry _≋_ ⦄
⦃ _ : Transitivity _≋_ ⦄
→ Equivalence _≋_
Equivalence.′reflexivity Equivalence⋆ = it
Equivalence.′symmetry Equivalence⋆ = it
Equivalence.′transitivity Equivalence⋆ = it
| {
"alphanum_fraction": 0.6687737042,
"avg_line_length": 27.275862069,
"ext": "agda",
"hexsha": "1076cdbc1ee33d0a77e7aabb5c9721d2df620273",
"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/Class/Equivalence.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/Class/Equivalence.agda",
"max_line_length": 80,
"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/Class/Equivalence.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 308,
"size": 791
} |
module sv20.assign2.Second_old4 where
open import Data.Bool as Bool using (Bool; true; false; T; _∨_; _∧_)
--open import Relation.Nullary using (¬_)
open import Data.Unit using (⊤; tt)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_)
open import Level using (Level; _⊔_; 0ℓ) renaming (suc to lsuc)
--open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_×_; ∃-syntax) renaming (_,_ to ⟨_,_⟩)
open import Function using (_∘_)
--import Relation.Binary.PropositionalEquality as Eq
--open Eq using (_≡_; refl; subst)
Subset : ∀ {α} (A : Set α) -> Set _
Subset A = A → Bool
_∈_ : ∀ {α} {A : Set α} → A → Subset A → Set
a ∈ p = T (p a)
--odd : Subset ℕ
--odd 0 = false
--odd 1 = true
--odd (suc (suc n)) = odd n
--
--_ : 3 ∈ odd
--_ = tt
--
--_ : Subset Set -- I'm not actually sure, what this is
--_ = λ _ → true
-- _ : true ∈ odd -- Doesn't make sense. Type inference fails
--_ = ?
--∈or∉ : ∀ {A : Set} (SubA : Subset A) (a : A) → (a ∈ SubA) ⊎ ¬ (a ∈ SubA)
--∈or∉ subset a with subset a
--... | true = inj₁ tt
--... | false = inj₂ ⊥-elim
--
--empty-⊥ : ∀ (sub : Subset ⊥) (a : ⊥) → ¬ (a ∈ sub)
--empty-⊥ _ ()
--¬⊥ : ∀ (A : Set) → ¬ (⊥ ∈ A) -- doesn't make any sense
--¬⊥ = ?
Relation : ∀ {α β} (A : Set α) (B : Set β) → Set (α ⊔ β)
Relation A B = Subset (A × B)
--equalℕ : Relation ℕ ℕ
--equalℕ ⟨ zero , zero ⟩ = true
--equalℕ ⟨ zero , (suc n) ⟩ = false
--equalℕ ⟨ (suc m) , zero ⟩ = false
--equalℕ ⟨ (suc m) , (suc n) ⟩ = equalℕ ⟨ m , n ⟩
--_ : equalℕ ⟨ 3 , 4 ⟩ ≡ false
--_ = refl
_∪_ : ∀ {A : Set} → Subset A → Subset A → Subset A
A ∪ B = λ x → (A x) ∨ (B x)
_∩_ : ∀ {A : Set} → Subset A → Subset A → Subset A
A ∩ B = λ x → (A x) ∧ (B x)
_⊆_ : ∀ {A : Set} → Subset A → Subset A → Set
A ⊆ B = ∀ x → x ∈ A → x ∈ B
wholeSet : ∀ (A : Set) → Subset A
wholeSet _ = λ _ → true
--odd⊆ℕ : odd ⊆ wholeSet ℕ
----odd⊆ℕ zero ()
----odd⊆ℕ 1 tt = tt
----odd⊆ℕ (suc (suc n)) _ = tt
---- or, simply
--odd⊆ℕ _ _ = tt
-- In general
∀subset⊆set : ∀ {A : Set} {sub : Subset A} → sub ⊆ wholeSet A
∀subset⊆set = λ _ _ → tt
record _⇔_ (A B : Set) : Set where
field
to : A → B
from : B → A
record Range (A B : Set) : Set where
field
range : Relation A B → Subset B
def : ∀ (rel : Relation A B) (b : B)
→ (∃[ a ] (⟨ a , b ⟩ ∈ rel))
⇔ (b ∈ range rel)
--lemma : ∀ {A B : Set}
-- (F G : Relation A B)
-- (b : B)
-- → ∃[ a ] (⟨ a , b ⟩ ∈ (F ∩ G))
-- → ∃[ a ] ((⟨ a , b ⟩ ∈ F) × (⟨ a , b ⟩ ∈ G))
--lemma f g b ⟨ a , f∩ga ⟩ with f ⟨ a , b ⟩ | g ⟨ a , b ⟩
--... | true | true = ⟨ ? , ⟨ ? , ? ⟩ ⟩
--... | true | false = ⊥-elim f∩ga
--... | false | true = ⊥-elim f∩ga
--... | false | false = ⊥-elim f∩ga
--
--module range-props {A B : Set} (rng : Range A B) where
-- range = Range.range rng
-- def = Range.def rng
--
-- range-∩-⊆ : (F G : Relation A B)
-- → range (F ∩ G) ⊆ (range F ∩ range G)
-- range-∩-⊆ f g b = ?
-- where
-- --def-rngf-→ = _⇔_.to (def f b)
--
-- -- b ∈ range (f ∩ g) → ∃[ a ] (⟨ a , b ⟩ ∈ (f ∩ g))
-- def-rngf-← = _⇔_.from (def (f ∩ g) b)
-- -- b ∈ range (f ∩ g) → ∃[ a ] ((⟨ a , b ⟩ ∈ F) × (⟨ a , b ⟩ ∈ G))
-- lemma' = (lemma f g b) ∘ def-rngf-←
-- Class exercise
-- Dammit! All definitions of subset I have found for agda make this problem not a problem
exercise103a : ∀ {a} {A B : Subset a}
→ (∀ x → x ∈ A → x ∈ B)
→ A ⊆ B
exercise103a ∀x→x∈A→x∈B = ∀x→x∈A→x∈B
| {
"alphanum_fraction": 0.464811784,
"avg_line_length": 29.328,
"ext": "agda",
"hexsha": "b6bb0c61d46835f14d2342fccfce4645a6d2589b",
"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/sv20/assign2/Second_old4.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/sv20/assign2/Second_old4.agda",
"max_line_length": 90,
"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/sv20/assign2/Second_old4.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1510,
"size": 3666
} |
-- Andreas, 2018-05-11, issue #3049 reported by Ulf
-- Positivity checker too optimistic about polarity of arguments
-- beyond the formal function arity.
-- Backwards-compatible version of the test case.
-- {-# OPTIONS -v tc.pos.args:100 #-}
module Issue3049 where
data Bool : Set where
true false : Bool
T : Bool → Set₁
T true = Set → Set
T false = Set
bad : ∀ b → T b
bad true = λ A → A → A -- negative A
bad false = Bool
F : Bool → ∀ b → T b
F true b = bad b -- is not (can't be) eta-expanded
F false true = λ A → A
F false false = Bool
-- Should fail positivity check:
data D : Set where
nop : (b : Bool) → F b true D → D
data ⊥ : Set where
d : D
d = nop true (λ x → x)
!d : D → ⊥
!d (nop true f) = !d (f d)
!d (nop false x) = !d x
loop : ⊥
loop = !d d
| {
"alphanum_fraction": 0.6007556675,
"avg_line_length": 18.4651162791,
"ext": "agda",
"hexsha": "96f5e2faaf2d1a019d82a69a9034db3cbaa96245",
"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/Issue3049.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/Issue3049.agda",
"max_line_length": 64,
"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/Issue3049.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": 269,
"size": 794
} |
-- Andreas, 2012-10-20
module Issue481NonExistentModule where
open import NonExistentModule Set
-- test the error message and location
| {
"alphanum_fraction": 0.7985611511,
"avg_line_length": 15.4444444444,
"ext": "agda",
"hexsha": "8b119e571de4f1f26fa5f581acd8eccf9ec7b2ee",
"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/Issue481NonExistentModule.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/Issue481NonExistentModule.agda",
"max_line_length": 38,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/fail/Issue481NonExistentModule.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": 36,
"size": 139
} |
module Haskell.Prim.Traversable where
open import Haskell.Prim
open import Haskell.Prim.Applicative
open import Haskell.Prim.Functor
open import Haskell.Prim.Foldable
open import Haskell.Prim.Monad
open import Haskell.Prim.List
open import Haskell.Prim.Maybe
open import Haskell.Prim.Either
open import Haskell.Prim.Tuple
--------------------------------------------------
-- Traversable
record Traversable (t : Set → Set) : Set₁ where
field
traverse : ⦃ Applicative f ⦄ → (a → f b) → t a → f (t b)
overlap ⦃ functor ⦄ : Functor t
overlap ⦃ foldable ⦄ : Foldable t
sequenceA : ⦃ Applicative f ⦄ → t (f a) → f (t a)
sequenceA = traverse id
mapM : ⦃ Monad m ⦄ → (a → m b) → t a → m (t b)
mapM = traverse
sequence : ⦃ Monad m ⦄ → t (m a) → m (t a)
sequence = sequenceA
open Traversable ⦃ ... ⦄ public
instance
iTraversableList : Traversable List
iTraversableList .traverse f [] = pure []
iTraversableList .traverse f (x ∷ xs) = ⦇ f x ∷ traverse f xs ⦈
iTraversableMaybe : Traversable Maybe
iTraversableMaybe .traverse f Nothing = pure Nothing
iTraversableMaybe .traverse f (Just x) = Just <$> f x
iTraversableEither : Traversable (Either a)
iTraversableEither .traverse f (Left x) = pure (Left x)
iTraversableEither .traverse f (Right y) = Right <$> f y
iTraversablePair : Traversable (a ×_)
iTraversablePair .traverse f (x , y) = (x ,_) <$> f y
| {
"alphanum_fraction": 0.6591070163,
"avg_line_length": 28.7959183673,
"ext": "agda",
"hexsha": "beec7aa74a29ce9138dcd904668ce44aace268c8",
"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": "4cb28f1b5032948b19b977b390fa260be292abf6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "flupe/agda2hs",
"max_forks_repo_path": "lib/Haskell/Prim/Traversable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6",
"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": "flupe/agda2hs",
"max_issues_repo_path": "lib/Haskell/Prim/Traversable.agda",
"max_line_length": 65,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "flupe/agda2hs",
"max_stars_repo_path": "lib/Haskell/Prim/Traversable.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 451,
"size": 1411
} |
open import Data.List using ( List ; [] ; _∷_ )
open import Data.List.Any using ( here ; there )
open import Data.Product using ( _,_ ; proj₁ ; proj₂ )
open import Data.Sum using ( inj₁ ; inj₂ )
open import Relation.Binary.PropositionalEquality using
( refl ; sym ; trans ; subst₂ )
open import Relation.Unary using ( _∈_ ; _⊆_ )
open import Web.Semantic.DL.ABox using
( ABox ; ε ; _,_ ; _∼_ ; ⟨ABox⟩ ; Assertions
; ⟨ABox⟩-resp-id ; ⟨ABox⟩-resp-∘ ; ⟨ABox⟩-resp-∘² )
open import Web.Semantic.DL.ABox.Interp using ( Interp ; _,_ ; ⌊_⌋ ; ind ; _*_ )
open import Web.Semantic.DL.ABox.Interp.Morphism using ( _,_ )
open import Web.Semantic.DL.ABox.Model using
( _⊨a_ ; *-resp-⟨ABox⟩ ; ⊨a-resp-⊇ )
open import Web.Semantic.DL.Category.Object using
( Object ; _,_ ; IN ; fin ; iface )
open import Web.Semantic.DL.Category.Morphism using
( _⇒_ ; _,_ ; BN ; impl )
open import Web.Semantic.DL.Category.Tensor using ( _⊗_ )
open import Web.Semantic.DL.Category.Unit using ( I )
open import Web.Semantic.DL.Integrity using
( Unique ; Mediator ; Initial ; _⊕_⊨_ ; _,_ )
open import Web.Semantic.DL.KB using ( _,_ )
open import Web.Semantic.DL.KB.Model using ( _⊨_ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox using ( TBox ; _,_ )
open import Web.Semantic.DL.TBox.Interp using
( _⊨_≈_ ; ≈-refl ; ≈-sym ; ≈-trans )
open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-refl ; ≲-image )
open import Web.Semantic.DL.TBox.Model using ( _⊨t_ )
open import Web.Semantic.Util using
( id ; _∘_ ; False ; tt ; ⊎-swap ; ⊎-assoc ; ⊎-assoc⁻¹ ; ⊎-unit₁ ; ⊎-unit₂
; _∈ˡ_ ; _⊕_⊕_ ; inode ; bnode ; enode )
module Web.Semantic.DL.Category.Wiring {Σ : Signature} where
wires : ∀ {X Y} → (Y → X) → List Y → ABox Σ (X ⊕ False ⊕ Y)
wires f [] = ε
wires f (y ∷ ys) = (inode (f y) ∼ enode y , wires f ys)
wires-≈ : ∀ {X Y y ys I} (f : Y → X) → (y ∈ˡ ys) → (I ⊨a wires f ys) →
(⌊ I ⌋ ⊨ ind I (inode (f y)) ≈ ind I (enode y))
wires-≈ f (here refl) (x≈y , xs≈ys) = x≈y
wires-≈ f (there y∈ys) (x≈y , xs≈ys) = wires-≈ f y∈ys xs≈ys
wires-≈⁻¹ : ∀ {X Y I} (f : Y → X) →
(∀ y → ⌊ I ⌋ ⊨ ind I (inode (f y)) ≈ ind I (enode y)) →
∀ ys → (I ⊨a wires f ys)
wires-≈⁻¹ f ∀y∙x≈y [] = tt
wires-≈⁻¹ f ∀y∙x≈y (y ∷ ys) = (∀y∙x≈y y , wires-≈⁻¹ f ∀y∙x≈y ys)
wired : ∀ {X Y} → (Y → X) → (X ⊕ False ⊕ Y) → X
wired f (inode x) = x
wired f (bnode ())
wired f (enode y) = f y
wired-init : ∀ {X Y} (f : Y → X) ys → (∀ y → y ∈ˡ ys) →
(I : Interp Σ X) → (S : TBox Σ) → (⌊ I ⌋ ⊨t S) →
(wired f * I ∈ Initial I (S , wires f ys))
wired-init f ys ∀y∙y∈ys (I , i) S I⊨S =
( (≲-refl I , λ x → ≈-refl I)
, (I⊨S , wires-≈⁻¹ f (λ x → ≈-refl I) ys)
, mediator ) where
mediator : Mediator (I , i) (I , i ∘ wired f)
(≲-refl I , λ x → ≈-refl I) (S , wires f ys)
mediator (K , k) (I≲K , i≲k) (K⊨S , K⊨F) =
((I≲K , j≲k) , (λ x → ≈-refl K) , uniq ) where
j≲k : ∀ x → K ⊨ ≲-image I≲K (i (wired f x)) ≈ k x
j≲k (inode x) = i≲k x
j≲k (bnode ())
j≲k (enode y) = ≈-trans K (i≲k (f y)) (wires-≈ f (∀y∙y∈ys y) K⊨F)
uniq : Unique (I , i) (I , i ∘ wired f) (K , k)
(≲-refl I , λ x → ≈-refl I) (I≲K , i≲k)
uniq J≲₁K J≲₂K I≲K≋I≲J≲₁K I≲K≋I≲J≲₂K x =
≈-trans K (≈-sym K (I≲K≋I≲J≲₁K x)) (I≲K≋I≲J≲₂K x)
wires✓ : ∀ {X Y ys} (f : Y → X) → (∀ y → y ∈ˡ ys) →
(S T : TBox Σ) (A : ABox Σ X) (B : ABox Σ Y) →
(Assertions (⟨ABox⟩ f B) ⊆ Assertions A) →
(I : Interp Σ X) → (I ⊨ (S , T) , A) → (I ⊕ S , wires f ys ⊨ T , B)
wires✓ {X} {Y} {ys} f ∀y∙y∈ys S T A B B⊆A I I⊨STA =
(J , J-init , (J⊨T , J⊨B)) where
J : Interp Σ (X ⊕ False ⊕ Y)
J = wired f * I
J⊨T : ⌊ J ⌋ ⊨t T
J⊨T = proj₂ (proj₁ I⊨STA)
J⊨B : enode * J ⊨a B
J⊨B = *-resp-⟨ABox⟩ f I B (⊨a-resp-⊇ I (⟨ABox⟩ f B) A B⊆A (proj₂ I⊨STA))
J-init : J ∈ Initial I (S , wires f ys)
J-init = wired-init f ys ∀y∙y∈ys I S (proj₁ (proj₁ I⊨STA))
wiring-impl : ∀ {S T : TBox Σ} → (A B : Object S T) (f : IN B → IN A) →
ABox Σ (IN A ⊕ False ⊕ IN B)
wiring-impl A B f =
wires f (proj₁ (fin B))
wiring-impl✓ : ∀ {S T : TBox Σ} → (A B : Object S T) (f : IN B → IN A) →
(Assertions (⟨ABox⟩ f (iface B)) ⊆ Assertions (iface A)) →
∀ I → (I ⊨ (S , T) , iface A) → (I ⊕ (S , wiring-impl A B f) ⊨ (T , iface B))
wiring-impl✓ {S} {T} (X , X∈Fin , A) (Y , Y∈Fin , B) f B⊆A =
wires✓ f (proj₂ Y∈Fin) S T A B B⊆A
wiring : ∀ {S T : TBox Σ} → (A B : Object S T) (f : IN B → IN A) →
(Assertions (⟨ABox⟩ f (iface B)) ⊆ Assertions (iface A)) →
(A ⇒ B)
wiring A B f B⊆A =
( False , wiring-impl A B f , wiring-impl✓ A B f B⊆A )
id✓ : ∀ {S T : TBox Σ} → (A : Object S T) →
(Assertions (⟨ABox⟩ id (iface A)) ⊆ Assertions (iface A))
id✓ A = subst₂ Assertions (⟨ABox⟩-resp-id (iface A)) refl
identity : ∀ {S T : TBox Σ} → (A : Object S T) → (A ⇒ A)
identity A = wiring A A id (id✓ A)
⊎-swap✓ : ∀ {S T : TBox Σ} → (A B : Object S T) →
Assertions (⟨ABox⟩ ⊎-swap (iface (B ⊗ A))) ⊆ Assertions (iface (A ⊗ B))
⊎-swap✓ A B (inj₁ b∈B) =
inj₂ (subst₂ Assertions (⟨ABox⟩-resp-∘ ⊎-swap inj₁ (iface B)) refl b∈B)
⊎-swap✓ A B (inj₂ a∈A) =
inj₁ (subst₂ Assertions (⟨ABox⟩-resp-∘ ⊎-swap inj₂ (iface A)) refl a∈A)
symm : ∀ {S T : TBox Σ} → (A B : Object S T) → ((A ⊗ B) ⇒ (B ⊗ A))
symm A B = wiring (A ⊗ B) (B ⊗ A) ⊎-swap (⊎-swap✓ A B)
⊎-assoc⁻¹✓ : ∀ {S T : TBox Σ} → (A B C : Object S T) →
(Assertions (⟨ABox⟩ ⊎-assoc⁻¹ (iface (A ⊗ (B ⊗ C))))) ⊆
(Assertions (iface ((A ⊗ B) ⊗ C)))
⊎-assoc⁻¹✓ A B C (inj₁ a∈A) = inj₁ (inj₁ (subst₂ Assertions
(trans (⟨ABox⟩-resp-∘ ⊎-assoc⁻¹ inj₁ (iface A))
(sym (⟨ABox⟩-resp-∘ inj₁ inj₁ (iface A))))
refl a∈A))
⊎-assoc⁻¹✓ A B C (inj₂ (inj₁ b∈B)) = inj₁ (inj₂ (subst₂ Assertions
(trans (⟨ABox⟩-resp-∘² ⊎-assoc⁻¹ inj₂ inj₁ (iface B))
(sym (⟨ABox⟩-resp-∘ inj₁ inj₂ (iface B))))
refl b∈B))
⊎-assoc⁻¹✓ A B C (inj₂ (inj₂ c∈C)) = inj₂ (subst₂ Assertions
(⟨ABox⟩-resp-∘² ⊎-assoc⁻¹ inj₂ inj₂ (iface C))
refl c∈C)
assoc : ∀ {S T : TBox Σ} → (A B C : Object S T) →
(((A ⊗ B) ⊗ C) ⇒ (A ⊗ (B ⊗ C)))
assoc A B C = wiring ((A ⊗ B) ⊗ C) (A ⊗ (B ⊗ C)) ⊎-assoc⁻¹ (⊎-assoc⁻¹✓ A B C)
⊎-assoc✓ : ∀ {S T : TBox Σ} → (A B C : Object S T) →
(Assertions (⟨ABox⟩ ⊎-assoc (iface ((A ⊗ B) ⊗ C)))) ⊆
(Assertions (iface (A ⊗ (B ⊗ C))))
⊎-assoc✓ A B C (inj₁ (inj₁ a∈A)) = inj₁ (subst₂ Assertions
(⟨ABox⟩-resp-∘² ⊎-assoc inj₁ inj₁ (iface A))
refl a∈A)
⊎-assoc✓ A B C (inj₁ (inj₂ b∈B)) = inj₂ (inj₁ (subst₂ Assertions
(trans (⟨ABox⟩-resp-∘² ⊎-assoc inj₁ inj₂ (iface B))
(sym (⟨ABox⟩-resp-∘ inj₂ inj₁ (iface B))))
refl b∈B))
⊎-assoc✓ A B C (inj₂ c∈C) = inj₂ (inj₂ (subst₂ Assertions
(trans (⟨ABox⟩-resp-∘ ⊎-assoc inj₂ (iface C))
(sym (⟨ABox⟩-resp-∘ inj₂ inj₂ (iface C))))
refl c∈C))
assoc⁻¹ : ∀ {S T : TBox Σ} → (A B C : Object S T) →
((A ⊗ (B ⊗ C)) ⇒ ((A ⊗ B) ⊗ C))
assoc⁻¹ A B C = wiring (A ⊗ (B ⊗ C)) ((A ⊗ B) ⊗ C) ⊎-assoc (⊎-assoc✓ A B C)
inj₂✓ : ∀ {S T : TBox Σ} → (A : Object S T) →
(Assertions (⟨ABox⟩ inj₂ (iface A))) ⊆
(Assertions (iface (I ⊗ A)))
inj₂✓ A = inj₂
unit₁ : ∀ {S T : TBox Σ} (A : Object S T) → ((I ⊗ A) ⇒ A)
unit₁ A = wiring (I ⊗ A) A inj₂ (inj₂✓ A)
⊎-unit₁✓ : ∀ {S T : TBox Σ} → (A : Object S T) →
Assertions (⟨ABox⟩ ⊎-unit₁ (iface (I ⊗ A))) ⊆ Assertions (iface A)
⊎-unit₁✓ A (inj₁ ())
⊎-unit₁✓ A (inj₂ a∈A) = subst₂ Assertions
(trans (⟨ABox⟩-resp-∘ ⊎-unit₁ inj₂ (iface A)) (⟨ABox⟩-resp-id (iface A)))
refl a∈A
unit₁⁻¹ : ∀ {S T : TBox Σ} (A : Object S T) → (A ⇒ (I ⊗ A))
unit₁⁻¹ A = wiring A (I ⊗ A) ⊎-unit₁ (⊎-unit₁✓ A)
inj₁✓ : ∀ {S T : TBox Σ} → (A : Object S T) →
(Assertions (⟨ABox⟩ inj₁ (iface A))) ⊆
(Assertions (iface (A ⊗ I)))
inj₁✓ A = inj₁
unit₂ : ∀ {S T : TBox Σ} (A : Object S T) → ((A ⊗ I) ⇒ A)
unit₂ A = wiring (A ⊗ I) A inj₁ (inj₁✓ A)
⊎-unit₂✓ : ∀ {S T : TBox Σ} (A : Object S T) →
Assertions (⟨ABox⟩ ⊎-unit₂ (iface (A ⊗ I))) ⊆ Assertions (iface A)
⊎-unit₂✓ A (inj₁ a∈A) = subst₂ Assertions
(trans (⟨ABox⟩-resp-∘ ⊎-unit₂ inj₁ (iface A)) (⟨ABox⟩-resp-id (iface A)))
refl a∈A
⊎-unit₂✓ A (inj₂ ())
unit₂⁻¹ : ∀ {S T : TBox Σ} (A : Object S T) → (A ⇒ (A ⊗ I))
unit₂⁻¹ A = wiring A (A ⊗ I) ⊎-unit₂ (⊎-unit₂✓ A)
| {
"alphanum_fraction": 0.5322540781,
"avg_line_length": 39.2815533981,
"ext": "agda",
"hexsha": "fb189a2ac0c648021e4bf61b3378c80a25582b0e",
"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/Wiring.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/Wiring.agda",
"max_line_length": 81,
"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/Wiring.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": 4059,
"size": 8092
} |
module _ where
module Test₁ where
module A where
infixl 0 _+_
data D : Set where
• : D
_+_ : D → D → D
module B where
data D : Set where
• : D
_+_ : D → D → D
open A
open B
Foo : A.D
Foo = • + • + •
module Test₂ where
module A where
data D : Set where
• : D
_+_ : D → D → D
module B where
data D : Set where
• : D
_+_ : D → D → D
open A
open B
Foo : A.D
Foo = • + •
module Test₃ where
module A where
data D : Set where
• : D
c : D → D → D
syntax c x y = x + y
module B where
data D : Set where
• : D
c : D → D → D
syntax c x y = x + y
open A
open B
Foo : A.D
Foo = • + •
| {
"alphanum_fraction": 0.4404283802,
"avg_line_length": 10.9852941176,
"ext": "agda",
"hexsha": "f8d822a298a1f1ed2ad7fd3c0cdd3ab6730a9807",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue1436-18.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue1436-18.agda",
"max_line_length": 24,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue1436-18.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": 277,
"size": 747
} |
postulate
A : Set
B : Set
t : B
data C : (b : B) → Set
foo : (b : B) → C b → B
data C where
c : (x : C t) → C (foo t x)
foo b x = {!x!}
| {
"alphanum_fraction": 0.4256756757,
"avg_line_length": 10.5714285714,
"ext": "agda",
"hexsha": "0b0efefaf6555c6c82ff2a6f6220ad4c1e9930c1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/interaction/Issue3032.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/interaction/Issue3032.agda",
"max_line_length": 29,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue3032.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": 70,
"size": 148
} |
module Syntax.Implication.Dependent where
open import Functional using (id)
open import Functional.Dependent
import Lvl
open import Type
private variable ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Lvl.Level
_⇒-[_]_ : ∀(X : Type{ℓ₁}){Y : ∀{_ : X} → Type{ℓ₂}}{Z : ∀{x : X}{_ : Y{x}} → Type{ℓ₃}} → (P : (x : X) → Y{x}) → (∀{x : X} → (y : Y{x}) → Z{x}{y}) → ((x : X) → Z{x}{P(x)})
_⇒-[_]_ = const(swap(_∘_))
infixr 0.98 _⇒-[_]_
{-# INLINE _⇒-[_]_ #-}
_⇒-[]_ : ∀(X : Type{ℓ₁}){Y : ∀{_ : X} → Type{ℓ₂}} → ((x : X) → Y{x}) → ((x : X) → Y{x})
_⇒-[]_ = const id
infixr 0.98 _⇒-[]_
{-# INLINE _⇒-[]_ #-}
_⇒-end : ∀(X : Type{ℓ₁}) → (X → X)
_⇒-end = const id
infixr 0.99 _⇒-end
{-# INLINE _⇒-end #-}
_⇒_ = apply
infixl 0.97 _⇒_
{-# INLINE _⇒_ #-}
-- TODO: Change these to be similar to the ones in Syntax.Implication
•_⇒₁_ = apply
infixl 0.97 •_⇒₁_
{-# INLINE •_⇒₁_ #-}
•_•_⇒₂_ : ∀{X : Type{ℓ₁}}{Y : ∀{_ : X} → Type{ℓ₂}}{Z : ∀{x : X}{_ : Y{x}} → Type{ℓ₃}} → (x : X) → (y : Y{x}) → ((x : X) → (y : Y{x}) → Z{x}{y}) → Z{x}{y}
• a • b ⇒₂ P = P ⇒ apply a ⇒ apply b
infixl 0.97 •_•_⇒₂_
{-# INLINE •_•_⇒₂_ #-}
•_•_•_⇒₃_ : ∀{X : Type{ℓ₁}}{Y : ∀{_ : X} → Type{ℓ₂}}{Z : ∀{x : X}{_ : Y{x}} → Type{ℓ₃}}{W : ∀{x : X}{y : Y{x}}{_ : Z{x}{y}} → Type{ℓ₄}} → (x : X) → (y : Y{x}) → (z : Z{x}{y}) → ((x : X) → (y : Y{x}) → (z : Z{x}{y}) → W{x}{y}{z}) → W{x}{y}{z}
• a • b • c ⇒₃ P = P ⇒ apply a ⇒ apply b ⇒ apply c
infixl 0.97 •_•_•_⇒₃_
{-# INLINE •_•_•_⇒₃_ #-}
| {
"alphanum_fraction": 0.4615384615,
"avg_line_length": 32.9534883721,
"ext": "agda",
"hexsha": "963058a04eeeee0cf6f9d9e0801b5d77f457e959",
"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/Dependent.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/Dependent.agda",
"max_line_length": 241,
"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/Dependent.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": 765,
"size": 1417
} |
module Numeral.Natural.Oper where
open import Numeral.Natural
infixl 10010 _+_
infix 10010 _−₀_ _𝄩_
infixl 10020 _⋅_
-- infix 10020 _/₀_
infixl 10030 _^_
-- TODO: It would require a great amount of work, but consider changing the induction to being on the left side instead of the right on _+_ and _⋅_. It will then mirror how lists (a similar structure) uses induction in its definition. The advantage of having it on the right side as it is now is that induction using the full operator name is easier: ℕ-induction(_+_ a) vs ℕ-induction(a ↦ _+_ a b)
-- Addition
_+_ : ℕ → ℕ → ℕ
x + 𝟎 = x
x + 𝐒(y) = 𝐒(x + y)
{-# BUILTIN NATPLUS _+_ #-}
-- Multiplication
_⋅_ : ℕ → ℕ → ℕ
_ ⋅ 𝟎 = 𝟎
x ⋅ 𝐒(y) = x + (x ⋅ y)
{-# BUILTIN NATTIMES _⋅_ #-}
-- Exponentiation
_^_ : ℕ → ℕ → ℕ
x ^ 𝟎 = 𝐒(𝟎)
x ^ 𝐒(y) = x ⋅ (x ^ y)
-- Factorial
_! : ℕ → ℕ
𝟎 ! = 𝐒(𝟎)
𝐒(x) ! = 𝐒(x) ⋅ (x !)
-- Distance (Absolute subtraction) (Interval length)
_𝄩_ : ℕ → ℕ → ℕ
𝟎 𝄩 𝟎 = 𝟎
𝐒(x) 𝄩 𝟎 = 𝐒(x)
𝟎 𝄩 𝐒(x) = 𝐒(x)
𝐒(x) 𝄩 𝐒(y) = x 𝄩 y
-- Closed total subtraction (monus)
_−₀_ : ℕ → ℕ → ℕ
x −₀ 𝟎 = x
𝟎 −₀ 𝐒(_) = 𝟎
𝐒(x) −₀ 𝐒(y) = x −₀ y
{-# BUILTIN NATMINUS _−₀_ #-}
-- Closed total ceiled division (rounding up)
{-# TERMINATING #-}
_⌈/₀⌉_ : ℕ → ℕ → ℕ
𝟎 ⌈/₀⌉ y = 𝟎
{-# CATCHALL #-}
x ⌈/₀⌉ 𝟎 = 𝟎
{-# CATCHALL #-}
x ⌈/₀⌉ y = 𝐒((x −₀ y) ⌈/₀⌉ y)
-- Hyperoperation: (a ↑[n]↑ b) where (n=0)⇒(_ ↦ 𝐒) , (n=1)⇒(+) , (n=2)⇒(⋅) , (n=3)⇒(^)
_↑[_]↑_ : ℕ → ℕ → ℕ → ℕ
_ ↑[ 0 ]↑ b = 𝐒(b)
a ↑[ 1 ]↑ 0 = a
_ ↑[ 2 ]↑ 0 = 0
_ ↑[ 𝐒(𝐒(𝐒(n))) ]↑ 0 = 1
{-# CATCHALL #-}
a ↑[ 𝐒(n) ]↑ (𝐒(b)) = a ↑[ n ]↑ (a ↑[ n ]↑ b)
| {
"alphanum_fraction": 0.5266089109,
"avg_line_length": 23.7647058824,
"ext": "agda",
"hexsha": "164d83523a0a18417516f9bc78279691ff24fd52",
"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/Natural/Oper.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/Natural/Oper.agda",
"max_line_length": 397,
"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/Natural/Oper.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": 826,
"size": 1616
} |
{-# OPTIONS --without-K #-}
{- Here, truncations with propositional computational behaviour are defined.
This lack of a definitional β-rule enabled us to talk about this notion
inside type theory without truncations, albeit complicating setup and proofs.
After definition and basic accessories concerning universal properties,
recursion and elimination, we prove that truncation is functorial.
With this, we turn our attention to the problem of uniqueness of truncation,
i.e. the type of truncations of a given type being propositional. -}
module Universe.Trunc.Basics where
open import lib.Basics
open import lib.NType2
open import lib.Equivalences2
open import lib.types.Unit
open import lib.types.Nat hiding (_+_)
open import lib.types.Pi
open import lib.types.Sigma
open import lib.types.Paths
open import Universe.Utility.General
open import Universe.Utility.TruncUniverse
open import Universe.Trunc.Universal
-- *** Definition 6.4 ***
record trunc-ty {i} (n : ℕ₋₂) (A : Type i)
(j : ULevel) : Type (lsucc (i ⊔ j)) where
constructor ty-cons
field
type : n -Type i
cons : A → ⟦ type ⟧
univ : univ-Type type cons j
module _ {i} {n : ℕ₋₂} {A : Type i} where
trunc-ty-lower : ∀ {j₀} (j₁ : ULevel) → trunc-ty n A (j₀ ⊔ j₁) → trunc-ty n A j₀
trunc-ty-lower {j₀} j₁ (ty-cons t c u) = ty-cons t c (univ-lower t c (j₀ ⊔ j₁) u)
{- Since Agda does not support specifying ordering relations on universe levels,
we encounter an awkward dependency inversion: the index k needs to be
specified in the module arguments, since the truncation type depends on it,
even though we would rather have it at each individual definition.
This shortcoming will be the source of many explicitely specified levels. -}
module trunc-props {i} {n : ℕ₋₂} {A : Type i} {j k} (tr : trunc-ty n A (i ⊔ j ⊔ k)) where
open trunc-ty tr
up : (U : n -Type k) → (⟦ type ⟧ → ⟦ U ⟧) ≃ (A → ⟦ U ⟧)
up U = ((λ f → f ∘ cons) , univ-lower type cons (i ⊔ j ⊔ k) univ U)
dup : (U : ⟦ type ⟧ → n -Type k) → ((ta : ⟦ type ⟧) → ⟦ U ta ⟧) ≃ ((a : A) → ⟦ U (cons a) ⟧)
dup U = ((λ f → f ∘ cons) , with-univ.duniv type cons (univ-lower type cons (i ⊔ j ⊔ k) univ) U)
abstract
rec : (U : n -Type k) → (A → ⟦ U ⟧) → ⟦ type ⟧ → ⟦ U ⟧
rec U = <– (up U)
elim : (U : ⟦ type ⟧ → n -Type k) → ((a : A) → ⟦ U (cons a) ⟧) → (ta : ⟦ type ⟧) → ⟦ U ta ⟧
elim U = <– (dup U)
rec-β : {U : n -Type k} {f : A → ⟦ U ⟧} (a : A) → rec U f (cons a) == f a
rec-β {U} {f} a = app= (<–-inv-r (up U) f) a
elim-β : {U : ⟦ type ⟧ → n -Type k} {f : (a : A) → ⟦ U (cons a) ⟧} (a : A) → elim U f (cons a) == f a
elim-β {U} {f} a = app= (<–-inv-r (dup U) f) a
{- Truncation acts as a functor.
While tedious, we state all lemmata in their most general form.
Instead of assuming an n-truncation operator, we individually assume
a truncation for each type we need. While seeming overly convoluted
at first, this generality will actually pay off with an unconventional
use of fmap-equiv in showing that trunc-ty is propositional. -}
module trunc-functor {n : ℕ₋₂} where
open trunc-ty
open trunc-props
-- The functorial action of truncation (truncation preserves maps).
module _ {ia ib j} where
module fmap {A : Type ia} {B : Type ib}
(TrA : trunc-ty n A (ia ⊔ ib ⊔ j))
(TrB : trunc-ty n B (ia ⊔ ib ⊔ j))
(f : A → B) where
map : ⟦ type TrA ⟧ → ⟦ type TrB ⟧
map = rec {j = ia ⊔ ib ⊔ j} TrA (type TrB) (cons TrB ∘ f)
β : (a : A) → map (cons TrA a) == cons TrB (f a)
β = rec-β TrA {type TrB}
-- The functorial action preserves the identity.
module _ {i j} {A : Type i} (TrA : trunc-ty n A (i ⊔ j)) where
private
module I = fmap {j = i ⊔ j} TrA TrA (idf _)
fmap-fuse-id : (ta : ⟦ type TrA ⟧) → I.map ta == ta
fmap-fuse-id = elim {j = i ⊔ j} TrA (λ ta → Path-≤ (type TrA) (I.map ta) ta) I.β
-- The functorial action preserves composition.
module _ {ia ib ic j} where
private
l : ULevel
l = ia ⊔ ib ⊔ ic ⊔ j
module _ {A : Type ia} {B : Type ib} {C : Type ic}
(TrA : trunc-ty n A l)
(TrB : trunc-ty n B l)
(TrC : trunc-ty n C l)
(f : A → B) (g : B → C) where
private
module F = fmap {j = l} TrA TrB f
module G = fmap {j = l} TrB TrC g
module GF = fmap {j = l} TrA TrC (g ∘ f)
open trunc-props
fmap-fuse-∘ : (ta : ⟦ type TrA ⟧) → GF.map ta == G.map (F.map ta)
fmap-fuse-∘ = elim {j = l} TrA (λ ta →
Path-≤ (type TrC) (GF.map ta) (G.map (F.map ta))) $ λ a →
GF.map (cons TrA a) =⟨ GF.β a ⟩
cons TrC (g (f a)) =⟨ ! (G.β (f a)) ⟩
G.map (cons TrB (f a)) =⟨ ap G.map (! (F.β a)) ⟩
G.map (F.map (cons TrA a)) ∎
{- Corollary: truncation preserves equivalences.
The below general form produces a unexpected benefit: the underlying
type of a truncation is unique up to constructor-preserving equivalence. -}
module _ where
private
module _ {ia ib j} where
private
l : ULevel
l = ia ⊔ ib ⊔ j
module half {A : Type ia} {B : Type ib}
(TrA : trunc-ty n A l)
(TrB : trunc-ty n B l)
(e : A ≃ B) where
module F = fmap {j = l} TrA TrB (–> e)
module G = fmap {j = l} TrB TrA (<– e)
module BB = fmap {j = l} TrB TrB
f-g : (tb : ⟦ type TrB ⟧) → F.map (G.map tb) == tb
f-g tb =
F.map (G.map tb)
=⟨ ! (fmap-fuse-∘ {j = l} TrB TrA TrB (<– e) (–> e) tb) ⟩
BB.map (–> e ∘ <– e) tb
=⟨ app= (ap BB.map (λ= (<–-inv-r e))) tb ⟩
BB.map (idf _) tb
=⟨ fmap-fuse-id {j = l} TrB tb ⟩
tb
∎
module _ {ia ib j} where
module _ {A : Type ia} {B : Type ib}
(TrA : trunc-ty n A (ia ⊔ ib ⊔ j))
(TrB : trunc-ty n B (ia ⊔ ib ⊔ j))
(e : A ≃ B) where
private
module H = half {j = j} TrA TrB e
module K = half {j = j} TrB TrA (e ⁻¹)
fmap-equiv : ⟦ type TrA ≃-≤ type TrB ⟧
fmap-equiv = equiv H.F.map K.F.map H.f-g K.f-g
{- The type of n-truncations of A is propositional:
truncations are unique if existent. -}
module _ {i} {n : ℕ₋₂} {A : Type i} where
open trunc-ty
open trunc-functor
{- For the purpose of this module, it will be easier
for us to regard trunc-ty as a left-associatived Σ-type.
In this way, we may examine the equality on the first component
while disregarding the second one, which is a proposition. -}
private
e : ∀ {j} → trunc-ty n A j ≃ Σ (Σ _ _) _
e = equiv (λ {(ty-cons t c u) → ((t , c) , u)})
(λ {((t , c) , u) → ty-cons t c u})
(λ _ → idp) (λ _ → idp)
{- First, let us structurally decompose the combined equality
over the type and cons record fields of trunc-ty.
Note that this kind of lemma would be superfluous in
a proof assistant fully supporting univalent foundations. -}
path : (U V : Σ (n -Type i) (λ ty → A → ⟦ ty ⟧))
→ (U == V) ≃ Σ (⟦ fst U ⟧ ≃ ⟦ fst V ⟧) (λ e → –> e ∘ snd U == snd V)
path ((X , u) , f) ((Y , v) , g) = equiv-Σ eq₁ (_⁻¹ ∘ eq₂)
∘e =Σ-eqv _ _ ⁻¹ where
eq₁ : ((X , u) == (Y , v)) ≃ (X ≃ Y)
eq₁ =
(X , u) == (Y , v) ≃⟨ =Σ-eqv _ _ ⁻¹ ⟩
Σ (X == Y) (λ p → u == v [ _ ↓ p ]) ≃⟨ Σ₂-contr h ⟩
X == Y ≃⟨ ua-equiv ⁻¹ ⟩
X ≃ Y ≃∎ where
h : (p : X == Y) → is-contr (u == v [ _ ↓ p ])
h _ = =-[-↓-]-level (λ _ → has-level-is-prop)
eq₂ : (e : X ≃ Y) → (–> e ∘ f == g) ≃ (f == g [ _ ↓ <– eq₁ e ])
eq₂ = λ e →
–> e ∘ f == g ≃⟨ app=-equiv ⟩
(∀ a → –> e (f a) == g a) ≃⟨ equiv-Π-r (λ a → ↓-idf-ua-equiv e) ⟩
(∀ a → f a == g a [ _ ↓ ua e ]) ≃⟨ ↓-cst→app-equiv ⟩
(f == g [ _ ↓ ua e ]) ≃⟨ ↓-cst2-equiv _ _ ⟩
(f == g [ _ ↓ <– eq₁ e ]) ≃∎
module _ {j} where
{- Important special case of the general form of fmap-equiv:
the underlying type of a truncation is unique
up to constructor-preserving equivalence. -}
module unique (Tr₁ : trunc-ty n A (i ⊔ j))
(Tr₂ : trunc-ty n A (i ⊔ j)) where
type-equiv : ⟦ type Tr₁ ≃-≤ type Tr₂ ⟧
type-equiv = fmap-equiv {j = j} Tr₁ Tr₂ (ide _)
cons-path : –> type-equiv ∘ cons Tr₁ == cons Tr₂
cons-path = λ= (fmap.β {j = j} Tr₁ Tr₂ (idf _))
type-cons-path : Path {A = Σ (n -Type i) (λ ty → A → ⟦ ty ⟧)}
(fst (–> e Tr₁)) (fst (–> e Tr₂))
type-cons-path = <– (path _ _) (type-equiv , cons-path)
-- *** Lemma 6.7 ***
-- We are now ready to prove propositionality of trunc-ty.
trunc-ty-prop : is-prop (trunc-ty n A _)
trunc-ty-prop = all-paths-is-prop $ λ Tr₀ Tr₁ → <– (equiv-ap e _ _) (pair=
(unique.type-cons-path Tr₀ Tr₁)
(prop-has-all-paths-↓ (Π-level (λ _ → is-equiv-is-prop _))))
trunc-inhab-contr : trunc-ty n A _ → is-contr (trunc-ty n A _)
trunc-inhab-contr Tr = (Tr , prop-has-all-paths trunc-ty-prop _)
| {
"alphanum_fraction": 0.5215957447,
"avg_line_length": 40.6926406926,
"ext": "agda",
"hexsha": "db2594c5d6155e627c8618b312078da71f5ad8c3",
"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": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sattlerc/HoTT-Agda",
"max_forks_repo_path": "Universe/Trunc/Basics.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"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": "sattlerc/HoTT-Agda",
"max_issues_repo_path": "Universe/Trunc/Basics.agda",
"max_line_length": 105,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "sattlerc/HoTT-Agda",
"max_stars_repo_path": "Universe/Trunc/Basics.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3301,
"size": 9400
} |
record _×_ (A B : Set) : Set where
no-eta-equality
constructor _,_
field
fst : A
snd : B
open _×_
swap : ∀ {A B} → A × B → B × A
swap (x , y) = y , x
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
-- This should fail since we don't have eta for _×_.
fails : ∀ {A B} (p : A × B) → swap p ≡ (snd p , fst p)
fails p = refl
| {
"alphanum_fraction": 0.5171428571,
"avg_line_length": 17.5,
"ext": "agda",
"hexsha": "e6db38b951a22bd08290a5d0db61eb596d5651d8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/NoEtaPatterns.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/NoEtaPatterns.agda",
"max_line_length": 54,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/NoEtaPatterns.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": 145,
"size": 350
} |
-- Author: Makoto Takeyama
module ParenDepTac where
----------------------------------------------------------------------
-- Preliminary
----------------------------------------------------------------------
infix 3 _≡_
data _≡_ {A : Set}(x : A) : A -> Set where
refl : x ≡ x
subst : {A : Set}(C : A -> Set){x y : A} -> x ≡ y -> C y -> C x
subst C refl c = c
sym : {A : Set}{x y : A} -> x ≡ y -> y ≡ x
sym refl = refl
cong : {A B : Set}(f : A -> B){x y : A} -> x ≡ y -> f x ≡ f y
cong f refl = refl
infixl 2 _`tran`_
_`tran`_ : {A : Set}{x y z : A} -> x ≡ y -> y ≡ z -> x ≡ z
refl `tran` refl = refl
data FALSE : Set where
data TRUE : Set where tt : TRUE
data Nat : Set where
zer : Nat
suc : Nat -> Nat
_+_ : Nat -> Nat -> Nat
zer + n = n
suc m + n = suc ( m + n )
----------------------------------------------------------------------
-- Strings of parentheses
----------------------------------------------------------------------
infix 5 ≪_ ≫_
data Parens : Set where
ε : Parens
≪_ : Parens -> Parens
≫_ : Parens -> Parens
infixr 5 _·_
_·_ : Parens -> Parens -> Parens
ε · ys = ys
≪ xs · ys = ≪ (xs · ys)
≫ xs · ys = ≫ (xs · ys)
·ass : (xs : Parens){ys zs : Parens} -> xs · (ys · zs) ≡ (xs · ys) · zs
·ass ε = refl
·ass (≪ xs) = cong ≪_ (·ass xs)
·ass (≫ xs) = cong ≫_ (·ass xs)
·unitR : {xs : Parens} -> xs · ε ≡ xs
·unitR {ε} = refl
·unitR {≪ xs} = cong ≪_ ·unitR
·unitR {≫ xs} = cong ≫_ ·unitR
_≫' : Parens -> Parens
xs ≫' = xs · ≫ ε
_≪' : Parens -> Parens
xs ≪' = xs · ≪ ε
----------------------------------------------------------------------
-- A poorman's tactics for equational reasoning
----------------------------------------------------------------------
infixr 5 _⊙_
data Exp : Set where
Var : Nat -> Exp
Lit : Parens -> Exp
_⊙_ : Exp -> Exp -> Exp
nf0 : Exp -> Exp -> Exp
nf0 (Var x) e0 = Var x ⊙ e0
nf0 (Lit a) e0 = Lit a ⊙ e0
nf0 (e1 ⊙ e2) e0 = nf0 e1 (nf0 e2 e0)
nf : Exp -> Exp
nf e = nf0 e (Lit ε)
Env = Nat -> Parens
module withEnv(ρ : Env) where
⟦_⟧ : Exp -> Parens
⟦ Var x ⟧ = ρ x
⟦ Lit a ⟧ = a
⟦ e1 ⊙ e2 ⟧ = ⟦ e1 ⟧ · ⟦ e2 ⟧
nfSound0 : (e e0 : Exp) -> ⟦ e ⊙ e0 ⟧ ≡ ⟦ nf0 e e0 ⟧
nfSound0 (Var x) e0 = refl
nfSound0 (Lit a) e0 = refl
nfSound0 (e1 ⊙ e2) e0 = sym (·ass ⟦ e1 ⟧) `tran`
cong (_·_ ⟦ e1 ⟧) (nfSound0 e2 e0) `tran`
nfSound0 e1 (nf0 e2 e0)
nfSound : (e : Exp) -> ⟦ e ⟧ ≡ ⟦ nf e ⟧
nfSound e = sym ·unitR `tran` nfSound0 e (Lit ε)
tac : (e1 e2 : Exp) -> nf e1 ≡ nf e2 -> ⟦ e1 ⟧ ≡ ⟦ e2 ⟧
tac e1 e2 p = nfSound e1 `tran` subst (\x -> ⟦ x ⟧ ≡ ⟦ nf e2 ⟧) p refl `tran`
sym (nfSound e2)
module tac4 (a0 a1 a2 a3 : Parens) where
ρ : Env
ρ zer = a0
ρ (suc zer) = a1
ρ (suc (suc zer)) = a2
ρ (suc (suc (suc zer))) = a3
ρ (suc (suc (suc (suc _ )))) = ε
open module tac4' = withEnv ρ public using (tac)
v0 = Var zer
v1 = Var (suc zer)
v2 = Var (suc (suc zer))
v3 = Var (suc (suc (suc zer)))
[≪] = Lit (≪ ε)
[≫] = Lit (≫ ε)
----------------------------------------------------------------------
-- Derivations of S and T grammars
-- indexed by their underlying strings
----------------------------------------------------------------------
infix 3 _∈S _∈T
infix 4 <_> _⟨_⟩
infixl 4 _•_
data _∈S : Parens -> Set where
εS : ε ∈S
<_> : {xs : Parens} -> xs ∈S -> ≪ xs ≫' ∈S
_•_ : {xs ys : Parens} -> xs ∈S -> ys ∈S -> xs · ys ∈S
data _∈T : Parens -> Set where
εT : ε ∈T
_⟨_⟩ : {xs ys : Parens} -> xs ∈T -> ys ∈T -> xs · ≪ ys ≫' ∈T
----------------------------------------------------------------------
-- Equivalence of S and T grammars
----------------------------------------------------------------------
infixl 3 _○_
_○_ : {xs ys : Parens} -> xs ∈T -> ys ∈T -> xs · ys ∈T
t ○ εT = subst _∈T ·unitR t
_○_ {xs} t (t1 ⟨ t2 ⟩) = subst _∈T (·ass xs) ((t ○ t1) ⟨ t2 ⟩)
S⊂T : {xs : Parens} -> xs ∈S -> xs ∈T
S⊂T εS = εT
S⊂T (< s >) = εT ⟨ S⊂T s ⟩
S⊂T (s1 • s2) = S⊂T s1 ○ S⊂T s2
T⊂S : {xs : Parens} -> xs ∈T -> xs ∈S
T⊂S εT = εS
T⊂S (t1 ⟨ t2 ⟩) = T⊂S t1 • < T⊂S t2 >
----------------------------------------------------------------------
-- Recursively defined test function
----------------------------------------------------------------------
Test : Nat -> Parens -> Set
Test n (≪ xs) = Test (suc n) xs
Test (suc n) (≫ xs) = Test n xs
Test zer (≫ xs) = FALSE
Test (suc n) ε = FALSE
Test zer ε = TRUE
----------------------------------------------------------------------
-- Soundness of Test
----------------------------------------------------------------------
lemTest : (m : Nat)(xs : Parens) -> Test m xs ->
(n : Nat)(ys : Parens) -> Test n ys ->
Test (m + n) (xs · ys)
lemTest m (≪ xs) p = lemTest (suc m) xs p
lemTest (suc m) (≫ xs) p = lemTest m xs p
lemTest zer (≫ xs) ()
lemTest (suc m) ε ()
lemTest zer ε tt = \ n ys q -> q
sound : {xs : Parens} -> xs ∈S -> Test zer xs
sound εS = tt
sound (<_>{xs} s) = lemTest zer xs (sound s) (suc zer) (≫ ε) tt
sound (_•_{xs}{ys} s1 s2) = lemTest zer xs (sound s1) zer ys (sound s2)
----------------------------------------------------------------------
-- Completeness of Test
----------------------------------------------------------------------
complete : (xs : Parens) -> Test zer xs -> xs ∈S
complete xs0 p0 = parse init εS xs0 p0
where
data St : Nat -> Parens -> Set where
init : St zer ε
_*_≪ : {n : Nat} ->
{xs : Parens} -> St n xs ->
{ys : Parens} -> ys ∈S ->
St (suc n) (xs · ys ≪')
stPar : forall {n xs} -> St n xs -> Parens
stPar {xs = xs} _ = xs
∈SPar : forall {xs} -> xs ∈S -> Parens
∈SPar {xs} _ = xs
parse : {n : Nat} ->
{xs : Parens} -> St n xs ->
{ys : Parens} -> ys ∈S ->
(zs : Parens) -> Test n zs ->
xs · ys · zs ∈S
-- <SHIFT> (st , s , ≪ zs ) ↦ (st * s ≪ , εS , zs)
-- <REDUCE> (st * s3 ≪ , s , ≫ zs ) ↦ (st , s3 • < s > , zs)
-- <FINISH> (init , s , ε ) ↦ s
parse {_} {xs} st {ys} s (≪ zs) p = subst _∈S eq (parse (st * s ≪) εS zs p)
where open module foo = tac4 xs ys zs ε
eq = tac (v0 ⊙ v1 ⊙ [≪] ⊙ v2) ((v0 ⊙ v1 ⊙ [≪]) ⊙ v2) refl
parse (st * s3 ≪) {ys} s (≫ zs) p
= subst _∈S eq (parse st (s3 • < s >) zs p)
where open module foo = tac4 (stPar st) (∈SPar s3) ys zs
eq = tac ((v0 ⊙ v1 ⊙ [≪]) ⊙ v2 ⊙ [≫] ⊙ v3)
( v0 ⊙ (v1 ⊙ [≪] ⊙ v2 ⊙ [≫]) ⊙ v3) refl
parse ( _ * _ ≪) _ ε ()
parse init _ (≫ zs) ()
parse init s ε tt = subst _∈S ·unitR s
| {
"alphanum_fraction": 0.3839637798,
"avg_line_length": 29.0127118644,
"ext": "agda",
"hexsha": "aa607de92cb016090ef0fbf4c0cc65ceedd9421b",
"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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/agda-kanso",
"max_forks_repo_path": "examples/ParenDepTac.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"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": "asr/agda-kanso",
"max_issues_repo_path": "examples/ParenDepTac.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/ParenDepTac.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2577,
"size": 6847
} |
{-# OPTIONS --rewriting #-}
module Correctness where
open import Convertibility public
open import Semantics public
{-# BUILTIN REWRITE _≡_ #-}
{-# REWRITE idmono⊩⋆ #-}
-- TODO: Naming things.
module _ {{_ : Model}} where
⟦_≔_⟧∈ : ∀ {C Γ w} → (i : C ∈ Γ) → w ⟪ Γ ∖ i ⊫ C ⟫ →
∀ {A} → A ∈ Γ → w ⟪ Γ ∖ i ⊫ A ⟫
⟦ i ≔ ⟪c⟫ ⟧∈ j with i ≟∈ j
⟦ i ≔ ⟪c⟫ ⟧∈ .i | same = ⟪c⟫
⟦ i ≔ ⟪c⟫ ⟧∈ ._ | diff j = ⟪var⟫ j
lem≔∈ : ∀ {A C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (j : A ∈ Γ) →
⟦ i ≔ eval c ⟧∈ j ≡ eval ([ i ≔ c ]∈ j) {w}
lem≔∈ i c j with i ≟∈ j
lem≔∈ i c .i | same = refl
lem≔∈ i c ._ | diff j = refl
-- TODO: Naming things.
module _ {{_ : Model}} where
plug : ∀ {C Γ w} → (i : C ∈ Γ) → w ⊩⋆ Γ ∖ i → w ⊩ C → w ⊩⋆ Γ
plug top γ s = γ , s
plug (pop i) (γ , r) s = plug i γ s , r
⟦_≔_⟧ : ∀ {C Γ w} → (i : C ∈ Γ) → w ⟪ Γ ∖ i ⊫ C ⟫ →
∀ {A} → (∀ {w′} → w′ ⟪ Γ ⊫ A ⟫) → w ⟪ Γ ∖ i ⊫ A ⟫
⟦ i ≔ ⟪c⟫ ⟧ ⟪d⟫ = λ γ → ⟪d⟫ (plug i γ (⟪c⟫ γ))
-- TODO: The var case in lem≔.
postulate
oops≔var₁ : ∀ {C Γ w} → (i : C ∈ Γ) (⟪c⟫ : w ⟪ Γ ∖ i ⊫ C ⟫) (γ : w ⊩⋆ Γ ∖ i) →
⟪var⟫ {C} i (plug i γ (⟪c⟫ γ)) ≡ ⟪c⟫ γ
-- oops≔var₁ top ⟪c⟫ γ = refl
-- oops≔var₁ (pop i) ⟪c⟫ (γ , s) = {!!}
postulate
oops≔var₂ : ∀ {A C Γ w} → (i : C ∈ Γ) (⟪c⟫ : w ⟪ Γ ∖ i ⊫ C ⟫) (j : A ∈ Γ ∖ i) (γ : w ⊩⋆ Γ ∖ i) →
⟪var⟫ {A} (mono∈ (thin⊆ i) j) (plug i γ (⟪c⟫ γ)) ≡ ⟪var⟫ {A} j γ
-- oops≔var₂ top ⟪c⟫ j γ = cong² ⟪var⟫ (idmono∈ j) refl
-- oops≔var₂ (pop i) ⟪c⟫ j (γ , s) = {!!}
oops≔var : ∀ {A C Γ w} → (i : C ∈ Γ) (⟪c⟫ : w ⟪ Γ ∖ i ⊫ C ⟫) (j : A ∈ Γ) →
⟦ i ≔ ⟪c⟫ ⟧ {A} (⟪var⟫ {A} j) ≡ ⟦ i ≔ ⟪c⟫ ⟧∈ {A} j
oops≔var i ⟪c⟫ j with i ≟∈ j
oops≔var i ⟪c⟫ .i | same = funext (λ γ → oops≔var₁ i ⟪c⟫ γ)
oops≔var i ⟪c⟫ ._ | diff j = funext (λ γ → oops≔var₂ i ⟪c⟫ j γ)
-- TODO: The lam case in lem≔.
lem₁ : ∀ {C Γ w w′} → (i : C ∈ Γ) (γ : w ⊩⋆ Γ ∖ i) (s : w ⊩ C) (p : w ≤ w′) →
mono⊩⋆ p (plug i γ s) ≡ plug i (mono⊩⋆ p γ) (mono⊩ {C} p s)
lem₁ top γ s p = refl
lem₁ (pop i) (γ , r) s p = cong² _,_ (lem₁ i γ s p) refl
mutual
postulate
lem₂ : ∀ {A Γ w w′} → (p : w ≤ w′) (d : Γ ⊢ A) (γ : w ⊩⋆ Γ) →
mono⊩ {A} p (eval d γ) ≡ eval d (mono⊩⋆ p γ)
-- lem₂ p (var {A} j) γ = {!!}
-- lem₂ p (lam {A} {B} d) γ = {!!}
-- lem₂ p (app {A} {B} d e) γ = {!!}
-- lem₂ p (pair {A} {B} d e) γ = lem₂pair p d e γ
-- lem₂ p (fst {A} {B} d) γ = lem₂fst p d γ
-- lem₂ p (snd {A} {B} d) γ = lem₂snd p d γ
-- lem₂ p unit γ = refl
lem₂pair : ∀ {A B Γ w w′} → (p : w ≤ w′) (d : Γ ⊢ A) (e : Γ ⊢ B) (γ : w ⊩⋆ Γ) →
mono⊩ {A ⩕ B} p (⟪pair⟫ {A} {B} (eval d) (eval e) γ) ≡ ⟪pair⟫ {A} {B} (eval d) (eval e) (mono⊩⋆ p γ)
lem₂pair {A} {B} p d e γ =
begin
mono⊩ {A ⩕ B} p (⟪pair⟫ {A} {B} (eval d) (eval e) γ)
≡⟨⟩
⟪pair⟫ {A} {B} (λ γ′ → mono⊩ {A} p (eval d γ)) (λ γ′ → mono⊩ {B} p (eval e γ)) (mono⊩⋆ p γ)
≡⟨ cong² (λ ⟪d⟫ ⟪e⟫ → ⟪pair⟫ {A} {B} ⟪d⟫ ⟪e⟫ (mono⊩⋆ p γ)) (funext (λ γ′ → lem₂ p d γ)) (funext (λ γ′ → lem₂ p e γ)) ⟩
⟪pair⟫ {A} {B} (λ γ′ → eval d (mono⊩⋆ p γ)) (λ γ′ → eval e (mono⊩⋆ p γ)) (mono⊩⋆ p γ)
≡⟨⟩
⟪pair⟫ {A} {B} (eval d) (eval e) (mono⊩⋆ p γ)
∎
lem₂fst : ∀ {A B Γ w w′} → (p : w ≤ w′) (d : Γ ⊢ A ⩕ B) (γ : w ⊩⋆ Γ) →
mono⊩ {A} p (⟪fst⟫ {A} {B} (eval d) γ) ≡ ⟪fst⟫ {A} {B} (eval d) (mono⊩⋆ p γ)
lem₂fst {A} {B} p d γ =
begin
mono⊩ {A} p (⟪fst⟫ {A} {B} (eval d) γ)
≡⟨⟩
⟪fst⟫ {A} {B} (λ γ′ → mono⊩ {A ⩕ B} p (eval d γ)) (mono⊩⋆ p γ)
≡⟨ cong (λ ⟪d⟫ → ⟪fst⟫ {A} {B} ⟪d⟫ (mono⊩⋆ p γ)) (funext (λ γ′ → lem₂ p d γ)) ⟩
⟪fst⟫ {A} {B} (λ γ′ → eval d (mono⊩⋆ p γ)) (mono⊩⋆ p γ)
≡⟨⟩
⟪fst⟫ {A} {B} (eval d) (mono⊩⋆ p γ)
∎
lem₂snd : ∀ {A B Γ w w′} → (p : w ≤ w′) (d : Γ ⊢ A ⩕ B) (γ : w ⊩⋆ Γ) →
mono⊩ {B} p (⟪snd⟫ {A} {B} (eval d) γ) ≡ ⟪snd⟫ {A} {B} (eval d) (mono⊩⋆ p γ)
lem₂snd {A} {B} p d γ =
begin
mono⊩ {B} p (⟪snd⟫ {A} {B} (eval d) γ)
≡⟨⟩
⟪snd⟫ {A} {B} (λ γ′ → mono⊩ {A ⩕ B} p (eval d γ)) (mono⊩⋆ p γ)
≡⟨ cong (λ ⟪d⟫ → ⟪snd⟫ {A} {B} ⟪d⟫ (mono⊩⋆ p γ)) (funext (λ γ′ → lem₂ p d γ)) ⟩
⟪snd⟫ {A} {B} (λ γ′ → eval d (mono⊩⋆ p γ)) (mono⊩⋆ p γ)
≡⟨⟩
⟪snd⟫ {A} {B} (eval d) (mono⊩⋆ p γ)
∎
postulate
oops≔lam₂ : ∀ {A C Γ w w′} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (γ : w ⊩⋆ Γ ∖ i) (p : w ≤ w′) (s : w′ ⊩ A) →
mono⊩ {C} p (eval c γ) ≡ eval (mono⊢ (weak⊆ {A = A}) c) (mono⊩⋆ p γ , s)
-- oops≔lam₂ i c γ p s = {!!}
oops≔lam₁ : ∀ {A B C Γ w w′} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ , A ⊢ B) (γ : w ⊩⋆ Γ ∖ i) (p : w ≤ w′) (s : w′ ⊩ A) →
eval d (mono⊩⋆ p (plug i γ (eval c γ)) , s) ≡ eval d (plug i (mono⊩⋆ p γ) (eval (mono⊢ (weak⊆ {A = A}) c) (mono⊩⋆ p γ , s)) , s)
oops≔lam₁ {A} {B} {C} i c d γ p s =
begin
eval d (mono⊩⋆ p (plug i γ (eval c γ)) , s)
≡⟨ cong (eval d) (cong² _,_ (lem₁ i γ (eval c γ) p) refl) ⟩
eval d (plug i (mono⊩⋆ p γ) (mono⊩ {C} p (eval c γ)) , s)
≡⟨ cong (eval d) (cong² _,_ (cong² (plug i) refl (oops≔lam₂ i c γ p s)) refl) ⟩
eval d (plug i (mono⊩⋆ p γ) (eval (mono⊢ weak⊆ c) (mono⊩⋆ p γ , s)) , s)
∎
oops≔lam : ∀ {A B C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ , A ⊢ B) →
⟦ i ≔ eval c {w} ⟧ {A ⇒ B} (⟪lam⟫ {A} {B} (eval d)) ≡
⟪lam⟫ {A} {B} (⟦ pop {A = C} {B = A} i ≔ eval (mono⊢ (weak⊆ {A = A}) c) ⟧ {B} (eval d))
oops≔lam i c d = funext (λ γ → ⟨funext⟩ (funext (λ p → funext (λ s → oops≔lam₁ i c d γ p s))))
mutual
lem≔ : ∀ {A C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ ⊢ A) →
⟦ i ≔ eval c ⟧ {A} (eval d) ≡ eval ([ i ≔ c ] d) {w}
lem≔ i c (var j) = lem≔var i c j
lem≔ i c (lam d) = lem≔lam i c d
lem≔ i c (app d e) = lem≔app i c d e
lem≔ i c (pair d e) = lem≔pair i c d e
lem≔ i c (fst d) = lem≔fst i c d
lem≔ i c (snd d) = lem≔snd i c d
lem≔ i c unit = lem≔unit i c
lem≔var : ∀ {A C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (j : A ∈ Γ) →
⟦ i ≔ eval c ⟧ {A} (⟪var⟫ {A} j) ≡ eval ([ i ≔ c ] (var j)) {w}
lem≔var {A} i c j =
begin
⟦ i ≔ eval c ⟧ {A} (⟪var⟫ {A} j)
≡⟨ oops≔var i (eval c) j ⟩
⟦ i ≔ eval c ⟧∈ {A} j
≡⟨ lem≔∈ i c j ⟩
eval ([ i ≔ c ]∈ j)
≡⟨⟩
eval ([ i ≔ c ] (var j))
∎
lem≔lam : ∀ {A B C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ , A ⊢ B) →
⟦ i ≔ eval c ⟧ {A ⇒ B} (⟪lam⟫ {A} {B} (eval d)) ≡ eval ([ i ≔ c ] (lam d)) {w}
lem≔lam {A} {B} {C} i c d =
begin
⟦ i ≔ eval c ⟧ {A ⇒ B} (⟪lam⟫ {A} {B} (eval d))
≡⟨ oops≔lam i c d ⟩
⟪lam⟫ {A} {B} (⟦ pop {A = C} {B = A} i ≔ eval (mono⊢ (weak⊆ {A = A}) c) ⟧ {B} (eval d))
≡⟨ cong (⟪lam⟫ {A} {B}) (⟨funext⟩ (lem≔ (pop i) (mono⊢ (weak⊆ {A = A}) c) d)) ⟩
⟪lam⟫ {A} {B} (eval ([ pop {A = C} {B = A} i ≔ mono⊢ (weak⊆ {A = A}) c ] d))
≡⟨⟩
eval (lam ([ pop i ≔ mono⊢ weak⊆ c ] d))
≡⟨⟩
eval ([ i ≔ c ] (lam d))
∎
lem≔app : ∀ {A B C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ ⊢ A ⇒ B) (e : Γ ⊢ A) →
⟦ i ≔ eval c ⟧ {B} (⟪app⟫ {A} {B} (eval d) (eval e)) ≡ eval ([ i ≔ c ] (app d e)) {w}
lem≔app {A} {B} i c d e =
begin
⟦ i ≔ eval c ⟧ {B} (⟪app⟫ {A} {B} (eval d) (eval e))
≡⟨⟩
⟪app⟫ {A} {B} (⟦ i ≔ eval c ⟧ {A ⇒ B} (eval d)) (⟦ i ≔ eval c ⟧ {A} (eval e))
≡⟨ cong² (⟪app⟫ {A} {B}) (lem≔ i c d) (funext (λ γ → extfun (lem≔ i c e) γ)) ⟩
⟪app⟫ {A} {B} (eval ([ i ≔ c ] d)) (eval ([ i ≔ c ] e))
≡⟨⟩
eval (app ([ i ≔ c ] d) ([ i ≔ c ] e))
≡⟨⟩
eval ([ i ≔ c ] (app d e))
∎
lem≔pair : ∀ {A B C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ ⊢ A) (e : Γ ⊢ B) →
⟦ i ≔ eval c ⟧ {A ⩕ B} (⟪pair⟫ {A} {B} (eval d) (eval e)) ≡ eval ([ i ≔ c ] (pair d e)) {w}
lem≔pair {A} {B} i c d e =
begin
⟦ i ≔ eval c ⟧ {A ⩕ B} (⟪pair⟫ {A} {B} (eval d) (eval e))
≡⟨⟩
⟪pair⟫ {A} {B} (⟦ i ≔ eval c ⟧ {A} (eval d)) (⟦ i ≔ eval c ⟧ {B} (eval e))
≡⟨ cong² (⟪pair⟫ {A} {B}) (lem≔ i c d) (lem≔ i c e) ⟩
⟪pair⟫ {A} {B} (eval ([ i ≔ c ] d)) (eval ([ i ≔ c ] e))
≡⟨⟩
eval (pair ([ i ≔ c ] d) ([ i ≔ c ] e))
≡⟨⟩
eval ([ i ≔ c ] (pair d e))
∎
lem≔fst : ∀ {A B C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ ⊢ A ⩕ B) →
⟦ i ≔ eval c ⟧ {A} (⟪fst⟫ {A} {B} (eval d)) ≡ eval ([ i ≔ c ] (fst d)) {w}
lem≔fst {A} {B} i c d =
begin
⟦ i ≔ eval c ⟧ {A} (⟪fst⟫ {A} {B} (eval d))
≡⟨⟩
⟪fst⟫ {A} {B} (⟦ i ≔ eval c ⟧ {A ⩕ B} (eval d))
≡⟨ cong (⟪fst⟫ {A} {B}) (lem≔ i c d) ⟩
⟪fst⟫ {A} {B} (eval ([ i ≔ c ] d))
≡⟨⟩
eval (fst ([ i ≔ c ] d))
≡⟨⟩
eval ([ i ≔ c ] (fst d))
∎
lem≔snd : ∀ {A B C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) (d : Γ ⊢ A ⩕ B) →
⟦ i ≔ eval c ⟧ {B} (⟪snd⟫ {A} {B} (eval d)) ≡ eval ([ i ≔ c ] (snd d)) {w}
lem≔snd {A} {B} i c d =
begin
⟦ i ≔ eval c ⟧ {B} (⟪snd⟫ {A} {B} (eval d))
≡⟨⟩
⟪snd⟫ {A} {B} (⟦ i ≔ eval c ⟧ {A ⩕ B} (eval d))
≡⟨ cong (⟪snd⟫ {A} {B}) (lem≔ i c d) ⟩
⟪snd⟫ {A} {B} (eval ([ i ≔ c ] d))
≡⟨⟩
eval (snd ([ i ≔ c ] d))
≡⟨⟩
eval ([ i ≔ c ] (snd d))
∎
lem≔unit : ∀ {C Γ w} → (i : C ∈ Γ) (c : Γ ∖ i ⊢ C) →
⟦ i ≔ eval c ⟧ {⫪} ⟪unit⟫ ≡ eval ([ i ≔ c ] unit) {w}
lem≔unit i c = refl
-- TODO: Naming things.
-- NOTE: This is using {-# REWRITE idmono⊩⋆ #-}.
module _ {{_ : Model}} where
lemreduce⇒ : ∀ {A B Γ w} → (d : Γ , A ⊢ B) (e : Γ ⊢ A) →
⟪app⟫ {A} {B} (⟪lam⟫ {A} {B} (eval d)) (eval e {w}) ≡ eval ([ top ≔ e ] d) {w}
lemreduce⇒ d e = lem≔ top e d
-- TODO: The expand⇒ case in eval✓.
module _ {{_ : Model}} where
postulate
lemexpand⇒ : ∀ {A B Γ w} → (d : Γ ⊢ A ⇒ B) →
eval d {w} ≡ ⟪lam⟫ {A} {B} (⟪app⟫ {A} {B} {Γ , A} (eval (mono⊢ {A ⇒ B} (weak⊆ {A = A}) d)) (⟪v₀⟫ {A}))
-- lemexpand⇒ d = {!!}
-- Correctness of evaluation with respect to β-η-equivalence.
module _ {{_ : Model}} where
eval✓ : ∀ {A Γ} {d d′ : Γ ⊢ A} {w} → d ≡ᵝᵑ d′ → eval d {w} ≡ eval d′ {w}
eval✓ refl≡ᵝᵑ = refl
eval✓ (trans≡ᵝᵑ p q) = trans (eval✓ p) (eval✓ q)
eval✓ (sym≡ᵝᵑ p) = sym (eval✓ p)
eval✓ (cong≡ᵝᵑlam {A} {B} p) = cong (⟪lam⟫ {A} {B}) (⟨funext⟩ (eval✓ p))
eval✓ (cong≡ᵝᵑapp {A} {B} p q) = cong² (⟪app⟫ {A} {B}) (eval✓ p) (eval✓ q)
eval✓ (cong≡ᵝᵑpair {A} {B} p q) = cong² (⟪pair⟫ {A} {B}) (eval✓ p) (eval✓ q)
eval✓ (cong≡ᵝᵑfst {A} {B} p) = cong (⟪fst⟫ {A} {B}) (eval✓ p)
eval✓ (cong≡ᵝᵑsnd {A} {B} p) = cong (⟪snd⟫ {A} {B}) (eval✓ p)
eval✓ (reduce⇒ d e) = lemreduce⇒ d e
eval✓ (reduce⩕₁ d e) = refl
eval✓ (reduce⩕₂ d e) = refl
eval✓ (expand⇒ d) = lemexpand⇒ d
eval✓ (expand⩕ d) = refl
eval✓ (expand⫪ d) = refl
| {
"alphanum_fraction": 0.3696844377,
"avg_line_length": 39.3038869258,
"ext": "agda",
"hexsha": "6da0b9ebe490e67bb437da3b3294463f3df01659",
"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": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/nbe-correctness",
"max_forks_repo_path": "src/Correctness.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/nbe-correctness",
"max_issues_repo_path": "src/Correctness.agda",
"max_line_length": 142,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/nbe-correctness",
"max_stars_repo_path": "src/Correctness.agda",
"max_stars_repo_stars_event_max_datetime": "2017-03-23T18:51:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-23T06:25:23.000Z",
"num_tokens": 6064,
"size": 11123
} |
{-# OPTIONS --without-K --safe #-}
module PiFracMemSem where
open import Relation.Binary.Core
open import Data.Empty
open import Function
open import Data.Nat
open import Data.Nat.Properties
open import Data.Fin as Fin using (Fin; zero; suc)
open import Data.Vec
open import Data.Vec.Relation.Unary.Any.Properties
open import Data.Vec.Any hiding (map)
open import Data.Empty using (⊥)
open import Data.Unit using (⊤; tt)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_×_; _,_; proj₁; proj₂; Σ-syntax)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
renaming ([_] to R[_])
open import PiFracDyn
infix 80 ∣_∣
∣_∣ : (A : 𝕌) → ℕ
∣ 𝟘 ∣ = 0
∣ 𝟙 ∣ = 1
∣ A₁ +ᵤ A₂ ∣ = ∣ A₁ ∣ + ∣ A₂ ∣
∣ A₁ ×ᵤ A₂ ∣ = ∣ A₁ ∣ * ∣ A₂ ∣
∣ 𝟙/ A ∣ = 1
Vec× : ∀ {n m} {A B : Set} → Vec A n → Vec B m → Vec (A × B) (n * m)
Vec× va vb = concat (map (λ a₁ → map (a₁ ,_) vb) va)
∈map : ∀ {ℓ₁ ℓ₂} {n} {A : Set ℓ₁} {B : Set ℓ₂} {v : Vec A n} → (f : A → B) → (a : A)
→ Any (a ≡_) v → Any (f a ≡_) (map f v)
∈map f a (here refl) = here refl
∈map f a (there a∈v) = there (∈map f a a∈v)
inVec× : ∀ {n m} {A B : Set} → (va : Vec A n) → (vb : Vec B m)
→ (a : A) (b : B)
→ Any (a ≡_) va → Any (b ≡_) vb
→ Any ((a , b) ≡_) (Vec× va vb)
inVec× (a ∷ va) vb .a b (here refl) b∈vb = ++⁺ˡ {xs = map (a ,_) vb} (∈map _ _ b∈vb)
inVec× (x ∷ va) vb a b (there a∈va) b∈vb = ++⁺ʳ (map (x ,_) vb) (inVec× va vb a b a∈va b∈vb)
any≡← : ∀ {ℓ} {A : Set ℓ} {n} {a} → (v : Vec A n) → (i : Fin n) → a ≡ lookup v i → Any (a ≡_) v
any≡← (_ ∷ _) Fin.0F refl = here refl
any≡← (_ ∷ v) (suc i) refl = there (any≡← v i refl)
Enum : (A : 𝕌) → Vec ⟦ A ⟧ ∣ A ∣
Enum 𝟘 = []
Enum 𝟙 = tt ∷ []
Enum (A₁ +ᵤ A₂) = map inj₁ (Enum A₁) ++ map inj₂ (Enum A₂)
Enum (A₁ ×ᵤ A₂) = Vec× (Enum A₁) (Enum A₂)
Enum (𝟙/ A) = ○ ∷ []
Find : {A : 𝕌} (x : ⟦ A ⟧) → Σ[ i ∈ Fin ∣ A ∣ ] (x ≡ lookup (Enum A) i)
Find {𝟘} ()
Find {𝟙} tt = index tt∈𝟙 , lookup-index tt∈𝟙
where
tt∈𝟙 : Any (tt ≡_) (Enum 𝟙)
tt∈𝟙 = here refl
Find {A₁ +ᵤ A₂} (inj₁ x) =
let i , p₁ = Find x in
let x∈A₁ : Any ((inj₁ x) ≡_) (Enum (A₁ +ᵤ A₂))
x∈A₁ = ++⁺ˡ {xs = map inj₁ (Enum A₁)} (∈map inj₁ x (any≡← _ i p₁)) in
index x∈A₁ , lookup-index x∈A₁
Find {A₁ +ᵤ A₂} (inj₂ y) =
let j , p₂ = Find y in
let y∈A₂ : Any ((inj₂ y) ≡_) (Enum (A₁ +ᵤ A₂))
y∈A₂ = ++⁺ʳ (map inj₁ (Enum A₁)) (∈map inj₂ y (any≡← _ j p₂)) in
index y∈A₂ , lookup-index y∈A₂
Find {A₁ ×ᵤ A₂} (x , y) =
let i , p₁ = Find x
j , p₂ = Find y in
let xy∈A₁×A₂ : Any ((x , y) ≡_) (Enum (A₁ ×ᵤ A₂))
xy∈A₁×A₂ = inVec× (Enum A₁) (Enum A₂) x y (any≡← (Enum A₁) i p₁) (any≡← (Enum A₂) j p₂) in
index xy∈A₁×A₂ , lookup-index xy∈A₁×A₂
Find {𝟙/ A} ○ = index ○∈𝟙/A , lookup-index ○∈𝟙/A
where
○∈𝟙/A : Any (○ ≡_) (Enum (𝟙/ A))
○∈𝟙/A = here refl
Find' : {A : 𝕌} (x : ⟦ A ⟧) → Fin ∣ A ∣
Find' = proj₁ ∘ Find
data State (A : 𝕌) : Set where
⟪_[_]⟫ : Vec ⟦ A ⟧ ∣ A ∣ → Fin ∣ A ∣ → State A
resolve : {A : 𝕌} → State A → ⟦ A ⟧
resolve ⟪ v [ i ]⟫ = lookup v i
st : {A B : 𝕌} → ⟦ A ⟧ → (c : A ↔ B) → Σ[ C ∈ 𝕌 ] (C ↔ B × State C)
st (inj₂ y) (unite₊l {t}) = _ , id↔ , ⟪ Enum t [ Find' y ]⟫
st a (uniti₊l {t}) = _ , id↔ , ⟪ (Enum (𝟘 +ᵤ t)) [ Find' a ]⟫
st (inj₁ x) (unite₊r {t}) = _ , id↔ , ⟪ Enum t [ Find' x ]⟫
st a (uniti₊r {t}) = _ , id↔ , ⟪ (Enum (t +ᵤ 𝟘)) [ Find' {t +ᵤ 𝟘} (inj₁ a) ]⟫
st (inj₁ x) (swap₊ {t₁} {t₂}) = _ , id↔ , ⟪ Enum _ [ Find' {t₂ +ᵤ t₁} (inj₂ x) ]⟫
st (inj₂ y) (swap₊ {t₁} {t₂}) = _ , id↔ , ⟪ Enum _ [ Find' {t₂ +ᵤ t₁} (inj₁ y) ]⟫
st (inj₁ x) (assocl₊ {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {(t₁ +ᵤ t₂) +ᵤ t₃} (inj₁ (inj₁ x)) ]⟫
st (inj₂ (inj₁ x)) (assocl₊ {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {(t₁ +ᵤ t₂) +ᵤ t₃} (inj₁ (inj₂ x)) ]⟫
st (inj₂ (inj₂ y)) (assocl₊ {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {(t₁ +ᵤ t₂) +ᵤ t₃} (inj₂ y) ]⟫
st (inj₁ (inj₁ x)) (assocr₊ {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {t₁ +ᵤ t₂ +ᵤ t₃} (inj₁ x) ]⟫
st (inj₁ (inj₂ y)) (assocr₊ {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {t₁ +ᵤ t₂ +ᵤ t₃} (inj₂ (inj₁ y)) ]⟫
st (inj₂ y) (assocr₊ {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {t₁ +ᵤ t₂ +ᵤ t₃} (inj₂ (inj₂ y)) ]⟫
st (tt , y) unite⋆l = _ , id↔ , ⟪ Enum _ [ Find' y ]⟫
st a uniti⋆l = _ , id↔ , ⟪ Enum _ [ Find' (tt , a) ]⟫
st (x , tt) unite⋆r = _ , id↔ , ⟪ Enum _ [ Find' x ]⟫
st a uniti⋆r = _ , id↔ , ⟪ Enum _ [ Find' (a , tt) ]⟫
st (x , y) swap⋆ = _ , id↔ , ⟪ Enum _ [ Find' (y , x) ]⟫
st (x , y , z) assocl⋆ = _ , id↔ , ⟪ Enum _ [ Find' ((x , y) , z) ]⟫
st ((x , y) , z) assocr⋆ = _ , id↔ , ⟪ Enum _ [ Find' (x , y , z) ]⟫
st (inj₁ x , y) (dist {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {t₁ ×ᵤ t₃ +ᵤ t₂ ×ᵤ t₃} (inj₁ (x , y)) ]⟫
st (inj₂ x , y) (dist {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {t₁ ×ᵤ t₃ +ᵤ t₂ ×ᵤ t₃} (inj₂ (x , y)) ]⟫
st (inj₁ (x , y)) (factor {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {(t₁ +ᵤ t₂) ×ᵤ t₃} (inj₁ x , y) ]⟫
st (inj₂ (y , z)) (factor {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {(t₁ +ᵤ t₂) ×ᵤ t₃} (inj₂ y , z) ]⟫
st (x , inj₁ y) (distl {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {(t₁ ×ᵤ t₂) +ᵤ (t₁ ×ᵤ t₃)} (inj₁ (x , y)) ]⟫
st (x , inj₂ y) (distl {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {(t₁ ×ᵤ t₂) +ᵤ (t₁ ×ᵤ t₃)} (inj₂ (x , y)) ]⟫
st (inj₁ (x , y)) (factorl {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {t₁ ×ᵤ (t₂ +ᵤ t₃)} (x , inj₁ y) ]⟫
st (inj₂ (x , z)) (factorl {t₁} {t₂} {t₃}) = _ , id↔ , ⟪ Enum _ [ Find' {t₁ ×ᵤ (t₂ +ᵤ t₃)} (x , inj₂ z) ]⟫
st tt (η {t} v) = _ , id↔ , ⟪ Enum (t ×ᵤ (𝟙/ v)) [ Find' {t ×ᵤ (𝟙/ v)} (v , ○) ]⟫
st (x , ○) (ε {t} v) with 𝕌dec t v x
st (x , ○) (ε {t} v) | yes _ = _ , id↔ , ⟪ Enum _ [ Find' tt ]⟫
st (x , ○) (ε {t} v) | no _ = _ , (ε {t} v) , ⟪ Enum (t ×ᵤ (𝟙/ v)) [ Find' {t ×ᵤ (𝟙/ v)} (x , ○) ]⟫
st a id↔ = _ , id↔ , ⟪ Enum _ [ Find' a ]⟫
st a (id↔ ⊚ c) = _ , c , ⟪ Enum _ [ Find' a ]⟫
st a (c₁ ⊚ c₂) = let _ , c , st' = st a c₁ in
_ , c ⊚ c₂ , st'
st (inj₁ x) (_⊕_ {t₁} {t₂} {_} {t₄} id↔ c₂) = _ , id↔ , ⟪ Enum _ [ Find' {_ +ᵤ t₄} (inj₁ x) ]⟫
st (inj₁ x) (_⊕_ {t₁} {t₂} c₁ c₂) = let _ , c , st' = st x c₁ in
_ , c ⊕ c₂ , ⟪ Enum _ [ Find' {_ +ᵤ t₂} (inj₁ $ resolve st') ]⟫
st (inj₂ y) (_⊕_ {t₁} {t₂} {t₃} {_} c₁ id↔) = _ , id↔ , ⟪ Enum _ [ Find' {t₃ +ᵤ _} (inj₂ y) ]⟫
st (inj₂ y) (_⊕_ {t₁} c₁ c₂) = let _ , c , st' = st y c₂ in
_ , c₁ ⊕ c , ⟪ Enum _ [ Find' {t₁ +ᵤ _} (inj₂ $ resolve st') ]⟫
st (x , y) (id↔ ⊗ id↔) = _ , id↔ , ⟪ Enum _ [ Find' (x , y) ]⟫
st (x , y) (id↔ ⊗ c₂) = let _ , c , st' = st y c₂ in
_ , id↔ ⊗ c , ⟪ Enum _ [ Find' (x , resolve st') ]⟫
st (x , y) (c₁ ⊗ c₂) = let _ , c , st' = st x c₁ in
_ , c ⊗ c₂ , ⟪ Enum _ [ Find' (resolve st' , y) ]⟫
step : {A B : 𝕌} (c : A ↔ B) → State A → Σ[ C ∈ 𝕌 ] (C ↔ B × State C)
step c ⟪ v [ i ]⟫ = st (lookup v i) c
data State' : Set where
⟪_∥_[_]⟫ : {A B : 𝕌} → A ↔ B → Vec ⟦ A ⟧ ∣ A ∣ → Fin ∣ A ∣ → State'
step' : State' → State'
step' ⟪ c ∥ v [ i ]⟫ with step c ⟪ v [ i ]⟫
step' ⟪ c ∥ v [ i ]⟫ | _ , c' , ⟪ v' [ i' ]⟫ = ⟪ c' ∥ v' [ i' ]⟫
run : (n : ℕ) → State' → Vec State' (suc n)
run 0 st = [ st ]
run (suc n) st with run n st
... | sts with last sts
... | ⟪ cx ∥ vx [ ix ]⟫ rewrite +-comm 1 (suc n) = sts ++ [ step' ⟪ cx ∥ vx [ ix ]⟫ ]
ex₁ : Vec State' 33
ex₁ = run 32 ⟪ id' ∥ Enum 𝟚 [ Fin.fromℕ 1 ]⟫
| {
"alphanum_fraction": 0.4242613921,
"avg_line_length": 49.925,
"ext": "agda",
"hexsha": "ca192d65dd5d88bff1ab5b14c5faf752df38bb85",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "fracGC/PiFracMemSem.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "fracGC/PiFracMemSem.agda",
"max_line_length": 117,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "fracGC/PiFracMemSem.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 4116,
"size": 7988
} |
open import Common.Prelude
open import Common.Equality
open import Common.Reflection
pattern _`+_ a b = def (quote _+_) (vArg a ∷ vArg b ∷ [])
`_ : Term → Term
` con c [] = con (quote Term.con) (vArg (lit (qname c)) ∷ vArg (con (quote []) []) ∷ [])
` _ = unknown
-- Prevent quotation
data WrapTerm : Set where
wrap : Term → WrapTerm
macro
eval : WrapTerm → Tactic
eval (wrap u) hole = bindTC (normalise u) λ u → unify hole (` u)
t : Term
t = lam visible (abs "n" (lit (nat 1) `+ var 0 []))
lem : eval (wrap t) ≡ Term.con (quote suc) []
lem = refl
| {
"alphanum_fraction": 0.6102292769,
"avg_line_length": 22.68,
"ext": "agda",
"hexsha": "b855a50e356b73cbc1502bfe8e070c8a0c461969",
"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/MacroEval.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/MacroEval.agda",
"max_line_length": 88,
"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/MacroEval.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": 190,
"size": 567
} |
-- Hilbert-style formalisation of closed syntax.
-- Sequences of terms.
module OldBasicILP.UntypedSyntax.ClosedHilbertSequential where
open import OldBasicILP.UntypedSyntax.Common public
-- Closed, untyped representations.
data Rep : ℕ → Set where
NIL : Rep zero
MP : ∀ {n} → Fin n → Fin n → Rep n → Rep (suc n)
CI : ∀ {n} → Rep n → Rep (suc n)
CK : ∀ {n} → Rep n → Rep (suc n)
CS : ∀ {n} → Rep n → Rep (suc n)
NEC : ∀ {n} → ∀ {`n} → Rep (suc `n) → Rep n → Rep (suc n)
CDIST : ∀ {n} → Rep n → Rep (suc n)
CUP : ∀ {n} → Rep n → Rep (suc n)
CDOWN : ∀ {n} → Rep n → Rep (suc n)
CPAIR : ∀ {n} → Rep n → Rep (suc n)
CFST : ∀ {n} → Rep n → Rep (suc n)
CSND : ∀ {n} → Rep n → Rep (suc n)
UNIT : ∀ {n} → Rep n → Rep (suc n)
-- Anti-bug wrappers.
record Proof : Set where
constructor [_]
field
{len} : ℕ
rep : Rep (suc len)
open ClosedSyntax (Proof) public
-- Concatenation of representations.
_⧺ᴿ_ : ∀ {n₁ n₂} → Rep n₁ → Rep n₂ → Rep (n₁ + n₂)
r₁ ⧺ᴿ NIL = r₁
r₁ ⧺ᴿ MP i j r₂ = MP (monoFin weak≤+₂ i) (monoFin weak≤+₂ j) (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CI r₂ = CI (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CK r₂ = CK (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CS r₂ = CS (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ NEC `r r₂ = NEC `r (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CDIST r₂ = CDIST (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CUP r₂ = CUP (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CDOWN r₂ = CDOWN (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CPAIR r₂ = CPAIR (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CFST r₂ = CFST (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ CSND r₂ = CSND (r₁ ⧺ᴿ r₂)
r₁ ⧺ᴿ UNIT r₂ = UNIT (r₁ ⧺ᴿ r₂)
-- Modus ponens and necessitation in nested form.
APP : ∀ {n₁ n₂} → Rep (suc n₁) → Rep (suc n₂) → Rep (suc (suc n₂ + suc n₁))
APP {n₁} {n₂} r₁ r₂ = MP zero (monoFin (weak≤+₁ (suc n₁)) zero) (r₂ ⧺ᴿ r₁)
BOX : ∀ {n} → Rep (suc n) → Rep (suc zero)
BOX {n} r = NEC r NIL
-- Derivations.
mutual
infix 3 ⊢ᴰ_
data ⊢ᴰ_ : Cx Ty → Set where
nil : ⊢ᴰ ∅
mp : ∀ {Ξ A B} → A ▻ B ∈ Ξ → A ∈ Ξ → ⊢ᴰ Ξ → ⊢ᴰ Ξ , B
ci : ∀ {Ξ A} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ▻ A
ck : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ▻ B ▻ A
cs : ∀ {Ξ A B C} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
nec : ∀ {Ξ A} → ∀ {`Ξ} → (d : ⊢ᴰ `Ξ , A)
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ ᴿ⌊ d ⌋ ] ⦂ A
cdist : ∀ {Ξ A B} → ∀ {n₁ n₂} → {r₁ : Rep (suc n₁)} → {r₂ : Rep (suc n₂)}
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r₁ ] ⦂ (A ▻ B) ▻ [ r₂ ] ⦂ A ▻ [ APP r₁ r₂ ] ⦂ B
cup : ∀ {Ξ A} → ∀ {n} → {r : Rep (suc n)}
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r ] ⦂ A ▻ [ BOX r ] ⦂ [ r ] ⦂ A
cdown : ∀ {Ξ A} → ∀ {n} → {r : Rep (suc n)}
→ ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r ] ⦂ A ▻ A
cpair : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ▻ B ▻ A ∧ B
cfst : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ∧ B ▻ A
csnd : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ∧ B ▻ B
unit : ∀ {Ξ} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , ⊤
-- Projection from derivations to representations.
ᴿ⌊_⌋ : ∀ {Ξ} → ⊢ᴰ Ξ → Rep ᴺ⌊ Ξ ⌋
ᴿ⌊ nil ⌋ = NIL
ᴿ⌊ mp i j d ⌋ = MP ⁱ⌊ i ⌋ ⁱ⌊ j ⌋ ᴿ⌊ d ⌋
ᴿ⌊ ci d ⌋ = CI ᴿ⌊ d ⌋
ᴿ⌊ ck d ⌋ = CK ᴿ⌊ d ⌋
ᴿ⌊ cs d ⌋ = CS ᴿ⌊ d ⌋
ᴿ⌊ nec `d d ⌋ = NEC ᴿ⌊ `d ⌋ ᴿ⌊ d ⌋
ᴿ⌊ cdist d ⌋ = CDIST ᴿ⌊ d ⌋
ᴿ⌊ cup d ⌋ = CUP ᴿ⌊ d ⌋
ᴿ⌊ cdown d ⌋ = CDOWN ᴿ⌊ d ⌋
ᴿ⌊ cpair d ⌋ = CPAIR ᴿ⌊ d ⌋
ᴿ⌊ cfst d ⌋ = CFST ᴿ⌊ d ⌋
ᴿ⌊ csnd d ⌋ = CSND ᴿ⌊ d ⌋
ᴿ⌊ unit d ⌋ = UNIT ᴿ⌊ d ⌋
-- Anti-bug wrappers.
infix 3 ⊢_
⊢_ : Ty → Set
⊢ A = ∃ (λ Ξ → ⊢ᴰ Ξ , A)
-- Concatenation of derivations.
_⧺ᴰ_ : ∀ {Ξ₁ Ξ₂} → ⊢ᴰ Ξ₁ → ⊢ᴰ Ξ₂ → ⊢ᴰ Ξ₁ ⧺ Ξ₂
d₁ ⧺ᴰ nil = d₁
d₁ ⧺ᴰ mp i j d₂ = mp (mono∈ weak⊆⧺₂ i) (mono∈ weak⊆⧺₂ j) (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ ci d₂ = ci (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ ck d₂ = ck (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cs d₂ = cs (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ nec `d d₂ = nec `d (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cdist d₂ = cdist (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cup d₂ = cup (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cdown d₂ = cdown (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cpair d₂ = cpair (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ cfst d₂ = cfst (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ csnd d₂ = csnd (d₁ ⧺ᴰ d₂)
d₁ ⧺ᴰ unit d₂ = unit (d₁ ⧺ᴰ d₂)
-- Modus ponens and necessitation in nested form.
app : ∀ {A B} → ⊢ A ▻ B → ⊢ A → ⊢ B
app {A} {B} (Ξ₁ , d₁) (Ξ₂ , d₂) = Ξ₃ , d₃
where Ξ₃ = (Ξ₂ , A) ⧺ (Ξ₁ , A ▻ B)
d₃ = mp top (mono∈ (weak⊆⧺₁ (Ξ₁ , A ▻ B)) top) (d₂ ⧺ᴰ d₁)
box : ∀ {A} → (t : ⊢ A) → ⊢ [ ᴿ⌊ π₂ t ⌋ ] ⦂ A
box (Ξ , d) = ∅ , nec d nil
| {
"alphanum_fraction": 0.4462237094,
"avg_line_length": 28.6575342466,
"ext": "agda",
"hexsha": "50eb04987f2f1cf33592c9a1b5f8e49cd3e45300",
"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": "OldBasicILP/UntypedSyntax/ClosedHilbertSequential.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": "OldBasicILP/UntypedSyntax/ClosedHilbertSequential.agda",
"max_line_length": 89,
"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": "OldBasicILP/UntypedSyntax/ClosedHilbertSequential.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": 2595,
"size": 4184
} |
module Nat.Sum where
open import Data.Nat
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open DecTotalOrder decTotalOrder hiding (refl)
+id : (n : ℕ) → n + zero ≡ n
+id zero = refl
+id (suc n) = cong suc (+id n)
+assoc : (m n : ℕ) → m + suc n ≡ suc (m + n)
+assoc zero n = refl
+assoc (suc m) n = cong suc (+assoc m n)
| {
"alphanum_fraction": 0.656424581,
"avg_line_length": 21.0588235294,
"ext": "agda",
"hexsha": "be82a3f09ef970423398bc55dd8eb9a05a83edb1",
"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/Nat/Sum.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/Nat/Sum.agda",
"max_line_length": 50,
"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/Nat/Sum.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": 119,
"size": 358
} |
module CH where
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
infixl 6 _+_
_+_ : ℕ → ℕ → ℕ
zero + m = m
(succ n) + m = succ (n + m)
infix 4 _≡_
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
{-
t1 : {n : ℕ} -> zero ≡ n
t1 = refl
-}
data _==_ {A : Set} : A → A → Set where
refl' : (a : A) → a == a
sym : ∀ x y → x == y → y == x
sym .a .a (refl' a) = refl' a
| {
"alphanum_fraction": 0.4464751958,
"avg_line_length": 14.7307692308,
"ext": "agda",
"hexsha": "d78a1fc1d3571ec426ae75ff329eaa34bbce6d8b",
"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/CH.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/CH.agda",
"max_line_length": 42,
"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/CH.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": 183,
"size": 383
} |
-- This is mainly a test of the quality of error messages for
-- termination problems.
module TerminationLambda where
postulate Id : Set → Set
F : Set → Set
F = λ A → F (Id A)
| {
"alphanum_fraction": 0.6983240223,
"avg_line_length": 17.9,
"ext": "agda",
"hexsha": "8d527116522044630d1a87eb57e15a0f6a170a7b",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/TerminationLambda.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/TerminationLambda.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": "test/Fail/TerminationLambda.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": 48,
"size": 179
} |
module UniDB.Morph.Shifts where
open import UniDB.Spec
--------------------------------------------------------------------------------
data Shifts : MOR where
refl : {γ : Dom} → Shifts γ γ
step : {γ₁ γ₂ : Dom} (ξ : Shifts γ₁ γ₂) → Shifts γ₁ (suc γ₂)
skip : {γ₁ γ₂ : Dom} (ξ : Shifts γ₁ γ₂) → Shifts (suc γ₁) (suc γ₂)
shiftIx : {γ₁ γ₂ : Dom} (ξ : Shifts γ₁ γ₂) (i : Ix γ₁) → Ix γ₂
shiftIx refl i = i
shiftIx (step ξ) i = suc (shiftIx ξ i)
shiftIx (skip ξ) zero = zero
shiftIx (skip ξ) (suc i) = suc (shiftIx ξ i)
--------------------------------------------------------------------------------
instance
iLkShifts : {T : STX} {{vrT : Vr T}} → Lk T Shifts
lk {{iLkShifts}} ξ i = vr (shiftIx ξ i)
iUpShifts : Up Shifts
_↑₁ {{iUpShifts}} refl = refl
_↑₁ {{iUpShifts}} ξ = skip ξ
_↑_ {{iUpShifts}} ξ 0 = ξ
_↑_ {{iUpShifts}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁
↑-zero {{iUpShifts}} ξ = refl
↑-suc {{iUpShifts}} ξ δ⁺ = refl
iIdmShifts : Idm Shifts
idm {{iIdmShifts}} γ = refl {γ}
iWkmShifts : Wkm Shifts
wkm {{iWkmShifts}} zero = idm _
wkm {{iWkmShifts}} (suc δ) = step (wkm δ)
iCompShifts : Comp Shifts
_⊙_ {{iCompShifts}} ξ₁ refl = ξ₁
_⊙_ {{iCompShifts}} ξ₁ (step ξ₂) = step (ξ₁ ⊙ ξ₂)
_⊙_ {{iCompShifts}} refl (skip ξ₂) = skip ξ₂
_⊙_ {{iCompShifts}} (step ξ₁) (skip ξ₂) = step (ξ₁ ⊙ ξ₂)
_⊙_ {{iCompShifts}} (skip ξ₁) (skip ξ₂) = skip (ξ₁ ⊙ ξ₂)
--------------------------------------------------------------------------------
shiftIx-⊙ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts γ₁ γ₂) (ξ₂ : Shifts γ₂ γ₃) →
(i : Ix γ₁) → shiftIx (ξ₁ ⊙ ξ₂) i ≡ shiftIx ξ₂ (shiftIx ξ₁ i)
shiftIx-⊙ ξ₁ refl i = refl
shiftIx-⊙ ξ₁ (step ξ₂) i = cong suc (shiftIx-⊙ ξ₁ ξ₂ i)
shiftIx-⊙ refl (skip ξ₂) i = refl
shiftIx-⊙ (step ξ₁) (skip ξ₂) i = cong suc (shiftIx-⊙ ξ₁ ξ₂ i)
shiftIx-⊙ (skip ξ₁) (skip ξ₂) zero = refl
shiftIx-⊙ (skip ξ₁) (skip ξ₂) (suc i) = cong suc (shiftIx-⊙ ξ₁ ξ₂ i)
shiftIx-wkm : {γ : Dom} (δ : Dom) (i : Ix γ) →
shiftIx (wkm δ) i ≡ wk δ i
shiftIx-wkm zero i = refl
shiftIx-wkm (suc δ) i = cong suc (shiftIx-wkm δ i)
--------------------------------------------------------------------------------
instance
iUpIdmShifts : UpIdm Shifts
idm-↑₁ {{iUpIdmShifts}} = refl
iCompIdmShifts : CompIdm Shifts
⊙-idm {{iCompIdmShifts}} ξ = refl
idm-⊙ {{iCompIdmShifts}} refl = refl
idm-⊙ {{iCompIdmShifts}} (step ξ) = cong step (idm-⊙ ξ)
idm-⊙ {{iCompIdmShifts}} (skip ξ) = refl
iUpCompShifts : UpComp Shifts
⊙-↑₁ {{iUpCompShifts}} ξ refl = refl
⊙-↑₁ {{iUpCompShifts}} refl (step ζ) = cong (skip ∘ step) (idm-⊙ ζ)
⊙-↑₁ {{iUpCompShifts}} (step ξ) (step ζ) = refl
⊙-↑₁ {{iUpCompShifts}} (skip ξ) (step ζ) = refl
⊙-↑₁ {{iUpCompShifts}} refl (skip ζ) = refl
⊙-↑₁ {{iUpCompShifts}} (step ξ) (skip ζ) = refl
⊙-↑₁ {{iUpCompShifts}} (skip ξ) (skip ζ) = refl
iWkmHomShifts : WkmHom Shifts
wkm-zero {{iWkmHomShifts}} = refl
wkm-suc {{iWkmHomShifts}} δ = refl
module _ {T : STX} {{vrT : Vr T}} where
instance
iLkUpShifts : {{wkT : Wk T}} {{wkVrT : WkVr T}} → LkUp T Shifts
lk-↑₁-zero {{iLkUpShifts}} refl = refl
lk-↑₁-zero {{iLkUpShifts}} (step ξ) = refl
lk-↑₁-zero {{iLkUpShifts}} (skip ξ) = refl
lk-↑₁-suc {{iLkUpShifts}} refl i = sym (wk₁-vr i)
lk-↑₁-suc {{iLkUpShifts}} (step ξ) i = sym (wk₁-vr (suc (shiftIx ξ i)))
lk-↑₁-suc {{iLkUpShifts}} (skip ξ) i = sym (wk₁-vr (shiftIx (skip ξ) i))
iLkRenShifts : LkRen T Shifts
lk-ren {{iLkRenShifts}} ξ i = refl
iLkIdmShifts : LkIdm T Shifts
lk-idm {{iLkIdmShifts}} i = refl
iLkWkmShifts : LkWkm T Shifts
lk-wkm {{iLkWkmShifts}} δ i = cong vr (shiftIx-wkm δ i)
--------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.508744856,
"avg_line_length": 35.6697247706,
"ext": "agda",
"hexsha": "43f980e126ff82cc2e3193932c44ef7d04c1acab",
"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": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "skeuchel/unidb-agda",
"max_forks_repo_path": "UniDB/Morph/Shifts.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"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": "skeuchel/unidb-agda",
"max_issues_repo_path": "UniDB/Morph/Shifts.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "skeuchel/unidb-agda",
"max_stars_repo_path": "UniDB/Morph/Shifts.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1692,
"size": 3888
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.