Search is not available for this dataset
text
string | meta
dict |
---|---|
module _ where
open import Agda.Builtin.Equality
module _ (Ty : Set) where
data Cxt : Set where
sg : (A : Ty) → Cxt
_∙_ : (Γ₁ Γ₂ : Cxt) → Cxt
postulate Sub : Cxt → Cxt → Set
variable Γ Δ : Cxt
data Var (A : Ty) : Cxt → Set where
• : Var A (sg A)
inl : (x : Var A Γ) → Var A (Γ ∙ Δ)
postulate
T : ∀ {a} {A : Set a} → A → Set
bla : T Γ
check-bla : {Ty : Set} {Γ : Cxt Ty} → T Γ
check-bla = bla
| {
"alphanum_fraction": 0.525462963,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "370a2ec929012269839aaa3d853e91d79be4e8e8",
"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/Issue3164.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/Issue3164.agda",
"max_line_length": 41,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3164.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": 184,
"size": 432
} |
module _ where
open import Common.Prelude
data Vec (A : Set) : Nat → Set where
[] : Vec A 0
_∷_ : ∀ {@0 n} → A → Vec A n → Vec A (suc n)
sum : ∀ {@0 n} → Vec Nat n → Nat
sum (x ∷ xs) = x + sum xs
sum [] = 0
foldl : ∀ {A} {B : Nat → Set} → (∀ {@0 n} → B n → A → B (suc n)) → B 0 → ∀ {@0 n} → Vec A n → B n
foldl {B = B} f z (x ∷ xs) = foldl {B = λ n → B (suc n)} f (f z x) xs
foldl f z [] = z
reverse : ∀ {A} {@0 n} → Vec A n → Vec A n
reverse = foldl {B = Vec _} (λ xs x → x ∷ xs) []
downFrom : ∀ n → Vec Nat n
downFrom zero = []
downFrom (suc n) = n ∷ downFrom n
main : IO Unit
main = printNat (sum (reverse (downFrom 100000)))
| {
"alphanum_fraction": 0.50625,
"avg_line_length": 24.6153846154,
"ext": "agda",
"hexsha": "594d7c8583c31d61c0025526a41773954111726f",
"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": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "phadej/agda",
"max_forks_repo_path": "test/Compiler/simple/VecReverseErased.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"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": "phadej/agda",
"max_issues_repo_path": "test/Compiler/simple/VecReverseErased.agda",
"max_line_length": 97,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "phadej/agda",
"max_stars_repo_path": "test/Compiler/simple/VecReverseErased.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 276,
"size": 640
} |
{-# OPTIONS --safe --without-K #-}
------------------------------------------------------------------------
-- Group objects in a cartesian category.
------------------------------------------------------------------------
open import Categories.Category
open import Categories.Category.Cartesian
module Categories.Object.Group {o ℓ e} {𝒞 : Category o ℓ e} (C : Cartesian 𝒞) where
open import Level
open import Categories.Category.BinaryProducts 𝒞 using (BinaryProducts)
open import Categories.Category.Cartesian.Monoidal
open import Categories.Object.Monoid (CartesianMonoidal.monoidal C)
open import Categories.Object.Terminal 𝒞
open Category 𝒞
open Cartesian C
module Π = BinaryProducts products
open BinaryProducts products using (_×_; _⁂_; ⟨_,_⟩)
open Terminal terminal
record IsGroup (G : Obj) : Set (ℓ ⊔ e) where
-- any group object is also a monoid object
field
isMonoid : IsMonoid G
open IsMonoid isMonoid public
field
-- inverse operation
ι : G ⇒ G
-- ι is in fact an inverse
inverseˡ : η ∘ ! ≈ μ ∘ ⟨ ι , id ⟩
inverseʳ : η ∘ ! ≈ μ ∘ ⟨ id , ι ⟩
record Group : Set (o ⊔ ℓ ⊔ e) where
field
Carrier : Obj
isGroup : IsGroup Carrier
open IsGroup isGroup public
monoid : Monoid
monoid = record { isMonoid = isMonoid }
open Group
record Group⇒ (G H : Group) : Set (ℓ ⊔ e) where
field
arr : Carrier G ⇒ Carrier H
preserves-μ : arr ∘ μ G ≈ μ H ∘ (arr ⁂ arr)
preserves-η : arr ∘ η G ≈ η H
preserves-ι : arr ∘ ι G ≈ ι H ∘ arr
| {
"alphanum_fraction": 0.6099337748,
"avg_line_length": 26.9642857143,
"ext": "agda",
"hexsha": "b575714821a88ff4a856f51c632e6b83972e0539",
"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": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Object/Group.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"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": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Object/Group.agda",
"max_line_length": 83,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Object/Group.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z",
"num_tokens": 438,
"size": 1510
} |
{-# OPTIONS --disable-positivity-check #-}
module univ where
import Logic.ChainReasoning
module Chain {A : Set}
( _==_ : A -> A -> Set)
(refl : {x : A} -> x == x)
(trans : {x y z : A} -> x == y -> y == z -> x == z) =
Logic.ChainReasoning.Mono.Homogenous _==_ (\x -> refl) (\x y z -> trans)
data N1 : Set where
T : N1
data N0 : Set where
data Sigma (A:Set)(B : A -> Set) : Set where
Pair : (x:A) -> B x -> Sigma A B
rel : Set -> Set1
rel A = A -> A -> Set
pred : Set -> Set1
pred A = A -> Set
Refl : {A:Set} -> rel A -> Set
Refl {A} R = {x : A} -> R x x
Sym : {A:Set} -> rel A -> Set
Sym {A} R = {x y : A} -> R x y -> R y x
Trans : {A:Set} -> rel A -> Set
Trans {A} R = {x y z : A} -> R x y -> R y z -> R x z
Map : (A:Set) -> rel A -> (B:Set) -> rel B -> pred (A -> B)
Map A _R_ B _S_ f = {x y : A} -> x R y -> f x S f y
postulate
N : Set
_=N_ : rel N
refN : Refl _=N_
symN : Sym _=N_
transN : Trans _=N_
-- mutual inductive recursive definition of S and the functions _=S_, El, eq, and all the
-- proofs on these functions
mutual
infix 40 _==_ _=S_
infixr 80 _<<_
data S : Set where
nat : S
pi : (A:S) -> (f:El A -> S) -> Map (El A) _==_ S _=S_ f -> S
_=S'_ : rel S
nat =S' nat = N1
nat =S' pi A f pf = N0
pi _ _ _ =S' nat = N0
pi A F pF =S' pi B G pG =
Sigma (A =S B) \ A=B -> (x : El B) -> F (A=B << x) =S G x
data _=S_ (A B : S) : Set where
eqS : A =S' B -> A =S B
El' : S -> Set
El' nat = N
El' (pi A F pF) =
Sigma ((x : El A) -> El (F x))
\f -> {x y : El A}(x=y : x == y) ->
f x == pF x=y << f y
data El (A : S) : Set where
el : El' A -> El A
_=='_ : {A : S} -> rel (El A)
_=='_ {nat} (el x) (el y) = x =N y
_=='_ {pi A F pF} (el (Pair f pf)) (el (Pair g pg)) =
(x : El A) -> f x == g x
data _==_ {A : S}(x y : El A) : Set where
eq : x ==' y -> x == y
_<<_ : {A B : S} -> A =S B -> El B -> El A
_<<_ {nat} {nat} p x = x
_<<_ {pi A F pF} {pi B G pG} (eqS (Pair A=B F=G)) (el (Pair g pg)) =
el (Pair f (\{x}{y} -> pf x y))
where
B=A = symS A=B
F=Gc : (x : El A) -> F x =S G (B=A << x)
F=Gc x =
transS (transS refS (symS (pF (castlem A=B (symS A=B) x))))
(F=G (symS A=B << x))
-- chain> F x
-- === F (A=B << B=A << x) by symS (pF (castlem A=B B=A x))
-- === G (B=A << x) by F=G (B=A << x)
-- where
-- open module C = Chain _=S_ refS transS
f : (x : El A) -> El (F x)
f x = F=Gc x << g (B=A << x)
pf : (x y : El A)(p : x == y) -> f x == pF p << f y
pf x y x=y = trans fx=ccgy ccgy=cfy
where
cx = B=A << x
cy = B=A << y
cx=cy : cx == cy
cx=cy = p<< B=A x=y
cgy : El (G cx)
cgy = pG cx=cy << g cy
gx=gy : g cx == cgy
gx=gy = pg cx=cy
ccgy : El (F x)
ccgy = F=Gc x << cgy
fx=ccgy : f x == ccgy
fx=ccgy = p<< (F=Gc x) gx=gy
cfy : El (F x)
cfy = pF x=y << f y
ccgy=cfy : ccgy == cfy
ccgy=cfy = castlem2 (F=Gc x) (pF x=y)
(pG cx=cy) (F=Gc y)
(g cy)
p<< : {A B : S}(A=B : A =S B) -> Map (El B) _==_ (El A) _==_ (_<<_ A=B)
p<< {nat}{nat} _ x=y = x=y
p<< {pi A F pF} {pi B G pG} (eqS (Pair A=B F=G))
{el (Pair f pf)} {el (Pair g pg)} (eq f=g) = eq cf=cg
where
open module C = Logic.ChainReasoning.Mono.Homogenous _=S_ (\x -> refS) (\x y z -> transS)
B=A = symS A=B
F=Gc : (x : El A) -> F x =S G (B=A << x)
F=Gc x =
chain> F x
=== F (A=B << B=A << x) by symS (pF (castlem A=B B=A x))
=== G (B=A << x) by F=G _
cf=cg : (x : El A) -> F=Gc x << f (B=A << x)
== F=Gc x << g (B=A << x)
cf=cg x = p<< (F=Gc x) (f=g (B=A << x))
p<< {nat} {pi _ _ _} (eqS ()) _
p<< {pi _ _ _} {nat} (eqS ()) _
refS : Refl _=S_
refS {nat} = eqS T
refS {pi A F pF} = eqS (Pair refS \(x : El A) -> pF (castref refS x))
transS : Trans _=S_
transS {nat}{nat}{nat} p q = p
transS {nat}{nat}{pi _ _ _} _ (eqS ())
transS {nat}{pi _ _ _}{_} (eqS ()) _
transS {pi _ _ _}{nat}{_} (eqS ()) _
transS {pi _ _ _}{pi _ _ _}{nat} _ (eqS ())
transS {pi A F pF}{pi B G pG}{pi C H pH}
(eqS (Pair A=B F=G)) (eqS (Pair B=C G=H)) =
eqS (Pair A=C F=H)
where
open module C = Chain _=S_ refS transS
A=C = transS A=B B=C
F=H : (x : El C) -> F (A=C << x) =S H x
F=H x =
chain> F (A=C << x)
=== F (A=B << B=C << x) by symS (pF (casttrans A=B B=C A=C x))
=== G (B=C << x) by F=G (B=C << x)
=== H x by G=H x
symS : Sym _=S_
symS {nat}{nat} p = p
symS {pi _ _ _}{nat} (eqS ())
symS {nat}{pi _ _ _} (eqS ())
symS {pi A F pF}{pi B G pg} (eqS (Pair A=B F=G)) = eqS (Pair B=A G=F)
where
open module C = Chain _=S_ refS transS
B=A = symS A=B
G=F : (x : El A) -> G (B=A << x) =S F x
G=F x =
chain> G (B=A << x)
=== F (A=B << B=A << x) by symS (F=G (B=A << x))
=== F x by pF (castlem A=B B=A x)
pfi : {A B : S}(p q : A =S B)(x : El B) -> p << x == q << x
pfi {nat}{nat} _ _ x = ref
pfi {nat}{pi _ _ _} (eqS ()) _ _
pfi {pi _ _ _}{nat} (eqS ()) _ _
pfi {pi A F pF}{pi B G pG} (eqS (Pair A=B1 F=G1)) (eqS (Pair A=B2 F=G2))
(el (Pair f pf)) = eq f1=f2
where
B=A1 = symS A=B1
B=A2 = symS A=B2
f1=f2 : (x : El A) -> _ << f (B=A1 << x) == _ << f (B=A2 << x)
f1=f2 x =
chain> _ << f (B=A1 << x)
=== _ << _ << f (B=A2 << x) by p<< _ lem2
=== _ << f (B=A2 << x) by casttrans _ _ _ _
where
open module C = Chain _==_ (ref {F x}) (trans {F x})
lem1 : B=A1 << x == B=A2 << x
lem1 = pfi B=A1 B=A2 x
lem2 : f (B=A1 << x) == _ << f (B=A2 << x)
lem2 = pf lem1
castref : {A : S}(p : A =S A)(x : El A) -> p << x == x
castref {nat} p x = ref
castref {pi A F pF} (eqS (Pair A=A F=F)) (el (Pair f pf)) = eq cf=f
where
A=A' = symS A=A
cf=f : (x : El A) -> _ << f (A=A' << x) == f x
cf=f x =
chain> Fx=Fcx << f (A=A' << x)
=== Fx=Fcx << _ << f x by p<< Fx=Fcx lem2
=== refS << f x by casttrans _ _ _ (f x)
=== f x by castref _ (f x)
where
Fx=Fcx = _
open module C = Chain _==_ (ref {F x}) (trans {F x})
lem1 : A=A' << x == x
lem1 = castref A=A' x
lem2 : f (A=A' << x) == _ << f x
lem2 = pf lem1
casttrans : {A B C : S}(A=B : A =S B)(B=C : B =S C)(A=C : A =S C)(x : El C) ->
A=B << B=C << x == A=C << x
casttrans {nat}{nat}{nat} _ _ _ x = ref
casttrans {nat}{nat}{pi _ _ _} _ (eqS ()) _ _
casttrans {nat}{pi _ _ _}{_} (eqS ()) _ _ _
casttrans {pi _ _ _}{nat}{_} (eqS ()) _ _ _
casttrans {pi _ _ _}{pi _ _ _}{nat} _ (eqS ()) _ _
casttrans {pi A F pF}{pi B G pG}{pi C H pH}
(eqS (Pair A=B F=G))(eqS (Pair B=C G=H))(eqS (Pair A=C F=H))
(el (Pair h ph)) = eq prf
where
B=A = symS A=B
C=B = symS B=C
C=A = symS A=C
prf : (x : El A) -> _ << _ << h (C=B << B=A << x) == _ << h (C=A << x)
prf x =
chain> Fx=Gcx << Gcx=Hccx << h (C=B << B=A << x)
=== Fx=Hccx << h (C=B << B=A << x) by casttrans _ _ _ _
=== Fx=Hccx << _ << h (C=A << x) by p<< _ (ph (casttrans C=B B=A C=A x))
=== Fx=Hcx << h (C=A << x) by casttrans _ _ _ _
where
Fx=Gcx = _
Gcx=Hccx = _
Fx=Hccx = transS (lemF=Gc A=B pF pG F=G _)
(lemF=Gc B=C pG pH G=H _)
Fx=Hcx = _
open module C = Chain _==_ (ref {F x}) (trans {F x})
lemF=Gc : {A B : S}(A=B : A =S B)
{F : El A -> S}(pF : Map (El A) _==_ S _=S_ F)
{G : El B -> S}(pG : Map (El B) _==_ S _=S_ G)
(F=G : (x : El B) -> F (A=B << x) =S G x)
(x : El A) -> F x =S G (symS A=B << x)
lemF=Gc A=B {F} pF {G} pG F=G x =
chain> F x
=== F (A=B << B=A << x) by symS (pF (castlem A=B B=A x))
=== G (B=A << x) by F=G _
where
open module C = Chain _=S_ refS transS
B=A = symS A=B
castlem : {A B : S}(p : A =S B)(q : B =S A)(x : El A) ->
p << q << x == x
castlem {A}{B} p q x =
chain> p << q << x
=== refS << x by casttrans p q refS x
=== x by castref refS x
where open module C = Chain _==_ (ref {A}) (trans {A})
castlem2 : {A B B' C : S}(A=B : A =S B)(A=B' : A =S B')(B=C : B =S C)(B'=C : B' =S C)
(x : El C) ->
A=B << B=C << x == A=B' << B'=C << x
castlem2 {A} p p' q q' x =
chain> p << q << x
=== transS p q << x by casttrans _ _ _ x
=== transS p' q' << x by pfi _ _ _
=== p' << q' << x by sym (casttrans _ _ _ x)
where open module C = Chain _==_ (ref {A}) (trans {A})
ref : {A:S} -> Refl {El A} _==_
ref {nat} {el n} = eq refN
ref {pi A F pF}{el (Pair f pf)} = eq f=f
where
f=f : (x : El A) -> f x == f x
f=f x = ref
trans : {A:S} -> Trans {El A} _==_
trans {nat}{el x}{el y}{el z} (eq p) (eq q) = eq (transN p q)
trans {pi A F pF}{el (Pair f pf)}{el (Pair g pg)}{el (Pair h ph)}
(eq f=g)(eq g=h) = eq f=h
where
f=h : (x : El A) -> f x == h x
f=h x = trans (f=g x) (g=h x)
sym : {A:S} -> Sym {El A} _==_
sym {nat}{el x}{el y} (eq p) = eq (symN p)
sym {pi A F pF}{el (Pair f pf)}{el (Pair g pg)}
(eq f=g) = eq g=f
where
g=f : (x : El A) -> g x == f x
g=f x = sym (f=g x)
| {
"alphanum_fraction": 0.3997606224,
"avg_line_length": 31.1366459627,
"ext": "agda",
"hexsha": "fa37bf22144fd7a59e883628266cd5e3a660f388",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/bugs/univ.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/bugs/univ.agda",
"max_line_length": 95,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/bugs/univ.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": 4108,
"size": 10026
} |
module _ where
open import utility
open import Function using (_∘_)
open import Esterel.Lang
open import Esterel.Lang.Properties
open import Esterel.Lang.CanFunction
using (Canₛ ; Canₛₕ)
open import Esterel.Environment as Env
using (Env ; Θ ; _←_ ; module SigMap ; module ShrMap ; module VarMap ; []env ; sig-stats ; Dom)
open import Esterel.Context
using (EvaluationContext ; EvaluationContext1 ; _⟦_⟧e ; _≐_⟦_⟧e ;
Context ; Context1 ; _⟦_⟧c ; _≐_⟦_⟧c)
open import Esterel.Context.Properties
open import Esterel.Variable.Signal as Signal
using (Signal ; _ₛ)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar)
open import Esterel.Variable.Sequential as SeqVar
using (SeqVar)
open import Relation.Nullary
using (¬_ ; yes ; no)
open import Relation.Binary.PropositionalEquality
using (_≡_ ; refl)
open import Data.Empty
using (⊥ ; ⊥-elim)
import Data.FiniteMap
open import Data.List
using (List ; _∷_ ; [] ; _++_)
open import Data.List.All as All
using (All ; _∷_ ; [])
open import Data.Nat
using (ℕ ; zero ; suc ; _+_)
open import Data.Product
using (Σ-syntax ; Σ ; _,_ ; proj₁ ; proj₂ ; _×_ ; _,′_ ; ∃ )
open import Data.Sum
using (_⊎_ ; inj₁ ; inj₂)
open import Relation.Binary.PropositionalEquality
open import Esterel.Lang.Binding
-- open import coherence
open import blocked
open import sn-calculus
open import par-swap
open import calculus
open _≐_⟦_⟧e
open _≐_⟦_⟧c
open EvaluationContext1
open Context1
open import Data.Maybe
sn≡ₑ-context : ∀ p q C ->
(∀ p BVp FVp -> CorrectBinding p BVp FVp -> CB (C ⟦ p ⟧c)) ->
p sn≡ₑ q -> (C ⟦ p ⟧c) sn≡ₑ (C ⟦ q ⟧c)
sn≡ₑ-context p q C CBfill (rstp psn⟶q) = rstp (Context-sn⟶⟦⟧ C psn⟶q)
sn≡ₑ-context p q C CBfill (rsym{p = .q}{BV = BV} {FV} psn≡ₑq CBq) with sn≡ₑ-context q p C CBfill psn≡ₑq
... | C⟦q⟧csn≡ₑC⟦p⟧c = rsym C⟦q⟧csn≡ₑC⟦p⟧c (CBfill q BV FV CBq)
sn≡ₑ-context p .p C _ rref = rref
sn≡ₑ-context p q C CBfill (rtrn{r = r} psn≡ₑr rsn≡ₑq) with
sn≡ₑ-context p r C CBfill psn≡ₑr | sn≡ₑ-context r q C CBfill rsn≡ₑq
... | C⟦p⟧csn≡ₑC⟦r⟧c | C⟦r⟧csn≡ₑC⟦q⟧c = rtrn {r = C ⟦ r ⟧c} C⟦p⟧csn≡ₑC⟦r⟧c C⟦r⟧csn≡ₑC⟦q⟧c
sn≡ₑ-sn⟶* : ∀ {p q} -> p sn⟶* q -> p sn≡ₑ q
sn≡ₑ-sn⟶* rrefl = rref
sn≡ₑ-sn⟶* (rstep psn⟶q psn⟶*q) = rtrn (rstp psn⟶q) (sn≡ₑ-sn⟶* psn⟶*q)
≡ₑ-context :
∀ {p q} -> ∀ C1 C2 ->
(∀ {r r′ BVp FVp} -> CorrectBinding r BVp FVp -> r′ ≐ C2 ⟦ r ⟧c -> CB r′) ->
p ≡ₑ q # C1 ->
p ≡ₑ q # (C2 ++ C1)
≡ₑ-context C C′ CBfill ≡ₑrefl = ≡ₑrefl
≡ₑ-context C C′ CBfill (≡ₑtran p≡ₑr r≡ₑq)
with ≡ₑ-context C C′ CBfill p≡ₑr
... | p≡ₑr#C
with ≡ₑ-context C C′ CBfill r≡ₑq
... | r≡ₑq#C = ≡ₑtran p≡ₑr#C r≡ₑq#C
≡ₑ-context C C′ CBfill (≡ₑsymm{q = q} CBq p≡ₑq)
with ≡ₑ-context C C′ CBfill p≡ₑq
... | q≡ₑp#C = ≡ₑsymm (CBfill CBq (++-is-nesting C′ C _)) q≡ₑp#C
≡ₑ-context C1 C2 CBfill (≡ₑctxt{_}{C''} C′⟦p⟧≐C′⟦p⟧c C′⟦q⟧≐C′⟦q⟧c p≡ₑq)
with ≡ₑ-context (C1 ++ C'') C2 wrapCBfill p≡ₑq where
wrapCBfill : ∀ {r r′ BVp FVp} ->
CorrectBinding r BVp FVp ->
r′ ≐ C2 ⟦ r ⟧c ->
CB r′
wrapCBfill{r} CB C′⟦r⟧c = CBfill CB C′⟦r⟧c
... | p≡ₑq#[C′++C++C''] rewrite sym (++-assoc C2 C1 C'')
= ≡ₑctxt C′⟦p⟧≐C′⟦p⟧c C′⟦q⟧≐C′⟦q⟧c p≡ₑq#[C′++C++C'']
≡ₑ-context C C′ CBfill (≡ₑstep p⟶₁q)
= ≡ₑstep p⟶₁q
θ-present-signals : Env → List Signal
θ-present-signals θ = Data.List.mapMaybe (f ∘ _ₛ) DomS
where
DomS = (fst (Env.Dom θ))
f : Signal → Maybe Signal
f S with (Env.Sig∈ S θ)
... | (no S∈) = nothing
... | (yes S∈) with sig-stats{S} θ S∈
... | Signal.present = just S
... | Signal.absent = nothing
... | Signal.unknown = nothing
get-signals : Term → List Signal
get-signals nothin = []
get-signals pause = []
get-signals (signl S p) = []
get-signals (present S ∣⇒ p ∣⇒ p₁) = []
get-signals (emit S) = []
get-signals (p ∥ p₁) = []
get-signals (loop p) = []
get-signals (loopˢ p q) = []
get-signals (p >> p₁) = []
get-signals (suspend p S) = []
get-signals (trap p) = []
get-signals (exit x) = []
get-signals (shared s ≔ e in: p) = []
get-signals (s ⇐ e) = []
get-signals (var x ≔ e in: p) = []
get-signals (x ≔ e) = []
get-signals (if x ∣⇒ p ∣⇒ p₁) = []
get-signals (ρ⟨ θ , A ⟩· p) = θ-present-signals θ
data eval-result : Set where
output : List Signal → eval-result
data non-constructive : Env → Term → Set where
nc : ∀{p θ} → (Σ (Env × Term) λ {(θq , q) → (ρ⟨ θ , GO ⟩· p) sn≡ₑ (ρ⟨ θq , GO ⟩· q) × (manifests-as-non-constructive θq GO q)})
→ non-constructive θ p
data evalsn≡ₑ : Term → Env → eval-result → Set where
evalsn-complete : ∀{p q θ θq} →
(ρθ·p≡q : (ρ⟨ θ , GO ⟩· p) sn≡ₑ (ρ⟨ θq , GO ⟩· q)) →
(complete-q : complete (ρ⟨ θq , GO ⟩· q)) →
evalsn≡ₑ p θ (output (get-signals (ρ⟨ θq , GO ⟩· q)))
data eval∥R∪sn≡ₑ : Term → Env → eval-result → Set where
eval∥R∪sn-complete : ∀{p q θ θq} →
(ρθ·p≡q : (ρ⟨ θ , GO ⟩· p) ∥R∪sn≡ₑ (ρ⟨ θq , GO ⟩· q)) →
(complete-q : complete (ρ⟨ θq , GO ⟩· q)) →
eval∥R∪sn≡ₑ p θ (output (get-signals (ρ⟨ θq , GO ⟩· q)))
data eval≡ₑ : Term → Env → eval-result → Set where
eval-complete : ∀{p q θ θq} →
(ρθ·p≡q : (ρ⟨ θ , GO ⟩· p) ≡ₑ (ρ⟨ θq , GO ⟩· q) # []) →
(complete-q : complete (ρ⟨ θq , GO ⟩· q)) →
eval≡ₑ p θ (output (get-signals (ρ⟨ θq , GO ⟩· q)))
| {
"alphanum_fraction": 0.5874045802,
"avg_line_length": 33.8064516129,
"ext": "agda",
"hexsha": "c0c6346a50d31626da04fafbf4ca85692c812a17",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/eval.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "florence/esterel-calculus",
"max_issues_repo_path": "agda/eval.agda",
"max_line_length": 129,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/eval.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 2464,
"size": 5240
} |
-- The comonad named Store by Russel O'Connor.
-- See his WGP 2011 paper.
{-# OPTIONS --copatterns #-}
module Control.Comonad.Store where
open import Function using (id) renaming (_∘′_ to _∘_)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; cong; cong₂; module ≡-Reasoning)
open ≡-Reasoning
open import Axiom.FunctionExtensionality
open import Util.Equality
open import Control.Functor
open import Control.Functor.NaturalTransformation
open import Control.Comonad
-- The Store comonad.
record Store (I O : Set) : Set where
constructor store
field
peek : I → O
pos : I
extract : O
extract = peek pos
{- not in scope: store
extend′ : ∀ {B} → (Store I O → B) → Store I B
extend′ f = store (f ∘ store peek) pos
-}
extend′ : ∀ {B} → (Store I O → B) → Store I B
pos (extend′ f) = pos
peek (extend′ f) = f ∘ s
where
s : I → Store I O
peek (s i) = peek
pos (s i) = i
storeIsComonad : ∀ I → IsComonad (Store I)
storeIsComonad I = record
{ extract = extract
; extend = extend
; extend-β = refl
; extend-η = refl
; extend-∘ = refl
}
where
extract : ∀ {O} → Store I O → O
extract (store v i) = v i
extend : ∀ {A B} → (Store I A → B) → Store I A → Store I B
extend f (store v i) = store (f ∘ store v) i
extend-β : ∀ {A B} (f : Store I A → B) → extract ∘ extend f ≡ f
extend-β f = refl
StoreC : ∀ I → Comonad
StoreC I = comonad (Store I) (storeIsComonad I)
-- Functoriality,
storeIsFunctor : ∀ I → IsFunctor (Store I)
storeIsFunctor I = IsComonad.isFunctor (storeIsComonad I)
StoreF : (I : Set) → Functor
StoreF I = functor (Store I) (storeIsFunctor I)
idLens : ∀ {I} → I → Store I I
idLens = store id
-- Van Laarhoven presentation
record LStore (I O : Set) : Set₁ where
-- constructor lstore
field
modifier : (FF : Functor) → let open Functor FF in
(I → F I) → F O
-- Laws.
-- 0. Free theorem.
field
modifier-free : {FF GG : Functor} (N : NatTrans FF GG) →
let open Functor FF using () renaming (F to F) in
let open Functor GG using () renaming (F to G) in
let open NatTrans N using () renaming (eta to η) in
(f : I → F I) →
η (modifier FF f) ≡ modifier GG (η ∘ f)
-- 1. Identity
-- modifier-id :
-- Converting between store comonads.
storeToLStore : ∀ {I O} → Store I O → LStore I O
storeToLStore {I = I} {O = O} (store v i) = record
{ modifier = modifier
; modifier-free = modifier-free
}
where
modifier : (FF : Functor) → let open Functor FF in
(I → F I) → F O
modifier FF f = map v (f i)
where open Functor FF
modifier-free : {FF GG : Functor} (N : NatTrans FF GG) →
let open Functor FF using () renaming (F to F) in
let open Functor GG using () renaming (F to G) in
let open NatTrans N using () renaming (eta to η) in
(f : I → F I) →
η (modifier FF f) ≡ modifier GG (η ∘ f)
modifier-free {FF = FF}{GG = GG} N f = begin
η (modifier FF f) ≡⟨⟩
(η ∘ mapF v) (f i) ≡⟨ app-≡ (f i) (naturality _) ⟩
(mapG v ∘ η) (f i) ≡⟨⟩
modifier GG (η ∘ f) ∎
where
open Functor FF using () renaming (F to F; map to mapF; map-id to mapF-id; map-∘ to mapF-∘)
open Functor GG using () renaming (F to G; map to mapG; map-id to mapG-id; map-∘ to mapG-∘)
open NatTrans N using (naturality) renaming (eta to η)
lstoreToStore : ∀ {I O} → LStore I O → Store I O
lstoreToStore {I = I} {O = O} l = LStore.modifier l (StoreF I) idLens
-- Isomorphism.
storeId : ∀ {I O} (s : Store I O) → lstoreToStore (storeToLStore s) ≡ s
storeId {I = I}{O = O} (store v i) = begin
lstoreToStore (storeToLStore (store v i)) ≡⟨⟩
LStore.modifier (storeToLStore (store v i)) (StoreF I) idLens ≡⟨⟩
Functor.map (StoreF I) v (idLens i) ≡⟨⟩
Functor.map (StoreF I) v (store id i) ≡⟨⟩
store (v ∘ id) i ≡⟨⟩
store v i ∎
-- -- BAD IDEA: the proof of modifier-free should not be compared with ≡
-- lstoreId : ∀ {I O} (l : LStore I O) → storeToLStore (lstoreToStore l) ≡ l
-- lstoreId {I = I}{O = O} l = begin
-- storeToLStore (lstoreToStore l) ≡⟨⟩
-- storeToLStore (modifier (StoreF I) idLens) ≡⟨⟩
-- storeToLStore (modifier (StoreF I) idLens) ≡⟨ {!!} ⟩
-- l ∎
-- where open LStore l
| {
"alphanum_fraction": 0.5728565082,
"avg_line_length": 29.0451612903,
"ext": "agda",
"hexsha": "4065077113d4cb066722abfe750bb59fec2263c4",
"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": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andreasabel/cubical",
"max_forks_repo_path": "src/Control/Comonad/Store.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3",
"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": "andreasabel/cubical",
"max_issues_repo_path": "src/Control/Comonad/Store.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andreasabel/cubical",
"max_stars_repo_path": "src/Control/Comonad/Store.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1550,
"size": 4502
} |
module z04-lists where
open import bool
open import eq
open import nat
open import nat-thms
open import product-thms using (keep)
open import logic -- needed for filter-idem
{-
-- p 75
'data' : datatype declaration
'𝕃' : name of type being declared
{ℓ} : level
A : element type (polymorphic)
𝕃 is a type level function
- takes a type (bound to 'A') - at level ℓ
- returns a type - at level same level ℓ
-}
data 𝕃 {ℓ} (A : Set ℓ) : Set ℓ where
[] : 𝕃 A
_::_ : (x : A) (xs : 𝕃 A) → 𝕃 A
-- from lists.agda
[_] : ∀ {ℓ} {A : Set ℓ} → A → 𝕃 A
[ x ] = x :: []
-- p 77
length : ∀ {ℓ} {A : Set ℓ } → 𝕃 A → ℕ
length [] = 0
length (x :: xs) = suc (length xs)
-- 78
_++_ : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A → 𝕃 A
[] ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
-- 79
map : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → (A → B) → 𝕃 A → 𝕃 B
map f [] = []
map f (x :: xs) = f x :: map f xs
-- 80
filter : ∀ {ℓ} {A : Set ℓ} → (A → 𝔹) → 𝕃 A → 𝕃 A
filter p [] = []
filter p (x :: xs) = if p x then x :: r else r
where
r = filter p xs
-- p 81
remove : ∀ {ℓ} {A : Set ℓ} (eq : A → A → 𝔹) (a : A) (l : 𝕃 A) → 𝕃 A
remove eq a l = filter (λ x → ~ (eq a x)) l
-- p 82
data maybe {ℓ} (A : Set ℓ) : Set ℓ where
just : A → maybe A
nothing : maybe A
nth : ∀ {ℓ} {A : Set ℓ} → ℕ → 𝕃 A → maybe A
nth _ [] = nothing
nth 0 (x :: xs) = just x
nth (suc n) (x :: xs) = nth n xs
-- p 83
-- inefficient
sreverse : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A
sreverse [] = []
sreverse (h :: t) = sreverse t ++ [ h ]
reverse-helper : ∀ {ℓ}{A : Set ℓ} → 𝕃 A → 𝕃 A → 𝕃 A
reverse-helper h [] = h
reverse-helper h (x :: xs) = reverse-helper (x :: h) xs
reverse : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A
reverse l = reverse-helper [] l
------------------------------------------------------------------------------
-- p 84 Reasong about List Operations
length-++ : ∀ {ℓ}{A : Set ℓ} (l1 l2 : 𝕃 A)
→ length (l1 ++ l2) ≡ length l1 + length l2
length-++ [] l2 -- length ([] ++ l2) ≡ length [] + length l2
-- length l2 ≡ length l2
= refl
length-++ (x :: xs) l2 -- length ((x :: xs) ++ l2) ≡ length (x :: xs) + length l2
-- suc (length (xs ++ l2)) ≡ suc (length xs + length l2)
-- |
rewrite -- IH ≡
-- v
length-++ xs l2 -- suc (length xs + length l2) ≡ suc (length xs + length l2)
= refl
-- p 86
++-assoc : ∀ {ℓ} {A : Set ℓ} (l1 l2 l3 : 𝕃 A)
→ (l1 ++ l2) ++ l3
≡ l1 ++ (l2 ++ l3)
++-assoc [] l2 l3 -- (([] ++ l2) ++ l3) ≡ ([] ++ (l2 ++ l3))
-- (l2 ++ l3) ≡ (l2 ++ l3)
= refl
++-assoc (x :: xs) l2 l3 -- (((x :: xs) ++ l2) ++ l3) ≡ ((x :: xs) ++ (l2 ++ l3))
-- (x :: ((xs ++ l2) ++ l3)) ≡ (x :: (xs ++ (l2 ++ l3)))
rewrite -- IH v
++-assoc xs l2 l3 -- (x :: (xs ++ (l2 ++ l3))) ≡ (x :: (xs ++ (l2 ++ l3)))
= refl
{-
------------------------------------------------------------------------------
-- p 87 - WITH
for
- any type A (of any level),
- any predicate p on A
- any list of A
the length of the list after filtering l with p
<=
length of l
-}
length-filter : ∀ {ℓ} {A : Set ℓ} (p : A → 𝔹) (l : 𝕃 A)
→ length (filter p l) ≤ length l ≡ tt
-- proof case-splits input list
length-filter p [] -- length (filter p []) ≤ length [] ≡ tt
-- 0 ≤ 0 ≡ tt
= refl
-- Consider cases where predicate returns tt or ff.
-- The predicate return value is NOT an input to length-filter.
-- WITH : extend pattern on left side with an additional pattern, here : | tt and | ff
length-filter p (x :: l) with p x
length-filter p (x :: l) | tt -- length (filter p l) < length l
-- || length (filter p l) =ℕ length l ≡ tt
= length-filter p l -- IH
length-filter p (x :: l) | ff -- length (filter p l) < suc (length l)
= -- || length (filter p l) =ℕ suc (length l) ≡ tt
≤-trans {length (filter p l)}
(length-filter p l) -- IH
(≤-suc (length l)) -- ≤-suc proves length l ≤ suc (length l)
{- this is to see the goal for the non-nil case
lf : ∀ {ℓ} {A : Set ℓ} (p : A → 𝔹) (l : 𝕃 A)
→ length (filter p l) ≤ length l ≡ tt
lf p [] = refl
lf p (x :: l) -- length (filter p (x :: l)) ≤ length (x :: l) ≡ tt
-- length (if p x then x :: filter p l else filter p l) ≤ suc (length l) ≡ tt
= {!!}
------------------------------------------------------------------------------
-- p 90 KEEP (called INSPECT in Agda standard library)
filtering a list twice using same predicate gives the same result as filtering it once
cannot use WITH because Agda only applies the p ≡ tt to the goal once, not the next iteration
(see page 92 for more details)
'with keep (p x)' : make additional variable (here p') available
-}
filter-idem : ∀ {ℓ} {A : Set ℓ} (p : A → 𝔹) (l : 𝕃 A)
→ (filter p (filter p l)) ≡ (filter p l)
filter-idem p [] -- filter p (filter p []) ≡ filter p []
-- [] ≡ []
= refl
{-
filter-idem p (x :: l) -- filter p (filter p (x :: l)) ≡ filter p (x :: l)
--
-- filter p (if p x then x :: filter p l else filter p l)
-- ≡ if p x then x :: filter p l else filter p l
= {!!}
-}
filter-idem p (x :: l) with keep (p x)
filter-idem p (x :: l) | tt , p' -- filter p (if p x then x :: filter p l else filter p l)
-- ≡ if p x then x :: filter p l else filter p l
rewrite
-- agda does not instantiate 'p x' in goal
-- must explicit use it below to change 'p x' to 'tt' (or 'ff' further below)
p' -- filter p (if tt then x :: filter p l else filter p l)
-- ≡ if tt then x :: filter p l else filter p l
--
-- if p x then x :: filter p (filter p l) else filter p (filter p l)
-- ≡ (x :: filter p l)
-- use it again to eliminate the if
| p' -- if tt then x :: filter p (filter p l) else filter p (filter p l)
-- ≡ (x :: filter p l)
--
-- (x :: filter p (filter p l)) ≡ (x :: filter p l)
| filter-idem p l -- (x :: filter p l) ≡ (x :: filter p l)
= refl
filter-idem p (x :: l) | ff , p' -- filter p (if p x then x :: filter p l else filter p l)
-- ≡ if p x then x :: filter p l else filter p l
rewrite p' -- filter p (if ff then x :: filter p l else filter p l)
-- ≡ if ff then x :: filter p l else filter p l
--
-- filter p (filter p l) ≡ filter p l
= filter-idem p l
{-
------------------------------------------------------------------------------
-- p 93
reverse-helper args
- reverse of the list processed so far
- rest of list to be reversed
tricky to figure out what general property of reverse-helper to prove
-length of reverse-helper h l is sum of lengths of h and l
-}
length-reverse-helper
: ∀ {ℓ} {A : Set ℓ} (h l : 𝕃 A)
→ length (reverse-helper h l) ≡ length h + length l
length-reverse-helper h [] -- length (reverse-helper h []) ≡ length h + length []
-- length h ≡ length h + 0
rewrite
+comm (length h) 0 -- length h ≡ length h
-- also can do via
-- rewrite +0 (length h) = refl
= refl
length-reverse-helper h (x :: xs)
-- length (reverse-helper h (x :: xs)) ≡ length h + length (x :: xs)
-- length (reverse-helper (x :: h) xs) ≡ length h + suc (length xs)
rewrite
length-reverse-helper (x :: h) xs -- IH -- suc (length h + length xs) ≡ length h + suc (length xs)
| +suc (length h) (length xs) -- suc (length h + length xs) ≡ suc (length h + length xs)
= refl
length-reverse : ∀ {ℓ} {A : Set ℓ} (l : 𝕃 A)
→ length (reverse l) ≡ length l
length-reverse l = length-reverse-helper [] l
{-
------------------------------------------------------------------------------
-- p 95 conclusion : WITH and KEEP (aka INSPECT)
-- p 96 EXERCISES
-- 1
-}
-------------------------
-- NOT TRUE
-- 1a : ∀ {ℓ} {A : Set ℓ} (l1 l2 : 𝕃 A) → l1 ++ l2 ≡ l2 ++ l1
-------------------------
-- NOT TRUE
-- 1b : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) (l : 𝕃 A) → length (map f l) ≡ suc (length l)
-------------------------
-- 1c: TRUE
repeat : ∀ {ℓ} {A : Set ℓ} → ℕ → A → 𝕃 A
repeat 0 a = []
repeat (suc n) a = a :: (repeat n a)
1c : ∀ {ℓ} {A : Set ℓ} {p : A → 𝔹} {a : A} (n : ℕ)
→ p a ≡ ff
→ filter p (repeat n a) ≡ []
1c 0 prop -- filter p (repeat zero a) ≡ []
-- [] ≡ []
= refl
1c (suc n) prop -- filter p (repeat (suc n) a) ≡ []
-- if p a then a :: filter p (repeat n a) else filter p (repeat n a) ≡ []
rewrite
prop -- if ff then a :: filter p (repeat n a) else filter p (repeat n a) ≡ []
-- filter p (repeat n a) ≡ []
= 1c n prop -- IH
-------------------------
-- NOT TRUE
-- 1d : ∀ {ℓ} {A : Set ℓ} (l : 𝕃 A) → is-empty l ≡ tt → is-empty (reverse l) ≡ ff
-------------------------
-- TRUE
1e : ∀ {ℓ} {A : Set ℓ} (p : A -> 𝔹) (l1 l2 : 𝕃 A)
→ filter p (l1 ++ l2)
≡ filter p l1 ++ filter p l2
1e p [] l2 -- filter p ([] ++ l2) ≡ (filter p [] ++ filter p l2)
-- filter p l2 ≡ filter p l2
= refl
1e p (x :: xs) l2 with keep (p x)
1e p (x :: xs) l2 | tt , p' -- if p x then x :: filter p (xs ++ l2) else filter p (xs ++ l2)
-- ≡ ((if p x then x :: filter p xs else filter p xs) ++ filter p l2)
rewrite
p' -- if tt then x :: filter p (xs ++ l2) else filter p (xs ++ l2)
-- ≡ ((if tt then x :: filter p xs else filter p xs) ++ filter p l2)
--
-- (x :: filter p (xs ++ l2))
-- ≡ (x :: (filter p xs ++ filter p l2))
| 1e p xs l2 -- (x :: (filter p xs ++ filter p l2))
-- ≡ (x :: (filter p xs ++ filter p l2))
= refl
1e p (x :: xs) l2 | ff , p' -- if p x then x :: filter p (xs ++ l2) else filter p (xs ++ l2)
-- ≡ ((if p x then x :: filter p xs else filter p xs) ++ filter p l2)
rewrite
p' -- if ff then x :: filter p (xs ++ l2) else filter p (xs ++ l2)
-- ≡ ((if ff then x :: filter p xs else filter p xs) ++ filter p l2)
--
-- filter p (xs ++ l2) ≡ (filter p xs ++ filter p l2)
= 1e p xs l2 -- IH
--------------------------------------------------
-- 2
-------------------------
-- 2a [] : 𝕃 Set (𝕃 _A_277)
-------------------------
2b : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → ℕ
2b [] = 0
2b (x :: xs) = suc (2b xs)
-------------------------
-- Note: 2ci does not explicitly give ℓ
-- Note: some other answers are probably OK - did not check
2c : ∀ {ℓ} {A : Set ℓ} {B : Set ℓ} {C : Set ℓ}
→ (A → B)
→ (B → C)
→ 𝕃 A
→ 𝕃 C
2c f g x = map g (map f x)
--------------------------------------------------
-- 3
takeWhile : ∀ {ℓ} {A : Set ℓ} → (A → 𝔹) -> 𝕃 A → 𝕃 A
takeWhile p [] = []
takeWhile p (x :: xs) = if p x then x :: takeWhile p xs else takeWhile p xs
--------------------------------------------------
-- 4
4twr : ∀ {ℓ} {A : Set ℓ} {p : A → 𝔹} {a : A} (n : ℕ)
→ p a ≡ tt
→ takeWhile p (repeat n a) ≡ repeat n a
4twr zero p -- takeWhile p₁ (repeat zero a) ≡ repeat zero a
-- [] ≡ []
= refl
4twr {l} {A} {pred} {a} (suc n) p -- takeWhile p₁ (repeat (suc n) a) ≡ repeat (suc n) a
-- if p₁ a then a :: takeWhile p₁ (repeat n a) else takeWhile p₁ (repeat n a)
-- ≡ (a :: repeat n a)
rewrite
p -- if tt then a :: takeWhile p₁ (repeat n a) else takeWhile p₁ (repeat n a)
-- ≡ (a :: repeat n a)
-- (a :: takeWhile p₁ (repeat n a))
-- ≡ (a :: repeat n a)
| 4twr {l} {A} {pred} {a} n p -- (a :: repeat n a) ≡ (a :: repeat n a)
= refl
--------------------------------------------------
-- 5
take : ∀ {ℓ} {A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A
take 0 _ = []
take _ [] = []
take (suc n) (x :: xs) = x :: take n xs
--------------------------------------------------
-- 6
nthTail : ∀ {ℓ} {A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A
nthTail 0 xs = xs
nthTail _ [] = []
nthTail (suc n) (x :: xs) = nthTail n xs
{-
6tn : ∀ {ℓ} {A : Set ℓ} {a : A} (n : ℕ) (l : 𝕃 A)
→ take n l ++ nthTail n l ≡ l
6tn zero l -- (take zero l ++ nthTail zero l) ≡ l
-- l ≡ l
= refl
6tn {ℓ} {A} {a} (suc n) l -- (take (suc n) l ++ nthTail (suc n) l) ≡ l
rewrite
6tn {ℓ} {A} {a} n l
= {!!}
-}
6tn : ∀ {ℓ} {A : Set ℓ} {a : A} (n : ℕ) (l : 𝕃 A)
→ take n l ++ nthTail n l ≡ l
6tn zero [] -- (take zero [] ++ nthTail zero []) ≡ []
-- [] ≡ []
= refl
6tn (suc n) [] -- (take (suc n) [] ++ nthTail (suc n) []) ≡ []
-- [] ≡ []
= refl
6tn zero (x :: xs) -- (take zero (x :: xs) ++ nthTail zero (x :: xs)) ≡ (x :: xs)
-- (x :: xs) ≡ (x :: xs)
= refl
6tn {ℓ} {A} {a} (suc n) (x :: xs) -- (take (suc n) (x :: xs) ++ nthTail (suc n) (x :: xs)) ≡ (x :: xs)
-- (x :: (take n xs ++ nthTail n xs)) ≡ (x :: xs)
rewrite
6tn {ℓ} {A} {a} n xs -- (x :: xs) ≡ (x :: xs)
= refl
| {
"alphanum_fraction": 0.3800706621,
"avg_line_length": 36.6522781775,
"ext": "agda",
"hexsha": "ff6fb52052a86db45f26d510887608f0182e603c",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z",
"max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"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": "haroldcarr/learn-haskell-coq-ml-etc",
"max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda",
"max_line_length": 115,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z",
"num_tokens": 4834,
"size": 15284
} |
-- {-# OPTIONS -v tc.proj.like:10 #-}
-- {-# OPTIONS -v tc.conv:10 #-}
open import Common.Level
module ProjectionLikeAndModules (A : Set) (a : A) where
record ⊤ : Set where
constructor tt
data Wrap (W : Set) : Set where
wrap : W → Wrap W
data Bool : Set where
true false : Bool
-- postulate
-- `or' should be projection like in the module parameters
if : Bool → {ℓ : Level} {B : Set ℓ} → B → B → B
if true a b = a
if false a b = b
postulate
u v : ⊤
P : {ℓ : Level} {C : Set ℓ} (c : C) -> Set
test : (y : Bool)
-> P (if y (wrap u) (wrap tt))
-> P (if y (wrap tt) (wrap v))
test y h = h
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/Conversion.hs:536
| {
"alphanum_fraction": 0.6115591398,
"avg_line_length": 21.8823529412,
"ext": "agda",
"hexsha": "788165820d62d76ea1a1ad7976e54c9b547bf768",
"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/ProjectionLikeAndModules.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/ProjectionLikeAndModules.agda",
"max_line_length": 70,
"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/ProjectionLikeAndModules.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": 744
} |
{-# OPTIONS --without-K --safe #-}
open import Algebra.Structures.Bundles.Field
open import Algebra.Linear.Structures.Bundles
module Algebra.Linear.Space.Product
{k ℓ} (K : Field k ℓ)
{a₁ ℓ₁} (V₁-space : VectorSpace K a₁ ℓ₁)
{a₂ ℓ₂} (V₂-space : VectorSpace K a₂ ℓ₂)
where
open import Relation.Binary
open import Level using (_⊔_)
open import Data.Nat using (ℕ; zero; suc) renaming (_+_ to _+ℕ_)
open import Algebra.Linear.Structures.VectorSpace
import Algebra.FunctionProperties as FP
open VectorSpaceField K
open VectorSpace V₁-space
using ()
renaming
( Carrier to V₁
; _≈_ to _≈₁_
; isEquivalence to ≈₁-isEquiv
; refl to ≈₁-refl
; sym to ≈₁-sym
; trans to ≈₁-trans
; _+_ to _+₁_
; _∙_ to _∙₁_
; -_ to -₁_
; 0# to 0₁
; +-identityˡ to +₁-identityˡ
; +-identityʳ to +₁-identityʳ
; +-identity to +₁-identity
; +-cong to +₁-cong
; +-assoc to +₁-assoc
; +-comm to +₁-comm
; *ᵏ-∙-compat to *ᵏ-∙₁-compat
; ∙-+-distrib to ∙₁-+₁-distrib
; ∙-+ᵏ-distrib to ∙₁-+ᵏ-distrib
; ∙-cong to ∙₁-cong
; ∙-identity to ∙₁-identity
; ∙-absorbˡ to ∙₁-absorbˡ
; ∙-absorbʳ to ∙₁-absorbʳ
; -‿cong to -₁‿cong
; -‿inverseˡ to -₁‿inverseˡ
; -‿inverseʳ to -₁‿inverseʳ
)
open VectorSpace V₂-space
using ()
renaming
( Carrier to V₂
; _≈_ to _≈₂_
; isEquivalence to ≈₂-isEquiv
; refl to ≈₂-refl
; sym to ≈₂-sym
; trans to ≈₂-trans
; _+_ to _+₂_
; _∙_ to _∙₂_
; -_ to -₂_
; 0# to 0₂
; +-identityˡ to +₂-identityˡ
; +-identityʳ to +₂-identityʳ
; +-identity to +₂-identity
; +-cong to +₂-cong
; +-assoc to +₂-assoc
; +-comm to +₂-comm
; *ᵏ-∙-compat to *ᵏ-∙₂-compat
; ∙-+-distrib to ∙₂-+₂-distrib
; ∙-+ᵏ-distrib to ∙₂-+ᵏ-distrib
; ∙-cong to ∙₂-cong
; ∙-identity to ∙₂-identity
; ∙-absorbˡ to ∙₂-absorbˡ
; ∙-absorbʳ to ∙₂-absorbʳ
; -‿cong to -₂‿cong
; -‿inverseˡ to -₂‿inverseˡ
; -‿inverseʳ to -₂‿inverseʳ
)
open import Data.Product
open import Data.Product.Relation.Binary.Pointwise.NonDependent
private
V : Set (a₁ ⊔ a₂)
V = V₁ × V₂
_≈_ : Rel V (ℓ₁ ⊔ ℓ₂)
_≈_ = Pointwise _≈₁_ _≈₂_
≈-isEquiv : IsEquivalence _≈_
≈-isEquiv = ×-isEquivalence ≈₁-isEquiv ≈₂-isEquiv
prod-setoid : Setoid (a₁ ⊔ a₂) (ℓ₁ ⊔ ℓ₂)
prod-setoid = record
{ Carrier = V
; _≈_ = _≈_
; isEquivalence = ≈-isEquiv
}
open IsEquivalence ≈-isEquiv renaming
( refl to ≈-refl
; sym to ≈-sym
; trans to ≈-trans
)
open import Algebra.FunctionProperties _≈_
open import Algebra.Structures _≈_
0# : V
0# = (0₁ , 0₂)
-_ : Op₁ V
- (x₁ , x₂) = (-₁ x₁ , -₂ x₂)
infixr 25 _+_
_+_ : Op₂ V
(x₁ , x₂) + (y₁ , y₂) = (x₁ +₁ y₁ , x₂ +₂ y₂)
infixr 30 _∙_
_∙_ : K' -> V -> V
k ∙ (x₁ , x₂) = (k ∙₁ x₁ , k ∙₂ x₂)
+-cong : Congruent₂ _+_
+-cong (r₁ , r₂) (s₁ , s₂) = ( +₁-cong r₁ s₁ , +₂-cong r₂ s₂ )
+-assoc : Associative _+_
+-assoc (x₁ , x₂) (y₁ , y₂) (z₁ , z₂) = ( +₁-assoc x₁ y₁ z₁ , +₂-assoc x₂ y₂ z₂ )
+-identityˡ : LeftIdentity 0# _+_
+-identityˡ (x₁ , x₂) = ( +₁-identityˡ x₁ , +₂-identityˡ x₂ )
+-identityʳ : RightIdentity 0# _+_
+-identityʳ (x₁ , x₂) = ( +₁-identityʳ x₁ , +₂-identityʳ x₂ )
+-identity : Identity 0# _+_
+-identity = +-identityˡ , +-identityʳ
+-comm : Commutative _+_
+-comm (x₁ , x₂) (y₁ , y₂) = ( +₁-comm x₁ y₁ , +₂-comm x₂ y₂ )
*ᵏ-∙-compat : ∀ (a b : K') (u : V) -> ((a *ᵏ b) ∙ u) ≈ (a ∙ (b ∙ u))
*ᵏ-∙-compat a b (x₁ , x₂) = ( *ᵏ-∙₁-compat a b x₁ , *ᵏ-∙₂-compat a b x₂ )
∙-+-distrib : ∀ (a : K') (u v : V) -> (a ∙ (u + v)) ≈ ((a ∙ u) + (a ∙ v))
∙-+-distrib a (x₁ , x₂) (y₁ , y₂) = ( ∙₁-+₁-distrib a x₁ y₁ , ∙₂-+₂-distrib a x₂ y₂ )
∙-+ᵏ-distrib : ∀ (a b : K') (u : V) -> ((a +ᵏ b) ∙ u) ≈ ((a ∙ u) + (b ∙ u))
∙-+ᵏ-distrib a b (x₁ , x₂) = ( ∙₁-+ᵏ-distrib a b x₁ , ∙₂-+ᵏ-distrib a b x₂ )
∙-cong : ∀ {a b : K'} {u v : V} -> a ≈ᵏ b -> u ≈ v -> (a ∙ u) ≈ (b ∙ v)
∙-cong rₓ (r₁ , r₂) = ( ∙₁-cong rₓ r₁ , ∙₂-cong rₓ r₂ )
∙-identity : ∀ (x : V) → (1ᵏ ∙ x) ≈ x
∙-identity (x₁ , x₂) = ( ∙₁-identity x₁ , ∙₂-identity x₂ )
∙-absorbˡ : ∀ (x : V) → (0ᵏ ∙ x) ≈ 0#
∙-absorbˡ (x₁ , x₂) = ( ∙₁-absorbˡ x₁ , ∙₂-absorbˡ x₂ )
-‿inverseˡ : LeftInverse 0# -_ _+_
-‿inverseˡ (x₁ , x₂) = ( -₁‿inverseˡ x₁ , -₂‿inverseˡ x₂ )
-‿inverseʳ : RightInverse 0# -_ _+_
-‿inverseʳ (x₁ , x₂) = ( -₁‿inverseʳ x₁ , -₂‿inverseʳ x₂ )
-‿inverse : Inverse 0# -_ _+_
-‿inverse = -‿inverseˡ , -‿inverseʳ
-‿cong : Congruent₁ -_
-‿cong (x₁ , x₂) = ( -₁‿cong x₁ , -₂‿cong x₂ )
isMagma : IsMagma _+_
isMagma = record
{ isEquivalence = ≈-isEquiv
; ∙-cong = +-cong
}
isSemigroup : IsSemigroup _+_
isSemigroup = record
{ isMagma = isMagma
; assoc = +-assoc
}
isMonoid : IsMonoid _+_ 0#
isMonoid = record
{ isSemigroup = isSemigroup
; identity = +-identity
}
isGroup : IsGroup _+_ 0# -_
isGroup = record
{ isMonoid = isMonoid
; inverse = -‿inverse
; ⁻¹-cong = -‿cong
}
isAbelianGroup : IsAbelianGroup _+_ 0# -_
isAbelianGroup = record
{ isGroup = isGroup
; comm = +-comm
}
isVectorSpace : IsVectorSpace K _≈_ _+_ _∙_ -_ 0#
isVectorSpace = record
{ isAbelianGroup = isAbelianGroup
; *ᵏ-∙-compat = *ᵏ-∙-compat
; ∙-+-distrib = ∙-+-distrib
; ∙-+ᵏ-distrib = ∙-+ᵏ-distrib
; ∙-cong = ∙-cong
; ∙-identity = ∙-identity
; ∙-absorbˡ = ∙-absorbˡ
}
vectorSpace : VectorSpace K (a₁ ⊔ a₂) (ℓ₁ ⊔ ℓ₂)
vectorSpace = record { isVectorSpace = isVectorSpace }
| {
"alphanum_fraction": 0.5424511545,
"avg_line_length": 25.9447004608,
"ext": "agda",
"hexsha": "fcda9498d211da87f491dcdd6db183a84c302ff7",
"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/Space/Product.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/Space/Product.agda",
"max_line_length": 85,
"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/Space/Product.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": 2636,
"size": 5630
} |
{- 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
import LibraBFT.Concrete.Properties.PreferredRound as PR
open import LibraBFT.Concrete.Obligations
-- In this module, we (will) prove the implementation obligation for the PreferredRound rule.
module LibraBFT.Impl.Properties.PreferredRound where
postulate -- TODO-3 : prove. Note that this is a substantial
-- undertaking that should not be started before we have
-- a proof for the similar-but-much-simpler VotesOnce
-- property, and also not before we have an
-- implementation (perhaps some incremental extension of
-- our current fake/simple implementaion) that we can
-- reasonably hope actually ensures the property!
pr₁ : PR.ImplObligation₁
| {
"alphanum_fraction": 0.7205882353,
"avg_line_length": 44.347826087,
"ext": "agda",
"hexsha": "8957f5ccecf6ef11768787fae465ff3548a283ce",
"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/Impl/Properties/PreferredRound.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/Impl/Properties/PreferredRound.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/Impl/Properties/PreferredRound.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 239,
"size": 1020
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.Gysin where
open import Cubical.Foundations.Path
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Function
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Pointed.Homogeneous
open import Cubical.Functions.Embedding
open import Cubical.Relation.Nullary
open import Cubical.Data.Unit
open import Cubical.Data.Bool
open import Cubical.Data.Nat renaming (_+_ to _+ℕ_ ; _·_ to _·ℕ_)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Int hiding (_+'_)
open import Cubical.Data.Sigma
open import Cubical.Data.Sum
open import Cubical.Data.Fin
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Int
open import Cubical.HITs.Truncation as T
open import Cubical.HITs.SetTruncation as ST
open import Cubical.HITs.PropositionalTruncation as PT
open import Cubical.HITs.Pushout.Flattening
open import Cubical.HITs.Pushout
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.S1 renaming (_·_ to _*_)
open import Cubical.HITs.Join
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Hopf
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Group.Base
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.Groups.Connected
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.MayerVietorisUnreduced
open import Cubical.ZCohomology.Groups.Unit
open import Cubical.ZCohomology.Groups.Wedge
open import Cubical.ZCohomology.Groups.Sn
open import Cubical.ZCohomology.RingStructure.CupProduct
open import Cubical.ZCohomology.RingStructure.RingLaws
open import Cubical.ZCohomology.RingStructure.GradedCommutativity
open PlusBis
-- There seems to be some problems with the termination checker.
-- Spelling out integer induction with 3 base cases like this
-- solves the issue.
private
Int-ind : ∀ {ℓ} (P : ℤ → Type ℓ)
→ P (pos zero) → P (pos 1)
→ P (negsuc zero)
→ ((x y : ℤ) → P x → P y → P (x + y)) → (x : ℤ) → P x
Int-ind P z one min ind (pos zero) = z
Int-ind P z one min ind (pos (suc zero)) = one
Int-ind P z one min ind (pos (suc (suc n))) =
ind (pos (suc n)) 1 (Int-ind P z one min ind (pos (suc n))) one
Int-ind P z one min ind (negsuc zero) = min
Int-ind P z one min ind (negsuc (suc n)) =
ind (negsuc n) (negsuc zero) (Int-ind P z one min ind (negsuc n)) min
-- The untruncated version (coHomRed n (S₊ n)), i.e.
-- (S₊∙ n →∙ coHomK-ptd n) is in fact equal to
-- (coHomRed n (S₊ n)). Its useful to formulate
-- (S₊∙ n →∙ coHomK-ptd n) as a group in its own right
-- and prove it equivalent to (coHomRed n (S₊ n)).
-- We start with the addition
private
_++_ : ∀ {ℓ} {A : Pointed ℓ} {n : ℕ} →
(A →∙ coHomK-ptd n) → (A →∙ coHomK-ptd n) → (A →∙ coHomK-ptd n)
fst (f ++ g) x = fst f x +ₖ fst g x
snd (f ++ g) = cong₂ _+ₖ_ (snd f) (snd g) ∙ rUnitₖ _ (0ₖ _)
-- If we truncate the addition, we get back our usual
-- addition on (coHomRed n (S₊ n))
addAgree : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) (x y : A →∙ coHomK-ptd n)
→ Path (fst (coHomRedGrDir n A))
∣ x ++ y ∣₂
(∣ x ∣₂ +ₕ∙ ∣ y ∣₂)
addAgree {A = A} zero f g =
cong ∣_∣₂ (→∙Homogeneous≡ (isHomogeneousKn _) refl)
addAgree {A = A} (suc zero) f g =
cong ∣_∣₂ (→∙Homogeneous≡ (isHomogeneousKn _) refl)
addAgree {A = A} (suc (suc n)) f g =
cong ∣_∣₂ (→∙Homogeneous≡ (isHomogeneousKn _) refl)
-- We formulate (S₊∙ n →∙ coHomK-ptd n) as a group, πS.
module _ where
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Semigroup
open GroupStr
open IsGroup
open IsMonoid
open IsSemigroup
πS : (n : ℕ) → Group ℓ-zero
fst (πS n) = S₊∙ n →∙ coHomK-ptd n
1g (snd (πS n)) = (λ _ → 0ₖ n) , refl
GroupStr._·_ (snd (πS n)) f g = (λ x → fst f x +ₖ fst g x)
, cong₂ _+ₖ_ (snd f) (snd g) ∙ rUnitₖ n (0ₖ n)
inv (snd (πS n)) f = (λ x → -ₖ fst f x) , cong -ₖ_ (snd f) ∙ -0ₖ {n = n}
isGroup (snd (πS n)) = makeIsGroup
(helper n)
(λ x y z → →∙Homogeneous≡
(isHomogeneousKn n)
(funExt λ w → assocₖ n (fst x w) (fst y w) (fst z w)))
(λ { (f , p) → →∙Homogeneous≡ (isHomogeneousKn n) (funExt λ x → rUnitₖ n (f x)) })
(λ { (f , p) → →∙Homogeneous≡ (isHomogeneousKn n) (funExt λ x → lUnitₖ n (f x)) })
(λ { (f , p) → →∙Homogeneous≡ (isHomogeneousKn n) (funExt λ x → rCancelₖ n (f x)) })
(λ { (f , p) → →∙Homogeneous≡ (isHomogeneousKn n) (funExt λ x → lCancelₖ n (f x)) })
where
helper : (n : ℕ) → isSet (S₊∙ n →∙ coHomK-ptd n)
helper zero = isOfHLevelΣ 2 (isSetΠ (λ _ → isSetℤ)) λ _ → isOfHLevelPath 2 isSetℤ _ _
helper (suc n) = isOfHLevel↑∙' 0 n
isSetπS : (n : ℕ) → isSet (S₊∙ n →∙ coHomK-ptd n)
isSetπS = λ n → is-set (snd (πS n))
-- πS is equivalent to (coHomRed n (S₊∙ n))
K : (n : ℕ) → GroupIso (coHomRedGrDir n (S₊∙ n)) (πS n)
fst (K n) = setTruncIdempotentIso (isSetπS n)
snd (K zero) =
makeIsGroupHom
(ST.elim2 (λ _ _ → isOfHLevelPath 2 (isSetπS 0) _ _)
λ f g → →∙Homogeneous≡ (isHomogeneousKn 0) refl)
snd (K (suc zero)) =
makeIsGroupHom
(ST.elim2 (λ _ _ → isOfHLevelPath 2 (isSetπS 1) _ _)
λ f g → →∙Homogeneous≡ (isHomogeneousKn 1) refl)
snd (K (suc (suc n))) =
makeIsGroupHom
(ST.elim2 (λ _ _ → isOfHLevelPath 2 (isSetπS _) _ _)
λ f g → →∙Homogeneous≡ (isHomogeneousKn _) refl)
-- πS has the following generator
genFunSpace : (n : ℕ) → S₊∙ n →∙ coHomK-ptd n
fst (genFunSpace zero) false = 1
fst (genFunSpace zero) true = 0
snd (genFunSpace zero) = refl
fst (genFunSpace (suc n)) = ∣_∣
snd (genFunSpace (suc zero)) = refl
snd (genFunSpace (suc (suc n))) = refl
πS≅ℤ : (n : ℕ) → GroupIso (πS n) ℤGroup
fst (πS≅ℤ zero) = IsoBool→∙
snd (πS≅ℤ zero) = makeIsGroupHom λ _ _ → refl
πS≅ℤ (suc n) =
compGroupIso
(invGroupIso (K (suc n)))
(compGroupIso
(GroupEquiv→GroupIso (coHomGr≅coHomRedGr n (S₊∙ (suc n))))
(Hⁿ-Sⁿ≅ℤ n))
Iso-πS-ℤ : (n : ℕ) → Iso (S₊∙ (suc n) →∙ coHomK-ptd (suc n)) ℤ
Iso-πS-ℤ n = compIso (invIso (setTruncIdempotentIso (isOfHLevel↑∙' 0 n)))
(compIso (equivToIso (fst (coHomGr≅coHomRedGr n (S₊∙ (suc n)))))
(fst (Hⁿ-Sⁿ≅ℤ n)))
Iso-πS-ℤ' : (n : ℕ) → Iso (S₊∙ n →∙ coHomK-ptd n) ℤ
Iso-πS-ℤ' n = fst (πS≅ℤ n)
Iso-πS-ℤPres1 : (n : ℕ) → Iso.fun (fst (πS≅ℤ (suc n))) (∣_∣ , refl) ≡ pos 1
Iso-πS-ℤPres1 zero = refl
Iso-πS-ℤPres1 (suc n) =
cong (Iso.fun (fst (Hⁿ-Sⁿ≅ℤ n))) (lem n) ∙ Iso-πS-ℤPres1 n
where
lem : (n : ℕ) → Iso.fun (fst (suspensionAx-Sn n n)) ∣ ∣_∣ ∣₂ ≡ ∣ ∣_∣ ∣₂
lem zero =
cong ∣_∣₂ (funExt λ x → transportRefl (∣ x ∣ +ₖ (0ₖ 1)) ∙ rUnitₖ 1 ∣ x ∣)
lem (suc n) = cong ∣_∣₂
(funExt λ x → (λ i → transportRefl ((ΩKn+1→Kn (suc (suc n))
(transp (λ j → 0ₖ (suc (suc (suc n))) ≡ ∣ merid north (~ j ∧ ~ i) ∣) i
(λ z → ∣ compPath-filler
(merid (transportRefl (transportRefl x i) i))
(sym (merid north)) i z
∣)))) i)
∙ Iso.leftInv (Iso-Kn-ΩKn+1 (suc (suc n))) ∣ x ∣)
-- The first step of the Gysin sequence is to formulate
-- an equivalence g : Kᵢ ≃ (Sⁿ →∙ Kᵢ₊ₙ)
module g-base where
g : (n : ℕ) (i : ℕ) → coHomK i → (S₊∙ n →∙ coHomK-ptd (i +' n))
fst (g n i x) y = x ⌣ₖ (genFunSpace n) .fst y
snd (g n i x) = cong (x ⌣ₖ_) ((genFunSpace n) .snd) ∙ ⌣ₖ-0ₖ i n x
-- We give another version of g which will be easier to work with now
G : (n : ℕ) (i : ℕ) → coHomK i → (S₊∙ n →∙ coHomK-ptd (n +' i))
fst (G n i x) y = (genFunSpace n) .fst y ⌣ₖ x
snd (G n i x) = cong (_⌣ₖ x) ((genFunSpace n) .snd) ∙ 0ₖ-⌣ₖ n i x
-ₖ'^-Iso : (n : ℕ) (i : ℕ)
→ (S₊∙ n →∙ coHomK-ptd (i +' n)) ≃ (S₊∙ n →∙ coHomK-ptd (i +' n))
-ₖ'^-Iso n i = isoToEquiv (iso F F FF FF)
where
lem : (i n : ℕ) → (-ₖ'^ i · n) (snd (coHomK-ptd (i +' n))) ≡ 0ₖ _
lem zero zero = refl
lem zero (suc zero) = refl
lem zero (suc (suc n)) = refl
lem (suc zero) zero = refl
lem (suc (suc i)) zero = refl
lem (suc i) (suc n) = refl
F : S₊∙ n →∙ coHomK-ptd (i +' n) → S₊∙ n →∙ coHomK-ptd (i +' n)
fst (F f) x = (-ₖ'^ i · n) (fst f x)
snd (F f) = cong (-ₖ'^ i · n) (snd f) ∙ lem i n
FF : (x : _) → F (F x) ≡ x
FF x =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ y → -ₖ'-gen² i n _ _ (fst x y))
transpPres0ₖ : ∀ {k m : ℕ} (p : k ≡ m) → subst coHomK p (0ₖ k) ≡ 0ₖ m
transpPres0ₖ {k = k} =
J (λ m p → subst coHomK p (0ₖ k) ≡ 0ₖ m) (transportRefl _)
-- There will be some index swapping going on. We state this explicitly, since we will
-- need to trace the maps later
indexSwap : (n : ℕ) (i : ℕ)
→ (S₊∙ n →∙ coHomK-ptd (n +' i))
≃ (S₊∙ n →∙ coHomK-ptd (i +' n))
indexSwap n i =
isoToEquiv (iso (λ f → (λ x → subst coHomK (+'-comm n i) (fst f x)) ,
cong (subst coHomK (+'-comm n i)) (snd f) ∙ transpPres0ₖ (+'-comm n i))
(λ f → (λ x → subst coHomK (sym (+'-comm n i)) (fst f x))
, (cong (subst coHomK (sym (+'-comm n i))) (snd f)
∙ transpPres0ₖ (sym (+'-comm n i))))
(λ f → →∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ x → transportTransport⁻ _ (f .fst x)))
λ f → →∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ x → transportTransport⁻ _ (f .fst x)))
-- g is a composition of G and our two previous equivs.
g≡ : (n : ℕ) (i : ℕ) → g n i ≡ λ x
→ fst (compEquiv (indexSwap n i) (-ₖ'^-Iso n i)) ((G n i) x)
g≡ n i = funExt (λ f → →∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ y → gradedComm'-⌣ₖ _ _ f (genFunSpace n .fst y)))
-- We need a third Iso.
suspKn-Iso-fun : (n m : ℕ) →
(S₊∙ (suc n) →∙ coHomK-ptd (suc m))
→ (S₊ n → coHomK m)
suspKn-Iso-fun zero m (f , p) false = ΩKn+1→Kn _ (sym p ∙∙ cong f loop ∙∙ p)
suspKn-Iso-fun zero m (f , p) true = 0ₖ _
suspKn-Iso-fun (suc n) m (f , p) x =
ΩKn+1→Kn _ (sym p ∙∙ cong f (merid x ∙ sym (merid (ptSn _))) ∙∙ p)
suspKn-Iso-fun∙ : (n m : ℕ) → (f : _) → suspKn-Iso-fun n m f (ptSn _) ≡ 0ₖ m
suspKn-Iso-fun∙ zero m = λ _ → refl
suspKn-Iso-fun∙ (suc n) m (f , p) =
cong (ΩKn+1→Kn m)
(cong (sym p ∙∙_∙∙ p) (cong (cong f) (rCancel (merid (ptSn _)))))
∙∙ cong (ΩKn+1→Kn m) (∙∙lCancel p)
∙∙ ΩKn+1→Kn-refl m
suspKn-Iso-inv : (n m : ℕ) → (S₊∙ n →∙ coHomK-ptd m)
→ (S₊∙ (suc n) →∙ coHomK-ptd (suc m))
fst (suspKn-Iso-inv zero m (f , p)) base = 0ₖ _
fst (suspKn-Iso-inv zero m (f , p)) (loop i) = Kn→ΩKn+1 m (f false) i
snd (suspKn-Iso-inv zero m (f , p)) = refl
fst (suspKn-Iso-inv (suc n) m (f , p)) north = 0ₖ _
fst (suspKn-Iso-inv (suc n) m (f , p)) south = 0ₖ _
fst (suspKn-Iso-inv (suc n) m (f , p)) (merid a i) = Kn→ΩKn+1 m (f a) i
snd (suspKn-Iso-inv (suc n) m (f , p)) = refl
suspKn-Iso : (n m : ℕ) →
Iso (S₊∙ (suc n) →∙ coHomK-ptd (suc m))
(S₊∙ n →∙ coHomK-ptd m)
Iso.fun (suspKn-Iso n m) f = (suspKn-Iso-fun n m f)
, (suspKn-Iso-fun∙ n m f)
Iso.inv (suspKn-Iso n m) = suspKn-Iso-inv n m
Iso.rightInv (suspKn-Iso zero m) (f , p) =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { false → cong (ΩKn+1→Kn m) (sym (rUnit _))
∙ Iso.leftInv (Iso-Kn-ΩKn+1 _) (f false)
; true → sym p})
Iso.rightInv (suspKn-Iso (suc n) m) (f , p) =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ x →
(λ i → ΩKn+1→Kn m
(sym (rUnit
(cong-∙
(suspKn-Iso-inv (suc n) m (f , p) .fst)
(merid x) (sym (merid (ptSn _))) i)) i))
∙∙ cong (ΩKn+1→Kn m)
(cong (Kn→ΩKn+1 m (f x) ∙_)
(cong sym (cong (Kn→ΩKn+1 m) p ∙ Kn→ΩKn+10ₖ m))
∙ sym (rUnit _))
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 _) (f x))
Iso.leftInv (suspKn-Iso zero m) (f , p) = →∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { base → sym p
; (loop i) j → lem j i})
where
lem : PathP (λ i → p (~ i) ≡ p (~ i))
(Kn→ΩKn+1 m (ΩKn+1→Kn m (sym p ∙∙ cong f loop ∙∙ p)))
(cong f loop)
lem = Iso.rightInv (Iso-Kn-ΩKn+1 _) _
◁ λ i → doubleCompPath-filler (sym p) (cong f loop) p (~ i)
Iso.leftInv (suspKn-Iso (suc n) m) (f , p) =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { north → sym p
; south → sym p ∙ cong f (merid (ptSn _))
; (merid a i) j → lem a j i})
where
lem : (a : S₊ (suc n))
→ PathP (λ i → p (~ i) ≡ (sym p ∙ cong f (merid (ptSn (suc n)))) i)
(Kn→ΩKn+1 m
(ΩKn+1→Kn m
(sym p ∙∙ cong f (merid a ∙ sym (merid (ptSn _))) ∙∙ p)))
(cong f (merid a))
lem a = Iso.rightInv (Iso-Kn-ΩKn+1 _) _
◁ λ i j → hcomp (λ k →
λ { (i = i1) → (f (merid a j))
; (j = i0) → p (k ∧ ~ i)
; (j = i1) → compPath-filler'
(sym p) (cong f (merid (ptSn _))) k i })
(f (compPath-filler (merid a) (sym (merid (ptSn _))) (~ i) j))
glIsoInvHom : (n m : ℕ) (x y : coHomK n) (z : S₊ (suc m))
→ Iso.inv (suspKn-Iso _ _) (G m n (x +ₖ y)) .fst z
≡ Iso.inv (suspKn-Iso _ _) (G m n x) .fst z
+ₖ Iso.inv (suspKn-Iso _ _) (G m n y) .fst z
glIsoInvHom zero zero x y base = refl
glIsoInvHom (suc n) zero x y base = refl
glIsoInvHom zero zero x y (loop i) j = lem j i
where
lem : (cong (Iso.inv (suspKn-Iso _ _) (G zero zero (x + y)) .fst) loop)
≡ cong₂ _+ₖ_ (cong (Iso.inv (suspKn-Iso _ _) (G zero zero x) .fst) loop)
(cong (Iso.inv (suspKn-Iso _ _) (G zero zero y) .fst) loop)
lem = Kn→ΩKn+1-hom 0 x y
∙ ∙≡+₁ (cong (Iso.inv (suspKn-Iso _ _) (G zero zero x) .fst) loop)
(cong (Iso.inv (suspKn-Iso _ _) (G zero zero y) .fst) loop)
glIsoInvHom (suc n) zero x y (loop i) j = lem j i
where
lem : Kn→ΩKn+1 (suc n) ((pos (suc zero)) ·₀ (x +ₖ y))
≡ cong₂ _+ₖ_ (cong (Iso.inv (suspKn-Iso zero (zero +' suc n))
(G zero (suc n) x) .fst) loop)
(cong (Iso.inv (suspKn-Iso zero (zero +' suc n))
(G zero (suc n) y) .fst) loop)
lem = cong (Kn→ΩKn+1 (suc n)) (lUnit⌣ₖ _ (x +ₖ y))
∙∙ Kn→ΩKn+1-hom (suc n) x y
∙∙ (λ i → ∙≡+₂ n (Kn→ΩKn+1 (suc n) (lUnit⌣ₖ _ x (~ i)))
(Kn→ΩKn+1 (suc n) (lUnit⌣ₖ _ y (~ i))) i)
glIsoInvHom zero (suc m) x y north = refl
glIsoInvHom zero (suc m) x y south = refl
glIsoInvHom zero (suc m) x y (merid a i) j = lem j i
where
lem : Kn→ΩKn+1 (suc m) (_⌣ₖ_ {n = suc m} {m = zero} ∣ a ∣ (x + y))
≡ cong₂ _+ₖ_ (Kn→ΩKn+1 (suc m) (_⌣ₖ_ {n = suc m} {m = zero} ∣ a ∣ x))
(Kn→ΩKn+1 (suc m) (_⌣ₖ_ {n = suc m} {m = zero} ∣ a ∣ y))
lem = cong (Kn→ΩKn+1 (suc m)) (leftDistr-⌣ₖ (suc m) 0 ∣ a ∣ x y)
∙∙ Kn→ΩKn+1-hom (suc m) _ _
∙∙ ∙≡+₂ _ _ _
glIsoInvHom (suc n) (suc m) x y north = refl
glIsoInvHom (suc n) (suc m) x y south = refl
glIsoInvHom (suc n) (suc m) x y (merid a i) j = lem j i
where
lem : Kn→ΩKn+1 (suc (suc (m +ℕ n)))
(_⌣ₖ_ {n = suc m} {m = suc n} ∣ a ∣ (x +ₖ y))
≡ cong₂ _+ₖ_ (Kn→ΩKn+1 (suc (suc (m +ℕ n)))
(_⌣ₖ_ {n = suc m} {m = suc n} ∣ a ∣ x))
(Kn→ΩKn+1 (suc (suc (m +ℕ n)))
(_⌣ₖ_ {n = suc m} {m = suc n} ∣ a ∣ y))
lem = cong (Kn→ΩKn+1 (suc (suc (m +ℕ n))))
(leftDistr-⌣ₖ (suc m) (suc n) ∣ a ∣ x y)
∙∙ Kn→ΩKn+1-hom _ _ _
∙∙ ∙≡+₂ _ _ _
private
+'-suc : (n m : ℕ) → suc n +' m ≡ suc (n +' m)
+'-suc zero zero = refl
+'-suc (suc n) zero = refl
+'-suc zero (suc m) = refl
+'-suc (suc n) (suc m) = refl
decomposeG : (i n : ℕ) (x : coHomK i)
→ G (suc n) i x
≡ subst (λ x → S₊∙ (suc n) →∙ coHomK-ptd x)
(sym (+'-suc n i))
(Iso.inv (suspKn-Iso n _) (G n i x))
decomposeG zero zero x =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ z → (λ i → x ·₀ ∣ z ∣) ∙ h3 x z ∙ sym (transportRefl _))
where
h3 : (x : ℤ) (z : S¹)
→ _·₀_ {n = 1} x ∣ z ∣
≡ fst (Iso.inv (suspKn-Iso 0 zero) (G zero zero x)) z
h3 =
Int-ind _
(λ { base → refl ; (loop i) j → Kn→ΩKn+10ₖ zero (~ j) i})
(λ { base → refl ; (loop i) j → rUnit (cong ∣_∣ₕ (lUnit loop j)) j i})
(λ { base → refl ; (loop i) j → rUnit (cong ∣_∣ₕ (sym loop)) j i})
λ x y inx iny z
→ rightDistr-⌣ₖ 0 1 x y ∣ z ∣
∙∙ cong₂ _+ₖ_ (inx z) (iny z)
∙∙ sym (glIsoInvHom zero zero x y z)
decomposeG (suc i) zero x =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ z → lem z
∙ sym (transportRefl
((Iso.inv (suspKn-Iso zero (suc i)) (G zero (suc i) x)) .fst z)))
where
lem : (z : S₊ 1)
→ _ ≡ Iso.inv (suspKn-Iso zero (suc i)) (G zero (suc i) x) .fst z
lem base = refl
lem (loop k) j = Kn→ΩKn+1 (suc i) (lUnit⌣ₖ _ x (~ j)) k
decomposeG zero (suc n) x =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ z → main x z
∙ λ i → transportRefl
(Iso.inv (suspKn-Iso (suc n) (suc n))
(G (suc n) zero x)) (~ i) .fst z)
where
+merid : rUnitₖ (suc (suc n)) ∣ south ∣ ≡ cong ∣_∣ₕ (merid (ptSn _))
+merid = sym (lUnit _)
∙ cong (cong ∣_∣ₕ)
λ j i → transp (λ _ → S₊ (suc (suc n))) (i ∨ j)
(merid (ptSn (suc n)) i)
lem : (a : S₊ (suc n))
→ PathP (λ i → ∣ merid a i ∣ₕ
≡ Kn→ΩKn+1 (suc n) (∣ a ∣ +ₖ (0ₖ _)) i)
refl (sym (rUnitₖ (suc (suc n)) ∣ south ∣))
lem a =
flipSquare ((λ i j → ∣ compPath-filler (merid a)
(sym (merid (ptSn _))) i j ∣ₕ)
▷ cong (Kn→ΩKn+1 (suc n)) (sym (rUnitₖ (suc n) ∣ a ∣ₕ)))
▷ sym (cong sym +merid)
lem₂ : (a : S₊ (suc n)) → (λ i → -ₖ ∣ merid a i ∣)
≡ Kn→ΩKn+1 (suc n) (-ₖ ∣ a ∣)
lem₂ a =
cong (cong ∣_∣ₕ) (sym (symDistr (merid a)
(sym (merid (ptSn (suc n))))))
∙ sym (Kn→ΩKn+1-ₖ (suc n) ∣ a ∣)
main : (x : ℤ) (z : S₊ (suc (suc n)))
→ _⌣ₖ_ {n = suc (suc n)} {m = 0} ∣ z ∣ x
≡ Iso.inv (suspKn-Iso (suc n) (suc n)) (G (suc n) zero x) .fst z
main = Int-ind _
(λ { north → refl ; south → refl
; (merid a i) j → Kn→ΩKn+10ₖ (suc n) (~ j) i})
(λ { north → refl ; south → refl
; (merid a i) j →
hcomp (λ k →
λ { (i = i0) → ∣ north ∣
; (i = i1) → rUnitₖ (suc (suc n)) ∣ south ∣ (~ k)
; (j = i0) → rUnitₖ (suc (suc n)) ∣ merid a i ∣ (~ k)
; (j = i1) → lem a i k})
∣ merid a i ∣ₕ})
(λ { north → refl
; south → refl
; (merid a i) j → lem₂ a j i})
λ x y indx indy z → leftDistr-⌣ₖ _ _ ∣ z ∣ x y
∙ cong₂ _+ₖ_ (indx z) (indy z)
∙ sym (glIsoInvHom _ _ _ _ _)
decomposeG (suc i) (suc n) x =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ z → lem z
∙ λ j →
transportRefl ((Iso.inv (suspKn-Iso (suc n) (suc (suc (n +ℕ i))))
(G (suc n) (suc i) x))) (~ j) .fst z)
where
lem : (z : S₊ (suc (suc n))) → _
lem north = refl
lem south = refl
lem (merid a i) = refl
isEquivGzero : (i : ℕ) → isEquiv (G zero i)
isEquivGzero i =
isoToIsEquiv
(iso _ (λ f → fst f false)
(λ {(f , p) → →∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { false → rUnitₖ _ (f false) ; true → sym p})})
(lUnit⌣ₖ _))
isEquivG : (n i : ℕ) → isEquiv (G n i)
isEquivG zero i =
isoToIsEquiv
(iso _ (λ f → fst f false)
(λ {(f , p) → →∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { false → rUnitₖ _ (f false) ; true → sym p})})
(lUnit⌣ₖ _))
isEquivG (suc n) i =
subst isEquiv (sym (funExt (decomposeG i n)))
(compEquiv (compEquiv (G n i , isEquivG n i)
(isoToEquiv (invIso (suspKn-Iso n (n +' i)))))
(pathToEquiv (λ j → S₊∙ (suc n) →∙ coHomK-ptd (+'-suc n i (~ j)))) .snd)
isEquiv-g : (n i : ℕ) → isEquiv (g n i)
isEquiv-g n i =
subst isEquiv (sym (g≡ n i))
(compEquiv (G n i , isEquivG n i)
(compEquiv (indexSwap n i) (-ₖ'^-Iso n i)) .snd)
-- We now generealise the equivalence g to also apply to arbitrary fibrations (Q : B → Type)
-- satisfying (Q * ≃∙ Sⁿ)
module _ {ℓ} (B : Pointed ℓ) (Q : typ B → Pointed ℓ-zero)
(conB : (x y : typ B) → ∥ x ≡ y ∥₁)
(n : ℕ) (Q-is : Iso (typ (Q (pt B))) (S₊ n))
(Q-is-ptd : Iso.fun Q-is (pt (Q (pt B))) ≡ snd (S₊∙ n))
(c : (b : typ B) → (Q b →∙ coHomK-ptd n))
(c-pt : c (pt B) .fst ≡ ((λ x → genFunSpace n .fst (Iso.fun Q-is x))))
where
g : (b : typ B) (i : ℕ) → coHomK i → (Q b →∙ coHomK-ptd (i +' n))
fst (g b i x) y = x ⌣ₖ c b .fst y
snd (g b i x) = cong (x ⌣ₖ_) (c b .snd) ∙ ⌣ₖ-0ₖ i n x
g-hom : (b : typ B) (i : ℕ) → (x y : coHomK i)
→ g b i (x +ₖ y) ≡ ((g b i x) ++ (g b i y))
g-hom b i x y =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ z → rightDistr-⌣ₖ i n x y (c b .fst z))
gPathP' : (i : ℕ)
→ PathP (λ j → coHomK i →
(isoToPath Q-is j , ua-gluePath (isoToEquiv Q-is) (Q-is-ptd) j)
→∙ coHomK-ptd (i +' n))
(g (pt B) i) (g-base.g n i)
gPathP' i =
toPathP
(funExt
λ x → →∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ y
→ (λ i → transportRefl (transportRefl x i ⌣ₖ c (pt B) .fst
(Iso.inv Q-is (transportRefl y i))) i)
∙ cong (x ⌣ₖ_)
(funExt⁻ c-pt (Iso.inv Q-is y)
∙ cong (genFunSpace n .fst) (Iso.rightInv Q-is y))))
g-base : (i : ℕ) → isEquiv (g (pt B) i)
g-base i = transport (λ j → isEquiv (gPathP' i (~ j))) (g-base.isEquiv-g n i)
g-equiv : (b : typ B) (i : ℕ) → isEquiv (g b i)
g-equiv b i =
PT.rec (isPropIsEquiv _)
(J (λ b _ → isEquiv (g b i))
(g-base i))
(conB (pt B) b)
module _ {ℓ} (B : Pointed ℓ) (Q : typ B → Pointed ℓ-zero)
(conB : (x y : typ B) → ∥ x ≡ y ∥₂)
(n : ℕ) (Q-is : Iso (typ (Q (pt B))) (S₊ n))
(Q-is-ptd : Iso.fun Q-is (pt (Q (pt B))) ≡ snd (S₊∙ n)) where
is-setQ→K : (b : typ B) → isSet (Q b →∙ coHomK-ptd n)
is-setQ→K b =
ST.rec (isProp→isOfHLevelSuc 1 isPropIsSet)
(J (λ b _ → isSet (Q b →∙ coHomK-ptd n))
(subst isSet (cong (_→∙ coHomK-ptd n)
(ua∙ (isoToEquiv (invIso Q-is))
(cong (Iso.inv Q-is) (sym Q-is-ptd) ∙ Iso.leftInv Q-is _)))
(isOfHLevelRetractFromIso 2 (fst (πS≅ℤ n)) isSetℤ)))
(conB (pt B) b)
isConnB : isConnected 3 (typ B)
fst isConnB = ∣ pt B ∣
snd isConnB =
T.elim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
λ a → ST.rec (isOfHLevelTrunc 3 _ _) (cong ∣_∣ₕ) (conB (pt B) a)
isPropPath : isProp (∥ pt B ≡ pt B ∥₂)
isPropPath =
isOfHLevelRetractFromIso 1 setTruncTrunc2Iso
(isContr→isProp (isConnectedPath _ isConnB (pt B) (pt B)))
-- We construct a term in c* : (b : B) → (Q b →∙ Kₙ)
-- Which is equal to the generator of (Sⁿ →∙ Kₙ) over the base point.
c* : Σ[ c ∈ ((b : typ B) → (Q b →∙ coHomK-ptd n)) ]
(c (pt B) .fst ≡ ((λ x → genFunSpace n .fst (Iso.fun Q-is x))))
fst c* b =
ST.rec (is-setQ→K b)
(J (λ b _ → Q b →∙ coHomK-ptd n)
((λ x → genFunSpace n .fst (Iso.fun Q-is x))
, cong (genFunSpace n .fst) Q-is-ptd ∙ genFunSpace n .snd))
(conB (pt B) b)
snd c* =
funExt λ x → (λ i → ST.rec (is-setQ→K (pt B))
(J (λ b _ → Q b →∙ coHomK-ptd n)
((λ x₁ → genFunSpace n .fst (Iso.fun Q-is x₁)) ,
(λ i → genFunSpace n .fst (Q-is-ptd i))
∙ genFunSpace n .snd))
(isPropPath (conB (pt B) (pt B)) ∣ refl ∣₂ i) .fst x)
∙ (λ i → transportRefl (genFunSpace n .fst
(Iso.fun Q-is (transportRefl x i))) i)
p-help : {b : fst B} (p : pt B ≡ b)
→ (subst (fst ∘ Q) (sym p) (snd (Q b))) ≡ (snd (Q (pt B)))
p-help {b = b} =
J (λ b p → subst (fst ∘ Q) (sym p) (snd (Q b)) ≡ snd (Q (pt B)))
(transportRefl _)
-- This form of c* will make things somewhat easier to work with later on.
c≡ : (b : fst B) (p : ∥ pt B ≡ b ∥₂)
→ (c* .fst b)
≡ ST.rec (is-setQ→K b)
(λ pp → (λ qb →
genFunSpace n .fst (Iso.fun Q-is (subst (fst ∘ Q) (sym pp) qb)))
, cong (genFunSpace n .fst ∘ Iso.fun Q-is) (p-help pp)
∙ ((λ i → genFunSpace n .fst (Q-is-ptd i)) ∙ genFunSpace n .snd)) p
c≡ b =
ST.elim (λ _ → isOfHLevelPath 2 (is-setQ→K b) _ _)
(J (λ b a → c* .fst b ≡
ST.rec (is-setQ→K b) (λ pp →
(λ qb →
genFunSpace n .fst (Iso.fun Q-is (subst (fst ∘ Q) (sym pp) qb)))
,
cong (genFunSpace n .fst ∘ Iso.fun Q-is) (p-help pp) ∙
(λ i → genFunSpace n .fst (Q-is-ptd i)) ∙ genFunSpace n .snd) ∣ a ∣₂)
((λ i → ST.rec (is-setQ→K (pt B))
(J (λ b₁ _ → Q b₁ →∙ coHomK-ptd n)
((λ x → genFunSpace n .fst (Iso.fun Q-is x)) ,
(λ i → genFunSpace n .fst (Q-is-ptd i)) ∙ genFunSpace n .snd))
(isPropPath (conB (pt B) (pt B)) ∣ refl ∣₂ i))
∙ →∙Homogeneous≡ (isHomogeneousKn n)
(transportRefl ((λ x → genFunSpace n .fst (Iso.fun Q-is x)))
∙ funExt λ x → cong (genFunSpace n .fst ∘ Iso.fun Q-is)
(sym (transportRefl x)))))
-- We are now almost ready to define the Thom isomorphism.
-- The following module contains the types and functions occuring in it.
module preThom {ℓ ℓ'} (B : Pointed ℓ) (P : typ B → Type ℓ') where
E : Type _
E = Σ (typ B) P
Ẽ : Type _
Ẽ = Pushout {A = E} (λ _ → tt) fst
i : (n : ℕ) → (P-base : Iso (P (pt B)) (S₊ n)) → S₊ (suc n) → Ẽ
i zero P-base base = inr (pt B)
i zero P-base (loop j) = (sym (push (pt B , Iso.inv P-base false))
∙ push ((pt B) , Iso.inv P-base true)) j
i (suc n) P-base north = inl tt
i (suc n) P-base south = inr (pt B)
i (suc n) P-base (merid a i₁) = push (pt B , Iso.inv P-base a) i₁
Q : typ B → Pointed ℓ'
Q x = Susp (P x) , north
F : Type _
F = Σ (typ B) λ x → Q x .fst
F̃ : Type _
F̃ = Pushout {A = typ B} {C = F} (λ _ → tt) λ b → b , north
invFE : Ẽ → F̃
invFE (inl x) = inl tt
invFE (inr x) = inr (x , south)
invFE (push (x , a) i₁) = ((push x) ∙ λ i → inr (x , merid a i)) i₁
funFE : F̃ → Ẽ
funFE (inl x) = inl tt
funFE (inr (x , north)) = inl tt
funFE (inr (x , south)) = inr x
funFE (inr (x , merid a i₁)) = push (x , a) i₁
funFE (push a i₁) = inl tt
IsoFE : Iso F̃ Ẽ
Iso.fun IsoFE = funFE
Iso.inv IsoFE = invFE
Iso.rightInv IsoFE (inl x) = refl
Iso.rightInv IsoFE (inr x) = refl
Iso.rightInv IsoFE (push (x , a) i₁) k = lem k i₁
where
lem : cong funFE (((push x) ∙ λ i → inr (x , merid a i)))
≡ push (x , a)
lem = congFunct funFE (push x) (λ i → inr (x , merid a i))
∙ sym (lUnit (push (x , a)))
Iso.leftInv IsoFE (inl x) = refl
Iso.leftInv IsoFE (inr (x , north)) = push x
Iso.leftInv IsoFE (inr (x , south)) = refl
Iso.leftInv IsoFE (inr (x , merid a i)) j =
compPath-filler' (push x) (λ i₁ → inr (x , merid a i₁)) (~ j) i
Iso.leftInv IsoFE (push a i₁) k = push a (i₁ ∧ k)
F̃→Q : ∀ {ℓ} {A : Pointed ℓ} → (F̃ , inl tt) →∙ A → (b : typ B) → Q b →∙ A
fst (F̃→Q {A = A , a} (f , p) b) north = f (inr (b , north))
fst (F̃→Q {A = A , a} (f , p) b) south = f (inr (b , south))
fst (F̃→Q {A = A , a} (f , p) b) (merid a₁ i₁) = f (inr (b , merid a₁ i₁))
snd (F̃→Q {A = A , a} (f , p) b) = sym (cong f (push b)) ∙ p
Q→F̃ : ∀ {ℓ} {A : Pointed ℓ} → ((b : typ B) → Q b →∙ A) → (F̃ , inl tt) →∙ A
fst (Q→F̃ {A = A , a} f) (inl x) = a
fst (Q→F̃ {A = A , a} f) (inr (x , north)) = f x .fst north
fst (Q→F̃ {A = A , a} f) (inr (x , south)) = f x .fst south
fst (Q→F̃ {A = A , a} f) (inr (x , merid a₁ i₁)) = f x .fst (merid a₁ i₁)
fst (Q→F̃ {A = A , a} f) (push a₁ i₁) = snd (f a₁) (~ i₁)
snd (Q→F̃ {A = A , a} f) = refl
Q→F̃-hom : (n : ℕ) → (f g : ((b : typ B) → Q b →∙ coHomK-ptd n))
→ Q→F̃ (λ b → f b ++ g b) ≡ (Q→F̃ f ++ Q→F̃ g)
Q→F̃-hom n f g =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { (inl x) → sym (rUnitₖ _ (0ₖ _))
; (inr (x , north)) → refl
; (inr (x , south)) → refl
; (inr (x , merid a i₁)) → refl
; (push a j) i →
compPath-filler (cong₂ _+ₖ_ (snd (f a)) (snd (g a)))
(rUnitₖ n (0ₖ n)) (~ i) (~ j)})
Q→F̃→Q : ∀ {ℓ} {A : Pointed ℓ}
→ (x : (b : typ B) → Q b →∙ A) (b : typ B) (q : Q b .fst)
→ F̃→Q (Q→F̃ x) b .fst q ≡ x b .fst q
Q→F̃→Q f b north = refl
Q→F̃→Q f b south = refl
Q→F̃→Q f b (merid a i₁) = refl
F̃→Q→F̃ : ∀ {ℓ} {A : Pointed ℓ} (f : F̃ → typ A) (p : _)
→ (x : F̃) → fst (Q→F̃ {A = A} (F̃→Q (f , p))) x ≡ f x
F̃→Q→F̃ f p (inl x) = sym p
F̃→Q→F̃ f p (inr (x , north)) = refl
F̃→Q→F̃ f p (inr (x , south)) = refl
F̃→Q→F̃ f p (inr (x , merid a i₁)) = refl
F̃→Q→F̃ f p (push a i₁) j =
compPath-filler (sym (cong f (push a))) p (~ j) (~ i₁)
IsoF̃Q : ∀ {ℓ} {A : Pointed ℓ}
→ Iso ((F̃ , inl tt) →∙ A)
((b : typ B) → Q b →∙ A)
Iso.fun (IsoF̃Q {A = A , a}) = F̃→Q
Iso.inv (IsoF̃Q {A = A , a}) = Q→F̃
Iso.rightInv (IsoF̃Q {A = A , a}) f =
funExt λ b → ΣPathP (funExt (Q→F̃→Q f b)
, sym (rUnit (snd (f b))))
Iso.leftInv (IsoF̃Q {A = A , a}) (f , p) =
ΣPathP ((funExt (F̃→Q→F̃ f p))
, λ i j → p (~ i ∨ j))
-- The main result
ι : (k : ℕ) → Iso ((b : typ B) → Q b →∙ coHomK-ptd k)
((Ẽ , inl tt) →∙ coHomK-ptd k)
ι k = compIso (invIso IsoF̃Q) IsoFE-extend
where
IsoFE-extend : Iso ((F̃ , inl tt) →∙ coHomK-ptd k)
((Ẽ , inl tt) →∙ coHomK-ptd k)
Iso.fun IsoFE-extend G = (λ x → G .fst (Iso.inv IsoFE x))
, (snd G)
Iso.inv IsoFE-extend G = (λ x → G .fst (Iso.fun IsoFE x))
, (snd G)
Iso.rightInv IsoFE-extend G =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ x → cong (G .fst) (Iso.rightInv IsoFE x))
Iso.leftInv IsoFE-extend G =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ x → cong (G .fst) (Iso.leftInv IsoFE x))
ι-hom : (k : ℕ) → (f g : ((b : typ B) → Q b →∙ coHomK-ptd k))
→ Iso.fun (ι k) (λ b → f b ++ g b)
≡ (Iso.fun (ι k) f ++ Iso.fun (ι k) g)
ι-hom k f g =
→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ x → funExt⁻ (cong fst (Q→F̃-hom _ f g)) (invFE x))
-- Packing everything up gives us the Thom Isomorphism between
-- the nᵗʰ cohomology of B and the (n+i)ᵗʰ reduced cohomology of Ẽ,
-- as defined above
module Thom {ℓ} (B : Pointed ℓ) (P : typ B → Type ℓ-zero)
(conB : (x y : typ B) → ∥ x ≡ y ∥₁)
(n : ℕ) (Q-is : Iso (typ (preThom.Q B P (pt B))) (S₊ n))
(Q-is-ptd : Iso.fun Q-is (pt (preThom.Q B P (pt B))) ≡ snd (S₊∙ n))
(c : (b : typ B) → (preThom.Q B P b →∙ coHomK-ptd n))
(c-pt : c (pt B) .fst ≡ ((λ x → genFunSpace n .fst (Iso.fun Q-is x))))
where
ϕ : (i : ℕ)
→ GroupEquiv (coHomGr i (typ B))
(coHomRedGrDir (i +' n) (preThom.Ẽ B P , inl tt))
fst (ϕ i) =
isoToEquiv
(setTruncIso
(compIso
(codomainIsoDep
λ b →
equivToIso ((g B (preThom.Q B P) conB n Q-is Q-is-ptd c c-pt b i)
, g-equiv B (preThom.Q B P) conB n Q-is Q-is-ptd c c-pt b i))
(preThom.ι B P (i +' n))))
snd (ϕ i) =
makeIsGroupHom
(ST.elim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _)
λ F G →
cong ∣_∣₂ (cong (Iso.fun (preThom.ι B P (i +' n)))
(funExt (λ a →
g-hom B (preThom.Q B P)
conB n Q-is Q-is-ptd c c-pt a i (F a) (G a)))
∙ preThom.ι-hom B P (i +' n) _ _)
∙ addAgree (i +' n) _ _)
-- We finally get the Gysin sequence
module Gysin {ℓ} (B : Pointed ℓ) (P : typ B → Type ℓ-zero)
(conB : (x y : typ B) → ∥ x ≡ y ∥₂)
(n : ℕ) (Q-is : Iso (typ (preThom.Q B P (pt B))) (S₊ n))
(Q-is-ptd : Iso.fun Q-is (pt (preThom.Q B P (pt B))) ≡ snd (S₊∙ n))
where
0-connB : (x y : typ B) → ∥ x ≡ y ∥₁
0-connB x y = ST.rec (isProp→isSet squash₁) (∥_∥₁.∣_∣₁) (conB x y)
c = (c* B (preThom.Q B P) conB n Q-is Q-is-ptd .fst)
c-ptd = (c* B (preThom.Q B P) conB n Q-is Q-is-ptd .snd)
cEq = c≡ B (preThom.Q B P) conB n Q-is Q-is-ptd
module w = Thom B P 0-connB n Q-is Q-is-ptd c c-ptd
ϕ = w.ϕ
E' = preThom.E B P
E'̃ = preThom.Ẽ B P
-- The generator of coHom n (typ B)
e : coHom n (typ B)
e = ∣ (λ b → c b .fst south) ∣₂
-- The maps of interest are ⌣, p, E-susp and j*. In reality, we are interested
-- in the composition of ϕ and j* (which is just the cup product),
-- but it's easier to first give an exact sequence involving p, E-susp and j*
⌣-hom : (i : ℕ) → GroupHom (coHomGr i (typ B)) (coHomGr (i +' n) (typ B))
fst (⌣-hom i) x = x ⌣ e
snd (⌣-hom i) =
makeIsGroupHom λ f g → rightDistr-⌣ _ _ f g e
p : E' → typ B
p = fst
p-hom : (i : ℕ) → GroupHom (coHomGr i (typ B)) (coHomGr i E')
p-hom i = coHomMorph _ p
E-susp : (i : ℕ) →
GroupHom (coHomGr i E') (coHomRedGrDir (suc i) (E'̃ , inl tt))
fst (E-susp i) =
ST.map λ f → (λ { (inl x) → 0ₖ _
; (inr x) → 0ₖ _
; (push a j) → Kn→ΩKn+1 _ (f a) j}) , refl
snd (E-susp zero) =
makeIsGroupHom (ST.elim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _)
λ f g →
cong ∣_∣₂ (→∙Homogeneous≡ (isHomogeneousKn 1)
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a j) k →
(Kn→ΩKn+1-hom zero (f a) (g a)
∙ ∙≡+₁ (Kn→ΩKn+1 _ (f a)) (Kn→ΩKn+1 _ (g a))) k j})))
snd (E-susp (suc i)) =
makeIsGroupHom (ST.elim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _)
λ f g →
cong ∣_∣₂ (→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a j) k → (Kn→ΩKn+1-hom _ (f a) (g a)
∙ ∙≡+₂ _ (Kn→ΩKn+1 _ (f a))
(Kn→ΩKn+1 _ (g a))) k j})))
module cofibSeq where
j* : (i : ℕ) →
GroupHom (coHomRedGrDir i (E'̃ , (inl tt))) (coHomGr i (typ B))
fst (j* i) = ST.map λ f → λ x → fst f (inr x)
snd (j* zero) =
makeIsGroupHom
(ST.elim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _) λ _ _ → refl)
snd (j* (suc zero)) =
makeIsGroupHom
(ST.elim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _) λ _ _ → refl)
snd (j* (suc (suc i₁))) =
makeIsGroupHom
(ST.elim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _) λ _ _ → refl)
Im-j⊂Ker-p : (i : ℕ) (x : _) → isInIm (j* i) x → isInKer (p-hom i) x
Im-j⊂Ker-p i =
ST.elim (λ _ → isSetΠ (λ _ → isOfHLevelPath 2 squash₂ _ _))
λ f → PT.rec (squash₂ _ _)
(uncurry (ST.elim (λ _ → isSetΠ (λ _ → isOfHLevelPath 2 squash₂ _ _))
λ g P → subst (isInKer (p-hom i)) P
(cong ∣_∣₂ (funExt λ x →
cong (g .fst) (sym (push x)) ∙ g .snd))))
Ker-p⊂Im-j : (i : ℕ) (x : _) → isInKer (p-hom i) x → isInIm (j* i) x
Ker-p⊂Im-j i =
ST.elim (λ _ → isSetΠ (λ _ → isProp→isSet squash₁))
λ f ker → PT.rec squash₁
(λ id → ∣ ∣ (λ { (inl x) → 0ₖ _
; (inr x) → f x
; (push a i₁) → funExt⁻ id a (~ i₁)}) , refl ∣₂
, refl ∣₁)
(Iso.fun PathIdTrunc₀Iso ker)
Im-p⊂Ker-Susp : (i : ℕ) (x : _)
→ isInIm (p-hom i) x → isInKer (E-susp i) x
Im-p⊂Ker-Susp i =
ST.elim (λ _ → isSetΠ (λ _ → isOfHLevelPath 2 squash₂ _ _))
λ f → PT.rec (squash₂ _ _)
(uncurry (ST.elim (λ _ → isSetΠ (λ _ → isOfHLevelPath 2 squash₂ _ _))
λ g y → subst (isInKer (E-susp i)) y
(cong ∣_∣₂ (→∙Homogeneous≡ (isHomogeneousKn _)
(funExt λ { (inl x) → refl
; (inr x) → sym (Kn→ΩKn+1 _ (g x))
; (push a j) k → Kn→ΩKn+1 i (g (fst a)) (~ k ∧ j)})))))
Ker-Susp⊂Im-p : (i : ℕ) (x : _)
→ isInKer (E-susp i) x → isInIm (p-hom i) x
Ker-Susp⊂Im-p i =
ST.elim (λ _ → isSetΠ (λ _ → isProp→isSet squash₁))
λ f ker → PT.rec squash₁
(λ id → ∣ ∣ (λ x → ΩKn+1→Kn i (sym (funExt⁻ (cong fst id) (inr x)))) ∣₂
, cong ∣_∣₂ (funExt (λ { (a , b) →
cong (ΩKn+1→Kn i)
(lUnit _
∙ cong (_∙ sym (funExt⁻ (λ i₁ → fst (id i₁)) (inr a)))
(sym (flipSquare (cong snd id))
∙∙ (PathP→compPathR
(cong (funExt⁻ (cong fst id)) (push (a , b))))
∙∙ assoc _ _ _
∙ sym (rUnit _))
∙ (sym (assoc _ _ _)
∙∙ cong (Kn→ΩKn+1 i (f (a , b)) ∙_) (rCancel _)
∙∙ sym (rUnit _)))
∙ Iso.leftInv (Iso-Kn-ΩKn+1 _) (f (a , b))})) ∣₁)
(Iso.fun PathIdTrunc₀Iso ker)
Im-Susp⊂Ker-j : (i : ℕ) (x : _)
→ isInIm (E-susp i) x → isInKer (cofibSeq.j* (suc i)) x
Im-Susp⊂Ker-j i =
ST.elim (λ _ → isSetΠ (λ _ → isOfHLevelPath 2 squash₂ _ _))
λ g → PT.rec (squash₂ _ _)
(uncurry (ST.elim (λ _ → isSetΠ (λ _ → isOfHLevelPath 2 squash₂ _ _))
λ f id → PT.rec (squash₂ _ _)
(λ P → subst (isInKer (cofibSeq.j* (suc i))) (cong ∣_∣₂ P)
(cong ∣_∣₂ refl))
(Iso.fun PathIdTrunc₀Iso id)))
Ker-j⊂Im-Susp : (i : ℕ) (x : _)
→ isInKer (cofibSeq.j* (suc i)) x → isInIm (E-susp i) x
Ker-j⊂Im-Susp i =
ST.elim (λ _ → isSetΠ (λ _ → isProp→isSet squash₁))
λ f ker
→ PT.rec squash₁
(λ p → ∣ ∣ (λ x → ΩKn+1→Kn _ (sym (snd f)
∙∙ cong (fst f) (push x)
∙∙ funExt⁻ p (fst x))) ∣₂
, cong ∣_∣₂ (→∙Homogeneous≡ (isHomogeneousKn _)
(funExt (λ { (inl x) → sym (snd f)
; (inr x) → sym (funExt⁻ p x)
; (push a j) k → h3 f p a k j}))) ∣₁)
(Iso.fun PathIdTrunc₀Iso ker)
where
h3 : (f : (E'̃ , inl tt) →∙ coHomK-ptd (suc i))
→ (p : (fst f ∘ inr) ≡ (λ _ → 0ₖ (suc i)))
→ (a : preThom.E B P)
→ PathP (λ i → snd f (~ i) ≡ p (~ i) (fst a))
(Kn→ΩKn+1 i (ΩKn+1→Kn i (sym (snd f)
∙∙ cong (fst f) (push a)
∙∙ funExt⁻ p (fst a))))
(cong (fst f) (push a))
h3 f p a =
Iso.rightInv (Iso-Kn-ΩKn+1 i) _
◁ λ i j →
doubleCompPath-filler (sym (snd f)) (cong (fst f) (push a))
(funExt⁻ p (fst a)) (~ i) j
-- We compose ϕ and j*. The above exact sequence will induce another one for
-- this composition. In fact, this group hom is definitionally equal to
-- (λ x → x ⌣ e) modulo truncation elimination and snd fields.
ϕ∘j : (i : ℕ) → GroupHom (coHomGr i (typ B)) (coHomGr (i +' n) (typ B))
ϕ∘j i = compGroupHom (fst (fst (ϕ i)) , snd (ϕ i)) (cofibSeq.j* (i +' n))
private
+'-suc : (i n : ℕ) → (suc i +' n) ≡ suc (i +' n)
+'-suc zero zero = refl
+'-suc (suc i₁) zero = refl
+'-suc zero (suc n) = refl
+'-suc (suc i₁) (suc n) = refl
Path→GroupPath : ∀ {ℓ ℓ'} {n m : ℕ} (G : ℕ → Group ℓ) (H : Group ℓ')
(p : n ≡ m)
→ GroupEquiv (G n) H
→ GroupEquiv (G m) H
Path→GroupPath {n = n} G H =
J (λ m _ → GroupEquiv (G n) H → GroupEquiv (G m) H)
λ p → p
h-ret : ∀ {ℓ ℓ'} {n m : ℕ} (G : ℕ → Group ℓ) (H : Group ℓ')
→ (e : GroupEquiv (G n) H)
→ (p : n ≡ m)
→ (x : G m .fst)
→ invEq (fst e) (fst (fst (Path→GroupPath G H p e)) x)
≡ subst (λ x → G x .fst) (sym p) x
h-ret G H e =
J (λ m p → ((x : G m .fst)
→ invEq (fst e) (fst (fst (Path→GroupPath G H p e)) x)
≡ subst (λ x → G x .fst) (sym p) x))
λ x → cong (invEq (fst e) )
(λ i → transportRefl (transportRefl (fst (fst e)
(transportRefl (transportRefl x i) i)) i) i)
∙∙ retEq (fst e) x
∙∙ sym (transportRefl _)
thomIso' : (i : ℕ) → GroupEquiv (coHomRedGrDir (suc (i +' n)) (E'̃ , inl tt))
(coHomGr (suc i) (typ B))
thomIso' i = (Path→GroupPath
(λ n → coHomRedGrDir n (E'̃ , inl tt)) _ (+'-suc i n)
(invGroupEquiv (ϕ (suc i))))
ϕ' : (i : ℕ) → GroupHom (coHomRedGrDir (suc (i +' n)) (E'̃ , inl tt))
(coHomGr (suc i) (typ B))
ϕ' i = fst (fst (thomIso' i)) , snd (thomIso' i)
susp∘ϕ : (i : ℕ) → GroupHom (coHomGr (i +' n) E') (coHomGr (suc i) (typ B))
susp∘ϕ i = compGroupHom (E-susp (i +' n)) (ϕ' i)
Im-ϕ∘j⊂Ker-p : (i : ℕ) (x : _) → isInIm (ϕ∘j i) x → isInKer (p-hom _) x
Im-ϕ∘j⊂Ker-p i x p =
cofibSeq.Im-j⊂Ker-p _ x
(PT.rec squash₁ (uncurry (λ f p → ∣ fst (fst (ϕ _)) f , p ∣₁)) p)
Ker-p⊂Im-ϕ∘j : (i : ℕ) (x : _) → isInKer (p-hom _) x → isInIm (ϕ∘j i) x
Ker-p⊂Im-ϕ∘j i x p =
PT.rec squash₁
(uncurry (λ f p →
∣ (invEq (fst (ϕ _)) f)
, (cong (fst (cofibSeq.j* _)) (secEq (fst (ϕ _)) f) ∙ p) ∣₁))
(cofibSeq.Ker-p⊂Im-j _ x p)
Im-p⊂KerSusp∘ϕ : (i : ℕ) (x : _)
→ isInIm (p-hom _) x → isInKer (susp∘ϕ i) x
Im-p⊂KerSusp∘ϕ i x p =
cong (fst (ϕ' _)) (Im-p⊂Ker-Susp _ x p) ∙ IsGroupHom.pres1 (snd (ϕ' _))
KerSusp∘ϕ⊂Im-p : (i : ℕ) (x : _)
→ isInKer (susp∘ϕ i) x → isInIm (p-hom _) x
KerSusp∘ϕ⊂Im-p i x p =
Ker-Susp⊂Im-p _ x (sym (retEq (fst (thomIso' _)) _)
∙ (cong (invEq (fst (thomIso' _))) p
∙ IsGroupHom.pres1 (snd (invGroupEquiv (thomIso' _)))))
Im-Susp∘ϕ⊂Ker-ϕ∘j : (i : ℕ) → (x : _)
→ isInIm (susp∘ϕ i) x → isInKer (ϕ∘j (suc i)) x
Im-Susp∘ϕ⊂Ker-ϕ∘j i x =
PT.rec (squash₂ _ _)
(uncurry λ f → J (λ x p → isInKer (ϕ∘j (suc i)) x)
((λ i → fst (cofibSeq.j* _) (fst (fst (ϕ _)) (fst (ϕ' _) (fst (E-susp _) f))))
∙∙ cong (fst (cofibSeq.j* _))
((h-ret (λ n → coHomRedGrDir n (E'̃ , inl tt)) _
(invGroupEquiv (ϕ (suc i))) (+'-suc i n)) (fst (E-susp _) f))
∙∙ (natTranspLem _ (λ n → fst (cofibSeq.j* n)) (sym (+'-suc i n))
∙ cong (subst (λ z → coHomGr z (typ B) .fst) (sym (+'-suc i n)))
(Im-Susp⊂Ker-j _ (fst (E-susp (i +' n)) f) ∣ f , refl ∣₁)
∙ tLem i n)))
where
tLem : (i n : ℕ) → subst (λ z → coHomGr z (typ B) .fst) (sym (+'-suc i n))
(0ₕ _) ≡ 0ₕ _
tLem zero zero = refl
tLem zero (suc n) = refl
tLem (suc i₁) zero = refl
tLem (suc i₁) (suc n) = refl
Ker-ϕ∘j⊂Im-Susp∘ϕ : (i : ℕ) (x : _)
→ isInKer (ϕ∘j (suc i)) x → isInIm (susp∘ϕ i) x
Ker-ϕ∘j⊂Im-Susp∘ϕ i x p =
PT.rec squash₁
(uncurry (λ f p → ∣ f , cong (fst (fst (thomIso' i))) p
∙ secEq (fst (thomIso' _)) x ∣₁))
(Ker-j⊂Im-Susp _ (invEq (fst (thomIso' _)) x)
((cong (cofibSeq.j* (suc (i +' n)) .fst ) lem₁
∙ natTranspLem _ (λ n → cofibSeq.j* n .fst) (+'-suc i n))
∙∙ cong (transport (λ j → (coHomGr (+'-suc i n j) (typ B) .fst))) p
∙∙ lem₂ i n))
where
lem₁ : invEq (fst (thomIso' i)) x
≡ transport (λ j → coHomRed (+'-suc i n j)
(E'̃ , inl tt)) (fst (fst (ϕ _)) x)
lem₁ = cong (transport (λ j → coHomRed (+'-suc i n j) (E'̃ , inl tt)))
(transportRefl _ ∙ cong (fst (fst (ϕ _)))
λ i → transportRefl (transportRefl x i) i)
lem₂ : (i n : ℕ)
→ transport (λ j → coHomGr (+'-suc i n j) (typ B) .fst)
(GroupStr.1g (coHomGr (suc i +' n) (typ B) .snd)) ≡ 0ₕ _
lem₂ zero zero = refl
lem₂ zero (suc n) = refl
lem₂ (suc i₁) zero = refl
lem₂ (suc i₁) (suc n) = refl
-- Finally, we have that ϕ∘j is just the cup product, and we have arrived
-- at an exact sequence involving it.
ϕ∘j≡ : (i : ℕ) → ϕ∘j i ≡ ⌣-hom i
ϕ∘j≡ i =
Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(funExt (ST.elim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ _ → refl))
-- We can now restate the previous resluts for (λ x → x ⌣ e)
Im-⌣e⊂Ker-p : (i : ℕ) (x : _)
→ isInIm (⌣-hom i) x → isInKer (p-hom _) x
Im-⌣e⊂Ker-p i x p =
Im-ϕ∘j⊂Ker-p i x (subst (λ p → isInIm p x) (sym (ϕ∘j≡ i)) p)
Ker-p⊂Im-⌣e : (i : ℕ) (x : _)
→ isInKer (p-hom _) x → isInIm (⌣-hom i) x
Ker-p⊂Im-⌣e i x p =
subst (λ p → isInIm p x) (ϕ∘j≡ i) (Ker-p⊂Im-ϕ∘j i x p)
Im-Susp∘ϕ⊂Ker-⌣e : (i : ℕ) (x : _)
→ isInIm (susp∘ϕ i) x → isInKer (⌣-hom (suc i)) x
Im-Susp∘ϕ⊂Ker-⌣e i x p =
subst (λ p → isInKer p x) (ϕ∘j≡ (suc i)) (Im-Susp∘ϕ⊂Ker-ϕ∘j i x p)
Ker-⌣e⊂Im-Susp∘ϕ : (i : ℕ) (x : _)
→ isInKer (⌣-hom (suc i)) x → isInIm (susp∘ϕ i) x
Ker-⌣e⊂Im-Susp∘ϕ i x p =
Ker-ϕ∘j⊂Im-Susp∘ϕ i x (subst (λ p → isInKer p x) (sym (ϕ∘j≡ (suc i))) p)
| {
"alphanum_fraction": 0.4884532991,
"avg_line_length": 41.0915492958,
"ext": "agda",
"hexsha": "6c1c88d4db1e01dbe9876e105d1b1ad1e7981599",
"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/ZCohomology/Gysin.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/ZCohomology/Gysin.agda",
"max_line_length": 109,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/Gysin.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 19716,
"size": 46680
} |
import Lvl
open import Type
module Structure.Logic.Constructive.Propositional {ℓₗ} {Formula : Type{ℓₗ}} {ℓₘₗ} (Proof : Formula → Type{ℓₘₗ}) where
open import Logic.Predicate
private variable X Y Z : Formula
-- Rules of bottom (falsity).
record Bottom(⊥ : Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
elim : Proof(⊥) → Proof(X)
⊥ = \ ⦃([∃]-intro ▫) : ∃(Bottom)⦄ → ▫
module ⊥ {▫} ⦃ p ⦄ = Bottom {▫} p
-- Rules of top (truth).
record Top(⊤ : Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
intro : Proof(⊤)
⊤ = \ ⦃([∃]-intro ▫) : ∃(Top)⦄ → ▫
module ⊤ {▫} ⦃ p ⦄ = Top {▫} p
-- Rules of conjunction (and).
record Conjunction(_∧_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
intro : Proof(X) → Proof(Y) → Proof(X ∧ Y)
elimₗ : Proof(X ∧ Y) → Proof(X)
elimᵣ : Proof(X ∧ Y) → Proof(Y)
_∧_ = \ ⦃([∃]-intro ▫) : ∃(Conjunction)⦄ → ▫
module ∧ {▫} ⦃ p ⦄ = Conjunction {▫} p
-- Rules of implication.
record Implication(_⟶_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
intro : (Proof(X) → Proof(Y)) → Proof(X ⟶ Y)
elim : Proof(X ⟶ Y) → Proof(X) → Proof(Y)
_⟶_ = \ ⦃([∃]-intro ▫) : ∃(Implication)⦄ → ▫
module ⟶ {▫} ⦃ p ⦄ = Implication {▫} p
-- Rules of reversed implication.
record Consequence(_⟵_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
intro : (Proof(X) → Proof(Y)) → Proof(Y ⟵ X)
elim : Proof(Y ⟵ X) → Proof(X) → Proof(Y)
_⟵_ = \ ⦃([∃]-intro ▫) : ∃(Consequence)⦄ → ▫
module ⟵ {▫} ⦃ p ⦄ = Consequence {▫} p
-- Rules of equivalence.
record Equivalence(_⟷_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
intro : let _ = X in (Proof(Y) → Proof(X)) → (Proof(X) → Proof(Y)) → Proof(X ⟷ Y)
elimₗ : Proof(X ⟷ Y) → Proof(Y) → Proof(X)
elimᵣ : Proof(X ⟷ Y) → Proof(X) → Proof(Y)
_⟷_ = \ ⦃([∃]-intro ▫) : ∃(Equivalence)⦄ → ▫
module ⟷ {▫} ⦃ p ⦄ = Equivalence {▫} p
-- Rules of disjunction (or).
record Disjunction(_∨_ : Formula → Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
introₗ : Proof(X) → Proof(X ∨ Y)
introᵣ : Proof(Y) → Proof(X ∨ Y)
elim : (Proof(X) → Proof(Z)) → (Proof(Y) → Proof(Z)) → Proof(X ∨ Y) → Proof(Z)
_∨_ = \ ⦃([∃]-intro ▫) : ∃(Disjunction)⦄ → ▫
module ∨ {▫} ⦃ p ⦄ = Disjunction {▫} p
-- Rules of negation (not).
record Negation(¬_ : Formula → Formula) : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
intro : (Proof(X) → Proof(Y)) → (Proof(X) → Proof(¬ Y)) → Proof(¬ X)
elim : Proof(X) → Proof(¬ X) → Proof(Y)
¬_ = \ ⦃([∃]-intro ▫) : ∃(Negation)⦄ → ▫
module ¬ {▫} ⦃ p ⦄ = Negation {▫} p
record Logic : Type{ℓₘₗ Lvl.⊔ ℓₗ} where
field
⦃ bottom ⦄ : ∃(Bottom)
⦃ top ⦄ : ∃(Top)
⦃ conjunction ⦄ : ∃(Conjunction)
⦃ implication ⦄ : ∃(Implication)
⦃ consequence ⦄ : ∃(Consequence)
⦃ equivalence ⦄ : ∃(Equivalence)
⦃ disjunction ⦄ : ∃(Disjunction)
⦃ negation ⦄ : ∃(Negation)
| {
"alphanum_fraction": 0.5545138889,
"avg_line_length": 33.8823529412,
"ext": "agda",
"hexsha": "ba6094bf5a18b54ece7b5bf4c079029f1cd35ef5",
"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/Logic/Constructive/Propositional.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/Logic/Constructive/Propositional.agda",
"max_line_length": 117,
"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/Logic/Constructive/Propositional.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": 1319,
"size": 2880
} |
------------------------------------------------------------------------------
-- Properties for the equality on Conat
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Conat.Equality.PropertiesI where
open import FOTC.Base
open import FOTC.Data.Conat
open import FOTC.Data.Conat.Equality.Type
------------------------------------------------------------------------------
-- Because a greatest post-fixed point is a fixed-point, then the
-- relation _≈_ is also a pre-fixed point of the functional ≈-F, i.e.
--
-- ≈-F _≈_ ≤ _≈_ (see FOTC.Data.Conat.Equality.Type).
≈-in :
∀ {m n} →
m ≡ zero ∧ n ≡ zero
∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ m' ≈ n') →
m ≈ n
≈-in h = ≈-coind R h' h
where
R : D → D → Set
R m n = m ≡ zero ∧ n ≡ zero
∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ m' ≈ n')
h' : ∀ {m n} → R m n →
m ≡ zero ∧ n ≡ zero
∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ R m' n')
h' (inj₁ prf) = inj₁ prf
h' (inj₂ (m' , n' , prf₁ , prf₂ , m'≈n')) =
inj₂ (m' , n' , prf₁ , prf₂ , ≈-out m'≈n')
≈-refl : ∀ {n} → Conat n → n ≈ n
≈-refl {n} Cn = ≈-coind R h₁ h₂
where
R : D → D → Set
R a b = Conat a ∧ Conat b ∧ a ≡ b
h₁ : ∀ {a b} → R a b →
a ≡ zero ∧ b ≡ zero
∨ (∃[ a' ] ∃[ b' ] a ≡ succ₁ a' ∧ b ≡ succ₁ b' ∧ R a' b')
h₁ (Ca , Cb , h) with Conat-out Ca
... | inj₁ prf = inj₁ (prf , trans (sym h) prf)
... | inj₂ (a' , prf , Ca') =
inj₂ (a' , a' , prf , trans (sym h) prf , (Ca' , Ca' , refl))
h₂ : R n n
h₂ = Cn , Cn , refl
≡→≈ : ∀ {m n} → Conat m → Conat n → m ≡ n → m ≈ n
≡→≈ Cm _ refl = ≈-refl Cm
| {
"alphanum_fraction": 0.4108108108,
"avg_line_length": 31.8965517241,
"ext": "agda",
"hexsha": "bd2f3033243080fb4a4ad6810784360bcd88e022",
"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/Data/Conat/Equality/PropertiesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Data/Conat/Equality/PropertiesI.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Data/Conat/Equality/PropertiesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 724,
"size": 1850
} |
------------------------------------------------------------------------
-- Quotients, defined as families of equivalence classes
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- Partly based on the presentation of quotients in the HoTT book.
-- Perhaps that presentation is partly based on work by Voevodsky.
-- The generalisation from propositional equivalence relations to
-- "strong" equivalence relations is my own. In light of the results
-- below I see little use for this generalisation…
open import Equality
module Quotient.Families-of-equivalence-classes
{r} (eq : ∀ {a p} → Equality-with-J a p r) where
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection eq as Bij using (_↔_)
open import Bool eq
private
module D = Derived-definitions-and-properties eq
open D hiding (elim)
open import Equality.Decidable-UIP eq using (Constant)
open import Equality.Decision-procedures eq
import Equality.Groupoid eq as EG
open import Equivalence eq as Eq using (_≃_)
open import Equivalence-relation eq
open import Fin eq
open import Function-universe eq as F hiding (_∘_)
open import Groupoid
open import H-level eq as H-level
open import H-level.Closure eq
open import H-level.Truncation.Church eq as Trunc hiding (rec)
open import Nat eq as Nat
open import Surjection eq using (_↠_)
open import Univalence-axiom eq
------------------------------------------------------------------------
-- Strong equivalence relations
mutual
-- A strengthening of the concept of "equivalence relation".
Strong-equivalence :
∀ {a r} {A : Type a} →
(A → A → Type r) → Type (a ⊔ lsuc r)
Strong-equivalence = Strong-equivalence-with equivalence
-- A generalisation of "strong equivalence".
Strong-equivalence-with :
∀ {a r} {A : Type a} →
Kind → (A → A → Type r) → Type (a ⊔ lsuc r)
Strong-equivalence-with k R = ∀ {x y} → R x y ↝[ k ] (R x ≡ R y)
-- Strong equivalence relations (with equivalence) are strong
-- equivalence relations with any kind.
strong-equivalence⇒strong-equivalence-with :
∀ {k a r} {A : Type a} {R : A → A → Type r} →
Strong-equivalence R → Strong-equivalence-with k R
strong-equivalence⇒strong-equivalence-with strong-equivalence =
from-equivalence strong-equivalence
-- Strong equivalence relations with logical equivalence are
-- equivalence relations.
strong-equivalence-with-⇔⇒equivalence :
∀ {a r} {A : Type a} {R : A → A → Type r} →
Strong-equivalence-with logical-equivalence R →
Is-equivalence-relation R
strong-equivalence-with-⇔⇒equivalence {R = R} strong-equivalence =
record
{ reflexive = λ {x} →
$⟨ refl (R x) ⟩
R x ≡ R x ↝⟨ to-implication $ inverse strong-equivalence ⟩□
R x x □
; symmetric = λ {x y} →
R x y ↝⟨ to-implication strong-equivalence ⟩
R x ≡ R y ↝⟨ sym ⟩
R y ≡ R x ↝⟨ to-implication $ inverse strong-equivalence ⟩□
R y x □
; transitive = λ {x y z} Rxy Ryz →
to-implication (inverse strong-equivalence) (
R x ≡⟨ to-implication strong-equivalence Rxy ⟩
R y ≡⟨ to-implication strong-equivalence Ryz ⟩∎
R z ∎)
}
-- Strong equivalence relations are equivalence relations.
strong-equivalence⇒equivalence :
∀ {a r} {A : Type a} {R : A → A → Type r} →
Strong-equivalence R →
Is-equivalence-relation R
strong-equivalence⇒equivalence =
strong-equivalence-with-⇔⇒equivalence ∘
strong-equivalence⇒strong-equivalence-with
-- A relation that is an equivalence relation, and a family of
-- propositions, is a strong equivalence relation (assuming
-- extensionality and univalence).
propositional-equivalence⇒strong-equivalence :
∀ {a r} {A : Type a} {R : A → A → Type r} →
Extensionality (a ⊔ r) (lsuc r) →
Univalence r →
Is-equivalence-relation R →
(∀ x y → Is-proposition (R x y)) →
Strong-equivalence R
propositional-equivalence⇒strong-equivalence
{a} {r} {R = R} ext univ R-equiv R-prop {x = x} {y = y} =
Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = λ Rxy → apply-ext (lower-extensionality r lzero ext) λ z →
≃⇒≡ univ $
_↔_.to (Eq.⇔↔≃ (lower-extensionality a _ ext)
(R-prop x z) (R-prop y z))
(R x z ↝⟨ record { to = transitive (symmetric Rxy)
; from = transitive Rxy
} ⟩□
R y z □)
; from = λ Rx≡Ry → $⟨ reflexive ⟩
R y y ↝⟨ subst (_$ y) (sym Rx≡Ry) ⟩□
R x y □
}
; right-inverse-of = λ _ →
H-level.respects-surjection
(_≃_.surjection $ Eq.extensionality-isomorphism
(lower-extensionality r lzero ext))
1
(Π-closure (lower-extensionality r lzero ext) 1 λ z →
H-level-H-level-≡ˡ
(lower-extensionality a _ ext)
univ 0 (R-prop x z))
_ _
}
; left-inverse-of = λ _ → R-prop x y _ _
})
where
open Is-equivalence-relation R-equiv
-- _≡_ is a strong equivalence relation (assuming extensionality and
-- univalence).
equality-strong-equivalence :
∀ {a} {A : Type a} →
Extensionality a (lsuc a) →
Univalence a →
Strong-equivalence (_≡_ {A = A})
equality-strong-equivalence ext univ {x = x} {y = y} =
x ≡ y ↝⟨ inverse $ Π≡≃≡-↔-≡ _ _ (lower-extensionality lzero _ ext) ⟩
(∀ z → (z ≡ x) ≃ (z ≡ y)) ↝⟨ (∀-cong (lower-extensionality lzero _ ext) λ _ → Eq.↔⇒≃ $
Eq.≃-preserves-bijections (lower-extensionality lzero _ ext)
(Groupoid.⁻¹-bijection (EG.groupoid _))
(Groupoid.⁻¹-bijection (EG.groupoid _))) ⟩
(∀ z → (x ≡ z) ≃ (y ≡ z)) ↝⟨ (∀-cong ext λ _ → inverse $ ≡≃≃ univ) ⟩
(∀ z → (x ≡ z) ≡ (y ≡ z)) ↝⟨ Eq.extensionality-isomorphism ext ⟩□
(x ≡_) ≡ (y ≡_) □
-- If λ (_ _ : ⊤) → Fin n is a strong equivalence relation, then n is
-- equal to n ! (assuming extensionality and univalence).
const-Fin-strong-equivalence⇒≡! :
Extensionality (# 0) (# 1) →
Univalence (# 0) →
∀ n → Strong-equivalence (λ (_ _ : ⊤) → Fin n) → n ≡ n !
const-Fin-strong-equivalence⇒≡! ext univ n strong-equivalence =
_⇔_.to isomorphic-same-size (
Fin n ↔⟨ strong-equivalence ⟩
const (Fin n) ≡ const (Fin n) ↔⟨ inverse $ Eq.extensionality-isomorphism ext ⟩
(⊤ → Fin n ≡ Fin n) ↝⟨ Π-left-identity ⟩
Fin n ≡ Fin n ↝⟨ [Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ n ⟩
Fin (n !) □)
-- Thus there is at least one equivalence relation that is not a
-- strong equivalence relation (assuming extensionality and
-- univalence).
equivalence-but-not-strong-equivalence :
Extensionality (# 0) (# 1) →
Univalence (# 0) →
∃ λ (A : Type) →
∃ λ (R : A → A → Type) →
(∀ {x} → R x x) ×
(∀ {x y} → R x y → R y x) ×
(∀ {x y z} → R x y → R y z → R x z) ×
¬ Strong-equivalence R
equivalence-but-not-strong-equivalence ext univ =
A , R , rfl , sm , trns , not-strong-equivalence
where
A : Type
A = ⊤
R : A → A → Type
R _ _ = Fin 3
rfl : ∀ {x} → R x x
rfl = fzero
sm : ∀ {x y} → R x y → R y x
sm _ = fzero
trns : ∀ {x y z} → R x y → R y z → R x z
trns _ _ = fzero
not-strong-equivalence : ¬ Strong-equivalence R
not-strong-equivalence =
Strong-equivalence R ↝⟨ const-Fin-strong-equivalence⇒≡! ext univ 3 ⟩
3 ≡ 3 ! ↝⟨ from-⊎ (3 Nat.≟ (3 !)) ⟩□
⊥ □
-- On the other hand, if n is 2, then λ (_ _ : ⊤) → Fin n is a strong
-- equivalence relation (assuming extensionality and univalence).
const-Fin-2-strong-equivalence :
Extensionality (# 0) (# 1) →
Univalence (# 0) →
Strong-equivalence (λ (_ _ : ⊤) → Fin 2)
const-Fin-2-strong-equivalence ext univ =
Fin 2 ↔⟨ inverse $ [Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ 2 ⟩
Fin 2 ≡ Fin 2 ↔⟨ inverse Π-left-identity ⟩
(⊤ → Fin 2 ≡ Fin 2) ↝⟨ Eq.extensionality-isomorphism ext ⟩□
const (Fin 2) ≡ const (Fin 2) □
-- Thus there is at least one example of a strong equivalence relation
-- that is neither propositional nor the identity type (assuming
-- extensionality and univalence).
strong-equivalence-that-is-neither-propositional-nor-≡ :
Extensionality (# 0) (# 1) →
Univalence (# 0) →
∃ λ (A : Type) →
∃ λ (R : A → A → Type) →
Strong-equivalence R ×
¬ (∀ x y → Is-proposition (R x y)) ×
¬ (∀ x y → R x y ≃ (x ≡ y))
strong-equivalence-that-is-neither-propositional-nor-≡ ext univ =
⊤ , (λ _ _ → Fin 2) , const-Fin-2-strong-equivalence ext univ ,
(λ is-prop → $⟨ is-prop _ _ ⟩
Is-proposition (⊤ ⊎ ⊤ ⊎ ⊥) ↝⟨ H-level.respects-surjection (_↔_.surjection $ inverse Bool↔Fin2) 1 ⟩
Is-proposition Bool ↝⟨ ¬-Bool-propositional ⟩□
⊥ □) ,
(λ ≃≡ → let eq = ≃≡ tt tt in
⊎.inj₁≢inj₂ (
fzero ≡⟨ sym $ _≃_.left-inverse-of eq _ ⟩
_≃_.from eq (_≃_.to eq fzero) ≡⟨ cong (_≃_.from eq) $
mono (zero≤ 2) ⊤-contractible _ _ ⟩
_≃_.from eq (_≃_.to eq (fsuc fzero)) ≡⟨ _≃_.left-inverse-of eq _ ⟩∎
fsuc fzero ∎))
-- It is not in general the case that, if R is a strong equivalence
-- relation, then R on f is a strong equivalence relation (assuming
-- extensionality and univalence).
strong-equivalence-not-closed-under-on :
Extensionality (# 1) (# 2) →
Univalence (# 1) →
Univalence (# 0) →
∃ λ (A : Type₁) →
∃ λ (B : Type₁) →
∃ λ (R : A → A → Type₁) →
∃ λ (f : B → A) →
Strong-equivalence R ×
¬ Strong-equivalence (R on f)
strong-equivalence-not-closed-under-on ext univ₁ univ₀ =
Type , ↑ _ ⊤ , _≡_ , const (Fin 3) ,
equality-strong-equivalence ext univ₁ ,
not-strong-equivalence
where
not-strong-equivalence : ¬ Strong-equivalence (_≡_ on const (Fin 3))
not-strong-equivalence strong-equivalence = contradiction
where
3!≡3!! = _⇔_.to (isomorphic-same-size { n = 3 ! ! }) (
Fin (3 !) ↝⟨ inverse $ [Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ₀ 3 ⟩
Fin 3 ≡ Fin 3 ↔⟨ strong-equivalence ⟩
const (Fin 3 ≡ Fin 3) ≡ const (Fin 3 ≡ Fin 3) ↔⟨ inverse $ Eq.extensionality-isomorphism ext ⟩
(↑ _ ⊤ → (Fin 3 ≡ Fin 3) ≡ (Fin 3 ≡ Fin 3)) ↝⟨ →-cong₁ ext Bij.↑↔ ⟩
(⊤ → (Fin 3 ≡ Fin 3) ≡ (Fin 3 ≡ Fin 3)) ↝⟨ Π-left-identity ⟩
(Fin 3 ≡ Fin 3) ≡ (Fin 3 ≡ Fin 3) ↔⟨ ≡-preserves-≃ (lower-extensionality lzero _ ext) univ₁ univ₀
(Eq.↔⇒≃ $ [Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ₀ 3)
(Eq.↔⇒≃ $ [Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ₀ 3) ⟩
Fin (3 !) ≡ Fin (3 !) ↝⟨ [Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ₀ (3 !) ⟩□
Fin (3 ! !) □)
contradiction : ⊥
contradiction = from-⊎ ((3 !) Nat.≟ (3 ! !)) 3!≡3!!
-- However, Strong-equivalence-with k is closed under _on f when f is
-- an equivalence (assuming extensionality).
strong-equivalence-with-closed-under-on :
∀ {k a b r} {A : Type a} {B : Type b} {R : A → A → Type r} →
Extensionality (a ⊔ b) (lsuc r) →
(B≃A : B ≃ A) →
Strong-equivalence-with k R →
Strong-equivalence-with k (R on _≃_.to B≃A)
strong-equivalence-with-closed-under-on
{a = a} {b} {R = R} ext B≃A strong-equivalence {x} {y} =
R (f x) (f y) ↝⟨ strong-equivalence ⟩
R (f x) ≡ R (f y) ↔⟨⟩
(λ z → R (f x) z) ≡ (λ z → R (f y) z) ↔⟨ inverse $ Eq.extensionality-isomorphism
(lower-extensionality b lzero ext) ⟩
(∀ z → R (f x) z ≡ R (f y) z) ↔⟨ (Π-cong ext (inverse B≃A) λ z →
≡⇒≃ $ cong₂ _≡_ (lemma x z) (lemma y z)) ⟩
(∀ z → R (f x) (f z) ≡ R (f y) (f z)) ↔⟨ Eq.extensionality-isomorphism
(lower-extensionality a lzero ext) ⟩
(λ z → R (f x) (f z)) ≡ (λ z → R (f y) (f z)) ↔⟨⟩
(R on f) x ≡ (R on f) y □
where
f = _≃_.to B≃A
f⁻¹ = _≃_.from B≃A
lemma = λ x z →
R (f x) z ≡⟨ cong (R (f x)) $ sym $ _≃_.right-inverse-of B≃A _ ⟩∎
R (f x) (f (f⁻¹ z)) ∎
-- Various closure properties related to _×_ and _⊎_ fail to hold for
-- Strong-equivalence (assuming extensionality and univalence).
strong-equivalence-not-closed-under-×-or-⊎ :
Extensionality (# 0) (# 1) →
Univalence (# 0) →
∃ λ (A : Type) →
∃ λ (R₁ : A → A → Type) →
∃ λ (R₂ : A → A → Type) →
Strong-equivalence R₁ ×
Strong-equivalence R₂ ×
¬ Strong-equivalence (λ x y → R₁ x y × R₂ x y) ×
¬ Strong-equivalence (λ x y → R₁ x y ⊎ R₂ x y) ×
¬ Strong-equivalence (λ x y → R₁ (proj₁ x) (proj₁ y) ×
R₂ (proj₂ x) (proj₂ y)) ×
¬ Strong-equivalence (λ x y → R₁ (proj₁ x) (proj₁ y) ⊎
R₂ (proj₂ x) (proj₂ y))
strong-equivalence-not-closed-under-×-or-⊎ ext univ =
⊤ , R , R ,
strong-equivalence , strong-equivalence ,
not-strong-equivalence (Fin×Fin↔Fin* 2 2) ,
not-strong-equivalence (Fin⊎Fin↔Fin+ 2 2) ,
not-strong-equivalence′ (Fin×Fin↔Fin* 2 2) ,
not-strong-equivalence′ (Fin⊎Fin↔Fin+ 2 2)
where
R : ⊤ → ⊤ → Type
R = λ _ _ → Fin 2
strong-equivalence : Strong-equivalence R
strong-equivalence =
proj₁ $ proj₂ $ proj₂ $
strong-equivalence-that-is-neither-propositional-nor-≡ ext univ
not-strong-equivalence :
{B : Type} →
B ↔ Fin 4 →
¬ Strong-equivalence (λ (_ _ : ⊤) → B)
not-strong-equivalence {B} B↔Fin4 =
Strong-equivalence (λ _ _ → B) ↝⟨ (≡⇒↝ _ $ cong Strong-equivalence $ apply-ext ext λ _ → apply-ext ext λ _ →
≃⇒≡ univ $ Eq.↔⇒≃ B↔Fin4) ⟩
Strong-equivalence (λ _ _ → Fin 4) ↝⟨ const-Fin-strong-equivalence⇒≡! ext univ 4 ⟩
4 ≡ 4 ! ↝⟨ from-⊎ (4 Nat.≟ (4 !)) ⟩□
⊥ □
not-strong-equivalence′ :
{B : Type} →
B ↔ Fin 4 →
¬ Strong-equivalence (λ (_ _ : ⊤ × ⊤) → B)
not-strong-equivalence′ {B} B↔Fin4 =
Strong-equivalence (λ (_ _ : ⊤ × ⊤) → B) ↝⟨ (λ se {_ _} →
B ↝⟨ se {y = _} ⟩
const B ≡ const B ↝⟨ inverse $ Eq.extensionality-isomorphism ext ⟩
(⊤ × ⊤ → B ≡ B) ↝⟨ →-cong₁ ext ×-right-identity ⟩
(⊤ → B ≡ B) ↝⟨ Eq.extensionality-isomorphism ext ⟩□
const B ≡ const B □) ⟩
Strong-equivalence (λ (_ _ : ⊤) → B) ↝⟨ not-strong-equivalence B↔Fin4 ⟩□
⊥ □
-- Is the following a strong equivalence relation?
--
-- R (x , _) (y , _) = x ≡ y
--
-- (This is a combination of equality and the trivial relation, both
-- of which are strong equivalence relations.)
--
-- Answer: No, not in general (assuming extensionality and
-- univalence).
another-negative-result :
Extensionality (# 1) (# 2) →
Univalence (# 1) →
Univalence (# 0) →
∃ λ (A : Type₁) →
∃ λ (B : Type) →
¬ Strong-equivalence {A = A × B} (_≡_ on proj₁)
another-negative-result ext univ₁ univ₀ =
Type , Fin 2 , not-strong-equivalence
where
not-strong-equivalence : ¬ Strong-equivalence (_≡_ on proj₁)
not-strong-equivalence strong-equivalence = contradiction
where
4≡2 = _⇔_.to isomorphic-same-size (
Fin 4 ↝⟨ inverse $ [Fin→Fin]↔Fin^ (lower-extensionality _ _ ext) 2 2 ⟩
(Fin 2 → Fin 2) ↝⟨ →-cong (lower-extensionality _ _ ext) F.id $ inverse $
[Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ₀ 2 ⟩
(Fin 2 → Fin 2 ≡ Fin 2) ↔⟨ →-cong (lower-extensionality _ lzero ext) F.id $
equality-strong-equivalence ext univ₁ ⟩
(Fin 2 → (λ A → Fin 2 ≡ A) ≡ (λ A → Fin 2 ≡ A)) ↔⟨ →-cong (lower-extensionality _ lzero ext) F.id $ inverse $
Eq.extensionality-isomorphism ext ⟩
(Fin 2 → ∀ A → (Fin 2 ≡ A) ≡ (Fin 2 ≡ A)) ↝⟨ Π-comm ⟩
(∀ A → Fin 2 → (Fin 2 ≡ A) ≡ (Fin 2 ≡ A)) ↝⟨ inverse currying ⟩
(∀ A → (Fin 2 ≡ proj₁ A) ≡ (Fin 2 ≡ proj₁ A)) ↔⟨ Eq.extensionality-isomorphism ext ⟩
(λ A → Fin 2 ≡ proj₁ A) ≡ (λ A → Fin 2 ≡ proj₁ A) ↔⟨ inverse $ strong-equivalence {x = _ , fzero} {y = _ , fzero} ⟩
Fin 2 ≡ Fin 2 ↝⟨ [Fin≡Fin]↔Fin! (lower-extensionality _ _ ext) univ₀ 2 ⟩□
Fin 2 □)
contradiction : ⊥
contradiction = from-⊎ (4 Nat.≟ 2) 4≡2
------------------------------------------------------------------------
-- Quotients
-- Equivalence classes.
_is-equivalence-class-of_ :
∀ {a} {A : Type a} →
(A → Type a) → (A → A → Type a) → Type (lsuc (lsuc a))
_is-equivalence-class-of_ {a} P R =
∥ (∃ λ x → R x ≡ P) ∥ 1 (lsuc a)
-- Quotients.
infix 5 _/_
_/_ : ∀ {a} (A : Type a) → (A → A → Type a) → Type (lsuc (lsuc a))
A / R = ∃ λ (P : A → Type _) → P is-equivalence-class-of R
-- Quotienting with equality amounts to the same thing as not
-- quotienting at all (assuming extensionality and univalence).
/≡↔ :
∀ {a} {A : Type a} →
Extensionality (lsuc (lsuc a)) (lsuc a) →
Univalence a →
A / _≡_ ↔ A
/≡↔ {A = A} ext univ =
(∃ λ P → ∥ (∃ λ x → (x ≡_) ≡ P) ∥ 1 _) ↝⟨ (∃-cong λ _ → ∥∥↔ lzero ext irr) ⟩
(∃ λ P → ∃ λ x → (x ≡_) ≡ P) ↝⟨ ∃-comm ⟩
(∃ λ x → ∃ λ P → (x ≡_) ≡ P) ↝⟨ drop-⊤-right (λ _ → _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _) ⟩□
A □
where
se = equality-strong-equivalence
(lower-extensionality _ lzero ext) univ
se-refl :
∀ x → _≃_.to se (refl x) ≡ refl (x ≡_)
se-refl x = _≃_.from-to se (
sym (_≃_.to (≡⇒↝ _ (cong (_$ x) (refl (x ≡_)))) (sym (refl x))) ≡⟨ cong (λ p → sym (_≃_.to (≡⇒↝ _ p) (sym (refl x)))) $ cong-refl _ ⟩
sym (_≃_.to (≡⇒↝ _ (refl (x ≡ x))) (sym (refl x))) ≡⟨ cong (λ eq → sym (_≃_.to eq (sym (refl x)))) ≡⇒↝-refl ⟩
sym (sym (refl x)) ≡⟨ sym-sym _ ⟩∎
refl x ∎)
lemma :
{x y : A} (p : (x ≡_) ≡ (y ≡_)) →
cong _≡_ (subst (_$ x) p (refl x)) ≡ sym p
lemma {x = x} p =
cong _≡_ (subst (_$ x) p (refl x)) ≡⟨ cong (λ p → cong _≡_ (subst (_$ x) p (refl x))) $ sym $
_≃_.right-inverse-of se _ ⟩
cong _≡_ (subst (_$ x) (_≃_.to se (_≃_.from se p)) (refl x)) ≡⟨ D.elim (λ p → cong _≡_ (subst (_$ _) (_≃_.to se p) (refl _)) ≡
sym (_≃_.to se p))
(λ x →
cong _≡_ (subst (_$ x) (_≃_.to se (refl x)) (refl x)) ≡⟨ cong (λ p → cong _≡_ (subst (_$ x) p (refl x))) $ se-refl x ⟩
cong _≡_ (subst (_$ x) (refl (x ≡_)) (refl x)) ≡⟨ cong (cong _≡_) $ subst-refl _ _ ⟩
cong _≡_ (refl x) ≡⟨ cong-refl _ ⟩
refl (x ≡_ ) ≡⟨ sym sym-refl ⟩
sym (refl (x ≡_ )) ≡⟨ cong sym $ sym $ se-refl x ⟩∎
sym (_≃_.to se (refl x)) ∎)
(_≃_.from se p) ⟩
sym (_≃_.to se (_≃_.from se p)) ≡⟨ cong sym $ _≃_.right-inverse-of se _ ⟩∎
sym p ∎
irr : ∀ {P} (p q : ∃ λ x → (x ≡_) ≡ P) → p ≡ q
irr {P} (x , x≡≡) (y , y≡≡) =
Σ-≡,≡→≡
(_≃_.from se ((x ≡_) ≡⟨ x≡≡ ⟩
P ≡⟨ sym y≡≡ ⟩∎
(y ≡_) ∎))
(subst (λ x → (x ≡_) ≡ P)
(_≃_.from se (trans x≡≡ (sym y≡≡)))
x≡≡ ≡⟨⟩
subst (λ x → (x ≡_) ≡ P)
(sym $ _≃_.to (≡⇒↝ _ (cong (_$ x) (trans x≡≡ (sym y≡≡))))
(sym (refl x)))
x≡≡ ≡⟨ cong (λ eq → subst (λ x → (x ≡_) ≡ P) (sym eq) x≡≡) $ sym $
subst-in-terms-of-≡⇒↝ equivalence _ _ _ ⟩
subst (λ x → (x ≡_) ≡ P)
(sym $ subst (_$ x) (trans x≡≡ (sym y≡≡)) (sym (refl x)))
x≡≡ ≡⟨ cong (λ eq → subst (λ x → (x ≡_) ≡ P)
(sym (subst (_$ x) (trans x≡≡ (sym y≡≡)) eq)) _)
sym-refl ⟩
subst (λ x → (x ≡_) ≡ P)
(sym $ subst (_$ x) (trans x≡≡ (sym y≡≡)) (refl x))
x≡≡ ≡⟨ subst-∘ _ _ _ ⟩
subst (λ Q → Q ≡ P)
(cong _≡_ $
sym $ subst (_$ x) (trans x≡≡ (sym y≡≡)) (refl x))
x≡≡ ≡⟨ cong (λ eq → subst (λ Q → Q ≡ P) eq _) $ cong-sym _ _ ⟩
subst (λ Q → Q ≡ P)
(sym $ cong _≡_ $
subst (_$ x) (trans x≡≡ (sym y≡≡)) (refl x))
x≡≡ ≡⟨ subst-trans _ ⟩
trans (cong _≡_ $ subst (_$ x) (trans x≡≡ (sym y≡≡)) (refl x))
x≡≡ ≡⟨ cong (flip trans x≡≡) $ lemma _ ⟩
trans (sym (trans x≡≡ (sym y≡≡))) x≡≡ ≡⟨ cong (flip trans x≡≡) $ sym-trans _ _ ⟩
trans (trans (sym (sym y≡≡)) (sym x≡≡)) x≡≡ ≡⟨ trans-[trans-sym]- _ _ ⟩
sym (sym y≡≡) ≡⟨ sym-sym _ ⟩∎
y≡≡ ∎)
module _ {a} {A : Type a} {R : A → A → Type a} where
-- Equality characterisation lemmas for the quotient type.
equality-characterisation₁ :
Extensionality (lsuc (lsuc a)) (lsuc a) →
{x y : A / R} →
x ≡ y
↔
proj₁ x ≡ proj₁ y
equality-characterisation₁ ext {x} {y} =
x ≡ y ↝⟨ inverse Bij.Σ-≡,≡↔≡ ⟩
(∃ λ (eq : proj₁ x ≡ proj₁ y) →
subst (_is-equivalence-class-of R) eq (proj₂ x) ≡ proj₂ y) ↝⟨ (drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $
+⇒≡ $ truncation-has-correct-h-level 1 ext) ⟩□
proj₁ x ≡ proj₁ y □
equality-characterisation₂ :
Extensionality (lsuc (lsuc a)) (lsuc a) →
{x y : A / R} →
x ≡ y
↔
(∀ z → proj₁ x z ≡ proj₁ y z)
equality-characterisation₂ ext {x} {y} =
x ≡ y ↝⟨ equality-characterisation₁ ext ⟩
proj₁ x ≡ proj₁ y ↔⟨ inverse $ Eq.extensionality-isomorphism
(lower-extensionality _ lzero ext) ⟩□
(∀ z → proj₁ x z ≡ proj₁ y z) □
equality-characterisation₃ :
Extensionality (lsuc (lsuc a)) (lsuc a) →
Univalence a →
{x y : A / R} →
x ≡ y
↔
(∀ z → proj₁ x z ≃ proj₁ y z)
equality-characterisation₃ ext univ {x} {y} =
x ≡ y ↝⟨ equality-characterisation₂ ext ⟩
(∀ z → proj₁ x z ≡ proj₁ y z) ↔⟨ (∀-cong (lower-extensionality _ lzero ext) λ _ →
≡≃≃ univ) ⟩□
(∀ z → proj₁ x z ≃ proj₁ y z) □
-- Constructor for the quotient type.
[_] : A → A / R
[ a ] = R a , ∣ (a , refl (R a)) ∣₁
-- [_] is surjective (assuming extensionality).
[]-surjective :
Extensionality (lsuc (lsuc a)) (lsuc a) →
Surjective (lsuc a) [_]
[]-surjective ext (P , P-is-class) =
∥∥-map
1
(Σ-map
F.id
(λ {x} Rx≡P →
[ x ] ≡⟨ _↔_.from (equality-characterisation₁ ext) Rx≡P ⟩∎
(P , P-is-class) ∎))
P-is-class
-- If the relation is a family of types of h-level n, then the
-- equivalence classes are also families of types of h-level n
-- (assuming extensionality).
equivalence-classes-have-same-h-level-as-relation :
Extensionality a a →
∀ n →
(∀ x y → H-level n (R x y)) →
(x : A / R) → ∀ y → H-level n (proj₁ x y)
equivalence-classes-have-same-h-level-as-relation
ext n h (P , P-is-class) y =
Trunc.rec
1
(H-level-propositional ext n)
(λ { (z , Rz≡P) → H-level.respects-surjection
(≡⇒↝ _ (R z y ≡⟨ cong (_$ y) Rz≡P ⟩∎
P y ∎))
n
(h z y) })
(with-lower-level _ 1 P-is-class)
-- If R is a family of types of h-level n, then A / R has h-level
-- 1 + n (assuming extensionality and univalence).
quotient's-h-level-is-1-+-relation's-h-level :
Extensionality (lsuc (lsuc a)) (lsuc a) →
Univalence a →
Univalence (# 0) →
∀ n →
(∀ x y → H-level n (R x y)) →
H-level (1 + n) (A / R)
quotient's-h-level-is-1-+-relation's-h-level ext univ univ₀ = h′
where
lemma₁ :
∀ n →
(∀ x y z → H-level n (proj₁ x z ≡ proj₁ y z)) →
H-level (1 + n) (A / R)
lemma₁ n h = ≡↔+ _ _ λ x y → $⟨ h x y ⟩
(∀ z → H-level n (proj₁ x z ≡ proj₁ y z)) ↝⟨ Π-closure (lower-extensionality _ lzero ext) n ⟩
H-level n (∀ z → proj₁ x z ≡ proj₁ y z) ↝⟨ H-level.respects-surjection
(_↔_.surjection (inverse $ equality-characterisation₂ ext))
n ⟩□
H-level n (x ≡ y) □
lemma₂ :
∀ n →
(∀ x y → H-level (1 + n) (R x y)) →
∀ x y z → H-level (1 + n) (proj₁ x z ≡ proj₁ y z)
lemma₂ n h x _ z =
H-level-H-level-≡ˡ
(lower-extensionality _ _ ext) univ n
(equivalence-classes-have-same-h-level-as-relation
(lower-extensionality _ _ ext) (1 + n) h x z)
h′ : ∀ n →
(∀ x y → H-level n (R x y)) →
H-level (1 + n) (A / R)
h′ (suc n) h = lemma₁ (suc n) (lemma₂ n h)
h′ zero h =
lemma₁ zero λ x y z →
propositional⇒inhabited⇒contractible
(lemma₂ 0 (λ x y → mono₁ 0 (h x y)) x y z)
( $⟨ refl _ ⟩
⊤ ≡ ⊤ ↝⟨ ≡-preserves-≃ (lower-extensionality _ _ ext) univ₀ univ
(lemma₃ x z) (lemma₃ y z) ⟩
proj₁ x z ≡ proj₁ y z □)
where
lemma₃ : ∀ x z → ⊤ ≃ proj₁ x z
lemma₃ x z = $⟨ equivalence-classes-have-same-h-level-as-relation
(lower-extensionality _ _ ext)
0 h x z ⟩
Contractible (proj₁ x z) ↝⟨ _⇔_.to contractible⇔↔⊤ ⟩
proj₁ x z ↔ ⊤ ↝⟨ inverse ⟩
⊤ ↔ proj₁ x z ↝⟨ Eq.↔⇒≃ ⟩□
⊤ ≃ proj₁ x z □
-- If the relation is a strong equivalence relation with k, then it
-- is k-related to equality under [_] (assuming extensionality).
related↝[equal] :
∀ {k} →
Extensionality (lsuc (lsuc a)) (lsuc a) →
Strong-equivalence-with k R →
∀ {x y} → R x y ↝[ k ] [ x ] ≡ [ y ]
related↝[equal] ext strong-equivalence {x} {y} =
R x y ↝⟨ strong-equivalence ⟩
R x ≡ R y ↔⟨ inverse $ equality-characterisation₁ ext ⟩□
[ x ] ≡ [ y ] □
-- If the relation is a strong equivalence relation with a symmetric
-- kind k, then functions from quotients to sets are k-related to
-- relation-respecting functions (assuming extensionality).
/→set↝relation-respecting :
∀ {k} →
Extensionality (lsuc (lsuc a)) (lsuc (lsuc a)) →
Strong-equivalence-with ⌊ k ⌋-sym R →
{B : Type a} →
Is-set B →
(A / R → B)
↝[ ⌊ k ⌋-sym ]
∃ λ (f : A → B) → ∀ x y → R x y → f x ≡ f y
/→set↝relation-respecting {k} ext strong-equivalence {B = B} B-set =
((∃ λ P → ∥ (∃ λ x → R x ≡ P) ∥ 1 _) → B) ↔⟨ currying ⟩
(∀ P → ∥ (∃ λ x → R x ≡ P) ∥ 1 _ → B) ↔⟨ (∀-cong (lower-extensionality _ lzero ext) λ P → inverse $
constant-function≃∥inhabited∥⇒inhabited
lzero (lower-extensionality lzero _ ext) B-set) ⟩
(∀ P → ∃ λ (f : (∃ λ x → R x ≡ P) → B) → Constant f) ↔⟨ (∀-cong (lower-extensionality _ _ ext) λ _ →
Σ-cong currying λ _ → Bij.id) ⟩
(∀ P → ∃ λ (f : (x : A) → R x ≡ P → B) →
Constant (uncurry f)) ↔⟨ ΠΣ-comm ⟩
(∃ λ (f : ∀ P → (x : A) → R x ≡ P → B) →
∀ P → Constant (uncurry (f P))) ↝⟨ Σ-cong Π-comm (λ _ → F.id) ⟩
(∃ λ (f : (x : A) → ∀ P → R x ≡ P → B) →
∀ P → Constant (uncurry (flip f P))) ↝⟨ Σ-cong (∀-cong (lower-extensionality _ _ ext) λ _ →
inverse currying) (λ _ →
F.id) ⟩
(∃ λ (f : (x : A) → (∃ λ P → R x ≡ P) → B) →
∀ P → Constant (uncurry λ x eq → f x (P , eq))) ↝⟨ inverse $
Σ-cong (Bij.inverse $
∀-cong (lower-extensionality _ _ ext) λ _ →
drop-⊤-left-Π (lower-extensionality _ _ ext) $
_⇔_.to contractible⇔↔⊤ $
other-singleton-contractible _)
lemma ⟩□
(∃ λ (f : A → B) → ∀ x y → R x y → f x ≡ f y) □
where
lemma = λ f →
(∀ x y → R x y → f x ≡ f y) ↝⟨ (∀-cong (forget-ext? ⌊ k ⌋-sym $ lower-extensionality _ _ ext) λ x →
∀-cong (forget-ext? ⌊ k ⌋-sym $ lower-extensionality _ _ ext) λ y →
→-cong (forget-ext? ⌊ k ⌋-sym $ lower-extensionality _ _ ext)
strong-equivalence
F.id) ⟩
(∀ x y → R x ≡ R y → f x ≡ f y) ↔⟨ (∀-cong (lower-extensionality _ _ ext) λ _ →
∀-cong (lower-extensionality _ _ ext) λ _ →
→-cong (lower-extensionality _ _ ext)
(Groupoid.⁻¹-bijection (EG.groupoid _))
F.id) ⟩
(∀ x y → R y ≡ R x → f x ≡ f y) ↔⟨ (∀-cong (lower-extensionality _ _ ext) λ _ →
inverse currying) ⟩
(∀ x (q : ∃ λ y → R y ≡ R x) → f x ≡ f (proj₁ q)) ↔⟨ (∀-cong (lower-extensionality _ _ ext) λ _ →
inverse $ drop-⊤-left-Π {k = bijection} (lower-extensionality _ _ ext) $
_⇔_.to contractible⇔↔⊤ $
other-singleton-contractible _) ⟩
(∀ x (Q : ∃ λ P → R x ≡ P) (q : ∃ λ x → R x ≡ proj₁ Q) →
f x ≡ f (proj₁ q)) ↔⟨ (∀-cong (lower-extensionality _ _ ext) λ _ →
currying) ⟩
(∀ x P → R x ≡ P → (q : ∃ λ x → R x ≡ P) → f x ≡ f (proj₁ q)) ↔⟨ Π-comm ⟩
(∀ P x → R x ≡ P → (q : ∃ λ x → R x ≡ P) → f x ≡ f (proj₁ q)) ↔⟨ (∀-cong (lower-extensionality _ _ ext) λ _ →
inverse currying) ⟩
(∀ P (p q : ∃ λ x → R x ≡ P) → f (proj₁ p) ≡ f (proj₁ q)) ↔⟨⟩
(∀ P → Constant (uncurry λ x _ → f x)) ↔⟨ (∀-cong (lower-extensionality _ _ ext) λ _ →
≡⇒↝ bijection $ cong Constant $
apply-ext (lower-extensionality _ _ ext) λ _ →
sym $ subst-const _) ⟩□
(∀ P → Constant (uncurry λ x _ → subst (const B) _ (f x))) □
-- "Computation rule" for /→set↝relation-respecting.
proj₁-to-/→set↝relation-respecting :
∀ {k}
(ext : Extensionality (lsuc (lsuc a)) (lsuc (lsuc a)))
(strong-equivalence : Strong-equivalence-with ⌊ k ⌋-sym R)
{B : Type a}
(B-set : Is-set B)
(f : A / R → B) →
proj₁ (to-implication
(/→set↝relation-respecting ext strong-equivalence B-set) f)
≡
f ∘ [_]
proj₁-to-/→set↝relation-respecting ext eq {B} B-set f =
apply-ext (lower-extensionality _ _ ext) (lemma _ eq)
where
lemma :
∀ k (eq : Strong-equivalence-with ⌊ k ⌋-sym R) x →
proj₁
(to-implication (/→set↝relation-respecting ext eq B-set) f)
x
≡
f [ x ]
lemma logical-equivalence _ x =
subst (const B) (refl _) (f [ x ]) ≡⟨ subst-refl _ _ ⟩∎
f [ x ] ∎
lemma bijection _ x =
subst (const B) (refl _) (f [ x ]) ≡⟨ subst-refl _ _ ⟩∎
f [ x ] ∎
lemma equivalence _ x =
subst (const B) (refl _) (f [ x ]) ≡⟨ subst-refl _ _ ⟩∎
f [ x ] ∎
lemma equivalenceᴱ _ x =
subst (const B) (refl _) (f [ x ]) ≡⟨ subst-refl _ _ ⟩∎
f [ x ] ∎
-- Recursor (used to eliminate into sets). The recursor uses
-- extensionality and reflexivity.
rec :
Extensionality (lsuc (lsuc a)) (lsuc a) →
(∀ {x} → R x x) →
(B : Type a) →
Is-set B →
(f : A → B) →
(∀ {x y} → R x y → f x ≡ f y) →
A / R → B
rec ext refl B B-set f R⇒≡ (P , P-is-class) =
_≃_.to (constant-function≃∥inhabited∥⇒inhabited lzero ext B-set)
(f′ , f′-constant)
P-is-class
where
f′ : (∃ λ x → R x ≡ P) → B
f′ (x , _) = f x
f′-constant : Constant f′
f′-constant (x₁ , Rx₁≡P) (x₂ , Rx₂≡P) = R⇒≡ (
$⟨ refl ⟩
R x₂ x₂ ↝⟨ ≡⇒→ $ cong (λ Q → Q x₂) Rx₂≡P ⟩
P x₂ ↝⟨ ≡⇒→ $ cong (λ Q → Q x₂) $ sym Rx₁≡P ⟩□
R x₁ x₂ □)
private
-- The recursor's computation rule holds definitionally.
rec-[] :
(ext : Extensionality (lsuc (lsuc a)) (lsuc a))
(refl : ∀ {x} → R x x)
(B : Type a)
(B-set : Is-set B)
(f : A → B)
(R⇒≡ : ∀ {x y} → R x y → f x ≡ f y)
(x : A) →
rec ext refl B B-set f R⇒≡ [ x ] ≡ f x
rec-[] _ _ _ _ _ _ _ = refl _
-- Eliminator (used to eliminate into sets). The eliminator uses
-- extensionality, and the assumption that the relation is a "strong
-- equivalence relation with split surjections".
elim :
(ext : Extensionality (lsuc (lsuc a)) (lsuc a))
(strong-equivalence : Strong-equivalence-with surjection R)
(B : A / R → Type (lsuc a)) →
(∀ x → Is-set (B x)) →
(f : ∀ x → B [ x ]) →
(∀ {x y} (Rxy : R x y) →
subst B (_↠_.to (related↝[equal]
ext strong-equivalence) Rxy) (f x) ≡
f y) →
∀ x → B x
elim ext strong-equivalence B B-set f R⇒≡ (P , P-is-class) =
_≃_.to (constant-function≃∥inhabited∥⇒inhabited
lzero ext (B-set _))
(f′ , f′-constant)
P-is-class
where
f′ : (∃ λ x → R x ≡ P) → B (P , P-is-class)
f′ (x , Rx≡P) =
subst B
(_↔_.from (equality-characterisation₁ ext) Rx≡P)
(f x)
f′-constant : Constant f′
f′-constant (x , Rx≡P) (y , Ry≡P) =
subst B
(_↔_.from (equality-characterisation₁ ext) Rx≡P)
(f x) ≡⟨ cong (subst _ _) $ sym $ R⇒≡ _ ⟩
subst B
(_↔_.from (equality-characterisation₁ ext) Rx≡P)
(subst B (_↠_.to (related↝[equal]
ext strong-equivalence) lemma₁)
(f y)) ≡⟨ subst-subst _ _ _ _ ⟩
subst B
(trans (_↠_.to (related↝[equal]
ext strong-equivalence) lemma₁)
(_↔_.from (equality-characterisation₁ ext) Rx≡P))
(f y) ≡⟨ cong (λ eq → subst B eq _) lemma₄ ⟩∎
subst B
(_↔_.from (equality-characterisation₁ ext) Ry≡P)
(f y) ∎
where
lemma₁ = _↠_.from strong-equivalence (
R y ≡⟨ Ry≡P ⟩
P ≡⟨ sym Rx≡P ⟩∎
R x ∎)
lemma₂ = λ x →
_↔_.to (equality-characterisation₁ ext) (refl x) ≡⟨⟩
proj₁ (Σ-≡,≡←≡ (refl x)) ≡⟨ proj₁-Σ-≡,≡←≡ _ ⟩
cong proj₁ (refl x) ≡⟨ cong-refl _ ⟩∎
refl (proj₁ x) ∎
lemma₃ =
trans (_↠_.to strong-equivalence lemma₁) Rx≡P ≡⟨⟩
trans (_↠_.to strong-equivalence
(_↠_.from strong-equivalence (trans Ry≡P (sym Rx≡P))))
Rx≡P ≡⟨ cong (flip trans _) $ _↠_.right-inverse-of strong-equivalence _ ⟩
trans (trans Ry≡P (sym Rx≡P)) Rx≡P ≡⟨ trans-[trans-sym]- _ _ ⟩∎
Ry≡P ∎
lemma₄ =
trans (_↠_.to (related↝[equal] ext strong-equivalence) lemma₁)
(_↔_.from (equality-characterisation₁ ext) Rx≡P) ≡⟨⟩
trans (_↔_.from (equality-characterisation₁ ext)
(_↠_.to strong-equivalence lemma₁))
(_↔_.from (equality-characterisation₁ ext) Rx≡P) ≡⟨ Bij.trans-to-to≡to-trans
(λ _ _ → inverse $ equality-characterisation₁ ext)
lemma₂ ⟩
_↔_.from (equality-characterisation₁ ext)
(trans (_↠_.to strong-equivalence lemma₁) Rx≡P) ≡⟨ cong (_↔_.from (equality-characterisation₁ ext)) lemma₃ ⟩∎
_↔_.from (equality-characterisation₁ ext) Ry≡P ∎
-- A variant of elim that can be used if the motive composed with
-- [_] is a family of propositions.
--
-- I took the idea for this eliminator from Nicolai Kraus.
elim-Prop :
(ext : Extensionality (lsuc (lsuc a)) (lsuc a))
(strong-equivalence : Strong-equivalence-with surjection R)
(B : A / R → Type (lsuc a)) →
(∀ x → Is-proposition (B [ x ])) →
(f : ∀ x → B [ x ]) →
∀ x → B x
elim-Prop ext strong-equivalence B B-prop f x = elim
ext
strong-equivalence
B
(elim
ext
strong-equivalence
_
(λ _ → mono₁ 1 $ H-level-propositional ext′ 2)
(mono₁ 1 ∘ B-prop)
(λ _ → H-level-propositional ext′ 2 _ _))
f
(λ _ → B-prop _ _ _)
x
where
ext′ = lower-extensionality _ lzero ext
------------------------------------------------------------------------
-- An example
module ⊤/2 where
-- What happens if we quotient the unit type by the "binary-valued
-- trivial relation"?
⊤/2 : Type₂
⊤/2 = ⊤ / λ _ _ → Fin 2
-- The type is not a set (assuming extensionality and univalence).
not-a-set :
Extensionality (# 2) (# 1) →
Univalence (# 0) →
¬ Is-set ⊤/2
not-a-set ext univ =
Is-set ⊤/2 ↝⟨ _⇔_.from (≡↔+ 1 _) ⟩
((x y : ⊤/2) → Is-proposition (x ≡ y)) ↝⟨ (λ prop → prop _ _) ⟩
Is-proposition ([ tt ] ≡ [ tt ]) ↝⟨ H-level.respects-surjection
(_≃_.surjection $ inverse $
related↝[equal] ext
(const-Fin-2-strong-equivalence
(lower-extensionality _ lzero ext) univ))
1 ⟩
Is-proposition (Fin 2) ↝⟨ H-level.respects-surjection (_↔_.surjection $ inverse Bool↔Fin2) 1 ⟩
Is-proposition Bool ↝⟨ ¬-Bool-propositional ⟩□
⊥ □
-- The type is a groupoid (assuming extensionality and univalence).
is-groupoid :
Extensionality (# 2) (# 1) →
Univalence (# 0) →
H-level 3 ⊤/2
is-groupoid ext univ =
quotient's-h-level-is-1-+-relation's-h-level
ext univ univ 2 (λ _ _ → Fin-set 2)
-- Every value in the quotient is merely equal to [ tt ] (assuming
-- extensionality).
∥≡[tt]∥ :
Extensionality (# 2) (# 1) →
(x : ⊤/2) → ∥ x ≡ [ tt ] ∥ 1 (# 1)
∥≡[tt]∥ ext x = $⟨ []-surjective ext x ⟩
∥ ⊤ × [ tt ] ≡ x ∥ 1 _ ↝⟨ ∥∥-map 1 (sym ∘ proj₂) ⟩□
∥ x ≡ [ tt ] ∥ 1 _ □
-- The type is merely single-valued (assuming extensionality and a
-- resizing function for the propositional truncation).
merely-single-valued :
Extensionality (# 2) (# 2) →
({A : Type₂} → ∥ A ∥ 1 (# 1) → ∥ A ∥ 1 (# 2)) →
(x y : ⊤/2) → ∥ x ≡ y ∥ 1 (# 1)
merely-single-valued ext resize x y =
Trunc.rec
1
(truncation-has-correct-h-level 1 ext)
(λ x≡[tt] → ∥∥-map 1
(λ y≡[tt] → x ≡⟨ x≡[tt] ⟩
[ tt ] ≡⟨ sym y≡[tt] ⟩∎
y ∎)
(∥≡[tt]∥ ext′ y))
(resize (∥≡[tt]∥ ext′ x))
where
ext′ = lower-extensionality lzero _ ext
-- Every instance of the type's equality type is merely isomorphic
-- to Fin 2 (assuming extensionality, univalence, and a resizing
-- function for the propositional truncation).
∥≡↔2∥ :
Extensionality (# 2) (# 2) →
Univalence (# 0) →
({A : Type₂} → ∥ A ∥ 1 (# 1) → ∥ A ∥ 1 (# 2)) →
(x y : ⊤/2) → ∥ x ≡ y ↔ Fin 2 ∥ 1 (# 1)
∥≡↔2∥ ext univ resize x y =
Trunc.rec
1
(truncation-has-correct-h-level 1 ext)
(λ x≡[tt] →
∥∥-map
1
(λ y≡[tt] →
x ≡ y ↝⟨ ≡⇒↝ _ $ cong₂ _≡_ x≡[tt] y≡[tt] ⟩
[ tt ] ≡ [ tt ] ↔⟨ inverse $
related↝[equal]
(lower-extensionality lzero _ ext)
(const-Fin-2-strong-equivalence
(lower-extensionality _ _ ext) univ) ⟩□
Fin 2 □)
(∥≡[tt]∥ (lower-extensionality lzero _ ext) y))
(resize (∥≡[tt]∥ (lower-extensionality lzero _ ext) x))
| {
"alphanum_fraction": 0.4427044993,
"avg_line_length": 42.491943128,
"ext": "agda",
"hexsha": "7480f8306545c6c35c433fba620065e70e85e582",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Quotient/Families-of-equivalence-classes.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Quotient/Families-of-equivalence-classes.agda",
"max_line_length": 145,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Quotient/Families-of-equivalence-classes.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 14629,
"size": 44829
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Consequences.Injectivity where
open import Definition.Untyped hiding (wk)
import Definition.Untyped as U
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Weakening
open import Definition.Typed.Properties
open import Definition.Typed.EqRelInstance
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Fundamental.Reducibility
open import Tools.Embedding
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Helper function of injectivity for specific reducible Π-types
injectivity′ : ∀ {F G H E Γ l}
([ΠFG] : Γ ⊩⟨ l ⟩Π Π F ▹ G)
→ Γ ⊩⟨ l ⟩ Π F ▹ G ≡ Π H ▹ E / Π-intr [ΠFG]
→ Γ ⊢ F ≡ H
× Γ ∙ F ⊢ G ≡ E
injectivity′ (noemb (Πᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext))
(Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) =
let F≡F₁ , G≡G₁ = Π-PE-injectivity (whnfRed* (red D) Πₙ)
H≡F′ , E≡G′ = Π-PE-injectivity (whnfRed* D′ Πₙ)
⊢Γ = wf ⊢F
[F]₁ = [F] id ⊢Γ
[F]′ = irrelevance′ (PE.trans (wk-id _) (PE.sym F≡F₁)) [F]₁
[x∷F] = neuTerm ([F] (step id) (⊢Γ ∙ ⊢F)) (var 0) (var (⊢Γ ∙ ⊢F) here)
(refl (var (⊢Γ ∙ ⊢F) here))
[G]₁ = [G] (step id) (⊢Γ ∙ ⊢F) [x∷F]
[G]′ = PE.subst₂ (λ x y → _ ∙ y ⊩⟨ _ ⟩ x)
(PE.trans (wkSingleSubstId _) (PE.sym G≡G₁))
(PE.sym F≡F₁) [G]₁
[F≡H]₁ = [F≡F′] id ⊢Γ
[F≡H]′ = irrelevanceEq″ (PE.trans (wk-id _) (PE.sym F≡F₁))
(PE.trans (wk-id _) (PE.sym H≡F′))
[F]₁ [F]′ [F≡H]₁
[G≡E]₁ = [G≡G′] (step id) (⊢Γ ∙ ⊢F) [x∷F]
[G≡E]′ = irrelevanceEqLift″ (PE.trans (wkSingleSubstId _) (PE.sym G≡G₁))
(PE.trans (wkSingleSubstId _) (PE.sym E≡G′))
(PE.sym F≡F₁) [G]₁ [G]′ [G≡E]₁
in escapeEq [F]′ [F≡H]′ , escapeEq [G]′ [G≡E]′
injectivity′ (emb 0<1 x) (ιx [ΠFG≡ΠHE]) = injectivity′ x [ΠFG≡ΠHE]
-- Injectivity of Π
injectivity : ∀ {Γ F G H E} → Γ ⊢ Π F ▹ G ≡ Π H ▹ E → Γ ⊢ F ≡ H × Γ ∙ F ⊢ G ≡ E
injectivity ⊢ΠFG≡ΠHE =
let [ΠFG] , _ , [ΠFG≡ΠHE] = reducibleEq ⊢ΠFG≡ΠHE
in injectivity′ (Π-elim [ΠFG])
(irrelevanceEq [ΠFG] (Π-intr (Π-elim [ΠFG])) [ΠFG≡ΠHE])
| {
"alphanum_fraction": 0.5482315113,
"avg_line_length": 41.4666666667,
"ext": "agda",
"hexsha": "3bf0080bcd721d7852b941ef0935469149dfbac5",
"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": "Definition/Typed/Consequences/Injectivity.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": "Definition/Typed/Consequences/Injectivity.agda",
"max_line_length": 79,
"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": "Definition/Typed/Consequences/Injectivity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1030,
"size": 2488
} |
import Relation.Binary.PropositionalEquality as PEq
module Relation.Binary.PropositionalEquality.Extensionality
(funext : ∀ {ℓ₁ ℓ₂} → PEq.Extensionality ℓ₁ ℓ₂) where
funext² : ∀ {p q r}{P : Set p}{Q : P → Set q}
{R : (p : P) → Q p → Set r} →
{f g : ∀ (p : P)(q : Q p) → R p q} → (∀ p q → f p q PEq.≡ g p q) →
f PEq.≡ g
funext² f = funext λ p → funext λ q → f p q
funext³ : ∀ {p q r s}{P : Set p}{Q : P → Set q}
{R : (p : P) → Q p → Set r}{S : (p : P)(q : Q p) → R p q → Set s} →
{f g : ∀ (p : P)(q : Q p)(r : R p q) → S p q r} → (∀ p q r → f p q r PEq.≡ g p q r) →
f PEq.≡ g
funext³ f = funext λ p → funext λ q → funext λ r → f p q r
| {
"alphanum_fraction": 0.4771428571,
"avg_line_length": 38.8888888889,
"ext": "agda",
"hexsha": "7148ddb0ea100b95938a4a3148178007d8a06116",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Relation/Binary/PropositionalEquality/Extensionality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Relation/Binary/PropositionalEquality/Extensionality.agda",
"max_line_length": 95,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Relation/Binary/PropositionalEquality/Extensionality.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 304,
"size": 700
} |
{-# OPTIONS --prop --without-K --rewriting #-}
module Data.Nat.Log2 where
open import Data.Nat
open import Data.Nat.Properties
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl)
open import Agda.Builtin.Equality.Rewrite
private
aux : (P : ℕ → Set) → P zero → P (suc zero) → ((n : ℕ) → P ⌈ suc (suc n) /2⌉ → P (suc (suc n))) →
(n : ℕ) → (m : ℕ) → m ≤ n → P m
aux P bc₀ bc₁ is n zero h = bc₀
aux P bc₀ bc₁ is n (suc zero) h = bc₁
aux P bc₀ bc₁ is (suc (suc n)) (suc (suc m)) (s≤s (s≤s h)) =
is m (aux P bc₀ bc₁ is (suc n) ⌈ suc (suc m) /2⌉ (s≤s (≤-trans (⌈n/2⌉≤n m) h)))
strong-induction : (P : ℕ → Set) → P zero → P (suc zero) → ((n : ℕ) → P ⌈ suc (suc n) /2⌉ → P (suc (suc n))) → (n : ℕ) → P n
strong-induction P bc₀ bc₁ is n = aux P bc₀ bc₁ is n n ≤-refl
strong-induction/is : ∀ {P bc₀ bc₁ is n} →
aux P bc₀ bc₁ is (suc n) ⌈ suc (suc n) /2⌉ (s≤s (≤-trans (⌈n/2⌉≤n n) ≤-refl)) ≡
strong-induction P bc₀ bc₁ is ⌈ suc (suc n) /2⌉
strong-induction/is {P} {bc₀} {bc₁} {is} {n} = aux/unique
where
aux/unique : ∀ {m n₁ n₂ h₁ h₂} → aux P bc₀ bc₁ is n₁ m h₁ ≡ aux P bc₀ bc₁ is n₂ m h₂
aux/unique {zero} = refl
aux/unique {suc zero} = refl
aux/unique {suc (suc m)} {h₁ = s≤s (s≤s h₁)} {h₂ = s≤s (s≤s h₂)} = Eq.cong (is m) aux/unique
{-# REWRITE strong-induction/is #-}
⌈log₂_⌉ : ℕ → ℕ
⌈log₂_⌉ = strong-induction (λ _ → ℕ) zero zero (λ _ → suc)
log₂-mono : ⌈log₂_⌉ Preserves _≤_ ⟶ _≤_
log₂-mono {n₁} {n₂} =
strong-induction (λ n₁ → ∀ n₂ → n₁ ≤ n₂ → ⌈log₂ n₁ ⌉ ≤ ⌈log₂ n₂ ⌉)
(λ _ _ → z≤n)
(λ _ _ → z≤n)
(λ { n₁ ih (suc (suc n₂)) (s≤s (s≤s h)) → s≤s (ih ⌈ suc (suc n₂) /2⌉ (⌈n/2⌉-mono (s≤s (s≤s h))))})
n₁
n₂
⌈log₂n⌉≤n : ∀ n → ⌈log₂ n ⌉ ≤ n
⌈log₂n⌉≤n n = strong-induction' n n ≤-refl
where
strong-induction' : (n m : ℕ) → m ≤ n → ⌈log₂ m ⌉ ≤ m
strong-induction' n zero h = z≤n
strong-induction' n (suc zero) h = z≤n
strong-induction' (suc (suc n)) (suc (suc m)) (s≤s (s≤s h)) =
s≤s (
let open ≤-Reasoning in
begin
⌈log₂ suc ⌈ m /2⌉ ⌉
≤⟨ strong-induction' (suc n) (suc ⌈ m /2⌉) (s≤s (≤-trans (⌈n/2⌉≤n m) h)) ⟩
suc ⌈ m /2⌉
≤⟨ s≤s (⌈n/2⌉≤n m) ⟩
suc m
∎
)
log₂-suc : ∀ n {k} → ⌈log₂ n ⌉ ≤ suc k → ⌈log₂ ⌈ n /2⌉ ⌉ ≤ k
log₂-suc zero h = z≤n
log₂-suc (suc zero) h = z≤n
log₂-suc (suc (suc n)) (s≤s h) = h
⌈log₂n⌉≡0⇒n≤1 : {n : ℕ} → ⌈log₂ n ⌉ ≡ 0 → n ≤ 1
⌈log₂n⌉≡0⇒n≤1 {zero} refl = z≤n
⌈log₂n⌉≡0⇒n≤1 {suc zero} refl = s≤s z≤n
| {
"alphanum_fraction": 0.5296875,
"avg_line_length": 34.5945945946,
"ext": "agda",
"hexsha": "e954d0d6a9d9c1d8c55914591975b8c9bcd12233",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z",
"max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "jonsterling/agda-calf",
"max_forks_repo_path": "src/Data/Nat/Log2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "jonsterling/agda-calf",
"max_issues_repo_path": "src/Data/Nat/Log2.agda",
"max_line_length": 124,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "jonsterling/agda-calf",
"max_stars_repo_path": "src/Data/Nat/Log2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z",
"num_tokens": 1349,
"size": 2560
} |
import Lvl
module Structure.Category.Dual {ℓₒ ℓₘ ℓₑ : Lvl.Level} where
open import Data.Tuple as Tuple using ()
open import Functional using (swap)
open import Structure.Category
open import Structure.Categorical.Names
open import Structure.Categorical.Properties
import Structure.Operator.Properties as Properties
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Structure.Setoid
open import Type
module _
{Obj : Type{ℓₒ}}
{Morphism : Obj → Obj → Type{ℓₘ}}
⦃ morphism-equiv : ∀{x y} → Equiv{ℓₑ}(Morphism x y) ⦄
(cat : Category(Morphism))
where
open Category.ArrowNotation(cat)
open Category(cat)
private open module MorphismEquiv {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv{x}{y} ⦄) using ()
-- The opposite/dual category of a category.
dualCategory : Category(_⟵_)
Category._∘_ dualCategory = swap(_∘_)
Category.id dualCategory = id
BinaryOperator.congruence (Category.binaryOperator dualCategory) p₁ p₂ = congruence₂(_∘_) p₂ p₁
Morphism.Associativity.proof (Category.associativity dualCategory) = symmetry(_≡_) (Morphism.associativity(_∘_))
Morphism.Identityₗ.proof (Tuple.left (Category.identity dualCategory)) = Morphism.identity-right(_∘_)(id)
Morphism.Identityᵣ.proof (Tuple.right (Category.identity dualCategory)) = Morphism.identity-left (_∘_)(id)
dual : CategoryObject{ℓₒ}{ℓₘ} → CategoryObject{ℓₒ}{ℓₘ}
dual(intro cat) = intro(dualCategory cat)
| {
"alphanum_fraction": 0.7416612165,
"avg_line_length": 39.2051282051,
"ext": "agda",
"hexsha": "751aee5dec7c6bf3f0583b00d7816aa8b2030d99",
"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/Category/Dual.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/Category/Dual.agda",
"max_line_length": 125,
"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/Category/Dual.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": 443,
"size": 1529
} |
module RecordsAndModules where
module Setoids where
record Equiv (a : Set) : Set where
field
x : a
y : a
record Setoid : Set1 where
field
carrier : Set
equiv : Equiv carrier
module RegExps (S : Setoids.Setoid) where
data RegExp : Set where
ε : RegExp
module SimpleMatcher (S : Setoids.Setoid) where
open module R = RegExps S
foo : RegExp -> RegExp
foo ε = ε
| {
"alphanum_fraction": 0.6354916067,
"avg_line_length": 15.4444444444,
"ext": "agda",
"hexsha": "7e6d83d417565c829e536329132de30f3620f901",
"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/RecordsAndModules.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/RecordsAndModules.agda",
"max_line_length": 47,
"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/RecordsAndModules.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": 125,
"size": 417
} |
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- The values of terms in Nehemiah.Change.Term.
------------------------------------------------------------------------
module Nehemiah.Change.Value where
open import Nehemiah.Syntax.Type
open import Nehemiah.Syntax.Term
open import Nehemiah.Denotation.Value
open import Data.Integer
open import Structure.Bag.Nehemiah
import Parametric.Change.Value Const ⟦_⟧Base ΔBase as ChangeValue
⟦apply-base⟧ : ChangeValue.ApplyStructure
⟦apply-base⟧ base-int n Δn = n + Δn
⟦apply-base⟧ base-bag b Δb = b ++ Δb
⟦diff-base⟧ : ChangeValue.DiffStructure
⟦diff-base⟧ base-int m n = m - n
⟦diff-base⟧ base-bag a b = a \\ b
⟦nil-base⟧ : ChangeValue.NilStructure
⟦nil-base⟧ base-int n = + 0
⟦nil-base⟧ base-bag b = emptyBag
open ChangeValue.Structure ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧ public
| {
"alphanum_fraction": 0.6209223847,
"avg_line_length": 28.6774193548,
"ext": "agda",
"hexsha": "f15f47633e97fd814b617d3eef424e930384bd60",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Nehemiah/Change/Value.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Nehemiah/Change/Value.agda",
"max_line_length": 72,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Nehemiah/Change/Value.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 246,
"size": 889
} |
module Data.QuadTree.Implementation.Functors where
open import Haskell.Prelude renaming (zero to Z; suc to S)
open import Data.Lens.Lens
open import Data.Logic
open import Data.QuadTree.Implementation.Definition
open import Data.QuadTree.Implementation.ValidTypes
open import Data.QuadTree.Implementation.QuadrantLenses
{-# FOREIGN AGDA2HS
{-# LANGUAGE Safe #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE Rank2Types #-}
import Data.Nat
import Data.Lens.Lens
import Data.Logic
import Data.QuadTree.Implementation.Definition
import Data.QuadTree.Implementation.ValidTypes
import Data.QuadTree.Implementation.QuadrantLenses
#-}
record FunctorEq (f : (y : Set) -> {{ eqT : Eq y }} -> Set) : Set₁ where
field
fmapₑ : {a b : Set} -> {{ eqA : Eq a }} {{ eqB : Eq b }} -> (a → b) → f a → f b
open FunctorEq public
{-# COMPILE AGDA2HS FunctorEq class #-}
quadrantFunctor : (dep : Nat) -> FunctorEq (λ y -> VQuadrant y {dep})
quadrantFunctor dep .fmapₑ fn (CVQuadrant (Leaf v) {p}) = (CVQuadrant (Leaf $ fn v) {p})
quadrantFunctor (S dep) .fmapₑ fn (CVQuadrant (Node a b c d) {p}) =
(combine (fmapₑ (quadrantFunctor dep) fn sA) (fmapₑ (quadrantFunctor dep) fn sB) (fmapₑ (quadrantFunctor dep) fn sC) (fmapₑ (quadrantFunctor dep) fn sD)) where
sA = CVQuadrant a {aSub a b c d p}
sB = CVQuadrant b {bSub a b c d p}
sC = CVQuadrant c {cSub a b c d p}
sD = CVQuadrant d {dSub a b c d p}
toQt : {b : Set} -> {{ eqB : Eq b }}
-> (dep w h : Nat) .(q : IsTrue (dep == log2up (if w < h then h else w))) -> VQuadrant b {dep} -> VQuadTree b {dep}
toQt dep w h q (CVQuadrant qd {p}) = CVQuadTree (Wrapper (w , h) qd) {p} {q}
quadtreeFunctor : (dep : Nat) -> FunctorEq (λ y -> VQuadTree y {dep})
quadtreeFunctor dep .fmapₑ {a} {b} fn (CVQuadTree (Wrapper (w , h) qd) {p} {q}) =
toQt dep w h q (fmapₑ (quadrantFunctor dep) fn (CVQuadrant qd {p}))
| {
"alphanum_fraction": 0.6776636019,
"avg_line_length": 42.0227272727,
"ext": "agda",
"hexsha": "9422d539f65900ca6742df7d1c0fdac09448644d",
"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": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "JonathanBrouwer/research-project",
"max_forks_repo_path": "src/Data/QuadTree/Implementation/Functors.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f",
"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": "JonathanBrouwer/research-project",
"max_issues_repo_path": "src/Data/QuadTree/Implementation/Functors.agda",
"max_line_length": 161,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "JonathanBrouwer/research-project",
"max_stars_repo_path": "src/Data/QuadTree/Implementation/Functors.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z",
"num_tokens": 663,
"size": 1849
} |
module Issue978 where
module A where
infixr 4 _,_
record _×_ (A B : Set) : Set where
constructor _,_
field
fst : A
snd : B
module B where
infixl 2 _,_
data Ty : Set where
data Cxt : Set where
ε : Cxt
_,_ : (Γ : Cxt) (a : Ty) → Cxt
open A
open B
test : (Γ : Cxt) → Set₁
test ε = Set
test (ε , a) = ?
test (Γ , a , a₁) = ?
| {
"alphanum_fraction": 0.5324324324,
"avg_line_length": 12.3333333333,
"ext": "agda",
"hexsha": "e1800fe98b80e3b19118f52d81d5fd60ce18dbc3",
"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/Issue978.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/Issue978.agda",
"max_line_length": 36,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue978.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": 145,
"size": 370
} |
{-
Setting an unknown signal can only shrink Can.
canₖ-set-sig-monotonic : ∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
∀ k →
k ∈ Canₖ p (Env.set-sig {S} θ S∈ status) →
k ∈ Canₖ p θ
(And its counterpart for Canₛ and Canₛₕ.)
There are also corresponding Canθ versions: Setting a signal that
is immediately shadowed by the inner environment does not change
the result; setting a signal not in the inner environment can only
shrink Canθ.
canθ-set-sig-irr : ∀ sigs S'' →
∀ p S θ S∈ status →
Signal.unwrap S ∈ map (_+_ S'') (SigMap.keys sigs) →
Canθ sigs S'' p θ ≡ Canθ sigs S'' p (Env.set-sig {S} θ S∈ status)
canθₖ-set-sig-monotonic : ∀ sigs S'' →
∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
Signal.unwrap S ∉ map (_+_ S'') (SigMap.keys sigs) →
∀ k →
k ∈ Canθₖ sigs S'' p (Env.set-sig {S} θ S∈ status) →
k ∈ Canθₖ sigs S'' p θ
For convenient reasoning of Canθ, we have a wrapper around canθ?-set-sig-monotonic
lemmas: changing some unknowns to present or absent in the new signals (sigs) will
only make the result smaller.
canθₖ-add-sig-monotonic : ∀ sigs S'' p θ S status →
∀ k →
k ∈ Canθₖ sigs S'' p (θ ← Θ SigMap.[ S ↦ status ] VarMap.empty ShrMap.empty) →
k ∈ Canθₖ sigs S'' p (θ ← [S]-env S)
A similar lemma for Canθ also holds, with some proper add-sig-monotonic constriant
on the continuation. Specifically, this holds for using Canθ as the continuation.
canθ'ₛ-add-sig-monotonic : ∀ sigs S'' κ θ S status →
(∀ θ S status S' →
S' ∈ proj₁ (κ (θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) →
S' ∈ proj₁ (κ (θ ← [S]-env S))) →
∀ S' →
S' ∈ proj₁ (Canθ' sigs S'' κ (θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) →
S' ∈ proj₁ (Canθ' sigs S'' κ (θ ← [S]-env S))
canθ'ₛ-canθ-add-sig-monotonic : ∀ sigs S sigs' S' p θ S''' status →
∀ S'' →
S'' ∈ proj₁ (Canθ' sigs S (Canθ sigs' S' p)
(θ ← Θ SigMap.[ S''' ↦ status ] ShrMap.empty VarMap.empty)) →
S'' ∈ proj₁ (Canθ' sigs S (Canθ sigs' S' p)
(θ ← [S]-env S'''))
-}
module Esterel.Lang.CanFunction.SetSigMonotonic where
open import utility
open import Esterel.Lang
-- Note: the dependency is weird here; SetSigMonotonic should be basic
-- and cannot import Base. Instead, Base relies on SetSigMonotonic.
open import Esterel.Lang.CanFunction
open import Esterel.Context
open import Esterel.Environment as Env
using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap)
open import Esterel.CompletionCode as Code
using () renaming (CompletionCode to Code)
open import Esterel.Variable.Signal as Signal
using (Signal ; _ₛ) renaming (unwrap to _ˢ)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar ; _ₛₕ) renaming (unwrap to _ˢʰ)
open import Esterel.Variable.Sequential as SeqVar
using (SeqVar ; _ᵥ) renaming (unwrap to _ᵛ)
open import Data.Bool
using (Bool ; true ; false ; if_then_else_)
open import Data.Empty
using (⊥ ; ⊥-elim)
open import Data.List
using (List ; [] ; _∷_ ; _++_ ; map)
open import Data.List.Properties
using (map-id ; map-compose ; map-cong)
open import Data.List.Any
using (Any ; any ; here ; there)
open import Data.List.Any.Properties
using (++⁻)
renaming (++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ)
open import Data.Nat
using (ℕ ; zero ; suc ; _≟_ ; _+_)
open import Data.Nat.Properties.Simple
using (+-comm)
open import Data.Maybe
using (Maybe ; just ; nothing)
open import Data.Product
using (Σ ; proj₁ ; proj₂ ; ∃ ; _,_ ; _,′_ ; _×_)
open import Data.Sum
using (_⊎_ ; inj₁ ; inj₂)
open import Function
using (_∘_ ; id ; _∋_)
open import Relation.Nullary
using (¬_ ; Dec ; yes ; no)
open import Relation.Nullary.Decidable
using (⌊_⌋)
open import Relation.Binary.PropositionalEquality
using (_≡_ ; refl ; trans ; sym ; cong ; subst ; inspect ; [_] ; Reveal_·_is_
; module ≡-Reasoning)
open ListSet Data.Nat._≟_
using (set-subtract ; set-subtract-[] ; set-subtract-merge ; set-subtract-split ;
set-remove ; set-remove-removed ; set-remove-mono-∈ ; set-remove-not-removed ;
set-subtract-[a]≡set-remove)
open ≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎)
open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM
open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM
open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM
canₖ-set-sig-monotonic : ∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
∀ k →
k ∈ Canₖ p (Env.set-sig {S} θ S∈ status) →
k ∈ Canₖ p θ
canₛ-set-sig-monotonic : ∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
∀ S'' →
S'' ∈ Canₛ p (Env.set-sig {S} θ S∈ status) →
S'' ∈ Canₛ p θ
canₛₕ-set-sig-monotonic : ∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
∀ s →
s ∈ Canₛₕ p (Env.set-sig {S} θ S∈ status) →
s ∈ Canₛₕ p θ
canθ-set-sig-irr : ∀ sigs S'' →
∀ p S θ S∈ status →
Signal.unwrap S ∈ map (_+_ S'') (SigMap.keys sigs) →
Canθ sigs S'' p θ ≡ Canθ sigs S'' p (Env.set-sig {S} θ S∈ status)
canθₖ-set-sig-monotonic : ∀ sigs S'' →
∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
Signal.unwrap S ∉ map (_+_ S'') (SigMap.keys sigs) →
∀ k →
k ∈ Canθₖ sigs S'' p (Env.set-sig {S} θ S∈ status) →
k ∈ Canθₖ sigs S'' p θ
canθₛ-set-sig-monotonic : ∀ sigs S'' →
∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
Signal.unwrap S ∉ map (_+_ S'') (SigMap.keys sigs) →
∀ S' →
S' ∈ Canθₛ sigs S'' p (Env.set-sig {S} θ S∈ status) →
S' ∈ Canθₛ sigs S'' p θ
canθₛₕ-set-sig-monotonic : ∀ sigs S'' →
∀ p S θ S∈ status →
Env.sig-stats {S} θ S∈ ≡ Signal.unknown →
Signal.unwrap S ∉ map (_+_ S'') (SigMap.keys sigs) →
∀ s →
s ∈ Canθₛₕ sigs S'' p (Env.set-sig {S} θ S∈ status) →
s ∈ Canθₛₕ sigs S'' p θ
canθₖ-add-sig-monotonic : ∀ sigs S'' p θ S status →
∀ k →
k ∈ Canθₖ sigs S'' p (θ ← Θ SigMap.[ S ↦ status ] VarMap.empty ShrMap.empty) →
k ∈ Canθₖ sigs S'' p (θ ← [S]-env S)
canθₛ-add-sig-monotonic : ∀ sigs S'' p θ S status →
∀ S' →
S' ∈ Canθₛ sigs S'' p (θ ← Θ SigMap.[ S ↦ status ] VarMap.empty ShrMap.empty) →
S' ∈ Canθₛ sigs S'' p (θ ← [S]-env S)
canθₛₕ-add-sig-monotonic : ∀ sigs S'' p θ S status →
∀ s →
s ∈ Canθₛₕ sigs S'' p (θ ← Θ SigMap.[ S ↦ status ] VarMap.empty ShrMap.empty) →
s ∈ Canθₛₕ sigs S'' p (θ ← [S]-env S)
canθₖ-add-sig-monotonic sigs S'' p θ S status k k∈canθ-p-θ←[S↦status]
with any (_≟_ (Signal.unwrap S)) (map (_+_ S'') (SigMap.keys sigs))
... | yes S∈map-S''+-sigs =
subst (k ∈_)
(trans
(cong (Canθₖ sigs S'' p)
(begin
θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty
≡⟨ cong (θ ←_) (sym (Env.sig-put-1map-overwrite' S Signal.unknown status S∈[S])) ⟩
θ ← Env.set-sig {S} ([S]-env S) S∈[S] status
≡⟨ Env.sig-switch-right S status θ ([S]-env S) S∈[S] S∈Domθ←[S] ⟩
Env.set-sig {S} (θ ← [S]-env S) S∈Domθ←[S] status
∎))
(cong (proj₁ ∘ proj₂)
(sym
(canθ-set-sig-irr sigs S'' p S (θ ← [S]-env S) S∈Domθ←[S] status S∈map-S''+-sigs))))
k∈canθ-p-θ←[S↦status]
where S∈[S] = Env.sig-∈-single S Signal.unknown
S∈Domθ←[S] = Env.sig-←-monoʳ S ([S]-env S) θ S∈[S]
... | no S∉map-S''+-sigs =
canθₖ-set-sig-monotonic sigs S'' p S (θ ← [S]-env S) S∈Domθ←[S] status
(trans ⟨θ←[S]⟩S≡[S]S (Env.sig-stats-1map' S Signal.unknown S∈[S])) S∉map-S''+-sigs k
(subst (k ∈_)
(cong (Canθₖ sigs S'' p)
(begin
θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty
≡⟨ cong (θ ←_) (sym (Env.sig-put-1map-overwrite' S Signal.unknown status S∈[S])) ⟩
θ ← Env.set-sig {S} ([S]-env S) S∈[S] status
≡⟨ Env.sig-switch-right S status θ ([S]-env S) S∈[S] S∈Domθ←[S] ⟩
Env.set-sig {S} (θ ← [S]-env S) S∈Domθ←[S] status
∎))
k∈canθ-p-θ←[S↦status])
where S∈[S] = Env.sig-∈-single S Signal.unknown
S∈Domθ←[S] = Env.sig-←-monoʳ S ([S]-env S) θ S∈[S]
⟨θ←[S]⟩S≡[S]S = Env.sig-stats-←-right-irr' S θ ([S]-env S) S∈[S] S∈Domθ←[S]
canθₛ-add-sig-monotonic sigs S'' p θ S status S' S'∈canθ-p-θ←[S↦status]
with any (_≟_ (Signal.unwrap S)) (map (_+_ S'') (SigMap.keys sigs))
... | yes S∈map-S''+-sigs =
subst (S' ∈_)
(trans
(cong (Canθₛ sigs S'' p)
(begin
θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty
≡⟨ cong (θ ←_) (sym (Env.sig-put-1map-overwrite' S Signal.unknown status S∈[S])) ⟩
θ ← Env.set-sig {S} ([S]-env S) S∈[S] status
≡⟨ Env.sig-switch-right S status θ ([S]-env S) S∈[S] S∈Domθ←[S] ⟩
Env.set-sig {S} (θ ← [S]-env S) S∈Domθ←[S] status
∎))
(cong proj₁
(sym
(canθ-set-sig-irr sigs S'' p S (θ ← [S]-env S) S∈Domθ←[S] status S∈map-S''+-sigs))))
S'∈canθ-p-θ←[S↦status]
where S∈[S] = Env.sig-∈-single S Signal.unknown
S∈Domθ←[S] = Env.sig-←-monoʳ S ([S]-env S) θ S∈[S]
... | no S∉map-S''+-sigs =
canθₛ-set-sig-monotonic sigs S'' p S (θ ← [S]-env S) S∈Domθ←[S] status
(trans ⟨θ←[S]⟩S≡[S]S (Env.sig-stats-1map' S Signal.unknown S∈[S])) S∉map-S''+-sigs S'
(subst (S' ∈_)
(cong (Canθₛ sigs S'' p)
(begin
θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty
≡⟨ cong (θ ←_) (sym (Env.sig-put-1map-overwrite' S Signal.unknown status S∈[S])) ⟩
θ ← Env.set-sig {S} ([S]-env S) S∈[S] status
≡⟨ Env.sig-switch-right S status θ ([S]-env S) S∈[S] S∈Domθ←[S] ⟩
Env.set-sig {S} (θ ← [S]-env S) S∈Domθ←[S] status
∎))
S'∈canθ-p-θ←[S↦status])
where S∈[S] = Env.sig-∈-single S Signal.unknown
S∈Domθ←[S] = Env.sig-←-monoʳ S ([S]-env S) θ S∈[S]
⟨θ←[S]⟩S≡[S]S = Env.sig-stats-←-right-irr' S θ ([S]-env S) S∈[S] S∈Domθ←[S]
canθₛₕ-add-sig-monotonic sigs S'' p θ S status s s∈canθ-p-θ←[S↦status]
with any (_≟_ (Signal.unwrap S)) (map (_+_ S'') (SigMap.keys sigs))
... | yes S∈map-S''+-sigs =
subst (s ∈_)
(trans
(cong (Canθₛₕ sigs S'' p)
(begin
θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty
≡⟨ cong (θ ←_) (sym (Env.sig-put-1map-overwrite' S Signal.unknown status S∈[S])) ⟩
θ ← Env.set-sig {S} ([S]-env S) S∈[S] status
≡⟨ Env.sig-switch-right S status θ ([S]-env S) S∈[S] S∈Domθ←[S] ⟩
Env.set-sig {S} (θ ← [S]-env S) S∈Domθ←[S] status
∎))
(cong (proj₂ ∘ proj₂)
(sym
(canθ-set-sig-irr sigs S'' p S (θ ← [S]-env S) S∈Domθ←[S] status S∈map-S''+-sigs))))
s∈canθ-p-θ←[S↦status]
where S∈[S] = Env.sig-∈-single S Signal.unknown
S∈Domθ←[S] = Env.sig-←-monoʳ S ([S]-env S) θ S∈[S]
... | no S∉map-S''+-sigs =
canθₛₕ-set-sig-monotonic sigs S'' p S (θ ← [S]-env S) S∈Domθ←[S] status
(trans ⟨θ←[S]⟩S≡[S]S (Env.sig-stats-1map' S Signal.unknown S∈[S])) S∉map-S''+-sigs s
(subst (s ∈_)
(cong (Canθₛₕ sigs S'' p)
(begin
θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty
≡⟨ cong (θ ←_) (sym (Env.sig-put-1map-overwrite' S Signal.unknown status S∈[S])) ⟩
θ ← Env.set-sig {S} ([S]-env S) S∈[S] status
≡⟨ Env.sig-switch-right S status θ ([S]-env S) S∈[S] S∈Domθ←[S] ⟩
Env.set-sig {S} (θ ← [S]-env S) S∈Domθ←[S] status
∎))
s∈canθ-p-θ←[S↦status])
where S∈[S] = Env.sig-∈-single S Signal.unknown
S∈Domθ←[S] = Env.sig-←-monoʳ S ([S]-env S) θ S∈[S]
⟨θ←[S]⟩S≡[S]S = Env.sig-stats-←-right-irr' S θ ([S]-env S) S∈[S] S∈Domθ←[S]
canₖ-set-sig-monotonic nothin S θ S∈ status θS≡unknown k k∈can-p-θ' = k∈can-p-θ'
canₖ-set-sig-monotonic pause S θ S∈ status θS≡unknown k k∈can-p-θ' = k∈can-p-θ'
canₖ-set-sig-monotonic (signl S' p) S θ S∈ status θS≡unknown k k∈can-p-θ'
with Env.Sig∈ S ([S]-env S')
... | yes S∈Dom[S]-env
rewrite sym (map-id (proj₁ (Dom ([S]-env S'))))
| canθ-set-sig-irr (Env.sig ([S]-env S')) 0 p S θ S∈ status S∈Dom[S]-env
= k∈can-p-θ'
... | no S∉Dom[S]-env
rewrite sym (map-id (proj₁ (Dom ([S]-env S'))))
= canθₖ-set-sig-monotonic
(Env.sig ([S]-env S')) 0 p S θ S∈ status θS≡unknown
S∉Dom[S]-env
k k∈can-p-θ'
canₖ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-p-θ' with S' Signal.≟ S
canₖ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| no S'≢S with Env.Sig∈ S' θ | Env.Sig∈ S' (Env.set-sig {S} θ S∈ status)
canₖ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| no S'≢S | yes S'∈θ | no S'∉θ' =
⊥-elim (S'∉θ' (Env.sig-set-mono' {S'} {S} {θ} {status} {S∈} S'∈θ))
canₖ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| no S'≢S | no S'∉θ | yes S'∈θ' with Env.sig-stats {S'} (Env.set-sig {S} θ S∈ status) S'∈θ'
... | Signal.present =
++ˡ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ')
... | Signal.absent =
++ʳ (Canₖ p θ) (canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-p-θ')
... | Signal.unknown
with ++⁻ (Canₖ p (Env.set-sig {S} θ S∈ status)) k∈can-p-θ'
... | inj₁ k∈can-p'-θ' =
++ˡ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p'-θ')
... | inj₂ k∈can-q'-θ' =
++ʳ (Canₖ p θ) (canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-q'-θ')
canₖ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| no S'≢S | no S'∉θ | no S'∉θ'
with ++⁻ (Canₖ p (Env.set-sig {S} θ S∈ status)) k∈can-p-θ'
... | inj₁ k∈can-p'-θ' =
++ˡ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p'-θ')
... | inj₂ k∈can-q'-θ' =
++ʳ (Canₖ p θ) (canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-q'-θ')
canₖ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| no S'≢S | yes S'∈θ | yes S'∈θ'
with Env.sig-stats {S'} θ S'∈θ
| Env.sig-putputget {S'} {S} {θ} {_} {status} S'≢S S'∈θ S∈ S'∈θ' refl
... | Signal.present | eq rewrite eq = canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ'
... | Signal.absent | eq rewrite eq = canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-p-θ'
... | Signal.unknown | eq rewrite eq
with ++⁻ (Canₖ p (Env.set-sig {S} θ S∈ status)) k∈can-p-θ'
... | inj₁ k∈can-p'-θ' =
++ˡ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p'-θ')
... | inj₂ k∈can-q'-θ' =
++ʳ (Canₖ p θ) (canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-q'-θ')
canₖ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| yes refl with Env.Sig∈ S' θ | Env.Sig∈ S' (Env.set-sig {S} θ S∈ status)
... | no S'∉θ | S'∈θ'? = ⊥-elim (S'∉θ S∈)
... | yes S'∈θ | no S'∉θ' = ⊥-elim (S'∉θ' (Env.sig-set-mono' {S'} {S} {θ} {status} {S∈} S'∈θ))
... | yes S'∈θ | yes S'∈θ'
rewrite Env.sig-stats-∈-irr {S'} {θ} S'∈θ S∈ | θS≡unknown
with Env.sig-stats {S'} (Env.set-sig {S} θ S∈ status) S'∈θ'
... | Signal.present =
++ˡ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ')
... | Signal.absent =
++ʳ (Canₖ p θ) (canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-p-θ')
... | Signal.unknown
with ++⁻ (Canₖ p (Env.set-sig {S} θ S∈ status)) k∈can-p-θ'
... | inj₁ k∈can-p'-θ' =
++ˡ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p'-θ')
... | inj₂ k∈can-q'-θ' =
++ʳ (Canₖ p θ) (canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-q'-θ')
canₖ-set-sig-monotonic (emit S') S θ S∈ status θS≡unknown k k∈can-p-θ' = k∈can-p-θ'
canₖ-set-sig-monotonic (p ∥ q) S θ S∈ status
θS≡unknown k k∈can-p-θ' =
map-mono² Code._⊔_
(canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown)
(canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown)
k k∈can-p-θ'
canₖ-set-sig-monotonic (loop p) S θ S∈ status θS≡unknown k k∈can-p-θ' =
canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ'
canₖ-set-sig-monotonic (loopˢ p q) S θ S∈ status θS≡unknown k s∈can-loopˢpq-θ' =
canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k s∈can-loopˢpq-θ'
canₖ-set-sig-monotonic (p >> q) S θ S∈ status θS≡unknown k k∈can-p-θ'
with any (Code._≟_ Code.nothin) (Canₖ p θ)
| any (Code._≟_ Code.nothin) (Canₖ p (Env.set-sig {S} θ S∈ status))
canₖ-set-sig-monotonic (p >> q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| yes nothin∈can-p-θ | yes nothin∈can-p-θ'
with Code.nothin Code.≟ k
| ++⁻ (CodeSet.set-remove (Canₖ p (Env.set-sig {S} θ S∈ status)) Code.nothin) k∈can-p-θ'
... | nothin≟k | inj₂ k∈can-q-θ' =
++ʳ (CodeSet.set-remove (Canₖ p θ) Code.nothin)
(canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-q-θ')
... | yes refl | inj₁ nothin∈can-p-θ'-[nothin] =
⊥-elim (CodeSet.set-remove-removed {Code.nothin} {Canₖ p (Env.set-sig {S} θ S∈ status)}
nothin∈can-p-θ'-[nothin])
... | no nothin≢k | inj₁ k∈can-p-θ'-[nothin] =
++ˡ (CodeSet.set-remove-not-removed
nothin≢k
(canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k
(CodeSet.set-remove-mono-∈ Code.nothin k∈can-p-θ'-[nothin])))
canₖ-set-sig-monotonic (p >> q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| yes nothin∈can-p-θ | no nothin∉can-p-θ'
with Code.nothin Code.≟ k
... | yes refl = ⊥-elim (nothin∉can-p-θ' k∈can-p-θ')
... | no nothin≢k =
++ˡ (CodeSet.set-remove-not-removed
nothin≢k
(canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ'))
canₖ-set-sig-monotonic (p >> q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| no nothin∉can-p-θ | yes nothin∈can-p-θ'
= ⊥-elim (nothin∉can-p-θ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown Code.nothin nothin∈can-p-θ'))
canₖ-set-sig-monotonic (p >> q) S θ S∈ status θS≡unknown k k∈can-p-θ'
| no nothin∉can-p-θ | no nothin∉can-p-θ' =
canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ'
canₖ-set-sig-monotonic (suspend p S') S θ S∈ status θS≡unknown k k∈can-p-θ' =
canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ'
canₖ-set-sig-monotonic (trap p) S θ S∈ status θS≡unknown k k∈can-p-θ' =
map-mono Code.↓* (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown) k k∈can-p-θ'
canₖ-set-sig-monotonic (exit n) S θ S∈ status θS≡unknown k k∈can-p-θ' = k∈can-p-θ'
canₖ-set-sig-monotonic (shared s ≔ e in: p) S θ S∈ status θS≡unknown k k∈can-p-θ' =
canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ'
canₖ-set-sig-monotonic (s ⇐ e) S θ S∈ status θS≡unknown k k∈can-p-θ' = k∈can-p-θ'
canₖ-set-sig-monotonic (var x ≔ e in: p) S θ S∈ status θS≡unknown k k∈can-p-θ' =
canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ'
canₖ-set-sig-monotonic (x ≔ e) S θ S∈ status θS≡unknown k k∈can-p-θ' = k∈can-p-θ'
canₖ-set-sig-monotonic (if x ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown k k∈can-if-θ'
with ++⁻ (Canₖ p (Env.set-sig {S} θ S∈ status)) k∈can-if-θ'
... | inj₁ k∈can-p-θ' =
++ˡ (canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈can-p-θ')
... | inj₂ k∈can-q-θ' =
++ʳ
(Canₖ p θ)
(canₖ-set-sig-monotonic q S θ S∈ status θS≡unknown k k∈can-q-θ')
canₖ-set-sig-monotonic (ρ⟨ θ' , A ⟩· p) S θ S∈ status θS≡unknown k k∈can-p-θ'
with Env.Sig∈ S θ'
... | yes S∈Domθ'
rewrite sym (map-id (proj₁ (Dom θ')))
| canθ-set-sig-irr (Env.sig θ') 0 p S θ S∈ status S∈Domθ'
= k∈can-p-θ'
... | no S∉Domθ'
rewrite sym (map-id (proj₁ (Dom θ')))
= canθₖ-set-sig-monotonic (Env.sig θ') 0 p S θ S∈ status θS≡unknown S∉Domθ' k k∈can-p-θ'
canₛ-set-sig-monotonic nothin S θ S∈ status θS≡unknown S'' S''∈can-p-θ' = S''∈can-p-θ'
canₛ-set-sig-monotonic pause S θ S∈ status θS≡unknown S'' S''∈can-p-θ' = S''∈can-p-θ'
canₛ-set-sig-monotonic (signl S' p) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
with Env.Sig∈ S ([S]-env S')
... | yes S∈Dom[S]-env
rewrite sym (map-id (proj₁ (Dom ([S]-env S'))))
| canθ-set-sig-irr (Env.sig ([S]-env S')) 0 p S θ S∈ status S∈Dom[S]-env
= S''∈can-p-θ'
... | no S∉Dom[S]-env rewrite sym (map-id (proj₁ (Dom ([S]-env S'))))
with Signal.unwrap S' ≟ S''
... | yes refl =
⊥-elim
(set-remove-removed {S''}
{Canθₛ (Env.sig ([S]-env S')) 0 p (Env.set-sig {S} θ S∈ status)}
S''∈can-p-θ')
... | no S'≢S'' =
set-remove-not-removed S'≢S''
(canθₛ-set-sig-monotonic
(Env.sig ([S]-env S')) 0 p S θ S∈ status θS≡unknown
S∉Dom[S]-env S''
(set-remove-mono-∈ (Signal.unwrap S') S''∈can-p-θ'))
canₛ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
with S' Signal.≟ S
canₛ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
| no S'≢S with Env.Sig∈ S' θ | Env.Sig∈ S' (Env.set-sig {S} θ S∈ status)
canₛ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
| no S'≢S | yes S'∈θ | no S'∉θ' =
⊥-elim (S'∉θ' (Env.sig-set-mono' {S'} {S} {θ} {status} {S∈} S'∈θ))
canₛ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
| no S'≢S | no S'∉θ | yes S'∈θ' with Env.sig-stats {S'} (Env.set-sig {S} θ S∈ status) S'∈θ'
... | Signal.present =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ')
... | Signal.absent =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-p-θ')
... | Signal.unknown
with ++⁻ (Canₛ p (Env.set-sig {S} θ S∈ status)) S''∈can-p-θ'
... | inj₁ S''∈can-p'-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p'-θ')
... | inj₂ S''∈can-q'-θ' =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-q'-θ')
canₛ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
| no S'≢S | no S'∉θ | no S'∉θ'
with ++⁻ (Canₛ p (Env.set-sig {S} θ S∈ status)) S''∈can-p-θ'
... | inj₁ S''∈can-p'-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p'-θ')
... | inj₂ S''∈can-q'-θ' =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-q'-θ')
canₛ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
| no S'≢S | yes S'∈θ | yes S'∈θ'
with Env.sig-stats {S'} θ S'∈θ
| Env.sig-putputget {S'} {S} {θ} {_} {status} S'≢S S'∈θ S∈ S'∈θ' refl
... | Signal.present | eq rewrite eq = canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
... | Signal.absent | eq rewrite eq = canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
... | Signal.unknown | eq rewrite eq
with ++⁻ (Canₛ p (Env.set-sig {S} θ S∈ status)) S''∈can-p-θ'
... | inj₁ S''∈can-p'-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p'-θ')
... | inj₂ S''∈can-q'-θ' =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-q'-θ')
canₛ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
| yes refl with Env.Sig∈ S' θ | Env.Sig∈ S' (Env.set-sig {S} θ S∈ status)
... | no S'∉θ | S'∈θ'? = ⊥-elim (S'∉θ S∈)
... | yes S'∈θ | no S'∉θ' = ⊥-elim (S'∉θ' (Env.sig-set-mono' {S'} {S} {θ} {status} {S∈} S'∈θ))
... | yes S'∈θ | yes S'∈θ'
rewrite Env.sig-stats-∈-irr {S'} {θ} S'∈θ S∈ | θS≡unknown
with Env.sig-stats {S'} (Env.set-sig {S} θ S∈ status) S'∈θ'
... | Signal.present =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ')
... | Signal.absent =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-p-θ')
... | Signal.unknown
with ++⁻ (Canₛ p (Env.set-sig {S} θ S∈ status)) S''∈can-p-θ'
... | inj₁ S''∈can-p'-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p'-θ')
... | inj₂ S''∈can-q'-θ' =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-q'-θ')
canₛ-set-sig-monotonic (emit S') S θ S∈ status θS≡unknown S'' S''∈can-p-θ' = S''∈can-p-θ'
canₛ-set-sig-monotonic (p ∥ q) S θ S∈ status θS≡unknown S'' S''∈can-p∥q-θ'
with ++⁻ (Canₛ p (Env.set-sig {S} θ S∈ status)) S''∈can-p∥q-θ'
... | inj₁ S''∈can-p-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ')
... | inj₂ S''∈can-q-θ' =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-q-θ')
canₛ-set-sig-monotonic (loop p) S θ S∈ status θS≡unknown S'' S''∈can-p-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
canₛ-set-sig-monotonic (loopˢ p q) S θ S∈ status θS≡unknown S'' s∈can-loopˢpq-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' s∈can-loopˢpq-θ'
canₛ-set-sig-monotonic (p >> q) S θ S∈ status θS≡unknown S'' S''∈can-p>>q-θ'
with any (Code._≟_ Code.nothin) (Canₖ p θ)
| any (Code._≟_ Code.nothin) (Canₖ p (Env.set-sig {S} θ S∈ status))
... | no nothin∉can-p-θ | yes nothin∈can-p-θ' =
⊥-elim
(nothin∉can-p-θ
(canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown
Code.nothin nothin∈can-p-θ'))
... | no nothin∉can-p-θ | no nothin∉can-p-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p>>q-θ'
... | yes nothin∈can-p-θ | no nothin∉can-p-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p>>q-θ')
... | yes nothin∈can-p-θ | yes nothin∈can-p-θ'
with ++⁻ (Canₛ p (Env.set-sig {S} θ S∈ status)) S''∈can-p>>q-θ'
... | inj₁ S''∈can-p-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ')
... | inj₂ S''∈can-q-θ' =
++ʳ (Canₛ p θ) (canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-q-θ')
canₛ-set-sig-monotonic (suspend p S') S θ S∈ status θS≡unknown S'' S''∈can-p-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
canₛ-set-sig-monotonic (trap p) S θ S∈ status θS≡unknown S'' S''∈can-p-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
canₛ-set-sig-monotonic (exit n) S θ S∈ status θS≡unknown S'' S''∈can-p-θ' = S''∈can-p-θ'
canₛ-set-sig-monotonic (shared s' ≔ e in: p) S θ S∈ status θS≡unknown S'' S''∈can-p-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
canₛ-set-sig-monotonic (s' ⇐ e) S θ S∈ status θS≡unknown S'' S''∈can-p-θ' = S''∈can-p-θ'
canₛ-set-sig-monotonic (var x ≔ e in: p) S θ S∈ status θS≡unknown S'' S''∈can-p-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ'
canₛ-set-sig-monotonic (x ≔ e) S θ S∈ status θS≡unknown S'' S''∈can-p-θ' = S''∈can-p-θ'
canₛ-set-sig-monotonic (if x ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown S'' S''∈can-if-θ'
with ++⁻ (Canₛ p (Env.set-sig {S} θ S∈ status)) S''∈can-if-θ'
... | inj₁ S''∈can-p-θ' =
++ˡ (canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S'' S''∈can-p-θ')
... | inj₂ S''∈can-q-θ' =
++ʳ
(Canₛ p θ)
(canₛ-set-sig-monotonic q S θ S∈ status θS≡unknown S'' S''∈can-q-θ')
canₛ-set-sig-monotonic (ρ⟨ θ' , A ⟩· p) S θ S∈ status θS≡unknown S'' S''∈can-ρθ'p-θ'
with Env.Sig∈ S θ'
... | yes S∈Domθ'
rewrite sym (map-id (proj₁ (Dom θ')))
| canθ-set-sig-irr (Env.sig θ') 0 p S θ S∈ status S∈Domθ'
= S''∈can-ρθ'p-θ'
... | no S∉Domθ'
with set-subtract-merge {xs = Canθₛ (Env.sig θ') 0 p (Env.set-sig {S} θ S∈ status)}
{ys = proj₁ (Dom θ')}
S''∈can-ρθ'p-θ'
... | S''∈canθ-p-θ' , S''∉Domθ'
rewrite sym (map-id (proj₁ (Dom θ')))
with set-subtract-split
(canθₛ-set-sig-monotonic (Env.sig θ') 0 p S θ S∈ status θS≡unknown S∉Domθ'
S'' S''∈canθ-p-θ')
... | inj₂ S''∈Domθ' = ⊥-elim (S''∉Domθ' S''∈Domθ')
... | inj₁ S''∈canθ-p-θ-Domθ' = S''∈canθ-p-θ-Domθ'
canₛₕ-set-sig-monotonic nothin S θ S∈ status θS≡unknown s s∈can-p-θ' = s∈can-p-θ'
canₛₕ-set-sig-monotonic pause S θ S∈ status θS≡unknown s s∈can-p-θ' = s∈can-p-θ'
canₛₕ-set-sig-monotonic (signl S' p) S θ S∈ status θS≡unknown s s∈can-p-θ'
with Env.Sig∈ S ([S]-env S')
... | yes S∈Dom[S]-env
rewrite sym (map-id (proj₁ (Dom ([S]-env S'))))
| canθ-set-sig-irr (Env.sig ([S]-env S')) 0 p S θ S∈ status S∈Dom[S]-env
= s∈can-p-θ'
... | no S∉Dom[S]-env
rewrite sym (map-id (proj₁ (Dom ([S]-env S'))))
= canθₛₕ-set-sig-monotonic
(Env.sig ([S]-env S')) 0 p S θ S∈ status θS≡unknown
S∉Dom[S]-env
s s∈can-p-θ'
canₛₕ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-p-θ'
with S' Signal.≟ S
canₛₕ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-p-θ'
| no S'≢S with Env.Sig∈ S' θ | Env.Sig∈ S' (Env.set-sig {S} θ S∈ status)
canₛₕ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-p-θ'
| no S'≢S | yes S'∈θ | no S'∉θ' =
⊥-elim (S'∉θ' (Env.sig-set-mono' {S'} {S} {θ} {status} {S∈} S'∈θ))
canₛₕ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-p-θ'
| no S'≢S | no S'∉θ | yes S'∈θ' with Env.sig-stats {S'} (Env.set-sig {S} θ S∈ status) S'∈θ'
... | Signal.present =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ')
... | Signal.absent =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-p-θ')
... | Signal.unknown
with ++⁻ (Canₛₕ p (Env.set-sig {S} θ S∈ status)) s∈can-p-θ'
... | inj₁ s∈can-p'-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p'-θ')
... | inj₂ s∈can-q'-θ' =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-q'-θ')
canₛₕ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-p-θ'
| no S'≢S | no S'∉θ | no S'∉θ'
with ++⁻ (Canₛₕ p (Env.set-sig {S} θ S∈ status)) s∈can-p-θ'
... | inj₁ s∈can-p'-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p'-θ')
... | inj₂ s∈can-q'-θ' =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-q'-θ')
canₛₕ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-p-θ'
| no S'≢S | yes S'∈θ | yes S'∈θ'
with Env.sig-stats {S'} θ S'∈θ
| Env.sig-putputget {S'} {S} {θ} {_} {status} S'≢S S'∈θ S∈ S'∈θ' refl
... | Signal.present | eq rewrite eq = canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ'
... | Signal.absent | eq rewrite eq = canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-p-θ'
... | Signal.unknown | eq rewrite eq
with ++⁻ (Canₛₕ p (Env.set-sig {S} θ S∈ status)) s∈can-p-θ'
... | inj₁ s∈can-p'-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p'-θ')
... | inj₂ s∈can-q'-θ' =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-q'-θ')
canₛₕ-set-sig-monotonic (present S' ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-p-θ'
| yes refl with Env.Sig∈ S' θ | Env.Sig∈ S' (Env.set-sig {S} θ S∈ status)
... | no S'∉θ | S'∈θ'? = ⊥-elim (S'∉θ S∈)
... | yes S'∈θ | no S'∉θ' = ⊥-elim (S'∉θ' (Env.sig-set-mono' {S'} {S} {θ} {status} {S∈} S'∈θ))
... | yes S'∈θ | yes S'∈θ'
rewrite Env.sig-stats-∈-irr {S'} {θ} S'∈θ S∈ | θS≡unknown
with Env.sig-stats {S'} (Env.set-sig {S} θ S∈ status) S'∈θ'
... | Signal.present =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ')
... | Signal.absent =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-p-θ')
... | Signal.unknown
with ++⁻ (Canₛₕ p (Env.set-sig {S} θ S∈ status)) s∈can-p-θ'
... | inj₁ s∈can-p'-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p'-θ')
... | inj₂ s∈can-q'-θ' =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-q'-θ')
canₛₕ-set-sig-monotonic (emit S') S θ S∈ status θS≡unknown s s∈can-p-θ' = s∈can-p-θ'
canₛₕ-set-sig-monotonic (p ∥ q) S θ S∈ status θS≡unknown s s∈can-p∥q-θ'
with ++⁻ (Canₛₕ p (Env.set-sig {S} θ S∈ status)) s∈can-p∥q-θ'
... | inj₁ s∈can-p-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ')
... | inj₂ s∈can-q-θ' =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-q-θ')
canₛₕ-set-sig-monotonic (loop p) S θ S∈ status θS≡unknown s s∈can-p-θ' =
canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ'
canₛₕ-set-sig-monotonic (loopˢ p q) S θ S∈ status θS≡unknown s s∈can-loopˢpq-θ' =
canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-loopˢpq-θ'
canₛₕ-set-sig-monotonic (p >> q) S θ S∈ status θS≡unknown s s∈can-p>>q-θ'
with any (Code._≟_ Code.nothin) (Canₖ p θ)
| any (Code._≟_ Code.nothin) (Canₖ p (Env.set-sig {S} θ S∈ status))
... | no nothin∉can-p-θ | yes nothin∈-can-p-θ' =
⊥-elim
(nothin∉can-p-θ
(canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown
Code.nothin nothin∈-can-p-θ'))
... | no nothin∉can-p-θ | no nothin∉-can-p-θ' =
canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p>>q-θ'
... | yes nothin∈can-p-θ | no nothin∉-can-p-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p>>q-θ')
... | yes nothin∈can-p-θ | yes nothin∈-can-p-θ'
with ++⁻ (Canₛₕ p (Env.set-sig {S} θ S∈ status)) s∈can-p>>q-θ'
... | inj₁ s∈can-p-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ')
... | inj₂ s∈can-q-θ' =
++ʳ (Canₛₕ p θ) (canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-q-θ')
canₛₕ-set-sig-monotonic (suspend p S') S θ S∈ status θS≡unknown s s∈can-p-θ' =
canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ'
canₛₕ-set-sig-monotonic (trap p) S θ S∈ status θS≡unknown s s∈can-p-θ' =
canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ'
canₛₕ-set-sig-monotonic (exit n) S θ S∈ status θS≡unknown s s∈can-p-θ' = s∈can-p-θ'
canₛₕ-set-sig-monotonic (shared s' ≔ e in: p) S θ S∈ status θS≡unknown s s∈can-p-θ'
with SharedVar.unwrap s' Data.Nat.≟ s
... | yes refl =
⊥-elim (set-remove-removed {SharedVar.unwrap s'} {Canₛₕ p (Env.set-sig {S} θ S∈ status)}
s∈can-p-θ')
... | no s'≢s =
set-remove-not-removed s'≢s
(canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s
(set-remove-mono-∈ (SharedVar.unwrap s') s∈can-p-θ'))
canₛₕ-set-sig-monotonic (s' ⇐ e) S θ S∈ status θS≡unknown s s∈can-p-θ' = s∈can-p-θ'
canₛₕ-set-sig-monotonic (var x ≔ e in: p) S θ S∈ status θS≡unknown s s∈can-p-θ' =
canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ'
canₛₕ-set-sig-monotonic (x ≔ e) S θ S∈ status θS≡unknown s s∈can-p-θ' = s∈can-p-θ'
canₛₕ-set-sig-monotonic (if x ∣⇒ p ∣⇒ q) S θ S∈ status θS≡unknown s s∈can-if-θ'
with ++⁻ (Canₛₕ p (Env.set-sig {S} θ S∈ status)) s∈can-if-θ'
... | inj₁ s∈can-p-θ' =
++ˡ (canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈can-p-θ')
... | inj₂ s∈can-q-θ' =
++ʳ
(Canₛₕ p θ)
(canₛₕ-set-sig-monotonic q S θ S∈ status θS≡unknown s s∈can-q-θ')
canₛₕ-set-sig-monotonic (ρ⟨ θ' , A ⟩· p) S θ S∈ status θS≡unknown s s∈can-ρθ'p-θ'
with Env.Sig∈ S θ'
... | yes S∈Domθ'
rewrite sym (map-id (proj₁ (Dom θ')))
| canθ-set-sig-irr (Env.sig θ') 0 p S θ S∈ status S∈Domθ'
= s∈can-ρθ'p-θ'
... | no S∉Domθ'
with set-subtract-merge {xs = Canθₛₕ (Env.sig θ') 0 p (Env.set-sig {S} θ S∈ status)}
{ys = proj₁ (proj₂ (Dom θ'))}
s∈can-ρθ'p-θ'
... | s∈canθ-p-θ' , s∉Domθ'
rewrite sym (map-id (proj₁ (Dom θ')))
with set-subtract-split
(canθₛₕ-set-sig-monotonic (Env.sig θ') 0 p S θ S∈ status θS≡unknown S∉Domθ'
s s∈canθ-p-θ')
... | inj₂ s∈Domθ' = ⊥-elim (s∉Domθ' s∈Domθ')
... | inj₁ s∈canθ-p-θ-Domθ' = s∈canθ-p-θ-Domθ'
canθ-set-sig-irr [] S'' p S θ S∈Domθ status ()
canθ-set-sig-irr (nothing ∷ sigs) S'' p S θ S∈Domθ status S∈sigs
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
= canθ-set-sig-irr sigs (suc S'') p S θ S∈Domθ status S∈sigs
canθ-set-sig-irr (just Signal.present ∷ sigs) S'' p S θ S∈Domθ status S∈S'∷sigs
with (S'' ₛ) Signal.≟ S
... | yes refl
rewrite Env.sig-set-←-← S status θ ([S]-env-present S)
S∈Domθ (Env.sig-∈-single S Signal.present)
= refl
... | no S''≢S with S | S∈S'∷sigs
... | _ | here S≡S''+0 rewrite +-comm S'' 0 =
⊥-elim (S''≢S (Signal.unwrap-injective (sym S≡S''+0)))
... | zero ₛ | there S∈sigs
rewrite map-+-swap-suc S'' (SigMap.keys sigs)
= ⊥-elim (SigM.0∈S S∈sigs)
... | suc S' ₛ | there S∈sigs
rewrite sym (Env.sig-switch (suc S' ₛ) status θ ([S]-env-present (S'' ₛ))
S∈Domθ (Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env-present (S'' ₛ)) S∈Domθ)
(Env.sig-∉-single (suc S' ₛ) (S'' ₛ) Signal.present (S''≢S ∘ sym)))
| map-+-compose-suc S'' (SigMap.keys sigs)
= canθ-set-sig-irr sigs (suc S'') p (suc S' ₛ) (θ ← [S]-env-present (S'' ₛ))
(Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env-present (S'' ₛ)) S∈Domθ) status
S∈sigs
canθ-set-sig-irr (just Signal.absent ∷ sigs) S'' p S θ S∈Domθ status S∈S'∷sigs
with (S'' ₛ) Signal.≟ S
... | yes refl
rewrite Env.sig-set-←-← S status θ ([S]-env-absent S)
S∈Domθ (Env.sig-∈-single S Signal.absent)
= refl
... | no S''≢S with S | S∈S'∷sigs
... | _ | here S≡S''+0 rewrite +-comm S'' 0 =
⊥-elim (S''≢S (Signal.unwrap-injective (sym S≡S''+0)))
... | zero ₛ | there S∈sigs
rewrite map-+-swap-suc S'' (SigMap.keys sigs)
= ⊥-elim (SigM.0∈S S∈sigs)
... | suc S' ₛ | there S∈sigs
rewrite sym (Env.sig-switch (suc S' ₛ) status θ ([S]-env-absent (S'' ₛ))
S∈Domθ (Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ)
(Env.sig-∉-single (suc S' ₛ) (S'' ₛ) Signal.absent (S''≢S ∘ sym)))
| map-+-compose-suc S'' (SigMap.keys sigs)
= canθ-set-sig-irr sigs (suc S'') p (suc S' ₛ) (θ ← [S]-env-absent (S'' ₛ))
(Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ) status
S∈sigs
canθ-set-sig-irr (just Signal.unknown ∷ sigs) S'' p S θ S∈Domθ status S∈S'∷sigs
with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ)))
| any (_≟_ S'') (Canθₛ sigs (suc S'') p
((Env.set-sig {S} θ S∈Domθ status) ← [S]-env (S'' ₛ)))
canθ-set-sig-irr (just Signal.unknown ∷ sigs) S'' p S θ S∈Domθ status S∈S'∷sigs
| yes S''∈canθ-p-θ←[S''] | yes S''∈canθ-p-θ'←[S'']
with (S'' ₛ) Signal.≟ S
... | yes refl
rewrite Env.sig-set-←-← S status θ ([S]-env S)
S∈Domθ (Env.sig-∈-single S Signal.unknown)
= refl
... | no S''≢S with S | S∈S'∷sigs
... | _ | here S≡S''+0 rewrite +-comm S'' 0 =
⊥-elim (S''≢S (Signal.unwrap-injective (sym S≡S''+0)))
... | zero ₛ | there S∈sigs
rewrite map-+-swap-suc S'' (SigMap.keys sigs)
= ⊥-elim (SigM.0∈S S∈sigs)
... | suc S' ₛ | there S∈sigs
rewrite sym (Env.sig-switch (suc S' ₛ) status θ ([S]-env (S'' ₛ))
S∈Domθ (Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ)
(Env.sig-∉-single (suc S' ₛ) (S'' ₛ) Signal.unknown (S''≢S ∘ sym)))
| map-+-compose-suc S'' (SigMap.keys sigs)
= canθ-set-sig-irr sigs (suc S'') p (suc S' ₛ) (θ ← [S]-env (S'' ₛ))
(Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ) status
S∈sigs
canθ-set-sig-irr (just Signal.unknown ∷ sigs) S'' p S θ S∈Domθ status S∈S'∷sigs
| no S''∉can-pθ-θ←[S''] | no S''∉can-pθ-θ'←[S'']
with (S'' ₛ) Signal.≟ S
... | yes refl
rewrite Env.sig-set-←-← S status θ ([S]-env-absent S)
S∈Domθ (Env.sig-∈-single S Signal.absent)
= refl
... | no S''≢S with S | S∈S'∷sigs
... | _ | here S≡S''+0 rewrite +-comm S'' 0 =
⊥-elim (S''≢S (Signal.unwrap-injective (sym S≡S''+0)))
... | zero ₛ | there S∈sigs
rewrite map-+-swap-suc S'' (SigMap.keys sigs)
= ⊥-elim (SigM.0∈S S∈sigs)
... | suc S' ₛ | there S∈sigs
rewrite sym (Env.sig-switch (suc S' ₛ) status θ ([S]-env-absent (S'' ₛ))
S∈Domθ (Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ)
(Env.sig-∉-single (suc S' ₛ) (S'' ₛ) Signal.absent (S''≢S ∘ sym)))
| map-+-compose-suc S'' (SigMap.keys sigs)
= canθ-set-sig-irr sigs (suc S'') p (suc S' ₛ) (θ ← [S]-env-absent (S'' ₛ))
(Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ) status
S∈sigs
canθ-set-sig-irr (just Signal.unknown ∷ sigs) S'' p S θ S∈Domθ status S∈S'∷sigs
| yes S''∈canθ-p-θ←[S''] | no S''∉canθ-p-θ'←[S'']
with (S'' ₛ) Signal.≟ S
... | yes refl
rewrite Env.sig-set-←-← S status θ ([S]-env S)
S∈Domθ (Env.sig-∈-single S Signal.unknown)
= ⊥-elim (S''∉canθ-p-θ'←[S''] S''∈canθ-p-θ←[S''])
... | no S''≢S with S | S∈S'∷sigs
... | _ | here S≡S''+0 rewrite +-comm S'' 0 =
⊥-elim (S''≢S (Signal.unwrap-injective (sym S≡S''+0)))
... | zero ₛ | there S∈sigs
rewrite map-+-swap-suc S'' (SigMap.keys sigs)
= ⊥-elim (SigM.0∈S S∈sigs)
... | suc S' ₛ | there S∈sigs
rewrite sym (Env.sig-switch (suc S' ₛ) status θ ([S]-env (S'' ₛ))
S∈Domθ (Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ)
(Env.sig-∉-single (suc S' ₛ) (S'' ₛ) Signal.unknown (S''≢S ∘ sym)))
| map-+-compose-suc S'' (SigMap.keys sigs)
| canθ-set-sig-irr sigs (suc S'') p (suc S' ₛ) (θ ← [S]-env (S'' ₛ))
(Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ) status
S∈sigs
= ⊥-elim (S''∉canθ-p-θ'←[S''] S''∈canθ-p-θ←[S''])
canθ-set-sig-irr (just Signal.unknown ∷ sigs) S'' p S θ S∈Domθ status S∈S'∷sigs
| no S''∉canθ-p-θ←[S''] | yes S''∈canθ-p-θ'←[S'']
with (S'' ₛ) Signal.≟ S
... | yes refl
rewrite Env.sig-set-←-← S status θ ([S]-env S)
S∈Domθ (Env.sig-∈-single S Signal.unknown)
= ⊥-elim (S''∉canθ-p-θ←[S''] S''∈canθ-p-θ'←[S''])
... | no S''≢S with S | S∈S'∷sigs
... | _ | here S≡S''+0 rewrite +-comm S'' 0 =
⊥-elim (S''≢S (Signal.unwrap-injective (sym S≡S''+0)))
... | zero ₛ | there S∈sigs
rewrite map-+-swap-suc S'' (SigMap.keys sigs)
= ⊥-elim (SigM.0∈S S∈sigs)
... | suc S' ₛ | there S∈sigs
rewrite sym (Env.sig-switch (suc S' ₛ) status θ ([S]-env (S'' ₛ))
S∈Domθ (Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ)
(Env.sig-∉-single (suc S' ₛ) (S'' ₛ) Signal.unknown (S''≢S ∘ sym)))
| map-+-compose-suc S'' (SigMap.keys sigs)
| canθ-set-sig-irr sigs (suc S'') p (suc S' ₛ) (θ ← [S]-env (S'' ₛ))
(Env.sig-←-monoˡ (suc S' ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ) status
S∈sigs
= ⊥-elim (S''∉canθ-p-θ←[S''] S''∈canθ-p-θ'←[S''])
canθₖ-set-sig-monotonic [] S'' p S θ S∈ status θS≡unknown S∉sigs k k∈canθ-p-θ' =
canₖ-set-sig-monotonic p S θ S∈ status θS≡unknown k k∈canθ-p-θ'
canθₖ-set-sig-monotonic (nothing ∷ sigs) S'' p S θ S∈ status θS≡unknown S∉sigs k k∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
= canθₖ-set-sig-monotonic sigs (suc S'') p S θ S∈ status θS≡unknown S∉sigs
k k∈canθ-p-θ'
canθₖ-set-sig-monotonic (just Signal.present ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs k k∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₖ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-present (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) k
(subst (k ∈_)
(cong (Canθₖ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-present (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-present (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.present
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
k∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-present (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-present (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.present
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₖ-set-sig-monotonic (just Signal.absent ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs k k∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₖ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) k
(subst (k ∈_)
(cong (Canθₖ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
k∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₖ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status θS≡unknown S∉sigs k k∈canθ-p-θ'
with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ)))
| any (_≟_ S'') (Canθₛ sigs (suc S'') p ((Env.set-sig {S} θ S∈ status) ← [S]-env (S'' ₛ)))
canθₖ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs k k∈canθ-p-θ'
| yes S''∈canθ-p-θ←[S] | yes S''∈canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₖ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) k
(subst (k ∈_)
(cong (Canθₖ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
k∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₖ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs k k∈canθ-p-θ'
| no S''∉canθ-p-θ←[S] | no S''∉canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₖ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) k
(subst (k ∈_)
(cong (Canθₖ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
k∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₖ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs k k∈canθ-p-θ'
| no S''∉canθ-p-θ←[S] | yes S''∈canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
| cong (Canθₖ sigs (suc S'') p)
(Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))
= ⊥-elim
(S''∉canθ-p-θ←[S]
(canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S''
(subst (S'' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S''∈canθ-p-θ'←[S])))
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₖ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs k k∈canθ-p-θ'
| yes S''∈canθ-p-θ←[S] | no S''∉canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₖ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent
k k∈canθ-p-θ←[S↦absent]
where S''∈[S''] = Env.sig-∈-single (S'' ₛ) Signal.unknown
S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
S''∈Domθ←[S''] = Env.sig-←-monoʳ (S'' ₛ) ([S]-env (S'' ₛ)) θ S''∈[S'']
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
⟨θ←[S'']⟩S''≡[S'']S'' = Env.sig-stats-←-right-irr' (S'' ₛ) θ ([S]-env (S'' ₛ))
S''∈[S''] S''∈Domθ←[S'']
k∈canθ-p-θ←[S↦absent] =
canθₖ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) k
(subst (k ∈_)
(cong (Canθₖ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
k∈canθ-p-θ')
canθₛ-set-sig-monotonic [] S'' p S θ S∈ status θS≡unknown S∉sigs S' S'∈canθ-p-θ' =
canₛ-set-sig-monotonic p S θ S∈ status θS≡unknown S' S'∈canθ-p-θ'
canθₛ-set-sig-monotonic (nothing ∷ sigs) S'' p S θ S∈ status θS≡unknown S∉sigs S' S'∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
= canθₛ-set-sig-monotonic sigs (suc S'') p S θ S∈ status θS≡unknown S∉sigs
S' S'∈canθ-p-θ'
canθₛ-set-sig-monotonic (just Signal.present ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs S' S'∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-present (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S'
(subst (S' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-present (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-present (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.present
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S'∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-present (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-present (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.present
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛ-set-sig-monotonic (just Signal.absent ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs S' S'∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S'
(subst (S' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S'∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status θS≡unknown S∉sigs S' S'∈canθ-p-θ'
with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ)))
| any (_≟_ S'') (Canθₛ sigs (suc S'') p ((Env.set-sig {S} θ S∈ status) ← [S]-env (S'' ₛ)))
canθₛ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs S' S'∈canθ-p-θ'
| yes S''∈canθ-p-θ←[S] | yes S''∈canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S'
(subst (S' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S'∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs S' S'∈canθ-p-θ'
| no S''∉canθ-p-θ←[S] | no S''∉canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S'
(subst (S' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S'∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs S' S'∈canθ-p-θ'
| no S''∉canθ-p-θ←[S] | yes S''∈canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
| cong (Canθₛ sigs (suc S'') p)
(Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))
= ⊥-elim
(S''∉canθ-p-θ←[S]
(canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S''
(subst (S'' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S''∈canθ-p-θ'←[S])))
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs S' S'∈canθ-p-θ'
| yes S''∈canθ-p-θ←[S] | no S''∉canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent
S' S'∈canθ-p-θ←[S↦absent]
where S''∈[S''] = Env.sig-∈-single (S'' ₛ) Signal.unknown
S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
S''∈Domθ←[S''] = Env.sig-←-monoʳ (S'' ₛ) ([S]-env (S'' ₛ)) θ S''∈[S'']
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
⟨θ←[S'']⟩S''≡[S'']S'' = Env.sig-stats-←-right-irr' (S'' ₛ) θ ([S]-env (S'' ₛ))
S''∈[S''] S''∈Domθ←[S'']
S'∈canθ-p-θ←[S↦absent] =
canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S'
(subst (S' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S'∈canθ-p-θ')
canθₛₕ-set-sig-monotonic [] S'' p S θ S∈ status θS≡unknown S∉sigs s s∈canθ-p-θ' =
canₛₕ-set-sig-monotonic p S θ S∈ status θS≡unknown s s∈canθ-p-θ'
canθₛₕ-set-sig-monotonic (nothing ∷ sigs) S'' p S θ S∈ status θS≡unknown S∉sigs s s∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
= canθₛₕ-set-sig-monotonic sigs (suc S'') p S θ S∈ status θS≡unknown S∉sigs
s s∈canθ-p-θ'
canθₛₕ-set-sig-monotonic (just Signal.present ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs s s∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛₕ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-present (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) s
(subst (s ∈_)
(cong (Canθₛₕ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-present (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-present (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.present
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
s∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-present (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-present (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.present
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛₕ-set-sig-monotonic (just Signal.absent ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs s s∈canθ-p-θ'
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛₕ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) s
(subst (s ∈_)
(cong (Canθₛₕ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
s∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛₕ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status θS≡unknown S∉sigs s s∈canθ-p-θ'
with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ)))
| any (_≟_ S'') (Canθₛ sigs (suc S'') p ((Env.set-sig {S} θ S∈ status) ← [S]-env (S'' ₛ)))
canθₛₕ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs s s∈canθ-p-θ'
| yes S''∈canθ-p-θ←[S] | yes S''∈canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛₕ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) s
(subst (s ∈_)
(cong (Canθₛₕ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
s∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛₕ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs s s∈canθ-p-θ'
| no S''∉canθ-p-θ←[S] | no S''∉canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛₕ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) s
(subst (s ∈_)
(cong (Canθₛₕ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
s∈canθ-p-θ')
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛₕ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs s s∈canθ-p-θ'
| no S''∉canθ-p-θ←[S] | yes S''∈canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
| cong (Canθₛₕ sigs (suc S'') p)
(Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))
= ⊥-elim
(S''∉canθ-p-θ←[S]
(canθₛ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) S''
(subst (S'' ∈_)
(cong (Canθₛ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
S''∈canθ-p-θ'←[S])))
where S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env (S'' ₛ)) S∈
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.unknown
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
canθₛₕ-set-sig-monotonic (just Signal.unknown ∷ sigs) S'' p S θ S∈ status
θS≡unknown S∉sigs s s∈canθ-p-θ'
| yes S''∈canθ-p-θ←[S] | no S''∉canθ-p-θ'←[S]
rewrite map-+-compose-suc S'' (SigMap.keys sigs)
| +-comm S'' 0
= canθₛₕ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent
s s∈canθ-p-θ←[S↦absent]
where S''∈[S''] = Env.sig-∈-single (S'' ₛ) Signal.unknown
S∈Domθ←[S''] = Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈
S''∈Domθ←[S''] = Env.sig-←-monoʳ (S'' ₛ) ([S]-env (S'' ₛ)) θ S''∈[S'']
θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' S θ ([S]-env-absent (S'' ₛ)) S∈
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap))
S∈Domθ←[S'']
⟨θ←[S'']⟩S''≡[S'']S'' = Env.sig-stats-←-right-irr' (S'' ₛ) θ ([S]-env (S'' ₛ))
S''∈[S''] S''∈Domθ←[S'']
s∈canθ-p-θ←[S↦absent] =
canθₛₕ-set-sig-monotonic sigs (suc S'') p S
(θ ← [S]-env-absent (S'' ₛ))
S∈Domθ←[S''] status
(trans (sym θS≡⟨θ←[S'']⟩S) θS≡unknown)
(S∉sigs ∘ there) s
(subst (s ∈_)
(cong (Canθₛₕ sigs (suc S'') p)
(sym (Env.sig-switch S status θ ([S]-env-absent (S'' ₛ))
S∈ (Env.sig-←-monoˡ S θ ([S]-env-absent (S'' ₛ)) S∈)
(Env.sig-∉-single S (S'' ₛ) Signal.absent
(S∉sigs ∘ here ∘ cong Signal.unwrap)))))
s∈canθ-p-θ')
private -- re-defined and exported in Base; so we put it in private here
[_↦_] : Signal → Signal.Status → Env
[ S ↦ status ] = Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty
canθₛ-cong-←-add-sig-monotonic : ∀ sigs S'' p θ θ' S status →
∀ S' →
S' ∈ Canθₛ sigs S'' p ((θ ← Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty) ← θ') →
S' ∈ Canθₛ sigs S'' p ((θ ← [S]-env S) ← θ')
canθₛ-cong-←-add-sig-monotonic sigs S'' p θ θ' S status S' S'∈
with Env.Sig∈ S θ'
... | yes S∈Domθ'
rewrite sym (Env.←-assoc θ [ S ↦ status ] θ')
| cong (θ ←_) (Env.←-single-overwrite-sig S status θ' S∈Domθ')
| sym (Env.←-assoc θ ([S]-env S) θ')
| cong (θ ←_) (Env.←-single-overwrite-sig S Signal.unknown θ' S∈Domθ')
= S'∈
... | no S∉Domθ'
rewrite Env.←-assoc-comm θ ([S]-env S) θ'
(Env.sig-single-notin-distinct S Signal.unknown θ' S∉Domθ')
= canθₛ-add-sig-monotonic sigs S'' p (θ ← θ') S status S'
(subst (S' ∈_)
(cong (proj₁ ∘ Canθ sigs S'' p)
(Env.←-assoc-comm θ [ S ↦ status ] θ'
(Env.sig-single-notin-distinct S status θ' S∉Domθ')))
S'∈)
| {
"alphanum_fraction": 0.5328647703,
"avg_line_length": 49.0399408284,
"ext": "agda",
"hexsha": "b62259e7aefdc48122993b6e6d71d710292e401d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/Esterel/Lang/CanFunction/SetSigMonotonic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "florence/esterel-calculus",
"max_issues_repo_path": "agda/Esterel/Lang/CanFunction/SetSigMonotonic.agda",
"max_line_length": 107,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/Esterel/Lang/CanFunction/SetSigMonotonic.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 30893,
"size": 66302
} |
module Issue1624 where
open import Common.Char
open import Common.String
open import Common.List
test : List Char → String
test ('0' ∷ ('x' ∷ xs)) = "x"
test ('0' ∷ ('b' ∷ xs)) = "b"
test xs = "f"
open import Common.IO
open import Common.Unit
main : IO Unit
main = putStr (test x)
where x = '0' ∷ ('x' ∷ ('1' ∷ []))
| {
"alphanum_fraction": 0.5845697329,
"avg_line_length": 17.7368421053,
"ext": "agda",
"hexsha": "dd1661a201ddf76d4f72a93741b5ccbaea0abd92",
"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/Compiler/simple/Issue1624.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/Compiler/simple/Issue1624.agda",
"max_line_length": 36,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Compiler/simple/Issue1624.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": 113,
"size": 337
} |
------------------------------------------------------------------------
-- A coinductive definition of (strong) similarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Labelled-transition-system
module Similarity {ℓ} (lts : LTS ℓ) where
open import Equality.Propositional
open import Prelude
open import Prelude.Size
open import Bisimilarity lts as SB using ([_]_∼_; [_]_∼′_)
open import Indexed-container hiding (⟨_⟩)
open import Relation
import Similarity.General
open LTS lts
private
module General = Similarity.General lts _[_]⟶_ id
open General public
using (module StepC; ⟨_⟩; challenge; force;
reflexive-≤; reflexive-≤′; ≡⇒≤; ≤:_; ≤′:_;
[_]_≡_; [_]_≡′_; []≡↔; Extensionality; extensionality)
-- StepC is given in the following way, rather than via open public,
-- to make hyperlinks to it more informative.
StepC : Container (Proc × Proc) (Proc × Proc)
StepC = General.StepC
-- The following definitions are given explicitly, in order to make
-- the code easier to follow.
Similarity : Size → Rel₂ ℓ Proc
Similarity = ν StepC
Similarity′ : Size → Rel₂ ℓ Proc
Similarity′ = ν′ StepC
infix 4 [_]_≤_ [_]_≤′_ _≤_ _≤′_
[_]_≤_ : Size → Proc → Proc → Type ℓ
[ i ] p ≤ q = ν StepC i (p , q)
[_]_≤′_ : Size → Proc → Proc → Type ℓ
[ i ] p ≤′ q = ν′ StepC i (p , q)
_≤_ : Proc → Proc → Type ℓ
_≤_ = [ ∞ ]_≤_
_≤′_ : Proc → Proc → Type ℓ
_≤′_ = [ ∞ ]_≤′_
private
-- However, these definitions are definitionally equivalent to
-- corresponding definitions in General.
indirect-Similarity : Similarity ≡ General.Similarity
indirect-Similarity = refl
indirect-Similarity′ : Similarity′ ≡ General.Similarity′
indirect-Similarity′ = refl
indirect-[]≤ : [_]_≤_ ≡ General.[_]_≤_
indirect-[]≤ = refl
indirect-[]≤′ : [_]_≤′_ ≡ General.[_]_≤′_
indirect-[]≤′ = refl
indirect-≤ : _≤_ ≡ General._≤_
indirect-≤ = refl
indirect-≤′ : _≤′_ ≡ General._≤′_
indirect-≤′ = refl
mutual
-- Bisimilarity is contained in similarity.
∼⇒≤ : ∀ {i p q} → [ i ] p ∼ q → [ i ] p ≤ q
∼⇒≤ = λ p∼q →
⟨ (λ q⟶q′ →
let p′ , p⟶p′ , p′∼′q′ = SB.left-to-right p∼q q⟶q′
in p′ , p⟶p′ , ∼⇒≤′ p′∼′q′)
⟩
∼⇒≤′ : ∀ {i p q} → [ i ] p ∼′ q → [ i ] p ≤′ q
force (∼⇒≤′ p≳′q) = ∼⇒≤ (SB.force p≳′q)
mutual
-- Similarity is transitive.
transitive-≤ : ∀ {i p q r} → [ i ] p ≤ q → [ i ] q ≤ r → [ i ] p ≤ r
transitive-≤ p≤q q≤r =
⟨ (λ p⟶p′ →
let q′ , q⟶q′ , p′≤q′ = challenge p≤q p⟶p′
r′ , r⟶r′ , q′≤r′ = challenge q≤r q⟶q′
in r′ , r⟶r′ , transitive-≤′ p′≤q′ q′≤r′)
⟩
transitive-≤′ :
∀ {i p q r} → [ i ] p ≤′ q → [ i ] q ≤′ r → [ i ] p ≤′ r
force (transitive-≤′ p≤q q≤r) = transitive-≤ (force p≤q) (force q≤r)
| {
"alphanum_fraction": 0.5458452722,
"avg_line_length": 25.1531531532,
"ext": "agda",
"hexsha": "7efa0bb4e5932edf1215046927ebca0c68f3442f",
"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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Similarity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"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/up-to",
"max_issues_repo_path": "src/Similarity.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Similarity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1096,
"size": 2792
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Empty.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty.Base
isProp⊥ : isProp ⊥
isProp⊥ x = ⊥-elim x
| {
"alphanum_fraction": 0.7543103448,
"avg_line_length": 19.3333333333,
"ext": "agda",
"hexsha": "f21ca377833c58d6f104ea5fc0cf9447426f3e98",
"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": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "limemloh/cubical",
"max_forks_repo_path": "Cubical/Data/Empty/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"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": "limemloh/cubical",
"max_issues_repo_path": "Cubical/Data/Empty/Properties.agda",
"max_line_length": 42,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "limemloh/cubical",
"max_stars_repo_path": "Cubical/Data/Empty/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 68,
"size": 232
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Naturals
open import Numbers.Naturals.Order
open import Numbers.Naturals.Order.Lemmas
open import Numbers.Naturals.Order.WellFounded
open import KeyValue.KeyValue
open import Orders.Total.Definition
open import Orders.Partial.Definition
open import Vectors
open import Maybe
open import Semirings.Definition
open import Numbers.Naturals.EuclideanAlgorithm
module Numbers.Primes.PrimeNumbers where
open TotalOrder ℕTotalOrder
open Semiring ℕSemiring
open import Decidable.Lemmas ℕDecideEquality
dividesEqualityLemma'' : {a b : ℕ} → (quot1 quot2 : ℕ) → .(quot1 ≡ quot2) → (rem : ℕ) → .(pr1 : (quot1 +N a *N quot1) +N rem ≡ b) → .(pr2 : (quot2 +N a *N quot2) +N rem ≡ b) → (y : rem <N' succ a) → (x1 : zero <N' succ a) → _≡_ {A = divisionAlgResult' _ _} record { quot = quot1 ; rem = rem ; pr = pr1 ; remIsSmall = inl y ; quotSmall = inl x1 } record { quot = quot2 ; rem = rem ; pr = pr2 ; remIsSmall = inl y ; quotSmall = inl x1}
dividesEqualityLemma'' {a} {b} q1 q2 pr rem pr1 pr2 y x1 with squashN record { eq = pr }
... | refl = refl
dividesEqualityLemma' : {a b : ℕ} → (quot1 quot2 : ℕ) → (rem : ℕ) → .(pr1 : (quot1 +N a *N quot1) +N rem ≡ b) → .(pr2 : (quot2 +N a *N quot2) +N rem ≡ b) → (y : rem <N' succ a) → (y2 : rem <N' succ a) → (x1 : zero <N' succ a) → _≡_ {A = divisionAlgResult' _ _} record { quot = quot1 ; rem = rem ; pr = pr1 ; remIsSmall = inl y ; quotSmall = inl x1 } record { quot = quot2 ; rem = rem ; pr = pr2 ; remIsSmall = inl y2 ; quotSmall = inl x1}
dividesEqualityLemma' {a} {b} quot1 quot2 rem pr1 pr2 y y2 x1 with productCancelsLeft (succ a) quot2 quot1 (succIsPositive a) (canSubtractFromEqualityRight (transitivity (squashN record { eq = pr2 }) (equalityCommutative (squashN record { eq = pr1 }))))
... | refl with <N'Refl y y2
... | refl = refl
dividesEqualityLemma : {a b : ℕ} → (quot1 quot2 : ℕ) → (rem1 rem2 : ℕ) → .(pr1 : (quot1 +N a *N quot1) +N rem1 ≡ b) → .(pr2 : (quot2 +N a *N quot2) +N rem2 ≡ b) → .(rem1 ≡ rem2) → (y : rem1 <N' succ a) → (y2 : rem2 <N' succ a) → (x1 : zero <N' succ a) → _≡_ {A = divisionAlgResult' _ _} record { quot = quot1 ; rem = rem1 ; pr = pr1 ; remIsSmall = inl y ; quotSmall = inl x1 } record { quot = quot2 ; rem = rem2 ; pr = pr2 ; remIsSmall = inl y2 ; quotSmall = inl x1}
dividesEqualityLemma {a} {b} quot1 quot2 rem1 rem2 pr1 pr2 remEq y y2 x1 with squashN record { eq = remEq }
... | refl = dividesEqualityLemma' quot1 quot2 rem1 pr1 pr2 y y2 x1
dividesEqualityLemma1 : {a b : ℕ} → (quot1 quot2 : ℕ) → (rem1 rem2 : ℕ) → .(pr1 : (quot1 +N a *N quot1) +N rem1 ≡ b) → .(pr2 : (quot2 +N a *N quot2) +N rem2 ≡ b) → .(rem1 ≡ rem2) → (y : (rem1 <N' succ a) || (succ a =N' zero)) → (y2 : (rem2 <N' succ a) || (succ a =N' zero)) → (x1 : zero <N' succ a) → _≡_ {A = divisionAlgResult' _ _} record { quot = quot1 ; rem = rem1 ; pr = pr1 ; remIsSmall = y ; quotSmall = inl x1 } record { quot = quot2 ; rem = rem2 ; pr = pr2 ; remIsSmall = y2 ; quotSmall = inl x1}
dividesEqualityLemma1 {a} {b} quot1 quot2 rem1 rem2 pr1 pr2 remEq (inl x) (inl y) x1 = dividesEqualityLemma quot1 quot2 rem1 rem2 pr1 pr2 remEq x y x1
dividesEqualityLemma2 : {a b : ℕ} → (quot1 quot2 : ℕ) → (rem1 rem2 : ℕ) → .(pr1 : (quot1 +N a *N quot1) +N rem1 ≡ b) → .(pr2 : (quot2 +N a *N quot2) +N rem2 ≡ b) → .(rem1 ≡ rem2) → (y : (rem1 <N' succ a) || (succ a =N' zero)) → (y2 : (rem2 <N' succ a) || (succ a =N' zero)) → (x1 : zero <N' succ a) (x2 : zero <N' succ a) → _≡_ {A = divisionAlgResult' _ _} record { quot = quot1 ; rem = rem1 ; pr = pr1 ; remIsSmall = y ; quotSmall = inl x1 } record { quot = quot2 ; rem = rem2 ; pr = pr2 ; remIsSmall = y2 ; quotSmall = inl x2 }
dividesEqualityLemma2 {a} {b} quot1 quot2 rem1 rem2 pr1 pr2 remEq x y x1 x2 with <N'Refl x1 x2
... | refl = dividesEqualityLemma1 quot1 quot2 rem1 rem2 pr1 pr2 remEq x y x1
dividesEqualityLemma3 : {a b : ℕ} → (quot1 quot2 : ℕ) → (rem1 rem2 : ℕ) → .(pr1 : (succ a *N quot1) +N rem1 ≡ b) → .(pr2 : (succ a *N quot2) +N rem2 ≡ b) → .(rem1 ≡ rem2) → (y : (rem1 <N' succ a) || (succ a =N' zero)) → (y2 : (rem2 <N' succ a) || (succ a =N' zero)) → (x1 : (zero <N' succ a) || (zero =N' succ a) && (quot1 =N' zero)) (x2 : (zero <N' succ a) || (zero =N' succ a) && (quot2 =N' zero)) → _≡_ {A = divisionAlgResult' _ _} record { quot = quot1 ; rem = rem1 ; pr = pr1 ; remIsSmall = y ; quotSmall = x1 } record { quot = quot2 ; rem = rem2 ; pr = pr2 ; remIsSmall = y2 ; quotSmall = x2 }
dividesEqualityLemma3 {a} {b} quot1 quot2 rem1 rem2 pr1 pr2 remEq x y (inl x1) (inl x2) = dividesEqualityLemma2 quot1 quot2 rem1 rem2 pr1 pr2 remEq x y x1 x2
dividesEqualityPr' : {a b : ℕ} → (res1 res2 : divisionAlgResult' a b) → res1 ≡ res2
dividesEqualityPr' {zero} {zero} record { quot = quot₁ ; rem = rem₁ ; pr = pr1 ; remIsSmall = (inr f2) ; quotSmall = (inr (f4 ,, quot1=0)) } record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = (inr f1) ; quotSmall = (inr (f3 ,, quot=0)) } with squashN quot1=0
... | refl with squashN quot=0
... | refl with =N'Refl f1 f2
... | refl with =N'Refl f3 f4
... | refl with =N'Refl quot1=0 quot=0
... | refl with transitivity (squashN record { eq = pr }) (equalityCommutative (squashN record { eq = pr1 }))
... | refl = refl
dividesEqualityPr' {zero} {succ b} record { quot = quot1 ; rem = rem1 ; pr = pr1 ; remIsSmall = (inr rSm) ; quotSmall = (inr (f ,, quot1=0)) } record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = (inr rSm2) ; quotSmall = (inr (f2 ,, quot=0)) } with squashN quot=0
... | refl with squashN quot1=0
... | refl with =N'Refl rSm rSm2
... | refl with =N'Refl quot1=0 quot=0
... | refl with =N'Refl f f2
... | refl with transitivity (squashN record { eq = pr }) (equalityCommutative (squashN record { eq = pr1 }))
... | refl = refl
dividesEqualityPr' {succ a} {zero} record { quot = quot1 ; rem = rem1 ; pr = pr1 ; remIsSmall = (inl remSm) ; quotSmall = (inl qSm) } record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = (inl remSm2) ; quotSmall = (inl qSm2) } with sumZeroImpliesSummandsZero {quot +N a *N quot} {rem} (squashN record { eq = pr })
... | fst ,, refl with sumZeroImpliesSummandsZero {quot} {_} fst
... | refl ,, _ with sumZeroImpliesSummandsZero {_} {rem1} (squashN record { eq = pr1 })
... | fst2 ,, refl with sumZeroImpliesSummandsZero {quot1} {_} fst2
... | refl ,, _ with <N'Refl remSm remSm2
... | refl with <N'Refl qSm qSm2
... | refl = refl
dividesEqualityPr' {succ a} {succ b} record { quot = quot1 ; rem = rem1 ; pr = pr1 ; remIsSmall = inl remIsSmall1 ; quotSmall = inl (quotSmall1) } record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = inl remIsSmall ; quotSmall = (inl quotSmall) } = dividesEqualityLemma3 quot1 quot rem1 rem pr1 pr t (inl remIsSmall1) (inl remIsSmall) (inl quotSmall1) (inl quotSmall)
where
t : rem1 ≡ rem
t = modIsUnique record { quot = quot1 ; rem = rem1 ; pr = squash pr1 ; remIsSmall = inl (<N'To<N remIsSmall1) ; quotSmall = inl (<N'To<N quotSmall) } record { quot = quot ; rem = rem ; pr = squash pr ; remIsSmall = inl (<N'To<N remIsSmall) ; quotSmall = inl (<N'To<N quotSmall1) }
dividesEquality : {a b : ℕ} → (res1 res2 : a ∣' b) → res1 ≡ res2
dividesEquality (divides' res1 x1) (divides' res2 x2) with dividesEqualityPr' res1 res2
... | refl = refl
data notDiv : ℕ → ℕ → Set where
doesNotDivide : {a b : ℕ} → (res : divisionAlgResult a b) → 0 <N divisionAlgResult.rem res → notDiv a b
twoDividesFour : succ (succ zero) ∣ succ (succ (succ (succ zero)))
twoDividesFour = divides {(succ (succ zero))} {succ (succ (succ (succ zero)))} (record { quot = succ (succ zero) ; rem = zero ; pr = refl ; remIsSmall = inl (succIsPositive 1) ; quotSmall = inl (succIsPositive 1) }) refl
record Prime (p : ℕ) : Set where
field
p>1 : 1 <N p
pr : forall {i : ℕ} → i ∣ p → i <N p → zero <N i → i ≡ (succ zero)
record Composite (n : ℕ) : Set where
field
n>1 : 1 <N n
divisor : ℕ
dividesN : divisor ∣ n
divisorLessN : divisor <N n
divisorNot1 : 1 <N divisor
divisorPrime : Prime divisor
noSmallerDivisors : ∀ i → i <N divisor → 1 <N i → i ∣ n → False
notBothPrimeAndComposite : {n : ℕ} → Composite n → Prime n → False
notBothPrimeAndComposite {n} record { n>1 = n>1 ; divisor = divisor ; dividesN = dividesN ; divisorLessN = divisorLessN ; divisorNot1 = divisorNot1 } record { p>1 = p>1 ; pr = pr } = lessImpliesNotEqual divisorNot1 (equalityCommutative div=1)
where
div=1 : divisor ≡ 1
div=1 = pr {divisor} dividesN divisorLessN (TotalOrder.<Transitive ℕTotalOrder (succIsPositive 0) divisorNot1)
zeroIsNotPrime : Prime 0 → False
zeroIsNotPrime record { p>1 = p>1 ; pr = pr } = zeroNeverGreater p>1
oneIsNotPrime : Prime 1 → False
oneIsNotPrime record { p>1 = (le x proof) ; pr = pr } = naughtE (equalityCommutative absurd')
where
absurd : x +N 1 ≡ 0
absurd = succInjective proof
absurd' : succ x ≡ 0
absurd' rewrite Semiring.commutative ℕSemiring 1 x = absurd
twoIsPrime : Prime 2
Prime.p>1 twoIsPrime = succPreservesInequality (succIsPositive 0)
Prime.pr twoIsPrime {i} i|2 i<2 0<i with totality i (succ (succ zero))
Prime.pr twoIsPrime {zero} i|2 i<2 (le x ()) | order
Prime.pr twoIsPrime {succ zero} i|2 i<2 0<i | order = refl
Prime.pr twoIsPrime {succ (succ zero)} i|2 i<2 0<i | order = exFalso (lessImpliesNotEqual {2} i<2 refl)
Prime.pr twoIsPrime {succ (succ (succ i))} i|2 i<2 0<i | inl (inl x) = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder i<2 (succPreservesInequality (succPreservesInequality (succIsPositive i)))))
Prime.pr twoIsPrime {succ (succ (succ i))} i|2 i<2 0<i | inl (inr twoLessThree) = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder twoLessThree i<2))
Prime.pr twoIsPrime {succ (succ (succ i))} i|2 i<2 0<i | inr ()
threeIsPrime : Prime 3
Prime.p>1 threeIsPrime = le 1 refl
Prime.pr threeIsPrime {succ zero} i|3 i<3 _ = refl
Prime.pr threeIsPrime {succ (succ zero)} (divides record { quot = (succ (succ (succ zero))) ; rem = zero ; pr = () ; remIsSmall = remIsSmall ; quotSmall = quotSmall } x) i<3 _
Prime.pr threeIsPrime {succ (succ zero)} (divides record { quot = (succ (succ (succ (succ quot)))) ; rem = zero ; pr = () ; remIsSmall = remIsSmall ; quotSmall = quotSmall } x) i<3 _
Prime.pr threeIsPrime {succ (succ (succ i))} i|3 (le (succ (succ zero)) ()) _
Prime.pr threeIsPrime {succ (succ (succ i))} i|3 (le (succ (succ (succ x))) ()) _
compositeImpliesNotPrime : (m p : ℕ) → (succ zero <N m) → (m <N p) → (m ∣ p) → Prime p → False
compositeImpliesNotPrime zero p (le x ()) _ mDivP pPrime
compositeImpliesNotPrime (succ zero) p mLarge _ mDivP pPrime = lessImpliesNotEqual {succ zero} {succ zero} mLarge refl
compositeImpliesNotPrime (succ (succ m)) zero _ _ mDivP ()
compositeImpliesNotPrime (succ (succ m)) (succ zero) _ _ mDivP primeP = exFalso (oneIsNotPrime primeP)
compositeImpliesNotPrime (succ (succ m)) (succ (succ p)) _ mLessP mDivP pPrime = false
where
r = succ (succ m)
q = succ (succ p)
rEqOne : r ≡ succ zero
rEqOne = (Prime.pr pPrime) {r} mDivP mLessP (succIsPositive (succ m))
false : False
false = succIsNonzero (succInjective rEqOne)
fourIsNotPrime : Prime 4 → False
fourIsNotPrime = compositeImpliesNotPrime (succ (succ zero)) (succ (succ (succ (succ zero)))) (le zero refl) (le (succ zero) refl) twoDividesFour
record Coprime (a : ℕ) (b : ℕ) : Set where
field
hcf : hcfData a b
hcfNot1 : 1 <N hcfData.c hcf
record numberLessThan (n : ℕ) : Set where
field
a : ℕ
a<n : a <N' n
upper : ℕ
upper = n
numberLessThanEquality : {n : ℕ} → (a b : numberLessThan n) → (numberLessThan.a a ≡ numberLessThan.a b) → a ≡ b
numberLessThanEquality record { a = a ; a<n = a<n } record { a = b ; a<n = b<n } pr rewrite pr | <N'Refl a<n b<n = refl
numberLessThanOrder : (n : ℕ) → TotalOrder (numberLessThan n)
PartialOrder._<_ (TotalOrder.order (numberLessThanOrder n)) = λ a b → (numberLessThan.a a) <N numberLessThan.a b
PartialOrder.irreflexive (TotalOrder.order (numberLessThanOrder n)) pr = TotalOrder.irreflexive ℕTotalOrder pr
PartialOrder.<Transitive (TotalOrder.order (numberLessThanOrder n)) pr1 pr2 = TotalOrder.<Transitive ℕTotalOrder pr1 pr2
TotalOrder.totality (numberLessThanOrder n) a b with totality (numberLessThan.a a) (numberLessThan.a b)
TotalOrder.totality (numberLessThanOrder n) a b | inl (inl x) = inl (inl x)
TotalOrder.totality (numberLessThanOrder n) a b | inl (inr x) = inl (inr x)
TotalOrder.totality (numberLessThanOrder n) a b | inr x rewrite x = inr (numberLessThanEquality a b x)
numberLessThanInject : {newMax : ℕ} → (max : ℕ) → (n : numberLessThan max) → (max <N newMax) → (numberLessThan newMax)
numberLessThanInject max record { a = n ; a<n = n<max } max<newMax = record { a = n ; a<n = <NTo<N' (PartialOrder.<Transitive (TotalOrder.order ℕTotalOrder) (<N'To<N n<max) max<newMax) }
numberLessThanInjectComp : {max : ℕ} (a b : ℕ) → (i : numberLessThan b) → (pr : b <N a) → (pr2 : a <N max) → numberLessThanInject {max} a (numberLessThanInject {a} b i pr) pr2 ≡ numberLessThanInject {max} b i (PartialOrder.<Transitive (TotalOrder.order ℕTotalOrder) pr pr2)
numberLessThanInjectComp {max} a b record { a = i ; a<n = i<max } b<a a<max = numberLessThanEquality _ _ refl
allNumbersLessThanDescending : (n : ℕ) → Vec (numberLessThan n) n
allNumbersLessThanDescending zero = []
allNumbersLessThanDescending (succ n) = record { a = n ; a<n = <NTo<N' (le zero refl) } ,- vecMap (λ i → numberLessThanInject {succ n} (numberLessThan.upper i) i (le zero refl)) (allNumbersLessThanDescending n)
allNumbersLessThan : (n : ℕ) → Vec (numberLessThan n) n
allNumbersLessThan n = vecRev (allNumbersLessThanDescending n)
maxDivides : (a b : ℕ) → ((TotalOrder.max ℕTotalOrder a b) ∣ a) → (TotalOrder.max ℕTotalOrder a b) ∣ b → (((a ≡ 0) && (0 <N b)) || ((b ≡ 0) && (0 <N a))) || (a ≡ b)
maxDivides a b max|a max|b with totality a b
maxDivides a b max|a max|b | inl (inl a<b) = inl (inl (record { fst = gg ; snd = identityOfIndiscernablesLeft _<N_ a<b gg}))
where
gg : a ≡ 0
gg = biggerThanCantDivideLemma {a} {b} a<b max|a
maxDivides a b max|a max|b | inl (inr b<a) = inl (inr (record { fst = gg ; snd = identityOfIndiscernablesLeft _<N_ b<a gg }))
where
gg : b ≡ 0
gg = biggerThanCantDivideLemma b<a max|b
maxDivides a .a a|max b|max | inr refl = inr refl
{-
hcfsEquivalent' : {a b : ℕ} → extensionalHCF a b → hcfData a b
hcfData.c (hcfsEquivalent' {a} {b} record { c = c ; c|a = c|a ; c|b = c|b ; hcfExtension = hcfExtension }) = c
hcfData.c|a (hcfsEquivalent' {a} {b} record { c = c ; c|a = c|a ; c|b = c|b ; hcfExtension = hcfExtension }) = c|a
hcfData.c|b (hcfsEquivalent' {a} {b} record { c = c ; c|a = c|a ; c|b = c|b ; hcfExtension = hcfExtension }) = c|b
hcfData.hcf (hcfsEquivalent' {a} {b} record { c = c ; c|a = c|a ; c|b = c|b ; hcfExtension = hcfExtension }) x x|a x|b with totality ℕTotalOrder x c
hcfData.hcf (hcfsEquivalent' {a} {b} record { c = c ; c|a = c|a ; c|b = c|b ; zeroCase = zeroCase ; hcfExtension = hcfExtension ; hcfExtensionIsRightLength = hIRL }) x x|a x|b | inl (inl x<c) = {!!}
where
xLess : numberLessThan c
xLess = record { a = x ; a<n = x<c }
pair : Set
pair = Sg (numberLessThan c) (λ i → (notDiv (numberLessThan.a i) a || notDiv (numberLessThan.a i) b) || (numberLessThan.a i ∣ a) & numberLessThan.a i ∣ b & (numberLessThan.a i ∣ c))
pr : Sg pair λ p → (lookup (MapWithDomain.map hcfExtension) xLess ≡ {!!})
pr = MapWithDomain.lookup' hcfExtension xLess (hcfsContains {a} {b} {x} (record { c = c ; c|a = c|a ; c|b = c|b ; zeroCase = zeroCase ; hcfExtension = hcfExtension ; hcfExtensionIsRightLength = hIRL }) x<c)
hcfData.hcf (hcfsEquivalent' {a} {b} record { c = c ; c|a = c|a ; c|b = c|b ; zeroCase = _ ; hcfExtension = hcfExtension ; hcfExtensionIsRightLength = _ }) x x|a x|b | inl (inr c<x) = {!!}
hcfData.hcf (hcfsEquivalent' {a} {b} record { c = c ; c|a = c|a ; c|b = c|b ; zeroCase = _ ; hcfExtension = hcfExtension ; hcfExtensionIsRightLength = _ }) x x|a x|b | inr x=c rewrite x=c = aDivA c
extensionalHCFEquality : {a b : ℕ} → {h1 h2 : extensionalHCF a b} → (extensionalHCF.c h1 ≡ extensionalHCF.c h2) → h1 ≡ h2
extensionalHCFEquality {a} {b} {record { c = c1 ; c|a = c|a1 ; c|b = c|b1 ; hcfExtension = hcfExtension1 }} {record { c = c2 ; c|a = c|a2 ; c|b = c|b2 ; hcfExtension = hcfExtension2 }} pr rewrite pr = {!!}
-}
divisorIsSmaller : {a b : ℕ} → a ∣ succ b → succ b <N a → False
divisorIsSmaller {a} {b} (divides record { quot = zero ; rem = .0 ; pr = pr } refl) sb<a rewrite Semiring.sumZeroRight ℕSemiring (a *N zero) = go
where
go : False
go rewrite Semiring.productZeroRight ℕSemiring a = naughtE pr
divisorIsSmaller {a} {b} (divides record { quot = (succ quot) ; rem = .0 ; pr = pr } refl) sb<a rewrite Semiring.sumZeroRight ℕSemiring (a *N succ quot) = go
where
go : False
go rewrite equalityCommutative pr = go'
where
go' : False
go' rewrite multiplicationNIsCommutative a (succ quot) = cannotAddAndEnlarge' sb<a
primeDivisorIs1OrP : {a p : ℕ} → (prime : Prime p) → (a ∣ p) → (a ≡ 1) || (a ≡ p)
primeDivisorIs1OrP {zero} {zero} prime a|p = inr refl
primeDivisorIs1OrP {zero} {succ p} prime a|p = exFalso (zeroDividesNothing p a|p)
primeDivisorIs1OrP {succ zero} {p} prime a|p = inl refl
primeDivisorIs1OrP {succ (succ a)} {p} prime a|p with totality (succ (succ a)) p
primeDivisorIs1OrP {succ (succ a)} {p} prime a|p | inl (inl ssa<p) = go p prime a|p ssa<p
where
go : (n : ℕ) → Prime n → succ (succ a) ∣ n → succ (succ a) <N n → (succ (succ a) ≡ 1) || (succ (succ a) ≡ p)
go zero pr x|n n<n = exFalso (zeroIsNotPrime pr)
go (succ zero) pr x|n n<n = exFalso (oneIsNotPrime pr)
go (succ (succ n)) pr x|n n<n = inl ((Prime.pr pr) {succ (succ a)} x|n n<n (succIsPositive (succ a)))
primeDivisorIs1OrP {succ (succ a)} {zero} prime a|p | inl (inr x) = exFalso (zeroIsNotPrime prime)
primeDivisorIs1OrP {succ (succ a)} {succ p} prime a|p | inl (inr x) = exFalso (divisorIsSmaller {succ (succ a)} {p} a|p x)
primeDivisorIs1OrP {succ (succ a)} {p} prime a|p | inr x = inr x
hcfPrimeIsOne' : {p : ℕ} → {a : ℕ} → (Prime p) → (0 <N divisionAlgResult.rem (divisionAlg p a)) → (extendedHcf.c (euclid a p) ≡ 1) || (extendedHcf.c (euclid a p) ≡ p)
hcfPrimeIsOne' {p} {a} pPrime pCoprimeA with euclid a p
hcfPrimeIsOne' {p} {a} pPrime pCoprimeA | record { hcf = record { c = hcf ; c|a = hcf|a ; c|b = hcf|p ; hcf = hcfPr } } with divisionAlg p a
hcfPrimeIsOne' {p} {a} pPrime pCoprimeA | record { hcf = record { c = hcf ; c|a = hcf|a ; c|b = hcf|p ; hcf = hcfPr } } | record { quot = quot ; rem = rem ; pr = prPDivA } with primeDivisorIs1OrP pPrime hcf|p
hcfPrimeIsOne' {p} {a} pPrime pCoprimeA | record { hcf = record { c = hcf ; c|a = hcf|a ; c|b = hcf|p ; hcf = hcfPr } } | record { quot = quot ; rem = rem ; pr = prPDivA } | inl x = inl x
hcfPrimeIsOne' {p} {a} pPrime pCoprimeA | record { hcf = record { c = hcf ; c|a = hcf|a ; c|b = hcf|p ; hcf = hcfPr } } | record { quot = quot ; rem = rem ; pr = prPDivA } | inr x = inr x
divisionDecidable : (a b : ℕ) → (a ∣ b) || ((a ∣ b) → False)
divisionDecidable zero zero = inl (aDivA zero)
divisionDecidable zero (succ b) = inr f
where
f : zero ∣ succ b → False
f (divides record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = remIsSmall } x) rewrite x = naughtE pr
divisionDecidable (succ a) b with divisionAlg (succ a) b
divisionDecidable (succ a) b | record { quot = quot ; rem = zero ; pr = pr ; remIsSmall = remSmall } = inl (divides (record { quot = quot ; rem = zero ; pr = pr ; remIsSmall = remSmall ; quotSmall = inl (succIsPositive a) }) refl)
divisionDecidable (succ a) b | record { quot = b/a ; rem = succ rem ; pr = prANotDivB ; remIsSmall = inr p } = exFalso (naughtE (equalityCommutative p))
divisionDecidable (succ a) b | record { quot = b/a ; rem = succ rem ; pr = prANotDivB ; remIsSmall = inl p } = inr f
where
f : (succ a) ∣ b → False
f (divides record { quot = b/a' ; rem = .0 ; pr = pr } refl) rewrite Semiring.sumZeroRight ℕSemiring ((succ a) *N b/a') = naughtE (modUniqueLemma {zero} {succ rem} {succ a} b/a' b/a (succIsPositive a) p comp')
where
comp : (succ a) *N b/a' ≡ (succ a) *N b/a +N succ rem
comp = transitivity pr (equalityCommutative prANotDivB)
comp' : (succ a) *N b/a' +N zero ≡ (succ a) *N b/a +N succ rem
comp' rewrite Semiring.sumZeroRight ℕSemiring (succ a *N b/a') = comp
doesNotDivideImpliesNonzeroRem : (a b : ℕ) → ((a ∣ b) → False) → 0 <N divisionAlgResult.rem (divisionAlg a b)
doesNotDivideImpliesNonzeroRem a b pr with divisionAlg a b
doesNotDivideImpliesNonzeroRem a b pr | record { quot = quot ; rem = rem ; pr = divAlgPr ; remIsSmall = remIsSmall } with zeroIsValidRem rem
doesNotDivideImpliesNonzeroRem a b pr | record { quot = quot ; rem = rem ; pr = divAlgPr ; remIsSmall = remIsSmall } | inl x = x
doesNotDivideImpliesNonzeroRem a b pr | record { quot = quot ; rem = rem ; pr = divAlgPr ; remIsSmall = remIsSmall ; quotSmall = quotSmall } | inr x = exFalso (pr aDivB)
where
aDivB : a ∣ b
aDivB = divides (record { quot = quot ; rem = rem ; pr = divAlgPr ; remIsSmall = remIsSmall ; quotSmall = quotSmall }) x
hcfPrimeIsOne : {p : ℕ} → {a : ℕ} → (Prime p) → ((p ∣ a) → False) → extendedHcf.c (euclid a p) ≡ 1
hcfPrimeIsOne {p} {a} pPrime pr with hcfPrimeIsOne' {p} {a} pPrime (doesNotDivideImpliesNonzeroRem p a pr)
hcfPrimeIsOne {p} {a} pPrime pr | inl x = x
hcfPrimeIsOne {p} {a} pPrime pr | inr x with euclid a p
hcfPrimeIsOne {p} {a} pPrime pr | inr x | record { hcf = record { c = c ; c|a = c|a ; c|b = c|b ; hcf = hcf } ; extended1 = extended1 ; extended2 = extended2 ; extendedProof = extendedProof } rewrite x = exFalso (pr c|a)
reduceEquationMod : {a b c : ℕ} → (d : ℕ) → (a ∣ b) → (a ∣ c) → b ≡ c +N d → a ∣ d
reduceEquationMod {a} {b} {c} 0 a|b a|c pr = aDivZero a
reduceEquationMod {a} {b} {c} (succ d) (divides record { quot = b/a ; rem = .0 ; pr = prb/a ; remIsSmall = r1 ; quotSmall = qSm1 } refl) (divides record { quot = c/a ; rem = .0 ; pr = prc/a ; remIsSmall = r2 ; quotSmall = qSm2 } refl) b=c+d = identityOfIndiscernablesRight _∣_ a|b-c ex
where
c<b : c <N b
c<b rewrite succExtracts c d | Semiring.commutative ℕSemiring c d = le d (equalityCommutative b=c+d)
a|b-c : a ∣ subtractionNResult.result (-N (inl c<b))
a|b-c = dividesBothImpliesDividesDifference (divides record { quot = b/a ; rem = 0 ; pr = prb/a ; remIsSmall = r1 ; quotSmall = qSm1 } refl) (divides record { quot = c/a ; rem = 0 ; pr = prc/a ; remIsSmall = r2 ; quotSmall = qSm2 } refl) c<b
ex : subtractionNResult.result (-N {c} {b} (inl c<b)) ≡ subtractionNResult.result (-N {0} {succ d} (inl (succIsPositive d)))
ex = equivalentSubtraction c (succ d) b 0 (c<b) (succIsPositive d) (equalityCommutative (identityOfIndiscernablesLeft _≡_ b=c+d (equalityCommutative (Semiring.sumZeroRight ℕSemiring b))))
primesArePrime : {p : ℕ} → {a b : ℕ} → (Prime p) → p ∣ (a *N b) → (p ∣ a) || (p ∣ b)
primesArePrime {p} {a} {b} pPrime pr with divisionDecidable p a
primesArePrime {p} {a} {b} pPrime pr | inl p|a = inl p|a
primesArePrime {p} {a} {b} pPrime (divides record {quot = ab/p ; rem = .0 ; pr = p|ab ; remIsSmall = _ ; quotSmall = quotSmall } refl) | inr notp|a = inr (answer ex'')
where
euc : extendedHcf a p
euc = euclid a p
h : extendedHcf.c euc ≡ 1
h = hcfPrimeIsOne {p} {a} pPrime notp|a
x = extendedHcf.extended1 euc
y = extendedHcf.extended2 euc
extended : ((a *N x) ≡ p *N y +N extendedHcf.c euc) || (a *N x +N extendedHcf.c euc ≡ p *N y)
extended = extendedHcf.extendedProof euc
extended' : (a *N x ≡ p *N y +N 1) || (a *N x +N 1 ≡ p *N y)
extended' rewrite equalityCommutative h = extended
extended'' : ((a *N x ≡ p *N y +N 1) || (a *N x +N 1 ≡ p *N y)) → (b *N (a *N x) ≡ b *N (p *N y +N 1)) || (b *N (a *N x +N 1) ≡ b *N (p *N y))
extended'' (inl z) = inl (applyEquality (λ t → b *N t) z)
extended'' (inr z) = inr (applyEquality (λ t → b *N t) z)
ex : (b *N (a *N x) ≡ b *N (p *N y +N 1)) || (b *N (a *N x +N 1) ≡ b *N (p *N y)) → ((b *N a) *N x ≡ (b *N (p *N y) +N b)) || (((b *N a) *N x +N b) ≡ b *N (p *N y))
ex (inl z) rewrite Semiring.*Associative ℕSemiring b a x | Semiring.+DistributesOver* ℕSemiring b (p *N y) 1 | Semiring.productOneRight ℕSemiring b = inl z
ex (inr z) rewrite Semiring.+DistributesOver* ℕSemiring b (a *N x) 1 | Semiring.*Associative ℕSemiring b a x | Semiring.productOneRight ℕSemiring b = inr z
ex' : ((a *N b) *N x ≡ ((p *N y) *N b +N b)) || (((a *N b) *N x +N b) ≡ (p *N y) *N b)
ex' rewrite multiplicationNIsCommutative a b | multiplicationNIsCommutative (p *N y) b = ex (extended'' extended')
ex'' : ((a *N b) *N x ≡ (p *N (y *N b) +N b)) || (((a *N b) *N x +N b) ≡ p *N (y *N b))
ex'' rewrite Semiring.*Associative ℕSemiring (p) y b = ex'
inter1 : p ∣ (a *N b) *N x
inter1 = divides (record {quot = ab/p *N x ; rem = 0 ; pr = g ; remIsSmall = zeroIsValidRem p ; quotSmall = qsm quotSmall}) refl
where
g' : p *N ab/p ≡ a *N b
g' rewrite Semiring.sumZeroRight ℕSemiring (p *N ab/p) = p|ab
g'' : p *N (ab/p *N x) ≡ (a *N b) *N x
g'' rewrite Semiring.*Associative ℕSemiring (p) ab/p x = applyEquality (λ t → t *N x) g'
g : p *N (ab/p *N x) +N 0 ≡ (a *N b) *N x
g rewrite Semiring.sumZeroRight ℕSemiring (p *N (ab/p *N x)) = g''
qsm : ((0 <N p) || ((0 ≡ p) && (ab/p ≡ 0))) → (0 <N p) || ((0 ≡ p) && (ab/p *N x ≡ 0))
qsm (inl pr) = inl pr
qsm (inr (pr1 ,, pr2)) = inr (pr1 ,, blah)
where
blah : ab/p *N x ≡ 0
blah rewrite pr2 = refl
inter2 : ((0 <N p) || ((0 ≡ p) && (ab/p ≡ 0))) → p ∣ (p *N (y *N b))
inter2 (inl 0<p) = divides (record {quot = y *N b ; rem = 0 ; pr = Semiring.sumZeroRight ℕSemiring (p *N (y *N b)) ; remIsSmall = zeroIsValidRem p ; quotSmall = inl 0<p }) refl
inter2 (inr (0=p ,, ab/p=0)) = divides (record {quot = y *N b ; rem = 0 ; pr = Semiring.sumZeroRight ℕSemiring (p *N (y *N b)) ; remIsSmall = zeroIsValidRem p ; quotSmall = inr (0=p ,, blah) }) refl
where
oneZero : (a ≡ 0) || (b ≡ 0)
oneZero rewrite Semiring.commutative ℕSemiring (p *N ab/p) 0 | ab/p=0 | equalityCommutative 0=p = productZeroImpliesOperandZero (equalityCommutative p|ab)
blah : y *N b ≡ 0
blah with oneZero
blah | inl x1 = exFalso (notp|a p|a)
where
p|a : p ∣ a
p|a rewrite x1 = aDivZero p
blah | inr x1 rewrite x1 = Semiring.productZeroRight ℕSemiring y
answer : ((a *N b) *N x ≡ (p *N (y *N b) +N b)) || (((a *N b) *N x +N b) ≡ p *N (y *N b)) → (p ∣ b)
answer (inl z) = reduceEquationMod {p} b inter1 (inter2 quotSmall) z
answer (inr z) = reduceEquationMod {p} b (inter2 quotSmall) inter1 (equalityCommutative z)
primesAreBiggerThanOne : {p : ℕ} → Prime p → (1 <N p)
primesAreBiggerThanOne {zero} record { p>1 = (le x ()) ; pr = pr }
primesAreBiggerThanOne {succ zero} pr = exFalso (oneIsNotPrime pr)
primesAreBiggerThanOne {succ (succ p)} pr = succPreservesInequality (succIsPositive p)
primesAreBiggerThanZero : {p : ℕ} → Prime p → 0 <N p
primesAreBiggerThanZero {p} pr = TotalOrder.<Transitive ℕTotalOrder (succIsPositive 0) (primesAreBiggerThanOne pr)
record notDividedByLessThan (a : ℕ) (firstPossibleDivisor : ℕ) : Set where
field
previousDoNotDivide : ∀ x → 1 <N x → x <N firstPossibleDivisor → x ∣ a → False
alternativePrime : {a : ℕ} → 1 <N a → notDividedByLessThan a a → Prime a
alternativePrime {a} 1<a record { previousDoNotDivide = previousDoNotDivide } = record { pr = pr ; p>1 = 1<a}
where
pr : {x : ℕ} → (x|a : x ∣ a) (x<a : x <N a) (0<x : zero <N x) → x ≡ 1
pr {zero} _ _ (le x ())
pr {succ zero} _ _ _ = refl
pr {succ (succ x)} x|a x<a 0<x = exFalso (previousDoNotDivide (succ (succ x)) (succPreservesInequality (succIsPositive x)) x<a x|a)
divisibilityTransitive : {a b c : ℕ} → a ∣ b → b ∣ c → a ∣ c
divisibilityTransitive {a} {b} {c} (divides record { quot = b/a ; rem = .0 ; pr = prDivAB ; remIsSmall = remIsSmallAB ; quotSmall = quotSmall } refl) (divides record { quot = c/b ; rem = .0 ; pr = prDivBC ; remIsSmall = remIsSmallBC } refl) = divides record { quot = b/a *N c/b ; rem = 0 ; pr = p ; remIsSmall = zeroIsValidRem a ; quotSmall = qsm quotSmall } refl
where
p : a *N (b/a *N c/b) +N 0 ≡ c
p rewrite Semiring.sumZeroRight ℕSemiring (a *N (b/a *N c/b)) | Semiring.sumZeroRight ℕSemiring (b *N c/b) | Semiring.sumZeroRight ℕSemiring (a *N b/a) | Semiring.*Associative ℕSemiring a b/a c/b | prDivAB | prDivBC = refl
qsm : ((0 <N a) || (0 ≡ a) && (b/a ≡ 0)) → ((0 <N a) || (0 ≡ a) && (b/a *N c/b ≡ 0))
qsm (inl x) = inl x
qsm (inr (p1 ,, p2)) = inr (p1 ,, blah)
where
blah : b/a *N c/b ≡ 0
blah rewrite p2 = refl
compositeOrPrimeLemma : {a b : ℕ} → notDividedByLessThan b a → a ∣ b → {i : ℕ} → (i ∣ a) → (i <N a) → (0 <N i) → i ≡ 1
compositeOrPrimeLemma {a} {b} record { previousDoNotDivide = previousDoNotDivide } a|b {zero} i|a i<a 0<i = exFalso (lessIrreflexive 0<i)
compositeOrPrimeLemma {a} {b} record { previousDoNotDivide = previousDoNotDivide } a|b {succ zero} i|a i<a 0<i = refl
compositeOrPrimeLemma {a} {b} record { previousDoNotDivide = previousDoNotDivide } a|b {succ (succ i)} i|a i<a 0<i = exFalso (previousDoNotDivide (succ (succ i)) (succPreservesInequality (succIsPositive i)) i<a (divisibilityTransitive i|a a|b) )
compositeOrPrime : (a : ℕ) → (1 <N a) → (Composite a) || (Prime a)
compositeOrPrime a pr = go''' go''
where
base : notDividedByLessThan a 2
base = record { previousDoNotDivide = λ x 1<x x<2 _ → noIntegersBetweenXAndSuccX 1 1<x x<2 }
go : {firstPoss : ℕ} → notDividedByLessThan a firstPoss → ((notDividedByLessThan a (succ firstPoss)) || ((firstPoss ∣ a) && (firstPoss <N a))) || (firstPoss ≡ a)
go' : (firstPoss : ℕ) → (((notDividedByLessThan a firstPoss) || (Composite a))) || (notDividedByLessThan a a)
go'' : (notDividedByLessThan a a) || (Composite a)
go'' with go' a
... | inr x = inl x
... | inl x = x
go''' : ((notDividedByLessThan a a) || (Composite a)) → ((Composite a) || (Prime a))
go''' (inl x) = inr (alternativePrime pr x)
go''' (inr x) = inl x
go' (zero) = inl (inl (record { previousDoNotDivide = λ x 1<x x<0 _ → zeroNeverGreater x<0 }))
go' (succ 0) = inl (inl (record { previousDoNotDivide = λ x 1<x x<1 _ → TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder x<1 1<x) }))
go' (succ (succ zero)) = inl (inl base)
go' (succ (succ (succ firstPoss))) with go' (succ (succ firstPoss))
go' (succ (succ (succ firstPoss))) | inl (inl x) with go {succ (succ firstPoss)} x
go' (succ (succ (succ firstPoss))) | inl (inl x) | inl (inl x1) = inl (inl x1)
go' (succ (succ (succ firstPoss))) | inl (inl x) | inl (inr x1) = inl (inr record { noSmallerDivisors = λ i i<ssFP 1<i i|a → notDividedByLessThan.previousDoNotDivide x i 1<i i<ssFP i|a ; n>1 = pr ; divisor = succ (succ firstPoss) ; dividesN = _&&_.fst x1 ; divisorLessN = _&&_.snd x1 ; divisorNot1 = succPreservesInequality (succIsPositive firstPoss) ; divisorPrime = record { p>1 = succPreservesInequality (succIsPositive firstPoss) ; pr = compositeOrPrimeLemma {succ (succ firstPoss)} {a} x (_&&_.fst x1) } })
go' (succ (succ (succ firstPoss))) | inl (inl x) | inr y rewrite y = inr x
go' (succ (succ (succ firstPoss))) | inl (inr x) = inl (inr x)
go' (succ (succ (succ firstPoss))) | inr x = inr x
go {zero} pr = inl (inl (record { previousDoNotDivide = λ x 1<x x<1 _ → irreflexive (<Transitive x<1 1<x)}))
go {succ firstPoss} knownCoprime with totality (succ firstPoss) a
go {succ firstPoss} knownCoprime | inr x = inr x
go {succ firstPoss} knownCoprime | inl (inl sFP<a) with divisionAlg (succ firstPoss) a
go {succ firstPoss} knownCoprime | inl (inl sFP<a) | record { quot = quot ; rem = zero ; pr = pr ; remIsSmall = remIsSmall } = inl (inr record { fst = (divides (record { quot = quot ; rem = zero ; remIsSmall = remIsSmall ; pr = pr ; quotSmall = inl (succIsPositive firstPoss) }) refl) ; snd = sFP<a })
go {succ firstPoss} knownCoprime | inl (inl sFP<a) | record { quot = quot ; rem = succ rem ; pr = pr ; remIsSmall = remIsSmall } = inl next
where
previous : ∀ x → 1 <N x → x <N succ firstPoss → x ∣ a → False
previous = notDividedByLessThan.previousDoNotDivide knownCoprime
next : notDividedByLessThan a (succ (succ firstPoss)) || (((succ firstPoss) ∣ a) && (succ firstPoss <N a))
next with divisionAlg (succ firstPoss) a
next | record { quot = quot ; rem = zero ; pr = pr ; remIsSmall = remIsSmall } = inr (record { fst = divides record { quot = quot ; rem = zero ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = inl (succIsPositive firstPoss) } refl ; snd = sFP<a } )
next | record { quot = quot ; rem = succ rem ; pr = pr ; remIsSmall = remIsSmall } = inl record { previousDoNotDivide = (next' record { quot = quot ; rem = succ rem ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = inl (succIsPositive firstPoss) } (succIsPositive rem)) }
where
next' : (res : divisionAlgResult (succ firstPoss) a) → (pr : 0 <N divisionAlgResult.rem res) → (x : ℕ) → 1 <N x → x <N succ (succ firstPoss) → x ∣ a → False
next' (res) (prDiv) x 1<x x<ssFirstposs x|a with totality x (succ firstPoss)
next' (res) (prDiv) x 1<x x<ssFirstposs x|a | inl (inl x<sFirstPoss) = previous x 1<x x<sFirstPoss x|a
next' (res) (prDiv) x 1<x x<ssFirstposs x|a | inl (inr sFirstPoss<x) = noIntegersBetweenXAndSuccX (succ firstPoss) sFirstPoss<x x<ssFirstposs
next' res prDiv x 1<x x<ssFirstposs (divides res1 x1) | inr x=sFirstPoss rewrite equalityCommutative x=sFirstPoss = g
where
g : False
g with modIsUnique res res1
... | r rewrite r = lessImpliesNotEqual prDiv (equalityCommutative x1)
go {succ firstPoss} record { previousDoNotDivide = previousDoNotDivide } | inl (inr a<sFP) = exFalso (previousDoNotDivide a pr a<sFP (aDivA a))
primeDivPrimeImpliesEqual : {p1 p2 : ℕ} → Prime p1 → Prime p2 → p1 ∣ p2 → p1 ≡ p2
primeDivPrimeImpliesEqual {p1} {p2} pr1 pr2 p1|p2 with totality p1 p2
primeDivPrimeImpliesEqual {p1} {p2} pr1 record { p>1 = p>1 ; pr = pr } p1|p2 | inl (inl p1<p2) with pr p1|p2 p1<p2 (primesAreBiggerThanZero {p1} pr1)
... | p1=1 = exFalso (oneIsNotPrime contr)
where
contr : Prime 1
contr rewrite p1=1 = pr1
primeDivPrimeImpliesEqual {p1} {zero} pr1 pr2 p1|p2 | inl (inr p1>p2) = exFalso (zeroIsNotPrime pr2)
primeDivPrimeImpliesEqual {p1} {succ p2} pr1 pr2 p1|p2 | inl (inr p1>p2) = exFalso (divisorIsSmaller p1|p2 p1>p2)
primeDivPrimeImpliesEqual {p1} {p2} pr1 pr2 p1|p2 | inr p1=p2 = p1=p2
mult1Lemma : {a b : ℕ} → a *N succ b ≡ 1 → (a ≡ 1) && (b ≡ 0)
mult1Lemma {a} {b} pr = record { fst = _&&_.fst p ; snd = q}
where
p : (a ≡ 1) && (succ b ≡ 1)
p = productOneImpliesOperandsOne pr
q : b ≡ zero
q = succInjective (_&&_.snd p)
oneHasNoDivisors : {a : ℕ} → a ∣ 1 → a ≡ 1
oneHasNoDivisors {a} (divides record { quot = zero ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall } refl) rewrite Semiring.sumZeroRight ℕSemiring (a *N zero) | multiplicationNIsCommutative a zero | Semiring.sumZeroRight ℕSemiring a = exFalso (naughtE pr)
oneHasNoDivisors {a} (divides record { quot = (succ quot) ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall } refl) rewrite Semiring.sumZeroRight ℕSemiring (a *N succ quot) = _&&_.fst (mult1Lemma pr)
notSmallerMeansGE : {a b : ℕ} → (a <N b → False) → b ≤N a
notSmallerMeansGE {a} {b} notA<b with totality a b
notSmallerMeansGE {a} {b} notA<b | inl (inl x) = exFalso (notA<b x)
notSmallerMeansGE {a} {b} notA<b | inl (inr x) = inl x
notSmallerMeansGE {a} {b} notA<b | inr x = inr (equalityCommutative x)
| {
"alphanum_fraction": 0.6366613928,
"avg_line_length": 76.1670190275,
"ext": "agda",
"hexsha": "0463dffb48f10e7f1b34f6cd1265b4bf0f426fc1",
"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/Primes/PrimeNumbers.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/Primes/PrimeNumbers.agda",
"max_line_length": 599,
"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/Primes/PrimeNumbers.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": 13603,
"size": 36027
} |
------------------------------------------------------------------------
-- Functional semantics for a non-deterministic untyped λ-calculus
-- with constants
------------------------------------------------------------------------
{-# OPTIONS --no-termination-check #-}
module Lambda.Closure.Functional.Non-deterministic.No-workarounds where
open import Category.Monad.Partiality as Pa using (_⊥; now; later)
open import Codata.Musical.Notation
open import Data.Fin using (Fin; zero; suc; #_)
open import Data.List hiding (lookup)
open import Data.Maybe hiding (_>>=_)
open import Data.Nat
open import Data.Vec using ([]; _∷_; lookup)
open import Function
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Lambda.Syntax using (Ty; Ctxt)
open Lambda.Syntax.Closure using (con; ƛ)
open Lambda.Syntax.Ty
open import Lambda.VirtualMachine
hiding (comp; comp-val; comp-env; lookup-hom)
open Functional
private
module VM = Lambda.Syntax.Closure Code
------------------------------------------------------------------------
-- A monad with partiality, failure and non-determinism
-- This is basically the maybe monad transformer applied to the
-- partiality monad transformer applied to the non-determinism monad
-- N A = μX. A ⊎ X × X. Unfortunately it is somewhat awkward to
-- implement the partiality monad transformer in Agda: the definition
--
-- data Partiality′ (M : Set → Set) (A : Set) : Set where
-- now-or-later : M (A ⊎ Partiality′ M A) → Partiality′ M A
--
-- is rejected, because M might use its argument negatively.
infixr 6 _∣_
data D (A : Set) : Set where
fail : D A
return : (x : A) → D A
_∣_ : (x y : D A) → D A
later : (x : ∞ (D A)) → D A
-- The function force n removes (up to) n layers of later
-- constructors.
force : {A : Set} → ℕ → D A → D A
force (suc n) (later x) = force n (♭ x)
force n (x₁ ∣ x₂) = force n x₁ ∣ force n x₂
force _ x = x
-- Bind.
infixl 5 _>>=_
_>>=_ : {A B : Set} → D A → (A → D B) → D B
fail >>= f = fail
return x >>= f = f x
(x₁ ∣ x₂) >>= f = (x₁ >>= f) ∣ (x₂ >>= f)
later x >>= f = later (♯ (♭ x >>= f))
-- A deterministic non-terminating computation.
never : {A : Set} → D A
never = later (♯ never)
-- Strong bisimilarity.
infix 4 _≅_
data _≅_ {A : Set} : D A → D A → Set where
fail : fail ≅ fail
return : ∀ {x} → return x ≅ return x
_∣_ : ∀ {x₁ x₂ y₁ y₂}
(x₁≅y₁ : x₁ ≅ y₁) (x₂≅y₂ : x₂ ≅ y₂) → x₁ ∣ x₂ ≅ y₁ ∣ y₂
later : ∀ {x y} (x≅y : ∞ (♭ x ≅ ♭ y)) → later x ≅ later y
-- Strong bisimilarity is reflexive.
infixr 3 _∎
_∎ : {A : Set} (x : D A) → x ≅ x
fail ∎ = fail
return x ∎ = return
x₁ ∣ x₂ ∎ = (x₁ ∎) ∣ (x₂ ∎)
later x ∎ = later (♯ (♭ x ∎))
-- Strong bisimilarity is symmetric.
sym : {A : Set} {x y : D A} → x ≅ y → y ≅ x
sym fail = fail
sym return = return
sym (x₁≅y₁ ∣ x₂≅y₂) = sym x₁≅y₁ ∣ sym x₂≅y₂
sym (later x≅y) = later (♯ sym (♭ x≅y))
-- Strong bisimilarity is transitive.
infixr 2 _≅⟨_⟩_
_≅⟨_⟩_ : ∀ {A : Set} (x : D A) {y z} → x ≅ y → y ≅ z → x ≅ z
._ ≅⟨ fail ⟩ fail = fail
._ ≅⟨ return ⟩ return = return
._ ≅⟨ x₁≅y₁ ∣ x₂≅y₂ ⟩ y₁≅z₁ ∣ y₂≅z₂ = (_ ≅⟨ x₁≅y₁ ⟩ y₁≅z₁) ∣ (_ ≅⟨ x₂≅y₂ ⟩ y₂≅z₂)
._ ≅⟨ later x≅y ⟩ later y≅z = later (♯ (_ ≅⟨ ♭ x≅y ⟩ ♭ y≅z))
-- The monad laws hold up to strong bisimilarity.
left-identity : {A B : Set} {x : A} {f : A → D B} →
return x >>= f ≅ f x
left-identity {x = x} {f} = f x ∎
right-identity : {A : Set} (x : D A) → x >>= return ≅ x
right-identity fail = fail
right-identity (return x) = return
right-identity (x₁ ∣ x₂) = right-identity x₁ ∣ right-identity x₂
right-identity (later x) = later (♯ right-identity (♭ x))
associative : {A B C : Set} (x : D A) {f : A → D B} {g : B → D C} →
x >>= f >>= g ≅ x >>= λ y → f y >>= g
associative fail = fail
associative (return x) {f} {g} = f x >>= g ∎
associative (x₁ ∣ x₂) = associative x₁ ∣ associative x₂
associative (later x) = later (♯ associative (♭ x))
-- Bind respects strong bisimilarity.
infixl 5 _>>=-cong_
_>>=-cong_ : {A B : Set} {x₁ x₂ : D A} {f₁ f₂ : A → D B} →
x₁ ≅ x₂ → (∀ y → f₁ y ≅ f₂ y) → x₁ >>= f₁ ≅ x₂ >>= f₂
fail >>=-cong f₁≅f₂ = fail
return >>=-cong f₁≅f₂ = f₁≅f₂ _
later x≅y >>=-cong f₁≅f₂ = later (♯ (♭ x≅y >>=-cong f₁≅f₂))
x₁≅x₂ ∣ y₁≅y₂ >>=-cong f₁≅f₂ =
(x₁≅x₂ >>=-cong f₁≅f₂) ∣ (y₁≅y₂ >>=-cong f₁≅f₂)
-- More laws.
never-left-zero : {A B : Set} {f : A → D B} → never >>= f ≅ never
never-left-zero = later (♯ never-left-zero)
fail-left-zero : {A B : Set} {f : A → D B} → fail >>= f ≅ fail
fail-left-zero = fail ∎
------------------------------------------------------------------------
-- Syntax
infixl 9 _·_
data Tm (n : ℕ) : Set where
con : (i : ℕ) → Tm n
var : (x : Fin n) → Tm n
ƛ : (t : Tm (suc n)) → Tm n
_·_ : (t₁ t₂ : Tm n) → Tm n
_∣_ : (t₁ t₂ : Tm n) → Tm n
-- Convenient helper.
vr : ∀ m {n} {m<n : True (suc m ≤? n)} → Tm n
vr _ {m<n = m<n} = var (#_ _ {m<n = m<n})
open Lambda.Syntax.Closure Tm hiding (con; ƛ)
------------------------------------------------------------------------
-- Semantics
infix 9 _∙_
mutual
⟦_⟧ : ∀ {n} → Tm n → Env n → D Value
⟦ con i ⟧ ρ = return (con i)
⟦ var x ⟧ ρ = return (lookup ρ x)
⟦ ƛ t ⟧ ρ = return (ƛ t ρ)
⟦ t₁ · t₂ ⟧ ρ = ⟦ t₁ ⟧ ρ >>= λ v₁ →
⟦ t₂ ⟧ ρ >>= λ v₂ →
v₁ ∙ v₂
⟦ t₁ ∣ t₂ ⟧ ρ = ⟦ t₁ ⟧ ρ ∣ ⟦ t₂ ⟧ ρ
_∙_ : Value → Value → D Value
con i ∙ v₂ = fail
ƛ t₁ ρ ∙ v₂ = later (♯ (⟦ t₁ ⟧ (v₂ ∷ ρ)))
-- An abbreviation.
infix 9 _⟦·⟧_
_⟦·⟧_ : D Value → D Value → D Value
v₁ ⟦·⟧ v₂ = v₁ >>= λ v₁ → v₂ >>= λ v₂ → v₁ ∙ v₂
------------------------------------------------------------------------
-- Compiler
-- The compiler takes a code continuation.
--
-- Non-determinism is resolved by always picking the left choice.
comp : ∀ {n} → Tm n → Code n → Code n
comp (con i) c = con i ∷ c
comp (var x) c = var x ∷ c
comp (ƛ t) c = clo (comp t [ ret ]) ∷ c
comp (t₁ · t₂) c = comp t₁ (comp t₂ (app ∷ c))
comp (t₁ ∣ t₂) c = comp t₁ c
-- Environments and values can also be compiled.
mutual
comp-env : ∀ {n} → Env n → VM.Env n
comp-env [] = []
comp-env (v ∷ ρ) = comp-val v ∷ comp-env ρ
comp-val : Value → VM.Value
comp-val (con i) = con i
comp-val (ƛ t ρ) = ƛ (comp t [ ret ]) (comp-env ρ)
-- lookup x is homomorphic with respect to comp-env/comp-val.
lookup-hom : ∀ {n} (x : Fin n) ρ →
lookup (comp-env ρ) x ≡ comp-val (lookup ρ x)
lookup-hom zero (v ∷ ρ) = P.refl
lookup-hom (suc x) (v ∷ ρ) = lookup-hom x ρ
------------------------------------------------------------------------
-- Examples
-- A non-terminating term.
Ω : Tm 0
Ω = ω · ω
where ω = ƛ (vr 0 · vr 0)
Ω-loops : ⟦ Ω ⟧ [] ≅ never
Ω-loops = later (♯ Ω-loops)
-- A call-by-value fix-point combinator.
Z : {n : ℕ} → Tm n
Z = ƛ (t · t)
where t = ƛ (vr 1 · ƛ (vr 1 · vr 1 · vr 0))
-- A non-deterministically non-terminating term.
! : Tm 0
! = Z · ƛ (ƛ (vr 1 · vr 0 ∣ vr 1 · vr 0)) · con 0
-- Its semantics.
!-sem : D Value
!-sem = later (♯ later (♯ later (♯ later (♯ (!-sem ∣ !-sem)))))
⟦!⟧≅!-sem : ⟦ ! ⟧ [] ≅ !-sem
⟦!⟧≅!-sem = later (♯ lem)
where
lem : force 1 (⟦ ! ⟧ []) ≅ force 1 !-sem
lem = later (♯ later (♯ later (♯ (later (♯ lem) ∣ later (♯ lem)))))
-- How did I come up with this proof term? Through a manual
-- calculation...
--
-- Let us first define some abbreviations:
--
-- t₀ = vr 1 · vr 1 · vr 0
-- t₁ = ƛ t₀
-- t₂ = vr 1 · t₁
-- t₃ = ƛ t₂
--
-- u₀ = vr 1 · vr 0
-- u₁ = u₀ ∣ u₀
-- u₂ = ƛ u₁
-- u₃ = ƛ u₂
--
-- c₀ = ƛ u₂ []
-- c₁ = ƛ t₂ (c₀ ∷ [])
-- c₂ = ƛ t₀ (c₁ ∷ c₀ ∷ [])
--
-- Now we can calculate as follows (ignoring ♯):
--
-- ⟦ Z · u₃ · con 0 ⟧ []
-- = ⟦ Z · u₃ ⟧ [] ⟦·⟧ return (con 0)
-- = ƛ (t₃ · t₃) [] ∙ c₀ ⟦·⟧ return (con 0)
-- = later (⟦ t₃ · t₃ ⟧ (c₀ ∷ []) ⟦·⟧ return (con 0))
-- = later (c₁ ∙ c₁ ⟦·⟧ return (con 0))
--
-- = c₁ ∙ c₁ ⟦·⟧ return (con 0)
-- = later (⟦ t₂ ⟧ (c₁ ∷ c₀ ∷ []) ⟦·⟧ return (con 0))
-- = later (c₀ ∙ c₂ ⟦·⟧ return (con 0))
-- = later (later (⟦ u₂ ⟧ (c₂ ∷ []) ⟦·⟧ return (con 0)))
-- = later (later (ƛ u₁ (c₂ ∷ []) ∙ con 0))
-- = later (later (later (⟦ u₁ ⟧ (con 0 ∷ c₂ ∷ []))))
-- = later (later (later (⟦ u₀ ⟧ (con 0 ∷ c₂ ∷ []) ∣
-- ⟦ u₀ ⟧ (con 0 ∷ c₂ ∷ []))))
-- = later (later (later (c₂ ∙ con 0 ∣ c₂ ∙ con 0)))
-- = later (later (later (⟦ t₀ ⟧ (con 0 ∷ c₁ ∷ c₀ ∷ []) ∣
-- ⟦ t₀ ⟧ (con 0 ∷ c₁ ∷ c₀ ∷ []))))
-- = later (later (later (later (c₁ ∙ c₁ ⟦·⟧ return (con 0)) ∣
-- later (c₁ ∙ c₁ ⟦·⟧ return (con 0)))))
------------------------------------------------------------------------
-- A relation relating deterministic and non-deterministic
-- computations
-- x ≈∈ y means that x implements /one/ possible semantics of y (up to
-- weak bisimilarity).
infix 4 _≈∈_
data _≈∈_ {A : Set} : Maybe A ⊥ → D A → Set where
fail : now nothing ≈∈ fail
return : ∀ {x} → now (just x) ≈∈ return x
∣ˡ : ∀ {x y₁ y₂} (x≈∈y₁ : x ≈∈ y₁) → x ≈∈ y₁ ∣ y₂
∣ʳ : ∀ {x y₁ y₂} (x≈∈y₂ : x ≈∈ y₂) → x ≈∈ y₁ ∣ y₂
later : ∀ {x y} (x≈∈y : ∞ (♭ x ≈∈ ♭ y)) → later x ≈∈ later y
laterˡ : ∀ {x y} (x≈∈y : ♭ x ≈∈ y ) → later x ≈∈ y
laterʳ : ∀ {x y} (x≈∈y : x ≈∈ ♭ y ) → x ≈∈ later y
-- A transitivity-like result for _≡_ and _≈∈_.
infixr 2 _≡⟨_⟩_
_≡⟨_⟩_ : ∀ {A : Set} (x : Maybe A ⊥) {y z} → x ≡ y → y ≈∈ z → x ≈∈ z
_ ≡⟨ P.refl ⟩ y≈z = y≈z
-- A transitivity-like result for _≈∈_ and _≅_.
infixr 2 _≈∈⟨_⟩_
_≈∈⟨_⟩_ : ∀ {A : Set} (x : Maybe A ⊥) {y z} → x ≈∈ y → y ≅ z → x ≈∈ z
._ ≈∈⟨ fail ⟩ fail = fail
._ ≈∈⟨ return ⟩ return = return
_ ≈∈⟨ ∣ˡ x₁≈∈y₁ ⟩ y₁≅z₁ ∣ y₂≅z₂ = ∣ˡ (_ ≈∈⟨ x₁≈∈y₁ ⟩ y₁≅z₁)
_ ≈∈⟨ ∣ʳ x₂≈∈y₂ ⟩ y₁≅z₁ ∣ y₂≅z₂ = ∣ʳ (_ ≈∈⟨ x₂≈∈y₂ ⟩ y₂≅z₂)
._ ≈∈⟨ later x≈∈y ⟩ later y≅z = later (♯ (_ ≈∈⟨ ♭ x≈∈y ⟩ ♭ y≅z))
._ ≈∈⟨ laterˡ x≈∈y ⟩ y≅z = laterˡ (_ ≈∈⟨ x≈∈y ⟩ y≅z)
_ ≈∈⟨ laterʳ x≈∈y ⟩ later y≅z = laterʳ (_ ≈∈⟨ x≈∈y ⟩ ♭ y≅z)
-- An example.
lemma : Pa.never ≈∈ !-sem
lemma = later (♯ later (♯ later (♯ later (♯ ∣ˡ lemma))))
------------------------------------------------------------------------
-- Compiler correctness
module Correctness where
mutual
correct :
∀ {n} t {ρ : Env n} {c s} {k : Value → D VM.Value} →
(∀ v → exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈∈ k v) →
exec ⟨ comp t c , s , comp-env ρ ⟩ ≈∈ (⟦ t ⟧ ρ >>= k)
correct (con i) {ρ} {c} {s} {k} hyp = laterˡ (
exec ⟨ c , val (con i) ∷ s , comp-env ρ ⟩ ≈∈⟨ hyp (con i) ⟩
k (con i) ∎)
correct (var x) {ρ} {c} {s} {k} hyp = laterˡ (
exec ⟨ c , val (lookup (comp-env ρ) x) ∷ s , comp-env ρ ⟩ ≡⟨ P.cong (λ v → exec ⟨ c , val v ∷ s , comp-env ρ ⟩) (lookup-hom x ρ) ⟩
exec ⟨ c , val (comp-val (lookup ρ x)) ∷ s , comp-env ρ ⟩ ≈∈⟨ hyp (lookup ρ x) ⟩
k (lookup ρ x) ∎)
correct (ƛ t) {ρ} {c} {s} {k} hyp = laterˡ (
exec ⟨ c , val (comp-val (ƛ t ρ)) ∷ s , comp-env ρ ⟩ ≈∈⟨ hyp (ƛ t ρ) ⟩
k (ƛ t ρ) ∎)
correct (t₁ · t₂) {ρ} {c} {s} {k} hyp =
exec ⟨ comp t₁ (comp t₂ (app ∷ c)) , s , comp-env ρ ⟩ ≈∈⟨ correct t₁ (λ v₁ → correct t₂ (λ v₂ → ∙-correct v₁ v₂ hyp)) ⟩
(⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k) ≅⟨ ((⟦ t₁ ⟧ ρ ∎) >>=-cong λ _ → sym $ associative (⟦ t₂ ⟧ ρ)) ⟩
(⟦ t₁ ⟧ ρ >>= λ v₁ → (⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂) >>= k) ≅⟨ sym $ associative (⟦ t₁ ⟧ ρ) ⟩
(⟦ t₁ ⟧ ρ ⟦·⟧ ⟦ t₂ ⟧ ρ >>= k) ≅⟨ _ ∎ ⟩
(⟦ t₁ · t₂ ⟧ ρ >>= k) ∎
correct (t₁ ∣ t₂) {ρ} {c} {s} {k} hyp =
exec ⟨ comp t₁ c , s , comp-env ρ ⟩ ≈∈⟨ ∣ˡ (correct t₁ hyp) ⟩
(⟦ t₁ ⟧ ρ >>= k) ∣ (⟦ t₂ ⟧ ρ >>= k) ∎
∙-correct :
∀ {n} v₁ v₂ {ρ : Env n} {c s} {k : Value → D VM.Value} →
(∀ v → exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈∈ k v) →
exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≈∈
v₁ ∙ v₂ >>= k
∙-correct (con i) v₂ _ = fail
∙-correct (ƛ t₁ ρ₁) v₂ {ρ} {c} {s} {k} hyp =
exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val (ƛ t₁ ρ₁)) ∷ s , comp-env ρ ⟩ ≈∈⟨ later (♯ (
exec ⟨ comp t₁ [ ret ] , ret c (comp-env ρ) ∷ s , comp-env (v₂ ∷ ρ₁) ⟩ ≈∈⟨ correct t₁ (λ v → laterˡ (hyp v)) ⟩
(⟦ t₁ ⟧ (v₂ ∷ ρ₁) >>= k) ∎)) ⟩
(ƛ t₁ ρ₁ ∙ v₂ >>= k) ∎
correct : ∀ t →
exec ⟨ comp t [] , [] , [] ⟩ ≈∈
⟦ t ⟧ [] >>= λ v → return (comp-val v)
correct t = Correctness.correct t (λ _ → return)
------------------------------------------------------------------------
-- Type system (following Leroy and Grall)
infix 4 _⊢_∈_
data _⊢_∈_ {n} (Γ : Ctxt n) : Tm n → Ty → Set where
con : ∀ {i} → Γ ⊢ con i ∈ nat
var : ∀ {x} → Γ ⊢ var x ∈ lookup Γ x
ƛ : ∀ {t σ τ} (t∈ : ♭ σ ∷ Γ ⊢ t ∈ ♭ τ) → Γ ⊢ ƛ t ∈ σ ⇾ τ
_·_ : ∀ {t₁ t₂ σ τ} (t₁∈ : Γ ⊢ t₁ ∈ σ ⇾ τ) (t₂∈ : Γ ⊢ t₂ ∈ ♭ σ) →
Γ ⊢ t₁ · t₂ ∈ ♭ τ
_∣_ : ∀ {t₁ t₂ σ} (t₁∈ : Γ ⊢ t₁ ∈ σ) (t₂∈ : Γ ⊢ t₂ ∈ σ) →
Γ ⊢ t₁ ∣ t₂ ∈ σ
-- Ω is well-typed.
Ω-well-typed : (τ : Ty) → [] ⊢ Ω ∈ τ
Ω-well-typed τ =
_·_ {σ = ♯ σ} {τ = ♯ τ} (ƛ (var · var)) (ƛ (var · var))
where σ = ♯ σ ⇾ ♯ τ
-- The call-by-value fix-point combinator is also well-typed.
fix-well-typed :
∀ {σ τ} → [] ⊢ Z ∈ ♯ (♯ (σ ⇾ τ) ⇾ ♯ (σ ⇾ τ)) ⇾ ♯ (σ ⇾ τ)
fix-well-typed =
ƛ (_·_ {σ = υ} {τ = ♯ _}
(ƛ (var · ƛ (var · var · var)))
(ƛ (var · ƛ (var · var · var))))
where
υ : ∞ Ty
υ = ♯ (υ ⇾ ♯ _)
------------------------------------------------------------------------
-- Type soundness
-- WF-Value, WF-Env and WF-DV specify when a
-- value/environment/computation is well-formed with respect to a
-- given context (and type).
mutual
data WF-Value : Ty → Value → Set where
con : ∀ {i} → WF-Value nat (con i)
ƛ : ∀ {n Γ σ τ} {t : Tm (1 + n)} {ρ}
(t∈ : ♭ σ ∷ Γ ⊢ t ∈ ♭ τ) (ρ-wf : WF-Env Γ ρ) →
WF-Value (σ ⇾ τ) (ƛ t ρ)
infixr 5 _∷_
data WF-Env : ∀ {n} → Ctxt n → Env n → Set where
[] : WF-Env [] []
_∷_ : ∀ {n} {Γ : Ctxt n} {ρ σ v}
(v-wf : WF-Value σ v) (ρ-wf : WF-Env Γ ρ) →
WF-Env (σ ∷ Γ) (v ∷ ρ)
data WF-DV (σ : Ty) : D Value → Set where
return : ∀ {v} (v-wf : WF-Value σ v) → WF-DV σ (return v)
_∣_ : ∀ {x y}
(x-wf : WF-DV σ x) (y-wf : WF-DV σ y) → WF-DV σ (x ∣ y)
later : ∀ {x} (x-wf : ∞ (WF-DV σ (♭ x))) → WF-DV σ (later x)
-- Variables pointing into a well-formed environment refer to
-- well-formed values.
lookup-wf : ∀ {n Γ ρ} (x : Fin n) → WF-Env Γ ρ →
WF-Value (lookup Γ x) (lookup ρ x)
lookup-wf zero (v-wf ∷ ρ-wf) = v-wf
lookup-wf (suc x) (v-wf ∷ ρ-wf) = lookup-wf x ρ-wf
-- If we can prove WF-DV σ x, then x does not "go wrong".
does-not-go-wrong : ∀ {σ x} → WF-DV σ x → ¬ now nothing ≈∈ x
does-not-go-wrong (return v-wf) ()
does-not-go-wrong (x-wf ∣ y-wf) (∣ˡ x↯) = does-not-go-wrong x-wf x↯
does-not-go-wrong (x-wf ∣ y-wf) (∣ʳ y↯) = does-not-go-wrong y-wf y↯
does-not-go-wrong (later x-wf) (laterʳ x↯) =
does-not-go-wrong (♭ x-wf) x↯
-- Bind preserves WF-DV in the following way:
_>>=-cong-WF_ :
∀ {σ τ x f} →
WF-DV σ x → (∀ {v} → WF-Value σ v → WF-DV τ (f v)) →
WF-DV τ (x >>= f)
return v-wf >>=-cong-WF f-wf = f-wf v-wf
(x-wf ∣ y-wf) >>=-cong-WF f-wf = (x-wf >>=-cong-WF f-wf)
∣ (y-wf >>=-cong-WF f-wf)
later x-wf >>=-cong-WF f-wf = later (♯ (♭ x-wf >>=-cong-WF f-wf))
-- Well-typed programs do not "go wrong".
mutual
⟦⟧-wf : ∀ {n Γ} (t : Tm n) {σ} → Γ ⊢ t ∈ σ →
∀ {ρ} → WF-Env Γ ρ → WF-DV σ (⟦ t ⟧ ρ)
⟦⟧-wf (con i) con ρ-wf = return con
⟦⟧-wf (var x) var ρ-wf = return (lookup-wf x ρ-wf)
⟦⟧-wf (ƛ t) (ƛ t∈) ρ-wf = return (ƛ t∈ ρ-wf)
⟦⟧-wf (t₁ ∣ t₂) (t₁∈ ∣ t₂∈) ρ-wf = ⟦⟧-wf t₁ t₁∈ ρ-wf
∣ ⟦⟧-wf t₂ t₂∈ ρ-wf
⟦⟧-wf (t₁ · t₂) (t₁∈ · t₂∈) {ρ} ρ-wf =
⟦⟧-wf t₁ t₁∈ ρ-wf >>=-cong-WF λ f-wf →
⟦⟧-wf t₂ t₂∈ ρ-wf >>=-cong-WF λ v-wf →
∙-wf f-wf v-wf
∙-wf : ∀ {σ τ f v} →
WF-Value (σ ⇾ τ) f → WF-Value (♭ σ) v →
WF-DV (♭ τ) (f ∙ v)
∙-wf (ƛ t₁∈ ρ₁-wf) v₂-wf = later (♯ ⟦⟧-wf _ t₁∈ (v₂-wf ∷ ρ₁-wf))
type-soundness : ∀ {t : Tm 0} {σ} →
[] ⊢ t ∈ σ → ¬ now nothing ≈∈ ⟦ t ⟧ []
type-soundness t∈ = does-not-go-wrong (⟦⟧-wf _ t∈ [])
| {
"alphanum_fraction": 0.4532601563,
"avg_line_length": 32.4235976789,
"ext": "agda",
"hexsha": "2158082d93cb2a806b96979d1878432f7e17b0fd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "Lambda/Closure/Functional/Non-deterministic/No-workarounds.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/codata",
"max_issues_repo_path": "Lambda/Closure/Functional/Non-deterministic/No-workarounds.agda",
"max_line_length": 137,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "Lambda/Closure/Functional/Non-deterministic/No-workarounds.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 7413,
"size": 16763
} |
module CoinductiveConstructorsAndLet where
open import Common.Coinduction
data D : Set where
foo : D → ∞ D
foo x = let y = x in ♯ y
-- CoinductiveConstructorsAndLet.agda:9,24-25
-- Panic: thing out of context ([CtxId 1] is not a sub context of
-- [CtxId 3])
-- when checking that the expression y has type D
| {
"alphanum_fraction": 0.7211538462,
"avg_line_length": 22.2857142857,
"ext": "agda",
"hexsha": "00f33ca8336a232205a43a5ba703509bd2ad62dd",
"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/fail/CoinductiveConstructorsAndLet.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/CoinductiveConstructorsAndLet.agda",
"max_line_length": 65,
"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/fail/CoinductiveConstructorsAndLet.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": 98,
"size": 312
} |
module SystemF.NormalForm where
open import Prelude
open import SystemF.Syntax
open import SystemF.WellTyped
open import SystemF.Substitutions
open import Data.Vec hiding ([_])
open import Data.List hiding ([_])
mutual
-- The eta-long beta-normal form described by Andreas Abel in:
-- Abel, A., 2008, November.
-- Weak βη-normalization and normalization by evaluation for System F.
-- In Logic for Programming, Artificial Intelligence, and Reasoning (pp. 497-511).
-- Springer Berlin Heidelberg.
infix 4 _⊢_⇓_ _⊢_⇑_
data _⊢_⇓_ {ν n} (Γ : Ctx ν n) : Term ν n → Type ν → Set where
nvar : ∀ n → Γ ⊢ (var n) ⇓ (lookup n Γ)
napp : ∀ {a b f e} → Γ ⊢ f ⇓ (a →' b) → Γ ⊢ e ⇑ a → Γ ⊢ (f · e) ⇓ b
ntapp : ∀ {a f} b → Γ ⊢ f ⇓ (∀' a) → Γ ⊢ (f [ b ]) ⇓ a tp[/tp b ]
data _⊢_⇑_ {ν n} (Γ : Ctx ν n) : Term ν n → Type ν → Set where
nbase : ∀ {t a} → Base a → Γ ⊢ t ⇓ a → Γ ⊢ t ⇑ a
nabs : ∀ {a b e} → (a ∷ Γ) ⊢ e ⇑ b → Γ ⊢ (λ' a e) ⇑ (a →' b)
ntabs : ∀ {a e} → (ctx-weaken Γ) ⊢ e ⇑ a → Γ ⊢ (Λ e) ⇑ (∀' a)
mutual
⇓-sound : ∀ {ν n} {Γ : Ctx ν n} {t a} → Γ ⊢ t ⇓ a → Γ ⊢ t ∈ a
⇓-sound (nvar n₁) = var n₁
⇓-sound (napp p x) = (⇓-sound p) · ⇑-sound x
⇓-sound (ntapp b p) = ⇓-sound p [ b ]
⇑-sound : ∀ {ν n} {Γ : Ctx ν n} {t a} → Γ ⊢ t ⇑ a → Γ ⊢ t ∈ a
⇑-sound (nbase a p) = ⇓-sound p
⇑-sound (nabs x) = λ' _ (⇑-sound x)
⇑-sound (ntabs x) = Λ (⇑-sound x)
| {
"alphanum_fraction": 0.529957204,
"avg_line_length": 32.6046511628,
"ext": "agda",
"hexsha": "b347fac3faf650ba52f501617e45e6b0ecef6e78",
"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/NormalForm.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/NormalForm.agda",
"max_line_length": 84,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "metaborg/ts.agda",
"max_stars_repo_path": "src/SystemF/NormalForm.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z",
"num_tokens": 636,
"size": 1402
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of operations on M-types
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.M.Properties where
open import Level
open import Size
open import Codata.Thunk using (Thunk; force)
open import Codata.M
open import Codata.M.Bisimilarity
open import Data.Container.Core as C hiding (map)
import Data.Container.Morphism as Mp
open import Data.Product as Prod using (_,_)
open import Data.Product.Properties
open import Function
import Relation.Binary.PropositionalEquality as P
open import Data.Container.Relation.Binary.Pointwise using (_,_)
import Data.Container.Relation.Binary.Equality.Setoid as EqSetoid
private module Eq {a} (A : Set a) = EqSetoid (P.setoid A)
open Eq using (Eq)
module _ {s p} {C : Container s p} where
map-id : ∀ {i} c → Bisim C i (map (Mp.id C) c) c
map-id (inf (s , f)) = inf (P.refl , λ where p .force → map-id (f p .force))
module _ {s₁ s₂ p₁ p₂} {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂} where
map-cong : ∀ {i} {f g : C₁ ⇒ C₂} →
(∀ {X} t → Eq X C₂ (⟪ f ⟫ t) (⟪ g ⟫ t)) →
∀ c₁ → Bisim C₂ i (map f c₁) (map g c₁)
map-cong {f = f} {g} f≗g (inf t@(s , n)) with f≗g t
... | eqs , eqf = inf (eqs , λ where
p .force {j} → P.subst (λ t → Bisim C₂ j (map f (n (position f p) .force))
(map g (t .force)))
(eqf p)
(map-cong f≗g (n (position f p) .force)))
module _ {s₁ s₂ s₃ p₁ p₂ p₃} {C₁ : Container s₁ p₁}
{C₂ : Container s₂ p₂} {C₃ : Container s₃ p₃} where
map-compose : ∀ {i} {g : C₂ ⇒ C₃} {f : C₁ ⇒ C₂} c₁ →
Bisim C₃ i (map (g Mp.∘ f) c₁) (map g $′ map f c₁)
map-compose (inf (s , f)) = inf (P.refl , λ where p .force → map-compose (f _ .force))
module _ {s₁ s₂ p₁ p₂ s} {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂}
{S : Set s} {alg : S → ⟦ C₁ ⟧ S} {f : C₁ ⇒ C₂} where
map-unfold : ∀ {i} s → Bisim C₂ i (map f (unfold alg s))
(unfold (⟪ f ⟫ ∘′ alg) s)
map-unfold s = inf (P.refl , λ where p .force → map-unfold _)
| {
"alphanum_fraction": 0.5376439327,
"avg_line_length": 37.6333333333,
"ext": "agda",
"hexsha": "b1cbbeb6f5e3c8c4a59c12653bd844ff268d9f0b",
"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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Properties.agda",
"max_line_length": 88,
"max_stars_count": 5,
"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/Codata/M/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": 746,
"size": 2258
} |
-- Andreas, 2012-01-17
-- {-# OPTIONS -v tc.proj.like:50 #-}
-- {-# OPTIONS -v tc.conv.atom:50 #-}
module Issue553c where
postulate
A : Set
a : A
data Bool : Set where
true false : Bool
data WrapBool (C : Set) : Set where
wrap : Bool -> WrapBool C
-- a projection-like function (must not be constructor-headed!)
-- the dummy C is to make Agda accept f as projection like
f : {C : Set} -> WrapBool C -> A
f (wrap true) = a
f (wrap false) = a
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
-- it is important that f does not reduce, in order to enter compareAtom
test : (b : Bool) -> f {C = A} (wrap b) ≡ f (wrap b)
test b = refl
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/Conversion.hs:335
-- the problem is fixed now, since f is no longer projection-like
-- because of deep matching | {
"alphanum_fraction": 0.6542372881,
"avg_line_length": 27.65625,
"ext": "agda",
"hexsha": "04061c9f92aa3df636b4a963f13a67e151e6acdc",
"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/Issue553c.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/Issue553c.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue553c.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": 274,
"size": 885
} |
module STLC1.Kovacs.Substitution where
open import STLC1.Kovacs.Embedding public
open import Category
--------------------------------------------------------------------------------
-- Substitutions (Sub ; ∙ ; _,_)
infix 3 _⊢⋆_
data _⊢⋆_ : 𝒞 → 𝒞 → Set
where
∅ : ∀ {Γ} → Γ ⊢⋆ ∅
_,_ : ∀ {Γ Ξ A} → (σ : Γ ⊢⋆ Ξ) (M : Γ ⊢ A)
→ Γ ⊢⋆ Ξ , A
-- (_ₛ∘ₑ_)
-- NOTE: _◐_ = ren⋆
_◐_ : ∀ {Γ Γ′ Ξ} → Γ ⊢⋆ Ξ → Γ′ ⊇ Γ → Γ′ ⊢⋆ Ξ
∅ ◐ η = ∅
(σ , M) ◐ η = σ ◐ η , ren η M
-- (_ₑ∘ₛ_)
_◑_ : ∀ {Γ Ξ Ξ′} → Ξ′ ⊇ Ξ → Γ ⊢⋆ Ξ′ → Γ ⊢⋆ Ξ
done ◑ σ = σ
wkₑ η ◑ (σ , M) = η ◑ σ
liftₑ η ◑ (σ , M) = η ◑ σ , M
--------------------------------------------------------------------------------
-- (dropₛ)
wkₛ : ∀ {A Γ Ξ} → Γ ⊢⋆ Ξ → Γ , A ⊢⋆ Ξ
wkₛ σ = σ ◐ wkₑ idₑ
-- (keepₛ)
liftₛ : ∀ {A Γ Ξ} → Γ ⊢⋆ Ξ → Γ , A ⊢⋆ Ξ , A
liftₛ σ = wkₛ σ , 0
-- (⌜_⌝ᵒᵖᵉ)
⌊_⌋ : ∀ {Γ Γ′} → Γ′ ⊇ Γ → Γ′ ⊢⋆ Γ
⌊ done ⌋ = ∅
⌊ wkₑ η ⌋ = wkₛ ⌊ η ⌋
⌊ liftₑ η ⌋ = liftₛ ⌊ η ⌋
-- (∈ₛ)
getₛ : ∀ {Γ Ξ A} → Γ ⊢⋆ Ξ → Ξ ∋ A → Γ ⊢ A
getₛ (σ , M) zero = M
getₛ (σ , M) (suc i) = getₛ σ i
-- (Tmₛ)
sub : ∀ {Γ Ξ A} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A
sub σ (𝓋 i) = getₛ σ i
sub σ (ƛ M) = ƛ (sub (liftₛ σ) M)
sub σ (M ∙ N) = sub σ M ∙ sub σ N
sub σ (M , N) = sub σ M , sub σ N
sub σ (π₁ M) = π₁ (sub σ M)
sub σ (π₂ M) = π₂ (sub σ M)
sub σ τ = τ
-- (idₛ)
idₛ : ∀ {Γ} → Γ ⊢⋆ Γ
idₛ {∅} = ∅
idₛ {Γ , A} = liftₛ idₛ
cut : ∀ {Γ A B} → Γ ⊢ A → Γ , A ⊢ B → Γ ⊢ B
cut M N = sub (idₛ , M) N
-- (_∘ₛ_)
-- NOTE: _●_ = sub⋆
_●_ : ∀ {Γ Ξ Φ} → Ξ ⊢⋆ Φ → Γ ⊢⋆ Ξ → Γ ⊢⋆ Φ
∅ ● σ₁ = ∅
(σ₂ , M) ● σ₁ = σ₂ ● σ₁ , sub σ₁ M
--------------------------------------------------------------------------------
-- (assₛₑₑ)
comp◐○ : ∀ {Γ Γ′ Γ″ Ξ} → (η₁ : Γ″ ⊇ Γ′) (η₂ : Γ′ ⊇ Γ) (σ : Γ ⊢⋆ Ξ)
→ (σ ◐ η₂) ◐ η₁ ≡ σ ◐ (η₂ ○ η₁)
comp◐○ η₁ η₂ ∅ = refl
comp◐○ η₁ η₂ (σ , M) = _,_ & comp◐○ η₁ η₂ σ
⊗ (ren○ η₁ η₂ M ⁻¹)
-- (assₑₛₑ)
comp◑◐ : ∀ {Γ Γ′ Ξ Ξ′} → (η₁ : Γ′ ⊇ Γ) (σ : Γ ⊢⋆ Ξ′) (η₂ : Ξ′ ⊇ Ξ)
→ (η₂ ◑ σ) ◐ η₁ ≡ η₂ ◑ (σ ◐ η₁)
comp◑◐ η₁ ∅ done = refl
comp◑◐ η₁ (σ , M) (wkₑ η₂) = comp◑◐ η₁ σ η₂
comp◑◐ η₁ (σ , M) (liftₑ η₂) = (_, ren η₁ M) & comp◑◐ η₁ σ η₂
--------------------------------------------------------------------------------
-- (idlₑₛ)
lid◑ : ∀ {Γ Ξ} → (σ : Γ ⊢⋆ Ξ)
→ idₑ ◑ σ ≡ σ
lid◑ ∅ = refl
lid◑ (σ , M) = (_, M) & lid◑ σ
-- (idlₛₑ)
lid◐ : ∀ {Γ Γ′} → (η : Γ′ ⊇ Γ)
→ idₛ ◐ η ≡ ⌊ η ⌋
lid◐ done = refl
lid◐ (wkₑ η) = ((idₛ ◐_) ∘ wkₑ) & rid○ η ⁻¹
⦙ comp◐○ (wkₑ idₑ) η idₛ ⁻¹
⦙ wkₛ & lid◐ η
lid◐ (liftₑ η) = (_, 0) & ( comp◐○ (liftₑ η) (wkₑ idₑ) idₛ
⦙ ((idₛ ◐_) ∘ wkₑ) & ( lid○ η
⦙ rid○ η ⁻¹
)
⦙ comp◐○ (wkₑ idₑ) η idₛ ⁻¹
⦙ (_◐ wkₑ idₑ) & lid◐ η
)
-- (idrₑₛ)
rid◑ : ∀ {Γ Γ′} → (η : Γ′ ⊇ Γ)
→ η ◑ idₛ ≡ ⌊ η ⌋
rid◑ done = refl
rid◑ (wkₑ η) = comp◑◐ (wkₑ idₑ) idₛ η ⁻¹
⦙ wkₛ & rid◑ η
rid◑ (liftₑ η) = (_, 0) & ( comp◑◐ (wkₑ idₑ) idₛ η ⁻¹
⦙ (_◐ wkₑ idₑ) & rid◑ η
)
--------------------------------------------------------------------------------
-- (∈-ₑ∘ₛ)
get◑ : ∀ {Γ Ξ Ξ′ A} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ⊇ Ξ) (i : Ξ ∋ A)
→ getₛ (η ◑ σ) i ≡ (getₛ σ ∘ getₑ η) i
get◑ σ done i = refl
get◑ (σ , M) (wkₑ η) i = get◑ σ η i
get◑ (σ , M) (liftₑ η) zero = refl
get◑ (σ , M) (liftₑ η) (suc i) = get◑ σ η i
-- (Tm-ₑ∘ₛ)
mutual
sub◑ : ∀ {Γ Ξ Ξ′ A} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ⊇ Ξ) (M : Ξ ⊢ A)
→ sub (η ◑ σ) M ≡ (sub σ ∘ ren η) M
sub◑ σ η (𝓋 i) = get◑ σ η i
sub◑ σ η (ƛ M) = ƛ & sublift◑ σ η M
sub◑ σ η (M ∙ N) = _∙_ & sub◑ σ η M
⊗ sub◑ σ η N
sub◑ σ η (M , N) = _,_ & sub◑ σ η M
⊗ sub◑ σ η N
sub◑ σ η (π₁ M) = π₁ & sub◑ σ η M
sub◑ σ η (π₂ M) = π₂ & sub◑ σ η M
sub◑ σ η τ = refl
sublift◑ : ∀ {Γ Ξ Ξ′ A B} → (σ : Γ ⊢⋆ Ξ′) (η : Ξ′ ⊇ Ξ) (M : Ξ , B ⊢ A)
→ sub (liftₛ {B} (η ◑ σ)) M ≡
(sub (liftₛ σ) ∘ ren (liftₑ η)) M
sublift◑ σ η M = (λ σ′ → sub (σ′ , 0) M)
& comp◑◐ (wkₑ idₑ) σ η
⦙ sub◑ (liftₛ σ) (liftₑ η) M
--------------------------------------------------------------------------------
-- (∈-ₛ∘ₑ)
get◐ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ⊇ Γ) (σ : Γ ⊢⋆ Ξ) (i : Ξ ∋ A)
→ getₛ (σ ◐ η) i ≡ (ren η ∘ getₛ σ) i
get◐ η (σ , M) zero = refl
get◐ η (σ , M) (suc i) = get◐ η σ i
-- (Tm-ₛ∘ₑ)
mutual
sub◐ : ∀ {Γ Γ′ Ξ A} → (η : Γ′ ⊇ Γ) (σ : Γ ⊢⋆ Ξ) (M : Ξ ⊢ A)
→ sub (σ ◐ η) M ≡ (ren η ∘ sub σ) M
sub◐ η σ (𝓋 i) = get◐ η σ i
sub◐ η σ (ƛ M) = ƛ & sublift◐ η σ M
sub◐ η σ (M ∙ N) = _∙_ & sub◐ η σ M
⊗ sub◐ η σ N
sub◐ η σ (M , N) = _,_ & sub◐ η σ M
⊗ sub◐ η σ N
sub◐ η σ (π₁ M) = π₁ & sub◐ η σ M
sub◐ η σ (π₂ M) = π₂ & sub◐ η σ M
sub◐ η σ τ = refl
sublift◐ : ∀ {Γ Γ′ Ξ A B} → (η : Γ′ ⊇ Γ) (σ : Γ ⊢⋆ Ξ) (M : Ξ , B ⊢ A)
→ sub (liftₛ {B} (σ ◐ η)) M ≡
(ren (liftₑ η) ∘ sub (liftₛ σ)) M
sublift◐ η σ M = (λ σ′ → sub (σ′ , 0) M)
& ( comp◐○ (wkₑ idₑ) η σ
⦙ (σ ◐_) & (wkₑ & ( rid○ η
⦙ lid○ η ⁻¹
))
⦙ comp◐○ (liftₑ η) (wkₑ idₑ) σ ⁻¹
)
⦙ sub◐ (liftₑ η) (liftₛ σ) M
--------------------------------------------------------------------------------
-- (assₛₑₛ)
comp●◑ : ∀ {Γ Ξ Ξ′ Φ} → (σ₁ : Γ ⊢⋆ Ξ′) (η : Ξ′ ⊇ Ξ) (σ₂ : Ξ ⊢⋆ Φ)
→ (σ₂ ◐ η) ● σ₁ ≡ σ₂ ● (η ◑ σ₁)
comp●◑ σ₁ η ∅ = refl
comp●◑ σ₁ η (σ₂ , M) = _,_ & comp●◑ σ₁ η σ₂
⊗ (sub◑ σ₁ η M ⁻¹)
-- (assₛₛₑ)
comp●◐ : ∀ {Γ Γ′ Ξ Φ} → (η : Γ′ ⊇ Γ) (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ)
→ (σ₂ ● σ₁) ◐ η ≡ σ₂ ● (σ₁ ◐ η)
comp●◐ η σ₁ ∅ = refl
comp●◐ η σ₁ (σ₂ , M) = _,_ & comp●◐ η σ₁ σ₂
⊗ (sub◐ η σ₁ M ⁻¹)
--------------------------------------------------------------------------------
-- (∈-∘ₛ)
get● : ∀ {Γ Ξ Φ A} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (i : Φ ∋ A)
→ getₛ (σ₂ ● σ₁) i ≡ (sub σ₁ ∘ getₛ σ₂) i
get● σ₁ (σ₂ , M) zero = refl
get● σ₁ (σ₂ , M) (suc i) = get● σ₁ σ₂ i
-- (Tm-∘ₛ)
mutual
sub● : ∀ {Γ Ξ Φ A} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (M : Φ ⊢ A)
→ sub (σ₂ ● σ₁) M ≡ (sub σ₁ ∘ sub σ₂) M
sub● σ₁ σ₂ (𝓋 i) = get● σ₁ σ₂ i
sub● σ₁ σ₂ (ƛ M) = ƛ & sublift● σ₁ σ₂ M
sub● σ₁ σ₂ (M ∙ N) = _∙_ & sub● σ₁ σ₂ M
⊗ sub● σ₁ σ₂ N
sub● σ₁ σ₂ (M , N) = _,_ & sub● σ₁ σ₂ M
⊗ sub● σ₁ σ₂ N
sub● σ₁ σ₂ (π₁ M) = π₁ & sub● σ₁ σ₂ M
sub● σ₁ σ₂ (π₂ M) = π₂ & sub● σ₁ σ₂ M
sub● σ₁ σ₂ τ = refl
sublift● : ∀ {Γ Ξ Φ A B} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (M : Φ , B ⊢ A)
→ sub (liftₛ {B} (σ₂ ● σ₁)) M ≡
(sub (liftₛ σ₁) ∘ sub (liftₛ σ₂)) M
sublift● σ₁ σ₂ M = (λ σ′ → sub (σ′ , 0) M)
& ( comp●◐ (wkₑ idₑ) σ₁ σ₂
⦙ (σ₂ ●_) & (lid◑ (wkₛ σ₁) ⁻¹)
⦙ comp●◑ (liftₛ σ₁) (wkₑ idₑ) σ₂ ⁻¹
)
⦙ sub● (liftₛ σ₁) (liftₛ σ₂) M
--------------------------------------------------------------------------------
-- (∈-idₛ)
idgetₛ : ∀ {Γ A} → (i : Γ ∋ A)
→ getₛ idₛ i ≡ 𝓋 i
idgetₛ zero = refl
idgetₛ (suc i) = get◐ (wkₑ idₑ) idₛ i
⦙ wk & idgetₛ i
⦙ 𝓋 ∘ suc & idgetₑ i
-- (Tm-idₛ)
idsub : ∀ {Γ A} → (M : Γ ⊢ A)
→ sub idₛ M ≡ M
idsub (𝓋 i) = idgetₛ i
idsub (ƛ M) = ƛ & idsub M
idsub (M ∙ N) = _∙_ & idsub M
⊗ idsub N
idsub (M , N) = _,_ & idsub M
⊗ idsub N
idsub (π₁ M) = π₁ & idsub M
idsub (π₂ M) = π₂ & idsub M
idsub τ = refl
--------------------------------------------------------------------------------
-- (idrₛ)
rid● : ∀ {Γ Ξ} → (σ : Γ ⊢⋆ Ξ)
→ σ ● idₛ ≡ σ
rid● ∅ = refl
rid● (σ , M) = _,_ & rid● σ
⊗ idsub M
-- (idlₛ)
lid● : ∀ {Γ Ξ} → (σ : Γ ⊢⋆ Ξ)
→ idₛ ● σ ≡ σ
lid● ∅ = refl
lid● (σ , M) = (_, M) & ( comp●◑ (σ , M) (wkₑ idₑ) idₛ
⦙ lid● (idₑ ◑ σ)
⦙ lid◑ σ
)
-- (assₛ)
assoc● : ∀ {Γ Ξ Φ Ψ} → (σ₁ : Γ ⊢⋆ Ξ) (σ₂ : Ξ ⊢⋆ Φ) (σ₃ : Φ ⊢⋆ Ψ)
→ (σ₃ ● σ₂) ● σ₁ ≡ σ₃ ● (σ₂ ● σ₁)
assoc● σ₁ σ₂ ∅ = refl
assoc● σ₁ σ₂ (σ₃ , M) = _,_ & assoc● σ₁ σ₂ σ₃
⊗ (sub● σ₁ σ₂ M ⁻¹)
--------------------------------------------------------------------------------
𝗦𝗧𝗟𝗖 : Category 𝒞 _⊢⋆_
𝗦𝗧𝗟𝗖 =
record
{ idₓ = idₛ
; _⋄_ = _●_
; lid⋄ = lid●
; rid⋄ = rid●
; assoc⋄ = assoc●
}
subPsh : 𝒯 → Presheaf₀ 𝗦𝗧𝗟𝗖
subPsh A =
record
{ Fₓ = _⊢ A
; F = sub
; idF = fext! idsub
; F⋄ = λ σ₁ σ₂ → fext! (sub● σ₂ σ₁)
}
--------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.2970024362,
"avg_line_length": 28.5226586103,
"ext": "agda",
"hexsha": "211a5f0660175be469a28011730742afe443e892",
"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": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/coquand-kovacs",
"max_forks_repo_path": "src/STLC1/Kovacs/Substitution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"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/coquand-kovacs",
"max_issues_repo_path": "src/STLC1/Kovacs/Substitution.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/coquand-kovacs",
"max_stars_repo_path": "src/STLC1/Kovacs/Substitution.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4753,
"size": 9441
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties, related to products, that rely on the K rule
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Product.Properties.WithK where
open import Data.Product
open import Data.Product.Properties
open import Function
open import Relation.Binary using (Decidable)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (yes; no)
------------------------------------------------------------------------
-- Equality
module _ {a b} {A : Set a} {B : Set b} where
,-injective : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → a ≡ c × b ≡ d
,-injective refl = refl , refl
module _ {a b} {A : Set a} {B : A → Set b} where
,-injectiveʳ : ∀ {a} {b c : B a} → (Σ A B ∋ (a , b)) ≡ (a , c) → b ≡ c
,-injectiveʳ refl = refl
≡-dec : Decidable _≡_ → (∀ {a} → Decidable {A = B a} _≡_) →
Decidable {A = Σ A B} _≡_
≡-dec dec₁ dec₂ (a , x) (b , y) with dec₁ a b
... | no a≢b = no (a≢b ∘ ,-injectiveˡ)
... | yes refl with dec₂ x y
... | no x≢y = no (x≢y ∘ ,-injectiveʳ)
... | yes refl = yes refl
| {
"alphanum_fraction": 0.4787928222,
"avg_line_length": 32.2631578947,
"ext": "agda",
"hexsha": "0d3a8dafb04ece27f1300d0f87353562da1df1de",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Properties/WithK.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Properties/WithK.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Properties/WithK.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 383,
"size": 1226
} |
module Oscar.Object {𝔣} (FunctionName : Set 𝔣) where
open import Oscar.Category.Category
open import Oscar.Category.Functor
open import Oscar.Category.Morphism
open import Oscar.Category.Semifunctor
open import Oscar.Category.Semigroupoid
open import Oscar.Category.Setoid
open import Oscar.Data.Nat
{-
open import Oscar.Data.AList FunctionName
open import Oscar.Data.Equality
open import Oscar.Data.Equality.properties
open import Oscar.Data.Fin
open import Oscar.Data.List
open import Oscar.Data.Nat
open import Oscar.Data.Product
open import Oscar.Data.Step FunctionName
open import Oscar.Data.Term FunctionName
open import Oscar.Data.Term.internal.SubstituteAndSubstitution FunctionName
open import Oscar.Data.Unit
-}
open import Oscar.Function
open import Oscar.Level
{-
List : Set
ListNatAction : Nat → Set
ListNatMorphism : Nat → Nat → Set
Nat : Set
NatNatAction : Nat → Set
NatNatMorphism : Nat → Nat → Set
-}
{-
data ⋆ : Set where
∅ : ⋆
↧ : ⋆ → ⋆
data ⟱ {a} {A : Set a} : Set a where
data Nat[_↦_] (m : Nat) : Nat → Set where
zero : Nat[ m ↦ m ]
suc : ∀ {n} → Nat[ m ↦ n ] → Nat[ m ↦ suc n ]
_+²_ : ∀ {i₂ i₃} → Nat[ i₂ ↦ i₃ ] → ∀ {i₁} → Nat[ i₁ ↦ i₂ ] → Nat[ i₁ ↦ i₃ ]
zero +² y = y
suc x +² y = suc (x +² y)
data
Nat↥ = Fin
bar = Nat[ 0 ↦ 3 ]
br = Nat
br2 = Nat↥ 3
-}
open import Oscar.Data5
data Indexed : Set (lsuc ℓ) where
iset₀ : (⟦⟧ → Set) → Indexed
isetℓ : (⟦⟧ → Set ℓ) → Indexed
vec : ⟦⟧ → Indexed → Indexed
list : Indexed → Indexed
function : Indexed → Indexed → Indexed
data IsMonoid : Indexed → Set where
list : ∀ i → IsMonoid (list i)
function : ∀ i j → IsMonoid (function i j)
vec : ∀ n i → IsMonoid
open import Level
test-l : ∀ {ℓ} {ℓ'} → (⟦⟧ → Lift {ℓ = ℓ} Set) → (⟦⟧ → Lift {ℓ = ℓ'} Set)
test-l f n = lift (lower (f n))
data Categorical : Set (lsuc ℓ) where
set₀ : (⟦⟧ → ⟦⟧ → Set) → Categorical
setℓ : (⟦⟧ → ⟦⟧ → Set ℓ) → Categorical
function : Indexed → Indexed → Categorical {- e.g. Fin m → Term n -}
monoidal-function : Indexed → Indexed → Categorical {- e.g. Fin n → Term n -}
alist = setℓ AList
ifin = iset₀ Fin
iterm = isetℓ Term
iterms = λ N → isetℓ (Terms N)
istep = isetℓ Step
iliststep = list (istep)
finterm = relational-function ifin iterm
termterm = relational-function iterm iterm
termsterms = λ N → relational-function (iterms N) (iterms N)
stepstep = relational-function istep istep
data Functorial : Categorical → Categorical → Set (lsuc ℓ) where
unpack : Functorial alist finterm
substitute : Functorial finterm termterm
substitutes : (N : ⟦⟧) → Functorial finterm (termsterms N)
stepify : Functorial termterm stepstep
collapse : (n : Nat) → Arrow (listStepN n) (termtermN n)
reduce : (n : Nat) → Arrow (termtermN n) termterm
COMPOSE : ∀ {o₂ o₃} → Functorial o₂ o₃ → ∀ {o₁} → Functorial o₁ o₂ → Functorial o₁ o₃
data Cat : Set where
identity : Cat
cat : Category → Cat
compose :
-- sustitute : Functorial
-- unpack : Arrow alist finterm
-- substitute : Arrow finterm termterm
-- substitutes : (N : Nat) → Arrow finterm (termsterms N)
-- stepify : Arrow termterm stepstep
-- collapse : (n : Nat) → Arrow (listStepN n) (termtermN n)
-- reduce : (n : Nat) → Arrow (termtermN n) termterm
-- COMPOSE : ∀ {o₂ o₃} → Arrow o₂ o₃ → ∀ {o₁} → Arrow o₁ o₂ → Arrow o₁ o₃
-- finterm : Object
-- termterm : Object
-- termsterms : Nat → Object
-- stepstep : Object
-- listStepN : Nat → Object
-- termtermN : Nat → Object
-- list∘ : Object → Object
-- {-
-- object⋆ : Object → Set _
-- object⋆ alist = Nat
-- object⋆ finterm = Nat
-- object⋆ termterm = Nat
-- object⋆ (termsterms N) = Nat
-- object⋆ stepstep = Nat
-- object⋆ (listStepN _) = ⊤
-- object⋆ (termtermN _) = ⊤
-- objectMorphism : (o : Object) → Morphism (object⋆ o) 𝔣 𝔣
-- objectMorphism alist = ⇧ AList
-- objectMorphism finterm = Fin ⇨ Term
-- objectMorphism termterm = Term ⇨ Term
-- objectMorphism (termsterms N) = Terms N ⇨ Terms N
-- objectMorphism stepstep = Step ⇨ Step
-- Setoid.⋆ ((objectMorphism (listStepN n) Morphism.⇒ _) _) = List (Step n)
-- IsSetoid._≋_ (Setoid.isSetoid ((objectMorphism (listStepN N) Morphism.⇒ _) _)) = _≡_
-- Setoid.⋆ ((objectMorphism (termtermN n) Morphism.⇒ _) _) = Term n → Term n
-- IsSetoid._≋_ (Setoid.isSetoid ((objectMorphism (termtermN N) Morphism.⇒ _) _)) = _≡̇_
-- IsSetoid._≋_ (Morphism.isSetoid (objectMorphism (termtermN N))) = _≡̇_
-- -}
-- objectCategory : Object → Category lzero 𝔣 𝔣
-- objectCategory alist = {!!}
-- objectCategory finterm = 𝔾₁
-- objectCategory termterm = 𝔾₂
-- objectCategory (termsterms N) = 𝔾₂ₛ N
-- objectCategory stepstep = {!!}
-- objectCategory (listStepN x) = {!!}
-- objectCategory (termtermN x) = {!!}
-- Semigroupoid.⋆ (Category.semigroupoid (objectCategory (list∘ G))) = List (Category.⋆ (objectCategory G))
-- Morphism._⇒_ (Semigroupoid.𝔐 (Category.semigroupoid (objectCategory (list∘ G)))) = {!!}
-- Morphism.isSetoid (Semigroupoid.𝔐 (Category.semigroupoid (objectCategory (list∘ G)))) = {!!}
-- Semigroupoid._∙_ (Category.semigroupoid (objectCategory (list∘ G))) = {!!}
-- Semigroupoid.isSemigroupoid (Category.semigroupoid (objectCategory (list∘ G))) = {!!}
-- Category.ε (objectCategory (list∘ G)) = {!!}
-- Category.isCategory (objectCategory (list∘ G)) = {!!}
-- data Arrow : Object → Object → Set where
-- unpack : Arrow alist finterm
-- substitute : Arrow finterm termterm
-- substitutes : (N : Nat) → Arrow finterm (termsterms N)
-- stepify : Arrow termterm stepstep
-- collapse : (n : Nat) → Arrow (listStepN n) (termtermN n)
-- reduce : (n : Nat) → Arrow (termtermN n) termterm
-- COMPOSE : ∀ {o₂ o₃} → Arrow o₂ o₃ → ∀ {o₁} → Arrow o₁ o₂ → Arrow o₁ o₃
-- data SimpleArrow : ∀ {o1 o2} → Arrow o1 o2 → Set where
-- unpack : SimpleArrow unpack
-- substitute : SimpleArrow substitute
-- substitutes : (N : Nat) → SimpleArrow (substitutes N)
-- stepify : SimpleArrow stepify
-- collapse : (n : Nat) → SimpleArrow (collapse n)
-- reduce : (n : Nat) → SimpleArrow (reduce n)
-- import Data.List as LIST
-- open import Algebra using (Monoid)
-- serialiseArrow : ∀ {o1 o2} → Arrow o1 o2 → List (∃ λ o1 → ∃ λ o2 → ∃ λ (a : Arrow o1 o2) → SimpleArrow a)
-- serialiseArrow unpack = (_ , _ , _ , unpack) ∷ []
-- serialiseArrow substitute = {!!}
-- serialiseArrow (substitutes N) = {!!}
-- serialiseArrow stepify = {!!}
-- serialiseArrow (collapse n) = {!!}
-- serialiseArrow (reduce n) = {!!}
-- serialiseArrow (COMPOSE g f) =
-- let g' = serialiseArrow g
-- f' = serialiseArrow f
-- in Monoid._∙_ (LIST.monoid (∃ (λ o1 → ∃ (λ o2 → ∃ SimpleArrow)))) g' f'
-- open import Data.Empty
-- eqArrow : ∀ {o1 o2} → Arrow o1 o2 → Arrow o1 o2 → Set
-- eqArrow x y = serialiseArrow x ≡ serialiseArrow y
-- open IsSemifunctor ⦃ … ⦄ using () renaming (extensionality to ext; distributivity to dist)
-- module _
-- {𝔬₁ 𝔪₁ 𝔮₁ 𝔬₂ 𝔪₂ 𝔮₂ 𝔬₃ 𝔪₃ 𝔮₃}
-- (c₁ : Semigroupoid 𝔬₁ 𝔪₁ 𝔮₁)
-- (c₂ : Semigroupoid 𝔬₂ 𝔪₂ 𝔮₂)
-- (c₃ : Semigroupoid 𝔬₃ 𝔪₃ 𝔮₃)
-- where
-- private
-- module 𝔊₁ = Semigroupoid c₁
-- module 𝔊₂ = Semigroupoid c₂
-- module 𝔊₃ = Semigroupoid c₃
-- composeS : ∀
-- {μ₁₂ : 𝔊₁.⋆ → 𝔊₂.⋆}
-- (𝔣₁₂ : ∀ {x y} → x 𝔊₁.↦ y → μ₁₂ x 𝔊₂.↦ μ₁₂ y)
-- {μ₂₃ : 𝔊₂.⋆ → 𝔊₃.⋆}
-- (𝔣₂₃ : ∀ {x y} → x 𝔊₂.↦ y → μ₂₃ x 𝔊₃.↦ μ₂₃ y)
-- ⦃ _ : IsSemifunctor (c₁ , c₂) 𝔣₁₂ ⦄
-- ⦃ _ : IsSemifunctor (c₂ , c₃) 𝔣₂₃ ⦄
-- → IsSemifunctor (c₁ , c₃) (𝔣₂₃ ∘ 𝔣₁₂)
-- IsSemifunctor.extensionality (composeS 𝔣₁₂ 𝔣₂₃ ⦃ isS₁ ⦄ ⦃ isS₂ ⦄) f₁≋f₂ = ext ⦃ isS₂ ⦄ (ext ⦃ isS₁ ⦄ f₁≋f₂)
-- IsSemifunctor.distributivity (composeS {μ₁₂} 𝔣₁₂ {μ₂₃} 𝔣₂₃ ⦃ isS₁ ⦄ ⦃ isS₂ ⦄) {x} {y} f {z} g =
-- let eq₁ = ext ⦃ isS₂ ⦄ (dist ⦃ isS₁ ⦄ f g)
-- eq₂ = dist ⦃ isS₂ ⦄ (𝔣₁₂ f) (𝔣₁₂ g)
-- instance _ = IsSetoid.isEquivalence 𝔊₃.isSetoid
-- in transitivity eq₁ eq₂
-- module _
-- {𝔬₁ 𝔪₁ 𝔮₁ 𝔬₂ 𝔪₂ 𝔮₂ 𝔬₃ 𝔪₃ 𝔮₃}
-- (c₁ : Category 𝔬₁ 𝔪₁ 𝔮₁)
-- (c₂ : Category 𝔬₂ 𝔪₂ 𝔮₂)
-- (c₃ : Category 𝔬₃ 𝔪₃ 𝔮₃)
-- where
-- private
-- module 𝔊₁ = Category c₁
-- module 𝔊₂ = Category c₂
-- module 𝔊₃ = Category c₃
-- composeF : ∀
-- {μ₁₂ : 𝔊₁.⋆ → 𝔊₂.⋆}
-- (𝔣₁₂ : ∀ {x y} → x 𝔊₁.↦ y → μ₁₂ x 𝔊₂.↦ μ₁₂ y)
-- {μ₂₃ : 𝔊₂.⋆ → 𝔊₃.⋆}
-- (𝔣₂₃ : ∀ {x y} → x 𝔊₂.↦ y → μ₂₃ x 𝔊₃.↦ μ₂₃ y)
-- ⦃ _ : IsFunctor (c₁ , c₂) 𝔣₁₂ ⦄
-- ⦃ _ : IsFunctor (c₂ , c₃) 𝔣₂₃ ⦄
-- → IsFunctor (c₁ , c₃) (𝔣₂₃ ∘ 𝔣₁₂)
-- IsFunctor.isSemifunctor (composeF 𝔣₁₂ 𝔣₂₃ ⦃ isF₁ ⦄ ⦃ isF₂ ⦄) = composeS _ _ _ _ _ ⦃ (IsFunctor.isSemifunctor isF₁) ⦄ ⦃ (IsFunctor.isSemifunctor isF₂) ⦄
-- IsFunctor.identity (composeF {μ₁₂} 𝔣₁₂ 𝔣₂₃ ⦃ isF₁ ⦄ ⦃ isF₂ ⦄) x =
-- let f₁₂ε≋ε = identity ⦃ isF₁ ⦄ x
-- f₂₃f₁₂ε≋f₂₃ε = ext ⦃ IsFunctor.isSemifunctor isF₂ ⦄ f₁₂ε≋ε
-- f₂₃ε≋ε = identity ⦃ isF₂ ⦄ (μ₁₂ x)
-- instance _ = IsSetoid.isEquivalence 𝔊₃.isSetoid
-- in transitivity f₂₃f₁₂ε≋f₂₃ε f₂₃ε≋ε
-- --𝔬₁ 𝔪₁ 𝔮₁ 𝔬₃ 𝔪₃ 𝔮₃
-- --composeF 𝔣₁₂ 𝔣₂₃ = (c₁ , c₃) , (𝔣₂₃ ∘ 𝔣₁₂)
-- arrowIsFunctor : ∀ {o₁ o₂} → Arrow o₁ o₂
-- → ∃ λ μ
-- → (let c1 = objectCategory o₁)
-- (let c2 = objectCategory o₂)
-- (let module 𝔊₁ = Category c1)
-- (let module 𝔊₂ = Category c2)
-- → ∃ λ (f : ∀ {x y} → x 𝔊₁.↦ y → μ x 𝔊₂.↦ μ y)
-- → (IsFunctor (objectCategory o₁ , objectCategory o₂) {μ} f)
-- arrowIsFunctor unpack = {!!}
-- arrowIsFunctor substitute = _ , _ , IsFunctor𝔾₁,₂◂
-- arrowIsFunctor (substitutes N) = _ , _ , IsFunctor𝔾₁,₂ₛ◂ {N}
-- arrowIsFunctor stepify = {!!}
-- arrowIsFunctor (collapse n) = {!!}
-- arrowIsFunctor (reduce n) = {!!}
-- arrowIsFunctor (COMPOSE a1 a2) =
-- let _ , _ , isF1 = arrowIsFunctor a1
-- _ , _ , isF2 = arrowIsFunctor a2
-- in _ , _ , composeF _ _ _ _ _ ⦃ isF2 ⦄ ⦃ isF1 ⦄
-- arrowFunctor : ∀ {o₁ o₂} → Arrow o₁ o₂ → Functor _ _ _ _ _ _
-- arrowFunctor {o₁} {o₂} a =
-- let cs , f , IF = arrowIsFunctor a
-- instance _ = IF
-- in (objectCategory o₁ , objectCategory o₂) , f
-- category : Category _ _ _
-- Semigroupoid.⋆ (Category.semigroupoid category) = Object
-- Setoid.⋆ ((Semigroupoid.𝔐 (Category.semigroupoid category) Morphism.⇒ o1) o2) = Arrow o1 o2
-- IsSetoid._≋_ (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid category) Morphism.⇒ x) x₁)) = {!!}
-- IsSetoid.isEquivalence (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid category) Morphism.⇒ x) x₁)) = {!!}
-- IsSetoid._≋_ (Morphism.isSetoid (Semigroupoid.𝔐 (Category.semigroupoid category))) = eqArrow
-- IsSetoid.isEquivalence (Morphism.isSetoid (Semigroupoid.𝔐 (Category.semigroupoid category))) = {!!}
-- Semigroupoid._∙_ (Category.semigroupoid category) g f = COMPOSE g f
-- IsSemigroupoid.extensionality (Semigroupoid.isSemigroupoid (Category.semigroupoid category)) = {!!}
-- IsSemigroupoid.associativity (Semigroupoid.isSemigroupoid (Category.semigroupoid category)) = {!!}
-- Category.ε category = {!!}
-- IsCategory.left-identity (Category.isCategory category) = {!!}
-- IsCategory.right-identity (Category.isCategory category) = {!!}
| {
"alphanum_fraction": 0.6332601135,
"avg_line_length": 35.5895765472,
"ext": "agda",
"hexsha": "c701136a207356f982c526cfb3dad7ae86fab3c9",
"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/Object.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/Object.agda",
"max_line_length": 156,
"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/Object.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4473,
"size": 10926
} |
module Syntax where
open import Stack public
-- Abstract symbols, or atoms.
abstract
Atom : Set
Atom = Nat
-- Types, or propositions in constructive logic.
infixl 9 _⩕_
infixr 7 _⇒_
data Type : Set where
α_ : Atom → Type
_⇒_ : Type → Type → Type
_⩕_ : Type → Type → Type
⫪ : Type
-- Contexts, or stacks of types.
Context : Set
Context = Stack Type
-- Derivations, or syntactic entailment.
infix 3 _⊢_
data _⊢_ : Context → Type → Set where
var : ∀ {A Γ} → A ∈ Γ → Γ ⊢ A
lam : ∀ {A B Γ} → Γ , A ⊢ B → Γ ⊢ A ⇒ B
app : ∀ {A B Γ} → Γ ⊢ A ⇒ B → Γ ⊢ A → Γ ⊢ B
pair : ∀ {A B Γ} → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ⩕ B
fst : ∀ {A B Γ} → Γ ⊢ A ⩕ B → Γ ⊢ A
snd : ∀ {A B Γ} → Γ ⊢ A ⩕ B → Γ ⊢ B
unit : ∀ {Γ} → Γ ⊢ ⫪
-- Shorthand for variables.
v₀ : ∀ {A Γ} → Γ , A ⊢ A
v₀ = var i₀
v₁ : ∀ {A B Γ} → Γ , A , B ⊢ A
v₁ = var i₁
v₂ : ∀ {A B C Γ} → Γ , A , B , C ⊢ A
v₂ = var i₂
-- Stacks of derivations, or simultaneous syntactic entailment.
infix 3 _⊢⋆_
_⊢⋆_ : Context → Stack Type → Set
Γ ⊢⋆ ∅ = ⊤
Γ ⊢⋆ Ξ , A = Γ ⊢⋆ Ξ ∧ Γ ⊢ A
-- Monotonicity of syntactic entailment with respect to context inclusion.
mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A
mono⊢ p (var i) = var (mono∈ p i)
mono⊢ p (lam d) = lam (mono⊢ (keep p) d)
mono⊢ p (app d e) = app (mono⊢ p d) (mono⊢ p e)
mono⊢ p (pair d e) = pair (mono⊢ p d) (mono⊢ p e)
mono⊢ p (fst d) = fst (mono⊢ p d)
mono⊢ p (snd d) = snd (mono⊢ p d)
mono⊢ p unit = unit
mono⊢⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ Ξ → Γ′ ⊢⋆ Ξ
mono⊢⋆ {∅} p ∙ = ∙
mono⊢⋆ {Ξ , A} p (ζ , d) = mono⊢⋆ p ζ , mono⊢ p d
-- TODO: Naming things.
idmono⊢ : ∀ {A Γ} → (d : Γ ⊢ A) → mono⊢ refl⊆ d ≡ d
idmono⊢ (var {A} i) = cong var (idmono∈ i)
idmono⊢ (lam d) = cong lam (idmono⊢ d)
idmono⊢ (app d e) = cong² app (idmono⊢ d) (idmono⊢ e)
idmono⊢ (pair d e) = cong² pair (idmono⊢ d) (idmono⊢ e)
idmono⊢ (fst d) = cong fst (idmono⊢ d)
idmono⊢ (snd d) = cong snd (idmono⊢ d)
idmono⊢ unit = refl
idmono⊢⋆ : ∀ {Ξ Γ} → (ζ : Γ ⊢⋆ Ξ) → mono⊢⋆ refl⊆ ζ ≡ ζ
idmono⊢⋆ {∅} ∙ = refl
idmono⊢⋆ {Ξ , A} (ζ , d) = cong² _,_ (idmono⊢⋆ ζ) (idmono⊢ d)
-- Reflexivity of simultaneous syntactic entailment.
refl⊢⋆ : ∀ {Γ} → Γ ⊢⋆ Γ
refl⊢⋆ {∅} = ∙
refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀
-- Substitution.
[_≔_]∈_ : ∀ {A C Γ} → (i : C ∈ Γ) → Γ ∖ i ⊢ C → A ∈ Γ → Γ ∖ i ⊢ A
[ i ≔ c ]∈ j with i ≟∈ j
[ i ≔ c ]∈ .i | same = c
[ i ≔ c ]∈ ._ | diff j = var j
[_≔_]_ : ∀ {A C Γ} → (i : C ∈ Γ) → Γ ∖ i ⊢ C → Γ ⊢ A → Γ ∖ i ⊢ A
[ i ≔ c ] var j = [ i ≔ c ]∈ j
[ i ≔ c ] lam d = lam ([ pop i ≔ mono⊢ weak⊆ c ] d)
[ i ≔ c ] app d e = app ([ i ≔ c ] d) ([ i ≔ c ] e)
[ i ≔ c ] pair d e = pair ([ i ≔ c ] d) ([ i ≔ c ] e)
[ i ≔ c ] fst d = fst ([ i ≔ c ] d)
[ i ≔ c ] snd d = snd ([ i ≔ c ] d)
[ i ≔ c ] unit = unit
-- Grafting of derivation trees, or simultaneous substitution, or cut.
graft∈ : ∀ {A Ξ Γ} → Γ ⊢⋆ Ξ → A ∈ Ξ → Γ ⊢ A
graft∈ (ζ , d) top = d
graft∈ (ζ , d) (pop i) = graft∈ ζ i
graft⊢ : ∀ {A Ξ Γ} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A
graft⊢ ζ (var i) = graft∈ ζ i
graft⊢ ζ (lam d) = lam (graft⊢ (mono⊢⋆ weak⊆ ζ , v₀) d)
graft⊢ ζ (app d e) = app (graft⊢ ζ d) (graft⊢ ζ e)
graft⊢ ζ (pair d e) = pair (graft⊢ ζ d) (graft⊢ ζ e)
graft⊢ ζ (fst d) = fst (graft⊢ ζ d)
graft⊢ ζ (snd d) = snd (graft⊢ ζ d)
graft⊢ ζ unit = unit
-- Derivations, or syntactic entailment, in normal form.
mutual
infix 3 _⊢ⁿᶠ_
data _⊢ⁿᶠ_ : Context → Type → Set where
neⁿᶠ : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊢ⁿᶠ A
lamⁿᶠ : ∀ {A B Γ} → Γ , A ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ⇒ B
pairⁿᶠ : ∀ {A B Γ} → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ⩕ B
unitⁿᶠ : ∀ {Γ} → Γ ⊢ⁿᶠ ⫪
infix 3 _⊢ⁿᵉ_
data _⊢ⁿᵉ_ : Context → Type → Set where
varⁿᵉ : ∀ {A Γ} → A ∈ Γ → Γ ⊢ⁿᵉ A
appⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ⇒ B → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᵉ B
fstⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ⩕ B → Γ ⊢ⁿᵉ A
sndⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ⩕ B → Γ ⊢ⁿᵉ B
-- Shorthand for variables.
v₀ⁿᵉ : ∀ {A Γ} → Γ , A ⊢ⁿᵉ A
v₀ⁿᵉ = varⁿᵉ top
-- Stacks of derivations, or simultaneous syntactic entailment, in normal form.
infix 3 _⊢⋆ⁿᵉ_
_⊢⋆ⁿᵉ_ : Context → Stack Type → Set
Γ ⊢⋆ⁿᵉ ∅ = ⊤
Γ ⊢⋆ⁿᵉ Ξ , A = Γ ⊢⋆ⁿᵉ Ξ ∧ Γ ⊢ⁿᵉ A
-- Translation from normal form to arbitrary form.
mutual
nf→af : ∀ {A Γ} → Γ ⊢ⁿᶠ A → Γ ⊢ A
nf→af (neⁿᶠ d) = ne→af d
nf→af (lamⁿᶠ d) = lam (nf→af d)
nf→af (pairⁿᶠ d e) = pair (nf→af d) (nf→af e)
nf→af unitⁿᶠ = unit
ne→af : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊢ A
ne→af (varⁿᵉ i) = var i
ne→af (appⁿᵉ d e) = app (ne→af d) (nf→af e)
ne→af (fstⁿᵉ d) = fst (ne→af d)
ne→af (sndⁿᵉ d) = snd (ne→af d)
-- Monotonicity of syntactic entailment with respect to context inclusion, in normal form.
mutual
mono⊢ⁿᶠ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᶠ A → Γ′ ⊢ⁿᶠ A
mono⊢ⁿᶠ p (neⁿᶠ d) = neⁿᶠ (mono⊢ⁿᵉ p d)
mono⊢ⁿᶠ p (lamⁿᶠ d) = lamⁿᶠ (mono⊢ⁿᶠ (keep p) d)
mono⊢ⁿᶠ p (pairⁿᶠ d e) = pairⁿᶠ (mono⊢ⁿᶠ p d) (mono⊢ⁿᶠ p e)
mono⊢ⁿᶠ p unitⁿᶠ = unitⁿᶠ
mono⊢ⁿᵉ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᵉ A → Γ′ ⊢ⁿᵉ A
mono⊢ⁿᵉ p (varⁿᵉ i) = varⁿᵉ (mono∈ p i)
mono⊢ⁿᵉ p (appⁿᵉ d e) = appⁿᵉ (mono⊢ⁿᵉ p d) (mono⊢ⁿᶠ p e)
mono⊢ⁿᵉ p (fstⁿᵉ d) = fstⁿᵉ (mono⊢ⁿᵉ p d)
mono⊢ⁿᵉ p (sndⁿᵉ d) = sndⁿᵉ (mono⊢ⁿᵉ p d)
mono⊢⋆ⁿᵉ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ⁿᵉ Ξ → Γ′ ⊢⋆ⁿᵉ Ξ
mono⊢⋆ⁿᵉ {∅} p ∙ = ∙
mono⊢⋆ⁿᵉ {Ξ , A} p (ζ , d) = mono⊢⋆ⁿᵉ p ζ , mono⊢ⁿᵉ p d
-- TODO: Naming things.
mutual
idmono⊢ⁿᶠ : ∀ {A Γ} → (d : Γ ⊢ⁿᶠ A) → mono⊢ⁿᶠ refl⊆ d ≡ d
idmono⊢ⁿᶠ (neⁿᶠ d) = cong neⁿᶠ (idmono⊢ⁿᵉ d)
idmono⊢ⁿᶠ (lamⁿᶠ d) = cong lamⁿᶠ (idmono⊢ⁿᶠ d)
idmono⊢ⁿᶠ (pairⁿᶠ d e) = cong² pairⁿᶠ (idmono⊢ⁿᶠ d) (idmono⊢ⁿᶠ e)
idmono⊢ⁿᶠ unitⁿᶠ = refl
idmono⊢ⁿᵉ : ∀ {A Γ} → (d : Γ ⊢ⁿᵉ A) → mono⊢ⁿᵉ refl⊆ d ≡ d
idmono⊢ⁿᵉ (varⁿᵉ i) = cong varⁿᵉ (idmono∈ i)
idmono⊢ⁿᵉ (appⁿᵉ d e) = cong² appⁿᵉ (idmono⊢ⁿᵉ d) (idmono⊢ⁿᶠ e)
idmono⊢ⁿᵉ (fstⁿᵉ d) = cong fstⁿᵉ (idmono⊢ⁿᵉ d)
idmono⊢ⁿᵉ (sndⁿᵉ d) = cong sndⁿᵉ (idmono⊢ⁿᵉ d)
idmono⊢⋆ⁿᵉ : ∀ {Ξ Γ} → (ζ : Γ ⊢⋆ⁿᵉ Ξ) → mono⊢⋆ⁿᵉ refl⊆ ζ ≡ ζ
idmono⊢⋆ⁿᵉ {∅} ∙ = refl
idmono⊢⋆ⁿᵉ {Ξ , A} (ζ , d) = cong² _,_ (idmono⊢⋆ⁿᵉ ζ) (idmono⊢ⁿᵉ d)
-- Reflexivity of simultaneous syntactic entailment, in normal form.
refl⊢⋆ⁿᵉ : ∀ {Γ} → Γ ⊢⋆ⁿᵉ Γ
refl⊢⋆ⁿᵉ {∅} = ∙
refl⊢⋆ⁿᵉ {Γ , A} = mono⊢⋆ⁿᵉ weak⊆ refl⊢⋆ⁿᵉ , v₀ⁿᵉ
| {
"alphanum_fraction": 0.4974611235,
"avg_line_length": 27.6403508772,
"ext": "agda",
"hexsha": "3f4acfad961f1d1768d8544b1d9efffebbe7b43d",
"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/Syntax.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/Syntax.agda",
"max_line_length": 90,
"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/Syntax.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": 3898,
"size": 6302
} |
------------------------------------------------------------------------
-- Encoder and decoder instances
------------------------------------------------------------------------
open import Atom
module Coding.Instances (atoms : χ-atoms) where
open import Prelude
open import Chi atoms
open import Free-variables atoms
open import Values atoms
open χ-atoms atoms
open import Coding atoms as Coding using (Rep; module Code)
instance
rep-Consts-Exp : ∀ {a} {A : Type a} ⦃ r : Rep A Consts ⦄ →
Rep A Exp
rep-Consts-Exp = Coding.rep-Consts-Exp
rep-Consts-Closed-exp :
∀ {a} {A : Type a} ⦃ r : Rep A Consts ⦄ → Rep A Closed-exp
rep-Consts-Closed-exp = Coding.rep-Consts-Closed-exp
rep-Bool : Rep Bool Consts
rep-Bool = Code.rep Coding.code-Bool
rep-ℕ : Rep ℕ Consts
rep-ℕ = Code.rep Coding.code-ℕ
rep-Var : Rep Var Consts
rep-Var = Code.rep Coding.code-Var
rep-Const : Rep Const Consts
rep-Const = Code.rep Coding.code-Const
rep-× : ∀ {a b} {A : Type a} {B : Type b}
⦃ c : Rep A Consts ⦄ ⦃ d : Rep B Consts ⦄ →
Rep (A × B) Consts
rep-× = Coding.rep-×
rep-Var⋆ : Rep (List Var) Consts
rep-Var⋆ = Code.rep Coding.code-Var⋆
rep-Exp : Rep Exp Consts
rep-Exp = Code.rep Coding.code-Exp
rep-Br : Rep Br Consts
rep-Br = Code.rep Coding.code-Br
rep-Exps : Rep (List Exp) Consts
rep-Exps = Code.rep Coding.code-Exps
rep-Brs : Rep (List Br) Consts
rep-Brs = Code.rep Coding.code-Brs
rep-Closed : Rep Closed-exp Consts
rep-Closed = Code.rep Coding.code-Closed
| {
"alphanum_fraction": 0.582278481,
"avg_line_length": 25.0793650794,
"ext": "agda",
"hexsha": "e37e6d2f764d6c2e802d6291cdd41a765aecfcb2",
"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": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/chi",
"max_forks_repo_path": "src/Coding/Instances.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1",
"max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/chi",
"max_issues_repo_path": "src/Coding/Instances.agda",
"max_line_length": 72,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/chi",
"max_stars_repo_path": "src/Coding/Instances.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z",
"num_tokens": 495,
"size": 1580
} |
module Nat where
import Bool
open Bool
data Nat : Set where
zero : Nat
suc : Nat -> Nat
infixr 25 _+_
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
infix 10 _==_ _<_
_==_ : Nat -> Nat -> Bool
zero == zero = true
suc n == zero = false
zero == suc m = false
suc n == suc m = n == m
_<_ : Nat -> Nat -> Bool
n < zero = false
zero < suc m = true
suc n < suc m = n < m
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
-- {-# BUILTIN NATPLUS _+_ #-}
-- {-# BUILTIN NATEQUALS _==_ #-}
-- {-# BUILTIN NATLESS _<_ #-}
| {
"alphanum_fraction": 0.5354058722,
"avg_line_length": 15.6486486486,
"ext": "agda",
"hexsha": "88aa22dac0138be998c44c544769852b631cbf36",
"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": "benchmark/ac/Nat.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": "benchmark/ac/Nat.agda",
"max_line_length": 33,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "benchmark/ac/Nat.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": 211,
"size": 579
} |
module #1 where
open import Level
open import Relation.Binary.PropositionalEquality
{-
Exercise 1.1. Given functions f : A → B and g : B → C, define their composite g ◦ f : A → C.
Show that we have h ◦ (g ◦ f ) ≡ (h ◦ g) ◦ f .
-}
-- Function composition
_∘_ : ∀ {a b c}{A : Set a}{B : Set b}{C : Set c} → (B → C) → (A → B) → A → C
f ∘ g = λ x → f (g x)
-- Proof of associativity of composition
∘-assoc : ∀ {a b c d}{A : Set a}{B : Set b}{C : Set c}{D : Set d} →
(h : C → D) → (g : B → C) → (f : A → B) →
h ∘ (g ∘ f) ≡ (h ∘ g) ∘ f
∘-assoc _ _ _ = refl
| {
"alphanum_fraction": 0.5008635579,
"avg_line_length": 28.95,
"ext": "agda",
"hexsha": "ec70a3709984c7365fced018163bc1c184809a65",
"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": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CodaFi/HoTT-Exercises",
"max_forks_repo_path": "Chapter1/#1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"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": "CodaFi/HoTT-Exercises",
"max_issues_repo_path": "Chapter1/#1.agda",
"max_line_length": 92,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CodaFi/HoTT-Exercises",
"max_stars_repo_path": "Chapter1/#1.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 239,
"size": 579
} |
module Miscellaneous.InstanceLoop where
open import Type
postulate A : TYPE
postulate B : TYPE
postulate C : TYPE
instance
postulate ab : ⦃ A ⦄ → B
instance
postulate ba : ⦃ B ⦄ → A
postulate a : A
test-a : B
test-a = ab
| {
"alphanum_fraction": 0.683982684,
"avg_line_length": 12.1578947368,
"ext": "agda",
"hexsha": "9455e90059edec99f6d278a21feaa8aa2624424e",
"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": "Miscellaneous/InstanceLoop.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": "Miscellaneous/InstanceLoop.agda",
"max_line_length": 39,
"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": "Miscellaneous/InstanceLoop.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": 78,
"size": 231
} |
module Lemmachine.Resource.Universe where
open import Lemmachine.Request
open import Lemmachine.Response
open import Data.Maybe
open import Data.List
open import Data.Product
open import Data.Bool
open import Data.String
AuthHead = Bool
MediaType = String
Handler = String
Charset = String
CharsetConverter = String
Encoding = String
Encoder = String
MovedURI = String
DateTime = String
ETag = String
data Code : Set where
resourceExists serviceAvailable isAuthorized : Code
forbidden allowMissingPost malformedRequest : Code
uriTooLong knownContentType validContentHeaders : Code
validEntityLength options allowedMethods : Code
knownMethods deleteResource deleteCompleted : Code
postIsCreate createPath processPost : Code
contentTypesProvided languageAvailable contentTypesAccepted : Code
charsetsProvided encodingsProvided variances : Code
isConflict multipleChoices previouslyExisted : Code
movedPermanently movedTemporarily lastModified : Code
expires generateETag finishRequest body : Code
El : Code → Set
El resourceExists = Request → Bool
El serviceAvailable = Request → Bool
El isAuthorized = Request → AuthHead
El forbidden = Request → Bool
El allowMissingPost = Request → Bool
El malformedRequest = Request → Bool
El uriTooLong = Request → Bool
El knownContentType = Request → Bool
El validContentHeaders = Request → Bool
El validEntityLength = Request → Bool
El options = Request → List ResponseHeader
El allowedMethods = Request → List Method
El knownMethods = Request → List Method
El deleteResource = Request → Bool
El deleteCompleted = Request → Bool
El postIsCreate = Request → Bool
El createPath = Request → Maybe Path
El processPost = Request → Bool
El contentTypesProvided = Request → List MediaType
El languageAvailable = Request → Bool
El contentTypesAccepted = Request → List (MediaType × Handler)
El charsetsProvided = Request → List (Charset × CharsetConverter)
El encodingsProvided = Request → List (Encoding × Encoder)
El variances = Request → List RequestHeader
El isConflict = Request → Bool
El multipleChoices = Request → Bool
El previouslyExisted = Request → Bool
El movedPermanently = Request → Maybe MovedURI
El movedTemporarily = Request → Maybe MovedURI
El lastModified = Request → Maybe DateTime
El expires = Request → Maybe DateTime
El generateETag = Request → Maybe ETag
El finishRequest = Request → Bool
El body = Status → String
| {
"alphanum_fraction": 0.7998328458,
"avg_line_length": 34.6811594203,
"ext": "agda",
"hexsha": "edbbf5ae73758795f3fe90df5701a7d6cf5dcb43",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "src/Lemmachine/Resource/Universe.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "src/Lemmachine/Resource/Universe.agda",
"max_line_length": 68,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "src/Lemmachine/Resource/Universe.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 541,
"size": 2393
} |
------------------------------------------------------------------------------
-- FOTC list terms properties
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Base.List.PropertiesI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Base.List
------------------------------------------------------------------------------
-- Congruence properties
∷-leftCong : ∀ {x y xs} → x ≡ y → x ∷ xs ≡ y ∷ xs
∷-leftCong refl = refl
∷-rightCong : ∀ {x xs ys} → xs ≡ ys → x ∷ xs ≡ x ∷ ys
∷-rightCong refl = refl
∷-cong : ∀ {x y xs ys} → x ≡ y → xs ≡ ys → x ∷ xs ≡ y ∷ ys
∷-cong refl refl = refl
headCong : ∀ {xs ys} → xs ≡ ys → head₁ xs ≡ head₁ ys
headCong refl = refl
tailCong : ∀ {xs ys} → xs ≡ ys → tail₁ xs ≡ tail₁ ys
tailCong refl = refl
------------------------------------------------------------------------------
-- Injective properties
∷-injective : ∀ {x y xs ys} → x ∷ xs ≡ y ∷ ys → x ≡ y ∧ xs ≡ ys
∷-injective {x} {y} {xs} {ys} h = x≡y , xs≡ys
where
x≡y : x ≡ y
x≡y = x ≡⟨ sym (head-∷ x xs) ⟩
head₁ (x ∷ xs) ≡⟨ headCong h ⟩
head₁ (y ∷ ys) ≡⟨ head-∷ y ys ⟩
y ∎
xs≡ys : xs ≡ ys
xs≡ys = xs ≡⟨ sym (tail-∷ x xs) ⟩
tail₁ (x ∷ xs) ≡⟨ tailCong h ⟩
tail₁ (y ∷ ys) ≡⟨ tail-∷ y ys ⟩
ys ∎
| {
"alphanum_fraction": 0.4032051282,
"avg_line_length": 30,
"ext": "agda",
"hexsha": "f96a72748bcce2fe7f59b2330212c25825eb6c5f",
"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/Base/List/PropertiesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Base/List/PropertiesI.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Base/List/PropertiesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 507,
"size": 1560
} |
{-# OPTIONS --without-K #-}
open import HoTT.Base
open import HoTT.Equivalence
module HoTT.Equivalence.Empty where
open variables
𝟎-equiv : {A : 𝒰 i} → ¬ A → 𝟎 {i} ≃ A
𝟎-equiv ¬a = 𝟎-rec , qinv→isequiv (𝟎-rec ∘ ¬a , 𝟎-ind , 𝟎-rec ∘ ¬a)
| {
"alphanum_fraction": 0.6317991632,
"avg_line_length": 21.7272727273,
"ext": "agda",
"hexsha": "d06600309078b58961a2bddacd8f091a17ccb058",
"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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "michaelforney/hott",
"max_forks_repo_path": "HoTT/Equivalence/Empty.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "michaelforney/hott",
"max_issues_repo_path": "HoTT/Equivalence/Empty.agda",
"max_line_length": 67,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "michaelforney/hott",
"max_stars_repo_path": "HoTT/Equivalence/Empty.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 104,
"size": 239
} |
-- 2014-05-27 Jesper and Andreas
postulate
A : Set
{-# BUILTIN REWRITE A #-}
-- Expected error:
-- A does not have the right type for a rewriting relation
-- because it should accept at least two arguments
-- when checking the pragma BUILTIN REWRITE A
| {
"alphanum_fraction": 0.7209302326,
"avg_line_length": 21.5,
"ext": "agda",
"hexsha": "c230084a611da1e9e62f83b36443cee1c9ea26cb",
"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/fail/RewriteRelationNotEnoughArguments.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/RewriteRelationNotEnoughArguments.agda",
"max_line_length": 59,
"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/fail/RewriteRelationNotEnoughArguments.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": 67,
"size": 258
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.elims.SuspSmash
-- (ΣX)∧Y ≃ Σ(X∧Y)
module homotopy.SuspSmash where
module _ {i j} (X : Ptd i) (Y : Ptd j) where
private
x₀ = pt X
y₀ = pt Y
Σ∧-out-smgluel-merid : ∀ (x : de⊙ X) →
Square idp
(ap (Susp-fmap (λ x' → smin x' y₀)) (merid x))
(ap (λ sx → north) (merid x))
(! (merid (smin x₀ y₀)))
Σ∧-out-smgluel-merid x =
((SuspFmap.merid-β (λ x' → smin x' y₀) x ∙ ap merid (∧-norm-l x)) ∙v⊡
tr-square (merid (smin x₀ y₀))) ⊡v∙
! (ap-cst north (merid x))
module Σ∧OutSmgluel =
SuspPathElim
(Susp-fmap (λ x' → smin x' y₀))
(λ sx → north)
idp
(! (merid (smin x₀ y₀)))
Σ∧-out-smgluel-merid
module Σ∧Out =
SmashRec {X = ⊙Susp (de⊙ X)} {Y = Y}
{C = Susp (X ∧ Y)}
(λ sx y → Susp-fmap (λ x → smin x y) sx)
north
north
Σ∧OutSmgluel.f
(λ y → idp)
Σ∧-out : ⊙Susp (de⊙ X) ∧ Y → Susp (X ∧ Y)
Σ∧-out = Σ∧Out.f
⊙Σ∧-out : ⊙Susp (de⊙ X) ⊙∧ Y ⊙→ ⊙Susp (X ∧ Y)
⊙Σ∧-out = Σ∧-out , idp
Σ∧-out-∧-norm-r : ∀ (y : de⊙ Y) →
ap Σ∧-out (∧-norm-r y) == idp
Σ∧-out-∧-norm-r y = Σ∧Out.∧-norm-r-β y
∧Σ-out-smgluer-merid : ∀ (y : de⊙ Y) →
Square idp
(ap (λ sy → Susp-fmap (smin x₀) sy) (merid y))
(ap (λ sy → north) (merid y))
(! (merid (smin x₀ y₀)))
∧Σ-out-smgluer-merid y =
((SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ∙v⊡
tr-square (merid (smin x₀ y₀))) ⊡v∙
! (ap-cst north (merid y))
module ∧ΣOutSmgluer =
SuspPathElim
(λ sy → Susp-fmap (smin x₀) sy)
(λ sy → north)
idp
(! (merid (smin x₀ y₀)))
∧Σ-out-smgluer-merid
module ∧ΣOut =
SmashRec {X = X} {Y = ⊙Susp (de⊙ Y)}
{C = Susp (X ∧ Y)}
(λ x sy → Susp-fmap (smin x) sy)
north
north
(λ x → idp)
∧ΣOutSmgluer.f
∧Σ-out : X ∧ ⊙Susp (de⊙ Y) → Susp (X ∧ Y)
∧Σ-out = ∧ΣOut.f
⊙∧Σ-out : X ⊙∧ ⊙Susp (de⊙ Y) ⊙→ ⊙Susp (X ∧ Y)
⊙∧Σ-out = ∧Σ-out , idp
∧Σ-out-∧-norm-l : ∀ (x : de⊙ X) →
ap ∧Σ-out (∧-norm-l x) == idp
∧Σ-out-∧-norm-l x = ∧ΣOut.∧-norm-l-β x
Σ∧-in-merid-smin : de⊙ X → de⊙ Y → pt (⊙Susp (de⊙ X) ⊙∧ Y) == pt (⊙Susp (de⊙ X) ⊙∧ Y)
Σ∧-in-merid-smin x y = ↯ $
smin north y₀
=⟪ ! (∧-norm-r y) ⟫
smin north y
=⟪ ap (λ sx → smin sx y) (merid x ∙ ! (merid x₀)) ⟫
smin north y
=⟪ ∧-norm-r y ⟫
smin north y₀ ∎∎
Σ∧-in-merid-smgluel : ∀ (x : de⊙ X) → Σ∧-in-merid-smin x y₀ == idp
Σ∧-in-merid-smgluel x = ↯ $
Σ∧-in-merid-smin x y₀
=⟪ ap (λ u → ! u ∙ ap (λ sx → smin sx y₀) (merid x ∙ ! (merid x₀)) ∙ u)
(!-inv-r (smgluer y₀)) ⟫
ap (λ sx → smin sx y₀) (merid x ∙ ! (merid x₀)) ∙ idp
=⟪ ap (_∙ idp) $
ap-null-homotopic (λ sx → smin sx y₀)
smgluel
(merid x ∙ ! (merid x₀)) ⟫
(smgluel north ∙ ! (smgluel north)) ∙ idp
=⟪ ap (_∙ idp) (!-inv-r (smgluel north)) ⟫
idp ∎∎
Σ∧-in-merid-smgluer : ∀ (y : de⊙ Y) → Σ∧-in-merid-smin x₀ y == idp
Σ∧-in-merid-smgluer y = ↯ $
Σ∧-in-merid-smin x₀ y
=⟪ ap (λ p → ! (∧-norm-r y) ∙ ap (λ sx → smin sx y) p ∙ ∧-norm-r y)
(!-inv-r (merid x₀)) ⟫
! (∧-norm-r y) ∙ ∧-norm-r y
=⟪ !-inv-l (∧-norm-r y) ⟫
idp ∎∎
Σ∧-in : Susp (X ∧ Y) → ⊙Susp (de⊙ X) ∧ Y
Σ∧-in =
Susp-rec
{C = ⊙Susp (de⊙ X) ∧ Y}
(smin north y₀)
(smin north y₀)
(Smash-rec
{C = smin north y₀ == smin north y₀}
Σ∧-in-merid-smin
idp
idp
Σ∧-in-merid-smgluel
Σ∧-in-merid-smgluer)
module _ {i j} (X : Ptd i) (Y : Ptd j) where
private
x₀ = pt X
y₀ = pt Y
∧-swap-∧Σ-out-merid : ∀ (x : de⊙ X) (y : de⊙ Y) →
ap (Susp-fmap (∧-swap X Y) ∘ Susp-fmap (smin x)) (merid y) =-=
merid (smin y x)
∧-swap-∧Σ-out-merid x y =
ap (Susp-fmap (∧-swap X Y) ∘ Susp-fmap (smin x)) (merid y)
=⟪ ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x)) (merid y) ⟫
ap (Susp-fmap (∧-swap X Y)) (ap (Susp-fmap (smin x)) (merid y))
=⟪ ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x) y) ⟫
ap (Susp-fmap (∧-swap X Y)) (merid (smin x y))
=⟪ SuspFmap.merid-β (∧-swap X Y) (smin x y) ⟫
merid (smin y x) ∎∎
{- This is the same as `! (Susp-fmap-∘ (∧-swap X Y) (smin x))`, except that
the merid case is easier to reason about, which we will do in
`Σ∧-∧Σ-swap-smgluer-merid`. -}
module Σ∧-∧Σ-swap-smin (x : de⊙ X) =
SuspPathElim
(Susp-fmap (∧-swap X Y) ∘ Susp-fmap (smin x))
(Susp-fmap (λ y → smin y x))
idp
idp
(λ y → ↯ (∧-swap-∧Σ-out-merid x y) ∙v⊡ vid-square ⊡v∙ ! (SuspFmap.merid-β (λ y' → smin y' x) y))
∧-swap-∧Σ-out-smgluel : ∀ x →
ap (Susp-fmap (∧-swap X Y) ∘ ∧Σ-out X Y) (smgluel x) == idp
∧-swap-∧Σ-out-smgluel x =
ap (Susp-fmap (∧-swap X Y) ∘ ∧Σ-out X Y) (smgluel x)
=⟨ ap-∘ (Susp-fmap (∧-swap X Y)) (∧Σ-out X Y) (smgluel x) ⟩
ap (Susp-fmap (∧-swap X Y)) (ap (∧Σ-out X Y) (smgluel x))
=⟨ ap (ap (Susp-fmap (∧-swap X Y))) (∧ΣOut.smgluel-β X Y x) ⟩
idp =∎
Σ∧-out-∧-swap-smgluel : ∀ x →
ap (Σ∧-out Y X ∘ ∧-swap X (⊙Susp (de⊙ Y))) (smgluel x) == idp
Σ∧-out-∧-swap-smgluel x =
ap (Σ∧-out Y X ∘ ∧-swap X (⊙Susp (de⊙ Y))) (smgluel x)
=⟨ ap-∘ (Σ∧-out Y X) (∧-swap X (⊙Susp (de⊙ Y))) (smgluel x) ⟩
ap (Σ∧-out Y X) (ap (∧-swap X (⊙Susp (de⊙ Y))) (smgluel x))
=⟨ ap (ap (Σ∧-out Y X)) (SmashSwap.smgluel-β X (⊙Susp (de⊙ Y)) x) ⟩
ap (Σ∧-out Y X) (∧-norm-r x)
=⟨ Σ∧-out-∧-norm-r Y X x ⟩
idp =∎
∧-swap-∧Σ-out-smgluer : ∀ sy →
ap (Susp-fmap (∧-swap X Y) ∘ ∧Σ-out X Y) (smgluer sy) ==
ap (Susp-fmap (∧-swap X Y)) (∧ΣOutSmgluer.f X Y sy)
∧-swap-∧Σ-out-smgluer sy =
ap (Susp-fmap (∧-swap X Y) ∘ ∧Σ-out X Y) (smgluer sy)
=⟨ ap-∘ (Susp-fmap (∧-swap X Y)) (∧Σ-out X Y) (smgluer sy) ⟩
ap (Susp-fmap (∧-swap X Y)) (ap (∧Σ-out X Y) (smgluer sy))
=⟨ ap (ap (Susp-fmap (∧-swap X Y))) (∧ΣOut.smgluer-β X Y sy) ⟩
ap (Susp-fmap (∧-swap X Y)) (∧ΣOutSmgluer.f X Y sy) =∎
Σ∧-out-∧-swap-smgluer : ∀ sy →
ap (Σ∧-out Y X ∘ ∧-swap X (⊙Susp (de⊙ Y))) (smgluer sy) == Σ∧OutSmgluel.f Y X sy
Σ∧-out-∧-swap-smgluer sy =
ap (Σ∧-out Y X ∘ ∧-swap X (⊙Susp (de⊙ Y))) (smgluer sy)
=⟨ ap-∘ (Σ∧-out Y X) (∧-swap X (⊙Susp (de⊙ Y))) (smgluer sy) ⟩
ap (Σ∧-out Y X) (ap (∧-swap X (⊙Susp (de⊙ Y))) (smgluer sy))
=⟨ ap (ap (Σ∧-out Y X)) (SmashSwap.smgluer-β X (⊙Susp (de⊙ Y)) sy) ⟩
ap (Σ∧-out Y X) (∧-norm-l sy)
=⟨ Σ∧Out.∧-norm-l-β Y X sy ⟩
Σ∧OutSmgluel.f Y X sy ∙ idp
=⟨ ∙-unit-r (Σ∧OutSmgluel.f Y X sy) ⟩
Σ∧OutSmgluel.f Y X sy =∎
Σ∧-∧Σ-swap-smgluer-merid : ∀ y →
Cube ids
((ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
∙v⊡ vid-square)
(natural-square (Σ∧-∧Σ-swap-smin.f x₀) (merid y))
(natural-square (ap (Susp-fmap (∧-swap X Y)) ∘ ∧ΣOutSmgluer.f X Y) (merid y))
(natural-square (Σ∧OutSmgluel.f Y X) (merid y))
(natural-square (λ v → idp) (merid y))
Σ∧-∧Σ-swap-smgluer-merid y =
cube-shift-back (! (Σ∧-∧Σ-swap-smin.merid-square-β x₀ y)) $
custom-cube-∙v⊡
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
(↯ (∧-swap-∧Σ-out-merid x₀ y))
(ap-cst north (merid y)) $
cube-shift-top (! top-path) $
custom-cube-⊡v∙
(! (SuspFmap.merid-β (λ y' → smin y' x₀) y))
(ap-cst north (merid y)) $
cube-shift-front (! front-path) $
cube-shift-bot (! bot-path) $
custom-cube (ap merid (∧-norm-l y))
where
custom-cube-∙v⊡ :
∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A}
{p₀₋₀ : a₀₀₀ == a₀₁₀}
{p₋₀₀ : a₀₀₀ == a₁₀₀}
{p₋₁₀ : a₀₁₀ == a₁₁₀}
{p₁₋₀ : a₁₀₀ == a₁₁₀}
{sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left
{p₀₋₁ : a₀₀₁ == a₀₁₁}
{p₋₀₁ p₋₀₁' : a₀₀₁ == a₁₀₁} (q₋₀₁ : p₋₀₁' == p₋₀₁)
{p₋₁₁ : a₀₁₁ == a₁₁₁}
{p₁₋₁ : a₁₀₁ == a₁₁₁}
{sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right
{p₀₀₋ p₀₀₋' : a₀₀₀ == a₀₀₁} (q₀₀₋ : p₀₀₋' == p₀₀₋)
{p₀₁₋ : a₀₁₀ == a₀₁₁}
{p₁₀₋ p₁₀₋' : a₁₀₀ == a₁₀₁} (q₁₀₋ : p₁₀₋ == p₁₀₋')
{p₁₁₋ : a₁₁₀ == a₁₁₁}
{sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back
{sq₋₀₋ : Square p₋₀₀ p₀₀₋' p₁₀₋ p₋₀₁'} -- top
{sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} -- bottom
{sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front
→ Cube sq₋₋₀ sq₋₋₁ sq₀₋₋ ((! q₀₀₋ ∙v⊡ sq₋₀₋ ⊡v∙ q₁₀₋) ⊡h∙ q₋₀₁) sq₋₁₋ (! q₁₀₋ ∙v⊡ sq₁₋₋)
→ Cube sq₋₋₀ (q₋₀₁ ∙v⊡ sq₋₋₁) (q₀₀₋ ∙v⊡ sq₀₋₋) sq₋₀₋ sq₋₁₋ sq₁₋₋
custom-cube-∙v⊡ idp idp idp c = c
custom-cube-⊡v∙ : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A}
{p₀₋₀ : a₀₀₀ == a₀₁₀}
{p₋₀₀ : a₀₀₀ == a₁₀₀}
{p₋₁₀ : a₀₁₀ == a₁₁₀}
{p₁₋₀ : a₁₀₀ == a₁₁₀}
{sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left
{p₀₋₁ : a₀₀₁ == a₀₁₁}
{p₋₀₁ : a₀₀₁ == a₁₀₁}
{p₋₁₁ : a₀₁₁ == a₁₁₁}
{p₁₋₁ : a₁₀₁ == a₁₁₁}
{sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right
{p₀₀₋ : a₀₀₀ == a₀₀₁}
{p₀₁₋ p₀₁₋' : a₀₁₀ == a₀₁₁} (q₀₁₋ : p₀₁₋ == p₀₁₋')
{p₁₀₋ : a₁₀₀ == a₁₀₁}
{p₁₁₋ p₁₁₋' : a₁₁₀ == a₁₁₁} (q₁₁₋ : p₁₁₋ == p₁₁₋')
{sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back
{sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} -- top
{sq₋₁₋ : Square p₋₁₀ p₀₁₋' p₁₁₋ p₋₁₁} -- bottom
{sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front
→ Cube sq₋₋₀ sq₋₋₁ sq₀₋₋ sq₋₀₋ (q₀₁₋ ∙v⊡ sq₋₁₋ ⊡v∙ q₁₁₋) (sq₁₋₋ ⊡v∙ q₁₁₋)
→ Cube sq₋₋₀ sq₋₋₁ (sq₀₋₋ ⊡v∙ q₀₁₋) sq₋₀₋ sq₋₁₋ sq₁₋₋
custom-cube-⊡v∙ idp idp c = c
custom-cube : ∀ {i} {A : Type i} {a₀ a₁ : A}
{p q : a₀ == a₁} (r : p == q)
→ Cube ids
vid-square
vid-square
(r ∙v⊡ tr-square q)
(r ∙v⊡ tr-square q)
ids
custom-cube {p = idp} {q = .idp} r@idp = idc
top-path :
(! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
natural-square (ap (Susp-fmap (∧-swap X Y)) ∘ ∧ΣOutSmgluer.f X Y) (merid y) ⊡v∙
ap-cst north (merid y)) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
==
ap merid (∧-norm-l y) ∙v⊡ tr-square (merid (smin y₀ x₀))
top-path =
(! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
natural-square (ap (Susp-fmap (∧-swap X Y)) ∘ ∧ΣOutSmgluer.f X Y) (merid y) ⊡v∙
ap-cst north (merid y)) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
u ⊡v∙
ap-cst north (merid y)) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $
natural-square-ap (Susp-fmap (∧-swap X Y)) (∧ΣOutSmgluer.f X Y) (merid y) ⟩
(! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
(ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
∘-ap (Susp-fmap (∧-swap X Y)) (λ _ → north) (merid y)) ⊡v∙
ap-cst north (merid y)) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
u) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $
∙v⊡-⊡v∙-comm
(ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y))
(ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
∘-ap (Susp-fmap (∧-swap X Y)) (λ _ → north) (merid y))
(ap-cst north (merid y)) ⟩
(! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
∘-ap (Susp-fmap (∧-swap X Y)) (λ _ → north) (merid y) ⊡v∙
ap-cst north (merid y)) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ∙v⊡
u) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $
⊡v∙-assoc
(ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)))
(∘-ap (Susp-fmap (∧-swap X Y)) (λ _ → north) (merid y))
(ap-cst north (merid y)) ⟩
(! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
(∘-ap (Susp-fmap (∧-swap X Y)) (λ _ → north) (merid y) ∙ ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
u) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $
=ₛ-out $ ap-∘-cst-coh (Susp-fmap (∧-swap X Y)) north (merid y) ⟩
(! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙v⊡
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → u ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $ ! $
∙v⊡-assoc
(! (↯ (∧-swap-∧Σ-out-merid x₀ y)))
(ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y))
(ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap-cst north (merid y))) ⟩
((! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ∙
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y)) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (u ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $ =ₛ-out $
! (↯ (∧-swap-∧Σ-out-merid x₀ y)) ◃∙
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ◃∎
=ₛ⟨ 0 & 1 & !-∙-seq $
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ◃∙
↯ (tail (∧-swap-∧Σ-out-merid x₀ y)) ◃∎ ⟩
! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ◃∙
! (ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y)) ◃∙
ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ◃∎
=ₛ⟨ 1 & 2 & seq-!-inv-l (ap-∘ (Susp-fmap (∧-swap X Y)) (Susp-fmap (smin x₀)) (merid y) ◃∎) ⟩
! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ◃∎ ∎ₛ ⟩
(! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (natural-square (∧ΣOutSmgluer.f X Y) (merid y)) ⊡v∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) u ⊡v∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $
∧ΣOutSmgluer.merid-square-β X Y y ⟩
(! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (∧Σ-out-smgluer-merid X Y y) ⊡v∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
u) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $
ap-square-⊡v∙
(Susp-fmap (∧-swap X Y))
(∧Σ-out-smgluer-merid X Y y)
(ap-cst north (merid y)) ⟩
(! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y))
(∧Σ-out-smgluer-merid X Y y ⊡v∙ ap-cst north (merid y))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) u) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $
∧Σ-out-smgluer-merid X Y y ⊡v∙ ap-cst north (merid y)
=⟨ ⊡v∙-assoc
((SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ∙v⊡ tr-square (merid (smin x₀ y₀)))
(! (ap-cst north (merid y)))
(ap-cst north (merid y)) ⟩
((SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ∙v⊡
tr-square (merid (smin x₀ y₀))) ⊡v∙
(! (ap-cst north (merid y)) ∙ ap-cst north (merid y))
=⟨ ap (((SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ∙v⊡
tr-square (merid (smin x₀ y₀))) ⊡v∙_) $
!-inv-l (ap-cst north (merid y)) ⟩
(SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ∙v⊡
tr-square (merid (smin x₀ y₀)) =∎ ⟩
(! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y))
((SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ∙v⊡
tr-square (merid (smin x₀ y₀)))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
u) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $ ! $
ap-square-∙v⊡
(Susp-fmap (∧-swap X Y))
(SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y))
(tr-square (merid (smin x₀ y₀))) ⟩
(! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙v⊡
ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀)))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (_⊡h∙ (ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $ ! $
∙v⊡-assoc
(! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))))
(ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)))
(ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀)))) ⟩
((! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ∙
ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀)))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap (λ u → (u ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀)))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))) $ =ₛ-out $
! (↯ (tail (∧-swap-∧Σ-out-merid x₀ y))) ◃∙
ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ◃∎
=ₛ⟨ 0 & 1 & !-∙-seq (tail (∧-swap-∧Σ-out-merid x₀ y)) ⟩
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y)) ◃∙
! (ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y)) ◃∙
ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y ∙ ap merid (∧-norm-r y)) ◃∎
=ₛ⟨ 2 & 1 &
ap-seq-∙ (ap (Susp-fmap (∧-swap X Y))) $
(SuspFmap.merid-β (smin x₀) y ◃∙ ap merid (∧-norm-r y) ◃∎) ⟩
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y)) ◃∙
! (ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y)) ◃∙
ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y) ◃∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap merid (∧-norm-r y)) ◃∎
=ₛ⟨ 1 & 2 & seq-!-inv-l (ap (ap (Susp-fmap (∧-swap X Y))) (SuspFmap.merid-β (smin x₀) y) ◃∎) ⟩
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y)) ◃∙
ap (ap (Susp-fmap (∧-swap X Y))) (ap merid (∧-norm-r y)) ◃∎
=ₛ₁⟨ 1 & 1 & ∘-ap (ap (Susp-fmap (∧-swap X Y))) merid (∧-norm-r y) ⟩
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y)) ◃∙
ap (ap (Susp-fmap (∧-swap X Y)) ∘ merid) (∧-norm-r y) ◃∎
=ₛ⟨ !ₛ $ homotopy-naturality
(merid ∘ ∧-swap X Y)
(ap (Susp-fmap (∧-swap X Y)) ∘ merid)
(! ∘ SuspFmap.merid-β (∧-swap X Y))
(∧-norm-r y) ⟩
ap (merid ∘ ∧-swap X Y) (∧-norm-r y) ◃∙
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)) ◃∎
=ₛ₁⟨ 0 & 1 & ap-∘ merid (∧-swap X Y) (∧-norm-r y) ⟩
ap merid (ap (∧-swap X Y) (∧-norm-r y)) ◃∙
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)) ◃∎
=ₛ₁⟨ 0 & 1 & ap (ap merid) (∧-swap-norm-r-β X Y y) ⟩
ap merid (∧-norm-l y) ◃∙
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)) ◃∎ ∎ₛ ⟩
((ap merid (∧-norm-l y) ∙ ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀)))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ∙v⊡-⊡h∙-comm
(ap merid (∧-norm-l y) ∙ ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
(ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀))))
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ⟩
(ap merid (∧-norm-l y) ∙ ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀))) ⊡h∙
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
=⟨ ap ((ap merid (∧-norm-l y) ∙ ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ∙v⊡_) $
! $ ⊡h∙-assoc
(ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀))))
(ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)))
(ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ⟩
(ap merid (∧-norm-l y) ∙ ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ∙v⊡
ap-square (Susp-fmap (∧-swap X Y)) (tr-square (merid (smin x₀ y₀))) ⊡h∙
ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ⊡h∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))
=⟨ ap (λ u → (ap merid (∧-norm-l y) ∙ ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ∙v⊡
u ⊡h∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) $
ap-tr-square (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ⟩
(ap merid (∧-norm-l y) ∙ ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ∙v⊡
tr-square (ap (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀))) ⊡h∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))
=⟨ ∙v⊡-assoc
(ap merid (∧-norm-l y))
(! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)))
(tr-square (ap (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀))) ⊡h∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ⟩
ap merid (∧-norm-l y) ∙v⊡
! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)) ∙v⊡
tr-square (ap (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀))) ⊡h∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))
=⟨ ap (ap merid (∧-norm-l y) ∙v⊡_) $
tr-square-∙v⊡-⊡h∙ (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀)) ⟩
ap merid (∧-norm-l y) ∙v⊡ tr-square (merid (smin y₀ x₀)) =∎
front-path :
(! (ap-cst (north {A = Y ∧ X}) (merid y)) ∙v⊡
natural-square (λ v → idp) (merid y)) ⊡v∙
ap-cst north (merid y)
==
ids
front-path =
(! (ap-cst (north {A = Y ∧ X}) (merid y)) ∙v⊡
natural-square (λ v → idp) (merid y)) ⊡v∙
ap-cst north (merid y)
=⟨ ∙v⊡-⊡v∙-comm
(! (ap-cst (north {A = Y ∧ X}) (merid y)))
(natural-square (λ v → idp) (merid y))
(ap-cst north (merid y)) ⟩
! (ap-cst (north {A = Y ∧ X}) (merid y)) ∙v⊡
natural-square (λ v → idp) (merid y) ⊡v∙
ap-cst north (merid y)
=⟨ natural-square-cst
north
north
(λ v → idp)
(merid y) ⟩
disc-to-square (ap (λ v → idp) (merid y))
=⟨ ap disc-to-square (ap-cst idp (merid y)) ⟩
ids =∎
bot-path :
! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡
natural-square (Σ∧OutSmgluel.f Y X) (merid y) ⊡v∙
ap-cst north (merid y)
==
ap merid (∧-norm-l y) ∙v⊡ tr-square (merid (smin y₀ x₀))
bot-path =
! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡
natural-square (Σ∧OutSmgluel.f Y X) (merid y) ⊡v∙
ap-cst north (merid y)
=⟨ ap (λ u → ! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡ u ⊡v∙ ap-cst north (merid y)) $
Σ∧OutSmgluel.merid-square-β Y X y ⟩
! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡
Σ∧-out-smgluel-merid Y X y ⊡v∙
ap-cst north (merid y)
=⟨ ap (! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡_) $
⊡v∙-assoc
((SuspFmap.merid-β (λ y' → smin y' x₀) y ∙ ap merid (∧-norm-l y)) ∙v⊡
tr-square (merid (smin y₀ x₀)))
(! (ap-cst north (merid y)))
(ap-cst north (merid y)) ⟩
! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡
((SuspFmap.merid-β (λ y' → smin y' x₀) y ∙ ap merid (∧-norm-l y)) ∙v⊡
tr-square (merid (smin y₀ x₀))) ⊡v∙
(! (ap-cst north (merid y)) ∙ ap-cst north (merid y))
=⟨ ap (λ u → ! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡
((SuspFmap.merid-β (λ y' → smin y' x₀) y ∙ ap merid (∧-norm-l y)) ∙v⊡
tr-square (merid (smin y₀ x₀))) ⊡v∙
u) $
!-inv-l (ap-cst north (merid y)) ⟩
! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙v⊡
((SuspFmap.merid-β (λ y' → smin y' x₀) y ∙ ap merid (∧-norm-l y)) ∙v⊡
tr-square (merid (smin y₀ x₀)))
=⟨ ! $ ∙v⊡-assoc
(! (SuspFmap.merid-β (λ y' → smin y' x₀) y))
(SuspFmap.merid-β (λ y' → smin y' x₀) y ∙ ap merid (∧-norm-l y))
(tr-square (merid (smin y₀ x₀))) ⟩
(! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ∙
SuspFmap.merid-β (λ y' → smin y' x₀) y ∙
ap merid (∧-norm-l y)) ∙v⊡
tr-square (merid (smin y₀ x₀))
=⟨ ap (_∙v⊡ tr-square (merid (smin y₀ x₀))) $ =ₛ-out $
! (SuspFmap.merid-β (λ y' → smin y' x₀) y) ◃∙
SuspFmap.merid-β (λ y' → smin y' x₀) y ◃∙
ap merid (∧-norm-l y) ◃∎
=ₛ⟨ 0 & 2 & seq-!-inv-l (SuspFmap.merid-β (λ y' → smin y' x₀) y ◃∎) ⟩
ap merid (∧-norm-l y) ◃∎ ∎ₛ ⟩
ap merid (∧-norm-l y) ∙v⊡ tr-square (merid (smin y₀ x₀)) =∎
Σ∧-∧Σ-swap-smgluer : ∀ sy →
Square (Σ∧-∧Σ-swap-smin.f x₀ sy)
(ap (Susp-fmap (∧-swap X Y)) (∧ΣOutSmgluer.f X Y sy))
(Σ∧OutSmgluel.f Y X sy)
idp
Σ∧-∧Σ-swap-smgluer =
Susp-elim
ids
((ap-! (Susp-fmap (∧-swap X Y)) (merid (smin x₀ y₀)) ∙
ap ! (SuspFmap.merid-β (∧-swap X Y) (smin x₀ y₀))) ∙v⊡
vid-square)
(λ y → cube-to-↓-square (Σ∧-∧Σ-swap-smgluer-merid y))
swap-∧Σ-out : Susp-fmap (∧-swap X Y) ∘ ∧Σ-out X Y
∼ Σ∧-out Y X ∘ ∧-swap X (⊙Susp (de⊙ Y))
swap-∧Σ-out =
Smash-Path-elim
(Susp-fmap (∧-swap X Y) ∘ ∧Σ-out X Y)
(Σ∧-out Y X ∘ ∧-swap X (⊙Susp (de⊙ Y)))
Σ∧-∧Σ-swap-smin.f
idp
idp
(λ x → ∧-swap-∧Σ-out-smgluel x ∙v⊡ ids ⊡v∙ ! (Σ∧-out-∧-swap-smgluel x))
(λ sy → ∧-swap-∧Σ-out-smgluer sy ∙v⊡
Σ∧-∧Σ-swap-smgluer sy ⊡v∙
! (Σ∧-out-∧-swap-smgluer sy))
⊙swap-∧Σ-out : ⊙Susp-fmap (∧-swap X Y) ◃⊙∘ ⊙∧Σ-out X Y ◃⊙idf
=⊙∘
⊙Σ∧-out Y X ◃⊙∘ ⊙∧-swap X (⊙Susp (de⊙ Y)) ◃⊙idf
⊙swap-∧Σ-out = =⊙∘-in (⊙λ=' swap-∧Σ-out idp)
module _ {i j} (X : Ptd i) (Y : Ptd j) where
⊙swap-Σ∧-out : ⊙Susp-fmap (∧-swap X Y) ◃⊙∘ ⊙Σ∧-out X Y ◃⊙idf
=⊙∘
⊙∧Σ-out Y X ◃⊙∘ ⊙∧-swap (⊙Susp (de⊙ X)) Y ◃⊙idf
⊙swap-Σ∧-out =
⊙Susp-fmap (∧-swap X Y) ◃⊙∘ ⊙Σ∧-out X Y ◃⊙idf
=⊙∘⟨ 2 & 0 & !⊙∘ $ ⊙∧-swap-inv (⊙Susp (de⊙ X)) Y ⟩
⊙Susp-fmap (∧-swap X Y) ◃⊙∘
⊙Σ∧-out X Y ◃⊙∘
⊙∧-swap Y (⊙Susp (de⊙ X)) ◃⊙∘
⊙∧-swap (⊙Susp (de⊙ X)) Y ◃⊙idf
=⊙∘⟨ 1 & 2 & !⊙∘ (⊙swap-∧Σ-out Y X) ⟩
⊙Susp-fmap (∧-swap X Y) ◃⊙∘
⊙Susp-fmap (∧-swap Y X) ◃⊙∘
⊙∧Σ-out Y X ◃⊙∘
⊙∧-swap (⊙Susp (de⊙ X)) Y ◃⊙idf
=⊙∘⟨ 0 & 2 & !⊙∘ $ =⊙∘-in {fs = ⊙Susp-fmap (∧-swap X Y ∘ ∧-swap Y X) ◃⊙idf} $
⊙Susp-fmap-∘ (∧-swap X Y) (∧-swap Y X) ⟩
⊙Susp-fmap (∧-swap X Y ∘ ∧-swap Y X) ◃⊙∘
⊙∧Σ-out Y X ◃⊙∘
⊙∧-swap (⊙Susp (de⊙ X)) Y ◃⊙idf
=⊙∘₁⟨ 0 & 1 & ap ⊙Susp-fmap (λ= (∧-swap-inv Y X)) ⟩
⊙Susp-fmap (idf _) ◃⊙∘
⊙∧Σ-out Y X ◃⊙∘
⊙∧-swap (⊙Susp (de⊙ X)) Y ◃⊙idf
=⊙∘⟨ 0 & 1 & ⊙Susp-fmap-idf (Y ∧ X) ⟩
⊙∧Σ-out Y X ◃⊙∘
⊙∧-swap (⊙Susp (de⊙ X)) Y ◃⊙idf ∎⊙∘
| {
"alphanum_fraction": 0.4431211626,
"avg_line_length": 48.0162962963,
"ext": "agda",
"hexsha": "850d9a465e226389701003dd23143b57b3848ff6",
"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": "theorems/homotopy/SuspSmash.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": "theorems/homotopy/SuspSmash.agda",
"max_line_length": 111,
"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": "theorems/homotopy/SuspSmash.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": 15562,
"size": 32411
} |
{-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.data:25 #-}
-- {-# OPTIONS -v tc.conv.coerce:0 -v tc.with:25 #-}
module FilterSub where
open import Common.Level
open import Common.Equality
_∘_ : ∀ {a b c}
{A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} →
(∀ {x} (y : B x) → C y) → (g : (x : A) → B x) →
((x : A) → C (g x))
f ∘ g = λ x → f (g x)
data Bool : Set where
true false : Bool
if_then_else_ : ∀ {a}{A : Set a} → Bool → A → A → A
if true then t else e = t
if false then t else e = e
data Maybe {a} (A : Set a) : Set a where
nothing : Maybe A
just : A → Maybe A
infixr 5 _∷_
data List {a} (A : Set a) : Set a where
[] : List A
_∷_ : (x : A) (xs : List A) → List A
data Any {a p} {A : Set a}
(P : A → Set p) : List A → Set (a ⊔ p) where
here : ∀ {x xs} (px : P x) → Any P (x ∷ xs)
there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs)
infix 4 _⊆_ _∈_
_∈_ : ∀ {a}{A : Set a} → A → List A → Set _
x ∈ xs = Any (_≡_ x) xs
_⊆_ : ∀ {a}{A : Set a} → List A → List A → Set _
xs ⊆ ys = ∀ {x} → x ∈ xs → x ∈ ys
filter : ∀ {a} {A : Set a} → (A → Bool) → List A → List A
filter p [] = []
filter p (x ∷ xs) with p x
... | true = x ∷ filter p xs
... | false = filter p xs
filter-⊆ : ∀ {a} {A : Set a} (p : A → Bool) →
(xs : List A) → filter p xs ⊆ xs
filter-⊆ _ [] = λ ()
filter-⊆ p (x ∷ xs) with p x | filter-⊆ p xs
... | false | hyp = there ∘ hyp
... | true | hyp =
λ { (here eq) → here eq
; (there ∈filter) → there (hyp ∈filter)
}
| {
"alphanum_fraction": 0.4683870968,
"avg_line_length": 25.4098360656,
"ext": "agda",
"hexsha": "a2cd1ff53db0e1277f6757bcebfa86a79f743a04",
"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/FilterSub.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/FilterSub.agda",
"max_line_length": 65,
"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/FilterSub.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": 651,
"size": 1550
} |
{-# OPTIONS --safe #-}
module Cubical.Categories.Instances.CommAlgebras where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Powerset
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Algebra
open import Cubical.Algebra.CommAlgebra
open import Cubical.Categories.Category
open import Cubical.Categories.Functor.Base
open import Cubical.HITs.PropositionalTruncation
open Category
open CommAlgebraHoms
private
variable
ℓ ℓ' ℓ'' : Level
module _ (R : CommRing ℓ) where
CommAlgebrasCategory : Category (ℓ-suc (ℓ-max ℓ ℓ')) (ℓ-max ℓ ℓ')
ob CommAlgebrasCategory = CommAlgebra R _
Hom[_,_] CommAlgebrasCategory = CommAlgebraHom
id CommAlgebrasCategory {A} = idCommAlgebraHom A
_⋆_ CommAlgebrasCategory {A} {B} {C} = compCommAlgebraHom A B C
⋆IdL CommAlgebrasCategory {A} {B} = compIdCommAlgebraHom {A = A} {B}
⋆IdR CommAlgebrasCategory {A} {B} = idCompCommAlgebraHom {A = A} {B}
⋆Assoc CommAlgebrasCategory {A} {B} {C} {D} = compAssocCommAlgebraHom {A = A} {B} {C} {D}
isSetHom CommAlgebrasCategory = isSetAlgebraHom _ _
module PreSheafFromUniversalProp (C : Category ℓ ℓ') (P : ob C → Type ℓ)
{R : CommRing ℓ''} (𝓕 : Σ (ob C) P → CommAlgebra R ℓ'')
(uniqueHom : ∀ x y → C [ fst x , fst y ] → isContr (CommAlgebraHom (𝓕 y) (𝓕 x)))
where
private
∥P∥ : ℙ (ob C)
∥P∥ x = ∥ P x ∥ , isPropPropTrunc
ΣC∥P∥Cat = ΣPropCat C ∥P∥
𝓕UniqueEquiv : (x : ob C) (p q : P x) → isContr (CommAlgebraEquiv (𝓕 (x , p)) (𝓕 (x , q)))
𝓕UniqueEquiv x = contrCommAlgebraHom→contrCommAlgebraEquiv (curry 𝓕 x) λ p q → uniqueHom _ _ (id C)
theMap : (x : ob C) → ∥ P x ∥ → CommAlgebra R ℓ''
theMap x = recPT→CommAlgebra (curry 𝓕 x) (λ p q → 𝓕UniqueEquiv x p q .fst)
λ p q r → 𝓕UniqueEquiv x p r .snd _
theAction : (x y : ob C) → C [ x , y ]
→ (p : ∥ P x ∥) (q : ∥ P y ∥) → isContr (CommAlgebraHom (theMap y q) (theMap x p))
theAction _ _ f = elim2 (λ _ _ → isPropIsContr) λ _ _ → uniqueHom _ _ f
open Functor
universalPShf : Functor (ΣC∥P∥Cat ^op) (CommAlgebrasCategory {ℓ = ℓ''} R {ℓ' = ℓ''})
F-ob universalPShf = uncurry theMap
F-hom universalPShf {x = x} {y = y} f = theAction _ _ f (y .snd) (x. snd) .fst
F-id universalPShf {x = x} = theAction (x .fst) (x .fst) (id C) (x .snd) (x .snd) .snd _
F-seq universalPShf {x = x} {z = z} f g = theAction _ _ (g ⋆⟨ C ⟩ f) (z .snd) (x .snd) .snd _
| {
"alphanum_fraction": 0.6387122417,
"avg_line_length": 39.9365079365,
"ext": "agda",
"hexsha": "29e3a8eb9c0e9d19b155ff219991289ce6919bb4",
"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": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"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": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda",
"max_line_length": 100,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/Categories/Instances/CommAlgebras.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z",
"num_tokens": 976,
"size": 2516
} |
{-# OPTIONS --safe #-}
module Definition.Typed.RedSteps where
open import Definition.Untyped
open import Definition.Typed
-- Concatenation of type reduction closures
_⇨*_ : ∀ {Γ A B C r} → Γ ⊢ A ⇒* B ^ r → Γ ⊢ B ⇒* C ^ r → Γ ⊢ A ⇒* C ^ r
id ⊢B ⇨* B⇒C = B⇒C
(A⇒A′ ⇨ A′⇒B) ⇨* B⇒C = A⇒A′ ⇨ (A′⇒B ⇨* B⇒C)
-- Concatenation of term reduction closures
_⇨∷*_ : ∀ {Γ A t u v l} → Γ ⊢ t ⇒* u ∷ A ^ l → Γ ⊢ u ⇒* v ∷ A ^ l → Γ ⊢ t ⇒* v ∷ A ^ l
id ⊢u ⇨∷* u⇒v = u⇒v
(t⇒t′ ⇨ t′⇒u) ⇨∷* u⇒v = t⇒t′ ⇨ (t′⇒u ⇨∷* u⇒v)
-- Conversion of reduction closures
conv* : ∀ {Γ A B t u l } → Γ ⊢ t ⇒* u ∷ A ^ l → Γ ⊢ A ≡ B ^ [ ! , l ] → Γ ⊢ t ⇒* u ∷ B ^ l
conv* (id x) A≡B = id (conv x A≡B)
conv* (x ⇨ d) A≡B = conv x A≡B ⇨ conv* d A≡B
conv:* : ∀ {Γ A B t u l } → Γ ⊢ t :⇒*: u ∷ A ^ l → Γ ⊢ A ≡ B ^ [ ! , l ] → Γ ⊢ t :⇒*: u ∷ B ^ l
conv:* [[ ⊢t , ⊢u , d ]] e = [[ (conv ⊢t e) , (conv ⊢u e) , (conv* d e) ]]
-- Universe of reduction closures
univ* : ∀ {Γ A B r l} → Γ ⊢ A ⇒* B ∷ (Univ r l) ^ next l → Γ ⊢ A ⇒* B ^ [ r , ι l ]
univ* (id x) = id (univ x)
univ* (x ⇨ A⇒B) = univ x ⇨ univ* A⇒B
-- Application substitution of reduction closures
app-subst* : ∀ {Γ A B t t′ a rA lA lB l} → Γ ⊢ t ⇒* t′ ∷ Π A ^ rA ° lA ▹ B ° lB ° l ^ ι l → Γ ⊢ a ∷ A ^ [ rA , ι lA ]
→ Γ ⊢ t ∘ a ^ l ⇒* t′ ∘ a ^ l ∷ B [ a ] ^ ι lB
app-subst* (id x) a₁ = id (x ∘ⱼ a₁)
app-subst* (x ⇨ t⇒t′) a₁ = app-subst x a₁ ⇨ app-subst* t⇒t′ a₁
| {
"alphanum_fraction": 0.4547413793,
"avg_line_length": 37.6216216216,
"ext": "agda",
"hexsha": "9a23a27f7630a99bffb8ae427b523f870ad9a73c",
"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/Typed/RedSteps.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/Typed/RedSteps.agda",
"max_line_length": 117,
"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/Typed/RedSteps.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": 764,
"size": 1392
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
import LibraBFT.Impl.Types.BlockInfo as BlockInfo
import LibraBFT.Impl.Crypto.Crypto.Hash as Hash
open import LibraBFT.ImplShared.Consensus.Types
open import Util.Prelude
module LibraBFT.Impl.Types.LedgerInfo where
mockGenesis : Maybe ValidatorSet → Either ErrLog LedgerInfo
mockGenesis mvs = LedgerInfo∙new <$> BlockInfo.mockGenesis mvs <*> pure Hash.valueZero
| {
"alphanum_fraction": 0.7617554859,
"avg_line_length": 39.875,
"ext": "agda",
"hexsha": "f45047dae812aa42f8432801c970fcb074a4c156",
"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": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Types/LedgerInfo.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"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": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Types/LedgerInfo.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Types/LedgerInfo.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 164,
"size": 638
} |
open import Prelude
open import Nat
open import core
open import contexts
module lemmas-env where
env-ctx-same-1 : ∀{Δ Σ' Γ E x} →
Δ , Σ' , Γ ⊢ E →
x # E →
x # Γ
env-ctx-same-1 EnvId h = x#∅
env-ctx-same-1 {x = x} (EnvInd {E = E} {x = x'} ctxcons _) x#E+
with natEQ x x'
... | Inl refl = abort (x#E+ (_ , x,a∈Γ,,x,a {Γ = E}))
... | Inr x≠x'
with env-ctx-same-1 ctxcons (x#Γ+→x#Γ {Γ = E} x#E+)
... | x#Γ = x#Γ→x#Γ+ x≠x' x#Γ
env-ctx-same-2 : ∀{Δ Σ' Γ E x} →
Δ , Σ' , Γ ⊢ E →
x # Γ →
x # E
env-ctx-same-2 EnvId h = x#∅
env-ctx-same-2 {x = x} (EnvInd {Γ = Γ} {x = x'} ctxcons _) x#Γ+
with natEQ x x'
... | Inl refl = abort (x#Γ+ (_ , x,a∈Γ,,x,a {Γ = Γ}))
... | Inr x≠x'
with env-ctx-same-2 ctxcons (x#Γ+→x#Γ {Γ = Γ} x#Γ+)
... | x#E = x#Γ→x#Γ+ x≠x' x#E
env-all-Γ : ∀{Δ Σ' Γ E x τ} →
Δ , Σ' , Γ ⊢ E →
(x , τ) ∈ Γ →
Σ[ r ∈ result ] ((x , r) ∈ E ∧ Δ , Σ' ⊢ r ·: τ)
env-all-Γ EnvId x∈Γ = abort (x#∅ (_ , x∈Γ))
env-all-Γ {x = x} (EnvInd {Γ = Γ} {E} {x'} ctxcons ta) x∈Γ
with natEQ x x'
... | Inl refl
rewrite ctxunicity x∈Γ (x,a∈Γ,,x,a {Γ = Γ})
= _ , x,a∈Γ,,x,a {Γ = E} , ta
... | Inr x≠x'
with env-all-Γ ctxcons (x∈Γ+→x∈Γ {Γ = Γ} x≠x' x∈Γ)
... | _ , x∈E , ta-rec = _ , x∈Γ→x∈Γ+ x≠x' x∈E , ta-rec
env-all-E : ∀{Δ Σ' Γ E x r} →
Δ , Σ' , Γ ⊢ E →
(x , r) ∈ E →
Σ[ τ ∈ typ ] ((x , τ) ∈ Γ ∧ Δ , Σ' ⊢ r ·: τ)
env-all-E EnvId x∈E = abort (x#∅ (_ , x∈E))
env-all-E {x = x} (EnvInd {Γ = Γ} {E} {x'} ctxcons ta) x∈E
with natEQ x x'
... | Inl refl
rewrite ctxunicity x∈E (x,a∈Γ,,x,a {Γ = E})
= _ , x,a∈Γ,,x,a {Γ = Γ} , ta
... | Inr x≠x'
with env-all-E ctxcons (x∈Γ+→x∈Γ {Γ = E} x≠x' x∈E)
... | _ , x∈Γ , ta-rec = _ , x∈Γ→x∈Γ+ x≠x' x∈Γ , ta-rec
| {
"alphanum_fraction": 0.3948302078,
"avg_line_length": 34.0172413793,
"ext": "agda",
"hexsha": "af4bf8b07fe35590492400f8791121ae336d217e",
"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": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnat-myth-",
"max_forks_repo_path": "lemmas-env.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazelnat-myth-",
"max_issues_repo_path": "lemmas-env.agda",
"max_line_length": 65,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazelnat-myth-",
"max_stars_repo_path": "lemmas-env.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-19T23:42:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-19T23:42:31.000Z",
"num_tokens": 995,
"size": 1973
} |
{-# OPTIONS --allow-unsolved-metas #-}
open import Level
open import Ordinals
module OPair {n : Level } (O : Ordinals {n}) where
open import zf
open import logic
import OD
import ODUtil
import OrdUtil
open import Relation.Nullary
open import Relation.Binary
open import Data.Empty
open import Relation.Binary
open import Relation.Binary.Core
open import Relation.Binary.PropositionalEquality
open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ )
open OD O
open OD.OD
open OD.HOD
open ODAxiom odAxiom
open Ordinals.Ordinals O
open Ordinals.IsOrdinals isOrdinal
open Ordinals.IsNext isNext
open OrdUtil O
open ODUtil O
open _∧_
open _∨_
open Bool
open _==_
<_,_> : (x y : HOD) → HOD
< x , y > = (x , x ) , (x , y )
exg-pair : { x y : HOD } → (x , y ) =h= ( y , x )
exg-pair {x} {y} = record { eq→ = left ; eq← = right } where
left : {z : Ordinal} → odef (x , y) z → odef (y , x) z
left (case1 t) = case2 t
left (case2 t) = case1 t
right : {z : Ordinal} → odef (y , x) z → odef (x , y) z
right (case1 t) = case2 t
right (case2 t) = case1 t
ord≡→≡ : { x y : HOD } → & x ≡ & y → x ≡ y
ord≡→≡ eq = subst₂ (λ j k → j ≡ k ) *iso *iso ( cong ( λ k → * k ) eq )
od≡→≡ : { x y : Ordinal } → * x ≡ * y → x ≡ y
od≡→≡ eq = subst₂ (λ j k → j ≡ k ) &iso &iso ( cong ( λ k → & k ) eq )
eq-prod : { x x' y y' : HOD } → x ≡ x' → y ≡ y' → < x , y > ≡ < x' , y' >
eq-prod refl refl = refl
xx=zy→x=y : {x y z : HOD } → ( x , x ) =h= ( z , y ) → x ≡ y
xx=zy→x=y {x} {y} eq with trio< (& x) (& y)
xx=zy→x=y {x} {y} eq | tri< a ¬b ¬c with eq← eq {& y} (case2 refl)
xx=zy→x=y {x} {y} eq | tri< a ¬b ¬c | case1 s = ⊥-elim ( o<¬≡ (sym s) a )
xx=zy→x=y {x} {y} eq | tri< a ¬b ¬c | case2 s = ⊥-elim ( o<¬≡ (sym s) a )
xx=zy→x=y {x} {y} eq | tri≈ ¬a b ¬c = ord≡→≡ b
xx=zy→x=y {x} {y} eq | tri> ¬a ¬b c with eq← eq {& y} (case2 refl)
xx=zy→x=y {x} {y} eq | tri> ¬a ¬b c | case1 s = ⊥-elim ( o<¬≡ s c )
xx=zy→x=y {x} {y} eq | tri> ¬a ¬b c | case2 s = ⊥-elim ( o<¬≡ s c )
prod-eq : { x x' y y' : HOD } → < x , y > =h= < x' , y' > → (x ≡ x' ) ∧ ( y ≡ y' )
prod-eq {x} {x'} {y} {y'} eq = ⟪ lemmax , lemmay ⟫ where
lemma2 : {x y z : HOD } → ( x , x ) =h= ( z , y ) → z ≡ y
lemma2 {x} {y} {z} eq = trans (sym (xx=zy→x=y lemma3 )) ( xx=zy→x=y eq ) where
lemma3 : ( x , x ) =h= ( y , z )
lemma3 = ==-trans eq exg-pair
lemma1 : {x y : HOD } → ( x , x ) =h= ( y , y ) → x ≡ y
lemma1 {x} {y} eq with eq← eq {& y} (case2 refl)
lemma1 {x} {y} eq | case1 s = ord≡→≡ (sym s)
lemma1 {x} {y} eq | case2 s = ord≡→≡ (sym s)
lemma4 : {x y z : HOD } → ( x , y ) =h= ( x , z ) → y ≡ z
lemma4 {x} {y} {z} eq with eq← eq {& z} (case2 refl)
lemma4 {x} {y} {z} eq | case1 s with ord≡→≡ s -- x ≡ z
... | refl with lemma2 (==-sym eq )
... | refl = refl
lemma4 {x} {y} {z} eq | case2 s = ord≡→≡ (sym s) -- y ≡ z
lemmax : x ≡ x'
lemmax with eq→ eq {& (x , x)} (case1 refl)
lemmax | case1 s = lemma1 (ord→== s ) -- (x,x)≡(x',x')
lemmax | case2 s with lemma2 (ord→== s ) -- (x,x)≡(x',y') with x'≡y'
... | refl = lemma1 (ord→== s )
lemmay : y ≡ y'
lemmay with lemmax
... | refl with lemma4 eq -- with (x,y)≡(x,y')
... | eq1 = lemma4 (ord→== (cong (λ k → & k ) eq1 ))
--
-- unlike ordered pair, ZFProduct is not a HOD
data ord-pair : (p : Ordinal) → Set n where
pair : (x y : Ordinal ) → ord-pair ( & ( < * x , * y > ) )
ZFProduct : OD
ZFProduct = record { def = λ x → ord-pair x }
-- open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ )
-- eq-pair : { x x' y y' : Ordinal } → x ≡ x' → y ≡ y' → pair x y ≅ pair x' y'
-- eq-pair refl refl = HE.refl
pi1 : { p : Ordinal } → ord-pair p → Ordinal
pi1 ( pair x y) = x
π1 : { p : HOD } → def ZFProduct (& p) → HOD
π1 lt = * (pi1 lt )
pi2 : { p : Ordinal } → ord-pair p → Ordinal
pi2 ( pair x y ) = y
π2 : { p : HOD } → def ZFProduct (& p) → HOD
π2 lt = * (pi2 lt )
op-cons : { ox oy : Ordinal } → def ZFProduct (& ( < * ox , * oy > ))
op-cons {ox} {oy} = pair ox oy
def-subst : {Z : OD } {X : Ordinal }{z : OD } {x : Ordinal }→ def Z X → Z ≡ z → X ≡ x → def z x
def-subst df refl refl = df
p-cons : ( x y : HOD ) → def ZFProduct (& ( < x , y >))
p-cons x y = def-subst {_} {_} {ZFProduct} {& (< x , y >)} (pair (& x) ( & y )) refl (
let open ≡-Reasoning in begin
& < * (& x) , * (& y) >
≡⟨ cong₂ (λ j k → & < j , k >) *iso *iso ⟩
& < x , y >
∎ )
op-iso : { op : Ordinal } → (q : ord-pair op ) → & < * (pi1 q) , * (pi2 q) > ≡ op
op-iso (pair ox oy) = refl
p-iso : { x : HOD } → (p : def ZFProduct (& x) ) → < π1 p , π2 p > ≡ x
p-iso {x} p = ord≡→≡ (op-iso p)
p-pi1 : { x y : HOD } → (p : def ZFProduct (& < x , y >) ) → π1 p ≡ x
p-pi1 {x} {y} p = proj1 ( prod-eq ( ord→== (op-iso p) ))
p-pi2 : { x y : HOD } → (p : def ZFProduct (& < x , y >) ) → π2 p ≡ y
p-pi2 {x} {y} p = proj2 ( prod-eq ( ord→== (op-iso p)))
ω-pair : {x y : HOD} → {m : Ordinal} → & x o< next m → & y o< next m → & (x , y) o< next m
ω-pair lx ly = next< (omax<nx lx ly ) ho<
ω-opair : {x y : HOD} → {m : Ordinal} → & x o< next m → & y o< next m → & < x , y > o< next m
ω-opair {x} {y} {m} lx ly = lemma0 where
lemma0 : & < x , y > o< next m
lemma0 = osucprev (begin
osuc (& < x , y >)
<⟨ osuc<nx ho< ⟩
next (omax (& (x , x)) (& (x , y)))
≡⟨ cong (λ k → next k) (sym ( omax≤ _ _ pair-xx<xy )) ⟩
next (osuc (& (x , y)))
≡⟨ sym (nexto≡) ⟩
next (& (x , y))
≤⟨ x<ny→≤next (ω-pair lx ly) ⟩
next m
∎ ) where
open o≤-Reasoning O
_⊗_ : (A B : HOD) → HOD
A ⊗ B = Union ( Replace B (λ b → Replace A (λ a → < a , b > ) ))
product→ : {A B a b : HOD} → A ∋ a → B ∋ b → ( A ⊗ B ) ∋ < a , b >
product→ {A} {B} {a} {b} A∋a B∋b = λ t → t (& (Replace A (λ a → < a , b >)))
⟪ lemma1 , subst (λ k → odef k (& < a , b >)) (sym *iso) lemma2 ⟫ where
lemma1 : odef (Replace B (λ b₁ → Replace A (λ a₁ → < a₁ , b₁ >))) (& (Replace A (λ a₁ → < a₁ , b >)))
lemma1 = replacement← B b B∋b
lemma2 : odef (Replace A (λ a₁ → < a₁ , b >)) (& < a , b >)
lemma2 = replacement← A a A∋a
x<nextA : {A x : HOD} → A ∋ x → & x o< next (odmax A)
x<nextA {A} {x} A∋x = ordtrans (c<→o< {x} {A} A∋x) ho<
A<Bnext : {A B x : HOD} → & A o< & B → A ∋ x → & x o< next (odmax B)
A<Bnext {A} {B} {x} lt A∋x = osucprev (begin
osuc (& x)
<⟨ osucc (c<→o< A∋x) ⟩
osuc (& A)
<⟨ osucc lt ⟩
osuc (& B)
<⟨ osuc<nx ho< ⟩
next (odmax B)
∎ ) where open o≤-Reasoning O
ZFP : (A B : HOD) → HOD
ZFP A B = record { od = record { def = λ x → ord-pair x ∧ ((p : ord-pair x ) → odef A (pi1 p) ∧ odef B (pi2 p) )} ;
odmax = omax (next (odmax A)) (next (odmax B)) ; <odmax = λ {y} px → lemma y px }
where
lemma : (y : Ordinal) → ( ord-pair y ∧ ((p : ord-pair y) → odef A (pi1 p) ∧ odef B (pi2 p))) → y o< omax (next (odmax A)) (next (odmax B))
lemma y lt with proj1 lt
lemma p lt | pair x y with trio< (& A) (& B)
lemma p lt | pair x y | tri< a ¬b ¬c = ordtrans (ω-opair (A<Bnext a (subst (λ k → odef A k ) (sym &iso)
(proj1 (proj2 lt (pair x y))))) (lemma1 (proj2 (proj2 lt (pair x y))))) (omax-y _ _ ) where
lemma1 : odef B y → & (* y) o< next (HOD.odmax B)
lemma1 lt = x<nextA {B} (d→∋ B lt)
lemma p lt | pair x y | tri≈ ¬a b ¬c = ordtrans (ω-opair (x<nextA {A} (d→∋ A ((proj1 (proj2 lt (pair x y)))))) lemma2 ) (omax-x _ _ ) where
lemma2 : & (* y) o< next (HOD.odmax A)
lemma2 = ordtrans ( subst (λ k → & (* y) o< k ) (sym b) (c<→o< (d→∋ B ((proj2 (proj2 lt (pair x y))))))) ho<
lemma p lt | pair x y | tri> ¬a ¬b c = ordtrans (ω-opair (x<nextA {A} (d→∋ A ((proj1 (proj2 lt (pair x y))))))
(A<Bnext c (subst (λ k → odef B k ) (sym &iso) (proj2 (proj2 lt (pair x y)))))) (omax-x _ _ )
ZFP⊆⊗ : {A B : HOD} {x : Ordinal} → odef (ZFP A B) x → odef (A ⊗ B) x
ZFP⊆⊗ {A} {B} {px} ⟪ (pair x y) , p2 ⟫ = product→ (d→∋ A (proj1 (p2 (pair x y) ))) (d→∋ B (proj2 (p2 (pair x y) )))
-- axiom of choice required
-- ⊗⊆ZFP : {A B x : HOD} → ( A ⊗ B ) ∋ x → def ZFProduct (& x)
-- ⊗⊆ZFP {A} {B} {x} lt = subst (λ k → ord-pair (& k )) {!!} op-cons
| {
"alphanum_fraction": 0.4747063054,
"avg_line_length": 38.9813084112,
"ext": "agda",
"hexsha": "d07511ba5696cc5ba7b2cd5a9ff365c898d073f7",
"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": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shinji-kono/zf-in-agda",
"max_forks_repo_path": "src/OPair.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "shinji-kono/zf-in-agda",
"max_issues_repo_path": "src/OPair.agda",
"max_line_length": 146,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shinji-kono/zf-in-agda",
"max_stars_repo_path": "src/OPair.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z",
"num_tokens": 3718,
"size": 8342
} |
module PreludeString where
import RTP -- magic module
import PreludeList
open PreludeList using (List)
open import AlonzoPrelude
infixr 50 _++_
private
primitive
primStringAppend : String -> String -> String
-- primStringReverse : String -> String
primStringToList : String -> List Char
primStringFromList : List Char -> String
_++_ = primStringAppend
reverseString = RTP.primStringReverse
toList : String -> List Char
toList = primStringToList
fromList : List Char -> String
fromList = primStringFromList
-- toList = RTP.primStringToList
-- fromList = RTP.primStringFromList
| {
"alphanum_fraction": 0.7217806041,
"avg_line_length": 17.9714285714,
"ext": "agda",
"hexsha": "c5518ca6f89ab2d8be41d51cb37b7ddc3093192f",
"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": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/PreludeString.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/PreludeString.agda",
"max_line_length": 52,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/PreludeString.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 160,
"size": 629
} |
-- ----------------------------------------------------------------------
-- The Agda Descriptor Library
--
-- (Closed) Sets
-- ----------------------------------------------------------------------
module Data.Set where
open import Data.Empty using (⊥)
open import Data.Fin using (Fin; suc; zero)
open import Data.Nat using (ℕ)
open import Data.Product using (Σ)
open import Data.Unit using (⊤)
open import Data.Desc using (Desc; μ; _##_; _⟶_; Π)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
-- ----------------------------------------------------------------------
-- Definition
--
-- A `Desc is a closed dependent type theory of
-- strictly positive functors : Set/A → Set/A
--
-- A `Set is a open dependent type theory of
-- the Agda model
--
-- To ensure a closed universe, we use
-- induction recursion.
data `Set : Set
⟦_⟧ : `Set → Set
private
variable
A : `Set
data `Desc (A : `Set) : Set
⟪_⟫ : `Desc A → Desc ⟦ A ⟧
data `Set where
`Fin : ℕ → `Set
`Σ `Π : (B : `Set) → (⟦ B ⟧ → `Set) → `Set
`μ : `Desc A → ⟦ A ⟧ → `Set
⟦ `Fin n ⟧ = Fin n
⟦ `Σ A B ⟧ = Σ ⟦ A ⟧ (λ a → ⟦ B a ⟧ )
⟦ `Π A B ⟧ = (a : ⟦ A ⟧) → ⟦ B a ⟧
⟦ `μ d a ⟧ = μ ⟪ d ⟫ a
infixr 6 _⟶_
data `Desc A where
`Π : (B : `Set) → (⟦ B ⟧ → `Desc A) → `Desc A
_⟶_ : `Desc A → `Desc A → `Desc A
_`##_ : (`Set → `Set) → ⟦ A ⟧ → `Desc A
⟪ `Π B d ⟫ = Π ⟦ B ⟧ (λ b → ⟪ d b ⟫)
⟪ d₁ ⟶ d₂ ⟫ = ⟪ d₁ ⟫ ⟶ ⟪ d₂ ⟫
⟪ f `## a ⟫ = {! !} ## a
-- ----------------------------------------------------------------------
-- Example (Basic)
-- `⊤ : `Set
-- `⊤ = `Fin 1
-- `tt : ⟦ `⊤ ⟧
-- `tt = zero
-- `const : `Set → `Desc `⊤
-- `const A = `Π A λ _ → `# `tt
-- _`≡_ : ⟦ A ⟧ → ⟦ A ⟧ → `Set
-- x `≡ y = `μ (`# x) y
-- ----------------------------------------------------------------------
-- pattern nil = zero
-- pattern cons = (suc zero)
-- TODO: First order isomorphisms
-- _ : ⟦ zero `≡ zero ⟧
-- _ = {! refl !}
-- ListD : `Set → `Desc `⊤
-- ListD A = `Π (`Fin 2)
-- λ{ nil → `# `tt
-- ; cons → `const A ⟶ `# `tt ⟶ `# `tt }
-- `List : `Set → `Set
-- `List A = `μ (ListD A) `tt
-- RoseD : `Set → `Desc `⊤
-- RoseD A = `const A ⟶ `List $ (`# `tt) ⟶ `# `tt
-- _#_ : (Set → Set) → A → Desc A
--
-- Computional:
-- f (X a)
--
-- Propositional:
-- f (a′ ≡ a)
| {
"alphanum_fraction": 0.4105815479,
"avg_line_length": 20.4196428571,
"ext": "agda",
"hexsha": "ae1e438db49e8db007f43b019e9a77feb2c32e5c",
"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": "27fd49914d5ce1cc90d319089686861b33e8f19f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "johnyob/agda-desc",
"max_forks_repo_path": "src/Data/Set.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f",
"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": "johnyob/agda-desc",
"max_issues_repo_path": "src/Data/Set.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "johnyob/agda-desc",
"max_stars_repo_path": "src/Data/Set.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 862,
"size": 2287
} |
------------------------------------------------------------------------
-- Universe levels
------------------------------------------------------------------------
module Common.Level where
postulate
Level : Set
lzero : Level
lsuc : (i : Level) → Level
_⊔_ : Level -> Level -> Level
{-# IMPORT Common.FFI #-}
{-# COMPILED_TYPE Level Common.FFI.Level #-}
{-# COMPILED lzero Common.FFI.Zero #-}
{-# COMPILED lsuc Common.FFI.Suc #-}
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO lzero #-}
{-# BUILTIN LEVELSUC lsuc #-}
{-# BUILTIN LEVELMAX _⊔_ #-}
infixl 6 _⊔_
| {
"alphanum_fraction": 0.4661016949,
"avg_line_length": 22.6923076923,
"ext": "agda",
"hexsha": "e4d6278bd4002cc606aff23331bf1b77f799a37c",
"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": "test/Common/Level.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": "test/Common/Level.agda",
"max_line_length": 72,
"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": "test/Common/Level.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 144,
"size": 590
} |
------------------------------------------------------------------------
-- "Equational" reasoning combinator setup
------------------------------------------------------------------------
{-# OPTIONS --safe #-}
open import Labelled-transition-system
-- Note that the module parameter is explicit. If the LTS is not given
-- explicitly, then the use of _[ μ ]⟶_ in the instances below can
-- make it hard for Agda to infer what instance to use.
module Labelled-transition-system.Equational-reasoning-instances
{ℓ} (lts : LTS ℓ) where
open import Prelude
open import Equational-reasoning
open LTS lts
private
-- Converts one kind of proof of silence to another kind.
get : ∀ {μ} → T (silent? μ) → Silent μ
get {μ} _ with silent? μ
get {μ} () | no _
get {μ} _ | yes s = s
instance
convert⟶ : ∀ {μ} → Convertible _[ μ ]⟶_ _[ μ ]⟶_
convert⟶ = is-convertible id
convert⟶⇒ : ∀ {μ} {s : T (silent? μ)} → Convertible _[ μ ]⟶_ _⇒_
convert⟶⇒ {s = s} = is-convertible (⟶→⇒ (get s))
convert⟶[]⇒ : ∀ {μ} → Convertible _[ μ ]⟶_ _[ μ ]⇒_
convert⟶[]⇒ = is-convertible ⟶→[]⇒
convert⟶⇒̂ : ∀ {μ} → Convertible _[ μ ]⟶_ _[ μ ]⇒̂_
convert⟶⇒̂ = is-convertible ⟶→⇒̂
convert⟶⟶̂ : ∀ {μ} → Convertible _[ μ ]⟶_ _[ μ ]⟶̂_
convert⟶⟶̂ = is-convertible ⟶→⟶̂
convert⇒ : Convertible _⇒_ _⇒_
convert⇒ = is-convertible id
convert⇒⇒̂ : ∀ {μ} {s : T (silent? μ)} → Convertible _⇒_ _[ μ ]⇒̂_
convert⇒⇒̂ {s = s} = is-convertible (silent (get s))
convert[]⇒ : ∀ {μ} → Convertible _[ μ ]⇒_ _[ μ ]⇒_
convert[]⇒ = is-convertible id
convert[]⇒⇒ : ∀ {μ} {s : T (silent? μ)} → Convertible _[ μ ]⇒_ _⇒_
convert[]⇒⇒ {s = s} = is-convertible ([]⇒→⇒ (get s))
convert[]⇒⇒̂ : ∀ {μ} → Convertible _[ μ ]⇒_ _[ μ ]⇒̂_
convert[]⇒⇒̂ = is-convertible ⇒→⇒̂
convert⇒̂ : ∀ {μ} → Convertible _[ μ ]⇒̂_ _[ μ ]⇒̂_
convert⇒̂ = is-convertible id
convert⇒̂⇒ : ∀ {μ} {s : T (silent? μ)} → Convertible _[ μ ]⇒̂_ _⇒_
convert⇒̂⇒ {s = s} = is-convertible (⇒̂→⇒ (get s))
convert⇒̂[]⇒ : ∀ {μ} {¬s : if (silent? μ) then ⊥ else ⊤} →
Convertible _[ μ ]⇒̂_ _[ μ ]⇒_
convert⇒̂[]⇒ {μ} with silent? μ
convert⇒̂[]⇒ {¬s = ()} | yes _
convert⇒̂[]⇒ | no ¬s = is-convertible (⇒̂→[]⇒ ¬s)
convert⟶̂ : ∀ {μ} → Convertible _[ μ ]⟶̂_ _[ μ ]⟶̂_
convert⟶̂ = is-convertible id
convert⟶̂⇒ : ∀ {μ} {s : T (silent? μ)} → Convertible _[ μ ]⟶̂_ _⇒_
convert⟶̂⇒ {s = s} = is-convertible (⟶̂→⇒ (get s))
convert⟶̂⇒̂ : ∀ {μ} → Convertible _[ μ ]⟶̂_ _[ μ ]⇒̂_
convert⟶̂⇒̂ = is-convertible ⟶̂→⇒̂
reflexive⇒ : Reflexive _⇒_
reflexive⇒ = is-reflexive done
reflexive⟶̂ : ∀ {μ} {s : T (silent? μ)} → Reflexive _[ μ ]⟶̂_
reflexive⟶̂ {s = s} = is-reflexive (done (get s))
reflexive⇒̂ : ∀ {μ} {s : T (silent? μ)} → Reflexive _[ μ ]⇒̂_
reflexive⇒̂ {s = s} = is-reflexive (silent (get s) done)
trans⇒ : Transitive _⇒_ _⇒_
trans⇒ = is-transitive ⇒-transitive
trans⟶⇒ : ∀ {μ} {s : T (silent? μ)} → Transitive _[ μ ]⟶_ _⇒_
trans⟶⇒ {s = s} = is-transitive (⇒-transitive ∘ ⟶→⇒ (get s))
trans⇒̂⇒ : ∀ {μ} {s : T (silent? μ)} → Transitive _[ μ ]⇒̂_ _⇒_
trans⇒̂⇒ {s = s} = is-transitive (⇒-transitive ∘ ⇒̂→⇒ (get s))
trans⟶̂⇒ : ∀ {μ} {s : T (silent? μ)} → Transitive _[ μ ]⟶̂_ _⇒_
trans⟶̂⇒ {s = s} = is-transitive (⇒-transitive ∘ ⟶̂→⇒ (get s))
trans⇒[]⇒ : ∀ {μ} → Transitive _⇒_ _[ μ ]⇒_
trans⇒[]⇒ = is-transitive ⇒[]⇒-transitive
trans⟶[]⇒ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive _[ μ′ ]⟶_ _[ μ ]⇒_
trans⟶[]⇒ {s = s} = is-transitive (⇒[]⇒-transitive ∘ ⟶→⇒ (get s))
trans[]⇒[]⇒ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive _[ μ′ ]⇒_ _[ μ ]⇒_
trans[]⇒[]⇒ {s = s} = is-transitive (⇒[]⇒-transitive ∘ []⇒→⇒ (get s))
trans⟶̂[]⇒ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive _[ μ′ ]⟶̂_ _[ μ ]⇒_
trans⟶̂[]⇒ {s = s} = is-transitive (⇒[]⇒-transitive ∘ ⟶̂→⇒ (get s))
trans⇒⇒̂ : ∀ {μ} → Transitive _⇒_ _[ μ ]⇒̂_
trans⇒⇒̂ = is-transitive ⇒⇒̂-transitive
trans⟶⇒̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive _[ μ′ ]⟶_ _[ μ ]⇒̂_
trans⟶⇒̂ {s = s} = is-transitive (⇒⇒̂-transitive ∘ ⟶→⇒ (get s))
trans[]⇒⇒̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive _[ μ′ ]⇒_ _[ μ ]⇒̂_
trans[]⇒⇒̂ {s = s} = is-transitive (⇒⇒̂-transitive ∘ []⇒→⇒ (get s))
trans[]⇒̂⇒̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive _[ μ′ ]⇒̂_ _[ μ ]⇒̂_
trans[]⇒̂⇒̂ {s = s} = is-transitive (⇒⇒̂-transitive ∘ ⇒̂→⇒ (get s))
trans⟶̂⇒̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive _[ μ′ ]⟶̂_ _[ μ ]⇒̂_
trans⟶̂⇒̂ {s = s} = is-transitive (⇒⇒̂-transitive ∘ ⟶̂→⇒ (get s))
trans′⇒⟶ : ∀ {μ} {s : T (silent? μ)} → Transitive′ _⇒_ _[ μ ]⟶_
trans′⇒⟶ {s = s} =
is-transitive (flip (flip ⇒-transitive ∘ ⟶→⇒ (get s)))
trans′⇒[]⇒ : ∀ {μ} {s : T (silent? μ)} → Transitive′ _⇒_ _[ μ ]⇒_
trans′⇒[]⇒ {s = s} =
is-transitive (flip (flip ⇒-transitive ∘ []⇒→⇒ (get s)))
trans′⇒⇒̂ : ∀ {μ} {s : T (silent? μ)} → Transitive′ _⇒_ _[ μ ]⇒̂_
trans′⇒⇒̂ {s = s} =
is-transitive (flip (flip ⇒-transitive ∘ ⇒̂→⇒ (get s)))
trans′⇒⟶̂ : ∀ {μ} {s : T (silent? μ)} → Transitive′ _⇒_ _[ μ ]⟶̂_
trans′⇒⟶̂ {s = s} =
is-transitive (flip (flip ⇒-transitive ∘ ⟶̂→⇒ (get s)))
trans′[]⇒⟶ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒_ _[ μ′ ]⟶_
trans′[]⇒⟶ {s = s} =
is-transitive (flip (flip []⇒⇒-transitive ∘ ⟶→⇒ (get s)))
trans′[]⇒⇒ : ∀ {μ} → Transitive′ _[ μ ]⇒_ _⇒_
trans′[]⇒⇒ = is-transitive []⇒⇒-transitive
trans′[]⇒[]⇒ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒_ _[ μ′ ]⇒_
trans′[]⇒[]⇒ {s = s} =
is-transitive (flip (flip []⇒⇒-transitive ∘ []⇒→⇒ (get s)))
trans′[]⇒[]⇒̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒_ _[ μ′ ]⇒̂_
trans′[]⇒[]⇒̂ {s = s} =
is-transitive (flip (flip []⇒⇒-transitive ∘ ⇒̂→⇒ (get s)))
trans′[]⇒⟶̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒_ _[ μ′ ]⟶̂_
trans′[]⇒⟶̂ {s = s} =
is-transitive (flip (flip []⇒⇒-transitive ∘ ⟶̂→⇒ (get s)))
trans′⇒̂⟶ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒̂_ _[ μ′ ]⟶_
trans′⇒̂⟶ {s = s} =
is-transitive (flip (flip ⇒̂⇒-transitive ∘ ⟶→⇒ (get s)))
trans′⇒̂⇒ : ∀ {μ} → Transitive′ _[ μ ]⇒̂_ _⇒_
trans′⇒̂⇒ = is-transitive ⇒̂⇒-transitive
trans′⇒̂[]⇒ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒̂_ _[ μ′ ]⇒_
trans′⇒̂[]⇒ {s = s} =
is-transitive (flip (flip ⇒̂⇒-transitive ∘ []⇒→⇒ (get s)))
trans′⇒̂⇒̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒̂_ _[ μ′ ]⇒̂_
trans′⇒̂⇒̂ {s = s} =
is-transitive (flip (flip ⇒̂⇒-transitive ∘ ⇒̂→⇒ (get s)))
trans′⇒̂⟶̂ : ∀ {μ μ′} {s : T (silent? μ′)} →
Transitive′ _[ μ ]⇒̂_ _[ μ′ ]⟶̂_
trans′⇒̂⟶̂ {s = s} =
is-transitive (flip (flip ⇒̂⇒-transitive ∘ ⟶̂→⇒ (get s)))
| {
"alphanum_fraction": 0.4716596241,
"avg_line_length": 34.315,
"ext": "agda",
"hexsha": "f5baa7a6f1a8f561e052859bc2f7b5a18943718c",
"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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Labelled-transition-system/Equational-reasoning-instances.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"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/up-to",
"max_issues_repo_path": "src/Labelled-transition-system/Equational-reasoning-instances.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Labelled-transition-system/Equational-reasoning-instances.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3600,
"size": 6863
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 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.Impl.Consensus.EpochManagerTypes
import LibraBFT.Impl.Consensus.ConsensusProvider as ConsensusProvider
import LibraBFT.Impl.IO.OBM.GenKeyFile as GenKeyFile
import LibraBFT.Impl.IO.OBM.ObmNeedFetch as ObmNeedFetch
import LibraBFT.Impl.Types.ValidatorSigner as ValidatorSigner
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Interface.Output
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.PKCS
open import Util.Prelude
module LibraBFT.Impl.IO.OBM.Start where
{-
This only does the initialization steps from the Haskell version.
If initialization succeeds, it returns
- the EpochManager (for all epochs)
- note: this contains the initialized RoundManager for the current epoch (i.e., Epoch 0)
- any output from the RoundManager produced during initialization
The only output is (with info logging removed):
-- only the leader of round 1 will broadcast a proposal
BroadcastProposal; [ ... peer addresses ... ];
(ProposalMsg
(B 7194dca (BD 1 1 (Prop ("TX/1/1")) ...)) -- proposed block
(SI (hqc c66a132) (hcc N) (htc (TC N)))) -- SyncInfo
The Haskell code, after initialization, hooks up the communication channels and sockets
and starts threads that handle them. One of the threads is given to
EpochManager.obmStartLoop to get input and pass it through the EpochManager
and then (usually) on to the RoundMnager.
TODO-3: Replace 'Handle.initRM' with the initialized RoundManager obtained
through the following 'startViaConsensusProvider'.
TODO-3: Figure out how to handle the initial BroadcastProposal.
-}
module startViaConsensusProvider-ed
(now : Instant)
(nfl : GenKeyFile.NfLiwsVsVvPe)
(txTDS : TxTypeDependentStuffForNetwork)
where
step₁ : (NodeConfig × OnChainConfigPayload × LedgerInfoWithSignatures × SK × ProposerElection)
→ EitherD ErrLog (EpochManager × List Output)
step₀ : EitherD ErrLog (EpochManager × List Output)
step₀ = do
let (nf , liws , vs , vv , pe) = nfl
(nc , occp , liws , sk , pe) ← ConsensusProvider.obmInitialData-ed-abs (nf , liws , vs , vv , pe)
step₁ (nc , occp , liws , sk , pe)
step₁ (nc , occp , liws' , sk , _) =
ConsensusProvider.startConsensus-ed-abs
nc now occp liws' sk
(ObmNeedFetch∙new {- newNetwork -stps'-})
(txTDS ^∙ ttdsnProposalGenerator) (txTDS ^∙ ttdsnStateComputer)
abstract
startViaConsensusProvider-ed-abs = startViaConsensusProvider-ed.step₀
startViaConsensusProvider-ed-abs-≡ : startViaConsensusProvider-ed-abs ≡ startViaConsensusProvider-ed.step₀
startViaConsensusProvider-ed-abs-≡ = refl
| {
"alphanum_fraction": 0.7298292601,
"avg_line_length": 43.9264705882,
"ext": "agda",
"hexsha": "f10883e652f829ac224c82a01bec1230f6d36b17",
"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": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/IO/OBM/Start.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"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": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/IO/OBM/Start.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/IO/OBM/Start.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 813,
"size": 2987
} |
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; sym; trans; cong; cong₂; _≢_)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.List using (List; []; _∷_; dropWhile)
open import Data.Char using (Char)
open import Data.Bool using (Bool; true; false)
import Data.Char as Char using (_≟_)
open import Relation.Nullary using (¬_; Dec; yes; no)
open import Relation.Nullary.Decidable using (⌊_⌋)
data Head {A : Set} (P : A → Bool) : List A → Set where
head : ∀ (c : A) (s : List A) → P c ≡ true → Head P (c ∷ s)
prime : Char
prime = '′'
isPrime : Char → Bool
isPrime c = ⌊ c Char.≟ prime ⌋
head-lemma : ∀ (s : List Char) → ¬ Head isPrime (dropWhile isPrime s)
head-lemma [] = λ()
head-lemma (c ∷ s) with isPrime c
... | true = head-lemma s
... | false = ¬h
where
¬h : ¬ Head isPrime (c ∷ s)
¬h (head c s eqn′) = {!!}
{-
Goal: ⊥
————————————————————————————————————————————————————————————
s : List Char
c : Char
eqn′ : ⌊ (c Char.≟ '′' | .Agda.Builtin.Char.primCharEquality c '′')
⌋
≡ true
s : List Char
c : Char
-}
| {
"alphanum_fraction": 0.5479331574,
"avg_line_length": 27.7317073171,
"ext": "agda",
"hexsha": "53639a4fa453618d5c2aec2396ca1c0b95120d5a",
"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/Head.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/Head.agda",
"max_line_length": 69,
"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/Head.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": 384,
"size": 1137
} |
------------------------------------------------------------------------------
-- A proof that is rejected using the --without-K option
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Lists where
open import FOTC.Base
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.List
open import FOTC.Data.List.PropertiesI
open import FOTC.Data.List.WF-Relation.LT-Cons
open import FOTC.Data.List.WF-Relation.LT-Length
------------------------------------------------------------------------------
-- LTC → LTL.
-- 25 April 2014. The proof is accepted using Cockx's --without-K
-- implementation.
LTC→LTL : ∀ {xs ys} → List xs → LTC xs ys → LTL xs ys
LTC→LTL Lxs (x , refl) = lg-x<lg-x∷xs x Lxs
LTC→LTL' : ∀ {xs ys} → List xs → LTC xs ys → LTL xs ys
LTC→LTL' {xs} {ys} Lxs (x , h) =
subst (λ ys' → length xs < length ys')
(sym h)
(lg-x<lg-x∷xs x Lxs)
| {
"alphanum_fraction": 0.4894009217,
"avg_line_length": 33.90625,
"ext": "agda",
"hexsha": "93be4dc7668c84e9f07e1b2333236d45c0a8cd3d",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/k-axiom/Lists.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/k-axiom/Lists.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/k-axiom/Lists.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": 278,
"size": 1085
} |
module Data.Fin.Properties.Extra where
open import Data.Fin hiding (_≤_)
open import Data.Nat
open import Data.Nat.Properties
open import Relation.Binary.PropositionalEquality
inject≤-trans : ∀ {l m n} i (p : l ≤ m)(q : m ≤ n) → inject≤ (inject≤ i p) q ≡ inject≤ i (≤-trans p q)
inject≤-trans () z≤n q
inject≤-trans zero (s≤s p) (s≤s q) = refl
inject≤-trans (suc i) (s≤s p) (s≤s q) = cong suc (inject≤-trans i p q)
| {
"alphanum_fraction": 0.6650717703,
"avg_line_length": 32.1538461538,
"ext": "agda",
"hexsha": "4fd90f854ed4745976eceb2cead5ccd758544e51",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Data/Fin/Properties/Extra.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Data/Fin/Properties/Extra.agda",
"max_line_length": 102,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Data/Fin/Properties/Extra.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 165,
"size": 418
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.Comma.Functors where
open import Categories.Category
open import Categories.Functor renaming (_∘_ to _∘F_)
open import Categories.FunctorCategory renaming (Functors to [_⇒_])
open import Categories.NaturalTransformation using (module NaturalTransformation)
open import Data.Product using (∃; _,_; proj₁; proj₂; zip; map)
open import Level
open import Relation.Binary using (Rel)
open import Categories.Support.EqReasoning
open import Categories.Square
open import Categories.Comma
open import Categories.Product renaming (Product to _×_)
πComma :
∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃}
→ {A : Category o₁ ℓ₁ e₁}
→ {B : Category o₂ ℓ₂ e₂}
→ {C : Category o₃ ℓ₃ e₃}
→ (S : Functor B C) (T : Functor A C)
→ Functor (S ↓ T) (B × A)
πComma {A = A} {B} {C} S T =
record
{ F₀ = F₀′
; F₁ = F₁′
; identity = B×A.Equiv.refl
; homomorphism = B×A.Equiv.refl
; F-resp-≡ = λ pf → pf
}
where
module S↓T = Category (S ↓ T)
module B×A = Category (B × A)
open Comma S T using (_,_[_]) renaming (_,_,_ to ⟨_,_,_⟩)
F₀′ : S↓T.Obj → B×A.Obj
F₀′ ⟨ α , β , f ⟩ = α , β
F₁′ : ∀ {X Y} → (S ↓ T) [ X , Y ] → (B × A) [ F₀′ X , F₀′ Y ]
F₁′ (g , h [ commutes ]) = g , h
InducedFunctor : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃}
{A : Category o₁ ℓ₁ e₁}
{B : Category o₂ ℓ₂ e₂}
{C : Category o₃ ℓ₃ e₃}
{s₁ s₂ d₁ d₂}
(m : (Category.op [ A ⇒ C ] × [ B ⇒ C ]) [ (s₁ , s₂) , (d₁ , d₂) ])
→ Functor (s₁ ↓ s₂) (d₁ ↓ d₂)
InducedFunctor {A = A} {B} {C} {s₁} {s₂} {d₁} {d₂} m = record
{ F₀ = F₀′
; F₁ = F₁′
; identity = λ {X} → d₁↓d₂.Equiv.refl {_} {_} {d₁↓d₂.id {F₀′ X}}
; homomorphism = λ {_ _ _ f g} → d₁↓d₂.Equiv.refl {_} {_} {F₁′ ((s₁ ↓ s₂) [ g ∘ f ])}
; F-resp-≡ = λ pf → pf
}
where
module s₁↓s₂ = Category (s₁ ↓ s₂)
module d₁↓d₂ = Category (d₁ ↓ d₂)
module s₁ = Functor s₁
module s₂ = Functor s₂
module d₁ = Functor d₁
module d₂ = Functor d₂
module m₁ = NaturalTransformation (proj₁ m)
module m₂ = NaturalTransformation (proj₂ m)
open Category C
open Comma renaming (_,_,_ to ⟨_,_,_⟩)
F₀′ : s₁↓s₂.Obj → d₁↓d₂.Obj
F₀′ ⟨ α , β , f ⟩ = ⟨ α , β , m₂.η β ∘ f ∘ m₁.η α ⟩
F₁′ : ∀ {X Y} → (s₁ ↓ s₂) [ X , Y ] → (d₁ ↓ d₂) [ F₀′ X , F₀′ Y ]
F₁′ {⟨ α₁ , β₁ , f₁ ⟩} {⟨ α₂ , β₂ , f₂ ⟩} (g , h [ commutes ]) = g , h [ (
begin
d₂.F₁ h ∘ m₂.η β₁ ∘ f₁ ∘ m₁.η α₁
↑⟨ pushˡ (m₂.commute h) ⟩
(m₂.η β₂ ∘ s₂.F₁ h) ∘ f₁ ∘ m₁.η α₁
↓⟨ pullˡ (pullʳ commutes) ⟩
(m₂.η β₂ ∘ f₂ ∘ s₁.F₁ g) ∘ m₁.η α₁
↑⟨ extendˡ (extendˡ (m₁.commute g)) ⟩
(m₂.η β₂ ∘ f₂ ∘ m₁.η α₂) ∘ d₁.F₁ g
∎ ) ]
where
open HomReasoning
open GlueSquares C
| {
"alphanum_fraction": 0.5357269819,
"avg_line_length": 32.3333333333,
"ext": "agda",
"hexsha": "7547d083d7dd62441c155c0a5a570a763d5ee23c",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Comma/Functors.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Comma/Functors.agda",
"max_line_length": 87,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Comma/Functors.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 1196,
"size": 2813
} |
-- Andreas, Bentfest 2016-04-28 Marsstrand
-- Issue 1944: also resolve overloaded projections in checking position
module _ (A : Set) (a : A) where
record R B : Set where
field f : B
open R
record S B : Set where
field f : B
open S
test : R A → A
test = f
test1 : ∀{A} → R A → A
test1 = f
test2 : ∀ A → R A → A
test2 A = f {A}
postulate
F : Set → Set
mapF : ∀{A B} (f : A → B) → F A → F B
fr : F (R A)
test3 : F (R A) → F A
test3 = mapF f
test4 : F (R _) → F A
test4 = mapF f
test5 : ∀{A} → F (F (R A)) → F _
test5 = mapF (mapF f)
test6 = mapF f fr
| {
"alphanum_fraction": 0.5649122807,
"avg_line_length": 15,
"ext": "agda",
"hexsha": "5e0adefe4654d4b1999d59ae434c143dfe918ac9",
"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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/Succeed/Issue1944-UnappliedOverloadedProjection.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"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": "pthariensflame/agda",
"max_issues_repo_path": "test/Succeed/Issue1944-UnappliedOverloadedProjection.agda",
"max_line_length": 71,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/Succeed/Issue1944-UnappliedOverloadedProjection.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": 237,
"size": 570
} |
module nat-thms where
open import bool
open import bool-thms
open import bool-thms2
open import eq
open import nat
open import neq
open import product
open import product-thms
open import sum
open import level
open import negation
--------------------------------------------------
-- properties of addition
--------------------------------------------------
0+ : ∀ (x : ℕ) → 0 + x ≡ x
0+ x = refl
+0 : ∀ (x : ℕ) → x + 0 ≡ x
+0 zero = refl
+0 (suc x) rewrite +0 x = refl
+1 : ∀ (x : ℕ) → x + 1 ≡ suc x
+1 zero = refl
+1 (suc x) rewrite +1 x = refl
+suc : ∀ (x y : ℕ) → x + (suc y) ≡ suc(x + y)
+suc zero y = refl
+suc (suc x) y rewrite +suc x y = refl
+assoc : ∀ (x y z : ℕ) → x + (y + z) ≡ (x + y) + z
+assoc zero y z = refl
+assoc (suc x) y z rewrite +assoc x y z = refl
+comm : ∀ (x y : ℕ) → x + y ≡ y + x
+comm zero y rewrite +0 y = refl
+comm (suc x) y rewrite +suc y x | +comm x y = refl
+perm : ∀ (x y z : ℕ) → x + (y + z) ≡ y + (x + z)
+perm x y z rewrite +assoc x y z | +comm x y | sym (+assoc y x z) = refl
+perm2 : ∀ (x y z : ℕ) → (x + y) + z ≡ (x + z) + y
+perm2 x y z rewrite sym (+assoc x y z) | +comm y z | +assoc x z y = refl
+≡0 : ∀ {x y : ℕ} → x + y ≡ 0 → x ≡ 0 ∧ y ≡ 0
+≡0{zero}{zero} p = refl , refl
+≡0{zero}{suc y} ()
+≡0{suc x}{zero} ()
+≡0{suc x}{suc y} ()
--------------------------------------------------
-- properties of multiplication
--------------------------------------------------
*0 : ∀ (x : ℕ) → x * 0 ≡ 0
*0 zero = refl
*0 (suc x) rewrite *0 x = refl
*1 : ∀ {n : ℕ} → n * 1 ≡ n
*1 {0} = refl
*1 {suc n} rewrite *1 {n} = refl
*suc : ∀ (x y : ℕ) → x * (suc y) ≡ x + x * y
*suc zero y = refl
*suc (suc x) y rewrite *suc x y | +assoc y x (x * y) | +assoc x y (x * y) | +comm y x = refl
*distribr : ∀ (x y z : ℕ) → (x + y) * z ≡ x * z + y * z
*distribr zero y z = refl
*distribr (suc x) y z rewrite *distribr x y z = +assoc z (x * z) (y * z)
*distribl : ∀ (x y z : ℕ) → x * (y + z) ≡ x * y + x * z
*distribl 0 y z = refl
*distribl (suc x) y z rewrite *distribl x y z | +assoc (y + z) (x * y) (x * z) | +assoc (y + x * y) z (x * z) | +comm (y + z) (x * y) | +assoc (x * y) y z | +comm (x * y) y = refl
*comm : ∀ (x y : ℕ) → x * y ≡ y * x
*comm zero y rewrite *0 y = refl
*comm (suc x) y rewrite *suc y x | *comm x y = refl
*assoc : ∀ (x y z : ℕ) → x * (y * z) ≡ (x * y) * z
*assoc zero y z = refl
*assoc (suc x) y z rewrite *assoc x y z | *distribr y (x * y) z = refl
--------------------------------------------------
-- basic properties of pred
--------------------------------------------------
sucpred : ∀ {x : ℕ} → iszero x ≡ ff → suc (pred x) ≡ x
sucpred{0} ()
sucpred{suc x} p = refl
pred+ : ∀ (x y : ℕ) → iszero x ≡ ff → (pred x) + y ≡ pred (x + y)
pred+ 0 y ()
pred+ (suc x) y p = refl
--------------------------------------------------
-- properties of <, ≤, and =ℕ, iszero
--------------------------------------------------
<-0 : ∀ (x : ℕ) → x < 0 ≡ ff
<-0 0 = refl
<-0 (suc y) = refl
0-≤ : ∀ (x : ℕ) → 0 ≤ x ≡ tt
0-≤ 0 = refl
0-≤ (suc x) = refl
<-drop : ∀ {x y : ℕ} → (x < (suc y) ≡ tt) → x ≡ y ∨ x < y ≡ tt
<-drop {0} {0} p = inj₁ refl
<-drop {suc x} {0} p rewrite <-0 x = 𝔹-contra p
<-drop {0} {suc y} p = inj₂ refl
<-drop {suc x} {suc y} p with <-drop {x} {y} p
... | inj₁ u rewrite u = inj₁ refl
... | inj₂ u = inj₂ u
=ℕ-refl : ∀ (x : ℕ) → (x =ℕ x) ≡ tt
=ℕ-refl 0 = refl
=ℕ-refl (suc x) = (=ℕ-refl x)
=ℕ-to-≡ : ∀ {x y : ℕ} → x =ℕ y ≡ tt → x ≡ y
=ℕ-to-≡ {0} {0} u = refl
=ℕ-to-≡ {suc x} {0} ()
=ℕ-to-≡ {0} {suc y} ()
=ℕ-to-≡ {suc x} {suc y} u rewrite =ℕ-to-≡ {x} {y} u = refl
=ℕ-from-≡ : ∀ {x y : ℕ} → x ≡ y → x =ℕ y ≡ tt
=ℕ-from-≡ {x} refl = =ℕ-refl x
=ℕ-sym : ∀ (x y : ℕ) → (x =ℕ y) ≡ (y =ℕ x)
=ℕ-sym 0 0 = refl
=ℕ-sym 0 (suc y) = refl
=ℕ-sym (suc x) 0 = refl
=ℕ-sym (suc x) (suc y) rewrite =ℕ-sym x y = refl
=ℕ-suc : ∀ (x : ℕ) → suc x =ℕ x ≡ ff
=ℕ-suc 0 = refl
=ℕ-suc (suc x) = =ℕ-suc x
<-suc : ∀ (n : ℕ) → n < suc n ≡ tt
<-suc 0 = refl
<-suc (suc n) rewrite <-suc n = refl
<-suc2 : ∀ (n : ℕ) → suc n < n ≡ ff
<-suc2 0 = refl
<-suc2 (suc n) = <-suc2 n
≤-suc : ∀ (n : ℕ) → n ≤ suc n ≡ tt
≤-suc n rewrite <-suc n = refl
≤-suc2 : ∀ (n : ℕ) → suc n ≤ n ≡ ff
≤-suc2 n rewrite <-suc2 n | =ℕ-suc n = refl
<-push : ∀ {x y : ℕ} → (suc x) < y ≡ tt → Σ ℕ (λ y' → y ≡ (suc y'))
<-push {x} {0} ()
<-push {0} {suc y} p = (y , refl)
<-push {suc x} {suc y} p with <-push {x} {y} p
... | ( y' , p' ) rewrite p' = (suc y' , refl)
suc-inj : ∀ {n m : ℕ} → suc n ≡ suc m → n ≡ m
suc-inj {n} {m} p rewrite (=ℕ-to-≡{n} (=ℕ-from-≡ p)) = refl
<-implies-suc : ∀ {x y : ℕ} → x < y ≡ tt → Σ ℕ λ y' → y ≡ suc y'
<-implies-suc{x}{0} p rewrite <-0 x = 𝔹-contra p
<-implies-suc{y = suc y} p = y , refl
<=ℕff : ∀ (x : ℕ) → 0 < x ≡ tt → x =ℕ 0 ≡ ff
<=ℕff 0 ()
<=ℕff (suc x) p = refl
nonzero< : ∀ {n : ℕ} → iszero n ≡ ff → 0 < n ≡ tt
nonzero<{0} ()
nonzero<{(suc n)} p = refl
iszerosum : ∀ (x y : ℕ) → iszero(x + y) ≡ iszero(x) && iszero(y)
iszerosum 0 y = refl
iszerosum (suc x) y = refl
iszerosum2 : ∀ (x y : ℕ) → iszero x ≡ ff → iszero(x + y) ≡ ff
iszerosum2 0 y ()
iszerosum2 (suc x) y _ = refl
iszeromult : ∀ (x y : ℕ) → iszero x ≡ ff → iszero y ≡ ff →
iszero (x * y) ≡ ff
iszeromult zero zero () q
iszeromult zero (suc y) () q
iszeromult (suc x) zero p ()
iszeromult (suc x) (suc y) p q = refl
<≤ : ∀ {n m : ℕ} → n < m ≡ tt → n ≤ m ≡ tt
<≤ {n}{m} p rewrite p = refl
≤+1 : ∀(x y : ℕ) → x ≤ x + y ≡ tt
≤+1 zero zero = refl
≤+1 zero (suc y) = refl
≤+1 (suc x) zero rewrite +0 x | =ℕ-refl x | ||-tt (x < x) = refl
≤+1 (suc x) (suc y) = ≤+1 x (suc y)
≤+2 : ∀(x y : ℕ) → y ≤ x + y ≡ tt
≤+2 x y rewrite +comm x y = ≤+1 y x
-- a theorem about quotients q, divisors d, and remainders r
÷< : ∀ {d q r x : ℕ} → 1 < d ≡ tt → q * d + r ≡ suc x → q < suc x ≡ tt
÷<{0} () p
÷<{suc 0} () p
÷<{suc (suc d)}{0} u p = refl
÷<{suc (suc d)}{suc q}{r}{0} u ()
÷<{suc (suc d)}{suc q}{r}{suc x} u p with suc-inj{suc (d + q * suc (suc d) + r)}{suc x} p
... | p' rewrite sym (+suc (d + q * suc (suc d)) r) | +comm d (q * suc (suc d))
| sym (+assoc (q * (suc (suc d))) d (suc r)) = ÷<{suc (suc d)}{q}{d + suc r}{x} refl p'
--------------------------------------------------
-- ordering properties of < and ≤ℕ
--------------------------------------------------
<-irrefl : ∀ (n : ℕ) → n < n ≡ ff
<-irrefl 0 = refl
<-irrefl (suc n) = <-irrefl n
<-asym : ∀ {x y : ℕ} → x < y ≡ tt → y < x ≡ ff
<-asym {0} {0} _ = refl
<-asym {0} {suc y} p = refl
<-asym {suc x}{0} ()
<-asym {suc x}{suc y} p = <-asym {x} {y} p
ℕ-trichotomy𝔹 : ∀ (n m : ℕ) → n < m || n =ℕ m || m < n ≡ tt
ℕ-trichotomy𝔹 0 0 = refl
ℕ-trichotomy𝔹 0 (suc m) = refl
ℕ-trichotomy𝔹 (suc n) 0 = refl
ℕ-trichotomy𝔹 (suc n) (suc m) = ℕ-trichotomy𝔹 n m
ℕ-trichotomy : ∀ (n m : ℕ) → (n < m ≡ tt) ∨ (n =ℕ m ≡ tt) ∨ (m < n ≡ tt)
ℕ-trichotomy n m with ||-split{n < m} (ℕ-trichotomy𝔹 n m)
... | inj₁ p = inj₁ p
... | inj₂ p with ||-split{n =ℕ m} p
... | inj₁ p' = inj₂ (inj₁ p')
... | inj₂ p' = inj₂ (inj₂ p')
<-insert : ∀ {x n m : ℕ} → n ≤ m ≡ tt → (x < n ≡ tt) ∨ (n ≤ x && x ≤ m ≡ tt) ∨ (m < x ≡ tt)
<-insert{x}{n}{m} q with ℕ-trichotomy x n
<-insert{x}{n}{m} q | inj₁ p = inj₁ p
<-insert{x}{n}{m} q | inj₂ (inj₁ p) rewrite (=ℕ-to-≡{x} p) | =ℕ-refl n | ||-tt (n < n) = inj₂ (inj₁ q)
<-insert{x}{n}{m} q | inj₂ (inj₂ p) rewrite p with ℕ-trichotomy x m
<-insert{x}{n}{m} q | inj₂ (inj₂ p) | inj₁ p' rewrite p' = inj₂ (inj₁ refl)
<-insert{x}{n}{m} q | inj₂ (inj₂ p) | inj₂ (inj₁ p') rewrite p' | ||-tt (x < m) = inj₂ (inj₁ refl)
<-insert{x}{n}{m} q | inj₂ (inj₂ p) | inj₂ (inj₂ p') = inj₂ (inj₂ p')
<-insert2 : ∀ {x n m : ℕ} → n ≤ m ≡ tt → (x < n ≡ tt) ∨ (n ≤ x ≡ tt ∧ x ≤ m ≡ tt) ∨ (m < x ≡ tt)
<-insert2{x}{n}{m} p with <-insert{x}{n}{m} p
<-insert2{x}{n}{m} p | inj₁ p' = inj₁ p'
<-insert2{x}{n}{m} p | inj₂ (inj₁ p') with &&-elim {n ≤ x} {x ≤ m} p'
<-insert2{x}{n}{m} p | inj₂ (inj₁ p') | p1 , p2 = inj₂ (inj₁ (p1 , p2))
<-insert2{x}{n}{m} p | inj₂ (inj₂ p') = inj₂ (inj₂ p')
<-trans : ∀ {x y z : ℕ} → x < y ≡ tt → y < z ≡ tt → x < z ≡ tt
<-trans {x} {0} p1 p2 rewrite <-0 x = 𝔹-contra p1
<-trans {0} {suc y} {0} p1 ()
<-trans {0} {suc y} {suc z} p1 p2 = refl
<-trans {suc x} {suc y} {0} p1 ()
<-trans {suc x} {suc y} {suc z} p1 p2 = <-trans {x} {y} {z} p1 p2
-- <≤-trans : ∀ {x y z : ℕ} → x < y ≡ tt → y ≤ z ≡ tt → x < z ≡ tt
-- <≤-trans {x} {y} {z} p1 p2 with ||-split p2
-- ... | inj₁ p' = <-trans{x} p1 p'
-- ... | inj₂ p' rewrite =ℕ-to-≡ {y} {z} p' = p1
≤<-trans : ∀ {x y z : ℕ} → x ≤ y ≡ tt → y < z ≡ tt → x < z ≡ tt
≤<-trans {x} {y} {z} p1 p2 with ||-split p1
... | inj₁ p' = <-trans{x} p' p2
... | inj₂ p' rewrite =ℕ-to-≡ {x} {y} p' = p2
≤-refl : ∀ (x : ℕ) → x ≤ x ≡ tt
≤-refl 0 = refl
≤-refl (suc x) = ≤-refl x
≤-trans : ∀ {x y z : ℕ} → x ≤ y ≡ tt → y ≤ z ≡ tt → x ≤ z ≡ tt
≤-trans {x} {y} {z} p1 p2 with ||-split p1 | ||-split p2
... | inj₁ p' | inj₁ p'' rewrite <-trans {x} p' p'' = refl
... | inj₂ p' | inj₁ p'' rewrite =ℕ-to-≡ {x} p' | p'' = refl
... | inj₁ p' | inj₂ p'' rewrite =ℕ-to-≡ {y} p'' | p' = refl
... | inj₂ p' | inj₂ p'' rewrite =ℕ-to-≡ {x} p' | =ℕ-to-≡ {y} p'' | =ℕ-refl z | ||-tt (z < z) = refl
suc≤ : ∀ {n n' : ℕ} → suc n ≤ suc n' ≡ tt → n ≤ n' ≡ tt
suc≤{n}{n'} p = p
-- suc≤< : ∀ {n n' : ℕ} → suc n ≤ n' ≡ tt → n < n' ≡ tt
-- suc≤<{n} p = <≤-trans{n} (<-suc n) p
suc<< : ∀ {n' n : ℕ} → suc n < n' ≡ tt → n < n' ≡ tt
suc<<{n = n} p = <-trans{n} (<-suc n) p
<-suc-trans : ∀{x y : ℕ} → x < y ≡ tt → x < suc y ≡ tt
<-suc-trans{0}{0} _ = refl
<-suc-trans{suc x}{0} ()
<-suc-trans{0}{suc y} _ = refl
<-suc-trans{suc x}{suc y} p = <-suc-trans{x}{y} p
≤-suc-trans : ∀{x y : ℕ} → x ≤ y ≡ tt → x ≤ suc y ≡ tt
≤-suc-trans{0}{0} _ = refl
≤-suc-trans{suc x}{0} ()
≤-suc-trans{0}{suc y} _ = refl
≤-suc-trans{suc x}{suc y} p = ≤-suc-trans{x}{y} p
-------------------------------------------------------------
-- more properties relating <, ≤ with arithmetic operations
-------------------------------------------------------------
<+ : ∀ {x y : ℕ} → y =ℕ 0 ≡ ff → x < y + x ≡ tt
<+{y = 0} ()
<+{x}{suc 0} p = <-suc x
<+{x}{suc (suc y)} p = <-trans{x}{(suc y) + x}{suc ((suc y) + x)} (<+{x}{suc y} refl) (<-suc ((suc y) + x))
<+2 : ∀ {x y : ℕ} → x < (suc y) + x ≡ tt
<+2{x}{y} = <+{x}{suc y} refl
<-iter-suc-trans-t-h : (n : ℕ) → (x : ℕ) → (accum : ℕ) → Set
<-iter-suc-trans-t-h 0 x accum = x < accum ≡ tt
<-iter-suc-trans-t-h (suc n) x accum = <-iter-suc-trans-t-h n x (suc accum)
<-iter-suc-trans-t : (n : ℕ) → (x : ℕ) → Set
<-iter-suc-trans-t n x = <-iter-suc-trans-t-h n x (suc x)
<-iter-suc-trans-h : ∀ (n : ℕ) → (x : ℕ) → (accum : ℕ) → x < accum ≡ tt → <-iter-suc-trans-t-h n x accum
<-iter-suc-trans-h 0 x accum p = p
<-iter-suc-trans-h (suc n) x accum p = <-iter-suc-trans-h n x (suc accum) (<-suc-trans{x} p)
<-iter-suc-trans : ∀ (n : ℕ) → (x : ℕ) → <-iter-suc-trans-t n x
<-iter-suc-trans n x = <-iter-suc-trans-h n x (suc x) (<-suc x)
≤0 : ∀ (n : ℕ) → 0 ≤ n ≡ tt
≤0 0 = refl
≤0 (suc n) = refl
≤2* : ∀ (x : ℕ) → x ≤ 2 * x ≡ tt
≤2* 0 = refl
≤2* (suc x) rewrite +suc x (x + 0) | ≤<-trans {x} (≤2* x) (<-suc (2 * x)) = refl
0<+ : ∀ (x y : ℕ) → 0 < y ≡ tt → 0 < x + y ≡ tt
0<+ 0 y p = p
0<+ (suc x) y p = refl
<=ℕff2 : ∀ (x : ℕ) → 1 < x ≡ tt → x =ℕ 0 ≡ ff
<=ℕff2 x p = <=ℕff x (<-trans{0}{1}{x} refl p)
*≤ : ∀(x y : ℕ) → x ≤ x * (suc y) ≡ tt
*≤ zero y = refl
*≤ (suc x) y = ≤-trans {x} (*≤ x y) (≤+2 y (x * suc y))
--------------------------------------------------
-- relationships between ≤ and <
--------------------------------------------------
≤ff : ∀ {x y : ℕ} → x ≤ y ≡ ff → y < x ≡ tt
≤ff{0}{0} ()
≤ff{0}{suc y} ()
≤ff{suc x}{0} _ = refl
≤ff{suc x}{suc y} p rewrite ≤ff {x}{y} p = refl
<ff : ∀ {x y : ℕ} → x < y ≡ ff → y ≤ x ≡ tt
<ff{x}{y} p with ℕ-trichotomy x y
... | inj₁ u rewrite u = 𝔹-contra (sym p)
... | inj₂ (inj₁ u) rewrite (=ℕ-to-≡{x} u) | =ℕ-refl y | ||-tt (y < y) = refl
... | inj₂ (inj₂ u) rewrite u = refl
<-not-=ℕ : ∀{x y : ℕ} → x < y ≡ tt → y =ℕ x ≡ ff
<-not-=ℕ{0}{0} ()
<-not-=ℕ{suc x}{0} ()
<-not-=ℕ{0}{suc y} p = refl
<-not-=ℕ{suc x}{suc y} p = <-not-=ℕ{x}{y} p
<-not-> : ∀{x y : ℕ} → x < y ≡ tt → y < x ≡ ff
<-not->{0}{0} ()
<-not->{suc x}{0} ()
<-not->{0}{suc y} p = refl
<-not->{suc x}{suc y} p = <-not->{x}{y} p
<tt : ∀ {x y : ℕ} → x < y ≡ tt → y ≤ x ≡ ff
<tt{x}{y} p rewrite <-not-=ℕ{x}{y} p | <-not->{x}{y} p = refl
≤-antisym : ∀{x y : ℕ} → x ≤ y ≡ tt → y ≤ x ≡ tt → x ≡ y
≤-antisym{x}{y} p q with ||-split {x < y} p
≤-antisym{x}{y} p q | inj₁ u rewrite <tt{x} u with q
≤-antisym{x}{y} p q | inj₁ u | ()
≤-antisym{x}{y} p q | inj₂ u = =ℕ-to-≡ u
--------------------------------------------------
-- monotonicity properties of < and ≤ℕ
--------------------------------------------------
<+mono1 : ∀ {z x y : ℕ} → x < y ≡ tt → z + x < z + y ≡ tt
<+mono1{0} p = p
<+mono1{suc z} p = <+mono1{z} p
<+mono2 : ∀ {x y z : ℕ} → x < y ≡ tt → x + z < y + z ≡ tt
<+mono2{x}{y}{z} p rewrite +comm x z | +comm y z | <+mono1{z}{x}{y} p = refl
--------------------------------------------------
-- properties of subtraction
--------------------------------------------------
0∸ : ∀ {x : ℕ} → 0 ∸ x ≡ 0
0∸{0} = refl
0∸{suc x} = refl
∸≤ : ∀ (x y : ℕ) → x ∸ y ≤ x ≡ tt
∸≤ 0 0 = refl
∸≤ (suc x) 0 rewrite (=ℕ-refl x) = ||-tt (x < x)
∸≤ 0 (suc y) = refl
∸≤ (suc x) (suc y) with ||-split{x ∸ y < x}{x ∸ y =ℕ x} (∸≤ x y)
... | inj₁ u rewrite <-trans {x ∸ y} u (<-suc x) = refl
... | inj₂ u rewrite (=ℕ-to-≡ {x ∸ y} u) | <-suc x = refl
∸< : ∀ {x y : ℕ} → x =ℕ 0 ≡ ff → x ∸ (suc y) < x ≡ tt
∸< {0} {y} ()
∸< {suc x} {y} _ with ||-split{x ∸ y < x}{x ∸ y =ℕ x} (∸≤ x y)
... | inj₁ u = <-trans {x ∸ y} u (<-suc x)
... | inj₂ u rewrite (=ℕ-to-≡ {x ∸ y} u) = <-suc x
∸<1 : ∀ {x y : ℕ} → x ∸ y < suc x ≡ tt
∸<1 {zero} {zero} = refl
∸<1 {zero} {suc y} = refl
∸<1 {suc x} {zero} = <-suc x
∸<1 {suc x} {suc y} = <-trans {x ∸ y}{suc x} (∸<1 {x} {y}) (<-suc x)
+∸1 : ∀ {x y : ℕ} → x < y ≡ tt → x + (y ∸ x) ≡ y
+∸1{0} p = refl
+∸1{suc x}{0} ()
+∸1{suc x}{suc y} p rewrite +∸1{x}{y} p = refl
∸+ : ∀ {x y z : ℕ} → x ∸ (y + z) ≡ (x ∸ y) ∸ z
∸+{x}{0} = refl
∸+{0}{suc y}{z} rewrite 0∸{z} = refl
∸+{suc x}{suc y} = ∸+{x}{y}
∸+2 : ∀ {x y : ℕ} → y ≤ x ≡ tt → (x ∸ y) + y ≡ x
∸+2{0}{0} _ = refl
∸+2{suc x}{0} _ rewrite +0 x = refl
∸+2{0}{suc y} ()
∸+2{suc x}{suc y} p rewrite +suc (x ∸ y) y | ∸+2{x}{y} p = refl
∸eq-swap : ∀ {x y z : ℕ} → y ≤ x ≡ tt → z ≡ x ∸ y → z + y ≡ x
∸eq-swap{x}{y}{z} p q = lem (cong (λ w → w + y) q)
where lem : z + y ≡ (x ∸ y) + y → z + y ≡ x
lem p' rewrite ∸+2{x}{y} p = p'
<∸ : ∀ {x y : ℕ} → (y < x ≡ tt) → ((x ∸ y =ℕ 0) ≡ ff)
<∸ {0}{y} p with <-0 y
... | q rewrite p = 𝔹-contra (sym q)
<∸ {suc x}{0} p = refl
<∸ {suc x}{suc y} p = <∸{x}{y} p
<∸suc : ∀ {x y : ℕ} → (y < x ≡ tt) → Σ ℕ (λ n → x ∸ y ≡ suc n)
<∸suc{x}{y} p with keep (x ∸ y)
<∸suc{x}{y} p | 0 , r with <∸{x}{y} p
<∸suc{x}{y} p | 0 , r | q rewrite r with q
<∸suc{x}{y} p | 0 , r | q | ()
<∸suc{x}{y} p | suc n , r = n , r
∸suc : ∀ {x y z : ℕ } → y < x ≡ tt → x ∸ (y + (suc z)) < x ∸ y ≡ tt
∸suc{x}{y}{z} p rewrite ∸+{x}{y}{suc z} = ∸< {x ∸ y} (<∸{x}{y} p)
∸suc2 : ∀ {x y z : ℕ } → y < x ≡ tt → x ∸ ((suc z) + y) < x ∸ y ≡ tt
∸suc2{x}{y}{z} p rewrite +comm (suc z) y = ∸suc{x}{y}{z} p
∸cancel : ∀ (x y z : ℕ) → (x + y) ∸ (x + z) ≡ y ∸ z
∸cancel 0 y z = refl
∸cancel (suc x) y z = ∸cancel x y z
distribr*∸ : ∀ (x y z : ℕ) → (x ∸ y) * z ≡ x * z ∸ y * z
distribr*∸ 0 y z rewrite 0∸{y} | 0∸{y * z} = refl
distribr*∸ (suc x) 0 z = refl
distribr*∸ (suc x) (suc y) z rewrite distribr*∸ x y z | ∸cancel z (x * z) (y * z) = refl
∸≤2 : ∀ (n x y : ℕ) → x ≤ suc n ≡ tt → y =ℕ 0 ≡ ff → x ∸ y ≤ n ≡ tt
∸≤2 0 0 y p1 p2 rewrite 0∸{y} = refl
∸≤2 0 (suc x) 0 p1 ()
∸≤2 0 (suc 0) (suc y) p1 p2 rewrite 0∸{y}= refl
∸≤2 0 (suc (suc x)) (suc y) () p2
∸≤2 (suc n) 0 y p1 p2 rewrite 0∸{y} = refl
∸≤2 (suc n) (suc x) 0 p1 ()
∸≤2 (suc n) (suc x) (suc 0) p1 p2 = p1
∸≤2 (suc n) (suc x) (suc (suc y)) p1 p2 = ≤-trans{x ∸ suc y}{n}{suc n} (∸≤2 n x (suc y) p1 refl) (≤-suc n)
--------------------------------------------------
-- properties of min, max
--------------------------------------------------
min-forced1 : ∀ {n n' m : ℕ} → n < n' ≡ tt → n ≡ min n' m → n ≡ m
min-forced1{n}{n'}{m} p1 p2 with n' < m
... | tt rewrite p2 = 𝔹-contra (trans (sym (<-irrefl n')) p1)
... | ff = p2
min-suc : ∀ (n m : ℕ) → min (suc n) (suc m) ≡ suc (min n m)
min-suc n m rewrite (ite-arg suc (n < m) n m) = refl
max-suc : ∀ (n m : ℕ) → max (suc n) (suc m) ≡ suc (max n m)
max-suc n m rewrite (ite-arg suc (n < m) m n) = refl
min-mono1 : ∀ (n n' m : ℕ) → n ≤ n' ≡ tt → min n m ≤ min n' m ≡ tt
min-mono1 n n' m p with ||-split{n < n'} p
... | inj₂ p' rewrite =ℕ-to-≡ {n} p' | =ℕ-refl (min n' m) | ||-tt ((min n' m) < (min n' m)) = refl
... | inj₁ p' with ℕ-trichotomy n' m
... | inj₁ p'' rewrite <-trans {n} p' p'' | p'' | p' = refl
... | inj₂ (inj₁ p'') rewrite =ℕ-to-≡ {n'} p'' | p' | =ℕ-refl (min n m) | ||-tt ((min n m) < (min n m)) | <-irrefl m | p' = refl
... | inj₂ (inj₂ p'') rewrite <-asym {m} p'' with ℕ-trichotomy n m
... | inj₁ p''' rewrite p''' | p''' = refl
... | inj₂ (inj₁ p''') rewrite =ℕ-to-≡ {n} p''' | <-irrefl m | =ℕ-refl m | ||-tt (m < m) = refl
... | inj₂ (inj₂ p''') rewrite <-asym {m} p''' | =ℕ-refl m | ||-tt (m < m) = refl
min-comm : ∀ (n m : ℕ) → min n m ≡ min m n
min-comm n m with ℕ-trichotomy n m
... | inj₁ p rewrite p | <-asym {n} p = refl
... | inj₂ (inj₁ p) rewrite =ℕ-to-≡ {n} p = refl
... | inj₂ (inj₂ p) rewrite p | <-asym {m} p = refl
min-mono2 : ∀ (n m m' : ℕ) → m ≤ m' ≡ tt → min n m ≤ min n m' ≡ tt
min-mono2 n m m' p rewrite min-comm n m | min-comm n m' = min-mono1 m m' n p
min-same : ∀ (n : ℕ) → min n n ≡ n
min-same n rewrite <-irrefl n = refl
min-<1 : ∀ {n m : ℕ} → min n m ≤ m ≡ tt
min-<1{0}{0} = refl
min-<1{0}{suc m} = refl
min-<1{suc n}{0} = refl
min-<1{suc n}{suc m} rewrite min-suc n m = min-<1{n}
min-<2 : ∀ {n m : ℕ} → min n m ≤ n ≡ tt
min-<2{0}{0} = refl
min-<2{0}{suc m} = refl
min-<2{suc n}{0} = refl
min-<2{suc n}{suc m} rewrite min-suc n m = min-<2{n}
max-<1 : ∀ {n m : ℕ} → n ≤ max n m ≡ tt
max-<1{0}{0} = refl
max-<1{0}{suc m} = refl
max-<1{suc n}{0} rewrite =ℕ-refl n | ||-tt (n < n) = refl
max-<1{suc n}{suc m} rewrite max-suc n m = max-<1{n}
max-<2 : ∀ {n m : ℕ} → n ≤ max n m ≡ tt
max-<2{0}{0} = refl
max-<2{0}{suc m} = refl
max-<2{suc n}{0} rewrite =ℕ-refl n | ||-tt (n < n) = refl
max-<2{suc n}{suc m} rewrite max-suc n m = max-<2{n}
--------------------------------------------------
-- some disequalities
--------------------------------------------------
+≢ : ∀ (x y : ℕ) → x ≢ x + suc y
+≢ 0 y ()
+≢ (suc x) y p with =ℕ-from-≡ {suc x} p
... | q with =ℕ-to-≡ {x} q
... | r = +≢ x y r
--------------------------------------------------
-- properties of parity
--------------------------------------------------
parity-even : ∀ (x : ℕ) → parity (x * 2) ≡ ff
parity-even 0 = refl
parity-even (suc x) rewrite parity-even x = refl
parity-even2 : ∀ (x : ℕ) → parity (2 * x) ≡ ff
parity-even2 x rewrite *comm 2 x = parity-even x
parity-odd : ∀ (x : ℕ) → parity (x * 2 + 1) ≡ tt
parity-odd 0 = refl
parity-odd (suc x) rewrite parity-odd x = refl
parity-add : ∀ (x y : ℕ) → parity (x + y) ≡ (parity x) xor (parity y)
parity-add 0 y rewrite ff-xor (parity y) = refl
parity-add (suc x) y rewrite parity-add x y | ~-xor-distrb (parity x) (parity y) = refl
parity-mult : ∀ (x y : ℕ) → parity (x * y) ≡ (parity x) && (parity y)
parity-mult 0 y = refl
parity-mult (suc x) y rewrite parity-add y (x * y) | parity-mult x y = xor-distrib-&& (parity y) (parity x)
--------------------------------------------------
-- properties of power
--------------------------------------------------
1-pow : ∀ {n : ℕ} → 1 pow n ≡ 1
1-pow {0} = refl
1-pow {(suc n)} rewrite 1-pow {n} = refl
nonzero-pow : ∀ (x y : ℕ) → x =ℕ 0 ≡ ff → iszero (x pow y) ≡ ff
nonzero-pow x 0 _ = refl
nonzero-pow 0 (suc y) ()
nonzero-pow (suc x) (suc y) p rewrite iszerosum2 (suc x pow y) (x * suc x pow y) (nonzero-pow (suc x) y refl) = refl
pow+ : ∀ (x y z : ℕ) → x pow (y + z) ≡ (x pow y) * (x pow z)
pow+ x 0 z rewrite +0 (x pow z) = refl
pow+ x (suc y) z rewrite pow+ x y z | *assoc x (x pow y) (x pow z) = refl
pow* : ∀ (x y z : ℕ) → x pow (y * z) ≡ (x pow y) pow z
pow* x y 0 rewrite *0 y = refl
pow* x y (suc z) rewrite sym (pow* x y z) | sym (pow+ x y (y * z)) | *comm y (suc z) | *comm y z = refl
--------------------------------------------------
-- properties of factorial
--------------------------------------------------
factorial-nonzero : ∀ (n : ℕ) → iszero (factorial n) ≡ ff
factorial-nonzero zero = refl
factorial-nonzero (suc x) rewrite iszerosum (factorial x) (x * factorial x) | factorial-nonzero x = refl
--------------------------------------------------
-- injectivity properties of addition
--------------------------------------------------
+inj1 : ∀ {x y z : ℕ} → x + y ≡ x + z → y ≡ z
+inj1 {0} {y} {z} p = p
+inj1 {suc x} {y} {z} p = +inj1 {x} {y} {z} (suc-inj p)
+inj2 : ∀ {x y z : ℕ} → x + z ≡ y + z → x ≡ y
+inj2 {x} {y} {z} p rewrite +comm x z | +comm y z = +inj1 {z} {x} {y} p
--------------------------------------------------
-- properties of is-even, is-odd
--------------------------------------------------
even~odd : ∀ (x : ℕ) → is-even x ≡ ~ is-odd x
odd~even : ∀ (x : ℕ) → is-odd x ≡ ~ is-even x
even~odd zero = refl
even~odd (suc x) = odd~even x
odd~even zero = refl
odd~even (suc x) = even~odd x
suc-eq : ∀{x y} → suc x ≡ suc y → x ≡ y
suc-eq refl = refl
suc-eq⊥ : ∀{x y} → ¬ (x ≡ y) → ¬ (suc x ≡ suc y)
suc-eq⊥ p refl = p refl
zero-suc-eq⊥ : ∀{x} → zero ≡ suc x → ⊥ {lzero}
zero-suc-eq⊥ ()
suc-zero-eq⊥ : ∀{x} → suc x ≡ zero → ⊥ {lzero}
suc-zero-eq⊥ ()
| {
"alphanum_fraction": 0.4408203034,
"avg_line_length": 33.8351648352,
"ext": "agda",
"hexsha": "3782a7c2e42c5b3c698afcc4a13288e7f194a51b",
"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": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "nat-thms.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"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": "heades/AUGL",
"max_issues_repo_path": "nat-thms.agda",
"max_line_length": 179,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "nat-thms.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 10156,
"size": 21553
} |
module _ where
module M (X : Set) where
postulate
F : Set
G : Set
data ⊥ : Set where
open M ⊥ hiding (F)
easy : M.G ⊥
easy = {!!} -- G
hard : M.F ⊥
hard = {!!} -- M.F ⊥ (and not .Issue1640._.F)
data ⊤ : Set where
tt : ⊤
module With where
private
F : ⊤ → Set
F x with x
F _ | tt = ⊥
T = F
tricky : ∀ t → With.T t
tricky t = {!!} -- .Issue1640.With.F t | t
| {
"alphanum_fraction": 0.4962406015,
"avg_line_length": 12.46875,
"ext": "agda",
"hexsha": "39e81b9cbc22ca8bee876244b1bfab9f9f1cc67a",
"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/Issue1640.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/Issue1640.agda",
"max_line_length": 48,
"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/Issue1640.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": 162,
"size": 399
} |
{-# OPTIONS --rewriting --confluence-check #-}
open import Agda.Builtin.Nat using (Nat; zero; suc)
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
variable
k l m n : Nat
postulate
max : Nat → Nat → Nat
max-0l : max 0 n ≡ n
max-0r : max m 0 ≡ m
max-diag : max m m ≡ m
max-ss : max (suc m) (suc n) ≡ suc (max m n)
max-assoc : max (max k l) m ≡ max k (max l m)
{-# REWRITE max-0l #-}
{-# REWRITE max-0r #-}
{-# REWRITE max-diag #-}
{-# REWRITE max-ss #-}
{-# REWRITE max-assoc #-} -- not confluent!
| {
"alphanum_fraction": 0.6132596685,
"avg_line_length": 22.625,
"ext": "agda",
"hexsha": "cbf49c5c36f0507d252af84a749fe41c44e119a5",
"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/RewritingNonConfluent1.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/RewritingNonConfluent1.agda",
"max_line_length": 51,
"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/RewritingNonConfluent1.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": 198,
"size": 543
} |
module bstd.bake where
open import Agda.Builtin.Nat
open import Agda.Builtin.String
open import Data.Word8.Primitive
open import Data.ByteString.Primitive.Strict
open import Data.Tuple.Base
module bpace
(Scalar : Set)
(Point : Set)
(scalarMul : Scalar → Point → Point)
(2ᴸ : Set)
(Key : Set)
(enc dec : Key → 2ᴸ → 2ᴸ)
(swu : 2ᴸ → 2ᴸ → Point)
(Hello : Set)
(I : Set) (i₀ i₁ : I)
(kdf : (K Vᵃ Vᵇ : Point) (helloᵃ helloᵇ : Hello) → I → Key)
(Tag : Set)
(mac : Key → I → Tag)
where
s₂ : (K₂ : Key)
→ (Rᵇ : 2ᴸ)
→ 2ᴸ
s₂ K₂ Rᵇ = Yᵇ where
Yᵇ = enc K₂ Rᵇ
s₃ : (K₂ : Key)
→ (Rᵃ : 2ᴸ) → (uᵃ : Scalar)
→ (Yᵇ : 2ᴸ)
→ 2ᴸ ∥ Point
s₃ K₂ Rᵃ uᵃ Yᵇ = Yᵃ , Vᵃ where
Rᵇ = dec K₂ Yᵇ
Yᵃ = enc K₂ Rᵃ
W = swu Rᵃ Rᵇ
Vᵃ = scalarMul uᵃ W
s₄ : (K₂ : Key)
→ (Rᵇ : 2ᴸ) → (uᵇ : Scalar) → (helloᵇ : Hello)
→ (Yᵃ : 2ᴸ) → (Vᵃ : Point) → (helloᵃ : Hello)
→ Point ∥ Tag
s₄ K₂ Rᵇ uᵇ helloᵇ Yᵃ Vᵃ helloᵃ = Vᵇ , Tᵇ where
Rᵃ = dec K₂ Yᵃ
W = swu Rᵃ Rᵇ
Vᵇ = scalarMul uᵇ W
K = scalarMul uᵇ Vᵃ
K₀ = kdf K Vᵃ Vᵇ helloᵃ helloᵇ i₀
K₁ = kdf K Vᵃ Vᵇ helloᵃ helloᵇ i₁
Tᵇ = mac K₁ i₁
s₅ : (Vᵇ : Point) → (helloᵇ : Hello)
→ (uᵃ : Scalar) → (Vᵃ : Point) → (helloᵃ : Hello)
→ Tag
s₅ Vᵇ helloᵇ uᵃ Vᵃ helloᵃ = Tᵃ where
K = scalarMul uᵃ Vᵇ
K₀ = kdf K Vᵃ Vᵇ helloᵃ helloᵇ i₀
K₁ = kdf K Vᵃ Vᵇ helloᵃ helloᵇ i₁
Tᵃ = mac K₁ i₀
| {
"alphanum_fraction": 0.5550070522,
"avg_line_length": 23.2459016393,
"ext": "agda",
"hexsha": "4602983066cfd30e87682d889351c285c223842e",
"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": "fe95ba440099f9cf086096469133576a9652c122",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/bstd",
"max_forks_repo_path": "src/bstd/bake.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fe95ba440099f9cf086096469133576a9652c122",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "semenov-vladyslav/bstd",
"max_issues_repo_path": "src/bstd/bake.agda",
"max_line_length": 61,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "fe95ba440099f9cf086096469133576a9652c122",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/bstd",
"max_stars_repo_path": "src/bstd/bake.agda",
"max_stars_repo_stars_event_max_datetime": "2019-06-29T10:40:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-29T10:40:15.000Z",
"num_tokens": 815,
"size": 1418
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Pretty Printing
-- This module is based on Jean-Philippe Bernardy's functional pearl
-- "A Pretty But Not Greedy Printer"
------------------------------------------------------------------------
{-# OPTIONS --with-K #-}
open import Data.Nat.Base using (ℕ)
module Text.Pretty (width : ℕ) where
import Level
open import Data.Char.Base using (Char)
open import Data.List.Base
using (List; _∷_; []; [_]; uncons; _++_; map; filter)
open import Data.List.NonEmpty as List⁺ using (foldr₁)
open import Data.Maybe.Base using (maybe′)
open import Data.Product using (uncurry)
open import Data.String.Base using (String; fromList; replicate)
open import Function.Base
open import Category.Monad using (RawMonad)
import Data.List.Categorical as Cat
open RawMonad (Cat.monad {Level.zero})
import Data.Nat.Properties as ℕₚ
open import Data.List.Extrema.Core ℕₚ.≤-totalOrder using (⊓ᴸ)
------------------------------------------------------------------------
-- Internal representation of documents and rendering function
import Text.Pretty.Core as Core
Doc = List Core.Block
render : Doc → String
render = Core.render
∘ maybe′ (foldr₁ (⊓ᴸ Core.Block.height) ∘′ uncurry List⁺._∷_) Core.empty
∘ uncons
------------------------------------------------------------------------
-- Basic building blocks
fail : Doc
fail = []
text : String → Doc
text = filter (Core.valid width) ∘ pure ∘ Core.text
empty : Doc
empty = text ""
char : Char → Doc
char c = text (fromList (c ∷ []))
spaces : ℕ → Doc
spaces n = text (replicate n ' ')
semi colon comma space dot : Doc
semi = char ';'; colon = char ':'
comma = char ','; space = char ' '; dot = char '.'
backslash forwardslash equal : Doc
backslash = char '\\'; forwardslash = char '/'; equal = char '='
squote dquote : Doc
squote = char '\''; dquote = char '"'
lparen rparen langle rangle : Doc
lparen = char '('; rparen = char ')'
langle = char '<'; rangle = char '>'
lbrace rbrace llbrace rrbrace : Doc
lbrace = char '{'; rbrace = char '}'
llbrace = char '⦃'; rrbrace = char '⦄'
lbracket rbracket llbracket rrbracket : Doc
lbracket = char '['; rbracket = char ']'
llbracket = char '⟦'; rrbracket = char '⟧'
------------------------------------------------------------------------
-- Combining two documents
infixr 5 _<>_
_<>_ : Doc → Doc → Doc
xs <> ys = filter (Core.valid width) (Core._<>_ <$> xs ⊛ ys)
flush : Doc → Doc
flush = map Core.flush
infixr 5 _<+>_
_<+>_ : Doc → Doc → Doc
x <+> y = x <> space <> y
infixr 5 _$$_
_$$_ : Doc → Doc → Doc
x $$ y = flush x <> y
infixr 4 _<|>_
_<|>_ : Doc → Doc → Doc
x <|> y = x ++ y
------------------------------------------------------------------------
-- Combining lists of documents
foldDoc : (Doc → Doc → Doc) → List Doc → Doc
foldDoc _ [] = empty
foldDoc _ (x ∷ []) = x
foldDoc f (x ∷ xs) = f x (foldDoc f xs)
hsep vcat : List Doc → Doc
hsep = foldDoc _<+>_
vcat = foldDoc _$$_
sep : List Doc → Doc
sep [] = empty
sep xs = hsep xs <|> vcat xs
------------------------------------------------------------------------
-- Defined combinators
parens : Doc → Doc
parens d = lparen <> d <> rparen
commaSep : List Doc → Doc
commaSep = foldDoc (λ d e → d <> comma <+> e)
newline : Doc
newline = flush empty
| {
"alphanum_fraction": 0.5493293592,
"avg_line_length": 25.2255639098,
"ext": "agda",
"hexsha": "bcdb3f71f7d348b220b27e1c344569dbcfc43ffd",
"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/Text/Pretty.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/Text/Pretty.agda",
"max_line_length": 79,
"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/Text/Pretty.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": 905,
"size": 3355
} |
{-# OPTIONS --safe #-}
module Cubical.Data.NatPlusOne.MoreNats.AssocNat where
open import Cubical.Data.NatPlusOne.MoreNats.AssocNat.Base public
open import Cubical.Data.NatPlusOne.MoreNats.AssocNat.Properties public
| {
"alphanum_fraction": 0.8248847926,
"avg_line_length": 36.1666666667,
"ext": "agda",
"hexsha": "90b08ba6fd40056dca951f61319570511365c23a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat.agda",
"max_line_length": 71,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat.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": 57,
"size": 217
} |
{-# OPTIONS --without-K --safe #-}
open import Algebra.Structures.Bundles.Field
module Algebra.Linear.Construct.Matrix
{k ℓ} (K : Field k ℓ)
where
open import Level using (_⊔_)
open import Data.Product hiding (map)
open import Data.Fin using (Fin; toℕ; fromℕ; _≤_)
open import Data.Fin.Properties using (¬Fin0)
open import Data.Nat hiding (_⊔_; _≤_) renaming (_+_ to _+ℕ_; _*_ to _*ℕ_)
open import Data.Nat.Properties using (1+n≢0)
open import Relation.Binary
import Data.Vec.Relation.Binary.Pointwise.Inductive as PW
open import Algebra.Linear.Core
import Data.Vec.Properties as VP
open import Algebra.Structures.Field.Utils K
import Algebra.Linear.Construct.Vector K as V
open V
using (Vec; zipWith; replicate)
renaming
( _+_ to _+v_
; _∙_ to _∙v_
; -_ to -v_
)
open import Relation.Binary.PropositionalEquality as P
using (_≡_; subst; subst-subst-sym; _≗_)
renaming
( refl to ≡-refl
; sym to ≡-sym
; trans to ≡-trans
)
import Algebra.Linear.Structures.VectorSpace as VS
open VS.VectorSpaceField K
open import Data.Nat.Properties
using
( ≤-refl
; ≤-reflexive
; ≤-antisym
; n∸n≡0
; m+[n∸m]≡n
; m≤m+n
; suc-injective
)
renaming
( +-identityˡ to +ℕ-identityˡ
; +-identityʳ to +ℕ-identityʳ
)
Matrix : ℕ -> ℕ -> Set k
Matrix n p = Vec (Vec K' p) n
private
M : ℕ -> ℕ -> Set k
M = Matrix
_≈ʰ_ : ∀ {n p n' p'} (A : M n p) (B : M n' p') → Set (k ⊔ ℓ)
_≈ʰ_ = PW.Pointwise V._≈ʰ_
module _ {n p} where
setoid : Setoid k (k ⊔ ℓ)
setoid = record
{ Carrier = M n p
; _≈_ = _≈ʰ_ {n} {p}
; isEquivalence = PW.isEquivalence (V.≈-isEquiv {p}) n
}
open Setoid setoid public
renaming
( refl to ≈-refl
; sym to ≈-sym
; trans to ≈-trans
; reflexive to ≈-reflexive
; isEquivalence to ≈-isEquiv
)
import Algebra.FunctionProperties as FP
tabulate : ∀ {n p} -> (Fin n -> Fin p -> K') -> M n p
tabulate f = V.tabulate λ i -> V.tabulate λ j -> f i j
tabulate⁺ : ∀ {n p} {f g : Fin n -> Fin p -> K'}
-> (∀ i j -> f i j ≈ᵏ g i j)
-> tabulate f ≈ tabulate g
tabulate⁺ {0} r = PW.[]
tabulate⁺ {suc n} {p} {f} {g} r =
(PW.tabulate⁺ (r Fin.zero)) PW.∷ tabulate⁺ {n} {p} λ i j → r (Fin.suc i) j
fromVec : ∀ {n p} -> V.Vec K' (n *ℕ p) -> M n p
fromVec {0} V.[] = V.[]
fromVec {suc n} {p} xs =
let (vp , vnp , _) = V.splitAt p xs
in vp V.∷ fromVec {n} vnp
toVec : ∀ {n p} -> M n p -> V.Vec K' (n *ℕ p)
toVec {n} {p} = V.concat {m = p} {n = n}
concat∘fromVec : ∀ {n p} (v : V.Vec K' (n *ℕ p)) -> toVec {n} {p} (fromVec v) V.≈ v
concat∘fromVec {0} V.[] = PW.[]
concat∘fromVec {suc n} {p} v =
let (vn , vnp , r) = V.splitAt p v
in begin
toVec {suc n} {p} (fromVec v)
≡⟨⟩
vn V.++ toVec {n} {p} (fromVec vnp)
≈⟨ V.++-cong {p} {n *ℕ p} V.≈-refl (concat∘fromVec {n} {p} vnp) ⟩
vn V.++ vnp
≈⟨ V.≈-sym (V.≈-reflexive r) ⟩
v
∎
where open import Relation.Binary.EqReasoning (V.setoid (suc n *ℕ p))
_++_ : ∀ {n p q} -> M n p -> M n q -> M n (p +ℕ q)
_++_ = zipWith V._++_
_‡_ : ∀ {n m p} -> M n p -> M m p -> M (n +ℕ m) p
_‡_ = V._++_
lookup : ∀ {n p} -> M n p -> Fin n -> Fin p -> K'
lookup A i j = V.lookup (V.lookup A i) j
_⟪_,_⟫ : ∀ {n p} -> M n p -> Fin n -> Fin p -> K'
_⟪_,_⟫ = lookup
lookup-cong : ∀ {n p} {A B : M n p} (i : Fin n) (j : Fin p) -> A ≈ B -> (A ⟪ i , j ⟫) ≈ᵏ (B ⟪ i , j ⟫)
lookup-cong i j rs = PW.lookup (PW.lookup rs i) j
tabulate∘lookup : ∀ {n p} (A : M n p) → tabulate (lookup A) ≡ A
tabulate∘lookup A =
begin
tabulate (lookup A)
≡⟨⟩
V.tabulate (λ i -> V.tabulate λ j -> V.lookup (V.lookup A i) j)
≡⟨ VP.tabulate-cong (λ i → VP.tabulate∘lookup (V.lookup A i)) ⟩
V.tabulate (λ i -> V.lookup A i)
≡⟨ VP.tabulate∘lookup A ⟩
A
∎
where open import Relation.Binary.PropositionalEquality as Eq
open Eq.≡-Reasoning
lookup∘tabulate : ∀ {n p} (f : Fin n -> Fin p -> K') (i : Fin n) (j : Fin p)
-> lookup (tabulate f) i j ≡ f i j
lookup∘tabulate {suc n} f i j =
begin
lookup (tabulate f) i j
≡⟨⟩
V.lookup (V.lookup (V.tabulate λ i′ -> V.tabulate λ j′ -> f i′ j′) i) j
≡⟨ cong (λ u → V.lookup u j) (VP.lookup∘tabulate (λ i′ -> V.tabulate λ j′ -> f i′ j′) i) ⟩
V.lookup (V.tabulate λ j′ -> f i j′) j
≡⟨ VP.lookup∘tabulate (λ j′ -> f i j′) j ⟩
f i j
∎
where open import Relation.Binary.PropositionalEquality as Eq
open Eq.≡-Reasoning
tabulate-cong-≡ : ∀ {n p} {f g : Fin n -> Fin p -> K'} -> (∀ i j -> f i j ≡ g i j) -> tabulate f ≡ tabulate g
tabulate-cong-≡ {f = f} {g = g} r = VP.tabulate-cong (λ i → VP.tabulate-cong (λ j → r i j))
tabulate-cong : ∀ {n p} {f g : Fin n -> Fin p -> K'} -> (∀ i j -> f i j ≈ᵏ g i j) -> tabulate f ≈ tabulate g
tabulate-cong {f = f} {g = g} r = PW.tabulate⁺ (λ i → V.tabulate-cong (λ j → r i j))
transpose : ∀ {n p} -> M n p -> M p n
transpose A = tabulate λ i j -> A ⟪ j , i ⟫
_ᵀ : ∀ {n p} -> M n p -> M p n
_ᵀ = transpose
transpose-involutive : ∀ {n p} (A : M n p) -> ((A ᵀ) ᵀ) ≡ A
transpose-involutive A =
begin
((A ᵀ)ᵀ)
≡⟨⟩
(tabulate λ i j -> (tabulate λ i′ j′ -> A ⟪ j′ , i′ ⟫) ⟪ j , i ⟫)
≡⟨ tabulate-cong-≡ (λ i j → lookup∘tabulate (λ i′ j′ -> A ⟪ j′ , i′ ⟫) j i) ⟩
(tabulate λ i j -> A ⟪ i , j ⟫)
≡⟨ tabulate∘lookup A ⟩
A
∎
where open import Relation.Binary.PropositionalEquality as Eq
open Eq.≡-Reasoning
map : ∀ {n p} -> (K' -> K') -> M n p -> M n p
map f = V.map (V.map f)
mapRows : ∀ {n p q} -> (V.Vec K' p -> V.Vec K' q) -> M n p -> M n q
mapRows = V.map
mapCols : ∀ {n m p} -> (V.Vec K' n -> V.Vec K' m) -> M n p -> M m p
mapCols f A = (V.map f (A ᵀ)) ᵀ
map-cong : ∀ {n p} {f g : K' -> K'} -> f ≗ g -> map {n} {p} f ≗ map g
map-cong r = VP.map-cong (VP.map-cong r)
mapRows-cong : ∀ {n p q} {f g : V.Vec K' p -> V.Vec K' q}
-> f ≗ g -> mapRows {n} f ≗ mapRows g
mapRows-cong = VP.map-cong
mapCols-cong : ∀ {n m p} {f g : V.Vec K' n -> V.Vec K' m}
-> f ≗ g -> mapCols {n} {m} {p} f ≗ mapCols g
mapCols-cong r A = P.cong transpose (VP.map-cong r (transpose A))
open import Data.Nat.DivMod
_+_ : ∀ {n p} -> FP.Op₂ (M n p)
_+_ = zipWith V._+_
_∙_ : ∀ {n p} -> ScalarMultiplication K' (M n p)
_∙_ k = V.map (k V.∙_)
-_ : ∀ {n p} -> FP.Op₁ (M n p)
-_ = V.map V.-_
0# : ∀ {n p} -> M n p
0# = replicate V.0#
+-cong : ∀ {n p} {A B C D : M n p} -> A ≈ B -> C ≈ D -> (A + C) ≈ (B + D)
+-cong PW.[] PW.[] = PW.[]
+-cong (r₁ PW.∷ rs₁) (r₂ PW.∷ rs₂) = V.+-cong r₁ r₂ PW.∷ +-cong rs₁ rs₂
+-assoc : ∀ {n p} (A B C : M n p) -> ((A + B) + C) ≈ (A + (B + C))
+-assoc V.[] V.[] V.[] = PW.[]
+-assoc (u V.∷ us) (v V.∷ vs) (w V.∷ ws) =
V.+-assoc u v w PW.∷ +-assoc us vs ws
+-identityˡ : ∀ {n p} (A : M n p) -> (0# + A) ≈ A
+-identityˡ V.[] = PW.[]
+-identityˡ (u V.∷ us) = V.+-identityˡ u PW.∷ +-identityˡ us
+-identityʳ : ∀ {n p} (A : M n p) -> (A + 0#) ≈ A
+-identityʳ V.[] = PW.[]
+-identityʳ (u V.∷ us) = V.+-identityʳ u PW.∷ +-identityʳ us
+-identity : ∀ {n p} -> ((∀ (A : M n p) -> ((0# + A) ≈ A)) × (∀ (A : M n p) -> ((A + 0#) ≈ A)))
+-identity = +-identityˡ , +-identityʳ
+-comm : ∀ {n p} (A B : M n p) -> (A + B) ≈ (B + A)
+-comm V.[] V.[] = PW.[]
+-comm (u V.∷ us) (v V.∷ vs) = (V.+-comm u v) PW.∷ (+-comm us vs)
*ᵏ-∙-compat : ∀ {n p} (a b : K') (A : M n p) -> ((a *ᵏ b) ∙ A) ≈ (a ∙ (b ∙ A))
*ᵏ-∙-compat a b V.[] = PW.[]
*ᵏ-∙-compat a b (u V.∷ us) = (V.*ᵏ-∙-compat a b u) PW.∷ (*ᵏ-∙-compat a b us)
∙-+-distrib : ∀ {n p} (a : K') (A B : M n p) -> (a ∙ (A + B)) ≈ ((a ∙ A) + (a ∙ B))
∙-+-distrib a V.[] V.[] = PW.[]
∙-+-distrib a (u V.∷ us) (v V.∷ vs) = (V.∙-+-distrib a u v) PW.∷ (∙-+-distrib a us vs)
∙-+ᵏ-distrib : ∀ {n p} (a b : K') (A : M n p) -> ((a +ᵏ b) ∙ A) ≈ ((a ∙ A) + (b ∙ A))
∙-+ᵏ-distrib a b V.[] = PW.[]
∙-+ᵏ-distrib a b (u V.∷ us) = (V.∙-+ᵏ-distrib a b u) PW.∷ (∙-+ᵏ-distrib a b us)
∙-cong : ∀ {n p} {a b : K'} {A B : M n p} → a ≈ᵏ b -> A ≈ B -> (a ∙ A) ≈ (b ∙ B)
∙-cong rᵏ PW.[] = PW.[]
∙-cong rᵏ (r PW.∷ rs) = (V.∙-cong rᵏ r) PW.∷ (∙-cong rᵏ rs)
∙-identity : ∀ {n p} (A : M n p) → (1ᵏ ∙ A) ≈ A
∙-identity V.[] = PW.[]
∙-identity (u V.∷ us) = (V.∙-identity u) PW.∷ (∙-identity us)
∙-absorbˡ : ∀ {n p} (A : M n p) → (0ᵏ ∙ A) ≈ 0#
∙-absorbˡ V.[] = PW.[]
∙-absorbˡ (u V.∷ us) = (V.∙-absorbˡ u) PW.∷ (∙-absorbˡ us)
-‿inverseˡ : ∀ {n p} (A : M n p) -> ((- A) + A) ≈ 0#
-‿inverseˡ V.[] = PW.[]
-‿inverseˡ (u V.∷ us) = (V.-‿inverseˡ u) PW.∷ (-‿inverseˡ us)
-‿inverseʳ : ∀ {n p} (A : M n p) -> (A + (- A)) ≈ 0#
-‿inverseʳ V.[] = PW.[]
-‿inverseʳ (u V.∷ us) = (V.-‿inverseʳ u) PW.∷ (-‿inverseʳ us)
-‿inverse : ∀ {n p} → (∀ (A : M n p) -> ((- A) + A) ≈ 0#) × (∀ (A : M n p) -> (A + (- A)) ≈ 0#)
-‿inverse = -‿inverseˡ , -‿inverseʳ
-‿cong : ∀ {n p} {A B : M n p} -> A ≈ B -> (- A) ≈ (- B)
-‿cong PW.[] = PW.[]
-‿cong (r PW.∷ rs) = (V.-‿cong r) PW.∷ (-‿cong rs)
concat-+ : ∀ {n p} (A B : M n p) -> V.concat (V.zipWith V._+_ A B) V.≈ (V.concat A) +v (V.concat B)
concat-+ {0} {p} V.[] V.[] =
V.≈-trans (PW.concat⁺ {m = p} {p = 0} PW.[]) (V.≈-sym (V.+-identityˡ V.[]))
concat-+ {suc n} {p} (u V.∷ us) (v V.∷ vs) =
begin
V.concat (V.zipWith V._+_ (u V.∷ us) (v V.∷ vs))
≡⟨⟩
(u V.+ v) V.++ V.concat (V.zipWith V._+_ us vs)
≈⟨ V.++-cong V.≈-refl (concat-+ {n} {p} us vs) ⟩
(u V.+ v) V.++ (V.concat us V.+ V.concat vs)
≈⟨ V.≈-sym (V.+-++-distrib u (V.concat us) v (V.concat vs)) ⟩
(V.concat (u V.∷ us)) V.+ (V.concat (v V.∷ vs))
∎
where open import Relation.Binary.EqReasoning (V.setoid (p +ℕ n *ℕ p))
concat-0# : ∀ {n p} -> V.concat (0# {n} {p}) V.≈ (V.0# {n *ℕ p})
concat-0# {0} = PW.[]
concat-0# {suc n} {p} =
begin
V.concat (0# {suc n} {p})
≡⟨⟩
V.0# {p} V.++ V.concat (0# {n} {p})
≈⟨ PW.++⁺ V.≈-refl (concat-0# {n} {p}) ⟩
V.0# {p} V.++ V.0# {n *ℕ p}
≈⟨ V.0++0≈0 {p} {n *ℕ p} ⟩
V.0# {p +ℕ n *ℕ p}
∎
where open import Relation.Binary.EqReasoning (V.setoid (p +ℕ n *ℕ p))
concat-∙ : ∀ {n p} (c : K') (A : M n p) -> V.concat (c ∙ A) V.≈ (c V.∙ V.concat A)
concat-∙ {0} c V.[] = PW.[]
concat-∙ {suc n} {p} c (u V.∷ us) =
begin
V.concat ((c V.∙ u) V.∷ (c ∙ us))
≡⟨⟩
(c V.∙ u) V.++ (V.concat (c ∙ us))
≈⟨ V.++-cong V.≈-refl (concat-∙ {n} {p} c us) ⟩
(c V.∙ u) V.++ (c V.∙ V.concat us)
≈⟨ V.≈-sym (V.∙-++-distrib c u (V.concat us)) ⟩
c V.∙ V.concat (u V.∷ us)
∎
where open import Relation.Binary.EqReasoning (V.setoid (p +ℕ n *ℕ p))
I : ∀ {n p} -> M n p
I = tabulate δ
_*_ : ∀ {n p q} -> M n p -> M p q -> M n q
A * B = tabulate λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (B ⟪ k , j ⟫)
*-cong : ∀ {n p q} {A B : M n p} {C D : M p q}
-> A ≈ B -> C ≈ D -> (A * C) ≈ (B * D)
*-cong {n} {q = q} {A} {B} {C} {D} r₁ r₂ =
begin
A * C
≡⟨⟩
tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (C ⟪ k , j ⟫))
≈⟨ tabulate⁺ (λ i j -> V.sum-tab-cong λ k → *ᵏ-cong (lookup-cong i k r₁) (lookup-cong k j r₂)) ⟩
B * D
∎
where open import Relation.Binary.EqReasoning (setoid {n} {q})
*-assoc : ∀ {n p q r} (A : M n p) (B : M p q) (C : M q r)
-> ((A * B) * C) ≈ (A * (B * C))
*-assoc {n} {r = r} A B C = tabulate⁺ λ i j ->
begin
V.sum-tab (λ k′ -> ((A * B) ⟪ i , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫))
≈⟨ V.sum-tab-cong (λ k′ -> *ᵏ-cong (≈ᵏ-reflexive (lookup∘tabulate
(λ i′ j′ -> V.sum-tab λ k -> (A ⟪ i′ , k ⟫) *ᵏ (B ⟪ k , j′ ⟫)) i k′)) ≈ᵏ-refl) ⟩
V.sum-tab (λ k′ -> (V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (B ⟪ k , k′ ⟫)) *ᵏ (C ⟪ k′ , j ⟫))
≈⟨ V.sum-tab-cong (λ k′ -> V.*ᵏ-sum-tab-distribʳ (C ⟪ k′ , j ⟫) λ k -> (A ⟪ i , k ⟫) *ᵏ (B ⟪ k , k′ ⟫)) ⟩
V.sum-tab (λ k′ -> V.sum-tab λ k -> ((A ⟪ i , k ⟫) *ᵏ (B ⟪ k , k′ ⟫)) *ᵏ (C ⟪ k′ , j ⟫))
≈⟨ V.sum-tab-cong (λ k′ -> V.sum-tab-cong λ k -> *ᵏ-assoc (A ⟪ i , k ⟫) (B ⟪ k , k′ ⟫) (C ⟪ k′ , j ⟫)) ⟩
V.sum-tab (λ k′ -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)))
≈⟨ V.sum-tab-cong (λ k′ -> V.sum-tab-cong λ k -> *ᵏ-comm (A ⟪ i , k ⟫) ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫))) ⟩
V.sum-tab (λ k′ -> V.sum-tab λ k -> ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) *ᵏ (A ⟪ i , k ⟫))
≈⟨ V.sum-tab-swap (λ k k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) (λ k -> A ⟪ i , k ⟫) ⟩
V.sum-tab (λ k -> V.sum-tab λ k′ -> ((B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) *ᵏ (A ⟪ i , k ⟫))
≈⟨ V.sum-tab-cong (λ k -> ≈ᵏ-trans
(≈ᵏ-sym (V.*ᵏ-sum-tab-distribʳ (A ⟪ i , k ⟫) λ k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)))
(*ᵏ-comm (V.sum-tab λ k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)) (A ⟪ i , k ⟫))) ⟩
V.sum-tab (λ k -> (A ⟪ i , k ⟫) *ᵏ V.sum-tab (λ k′ -> (B ⟪ k , k′ ⟫) *ᵏ (C ⟪ k′ , j ⟫)))
≈⟨ V.sum-tab-cong (λ k -> *ᵏ-cong ≈ᵏ-refl
(≈ᵏ-sym (≈ᵏ-reflexive (lookup∘tabulate
(λ i′ j′ -> V.sum-tab λ k′ -> (B ⟪ i′ , k′ ⟫) *ᵏ (C ⟪ k′ , j′ ⟫)) k j)))) ⟩
V.sum-tab (λ k -> (A ⟪ i , k ⟫) *ᵏ ((B * C) ⟪ k , j ⟫))
∎
where open import Relation.Binary.EqReasoning (Field.setoid K)
*-identityˡ : ∀ {n p} (A : M n p) -> I * A ≈ A
*-identityˡ {n} {p} A =
begin
I * A
≡⟨⟩
tabulate (λ i j -> V.sum-tab λ k -> (I ⟪ i , k ⟫) *ᵏ (A ⟪ k , j ⟫))
≈⟨ tabulate-cong (λ i j -> V.sum-tab-cong {n} λ k -> *ᵏ-cong (≈ᵏ-reflexive (lookup∘tabulate δ i k)) ≈ᵏ-refl) ⟩
tabulate (λ i j -> V.sum-tab λ k -> δ i k *ᵏ (A ⟪ k , j ⟫))
≈⟨ tabulate-cong (λ i j -> V.sum-tab-δ (λ k -> A ⟪ k , j ⟫) i) ⟩
tabulate (λ i j -> A ⟪ i , j ⟫)
≡⟨ tabulate∘lookup A ⟩
A
∎
where open import Relation.Binary.EqReasoning (setoid {n} {p})
*-identityʳ : ∀ {n p} (A : M n p) -> A * I ≈ A
*-identityʳ {n} {p} A =
begin
A * I
≡⟨⟩
tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ (I ⟪ k , j ⟫))
≈⟨ tabulate-cong (λ i j -> V.sum-tab-cong {p} λ k -> *ᵏ-cong ≈ᵏ-refl (≈ᵏ-reflexive (lookup∘tabulate δ k j))) ⟩
tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ δ k j)
≈⟨ tabulate-cong (λ i j -> V.sum-tab-cong {p} λ k -> *ᵏ-cong ≈ᵏ-refl (δ-comm k j)) ⟩
tabulate (λ i j -> V.sum-tab λ k -> (A ⟪ i , k ⟫) *ᵏ δ j k)
≈⟨ tabulate-cong (λ i j -> ≈ᵏ-trans (V.sum-tab-cong {p} (λ k -> *ᵏ-comm ((A ⟪ i , k ⟫)) (δ j k)))
(V.sum-tab-δ (λ k -> A ⟪ i , k ⟫) j)) ⟩
tabulate (λ i j -> A ⟪ i , j ⟫)
≡⟨ tabulate∘lookup A ⟩
A
∎
where open import Relation.Binary.EqReasoning (setoid {n} {p})
module _ {n p} where
open IsEquivalence (≈-isEquiv {n} {p}) public
using ()
renaming
( refl to ≈-refl
; sym to ≈-sym
; trans to ≈-trans
)
open FP (_≈_ {n} {p})
open import Algebra.Structures (_≈_ {n} {p})
open import Algebra.Linear.Structures.Bundles
isMagma : IsMagma _+_
isMagma = record
{ isEquivalence = ≈-isEquiv
; ∙-cong = +-cong
}
isSemigroup : IsSemigroup _+_
isSemigroup = record
{ isMagma = isMagma
; assoc = +-assoc
}
isMonoid : IsMonoid _+_ 0#
isMonoid = record
{ isSemigroup = isSemigroup
; identity = +-identity
}
isGroup : IsGroup _+_ 0# -_
isGroup = record
{ isMonoid = isMonoid
; inverse = -‿inverse
; ⁻¹-cong = -‿cong
}
isAbelianGroup : IsAbelianGroup _+_ 0# -_
isAbelianGroup = record
{ isGroup = isGroup
; comm = +-comm
}
open VS K
isVectorSpace : VS.IsVectorSpace K (_≈_ {n}) _+_ _∙_ -_ 0#
isVectorSpace = record
{ isAbelianGroup = isAbelianGroup
; *ᵏ-∙-compat = *ᵏ-∙-compat
; ∙-+-distrib = ∙-+-distrib
; ∙-+ᵏ-distrib = ∙-+ᵏ-distrib
; ∙-cong = ∙-cong
; ∙-identity = ∙-identity
; ∙-absorbˡ = ∙-absorbˡ
}
vectorSpace : VectorSpace K k (k ⊔ ℓ)
vectorSpace = record { isVectorSpace = isVectorSpace }
open import Algebra.Linear.Structures.FiniteDimensional K
open import Algebra.Linear.Morphism.VectorSpace K
open import Algebra.Linear.Morphism.Bundles K
open import Algebra.Morphism.Definitions (M n p) (Vec K' (n *ℕ p)) V._≈_
open import Algebra.Linear.Morphism.Definitions K (M n p) (Vec K' (n *ℕ p)) V._≈_
import Relation.Binary.Morphism.Definitions (M n p) (Vec K' (n *ℕ p)) as R
open import Function
open import Relation.Binary.EqReasoning (V.setoid (n *ℕ p))
⟦_⟧ : M n p -> Vec K' (n *ℕ p)
⟦_⟧ = V.concat
⟦⟧-cong : R.Homomorphic₂ _≈_ (V._≈_ {n *ℕ p}) ⟦_⟧
⟦⟧-cong = PW.concat⁺
+-homo : Homomorphic₂ ⟦_⟧ _+_ _+v_
+-homo = concat-+
0#-homo : Homomorphic₀ ⟦_⟧ 0# V.0#
0#-homo = concat-0# {n} {p}
∙-homo : ScalarHomomorphism ⟦_⟧ _∙_ _∙v_
∙-homo = concat-∙
⟦⟧-injective : Injective (_≈_ {n} {p}) (V._≈_ {n *ℕ p}) ⟦_⟧
⟦⟧-injective {A} {B} r = PW.concat⁻ A B r
⟦⟧-surjective : Surjective (_≈_ {n} {p}) (V._≈_ {n *ℕ p}) ⟦_⟧
⟦⟧-surjective v = fromVec {n} {p} v , concat∘fromVec {n} {p} v
embed : LinearIsomorphism vectorSpace (V.vectorSpace {n *ℕ p})
embed = record
{ ⟦_⟧ = ⟦_⟧
; isLinearIsomorphism = record
{ isLinearMonomorphism = record
{ isLinearMap = record
{ isAbelianGroupMorphism = record
{ gp-homo = record
{ mn-homo = record
{ sm-homo = record
{ ⟦⟧-cong = ⟦⟧-cong
; ∙-homo = +-homo
}
; ε-homo = 0#-homo
}
}
}
; ∙-homo = ∙-homo
}
; injective = ⟦⟧-injective
}
; surjective = ⟦⟧-surjective
}
}
isFiniteDimensional : IsFiniteDimensional _≈_ _+_ _∙_ -_ 0# (n *ℕ p)
isFiniteDimensional = record
{ isVectorSpace = isVectorSpace
; embed = embed
}
| {
"alphanum_fraction": 0.4842244149,
"avg_line_length": 32.7054409006,
"ext": "agda",
"hexsha": "e7a6bd35228317af73d23029c9dd306733529e30",
"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.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.agda",
"max_line_length": 112,
"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.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": 8313,
"size": 17432
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Setoids.Setoids
open import Groups.Definition
open import Groups.Subgroups.Definition
open import Groups.Actions.Definition
open import Sets.EquivalenceRelations
open import Groups.Actions.Definition
module Groups.Actions.Stabiliser {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (act : GroupAction G T) where
open GroupAction act
open Setoid T
stabiliserPred : (x : B) → (g : A) → Set d
stabiliserPred x g = (action g x) ∼ x
stabiliserWellDefined : (x : B) → {g h : A} → Setoid._∼_ S g h → (stabiliserPred x g) → stabiliserPred x h
stabiliserWellDefined x {g} {h} g=h gx=x = transitive (actionWellDefined1 (Equivalence.symmetric (Setoid.eq S) g=h)) gx=x
where
open Equivalence eq
open Setoid T
open Equivalence (Setoid.eq T)
stabiliserSubgroup : (x : B) → Subgroup G (stabiliserPred x)
Subgroup.isSubset (stabiliserSubgroup x) = stabiliserWellDefined x
Subgroup.closedUnderPlus (stabiliserSubgroup x) gx=x hx=x = transitive associativeAction (transitive (actionWellDefined2 hx=x) gx=x)
Subgroup.containsIdentity (stabiliserSubgroup x) = identityAction
Subgroup.closedUnderInverse (stabiliserSubgroup x) {g} gx=x = transitive (transitive (transitive (actionWellDefined2 (symmetric gx=x)) (symmetric associativeAction)) (actionWellDefined1 (invLeft {g}))) identityAction
where
open Group G
| {
"alphanum_fraction": 0.737534626,
"avg_line_length": 43.7575757576,
"ext": "agda",
"hexsha": "50fa96831a26b26807355f2caa8c6a95644fc654",
"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": "Groups/Actions/Stabiliser.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": "Groups/Actions/Stabiliser.agda",
"max_line_length": 216,
"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": "Groups/Actions/Stabiliser.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": 447,
"size": 1444
} |
module TelescopingLet3 where
module Star where
★ : Set₁
★ = Set
★₁ : Set₂
★₁ = Set₁
module MEndo (open Star) (A : ★) where
Endo = A → A
-- at this point, ★ should no longer be in scope
data D3 (open Star using (★₁)) : ★₁ where
c : (A : ★) → D3
-- ★₁ is in scope
-- ★ is not in scope since it was not brought in scope
-- (not included in the using ())
| {
"alphanum_fraction": 0.6059782609,
"avg_line_length": 18.4,
"ext": "agda",
"hexsha": "3bfba5977817264de55eb1b232f73348facba002",
"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/TelescopingLet3.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/TelescopingLet3.agda",
"max_line_length": 54,
"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/TelescopingLet3.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": 130,
"size": 368
} |
variable {A} : Set _
id : A → A
id a = a
test : Set₁
test = id {A = Set₁} Set
| {
"alphanum_fraction": 0.5308641975,
"avg_line_length": 9,
"ext": "agda",
"hexsha": "b5b7bc12a2c05024cbfd8b28dea5dac2563e605b",
"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/Issue3115.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/Issue3115.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/Issue3115.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": 35,
"size": 81
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Category.Monoidal
open import Categories.Category.Monoidal.Closed
module Categories.Category.Monoidal.Closed.IsClosed.Dinatural
{o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (Cl : Closed M) where
open import Data.Product using (Σ; _,_)
open import Function using (_$_) renaming (_∘_ to _∙_)
open import Function.Equality as Π using (Π)
open import Categories.Category.Product
open import Categories.Category.Monoidal.Properties M
open import Categories.Morphism C
open import Categories.Morphism.Properties C
open import Categories.Morphism.Reasoning C
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Bifunctor
open import Categories.Functor.Bifunctor.Properties
open import Categories.NaturalTransformation hiding (id)
open import Categories.NaturalTransformation.Dinatural hiding (_∘ʳ_)
open import Categories.NaturalTransformation.NaturalIsomorphism as NI hiding (refl)
import Categories.Category.Closed as Cls
open Closed Cl
private
open Category C
α⇒ = associator.from
α⇐ = associator.to
module ℱ = Functor
module ⊗ = Functor ⊗
open HomReasoning
open Π.Π
open adjoint renaming (unit to η; counit to ε; Ladjunct to 𝕃; Ladjunct-comm′ to 𝕃-comm′;
Ladjunct-resp-≈ to 𝕃-resp-≈)
open import Categories.Category.Monoidal.Closed.IsClosed.Identity Cl
open import Categories.Category.Monoidal.Closed.IsClosed.L Cl
private
id² : {S T : Obj} → [ S , T ]₀ ⇒ [ S , T ]₀
id² = [ id , id ]₁
L-dinatural-comm : ∀ {X′ Y Z X f} → [ [ f , id ]₁ , id² ]₁ ∘ L X′ Y Z ≈ [ id² , [ f , id ]₁ ]₁ ∘ L X Y Z
L-dinatural-comm {X′} {Y} {Z} {X} {f} = begin
[ fˡ , id² ]₁ ∘ L X′ Y Z ≈⟨ [-,-].F-resp-≈ (refl , [-,-].identity) ⟩∘⟨refl ⟩
[ fˡ , id ]₁ ∘ L X′ Y Z ≈˘⟨ pushˡ [ [-,-] ]-commute ⟩
([ id , 𝕃 L-inner ]₁ ∘ [ fˡ , id ]₁) ∘ η.η YZ ≈˘⟨ pushʳ (mate.commute₁ [ f , id ]₁) ⟩
[ id , 𝕃 L-inner ]₁ ∘ 𝕃 (id ⊗₁ fˡ) ≈˘⟨ pushˡ (ℱ.homomorphism [ XY ,-]) ⟩
𝕃 (𝕃 L-inner ∘ id ⊗₁ fˡ) ≈˘⟨ 𝕃-resp-≈ 𝕃-comm′ ⟩
𝕃 (𝕃 $ L-inner ∘ (id ⊗₁ fˡ) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ push-f-right ⟩
𝕃 (𝕃 $ L-inner ∘ (id ⊗₁ id) ⊗₁ f) ≈⟨ 𝕃-resp-≈ $ pushˡ (ℱ.homomorphism [ X′ ,-]) ⟩
𝕃 ([ id , L-inner {X} ]₁ ∘ 𝕃 ((id ⊗₁ id) ⊗₁ f)) ≈⟨ 𝕃-resp-≈ $ ∘-resp-≈ʳ (∘-resp-≈ˡ (X′-resp-≈ (⊗.F-resp-≈ (⊗.identity , refl))) ○ mate.commute₁ f) ⟩
𝕃 ([ id , L-inner {X} ]₁ ∘ fˡ ∘ η.η (YZ ⊗₀ XY)) ≈⟨ 𝕃-resp-≈ $ pullˡ [ [-,-] ]-commute ○ assoc ⟩
𝕃 (fˡ ∘ 𝕃 L-inner) ≈⟨ ∘-resp-≈ˡ (ℱ.homomorphism [ XY ,-]) ○ assoc ⟩
[ id , fˡ ]₁ ∘ L X Y Z ≈˘⟨ [-,-].F-resp-≈ ([-,-].identity , refl) ⟩∘⟨refl ⟩
[ id² , fˡ ]₁ ∘ L X Y Z ∎
where
fˡ : ∀ {W} → [ X , W ]₀ ⇒ [ X′ , W ]₀
fˡ = [ f , id ]₁
XY = [ X , Y ]₀
YZ = [ Y , Z ]₀
X′-resp-≈ = ℱ.F-resp-≈ [ X′ ,-]
L-inner : ∀ {W} → ([ Y , Z ]₀ ⊗₀ [ W , Y ]₀) ⊗₀ W ⇒ Z
L-inner {W} = ε.η Z ∘ (id ⊗₁ ε.η {W} Y) ∘ α⇒
push-f-right : (ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ∘ (id ⊗₁ fˡ) ⊗₁ id ≈ (ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ∘ (id ⊗₁ id) ⊗₁ f
push-f-right = begin
(ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ∘ (id ⊗₁ fˡ) ⊗₁ id ≈⟨ pull-last assoc-commute-from ⟩
ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ id ⊗₁ fˡ ⊗₁ id ∘ α⇒ ≈˘⟨ refl⟩∘⟨ pushˡ (ℱ.homomorphism (YZ ⊗-)) ⟩
ε.η Z ∘ id ⊗₁ (ε.η Y ∘ fˡ ⊗₁ id) ∘ α⇒ ≈⟨ refl⟩∘⟨ ℱ.F-resp-≈ (YZ ⊗-) (mate.commute₂ f) ⟩∘⟨refl ⟩
ε.η Z ∘ id ⊗₁ (ε.η Y ∘ id ⊗₁ f) ∘ α⇒ ≈⟨ refl⟩∘⟨ ℱ.homomorphism (YZ ⊗-) ⟩∘⟨refl ⟩
ε.η Z ∘ (id ⊗₁ ε.η Y ∘ id ⊗₁ id ⊗₁ f) ∘ α⇒ ≈⟨ center⁻¹ refl (⟺ assoc-commute-from) ○ pullˡ assoc ⟩
(ε.η Z ∘ id ⊗₁ ε.η Y ∘ α⇒) ∘ (id ⊗₁ id) ⊗₁ f ∎
| {
"alphanum_fraction": 0.527173913,
"avg_line_length": 49.5384615385,
"ext": "agda",
"hexsha": "3d0a12e4cd489739dba01e2b6000ad839e13fefe",
"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": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Monoidal/Closed/IsClosed/Dinatural.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"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": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Monoidal/Closed/IsClosed/Dinatural.agda",
"max_line_length": 156,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Monoidal/Closed/IsClosed/Dinatural.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1724,
"size": 3864
} |
-- Andreas, 2016-10-11, AIM XXIV
-- COMPILED pragma accidentially also accepted for abstract definitions
open import Common.String
data Unit : Set where
unit : Unit
{-# COMPILED_DATA Unit () () #-}
postulate
IO : Set → Set
doNothing : IO Unit
{-# COMPILED_TYPE IO IO #-}
{-# BUILTIN IO IO #-}
{-# COMPILED doNothing (return ()) #-}
{-# IMPORT Data.Text.IO #-}
abstract
putStrLn : String → IO Unit
putStrLn _ = doNothing
{-# COMPILED putStrLn Data.Text.IO.putStrLn #-}
main = putStrLn "Hello, world!"
-- WAS: compiler produced ill-formed Haskell-code
-- NOW: Error on COMPILED pragma
| {
"alphanum_fraction": 0.679933665,
"avg_line_length": 19.4516129032,
"ext": "agda",
"hexsha": "eeb3d19d82384a6d8288ce2f9a3ad8aed1f97152",
"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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/Fail/Issue2248.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"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": "pthariensflame/agda",
"max_issues_repo_path": "test/Fail/Issue2248.agda",
"max_line_length": 71,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/Fail/Issue2248.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 157,
"size": 603
} |
postulate
A : Set
data D : Set → Set₁ where
d : (A : Set) → D A
f : Set → (D A → Set) → Set
f A f = f (d A)
-- Expected error:
-- A != A of type Set
-- (because one is a variable and one a defined identifier)
-- when checking that the pattern d A has type D A
| {
"alphanum_fraction": 0.6029962547,
"avg_line_length": 19.0714285714,
"ext": "agda",
"hexsha": "bfd382bb318e1505d1b6d114c8434a7cda9de073",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Fail/Issue998a.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Fail/Issue998a.agda",
"max_line_length": 59,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Fail/Issue998a.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": 89,
"size": 267
} |
module Numeral.Natural.Relation.Order.Existence.Proofs where
import Lvl
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Functional
open import Logic.Propositional
open import Logic.Propositional.Theorems
open import Logic.Predicate
open import Numeral.Natural
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Proofs
open import Numeral.Natural.Induction
open import Numeral.Natural.Relation.Order.Existence
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Function.Domain
open import Structure.Operator
open import Structure.Operator.Properties
import Structure.Relator.Names as Names
open import Structure.Relator.Ordering
open import Structure.Relator.Properties
open import Syntax.Transitivity
open import Type
[≡]-to-[≤] : ∀{x y : ℕ} → (x ≡ y) → (x ≤ y)
[≡]-to-[≤] x≡y = [∃]-intro 0 ⦃ x≡y ⦄
[≤]-minimum : ∀{x : ℕ} → (0 ≤ x)
[≤]-minimum {x} = [∃]-intro x ⦃ identityₗ(_+_)(𝟎) ⦄
[≤][0]ᵣ : ∀{x : ℕ} → (x ≤ 0) ↔ (x ≡ 0)
[≤][0]ᵣ {𝟎} = [↔]-intro [≡]-to-[≤] (const [≡]-intro)
[≤][0]ᵣ {𝐒(n)} = [↔]-intro (\()) (\{([∃]-intro _ ⦃ ⦄ )})
[≤][0]ᵣ-negation : ∀{x : ℕ} → ¬(𝐒(x) ≤ 0)
[≤][0]ᵣ-negation {x} (Sx≤0) = [𝐒]-not-0([↔]-to-[→] ([≤][0]ᵣ {𝐒(x)}) (Sx≤0))
[≤]-successor : ∀{a b : ℕ} → (a ≤ b) → (a ≤ 𝐒(b))
[≤]-successor ([∃]-intro(n) ⦃ proof ⦄) = [∃]-intro (𝐒(n)) ⦃ [≡]-with(𝐒) (proof) ⦄
[≤]-predecessor : ∀{a b : ℕ} → (𝐒(a) ≤ b) → (a ≤ b)
[≤]-predecessor ([∃]-intro n) = [∃]-intro(𝐒(n))
[≤]-without-[𝐒] : ∀{a b : ℕ} → (a ≤ b) ← (𝐒(a) ≤ 𝐒(b))
[≤]-without-[𝐒] {𝟎} {b} (_) = [≤]-minimum
[≤]-without-[𝐒] {𝐒(a)}{𝟎} ()
[≤]-without-[𝐒] {𝐒(a)}{𝐒(b)} ([∃]-intro(n) ⦃ proof ⦄) = [≤]-with-[𝐒] {a}{b} ([≤]-without-[𝐒] {a}{b} ([∃]-intro(n) ⦃ injective(𝐒) proof ⦄))
[≤][𝐒]ₗ : ∀{x : ℕ} → ¬(𝐒(x) ≤ x)
[≤][𝐒]ₗ {𝟎} (1≤0) = [≤][0]ᵣ-negation{0}(1≤0)
[≤][𝐒]ₗ {𝐒(n)} (SSn≤Sn) = [≤][𝐒]ₗ {n} ([≤]-without-[𝐒] {𝐒(n)}{n} (SSn≤Sn))
instance
[≤]-transitivity : Transitivity (_≤_)
Transitivity.proof [≤]-transitivity {a}{b}{c} ([∃]-intro n₁ ⦃ an₁b ⦄) ([∃]-intro n₂ ⦃ bn₂c ⦄) = [∃]-intro (n₁ + n₂) ⦃ p ⦄ where
p =
a + (n₁ + n₂) 🝖[ _≡_ ]-[ associativity(_+_) {a}{n₁}{n₂} ]-sym
(a + n₁) + n₂ 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(n₂) an₁b ]
b + n₂ 🝖[ _≡_ ]-[ bn₂c ]
c 🝖-end
instance
[≤]-reflexivity : Reflexivity (_≤_)
Reflexivity.proof [≤]-reflexivity = [≡]-to-[≤] [≡]-intro
instance
[≤]-antisymmetry : Antisymmetry (_≤_) (_≡_)
Antisymmetry.proof [≤]-antisymmetry {a} {b} ([∃]-intro(n₁) ⦃ an₁b ⦄) ([∃]-intro(n₂) ⦃ bn₂a ⦄) =
a 🝖[ _≡_ ]-[]
a + 𝟎 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(a) n₁0 ]-sym
a + n₁ 🝖[ _≡_ ]-[ an₁b ]
b 🝖-end
where
n₁n₂0 : (n₁ + n₂ ≡ 0)
n₁n₂0 = cancellationₗ(_+_) $
a + (n₁ + n₂) 🝖[ _≡_ ]-[ associativity(_+_) {a}{n₁}{n₂} ]-sym
(a + n₁) + n₂ 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(n₂) an₁b ]
b + n₂ 🝖[ _≡_ ]-[ bn₂a ]
a 🝖[ _≡_ ]-[]
a + 0 🝖-end
n₁0 : (n₁ ≡ 0)
n₁0 = [∧]-elimₗ ([+]-sum-is-0 {n₁} {n₂} n₁n₂0)
instance
[≤]-weakPartialOrder : Weak.PartialOrder (_≤_) (_≡_)
[≤]-weakPartialOrder = record{}
[<]-minimum : ∀{x : ℕ} → (0 < 𝐒(x))
[<]-minimum = [≤]-with-[𝐒] {0} [≤]-minimum
[≥]-is-[≮] : ∀{a b : ℕ} → ¬(a < b) ← (a ≥ b)
[≥]-is-[≮] {a}{b} b≤a Sa≤b = [≤][𝐒]ₗ (transitivity(_≤_) {x = 𝐒(a)}{y = b}{z = a} Sa≤b b≤a)
-- [≤]-is-[≯] : ∀{a b : ℕ} → ¬(a > b) ← (a ≤ b)
-- [≤]-is-[≯] {a}{b} = [≥]-is-[≮] {b}{a}
-- [>]-is-[≰] : ∀{a b : ℕ} → ¬(a ≤ b) ← (a > b)
-- [>]-is-[≰] {a}{b} (Sb≤a) (a≤b) = [≤]-is-[≯] {a}{b} (a≤b) (Sb≤a)
-- [<]-is-[≱] : ∀{a b : ℕ} → ¬(a ≥ b) ← (a < b)
-- [<]-is-[≱] {a}{b} = [>]-is-[≰] {b}{a}
instance
[≤]-totality : ConverseTotal(_≤_)
[≤]-totality = intro p where
p : Names.ConverseTotal(_≤_)
p {𝟎} {𝟎} = [∨]-introₗ ([≡]-to-[≤] [≡]-intro)
p {𝐒(a)}{𝟎} = [∨]-introᵣ ([≤]-minimum)
p {𝟎} {𝐒(b)} = [∨]-introₗ ([≤]-minimum)
p {𝐒(a)}{𝐒(b)} = [∨]-elim ([∨]-introₗ ∘ ([≤]-with-[𝐒] {a}{b})) ([∨]-introᵣ ∘ ([≤]-with-[𝐒] {b}{a})) (p {a}{b})
| {
"alphanum_fraction": 0.4791100124,
"avg_line_length": 35.4824561404,
"ext": "agda",
"hexsha": "6ee5b3e528a88c141887e428e8536de170348dd6",
"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/Relation/Order/Existence/Proofs.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/Relation/Order/Existence/Proofs.agda",
"max_line_length": 138,
"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/Relation/Order/Existence/Proofs.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": 2126,
"size": 4045
} |
------------------------------------------------------------------------
-- Propositional (intensional) equality
------------------------------------------------------------------------
module Relation.Binary.PropositionalEquality where
open import Relation.Binary
open import Relation.Binary.Consequences
open import Relation.Binary.FunctionSetoid
open import Data.Function
open import Data.Product
-- Some of the definitions can be found in the following modules:
open import Relation.Binary.Core public using (_≡_; refl; _≢_)
open import Relation.Binary.PropositionalEquality.Core public
------------------------------------------------------------------------
-- Some properties
subst₂ : ∀ {A B} (P : A → B → Set) →
∀ {x₁ x₂ y₁ y₂} → x₁ ≡ x₂ → y₁ ≡ y₂ → P x₁ y₁ → P x₂ y₂
subst₂ P refl refl p = p
subst₁ : ∀ {a} (P : a → Set₁) → ∀ {x y} → x ≡ y → P x → P y
subst₁ P refl p = p
cong : Congruential _≡_
cong = subst⟶cong refl subst
cong₂ : Congruential₂ _≡_
cong₂ = cong+trans⟶cong₂ cong trans
setoid : Set → Setoid
setoid a = record
{ carrier = a
; _≈_ = _≡_
; isEquivalence = isEquivalence
}
decSetoid : ∀ {a} → Decidable (_≡_ {a}) → DecSetoid
decSetoid dec = record
{ _≈_ = _≡_
; isDecEquivalence = record
{ isEquivalence = isEquivalence
; _≟_ = dec
}
}
isPreorder : ∀ {a} → IsPreorder {a} _≡_ _≡_
isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = id
; trans = trans
; ∼-resp-≈ = resp₂ _≡_
}
preorder : Set → Preorder
preorder a = record
{ carrier = a
; _≈_ = _≡_
; _∼_ = _≡_
; isPreorder = isPreorder
}
------------------------------------------------------------------------
-- Pointwise equality
infix 4 _≗_
_→-setoid_ : (A B : Set) → Setoid
A →-setoid B = A ≡⇨ λ _ → setoid B
_≗_ : ∀ {a b} (f g : a → b) → Set
_≗_ {a} {b} = Setoid._≈_ (a →-setoid b)
→-to-⟶ : ∀ {A B} → (A → B) → setoid A ⟶ setoid B
→-to-⟶ f = record { _⟨$⟩_ = f; pres = cong f }
------------------------------------------------------------------------
-- The inspect idiom
-- The inspect idiom can be used when you want to pattern match on the
-- result r of some expression e, and you also need to "remember" that
-- r ≡ e.
data Inspect {a : Set} (x : a) : Set where
_with-≡_ : (y : a) (eq : y ≡ x) → Inspect x
inspect : ∀ {a} (x : a) → Inspect x
inspect x = x with-≡ refl
-- Example usage:
-- f x y with inspect (g x)
-- f x y | c z with-≡ eq = ...
------------------------------------------------------------------------
-- Convenient syntax for equational reasoning
import Relation.Binary.EqReasoning as EqR
-- Relation.Binary.EqReasoning is more convenient to use with _≡_ if
-- the combinators take the type argument (a) as a hidden argument,
-- instead of being locked to a fixed type at module instantiation
-- time.
module ≡-Reasoning where
private
module Dummy {a : Set} where
open EqR (setoid a) public
hiding (_≡⟨_⟩_) renaming (_≈⟨_⟩_ to _≡⟨_⟩_)
open Dummy public
| {
"alphanum_fraction": 0.5324165029,
"avg_line_length": 26.7894736842,
"ext": "agda",
"hexsha": "24392199b4bdb47e4be015aee958e4fef8319cf8",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 941,
"size": 3054
} |
module _ where
open import Agda.Primitive
module _ (a ℓ ℓ' : Level) where
mutual
X : Level
X = _ -- Agda 2.5.1.1 solves this level meta
hyp : Set₁
hyp with (lsuc ℓ')
... | _ = Set
where
X<=a : Set (X ⊔ a) → Set a
X<=a A = A
test : Set₁
test with (lsuc ℓ)
... | _ = Set
where
a<=X : Set (X ⊔ a) → Set X
a<=X A = A
| {
"alphanum_fraction": 0.4623115578,
"avg_line_length": 15.92,
"ext": "agda",
"hexsha": "d0f092b42373af96a5bf977f9cf9e32986bc6197",
"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/Issue2223c.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/Issue2223c.agda",
"max_line_length": 49,
"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/Issue2223c.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": 153,
"size": 398
} |
{-A
Polynomials over commutative rings
==================================
-}
{-# OPTIONS --safe #-}
----------------------------------
module Cubical.Algebra.Polynomials.Univariate.Properties where
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _Nat·_) hiding (·-comm)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Empty.Base renaming (rec to ⊥rec )
open import Cubical.Data.Bool
open import Cubical.Algebra.Group hiding (Bool)
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Polynomials.Univariate.Base
private
variable
ℓ ℓ' : Level
module PolyModTheory (R' : CommRing ℓ) where
private
R = fst R'
open PolyMod R'
open CommRingTheory R'
open RingTheory (CommRing→Ring R')
open GroupTheory (Ring→Group (CommRing→Ring R'))
pattern [_] x = x ∷ []
---------------------------------------
-- Definition
-- Identity for addition of polynomials
---------------------------------------
0P : Poly
0P = []
--ReplicatePoly(n,p) returns 0 ∷ 0 ∷ ... ∷ [] (n zeros)
ReplicatePoly0 : (n : ℕ) → Poly
ReplicatePoly0 zero = 0P
ReplicatePoly0 (suc n) = 0r ∷ ReplicatePoly0 n
--The empty polynomial has multiple equal representations on the form 0 + 0x + 0 x² + ...
replicatePoly0Is0P : ∀ (n : ℕ) → ReplicatePoly0 n ≡ 0P
replicatePoly0Is0P zero = refl
replicatePoly0Is0P (suc n) = (cong (0r ∷_) (replicatePoly0Is0P n)) ∙ drop0
-----------------------------
-- Definition
-- subtraction of polynomials
-----------------------------
Poly- : Poly → Poly
Poly- [] = []
Poly- (a ∷ p) = (- a) ∷ (Poly- p)
Poly- (drop0 i) = (cong (_∷ []) (inv1g) ∙ drop0) i
-- Double negation (of subtraction of polynomials) is the identity mapping
Poly-Poly- : (p : Poly) → Poly- (Poly- p) ≡ p
Poly-Poly- = ElimProp.f (λ x → Poly- (Poly- x) ≡ x)
refl
(λ a p e → cong (_∷ (Poly- (Poly- p)))
(-Idempotent a) ∙ cong (a ∷_ ) (e))
(isSetPoly _ _)
---------------------------
-- Definition
-- addition for polynomials
---------------------------
_Poly+_ : Poly → Poly → Poly
p Poly+ [] = p
[] Poly+ (drop0 i) = drop0 i
[] Poly+ (b ∷ q) = b ∷ q
(a ∷ p) Poly+ (b ∷ q) = (a + b) ∷ (p Poly+ q)
(a ∷ p) Poly+ (drop0 i) = +Rid a i ∷ p
(drop0 i) Poly+ (a ∷ q) = lem q i where
lem : ∀ q → (0r + a) ∷ ([] Poly+ q) ≡ a ∷ q
lem = ElimProp.f (λ q → (0r + a) ∷ ([] Poly+ q) ≡ a ∷ q)
(λ i → (+Lid a i ∷ []))
(λ r p _ → λ i → +Lid a i ∷ r ∷ p )
(isSetPoly _ _)
(drop0 i) Poly+ (drop0 j) = isSet→isSet' isSetPoly (cong ([_] ) (+Rid 0r)) drop0
(cong ([_] ) (+Lid 0r)) drop0 i j
-- [] is the left identity for Poly+
Poly+Lid : ∀ p → ([] Poly+ p ≡ p)
Poly+Lid = ElimProp.f (λ p → ([] Poly+ p ≡ p) )
refl
(λ r p prf → refl)
(λ x y → isSetPoly _ _ x y)
-- [] is the right identity for Poly+
Poly+Rid : ∀ p → (p Poly+ [] ≡ p)
Poly+Rid p = refl
--Poly+ is Associative
Poly+Assoc : ∀ p q r → p Poly+ (q Poly+ r) ≡ (p Poly+ q) Poly+ r
Poly+Assoc =
ElimProp.f (λ p → (∀ q r → p Poly+ (q Poly+ r) ≡ (p Poly+ q) Poly+ r))
(λ q r → Poly+Lid (q Poly+ r) ∙ cong (_Poly+ r) (sym (Poly+Lid q)))
(λ a p prf → ElimProp.f ((λ q → ∀ r → ((a ∷ p) Poly+ (q Poly+ r)) ≡
(((a ∷ p) Poly+ q) Poly+ r)))
(λ r → cong ((a ∷ p) Poly+_) (Poly+Lid r))
(λ b q prf2 →
ElimProp.f
(λ r → ((a ∷ p) Poly+ ((b ∷ q) Poly+ r)) ≡
((a + b ∷ (p Poly+ q)) Poly+ r))
refl
(λ c r prfp → cong ((a + (b + c))∷_)
(prf q r) ∙
(cong (_∷ ((p Poly+ q) Poly+ r))
(+Assoc a b c)))
(isSetPoly _ _))
λ x y i r → isSetPoly (x r i0) (y r i1) (x r) (y r) i)
λ x y i q r → isSetPoly _ _ (x q r) (y q r) i
-- for any polynomial, p, the additive inverse is given by Poly- p
Poly+Inverses : ∀ p → p Poly+ (Poly- p) ≡ []
Poly+Inverses = ElimProp.f ( λ p → p Poly+ (Poly- p) ≡ [])
refl --(Poly+Lid (Poly- []))
(λ r p prf → cong (r + - r ∷_) prf ∙
(cong (_∷ []) (+Rinv r) ∙ drop0))
(isSetPoly _ _)
--Poly+ is commutative
Poly+Comm : ∀ p q → p Poly+ q ≡ q Poly+ p
Poly+Comm = ElimProp.f (λ p → (∀ q → p Poly+ q ≡ q Poly+ p))
(λ q → Poly+Lid q)
(λ a p prf → ElimProp.f (λ q → ((a ∷ p) Poly+ q) ≡ (q Poly+ (a ∷ p)))
refl
(λ b q prf2 → cong (_∷ (p Poly+ q)) (+Comm a b) ∙
cong ((b + a) ∷_) (prf q))
(isSetPoly _ _)
)
(λ {p} → isPropΠ (λ q → isSetPoly (p Poly+ q) (q Poly+ p)))
--------------------------------------------------------------
-- Definition
-- multiplication of a polynomial by a (constant) ring element
--------------------------------------------------------------
_PolyConst*_ : (R) → Poly → Poly
r PolyConst* [] = []
r PolyConst* (a ∷ p) = (r · a) ∷ (r PolyConst* p)
r PolyConst* (drop0 i) = lem r i where
lem : ∀ r → [ r · 0r ] ≡ []
lem = λ r → [ r · 0r ] ≡⟨ cong (_∷ []) (0RightAnnihilates r) ⟩
[ 0r ] ≡⟨ drop0 ⟩
[] ∎
-- For any polynomial p we have: 0 _PolyConst*_ p = []
0rLeftAnnihilatesPoly : ∀ q → 0r PolyConst* q ≡ [ 0r ]
0rLeftAnnihilatesPoly = ElimProp.f (λ q → 0r PolyConst* q ≡ [ 0r ])
(sym drop0)
(λ r p prf → cong ((0r · r) ∷_) prf ∙
cong (_∷ [ 0r ]) (0LeftAnnihilates r) ∙
cong (0r ∷_) drop0 )
λ x y → isSetPoly _ _ x y
-- For any polynomial p we have: 1 _PolyConst*_ p = p
PolyConst*Lid : ∀ q → 1r PolyConst* q ≡ q
PolyConst*Lid = ElimProp.f (λ q → 1r PolyConst* q ≡ q ) refl
(λ a p prf → cong (_∷ (1r PolyConst* p)) (·Lid a) ∙
cong (a ∷_) (prf) )
λ x y → isSetPoly _ _ x y
--------------------------------
-- Definition
-- Multiplication of polynomials
--------------------------------
_Poly*_ : Poly → Poly → Poly
[] Poly* q = []
(a ∷ p) Poly* q = (a PolyConst* q) Poly+ (0r ∷ (p Poly* q))
(drop0 i) Poly* q = lem q i where
lem : ∀ q → (0r PolyConst* q) Poly+ [ 0r ] ≡ []
lem = λ q → ((0r PolyConst* q) Poly+ [ 0r ]) ≡⟨ cong ( _Poly+ [ 0r ] ) (0rLeftAnnihilatesPoly q)⟩
([ 0r ] Poly+ [ 0r ]) ≡⟨ cong (_∷ []) 0Idempotent ∙ drop0 ⟩
[] ∎
--------------------
--Definition
--Identity for Poly*
--------------------
1P : Poly
1P = [ 1r ]
-- For any polynomial p we have: p Poly* [] = []
0PRightAnnihilates : ∀ q → 0P Poly* q ≡ 0P
0PRightAnnihilates = ElimProp.f (λ q → 0P Poly* q ≡ 0P)
refl
(λ r p prf → prf)
λ x y → isSetPoly _ _ x y
-- For any polynomial p we have: [] Poly* p = []
0PLeftAnnihilates : ∀ p → p Poly* 0P ≡ 0P
0PLeftAnnihilates = ElimProp.f (λ p → p Poly* 0P ≡ 0P )
refl
(λ r p prf → cong (0r ∷_) prf ∙ drop0)
λ x y → isSetPoly _ _ x y
-- For any polynomial p we have: p Poly* [ 1r ] = p
Poly*Lid : ∀ q → 1P Poly* q ≡ q
Poly*Lid =
ElimProp.f (λ q → 1P Poly* q ≡ q)
drop0
(λ r p prf → lemma r p)
(λ x y → isSetPoly _ _ x y)
where
lemma : ∀ r p → 1r · r + 0r ∷ (1r PolyConst* p) ≡ r ∷ p
lemma =
λ r p → 1r · r + 0r ∷ (1r PolyConst* p) ≡⟨ cong (_∷ (1r PolyConst* p) )
(+Rid (1r · r)) ⟩
1r · r ∷ (1r PolyConst* p) ≡⟨ cong (_∷ 1r PolyConst* p) (·Lid r) ⟩
r ∷ (1r PolyConst* p) ≡⟨ cong (r ∷_) (PolyConst*Lid p) ⟩
r ∷ p ∎
-- Distribution of indeterminate: (p + q)x = px + qx
XLDistrPoly+ : ∀ p q → (0r ∷ (p Poly+ q)) ≡ ((0r ∷ p) Poly+ (0r ∷ q))
XLDistrPoly+ =
ElimProp.f (λ p → ∀ q → (0r ∷ (p Poly+ q)) ≡ ((0r ∷ p) Poly+ (0r ∷ q)) )
(λ q → (cong (0r ∷_) (Poly+Lid q)) ∙
cong (0r ∷_) (sym (Poly+Lid q)) ∙
sym (cong (_∷ [] Poly+ q) (+Lid 0r)))
(λ a p prf → ElimProp.f (λ q → 0r ∷ ((a ∷ p) Poly+ q) ≡
((0r ∷ a ∷ p) Poly+ (0r ∷ q)))
(cong (_∷ a ∷ p ) (sym (+Lid 0r)))
(λ b q prf2 → cong (_∷ a + b ∷ (p Poly+ q)) (sym (+Lid 0r)))
(λ x y i → isSetPoly (x i0) (x i1) x y i))
(λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i)
-- Distribution of a constant ring element over added polynomials p, q: a (p + q) = ap + aq
PolyConst*LDistrPoly+ : ∀ a p q → a PolyConst* (p Poly+ q) ≡
(a PolyConst* p) Poly+ (a PolyConst* q)
PolyConst*LDistrPoly+ =
λ a → ElimProp.f (λ p → ∀ q → a PolyConst* (p Poly+ q) ≡
(a PolyConst* p) Poly+ (a PolyConst* q))
(λ q → cong (a PolyConst*_) (Poly+Lid q) ∙
(sym (Poly+Lid (a PolyConst* q))))
(λ b p prf → ElimProp.f (λ q → (a PolyConst* ((b ∷ p) Poly+ q)) ≡
(a PolyConst* (b ∷ p)) Poly+ (a PolyConst* q))
refl
(λ c q prf2 → cong (_∷ (a PolyConst* (p Poly+ q)))
(·Rdist+ a b c) ∙
cong (a · b + a · c ∷_) (prf q))
(isSetPoly _ _))
(λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i)
--Poly* left distributes over Poly+
Poly*LDistrPoly+ : ∀ p q r → p Poly* (q Poly+ r) ≡ (p Poly* q) Poly+ (p Poly* r)
Poly*LDistrPoly+ =
ElimProp.f
(λ p → ∀ q r → p Poly* (q Poly+ r) ≡ (p Poly* q) Poly+ (p Poly* r))
(λ _ _ → refl)
(λ a p prf q r → ((a PolyConst* (q Poly+ r)) Poly+
(0r ∷(p Poly*(q Poly+ r)))) ≡⟨
cong (_Poly+ (0r ∷ (p Poly* (q Poly+ r))))
(PolyConst*LDistrPoly+ a q r)
⟩
(((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+
(0r ∷ (p Poly* (q Poly+ r)))) ≡⟨
cong (((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+_)
(cong (0r ∷_) (prf q r))
⟩
(((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+
(0r ∷ ((p Poly* q) Poly+ (p Poly* r)))) ≡⟨
cong (((a PolyConst* q) Poly+
(a PolyConst* r)) Poly+_)
(XLDistrPoly+ (p Poly* q) (p Poly* r))
⟩
(((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+
((0r ∷ (p Poly* q)) Poly+ (0r ∷ (p Poly* r)))) ≡⟨
Poly+Assoc ((a PolyConst* q) Poly+
(a PolyConst* r))
(0r ∷ (p Poly* q))
(0r ∷ (p Poly* r))
⟩
(((a PolyConst* q) Poly+ (a PolyConst* r)) Poly+
(0r ∷ (p Poly* q))) Poly+ (0r ∷ (p Poly* r)) ≡⟨ cong (_Poly+ (0r ∷ (p Poly* r)))
(sym (Poly+Assoc (a PolyConst* q)
(a PolyConst* r)
(0r ∷ (p Poly* q))))
⟩
(((a PolyConst* q) Poly+ ((a PolyConst* r) Poly+
(0r ∷ (p Poly* q)))) Poly+ (0r ∷ (p Poly* r))) ≡⟨
cong (_Poly+ (0r ∷ (p Poly* r)))
(cong ((a PolyConst* q) Poly+_)
(Poly+Comm (a PolyConst* r)
(0r ∷ (p Poly* q))))
⟩
(((a PolyConst* q) Poly+ ((0r ∷ (p Poly* q)) Poly+
(a PolyConst* r))) Poly+ (0r ∷ (p Poly* r))) ≡⟨
cong (_Poly+ (0r ∷ (p Poly* r)))
(Poly+Assoc (a PolyConst* q)
(0r ∷ (p Poly* q))
(a PolyConst* r))
⟩
((((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) Poly+
(a PolyConst* r)) Poly+ (0r ∷ (p Poly* r))) ≡⟨
sym (Poly+Assoc ((a PolyConst* q) Poly+
(0r ∷ (p Poly* q)))
((a PolyConst* r))
((0r ∷ (p Poly* r))))
⟩
((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) Poly+
((a PolyConst* r) Poly+ (0r ∷ (p Poly* r))) ∎)
(λ x y i q r → isSetPoly _ _ (x q r) (y q r) i)
-- The constant multiplication of a ring element, a, with a polynomial, p, can be
-- expressed by polynomial multiplication with the singleton polynomial [ a ]
PolyConst*r=Poly*[r] : ∀ a p → a PolyConst* p ≡ p Poly* [ a ]
PolyConst*r=Poly*[r] =
λ a → ElimProp.f (λ p → a PolyConst* p ≡ p Poly* [ a ])
refl
( λ r p prf → a · r ∷ (a PolyConst* p) ≡⟨
cong (a · r ∷_) prf
⟩
a · r ∷ (p Poly* [ a ]) ≡⟨
cong (a · r ∷_)
(sym (Poly+Lid (p Poly* [ a ])))
⟩
a · r ∷ ([] Poly+ (p Poly* [ a ])) ≡⟨
cong (_∷ ([] Poly+ (p Poly* [ a ])))
(·Comm a r )
⟩
r · a ∷ ([] Poly+ (p Poly* [ a ])) ≡⟨
cong (_∷ ([] Poly+ (p Poly* [ a ])))
(sym (+Rid (r · a)))
⟩
r · a + 0r ∷ ([] Poly+ (p Poly* [ a ])) ∎)
( λ x y i → isSetPoly (x i0) (x i1) x y i)
-- Connection between the constant multiplication and the multiplication in the ring
PolyConst*Nested· : ∀ a b p → a PolyConst* (b PolyConst* p) ≡ (a · b) PolyConst* p
PolyConst*Nested· =
λ a b → ElimProp.f (λ p → a PolyConst* (b PolyConst* p) ≡ (a · b) PolyConst* p)
refl
(λ c p prf → cong ((a · (b · c)) ∷_) prf ∙
cong (_∷ ((a · b) PolyConst* p)) (·Assoc a b c))
(isSetPoly _ _)
-- We can move the indeterminate from left to outside: px * q = (p * q)x
0r∷LeftAssoc : ∀ p q → (0r ∷ p) Poly* q ≡ 0r ∷ (p Poly* q)
0r∷LeftAssoc =
ElimProp.f (λ p → ∀ q → (0r ∷ p) Poly* q ≡ 0r ∷ (p Poly* q))
(λ q → cong (_Poly+ [ 0r ])((cong (_Poly+ []) (0rLeftAnnihilatesPoly q))) ∙
cong (_∷ []) (+Lid 0r))
(λ r p b q → cong (_Poly+ (0r ∷ ((r PolyConst* q) Poly+ (0r ∷ (p Poly* q)))))
((0rLeftAnnihilatesPoly q) ∙ drop0))
(λ x y i q → isSetPoly _ _ (x q) (y q) i)
--Associativity of constant multiplication in relation to polynomial multiplication
PolyConst*AssocPoly* : ∀ a p q → a PolyConst* (p Poly* q) ≡ (a PolyConst* p) Poly* q
PolyConst*AssocPoly* =
λ a → ElimProp.f (λ p → ∀ q → a PolyConst* (p Poly* q) ≡ (a PolyConst* p) Poly* q)
(λ q → refl)
(λ b p prf q → a PolyConst* ((b PolyConst* q) Poly+
(0r ∷ (p Poly* q))) ≡⟨
PolyConst*LDistrPoly+ a
(b PolyConst* q)
(0r ∷ (p Poly* q))
⟩
(a PolyConst* (b PolyConst* q)) Poly+
(a PolyConst* (0r ∷ (p Poly* q))) ≡⟨
cong (_Poly+ (a · 0r ∷ (a PolyConst* (p Poly* q))))
(PolyConst*Nested· a b q)
⟩
((a · b) PolyConst* q) Poly+
(a PolyConst* (0r ∷ (p Poly* q))) ≡⟨
cong (((a · b) PolyConst* q) Poly+_)
(cong (a · 0r ∷_)
(PolyConst*r=Poly*[r] a
(p Poly* q)))
⟩
((a · b) PolyConst* q) Poly+
(a · 0r ∷ ((p Poly* q) Poly* [ a ])) ≡⟨
cong (((a · b) PolyConst* q) Poly+_)
(cong (_∷ ((p Poly* q) Poly* [ a ]))
(0RightAnnihilates a)) ⟩
((a · b) PolyConst* q) Poly+
(0r ∷ ((p Poly* q) Poly* [ a ])) ≡⟨
cong (((a · b) PolyConst* q) Poly+_)
(cong (0r ∷_)
(sym (PolyConst*r=Poly*[r] a (p Poly* q))))
⟩
((a · b) PolyConst* q) Poly+
(0r ∷ (a PolyConst* (p Poly* q))) ≡⟨
cong (((a · b) PolyConst* q) Poly+_)
(cong (0r ∷_) (prf q))
⟩
((a · b) PolyConst* q) Poly+
(0r ∷ ((a PolyConst* p) Poly* q)) ∎)
(λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i)
-- We can move the indeterminate from left to outside: p * qx = (p * q)x
0r∷RightAssoc : ∀ p q → p Poly* (0r ∷ q) ≡ 0r ∷ (p Poly* q)
0r∷RightAssoc =
ElimProp.f (λ p → ∀ q → p Poly* (0r ∷ q) ≡ 0r ∷ (p Poly* q))
(λ q → sym drop0)
(λ a p prf q → ((a ∷ p) Poly* (0r ∷ q)) ≡⟨
cong ( a · 0r + 0r ∷_)
(cong ((a PolyConst* q) Poly+_ )
(prf q))
⟩
a · 0r + 0r ∷ ((a PolyConst* q) Poly+
(0r ∷ (p Poly* q))) ≡⟨
cong (_∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))))
((+Rid (a · 0r)))
⟩
a · 0r ∷ ((a PolyConst* q) Poly+
(0r ∷ (p Poly* q))) ≡⟨
cong (_∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))))
(0RightAnnihilates a) ⟩
0r ∷ ((a PolyConst* q) Poly+ (0r ∷ (p Poly* q))) ∎)
(λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i)
-- We can move the indeterminate around: px * q = p * qx
0r∷Comm : ∀ p q → (0r ∷ p) Poly* q ≡ p Poly* (0r ∷ q)
0r∷Comm = ElimProp.f (λ p → ∀ q → (0r ∷ p) Poly* q ≡ p Poly* (0r ∷ q))
(λ q → (cong ((0r PolyConst* q) Poly+_) drop0) ∙
0rLeftAnnihilatesPoly q ∙
drop0 )
(λ a p prf q → ((0r ∷ a ∷ p) Poly* q) ≡⟨ 0r∷LeftAssoc (a ∷ p) q ⟩
0r ∷ ((a ∷ p) Poly* q) ≡⟨ sym (0r∷RightAssoc (a ∷ p) q) ⟩
((a ∷ p) Poly* (0r ∷ q)) ∎
)
λ x y i q → isSetPoly (x q i0) (x q i1) (x q) (y q) i
--Poly* is commutative
Poly*Commutative : ∀ p q → p Poly* q ≡ q Poly* p
Poly*Commutative =
ElimProp.f (λ p → ∀ q → p Poly* q ≡ q Poly* p)
(λ q → sym (0PLeftAnnihilates q))
(λ a p prf q → (a PolyConst* q) Poly+ (0r ∷ (p Poly* q)) ≡⟨
cong ((a PolyConst* q) Poly+_)
(cong (0r ∷_) (prf q)) ⟩
((a PolyConst* q) Poly+ (0r ∷ (q Poly* p))) ≡⟨
cong ((a PolyConst* q) Poly+_)
(sym (0r∷LeftAssoc q p))
⟩
((a PolyConst* q) Poly+ ((0r ∷ q) Poly* p)) ≡⟨
cong (_Poly+ ((0r PolyConst* p) Poly+ (0r ∷ (q Poly* p))))
(PolyConst*r=Poly*[r] a q) ⟩
((q Poly* [ a ]) Poly+ ((0r ∷ q) Poly* p)) ≡⟨
cong ((q Poly* [ a ]) Poly+_)
(0r∷Comm q p)
⟩
((q Poly* [ a ]) Poly+ (q Poly* (0r ∷ p))) ≡⟨
sym (Poly*LDistrPoly+ q [ a ] (0r ∷ p))
⟩
(((q Poly* ([ a ] Poly+ (0r ∷ p))))) ≡⟨
cong (q Poly*_)
(Poly+Comm [ a ] (0r ∷ p))
⟩
((q Poly* ((0r ∷ p) Poly+ [ a ]))) ≡⟨
refl
⟩
(q Poly* ((0r + a) ∷ p)) ≡⟨ cong (q Poly*_)
(cong (_∷ p) (+Lid a))
⟩
(q Poly* (a ∷ p)) ∎)
(λ x y i q → isSetPoly _ _ (x q ) (y q) i)
--1P is the right identity of Poly*.
Poly*Rid : ∀ p → p Poly* 1P ≡ p
Poly*Rid = λ p → (Poly*Commutative p 1P ∙ Poly*Lid p)
--Polynomial multiplication right distributes over polynomial addition.
Poly*RDistrPoly+ : ∀ p q r → (p Poly+ q) Poly* r ≡ (p Poly* r) Poly+ (q Poly* r)
Poly*RDistrPoly+ = λ p q r → sym (Poly*Commutative r (p Poly+ q)) ∙
Poly*LDistrPoly+ r p q ∙
cong (_Poly+ (r Poly* q)) (Poly*Commutative r p) ∙
cong ((p Poly* r) Poly+_) (Poly*Commutative r q)
--Polynomial multiplication is associative
Poly*Associative : ∀ p q r → p Poly* (q Poly* r) ≡ (p Poly* q) Poly* r
Poly*Associative =
ElimProp.f (λ p → ∀ q r → p Poly* (q Poly* r) ≡ (p Poly* q) Poly* r )
(λ _ _ → refl)
(λ a p prf q r →
((a ∷ p) Poly* (q Poly* r)) ≡⟨
cong (_Poly+ (0r ∷ (p Poly* (q Poly* r))))
(PolyConst*AssocPoly* a q r)
⟩
(((a PolyConst* q) Poly* r) Poly+
(0r ∷ (p Poly* (q Poly* r)))) ≡⟨
sym (cong (((a PolyConst* q) Poly* r) Poly+_)
(cong (_∷ (p Poly* (q Poly* r)))
(+Lid 0r)))
⟩
(((a PolyConst* q) Poly* r) Poly+
(0r + 0r ∷ (p Poly* (q Poly* r)))) ≡⟨
cong (((a PolyConst* q) Poly* r) Poly+_)
(cong (0r + 0r ∷_)
(sym (Poly+Lid (p Poly* (q Poly* r)))))
⟩
(((a PolyConst* q) Poly* r) Poly+
(0r + 0r ∷ ([] Poly+ (p Poly* (q Poly* r))))) ≡⟨
cong (((a PolyConst* q) Poly* r) Poly+_)
(cong (0r + 0r ∷_)
(cong ([] Poly+_)
(prf q r)))
⟩
(((a PolyConst* q) Poly* r) Poly+
(0r + 0r ∷ ([] Poly+ ((p Poly* q) Poly* r)))) ≡⟨
cong (((a PolyConst* q) Poly* r) Poly+_)
(cong (_Poly+ (0r ∷ ((p Poly* q) Poly* r)))
(sym (0rLeftAnnihilatesPoly r)))
⟩
(((a PolyConst* q) Poly* r) Poly+
((0r PolyConst* r) Poly+ (0r ∷ ((p Poly* q) Poly* r)))) ≡⟨
sym (Poly*RDistrPoly+ (a PolyConst* q)
(0r ∷ (p Poly* q)) r)
⟩
((((a ∷ p) Poly* q) Poly* r)) ∎)
(λ x y i q r → isSetPoly _ _ (x q r) (y q r) i)
-----------------------------------------------------------------------------
-- Product by Xn and operationsproperties on it
prod-Xn : (n : ℕ) → Poly → Poly
prod-Xn zero x = x
prod-Xn (suc n) x = 0r ∷ (prod-Xn n x)
prod-Xn-0P : (n : ℕ) → prod-Xn n 0P ≡ 0P
prod-Xn-0P zero = refl
prod-Xn-0P (suc n) = cong (λ X → 0r ∷ X) (prod-Xn-0P n) ∙ drop0
prod-Xn-sum : (n : ℕ) → (x y : Poly) → (prod-Xn n x) Poly+ (prod-Xn n y) ≡ prod-Xn n (x Poly+ y)
prod-Xn-sum zero x y = refl
prod-Xn-sum (suc n) x y = cong₂ _∷_ (+Rid 0r) (prod-Xn-sum n x y)
prod-Xn-comp : (n m : ℕ) → (x : Poly) → prod-Xn n (prod-Xn m x) ≡ prod-Xn (n +n m) x
prod-Xn-comp zero m x = refl
prod-Xn-comp (suc n) m x = cong (λ X → 0r ∷ X) (prod-Xn-comp n m x)
prod-Xn-∷ : (n : ℕ) → (r : R) → (x : Poly) → (prod-Xn n (r ∷ [])) Poly+ (0r ∷ prod-Xn n x) ≡ prod-Xn n (r ∷ x)
prod-Xn-∷ zero r x = cong₂ _∷_ (+Rid r) (Poly+Lid x)
prod-Xn-∷ (suc n) r x = cong₂ _∷_ (+Lid 0r) (prod-Xn-∷ n r x)
prod-Xn-prod-0 : (m : ℕ) → (x y : Poly) → x Poly* (prod-Xn m y) ≡ prod-Xn m (x Poly* y)
prod-Xn-prod-0 zero x y = refl
prod-Xn-prod-0 (suc m) x y = ((x Poly* (0r ∷ prod-Xn m y)))
≡⟨ Poly*Commutative x (prod-Xn (suc m) y) ⟩
((0r PolyConst* x) Poly+ (0r ∷ (prod-Xn m y Poly* x)))
≡⟨ cong (λ X → X Poly+ (0r ∷ ((prod-Xn m y) Poly* x))) ((0rLeftAnnihilatesPoly x) ∙ drop0) ⟩
((0r ∷ (prod-Xn m y Poly* x)))
≡⟨ cong (λ X → 0r ∷ X) (Poly*Commutative (prod-Xn m y) x) ⟩
(0r ∷ (x Poly* prod-Xn m y))
≡⟨ cong (λ X → 0r ∷ X) (prod-Xn-prod-0 m x y) ⟩
(0r ∷ prod-Xn m (x Poly* y)) ∎
prod-Xn-prod : (n m : ℕ) → (x y : Poly) → (prod-Xn n x) Poly* (prod-Xn m y) ≡ prod-Xn (n +n m) (x Poly* y)
prod-Xn-prod zero m x y = prod-Xn-prod-0 m x y
prod-Xn-prod (suc n) m x y = cong₂ _Poly+_ ((0rLeftAnnihilatesPoly (prod-Xn m y)) ∙ drop0) (cong (λ X → 0r ∷ X) (prod-Xn-prod n m x y))
----------------------------------------------------------------------------------------------
-- An instantiation of Polynomials as a commutative ring can be found in CommRing/Instances --
----------------------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.322786417,
"avg_line_length": 51.7405582923,
"ext": "agda",
"hexsha": "812225b2a6ab65aac311ed79905ceb8f6fa08317",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Algebra/Polynomials/Univariate/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Algebra/Polynomials/Univariate/Properties.agda",
"max_line_length": 137,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Algebra/Polynomials/Univariate/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 8732,
"size": 31510
} |
------------------------------------------------------------------------
-- Conversion of ≤ to <, along with a number of properties
------------------------------------------------------------------------
-- Possible TODO: Prove that a conversion ≤ → < → ≤ returns a
-- relation equivalent to the original one (and similarly for
-- < → ≤ → <).
open import Relation.Binary
module Relation.Binary.NonStrictToStrict
{a : Set} (_≈_ _≤_ : Rel a)
where
open import Relation.Nullary
open import Relation.Binary.Consequences
open import Data.Function
open import Data.Product
open import Data.Sum
------------------------------------------------------------------------
-- Conversion
-- _≤_ can be turned into _<_ as follows:
_<_ : Rel a
x < y = (x ≤ y) × ¬ (x ≈ y)
------------------------------------------------------------------------
-- The converted relations have certain properties
-- (if the original relations have certain other properties)
irrefl : Irreflexive _≈_ _<_
irrefl x≈y x<y = proj₂ x<y x≈y
trans : IsPartialOrder _≈_ _≤_ → Transitive _<_
trans po = λ x<y y<z →
( PO.trans (proj₁ x<y) (proj₁ y<z)
, λ x≈z → proj₂ x<y $ lemma (proj₁ x<y) (proj₁ y<z) x≈z
)
where
module PO = IsPartialOrder po
lemma : ∀ {x y z} → x ≤ y → y ≤ z → x ≈ z → x ≈ y
lemma x≤y y≤z x≈z =
PO.antisym x≤y $ PO.trans y≤z (PO.reflexive $ PO.Eq.sym x≈z)
<-resp-≈ : IsEquivalence _≈_ → _≤_ Respects₂ _≈_ → _<_ Respects₂ _≈_
<-resp-≈ eq ≤-resp-≈ =
(λ {x y' y} y'≈y x<y' →
( proj₁ ≤-resp-≈ y'≈y (proj₁ x<y')
, λ x≈y → proj₂ x<y' (Eq.trans x≈y (Eq.sym y'≈y))
)
) ,
(λ {y x' x} x'≈x x'<y →
( proj₂ ≤-resp-≈ x'≈x (proj₁ x'<y)
, λ x≈y → proj₂ x'<y (Eq.trans x'≈x x≈y)
))
where module Eq = IsEquivalence eq
trichotomous : Symmetric _≈_ → Decidable _≈_ →
Antisymmetric _≈_ _≤_ → Total _≤_ →
Trichotomous _≈_ _<_
trichotomous ≈-sym ≈-dec antisym total x y with ≈-dec x y
... | yes x≈y = tri≈ (irrefl x≈y) x≈y (irrefl (≈-sym x≈y))
... | no x≉y with total x y
... | inj₁ x≤y = tri< (x≤y , x≉y) x≉y
(x≉y ∘ antisym x≤y ∘ proj₁)
... | inj₂ x≥y = tri> (x≉y ∘ flip antisym x≥y ∘ proj₁) x≉y
(x≥y , x≉y ∘ ≈-sym)
decidable : Decidable _≈_ → Decidable _≤_ → Decidable _<_
decidable ≈-dec ≤-dec x y with ≈-dec x y | ≤-dec x y
... | yes x≈y | _ = no (flip proj₂ x≈y)
... | no x≉y | yes x≤y = yes (x≤y , x≉y)
... | no x≉y | no x≰y = no (x≰y ∘ proj₁)
| {
"alphanum_fraction": 0.5,
"avg_line_length": 32.2077922078,
"ext": "agda",
"hexsha": "edffbc93e70a9b199ed93be4d9c130e19eafa967",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/NonStrictToStrict.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/NonStrictToStrict.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/NonStrictToStrict.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 940,
"size": 2480
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use Data.List.Relation.Unary.All
-- directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.All where
open import Data.List.Relation.Unary.All public
{-# WARNING_ON_IMPORT
"Data.List.All was deprecated in v1.0.
Use Data.List.Relation.Unary.All instead."
#-}
| {
"alphanum_fraction": 0.5093167702,
"avg_line_length": 26.8333333333,
"ext": "agda",
"hexsha": "c53c76a27ad96ea668d9619b4a9170958c52f48c",
"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/All.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/All.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/All.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": 87,
"size": 483
} |
{-# OPTIONS -v impossible:100 #-}
module Issue882a where
open import Common.Level
open import Common.Equality
private
primitive
primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
-- trustMe {x = x} {y = y} evaluates to refl if x and y are
-- definitionally equal.
--
-- For an example of the use of trustMe, see Data.String._≟_.
trustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
trustMe = primTrustMe
postulate
S : Set
B : Set
b : B
M : Set
M = B -> S
out : M -> M
out m = o
where
s : S
s = m b
postulate
mko : (mm : S) -> s ≡ mm -> M
o : M
o n = mko (m b) trustMe n
postulate
unfold : (M -> M) -> M
inn : M
inn = unfold out
postulate
n : B
iso1 : inn ≡ inn
iso1 rewrite refl {x = n} = {!!}
-- iso1 rewrite (refl {a = lzero}{A = B}{x = n}) = {!!}
{- Error
OLD:
An internal error has occurred. Please report this as a bug.
Location of the error: src/full/Agda/TypeChecking/Conversion.hs:636
NEW:
Some vomit about Setω not equal to Level when checking well-formedness
of with type.
NEWER (2013-11-30):
Cannot instantiate the metavariable _48 to solution m b since it
contains the variable m which is not in scope of the metavariable
or irrelevant in the metavariable but relevant in the solution
when checking that the type
B →
(w : _x_48 ≡ _x_48) →
unfold (λ m → _.mko m (m b) w) ≡ unfold (λ m → _.mko m (m b) w)
of the generated with function is well-formed
NOW (2014-05-17):
Rewriting with refl is a no-op, so no error is triggered any more.
Just an unresolved meta now.
-}
| {
"alphanum_fraction": 0.6461336828,
"avg_line_length": 19.5641025641,
"ext": "agda",
"hexsha": "062944f5ddbc3befeccaaa19e16cce803263ff77",
"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": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "test/fail/Issue882a.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "test/fail/Issue882a.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/fail/Issue882a.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 511,
"size": 1526
} |
{-# OPTIONS --cubical --guardedness --postfix-projections #-}
module Data.Graph where
open import Prelude
open import Data.List
open import Data.Nat
-- record Thunk (A : Type a) : Type a where
-- coinductive
-- constructor ⟪_⟫
-- field force : A
-- open Thunk
-- infixr 5 _◃_
-- record Stream (A : Type a) : Type a where
-- constructor _◃_
-- coinductive
-- field
-- head : A
-- tail : (Stream A)
-- open Stream
Graph : Type a → Type a
Graph A = A → List A
Stream : Type a → Type a
Stream A = ℕ → A
pure : A → Stream A
pure x _ = x
smap : (A → B) → Stream A → Stream B
smap f xs n = f (xs n)
bfs : Graph A → A → Stream (List A)
bfs g r zero = r ∷ []
bfs g r (suc n) = concatMap g (bfs g r n)
-- module _ {A : Type a} (g : Graph A) where
-- mutual
-- bfs-foldr : List A → Stream (List A) → Stream (List A)
-- bfs-foldr [] qs = qs
-- bfs-foldr (x ∷ xs) qs .head = x ∷ bfs-foldr xs qs .head
-- bfs-foldr (x ∷ xs) qs .tail .force = bfs-foldr (g x) (bfs-foldr xs qs .tail .force)
-- -- bfs-cons : A → Stream (List A) → Stream (List A)
-- -- bfs-cons x (q ◃ qs) = (x ∷ q) ◃ bfs-foldr (g x) qs
-- -- bfs : A → Stream (List A)
-- -- bfs r = bfs-cons r (pure [])
| {
"alphanum_fraction": 0.5599022005,
"avg_line_length": 22.7222222222,
"ext": "agda",
"hexsha": "c31118ce3b56b767f151245f18fa46e3250b45b9",
"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/Graph.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/Graph.agda",
"max_line_length": 90,
"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/Graph.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": 436,
"size": 1227
} |
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
record D (A : Set) : Set where
constructor mkD
field d : A
open D {{...}}
module test where
instance
_ : D Bool
_ = mkD true
a : D Nat
a = mkD 0
_ : d ≡ true
_ = refl
_ : d ≡ zero
_ = refl
-- no instance in scope
-- _ : d ≡ true
-- _ = ?
_ : d ≡ zero
_ = refl
| {
"alphanum_fraction": 0.5776081425,
"avg_line_length": 11.9090909091,
"ext": "agda",
"hexsha": "263aef8550f7b83c65f0b3ffc376db667491cb3d",
"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/Issue2498.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/Issue2498.agda",
"max_line_length": 33,
"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/Issue2498.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": 143,
"size": 393
} |
open import Agda.Builtin.List
open import Agda.Builtin.Unit
open import Agda.Builtin.Nat
open import Agda.Builtin.String
renaming (primShowNat to show)
open import Agda.Builtin.Reflection
renaming (bindTC to _>>=_; returnTC to return)
pattern vArg t = arg (arg-info visible relevant) t
pattern var₀ x = var x []
infixr 10 _++_
_++_ = primStringAppend
postulate
whatever : ∀ {a} {A : Set a} → A
macro
test1 : Nat → Term → TC _
test1 n _ =
extendContext (vArg (quoteTerm Nat)) do
var₀ i ← quoteTC n where _ → whatever
m ← unquoteTC {A = Nat} (var₀ 0)
var₀ j ← quoteTC m where _ → whatever
extendContext (vArg (quoteTerm Nat)) do
var₀ k ← quoteTC n where _ → whatever
var₀ l ← quoteTC m where _ → whatever
typeError (strErr (show i ++ show k ++ show j ++ show l) ∷ [])
test2 : Term → TC _
test2 hole = do
st ← quoteTC Set
t ← extendContext (vArg st) do
v ← unquoteTC {A = Set} (var₀ zero)
extendContext (vArg (var₀ zero)) do
_ ← unquoteTC {A = v} (var₀ zero)
return tt
u ← quoteTC t
unify hole u
test3 : Nat → Term → TC _
test3 n _ = do
m ← extendContext (vArg (quoteTerm Nat)) (return n)
var₀ i ← quoteTC m where _ → whatever
typeError (strErr (show i) ∷ [])
localvar : Term → TC _
localvar _ = do
m ← extendContext (vArg (quoteTerm Nat)) (unquoteTC {A = Nat} (var₀ 0))
typeError (strErr (show m) ∷ [])
| {
"alphanum_fraction": 0.622329428,
"avg_line_length": 28.4509803922,
"ext": "agda",
"hexsha": "8c1f7d2d2fc1b3d02a86e0f778696125dc00cff2",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.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/Issue3831.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue3831.agda",
"max_line_length": 75,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue3831.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z",
"num_tokens": 470,
"size": 1451
} |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.HSpace where
record HSpaceStructure {i} (A : Type i) : Type i where
constructor hSpaceStructure
field
e : A
μ : A → A → A
μe- : (a : A) → μ e a == a
μ-e : (a : A) → μ a e == a
module ConnectedHSpace {i} (A : Type i) (c : is-connected ⟨0⟩ A)
(hA : HSpaceStructure A) where
open HSpaceStructure hA
{-
Given that [A] is 0-connected, to prove that each [μ a] is an equivalence we
only need to prove that one of them is. But for [a] = [e], [μ a] is the
identity so we’re done.
-}
μ-is-equiv : (a : A) → is-equiv (μ a)
μ-is-equiv = prop-over-connected {a = e} c
(λ a → (is-equiv (μ a) , is-equiv-is-prop (μ a)))
(transport! is-equiv (λ= μe-) (idf-is-equiv A))
μ'-is-equiv : (a : A) → is-equiv (λ a' → μ a' a)
μ'-is-equiv = prop-over-connected {a = e} c
(λ a → (is-equiv (λ a' → μ a' a) , is-equiv-is-prop (λ a' → μ a' a)))
(transport! is-equiv (λ= μ-e) (idf-is-equiv A))
μ-equiv : A → A ≃ A
μ-equiv a = (μ a , μ-is-equiv a)
μ'-equiv : A → A ≃ A
μ'-equiv a = ((λ a' → μ a' a) , μ'-is-equiv a)
| {
"alphanum_fraction": 0.5533807829,
"avg_line_length": 27.4146341463,
"ext": "agda",
"hexsha": "f8504db895309189e8a312ca86a1fee0a27c5af8",
"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/HSpace.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/HSpace.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "homotopy/HSpace.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": 422,
"size": 1124
} |
-- WARNING: This file was generated automatically by Vehicle
-- and should not be modified manually!
-- Metadata
-- - Agda version: 2.6.2
-- - AISEC version: 0.1.0.1
-- - Time generated: ???
{-# OPTIONS --allow-exec #-}
open import Vehicle
open import Vehicle.Data.Tensor
open import Data.Product
open import Data.Integer as ℤ using (ℤ)
open import Data.Rational as ℚ using (ℚ)
open import Data.Bool as 𝔹 using (Bool; true; false; if_then_else_)
open import Data.Fin as Fin using (Fin; #_)
open import Data.List
open import Relation.Nullary
open import Relation.Nullary.Decidable
module simple-if-temp-output where
postulate f : Tensor ℚ (1 ∷ []) → Tensor ℚ (1 ∷ [])
abstract
prop1 : ∀ (x : ℚ) → if ⌊ x ℚ.>? ℤ.+ 0 ℚ./ 1 ⌋ then f (x ∷ []) (# 0) ℚ.> ℤ.+ 0 ℚ./ 1 else f (x ∷ []) (# 0) ℚ.≤ ℤ.+ 0 ℚ./ 1
prop1 = checkSpecification record
{ proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp"
}
abstract
prop3 : ∃ λ (x : ℚ) → if ⌊ f (x ∷ []) (# 0) ℚ.>? ℤ.+ 0 ℚ./ 1 ⌋ then x ℚ.≥ ℤ.+ 0 ℚ./ 1 else x ℚ.< ℤ.+ 0 ℚ./ 1
prop3 = checkSpecification record
{ proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp"
} | {
"alphanum_fraction": 0.6401384083,
"avg_line_length": 33.0285714286,
"ext": "agda",
"hexsha": "b40a6be846c6ef022d62c30138b4891ce8a51cea",
"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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "vehicle-lang/vehicle",
"max_forks_repo_path": "test/Test/Compile/Golden/simple-if/simple-if-output.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "vehicle-lang/vehicle",
"max_issues_repo_path": "test/Test/Compile/Golden/simple-if/simple-if-output.agda",
"max_line_length": 123,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "vehicle-lang/vehicle",
"max_stars_repo_path": "test/Test/Compile/Golden/simple-if/simple-if-output.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z",
"num_tokens": 423,
"size": 1156
} |
module Imports.ATP-A where
postulate
D : Set
_≡_ : D → D → Set
a b : D
postulate p : a ≡ b
| {
"alphanum_fraction": 0.5480769231,
"avg_line_length": 11.5555555556,
"ext": "agda",
"hexsha": "5206ea2c778c4fd845ecd782270323251943f540",
"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": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "asr/eagda",
"max_forks_repo_path": "test/fail/Imports/ATP-A.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"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": "asr/eagda",
"max_issues_repo_path": "test/fail/Imports/ATP-A.agda",
"max_line_length": 26,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "asr/eagda",
"max_stars_repo_path": "test/fail/Imports/ATP-A.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 46,
"size": 104
} |
{-# OPTIONS --cubical-compatible #-}
-- {-# OPTIONS -v tc.lhs.unify:15 #-}
open import Common.Equality
open import Common.Prelude
data Fin : (n : Nat) → Set where
zero : {n : Nat} → Fin (suc n)
suc : {n : Nat} (i : Fin n) → Fin (suc n)
data _≅_ {A : Set} (a : A) : {B : Set} (b : B) → Set1 where
refl : a ≅ a
OffDiag : ∀ {n m} → Fin n → Fin m → Set
OffDiag zero zero = ⊥
OffDiag (suc _) (suc _) = ⊥
OffDiag _ _ = ⊤
inj-Fin-≅ : ∀ {n m} {i : Fin n} {j : Fin m} → i ≅ j → OffDiag i j → ⊥
inj-Fin-≅ {i = zero} {zero} eq ()
inj-Fin-≅ {i = zero} {suc j} ()
inj-Fin-≅ {i = suc i} {zero} ()
inj-Fin-≅ {i = suc i} {suc j} p ()
| {
"alphanum_fraction": 0.5038402458,
"avg_line_length": 26.04,
"ext": "agda",
"hexsha": "46ca7c9be6cffe8e8f2b40d3b3f3f41de44fd664",
"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": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Fail/Issue1408a.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Fail/Issue1408a.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Fail/Issue1408a.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 291,
"size": 651
} |
module Cxt (K : Set) where
open import Basics
open import Pr
open import Nom
mutual
data Cxt : Set where
EC : Cxt
_[_-_] : (G : Cxt)(x : Nom) -> K -> {p : [| G Hasn't x |]} -> Cxt
HAS : Cxt -> Nom -> Bool
HAS EC x = false
HAS (G [ y - S ]) x with nomEq y x
HAS (G [ y - S ]) .y | yes refl = true
... | no n = HAS G x
_Has_ : Cxt -> Nom -> Pr
G Has x = So (HAS G x)
_Hasn't_ : Cxt -> Nom -> Pr
G Hasn't x = So (not (HAS G x))
GooN : (G : Cxt)(T : K) -> Nom -> Pr
GooN EC T y = ff
GooN (G [ x - S ]) T y with nomEq x y
GooN (G [ x - S ]) T .x | yes refl = S eq T
GooN (G [ x - S ]) T y | no n = GooN G T y
_?-_ : (G : Cxt)(x : Nom){p : [| G Has x |]} -> K :- \ T -> GooN G T x
(EC ?- y) {}
((G [ x - S ]) ?- y) {_} with nomEq x y
((G [ x - S ]) ?- .x) {_} | yes refl = [ S / refl ]
((G [ x - S ]) ?- y) {p} | no n = (G ?- y) {p}
topGooN : (G : Cxt)(x : Nom){p : [| G Hasn't x |]}(S : K) ->
[| GooN ((G [ x - S ]) {p}) S x |]
topGooN G x S with nomEq x x
topGooN G x S | yes refl = refl
topGooN G x S | no n = magic (n refl)
| {
"alphanum_fraction": 0.4362176628,
"avg_line_length": 26.6904761905,
"ext": "agda",
"hexsha": "5b495bb9e80bf057fea05226778b834b6ba1b25f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "benchmark/Syntacticosmos/Cxt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "benchmark/Syntacticosmos/Cxt.agda",
"max_line_length": 70,
"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": "benchmark/Syntacticosmos/Cxt.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": 489,
"size": 1121
} |
{-# OPTIONS --sized-types #-}
module SOList.Lower.Properties {A : Set}(_≤_ : A → A → Set) where
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import Size
open import List.Sorted _≤_
open import SOList.Lower _≤_
lemma-solist-sorted : {ι : Size}{b : Bound} → (xs : SOList {ι} b) → Sorted (forget xs)
lemma-solist-sorted onil = nils
lemma-solist-sorted (:< {x = x} _ onil) = singls x
lemma-solist-sorted (:< b≤x (:< (lexy x≤y) ys)) = conss x≤y (lemma-solist-sorted (:< (lexy x≤y) ys))
| {
"alphanum_fraction": 0.6561886051,
"avg_line_length": 29.9411764706,
"ext": "agda",
"hexsha": "fb0b907750865875e404b8e12fe16d0f24cf3d70",
"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/SOList/Lower/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/SOList/Lower/Properties.agda",
"max_line_length": 101,
"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/SOList/Lower/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 187,
"size": 509
} |
module Float where
import Lvl
open import Type
postulate Float : Type{Lvl.𝟎}
{-# BUILTIN FLOAT Float #-}
| {
"alphanum_fraction": 0.6964285714,
"avg_line_length": 14,
"ext": "agda",
"hexsha": "3ff72daa13374862d2954b423c07c30cd80e7a18",
"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": "Float.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": "Float.agda",
"max_line_length": 29,
"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": "Float.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": 32,
"size": 112
} |
{-# OPTIONS --copatterns #-}
open import Common.Equality
open import Common.Product
id : {A : Set} → A → A
id x = x
record Functor (F : Set → Set) : Set₁ where
field
map : ∀ {A B} → (A → B) → F A → F B
map-id : ∀ {A}{x : F A} → map id x ≡ x
open Functor
test : {C : Set} → Functor (_×_ C)
map test f (c , a) = c , f a
map-id test = refl -- : map test id x ≡ x
-- needs to match against record constructor
-- x/(c,a) = proj₁ x / c, proj₂ x / a
| {
"alphanum_fraction": 0.5400843882,
"avg_line_length": 23.7,
"ext": "agda",
"hexsha": "38b9c99d43b89335e56640828f68aea3c221b943",
"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/Issue959.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/Issue959.agda",
"max_line_length": 51,
"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/Issue959.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": 171,
"size": 474
} |
{-# OPTIONS --without-K --exact-split #-}
module 02-pi where
import 00-preamble
open 00-preamble public
-- Section 2.3 The identity function, composition, and their laws
-- Definition 2.3.1
id : {i : Level} {A : UU i} → A → A
id a = a
-- Definition 2.3.2
_∘_ :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} →
(B → C) → ((A → B) → (A → C))
(g ∘ f) a = g (f a)
-- Exercises
-- Exercise 2.3
const : {i j : Level} (A : UU i) (B : UU j) (b : B) → A → B
const A B b x = b
-- Exercise 2.4
_∘'_ :
{i j k : Level} {A : UU i} {B : A → UU j} {C : (x : A) → B x → UU k} →
(g : (x : A) → (y : B x) → C x y) (f : (x : A) → B x) → (x : A) → C x (f x)
(g ∘' f) x = g x (f x)
-- Exercise 2.5
Π-swap : {i j k : Level} {A : UU i} {B : UU j} {C : A → (B → UU k)} →
((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y)
Π-swap f y x = f x y
| {
"alphanum_fraction": 0.4555160142,
"avg_line_length": 23.4166666667,
"ext": "agda",
"hexsha": "accb85bc3f9f4748b2cf889d46827cfb515dfad5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "hemangandhi/HoTT-Intro",
"max_forks_repo_path": "Agda/02-pi.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "hemangandhi/HoTT-Intro",
"max_issues_repo_path": "Agda/02-pi.agda",
"max_line_length": 77,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "hemangandhi/HoTT-Intro",
"max_stars_repo_path": "Agda/02-pi.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 408,
"size": 843
} |
------------------------------------------------------------------------
-- Some parsers which require a decidable token equality
------------------------------------------------------------------------
open import Relation.Binary
module RecursiveDescent.Inductive.Token (D : DecSetoid) where
open DecSetoid D using (_≟_) renaming (carrier to tok)
open import RecursiveDescent.Inductive
open import RecursiveDescent.Inductive.SimpleLib
open import Data.Maybe
open import Relation.Nullary
open import Data.Vec
open import Data.Vec1
-- Parsing a given token (or, really, a given equivalence class of
-- tokens).
sym : forall {nt} -> tok -> Parser tok nt _ tok
sym c = sat p
where
p : tok -> Maybe tok
p x with c ≟ x
... | yes _ = just x
... | no _ = nothing
-- Parsing a sequence of tokens.
string : forall {nt n} -> Vec tok n -> Parser tok nt _ (Vec tok n)
string cs = sequence (map₀₁ sym cs)
| {
"alphanum_fraction": 0.600877193,
"avg_line_length": 26.8235294118,
"ext": "agda",
"hexsha": "222894395697c7ab72266a3161085b70d6c135c0",
"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": "misc/RecursiveDescent/Inductive/Token.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "misc/RecursiveDescent/Inductive/Token.agda",
"max_line_length": 72,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yurrriq/parser-combinators",
"max_stars_repo_path": "misc/RecursiveDescent/Inductive/Token.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z",
"num_tokens": 214,
"size": 912
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Propositional (intensional) equality
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.PropositionalEquality where
open import Algebra
open import Algebra.Structures
open import Algebra.Definitions
import Axiom.Extensionality.Propositional as Ext
open import Axiom.UniquenessOfIdentityProofs
open import Function.Base
open import Function.Equality using (Π; _⟶_; ≡-setoid)
open import Level using (Level; _⊔_)
open import Data.Product using (∃)
open import Relation.Nullary using (yes ; no)
open import Relation.Nullary.Decidable.Core
open import Relation.Unary using (Pred)
open import Relation.Binary
open import Relation.Binary.Indexed.Heterogeneous
using (IndexedSetoid)
import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial
as Trivial
private
variable
a b c ℓ p : Level
A : Set a
B : Set b
C : Set c
------------------------------------------------------------------------
-- Re-export contents of core module
open import Relation.Binary.PropositionalEquality.Core public
------------------------------------------------------------------------
-- Some properties
subst₂ : ∀ (_∼_ : REL A B ℓ) {x y u v} → x ≡ y → u ≡ v → x ∼ u → y ∼ v
subst₂ _ refl refl p = p
cong-app : ∀ {A : Set a} {B : A → Set b} {f g : (x : A) → B x} →
f ≡ g → (x : A) → f x ≡ g x
cong-app refl x = refl
cong₂ : ∀ (f : A → B → C) {x y u v} → x ≡ y → u ≡ v → f x u ≡ f y v
cong₂ f refl refl = refl
------------------------------------------------------------------------
-- Structure of equality as a binary relation
isEquivalence : IsEquivalence {A = A} _≡_
isEquivalence = record
{ refl = refl
; sym = sym
; trans = trans
}
isDecEquivalence : Decidable _≡_ → IsDecEquivalence {A = A} _≡_
isDecEquivalence _≟_ = record
{ isEquivalence = isEquivalence
; _≟_ = _≟_
}
isPreorder : IsPreorder {A = A} _≡_ _≡_
isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = id
; trans = trans
}
------------------------------------------------------------------------
-- Bundles for equality as a binary relation
setoid : Set a → Setoid _ _
setoid A = record
{ Carrier = A
; _≈_ = _≡_
; isEquivalence = isEquivalence
}
decSetoid : Decidable {A = A} _≡_ → DecSetoid _ _
decSetoid _≟_ = record
{ _≈_ = _≡_
; isDecEquivalence = isDecEquivalence _≟_
}
preorder : Set a → Preorder _ _ _
preorder A = record
{ Carrier = A
; _≈_ = _≡_
; _∼_ = _≡_
; isPreorder = isPreorder
}
------------------------------------------------------------------------
-- Pointwise equality
infix 4 _≗_
_→-setoid_ : ∀ (A : Set a) (B : Set b) → Setoid _ _
A →-setoid B = ≡-setoid A (Trivial.indexedSetoid (setoid B))
_≗_ : (f g : A → B) → Set _
_≗_ {A = A} {B = B} = Setoid._≈_ (A →-setoid B)
:→-to-Π : ∀ {A : Set a} {B : IndexedSetoid A b ℓ} →
((x : A) → IndexedSetoid.Carrier B x) → Π (setoid A) B
:→-to-Π {B = B} f = record
{ _⟨$⟩_ = f
; cong = λ { refl → IndexedSetoid.refl B }
}
where open IndexedSetoid B using (_≈_)
→-to-⟶ : ∀ {A : Set a} {B : Setoid b ℓ} →
(A → Setoid.Carrier B) → setoid A ⟶ B
→-to-⟶ = :→-to-Π
------------------------------------------------------------------------
-- Inspect
-- Inspect can be used when you want to pattern match on the result r
-- of some expression e, and you also need to "remember" that r ≡ e.
-- See README.Inspect for an explanation of how/why to use this.
record Reveal_·_is_ {A : Set a} {B : A → Set b}
(f : (x : A) → B x) (x : A) (y : B x) :
Set (a ⊔ b) where
constructor [_]
field eq : f x ≡ y
inspect : ∀ {A : Set a} {B : A → Set b}
(f : (x : A) → B x) (x : A) → Reveal f · x is f x
inspect f x = [ refl ]
------------------------------------------------------------------------
-- Propositionality
isPropositional : Set a → Set a
isPropositional A = (a b : A) → a ≡ b
------------------------------------------------------------------------
-- Various equality rearrangement lemmas
trans-injectiveˡ : ∀ {x y z : A} {p₁ p₂ : x ≡ y} (q : y ≡ z) →
trans p₁ q ≡ trans p₂ q → p₁ ≡ p₂
trans-injectiveˡ refl = subst₂ _≡_ (trans-reflʳ _) (trans-reflʳ _)
trans-injectiveʳ : ∀ {x y z : A} (p : x ≡ y) {q₁ q₂ : y ≡ z} →
trans p q₁ ≡ trans p q₂ → q₁ ≡ q₂
trans-injectiveʳ refl eq = eq
cong-id : ∀ {x y : A} (p : x ≡ y) → cong id p ≡ p
cong-id refl = refl
cong-∘ : ∀ {x y : A} {f : B → C} {g : A → B} (p : x ≡ y) →
cong (f ∘ g) p ≡ cong f (cong g p)
cong-∘ refl = refl
module _ {P : Pred A p} {x y : A} where
subst-injective : ∀ (x≡y : x ≡ y) {p q : P x} →
subst P x≡y p ≡ subst P x≡y q → p ≡ q
subst-injective refl p≡q = p≡q
subst-subst : ∀ {z} (x≡y : x ≡ y) {y≡z : y ≡ z} {p : P x} →
subst P y≡z (subst P x≡y p) ≡ subst P (trans x≡y y≡z) p
subst-subst refl = refl
subst-subst-sym : (x≡y : x ≡ y) {p : P y} →
subst P x≡y (subst P (sym x≡y) p) ≡ p
subst-subst-sym refl = refl
subst-sym-subst : (x≡y : x ≡ y) {p : P x} →
subst P (sym x≡y) (subst P x≡y p) ≡ p
subst-sym-subst refl = refl
subst-∘ : ∀ {x y : A} {P : Pred B p} {f : A → B}
(x≡y : x ≡ y) {p : P (f x)} →
subst (P ∘ f) x≡y p ≡ subst P (cong f x≡y) p
subst-∘ refl = refl
subst-application : ∀ {a₁ a₂ b₁ b₂} {A₁ : Set a₁} {A₂ : Set a₂}
(B₁ : A₁ → Set b₁) {B₂ : A₂ → Set b₂}
{f : A₂ → A₁} {x₁ x₂ : A₂} {y : B₁ (f x₁)}
(g : ∀ x → B₁ (f x) → B₂ x) (eq : x₁ ≡ x₂) →
subst B₂ eq (g x₁ y) ≡ g x₂ (subst B₁ (cong f eq) y)
subst-application _ _ refl = refl
-- A lemma that is very similar to Lemma 2.4.3 from the HoTT book.
naturality : ∀ {x y} {x≡y : x ≡ y} {f g : A → B}
(f≡g : ∀ x → f x ≡ g x) →
trans (cong f x≡y) (f≡g y) ≡ trans (f≡g x) (cong g x≡y)
naturality {x = x} {x≡y = refl} f≡g =
f≡g x ≡⟨ sym (trans-reflʳ _) ⟩
trans (f≡g x) refl ∎
where open ≡-Reasoning
-- A lemma that is very similar to Corollary 2.4.4 from the HoTT book.
cong-≡id : ∀ {f : A → A} {x : A} (f≡id : ∀ x → f x ≡ x) →
cong f (f≡id x) ≡ f≡id (f x)
cong-≡id {f = f} {x} f≡id =
cong f fx≡x ≡⟨ sym (trans-reflʳ _) ⟩
trans (cong f fx≡x) refl ≡⟨ cong (trans _) (sym (trans-symʳ fx≡x)) ⟩
trans (cong f fx≡x) (trans fx≡x (sym fx≡x)) ≡⟨ sym (trans-assoc (cong f fx≡x)) ⟩
trans (trans (cong f fx≡x) fx≡x) (sym fx≡x) ≡⟨ cong (λ p → trans p (sym _)) (naturality f≡id) ⟩
trans (trans f²x≡x (cong id fx≡x)) (sym fx≡x) ≡⟨ cong (λ p → trans (trans f²x≡x p) (sym fx≡x)) (cong-id _) ⟩
trans (trans f²x≡x fx≡x) (sym fx≡x) ≡⟨ trans-assoc f²x≡x ⟩
trans f²x≡x (trans fx≡x (sym fx≡x)) ≡⟨ cong (trans _) (trans-symʳ fx≡x) ⟩
trans f²x≡x refl ≡⟨ trans-reflʳ _ ⟩
f≡id (f x) ∎
where open ≡-Reasoning; fx≡x = f≡id x; f²x≡x = f≡id (f x)
module _ (_≟_ : Decidable {A = A} _≡_) {x y : A} where
≡-≟-identity : (eq : x ≡ y) → x ≟ y ≡ yes eq
≡-≟-identity eq = dec-yes-irr (x ≟ y) (Decidable⇒UIP.≡-irrelevant _≟_) eq
≢-≟-identity : x ≢ y → ∃ λ ¬eq → x ≟ y ≡ no ¬eq
≢-≟-identity ¬eq = dec-no (x ≟ y) ¬eq
------------------------------------------------------------------------
-- Any operation forms a magma over _≡_
isMagma : (_∙_ : Op₂ A) → IsMagma _≡_ _∙_
isMagma _∙_ = record
{ isEquivalence = isEquivalence
; ∙-cong = cong₂ _∙_
}
magma : (_∙_ : Op₂ A) → Magma _ _
magma _∙_ = record
{ isMagma = isMagma _∙_
}
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.0
Extensionality = Ext.Extensionality
{-# WARNING_ON_USAGE Extensionality
"Warning: Extensionality was deprecated in v1.0.
Please use Extensionality from `Axiom.Extensionality.Propositional` instead."
#-}
extensionality-for-lower-levels = Ext.lower-extensionality
{-# WARNING_ON_USAGE extensionality-for-lower-levels
"Warning: extensionality-for-lower-levels was deprecated in v1.0.
Please use lower-extensionality from `Axiom.Extensionality.Propositional` instead."
#-}
∀-extensionality = Ext.∀-extensionality
{-# WARNING_ON_USAGE ∀-extensionality
"Warning: ∀-extensionality was deprecated in v1.0.
Please use ∀-extensionality from `Axiom.Extensionality.Propositional` instead."
#-}
| {
"alphanum_fraction": 0.5051534715,
"avg_line_length": 32.9440298507,
"ext": "agda",
"hexsha": "8178ed79d99065c45a6a29e9289774e369f3850d",
"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/Relation/Binary/PropositionalEquality.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/Relation/Binary/PropositionalEquality.agda",
"max_line_length": 111,
"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/Relation/Binary/PropositionalEquality.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": 3139,
"size": 8829
} |
{-# TERMINATING #-}
{-# NO_POSITIVITY_CHECK #-}
mutual
data D₁ : Set where
lam : (D₁ → D₁) → D₁
Foo₁ : Set
Foo₁ = Foo₁
{-# NON_TERMINATING #-}
{-# NO_POSITIVITY_CHECK #-}
mutual
data D₂ : Set where
lam : (D₂ → D₂) → D₂
Foo₂ : Set
Foo₂ = Foo₂
| {
"alphanum_fraction": 0.5467625899,
"avg_line_length": 14.6315789474,
"ext": "agda",
"hexsha": "92d5a18ea64e1ecd6fd10142e05b5863efbb60a5",
"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/Issue1755b.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/Issue1755b.agda",
"max_line_length": 27,
"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/Issue1755b.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": 102,
"size": 278
} |
record R0 : Set₁ where
constructor c0
field f0 : Set
record R1 : Set₁ where
constructor c1
field f1 : R0
test : R1 → Set₁
test x@(c1 x) = Set
| {
"alphanum_fraction": 0.6578947368,
"avg_line_length": 13.8181818182,
"ext": "agda",
"hexsha": "5f9b331549595ef299774fac30f130831dd43d66",
"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/Issue4631.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/Issue4631.agda",
"max_line_length": 22,
"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/Issue4631.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": 59,
"size": 152
} |
-- forcePi should be allowed to generate constraints
module Lambda where
data Bool : Set where
true : Bool
false : Bool
T : Bool -> Set
T true = Bool -> Bool
T false = Bool
id : {x : Bool} -> T x -> T x
id y = y
f : Bool -> Bool
f = id (\x -> x)
| {
"alphanum_fraction": 0.5953307393,
"avg_line_length": 13.5263157895,
"ext": "agda",
"hexsha": "1d6430c8e62015c24a861dfa9431415ec03c21cd",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/bugs/Lambda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/bugs/Lambda.agda",
"max_line_length": 52,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/bugs/Lambda.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": 83,
"size": 257
} |
-- Andreas, 2013-03-20 Problem was that CompiledClause.Match.unfoldCoinduction
-- did not instantiate metas
-- {-# OPTIONS -v tc.meta.assign:10 -v tc.reduce:100 -v tc.with.abstract:50 #-}
{-# OPTIONS --allow-unsolved-metas #-}
module Issue826 where
open import Common.Coinduction
postulate
A : Set
x : A
P : A → Set
p : P x
data Q : ∞ A → Set where
♯x = ♯ x
Foo : Q ♯x
Foo = goal
where
x′ : _
x′ = _ -- problem went away if we wrote ♯x here
goal : Q x′ -- ensures that x′ = ♯ x (instantiates meta)
goal = {!♭ x′!} -- normalization of this expression should be x, but was not
-- Note that ♭ x′ is definitionally equal to x:
ok : P (♭ x′)
ok = p
good : P x
good with (♭ x′) | p
good | y | p′ = p′
{- This still does not work because the underscore is solved too late,
only after with-abstraction is taking place.
bad : P (♭ x′)
bad with x | p
bad | y | p′ = p′
-}
| {
"alphanum_fraction": 0.6133625411,
"avg_line_length": 20.2888888889,
"ext": "agda",
"hexsha": "7f47bc3dabe788e96b407c356afceb9d2283bbb4",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue826.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue826.agda",
"max_line_length": 79,
"max_stars_count": 3,
"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/Issue826.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": 312,
"size": 913
} |
module SetInf where
id : ∀ {A} → A → A
id x = x
| {
"alphanum_fraction": 0.5306122449,
"avg_line_length": 9.8,
"ext": "agda",
"hexsha": "56dba006b564eab880908b4a5ecf80d101ce6adb",
"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/SetInf.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/SetInf.agda",
"max_line_length": 19,
"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/SetInf.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": 21,
"size": 49
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.