Search is not available for this dataset
text
string | meta
dict |
---|---|
module examplesPaperJFP.CounterCell where
open import Data.Product
open import Data.Nat.Base
open import Data.Nat.Show
open import Data.String.Base using (String; _++_)
open import Size
-- open import NativeIO
-- open import SizedIO.Base
-- open import SizedIO.Object
-- open import SizedIO.IOObject
-- open import SizedIO.ConsoleObject
-- open import SizedIO.Console hiding (main)
open import examplesPaperJFP.NativeIOSafe
open import examplesPaperJFP.ConsoleInterface
open import examplesPaperJFP.Console hiding (main)
open import examplesPaperJFP.Object using (Interface; Method; Result; CellMethod; get; put; CellResult; cellJ)
open import examplesPaperJFP.Sized hiding (program; main)
data CounterMethod A : Set where
super : (m : CellMethod A) → CounterMethod A
stats : CounterMethod A
pattern getᶜ = super get
pattern putᶜ x = super (put x)
statsCellI : (A : Set) → Interface
Method (statsCellI A) = CounterMethod A
Result (statsCellI A) (super m) = Result (cellJ A) m
Result (statsCellI A) stats = Unit
CounterC : (i : Size) → Set
CounterC = IOObject ConsoleInterface (statsCellI String)
counterCell : ∀{i} (c : CellC i) (ngets nputs : ℕ) → CounterC i
method (counterCell c ngets nputs) getᶜ =
method c get >>= λ { (s , c′) →
return (s , counterCell c′ (1 + ngets) nputs) }
method (counterCell c ngets nputs) (putᶜ x) =
method c (put x) >>= λ { (_ , c′) →
return (unit , counterCell c′ ngets (1 + nputs)) }
method (counterCell c ngets nputs) stats =
exec (putStrLn ("Counted "
++ show ngets ++ " calls to get and "
++ show nputs ++ " calls to put.")) λ _ →
return (unit , counterCell c ngets nputs)
program : String → IO ConsoleInterface ∞ Unit
program arg =
let c₀ = counterCell (simpleCell "Start") 0 0 in
method c₀ getᶜ >>= λ{ (s , c₁) →
exec (putStrLn s) λ _ →
method c₁ (putᶜ arg) >>= λ{ (_ , c₂) →
method c₂ getᶜ >>= λ{ (s′ , c₃) →
exec (putStrLn s′) λ _ →
method c₃ (putᶜ "Over!") >>= λ{ (_ , c₄) →
method c₄ stats >>= λ{ (_ , c₅) →
return unit }}}}}
main : NativeIO Unit
main = translateIO translateIOConsoleLocal (program "Hello")
| {
"alphanum_fraction": 0.629982669,
"avg_line_length": 32.9714285714,
"ext": "agda",
"hexsha": "4d6091193fa82bcf3dfe82b9f5a6bf77c75822f3",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "examples/examplesPaperJFP/CounterCell.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"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": "agda/ooAgda",
"max_issues_repo_path": "examples/examplesPaperJFP/CounterCell.agda",
"max_line_length": 110,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "examples/examplesPaperJFP/CounterCell.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 697,
"size": 2308
} |
module bools where
open import lib
----------------------------------------------------------------------
-- these problems are about the nand operator, also known as the Scheffer stroke
----------------------------------------------------------------------
nand-not : ∀ (b : 𝔹) → ~ b ≡ b nand b
nand-not tt = refl
nand-not ff = refl
nand-or : ∀ (b1 b2 : 𝔹) → b1 || b2 ≡ (b1 nand b1) nand (b2 nand b2)
nand-or tt tt = refl
nand-or tt ff = refl
nand-or ff tt = refl
nand-or ff ff = refl
nand-and : ∀ (b1 b2 : 𝔹) → b1 && b2 ≡ (b1 nand b2) nand (b1 nand b2)
nand-and tt tt = refl
nand-and tt ff = refl
nand-and ff tt = refl
nand-and ff ff = refl
nand-imp : ∀ (b1 b2 : 𝔹) → b1 imp b2 ≡ b1 nand (b2 nand b2)
nand-imp tt tt = refl
nand-imp tt ff = refl
nand-imp ff tt = refl
nand-imp ff ff = refl
ite-not : ∀(A : Set)(x : 𝔹)(y : A)(z : A) → if x then y else z ≡ if ~ x then z else y
ite-not A tt y z = refl
ite-not A ff y z = refl
&&-distrib : ∀ x y z → x && (y || z) ≡ (x && y) || (x && z)
&&-distrib tt tt tt = refl
&&-distrib tt tt ff = refl
&&-distrib tt ff tt = refl
&&-distrib tt ff ff = refl
&&-distrib ff tt tt = refl
&&-distrib ff tt ff = refl
&&-distrib ff ff tt = refl
&&-distrib ff ff ff = refl
combK : ∀ x y → x imp (y imp x) ≡ tt
combK tt tt = refl
combK tt ff = refl
combK ff tt = refl
combK ff ff = refl
combS : ∀ x y z → (x imp (y imp z)) ≡ tt → (x imp y) ≡ tt → x ≡ tt → z ≡ tt
combS tt tt tt x₁ x₂ x₃ = refl
| {
"alphanum_fraction": 0.5148448043,
"avg_line_length": 28.5,
"ext": "agda",
"hexsha": "2ba45644141ea02aba82bac9bc9c453d8d1e49c8",
"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": "51d54ed9c232f93baad238d328b77dd024344226",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout6",
"max_forks_repo_path": "bools.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "51d54ed9c232f93baad238d328b77dd024344226",
"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": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout6",
"max_issues_repo_path": "bools.agda",
"max_line_length": 86,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "51d54ed9c232f93baad238d328b77dd024344226",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout6",
"max_stars_repo_path": "bools.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 553,
"size": 1482
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cohomology.ChainComplex
open import cohomology.Theory
open import groups.KernelImage
open import cw.CW
module cw.cohomology.ReconstructedCochainComplex {i : ULevel} (OT : OrdinaryTheory i) where
open OrdinaryTheory OT
import cw.cohomology.TipAndAugment OT as TAA
import cw.cohomology.TipCoboundary OT as TC
import cw.cohomology.HigherCoboundary OT as HC
open import cw.cohomology.WedgeOfCells OT
cochain-template : ∀ {n} (⊙skel : ⊙Skeleton {i} n) {m}
→ Dec (m ≤ n) → AbGroup i
cochain-template ⊙skel (inr _) = Lift-abgroup {j = i} Unit-abgroup
cochain-template ⊙skel {m = 0} (inl 0≤n) = TAA.C2×CX₀-abgroup (⊙cw-take 0≤n ⊙skel) 0
cochain-template ⊙skel {m = S m} (inl Sm≤n) = CXₙ/Xₙ₋₁-abgroup (⊙cw-take Sm≤n ⊙skel) (ℕ-to-ℤ (S m))
cochain-is-abelian-template : ∀ {n} (⊙skel : ⊙Skeleton {i} n) {m} m≤n?
→ is-abelian (AbGroup.grp (cochain-template ⊙skel {m} m≤n?))
cochain-is-abelian-template ⊙skel m≤n? = AbGroup.comm (cochain-template ⊙skel m≤n?)
abstract
private
coboundary-first-template : ∀ {n} (⊙skel : ⊙Skeleton {i} n)
→ (0≤n : 0 ≤ n) (1≤n : 1 ≤ n)
→ ⊙cw-init (⊙cw-take 1≤n ⊙skel) == ⊙cw-take (≤-trans lteS 1≤n) ⊙skel
→ ⊙cw-take (≤-trans lteS 1≤n) ⊙skel == ⊙cw-take 0≤n ⊙skel
→ TAA.C2×CX₀ (⊙cw-take 0≤n ⊙skel) 0 →ᴳ CXₙ/Xₙ₋₁ (⊙cw-take 1≤n ⊙skel) 1
coboundary-first-template ⊙skel 0≤n 1≤n path₀ path₁ =
TC.cw-co∂-head (⊙cw-take 1≤n ⊙skel)
∘ᴳ transport!ᴳ (λ ⊙skel → TAA.C2×CX₀ ⊙skel 0) (path₀ ∙ path₁)
coboundary-higher-template : ∀ {n} (⊙skel : ⊙Skeleton {i} n)
→ {m : ℕ} (Sm≤n : S m ≤ n) (SSm≤n : S (S m) ≤ n)
→ ⊙cw-init (⊙cw-take SSm≤n ⊙skel) == ⊙cw-take (≤-trans lteS SSm≤n) ⊙skel
→ ⊙cw-take (≤-trans lteS SSm≤n) ⊙skel == ⊙cw-take Sm≤n ⊙skel
→ CXₙ/Xₙ₋₁ (⊙cw-take Sm≤n ⊙skel) (ℕ-to-ℤ (S m))
→ᴳ CXₙ/Xₙ₋₁ (⊙cw-take SSm≤n ⊙skel) (ℕ-to-ℤ (S (S m)))
coboundary-higher-template ⊙skel {m} Sm≤n SSm≤n path₀ path₁ =
HC.cw-co∂-last (⊙cw-take SSm≤n ⊙skel)
∘ᴳ transport!ᴳ (λ ⊙skel → CXₙ/Xₙ₋₁ ⊙skel (ℕ-to-ℤ (S m))) (path₀ ∙ path₁)
coboundary-template : ∀ {n} (⊙skel : ⊙Skeleton {i} n)
→ {m : ℕ} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n))
→ AbGroup.grp (cochain-template ⊙skel m≤n?)
→ᴳ AbGroup.grp (cochain-template ⊙skel Sm≤n?)
coboundary-template ⊙skel _ (inr _) = cst-hom
coboundary-template ⊙skel (inr m≰n) (inl Sm≤n) = ⊥-rec $ m≰n (≤-trans lteS Sm≤n)
coboundary-template ⊙skel {m = 0} (inl 0≤n) (inl 1≤n) =
coboundary-first-template ⊙skel 0≤n 1≤n (⊙cw-init-take 1≤n ⊙skel)
(ap (λ 0≤n → ⊙cw-take 0≤n ⊙skel) (≤-has-all-paths (≤-trans lteS 1≤n) 0≤n))
coboundary-template ⊙skel {m = S m} (inl Sm≤n) (inl SSm≤n) =
coboundary-higher-template ⊙skel Sm≤n SSm≤n (⊙cw-init-take SSm≤n ⊙skel)
(ap (λ Sm≤n → ⊙cw-take Sm≤n ⊙skel) (≤-has-all-paths (≤-trans lteS SSm≤n) Sm≤n))
cochain-complex : ∀ {n} → ⊙Skeleton {i} n → CochainComplex i
cochain-complex {n} ⊙skel = record {M} where
module M where
head : AbGroup i
head = C-abgroup 0 (⊙Lift ⊙Bool)
cochain : ℕ → AbGroup i
cochain m = cochain-template ⊙skel (≤-dec m n)
augment : C 0 (⊙Lift ⊙Bool) →ᴳ AbGroup.grp (cochain 0)
augment = TAA.cw-coε (⊙cw-take (O≤ n) ⊙skel)
coboundary : ∀ m → (AbGroup.grp (cochain m) →ᴳ AbGroup.grp (cochain (S m)))
coboundary m = coboundary-template ⊙skel (≤-dec m n) (≤-dec (S m) n)
{- Properties of coboundaries -}
{- lemmas of paths -}
private
abstract
path-lemma₀ : ∀ {n} (⊙skel : ⊙Skeleton {i} (S n)) {m} (m<n : m < n) (Sm<n : S m < n)
→ ap (λ m≤Sn → ⊙cw-take m≤Sn ⊙skel) (≤-has-all-paths (≤-trans lteS (lteSR (inr Sm<n))) (lteSR (inr m<n)))
== ap (λ m≤n → ⊙cw-take m≤n (⊙cw-init ⊙skel)) (≤-has-all-paths (≤-trans lteS (inr Sm<n)) (inr m<n))
path-lemma₀ ⊙skel m<n Sm<n =
ap (λ m≤Sn → ⊙cw-take m≤Sn ⊙skel) (≤-has-all-paths (≤-trans lteS (lteSR (inr Sm<n))) (lteSR (inr m<n)))
=⟨ ap (ap (λ m≤Sn → ⊙cw-take m≤Sn ⊙skel)) (contr-has-all-paths (≤-is-prop _ _) _ _) ⟩
ap (λ m≤Sn → ⊙cw-take m≤Sn ⊙skel) (ap (lteSR ∘ inr) (<-has-all-paths (<-trans ltS Sm<n) m<n))
=⟨ ∘-ap (λ m≤Sn → ⊙cw-take m≤Sn ⊙skel) (lteSR ∘ inr) _ ⟩
ap (λ Sm<n → ⊙cw-take (lteSR (inr Sm<n)) ⊙skel) (<-has-all-paths (<-trans ltS Sm<n) m<n)
=⟨ ap-∘ (λ m≤n → ⊙cw-take m≤n (⊙cw-init ⊙skel)) inr _ ⟩
ap (λ m≤n → ⊙cw-take m≤n (⊙cw-init ⊙skel)) (ap inr (<-has-all-paths (<-trans ltS Sm<n) m<n))
=⟨ ap (ap (λ m≤n → ⊙cw-take m≤n (⊙cw-init ⊙skel))) (contr-has-all-paths (≤-is-prop _ _) _ _) ⟩
ap (λ m≤n → ⊙cw-take m≤n (⊙cw-init ⊙skel)) (≤-has-all-paths (≤-trans lteS (inr Sm<n)) (inr m<n))
=∎
-- would be trivial with [≤-has-all-paths] defined with the set detection (issue #2003)
path-lemma₁ : ∀ {n} (⊙skel : ⊙Skeleton {i} (S (S n)))
→ ap (λ n≤SSn → ⊙cw-take n≤SSn ⊙skel) (≤-has-all-paths (lteSR lteS) (lteSR lteS))
== ap (λ n≤Sn → ⊙cw-take n≤Sn (⊙cw-init ⊙skel)) (≤-has-all-paths lteS lteS)
path-lemma₁ ⊙skel =
ap (λ n≤SSn → ⊙cw-take n≤SSn ⊙skel) (≤-has-all-paths (lteSR lteS) (lteSR lteS))
=⟨ ap (ap (λ n≤SSn → ⊙cw-take n≤SSn ⊙skel)) (contr-has-all-paths (≤-is-prop _ _) _ _) ⟩
idp
=⟨ ap (ap (λ n≤Sn → ⊙cw-take n≤Sn (⊙cw-init ⊙skel))) (contr-has-all-paths (≤-is-prop _ _) _ _) ⟩
ap (λ n≤Sn → ⊙cw-take n≤Sn (⊙cw-init ⊙skel)) (≤-has-all-paths lteS lteS)
=∎
-- would be trivial with [≤-has-all-paths] defined with the set detection (issue #2003)
path-lemma₂ : ∀ {n} (⊙skel : ⊙Skeleton {i} (S n))
→ ap (λ n≤Sn → ⊙cw-take n≤Sn ⊙skel) (≤-has-all-paths lteS lteS) == idp
path-lemma₂ ⊙skel =
ap (λ n≤Sn → ⊙cw-take n≤Sn ⊙skel) (≤-has-all-paths lteS lteS)
=⟨ ap (ap (λ n≤Sn → ⊙cw-take n≤Sn ⊙skel)) (contr-has-all-paths (≤-is-prop _ _) _ _) ⟩
idp
=∎
{- properties of coboundary-template -}
abstract
{- lemmas of the first coboundary -}
coboundary-first-template-descend-from-far : ∀ {n} (⊙skel : ⊙Skeleton {i} (S n)) 0<n 1<n
→ coboundary-template {n = S n} ⊙skel {0} (inl (lteSR (inr 0<n))) (inl (lteSR (inr 1<n)))
== coboundary-template {n = n} (⊙cw-init ⊙skel) (inl (inr 0<n)) (inl (inr 1<n))
coboundary-first-template-descend-from-far ⊙skel 0<n 1<n =
ap (coboundary-first-template ⊙skel (lteSR (inr 0<n)) (lteSR (inr 1<n)) (⊙cw-init-take (lteSR (inr 1<n)) ⊙skel))
(path-lemma₀ ⊙skel 0<n 1<n)
coboundary-first-template-descend-from-two : ∀ (⊙skel : ⊙Skeleton {i} 2)
→ coboundary-template {n = 2} ⊙skel (inl (lteSR lteS)) (inl lteS)
== coboundary-template {n = 1} (⊙cw-init ⊙skel) (inl lteS) (inl lteE)
coboundary-first-template-descend-from-two ⊙skel =
ap (coboundary-first-template ⊙skel (lteSR lteS) lteS idp) (path-lemma₁ ⊙skel)
coboundary-first-template-β : ∀ (⊙skel : ⊙Skeleton {i} 1)
→ coboundary-template {n = 1} ⊙skel (inl lteS) (inl lteE)
== TC.cw-co∂-head ⊙skel
coboundary-first-template-β ⊙skel = group-hom= $
ap (GroupHom.f ∘ coboundary-first-template ⊙skel lteS lteE idp) (path-lemma₂ ⊙skel)
{- lemmas of higher coboundaries -}
coboundary-higher-template-descend-from-far : ∀ {n} (⊙skel : ⊙Skeleton {i} (S n)) {m} Sm<n SSm<n
→ coboundary-template {n = S n} ⊙skel {m = S m} (inl (lteSR (inr Sm<n))) (inl (lteSR (inr SSm<n)))
== coboundary-template {n = n} (⊙cw-init ⊙skel) {m = S m} (inl (inr Sm<n)) (inl (inr SSm<n))
coboundary-higher-template-descend-from-far ⊙skel {m} Sm<n SSm<n =
ap (coboundary-higher-template ⊙skel (lteSR (inr Sm<n)) (lteSR (inr SSm<n)) (⊙cw-init-take (lteSR (inr SSm<n)) ⊙skel))
(path-lemma₀ ⊙skel Sm<n SSm<n)
coboundary-higher-template-descend-from-one-above : ∀ {n} (⊙skel : ⊙Skeleton {i} (S (S (S n))))
→ coboundary-template {n = S (S (S n))} ⊙skel {m = S n} (inl (lteSR lteS)) (inl lteS)
== coboundary-template {n = S (S n)} (⊙cw-init ⊙skel) {m = S n} (inl lteS) (inl lteE)
coboundary-higher-template-descend-from-one-above ⊙skel =
ap (coboundary-higher-template ⊙skel (lteSR lteS) lteS idp) (path-lemma₁ ⊙skel)
coboundary-higher-template-β : ∀ {n} (⊙skel : ⊙Skeleton {i} (S (S n)))
→ coboundary-template {n = S (S n)} ⊙skel {m = S n} (inl lteS) (inl lteE)
== HC.cw-co∂-last ⊙skel
coboundary-higher-template-β ⊙skel = group-hom= $
ap (GroupHom.f ∘ coboundary-higher-template ⊙skel lteS lteE idp) (path-lemma₂ ⊙skel)
| {
"alphanum_fraction": 0.5757610969,
"avg_line_length": 54.4683544304,
"ext": "agda",
"hexsha": "a881314baa1c8fb385a932598dfe1785038bfc00",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/cohomology/ReconstructedCochainComplex.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"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": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/cohomology/ReconstructedCochainComplex.agda",
"max_line_length": 124,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/cohomology/ReconstructedCochainComplex.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3936,
"size": 8606
} |
module Cats.Util.Logic.Constructive where
open import Data.Empty public
using (⊥ ; ⊥-elim)
open import Data.Product public
using (_,_ ; ∃-syntax ; Σ-syntax)
renaming (_×_ to _∧_ ; proj₁ to ∧-eliml ; proj₂ to ∧-elimr)
open import Data.Sum public
using ()
renaming (_⊎_ to _∨_ ; inj₁ to ∨-introl ; inj₂ to ∨-intror)
open import Data.Unit public
using (⊤)
renaming (tt to ⊤-intro)
open import Relation.Nullary public
using (¬_)
-- De Morgan's constructive rules
module _ {p q} {P : Set p} {Q : Set q} where
¬∨¬→¬∧ : ¬ P ∨ ¬ Q → ¬ (P ∧ Q)
¬∨¬→¬∧ (∨-introl ¬p) (p , _) = ¬p p
¬∨¬→¬∧ (∨-intror ¬q) (_ , q) = ¬q q
¬∨→¬∧¬ : ¬ (P ∨ Q) → ¬ P ∧ ¬ Q
¬∨→¬∧¬ ¬p∨q = (λ p → ¬p∨q (∨-introl p)) , (λ q → ¬p∨q (∨-intror q))
¬∧¬→¬∨ : ¬ P ∧ ¬ Q → ¬ (P ∨ Q)
¬∧¬→¬∨ (¬p , _) (∨-introl p) = ¬p p
¬∧¬→¬∨ (_ , ¬q) (∨-intror q) = ¬q q
-- Quantifiers and negation
module _ {u p} {U : Set u} {P : U → Set p} where
¬∃→∀¬ : ¬ (∃[ u ] (P u)) → ∀ u → ¬ P u
¬∃→∀¬ ¬∃ u pu = ¬∃ (u , pu)
∀¬→¬∃ : (∀ u → ¬ (P u)) → ¬ (∃[ u ] (P u))
∀¬→¬∃ ∀¬ (u , pu) = ∀¬ u pu
∃¬→¬∀ : ∃[ u ] (¬ P u) → ¬ (∀ u → P u)
∃¬→¬∀ (u , ¬pu) ∀upu = ¬pu (∀upu u)
| {
"alphanum_fraction": 0.4516407599,
"avg_line_length": 24.125,
"ext": "agda",
"hexsha": "d91a5a5f8ac4e5443830f25e05e5f6f28a37507b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Util/Logic/Constructive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Util/Logic/Constructive.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Util/Logic/Constructive.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 579,
"size": 1158
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group.Instances.DiffInt where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Int.MoreInts.DiffInt renaming ( _+_ to _+ℤ_ ; _-_ to _-ℤ_)
open import Cubical.Algebra.Group.Base
open import Cubical.HITs.SetQuotients
open GroupStr
ℤGroup : Group₀
fst ℤGroup = ℤ
1g (snd ℤGroup) = [ 0 , 0 ]
_·_ (snd ℤGroup) = _+ℤ_
inv (snd ℤGroup) = -ℤ_
isGroup (snd ℤGroup) = makeIsGroup
ℤ-isSet
+ℤ-assoc
(λ x → zero-identityʳ 0 x)
(λ x → zero-identityˡ 0 x)
-ℤ-invʳ
-ℤ-invˡ
| {
"alphanum_fraction": 0.568627451,
"avg_line_length": 25.5,
"ext": "agda",
"hexsha": "a56ca50eca5e40926e17cd10ed342a27eb83a773",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group/Instances/DiffInt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/Instances/DiffInt.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group/Instances/DiffInt.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 211,
"size": 663
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Groups
open import Groups.Homomorphisms.Definition
open import Groups.Definition
open import Numbers.Naturals.Naturals
open import Setoids.Setoids
open import Functions.Definition
open import Sets.EquivalenceRelations
open import Rings.Definition
open import Rings.Homomorphisms.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.Homomorphisms.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+A_ _*A_ : A → A → A} (R : Ring S _+A_ _*A_) where
open import Groups.Homomorphisms.Lemmas2 (Ring.additiveGroup R)
imageRing : {c d : _} {B : Set c} {T : Setoid {c} {d} B} {_+B_ : B → B → B} {_*B_ : B → B → B} → (f : A → B) → SetoidSurjection S T f → ({x y : A} → Setoid._∼_ T (f (x +A y)) ((f x) +B (f y))) → ({x y : A} → Setoid._∼_ T (f (x *A y)) ((f x) *B (f y))) → ({x y m n : B} → Setoid._∼_ T x m → Setoid._∼_ T y n → Setoid._∼_ T (x +B y) (m +B n)) → ({x y m n : B} → Setoid._∼_ T x m → Setoid._∼_ T y n → Setoid._∼_ T (x *B y) (m *B n)) → Ring T _+B_ _*B_
Ring.additiveGroup (imageRing f surj respects+ respects* +wd *wd) = imageGroup f surj respects+ +wd
Ring.*WellDefined (imageRing f surj respects+ respects* +wd *wd) = *wd
Ring.1R (imageRing f surj respects+ respects* +wd *wd) = f (Ring.1R R)
Ring.groupIsAbelian (imageRing {T = T} f record { surjective = surjective ; wellDefined = wellDefined } respects+ respects* +wd *wd) {a} {b} with surjective {a}
... | x , fx=a with surjective {b}
... | y , fy=b = transitive (+wd (symmetric fx=a) (symmetric fy=b)) (transitive (transitive (symmetric respects+) (transitive (wellDefined (Ring.groupIsAbelian R)) respects+)) (+wd fy=b fx=a))
where
open Setoid T
open Equivalence eq
Ring.*Associative (imageRing {T = T} f record { surjective = surjective ; wellDefined = wellDefined } respects+ respects* +wd *wd) {a} {b} {c} with surjective {a}
... | x , fx=a with surjective {b}
... | y , fy=b with surjective {c}
... | z , fz=c = transitive (*wd (symmetric fx=a) (transitive (*wd (symmetric fy=b) (symmetric fz=c)) (symmetric respects*))) (transitive (transitive (symmetric respects*) (transitive (wellDefined (Ring.*Associative R)) respects*)) (*wd (transitive respects* (*wd fx=a fy=b)) fz=c))
where
open Setoid T
open Equivalence eq
Ring.*Commutative (imageRing {T = T} f record { surjective = surjective ; wellDefined = wellDefined } respects+ respects* +wd *wd) {a} {b} with surjective {a}
... | x , fx=a with surjective {b}
... | y , fy=b = transitive (*wd (symmetric fx=a) (symmetric fy=b)) (transitive (transitive (symmetric respects*) (transitive (wellDefined (Ring.*Commutative R)) respects*)) (*wd fy=b fx=a))
where
open Setoid T
open Equivalence eq
Ring.*DistributesOver+ (imageRing {T = T} f record { surjective = surjective ; wellDefined = wellDefined } respects+ respects* +wd *wd) {a} {b} {c} with surjective {a}
... | x , fx=a with surjective {b}
... | y , fy=b with surjective {c}
... | z , fz=c = transitive (*wd (symmetric fx=a) (+wd (symmetric fy=b) (symmetric fz=c))) (transitive (transitive (transitive (*wd reflexive (symmetric respects+)) (symmetric respects*)) (transitive (transitive (wellDefined (Ring.*DistributesOver+ R)) respects+) (+wd respects* respects*))) (+wd (*wd fx=a fy=b) (*wd fx=a fz=c)))
where
open Setoid T
open Equivalence eq
Ring.identIsIdent (imageRing {T = T} f record { wellDefined = wellDefined ; surjective = surjective } respects+ respects* +wd *wd) {b} with surjective {b}
Ring.identIsIdent (imageRing {T = T} f record { wellDefined = wellDefined ; surjective = surjective } respects+ respects* +wd *wd) {b} | a , fa=b = transitive (transitive (*wd reflexive (symmetric fa=b)) (transitive (symmetric respects*) (wellDefined (Ring.identIsIdent R)))) fa=b
where
open Setoid T
open Equivalence eq
homToImageRing : {c d : _} {B : Set c} {T : Setoid {c} {d} B} {_+B_ : B → B → B} {_*B_ : B → B → B} → (f : A → B) → (surj : SetoidSurjection S T f) → (respects+ : {x y : A} → Setoid._∼_ T (f (x +A y)) ((f x) +B (f y))) → (respects* : {x y : A} → Setoid._∼_ T (f (x *A y)) ((f x) *B (f y))) → (+wd : {x y m n : B} → Setoid._∼_ T x m → Setoid._∼_ T y n → Setoid._∼_ T (x +B y) (m +B n)) → (*wd : {x y m n : B} → Setoid._∼_ T x m → Setoid._∼_ T y n → Setoid._∼_ T (x *B y) (m *B n)) → RingHom R (imageRing f surj respects+ respects* +wd *wd) f
RingHom.preserves1 (homToImageRing {T = T} f surj respects+ respects* +wd *wd) = reflexive
where
open Setoid T
open Equivalence eq
RingHom.ringHom (homToImageRing f surj respects+ respects* +wd *wd) = respects*
RingHom.groupHom (homToImageRing f surj respects+ respects* +wd *wd) = homToImageGroup f surj respects+ +wd
| {
"alphanum_fraction": 0.6532071504,
"avg_line_length": 75.4761904762,
"ext": "agda",
"hexsha": "79fff15a95e41668a0fbd77a7f62acba8ada51ab",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Rings/Homomorphisms/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Rings/Homomorphisms/Lemmas.agda",
"max_line_length": 540,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Rings/Homomorphisms/Lemmas.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": 1668,
"size": 4755
} |
-- {-# OPTIONS --sized-types #-}
module Issue166NotSized where
postulate
Size : Set
↑_ : Size → Size
∞ : Size
-- {-# BUILTIN SIZE Size #-}
-- {-# BUILTIN SIZESUC ↑_ #-}
-- {-# BUILTIN SIZEINF ∞ #-}
data ⊥ : Set where
module M (A : Set) where
data SizedNat : {i : Size} → Set where
zero : {i : Size} → SizedNat {↑ i}
suc : {i : Size} → SizedNat {i} → SizedNat {↑ i}
open M ⊥
| {
"alphanum_fraction": 0.5328467153,
"avg_line_length": 17.8695652174,
"ext": "agda",
"hexsha": "56db6da1f319f5009fe71c8bc5745f490bb269a7",
"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/Issue166NotSized.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/Issue166NotSized.agda",
"max_line_length": 53,
"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/Issue166NotSized.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 145,
"size": 411
} |
------------------------------------------------------------------------
-- Total parser combinators (very short version)
-- Nils Anders Danielsson
------------------------------------------------------------------------
module Short where
open import Category.Monad
open import Coinduction
open import Data.Bool
import Data.BoundedVec.Inefficient as BoundedVec
open import Data.Char
import Data.Colist as Colist
open import Data.List as List
open import Data.Maybe
open import Data.Nat
open import Data.Nat.Show
open import Data.String using (Costring)
open import Function
open import IO hiding (return) renaming (_>>=_ to _>>=IO_)
open import Relation.Nullary.Decidable
open RawMonadPlus List.monadPlus using () renaming (_>>=_ to _>>=′_)
infix 7 _⋆ _+
infixl 6 _>>=_ _>>=app_
infixl 5 _∣_
------------------------------------------------------------------------
-- Helper functions
flatten : {A : Set} → Maybe (List A) → List A
flatten nothing = []
flatten (just xs) = xs
app : {A B : Set} → Maybe (A → List B) → A → List B
app nothing x = []
app (just f) x = f x
_>>=app_ : {A B : Set} → List A → Maybe (A → List B) → List B
xs >>=app nothing = []
xs >>=app just f = xs >>=′ f
------------------------------------------------------------------------
-- Parsers
mutual
data Parser : (R : Set) → List R → Set₁ where
return : ∀ {R} (x : R) → Parser R [ x ]
fail : ∀ {R} → Parser R []
token : Parser Char []
_∣_ : ∀ {R xs₁ xs₂}
(p₁ : Parser R xs₁ )
(p₂ : Parser R xs₂) →
Parser R (xs₁ ++ xs₂)
_>>=_ : ∀ {R₁ R₂ xs} {f : Maybe (R₁ → List R₂)}
(p₁ : ∞⟨ f ⟩Parser R₁ (flatten xs) )
(p₂ : (x : R₁) → ∞⟨ xs ⟩Parser R₂ (app f x)) →
Parser R₂ (flatten xs >>=app f)
∞⟨_⟩Parser : {R₂ : Set} → Maybe R₂ → (R₁ : Set) → List R₁ → Set₁
∞⟨ nothing ⟩Parser R₁ xs = ∞ (Parser R₁ xs)
∞⟨ just _ ⟩Parser R₁ xs = Parser R₁ xs
------------------------------------------------------------------------
-- Derived combinators
sat : ∀ {R} → (Char → Maybe R) → Parser R []
sat {R} p = token >>= (ok ∘ p)
where
ok-index : Maybe R → List R
ok-index nothing = []
ok-index (just x) = [ x ]
ok : (x : Maybe R) → Parser R (ok-index x)
ok nothing = fail
ok (just x) = return x
tok : Char → Parser Char []
tok t = sat (λ t′ → if t == t′ then just t′ else nothing)
return⋆ : ∀ {R} (xs : List R) → Parser R xs
return⋆ [] = fail
return⋆ (x ∷ xs) = return x ∣ return⋆ xs
mutual
_⋆ : ∀ {R} → Parser R [] → Parser (List R) _
p ⋆ = return [] ∣ p +
_+ : ∀ {R} → Parser R [] → Parser (List R) _
p + = p >>= λ x → ♯ (
p ⋆ >>= λ xs →
return (x ∷ xs) )
digit = sat (λ t → if in-range t then just (to-number t) else nothing)
where
in-range : Char → Bool
in-range t = ⌊ toNat '0' ≤? toNat t ⌋ ∧
⌊ toNat t ≤? toNat '9' ⌋
to-number : Char → ℕ
to-number t = toNat t ∸ toNat '0'
number = digit + >>= return ∘ foldl (λ n d → 10 * n + d) 0
------------------------------------------------------------------------
-- Parser interpreter
delayed? : ∀ {R R′ xs} {m : Maybe R′} → ∞⟨ m ⟩Parser R xs → Maybe R′
delayed? {m = m} _ = m
delayed?′ : ∀ {R₁ R₂ R′ : Set} {m : Maybe R′} {f : R₁ → List R₂} →
((x : R₁) → ∞⟨ m ⟩Parser R₂ (f x)) → Maybe R′
delayed?′ {m = m} _ = m
∂-initial : ∀ {R xs} → Parser R xs → Char → List R
∂-initial (return x) t = []
∂-initial fail t = []
∂-initial token t = [ t ]
∂-initial (p₁ ∣ p₂) t = ∂-initial p₁ t ++ ∂-initial p₂ t
∂-initial (p₁ >>= p₂) t with delayed? p₁ | delayed?′ p₂
... | just f | nothing = ∂-initial p₁ t >>=′ f
... | just f | just xs = (∂-initial p₁ t >>=′ f) ++
(xs >>=′ λ x → ∂-initial (p₂ x) t)
... | nothing | nothing = []
... | nothing | just xs = xs >>=′ λ x → ∂-initial (p₂ x) t
∂ : ∀ {R xs} (p : Parser R xs) (t : Char) → Parser R (∂-initial p t)
∂ (return x) t = fail
∂ fail t = fail
∂ token t = return t
∂ (p₁ ∣ p₂) t = ∂ p₁ t ∣ ∂ p₂ t
∂ (p₁ >>= p₂) t with delayed? p₁ | delayed?′ p₂
... | just f | nothing = ∂ p₁ t >>= (λ x → ♭ (p₂ x))
... | just f | just xs = ∂ p₁ t >>= (λ x → p₂ x)
∣ return⋆ xs >>= λ x → ∂ (p₂ x) t
... | nothing | nothing = ♯ ∂ (♭ p₁) t >>= (λ x → ♭ (p₂ x))
... | nothing | just xs = ♯ ∂ (♭ p₁) t >>= (λ x → p₂ x)
∣ return⋆ xs >>= λ x → ∂ (p₂ x) t
parse : ∀ {R xs} → Parser R xs → List Char → List R
parse {xs = xs} p [] = xs
parse p (t ∷ s) = parse (∂ p t) s
------------------------------------------------------------------------
-- Example
data Expr : Set where
num : (n : ℕ) → Expr
plus : (e₁ e₂ : Expr) → Expr
times : (e₁ e₂ : Expr) → Expr
⟦_⟧ : Expr → ℕ
⟦ num n ⟧ = n
⟦ plus e₁ e₂ ⟧ = ⟦ e₁ ⟧ + ⟦ e₂ ⟧
⟦ times e₁ e₂ ⟧ = ⟦ e₁ ⟧ * ⟦ e₂ ⟧
mutual
term = factor
∣ ♯ term >>= λ e₁ →
tok '+' >>= λ _ →
factor >>= λ e₂ →
return (plus e₁ e₂)
factor = atom
∣ ♯ factor >>= λ e₁ →
tok '*' >>= λ _ →
atom >>= λ e₂ →
return (times e₁ e₂)
atom = (number >>= return ∘ num)
∣ tok '(' >>= λ _ →
♯ term >>= λ e →
tok ')' >>= λ _ →
return e
------------------------------------------------------------------------
-- IO
toList : Costring → List Char
toList = BoundedVec.toList ∘ Colist.take 100000
main = run $
♯ getContents >>=IO λ s → ♯
let s′ = takeWhile (not ∘ _==_ '\n') $ toList s
es = parse term s′ in
mapM′ (putStrLn ∘ show ∘ ⟦_⟧) (Colist.fromList es)
| {
"alphanum_fraction": 0.4276944065,
"avg_line_length": 30.7015706806,
"ext": "agda",
"hexsha": "adcdce970d1d8d5e4858534016943a28acbc0bcd",
"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/Short.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/Short.agda",
"max_line_length": 73,
"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/Short.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": 1973,
"size": 5864
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- A solver that uses reflection to automatically obtain and solve
-- equations over rings.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Tactic.RingSolver where
open import Agda.Builtin.Reflection
open import Algebra
open import Data.Fin as Fin using (Fin)
open import Data.Vec as Vec using (Vec; _∷_; [])
open import Data.List as List using (List; _∷_; [])
open import Data.Maybe.Base as Maybe using (Maybe; just; nothing; fromMaybe)
open import Data.Nat using (ℕ; suc; zero; _<ᵇ_)
open import Data.Nat.Reflection using (toTerm; toFinTerm)
open import Data.Bool using (Bool; if_then_else_; true; false)
open import Data.Unit using (⊤)
open import Data.String using (String)
open import Data.Product using (_,_)
open import Function
open import Reflection.Argument
open import Reflection.Term
open import Reflection.TypeChecking.MonadSyntax
open import Tactic.RingSolver.NonReflective renaming (solve to solve-fn)
open import Tactic.RingSolver.Core.AlmostCommutativeRing
open import Tactic.RingSolver.Core.NatSet as NatSet
open import Tactic.RingSolver.Core.ReflectionHelp
open AlmostCommutativeRing
------------------------------------------------------------------------
-- Processing
------------------------------------------------------------------------
private
record RingNames : Set where
constructor +⇒_*⇒_^⇒_-⇒_
field
+′ *′ ^′ -′ : Maybe Name
checkIsRing : Term → TC Term
checkIsRing ring = checkType ring (def (quote AlmostCommutativeRing) (2 ⋯⟨∷⟩ []))
getVariableIDs : Term → Maybe NatSet
getVariableIDs = go []
where
go : NatSet → Term → Maybe NatSet
go t (con (quote List._∷_) (_ ∷ _ ∷ var i [] ⟨∷⟩ xs ⟨∷⟩ _)) = go (insert i t) xs
go t (con (quote List.List.[]) _) = just t
go _ _ = nothing
module OverRing (ring : Term) where
-- Takes the name of a function that takes the ring as it's first
-- explicit argument and the terms of it's arguments and inserts
-- the required ring arguments
-- e.g. "_+_" $ʳ xs = "_+_ {_} {_} ring xs"
_$ʳ_ : Name → Args Term → Term
nm $ʳ args = def nm (2 ⋯⟅∷⟆ ring ⟨∷⟩ args)
checkIsListOfVariables : Term → TC Term
checkIsListOfVariables xs =
checkType xs (def (quote List) (1 ⋯⟅∷⟆ (quote Carrier $ʳ []) ⟨∷⟩ [])) >>= normalise
getFieldName : Name → TC (Maybe Name)
getFieldName nm = normalise (nm $ʳ []) <&> λ where
(def f args) → just f
_ → nothing
getRingOperatorNames : TC RingNames
getRingOperatorNames = ⦇
+⇒ getFieldName (quote _+_)
*⇒ getFieldName (quote _*_)
^⇒ getFieldName (quote _^_)
-⇒ getFieldName (quote -_)
⦈
module _ (nms : RingNames) (numVars : ℕ) where
open RingNames nms
-- This function applies the hidden arguments that the constructors
-- that Expr needs. The first is the universe level, the second is the
-- type it contains, and the third is the number of variables it's
-- indexed by. All three of these could likely be inferred, but to
-- make things easier we supply the third because we know it.
_$ᵉ_ : Name → List (Arg Term) → Term
e $ᵉ xs = con e (1 ⋯⟅∷⟆ quote Carrier $ʳ [] ⟅∷⟆ toTerm numVars ⟅∷⟆ xs)
-- A constant expression.
Κ′ : Term → Term
Κ′ x = quote Κ $ᵉ (x ⟨∷⟩ [])
_⇓≟_ : Maybe Name → Name → Bool
nothing ⇓≟ _ = false
just x ⇓≟ y = primQNameEquality x y
{-# INLINE _⇓≟_ #-}
module ToExpr (Ι′ : ℕ → Maybe Term) where
mutual
-- Application of a ring operator often doesn't have a type as
-- simple as "Carrier → Carrier → Carrier": there may be hidden
-- arguments, etc. Here, we do our best to handle those cases,
-- by just taking the last two explicit arguments.
E⟨_⟩₂ : Name → List (Arg Term) → Term
E⟨ nm ⟩₂ (x ⟨∷⟩ y ⟨∷⟩ []) = nm $ᵉ (E x ⟨∷⟩ E y ⟨∷⟩ [])
E⟨ nm ⟩₂ (x ∷ xs) = E⟨ nm ⟩₂ xs
E⟨ nm ⟩₂ _ = unknown
E⟨_⟩₁ : Name → List (Arg Term) → Term
E⟨ nm ⟩₁ (x ⟨∷⟩ []) = nm $ᵉ (E x ⟨∷⟩ [])
E⟨ nm ⟩₁ (x ∷ xs) = E⟨ nm ⟩₁ xs
E⟨ _ ⟩₁ _ = unknown
E⟨^⟩ : List (Arg Term) → Term
E⟨^⟩ (x ⟨∷⟩ y ⟨∷⟩ []) = quote _⊛_ $ᵉ (E x ⟨∷⟩ y ⟨∷⟩ [])
E⟨^⟩ (x ∷ xs) = E⟨^⟩ xs
E⟨^⟩ _ = unknown
-- When trying to figure out the shape of an expression, one of
-- the difficult tasks is recognizing where constants in the
-- underlying ring are used. If we were only dealing with ℕ, we
-- might look for its constructors: however, we want to deal with
-- arbitrary types which implement AlmostCommutativeRing. If the
-- Term type contained type information we might be able to
-- recognize it there, but it doesn't.
--
-- We're in luck, though, because all other cases in the following
-- function *are* recognizable. As a result, the "catch-all" case
-- will just assume that it has a constant expression.
E : Term → Term
-- Recognise the ring's fields
E (def (quote _+_) xs) = E⟨ quote _⊕_ ⟩₂ xs
E (def (quote _*_) xs) = E⟨ quote _⊗_ ⟩₂ xs
E (def (quote _^_) xs) = E⟨^⟩ xs
E (def (quote -_) xs) = E⟨ quote ⊝_ ⟩₁ xs
-- Recognise the underlying implementation of the ring's fields
E (def nm xs) = if +′ ⇓≟ nm then E⟨ quote _⊕_ ⟩₂ xs else
if *′ ⇓≟ nm then E⟨ quote _⊗_ ⟩₂ xs else
if ^′ ⇓≟ nm then E⟨^⟩ xs else
if -′ ⇓≟ nm then E⟨ quote ⊝_ ⟩₁ xs else
Κ′ (def nm xs)
-- Variables
E v@(var x _) = fromMaybe (Κ′ v) (Ι′ x)
-- Special case to recognise "suc" for naturals
E (con (quote ℕ.suc) (x ⟨∷⟩ [])) = quote _⊕_ $ᵉ (Κ′ (toTerm 1) ⟨∷⟩ E x ⟨∷⟩ [])
E t = Κ′ t
callSolver : Vec String numVars → Term → Term → Args Type
callSolver nms lhs rhs =
2 ⋯⟅∷⟆ ring ⟨∷⟩ toTerm numVars ⟨∷⟩
vlams nms (quote _⊜_ $ʳ (toTerm numVars ⟨∷⟩ E lhs ⟨∷⟩ E rhs ⟨∷⟩ [])) ⟨∷⟩
hlams nms (quote refl $ʳ (1 ⋯⟅∷⟆ [])) ⟨∷⟩
[]
where
Ι′ : ℕ → Maybe Term
Ι′ i = if i <ᵇ numVars then just (var i []) else nothing
open ToExpr Ι′
constructSoln : NatSet → Term → Term → Term
constructSoln t lhs rhs =
quote trans $ʳ (3 ⋯⟅∷⟆
quote sym $ʳ (2 ⋯⟅∷⟆
quote Ops.correct $ʳ (1 ⋯⟅∷⟆ E lhs ⟨∷⟩ ρ ⟨∷⟩ []) ⟨∷⟩ [])
⟨∷⟩
(quote Ops.correct $ʳ (1 ⋯⟅∷⟆ E rhs ⟨∷⟩ ρ ⟨∷⟩ [])) ⟨∷⟩
[])
where
Ι′ : ℕ → Maybe Term
Ι′ i = Maybe.map (λ x → quote Ι $ᵉ (toFinTerm x ⟨∷⟩ [])) (lookup i t)
open ToExpr Ι′
ρ : Term
ρ = curriedTerm t
------------------------------------------------------------------------
-- Macros
------------------------------------------------------------------------
-- This is the main macro which solves for equations in which the variables
-- are universally quantified over:
--
-- lemma : ∀ x y → x + y ≈ y + x
-- lemma = solve-∀ TypeRing
--
-- where TypRing is your implementation of AlmostCommutativeRing. (Find some
-- example implementations in Polynomial.Solver.Ring.AlmostCommutativeRing.Instances).
solve-∀-macro : Name → Term → TC ⊤
solve-∀-macro ring hole = do
ring′ ← checkIsRing (def ring [])
commitTC
let open OverRing ring′
operatorNames ← getRingOperatorNames
hole′ ← inferType hole >>= reduce
let variables , k , equation = underPi hole′
just (lhs ∷ rhs ∷ []) ← pure (getArgs 2 equation)
where nothing → typeError (strErr "Malformed call to solve." ∷
strErr "Expected target type to be like: ∀ x y → x + y ≈ y + x." ∷
strErr "Instead: " ∷
termErr hole′ ∷
[])
unify hole (def (quote solve-fn) (callSolver operatorNames variables k lhs rhs))
macro
solve-∀ : Name → Term → TC ⊤
solve-∀ = solve-∀-macro
-- Use this macro when you want to solve something *under* a lambda. For example:
-- say you have a long proof, and you just want the solver to deal with an
-- intermediate step. Call it like so:
--
-- lemma₃ : ∀ x y → x + y * 1 + 3 ≈ 2 + 1 + y + x
-- lemma₃ x y = begin
-- x + y * 1 + 3 ≈⟨ +-comm x (y * 1) ⟨ +-cong ⟩ refl ⟩
-- y * 1 + x + 3 ≈⟨ solve (x ∷ y ∷ []) Int.ring ⟩
-- 3 + y + x ≡⟨ refl ⟩
-- 2 + 1 + y + x ∎
--
-- The first argument is the free variables, and the second is the
-- ring implementation (as before).
--
-- One thing to note here is that we need to be able to infer *both* sides of
-- the equality, which the normal equaltional reasoning combinators don't let you
-- do. You'll need the combinators defined in Relation.Binary.Reasoning.Inference.
-- These are just as powerful as the others, but have slightly better inference properties.
solve-macro : Term → Name → Term → TC ⊤
solve-macro i ring hole = do
ring′ ← checkIsRing (def ring [])
commitTC
let open OverRing ring′
operatorNames ← getRingOperatorNames
listOfVariables′ ← checkIsListOfVariables i
commitTC
hole′ ← inferType hole >>= reduce
just vars′ ← pure (getVariableIDs listOfVariables′)
where nothing → typeError (strErr "Malformed call to solve." ∷
strErr "First argument should be a list of free variables." ∷
strErr "Instead: " ∷
termErr listOfVariables′ ∷
[])
just (lhs ∷ rhs ∷ []) ← pure (getArgs 2 hole′)
where nothing → typeError (strErr "Malformed call to solve." ∷
strErr "First argument should be a list of free variables." ∷
strErr "Instead: " ∷
termErr hole′ ∷
[])
unify hole (constructSoln operatorNames (List.length vars′) vars′ lhs rhs)
macro
solve : Term → Name → Term → TC ⊤
solve = solve-macro
| {
"alphanum_fraction": 0.5325426945,
"avg_line_length": 40.694980695,
"ext": "agda",
"hexsha": "7cab859fed3d2f6060b6a80c5785a4bedccdd0a9",
"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/Tactic/RingSolver.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/Tactic/RingSolver.agda",
"max_line_length": 97,
"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/Tactic/RingSolver.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": 3101,
"size": 10540
} |
{-# OPTIONS --without-K #-}
open import homotopy.3x3.Common
open import homotopy.3x3.PushoutPushout
open import homotopy.3x3.Transpose
module homotopy.JoinAssoc3x3 {i} (A B C : Type i) where
open M using (Pushout^2)
join-assoc-span^2 : Span^2 {i}
join-assoc-span^2 =
span^2 A (A × C) (A × C) (A × B) ((A × B) × C) (A × C) B (B × C) C
fst (idf _) fst (λ u → fst (fst u) , snd u) fst snd fst snd (λ u → fst (fst u) , snd u) (λ u → snd (fst u) , snd u) (idf _) snd
(λ _ → idp) (λ _ → idp) (λ _ → idp) (λ _ → idp)
open import homotopy.3x3.Commutes join-assoc-span^2 as PP
module _ (A B : Type i) (f : B → A) where
lemma3-fun : Pushout (span A B B f (idf _)) → A
lemma3-fun = Lemma3Fun.f module _ where
module Lemma3Fun = PushoutRec (idf _) f (λ _ → idp)
lemma3-eq : (x : Pushout (span A B B f (idf _))) → left (lemma3-fun x) == x
lemma3-eq = Pushout-elim (λ _ → idp) glue (λ b → ↓-∘=idf-in left lemma3-fun (idp,=□idp,-in idp ∙□-i/ idp / ! (ap (ap left) (Lemma3Fun.glue-β b)) /))
lemma3 : Pushout (span A B B f (idf _)) ≃ A
lemma3 = equiv lemma3-fun left (λ _ → idp) lemma3-eq
module _ (A B : Type i) (f : B → A) where
lemma3'-fun : Pushout (span B A B (idf _) f) → A
lemma3'-fun = Lemma3'Fun.f module _ where
module Lemma3'Fun = PushoutRec f (idf _) (λ _ → idp)
lemma3'-eq : (x : Pushout (span B A B (idf _) f)) → right (lemma3'-fun x) == x
lemma3'-eq = ! ∘ (Pushout-elim glue (λ _ → idp) (λ b → ↓-idf=∘-in right lemma3'-fun (,idp=□,idp-in idp ∙□-i/ ap (ap right) (Lemma3'Fun.glue-β b) / idp /)))
lemma3' : Pushout (span B A B (idf _) f) ≃ A
lemma3' = equiv lemma3'-fun right (λ _ → idp) lemma3'-eq
module _ (X Y Z T : Type i) (f : Z → X) (g : Z → Y) where
private
P1 : Type i
P1 = Pushout (span X Y Z f g)
P2 : Type i
P2 = Pushout (span (X × T) (Y × T) (Z × T) (λ u → (f (fst u) , snd u)) (λ u → (g (fst u) , snd u)))
lemma4 : P2 ≃ (P1 × T)
lemma4 = equiv to from to-from from-to module Lemma4 where
to : P2 → P1 × T
to = To.f module _ where
module To = PushoutRec (λ u → (left (fst u) , snd u)) (λ u → (right (fst u) , snd u)) (λ u → pair×= (glue (fst u)) idp)
from-curr : T → (P1 → P2)
from-curr t = FromCurr.f module _ where
module FromCurr = PushoutRec {D = P2} (λ x → left (x , t)) (λ y → right (y , t)) (λ z → glue (z , t))
from : P1 × T → P2
from (x , t) = from-curr t x
to-from : (u : P1 × T) → to (from u) == u
to-from (x , t) = to-from-curr t x where
ap-idf,×cst : ∀ {i j} {A : Type i} {B : Type j}
{x y : A} (p : x == y) {b : B}
→ ap (λ v → v , b) p == pair×= p idp
ap-idf,×cst idp = idp
to-from-curr : (t : T) (x : P1) → to (from-curr t x) == (x , t)
to-from-curr t = Pushout-elim (λ _ → idp) (λ _ → idp) (λ z → ↓-='-in (ap-idf,×cst (glue z) ∙ ! (To.glue-β (z , t)) ∙ ! (ap (ap to) (FromCurr.glue-β t z)) ∙ ∘-ap to (from-curr t) (glue z)))
from-to : (u : P2) → from (to u) == u
from-to = Pushout-elim (λ _ → idp) (λ _ → idp) (λ c → ↓-∘=idf-in from to (! (ap (ap from) (To.glue-β c) ∙ ap-pair×= from (glue (fst c)) ∙ FromCurr.glue-β (snd c) (fst c)))) where
ap-pair×= : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A × B → C)
{a a' : A} (p : a == a') {b : B}
→ ap f (pair×= p idp) == ap (λ a → f (a , b)) p
ap-pair×= f {a = a} {a' = .a} idp = idp
module _ (X Y T : Type i) where
private
P1 : Type i
P1 = Pushout (span X Y (X × Y) fst snd)
P2 : Type i
P2 = Pushout (span (T × X) (T × Y) ((T × X) × Y) fst (λ u → (fst (fst u) , snd u)))
lemma4' : P2 ≃ (T × P1)
lemma4' = equiv to from to-from from-to module Lemma4' where
to : P2 → T × P1
to = To.f module _ where
module To = PushoutRec {D = T × P1} (λ u → (fst u , left (snd u))) (λ u → (fst u , right (snd u))) (λ c → pair×= idp (glue (snd (fst c) , snd c)))
from-curr : T → (P1 → P2)
from-curr t = FromCurr.f module _ where
module FromCurr = PushoutRec {D = P2} (λ x → left (t , x)) (λ y → right (t , y)) (λ z → glue ((t , fst z) , snd z))
from : T × P1 → P2
from (t , x) = from-curr t x
to-from : (u : T × P1) → to (from u) == u
to-from (t , x) = to-from-curr t x where
to-from-curr : (t : T) (x : P1) → to (from-curr t x) == (t , x)
to-from-curr t = Pushout-elim (λ _ → idp) (λ _ → idp) (λ c → ↓-='-in (ap-cst,id (λ _ → _) (glue c) ∙ ! (lemma5 c))) where
lemma5 : (c : X × Y) → ap (to ∘ from-curr t) (glue c) == pair×= idp (glue c)
lemma5 (x , y) =
ap (to ∘ from-curr t) (glue (x , y))
=⟨ ap-∘ to (from-curr t) (glue (x , y)) ⟩
ap to (ap (from-curr t) (glue (x , y)))
=⟨ FromCurr.glue-β t (x , y) |in-ctx ap to ⟩
ap to (glue ((t , x) , y))
=⟨ To.glue-β ((t , x) , y) ⟩
pair×= idp (glue (x , y)) ∎
from-to : (x : P2) → from (to x) == x
from-to = Pushout-elim (λ _ → idp) (λ _ → idp) (λ c → ↓-∘=idf-in from to (! (lemma42 c))) where
ap-pair×= : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A × B → C)
{a : A} {b b' : B} (p : b == b')
→ ap f (pair×= idp p) == ap (λ b → f (a , b)) p
ap-pair×= f {b = b} {b' = .b} idp = idp
lemma42 : (c : (T × X) × Y) → ap from (ap to (glue c)) == glue c
lemma42 ((t , x) , y) =
ap from (ap to (glue ((t , x) , y)))
=⟨ To.glue-β ((t , x) , y) |in-ctx ap from ⟩
ap from (pair×= idp (glue (x , y)))
=⟨ ap-pair×= from (glue (x , y)) ⟩
ap (from-curr t) (glue (x , y))
=⟨ FromCurr.glue-β t (x , y) ⟩
glue ((t , x) , y) ∎
lemma2 : M.v-h-span join-assoc-span^2 == *-span A (B * C)
lemma2 = span= (lemma3 A (A × C) fst) (ide _) (lemma4' B C A)
(Pushout-elim (λ _ → idp) (λ _ → idp) (λ x → ↓-='-in (lemma2-1 x ∙ ! (lemma2-2 x))))
(Pushout-elim (λ _ → idp) (λ _ → idp) (λ x → ↓-='-in (lemma2-3 x ∙ ! (M.F₃∙.glue-β join-assoc-span^2 _ ∙ ∙-unit-r (glue _))))) where
lemma2-1 : (x : (A × B) × C) → _
lemma2-1 ((a , b) , c) =
ap (fst ∘ Lemma4'.to B C A) (glue ((a , b) , c))
=⟨ ap-∘ fst (Lemma4'.to B C A) (glue ((a , b) , c)) ⟩
ap fst (ap (Lemma4'.to B C A) (glue ((a , b) , c)))
=⟨ Lemma4'.To.glue-β B C A ((a , b) , c) |in-ctx fst×= ⟩
fst×= (pair×= idp (glue (b , c)))
=⟨ fst×=-β idp (glue (b , c)) ⟩
idp ∎
lemma2-2 : (x : (A × B) × C) → _
lemma2-2 ((a , b) , c) =
ap (lemma3-fun A (A × C) fst ∘ M.f₁∙ join-assoc-span^2) (glue ((a , b) , c))
=⟨ ap-∘ (lemma3-fun A (A × C) fst) (M.f₁∙ join-assoc-span^2) (glue ((a , b) , c)) ⟩
ap (lemma3-fun A (A × C) fst) (ap (M.f₁∙ join-assoc-span^2) (glue ((a , b) , c)))
=⟨ M.F₁∙.glue-β join-assoc-span^2 ((a , b) , c) |in-ctx ap (lemma3-fun A (A × C) fst) ⟩
ap (lemma3-fun A (A × C) fst) (glue (a , c) ∙ idp)
=⟨ ∙-unit-r (glue (a , c)) |in-ctx ap (lemma3-fun A (A × C) fst) ⟩
ap (lemma3-fun A (A × C) fst) (glue (a , c))
=⟨ Lemma3Fun.glue-β A (A × C) fst (a , c) ⟩
idp ∎
lemma2-3 : (x : (A × B) × C) → _
lemma2-3 ((a , b) , c) =
ap (snd ∘ Lemma4'.to B C A) (glue ((a , b) , c))
=⟨ ap-∘ snd (Lemma4'.to B C A) (glue ((a , b) , c)) ⟩
ap snd (ap (Lemma4'.to B C A) (glue ((a , b) , c)))
=⟨ Lemma4'.To.glue-β B C A ((a , b) , c) |in-ctx snd×= ⟩
snd×= (pair×= idp (glue (b , c)))
=⟨ snd×=-β idp (glue (b , c)) ⟩
glue (b , c) ∎
lemma2' : M.v-h-span (transpose join-assoc-span^2) == *-span (A * B) C
lemma2' = span= (ide _) (lemma3' C (A × C) snd) (lemma4 A B (A × B) C fst snd)
(Pushout-elim (λ _ → idp) (λ _ → idp) (λ c → ↓-='-in (ap-∘ fst (Lemma4.to A B (A × B) C fst snd) (glue c) ∙ ap (ap fst) (Lemma4.To.glue-β A B (A × B) C fst snd c) ∙ fst×=-β (glue (fst c)) idp ∙ ! (∙-unit-r (glue (fst c))) ∙ ! (M.F₁∙.glue-β (transpose join-assoc-span^2) c))))
(Pushout-elim (λ _ → idp) (λ _ → idp) (λ u → ↓-='-in (lemma2'-1 u ∙ ! (lemma2'-2 u)))) where
lemma2'-1 : (u : (A × B) × C) → ap (snd ∘ Lemma4.to A B (A × B) C fst snd) (glue u) == idp
lemma2'-1 u =
ap (snd ∘ Lemma4.to A B (A × B) C fst snd) (glue u)
=⟨ ap-∘ snd (Lemma4.to A B (A × B) C fst snd) (glue u) ⟩
ap snd (ap (Lemma4.to A B (A × B) C fst snd) (glue u))
=⟨ Lemma4.To.glue-β A B (A × B) C fst snd u |in-ctx snd×= ⟩
snd×= (pair×= (glue (fst u)) idp)
=⟨ snd×=-β (glue (fst u)) idp ⟩
idp ∎
lemma2'-2 : (u : (A × B) × C) → ap (lemma3'-fun C (A × C) snd ∘ M.f₃∙ (transpose join-assoc-span^2)) (glue u) == idp
lemma2'-2 u =
ap (lemma3'-fun C (A × C) snd ∘ M.f₃∙ (transpose join-assoc-span^2)) (glue u)
=⟨ ap-∘ (lemma3'-fun C (A × C) snd) (M.f₃∙ (transpose join-assoc-span^2)) (glue u) ⟩
ap (lemma3'-fun C (A × C) snd) (ap (M.f₃∙ (transpose join-assoc-span^2)) (glue u))
=⟨ M.F₃∙.glue-β (transpose join-assoc-span^2) u |in-ctx ap (lemma3'-fun C (A × C) snd) ⟩
ap (lemma3'-fun C (A × C) snd) (glue (fst (fst u) , snd u) ∙ idp)
=⟨ ∙-unit-r (glue (fst (fst u) , snd u)) |in-ctx ap (lemma3'-fun C (A × C) snd) ⟩
ap (lemma3'-fun C (A × C) snd) (glue (fst (fst u) , snd u))
=⟨ Lemma3'Fun.glue-β C (A × C) snd (fst (fst u) , snd u) ⟩
idp ∎
lemma1 : Pushout^2 join-assoc-span^2 == A * (B * C)
lemma1 = ap Pushout lemma2
lemma1' : Pushout^2 (transpose join-assoc-span^2) == (A * B) * C
lemma1' = ap Pushout lemma2'
*-assoc : A * (B * C) == (A * B) * C
*-assoc = ! lemma1 ∙ ua PP.theorem ∙ lemma1' | {
"alphanum_fraction": 0.4847461206,
"avg_line_length": 43.2557077626,
"ext": "agda",
"hexsha": "df1a7769bb98dcf5863a45b0502a9643b3973e50",
"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/JoinAssoc3x3.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/JoinAssoc3x3.agda",
"max_line_length": 285,
"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/JoinAssoc3x3.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": 4253,
"size": 9473
} |
{-# OPTIONS --safe --without-K #-}
module Categories.Examples.Monad.Duration where
-- Monad induced by pairing a Monoid and a Setoid
open import Level
open import Function.Base using (_-⟪_⟫-_; _on_; _∘_) renaming (id to id→)
open import Function.Equality using (Π; _⟨$⟩_; cong)
open import Relation.Binary
open import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial
open import Data.Product using (Σ; _,_; _×_; proj₁; proj₂; dmap′; zip; map₁; map₂)
open import Algebra using (Monoid)
open import Categories.Category
open import Categories.Category.Instance.Setoids
open import Categories.Functor renaming (id to idF)
open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper)
open import Categories.Monad using (Monad)
open import Data.Nat.Properties renaming (+-0-monoid to +-0-nat-monoid)
open import Data.Integer.Properties renaming (+-0-monoid to +-0-integer-monoid)
open import Data.Rational.Properties renaming (+-0-monoid to +-0-rational-monoid)
open Monoid public
monoid×-₀ : ∀ {l₁ l₂ e₁ e₂} → Monoid l₁ e₁ → Setoid l₂ e₂ → Setoid _ _
monoid×-₀ m s = record
{ Carrier = m.Carrier × s.Carrier
; _≈_ = m._≈_ on proj₁ -⟪ _×_ ⟫- s._≈_ on proj₂
; isEquivalence = record
{ refl = m.refl , s.refl
; sym = dmap′ m.sym s.sym
; trans = zip m.trans s.trans
}
}
where
module m = Monoid m
module s = Setoid s
monoid×-₁ : ∀ {l₁ l₂ e₁ e₂} {A B : Setoid l₂ e₂} → (m : Monoid l₁ e₁) → (f : Setoids l₂ e₂ [ A , B ]) → Setoids _ _ [ monoid×-₀ m A , monoid×-₀ m B ]
monoid×-₁ _ f = record
{ _⟨$⟩_ = map₂ (_⟨$⟩_ f)
; cong = map₂ (cong f)
}
-- levels have to be the same because everything gets put into the same stop
monoid×-endo : ∀ {l₁ e₁} → Monoid l₁ e₁ → Endofunctor (Setoids l₁ e₁)
monoid×-endo m = record
{ F₀ = monoid×-₀ m
; F₁ = monoid×-₁ m
; identity = id→
; homomorphism = λ {_} {_} {_} {f} {g} p → map₂ (cong g ∘ cong f) p
; F-resp-≈ = λ f → map₂ f
}
monoid×-η : ∀ {l e} → (m : Monoid l e) → NaturalTransformation idF (monoid×-endo m)
monoid×-η m = ntHelper record
{ η = λ _ → record { _⟨$⟩_ = m.ε ,_ ; cong = m.refl ,_ }
; commute = λ f x → m.refl , cong f x
}
where module m = Monoid m
monoid×-μ : ∀ {l} → (m : Monoid l l) → NaturalTransformation (monoid×-endo m ∘F monoid×-endo m) (monoid×-endo m)
monoid×-μ m = ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = λ { (d , d₁ , value) → ( d m.∙ d₁) , value }
; cong = λ { (d , d₁ , v) → m.∙-cong d d₁ , v }
}
; commute = λ { f (d , d₁ , v) → m.∙-cong d d₁ , cong f v }
}
where
module m = Monoid m
monoid×-monad : ∀ {l} → Monoid l l → Monad (Setoids l l)
monoid×-monad m = record
{ F = monoid×-endo m
; η = monoid×-η m
; μ = monoid×-μ m
; assoc = λ (p₀ , p₁ , p₂ , p₃) → m.trans (m.∙-cong p₀ (m.∙-cong p₁ p₂)) (m.sym (m.assoc _ _ _)) , p₃
; sym-assoc = λ (p₀ , p₁ , p₂ , p₃) → m.trans (m.∙-cong (m.∙-cong p₀ p₁) p₂) ( (m.assoc _ _ _)) , p₃
; identityˡ = λ p → map₁ (m.trans (m.identityʳ _)) p
; identityʳ = λ p → map₁ (m.trans (m.identityˡ _)) p
}
where module m = Monoid m
natDuration : Monad (Setoids 0ℓ 0ℓ)
natDuration = monoid×-monad +-0-nat-monoid
integerDuration : Monad (Setoids 0ℓ 0ℓ)
integerDuration = monoid×-monad +-0-integer-monoid
rationalDuration : Monad (Setoids 0ℓ 0ℓ)
rationalDuration = monoid×-monad +-0-rational-monoid
| {
"alphanum_fraction": 0.6285032797,
"avg_line_length": 34.9375,
"ext": "agda",
"hexsha": "2850722f601d827e4ccb75f8e19133b203654d8d",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:35.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-08-07T08:05:09.000Z",
"max_forks_repo_head_hexsha": "4dbe20d538bf830a0c46050da2c6e6aa93f3804a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/categories-examples",
"max_forks_repo_path": "src/Categories/Examples/Monad/Duration.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "4dbe20d538bf830a0c46050da2c6e6aa93f3804a",
"max_issues_repo_issues_event_max_datetime": "2021-03-19T00:37:29.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-06-13T14:52:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/categories-examples",
"max_issues_repo_path": "src/Categories/Examples/Monad/Duration.agda",
"max_line_length": 149,
"max_stars_count": 8,
"max_stars_repo_head_hexsha": "4dbe20d538bf830a0c46050da2c6e6aa93f3804a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/categories-examples",
"max_stars_repo_path": "src/Categories/Examples/Monad/Duration.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-14T10:16:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-06-11T02:10:08.000Z",
"num_tokens": 1293,
"size": 3354
} |
module LongList where
infixr 6 _∷_
data List (A : Set) : Set where
[] : List A
_∷_ : A -> List A -> List A
postulate
Bool : Set
t : Bool
long : List Bool
long =
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷
[]
| {
"alphanum_fraction": 0.2505456413,
"avg_line_length": 71.7880184332,
"ext": "agda",
"hexsha": "7576c52cc33cd58f5460a4448fa65ee2e60a2b8e",
"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/LongList.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/LongList.agda",
"max_line_length": 76,
"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/LongList.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": 11667,
"size": 15578
} |
{-# OPTIONS --rewriting --prop --exact-split #-}
open import common
{-
An arity is something of the form (((n_1, k_1), …, (n_l, k_l)) , k), where the n_i are natural
numbers and the k_i and k are sorts. We will use two different types of sorts, so we parametrize
arities by the type of sorts.
The type [ArityArgs Sort] represents the first components of arities (the list), and [Arity Sort]
represents arities.
-}
data ArityArgs (Sort : Set) : Set where
[] : ArityArgs Sort
_,_ : ArityArgs Sort → (ℕ × Sort) → ArityArgs Sort
record Arity (Sort : Set) : Set where
constructor _,_
field
args : ArityArgs Sort
sort : Sort
open Arity public
SyntaxArityArgs = ArityArgs SyntaxSort
SyntaxArity = Arity SyntaxSort
{-
A signature consists of symbols, which are indexed by their arities. To have instead a set of
symbols and an arity function is very inconvenient.
-}
record Signature : Set₁ where
field
Symbols : SyntaxArity → Set
open Signature public
{-
Expressions are indexed by their syntactic class and their scope. An expression is either a variable
or a symbol applied to the appropriate number of arguments.
The type [Expr Σ n] is defined simultaneously with the type [Args Σ n args] which represents the
type of the arguments of a symbol with arity (args, _).
-}
data Args (Σ : Signature) (n : ℕ) : SyntaxArityArgs → Set
data Expr (Σ : Signature) (n : ℕ) : SyntaxSort → Set where
var : VarPos n → Expr Σ n Tm
sym : {ar : SyntaxArity} (s : Symbols Σ ar) → Args Σ n (args ar) → Expr Σ n (sort ar)
data Args Σ n where
[] : Args Σ n []
_,_ : {m : ℕ} {k : SyntaxSort} {args : SyntaxArityArgs}
→ Args Σ n args
→ Expr Σ (n + m) k
→ Args Σ n (args , (m , k))
{- Abbreviations for type-/term-expressions -}
TyExpr : (Σ : Signature) → ℕ → Set
TyExpr Σ n = Expr Σ n Ty
TmExpr : (Σ : Signature) → ℕ → Set
TmExpr Σ n = Expr Σ n Tm
{-
weakenV : {n m : ℕ} {{_ : n ≤ m}} (p : WeakPos n) → VarPos n → VarPos m
weakenV ⦃ ≤r ⦄ p x = x
weakenV ⦃ ≤S r ⦄ last x = prev (weakenV {{r}} last x)
weakenV ⦃ ≤S r ⦄ (prev p) last = last
weakenV ⦃ ≤S r ⦄ (prev p) (prev x) = prev (weakenV {{≤P (≤S r)}} p x)
-}
-- weakenVL : {n m : ℕ} {{_ : n ≤ m}} → VarPos n → VarPos m
-- weakenVL {{ ≤r }} x = x
-- weakenVL {{ ≤S p }} x = prev (weakenVL {{p}} x)
-- postulate
-- weakenV : {n m : ℕ} {{_ : n ≤ m}} (p : WeakPos n) → VarPos n → VarPos m
-- weakenV {m = _} ⦃ ≤r ⦄ last last = last
-- weakenV {m = _} ⦃ ≤S r ⦄ last last = prev (weakenV {{r}} last last)
-- weakenV {m = suc m} ⦃ r ⦄ (prev p) last = last
-- weakenV {m = suc m} ⦃ ≤r ⦄ last (prev x) = prev x
-- weakenV {m = suc m} ⦃ ≤S r ⦄ last (prev x) = prev (weakenV {m = m} {{≤P (≤S r)}} last x)
-- weakenV {m = suc m} ⦃ r ⦄ (prev p) (prev x) = prev (weakenV {m = m} {{≤P r}} p x)
-- weakenV {m = suc m} (prev wp) last = last
-- weakenV {m = suc m} {{p}} (prev wp) (prev x) = prev (weakenV {{≤P p}} wp x)
-- weakenV {m = suc m} ⦃ ≤r ⦄ last x = x
-- weakenV {m = suc m} ⦃ ≤S r ⦄ last x = prev (weakenV {{r}} last x)
-- weakenV {m = suc m} ⦃ p ⦄ (prev wp) last = last
-- weakenV {m = suc m} ⦃ p ⦄ (prev wp) (prev x) = prev (weakenV {{≤P p}} wp x)
-- weakenV {m = suc m} ⦃ ≤r ⦄ last x = x
-- weakenV {m = suc m} ⦃ ≤S p ⦄ last x = prev (weakenV {{p}} last x)
postulate
TODO : {A : Set} → A
weaken : {Σ : Signature} {k : _} {n m : ℕ} {{_ : n ≤ m}} (p : WeakPos n) → Expr Σ n k → Expr Σ m k
weakenA : {Σ : Signature} {ar : _} {n m : ℕ} {{_ : n ≤ m}} (p : WeakPos n) → Args Σ n ar → Args Σ m ar
weaken p (var x) = var (weakenV p x)
weaken p (sym s es) = sym s (weakenA p es)
weakenA p [] = []
weakenA {{q}} p (_,_ {m = m} es e) = (weakenA p es , weaken {{≤+ m {{q}}}} (weakenPos (≤-+ {m = m}) p) e)
weaken' : {Σ : Signature} {k : _} {n m : ℕ} {{_ : n ≤ m}} (p : WeakPos n) → Expr Σ n k → Expr Σ m k
weaken' ⦃ ≤r ⦄ p e = e
weaken' ⦃ ≤S q ⦄ p e = weaken {{≤S q}} p e
weakenL : {Σ : Signature} {k : _} {m n : ℕ} → Expr Σ m k → Expr Σ (m + n) k
weakenL {n = zero} e = e
weakenL {n = suc n} e = weaken last e
weaken0 : {Σ : Signature} {k : _} {n : ℕ} → Expr Σ 0 k → Expr Σ n k
weaken0 e = weaken {{0≤}} last e
weaken0' : {Σ : Signature} {k : _} {n : ℕ} → Expr Σ 0 k → Expr Σ n k
weaken0' {n = zero} e = e
weaken0' {n = suc n} e = weaken last e
weakenAL : {Σ : Signature} {ar : _} {m n : ℕ} → Args Σ m ar → Args Σ (m + n) ar
weakenAL {n = zero} es = es
weakenAL {n = suc n} es = weakenA last es
prev^last : (n l : ℕ) → WeakPos (n + l)
prev^last n zero = last
prev^last n (suc l) = prev (prev^last n l)
-- weaken≤ : {Σ : Signature} {k : _} {n m l : ℕ} {{_ : n ≤ m}} → Expr Σ (n + l) k → Expr Σ (m + l) k
-- weaken≤ ⦃ ≤r ⦄ e = e
-- weaken≤ {n = n} {l = l} ⦃ ≤S p ⦄ e = weaken {{TODO}} (prev^last n l) e
-- weaken^V' : {l m n : ℕ} → VarPos (l + m) → VarPos (l + n + m)
-- weaken^' : {Σ : Signature} {k : _} {l m n : ℕ} → Expr Σ (l + m) k → Expr Σ (l + n + m) k
-- weaken^A' : {Σ : Signature} {ar : _} {l m n : ℕ} → Args Σ (l + m) ar → Args Σ (l + n + m) ar
-- weaken^V' {zero} {m} {zero} k = k
-- weaken^V' {zero} {m} {suc n} k = prev (weaken^V' {zero} {m} {n} k)
-- weaken^V' {suc l} {m} {n} last = last
-- weaken^V' {suc l} {m} {n} (prev k) = prev (weaken^V' {l} {m} {n} k)
-- weaken^' {l = l} {m} {n} (var k) = var (weaken^V' {l = _} {m} {n} k)
-- weaken^' {l = l} {m} {n} (sym s x) = sym s (weaken^A' {l = _} {m} {n} x)
-- weaken^A' [] = []
-- weaken^A' {l = l} {m} {n} (_,_ {m = _} a x) = (weaken^A' {l = _} {m} {n} a , weaken^' {l = _} {m} {n} x)
-- -- this should not be defined as iterated weakening, it should reduce on expressions
-- weaken^ : {Σ : Signature} {k : _} {l n m : ℕ} {{p : n ≤ m}} → Expr Σ (l + n) k → Expr Σ (l + m) k
-- weaken^ {l = l} {n} {m} {{p}} k = weaken^' {l = l} {{!n!}} {{!!}} k
-- weaken^A : {Σ : Signature} {ar : _} {l n m : ℕ} {{p : n ≤ m}} → Args Σ (l + n) ar → Args Σ (l + m) ar
-- weaken^A {{p}} = weaken^A' {{p}}
-- weakenV≤r : {n : ℕ} {p : WeakPos n} (v : VarPos n) → weakenV {{≤r}} p v ≡ v
-- weakenV≤r {p = last} last = refl
-- weakenV≤r {p = prev p} last = refl
-- weakenV≤r {p = last} (prev v) = refl
-- weakenV≤r {p = prev p} (prev v) = ap prev (weakenV≤r {p = p} v)
-- weaken≤r : {Σ : Signature} {k : _} {n : ℕ} {p : WeakPos n} (e : Expr Σ n k) → weaken p e ≡ e
-- weakenA≤r : {Σ : Signature} {k : _} {n : ℕ} {p : WeakPos n} (as : Args Σ n k) → weakenA p as ≡ as
-- weaken≤r {p = p} (var x) = ap var (weakenV≤r {p = p} x)
-- weaken≤r (sym s x) = ap (sym s) (weakenA≤r x)
-- weakenA≤r [] = refl
-- weakenA≤r (es , e) = ap2 _,_ (weakenA≤r es) (weaken≤r e)
-- -- {-# REWRITE weaken^'≤r #-}
{- Contexts, [Ctx Σ n] represents contexts in signature [Σ] and of length [n] -}
data Ctx (Σ : Signature) : ℕ → Set where
◇ : Ctx Σ 0
_,_ : {n : ℕ} (Γ : Ctx Σ n) (A : TyExpr Σ n) → Ctx Σ (suc n)
{- TODO
Dependent contexts, [DepCtx Σ n m] represents contexts in signature [Σ], in scope [n], and of
length [m]. They are built in the other direction compared to [Ctx], we add types to the left
instead of adding them to the right. The reason is that the "purpose" of dependent contexts is to
move the types one by one to the context on the left.
-}
data DepCtx (Σ : Signature) (n : ℕ) : ℕ → Set where
◇ : DepCtx Σ n 0
_,_ : {m : ℕ} → DepCtx Σ n m → TyExpr Σ (n + m) → DepCtx Σ n (suc m)
{-
Extraction of types from contexts.
We need this partial version instead of the total well-typed one (below, not used).
-}
get : {Σ : Signature} {n : ℕ} (k : ℕ) → Ctx Σ n → Partial (VarPos n × TyExpr Σ n)
get k ◇ = fail
get zero (Γ , A) = return (last , weaken last A)
get (suc k) (Γ , X) = do
(k' , A) ← get k Γ
return (prev k' , weaken last A)
getTotal : {Σ : Signature} {n : ℕ} (k : VarPos n) → Ctx Σ n → TyExpr Σ n
getTotal last (Γ , A) = weaken last A
getTotal (prev k) (Γ , X) = weaken last (getTotal k Γ)
{-
In order to deal with extensions of signatures, we need a notion of map between signatures. There
are a few possible options:
- Mapping symbols to symbols: not strong enough, as later we need to map a symbol s(-) to the
expression s(a, -)
- Mapping expressions to expressions: too strong, makes it impossible to look inside expressions
- Mapping symbols to expression-building function: this is the approach we take. A symbol will be
mapped to a function of the corresponding arity between expressions of the codomain signature.
We need sometimes to restrict them to expressions in a certain scope (bounded below). This happens
for instance when turning typing rules to partial functions on the syntax, we replace something by a
specific term which lives in a scope, so the map between signatures does not work for a lower scope.
We need to have it bounded below (as opposed to having a fixed scope) otherwise we cannot map
expressions to expressions (as they may bind new variables).
Therefore we define [(Σ →Sig Σ') n] which represents maps from symbols of [Σ] to expression-building
functions for signature [Σ'], and which works for any scope above (and including) [n].
-}
record _→Sig_ (Σ Σ' : Signature) (n : ℕ) : Set where
constructor sub
field
_$_ : {m : ℕ} {{p : n ≤ m}} {ar : SyntaxArity} (s : Symbols Σ ar) → Args Σ' m (args ar) → Expr Σ' m (sort ar)
open _→Sig_ public
{- Identity map -}
idSig : {n : ℕ} {Σ : Signature} → (Σ →Sig Σ) n
idSig $ s = sym s
{- Lifting at a higher scope -}
liftSig : {m n : ℕ} {Σ Σ' : Signature} → (Σ →Sig Σ') m → (Σ →Sig Σ') (m + n)
(liftSig {n = n} ↑ $ s) x = _$_ ↑ {{≤tr {{≤-+ {m = n}}}}} s x
{- Lifting of a map between signatures to expressions -}
↑Expr : {Σ Σ' : Signature} {n : ℕ} {k : SyntaxSort} → (Σ →Sig Σ') n → Expr Σ n k → Expr Σ' n k
↑Args : {Σ Σ' : Signature} {n : ℕ} {args : SyntaxArityArgs} → (Σ →Sig Σ') n → Args Σ n args → Args Σ' n args
↑Expr ↑ (var x) = var x
↑Expr ↑ (sym s x) = (↑ $ s) (↑Args ↑ x)
↑Args ↑ [] = []
↑Args ↑ (_,_ {m = m} es e) = ↑Args ↑ es , ↑Expr (liftSig ↑) e
{-
[ExtSig Σ ar] extends the signature [Σ] by an arity [ar].
In order to add a symbol only at the correct arity, we use an inductive family (another possibility
would be to use decidable equality of arities but that would be very ugly).
-}
data ExtSigSymbols (S : SyntaxArity → Set) (ar : SyntaxArity) : SyntaxArity → Set where
prev : {ar' : SyntaxArity} → S ar' → (ExtSigSymbols S ar) ar'
new : (ExtSigSymbols S ar) ar
ExtSig : Signature → SyntaxArity → Signature
Symbols (ExtSig Σ ar) = ExtSigSymbols (Symbols Σ) ar
{- If an extended signature maps to [Σ'], then the original signature too. -}
Ext→ : {Σ Σ' : Signature} {ar : SyntaxArity} {n : ℕ} → (ExtSig Σ ar →Sig Σ') n → (Σ →Sig Σ') n
Ext→ ↑ $ s = ↑ $ (prev s)
{- Arities of metavariables -}
MArityArgs : ℕ → SyntaxArityArgs
MArityArgs zero = []
MArityArgs (suc n) = MArityArgs n , (0 , Tm)
MArity : ℕ → SyntaxSort → SyntaxArity
args (MArity n k) = MArityArgs n
sort (MArity n k) = k
{- [ExtSig^ Σ args] extends the signature [Σ] by symbols for metavariables with arities given by [args] -}
ExtSig^ : Signature → SyntaxArityArgs → Signature
ExtSig^ Σ [] = Σ
ExtSig^ Σ (args , (n , k)) = ExtSig (ExtSig^ Σ args) (MArity n k)
{- Example
ExtSig^ Σ ((0, Ty), (1, Ty)) = extend Σ with one symbol of arity (() , Ty) and
one symbol of arity ((0 , Tm), Ty)
-}
{-
Given two signatures [Σ] and [Σ'], we can map from a signature extended over [Σ] to [Σ'] as long as
we can map from [Σ] to [Σ'] and that we have terms [as] in [Σ'] to replace the new symbols.
[SubstM ↑ as] represents that map.
-}
-- trExpr : {Σ : Signature} {n n' : ℕ} (p : n === n') {k : SyntaxSort} → Expr Σ n k → Expr Σ n' k
-- trExpr refl u = u
-- trExpr! : {Σ : Signature} {n n' : ℕ} (p : n === n') {k : SyntaxSort} → Expr Σ n' k → Expr Σ n k
-- trExpr! refl u = u
pred : ℕ → ℕ
pred zero = zero
pred (suc n) = n
trV : {n m : ℕ} → n ≡ m → VarPos n → VarPos m
trV {m = suc m} p last = last
trV {m = suc m} p (prev x) = prev (trV (ap pred p) x)
tr : {Σ : Signature} {k : SyntaxSort} {n m : ℕ} → n ≡ m → Expr Σ n k → Expr Σ m k
trA : {Σ : Signature} {ar : SyntaxArityArgs} {n m : ℕ} → n ≡ m → Args Σ n ar → Args Σ m ar
tr p (var x) = var (trV p x)
tr p (sym s es) = sym s (trA p es)
trA p [] = []
trA p (es , x) = (trA p es , tr (ap (_+ _) p) x)
tr! : {Σ : Signature} {k : SyntaxSort} {n m : ℕ} → m ≡ n → Expr Σ n k → Expr Σ m k
tr! p e = tr (! p) e
data Mor (Σ : Signature) (n : ℕ) : ℕ → Set where
◇ : Mor Σ n 0
_,_ : {m : ℕ} (δ : Mor Σ n m) (u : TmExpr Σ n) → Mor Σ n (suc m)
weakenMor : {Σ : Signature} {n m : ℕ} → Mor Σ m n → Mor Σ (suc m) n
weakenMor ◇ = ◇
weakenMor (δ , u) = (weakenMor δ , weaken last u)
idMor : {Σ : Signature} {n : ℕ} → Mor Σ n n
idMor {n = zero} = ◇
idMor {n = suc n} = (weakenMor idMor , var last)
weakenMor+ : {Σ : Signature} (k : ℕ) {n m : ℕ} → Mor Σ m n → Mor Σ (m + k) (n + k)
weakenMor+ zero δ = δ
weakenMor+ (suc k) δ = (weakenMor (weakenMor+ k δ) , var last)
SubstMor : {Σ : Signature} {n m : ℕ} {k : SyntaxSort} → Expr Σ n k → Mor Σ m n → Expr Σ m k
SubstAMor : {Σ : Signature} {n m : ℕ} {args : SyntaxArityArgs} → Args Σ n args → Mor Σ m n → Args Σ m args
SubstMor (var last) (δ , u) = u
SubstMor (var (prev x)) (δ , u) = SubstMor (var x) δ
SubstMor (sym s es) δ = sym s (SubstAMor es δ)
SubstAMor [] δ = []
SubstAMor (_,_ {m = m} es x) δ = (SubstAMor es δ , SubstMor x (weakenMor+ m δ))
-- Subst1 : {Σ : Signature} {n : ℕ} (m : ℕ) {k : SyntaxSort} → Expr Σ (suc n + m) k → TmExpr Σ n → Expr Σ (n + m) k
-- Subst1A : {Σ : Signature} {n : ℕ} (m : ℕ) {args : SyntaxArityArgs} → Args Σ (suc n + m) args → TmExpr Σ n → Args Σ (n + m) args
-- Subst1 n (sym s x) a = sym s (Subst1A n x a)
-- Subst1 zero (var last) a = a
-- Subst1 zero (var (prev x)) a = var x
-- Subst1 (suc m) (var last) a = var last
-- Subst1 (suc m) (var (prev x)) a = weaken last (Subst1 m (var x) a)
-- Subst1A m [] a = []
-- Subst1A {n = n} m (_,_ {m = k} es e) a = (Subst1A m es a , tr! (assoc {n} {m} {k}) (Subst1 (m + k) (tr (assoc {suc n} {m} {k}) e) a))
Subst : {Σ : Signature} {l m : ℕ} {k : SyntaxSort} → Expr Σ (m + l) k → Args Σ m (MArityArgs l) → Expr Σ m k
Subst {l = zero} e [] = e
Subst {l = suc l} {m} e (as , a) = Subst (SubstMor e (idMor , weakenL a)) as
SubstM : {Σ Σ' : Signature} {m : ℕ} {args : SyntaxArityArgs}
→ (Σ →Sig Σ') m
→ Args Σ' m args
→ ((ExtSig^ Σ args) →Sig Σ') m
SubstM ↑ [] = ↑
SubstM ↑ (as , a) $ prev s = SubstM ↑ as $ s
(SubstM ↑ (_,_ {m = l} as a)) $ new = Subst (weaken' {{≤+ l}} (prev^last _ l) a)
subst : {n m : ℕ} {k : SyntaxSort} {Σ Σ' : Signature} (↑ : (Σ →Sig Σ') n) {args : SyntaxArityArgs} (as : Args Σ' (n + m) args)
→ Expr (ExtSig^ Σ args) (n + m) k
→ Expr Σ' (n + m) k
subst {m = m} ↑ as e = ↑Expr (SubstM (liftSig ↑) as) e
-- {-
-- Example:
-- args = ((0, Ty), (1, Ty), (1, Tm))
-- ExtSig^ Σ args = Σ + {A} + {B} + {u} where A has arity ((), Ty), B has arity ((0, Tm), Ty), u has arity ((0, Tm), Tm)
-- To get a map from it to Σ', we need
-- - a map from Σ to Σ'
-- - a type expression in Σ' (for A)
-- - a type expression in Σ' in scope (m + 1) (for B)
-- - a term expression in Σ' in scope (m + 1) (for u)
-- -}
| {
"alphanum_fraction": 0.5747241058,
"avg_line_length": 37.5112219451,
"ext": "agda",
"hexsha": "e1b9107f72195c423ec4ddef380367e4d4096d19",
"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": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guillaumebrunerie/general-type-theories",
"max_forks_repo_path": "syntx.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"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": "guillaumebrunerie/general-type-theories",
"max_issues_repo_path": "syntx.agda",
"max_line_length": 136,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guillaumebrunerie/general-type-theories",
"max_stars_repo_path": "syntx.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6060,
"size": 15042
} |
{-# OPTIONS --cubical --safe --postfix-projections #-}
module Relation.Nullary.Decidable.Logic where
open import Prelude
open import Data.Sum
open import Relation.Nullary.Decidable
disj : (A → C) → (B → C) → (¬ A → ¬ B → ¬ C) → Dec A → Dec B → Dec C
disj l r n x y .does = x .does or y .does
disj l r n (yes x) y .why = l x
disj l r n (no x) (yes y) .why = r y
disj l r n (no ¬x) (no ¬y) .why = n ¬x ¬y
conj : (A → B → C) → (¬ A → ¬ C) → (¬ B → ¬ C) → Dec A → Dec B → Dec C
conj c l r x y .does = x .does and y .does
conj c l r (no ¬x) y .why = l ¬x
conj c l r (yes x) (no ¬y) .why = r ¬y
conj c l r (yes x) (yes y) .why = c x y
negate : (A → ¬ B) → (¬ A → B) → Dec A → Dec B
negate t f d .does = not (d .does)
negate t f (yes d) .why = t d
negate t f (no ¬d) .why = f ¬d
! : Dec A → Dec (¬ A)
! = negate (λ x ¬x → ¬x x) id
infixl 7 _&&_
_&&_ : Dec A → Dec B → Dec (A × B)
_&&_ = conj _,_ (_∘ fst) (_∘ snd)
infixl 6 _||_
_||_ : Dec A → Dec B → Dec (A ⊎ B)
_||_ = disj inl inr either
| {
"alphanum_fraction": 0.53125,
"avg_line_length": 27.5555555556,
"ext": "agda",
"hexsha": "634ad7d4048ff021ac31b5b89577b9630db770d8",
"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": "Relation/Nullary/Decidable/Logic.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": "Relation/Nullary/Decidable/Logic.agda",
"max_line_length": 70,
"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": "Relation/Nullary/Decidable/Logic.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": 431,
"size": 992
} |
{-# OPTIONS --without-K #-}
module Pif2 where
{-- 2 paths --}
open import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; subst; subst₂; cong; cong₂; setoid;
inspect; [_]; proof-irrelevance; module ≡-Reasoning)
open import Relation.Binary.PropositionalEquality.TrustMe
using (trustMe)
open import Relation.Nullary using (Dec; yes; no; ¬_)
open import Data.Nat.Properties
using (m≢1+m+n; i+j≡0⇒i≡0; i+j≡0⇒j≡0; n≤m+n)
open import Data.Nat.Properties.Simple
using (+-right-identity; +-suc; +-assoc; +-comm;
*-assoc; *-comm; *-right-zero; distribʳ-*-+)
open import Data.Nat.DivMod using (_mod_)
open import Relation.Binary using (Rel; Decidable; Setoid)
open import Relation.Binary.Core using (Transitive)
open import Data.String using (String)
renaming (_++_ to _++S_)
open import Data.Nat.Show using (show)
open import Data.Bool using (Bool; false; true; T; _∧_; _∨_)
open import Data.Nat using (ℕ; suc; _+_; _∸_; _*_; _<_; _≮_; _≤_; _≰_;
z≤n; s≤s; _≟_; _≤?_; module ≤-Reasoning)
open import Data.Fin
using (Fin; zero; suc; toℕ; fromℕ; _ℕ-_; _≺_;
raise; inject+; inject₁; inject≤; _≻toℕ_)
renaming (_+_ to _F+_)
open import Data.Fin.Properties using (bounded; inject+-lemma)
open import Data.Vec.Properties
using (lookup∘tabulate; tabulate∘lookup; lookup-allFin; tabulate-∘;
tabulate-allFin; map-id; allFin-map)
open import Data.List
using (List; []; _∷_; _∷ʳ_; foldl; replicate; reverse; downFrom;
concatMap; gfilter; initLast; InitLast; _∷ʳ'_)
renaming (_++_ to _++L_; map to mapL; concat to concatL; zip to zipL)
open import Data.List.NonEmpty
using (List⁺; module List⁺; [_]; _∷⁺_; head; last; _⁺++_)
renaming (toList to nonEmptyListtoList; _∷ʳ_ to _n∷ʳ_; tail to ntail)
open List⁺ public
open import Data.List.Any using (Any; here; there; any; module Membership)
open import Data.Maybe using (Maybe; nothing; just; maybe′)
open import Data.Vec
using (Vec; tabulate; []; _∷_; tail; lookup; zip; zipWith; splitAt;
_[_]≔_; allFin; toList)
renaming (_++_ to _++V_; map to mapV; concat to concatV)
open import Function using (id; _∘_; _$_)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Unit using (⊤; tt)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (Σ; _×_; _,_; proj₁; proj₂)
open import Cauchy
open import Perm
open import Proofs
open import CauchyProofs
open import CauchyProofsT
open import CauchyProofsS
open import Groupoid
open import PiLevel0
open import Swaps
open import Pif
------------------------------------------------------------------------------
-- Picture so far:
--
-- path p
-- =====================
-- || || ||
-- || ||2path ||
-- || || ||
-- || || path q ||
-- t₁ =================t₂
-- || ... ||
-- =====================
--
-- The types t₁, t₂, etc are discrete groupoids. The paths between
-- them correspond to permutations. Each syntactically different
-- permutation corresponds to a path but equivalent permutations are
-- connected by 2paths. But now we want an alternative definition of
-- 2paths that is structural, i.e., that looks at the actual
-- construction of the path t₁ ⟷ t₂ in terms of combinators... The
-- theorem we want is that α ∼ β iff we can rewrite α to β using
-- various syntactic structural rules. We start with a collection of
-- simplication rules and then try to show they are complete.
-- Simplification rules
infix 30 _⇔_
data _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where
assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
(c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)
assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))
assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)
assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))
assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)
assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))
dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)
factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)
idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c
idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c
idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c
idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷)
linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷
linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c)
rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷
rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c)
unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)
uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)
unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)
unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))
unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)
unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)
swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)
swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))
unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)
uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)
unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)
unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))
unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)
unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)
swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)
swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))
swapfl⋆⇔ : {t₁ t₂ t₃ : U} →
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))
swapfr⋆⇔ : {t₁ t₂ t₃ : U} →
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)
id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c
trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
resp◎⇔ : {t₁ t₂ t₃ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)
resp⊕⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)
resp⊗⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)
-- better syntax for writing 2paths
infix 2 _▤
infixr 2 _⇔⟨_⟩_
_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
_ ⇔⟨ α ⟩ β = trans⇔ α β
_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)
_▤ c = id⇔
-- Inverses for 2paths
2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)
2! assoc◎l = assoc◎r
2! assoc◎r = assoc◎l
2! assoc⊕l = assoc⊕r
2! assoc⊕r = assoc⊕l
2! assoc⊗l = assoc⊗r
2! assoc⊗r = assoc⊗l
2! dist⇔ = factor⇔
2! factor⇔ = dist⇔
2! idl◎l = idl◎r
2! idl◎r = idl◎l
2! idr◎l = idr◎r
2! idr◎r = idr◎l
2! linv◎l = linv◎r
2! linv◎r = linv◎l
2! rinv◎l = rinv◎r
2! rinv◎r = rinv◎l
2! unitel₊⇔ = uniter₊⇔
2! uniter₊⇔ = unitel₊⇔
2! unitil₊⇔ = unitir₊⇔
2! unitir₊⇔ = unitil₊⇔
2! swapl₊⇔ = swapr₊⇔
2! swapr₊⇔ = swapl₊⇔
2! unitial₊⇔ = unitiar₊⇔
2! unitiar₊⇔ = unitial₊⇔
2! unitel⋆⇔ = uniter⋆⇔
2! uniter⋆⇔ = unitel⋆⇔
2! unitil⋆⇔ = unitir⋆⇔
2! unitir⋆⇔ = unitil⋆⇔
2! unitial⋆⇔ = unitiar⋆⇔
2! unitiar⋆⇔ = unitial⋆⇔
2! swapl⋆⇔ = swapr⋆⇔
2! swapr⋆⇔ = swapl⋆⇔
2! swapfl⋆⇔ = swapfr⋆⇔
2! swapfr⋆⇔ = swapfl⋆⇔
2! id⇔ = id⇔
2! (trans⇔ α β) = trans⇔ (2! β) (2! α)
2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)
2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)
2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β)
-- a nice example of 2 paths
negEx : uniti⋆ ◎ (swap⋆ ◎ ((swap₊ {ONE} {ONE} ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))
⇔ swap₊
negEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩
uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩
uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)
⇔⟨ assoc◎l ⟩
(uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆
⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩
(swap₊ ◎ uniti⋆) ◎ unite⋆
⇔⟨ assoc◎r ⟩
swap₊ ◎ (uniti⋆ ◎ unite⋆)
⇔⟨ resp◎⇔ id⇔ linv◎l ⟩
swap₊ ◎ id⟷
⇔⟨ idr◎l ⟩
swap₊ ▤
-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:
-- the points are types (t : U); the 1paths are ⟷; and the 2paths
-- between them are based on the simplification rules ⇔
G' : 1Groupoid
G' = record
{ set = U
; _↝_ = _⟷_
; _≈_ = _⇔_
; id = id⟷
; _∘_ = λ p q → q ◎ p
; _⁻¹ = !
; lneutr = λ _ → idr◎l
; rneutr = λ _ → idl◎l
; assoc = λ _ _ _ → assoc◎l
; equiv = record {
refl = id⇔
; sym = 2!
; trans = trans⇔
}
; linv = λ {t₁} {t₂} α → linv◎l
; rinv = λ {t₁} {t₂} α → rinv◎l
; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q
}
------------------------------------------------------------------------------
-- Soundness and completeness
-- The idea is to invert evaluation and use that to extract from each
-- extensional representation of a combinator, a canonical syntactic
-- representative
canonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)
canonical c = perm2c (size≡ c , c2perm c)
-- Check canonical NOT = canonical NEG1 = canonical NEG2 = canonical NEG3
-- = canonical NEG4 = canonical NEG5
canonicalEx : Bool
canonicalEx =
let x = canonical NOT in
comb= x (canonical NEG1) ∧
comb= x (canonical NEG2) ∧
comb= x (canonical NEG3) ∧
comb= x (canonical NEG4) ∧
comb= x (canonical NEG5)
-- Proof of soundness and completeness: now we want to verify that ⇔
-- is sound and complete with respect to ∼. The statement to prove is
-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂
assoc⊕∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
subst Cauchy (+-assoc (size t₁) (size t₃) (size t₅)) (c2cauchy ((c₁ ⊕ c₂) ⊕ c₃))
≡ c2cauchy (c₁ ⊕ (c₂ ⊕ c₃))
assoc⊕∼ {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃} =
begin (subst Cauchy (+-assoc (size t₁) (size t₃) (size t₅))
(mapV
(inject+ (size t₅))
(mapV (inject+ (size t₃)) (c2cauchy c₁) ++V
mapV (raise (size t₁)) (c2cauchy c₂))
++V mapV (raise (size t₁ + size t₃)) (c2cauchy c₃))
≡⟨ cong
(λ x →
subst Cauchy (+-assoc (size t₁) (size t₃) (size t₅))
(x ++V mapV (raise (size t₁ + size t₃)) (c2cauchy c₃)))
(map-++-commute
(inject+ (size t₅))
(mapV (inject+ (size t₃)) (c2cauchy c₁))) ⟩
subst Cauchy (+-assoc (size t₁) (size t₃) (size t₅))
((mapV (inject+ (size t₅)) (mapV (inject+ (size t₃)) (c2cauchy c₁)) ++V
mapV (inject+ (size t₅)) (mapV (raise (size t₁)) (c2cauchy c₂)))
++V mapV (raise (size t₁ + size t₃)) (c2cauchy c₃))
≡⟨ cong
(λ x →
subst Cauchy (+-assoc (size t₁) (size t₃) (size t₅))
(x ++V mapV (raise (size t₁ + size t₃)) (c2cauchy c₃)))
(cong₂ _++V_
(sym (map-∘ (inject+ (size t₅)) (inject+ (size t₃)) (c2cauchy c₁)))
(sym (map-∘ (inject+ (size t₅)) (raise (size t₁)) (c2cauchy c₂)))) ⟩
subst Cauchy (+-assoc (size t₁) (size t₃) (size t₅))
((mapV (inject+ (size t₅) ∘ inject+ (size t₃)) (c2cauchy c₁) ++V
mapV (inject+ (size t₅) ∘ raise (size t₁)) (c2cauchy c₂))
++V mapV (raise (size t₁ + size t₃)) (c2cauchy c₃))
≡⟨ {!!} ⟩
(subst
(λ x → Vec (Fin x) (size t₁))
(+-assoc (size t₁) (size t₃) (size t₅))
(mapV (inject+ (size t₅) ∘ inject+ (size t₃)) (c2cauchy c₁))) ++V
((subst
(λ x → Vec (Fin x) (size t₃))
(+-assoc (size t₁) (size t₃) (size t₅))
(mapV (inject+ (size t₅) ∘ raise (size t₁)) (c2cauchy c₂))) ++V
(subst
(λ x → Vec (Fin x) (size t₅))
(+-assoc (size t₁) (size t₃) (size t₅))
(mapV (raise (size t₁ + size t₃)) (c2cauchy c₃))))
≡⟨ {!!} ⟩
mapV (inject+ (size t₃ + size t₅)) (c2cauchy c₁) ++V
(mapV (raise (size t₁) ∘ inject+ (size t₅)) (c2cauchy c₂) ++V
mapV (raise (size t₁) ∘ raise (size t₃)) (c2cauchy c₃))
≡⟨ cong
(λ x → mapV (inject+ (size t₃ + size t₅)) (c2cauchy c₁) ++V x)
(cong₂ _++V_
(map-∘ (raise (size t₁)) (inject+ (size t₅)) (c2cauchy c₂))
(map-∘ (raise (size t₁)) (raise (size t₃)) (c2cauchy c₃))) ⟩
mapV (inject+ (size t₃ + size t₅)) (c2cauchy c₁) ++V
(mapV (raise (size t₁)) (mapV (inject+ (size t₅)) (c2cauchy c₂)) ++V
mapV (raise (size t₁)) (mapV (raise (size t₃)) (c2cauchy c₃)))
≡⟨ cong
(λ x → mapV (inject+ (size t₃ + size t₅)) (c2cauchy c₁) ++V x)
(sym (map-++-commute
(raise (size t₁))
(mapV (inject+ (size t₅)) (c2cauchy c₂)))) ⟩
mapV (inject+ (size t₃ + size t₅)) (c2cauchy c₁) ++V
(mapV (raise (size t₁))
(mapV (inject+ (size t₅)) (c2cauchy c₂) ++V
mapV (raise (size t₃)) (c2cauchy c₃)))
≡⟨ refl ⟩
pcompcauchy (c2cauchy c₁) (pcompcauchy (c2cauchy c₂) (c2cauchy c₃)) ∎)
where open ≡-Reasoning
soundness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)
soundness (assoc◎l {t₁} {t₂} {t₃} {t₄} {c₁} {c₂} {c₃}) =
assoc∼ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂} {c₃}
soundness (assoc◎r {t₁} {t₂} {t₃} {t₄} {c₁} {c₂} {c₃}) =
sym (assoc∼ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂} {c₃})
soundness (assoc⊕l {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃}) =
begin (c2cauchy (c₁ ⊕ (c₂ ⊕ c₃))
≡⟨ sym (assoc⊕∼ {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃}) ⟩
subst Cauchy (+-assoc (size t₁) (size t₃) (size t₅))
(c2cauchy {PLUS (PLUS t₁ t₃) t₅} {PLUS (PLUS t₂ t₄) t₆} ((c₁ ⊕ c₂) ⊕ c₃))
≡⟨ sym (scomprid _) ⟩
scompcauchy
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(c2cauchy {PLUS (PLUS t₁ t₃) t₅} {PLUS (PLUS t₂ t₄) t₆} ((c₁ ⊕ c₂) ⊕ c₃)))
(idcauchy (size t₁ + (size t₃ + size t₅)))
≡⟨ cong
(scompcauchy
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(c2cauchy
{PLUS (PLUS t₁ t₃) t₅}
{PLUS (PLUS t₂ t₄) t₆}
((c₁ ⊕ c₂) ⊕ c₃))))
(sym (congD! idcauchy (size≡! (assocl₊ {t₁} {t₃} {t₅})))) ⟩
scompcauchy
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(c2cauchy {PLUS (PLUS t₁ t₃) t₅} {PLUS (PLUS t₂ t₄) t₆} ((c₁ ⊕ c₂) ⊕ c₃)))
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(idcauchy ((size t₁ + size t₃) + size t₅)))
≡⟨ cong
(λ x →
scompcauchy
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(c2cauchy
{PLUS (PLUS t₁ t₃) t₅}
{PLUS (PLUS t₂ t₄) t₆}
((c₁ ⊕ c₂) ⊕ c₃)))
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅})) x))
(sym (congD! idcauchy (size≡! ((c₁ ⊕ c₂) ⊕ c₃)))) ⟩
scompcauchy
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(c2cauchy {PLUS (PLUS t₁ t₃) t₅} {PLUS (PLUS t₂ t₄) t₆} ((c₁ ⊕ c₂) ⊕ c₃)))
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(subst Cauchy (size≡! ((c₁ ⊕ c₂) ⊕ c₃))
(idcauchy ((size t₂ + size t₄) + size t₆))))
≡⟨ sym (subst-dist scompcauchy (size≡! (assocl₊ {t₁} {t₃} {t₅})) _ _) ⟩
subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(scompcauchy
(c2cauchy {PLUS (PLUS t₁ t₃) t₅} {PLUS (PLUS t₂ t₄) t₆} ((c₁ ⊕ c₂) ⊕ c₃))
(subst Cauchy (size≡! ((c₁ ⊕ c₂) ⊕ c₃))
(idcauchy ((size t₂ + size t₄) + size t₆))))
≡⟨ sym (scomplid _) ⟩
scompcauchy
(idcauchy (size t₁ + (size t₃ + size t₅)))
(subst Cauchy (size≡! (assocl₊ {t₁} {t₃} {t₅}))
(scompcauchy
(c2cauchy
{PLUS (PLUS t₁ t₃) t₅} {PLUS (PLUS t₂ t₄) t₆} ((c₁ ⊕ c₂) ⊕ c₃))
(subst Cauchy (size≡! ((c₁ ⊕ c₂) ⊕ c₃))
(idcauchy ((size t₂ + size t₄) + size t₆)))))
≡⟨ refl ⟩
c2cauchy (assocl₊ ◎ (((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)) ∎)
where open ≡-Reasoning
soundness (assoc⊕r {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃}) = {!!}
soundness (assoc⊗l {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃}) = {!!}
soundness (assoc⊗r {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃}) = {!!}
soundness (dist⇔ {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃}) = {!!}
soundness (factor⇔ {t₁} {t₂} {t₃} {t₄} {t₅} {t₆} {c₁} {c₂} {c₃}) = {!!}
soundness (idl◎l {t₁} {t₂} {c}) = id◎c∼c {t₁} {t₂} {c}
soundness (idl◎r {t₁} {t₂} {c}) = sym (id◎c∼c {t₁} {t₂} {c})
soundness (idr◎l {t₁} {t₂} {c}) = c◎id∼c {t₁} {t₂} {c}
soundness (idr◎r {t₁} {t₂} {c}) = sym (c◎id∼c {t₁} {t₂} {c})
soundness (linv◎l {t₁} {t₂} {c}) = linv∼ {t₁} {t₂} {c}
soundness (linv◎r {t₁} {t₂} {c}) = sym (linv∼ {t₁} {t₂} {c})
soundness (rinv◎l {t₁} {t₂} {c}) = rinv∼ {t₁} {t₂} {c}
soundness (rinv◎r {t₁} {t₂} {c}) = sym (rinv∼ {t₁} {t₂} {c})
soundness (unitel₊⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (uniter₊⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (unitil₊⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (unitir₊⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (unitial₊⇔ {t₁} {t₂}) = {!!}
soundness (unitiar₊⇔ {t₁} {t₂}) = {!!}
soundness (swapl₊⇔ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂}) = {!!}
soundness (swapr₊⇔ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂}) = {!!}
soundness (unitel⋆⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (uniter⋆⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (unitil⋆⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (unitir⋆⇔ {t₁} {t₂} {c₁} {c₂}) = {!!}
soundness (unitial⋆⇔ {t₁} {t₂}) = {!!}
soundness (unitiar⋆⇔ {t₁} {t₂}) = {!!}
soundness (swapl⋆⇔ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂}) = {!!}
soundness (swapr⋆⇔ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂}) = {!!}
soundness (swapfl⋆⇔ {t₁} {t₂} {t₃}) = {!!}
soundness (swapfr⋆⇔ {t₁} {t₂} {t₃}) = {!!}
soundness (id⇔ {t₁} {t₂} {c}) = refl∼ {t₁} {t₂} {c}
soundness (trans⇔ {t₁} {t₂} {c₁} {c₂} {c₃} α β) =
trans∼ {t₁} {t₂} {c₁} {c₂} {c₃} (soundness α) (soundness β)
soundness (resp◎⇔ {t₁} {t₂} {t₃} {c₁} {c₃} {c₂} {c₄} α β) =
resp∼ {t₁} {t₂} {t₃} {c₁} {c₂} {c₃} {c₄} (soundness α) (soundness β)
soundness (resp⊕⇔ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂} {c₃} {c₄} α β) = {!!}
soundness (resp⊗⇔ {t₁} {t₂} {t₃} {t₄} {c₁} {c₂} {c₃} {c₄} α β) = {!!}
-- If we can prove that every combinator is equal to its normal form
-- then we can prove completeness.
inversion : {t₁ t₂ : U} (c : t₁ ⟷ t₂) → canonical c ⇔ c
inversion (c₁ ◎ c₂) = {!!}
inversion {PLUS ZERO t} {.t} unite₊ = {!!}
inversion {t} {PLUS ZERO .t} uniti₊ = {!!}
inversion {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ = {!!}
inversion {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = {!!}
inversion {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = {!!}
inversion {TIMES ONE t} {.t} unite⋆ = {!!}
inversion {t} {TIMES ONE .t} uniti⋆ = {!!}
inversion {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = {!!}
inversion {TIMES t₁ (TIMES t₂ t₃)} {TIMES (TIMES .t₁ .t₂) .t₃} assocl⋆ = {!!}
inversion {TIMES (TIMES t₁ t₂) t₃} {TIMES .t₁ (TIMES .t₂ .t₃)} assocr⋆ = {!!}
inversion {TIMES .ZERO t} {ZERO} distz = {!!}
inversion {ZERO} {TIMES ZERO t} factorz = {!!}
inversion {TIMES (PLUS t₁ t₂) t₃} {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} dist = {!!}
inversion {PLUS (TIMES t₁ t₃) (TIMES t₂ .t₃)} {TIMES (PLUS .t₁ .t₂) .t₃} factor = {!!}
inversion {t} {.t} id⟷ =
canonical id⟷
⇔⟨ id⇔ ⟩
normalizeC t ◎
transposition*2c (size t) (size t) refl (cauchy→transposition* (idcauchy (size t))) ◎
! (normalizeC t)
⇔⟨ {!!} ⟩
normalizeC t ◎ id⟷ ◎ ! (normalizeC t)
⇔⟨ resp◎⇔ id⇔ idl◎l ⟩
normalizeC t ◎ ! (normalizeC t)
⇔⟨ linv◎l ⟩
id⟷ ▤
inversion {PLUS t₁ t₂} {PLUS t₃ t₄} (c₁ ⊕ c₂) = {!!}
inversion {TIMES t₁ t₂} {TIMES t₃ t₄} (c₁ ⊗ c₂) = {!!}
inversion {PLUS ONE ONE} {BOOL} foldBool = {!!}
{--
canonical foldBool =
((uniti₊ ◎ swap₊ ⊕ uniti₊ ◎ swap₊) ◎ assocr₊ ◎ (id⟷ ⊕ unite₊)) ◎
(id⟷ ◎ (id⟷ ⊕ id⟷) ◎ id⟷) ◎
(((id⟷ ⊕ uniti₊) ◎ assocl₊) ◎ (swap₊ ◎ unite₊ ⊕ swap₊ ◎ unite₊)) ◎
foldBool
--}
inversion {BOOL} {PLUS ONE ONE} unfoldBool = {!!}
resp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)
resp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔
completeness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)
completeness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ =
c₁
⇔⟨ 2! (inversion c₁) ⟩
canonical c₁
⇔⟨ resp≡⇔ {!!} ⟩
canonical c₂
⇔⟨ inversion c₂ ⟩
c₂ ▤
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.4867131632,
"avg_line_length": 42.0296846011,
"ext": "agda",
"hexsha": "c6b7f93713971ed1753678b9bcbadb1ab36ffce9",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/Obsolete/Pif2.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/Obsolete/Pif2.agda",
"max_line_length": 87,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/Obsolete/Pif2.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 11681,
"size": 22654
} |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.NType2
open import lib.types.Group
open import lib.types.Word
open import lib.groups.GeneratedAbelianGroup
open import lib.groups.GeneratedGroup
open import lib.groups.GroupProduct
open import lib.groups.Homomorphism
open import lib.groups.Isomorphism
module lib.groups.FreeAbelianGroup {i} where
module FreeAbelianGroup (A : Type i) where
private
module Gen = GeneratedAbelianGroup A empty-rel
open Gen hiding (GenAbGroup; module HomomorphismEquiv) public
CommutativityRel : Rel (Word A) i
CommutativityRel = AbGroupRel
FormalSumRel : Rel (Word A) i
FormalSumRel = QuotWordRel
FormalSum : Type i
FormalSum = QuotWord
FreeGroup : Group i
FreeGroup = Gen.GenGroup
FreeAbGroup : AbGroup i
FreeAbGroup = Gen.GenAbGroup
module FreeAbGroup = AbGroup FreeAbGroup
{- Universal Property -}
module Freeness {j} (G : AbGroup j) where
private
module G = AbGroup G
extend-equiv : (A → G.El) ≃ (FreeAbGroup.grp →ᴳ G.grp)
extend-equiv =
Gen.HomomorphismEquiv.extend-equiv G ∘e every-function-respects-empty-rel-equiv A G.grp
extend : (A → G.El) → (FreeAbGroup.grp →ᴳ G.grp)
extend = –> extend-equiv
extend-is-equiv : is-equiv extend
extend-is-equiv = snd extend-equiv
extend-hom : Πᴳ A (λ _ → G.grp) →ᴳ hom-group FreeAbGroup.grp G
extend-hom = record {M} where
module M where
f : (A → G.El) → (FreeAbGroup.grp →ᴳ G.grp)
f = extend
abstract
pres-comp : preserves-comp (Group.comp (Πᴳ A (λ _ → G.grp))) (Group.comp (hom-group FreeAbGroup.grp G)) f
pres-comp = λ f₁ f₂ → group-hom= $ λ= $
QuotWord-elim
(Word-extendᴳ-comp G f₁ f₂)
(λ _ → prop-has-all-paths-↓)
extend-iso : Πᴳ A (λ _ → G.grp) ≃ᴳ hom-group FreeAbGroup.grp G
extend-iso = extend-hom , snd extend-equiv
| {
"alphanum_fraction": 0.6722077922,
"avg_line_length": 28.3088235294,
"ext": "agda",
"hexsha": "882f7b00bee85ff5c5995ead5702c8b3fb799bd5",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "core/lib/groups/FreeAbelianGroup.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "core/lib/groups/FreeAbelianGroup.agda",
"max_line_length": 115,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "core/lib/groups/FreeAbelianGroup.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": 583,
"size": 1925
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Enriched.Over.One where
open import Level
open import Categories.Category.Monoidal.Instance.One
open import Categories.Enriched.Category
TruthValue : (o ℓ e t : Level) → Set (o ⊔ ℓ ⊔ e ⊔ suc t)
TruthValue o ℓ e t = Category (One-Monoidal {o} {ℓ} {e}) t
| {
"alphanum_fraction": 0.7064516129,
"avg_line_length": 25.8333333333,
"ext": "agda",
"hexsha": "b5f7471810866c5d197fecb240fd835b898f3af8",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Enriched/Over/One.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Enriched/Over/One.agda",
"max_line_length": 58,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Enriched/Over/One.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 93,
"size": 310
} |
{-# OPTIONS --without-K --safe #-}
module Util.HoTT.Equiv.Core where
open import Util.Prelude
open import Util.HoTT.HLevel.Core
infix 4 _≅_ _≃_
private
variable
α β γ : Level
A B C : Set α
Injective : (f : A → B) → Set _
Injective f = ∀ {x y} → f x ≡ f y → x ≡ y
record IsIso {A : Set α} {B : Set β} (forth : A → B) : Set (α ⊔ℓ β)
where
field
back : B → A
back∘forth : ∀ x → back (forth x) ≡ x
forth∘back : ∀ x → forth (back x) ≡ x
record _≅_ (A : Set α) (B : Set β) : Set (α ⊔ℓ β) where
field
forth : A → B
isIso : IsIso forth
open IsIso isIso public
open _≅_ public
IsEquiv : {A : Set α} {B : Set β} (forth : A → B)
→ Set (α ⊔ℓ β)
IsEquiv {A = A} {B} forth
= ∀ b → IsContr (Σ[ a ∈ A ] forth a ≡ b)
record _≃_ (A : Set α) (B : Set β) : Set (α ⊔ℓ β) where
field
forth : A → B
isEquiv : IsEquiv forth
open _≃_ public
| {
"alphanum_fraction": 0.5474040632,
"avg_line_length": 17.3725490196,
"ext": "agda",
"hexsha": "f1691fe4060eeec9391233404f107784ce4f54c8",
"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": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Util/HoTT/Equiv/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"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": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Util/HoTT/Equiv/Core.agda",
"max_line_length": 67,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Util/HoTT/Equiv/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 369,
"size": 886
} |
module Nat where
data Nat : Set
data Nat where
zero : Nat
suc : Nat -> Nat
plus : Nat -> Nat -> Nat
plus zero n = n
plus (suc m) n = suc (plus m n)
elim : (P : (n : Nat) -> Set) ->
(z : P (plus zero zero)) ->
(s : (n : Nat) -> P (plus zero n) -> P (plus (suc zero) n)) ->
(n : Nat) -> P n
elim P z s zero = z
elim P z s (suc n) = s n (elim P z s n)
| {
"alphanum_fraction": 0.4831168831,
"avg_line_length": 20.2631578947,
"ext": "agda",
"hexsha": "4ab64de6a2384eaa3940d66fe10269bd07df7b96",
"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": "src/prototyping/term/examples/Nat.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": "src/prototyping/term/examples/Nat.agda",
"max_line_length": 69,
"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": "src/prototyping/term/examples/Nat.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": 146,
"size": 385
} |
module Oscar.Category where
open import Oscar.Level
open import Oscar.Function
record Setoid {𝔬} (𝔒 : Ø 𝔬) 𝔮 : Ø 𝔬 ∙̂ ↑̂ 𝔮 where
infix 4 _≋_
field
_≋_ : 𝔒 → 𝔒 → Ø 𝔮
≋-reflexivity : ∀ {x} → x ≋ x
≋-symmetry : ∀ {x y} → x ≋ y → y ≋ x
≋-transitivity : ∀ {x y} → x ≋ y → ∀ {z} → y ≋ z → x ≋ z
record Semigroupoid
{𝔬} {𝔒 : Ø 𝔬}
{𝔪} (𝔐 : 𝔒 → 𝔒 → Ø 𝔪)
{𝔮} (𝔐-setoid : ∀ {x y} → Setoid (𝔐 x y) 𝔮)
: Ø 𝔬 ∙̂ 𝔪 ∙̂ 𝔮 where
instance _ = λ {x y} → 𝔐-setoid {x} {y}
open Setoid ⦃ … ⦄ using (_≋_)
infixr 9 _∙_
field
_∙_ : ∀ {y z} → 𝔐 y z → ∀ {x} → 𝔐 x y → 𝔐 x z
∙-extensionality : ∀ {x y} {f₁ f₂ : 𝔐 x y} → f₁ ≋ f₂ → ∀ {z} {g₁ g₂ : 𝔐 y z} → g₁ ≋ g₂ → g₁ ∙ f₁ ≋ g₂ ∙ f₂
∙-associativity : ∀ {w x} (f : 𝔐 w x) {y} (g : 𝔐 x y) {z} (h : 𝔐 y z) → (h ∙ g) ∙ f ≋ h ∙ (g ∙ f)
record Category
{𝔬} {𝔒 : Ø 𝔬}
{𝔪} {𝔐 : 𝔒 → 𝔒 → Ø 𝔪}
{𝔮} {𝔐-setoid : ∀ {x y} → Setoid (𝔐 x y) 𝔮}
(semigroupoid : Semigroupoid 𝔐 𝔐-setoid)
: Ø 𝔬 ∙̂ 𝔪 ∙̂ 𝔮 where
instance _ = λ {x y} → 𝔐-setoid {x} {y}
open Setoid ⦃ … ⦄ using (_≋_)
open Semigroupoid semigroupoid using (_∙_)
field
ε : ∀ {x} → 𝔐 x x
ε-left-identity : ∀ {x y} {f : 𝔐 x y} → ε ∙ f ≋ f
ε-right-identity : ∀ {x y} {f : 𝔐 x y} → f ∙ ε ≋ f
record Semifunctor
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔪₁} {𝔐₁ : 𝔒₁ → 𝔒₁ → Ø 𝔪₁}
{𝔮₁} {𝔐₁-setoid : ∀ {x y} → Setoid (𝔐₁ x y) 𝔮₁}
(semigroupoid₁ : Semigroupoid 𝔐₁ 𝔐₁-setoid)
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔪₂} {𝔐₂ : 𝔒₂ → 𝔒₂ → Ø 𝔪₂}
{𝔮₂} {𝔐₂-setoid : ∀ {x y} → Setoid (𝔐₂ x y) 𝔮₂}
(semigroupoid₂ : Semigroupoid 𝔐₂ 𝔐₂-setoid)
: Ø 𝔬₁ ∙̂ 𝔪₁ ∙̂ 𝔮₁ ∙̂ 𝔬₂ ∙̂ 𝔪₂ ∙̂ 𝔮₂
where
instance _ = λ {x y} → 𝔐₁-setoid {x} {y}
instance _ = λ {x y} → 𝔐₂-setoid {x} {y}
open Setoid ⦃ … ⦄ using (_≋_)
module ⒈ = Semigroupoid semigroupoid₁
module ⒉ = Semigroupoid semigroupoid₂
field
{μ} : 𝔒₁ → 𝔒₂
𝔣 : ∀ {x y} → 𝔐₁ x y → 𝔐₂ (μ x) (μ y)
𝔣-extensionality : ∀ {x y} → {f₁ f₂ : 𝔐₁ x y} → f₁ ≋ f₂ → 𝔣 f₁ ≋ 𝔣 f₂
𝔣-commutativity : ∀ {x y} {f : 𝔐₁ x y} {z} {g : 𝔐₁ y z} → 𝔣 (g ⒈.∙ f) ≋ 𝔣 g ⒉.∙ 𝔣 f
record Functor
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔪₁} {𝔐₁ : 𝔒₁ → 𝔒₁ → Ø 𝔪₁}
{𝔮₁} {𝔐₁-setoid : ∀ {x y} → Setoid (𝔐₁ x y) 𝔮₁}
{semigroupoid₁ : Semigroupoid 𝔐₁ 𝔐₁-setoid}
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔪₂} {𝔐₂ : 𝔒₂ → 𝔒₂ → Ø 𝔪₂}
{𝔮₂} {𝔐₂-setoid : ∀ {x y} → Setoid (𝔐₂ x y) 𝔮₂}
{semigroupoid₂ : Semigroupoid 𝔐₂ 𝔐₂-setoid}
(semifunctor : Semifunctor semigroupoid₁ semigroupoid₂)
(category₁ : Category semigroupoid₁)
(category₂ : Category semigroupoid₂)
: Ø 𝔬₁ ∙̂ 𝔪₁ ∙̂ 𝔮₁ ∙̂ 𝔬₂ ∙̂ 𝔪₂ ∙̂ 𝔮₂
where
instance _ = λ {x y} → 𝔐₂-setoid {x} {y}
open Setoid ⦃ … ⦄ using (_≋_)
open Semifunctor semifunctor using (𝔣; μ)
module ⒈ = Category category₁
module ⒉ = Category category₂
field
𝔣-identity : ∀ {x : 𝔒₁} → 𝔣 (⒈.ε {x = x}) ≋ (⒉.ε {x = μ x})
| {
"alphanum_fraction": 0.5174165457,
"avg_line_length": 32.4235294118,
"ext": "agda",
"hexsha": "6361f43b26866316f732e9241ceee5df3008a1c9",
"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/Category.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/Category.agda",
"max_line_length": 110,
"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/Category.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1670,
"size": 2756
} |
module consoleExamples.simpleLoop where
open import ConsoleLib
open import Data.Bool renaming (not to ¬)
open import Data.String hiding (_==_)
open import SizedIO.Base
open import Size
-- the following program asks the user for an input, which is a string.
-- It converts this string into a Boolean value (by mapping "true" to true and
-- "false" to false), applies Boolean negation to the result
-- and then converts the resulting Boolean value back to a string
boolStrInput2Bool : String → Bool
boolStrInput2Bool s = s ==str "true"
checkStrBoolInput : String → Bool
checkStrBoolInput s = (s ==str "true") ∨ (s ==str "false")
bool2Str : Bool → String
bool2Str true = "true"
bool2Str false = "false"
-- when writing a recursive program you need to write first the body
-- as an element of IOConsole
-- and apply an eliminator to it, followed by a a function which
-- results in an element of IOConsole'
-- otherwise the recursion would unfold and you get an infinite term
--
-- The functions WriteString+ and ReadLine+ which need the continuing program
-- as argument can be used to create elements of IOConsole'
--
-- Furthermore after applying a size argument (i which is of type Size)
-- the termination checker can figure out that your definition is productive
-- i.e. has at least one interaction before carrying out the recursion.
mainBody : ∀{i} → IOConsole i Unit
force (mainBody) = WriteString+ "Enter true or false"
(GetLine >>= λ s →
if (checkStrBoolInput s)
then (WriteString ("Result of negating your input is " ++
bool2Str (¬ (boolStrInput2Bool s))) >>= λ _ →
mainBody)
else
(WriteString ("Please enter \"true\" or \"false\"") >>= λ _ →
mainBody))
main : ConsoleProg
main = run mainBody
| {
"alphanum_fraction": 0.6609195402,
"avg_line_length": 36.8076923077,
"ext": "agda",
"hexsha": "b4ad0a572c8820bee649bf5625c38ff818315401",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "examples/consoleExamples/simpleLoop.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"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": "agda/ooAgda",
"max_issues_repo_path": "examples/consoleExamples/simpleLoop.agda",
"max_line_length": 84,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "examples/consoleExamples/simpleLoop.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 445,
"size": 1914
} |
module DoBlock3 where
data Id
(A : Set)
: Set
where
id
: A
→ Id A
_>>=_
: {A B : Set}
→ Id A
→ (A → Id B)
→ Id B
id x >>= f
= f x
_>>_
: {A B : Set}
→ Id A
→ Id B
→ Id B
_ >> y
= y
f
: {A : Set}
→ A
→ Id A
f x
= do
id x
id x
| {
"alphanum_fraction": 0.3674911661,
"avg_line_length": 7.6486486486,
"ext": "agda",
"hexsha": "1eabd3083954600d45ec71f31144b52d6ee2f662",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "msuperdock/agda-unused",
"max_forks_repo_path": "data/expression/DoBlock3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"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": "msuperdock/agda-unused",
"max_issues_repo_path": "data/expression/DoBlock3.agda",
"max_line_length": 21,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "msuperdock/agda-unused",
"max_stars_repo_path": "data/expression/DoBlock3.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z",
"num_tokens": 141,
"size": 283
} |
module Numeral.Natural.UnclosedOper where
import Lvl
open import Data
open import Data.Boolean.Stmt
open import Data.Option as Option using (Option)
open import Data.Option.Functions as Option
open import Logic.Propositional
open import Numeral.Finite as 𝕟
using (𝕟)
import Numeral.Finite.Bound as 𝕟bound
open import Numeral.Integer as ℤ
using (ℤ)
open import Numeral.Natural
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Comparisons
open import Numeral.Natural.Oper.Modulo
open import Numeral.Natural.Oper.Modulo.Proofs
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Decidable
open import Numeral.Natural.Relation.Order.Proofs
import Numeral.Sign as Sign
open import Type.Properties.Decidable.Proofs
infix 10010 _−_
-- TODO _/_ : ℕ → ℕ → ℚ
-- Unclosed total subtraction from natural numbers to an optional natural number.
-- When the subtraction gives a negative number semantically, this operation gives Option.None.
_−?_ : ℕ → ℕ → Option(ℕ)
a −? 𝟎 = Option.Some(a)
𝟎 −? 𝐒(b) = Option.None
𝐒(a) −? 𝐒(b) = a −? b
-- Unclosed total floored division
{-# TERMINATING #-}
_⌊/₀⌋_ : ℕ → ℕ → ℕ
𝐒(x) ⌊/₀⌋ 𝐒(y) with (𝐒(x) −? 𝐒(y))
... | Option.Some(𝐒x𝐒y) = 𝐒(𝐒x𝐒y ⌊/₀⌋ 𝐒(y))
... | Option.None = 𝟎
{-# CATCHALL #-}
_ ⌊/₀⌋ _ = 𝟎
-- Unclosed total subtraction from natural numbers to an optional natural number.
-- When dividing by 0, this operation gives Option.None.
{-# TERMINATING #-}
_⌊/⌋?_ : ℕ → ℕ → Option(ℕ)
_ ⌊/⌋? 𝟎 = Option.None
𝟎 ⌊/⌋? 𝐒(_) = Option.Some(𝟎)
𝐒(x) ⌊/⌋? 𝐒(y) with (𝐒(x) −? 𝐒(y))
... | Option.Some(𝐒x𝐒y) = Option.map 𝐒(𝐒x𝐒y ⌊/⌋? 𝐒(y))
... | Option.None = Option.Some(𝟎)
-- Unclosed total subtraction from natural numbers to an optional natural number.
-- When dividing by 0 or the division gives a rational number semantically, this operation gives Option.None.
{-# TERMINATING #-}
_/?_ : ℕ → ℕ → Option(ℕ)
_ /? 𝟎 = Option.None
𝟎 /? 𝐒(_) = Option.Some(𝟎)
𝐒(x) /? 𝐒(y) with (𝐒(x) −? 𝐒(y))
... | Option.Some(𝐒x𝐒y) = Option.map 𝐒(𝐒x𝐒y /? 𝐒(y))
... | Option.None = Option.None
-- Unclosed total subtraction from natural numbers to finite natural numbers
_−₀fin_ : (x : ℕ) → ℕ → 𝕟(𝐒(x))
𝟎 −₀fin _ = 𝕟.𝟎
𝐒(x) −₀fin 𝟎 = 𝕟.𝐒(x −₀fin 𝟎)
𝐒(x) −₀fin 𝐒(y) = 𝕟bound.bound-𝐒 (x −₀fin y)
-- Unclosed total subtraction from a natural number and a finite natural number to a finite natural number
_−fin_ : (x : ℕ) → 𝕟(𝐒(x)) → 𝕟(𝐒(x))
𝟎 −fin 𝕟.𝟎 = 𝕟.𝟎
𝐒(x) −fin 𝕟.𝟎 = 𝕟.𝐒(x −fin 𝕟.𝟎)
𝐒(x) −fin 𝕟.𝐒(y) = 𝕟bound.bound-𝐒 (x −fin y)
-- Modulo operation to upper bounded natural numbers.
_modfin_ : ℕ → (b : ℕ) → ⦃ _ : IsTrue(b ≢? 𝟎) ⦄ → 𝕟(b)
a modfin 𝐒 b = 𝕟.ℕ-to-𝕟 (a mod 𝐒(b)) ⦃ [↔]-to-[→] decider-true (mod-maxᵣ{a}{𝐒 b}) ⦄
| {
"alphanum_fraction": 0.6565547129,
"avg_line_length": 34.6125,
"ext": "agda",
"hexsha": "667cf8ac483cebd572d4f88f1b33608b80c7fa28",
"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/UnclosedOper.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/UnclosedOper.agda",
"max_line_length": 109,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Natural/UnclosedOper.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": 1148,
"size": 2769
} |
open import Type
module Structure.Operator.SetAlgebra {ℓ} (S : Type{ℓ}) where
import Lvl
open import Functional
open import Logic
open import Logic.Propositional
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Operator.Properties
open import Structure.Operator.Proofs
open import Structure.Relator.Properties
open import Syntax.Transitivity
record Fundamentals : Stmt{ℓ} where
infixl 1001 _∩_
infixl 1000 _∪_
field
_∪_ : S → S → S -- Union
_∩_ : S → S → S -- Intersection
∅ : S -- Empty set
𝐔 : S -- Universal set
field -- TODO: This is two commutative monoids with distributivity over each other
⦃ [∪]-commutativity ⦄ : Commutativity(_∪_)
⦃ [∩]-commutativity ⦄ : Commutativity(_∩_)
⦃ [∪]-associativity ⦄ : Associativity(_∪_)
⦃ [∩]-associativity ⦄ : Associativity(_∩_)
⦃ [∪][∩]-distributivityₗ ⦄ : Distributivityₗ(_∪_)(_∩_)
⦃ [∩][∪]-distributivityₗ ⦄ : Distributivityₗ(_∩_)(_∪_)
⦃ [∪]-identityₗ ⦄ : Identityₗ(_∪_)(∅)
⦃ [∩]-identityₗ ⦄ : Identityₗ(_∩_)(𝐔)
instance
[∪][∩]-distributivityᵣ : Distributivityᵣ(_∪_)(_∩_)
[∪][∩]-distributivityᵣ = [↔]-to-[→] OneTypeTwoOp.distributivity-equivalence-by-commutativity [∪][∩]-distributivityₗ
instance
[∩][∪]-distributivityᵣ : Distributivityᵣ(_∩_)(_∪_)
[∩][∪]-distributivityᵣ = [↔]-to-[→] OneTypeTwoOp.distributivity-equivalence-by-commutativity [∩][∪]-distributivityₗ
instance
[∪]-identityᵣ : Identityᵣ(_∪_)(∅)
[∪]-identityᵣ = [↔]-to-[→] One.identity-equivalence-by-commutativity [∪]-identityₗ
instance
[∩]-identityᵣ : Identityᵣ(_∩_)(𝐔)
[∩]-identityᵣ = [↔]-to-[→] One.identity-equivalence-by-commutativity [∩]-identityₗ
record Complement : Stmt{ℓ} where
infixl 1002 ∁_
infixl 1000 _∖_
field
∁_ : S → S -- Complement
field
⦃ fundamentals ⦄ : Fundamentals
open Fundamentals(fundamentals)
field -- TODO: Not really inverses. These are using the absorbers
[∪]-inverseᵣ : ∀{s : S} → (s ∪ ∁(s) ≡ 𝐔)
[∩]-inverseᵣ : ∀{s : S} → (s ∩ ∁(s) ≡ ∅)
_∖_ : S → S → S -- Difference
_∖_ (s₁)(s₂) = s₁ ∩ ∁(s₂)
[∪]-inverseₗ : ∀{s : S} → (∁(s) ∪ s ≡ 𝐔)
[∪]-inverseₗ = transitivity(_≡_) (commutativity(_∪_)) [∪]-inverseᵣ
[∩]-inverseₗ : ∀{s : S} → (∁(s) ∩ s ≡ ∅)
[∩]-inverseₗ = transitivity(_≡_) (commutativity(_∩_)) [∩]-inverseᵣ
[∁]-of-[∅] : (∁(∅) ≡ 𝐔)
[∁]-of-[∅] =
symmetry(_≡_) (identityₗ(_∪_)(∅))
🝖 ([∪]-inverseᵣ)
[∁]-of-[𝐔] : (∁(𝐔) ≡ ∅)
[∁]-of-[𝐔] =
symmetry(_≡_) (identityₗ(_∩_)(𝐔))
🝖 ([∩]-inverseᵣ)
[∪]-idempotence : ∀{s : S} → (s ∪ s) ≡ s
[∪]-idempotence{s} =
([≡]-intro)
🝖 (symmetry(_≡_) (identityᵣ(_∩_)(𝐔)))
🝖 ([≡]-with(expr ↦ ((s ∪ s) ∩ expr)) (symmetry(_≡_) [∪]-inverseᵣ))
🝖 (symmetry(_≡_) (distributivityₗ(_∪_)(_∩_)))
🝖 ([≡]-with(expr ↦ (s ∪ expr)) [∩]-inverseᵣ)
🝖 ((identityᵣ(_∪_)(∅)))
[∩]-idempotence : ∀{s : S} → (s ∩ s) ≡ s
[∩]-idempotence{s} =
([≡]-intro)
🝖 (symmetry(_≡_) (identityᵣ(_∪_)(∅)))
🝖 ([≡]-with(expr ↦ ((s ∩ s) ∪ expr)) (symmetry(_≡_) [∩]-inverseᵣ))
🝖 (symmetry(_≡_) (distributivityₗ(_∩_)(_∪_)))
🝖 ([≡]-with(expr ↦ (s ∩ expr)) [∪]-inverseᵣ)
🝖 ((identityᵣ(_∩_)(𝐔)))
[∪]-absorber : ∀{s : S} → (s ∪ 𝐔) ≡ 𝐔
[∪]-absorber{s} =
([≡]-with(expr ↦ s ∪ expr) (symmetry(_≡_) [∪]-inverseᵣ))
🝖 (symmetry(_≡_) (associativity(_∪_)))
🝖 ([≡]-with(expr ↦ expr ∪ ∁(s)) [∪]-idempotence)
🝖 ([∪]-inverseᵣ)
-- s∪𝐔 = s∪(s ∪ ∁(s)) = (s∪s) ∪ ∁(s) = s ∪ ∁(s) = 𝐔
[∩]-absorber : ∀{s : S} → (s ∩ ∅) ≡ ∅
[∩]-absorber{s} =
([≡]-with(expr ↦ s ∩ expr) (symmetry(_≡_) [∩]-inverseᵣ))
🝖 (symmetry(_≡_) (associativity(_∩_)))
🝖 ([≡]-with(expr ↦ expr ∩ ∁(s)) [∩]-idempotence)
🝖 ([∩]-inverseᵣ)
-- s∩∅ = s∩(s ∩ ∁(s)) = (s∩s) ∩ ∁(s) = s ∩ ∁(s) = ∅
-- postulate [∪]-absorptionₗ : ∀{s₁ s₂ : S} → (s₁ ∪ (s₁ ∩ s₂)) ≡ s₁
-- s₁∪(s₁∩s₂)
-- = (s₁∪s₁)∩(s₁∪s₂)
-- = s₁∩(s₁∪s₂)
-- = (s₁∩s₁) ∪ (s₁∩s₂)
-- = s₁ ∪ (s₁∩s₂)
-- = ?
-- postulate [∩]-absorptionₗ : ∀{s₁ s₂ : S} → (s₁ ∩ (s₁ ∪ s₂)) ≡ s₁
-- ∁(s₁) ∪ ∁(s₁ ∪ s₂) = ∁(s₁)
-- ∁(s₁) ∩ ∁(s₁ ∪ s₂) = ∁(s₁ ∪ s₂)
-- ∁(s₁) ∪ ∁(s₁ ∩ s₂) = ∁(s₁ ∩ s₂)
-- ∁(s₁) ∩ ∁(s₁ ∩ s₂) = ∁(s₁)
-- postulate a : ∀{a} → a
-- postulate [∁]-of-[∪] : ∀{s₁ s₂ : S} → ∁(s₁ ∪ s₂) ≡ ∁(s₁) ∩ ∁(s₂)
-- [∁]-of-[∪] =
-- ((∁(s₁) ∩ ∁(s₂)) ∪ (s₁ ∪ s₂)) = 𝐔 ?
-- (s₁ ∪ s₂) ∪ ∁(s₁ ∪ s₂) = 𝐔
-- ∁(s₂) ∩ ((s₁ ∪ s₂) ∪ ∁(s₁ ∪ s₂)) = ∁(s₁) ∩ 𝐔
-- (∁(s₂) ∩ (s₁ ∪ s₂)) ∪ (∁(s₁) ∩ ∁(s₁ ∪ s₂)) = ∁(s₂) ∩ 𝐔
-- (∁(s₂) ∩ (s₁ ∪ s₂)) ∪ (∁(s₁) ∩ ∁(s₁ ∪ s₂)) = ∁(s₂) ∩ 𝐔
-- (∁(s₂) ∩ (s₁ ∪ s₂)) ∪ (∁(s₁) ∩ ∁(s₁ ∪ s₂)) = ∁(s₂)
-- ∁(s₂) = (∁(s₂) ∩ (s₁ ∪ s₂)) ∪ (∁(s₁) ∩ ∁(s₁ ∪ s₂))
-- ∁(s₂) = ((∁(s₂) ∩ s₁) ∪ (∁(s₂) ∩ s₂)) ∪ ∁(s₁ ∪ s₂)
-- ∁(s₂) = ((∁(s₂) ∩ s₁) ∪ ∅) ∪ ∁(s₁ ∪ s₂)
-- ∁(s₂) = (∁(s₂) ∩ s₁) ∪ ∁(s₁ ∪ s₂)
-- ∁(s₁) ∩ ∁(s₂) = ∁(s₁) ∩ ((∁(s₂) ∩ s₁) ∪ ∁(s₁ ∪ s₂))
-- ∁(s₁) ∩ ∁(s₂) = (∁(s₁) ∩ (∁(s₂) ∩ s₁)) ∪ (∁(s₁) ∩ ∁(s₁ ∪ s₂))
-- ∁(s₁) ∩ ∁(s₂) = (∁(s₁) ∩ (∁(s₂) ∩ s₁)) ∪ ∁(s₁ ∪ s₂)
-- ∁(s₁) ∩ ∁(s₂) = (∁(s₁) ∩ (s₁ ∩ ∁(s₂))) ∪ ∁(s₁ ∪ s₂)
-- ∁(s₁) ∩ ∁(s₂) = ((∁(s₁) ∩ s₁) ∩ ∁(s₂)) ∪ ∁(s₁ ∪ s₂)
-- ∁(s₁) ∩ ∁(s₂) = (∅ ∩ ∁(s₂)) ∪ ∁(s₁ ∪ s₂)
-- ∁(s₁) ∩ ∁(s₂) = ∅ ∪ ∁(s₁ ∪ s₂)
-- ∁(s₁) ∩ ∁(s₂) = ∁(s₁ ∪ s₂)
-- postulate proof1 : ∀{a b c d} → (a ∩ b) ∩ (c ∪ d) ≡ (a ∩ (b ∩ d)) ∪ (b ∩ (a ∩ c))
-- (a ∩ b) ∩ (c ∪ d)
-- = ((a ∩ b) ∩ c) ∪ ((a ∩ b) ∩ d)
-- = ((b ∩ a) ∩ c) ∪ ((a ∩ b) ∩ d)
-- = (b ∩ (a ∩ c)) ∪ ((a ∩ b) ∩ d)
-- = (b ∩ (a ∩ c)) ∪ (a ∩ (b ∩ d))
-- = (a ∩ (b ∩ d)) ∪ (b ∩ (a ∩ c))
-- postulate proof2 : ∀{a b} → (a ∩ b) ∩ (∁(a) ∪ ∁(b)) ≡ ∅
-- (a ∩ b) ∩ (∁(a) ∪ ∁(b))
-- = (a ∩ (b ∩ ∁(b))) ∪ (b ∩ (a ∩ ∁(a)))
-- = (a ∩ ∅) ∪ (b ∩ (a ∩ ∁(a)))
-- = ∅ ∪ (b ∩ (a ∩ ∁(a)))
-- = b ∩ (a ∩ ∁(a))
-- = b ∩ ∅
-- = ∅
-- ∁(s₁ ∪ s₂) ∪ (s₁ ∪ s₂) = 𝐔
-- (∁(s₁ ∪ s₂) ∪ (s₁ ∪ s₂)) ∩ (∁(a) ∪ ∁(b)) = 𝐔 ∩ (∁(a) ∪ ∁(b))
-- (∁(s₁ ∪ s₂) ∪ (s₁ ∪ s₂)) ∩ (∁(a) ∪ ∁(b)) = ∁(a) ∪ ∁(b)
-- ∁(a) ∪ ∁(b) = (∁(s₁ ∪ s₂) ∪ (s₁ ∪ s₂)) ∩ (∁(a) ∪ ∁(b))
-- ∁(a) ∪ ∁(b) = (∁(s₁ ∪ s₂) ∩ (∁(a) ∪ ∁(b))) ∪ ((s₁ ∪ s₂) ∩ (∁(a) ∪ ∁(b)))
-- ∁(a) ∪ ∁(b) = (∁(s₁ ∪ s₂) ∩ (∁(a) ∪ ∁(b))) ∪ ∅
-- ∁(a) ∪ ∁(b) = ∁(s₁ ∪ s₂) ∩ (∁(a) ∪ ∁(b))
postulate [∁]-of-[∩] : ∀{s₁ s₂ : S} → ∁(s₁ ∩ s₂) ≡ ∁(s₁) ∪ ∁(s₂)
[∁∁]-elim : ∀{s : S} → ∁(∁(s)) ≡ s
[∁∁]-elim {s} = transitivity(_≡_) proof2 (symmetry(_≡_) proof1) where
proof1 : s ≡ s ∪ ∁(∁(s))
proof1 =
[∩]-inverseᵣ {∁(s)}
⩺ [≡]-with(s ∪_)
⩺ (eq ↦ transitivity(_≡_) eq ((identityᵣ(_∪_)(∅)) {s}))
⩺ symmetry(_≡_)
⩺ (eq ↦ transitivity(_≡_) eq ((distributivityₗ(_∪_)(_∩_))))
⩺ (eq ↦ transitivity(_≡_) eq ([≡]-with(_∩ (s ∪ ∁(∁(s)))) ([∪]-inverseᵣ)))
⩺ (eq ↦ transitivity(_≡_) eq (identityₗ(_∩_)(𝐔)))
-- ∁(s) ∩ ∁(∁(s)) ≡ ∅
-- s ∪ (∁(s) ∩ ∁(∁(s))) ≡ s ∪ ∅
-- s ∪ (∁(s) ∩ ∁(∁(s))) ≡ s
-- s ≡ s ∪ (∁(s) ∩ ∁(∁(s)))
-- s ≡ (s ∪ ∁(s)) ∩ (s ∪ ∁(∁(s)))
-- s ≡ 𝐔 ∩ (s ∪ ∁(∁(s)))
-- s ≡ s ∪ ∁(∁(s))
proof2 : ∁(∁(s)) ≡ s ∪ ∁(∁(s))
proof2 =
[∩]-inverseᵣ {s}
⩺ [≡]-with(_∪ ∁(∁(s)))
⩺ (eq ↦ transitivity(_≡_) eq (identityₗ(_∪_)(∅)))
⩺ symmetry(_≡_)
⩺ (eq ↦ transitivity(_≡_) eq ((distributivityᵣ(_∪_)(_∩_))))
⩺ (eq ↦ transitivity(_≡_) eq ([≡]-with((s ∪ ∁(∁(s))) ∩_) ([∪]-inverseᵣ)))
⩺ (eq ↦ transitivity(_≡_) eq ((identityᵣ(_∩_)(𝐔))))
-- (s ∩ ∁(s)) ∪ ∁(∁(s)) ≡ ∅ ∪ ∁(∁(s))
-- (s ∩ ∁(s)) ∪ ∁(∁(s)) ≡ ∁(∁(s))
-- ∁(∁(s)) ≡ (s ∩ ∁(s)) ∪ ∁(∁(s))
-- ∁(∁(s)) ≡ (s ∪ ∁(∁(s))) ∩ (∁(s) ∪ ∁(∁(s)))
-- ∁(∁(s)) ≡ (s ∪ ∁(∁(s))) ∩ 𝐔
-- ∁(∁(s)) ≡ s ∪ ∁(∁(s))
postulate [∁]-uniqueness : ∀{s₁ s₂ : S} → (s₁ ∪ s₂ ≡ 𝐔) → (s₁ ∩ s₂ ≡ ∅) → (s₁ ≡ ∁(s₂))
postulate [∁]-of-[∖] : ∀{s₁ s₂ : S} → ∁(s₁ ∖ s₂) ≡ ∁(s₁) ∪ s₂
postulate [∖]-of-[∁] : ∀{s₁ s₂ : S} → ∁(s₁) ∖ ∁(s₂) ≡ s₂ ∖ s₁
postulate [∖]-of-[∪]ᵣ : ∀{s₁ s₂ s₃ : S} → (s₁ ∖ (s₂ ∪ s₃)) ≡ (s₁ ∖ s₂)∩(s₁ ∖ s₃)
postulate [∖]-of-[∩]ᵣ : ∀{s₁ s₂ s₃ : S} → (s₁ ∖ (s₂ ∩ s₃)) ≡ (s₁ ∖ s₂)∪(s₁ ∖ s₃)
postulate [∖]-of-[∖]ᵣ : ∀{s₁ s₂ s₃ : S} → (s₁ ∖ (s₂ ∖ s₃)) ≡ (s₁ ∩ s₃)∪(s₁ ∖ s₂)
postulate [∩]-from-[∖] : ∀{s₁ s₂ : S} → (s₁ ∖ (s₁ ∖ s₂)) ≡ (s₁ ∩ s₂) -- TODO: from [∖]-of-[∖]ᵣ
postulate [∖]-self : ∀{s : S} → s ∖ s ≡ ∅
postulate [∖]-of-[∅]ₗ : ∀{s : S} → ∅ ∖ s ≡ ∅
postulate [∖]-of-[∅]ᵣ : ∀{s : S} → s ∖ ∅ ≡ s
postulate [∖]-of-[𝐔]ₗ : ∀{s : S} → 𝐔 ∖ s ≡ ∁(s)
postulate [∖]-of-[𝐔]ᵣ : ∀{s : S} → s ∖ 𝐔 ≡ ∅
record Subset : Type{Lvl.𝐒(ℓ)} where
field
_⊆_ : S → S → Stmt{ℓ} -- Subset
⦃ fundamentals ⦄ : Fundamentals
open Fundamentals(fundamentals)
field
⦃ [⊆]-antisymmetry ⦄ : Antisymmetry(_⊆_)(_≡_)
⦃ [⊆]-transitivity ⦄ : Transitivity(_⊆_)
⦃ [⊆]-reflexivity ⦄ : Reflexivity(_⊆_)
[≡]-to-[⊆] : ∀{a b} → (a ≡ b) → (a ⊆ b)
[⊆]ₗ-of-[∪] : ∀{a b c} → (a ⊆ c) → (b ⊆ c) → ((a ∪ b) ⊆ c)
[⊆]ᵣ-of-[∪]ₗ : ∀{a b} → (a ⊆ (a ∪ b))
[⊆]ₗ-of-[∩]ₗ : ∀{a b} → ((a ∩ b) ⊆ a)
[⊆]ᵣ-of-[∩] : ∀{a b c} → (c ⊆ a) → (c ⊆ b) → (c ⊆ (a ∩ b))
[⊆]ᵣ-of-[∪]ᵣ : ∀{a b} → (b ⊆ (a ∪ b))
[⊆]ᵣ-of-[∪]ᵣ {a}{b} =
[⊆]ᵣ-of-[∪]ₗ {b}{a}
🝖 [≡]-to-[⊆] (commutativity(_∪_))
[⊆]ₗ-of-[∩]ᵣ : ∀{a b} → ((a ∩ b) ⊆ b)
[⊆]ₗ-of-[∩]ᵣ {a}{b} =
[≡]-to-[⊆] (commutativity(_∩_))
🝖 [⊆]ₗ-of-[∩]ₗ {b}{a}
[⊆]-min : ∀{s} → (∅ ⊆ s)
[⊆]-min {s} =
[⊆]ᵣ-of-[∪]ₗ {∅}{s}
🝖 [≡]-to-[⊆] (identityₗ(_∪_)(∅))
[⊆]-max : ∀{s} → (s ⊆ 𝐔)
[⊆]-max {s} =
[≡]-to-[⊆] (symmetry(_≡_) (identityₗ(_∩_)(𝐔)))
🝖 [⊆]ₗ-of-[∩]ₗ {𝐔}{s}
[⊆][∩]-equiv : ∀{a b} → (a ⊆ b) ↔ (a ∩ b ≡ a)
[⊆][∩]-equiv {a}{b} = [↔]-intro l r where
l : (a ⊆ b) ← (a ∩ b ≡ a)
l aba =
[≡]-to-[⊆] (symmetry(_≡_) aba)
🝖 [⊆]ₗ-of-[∩]ᵣ
r : (a ⊆ b) → (a ∩ b ≡ a)
r ab =
(antisymmetry(_⊆_)(_≡_)
([⊆]ₗ-of-[∩]ₗ)
([⊆]ᵣ-of-[∩] {a}{b}{a} (reflexivity(_⊆_)) ab)
)
{-
[⊆][∪]-equiv : ∀{a b} → (a ⊆ b) ↔ (a ∪ b ≡ b)
[⊆][∪]-equiv {a}{b} = [↔]-intro l r where
l : (a ⊆ b) ← (a ∪ b ≡ b)
l aba =
[≡]-to-[⊆] (symmetry(_≡_) aba)
🝖 [⊆]ᵣ-of-[∪]ᵣ
r : (a ⊆ b) → (a ∪ b ≡ b)
r ab =
(antisymmetry
([⊆]ᵣ-of-[∪]ᵣ)
([⊆]ₗ-of-[∪] {a}{b}{a} reflexivity ab)
)
-}
-- [⊆][∖]-equiv : (a ⊆ b) ↔ (a ∖ b ≡ ∅)
-- [⊆][∁]-equiv : (a ⊆ b) ↔ (∁(b) ⊆ ∁(a))
-- [∩][∪]-sub : (a ∩ b) ⊆ (a ∪ b)
| {
"alphanum_fraction": 0.3914811229,
"avg_line_length": 32.898089172,
"ext": "agda",
"hexsha": "cb3ccc6f31fe3c87a89ce2d1d03530443564a2aa",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Operator/SetAlgebra.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Operator/SetAlgebra.agda",
"max_line_length": 119,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Operator/SetAlgebra.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": 6254,
"size": 10330
} |
module ImportTests.ExtractDependent where
open import Data.Bool
open import Data.Nat
open import ExtractDependent
f : ℕ -> Bool
f 0 = false
f _ = true
testApply : Bool
testApply = apply _ _ f 5
testApplyImp : Bool
testApplyImp = applyImp f 6
testApplyImpSameName : Bool
testApplyImpSameName = applyImpSameName {ℕ} Bool f 3
| {
"alphanum_fraction": 0.7720364742,
"avg_line_length": 16.45,
"ext": "agda",
"hexsha": "31243912f68f5da76375f7f0822db4f69e8367b0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "omega12345/RefactorAgda",
"max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractDependent.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "omega12345/RefactorAgda",
"max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractDependent.agda",
"max_line_length": 52,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "omega12345/RefactorAgda",
"max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractDependent.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z",
"num_tokens": 101,
"size": 329
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Values for AVL trees
-- Values must respect the underlying equivalence on keys
-----------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary using (Setoid; _Respects_)
module Data.AVL.Value {a ℓ} (S : Setoid a ℓ) where
open import Level using (suc; _⊔_)
import Function as F
open Setoid S renaming (Carrier to Key)
record Value v : Set (a ⊔ ℓ ⊔ suc v) where
constructor MkValue
field
family : Key → Set v
respects : family Respects _≈_
-- The function `const` is defined using copatterns to prevent eager
-- unfolding of the function in goal types.
const : ∀ {v} → Set v → Value v
Value.family (const V) = F.const V
Value.respects (const V) = F.const F.id
| {
"alphanum_fraction": 0.5797438882,
"avg_line_length": 29.6206896552,
"ext": "agda",
"hexsha": "79d3f5617ccefe8a4917415182213290c261070d",
"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/Data/AVL/Value.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/AVL/Value.agda",
"max_line_length": 72,
"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/Data/AVL/Value.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": 207,
"size": 859
} |
module Thesis.Subst where
--------------------------------------------------------------------------------
-- Prove substitution lemma. Unfortunately, this is done using a quite different
-- machinery from what we use elsewhere. The machinery for defining substitution
-- is taken from a formalization of hereditary substitution (Hereditary
-- Substitutions for Simple Types, Formalized, by Keller and Altenkirch), and
-- uses a different machinery for weakening.
-- I developed the lemmas relating substitution and this form of weakening from
-- scratch.
--------------------------------------------------------------------------------
open import Thesis.Lang hiding (_-_)
_-_ : ∀ {σ} Γ → Var Γ σ → Context
∅ - ()
(σ • Γ) - this = Γ
(τ • Γ) - that x = τ • (Γ - x)
import Relation.Binary.PropositionalEquality as P
open P hiding (subst)
open import Postulate.Extensionality
extend-env : ∀ {σ Γ} (x : Var Γ σ) (rho : ⟦ Γ - x ⟧Context) (v : ⟦ σ ⟧Type) → ⟦ Γ ⟧Context
extend-env this rho v = v • rho
extend-env (that x) (v1 • rho) v = v1 • extend-env x rho v
extend-env-sound : ∀ {σ Γ} (x : Var Γ σ) (rho : ⟦ Γ - x ⟧Context) (v : ⟦ σ ⟧Type) → v ≡ ⟦ x ⟧Var (extend-env x rho v)
extend-env-sound this rho v = refl
extend-env-sound (that x) (v1 • rho) v = extend-env-sound x rho v
wkv : ∀ {Γ σ τ} → (x : Var Γ σ) → Var (Γ - x) τ → Var Γ τ
wkv this y = that y
wkv (that x) this = this
wkv (that x) (that y) = that (wkv x y)
data EqV : ∀ {Γ σ τ} → Var Γ σ → Var Γ τ → Set where
same : ∀ {Γ σ} → {x : Var Γ σ} → EqV x x
diff : ∀ {Γ σ τ} → (x : Var Γ σ) → (z : Var (Γ - x) τ) → EqV x (wkv x z)
-- If x and y do not represent the same variable, then
-- ∃ z. y ≡ wkv x z, allowing us to construct a proof that diff x z : EqV x y
eq : ∀ {Γ σ τ} → (x : Var Γ σ) → (y : Var Γ τ) → EqV x y
eq this this = same
eq this (that y) = diff this y
eq (that x) this = diff (that x) this
eq (that x) (that y) with eq x y
eq (that y) (that .y) | same = same
eq (that x) (that .(wkv x z)) | diff .x z = diff (that x) (that z)
wkTerm : ∀ {Γ σ τ} → (x : Var Γ σ) → Term (Γ - x) τ → Term Γ τ
wkTerm x (var v) = var (wkv x v)
wkTerm x (app t₁ t₂) = (app (wkTerm x t₁) (wkTerm x t₂))
wkTerm x (abs t) = abs (wkTerm (that x) t)
wkTerm x (const c) = const c
wkv-sound : ∀ {Γ σ τ} → (x : Var Γ σ) → (y : Var (Γ - x) τ) →
(ρ : ⟦ Γ - x ⟧Context) (v : ⟦ σ ⟧Type) →
⟦ wkv x y ⟧Var (extend-env x ρ v) ≡ ⟦ y ⟧Var ρ
wkv-sound this y ρ v = refl
wkv-sound (that x) this (v0 • ρ) v = refl
wkv-sound (that x) (that y) (v0 • ρ) v = wkv-sound x y ρ v
wkTerm-sound : ∀ {Γ σ τ} → (x : Var Γ σ) → (t : Term (Γ - x) τ) →
(ρ : ⟦ Γ - x ⟧Context) (v : ⟦ σ ⟧Type) →
⟦ wkTerm x t ⟧Term (extend-env x ρ v) ≡ ⟦ t ⟧Term ρ
wkTerm-sound x (const c) ρ v = refl
wkTerm-sound x (var y) ρ v = wkv-sound x y ρ v
wkTerm-sound x (app t₁ t₂) ρ v
rewrite wkTerm-sound x t₁ ρ v
| wkTerm-sound x t₂ ρ v = refl
wkTerm-sound x (abs t) ρ v = ext (λ v₁ → wkTerm-sound (that x) t (v₁ • ρ) v)
substVar : ∀ {Γ σ τ} → Var Γ τ → (x : Var Γ σ) → Term (Γ - x) σ → Term (Γ - x) τ
substVar v x u with eq x v
substVar v .v u | same = u
substVar .(wkv x z) x u | diff .x z = var z
-- The above is the crucial rule. The dotted pattern makes producing the result
-- easy.
subst : ∀ {Γ σ τ} → Term Γ τ → (x : Var Γ σ) → Term (Γ - x) σ → Term (Γ - x) τ
subst (var v) x u = substVar v x u
subst (app t₁ t₂) x u = app (subst t₁ x u) (subst t₂ x u)
subst (abs t) x u = abs (subst t (that x) (wkTerm this u))
subst (const c) x u = const c
substVar-lemma : ∀ {σ τ Γ} (v : Var Γ τ) (x : Var Γ σ) s rho → ⟦ substVar v x s ⟧Term rho ≡ ⟦ v ⟧Var (extend-env x rho (⟦ s ⟧Term rho))
substVar-lemma v x s rho with eq x v
substVar-lemma .(wkv x z) x s rho | diff .x z = sym (wkv-sound x z rho (⟦ s ⟧Term rho))
substVar-lemma x .x s rho | same = extend-env-sound x rho (⟦ s ⟧Term rho)
subst-lemma : ∀ {σ τ Γ} (t : Term Γ τ) (x : Var Γ σ) s rho → ⟦ subst t x s ⟧Term rho ≡ ⟦ t ⟧Term (extend-env x rho (⟦ s ⟧Term rho))
subst-lemma (const c) x s rho = refl
subst-lemma (var y) x s rho = substVar-lemma y x s rho
subst-lemma (app t₁ t₂) x s rho rewrite subst-lemma t₁ x s rho | subst-lemma t₂ x s rho = refl
subst-lemma (abs t) x s rho = ext body
where
body : ∀ v → ⟦ subst t (that x) (wkTerm this s) ⟧Term (v • rho) ≡
⟦ t ⟧Term (v • extend-env x rho (⟦ s ⟧Term rho))
body v rewrite subst-lemma t (that x) (wkTerm this s) (v • rho) |
wkTerm-sound this s rho v = refl
| {
"alphanum_fraction": 0.5738520697,
"avg_line_length": 42.5096153846,
"ext": "agda",
"hexsha": "a3e04486b642b1fb2a7e63541ef317e34a1b7367",
"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": "Thesis/Subst.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": "Thesis/Subst.agda",
"max_line_length": 135,
"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": "Thesis/Subst.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": 1714,
"size": 4421
} |
------------------------------------------------------------------------------
-- Abelian group base
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module GroupTheory.AbelianGroup.Base where
-- We use the group theory base
open import GroupTheory.Base public
------------------------------------------------------------------------------
-- Abelian group theory axioms
-- We only need to add the commutativity axiom.
postulate comm : ∀ a b → a · b ≡ b · a
{-# ATP axiom comm #-}
| {
"alphanum_fraction": 0.4055232558,
"avg_line_length": 32.7619047619,
"ext": "agda",
"hexsha": "0ecdefc1c504bd23fda29c6733c76562fa9b8d5c",
"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/GroupTheory/AbelianGroup/Base.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/GroupTheory/AbelianGroup/Base.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/GroupTheory/AbelianGroup/Base.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": 111,
"size": 688
} |
-- Agda Sample File
-- https://github.com/agda/agda/blob/master/examples/syntax/highlighting/Test.agda
-- This test file currently lacks module-related stuff.
{- Nested
{- comment. -} -}
module Test where
infix 12 _!
infixl 7 _+_ _-_
infixr 2 -_
postulate x : Set
f : (Set -> Set -> Set) -> Set
f _*_ = x * x
data ℕ : Set where
zero : ℕ
suc : ℕ -> ℕ
_+_ : ℕ -> ℕ -> ℕ
zero + n = n
suc m + n = suc (m + n)
postulate _-_ : ℕ -> ℕ -> ℕ
-_ : ℕ -> ℕ
- n = n
_! : ℕ -> ℕ
zero ! = suc zero
suc n ! = n - n !
record Equiv {a : Set} (_≈_ : a -> a -> Set) : Set where
field
refl : forall x -> x ≈ x
sym : {x y : a} -> x ≈ y -> y ≈ x
_`trans`_ : forall {x y z} -> x ≈ y -> y ≈ z -> x ≈ z
data _≡_ {a : Set} (x : a) : a -> Set where
refl : x ≡ x
subst : forall {a x y} ->
(P : a -> Set) -> x ≡ y -> P x -> P y
subst {x = x} .{y = x} _ refl p = p
Equiv-≡ : forall {a} -> Equiv {a} _≡_
Equiv-≡ {a} =
record { refl = \_ -> refl
; sym = sym
; _`trans`_ = _`trans`_
}
where
sym : {x y : a} -> x ≡ y -> y ≡ x
sym refl = refl
_`trans`_ : {x y z : a} -> x ≡ y -> y ≡ z -> x ≡ z
refl `trans` refl = refl
postulate
String : Set
Char : Set
Float : Set
data Int : Set where
pos : ℕ → Int
negsuc : ℕ → Int
{-# BUILTIN STRING String #-}
{-# BUILTIN CHAR Char #-}
{-# BUILTIN FLOAT Float #-}
{-# BUILTIN NATURAL ℕ #-}
{-# BUILTIN INTEGER Int #-}
{-# BUILTIN INTEGERPOS pos #-}
{-# BUILTIN INTEGERNEGSUC negsuc #-}
data [_] (a : Set) : Set where
[] : [ a ]
_∷_ : a -> [ a ] -> [ a ]
{-# BUILTIN LIST [_] #-}
{-# BUILTIN NIL [] #-}
{-# BUILTIN CONS _∷_ #-}
primitive
primStringToList : String -> [ Char ]
string : [ Char ]
string = primStringToList "∃ apa"
char : Char
char = '∀'
anotherString : String
anotherString = "¬ be\
\pa"
nat : ℕ
nat = 45
float : Float
float = 45.0e-37
-- Testing qualified names.
open import Test
Eq = Test.Equiv {Test.ℕ}
| {
"alphanum_fraction": 0.5034791252,
"avg_line_length": 17.8053097345,
"ext": "agda",
"hexsha": "0b33568ca3f83047721432ed58c38564fd5172ad",
"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": "5ed3cf60fe0829b9c84698248e73e7e3306def5f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dawidsowa/syntax-highlighting",
"max_forks_repo_path": "autotests/input/test.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5ed3cf60fe0829b9c84698248e73e7e3306def5f",
"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": "dawidsowa/syntax-highlighting",
"max_issues_repo_path": "autotests/input/test.agda",
"max_line_length": 82,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5ed3cf60fe0829b9c84698248e73e7e3306def5f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dawidsowa/syntax-highlighting",
"max_stars_repo_path": "autotests/input/test.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 748,
"size": 2012
} |
{-
This second-order term syntax was created from the following second-order syntax description:
syntax CommRing | CR
type
* : 0-ary
term
zero : * | 𝟘
add : * * -> * | _⊕_ l20
one : * | 𝟙
mult : * * -> * | _⊗_ l30
neg : * -> * | ⊖_ r50
theory
(𝟘U⊕ᴸ) a |> add (zero, a) = a
(𝟘U⊕ᴿ) a |> add (a, zero) = a
(⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))
(⊕C) a b |> add(a, b) = add(b, a)
(𝟙U⊗ᴸ) a |> mult (one, a) = a
(𝟙U⊗ᴿ) a |> mult (a, one) = a
(⊗A) a b c |> mult (mult(a, b), c) = mult (a, mult(b, c))
(⊗D⊕ᴸ) a b c |> mult (a, add (b, c)) = add (mult(a, b), mult(a, c))
(⊗D⊕ᴿ) a b c |> mult (add (a, b), c) = add (mult(a, c), mult(b, c))
(𝟘X⊗ᴸ) a |> mult (zero, a) = zero
(𝟘X⊗ᴿ) a |> mult (a, zero) = zero
(⊖N⊕ᴸ) a |> add (neg (a), a) = zero
(⊖N⊕ᴿ) a |> add (a, neg (a)) = zero
(⊗C) a b |> mult(a, b) = mult(b, a)
-}
module CommRing.Syntax where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Construction.Structure
open import SOAS.ContextMaps.Inductive
open import SOAS.Metatheory.Syntax
open import CommRing.Signature
private
variable
Γ Δ Π : Ctx
α : *T
𝔛 : Familyₛ
-- Inductive term declaration
module CR:Terms (𝔛 : Familyₛ) where
data CR : Familyₛ where
var : ℐ ⇾̣ CR
mvar : 𝔛 α Π → Sub CR Π Γ → CR α Γ
𝟘 : CR * Γ
_⊕_ : CR * Γ → CR * Γ → CR * Γ
𝟙 : CR * Γ
_⊗_ : CR * Γ → CR * Γ → CR * Γ
⊖_ : CR * Γ → CR * Γ
infixl 20 _⊕_
infixl 30 _⊗_
infixr 50 ⊖_
open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛
CRᵃ : MetaAlg CR
CRᵃ = record
{ 𝑎𝑙𝑔 = λ where
(zeroₒ ⋮ _) → 𝟘
(addₒ ⋮ a , b) → _⊕_ a b
(oneₒ ⋮ _) → 𝟙
(multₒ ⋮ a , b) → _⊗_ a b
(negₒ ⋮ a) → ⊖_ a
; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) }
module CRᵃ = MetaAlg CRᵃ
module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where
open MetaAlg 𝒜ᵃ
𝕤𝕖𝕞 : CR ⇾̣ 𝒜
𝕊 : Sub CR Π Γ → Π ~[ 𝒜 ]↝ Γ
𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t
𝕊 (t ◂ σ) (old v) = 𝕊 σ v
𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε)
𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v
𝕤𝕖𝕞 𝟘 = 𝑎𝑙𝑔 (zeroₒ ⋮ tt)
𝕤𝕖𝕞 (_⊕_ a b) = 𝑎𝑙𝑔 (addₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b)
𝕤𝕖𝕞 𝟙 = 𝑎𝑙𝑔 (oneₒ ⋮ tt)
𝕤𝕖𝕞 (_⊗_ a b) = 𝑎𝑙𝑔 (multₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b)
𝕤𝕖𝕞 (⊖_ a) = 𝑎𝑙𝑔 (negₒ ⋮ 𝕤𝕖𝕞 a)
𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ CRᵃ 𝒜ᵃ 𝕤𝕖𝕞
𝕤𝕖𝕞ᵃ⇒ = record
{ ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t }
; ⟨𝑣𝑎𝑟⟩ = refl
; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } }
where
open ≡-Reasoning
⟨𝑎𝑙𝑔⟩ : (t : ⅀ CR α Γ) → 𝕤𝕖𝕞 (CRᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t)
⟨𝑎𝑙𝑔⟩ (zeroₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (addₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (oneₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (multₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (negₒ ⋮ _) = refl
𝕊-tab : (mε : Π ~[ CR ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v)
𝕊-tab mε new = refl
𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v
module _ (g : CR ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ CRᵃ 𝒜ᵃ g) where
open MetaAlg⇒ gᵃ⇒
𝕤𝕖𝕞! : (t : CR α Γ) → 𝕤𝕖𝕞 t ≡ g t
𝕊-ix : (mε : Sub CR Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v)
𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x
𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v
𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε))
= trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε))
𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩
𝕤𝕖𝕞! 𝟘 = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (_⊕_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! 𝟙 = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (_⊗_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (⊖_ a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩
-- Syntax instance for the signature
CR:Syn : Syntax
CR:Syn = record
{ ⅀F = ⅀F
; ⅀:CS = ⅀:CompatStr
; mvarᵢ = CR:Terms.mvar
; 𝕋:Init = λ 𝔛 → let open CR:Terms 𝔛 in record
{ ⊥ = CR ⋉ CRᵃ
; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ }
; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } }
-- Instantiation of the syntax and metatheory
open Syntax CR:Syn public
open CR:Terms public
open import SOAS.Families.Build public
open import SOAS.Syntax.Shorthands CRᵃ public
open import SOAS.Metatheory CR:Syn public
| {
"alphanum_fraction": 0.5020626062,
"avg_line_length": 26.5870967742,
"ext": "agda",
"hexsha": "659af290ca653a205aba9307ac867e1586dbff20",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/CommRing/Syntax.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/CommRing/Syntax.agda",
"max_line_length": 93,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/CommRing/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 2686,
"size": 4121
} |
module Data.Either.Multi where
open import Data
open import Data.Either
import Data.Tuple.Raiseᵣ.Functions as Raise
open import Data.Tuple.RaiseTypeᵣ
open import Data.Tuple.RaiseTypeᵣ.Functions
open import Data.Tuple using (_⨯_ ; _,_)
open import Function.Multi
open import Function.Multi.Functions
import Lvl
import Lvl.MultiFunctions as Lvl
open import Numeral.Finite
open import Numeral.Natural
open import Type
Alt : (n : ℕ) → ∀{ℓ𝓈} → TypesOfTypes{n}(ℓ𝓈) ⇉ Type{Lvl.⨆(ℓ𝓈)}
Alt(n) = binaryTypeRelator₊(n)(_‖_)(Empty)
pattern alt₀ x = _‖_.Left x
pattern alt₁ x = _‖_.Right(alt₀ x)
pattern alt₂ x = _‖_.Right(alt₁ x)
pattern alt₃ x = _‖_.Right(alt₂ x)
pattern alt₄ x = _‖_.Right(alt₃ x)
pattern alt₅ x = _‖_.Right(alt₄ x)
pattern alt₆ x = _‖_.Right(alt₅ x)
pattern alt₇ x = _‖_.Right(alt₆ x)
pattern alt₈ x = _‖_.Right(alt₇ x)
pattern alt₉ x = _‖_.Right(alt₈ x)
pattern alt₁,₂ x = _‖_.Right(x)
pattern alt₂,₃ x = _‖_.Right(alt₁,₂ x)
pattern alt₃,₄ x = _‖_.Right(alt₂,₃ x)
pattern alt₄,₅ x = _‖_.Right(alt₃,₄ x)
pattern alt₅,₆ x = _‖_.Right(alt₄,₅ x)
pattern alt₆,₇ x = _‖_.Right(alt₅,₆ x)
pattern alt₇,₈ x = _‖_.Right(alt₆,₇ x)
pattern alt₈,₉ x = _‖_.Right(alt₇,₈ x)
{-
-- TODO: Move or generalize uncurry
uncurryTypes : (n : ℕ) → ∀{ℓ𝓈}{ℓ}{B : Type{ℓ}} → (TypesOfTypes{𝐒(n)}(ℓ𝓈) ⇉ B) → (Types(ℓ𝓈) → B)
uncurryTypes(𝟎) f = f
uncurryTypes(𝐒(n)) f (x , xs) = uncurryTypes(n) (f(x)) xs
-- TODO: Problem with the type. Not normalizing correctly
alt : ∀{n}{ℓ𝓈}{As : Types(ℓ𝓈)} → (i : 𝕟(𝐒(n))) → (index i As) → uncurryTypes(n) (Alt(𝐒(n)){ℓ𝓈}) As
alt {0} 𝟎 x = x
alt {1} 𝟎 x = Left x
alt {1} (𝐒 𝟎) x = Right x
alt {𝐒(𝐒(n))} 𝟎 x = {!Left x!}
alt {𝐒(𝐒(n))} (𝐒 i) x = {!Right(alt {𝐒(n)} i x)!}
-}
| {
"alphanum_fraction": 0.6367231638,
"avg_line_length": 33.3962264151,
"ext": "agda",
"hexsha": "cea965bd7ca5094a6768483ef02323bcd69c73f8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Either/Multi.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Either/Multi.agda",
"max_line_length": 98,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Either/Multi.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": 822,
"size": 1770
} |
{-# OPTIONS --allow-unsolved-metas #-}
module FindTermNode where
open import TermNode
open import OscarPrelude
record FindTermNode (A : Set) : Set
where
field
findTermNode : A → TermNode → Maybe TermNode
open FindTermNode ⦃ … ⦄ public
open import TermCode
open import Term
open import Element
instance
FindTermNodeTermCode : FindTermNode TermCode
FindTermNode.findTermNode FindTermNodeTermCode termCode record { children = [] ; number = number₁ } = nothing
FindTermNode.findTermNode FindTermNodeTermCode termCode 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } = ifYes fst₁ ≟ termCode then just snd₁ else findTermNode termCode record 𝔫 { children = children₁ }
FindTermNodeTermCodes : FindTermNode (List TermCode)
FindTermNode.findTermNode FindTermNodeTermCodes [] node = just node
FindTermNode.findTermNode FindTermNodeTermCodes (x ∷ termCodes) node = join $ findTermNode termCodes <$> findTermNode x node
FindTermNodeTerm : FindTermNode Term
FindTermNode.findTermNode FindTermNodeTerm term node = findTermNode (encodeTerm term) node
-- This is starting to get difficult. We need Agda to know that the Term is encoded in the TermNode. Then we can drop the Maybe
getInterpretationOfTerm : Term → TermNode → Maybe Element
getInterpretationOfTerm τ node = ⟨_⟩ ∘ number <$> findTermNode (encodeTerm τ) node
open import Membership
FindTermNodeTermCode-ok : ∀ {𝔠 𝔫} → 𝔠 child∈ 𝔫 → IsJust (findTermNode 𝔠 𝔫)
FindTermNodeTermCode-ok {𝔠} {record { children = [] ; number = number₁ }} ()
--FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ = case (fst₁ ≟_) 𝔠 , graphAt {B = λ 𝑐 → Dec (fst₁ ≡ 𝑐)} (fst₁ ≟_) 𝔠 of λ { (yes x , snd₂) → {!!} ; (no x , snd₂) → {!!}} --λ { ((yes ===) , (inspect s1)) → {!!} ; ((no =n=) , inspect s2) → {!!} }
--FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ = case fst₁ ≟ 𝔠 of λ { (yes refl) → {!!} ; (no x) → {!!}}
FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ with fst₁ ≟ 𝔠
FindTermNodeTermCode-ok {𝔠} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} x₁ | yes eq2 = tt
FindTermNodeTermCode-ok {.fst₁} {record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} (zero) | no neq = ⊥-elim (neq refl)
FindTermNodeTermCode-ok {𝔠} {𝔫@record { children = (fst₁ , snd₁) ∷ children₁ ; number = number₁ }} (suc x₁) | no neq = FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} x₁
Justified : ∀ {a} {A : Set a} → (m : Maybe A) → IsJust m → ∃ λ x → m ≡ just x
Justified nothing ()
Justified (just x) x₁ = _ , refl
open import FunctionName
open import Vector
storeTerm-ok : ∀ τ 𝔫 𝔑 → IsJust (findTermNode τ (snd (runIdentity (runStateT (runStateT (storeTerm τ) 𝔑) 𝔫))))
storeTerm-ok (variable 𝑥) 𝔫 𝔑 with variable 𝑥 child∈? 𝔫
storeTerm-ok (variable 𝑥) 𝔫 𝔑 | no x with TermCode.variable 𝑥 ≟ variable 𝑥
storeTerm-ok (variable 𝑥) 𝔫 𝔑 | no x | yes _ = tt
storeTerm-ok (variable 𝑥) 𝔫 𝔑 | no x | no variable𝑥≢variable𝑥 = ⊥-elim (variable𝑥≢variable𝑥 refl)
--storeTerm-ok (variable 𝑥) 𝔫 𝔑 | yes vx∈𝔫 rewrite setGet-ok 𝔫 vx∈𝔫 = {!𝔫!}
storeTerm-ok (variable 𝑥) record { children = [] ; number = number₁ } 𝔑 | yes ()
--storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 rewrite setGet-ok 𝔫 vx∈𝔫 = {!!}
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 rewrite setGet-ok 𝔫 vx∈𝔫 with fst₁ ≟ variable 𝑥
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | yes eq = tt
--… | no neq = case vx∈𝔫 of λ { (here .(map fst children₁)) → ⊥-elim (neq refl) ; (there .fst₁ asdf) → case graphAt FindTermNodeTermCode-ok asdf of λ { (ingraph sss) → {!!} } } -- storeTerm-ok x {!record 𝔫 { children = children₁ }!} 𝔑 -- x record 𝔫 { children = children₁ } 𝔑
--… | no neq = case vx∈𝔫 of λ { (here .(map fst children₁)) → ⊥-elim (neq refl) ; (there .fst₁ asdf) → case inspect $ FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} asdf of λ { (.(FindTermNodeTermCode-ok asdf) , ingraph refl) → {!!}} } -- storeTerm-ok x {!record 𝔫 { children = children₁ }!} 𝔑 -- x record 𝔫 { children = children₁ } 𝔑
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq with vx∈𝔫
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq | zero = ⊥-elim (neq refl)
--storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq | there dfdsf fdsdfs with FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} fdsdfs | graphAt (FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }}) fdsdfs
--… | frfrrf | ingraph tttttt = transport _ (snd $ Justified (FindTermNode.findTermNode FindTermNodeTermCode (variable 𝑥) (record { children = children₁ ; number = number₁ })) (FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} fdsdfs)) _
storeTerm-ok x@(variable 𝑥) 𝔫@record { children = ((fst₁ , snd₁) ∷ children₁) ; number = number₁ } 𝔑 | yes vx∈𝔫 | no neq | suc fdsdfs rewrite (snd $ Justified (FindTermNode.findTermNode FindTermNodeTermCode (variable 𝑥) (record { children = children₁ ; number = number₁ })) (FindTermNodeTermCode-ok {𝔫 = record 𝔫 { children = children₁ }} fdsdfs)) = tt
storeTerm-ok (function 𝑥 𝑎) 𝔫 𝔑 with (function 𝑥 (arity 𝑎)) child∈? 𝔫
storeTerm-ok (function 𝑥 ⟨ ⟨ [] ⟩ ⟩) 𝔫 𝔑 | no x with Eq._==_ EqFunctionName ⟨ name 𝑥 ⟩ ⟨ name 𝑥 ⟩
storeTerm-ok (function 𝑥 ⟨ ⟨ [] ⟩ ⟩) 𝔫 𝔑 | no x | (yes refl) = tt
… | no neq = ⊥-elim (neq refl)
--storeTerm-ok τ₀@(function 𝑓 ⟨ τ₁ ∷ τ₂s ⟩) 𝔫 𝔑 | no 𝔠₁∉𝔫 = {!τ₁!}
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₁∉𝔫 with variable 𝑥 child∈? 𝔫
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) with 𝑓₀ ≟ 𝑓₀
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | yes refl with TermCode.variable 𝑥 ≟ variable 𝑥
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | yes refl | yes eq = tt
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | yes refl | no neq = ⊥-elim (neq refl)
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥 ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (yes 𝔠₁∈𝔫) | no neq = ⊥-elim (neq refl)
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) with 𝑓₀ ≟ 𝑓₀
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | yes refl with TermCode.variable 𝑥₁ ≟ variable 𝑥₁
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | yes refl | yes 𝔠₁≡𝔠₁ = tt
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | yes refl | no 𝔠₁≢𝔠₁ = ⊥-elim (𝔠₁≢𝔠₁ refl)
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ [] ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | (no 𝔠₁∉𝔫) | no 𝑓₀≢𝑓₀ = ⊥-elim (𝑓₀≢𝑓₀ refl) -- rewrite setGet-ok 𝔫 𝔠₁∈𝔫
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ τ₂ ∷ τ₃s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 with variable 𝑥₁ child∈? 𝔫
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ τ₂ ∷ τ₃s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | yes 𝔠₁∈𝔫 = {!!}
storeTerm-ok (function 𝑓₀ ⟨ ⟨ variable 𝑥₁ ∷ τ₂ ∷ τ₃s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₀∉𝔫 | no 𝔠₁∉𝔫 = {!!}
storeTerm-ok τ₀@(function 𝑓₀ ⟨ ⟨ function 𝑓₁ τ₁s ∷ τ₂s ⟩ ⟩) 𝔫 𝔑 | no 𝔠₁∉𝔫 = {!!}
storeTerm-ok (function 𝑥 x₁) 𝔫 𝔑 | yes x = {!!}
mutual
storeTermVerifiably' : (τ : Term) → StateT Nat (StateT (Σ TermNode λ n → IsJust (findTermNode τ n)) Identity) ⊤
storeTermVerifiably' (variable x) = {!!}
storeTermVerifiably' (function x x₁) = {!!}
storeTermVerifiably : Term → StateT Nat (StateT TermNode Identity) ⊤
storeTermVerifiably τ@(variable _) = storeTermCodes' (encodeTerm τ)
storeTermVerifiably τ@(function _ τs) = storeTermCodes' (encodeTerm τ) ~| storeTermsVerifiably τs
storeTermsVerifiably : Terms → StateT Nat (StateT TermNode Identity) ⊤
storeTermsVerifiably ⟨ ⟨ [] ⟩ ⟩ = return tt
storeTermsVerifiably ⟨ ⟨ τ ∷ τs ⟩ ⟩ = storeTermVerifiably τ ~| storeTermsVerifiably ⟨ ⟨ τs ⟩ ⟩ ~| return tt
| {
"alphanum_fraction": 0.6484177596,
"avg_line_length": 79.9134615385,
"ext": "agda",
"hexsha": "89fbca561a6d978bae16696427a09a9c7b35a57f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/FindTermNode.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/FindTermNode.agda",
"max_line_length": 352,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/FindTermNode.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3493,
"size": 8311
} |
module Relator.Congruence.Proofs where
import Lvl
open import Functional
open import Logic.Propositional
open import Logic.Predicate
-- TODO: open import Structure.Function.Domain
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Relator.Congruence
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Function.Names
open import Syntax.Transitivity
open import Type
module _ {ℓ₁ ℓ₂} {X : Type{ℓ₁}}{Y : Type{ℓ₂}} {f : X → Y} where
instance
[≅]-reflexivity : Reflexivity (_≅_of f)
Reflexivity.proof([≅]-reflexivity) = [≅]-intro [≡]-intro
instance
[≅]-symmetry : Symmetry (_≅_of f)
Symmetry.proof([≅]-symmetry) = ([≅]-intro ∘ symmetry(_≡_) ∘ [≅]-elim)
instance
[≅]-transitivity : Transitivity (_≅_of f)
Transitivity.proof([≅]-transitivity) (eq1) (eq2) = [≅]-intro(([≅]-elim eq1) 🝖 ([≅]-elim eq2))
instance
[≅]-equivalence : Equivalence (_≅_of f)
[≅]-equivalence = record {
reflexivity = [≅]-reflexivity ;
symmetry = [≅]-symmetry ;
transitivity = [≅]-transitivity
}
[≅]-to-[≡] : Injective(f) ↔ (∀{x₁ x₂ : X} → (x₁ ≅ x₂ of f) → (x₁ ≡ x₂))
[≅]-to-[≡] = [↔]-intro (_∘ [≅]-intro) (_∘ [≅]-elim)
module _ {ℓ₁ ℓ₂ ℓ₃} {X₁ : Type{ℓ₁}}{X₂ : Type{ℓ₂}}{Y : Type{ℓ₃}} where
[≅]-composition : ∀{x₁ x₂ : X₁}{g : X₁ → X₂} → (x₁ ≅ x₂ of g) → ∀{f : X₂ → Y} → (g(x₁) ≅ g(x₂) of f)
[≅]-composition ([≅]-intro (fx₁≡fx₂)) {f} = [≅]-intro ([≡]-with(f) (fx₁≡fx₂))
-- x₁ ≅ x₂
-- ⇔ g(x₁) = g(x₂)
-- ⇒ f(g(x₁)) = f(g(x₂))
| {
"alphanum_fraction": 0.5983502538,
"avg_line_length": 33.5319148936,
"ext": "agda",
"hexsha": "b9deab45c5ae43dbd1384914822e214821a5b12c",
"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": "Relator/Congruence/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": "Relator/Congruence/Proofs.agda",
"max_line_length": 102,
"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": "Relator/Congruence/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": 630,
"size": 1576
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- Exponential Object
-- TODO: Where is the notation from? It is neither from Wikipedia nor the nLab.
module Categories.Object.Exponential {o ℓ e} (𝒞 : Category o ℓ e) where
open Category 𝒞
open import Level
open import Function using (_$_)
open import Categories.Morphism.Reasoning 𝒞
open import Categories.Object.Product 𝒞
hiding (repack; repack≡id; repack∘; repack-cancel; up-to-iso; transport-by-iso)
open import Categories.Morphism 𝒞
open HomReasoning
private
variable
A B C D X Y : Obj
record Exponential (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where
field
B^A : Obj
product : Product B^A A
module product = Product product
B^A×A : Obj
B^A×A = product.A×B
field
eval : B^A×A ⇒ B
λg : ∀ (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ B^A)
β : ∀ (X×A : Product X A) {g : Product.A×B X×A ⇒ B} →
(eval ∘ [ X×A ⇒ product ] λg X×A g ×id ≈ g)
λ-unique : ∀ (X×A : Product X A) {g : Product.A×B X×A ⇒ B} {h : X ⇒ B^A} →
(eval ∘ [ X×A ⇒ product ] h ×id ≈ g) → (h ≈ λg X×A g)
η : ∀ (X×A : Product X A) {f : X ⇒ B^A } → λg X×A (eval ∘ [ X×A ⇒ product ] f ×id) ≈ f
η X×A {f} = sym (λ-unique X×A refl)
λ-cong : ∀ {X : Obj} (X×A : Product X A) {f g} →
f ≈ g → λg X×A f ≈ λg X×A g
λ-cong X×A {f = f} {g = g} f≡g = λ-unique X×A (trans (β X×A) f≡g)
subst : ∀ (p₂ : Product C A) (p₃ : Product D A) {f g} →
λg p₃ f ∘ g ≈ λg p₂ (f ∘ [ p₂ ⇒ p₃ ] g ×id)
subst p₂ p₃ {f} {g} = λ-unique p₂ (begin
eval ∘ [ p₂ ⇒ product ] λg p₃ f ∘ g ×id
≈˘⟨ refl⟩∘⟨ [ p₂ ⇒ p₃ ⇒ product ]×id∘×id ⟩
eval ∘ [ p₃ ⇒ product ] λg p₃ f ×id ∘ [ p₂ ⇒ p₃ ] g ×id
≈⟨ pullˡ (β p₃) ⟩
f ∘ [ p₂ ⇒ p₃ ] g ×id ∎)
η-id : λg product eval ≈ id
η-id = begin
λg product eval ≈˘⟨ identityʳ ⟩
λg product eval ∘ id ≈⟨ subst _ _ ⟩
λg product (eval ∘ [ product ⇒ product ] id ×id) ≈⟨ η product ⟩
id ∎
λ-unique′ : ∀ (X×A : Product X A) {h i : X ⇒ B^A} →
eval ∘ [ X×A ⇒ product ] h ×id ≈ eval ∘ [ X×A ⇒ product ] i ×id → h ≈ i
λ-unique′ p eq = trans (λ-unique p eq) (sym (λ-unique p refl))
-- some aliases to make proof signatures less ugly
[_]eval : ∀{A B}(e₁ : Exponential A B) → Exponential.B^A×A e₁ ⇒ B
[ e₁ ]eval = Exponential.eval e₁
[_]λ : ∀{A B}(e₁ : Exponential A B)
→ {X : Obj} → (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ Exponential.B^A e₁)
[ e₁ ]λ = Exponential.λg e₁
{-
D×C --id × f--> D×A --g--> B
D --λ (g ∘ id × f)--> B^C
\ ^
\ /
λ g λ (e ∘ id × f)
\ /
v /
B^A
-}
λ-distrib : ∀ (e₁ : Exponential C B) (e₂ : Exponential A B)
(p₃ : Product D C) (p₄ : Product D A) (p₅ : Product (Exponential.B^A e₂) C)
{f} {g : Product.A×B p₄ ⇒ B} →
[ e₁ ]λ p₃ (g ∘ [ p₃ ⇒ p₄ ]id× f)
≈ [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]id× f) ∘ [ e₂ ]λ p₄ g
λ-distrib e₁ e₂ p₃ p₄ p₅ {f} {g} = sym $ e₁.λ-unique p₃ $ begin
[ e₁ ]eval ∘ ([ p₃ ⇒ p₁ ] [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f) ∘ [ e₂ ]λ p₄ g ×id)
≈˘⟨ refl⟩∘⟨ [ p₃ ⇒ p₅ ⇒ p₁ ]×id∘×id ⟩
[ e₁ ]eval ∘ [ p₅ ⇒ p₁ ] [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f) ×id
∘ [ p₃ ⇒ p₅ ] [ e₂ ]λ p₄ g ×id
≈⟨ pullˡ (e₁.β p₅) ⟩
([ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f)
∘ [ p₃ ⇒ p₅ ] [ e₂ ]λ p₄ g ×id
≈⟨ assoc ⟩
[ e₂ ]eval ∘ [ p₅ ⇒ p₂ ]id× f
∘ [ p₃ ⇒ p₅ ] [ e₂ ]λ p₄ g ×id
≈˘⟨ refl⟩∘⟨ [ p₄ ⇒ p₂ , p₃ ⇒ p₅ ]first↔second ⟩
[ e₂ ]eval ∘ [ p₄ ⇒ p₂ ] [ e₂ ]λ p₄ g ×id ∘ [ p₃ ⇒ p₄ ]id× f
≈⟨ pullˡ (e₂.β p₄) ⟩
g ∘ [ p₃ ⇒ p₄ ]id× f ∎
where module e₁ = Exponential e₁
module e₂ = Exponential e₂
p₁ = e₁.product
p₂ = e₂.product
repack : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ⇒ Exponential.B^A e₂
repack e₁ e₂ = e₂.λg e₁.product e₁.eval
where
module e₁ = Exponential e₁
module e₂ = Exponential e₂
repack≡id : ∀{A B} (e : Exponential A B) → repack e e ≈ id
repack≡id = Exponential.η-id
repack∘ : ∀ (e₁ e₂ e₃ : Exponential A B) → repack e₂ e₃ ∘ repack e₁ e₂ ≈ repack e₁ e₃
repack∘ e₁ e₂ e₃ =
let p₁ = product e₁ in
let p₂ = product e₂ in
begin
[ e₃ ]λ p₂ [ e₂ ]eval
∘ [ e₂ ]λ p₁ [ e₁ ]eval
≈⟨ λ-cong e₃ p₂ (introʳ (second-id p₂)) ⟩∘⟨refl ⟩
[ e₃ ]λ p₂ ([ e₂ ]eval ∘ [ p₂ ⇒ p₂ ]id× id)
∘ [ e₂ ]λ p₁ [ e₁ ]eval
≈˘⟨ λ-distrib e₃ e₂ p₁ p₁ p₂ ⟩
[ e₃ ]λ p₁ ([ e₁ ]eval ∘ [ p₁ ⇒ p₁ ]id× id)
≈⟨ λ-cong e₃ p₁ (⟺ (introʳ (second-id (product e₁)))) ⟩
[ e₃ ]λ p₁ [ e₁ ]eval
∎
where open Exponential
repack-cancel : ∀{A B} (e₁ e₂ : Exponential A B) → repack e₁ e₂ ∘ repack e₂ e₁ ≈ id
repack-cancel e₁ e₂ = repack∘ e₂ e₁ e₂ ○ repack≡id e₂
up-to-iso : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ≅ Exponential.B^A e₂
up-to-iso e₁ e₂ = record
{ from = repack e₁ e₂
; to = repack e₂ e₁
; iso = record
{ isoˡ = repack-cancel e₂ e₁
; isoʳ = repack-cancel e₁ e₂
}
}
transport-by-iso : ∀ (e : Exponential A B) → Exponential.B^A e ≅ X → Exponential A B
transport-by-iso {X = X} e e≅X = record
{ B^A = X
; product = X×A
; eval = e.eval
; λg = λ Y×A Y×A⇒B → from ∘ (e.λg Y×A Y×A⇒B)
; β = λ Y×A {h} → begin
e.eval ∘ [ Y×A ⇒ X×A ] from ∘ e.λg Y×A h ×id ≈⟨ refl⟩∘⟨ e.product.⟨⟩-cong₂ (pullˡ (cancelˡ isoˡ))
(elimˡ refl) ⟩
e.eval ∘ [ Y×A ⇒ e.product ] e.λg Y×A h ×id ≈⟨ e.β Y×A ⟩
h ∎
; λ-unique = λ Y×A {h} {i} eq →
switch-tofromˡ e≅X $ e.λ-unique Y×A $ begin
e.eval ∘ [ Y×A ⇒ e.product ] to ∘ i ×id ≈⟨ refl⟩∘⟨ e.product.⟨⟩-cong₂ assoc (introˡ refl) ⟩
e.eval ∘ [ Y×A ⇒ X×A ] i ×id ≈⟨ eq ⟩
h ∎
}
where module e = Exponential e
X×A = Mobile e.product e≅X ≅.refl
open _≅_ e≅X
| {
"alphanum_fraction": 0.4675304155,
"avg_line_length": 36.5838150289,
"ext": "agda",
"hexsha": "da9c270b118836628d8378fac35adf31d54e9551",
"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/Object/Exponential.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/Object/Exponential.agda",
"max_line_length": 101,
"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/Object/Exponential.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2751,
"size": 6329
} |
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary.Core
module Morphism.Structures where
open import Algebra
import Algebra.Morphism.Definitions as MorphismDefinitions
open import Level using (Level; _⊔_)
import Function.Definitions as FunctionDefinitions
open import Relation.Binary.Morphism.Structures
open import Algebra.Morphism.Structures
private
variable
a b ℓ₁ ℓ₂ : Level
| {
"alphanum_fraction": 0.8029925187,
"avg_line_length": 23.5882352941,
"ext": "agda",
"hexsha": "fe8b381bdd51f3538575b857e7e8e06dfd7a295d",
"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": "72030f78934877ad67bf4e36e74e43845cabbf55",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Akshobhya1234/Agda-Algebra",
"max_forks_repo_path": "src/Morphism/Structures.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "72030f78934877ad67bf4e36e74e43845cabbf55",
"max_issues_repo_issues_event_max_datetime": "2022-01-31T18:19:52.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-02T20:50:34.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Akshobhya1234/Agda-Algebra",
"max_issues_repo_path": "src/Morphism/Structures.agda",
"max_line_length": 58,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "72030f78934877ad67bf4e36e74e43845cabbf55",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Akshobhya1234/Agda-Algebra",
"max_stars_repo_path": "src/Morphism/Structures.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 92,
"size": 401
} |
-- Andreas, 2015-05-02, issue reported by Gabe Dijkstra
open import Common.Prelude
open import Common.Equality
data T : Set where
c0 : ⊥ → T
c1 : ⊥ → T
-- The following should not pass, as c0 and c1 are not fully applied.
c0≠c1 : c0 ≡ c1 → ⊥
c0≠c1 ()
-- The latter conflicts with function extensionality.
postulate
fun-ext : {A B : Set} → (f g : A → B) → ((x : A) → f x ≡ g x) → f ≡ g
c0=c1 : c0 ≡ c1
c0=c1 = fun-ext c0 c1 (λ ())
wrong : ⊥
wrong = c0≠c1 c0=c1
| {
"alphanum_fraction": 0.6135881104,
"avg_line_length": 21.4090909091,
"ext": "agda",
"hexsha": "ee12ca12a1f10a2a7f46d6e30d6291b6c6e02dfa",
"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/Issue1497.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/Issue1497.agda",
"max_line_length": 71,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue1497.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": 193,
"size": 471
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Morphism.Cartesian where
open import Level
open import Categories.Category
open import Categories.Functor
private
variable
o ℓ e : Level
C D : Category o ℓ e
record Cartesian (F : Functor C D) {X Y} (f : C [ X , Y ]) : Set (levelOfTerm F) where
private
module C = Category C
module D = Category D
open Functor F
open D
field
universal : ∀ {A} {u : F₀ A ⇒ F₀ X} (h : C [ A , Y ]) →
F₁ f ∘ u ≈ F₁ h → C [ A , X ]
commute : ∀ {A} {u : F₀ A ⇒ F₀ X} {h : C [ A , Y ]}
(eq : F₁ f ∘ u ≈ F₁ h) →
C [ C [ f ∘ universal h eq ] ≈ h ]
compat : ∀ {A} {u : F₀ A ⇒ F₀ X} {h : C [ A , Y ]}
(eq : F₁ f ∘ u ≈ F₁ h) →
F₁ (universal h eq) ≈ u
| {
"alphanum_fraction": 0.4780487805,
"avg_line_length": 26.4516129032,
"ext": "agda",
"hexsha": "9f3cce53ea79e57de1a5072598e95058ab10e5ce",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Morphism/Cartesian.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Morphism/Cartesian.agda",
"max_line_length": 86,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Morphism/Cartesian.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 285,
"size": 820
} |
module Issue1232.Nat where
| {
"alphanum_fraction": 0.8214285714,
"avg_line_length": 9.3333333333,
"ext": "agda",
"hexsha": "c79531495a5ea75f7f533200330ef01425952b36",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue1232/Nat.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue1232/Nat.agda",
"max_line_length": 26,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue1232/Nat.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": 9,
"size": 28
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- An inductive definition for the permutation relation
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Binary.Permutation.Propositional
{a} {A : Set a} where
open import Data.List.Base using (List; []; _∷_)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
import Relation.Binary.Reasoning.Setoid as EqReasoning
------------------------------------------------------------------------
-- An inductive definition of permutation
-- Note that one would expect that this would be defined in terms of
-- `Permutation.Setoid`. This is not currently the case as it involves
-- adding in a bunch of trivial `_≡_` proofs to the constructors which
-- a) adds noise and b) prevents easy access to the variables `x`, `y`.
-- This may be changed in future when a better solution is found.
infix 3 _↭_
data _↭_ : Rel (List A) a where
refl : ∀ {xs} → xs ↭ xs
prep : ∀ {xs ys} x → xs ↭ ys → x ∷ xs ↭ x ∷ ys
swap : ∀ {xs ys} x y → xs ↭ ys → x ∷ y ∷ xs ↭ y ∷ x ∷ ys
trans : ∀ {xs ys zs} → xs ↭ ys → ys ↭ zs → xs ↭ zs
------------------------------------------------------------------------
-- _↭_ is an equivalence
↭-reflexive : _≡_ ⇒ _↭_
↭-reflexive refl = refl
↭-refl : Reflexive _↭_
↭-refl = refl
↭-sym : ∀ {xs ys} → xs ↭ ys → ys ↭ xs
↭-sym refl = refl
↭-sym (prep x xs↭ys) = prep x (↭-sym xs↭ys)
↭-sym (swap x y xs↭ys) = swap y x (↭-sym xs↭ys)
↭-sym (trans xs↭ys ys↭zs) = trans (↭-sym ys↭zs) (↭-sym xs↭ys)
-- A smart version of trans that avoids unnecessary `refl`s (see #1113).
↭-trans : Transitive _↭_
↭-trans refl ρ₂ = ρ₂
↭-trans ρ₁ refl = ρ₁
↭-trans ρ₁ ρ₂ = trans ρ₁ ρ₂
↭-isEquivalence : IsEquivalence _↭_
↭-isEquivalence = record
{ refl = refl
; sym = ↭-sym
; trans = ↭-trans
}
↭-setoid : Setoid _ _
↭-setoid = record
{ isEquivalence = ↭-isEquivalence
}
------------------------------------------------------------------------
-- A reasoning API to chain permutation proofs and allow "zooming in"
-- to localised reasoning.
module PermutationReasoning where
private
module Base = EqReasoning ↭-setoid
open EqReasoning ↭-setoid public
hiding (step-≈; step-≈˘)
infixr 2 step-↭ step-↭˘ step-swap step-prep
step-↭ = Base.step-≈
step-↭˘ = Base.step-≈˘
-- Skip reasoning on the first element
step-prep : ∀ x xs {ys zs : List A} → (x ∷ ys) IsRelatedTo zs →
xs ↭ ys → (x ∷ xs) IsRelatedTo zs
step-prep x xs rel xs↭ys = relTo (trans (prep x xs↭ys) (begin rel))
-- Skip reasoning about the first two elements
step-swap : ∀ x y xs {ys zs : List A} → (y ∷ x ∷ ys) IsRelatedTo zs →
xs ↭ ys → (x ∷ y ∷ xs) IsRelatedTo zs
step-swap x y xs rel xs↭ys = relTo (trans (swap x y xs↭ys) (begin rel))
syntax step-↭ x y↭z x↭y = x ↭⟨ x↭y ⟩ y↭z
syntax step-↭˘ x y↭z y↭x = x ↭˘⟨ y↭x ⟩ y↭z
syntax step-prep x xs y↭z x↭y = x ∷ xs <⟨ x↭y ⟩ y↭z
syntax step-swap x y xs y↭z x↭y = x ∷ y ∷ xs <<⟨ x↭y ⟩ y↭z
| {
"alphanum_fraction": 0.5474683544,
"avg_line_length": 32.2448979592,
"ext": "agda",
"hexsha": "b0ae5f6ec63bf37ced67409bf83d1e4faed3681b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Propositional.agda",
"max_line_length": 73,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Propositional.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 1101,
"size": 3160
} |
-- Andreas, 2017-11-19, issue #2854
-- Agda should not complain about "possibly empty type of sizes"
-- if the SIZELT builtin is not bound.
data Tree : Set₁ where
node : {A : Set} (f : A → Tree) → Tree
const : Tree → Tree
const t = node λ x → t
-- WAS:
-- Failed to solve the following constraints:
-- Is not empty type of sizes: _A_6 t
-- Expected:
-- Unsolved meta.
| {
"alphanum_fraction": 0.6578249337,
"avg_line_length": 20.9444444444,
"ext": "agda",
"hexsha": "5e02e4238913cd4ef871177b0e9af814e77b0ada",
"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/Issue2854.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/Issue2854.agda",
"max_line_length": 64,
"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/Issue2854.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": 116,
"size": 377
} |
module DSession where
open import Data.Bool
open import Data.Fin
open import Data.Empty
open import Data.List
open import Data.List.All
open import Data.Maybe hiding (All)
open import Data.Nat
open import Data.Product
open import Data.Sum
open import Data.Unit
open import Function using (_$_)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Typing
open import Syntax
open import Global
open import Channel
open import Values
-- this is really just a Kleisli arrow
data Cont (G : SCtx) (φ : TCtx) (t : Type) : Type → Set where
ident :
(ina-G : Inactive G)
→ (unr-φ : All Unr φ)
→ Cont G φ t t
bind : ∀ {φ₁ φ₂ G₁ G₂ t₂ t₃}
→ (ts : Split φ φ₁ φ₂)
→ (ss : SSplit G G₁ G₂)
→ (e₂ : Expr (t ∷ φ₁) t₂)
→ (ϱ₂ : VEnv G₁ φ₁)
→ (κ₂ : Cont G₂ φ₂ t₂ t₃)
→ Cont G φ t t₃
subsume : ∀ {t₁ t₂}
→ (t≤t1 : SubT t t₁)
→ (κ : Cont G φ t₁ t₂)
→ Cont G φ t t₂
compose : ∀ {G G₁ G₂ φ φ₁ φ₂ t₁ t₂ t₃}
→ Split φ φ₁ φ₂
→ SSplit G G₁ G₂
→ Cont G₁ φ₁ t₁ t₂
→ Cont G₂ φ₂ t₂ t₃
→ Cont G φ t₁ t₃
compose ss ssp (ident ina-G unr-φ) (ident ina-G₁ unr-φ₁) =
ident (ssplit-inactive ssp ina-G ina-G₁) (split-unr ss unr-φ unr-φ₁)
compose ss ssp (ident ina-G unr-φ) (bind ts ss₁ e₂ ϱ₂ κ₂) = bind {!!} {!!} e₂ ϱ₂ κ₂
compose ss ssp (ident ina-G unr-φ) (subsume t≤t1 κ₂)
with inactive-left-ssplit ssp ina-G
... | refl
= subsume t≤t1 {!!}
compose ss ssp (bind ts ss₁ e₂ ϱ₂ κ₁) (ident ina-G unr-φ) = {!!}
compose ss ssp (bind ts ss₁ e₂ ϱ₂ κ₁) (bind ts₁ ss₂ e₃ ϱ₃ κ₂) = {!!}
compose ss ssp (bind ts ss₁ e₂ ϱ₂ κ₁) (subsume t≤t1 κ₂) = {!!}
compose ss ssp (subsume t≤t1 κ₁) (ident ina-G unr-φ) = {!!}
compose ss ssp (subsume t≤t1 κ₁) (bind ts ss₁ e₂ ϱ₂ κ₂) = {!!}
compose ss ssp (subsume t≤t1 κ₁) (subsume t≤t2 κ₂) = {!!}
-- command is a monad
data Command (G : SCtx) (t : Type) : Set where
Return : (v : Val G t)
→ Command G t
Fork : ∀ {φ₁ φ₂ G₁ G₂}
→ (ss : SSplit G G₁ G₂)
→ (κ₁ : Cont G₁ φ₁ TUnit TUnit)
→ (κ₂ : Cont G₂ φ₂ TUnit t)
→ Command G t
New : ∀ {φ}
→ (s : SType)
→ (κ : Cont G φ (TPair (TChan (SType.force s)) (TChan (SType.force (dual s)))) t)
→ Command G t
Close : ∀ {φ G₁ G₂}
→ (ss : SSplit G G₁ G₂)
→ (v : Val G₁ (TChan send!))
→ (κ : Cont G₂ φ TUnit t)
→ Command G t
Wait : ∀ {φ G₁ G₂}
→ (ss : SSplit G G₁ G₂)
→ (v : Val G₁ (TChan send?))
→ (κ : Cont G₂ φ TUnit t)
→ Command G t
Send : ∀ {φ G₁ G₂ G₁₁ G₁₂ tv s}
→ (ss : SSplit G G₁ G₂)
→ (ss-args : SSplit G₁ G₁₁ G₁₂)
→ (vch : Val G₁₁ (TChan (send tv s)))
→ (v : Val G₁₂ tv)
→ (κ : Cont G₂ φ (TChan (SType.force s)) t)
→ Command G t
Recv : ∀ {φ G₁ G₂ tv s}
→ (ss : SSplit G G₁ G₂)
→ (vch : Val G₁ (TChan (recv tv s)))
→ (κ : Cont G₂ φ (TPair (TChan (SType.force s)) tv) t)
→ Command G t
Select : ∀ {φ G₁ G₂ s₁ s₂}
→ (ss : SSplit G G₁ G₂)
→ (lab : Selector)
→ (vch : Val G₁ (TChan (sintern s₁ s₂)))
→ (κ : Cont G₂ φ (TChan (selection lab (SType.force s₁) (SType.force s₂))) t)
→ Command G t
Branch : ∀ {φ G₁ G₂ s₁ s₂}
→ (ss : SSplit G G₁ G₂)
→ (vch : Val G₁ (TChan (sextern s₁ s₂)))
→ (dcont : (lab : Selector) → Cont G₂ φ (TChan (selection lab (SType.force s₁) (SType.force s₂))) t)
→ Command G t
NSelect : ∀ {φ G₁ G₂ m alt}
→ (ss : SSplit G G₁ G₂)
→ (lab : Fin m)
→ (vch : Val G₁ (TChan (sintN m alt)))
→ (κ : Cont G₂ φ (TChan (SType.force (alt lab))) t)
→ Command G t
NBranch : ∀ {φ G₁ G₂ m alt}
→ (ss : SSplit G G₁ G₂)
→ (vch : Val G₁ (TChan (sextN m alt)))
→ (dcont : (lab : Fin m) → Cont G₂ φ (TChan (SType.force (alt lab))) t)
→ Command G t
-- cont G = ∀ G' → G ≤ G' → SSplit G' Gval Gcont → Val Gval t →
data _≼_ G : SCtx → Set where
≼-rfl : G ≼ G
≼-ext : ∀ {G'} → G ≼ G' → G ≼ (nothing ∷ G')
{-
mbindf : ∀ {Gin G1in G2in G1out G2out t t'} → SSplit Gin G1in G2in
→ Command G1in G1out t
→ (∀ G2in' G1out' G2out' → G2in ≼ G2in' → G1out ≼ G1out' → G2out ≼ G2out'
→ Val G1out' t → Command G2in' G2out' t')
→ Command Gin G2out t'
mbindf = {!!}
-}
mbind : ∀ {G G₁ G₂ Φ t t'} → SSplit G G₁ G₂ → Command G₁ t → Cont G₂ Φ t t' → Command G t'
mbind ssp (Return v) (ident x x₁)
with inactive-right-ssplit ssp x
... | refl
= Return v
mbind ssp (Return v) (bind ts ss e₂ ϱ₂ cont) = {!!}
mbind ssp (Return v) (subsume t≤t1 cont) = {!!}
mbind ssp (Fork ss κ₁ κ₂) cont = Fork {!!} κ₁ {!!}
mbind ssp (New s κ) cont = {!!}
mbind ssp (Close ss v κ) cont = {!!}
mbind ssp (Wait ss v κ) cont = {!!}
mbind ssp (Send ss ss-args vch v κ) cont = {!!}
mbind ssp (Recv ss vch κ) cont = {!!}
mbind ssp (Select ss lab vch κ) cont = {!!}
mbind ssp (Branch ss vch dcont) cont = {!!}
mbind ssp (NSelect ss lab vch κ) cont = {!!}
mbind ssp (NBranch ss vch dcont) cont = {!!}
| {
"alphanum_fraction": 0.5731757877,
"avg_line_length": 29.4146341463,
"ext": "agda",
"hexsha": "981b16905a946875f44698c2c7d96f88787ff54c",
"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": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "peterthiemann/definitional-session",
"max_forks_repo_path": "src/DSession.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"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": "peterthiemann/definitional-session",
"max_issues_repo_path": "src/DSession.agda",
"max_line_length": 104,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "peterthiemann/definitional-session",
"max_stars_repo_path": "src/DSession.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z",
"num_tokens": 2023,
"size": 4824
} |
module Hwequivalence where
open import Relation.Binary.PropositionalEquality
open import Data.Bool
-- A 1-bit adder
bit-adder-spec : Bool → Bool → Bool → Bool
bit-adder-spec A B C = X ∧ Y
where
X : Bool
X = (A ∧ not B ∧ not C)
∨
(not A ∧ B ∧ not C)
∨
(not A ∧ not B ∧ C)
∨
(A ∧ B ∧ C)
Y : Bool
Y = (A ∧ B)
∨
(A ∧ C)
∨
(B ∧ C)
bit-adder-imp : Bool → Bool → Bool → Bool
bit-adder-imp A B C = X ∧ Y
where
u : Bool
u = (A ∧ not B)
∨
(not A ∧ B)
v : Bool
v = u ∧ C
w : Bool
w = A ∧ B
X : Bool
X = (u ∧ not C)
∨
(not u ∧ C)
Y : Bool
Y = (w ∨ v)
data _≃_ {A : Set} (f : A → A) (g : A → A) : Set where
f≃g : ((x y : A) → (x ≡ y) → (f x ≡ g y)) → f ≃ g
-- Prove equivalence of specification and implementation using
-- ≃ data type.
equivalence-spec-imp : ∀ (A B : Bool) → (bit-adder-spec A B) ≃ (bit-adder-imp A B)
equivalence-spec-imp A B = f≃g (λ x y x₁ → prove x y x₁)
where
pr1 : (x y : Bool) → (bit-adder-spec x y true) ≡ (bit-adder-imp x y true)
pr1 true true = refl
pr1 true false = refl
pr1 false true = refl
pr1 false false = refl
pr2 : (x y : Bool) → (bit-adder-spec x y false) ≡ (bit-adder-imp x y false)
pr2 true true = refl
pr2 true false = refl
pr2 false true = refl
pr2 false false = refl
prove : (x y : Bool) → (p : x ≡ y) → (bit-adder-spec A B x) ≡ (bit-adder-imp A B y)
prove true .true refl = pr1 A B
prove false .false refl = pr2 A B
| {
"alphanum_fraction": 0.5306666667,
"avg_line_length": 22.0588235294,
"ext": "agda",
"hexsha": "9cba825deca146ad4552002798019acf058cfab8",
"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": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "amal029/agda-tutorial-dybjer",
"max_forks_repo_path": "HWequivalence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166",
"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": "amal029/agda-tutorial-dybjer",
"max_issues_repo_path": "HWequivalence.agda",
"max_line_length": 85,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "amal029/agda-tutorial-dybjer",
"max_stars_repo_path": "HWequivalence.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z",
"num_tokens": 596,
"size": 1500
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Properties where
open import Definition.Untyped
open import Definition.Typed
open import Tools.Empty using (⊥; ⊥-elim)
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Escape context extraction
wfTerm : ∀ {Γ A t} → Γ ⊢ t ∷ A → ⊢ Γ
wfTerm (ℕⱼ ⊢Γ) = ⊢Γ
wfTerm (Πⱼ F ▹ G) = wfTerm F
wfTerm (var ⊢Γ x₁) = ⊢Γ
wfTerm (lamⱼ F t) with wfTerm t
wfTerm (lamⱼ F t) | ⊢Γ ∙ F′ = ⊢Γ
wfTerm (g ∘ⱼ a) = wfTerm a
wfTerm (zeroⱼ ⊢Γ) = ⊢Γ
wfTerm (sucⱼ n) = wfTerm n
wfTerm (natrecⱼ F z s n) = wfTerm z
wfTerm (conv t A≡B) = wfTerm t
wf : ∀ {Γ A} → Γ ⊢ A → ⊢ Γ
wf (ℕⱼ ⊢Γ) = ⊢Γ
wf (Uⱼ ⊢Γ) = ⊢Γ
wf (Πⱼ F ▹ G) = wf F
wf (univ A) = wfTerm A
wfEqTerm : ∀ {Γ A t u} → Γ ⊢ t ≡ u ∷ A → ⊢ Γ
wfEqTerm (refl t) = wfTerm t
wfEqTerm (sym t≡u) = wfEqTerm t≡u
wfEqTerm (trans t≡u u≡r) = wfEqTerm t≡u
wfEqTerm (conv t≡u A≡B) = wfEqTerm t≡u
wfEqTerm (Π-cong F F≡H G≡E) = wfEqTerm F≡H
wfEqTerm (app-cong f≡g a≡b) = wfEqTerm f≡g
wfEqTerm (β-red F t a) = wfTerm a
wfEqTerm (η-eq F f g f0≡g0) = wfTerm f
wfEqTerm (suc-cong n) = wfEqTerm n
wfEqTerm (natrec-cong F≡F′ z≡z′ s≡s′ n≡n′) = wfEqTerm z≡z′
wfEqTerm (natrec-zero F z s) = wfTerm z
wfEqTerm (natrec-suc n F z s) = wfTerm n
wfEq : ∀ {Γ A B} → Γ ⊢ A ≡ B → ⊢ Γ
wfEq (univ A≡B) = wfEqTerm A≡B
wfEq (refl A) = wf A
wfEq (sym A≡B) = wfEq A≡B
wfEq (trans A≡B B≡C) = wfEq A≡B
wfEq (Π-cong F F≡H G≡E) = wfEq F≡H
-- Reduction is a subset of conversion
subsetTerm : ∀ {Γ A t u} → Γ ⊢ t ⇒ u ∷ A → Γ ⊢ t ≡ u ∷ A
subsetTerm (natrec-subst F z s n⇒n′) =
natrec-cong (refl F) (refl z) (refl s) (subsetTerm n⇒n′)
subsetTerm (natrec-zero F z s) = natrec-zero F z s
subsetTerm (natrec-suc n F z s) = natrec-suc n F z s
subsetTerm (app-subst t⇒u a) = app-cong (subsetTerm t⇒u) (refl a)
subsetTerm (β-red A t a) = β-red A t a
subsetTerm (conv t⇒u A≡B) = conv (subsetTerm t⇒u) A≡B
subset : ∀ {Γ A B} → Γ ⊢ A ⇒ B → Γ ⊢ A ≡ B
subset (univ A⇒B) = univ (subsetTerm A⇒B)
subset*Term : ∀ {Γ A t u} → Γ ⊢ t ⇒* u ∷ A → Γ ⊢ t ≡ u ∷ A
subset*Term (id t) = refl t
subset*Term (t⇒t′ ⇨ t⇒*u) = trans (subsetTerm t⇒t′) (subset*Term t⇒*u)
subset* : ∀ {Γ A B} → Γ ⊢ A ⇒* B → Γ ⊢ A ≡ B
subset* (id A) = refl A
subset* (A⇒A′ ⇨ A′⇒*B) = trans (subset A⇒A′) (subset* A′⇒*B)
-- Can extract left-part of a reduction
redFirstTerm : ∀ {Γ t u A} → Γ ⊢ t ⇒ u ∷ A → Γ ⊢ t ∷ A
redFirstTerm (conv t⇒u A≡B) = conv (redFirstTerm t⇒u) A≡B
redFirstTerm (app-subst t⇒u a) = (redFirstTerm t⇒u) ∘ⱼ a
redFirstTerm (β-red A t a) = (lamⱼ A t) ∘ⱼ a
redFirstTerm (natrec-subst F z s n⇒n′) = natrecⱼ F z s (redFirstTerm n⇒n′)
redFirstTerm (natrec-zero F z s) = natrecⱼ F z s (zeroⱼ (wfTerm z))
redFirstTerm (natrec-suc n F z s) = natrecⱼ F z s (sucⱼ n)
redFirst : ∀ {Γ A B} → Γ ⊢ A ⇒ B → Γ ⊢ A
redFirst (univ A⇒B) = univ (redFirstTerm A⇒B)
redFirst*Term : ∀ {Γ t u A} → Γ ⊢ t ⇒* u ∷ A → Γ ⊢ t ∷ A
redFirst*Term (id t) = t
redFirst*Term (t⇒t′ ⇨ t′⇒*u) = redFirstTerm t⇒t′
redFirst* : ∀ {Γ A B} → Γ ⊢ A ⇒* B → Γ ⊢ A
redFirst* (id A) = A
redFirst* (A⇒A′ ⇨ A′⇒*B) = redFirst A⇒A′
-- No neutral terms are well-formed in an empty context
noNe : ∀ {t A} → ε ⊢ t ∷ A → Neutral t → ⊥
noNe (var x₁ ()) (var x)
noNe (conv ⊢t x) (var n) = noNe ⊢t (var n)
noNe (⊢t ∘ⱼ ⊢t₁) (∘ₙ neT) = noNe ⊢t neT
noNe (conv ⊢t x) (∘ₙ neT) = noNe ⊢t (∘ₙ neT)
noNe (natrecⱼ x ⊢t ⊢t₁ ⊢t₂) (natrecₙ neT) = noNe ⊢t₂ neT
noNe (conv ⊢t x) (natrecₙ neT) = noNe ⊢t (natrecₙ neT)
-- Neutrals do not weak head reduce
neRedTerm : ∀ {Γ t u A} (d : Γ ⊢ t ⇒ u ∷ A) (n : Neutral t) → ⊥
neRedTerm (conv d x) n = neRedTerm d n
neRedTerm (app-subst d x) (∘ₙ n) = neRedTerm d n
neRedTerm (β-red x x₁ x₂) (∘ₙ ())
neRedTerm (natrec-subst x x₁ x₂ d) (natrecₙ n₁) = neRedTerm d n₁
neRedTerm (natrec-zero x x₁ x₂) (natrecₙ ())
neRedTerm (natrec-suc x x₁ x₂ x₃) (natrecₙ ())
neRed : ∀ {Γ A B} (d : Γ ⊢ A ⇒ B) (N : Neutral A) → ⊥
neRed (univ x) N = neRedTerm x N
-- Whnfs do not weak head reduce
whnfRedTerm : ∀ {Γ t u A} (d : Γ ⊢ t ⇒ u ∷ A) (w : Whnf t) → ⊥
whnfRedTerm (conv d x) w = whnfRedTerm d w
whnfRedTerm (app-subst d x) (ne (∘ₙ x₁)) = neRedTerm d x₁
whnfRedTerm (β-red x x₁ x₂) (ne (∘ₙ ()))
whnfRedTerm (natrec-subst x x₁ x₂ d) (ne (natrecₙ x₃)) = neRedTerm d x₃
whnfRedTerm (natrec-zero x x₁ x₂) (ne (natrecₙ ()))
whnfRedTerm (natrec-suc x x₁ x₂ x₃) (ne (natrecₙ ()))
whnfRed : ∀ {Γ A B} (d : Γ ⊢ A ⇒ B) (w : Whnf A) → ⊥
whnfRed (univ x) w = whnfRedTerm x w
whnfRed*Term : ∀ {Γ t u A} (d : Γ ⊢ t ⇒* u ∷ A) (w : Whnf t) → t PE.≡ u
whnfRed*Term (id x) Uₙ = PE.refl
whnfRed*Term (id x) Πₙ = PE.refl
whnfRed*Term (id x) ℕₙ = PE.refl
whnfRed*Term (id x) lamₙ = PE.refl
whnfRed*Term (id x) zeroₙ = PE.refl
whnfRed*Term (id x) sucₙ = PE.refl
whnfRed*Term (id x) (ne x₁) = PE.refl
whnfRed*Term (conv x x₁ ⇨ d) w = ⊥-elim (whnfRedTerm x w)
whnfRed*Term (x ⇨ d) (ne x₁) = ⊥-elim (neRedTerm x x₁)
whnfRed* : ∀ {Γ A B} (d : Γ ⊢ A ⇒* B) (w : Whnf A) → A PE.≡ B
whnfRed* (id x) w = PE.refl
whnfRed* (x ⇨ d) w = ⊥-elim (whnfRed x w)
-- Whr is deterministic
whrDetTerm : ∀{Γ t u A u′ A′} (d : Γ ⊢ t ⇒ u ∷ A) (d′ : Γ ⊢ t ⇒ u′ ∷ A′) → u PE.≡ u′
whrDetTerm (conv d x) d′ = whrDetTerm d d′
whrDetTerm d (conv d′ x₁) = whrDetTerm d d′
whrDetTerm (app-subst d x) (app-subst d′ x₁) rewrite whrDetTerm d d′ = PE.refl
whrDetTerm (app-subst d x) (β-red x₁ x₂ x₃) = ⊥-elim (whnfRedTerm d lamₙ)
whrDetTerm (β-red x x₁ x₂) (app-subst d x₃) = ⊥-elim (whnfRedTerm d lamₙ)
whrDetTerm (β-red x x₁ x₂) (β-red x₃ x₄ x₅) = PE.refl
whrDetTerm (natrec-subst x x₁ x₂ d) (natrec-subst x₃ x₄ x₅ d′) rewrite whrDetTerm d d′ = PE.refl
whrDetTerm (natrec-subst x x₁ x₂ d) (natrec-zero x₃ x₄ x₅) = ⊥-elim (whnfRedTerm d zeroₙ)
whrDetTerm (natrec-subst x x₁ x₂ d) (natrec-suc x₃ x₄ x₅ x₆) = ⊥-elim (whnfRedTerm d sucₙ)
whrDetTerm (natrec-zero x x₁ x₂) (natrec-subst x₃ x₄ x₅ d′) = ⊥-elim (whnfRedTerm d′ zeroₙ)
whrDetTerm (natrec-zero x x₁ x₂) (natrec-zero x₃ x₄ x₅) = PE.refl
whrDetTerm (natrec-suc x x₁ x₂ x₃) (natrec-subst x₄ x₅ x₆ d′) = ⊥-elim (whnfRedTerm d′ sucₙ)
whrDetTerm (natrec-suc x x₁ x₂ x₃) (natrec-suc x₄ x₅ x₆ x₇) = PE.refl
whrDet : ∀{Γ A B B′} (d : Γ ⊢ A ⇒ B) (d′ : Γ ⊢ A ⇒ B′) → B PE.≡ B′
whrDet (univ x) (univ x₁) = whrDetTerm x x₁
whrDet↘Term : ∀{Γ t u A u′} (d : Γ ⊢ t ↘ u ∷ A) (d′ : Γ ⊢ t ⇒* u′ ∷ A) → Γ ⊢ u′ ⇒* u ∷ A
whrDet↘Term (proj₁ , proj₂) (id x) = proj₁
whrDet↘Term (id x , proj₂) (x₁ ⇨ d′) = ⊥-elim (whnfRedTerm x₁ proj₂)
whrDet↘Term (x ⇨ proj₁ , proj₂) (x₁ ⇨ d′) =
whrDet↘Term (PE.subst (λ x₂ → _ ⊢ x₂ ↘ _ ∷ _) (whrDetTerm x x₁) (proj₁ , proj₂)) d′
whrDet*Term : ∀{Γ t u A u′} (d : Γ ⊢ t ↘ u ∷ A) (d′ : Γ ⊢ t ↘ u′ ∷ A) → u PE.≡ u′
whrDet*Term (id x , proj₂) (id x₁ , proj₄) = PE.refl
whrDet*Term (id x , proj₂) (x₁ ⇨ proj₃ , proj₄) = ⊥-elim (whnfRedTerm x₁ proj₂)
whrDet*Term (x ⇨ proj₁ , proj₂) (id x₁ , proj₄) = ⊥-elim (whnfRedTerm x proj₄)
whrDet*Term (x ⇨ proj₁ , proj₂) (x₁ ⇨ proj₃ , proj₄) =
whrDet*Term (proj₁ , proj₂) (PE.subst (λ x₂ → _ ⊢ x₂ ↘ _ ∷ _)
(whrDetTerm x₁ x) (proj₃ , proj₄))
whrDet* : ∀{Γ A B B′} (d : Γ ⊢ A ↘ B) (d′ : Γ ⊢ A ↘ B′) → B PE.≡ B′
whrDet* (id x , proj₂) (id x₁ , proj₄) = PE.refl
whrDet* (id x , proj₂) (x₁ ⇨ proj₃ , proj₄) = ⊥-elim (whnfRed x₁ proj₂)
whrDet* (x ⇨ proj₁ , proj₂) (id x₁ , proj₄) = ⊥-elim (whnfRed x proj₄)
whrDet* (A⇒A′ ⇨ A′⇒*B , whnfB) (A⇒A″ ⇨ A″⇒*B′ , whnfB′) =
whrDet* (A′⇒*B , whnfB) (PE.subst (λ x → _ ⊢ x ↘ _)
(whrDet A⇒A″ A⇒A′)
(A″⇒*B′ , whnfB′))
-- Identity of syntactic reduction
idRed:*: : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A :⇒*: A
idRed:*: A = [ A , A , id A ]
idRedTerm:*: : ∀ {Γ A t} → Γ ⊢ t ∷ A → Γ ⊢ t :⇒*: t ∷ A
idRedTerm:*: t = [ t , t , id t ]
-- U cannot be a term
UnotInA : ∀ {A Γ} → Γ ⊢ U ∷ A → ⊥
UnotInA (conv U∷U x) = UnotInA U∷U
UnotInA[t] : ∀ {A B t a Γ}
→ t [ a ] PE.≡ U
→ Γ ⊢ a ∷ A
→ Γ ∙ A ⊢ t ∷ B
→ ⊥
UnotInA[t] () x₁ (ℕⱼ x₂)
UnotInA[t] () x₁ (Πⱼ x₂ ▹ x₃)
UnotInA[t] x₁ x₂ (var x₃ here) rewrite x₁ = UnotInA x₂
UnotInA[t] () x₂ (var x₃ (there x₄))
UnotInA[t] () x₁ (lamⱼ x₂ x₃)
UnotInA[t] () x₁ (x₂ ∘ⱼ x₃)
UnotInA[t] () x₁ (zeroⱼ x₂)
UnotInA[t] () x₁ (sucⱼ x₂)
UnotInA[t] () x₁ (natrecⱼ x₂ x₃ x₄ x₅)
UnotInA[t] x x₁ (conv x₂ x₃) = UnotInA[t] x x₁ x₂
redU*Term′ : ∀ {A B U′ Γ} → U′ PE.≡ U → Γ ⊢ A ⇒ U′ ∷ B → ⊥
redU*Term′ U′≡U (conv A⇒U x) = redU*Term′ U′≡U A⇒U
redU*Term′ () (app-subst A⇒U x)
redU*Term′ U′≡U (β-red x x₁ x₂) = UnotInA[t] U′≡U x₂ x₁
redU*Term′ () (natrec-subst x x₁ x₂ A⇒U)
redU*Term′ U′≡U (natrec-zero x x₁ x₂) rewrite U′≡U = UnotInA x₁
redU*Term′ () (natrec-suc x x₁ x₂ x₃)
redU*Term : ∀ {A B Γ} → Γ ⊢ A ⇒* U ∷ B → ⊥
redU*Term (id x) = UnotInA x
redU*Term (x ⇨ A⇒*U) = redU*Term A⇒*U
-- Nothing reduces to U
redU : ∀ {A Γ} → Γ ⊢ A ⇒ U → ⊥
redU (univ x) = redU*Term′ PE.refl x
redU* : ∀ {A Γ} → Γ ⊢ A ⇒* U → A PE.≡ U
redU* (id x) = PE.refl
redU* (x ⇨ A⇒*U) rewrite redU* A⇒*U = ⊥-elim (redU x)
| {
"alphanum_fraction": 0.5740929129,
"avg_line_length": 36.4074074074,
"ext": "agda",
"hexsha": "bcce14478032d2d95022fd562a03ed75a4c74319",
"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/Properties.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/Properties.agda",
"max_line_length": 96,
"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/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4673,
"size": 8847
} |
open import Data.Product using ( _×_ ; _,_ )
open import Relation.Unary using ( _∈_ )
open import Web.Semantic.DL.FOL using ( Formula ; _∈₂_ ; _∈₂_⇒_ )
open import Web.Semantic.DL.FOL.Model using ( _⊨f_ )
open import Web.Semantic.DL.Role using ( Role ; ⟨_⟩ ; ⟨_⟩⁻¹ )
open import Web.Semantic.DL.Role.Model using ( _⟦_⟧₂ ; ⟦⟧₂-resp-≈ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox.Interp using ( Interp ; ≈-sym )
module Web.Semantic.DL.Role.Skolemization {Σ : Signature} where
rskolem : ∀ {Δ} → Role Σ → Δ → Δ → Formula Σ Δ
rskolem ⟨ r ⟩ x y = (x , y) ∈₂ r
rskolem ⟨ r ⟩⁻¹ x y = (y , x) ∈₂ r
rskolem⇒ : ∀ {Δ} → Role Σ → Δ → Δ → Formula Σ Δ → Formula Σ Δ
rskolem⇒ ⟨ r ⟩ x y F = (x , y) ∈₂ r ⇒ F
rskolem⇒ ⟨ r ⟩⁻¹ x y F = (y , x) ∈₂ r ⇒ F
rskolem-sound : ∀ I R x y → (I ⊨f rskolem R x y) → ((x , y) ∈ I ⟦ R ⟧₂)
rskolem-sound I ⟨ r ⟩ x y xy∈⟦r⟧ = xy∈⟦r⟧
rskolem-sound I ⟨ r ⟩⁻¹ x y yx∈⟦r⟧ = yx∈⟦r⟧
rskolem⇒-sound : ∀ I R x y F → (I ⊨f rskolem⇒ R x y F) → ((x , y) ∈ I ⟦ R ⟧₂) → (I ⊨f F)
rskolem⇒-sound I ⟨ r ⟩ x y F xy∈r⇒F xy∈⟦r⟧ = xy∈r⇒F xy∈⟦r⟧
rskolem⇒-sound I ⟨ r ⟩⁻¹ x y F yx∈r⇒F yx∈⟦r⟧ = yx∈r⇒F yx∈⟦r⟧
| {
"alphanum_fraction": 0.5765920826,
"avg_line_length": 43.037037037,
"ext": "agda",
"hexsha": "8d633cdb538eb61924059f1b9034409bd6e9106d",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
"max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/Role/Skolemization.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bblfish/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/Role/Skolemization.agda",
"max_line_length": 88,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/DL/Role/Skolemization.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
"num_tokens": 605,
"size": 1162
} |
-- Inductively constructed substitution maps
module SOAS.ContextMaps.Inductive {T : Set} where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Sorting
open import SOAS.Families.Core {T}
open import SOAS.Variable
private
variable
α : T
Γ Δ : Ctx
𝒳 𝒴 : Familyₛ
-- A list of terms in context Δ for every variable in context Γ
data Sub (𝒳 : Familyₛ) : Ctx → Ctx → Set where
• : Sub 𝒳 ∅ Δ
_◂_ : 𝒳 α Δ → Sub 𝒳 Γ Δ → Sub 𝒳 (α ∙ Γ) Δ
infixl 120 _◂_
infix 150 _⟩
pattern _⟩ t = t ◂ •
-- Functorial mapping
Sub₁ : (f : 𝒳 ⇾̣ 𝒴) → Sub 𝒳 Γ Δ → Sub 𝒴 Γ Δ
Sub₁ f • = •
Sub₁ f (x ◂ σ) = f x ◂ Sub₁ f σ
-- Conversion between inductive substitutions and context maps
module _ {𝒳 : Familyₛ} where
index : Sub 𝒳 Γ Δ → Γ ~[ 𝒳 ]↝ Δ
index • ()
index (t ◂ σ) new = t
index (t ◂ σ) (old v) = index σ v
tabulate : Γ ~[ 𝒳 ]↝ Δ → Sub 𝒳 Γ Δ
tabulate {Γ = ∅} σ = •
tabulate {Γ = α ∙ Γ} σ = σ new ◂ tabulate (σ ∘ old)
ix∘tab≈id : (σ : Γ ~[ 𝒳 ]↝ Δ) (v : ℐ α Γ)
→ index (tabulate σ) v ≡ σ v
ix∘tab≈id {Γ = α ∙ Γ} σ new = refl
ix∘tab≈id {Γ = α ∙ Γ} σ (old v) = ix∘tab≈id (σ ∘ old) v
tab∘ix≈id : (σ : Sub 𝒳 Γ Δ) → tabulate (index σ) ≡ σ
tab∘ix≈id • = refl
tab∘ix≈id (x ◂ σ) rewrite tab∘ix≈id σ = refl
-- Naturality conditions
tabulate-nat : (f : 𝒳 ⇾̣ 𝒴)(σ : Γ ~[ 𝒳 ]↝ Δ)
→ tabulate {𝒴} (f ∘ σ) ≡ Sub₁ f (tabulate {𝒳} σ)
tabulate-nat {Γ = ∅} f σ = refl
tabulate-nat {Γ = α ∙ Γ} f σ = cong (f (σ new) ◂_) (tabulate-nat f (σ ∘ old))
index-nat : (f : 𝒳 ⇾̣ 𝒴)(σ : Sub 𝒳 Γ Δ)(v : ℐ α Γ)
→ index (Sub₁ f σ) v ≡ f (index σ v)
index-nat f (x ◂ σ) new = refl
index-nat f (x ◂ σ) (old v) = index-nat f σ v
| {
"alphanum_fraction": 0.5598086124,
"avg_line_length": 26.5396825397,
"ext": "agda",
"hexsha": "88adb72457d478e99395b804cacf9905c6753f43",
"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": "b224d31e20cfd010b7c924ce940f3c2f417777e3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "k4rtik/agda-soas",
"max_forks_repo_path": "SOAS/ContextMaps/Inductive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3",
"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": "k4rtik/agda-soas",
"max_issues_repo_path": "SOAS/ContextMaps/Inductive.agda",
"max_line_length": 77,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "k4rtik/agda-soas",
"max_stars_repo_path": "SOAS/ContextMaps/Inductive.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 779,
"size": 1672
} |
------------------------------------------------------------------------------
-- The division program is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module proves the correctness of the division program using
-- repeated subtraction (Dybjer 1985).
module FOTC.Program.Division.CorrectnessProofI where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Inequalities.PropertiesI
open import FOTC.Data.Nat.PropertiesI
import FOTC.Data.Nat.Induction.NonAcc.WF-I
open module WFInd = FOTC.Data.Nat.Induction.NonAcc.WF-I.WFInd
open import FOTC.Program.Division.Division
open import FOTC.Program.Division.ResultI
open import FOTC.Program.Division.Specification
open import FOTC.Program.Division.TotalityI
------------------------------------------------------------------------------
-- The division program is correct when the dividend is less than the
-- divisor.
div-x<y-correct : ∀ {i j} → N i → N j → i < j → divSpec i j (div i j)
div-x<y-correct Ni Nj i<j = div-x<y-N i<j , div-x<y-resultCorrect Ni Nj i<j
-- The division program is correct when the dividend is greater or
-- equal than the divisor.
div-x≮y-correct : ∀ {i j} → N i → N j →
(∀ {i'} → N i' → i' < i → divSpec i' j (div i' j)) →
j > zero →
i ≮ j →
divSpec i j (div i j)
div-x≮y-correct {i} {j} Ni Nj ah j>0 i≮j =
div-x≮y-N ih i≮j , div-x≮y-resultCorrect Ni Nj ih i≮j
where
-- The inductive hypothesis on i ∸ j.
ih : divSpec (i ∸ j) j (div (i ∸ j) j)
ih = ah {i ∸ j}
(∸-N Ni Nj)
(x≥y→y>0→x∸y<x Ni Nj (x≮y→x≥y Ni Nj i≮j) j>0)
------------------------------------------------------------------------------
-- The division program is correct.
-- We do the well-founded induction on i and we keep j fixed.
divCorrect : ∀ {i j} → N i → N j → j > zero → divSpec i j (div i j)
divCorrect {j = j} Ni Nj j>0 = <-wfind A ih Ni
where
A : D → Set
A d = divSpec d j (div d j)
-- The inductive step doesn't use the variable i (nor Ni). To make
-- this clear we write down the inductive step using the variables m
-- and n.
ih : ∀ {n} → N n → (∀ {m} → N m → m < n → A m) → A n
ih {n} Nn ah =
case (div-x<y-correct Nn Nj) (div-x≮y-correct Nn Nj ah j>0) (x<y∨x≮y Nn Nj)
------------------------------------------------------------------------------
-- References
--
-- Dybjer, Peter (1985). Program Verification in a Logical Theory of
-- Constructions. In: Functional Programming Languages and Computer
-- Architecture. Ed. by Jouannaud,
-- Jean-Pierre. Vol. 201. LNCS. Appears in revised form as Programming
-- Methodology Group Report 26, University of Gothenburg and Chalmers
-- University of Technology, June 1986. Springer, pp. 334–349.
| {
"alphanum_fraction": 0.557698703,
"avg_line_length": 38.5512820513,
"ext": "agda",
"hexsha": "728fc212c326a10f10c9374fc708063d2c2c8888",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Program/Division/CorrectnessProofI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Program/Division/CorrectnessProofI.agda",
"max_line_length": 79,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Program/Division/CorrectnessProofI.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": 862,
"size": 3007
} |
{-# OPTIONS --universe-polymorphism #-}
module UniversePolymorphicFunctor where
postulate
Level : Set
zero : Level
suc : (i : Level) → Level
_⊔_ : Level → Level → Level
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO zero #-}
{-# BUILTIN LEVELSUC suc #-}
{-# BUILTIN LEVELMAX _⊔_ #-}
infixl 6 _⊔_
record IsEquivalence {a ℓ} {A : Set a}
(_≈_ : A → A → Set ℓ) : Set (a ⊔ ℓ) where
field
refl : ∀ {x} → x ≈ x
sym : ∀ {i j} → i ≈ j → j ≈ i
trans : ∀ {i j k} → i ≈ j → j ≈ k → i ≈ k
record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where
infix 4 _≈_
field
Carrier : Set c
_≈_ : Carrier → Carrier → Set ℓ
isEquivalence : IsEquivalence _≈_
open IsEquivalence isEquivalence public
infixr 0 _⟶_
record _⟶_ {f₁ f₂ t₁ t₂}
(From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
infixl 5 _⟨$⟩_
field
_⟨$⟩_ : Setoid.Carrier From → Setoid.Carrier To
cong : ∀ {x y} →
Setoid._≈_ From x y → Setoid._≈_ To (_⟨$⟩_ x) (_⟨$⟩_ y)
open _⟶_ public
id : ∀ {a₁ a₂} {A : Setoid a₁ a₂} → A ⟶ A
id = record { _⟨$⟩_ = λ x → x; cong = λ x≈y → x≈y }
infixr 9 _∘_
_∘_ : ∀ {a₁ a₂} {A : Setoid a₁ a₂}
{b₁ b₂} {B : Setoid b₁ b₂}
{c₁ c₂} {C : Setoid c₁ c₂} →
B ⟶ C → A ⟶ B → A ⟶ C
f ∘ g = record
{ _⟨$⟩_ = λ x → f ⟨$⟩ (g ⟨$⟩ x)
; cong = λ x≈y → cong f (cong g x≈y)
}
_⇨_ : ∀ {f₁ f₂ t₁ t₂} → Setoid f₁ f₂ → Setoid t₁ t₂ → Setoid _ _
From ⇨ To = record
{ Carrier = From ⟶ To
; _≈_ = λ f g → ∀ {x y} → x ≈₁ y → f ⟨$⟩ x ≈₂ g ⟨$⟩ y
; isEquivalence = record
{ refl = λ {f} → cong f
; sym = λ f∼g x∼y → To.sym (f∼g (From.sym x∼y))
; trans = λ f∼g g∼h x∼y → To.trans (f∼g From.refl) (g∼h x∼y)
}
}
where
open module From = Setoid From using () renaming (_≈_ to _≈₁_)
open module To = Setoid To using () renaming (_≈_ to _≈₂_)
record Functor {f₁ f₂ f₃ f₄}
(F : Setoid f₁ f₂ → Setoid f₃ f₄) :
Set (suc (f₁ ⊔ f₂) ⊔ f₃ ⊔ f₄) where
field
map : ∀ {A B} → (A ⇨ B) ⟶ (F A ⇨ F B)
identity : ∀ {A} →
let open Setoid (F A ⇨ F A) in
map ⟨$⟩ id ≈ id
composition : ∀ {A B C} (f : B ⟶ C) (g : A ⟶ B) →
let open Setoid (F A ⇨ F C) in
map ⟨$⟩ (f ∘ g) ≈ (map ⟨$⟩ f) ∘ (map ⟨$⟩ g)
| {
"alphanum_fraction": 0.4862778731,
"avg_line_length": 26.202247191,
"ext": "agda",
"hexsha": "550d0fa337b54acd33538bb5bfc349659cd91658",
"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/misc/UniversePolymorphicFunctor.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/misc/UniversePolymorphicFunctor.agda",
"max_line_length": 67,
"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/misc/UniversePolymorphicFunctor.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": 1052,
"size": 2332
} |
-- Andreas, 2011-04-15
-- {-# OPTIONS -v tc.meta:20 #-}
module SameMeta where
infix 10 _≡_
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
infixr 5 _×_ _,_
data _×_ (A B : Set) : Set where
_,_ : A -> B -> A × B
postulate A : Set
same : let X : A -> A -> A -> A × A
X = _
in {x y z : A} -> X x y y ≡ (x , y)
× X x x y ≡ X x y y
same = refl , refl
-- second equation triggers pruning of second variable of X
-- which makes the first equation linear and solvable | {
"alphanum_fraction": 0.527027027,
"avg_line_length": 22.5217391304,
"ext": "agda",
"hexsha": "68d900d65b5af676da83d68a033d8bb294653f1c",
"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/SameMeta.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/SameMeta.agda",
"max_line_length": 59,
"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/SameMeta.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": 185,
"size": 518
} |
{-# OPTIONS --cubical --safe #-}
module Function.Isomorphism where
open import Cubical.Foundations.Equiv using (isoToEquiv) public
open import Cubical.Foundations.Isomorphism using (Iso; section; retract; isoToPath; iso) public
open import Level
open import Path
open import Function
open import Data.Sigma
open import Relation.Binary
open Iso public
infix 4 _⇔_
_⇔_ = Iso
sym-⇔ : (A ⇔ B) → (B ⇔ A)
fun (sym-⇔ A⇔B) = inv A⇔B
inv (sym-⇔ A⇔B) = fun A⇔B
leftInv (sym-⇔ A⇔B) = rightInv A⇔B
rightInv (sym-⇔ A⇔B) = leftInv A⇔B
refl-⇔ : A ⇔ A
fun refl-⇔ x = x
inv refl-⇔ x = x
leftInv refl-⇔ x = refl
rightInv refl-⇔ x = refl
trans-⇔ : A ⇔ B → B ⇔ C → A ⇔ C
fun (trans-⇔ A⇔B B⇔C) = fun B⇔C ∘ fun A⇔B
inv (trans-⇔ A⇔B B⇔C) = inv A⇔B ∘ inv B⇔C
leftInv (trans-⇔ A⇔B B⇔C) x = cong (inv A⇔B) (leftInv B⇔C _) ; leftInv A⇔B _
rightInv (trans-⇔ A⇔B B⇔C) x = cong (fun B⇔C) (rightInv A⇔B _) ; rightInv B⇔C _
iso-Σ : {B : A → Type b} {C : A → Type c} → (∀ x → B x ⇔ C x) → Σ A B ⇔ Σ A C
iso-Σ B⇔C .fun (x , xs) = x , B⇔C x .fun xs
iso-Σ B⇔C .inv (x , xs) = x , B⇔C x .inv xs
iso-Σ B⇔C .rightInv (x , xs) i .fst = x
iso-Σ B⇔C .rightInv (x , xs) i .snd = B⇔C x .rightInv xs i
iso-Σ B⇔C .leftInv (x , xs) i .fst = x
iso-Σ B⇔C .leftInv (x , xs) i .snd = B⇔C x .leftInv xs i
⇔-equiv : Equivalence (Type a) a
Equivalence._≋_ ⇔-equiv = _⇔_
Equivalence.sym ⇔-equiv = sym-⇔
Equivalence.refl ⇔-equiv = refl-⇔
Equivalence.trans ⇔-equiv = trans-⇔
open import HLevels
open import Equiv
iso⇔equiv : isSet A → (A ⇔ B) ⇔ (A ≃ B)
iso⇔equiv isSetA .fun = isoToEquiv
iso⇔equiv isSetA .inv = equivToIso
iso⇔equiv isSetA .rightInv x i .fst = x .fst
iso⇔equiv isSetA .rightInv x i .snd = isPropIsEquiv (x .fst) (isoToEquiv (equivToIso x) .snd) (x .snd) i
iso⇔equiv isSetA .leftInv x i .fun = x .fun
iso⇔equiv isSetA .leftInv x i .inv = x .inv
iso⇔equiv isSetA .leftInv x i .rightInv = x .rightInv
iso⇔equiv isSetA .leftInv x i .leftInv y = isSetA _ y (equivToIso (isoToEquiv x) .leftInv y) (x .leftInv y) i
| {
"alphanum_fraction": 0.6343545957,
"avg_line_length": 32.1129032258,
"ext": "agda",
"hexsha": "53e76b5fd9857805b93445e1be0216a026a981ff",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Function/Isomorphism.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Function/Isomorphism.agda",
"max_line_length": 109,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Function/Isomorphism.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 988,
"size": 1991
} |
-- Andreas, 2015-05-06, issue reported by Nisse
postulate
_ : Set
postulate
_ : Set
-- Error message WAS: "Multiple definitions of _."
-- BUT: If the first occurrence of _ is accepted, then the second one
-- should also be accepted.
-- Error NOW: "Invalid name: _"
| {
"alphanum_fraction": 0.695970696,
"avg_line_length": 19.5,
"ext": "agda",
"hexsha": "6b9174585feba6cc6c70562bc8f0ebc7fa402ea0",
"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/Issue1465.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/Issue1465.agda",
"max_line_length": 69,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue1465.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": 77,
"size": 273
} |
{-# OPTIONS --without-K #-}
module hott.equivalence where
open import hott.equivalence.alternative public
open import hott.equivalence.core public
open import hott.equivalence.properties public
open import hott.equivalence.inverse public
-- open import hott.equivalence.coind public
| {
"alphanum_fraction": 0.8204225352,
"avg_line_length": 31.5555555556,
"ext": "agda",
"hexsha": "bf60aaa0a508840e44f1db8b0a545f1b8b287198",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "hott/equivalence.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "HoTT/M-types",
"max_issues_repo_path": "hott/equivalence.agda",
"max_line_length": 47,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "hott/equivalence.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 56,
"size": 284
} |
-- Andreas, 2016-08-04, issue #964
-- Allow open metas and interaction points in imported files
{-# OPTIONS --allow-unsolved-metas #-}
-- {-# OPTIONS -v import:100 #-}
-- {-# OPTIONS -v meta.postulate:20 #-}
-- {-# OPTIONS -v tc.meta:25 #-}
-- Andreas, 2016-10-09, while working on issue #2223:
--
-- This module is an example that we can be in a context
-- that is shorter than the current section.
-- Typically, this would be the empty context.
--
-- {-# OPTIONS -v tc.constr.add:45 #-}
open import Common.Level
module Common.Issue964.UnsolvedMetas (A : Set₁) where
meta : Level
meta = {!!} -- unsolved interaction point
module M (B : Set) where
meta2 : Set meta
meta2 = _ -- unsolved meta
module N (C D : meta2) where
meta3 : meta2
meta3 = Set
-- EOF
| {
"alphanum_fraction": 0.6530089629,
"avg_line_length": 21.6944444444,
"ext": "agda",
"hexsha": "88de3041303e4a757e62be9f7f87c1995e72c673",
"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/Common/Issue964/UnsolvedMetas.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/Common/Issue964/UnsolvedMetas.agda",
"max_line_length": 60,
"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/Common/Issue964/UnsolvedMetas.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": 230,
"size": 781
} |
{-# OPTIONS --without-K --exact-split --safe #-}
open import Fragment.Algebra.Signature
module Fragment.Algebra.Homomorphism.Properties (Σ : Signature) where
open import Fragment.Algebra.Algebra Σ
open import Fragment.Algebra.Homomorphism.Base Σ
open import Fragment.Algebra.Homomorphism.Setoid Σ
open import Level using (Level)
open import Relation.Binary using (Setoid)
private
variable
a b c d ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level
A : Algebra {a} {ℓ₁}
B : Algebra {b} {ℓ₂}
C : Algebra {c} {ℓ₃}
D : Algebra {d} {ℓ₄}
id-unitˡ : ∀ {f : A ⟿ B} → id ⊙ f ≗ f
id-unitˡ {B = B} = Setoid.refl ∥ B ∥/≈
id-unitʳ : ∀ {f : A ⟿ B} → f ⊙ id ≗ f
id-unitʳ {B = B} = Setoid.refl ∥ B ∥/≈
⊙-assoc : ∀ (h : C ⟿ D) (g : B ⟿ C) (f : A ⟿ B)
→ (h ⊙ g) ⊙ f ≗ h ⊙ (g ⊙ f)
⊙-assoc {D = D} _ _ _ = Setoid.refl ∥ D ∥/≈
⊙-congˡ : ∀ (h : B ⟿ C) (f g : A ⟿ B)
→ f ≗ g
→ h ⊙ f ≗ h ⊙ g
⊙-congˡ h _ _ f≗g = ∣ h ∣-cong f≗g
⊙-congʳ : ∀ (h : A ⟿ B) (f g : B ⟿ C)
→ f ≗ g
→ f ⊙ h ≗ g ⊙ h
⊙-congʳ _ _ _ f≗g = f≗g
| {
"alphanum_fraction": 0.5288461538,
"avg_line_length": 25.3658536585,
"ext": "agda",
"hexsha": "770e6f4f63b531d84c04af5bf130ab04efd1a8c6",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z",
"max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "yallop/agda-fragment",
"max_forks_repo_path": "src/Fragment/Algebra/Homomorphism/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "yallop/agda-fragment",
"max_issues_repo_path": "src/Fragment/Algebra/Homomorphism/Properties.agda",
"max_line_length": 69,
"max_stars_count": 18,
"max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yallop/agda-fragment",
"max_stars_repo_path": "src/Fragment/Algebra/Homomorphism/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z",
"num_tokens": 482,
"size": 1040
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Environments (heterogeneous collections)
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Star.Environment {ℓ} (Ty : Set ℓ) where
open import Level
open import Data.Star.List
open import Data.Star.Decoration
open import Data.Star.Pointer as Pointer hiding (lookup)
open import Data.Unit
open import Function hiding (_∋_)
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
-- Contexts, listing the types of all the elements in an environment.
Ctxt : Set ℓ
Ctxt = List Ty
-- Variables (de Bruijn indices); pointers into environments.
infix 4 _∋_
_∋_ : Ctxt → Ty → Set ℓ
Γ ∋ σ = Any (const (Lift ℓ ⊤)) (σ ≡_) Γ
vz : ∀ {Γ σ} → Γ ▻ σ ∋ σ
vz = this refl
vs : ∀ {Γ σ τ} → Γ ∋ τ → Γ ▻ σ ∋ τ
vs = that _
-- Environments. The T function maps types to element types.
Env : ∀ {e} → (Ty → Set e) → (Ctxt → Set (ℓ ⊔ e))
Env T Γ = All T Γ
-- A safe lookup function for environments.
lookup : ∀ {Γ σ} {T : Ty → Set} → Γ ∋ σ → Env T Γ → T σ
lookup i ρ with Pointer.lookup i ρ
... | result refl x = x
| {
"alphanum_fraction": 0.5928917609,
"avg_line_length": 25.7916666667,
"ext": "agda",
"hexsha": "90d9d56baacc2f73d0ac85979ef082369f01a524",
"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/Data/Star/Environment.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/Star/Environment.agda",
"max_line_length": 72,
"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/Data/Star/Environment.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": 355,
"size": 1238
} |
-- | Stuff regarding isomorphisms and isomorphic data structures.
module Isomorphisms where
open import Function
open import Relation.Binary.PropositionalEquality as P
using (_≡_; refl; sym; trans; cong; module ≡-Reasoning)
open ≡-Reasoning
record IsIso {A B : Set} (f : A → B) : Set where
field
inv : B → A
isLeftInv : (a : A) → inv (f a) ≡ a
isRightInv : (b : B) → f (inv b) ≡ b
iso-comp : {A B C : Set} → {f : A → B} → {g : B → C} →
IsIso f → IsIso g → IsIso (g ∘ f)
iso-comp {A} {B} {C} {f} {g} if ig =
record { inv = IsIso.inv if ∘ IsIso.inv ig
; isLeftInv = λ a →
begin
(IsIso.inv if ∘ IsIso.inv ig) ((g ∘ f) a)
≡⟨ refl ⟩
(IsIso.inv if (IsIso.inv ig (g (f a))))
≡⟨ cong (λ x → IsIso.inv if x) (IsIso.isLeftInv ig (f a)) ⟩
(IsIso.inv if (f a))
≡⟨ IsIso.isLeftInv if a ⟩
a
∎
; isRightInv = λ c →
begin
(g ∘ f) ((IsIso.inv if ∘ IsIso.inv ig) c)
≡⟨ refl ⟩
g (f ((IsIso.inv if) ((IsIso.inv ig) c)))
≡⟨ cong (λ x → g x) (IsIso.isRightInv if (IsIso.inv ig c)) ⟩
g ((IsIso.inv ig) c)
≡⟨ IsIso.isRightInv ig c ⟩
c
∎
}
iso-rev : {A B : Set} → {f : A → B} → (I : IsIso f) →
IsIso (IsIso.inv I)
iso-rev {A} {B} {f} I =
record { inv = f
; isLeftInv = IsIso.isRightInv I
; isRightInv = IsIso.isLeftInv I }
record Iso (A B : Set) : Set where
field
iso : A → B
indeedIso : IsIso iso
iso-trans : {A B C : Set} → Iso A B → Iso B C → Iso A C
iso-trans I₁ I₂ =
record { iso = Iso.iso I₂ ∘ Iso.iso I₁
; indeedIso = iso-comp (Iso.indeedIso I₁) (Iso.indeedIso I₂) }
| {
"alphanum_fraction": 0.4938063063,
"avg_line_length": 31.1578947368,
"ext": "agda",
"hexsha": "fdbd109dcef9ae54bc792350fd30cc4947a34960",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "OTTTests/Isomorphisms.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "OTTTests/Isomorphisms.agda",
"max_line_length": 71,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "OTTTests/Isomorphisms.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 648,
"size": 1776
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- A binary representation of natural numbers
------------------------------------------------------------------------
module Data.Bin where
open import Data.Nat as Nat
using (ℕ; zero; z≤n; s≤s) renaming (suc to 1+_)
open Nat.≤-Reasoning
import Data.Nat.Properties as NP
open import Data.Digit
open import Data.Fin as Fin using (Fin; zero) renaming (suc to 1+_)
open import Data.Fin.Properties as FP using (_+′_)
open import Data.List as List hiding (downFrom)
open import Function
open import Data.Product
open import Algebra
open import Relation.Binary
open import Relation.Binary.Consequences
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; sym)
open import Relation.Nullary
private
module BitOrd = StrictTotalOrder (FP.strictTotalOrder 2)
------------------------------------------------------------------------
-- The type
-- A representation of binary natural numbers in which there is
-- exactly one representative for every number.
-- The function toℕ below defines the meaning of Bin.
infix 8 _1#
-- bs stands for the binary number 1<reverse bs>, which is positive.
Bin⁺ : Set
Bin⁺ = List Bit
data Bin : Set where
-- Zero.
0# : Bin
-- bs 1# stands for the binary number 1<reverse bs>.
_1# : (bs : Bin⁺) → Bin
------------------------------------------------------------------------
-- Conversion functions
-- Converting to a list of bits starting with the _least_ significant
-- one.
toBits : Bin → List Bit
toBits 0# = [ 0b ]
toBits (bs 1#) = bs ++ [ 1b ]
-- Converting to a natural number.
toℕ : Bin → ℕ
toℕ = fromDigits ∘ toBits
-- Converting from a list of bits, starting with the _least_
-- significant one.
fromBits : List Bit → Bin
fromBits [] = 0#
fromBits (b ∷ bs) with fromBits bs
fromBits (b ∷ bs) | bs′ 1# = (b ∷ bs′) 1#
fromBits (zero ∷ bs) | 0# = 0#
fromBits (1+ zero ∷ bs) | 0# = [] 1#
fromBits (1+ 1+ () ∷ bs) | _
-- Converting from a natural number.
fromℕ : ℕ → Bin
fromℕ n = fromBits $ proj₁ $ toDigits 2 n
------------------------------------------------------------------------
-- (Bin, _≡_, _<_) is a strict total order
infix 4 _<_
-- Order relation. Wrapped so that the parameters can be inferred.
data _<_ (b₁ b₂ : Bin) : Set where
less : (lt : (Nat._<_ on toℕ) b₁ b₂) → b₁ < b₂
private
<-trans : Transitive _<_
<-trans (less lt₁) (less lt₂) = less (NP.<-trans lt₁ lt₂)
asym : ∀ {b₁ b₂} → b₁ < b₂ → ¬ b₂ < b₁
asym {b₁} {b₂} (less lt) (less gt) = tri⟶asym cmp lt gt
where cmp = StrictTotalOrder.compare NP.strictTotalOrder
irr : ∀ {b₁ b₂} → b₁ < b₂ → b₁ ≢ b₂
irr lt eq = asym⟶irr (PropEq.resp₂ _<_) sym asym eq lt
irr′ : ∀ {b} → ¬ b < b
irr′ lt = irr lt refl
∷∙ : ∀ {b₁ b₂ bs₁ bs₂} →
bs₁ 1# < bs₂ 1# → (b₁ ∷ bs₁) 1# < (b₂ ∷ bs₂) 1#
∷∙ {b₁} {b₂} {bs₁} {bs₂} (less lt) = less (begin
1 + (m₁ + n₁ * 2) ≤⟨ ≤-refl {x = 1} +-mono
(≤-pred (FP.bounded b₁) +-mono ≤-refl) ⟩
1 + (1 + n₁ * 2) ≡⟨ refl ⟩
suc n₁ * 2 ≤⟨ lt *-mono ≤-refl ⟩
n₂ * 2 ≤⟨ n≤m+n m₂ (n₂ * 2) ⟩
m₂ + n₂ * 2 ∎
)
where
open Nat; open NP
open DecTotalOrder decTotalOrder renaming (refl to ≤-refl)
m₁ = Fin.toℕ b₁; m₂ = Fin.toℕ b₂
n₁ = toℕ (bs₁ 1#); n₂ = toℕ (bs₂ 1#)
∙∷ : ∀ {b₁ b₂ bs} →
Fin._<_ b₁ b₂ → (b₁ ∷ bs) 1# < (b₂ ∷ bs) 1#
∙∷ {b₁} {b₂} {bs} lt = less (begin
1 + (m₁ + n * 2) ≡⟨ sym (+-assoc 1 m₁ (n * 2)) ⟩
(1 + m₁) + n * 2 ≤⟨ lt +-mono ≤-refl ⟩
m₂ + n * 2 ∎)
where
open Nat; open NP
open DecTotalOrder decTotalOrder renaming (refl to ≤-refl)
open CommutativeSemiring commutativeSemiring using (+-assoc)
m₁ = Fin.toℕ b₁; m₂ = Fin.toℕ b₂; n = toℕ (bs 1#)
1<[23] : ∀ {b} → [] 1# < (b ∷ []) 1#
1<[23] {b} = less (NP.n≤m+n (Fin.toℕ b) 2)
1<2+ : ∀ {bs b} → [] 1# < (b ∷ bs) 1#
1<2+ {[]} = 1<[23]
1<2+ {b ∷ bs} = <-trans 1<[23] (∷∙ {b₁ = b} (1<2+ {bs}))
0<1 : 0# < [] 1#
0<1 = less (s≤s z≤n)
0<+ : ∀ {bs} → 0# < bs 1#
0<+ {[]} = 0<1
0<+ {b ∷ bs} = <-trans 0<1 1<2+
compare⁺ : Trichotomous (_≡_ on _1#) (_<_ on _1#)
compare⁺ [] [] = tri≈ irr′ refl irr′
compare⁺ [] (b ∷ bs) = tri< 1<2+ (irr 1<2+) (asym 1<2+)
compare⁺ (b ∷ bs) [] = tri> (asym 1<2+) (irr 1<2+ ∘ sym) 1<2+
compare⁺ (b₁ ∷ bs₁) (b₂ ∷ bs₂) with compare⁺ bs₁ bs₂
... | tri< lt ¬eq ¬gt = tri< (∷∙ lt) (irr (∷∙ lt)) (asym (∷∙ lt))
... | tri> ¬lt ¬eq gt = tri> (asym (∷∙ gt)) (irr (∷∙ gt) ∘ sym) (∷∙ gt)
compare⁺ (b₁ ∷ bs) (b₂ ∷ .bs) | tri≈ ¬lt refl ¬gt with BitOrd.compare b₁ b₂
compare⁺ (b ∷ bs) (.b ∷ .bs) | tri≈ ¬lt refl ¬gt | tri≈ ¬lt′ refl ¬gt′ =
tri≈ irr′ refl irr′
... | tri< lt′ ¬eq ¬gt′ = tri< (∙∷ lt′) (irr (∙∷ lt′)) (asym (∙∷ lt′))
... | tri> ¬lt′ ¬eq gt′ = tri> (asym (∙∷ gt′)) (irr (∙∷ gt′) ∘ sym) (∙∷ gt′)
compare : Trichotomous _≡_ _<_
compare 0# 0# = tri≈ irr′ refl irr′
compare 0# (bs₂ 1#) = tri< 0<+ (irr 0<+) (asym 0<+)
compare (bs₁ 1#) 0# = tri> (asym 0<+) (irr 0<+ ∘ sym) 0<+
compare (bs₁ 1#) (bs₂ 1#) = compare⁺ bs₁ bs₂
strictTotalOrder : StrictTotalOrder _ _ _
strictTotalOrder = record
{ Carrier = Bin
; _≈_ = _≡_
; _<_ = _<_
; isStrictTotalOrder = record
{ isEquivalence = PropEq.isEquivalence
; trans = <-trans
; compare = compare
; <-resp-≈ = PropEq.resp₂ _<_
}
}
------------------------------------------------------------------------
-- (Bin, _≡_) is a decidable setoid
decSetoid : DecSetoid _ _
decSetoid = StrictTotalOrder.decSetoid strictTotalOrder
infix 4 _≟_
_≟_ : Decidable {A = Bin} _≡_
_≟_ = DecSetoid._≟_ decSetoid
------------------------------------------------------------------------
-- Arithmetic
-- Power of two.
infixr 8 2^_
2^_ : ℕ → Bin⁺
2^ 0 = []
2^ 1+ n = 0b ∷ 2^ n
-- Base 2 logarithm (rounded downwards).
⌊log₂_⌋ : Bin⁺ → ℕ
⌊log₂ (b ∷ bs) ⌋ = 1+ ⌊log₂ bs ⌋
⌊log₂ [] ⌋ = 0
-- Multiplication by 2.
infix 7 _*2 _*2+1
_*2 : Bin → Bin
0# *2 = 0#
(bs 1#) *2 = (0b ∷ bs) 1#
_*2+1 : Bin → Bin
0# *2+1 = [] 1#
(bs 1#) *2+1 = (1b ∷ bs) 1#
-- Division by 2, rounded downwards.
⌊_/2⌋ : Bin → Bin
⌊ 0# /2⌋ = 0#
⌊ [] 1# /2⌋ = 0#
⌊ (b ∷ bs) 1# /2⌋ = bs 1#
-- Addition.
Carry : Set
Carry = Bit
addBits : Carry → Bit → Bit → Carry × Bit
addBits c b₁ b₂ with c +′ (b₁ +′ b₂)
... | zero = (0b , 0b)
... | 1+ zero = (0b , 1b)
... | 1+ 1+ zero = (1b , 0b)
... | 1+ 1+ 1+ zero = (1b , 1b)
... | 1+ 1+ 1+ 1+ ()
addCarryToBitList : Carry → List Bit → List Bit
addCarryToBitList zero bs = bs
addCarryToBitList (1+ zero) [] = 1b ∷ []
addCarryToBitList (1+ zero) (zero ∷ bs) = 1b ∷ bs
addCarryToBitList (1+ zero) (1+ zero ∷ bs) = 0b ∷ addCarryToBitList 1b bs
addCarryToBitList (1+ 1+ ()) _
addCarryToBitList _ ((1+ 1+ ()) ∷ _)
addBitLists : Carry → List Bit → List Bit → List Bit
addBitLists c [] bs₂ = addCarryToBitList c bs₂
addBitLists c bs₁ [] = addCarryToBitList c bs₁
addBitLists c (b₁ ∷ bs₁) (b₂ ∷ bs₂) with addBits c b₁ b₂
... | (c' , b') = b' ∷ addBitLists c' bs₁ bs₂
infixl 6 _+_
_+_ : Bin → Bin → Bin
m + n = fromBits (addBitLists 0b (toBits m) (toBits n))
-- Multiplication.
infixl 7 _*_
_*_ : Bin → Bin → Bin
0# * n = 0#
[] 1# * n = n
-- (b + 2 * bs 1#) * n = b * n + 2 * (bs 1# * n)
(b ∷ bs) 1# * n with bs 1# * n
(b ∷ bs) 1# * n | 0# = 0#
(zero ∷ bs) 1# * n | bs' 1# = (0b ∷ bs') 1#
(1+ zero ∷ bs) 1# * n | bs' 1# = n + (0b ∷ bs') 1#
((1+ 1+ ()) ∷ _) 1# * _ | _
-- Successor.
suc : Bin → Bin
suc n = [] 1# + n
-- Division by 2, rounded upwards.
⌈_/2⌉ : Bin → Bin
⌈ n /2⌉ = ⌊ suc n /2⌋
-- Predecessor.
pred : Bin⁺ → Bin
pred [] = 0#
pred (zero ∷ bs) = pred bs *2+1
pred (1+ zero ∷ bs) = (zero ∷ bs) 1#
pred (1+ 1+ () ∷ bs)
-- downFrom n enumerates all numbers from n - 1 to 0. This function is
-- linear in n. Analysis: fromℕ takes linear time, and the preds used
-- take amortised constant time (to see this, let the cost of a pred
-- be 2, and put 1 debit on every bit which is 1).
downFrom : ℕ → List Bin
downFrom n = helper n (fromℕ n)
where
helper : ℕ → Bin → List Bin
helper zero 0# = []
helper (1+ n) (bs 1#) = n′ ∷ helper n n′
where n′ = pred bs
-- Impossible cases:
helper zero (_ 1#) = []
helper (1+ _) 0# = []
------------------------------------------------------------------------
-- Tests
-- The tests below have been commented out since (at least one version
-- of) Agda is too slow or memory-hungry to type check them.
{-
-- The tests below are run when this module is type checked.
-- First some test helpers:
private
testLimit : ℕ
testLimit = 5
nats : List ℕ
nats = List.downFrom testLimit
nats⁺ : List ℕ
nats⁺ = filter (λ n → decToBool (Nat._≤?_ 1 n)) nats
natPairs : List (ℕ × ℕ)
natPairs = zip nats (reverse nats)
_=[_]_ : (ℕ → ℕ) → List ℕ → (Bin → Bin) → Set
f =[ ns ] g = map f ns ≡ map (toℕ ∘ g ∘ fromℕ) ns
_=[_]₂_ : (ℕ → ℕ → ℕ) → List (ℕ × ℕ) → (Bin → Bin → Bin) → Set
f =[ ps ]₂ g =
map (uncurry f) ps ≡ map (toℕ ∘ uncurry (g on fromℕ)) ps
-- And then the tests:
private
test-*2+1 : (λ n → Nat._+_ (Nat._*_ n 2) 1) =[ nats ] _*2+1
test-*2+1 = refl
test-*2 : (λ n → Nat._*_ n 2) =[ nats ] _*2
test-*2 = refl
test-⌊_/2⌋ : Nat.⌊_/2⌋ =[ nats ] ⌊_/2⌋
test-⌊_/2⌋ = refl
test-+ : Nat._+_ =[ natPairs ]₂ _+_
test-+ = refl
test-* : Nat._*_ =[ natPairs ]₂ _*_
test-* = refl
test-suc : 1+_ =[ nats ] suc
test-suc = refl
test-⌈_/2⌉ : Nat.⌈_/2⌉ =[ nats ] ⌈_/2⌉
test-⌈_/2⌉ = refl
drop-1# : Bin → Bin⁺
drop-1# 0# = []
drop-1# (bs 1#) = bs
test-pred : Nat.pred =[ nats⁺ ] (pred ∘ drop-1#)
test-pred = refl
test-downFrom : map toℕ (downFrom testLimit) ≡
List.downFrom testLimit
test-downFrom = refl
-}
| {
"alphanum_fraction": 0.5031031425,
"avg_line_length": 27.2144772118,
"ext": "agda",
"hexsha": "1808726baadc36c3ab84d5d3b9370d8208f6f27c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/Bin.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/Bin.agda",
"max_line_length": 80,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Data/Bin.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 4136,
"size": 10151
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.EM1HSpace
open import homotopy.EilenbergMacLane
open import homotopy.EilenbergMacLane1
open import homotopy.EM1HSpace
open import homotopy.EM1HSpaceAssoc
module homotopy.EilenbergMacLaneFunctor where
open EMExplicit
module _ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where
private
module φ = GroupHom φ
EM₁-fmap-hom : G →ᴳ Ω^S-group 0 (⊙EM₁ H)
EM₁-fmap-hom = group-hom f f-preserves-comp
where
f : Group.El G → embase' H == embase
f g = emloop (φ.f g)
f-preserves-comp : ∀ g₁ g₂ → f (Group.comp G g₁ g₂) == f g₁ ∙ f g₂
f-preserves-comp g₁ g₂ =
emloop (φ.f (Group.comp G g₁ g₂))
=⟨ ap emloop (φ.pres-comp g₁ g₂) ⟩
emloop (Group.comp H (φ.f g₁) (φ.f g₂))
=⟨ emloop-comp' H (φ.f g₁) (φ.f g₂) ⟩
emloop (φ.f g₁) ∙ emloop (φ.f g₂) =∎
module EM₁FmapRec =
EM₁Level₁Rec {G = G} {C = EM₁ H}
{{EM₁-level₁ H {⟨-2⟩}}}
embase
EM₁-fmap-hom
abstract
EM₁-fmap : EM₁ G → EM₁ H
EM₁-fmap = EM₁FmapRec.f
EM₁-fmap-embase-β : EM₁-fmap embase ↦ embase
EM₁-fmap-embase-β = EM₁FmapRec.embase-β
{-# REWRITE EM₁-fmap-embase-β #-}
EM₁-fmap-emloop-β : ∀ g → ap EM₁-fmap (emloop g) == emloop (φ.f g)
EM₁-fmap-emloop-β = EM₁FmapRec.emloop-β
⊙EM₁-fmap : ⊙EM₁ G ⊙→ ⊙EM₁ H
⊙EM₁-fmap = EM₁-fmap , idp
module _ {i j k} {G : Group i} {H : Group j} {K : Group k} (ψ : H →ᴳ K) (φ : G →ᴳ H) where
EM₁-fmap-∘ : EM₁-fmap (ψ ∘ᴳ φ) ∼ EM₁-fmap ψ ∘ EM₁-fmap φ
EM₁-fmap-∘ =
EM₁-set-elim
{P = λ x → EM₁-fmap (ψ ∘ᴳ φ) x == EM₁-fmap ψ (EM₁-fmap φ x)}
{{λ x → has-level-apply (EM₁-level₁ K) _ _}}
idp $
λ g → ↓-='-in' $
ap (EM₁-fmap ψ ∘ EM₁-fmap φ) (emloop g)
=⟨ ap-∘ (EM₁-fmap ψ) (EM₁-fmap φ) (emloop g) ⟩
ap (EM₁-fmap ψ) (ap (EM₁-fmap φ) (emloop g))
=⟨ ap (ap (EM₁-fmap ψ)) (EM₁-fmap-emloop-β φ g) ⟩
ap (EM₁-fmap ψ) (emloop (GroupHom.f φ g))
=⟨ EM₁-fmap-emloop-β ψ (GroupHom.f φ g) ⟩
emloop (GroupHom.f (ψ ∘ᴳ φ) g)
=⟨ ! (EM₁-fmap-emloop-β (ψ ∘ᴳ φ) g) ⟩
ap (EM₁-fmap (ψ ∘ᴳ φ)) (emloop g) =∎
⊙EM₁-fmap-∘ : ⊙EM₁-fmap (ψ ∘ᴳ φ) ⊙∼ ⊙EM₁-fmap ψ ⊙∘ ⊙EM₁-fmap φ
⊙EM₁-fmap-∘ = EM₁-fmap-∘ , idp
module _ {i} (G : Group i) where
EM₁-fmap-idhom : EM₁-fmap (idhom G) ∼ idf (EM₁ G)
EM₁-fmap-idhom =
EM₁-set-elim
{P = λ x → EM₁-fmap (idhom G) x == x}
{{λ x → has-level-apply (EM₁-level₁ G) (EM₁-fmap (idhom G) x) x}}
idp $
λ g → ↓-='-in' $ ! $
ap (EM₁-fmap (idhom G)) (emloop g)
=⟨ EM₁-fmap-emloop-β (idhom G) g ⟩
emloop g
=⟨ ! (ap-idf (emloop g)) ⟩
ap (idf (EM₁ G)) (emloop g) =∎
⊙EM₁-fmap-idhom : ⊙EM₁-fmap (idhom G) ⊙∼ ⊙idf (⊙EM₁ G)
⊙EM₁-fmap-idhom = EM₁-fmap-idhom , idp
module _ {i j} (G : Group i) (H : Group j) where
EM₁-fmap-cst-hom : EM₁-fmap (cst-hom {G = G} {H = H}) ∼ cst embase
EM₁-fmap-cst-hom =
EM₁-set-elim
{P = λ x → EM₁-fmap cst-hom x == embase}
{{λ x → has-level-apply (EM₁-level₁ H) (EM₁-fmap cst-hom x) embase}}
idp $
λ g → ↓-app=cst-in' $ ! $
ap (EM₁-fmap cst-hom) (emloop g)
=⟨ EM₁-fmap-emloop-β cst-hom g ⟩
emloop (Group.ident H)
=⟨ emloop-ident ⟩
idp =∎
⊙EM₁-fmap-cst-hom : ⊙EM₁-fmap (cst-hom {G = G} {H = H}) ⊙∼ ⊙cst
⊙EM₁-fmap-cst-hom = EM₁-fmap-cst-hom , idp
module _ {i j} (G : AbGroup i) (H : AbGroup j) (φ : G →ᴬᴳ H) where
⊙EM-fmap : ∀ n → ⊙EM G n ⊙→ ⊙EM H n
⊙EM-fmap = EMImplicitMap.⊙EM-fmap (⊙EM₁-fmap φ) (EM₁HSpace.H-⊙EM₁ G) (EM₁HSpace.H-⊙EM₁ H)
EM-fmap : ∀ n → EM G n → EM H n
EM-fmap n = fst (⊙EM-fmap n)
module _ {i} (G H : AbGroup i) (φ : AbGroup.grp G →ᴳ AbGroup.grp H) where
private
module SN = SpectrumNatural
{X = ⊙EM₁ (AbGroup.grp G)} {Y = ⊙EM₁ (AbGroup.grp H)}
(⊙EM₁-fmap φ)
{{EM₁-conn}} {{EM₁-conn}}
{{EM₁-level₁ (AbGroup.grp G)}} {{EM₁-level₁ (AbGroup.grp H)}}
(EM₁HSpace.H-⊙EM₁ G) (EM₁HSpace.H-⊙EM₁ H)
abstract
{-
checking this definition is very slow for some
mysterious reason (unification maybe?)
-}
⊙–>-spectrum-natural : ∀ (n : ℕ)
→ ⊙–> (spectrum H n) ◃⊙∘
⊙Ω-fmap (⊙EM-fmap G H φ (S n)) ◃⊙idf
=⊙∘
⊙EM-fmap G H φ n ◃⊙∘
⊙–> (spectrum G n) ◃⊙idf
⊙–>-spectrum-natural n =
⊙–> (spectrum H n) ◃⊙∘
⊙Ω-fmap (⊙EM-fmap G H φ (S n)) ◃⊙idf
=⊙∘₁⟨ 0 & 1 & ap ⊙–> (spectrum-def H n) ⟩
⊙–> (Spectrum.spectrum H n) ◃⊙∘
⊙Ω-fmap (⊙EM-fmap G H φ (S n)) ◃⊙idf
=⊙∘⟨ SN.⊙–>-spectrum-natural n ⟩
⊙EM-fmap G H φ n ◃⊙∘
⊙–> (Spectrum.spectrum G n) ◃⊙idf
=⊙∘₁⟨ 1 & 1 & ap ⊙–> (! (spectrum-def G n)) ⟩
⊙EM-fmap G H φ n ◃⊙∘
⊙–> (spectrum G n) ◃⊙idf ∎⊙∘
{-
derived from `⊙–>-spectrum-natural` instead of from
`SN.⊙<–-spectrum-natural n` since that circumvents
the slowness issue for this definition.
-}
⊙<–-spectrum-natural : ∀ (n : ℕ)
→ ⊙<– (spectrum H n) ◃⊙∘
⊙EM-fmap G H φ n ◃⊙idf
=⊙∘
⊙Ω-fmap (⊙EM-fmap G H φ (S n)) ◃⊙∘
⊙<– (spectrum G n) ◃⊙idf
⊙<–-spectrum-natural n =
⊙<– (spectrum H n) ◃⊙∘
⊙EM-fmap G H φ n ◃⊙idf
=⊙∘⟨ 2 & 0 & !⊙∘ $ ⊙<–-inv-r-=⊙∘ (spectrum G n) ⟩
⊙<– (spectrum H n) ◃⊙∘
⊙EM-fmap G H φ n ◃⊙∘
⊙–> (spectrum G n) ◃⊙∘
⊙<– (spectrum G n) ◃⊙idf
=⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙–>-spectrum-natural n ⟩
⊙<– (spectrum H n) ◃⊙∘
⊙–> (spectrum H n) ◃⊙∘
⊙Ω-fmap (⊙EM-fmap G H φ (S n)) ◃⊙∘
⊙<– (spectrum G n) ◃⊙idf
=⊙∘⟨ 0 & 2 & ⊙<–-inv-l-=⊙∘ (spectrum H n) ⟩
⊙Ω-fmap (⊙EM-fmap G H φ (S n)) ◃⊙∘
⊙<– (spectrum G n) ◃⊙idf ∎⊙∘
module _ {i j k} (G : AbGroup i) (H : AbGroup j) (K : AbGroup k) (ψ : H →ᴬᴳ K) (φ : G →ᴬᴳ H) where
private
module G = AbGroup G
module H = AbGroup H
module K = AbGroup K
⊙EM-fmap-∘ : ∀ n → ⊙EM-fmap G K (ψ ∘ᴳ φ) n == ⊙EM-fmap H K ψ n ⊙∘ ⊙EM-fmap G H φ n
⊙EM-fmap-∘ O =
⊙Ω-fmap (⊙EM₁-fmap (ψ ∘ᴳ φ))
=⟨ ap ⊙Ω-fmap (⊙λ= (⊙EM₁-fmap-∘ ψ φ)) ⟩
⊙Ω-fmap (⊙EM₁-fmap ψ ⊙∘ ⊙EM₁-fmap φ)
=⟨ ⊙Ω-fmap-∘ (⊙EM₁-fmap ψ) (⊙EM₁-fmap φ) ⟩
⊙Ω-fmap (⊙EM₁-fmap ψ) ⊙∘ ⊙Ω-fmap (⊙EM₁-fmap φ) =∎
⊙EM-fmap-∘ (S n) =
⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM₁-fmap (ψ ∘ᴳ φ)))
=⟨ ap (⊙Trunc-fmap ∘ ⊙Susp^-fmap n) (⊙λ= (⊙EM₁-fmap-∘ ψ φ)) ⟩
⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM₁-fmap ψ ⊙∘ ⊙EM₁-fmap φ))
=⟨ ap ⊙Trunc-fmap (⊙Susp^-fmap-∘ n (⊙EM₁-fmap ψ) (⊙EM₁-fmap φ)) ⟩
⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM₁-fmap ψ) ⊙∘ ⊙Susp^-fmap n (⊙EM₁-fmap φ))
=⟨ ! (⊙λ= (⊙Trunc-fmap-⊙∘ (⊙Susp^-fmap n (⊙EM₁-fmap ψ)) (⊙Susp^-fmap n (⊙EM₁-fmap φ)))) ⟩
⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM₁-fmap ψ)) ⊙∘ ⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM₁-fmap φ)) =∎
EM-fmap-∘ : ∀ n → EM-fmap G K (ψ ∘ᴳ φ) n == EM-fmap H K ψ n ∘ EM-fmap G H φ n
EM-fmap-∘ n = ap fst (⊙EM-fmap-∘ n)
module _ {i} (G : AbGroup i) where
private
module G = AbGroup G
open EM₁HSpace G using (mult; mult-emloop-β)
EM₁-neg : EM₁ G.grp → EM₁ G.grp
EM₁-neg = EM₁-fmap (inv-hom G)
⊙EM₁-neg : ⊙EM₁ G.grp ⊙→ ⊙EM₁ G.grp
⊙EM₁-neg = ⊙EM₁-fmap (inv-hom G)
abstract
EM₁-neg-emloop-β : ∀ g → ap EM₁-neg (emloop g) == ! (emloop g)
EM₁-neg-emloop-β g =
ap EM₁-neg (emloop g)
=⟨ EM₁-fmap-emloop-β (inv-hom G) g ⟩
emloop (G.inv g)
=⟨ emloop-inv g ⟩
! (emloop g) =∎
EM₁-neg-! : ∀ (p : embase' G.grp == embase)
→ ap EM₁-neg p == ! p
EM₁-neg-! p =
transport (λ q → ap EM₁-neg q == ! q)
(<–-inv-r (emloop-equiv G.grp) p) $
EM₁-neg-emloop-β (<– (emloop-equiv G.grp) p)
⊙Ω-fmap-⊙EM₁-neg : ⊙Ω-fmap ⊙EM₁-neg == ⊙Ω-!
⊙Ω-fmap-⊙EM₁-neg = ⊙λ=' EM₁-neg-! $ prop-has-all-paths-↓
{{has-level-apply (has-level-apply (EM₁-level₁ G.grp {n = -2}) _ _) _ _}}
EM₁-neg-inv-l : ∀ (x : EM₁ G.grp)
→ mult (EM₁-neg x) x == embase
EM₁-neg-inv-l =
EM₁-set-elim
{P = λ x → mult (EM₁-neg x) x == embase}
{{λ x → has-level-apply (EM₁-level₁ G.grp) _ _}}
idp $ λ g →
↓-='-in-=ₛ $ !ₛ $
ap (λ x → mult (EM₁-neg x) x) (emloop g) ◃∙
idp ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
ap (λ x → mult (EM₁-neg x) x) (emloop g) ◃∎
=ₛ₁⟨ ! (ap2-diag (λ x y → mult (EM₁-neg x) y) (emloop g)) ⟩
ap2 (λ x y → mult (EM₁-neg x) y) (emloop g) (emloop g) ◃∎
=ₛ⟨ ap2-out (λ x y → mult (EM₁-neg x) y) (emloop g) (emloop g) ⟩
ap (λ x → mult (EM₁-neg x) embase) (emloop g) ◃∙
ap (λ y → y) (emloop g) ◃∎
=ₛ₁⟨ 1 & 1 & ap-idf (emloop g) ⟩
ap (λ x → mult (EM₁-neg x) embase) (emloop g) ◃∙
emloop g ◃∎
=ₛ₁⟨ 0 & 1 & ap-∘ (λ x → mult x embase) EM₁-neg (emloop g) ⟩
ap (λ x → mult x embase) (ap EM₁-neg (emloop g)) ◃∙
emloop g ◃∎
=ₛ₁⟨ 0 & 1 & ap (ap (λ x → mult x embase)) (EM₁-neg-emloop-β g) ⟩
ap (λ x → mult x embase) (! (emloop g)) ◃∙
emloop g ◃∎
=ₛ₁⟨ 0 & 1 & ap-! (λ x → mult x embase) (emloop g) ⟩
! (ap (λ x → mult x embase) (emloop g)) ◃∙
emloop g ◃∎
=ₛ₁⟨ 0 & 1 & ap ! (mult-emloop-β g embase) ⟩
! (emloop g) ◃∙
emloop g ◃∎
=ₛ₁⟨ !-inv-l (emloop g) ⟩
idp ◃∎
=ₛ₁⟨ 1 & 0 & ! (ap-cst embase (emloop g)) ⟩
idp ◃∙
ap (cst embase) (emloop g) ◃∎ ∎ₛ
EM₁-neg-inv-r : ∀ (x : EM₁ G.grp)
→ mult x (EM₁-neg x) == embase
EM₁-neg-inv-r =
EM₁-set-elim
{P = λ x → mult x (EM₁-neg x) == embase}
{{λ x → has-level-apply (EM₁-level₁ G.grp) _ _}}
idp $ λ g →
↓-='-in-=ₛ $ !ₛ $
ap (λ x → mult x (EM₁-neg x)) (emloop g) ◃∙
idp ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
ap (λ x → mult x (EM₁-neg x)) (emloop g) ◃∎
=ₛ₁⟨ ! (ap2-diag (λ x y → mult x (EM₁-neg y)) (emloop g)) ⟩
ap2 (λ x y → mult x (EM₁-neg y)) (emloop g) (emloop g) ◃∎
=ₛ⟨ ap2-out (λ x y → mult x (EM₁-neg y)) (emloop g) (emloop g) ⟩
ap (λ x → mult x embase) (emloop g) ◃∙
ap EM₁-neg (emloop g) ◃∎
=ₛ₁⟨ 0 & 1 & mult-emloop-β g embase ⟩
emloop g ◃∙
ap EM₁-neg (emloop g) ◃∎
=ₛ₁⟨ 1 & 1 & EM₁-neg-emloop-β g ⟩
emloop g ◃∙
! (emloop g) ◃∎
=ₛ₁⟨ !-inv-r (emloop g) ⟩
idp ◃∎
=ₛ₁⟨ 1 & 0 & ! (ap-cst embase (emloop g)) ⟩
idp ◃∙
ap (λ _ → embase) (emloop g) ◃∎ ∎ₛ
EM-neg : ∀ (n : ℕ) → EM G n → EM G n
EM-neg n = EM-fmap G G (inv-hom G) n
⊙EM-neg : ∀ (n : ℕ) → ⊙EM G n ⊙→ ⊙EM G n
⊙EM-neg n = ⊙EM-fmap G G (inv-hom G) n
private
-- superseded by Susp-flip-EM-neg
EM-neg-2=Trunc-fmap-Susp-flip : EM-neg 2 ∼ Trunc-fmap Susp-flip
EM-neg-2=Trunc-fmap-Susp-flip =
Trunc-elim {{λ t → =-preserves-level (EM-level G 2)}} $
Susp-elim
{P = λ s → EM-neg 2 [ s ]₂ == Trunc-fmap Susp-flip [ s ]₂}
(ap [_]₂ (merid embase))
(ap [_]₂ (! (merid embase))) $
λ x → ↓-='-in-=ₛ $
ap [_]₂ (merid embase) ◃∙
ap (Trunc-fmap Susp-flip ∘ [_]₂) (merid x) ◃∎
=ₛ₁⟨ 1 & 1 & ap-∘ [_]₂ Susp-flip (merid x) ⟩
ap [_]₂ (merid embase) ◃∙
ap [_]₂ (ap Susp-flip (merid x)) ◃∎
=ₛ₁⟨ 1 & 1 & ap (ap [_]₂) (SuspFlip.merid-β x) ⟩
ap [_]₂ (merid embase) ◃∙
ap [_]₂ (! (merid x)) ◃∎
=ₛ₁⟨ 0 & 1 & ap (ap [_]₂) (! (!-! (merid embase))) ⟩
ap [_]₂ (! (! (merid embase))) ◃∙
ap [_]₂ (! (merid x)) ◃∎
=ₛ⟨ ap-seq-=ₛ [_]₂ (∙-!-seq (merid x ◃∙ ! (merid embase) ◃∎)) ⟩
ap [_]₂ (! (η x)) ◃∎
=ₛ₁⟨ ap-! [_]₂ (η x) ⟩
! (ap [_]₂ (η x)) ◃∎
=ₛ₁⟨ cancels-inverse (ap [_]₂ (η x)) (ap [_]₂ (η (EM₁-neg x))) $
ap [_]₂ (η x) ∙ ap [_]₂ (η (EM₁-neg x))
=⟨ ∙-ap [_]₂ (η x) (η (EM₁-neg x)) ⟩
ap [_]₂ (η x ∙ η (EM₁-neg x))
=⟨ ap (<– (=ₜ-equiv [ north ]₂ [ north ]₂)) $
! $ comp x (EM₁-neg x) ⟩
ap [_]₂ (η (mult x (EM₁-neg x)))
=⟨ ap (ap [_]₂ ∘ η) (EM₁-neg-inv-r x) ⟩
ap [_]₂ (η embase)
=⟨ ap (ap [_]₂) (!-inv-r (merid embase)) ⟩
idp =∎ ⟩
ap [_]₂ (η (EM₁-neg x)) ◃∎
=ₛ⟨ ap-seq-∙ [_]₂ (merid (EM₁-neg x) ◃∙ ! (merid embase) ◃∎) ⟩
ap [_]₂ (merid (EM₁-neg x)) ◃∙
ap [_]₂ (! (merid embase)) ◃∎
=ₛ₁⟨ 0 & 1 & ap (ap [_]₂) (! (SuspFmap.merid-β EM₁-neg x)) ⟩
ap [_]₂ (ap (Susp-fmap EM₁-neg) (merid x)) ◃∙
ap [_]₂ (! (merid embase)) ◃∎
=ₛ₁⟨ 0 & 1 & ∘-ap [_]₂ (Susp-fmap EM₁-neg) (merid x) ⟩
ap (EM-neg 2 ∘ [_]₂) (merid x) ◃∙
ap [_]₂ (! (merid embase)) ◃∎ ∎ₛ
where
open EM₁HSpaceAssoc G using (η; H-⊙EM₁; H-⊙EM₁-assoc; H-EM₁-assoc-coh-unit-l-r-pentagon)
open import homotopy.Pi2HSuspCompose H-⊙EM₁ H-⊙EM₁-assoc H-EM₁-assoc-coh-unit-l-r-pentagon
using (comp)
cancels-inverse : ∀ {i} {A : Type i} {x y : A}
(p : x == y) (q : y == x) → p ∙ q == idp → ! p == q
cancels-inverse p@idp [email protected] idp = idp
⊙EM-neg-2=⊙Trunc-fmap-⊙Susp-flip : ⊙EM-neg 2 == ⊙Trunc-fmap (⊙Susp-flip (⊙EM₁ G.grp))
⊙EM-neg-2=⊙Trunc-fmap-⊙Susp-flip =
⊙λ=' {X = ⊙EM G 2} {Y = ⊙EM G 2} EM-neg-2=Trunc-fmap-Susp-flip $
↓-idf=cst-in $
=ₛ-out $ !ₛ $
ap [_]₂ (merid embase) ◃∙
ap [_]₂ (! (merid embase)) ◃∎
=ₛ⟨ ap-seq-=ₛ [_]₂ (seq-!-inv-r (merid (embase' G.grp) ◃∎)) ⟩
[] ∎ₛ
⊙to-alt-EM : ∀ n → ⊙EM G (S (S n)) ⊙≃ ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ n (⊙EM G 2))
⊙to-alt-EM n =
(⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ⊙⁻¹ ⊙∘e
⊙coe-equiv (ap (⊙Trunc (⟨ n ⟩₋₂ +2+ 2)) (! (⊙Susp^-+ n 1))) ⊙∘e
⊙coe-equiv (ap (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n)) ⊙∘e
⊙coe-equiv (ap (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂))
⊙–>-⊙to-alt-EM : ∀ n →
⊙–> (⊙to-alt-EM n) ◃⊙idf
=⊙∘
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
⊙–>-⊙to-alt-EM n =
⊙–> (⊙to-alt-EM n) ◃⊙idf
=⊙∘⟨ =⊙∘-in idp ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙coe (ap (⊙Trunc (⟨ n ⟩₋₂ +2+ 2)) (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙coe (ap (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n)) ◃⊙∘
⊙coe (ap (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂)) ◃⊙idf
=⊙∘₁⟨ 1 & 1 & ! (⊙transport-⊙coe (⊙Trunc (⟨ n ⟩₋₂ +2+ 2)) (! (⊙Susp^-+ n 1))) ∙
⊙transport-⊙Trunc (! (⊙Susp^-+ n 1)) ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙coe (ap (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n)) ◃⊙∘
⊙coe (ap (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂)) ◃⊙idf
=⊙∘₁⟨ 2 & 1 & ! $ ⊙transport-⊙coe (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙coe (ap (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂)) ◃⊙idf
=⊙∘₁⟨ 3 & 1 & ! $ ⊙transport-⊙coe (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf ∎⊙∘
⊙EM-neg=⊙Trunc-fmap-⊙Susp-flip : ∀ (n : ℕ)
→ ⊙EM-neg (S (S n)) == ⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp)))
⊙EM-neg=⊙Trunc-fmap-⊙Susp-flip n =
equiv-is-inj
(post⊙∘-is-equiv (⊙to-alt-EM n))
(⊙EM-neg (S (S n)))
(⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp)))) $
=⊙∘-out {fs = ⊙–> (⊙to-alt-EM n) ◃⊙∘ ⊙EM-neg (S (S n)) ◃⊙idf}
{gs = ⊙–> (⊙to-alt-EM n) ◃⊙∘ ⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙idf} $
⊙–> (⊙to-alt-EM n) ◃⊙∘
⊙EM-neg (S (S n)) ◃⊙idf
=⊙∘⟨ 0 & 1 & ⊙–>-⊙to-alt-EM n ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙∘
⊙EM-neg (S (S n)) ◃⊙idf
=⊙∘⟨ 3 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘
(+2+-comm 2 ⟨ n ⟩₋₂)
(λ k → ⊙Trunc-fmap {n = k} (⊙Susp^-fmap (S n) ⊙EM₁-neg)) ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap (S n) ⊙EM₁-neg) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘⟨ 2 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘
(+-comm 1 n)
(λ l → ⊙Trunc-fmap (⊙Susp^-fmap l ⊙EM₁-neg)) ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap (n + 1) ⊙EM₁-neg) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘⟨ 1 & 2 & ⊙Trunc-fmap-seq-=⊙∘ $
=⊙∘-in {fs = ⊙coe (! (⊙Susp^-+ n 1)) ◃⊙∘ ⊙Susp^-fmap (n + 1) ⊙EM₁-neg ◃⊙idf}
{gs = ⊙Susp^-fmap n (⊙Susp-fmap EM₁-neg) ◃⊙∘ ⊙coe (! (⊙Susp^-+ n 1)) ◃⊙idf} $
! $ ⊙Susp^-+-natural' n 1 ⊙EM₁-neg ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Susp-fmap EM₁-neg)) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘⟨ 0 & 2 & ⊙Susp^-⊙Trunc-equiv-natural' (⊙Susp-fmap EM₁-neg) 2 n ⟩
⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM-neg 2)) ◃⊙∘
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘₁⟨ 0 & 1 & ap (⊙Trunc-fmap ∘ ⊙Susp^-fmap n) $
⊙EM-neg-2=⊙Trunc-fmap-⊙Susp-flip ⟩
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap (⊙Susp-flip (⊙EM₁ G.grp)))) ◃⊙∘
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘⟨ 0 & 2 & !⊙∘ $ ⊙Susp^-⊙Trunc-equiv-natural' (⊙Susp-flip _) 2 n ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Susp-flip (⊙EM₁ G.grp))) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘₁⟨ 3 & 1 & p ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Susp-flip (⊙EM₁ G.grp))) ◃⊙∘
⊙Trunc-fmap {n = ⟨ n ⟩₋₂ +2+ 2} (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙Trunc-fmap (⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n))) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘⟨ 1 & 3 & ⊙Trunc-fmap-seq-=⊙∘ $
⊙Susp^-fmap n (⊙Susp-flip (⊙EM₁ G.grp)) ◃⊙∘
⊙coe (! (⊙Susp^-+ n 1)) ◃⊙∘
⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n)) ◃⊙idf
=⊙∘⟨ 3 & 0 & ⊙contract ⟩
⊙Susp^-fmap n (⊙Susp-flip (⊙EM₁ G.grp)) ◃⊙∘
⊙coe (! (⊙Susp^-+ n 1)) ◃⊙∘
⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n)) ◃⊙∘
⊙coe (⊙Susp^-+ 1 n {⊙EM₁ G.grp}) ◃⊙idf
=⊙∘⟨ 1 & 3 & !⊙∘ $ ⊙coe-seq-∙ (⊙Susp^-comm-seq 1 n) ⟩
⊙Susp^-fmap n (⊙Susp-flip (⊙EM₁ G.grp)) ◃⊙∘
⊙coe (⊙Susp^-comm 1 n) ◃⊙idf
=⊙∘⟨ ⊙Susp^-comm-flip 0 n (⊙EM₁ G.grp) ⟩
⊙coe (⊙Susp^-comm 1 n) ◃⊙∘
⊙Susp-flip (⊙Susp^ 0 (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙idf
=⊙∘⟨ 0 & 1 & ⊙coe-seq-∙ (⊙Susp^-comm-seq 1 n) ⟩
⊙coe (! (⊙Susp^-+ n 1)) ◃⊙∘
⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n)) ◃⊙∘
⊙coe (⊙Susp^-+ 1 n {⊙EM₁ G.grp}) ◃⊙∘
⊙Susp-flip (⊙Susp^ 0 (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙idf
=⊙∘⟨ 2 & 1 & ⊙expand ⊙idf-seq ⟩
⊙coe (! (⊙Susp^-+ n 1)) ◃⊙∘
⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n)) ◃⊙∘
⊙Susp-flip (⊙Susp^ 0 (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙idf ∎⊙∘ ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙Trunc-fmap (⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n))) ◃⊙∘
⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙idf
=⊙∘⟨ 3 & 2 & ⊙transport-natural-=⊙∘
(+2+-comm 2 ⟨ n ⟩₋₂)
(λ k → ⊙Trunc-fmap {n = k} (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp)))) ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙Trunc-fmap (⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n))) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙∘
⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙idf
=⊙∘₁⟨ 2 & 1 & ! p ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv (⊙Susp (EM₁ G.grp)) 2 n) ◃⊙∘
⊙Trunc-fmap (⊙coe (! (⊙Susp^-+ n 1))) ◃⊙∘
⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ◃⊙∘
⊙transport (λ k → ⊙Trunc k (⊙Susp^ (S n) (⊙EM₁ G.grp))) (+2+-comm 2 ⟨ n ⟩₋₂) ◃⊙∘
⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙idf
=⊙∘⟨ 0 & 4 & !⊙∘ $ ⊙–>-⊙to-alt-EM n ⟩
⊙–> (⊙to-alt-EM n) ◃⊙∘
⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n (⊙EM₁ G.grp))) ◃⊙idf ∎⊙∘
where
p : ⊙transport (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ==
⊙Trunc-fmap (⊙coe (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n)))
p =
⊙transport-⊙coe (λ l → ⊙Trunc (⟨ n ⟩₋₂ +2+ 2) (⊙Susp^ l (⊙EM₁ G.grp))) (+-comm 1 n) ∙
ap ⊙coe (ap-∘ (⊙Trunc (⟨ n ⟩₋₂ +2+ 2)) (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n)) ∙
! (⊙transport-⊙coe (⊙Trunc (⟨ n ⟩₋₂ +2+ 2)) (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n))) ∙
⊙transport-⊙Trunc (ap (λ l → ⊙Susp^ l (⊙EM₁ G.grp)) (+-comm 1 n))
module _ {i} (G : AbGroup i) where
private
module G = AbGroup G
⊙EM-fmap-idhom : ∀ (n : ℕ)
→ ⊙EM-fmap G G (idhom G.grp) n == ⊙idf (⊙EM G n)
⊙EM-fmap-idhom O =
⊙Ω-fmap (⊙EM₁-fmap (idhom G.grp))
=⟨ ap ⊙Ω-fmap (⊙λ= (⊙EM₁-fmap-idhom G.grp)) ⟩
⊙Ω-fmap (⊙idf (⊙EM₁ G.grp))
=⟨ ⊙Ω-fmap-idf ⟩
⊙idf _ =∎
⊙EM-fmap-idhom (S n) =
⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM₁-fmap (idhom G.grp)))
=⟨ ap (⊙Trunc-fmap ∘ ⊙Susp^-fmap n) (⊙λ= (⊙EM₁-fmap-idhom G.grp)) ⟩
⊙Trunc-fmap (⊙Susp^-fmap n (⊙idf (⊙EM₁ G.grp)))
=⟨ ap ⊙Trunc-fmap (=⊙∘-out (⊙Susp^-fmap-idf n (⊙EM₁ G.grp))) ⟩
⊙Trunc-fmap (⊙idf (⊙Susp^ n (⊙EM₁ G.grp)))
=⟨ ⊙λ= ⊙Trunc-fmap-⊙idf ⟩
⊙idf _ =∎
EM-fmap-idhom : ∀ (n : ℕ)
→ EM-fmap G G (idhom G.grp) n == idf (EM G n)
EM-fmap-idhom n = ap fst (⊙EM-fmap-idhom n)
module _ {i} {j} (G : AbGroup i) (H : AbGroup j) where
⊙EM-fmap-cst-hom : ∀ (n : ℕ)
→ ⊙EM-fmap G H cst-hom n == ⊙cst
⊙EM-fmap-cst-hom O =
⊙Ω-fmap (⊙EM₁-fmap cst-hom)
=⟨ ap ⊙Ω-fmap (⊙λ= (⊙EM₁-fmap-cst-hom (AbGroup.grp G) (AbGroup.grp H))) ⟩
⊙Ω-fmap ⊙cst
=⟨ ⊙Ω-fmap-cst ⟩
⊙cst =∎
⊙EM-fmap-cst-hom (S n) =
⊙Trunc-fmap (⊙Susp^-fmap n (⊙EM₁-fmap cst-hom))
=⟨ ap (⊙Trunc-fmap ∘ ⊙Susp^-fmap n) (⊙λ= (⊙EM₁-fmap-cst-hom (AbGroup.grp G) (AbGroup.grp H))) ⟩
⊙Trunc-fmap (⊙Susp^-fmap n ⊙cst)
=⟨ ap ⊙Trunc-fmap (⊙Susp^-fmap-cst n) ⟩
⊙Trunc-fmap ⊙cst
=⟨ ⊙λ= ⊙Trunc-fmap-cst ⟩
⊙cst =∎
EM-fmap-cst-hom : ∀ (n : ℕ)
→ EM-fmap G H cst-hom n == cst (pt (⊙EM H n))
EM-fmap-cst-hom n = ap fst (⊙EM-fmap-cst-hom n)
transport-EM : ∀ {i} {G H : AbGroup i}
(p : G == H) (n : ℕ)
→ transport (λ K → EM K n) p == EM-fmap G H (coeᴬᴳ p) n
transport-EM {G = G} idp n = ! $
EM-fmap G G (coeᴳ idp) n
=⟨ ap (λ φ → EM-fmap G G φ n) (coeᴳ-idp (AbGroup.grp G)) ⟩
EM-fmap G G (idhom (AbGroup.grp G)) n
=⟨ EM-fmap-idhom G n ⟩
idf (EM G n) =∎
transport-EM-uaᴬᴳ : ∀ {i} (G H : AbGroup i)
(iso : G ≃ᴬᴳ H) (n : ℕ)
→ transport (λ K → EM K n) (uaᴬᴳ G H iso) == EM-fmap G H (–>ᴳ iso) n
transport-EM-uaᴬᴳ G H iso n =
transport (λ K → EM K n) (uaᴬᴳ G H iso)
=⟨ transport-EM (uaᴬᴳ G H iso) n ⟩
EM-fmap G H (coeᴬᴳ (uaᴬᴳ G H iso)) n
=⟨ ap (λ p → EM-fmap G H p n) (coeᴬᴳ-β G H iso) ⟩
EM-fmap G H (–>ᴳ iso) n =∎
⊙transport-⊙EM : ∀ {i} {G H : AbGroup i}
(p : G == H) (n : ℕ)
→ ⊙transport (λ K → ⊙EM K n) p == ⊙EM-fmap G H (coeᴬᴳ p) n
⊙transport-⊙EM {G = G} p@idp n = ! $
⊙EM-fmap G G (coeᴳ idp) n
=⟨ ap (λ φ → ⊙EM-fmap G G φ n) (coeᴳ-idp (AbGroup.grp G)) ⟩
⊙EM-fmap G G (idhom (AbGroup.grp G)) n
=⟨ ⊙EM-fmap-idhom G n ⟩
⊙idf (⊙EM G n) =∎
⊙transport-⊙EM-uaᴬᴳ : ∀ {i} (G H : AbGroup i)
(iso : G ≃ᴬᴳ H) (n : ℕ)
→ ⊙transport (λ K → ⊙EM K n) (uaᴬᴳ G H iso) == ⊙EM-fmap G H (–>ᴳ iso) n
⊙transport-⊙EM-uaᴬᴳ G H iso n =
⊙transport (λ K → ⊙EM K n) (uaᴬᴳ G H iso)
=⟨ ⊙transport-⊙EM (uaᴬᴳ G H iso) n ⟩
⊙EM-fmap G H (coeᴬᴳ (uaᴬᴳ G H iso)) n
=⟨ ap (λ p → ⊙EM-fmap G H p n) (coeᴬᴳ-β G H iso) ⟩
⊙EM-fmap G H (–>ᴳ iso) n =∎
| {
"alphanum_fraction": 0.4600084153,
"avg_line_length": 41.963081862,
"ext": "agda",
"hexsha": "79b2bece79a1091d7b4662d43b7adf4bffd1adac",
"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/EilenbergMacLaneFunctor.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/EilenbergMacLaneFunctor.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/EilenbergMacLaneFunctor.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": 14647,
"size": 26143
} |
{-# OPTIONS --guardedness #-}
module Issue728 where
open import Common.MAlonzo using () renaming (main to mainDefault)
main = mainDefault
| {
"alphanum_fraction": 0.7446808511,
"avg_line_length": 17.625,
"ext": "agda",
"hexsha": "292c24a52c189729d15dfa928064f311ca54fd21",
"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/Compiler/simple/Issue728.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/Compiler/simple/Issue728.agda",
"max_line_length": 66,
"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/Compiler/simple/Issue728.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": 32,
"size": 141
} |
module Pi-.Everything where
open import Pi-.Syntax -- Syntax of Pi-
open import Pi-.Opsem -- Abstract machine semantics of Pi-
open import Pi-.AuxLemmas -- Some auxiliary lemmas about opsem for forward/backward deterministic proof
open import Pi-.NoRepeat -- Forward/backward deterministic lemmas and Non-repeating lemma
open import Pi-.Invariants -- Some invariants about abstract machine semantics
open import Pi-.Eval -- Evaluator for Pi-
open import Pi-.Interp -- Big-step intepreter for Pi-
open import Pi-.Properties -- Properties of Pi-
open import Pi-.Examples -- Examples
open import Pi-.Category -- Pi- Category
| {
"alphanum_fraction": 0.7370820669,
"avg_line_length": 54.8333333333,
"ext": "agda",
"hexsha": "1a64dc48bac7f97aa4dc617eca9da5532fd26ebb",
"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": "Pi-/Everything.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": "Pi-/Everything.agda",
"max_line_length": 105,
"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": "Pi-/Everything.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": 151,
"size": 658
} |
module Data.List.Exts where
open import Class.Equality
open import Class.Monad
open import Class.Functor
open import Data.Bool hiding (_≟_)
open import Data.List
open import Data.Maybe using (Maybe; just; nothing)
open import Data.Maybe.Instance
open import Data.Nat using (ℕ; zero; suc; _⊔_)
open import Data.Product
open import Relation.Nullary
open import Relation.Unary
private
variable
A : Set
lookupMaybe : ∀ {a} {A : Set a} -> ℕ -> List A -> Maybe A
lookupMaybe n [] = nothing
lookupMaybe zero (x ∷ l) = just x
lookupMaybe (suc n) (x ∷ l) = lookupMaybe n l
findIndexList : {A : Set} {P : A -> Set} -> Decidable P -> List A -> Maybe ℕ
findIndexList P? [] = nothing
findIndexList P? (x ∷ v) with P? x
... | yes p = just 0
... | no ¬p = suc <$> findIndexList P? v
dropHeadIfAny : ∀ {a} {A : Set a} -> List A -> List A
dropHeadIfAny [] = []
dropHeadIfAny (x ∷ l) = l
-- inverse to intercalate
{-# TERMINATING #-}
splitMulti : ∀ {A : Set} {{_ : Eq A}} -> A -> List A -> List (List A)
splitMulti a [] = []
splitMulti a l@(x ∷ xs) with break (a ≟_) l
... | fst , snd = fst ∷ splitMulti a (dropHeadIfAny snd)
takeEven : ∀ {a} {A : Set a} -> List A -> List A
takeEven [] = []
takeEven (x ∷ []) = []
takeEven (x ∷ x₁ ∷ l) = x₁ ∷ takeEven l
maximum : List ℕ → ℕ
maximum [] = 0
maximum (x ∷ l) = x ⊔ maximum l
mapWithIndex : ∀ {a b} {A : Set a} {B : Set b} → (ℕ → A → B) → List A → List B
mapWithIndex f l = zipWith f (upTo (length l)) l
isInit : ⦃ EqB A ⦄ → List A → List A → Bool
isInit [] l' = true
isInit (x ∷ l) [] = false
isInit (x ∷ l) (x₁ ∷ l') = x ≣ x₁ ∧ isInit l l'
| {
"alphanum_fraction": 0.6143667297,
"avg_line_length": 27.8421052632,
"ext": "agda",
"hexsha": "c0502fd8a0c8a3d8f3149dffef96221c0d90fabc",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
"max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "WhatisRT/meta-cedille",
"max_forks_repo_path": "stdlib-exts/Data/List/Exts.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "WhatisRT/meta-cedille",
"max_issues_repo_path": "stdlib-exts/Data/List/Exts.agda",
"max_line_length": 78,
"max_stars_count": 35,
"max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "WhatisRT/meta-cedille",
"max_stars_repo_path": "stdlib-exts/Data/List/Exts.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z",
"num_tokens": 568,
"size": 1587
} |
{-# OPTIONS --rewriting --prop #-}
open import common
open import syntx
open import derivability
open import structuralrules
open import typingrules
open import typetheories
module _ where
{- Π-Types + a dependent type -}
module _ where
TypingRuleΠ : TypingRule (TTDer ◇) ([] , (0 , Ty) , (1 , Ty)) Ty
TypingRuleΠ = Ty ([] , Ty []
, Ty ([] , (sym 0 [] / apr T 0 [])))
ΠUEl-TT1 : TypeTheory
ΠUEl-TT1 = ◇ , TypingRuleΠ
TypingRuleλ : TypingRule (TTDer ΠUEl-TT1) ([] , (0 , Ty) , (1 , Ty) , (1 , Tm)) Tm
TypingRuleλ = Tm ([] , Ty []
, Ty ([] , (sym 0 [] / apr T 0 []))
, Tm ([] , (sym 1 [] / apr T 1 []))
(sym 1 ([] , sym 0 []) /
apr T 1 ([] ,0Tm apr T 0 [])))
(sym 3 ([] , sym 2 [] , sym 1 ([] , var last)) /
apr T 3 ([] ,0Ty apr T 2 [] ,1Ty apr T 1 ([] ,0Tm apr S (var 0) ([] , apr T 2 []))))
ΠUEl-TT2 : TypeTheory
ΠUEl-TT2 = ΠUEl-TT1 , TypingRuleλ
TypingRuleapp : TypingRule (TTDer ΠUEl-TT2) ([] , (0 , Ty) , (1 , Ty) , (0 , Tm) , (0 , Tm)) Tm
TypingRuleapp = Tm ([] , Ty []
, Ty ([] , (sym 0 [] / apr T 0 []))
, Tm [] (sym 3 ([] , sym 1 [] , sym 0 ([] , var last)) /
apr T 3 ([] ,0Ty apr T 1 [] ,1Ty apr T 0 ([] ,0Tm apr S (var 0) ([] , apr T 1 []))))
, Tm [] (sym 2 [] / apr T 2 []))
(sym 2 ([] , sym 0 []) /
apr T 2 ([] ,0Tm apr T 0 []))
ΠUEl-TT3 : TypeTheory
ΠUEl-TT3 = ΠUEl-TT2 , TypingRuleapp
TypingRuleBeta : EqualityRule (TTDer ΠUEl-TT3) ([] , (0 , Ty) , (1 , Ty) , (1 , Tm) , (0 , Tm)) Tm
TypingRuleBeta = Tm= ([] , Ty []
, Ty ([] , sym 0 [] / apr T 0 [])
, Tm ([] , sym 1 [] / apr T 1 [])
(sym 1 ([] , sym 0 []) /
apr T 1 ([] ,0Tm apr T 0 []))
, Tm [] (sym 2 [] / apr T 2 []))
(sym 2 ([] , sym 0 []) <:
sym 4 ([] , sym 3 []
, sym 2 ([] , var last)
, sym 5 ([] , sym 3 [] , sym 2 ([] , var last) , sym 1 ([] , var last))
, sym 0 []) /
apr T 4 ([]
,0Ty apr T 3 []
,1Ty apr T 2 ([] ,0Tm apr S (var 0) ([] ,0Ty apr T 3 []))
,0Tm apr T 5 ([] ,0Ty apr T 3 []
,1Ty apr T 2 ([] ,0Tm apr S (var zero) ([] ,0Ty apr T 3 []))
,1Tm apr T 1 ([] ,0Tm apr S (var zero) ([] ,0Ty apr T 3 []))) {-{{((tt , (tt , tt)) , ((tt , refl) , tt)) , ((tt , refl) , (refl , tt)) , tt}}-}
,0Tm apr T 0 []) {-{{((((tt , (tt , tt)) , ((tt , refl) , tt)) , (tt , (refl , tt))) , (tt , (refl , tt))) , tt}}-}
// sym 1 ([] , sym 0 [])
/ apr T 1 ([] ,0Tm apr T 0 []))
ΠUEl-TT4 : TypeTheory
ΠUEl-TT4 = ΠUEl-TT3 ,= TypingRuleBeta
TypingRuleEta : EqualityRule (TTDer ΠUEl-TT4) ([] , (0 , Ty) , (1 , Ty) , (0 , Tm)) Tm
TypingRuleEta = Tm= ([] , Ty []
, Ty ([] , sym 0 [] / apr T 0 [])
, Tm [] (sym 4 ([] , sym 1 [] , sym 0 ([] , var last))
/ apr T 4 ([] ,0Ty apr T 1 [] ,1Ty apr T 0 ([] ,0Tm apr S (var 0) ([] ,0Ty apr T 1 [])))))
(sym 5 ([] , sym 2 [] , sym 1 ([] , var last))
<: sym 0 []
/ apr T 0 []
// sym 4 ([] , sym 2 [] , sym 1 ([] , var last) , sym 3 ([] , sym 2 [] , sym 1 ([] , var last) , sym 0 [] , var last))
/ apr T 4 ([] ,0Ty apr T 2 []
,1Ty apr T 1 ([] ,0Tm apr S (var 0) ([] ,0Ty apr T 2 []))
,1Tm apr T 3 ([] ,0Ty apr T 2 []
,1Ty apr T 1 ([] ,0Tm apr S (var 0) ([] ,0Ty apr T 2 []))
,0Tm apr T 0 []
,0Tm apr S (var 0) ([] ,0Ty apr T 2 []))))
ΠUEl-TT5 : TypeTheory
ΠUEl-TT5 = ΠUEl-TT4 ,= TypingRuleEta
TypingRuleU : TypingRule (TTDer ΠUEl-TT5) [] Ty
TypingRuleU = Ty []
ΠUEl-TT6 : TypeTheory
ΠUEl-TT6 = ΠUEl-TT5 , TypingRuleU
TypingRuleEl : TypingRule (TTDer ΠUEl-TT6) ([] , (0 , Tm)) Ty
TypingRuleEl = Ty ([] , Tm [] (sym 0 [] / apr T 0 []))
ΠUEl-TT : TypeTheory
ΠUEl-TT = ΠUEl-TT6 , TypingRuleEl
-- {- Natural numbers -}
-- module _ where
-- TypingRuleℕ : TypingRule (TTDer ◇) [] Ty
-- TypingRuleℕ = Ty []
-- ℕ-TT0 : TypeTheory
-- ℕ-TT0 = ◇ , TypingRuleℕ
-- TypingRule0 : TypingRule (TTDer ℕ-TT0) [] Tm
-- TypingRule0 = Tm [] (sym 0 [] / apr T 0 [])
-- ℕ-TT1 : TypeTheory
-- ℕ-TT1 = ℕ-TT0 , TypingRule0
-- TypingRuleS : TypingRule (TTDer ℕ-TT1) ([] , (0 , Tm)) Tm
-- TypingRuleS = Tm ([] , Tm [] (sym 1 [] / apr T 1 []))
-- (sym 2 [] / apr T 2 [])
-- ℕ-TT2 : TypeTheory
-- ℕ-TT2 = ℕ-TT1 , TypingRuleS
-- TypingRuleℕ-elim : TypingRule (TTDer ℕ-TT2) ([] , (1 , Ty) , (0 , Tm) , (2 , Tm) , (0 , Tm)) Tm
-- TypingRuleℕ-elim = Tm ([] , Ty ([] , sym 2 [] / apr T 2 [])
-- , Tm [] (sym 0 ([] , sym 2 []) / apr T 0 ([] ,0Tm apr T 2 []))
-- , Tm ([] , sym 4 [] / apr T 4 []
-- , sym 2 ([] , sym 0 []) / apr T 2 ([] ,0Tm apr T 0 []))
-- (sym 3 ([] , sym 4 ([] , sym 1 [])) /
-- apr T 3 ([] ,0Tm apr T 4 ([] ,0Tm apr T 1 [])))
-- , Tm [] (sym 5 [] / apr T 5 []))
-- (sym 3 ([] , (sym 0 [])) / apr T 3 ([] ,0Tm apr T 0 []))
-- ℕ-TT3 : TypeTheory
-- ℕ-TT3 = ℕ-TT2 , TypingRuleℕ-elim
-- TypingRuleℕ0-β : EqualityRule (TTDer ℕ-TT3) ([] , (1 , Ty) , (0 , Tm) , (2 , Tm)) Tm
-- TypingRuleℕ0-β = Tm= ([] , Ty ([] , (sym 3 [] / apr T 3 []))
-- , Tm [] (sym 0 ([] , sym 3 []) / apr T 0 ([] ,0Tm apr T 3 []))
-- , Tm ([] , (sym 5 [] / apr T 5 [])
-- , (sym 2 ([] , sym 0 []) / apr T 2 ([] ,0Tm apr T 0 [])))
-- (sym 3 ([] , sym 5 ([] , sym 1 [])) / apr T 3 ([] ,0Tm apr T 5 ([] ,0Tm apr T 1 []))))
-- (sym 2 ([] , sym 5 []) <: sym 3 ([] , sym 2 ([] , var last) , sym 1 [] , sym 0 ([] , var (prev last) , var last) , sym 5 [])
-- / apr T 3 ([] ,1Ty apr T 2 ([] ,0Tm apr S (var 0) ([] ,0Ty apr T 6 []))
-- ,0Tm apr T 1 []
-- ,2Tm apr T 0 ([] ,0Tm apr S (var 1) ([] ,0Ty apr T 6 [])
-- ,0Tm apr S (var 0) ([] ,0Ty apr T 2 ([] ,0Tm apr S (var 1) ([] ,0Ty apr T 6 []))))
-- ,0Tm apr T 5 [])
-- // sym 1 []
-- / apr T 1 [])
-- ℕ-TT4 : TypeTheory
-- ℕ-TT4 = ℕ-TT3 ,= TypingRuleℕ0-β
-- TypingRuleℕS-β : EqualityRule (TTDer ℕ-TT4) ([] , (1 , Ty) , (0 , Tm) , (2 , Tm) , (0 , Tm)) Tm
-- TypingRuleℕS-β = Tm= ([] , Ty ([] , (sym 3 [] / apr T 3 []))
-- , Tm [] (sym 0 ([] , sym 3 []) / apr T 0 ([] ,0Tm apr T 3 []))
-- , Tm ([] , (sym 5 [] / apr T 5 [])
-- , (sym 2 ([] , sym 0 []) / apr T 2 ([] ,0Tm apr T 0 [])))
-- (sym 3 ([] , sym 5 ([] , sym 1 [])) / apr T 3 ([] ,0Tm apr T 5 ([] ,0Tm apr T 1 [])))
-- , Tm [] (sym 6 [] / apr T 6 []))
-- (sym 3 ([] , sym 5 ([] , sym 0 []))
-- <: sym 4 ([] , sym 3 ([] , var last) , sym 2 [] , sym 1 ([] , var (prev last) , var last) , sym 5 ([] , sym 0 []))
-- / apr T 4 ([] ,1Ty apr T 3 ([] ,0Tm apr S (var 0) ([] ,0Ty apr T 7 [])) ,0Tm apr T 2 [] ,2Tm apr T 1 ([] ,0Tm apr S (var 1) ([] ,0Ty apr T 7 []) ,0Tm (apr S (var 0) ([] ,0Ty apr T 3 ([] ,0Tm apr S (var 1) ([] ,0Ty apr T 7 []))))) ,0Tm apr T 5 ([] ,0Tm apr T 0 []))
-- // sym 1 ([] , sym 0 [] , sym 4 ([] , sym 3 ([] , var last) , sym 2 [] , sym 1 ([] , var (prev last) , var last) , sym 0 []))
-- / apr T 1 ([] ,0Tm apr T 0 [] ,0Tm apr T 4 ([] ,1Ty apr T 3 ([] ,0Tm apr S (var 0) ([] ,0Ty apr T 7 [])) ,0Tm apr T 2 [] ,2Tm apr T 1 ([] ,0Tm apr S (var 1) ([] ,0Ty apr T 7 []) ,0Tm (apr S (var 0) ([] ,0Ty apr T 3 ([] ,0Tm apr S (var 1) ([] ,0Ty apr T 7 []))))) ,0Tm apr T 0 [])))
-- ℕ-TT5 : TypeTheory
-- ℕ-TT5 = ℕ-TT4 ,= TypingRuleℕS-β
| {
"alphanum_fraction": 0.3402530003,
"avg_line_length": 53.773255814,
"ext": "agda",
"hexsha": "b854f765f3b3bc16fc2d46cd50faf6079eb281e5",
"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": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guillaumebrunerie/general-type-theories",
"max_forks_repo_path": "examples.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"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": "guillaumebrunerie/general-type-theories",
"max_issues_repo_path": "examples.agda",
"max_line_length": 309,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guillaumebrunerie/general-type-theories",
"max_stars_repo_path": "examples.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3211,
"size": 9249
} |
-- agad-modeの使い方
-- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html
{-# OPTIONS --without-K --safe #-}
module Learn.Interactive where
-- ロード
-- タイプチェックする
-- C-c C-l
-- Ctrlを押しながら、cを押して次にlを押す
-- このとき、ソース内に"?"が存在すればそれをゴールにする
-- ゴールには番号が振られる
-- 型推論する
-- C-c C-d
-- 評価する
-- C-c C-n
-- 終了させる
-- C-c C-x C-q
-- Ctrlを押しながら、c、x、qと押す
-- 再スタートさせる
-- C-c C-x C-r
----------------------------------------------------------------------------
-- ゴールへの操作
-- ゴール内に値を書いてからゴールにカーソルを合わせ実行する。
-- 与える
-- C-c C-SPC
-- Ctrlを押しながら、cを押して次にスペースを押す
-- 型が合っていればゴールは消える
-- リファイン
-- C-c C-r
-- 何もない状態で行うと関数ならラムダ、レコード型ならコンストラクタを挿入する
-- ゴールに関数がある場合、関数の引数をゴールにする
-- ケーススプリット
-- C-c C-c
-- ゴール内に変数を書く、またはC-c C-cして出てきた入力枠に変数を入力すると
-- その変数でパターンマッチングを行う
-- ゴールの型を確認する
-- C-c C-t
-- 環境を確認する
-- C-c C-e
----------------------------------------------------------------------------
-- 自然数
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
-- 等価性
infix 3 _≡_
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
cong : ∀ {A B : Set} (f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
-- 足し算
-- 右辺に?と書いてC-c C-l(ロード)する
-- モジュールは無視で
module Step1 where
_+_ : ℕ → ℕ → ℕ
m + n = {! !}
-- ゴールに"m"と入力する
module Step2 where
_+_ : ℕ → ℕ → ℕ
m + n = {! m !}
-- ゴールにカーソルを合わせ C-c C-c (ケーススプリット)する
module Step3 where
_+_ : ℕ → ℕ → ℕ
zero + n = {! !}
suc m + n = {! !}
-- インデントを整える
module Step4 where
_+_ : ℕ → ℕ → ℕ
zero + n = {! !}
suc m + n = {! !}
-- ゴール内に右辺値を書く
module Step5 where
_+_ : ℕ → ℕ → ℕ
zero + n = {! zero !}
suc m + n = {! !}
-- ゴールにカーソルを合わせ C-c C-SPC (Give)する
module Step6 where
_+_ : ℕ → ℕ → ℕ
zero + n = zero
suc m + n = {! !}
-- もう一方のゴールも同様にする
-- このときmは再帰的な呼び出しをするときに小さくなっている
_+_ : ℕ → ℕ → ℕ
zero + n = zero
suc m + n = suc (m + n)
-- +の結合性
-- 証明したい型を書く。右辺を?にしてゴールにする
module Assoc1 where
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
+-assoc m n o = {! !}
-- このとき+の定義から+の左の変数で帰納するとよいとわかる
-- 単一の変数であるならばパターンマッチングできるのでmを選びゴールに書く
module Assoc2 where
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
+-assoc m n o = {! m !}
-- C-c C-cする
-- ここで +-assoc zero n o の右辺のゴールでC-c C-tすると zero ≡ zero とわかる
-- 同じ形ならreflが使えるのでreflをC-c C-SPCする
module Assoc3 where
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
+-assoc zero n o = refl
+-assoc (suc m) n o = {! !}
-- 次に +-assoc (suc m) n o の右辺でC-c C-tすると
-- suc ((m + n) + o) ≡ suc (m + (n + o)) とわかる
-- 両辺に同じ関数(suc)が掛かっているのでcongが使える
-- congとゴール内に書く
module Assoc4 where
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
+-assoc zero n o = refl
+-assoc (suc m) n o = {!cong !}
-- C-c C-rするとゴールが分かれる
-- 前はsucを与える
module Assoc5 where
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
+-assoc zero n o = refl
+-assoc (suc m) n o = cong suc {! !}
-- 後ろは+-assoc m n oの型と同じなのでそれを与える
-- これで証明終了
module Assoc6 where
+-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o)
+-assoc zero n o = refl
+-assoc (suc m) n o = cong suc (+-assoc m n o)
| {
"alphanum_fraction": 0.5262089956,
"avg_line_length": 19.8456375839,
"ext": "agda",
"hexsha": "ebe13bcc8c0492b1a2da3128e5c14745c0a7ba29",
"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": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "Learn/Interactive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"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": "rei1024/agda-misc",
"max_issues_repo_path": "Learn/Interactive.agda",
"max_line_length": 76,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "Learn/Interactive.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 1652,
"size": 2957
} |
module Ual.Both where
infix 10 _∧_
record _∧_ (A B : Set) : Set where
field
andL : A
andR : B
| {
"alphanum_fraction": 0.6,
"avg_line_length": 13.125,
"ext": "agda",
"hexsha": "d1083a00739c6f6e4a02b4ac8029fc9f3e629716",
"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": "ea0260e1a0612ba581e4283dfb187f531a944dfd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "brunoczim/ual",
"max_forks_repo_path": "Both.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd",
"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": "brunoczim/ual",
"max_issues_repo_path": "Both.agda",
"max_line_length": 34,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ea0260e1a0612ba581e4283dfb187f531a944dfd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "brunoczim/ual",
"max_stars_repo_path": "Both.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 45,
"size": 105
} |
{-# OPTIONS --without-K #-}
open import Function
open import Data.Zero
open import Relation.Binary.PropositionalEquality.NP
open import Explore.Zero
import Explore.Universe.Type
import Explore.Universe
open import Function.Extensionality
open import Type.Identities
open import HoTT
open Equivalences
module Explore.Universe.Base
(open Explore.Universe.Type {𝟘})
(u : U) where
open Explore.Universe 𝟘
open FromKit 𝟘ⁱ (λ {{ua}}{{_}} → 𝟘ˢ-ok {{ua}}) 𝟘ˡ 𝟘ᶠ
(λ {{ua}} → Σᵉ𝟘-ok {{ua}})
Πᵉ𝟘-ok (λ {ℓ₀ ℓ₁} ℓᵣ → ⟦𝟘ᵉ⟧ {ℓ₀} {ℓ₁} {ℓᵣ} {_≡_})
(const 𝟙ᵁ) (λ {{ua}} {{fext}} v → equiv (λ _ ()) _ (λ f → λ= (λ())) (λ _ → refl))
u public
| {
"alphanum_fraction": 0.6255506608,
"avg_line_length": 28.375,
"ext": "agda",
"hexsha": "c17b379c7980172ee8897972f549c996f2538d81",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crypto-agda/explore",
"max_forks_repo_path": "lib/Explore/Universe/Base.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "crypto-agda/explore",
"max_issues_repo_path": "lib/Explore/Universe/Base.agda",
"max_line_length": 94,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crypto-agda/explore",
"max_stars_repo_path": "lib/Explore/Universe/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
"num_tokens": 265,
"size": 681
} |
-- Andreas, 2019-02-23, re #3578, less reduction in the unifier.
-- Non-interactive version of interaction/Issue635c.agda.
-- {-# OPTIONS -v tc.lhs.unify:50 #-}
open import Common.Bool
open import Common.Equality
open import Common.Product
test : (p : Bool × Bool) → proj₁ p ≡ true → Set
test _ refl = Bool
-- Tests that the unifier does the necessary weak head reduction.
| {
"alphanum_fraction": 0.7188328912,
"avg_line_length": 26.9285714286,
"ext": "agda",
"hexsha": "ea5f8961a2b5760c2eff4a34e9c40bf30572a650",
"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/Issue635.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/Issue635.agda",
"max_line_length": 65,
"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/Issue635.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": 105,
"size": 377
} |
{-# OPTIONS --without-K --safe #-}
module Fragment.Examples.Semigroup.Arith.Functions where
open import Fragment.Examples.Semigroup.Arith.Base
-- Fully dynamic associativity
+-dyn-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → (f m + n) + o ≡ f m + (n + o)
+-dyn-assoc₁ = fragment SemigroupFrex +-semigroup
+-dyn-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → ((f m + n) + o) + g p ≡ f m + (n + (o + g p))
+-dyn-assoc₂ = fragment SemigroupFrex +-semigroup
+-dyn-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m + n) + g o + (p + h q) ≡ f m + (n + g o + p) + h q
+-dyn-assoc₃ = fragment SemigroupFrex +-semigroup
*-dyn-assoc₁ : ∀ {f : ℕ → ℕ} {m n o} → (f m * n) * o ≡ f m * (n * o)
*-dyn-assoc₁ = fragment SemigroupFrex *-semigroup
*-dyn-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → ((f m * n) * o) * g p ≡ f m * (n * (o * g p))
*-dyn-assoc₂ = fragment SemigroupFrex *-semigroup
*-dyn-assoc₃ : ∀ {f g h : ℕ → ℕ} {m n o p q} → (f m * n) * g o * (p * h q) ≡ f m * (n * g o * p) * h q
*-dyn-assoc₃ = fragment SemigroupFrex *-semigroup
-- Partially static associativity
+-sta-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (m + 2) + (3 + f 0) ≡ m + (5 + f 0)
+-sta-assoc₁ = fragment SemigroupFrex +-semigroup
+-sta-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → (((f m + g n) + 5) + o) + p ≡ f m + (g n + (2 + (3 + (o + p))))
+-sta-assoc₂ = fragment SemigroupFrex +-semigroup
+-sta-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p} → f (n + m) + (n + 2) + (3 + (o + p)) ≡ f (n + m) + (((n + 1) + (4 + o)) + p)
+-sta-assoc₃ = fragment SemigroupFrex +-semigroup
*-sta-assoc₁ : ∀ {f : ℕ → ℕ} {m} → (m * 2) * (3 * f 0) ≡ m * (6 * f 0)
*-sta-assoc₁ = fragment SemigroupFrex *-semigroup
*-sta-assoc₂ : ∀ {f g : ℕ → ℕ} {m n o p} → (((f m * g n) * 6) * o) * p ≡ f m * (g n * (2 * (3 * (o * p))))
*-sta-assoc₂ = fragment SemigroupFrex *-semigroup
*-sta-assoc₃ : ∀ {f : ℕ → ℕ} {m n o p} → f (n + m) * (n * 4) * (3 * (o * p)) ≡ f (n + m) * (((n * 2) * (6 * o)) * p)
*-sta-assoc₃ = fragment SemigroupFrex *-semigroup
| {
"alphanum_fraction": 0.5061983471,
"avg_line_length": 42.0869565217,
"ext": "agda",
"hexsha": "dbe8368a033566bff61aa0e9b63359ee3f9430fa",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z",
"max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "yallop/agda-fragment",
"max_forks_repo_path": "src/Fragment/Examples/Semigroup/Arith/Functions.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "yallop/agda-fragment",
"max_issues_repo_path": "src/Fragment/Examples/Semigroup/Arith/Functions.agda",
"max_line_length": 116,
"max_stars_count": 18,
"max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yallop/agda-fragment",
"max_stars_repo_path": "src/Fragment/Examples/Semigroup/Arith/Functions.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z",
"num_tokens": 862,
"size": 1936
} |
-- Abstract definitions can't be projection-like
module Issue447 where
postulate
I : Set
R : I → Set
module M (i : I) (r : R i) where
abstract
P : Set₂
P = Set₁
p : P
p = Set
| {
"alphanum_fraction": 0.5792079208,
"avg_line_length": 11.8823529412,
"ext": "agda",
"hexsha": "38fac901e1e7139cd21e422f40307f69d8c0598e",
"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/Issue447.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/Issue447.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/Succeed/Issue447.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": 69,
"size": 202
} |
module Rationals where
open import Nats renaming (_+_ to _:+:_; _*_ to _:*:_)
open import Equality
open import Data.Product
open import Agda.Builtin.TrustMe
infixl 7 _÷_
infixr 5 _→ℕ
infixr 7 _÷_↓_
infixr 7 _÷_↑_
infixl 6 _+_
data ℚ : Set where
_÷_ : (a b : ℕ) → ℚ
_→ℕ : {a : ℕ} → ℚ → ∃ (λ m → m ≡ a)
_→ℕ {a} _ = a , refl
-- of course.
_÷_↓_ : ∀ a b n → (a :*: n ÷ (b :*: n)) ≡ a ÷ b
_ ÷ _ ↓ _ = primTrustMe
_÷_↑_ : ∀ a b n → a ÷ b ≡ (a :*: n ÷ (b :*: n))
a ÷ b ↑ n = sym (a ÷ b ↓ n)
_+_ : ℚ → ℚ → ℚ
a ÷ c + b ÷ d = (a :*: d :+: b :*: c) ÷ (c :*: d)
_*_ : ℚ → ℚ → ℚ
(a ÷ c) * (b ÷ d) = a :*: b ÷ (c :*: d)
_/_ : ℚ → ℚ → ℚ
(a ÷ c) / (b ÷ d) = a :*: d ÷ (c :*: b)
| {
"alphanum_fraction": 0.4472511144,
"avg_line_length": 19.2285714286,
"ext": "agda",
"hexsha": "4ae837d83d313f179fa4b7fe7e64cc04858a3593",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ice1k/Theorems",
"max_forks_repo_path": "src/Rationals.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "ice1k/Theorems",
"max_issues_repo_path": "src/Rationals.agda",
"max_line_length": 54,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ice1k/Theorems",
"max_stars_repo_path": "src/Rationals.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z",
"num_tokens": 363,
"size": 673
} |
module Implicits.Resolution.Infinite.Expressiveness where
open import Prelude hiding (Bool)
open import Data.Fin.Substitution
open import Data.List
open import Data.List.Any
open Membership-≡
open import Extensions.ListFirst
open import SystemF.Everything as F using ()
open import Implicits.Resolution.Ambiguous.Resolution as A
open import Implicits.Resolution.Deterministic.Resolution as D
open import Implicits.Resolution.Infinite.Resolution as I
open import Implicits.Syntax
open import Implicits.Substitutions
module Deterministic⊆Infinite where
complete : ∀ {ν} {a : Type ν} {Δ : ICtx ν} → Δ D.⊢ᵣ a → Δ I.⊢ᵣ a
complete (r-simp x r↓a) = r-simp (proj₁ $ first⟶∈ x) (lem r↓a)
where
lem : ∀ {ν} {Δ : ICtx ν} {r a} → Δ D.⊢ r ↓ a → Δ I.⊢ r ↓ a
lem (i-simp a) = i-simp a
lem (i-iabs x₁ x₂) = i-iabs (complete x₁) (lem x₂)
lem (i-tabs b x₁) = i-tabs b (lem x₁)
complete (r-iabs ρ₁ x) = r-iabs (complete x)
complete (r-tabs x) = r-tabs (complete x)
module Deterministic⊂Infinite where
open import Implicits.Resolution.Deterministic.Incomplete as Inc
-- We gave an example of a query that the det rules could not resolve
-- ((Int ⇒ Bool) List.∷ Bool List.∷ List.[]) ⊢ᵣ Bool
-- Here we derive it for the Infinite rules, to prove that we are strictly
-- more expressive
infinite-can : Δ I.⊢ᵣ Bool
infinite-can = r-simp (there (here refl)) p
where
p : Δ I.⊢ Bool ↓ tc 0
p = i-simp (tc 0)
module Infinite⇔Ambiguous
(nf : ∀ {ν n} {Γ : F.Ctx ν n} {t a} → Γ F.⊢ t ∈ a → ∃ λ (t₂ : F.Term ν n) → Γ F.⊢ t₂ ⇑ a)
where
open import Implicits.Resolution.Ambiguous.SystemFEquiv hiding (equivalent)
open import Implicits.Resolution.Infinite.NormalFormEquiv hiding (equivalent)
open import Implicits.Resolution.Embedding.Lemmas
open import Function.Equivalence
sound : ∀ {ν} {a : Type ν} {Δ : ICtx ν} → Δ I.⊢ᵣ a → Δ A.⊢ᵣ a
sound (r-simp x p) = lem p (r-ivar x)
where
lem : ∀ {ν} {Δ : ICtx ν} {a τ} → Δ I.⊢ a ↓ τ → Δ A.⊢ᵣ a → Δ A.⊢ᵣ (simpl τ)
lem (i-simp τ) ⊢y = ⊢y
lem (i-iabs ⊢a b↓τ) ⊢b = lem b↓τ (r-iapp ⊢b (sound ⊢a))
lem (i-tabs b a) ⊢y = lem a (r-tapp b ⊢y)
sound (r-iabs p) = r-iabs (sound p)
sound (r-tabs p) = r-tabs (sound p)
complete : ∀ {ν} {a : Type ν} {Δ : ICtx ν} → Δ A.⊢ᵣ a → Δ I.⊢ᵣ a
complete {a = a} p = subst₂ (λ Δ r → Δ I.⊢ᵣ r) (ctx→← _) (tp→← a) (from-⇑ (proj₂ (nf (to-⊢ p))))
equivalent : ∀ {ν} (Δ : ICtx ν) r → Δ I.⊢ᵣ r ⇔ Δ A.⊢ᵣ r
equivalent Δ r = equivalence sound complete
| {
"alphanum_fraction": 0.6332537788,
"avg_line_length": 36.4347826087,
"ext": "agda",
"hexsha": "e0127839af4282d15185e7cd1fe7ad5893765c32",
"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/Implicits/Resolution/Infinite/Expressiveness.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/Implicits/Resolution/Infinite/Expressiveness.agda",
"max_line_length": 98,
"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/Implicits/Resolution/Infinite/Expressiveness.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": 995,
"size": 2514
} |
module Issue493 where
module M where
postulate A B C : Set
open M using (A) hiding (B)
| {
"alphanum_fraction": 0.6956521739,
"avg_line_length": 11.5,
"ext": "agda",
"hexsha": "32dc9c47bb26c0508426d21ccdb3e603f2e8d567",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue493.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/Issue493.agda",
"max_line_length": 27,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/Issue493.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": 29,
"size": 92
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Rings.Definition
open import Rings.IntegralDomains.Definition
open import Fields.Fields
open import Setoids.Setoids
open import Sets.EquivalenceRelations
module Fields.FieldOfFractions.Field {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where
open import Fields.FieldOfFractions.Ring I
fieldOfFractions : Field fieldOfFractionsRing
Field.allInvertible fieldOfFractions (record { num = fst ; denom = b }) prA = (record { num = b ; denom = fst ; denomNonzero = ans }) , need
where
abstract
open Setoid S
open Equivalence eq
need : ((b * fst) * Ring.1R R) ∼ ((fst * b) * Ring.1R R)
need = Ring.*WellDefined R (Ring.*Commutative R) reflexive
ans : fst ∼ Ring.0R R → False
ans pr = prA need'
where
need' : (fst * Ring.1R R) ∼ (b * Ring.0R R)
need' = transitive (Ring.*WellDefined R pr reflexive) (transitive (transitive (Ring.*Commutative R) (Ring.timesZero R)) (symmetric (Ring.timesZero R)))
Field.nontrivial fieldOfFractions pr = IntegralDomain.nontrivial I (symmetric (transitive (symmetric (Ring.timesZero R)) (transitive (Ring.*Commutative R) (transitive pr (Ring.identIsIdent R)))))
where
open Setoid S
open Equivalence eq
pr' : (Ring.0R R) * (Ring.1R R) ∼ (Ring.1R R) * (Ring.1R R)
pr' = pr
| {
"alphanum_fraction": 0.6643788607,
"avg_line_length": 42.8529411765,
"ext": "agda",
"hexsha": "3a6d1afebd50978c95846c1a9cbc9dcb03686d37",
"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": "Fields/FieldOfFractions/Field.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": "Fields/FieldOfFractions/Field.agda",
"max_line_length": 195,
"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": "Fields/FieldOfFractions/Field.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": 459,
"size": 1457
} |
module Data.List.Combinatorics.Proofs where
import Lvl
open import Data
open import Data.List
open import Data.List.Combinatorics
open import Data.List.Functions hiding (skip) renaming (module LongOper to List)
open Data.List.Functions.LongOper
open import Data.List.Relation.Permutation
open import Data.List.Relation.Quantification
open import Data.List.Relation.Quantification.Proofs
open import Data.List.Relation.Sublist
open import Data.List.Relation.Sublist.Proofs
open import Data.List.Proofs
open import Data.List.Equiv.Id
open import Data.List.Proofs.Length
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
import Data.Tuple.Raiseᵣ as Tuple₊
import Data.Tuple.Raiseᵣ.Functions as Tuple₊
open import Functional
open import Logic.Propositional
open import Numeral.Natural
open import Numeral.Natural.Combinatorics
open import Numeral.Natural.Combinatorics.Proofs
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Proofs
open import Numeral.Natural.Oper.Proofs.Multiplication
open import Numeral.Natural.Oper.Proofs.Order
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs.Equiv
open import Structure.Function
open import Structure.Operator
open import Structure.Operator.Properties
open import Structure.Relator.Properties
open import Syntax.Function
open import Syntax.Transitivity
open import Type
private variable ℓ ℓ₁ ℓ₂ : Lvl.Level
private variable T A B : Type{ℓ}
private variable l l₁ l₂ : List(T)
private variable x : T
private variable n k : ℕ
sublists₊-contains-sublists : AllElements (_⊑ l) (sublists₊(l))
sublists₊-contains-sublists {l = ∅} = ∅
sublists₊-contains-sublists {l = x ⊰ l} with sublists₊(l) | sublists₊-contains-sublists {l = l}
... | ∅ | _ = use [⊑]-minimum ⊰ ∅
... | sx ⊰ sl | px ⊰ pl = use [⊑]-minimum ⊰ skip px ⊰ use px ⊰ p pl where
p : ∀{x : T}{l}{sl} → AllElements (_⊑ l) sl → AllElements (_⊑ (x ⊰ l)) (concatMap(y ↦ y ⊰ (x ⊰ y) ⊰ ∅) sl)
p {sl = ∅} ∅ = ∅
p {sl = _ ⊰ _} (sll ⊰ alsl) = (skip sll) ⊰ (use sll) ⊰ (p alsl)
{-
sublists₊-contains-all-nonempty-sublists : ∀{x}{l₁ l₂ : List(T)} → (x ⊰ l₁ ⊑ l₂) → ExistsElement (_≡ x ⊰ l₁) (sublists(l₂))
sublists₊-contains-all-nonempty-sublists {l₁ = l₁} {prepend x l₂} (use p) = ⊰ (• {!!})
sublists₊-contains-all-nonempty-sublists {l₁ = l₁} {prepend x l₂} (skip p) = ⊰ (⊰ {!sublists₊-contains-all-nonempty-sublists ?!})
sublists-contains-all-sublists : ∀{l₁ l₂ : List(T)} → (l₁ ⊑ l₂) → ExistsElement (_≡ l₁) (sublists(l₂))
sublists-contains-all-sublists {l₁ = ∅} {∅} _⊑_.empty = • [≡]-intro
sublists-contains-all-sublists {l₁ = ∅} {prepend x l₂} (skip sub) = • [≡]-intro
sublists-contains-all-sublists {l₁ = prepend x l₁} {prepend .x l₂} (use sub) = ⊰ (⊰ {!!})
sublists-contains-all-sublists {l₁ = prepend x l₁} {prepend x₁ l₂} (skip sub) = {!!}
-}
permutes-insertedEverywhere : AllElements (_permutes (x ⊰ l)) (insertedEverywhere x l)
permutes-insertedEverywhere {x = x} {∅} = _permutes_.prepend _permutes_.empty ⊰ ∅
permutes-insertedEverywhere {x = x} {y ⊰ l} = reflexivity(_permutes_) ⊰ AllElements-mapᵣ(y List.⊰_) (p ↦ trans (_permutes_.prepend p) _permutes_.swap) (permutes-insertedEverywhere {x = x} {l})
{-
AllElements-insertedEverywhere-function : ∀{P : List(T) → Type{ℓ}} → (∀{l₁ l₂}{x} → (l₁ permutes l₂) → (P(x ⊰ l₁) → P(x ⊰ l₂))) → (∀{l₁ l₂} → (l₁ permutes l₂) → (P(l₁) → P(l₂))) → (∀{l₁ l₂ : List(T)} → (l₁ permutes l₂) → (AllElements P (insertedEverywhere x l₁) → AllElements P (insertedEverywhere x l₂)))
AllElements-insertedEverywhere-function _ pperm {l₁ = ∅} {∅} _permutes_.empty p@(_ ⊰ _) = p
AllElements-insertedEverywhere-function t pperm {l₁ = x ⊰ l₁} {.x ⊰ l₂} (_permutes_.prepend perm) (p ⊰ pl) =
pperm (_permutes_.prepend (_permutes_.prepend perm)) p ⊰
{!AllElements-insertedEverywhere-function t pperm {l₁ = l₁} {l₂} perm!} -- TODO: Probably needs more assumptions
-- AllElements-insertedEverywhere-function {l₁ = l₁} {l₂} pperm perm (AllElements-without-map {!!} {!!} pl)
-- AllElements-map (x List.⊰_) (\{l} → {!!}) (AllElements-insertedEverywhere-function {l₁ = l₁} {l₂} pperm perm {!!})
AllElements-insertedEverywhere-function _ pperm {l₁ = x ⊰ .(x₁ ⊰ _)} {x₁ ⊰ .(x ⊰ _)} _permutes_.swap (p₁ ⊰ p₂ ⊰ pl) =
pperm (trans _permutes_.swap (_permutes_.prepend _permutes_.swap)) p₂ ⊰
pperm (trans (_permutes_.prepend _permutes_.swap) _permutes_.swap) p₁ ⊰
{!!}
AllElements-insertedEverywhere-function t pperm (trans perm₁ perm₂) = AllElements-insertedEverywhere-function t pperm perm₂ ∘ AllElements-insertedEverywhere-function t pperm perm₁
-}
permutations-contains-permutations : AllElements (_permutes l) (permutations(l))
permutations-contains-permutations {l = ∅} = _permutes_.empty ⊰ ∅
permutations-contains-permutations {l = x ⊰ ∅} = _permutes_.prepend _permutes_.empty ⊰ ∅
permutations-contains-permutations {l = x ⊰ y ⊰ l} = AllElements-concatMap(insertedEverywhere x) (perm ↦ AllElements-of-transitive-binary-relationₗ (_permutes_.prepend perm) permutes-insertedEverywhere) (permutations-contains-permutations {l = y ⊰ l})
sublists₊-length : length(sublists₊ l) ≡ (2 ^ (length l)) −₀ 1
sublists₊-length {l = ∅} = [≡]-intro
sublists₊-length {l = x ⊰ l} =
length(sublists₊ (x ⊰ l)) 🝖[ _≡_ ]-[]
length(singleton(x) ⊰ foldᵣ (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest)) ∅ (sublists₊ l)) 🝖[ _≡_ ]-[]
𝐒(length(foldᵣ (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest)) ∅ (sublists₊ l))) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (length-foldᵣ {l = sublists₊(l)}{init = ∅}{f = (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest))}{g = const(𝐒 ∘ 𝐒)} [≡]-intro) ]
𝐒(foldᵣ (prev ↦ rest ↦ 𝐒(𝐒(rest))) 𝟎 (sublists₊ l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (foldᵣ-constant-[+]ᵣ{l = sublists₊ l}{init = 𝟎}) ]
𝐒(2 ⋅ length(sublists₊ l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒 ∘ (2 ⋅_)) (sublists₊-length {l = l}) ]
𝐒(2 ⋅ (2 ^ (length l) −₀ 1)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (distributivityₗ(_⋅_)(_−₀_) {2}{2 ^ length(l)}{1}) ]
𝐒((2 ⋅ (2 ^ (length l))) −₀ 2) 🝖[ _≡_ ]-[]
𝐒((2 ^ 𝐒(length l)) −₀ 2) 🝖[ _≡_ ]-[]
𝐒((2 ^ length(x ⊰ l)) −₀ 2) 🝖[ _≡_ ]-[ [↔]-to-[→] [−₀][𝐒]ₗ-equality ([^]ₗ-strictly-growing {0}{0}{𝐒(length l)} [≤]-with-[𝐒]) ]-sym
𝐒(2 ^ length(x ⊰ l)) −₀ 2 🝖[ _≡_ ]-[]
(2 ^ length (x ⊰ l)) −₀ 1 🝖-end
sublists-length : length(sublists l) ≡ 2 ^ (length l)
sublists-length {l = l} =
length(sublists l) 🝖[ _≡_ ]-[]
length(∅ ⊰ sublists₊ l) 🝖[ _≡_ ]-[]
𝐒(length(sublists₊ l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (sublists₊-length {l = l}) ]
𝐒((2 ^ length(l)) −₀ 1) 🝖[ _≡_ ]-[ [↔]-to-[→] [−₀][𝐒]ₗ-equality ([^]ₗ-growing {2}{0}{length l} (\()) [≤]-minimum) ]-sym
𝐒(2 ^ length(l)) −₀ 1 🝖[ _≡_ ]-[]
2 ^ length(l) 🝖-end
combinations-length : length(combinations k l) ≡ 𝑐𝐶(length(l))(k)
combinations-length {0} {l = _} = [≡]-intro
combinations-length {𝐒 k} {l = ∅} = [≡]-intro
combinations-length {1} {l = x ⊰ l} =
length(combinations 1 (x ⊰ l)) 🝖[ _≡_ ]-[]
length(x ⊰ l) 🝖[ _≡_ ]-[]
𝐒(length l) 🝖[ _≡_ ]-[ 𝑐𝐶-singleton-subsets ]-sym
𝐒(𝑐𝐶 (length l) 1) 🝖[ _≡_ ]-[]
1 + 𝑐𝐶 (length l) 1 🝖[ _≡_ ]-[]
𝑐𝐶 (length l) 0 + 𝑐𝐶 (length l) 1 🝖[ _≡_ ]-[]
𝑐𝐶 (𝐒(length l)) 1 🝖[ _≡_ ]-[]
𝑐𝐶 (length(x ⊰ l)) 1 🝖-end
combinations-length {𝐒(𝐒 k)} {l = x ⊰ l} =
length(combinations (𝐒(𝐒 k)) (x ⊰ l)) 🝖[ _≡_ ]-[]
length(map (x ,_) (combinations (𝐒 k) l) ++ combinations (𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ length-[++] {l₁ = map (x ,_) (combinations (𝐒 k) l)}{l₂ = combinations (𝐒(𝐒 k)) l} ]
length(map (x ,_) (combinations (𝐒 k) l)) + length(combinations (𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(length(combinations (𝐒(𝐒 k)) l)) (length-map{f = (x ,_)}{x = combinations (𝐒 k) l}) ]
length(combinations (𝐒 k) l) + length(combinations (𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂(_+_) (combinations-length {𝐒 k} {l = l}) (combinations-length {𝐒(𝐒 k)} {l = l}) ]
𝑐𝐶(length(l))(𝐒 k) + 𝑐𝐶(length(l))(𝐒(𝐒 k)) 🝖[ _≡_ ]-[]
𝑐𝐶 (length(x ⊰ l)) (𝐒(𝐒 k)) 🝖-end
repeatableCombinations-length : length(repeatableCombinations k l) ≡ 𝑐𝐶((length(l) + k) −₀ 1)(k)
repeatableCombinations-length {0} {l = _} = [≡]-intro
repeatableCombinations-length {1} {l = x ⊰ l} = [≡]-intro
repeatableCombinations-length {𝐒 k} {l = ∅} = symmetry(_≡_) (𝑐𝐶-larger-subsets{k}{𝐒(k)} (reflexivity(_≤_)))
repeatableCombinations-length {𝐒(𝐒 k)} {l = x ⊰ l} =
length (repeatableCombinations (𝐒(𝐒 k)) (x ⊰ l)) 🝖[ _≡_ ]-[]
length(map(x ,_) (repeatableCombinations (𝐒 k) (x ⊰ l)) ++ repeatableCombinations(𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ length-[++] {l₁ = map(x ,_) (repeatableCombinations (𝐒 k) (x ⊰ l))}{l₂ = repeatableCombinations(𝐒(𝐒 k)) l} ]
length(map(x ,_) (repeatableCombinations (𝐒 k) (x ⊰ l))) + length(repeatableCombinations(𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(length(repeatableCombinations(𝐒(𝐒 k)) l)) (length-map {f = x ,_}{x = repeatableCombinations (𝐒 k) (x ⊰ l)}) ]
length(repeatableCombinations (𝐒 k) (x ⊰ l)) + length(repeatableCombinations(𝐒(𝐒 k)) l) 🝖[ _≡_ ]-[ congruence₂(_+_) (repeatableCombinations-length{k = 𝐒 k}{l = x ⊰ l}) (repeatableCombinations-length{k = 𝐒(𝐒 k)}{l = l}) ]
𝑐𝐶((length(x ⊰ l) + 𝐒(k)) −₀ 1)(𝐒(k)) + 𝑐𝐶((length(l) + 𝐒(𝐒(k))) −₀ 1)(𝐒(𝐒(k))) 🝖[ _≡_ ]-[]
𝑐𝐶((length(x ⊰ l) + 𝐒(𝐒 k)) −₀ 1) (𝐒(𝐒 k)) 🝖-end
tuples-length : length(tuples n l) ≡ length(l) ^ n
tuples-length {0} = [≡]-intro
tuples-length {1} = [≡]-intro
tuples-length {𝐒(𝐒(n))}{l = ∅} = [≡]-intro
tuples-length {𝐒(𝐒(n))}{l = x ⊰ l} =
length(tuples(𝐒(𝐒(n))) (x ⊰ l)) 🝖[ _≡_ ]-[]
length(concatMap(y ↦ map (y Tuple₊.⊰_) (tuples (𝐒(n)) (x ⊰ l))) (x ⊰ l)) 🝖[ _≡_ ]-[ length-concatMap {l = x ⊰ l}{f = y ↦ map (y Tuple₊.⊰_) (tuples (𝐒(n)) (x ⊰ l))} ]
foldᵣ((_+_) ∘ length ∘ (y ↦ map (y Tuple₊.⊰_) (tuples (𝐒(n)) (x ⊰ l)))) 𝟎 (x ⊰ l) 🝖[ _≡_ ]-[ foldᵣ-function₊-raw {l₁ = x ⊰ l}{a₁ = 𝟎} (\{a b} → [≡]-with(_+ b) (length-map{f = a Tuple₊.⊰_}{x = tuples (𝐒(n)) (x ⊰ l)})) [≡]-intro [≡]-intro ]
foldᵣ((_+_) ∘ length ∘ (y ↦ tuples (𝐒(n)) (x ⊰ l))) 𝟎 (x ⊰ l) 🝖[ _≡_ ]-[]
foldᵣ(const(length(tuples (𝐒(n)) (x ⊰ l)) +_)) 𝟎 (x ⊰ l) 🝖[ _≡_ ]-[ foldᵣ-constant-[+]ₗ{l = x ⊰ l} {init = 𝟎}{step = length(tuples (𝐒(n)) (x ⊰ l))} ]
length(x ⊰ l) ⋅ length(tuples(𝐒(n)) (x ⊰ l)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅_) (length(x ⊰ l)) (tuples-length {𝐒(n)} {l = x ⊰ l}) ]
length(x ⊰ l) ⋅ (length(x ⊰ l) ^ 𝐒(n)) 🝖[ _≡_ ]-[]
length(x ⊰ l) ^ 𝐒(𝐒(n)) 🝖-end
rotations-length : length(rotations l) ≡ length(l)
rotations-length{l = l} = length-accumulateIterate₀{f = rotateₗ(1)}{init = l}
insertedEverywhere-contents-length : AllElements(p ↦ length(p) ≡ 𝐒(length(l))) (insertedEverywhere x l)
insertedEverywhere-contents-length = AllElements-fn (Function.congruence ⦃ _ ⦄ Proofs.permutes-length-function) permutes-insertedEverywhere
insertedEverywhere-length : length(insertedEverywhere x l) ≡ 𝐒(length(l))
insertedEverywhere-length {x = x} {∅} = [≡]-intro
insertedEverywhere-length {x = x} {a ⊰ l} =
length(insertedEverywhere x (a ⊰ l)) 🝖[ _≡_ ]-[]
length((x ⊰ a ⊰ l) ⊰ (map (List.prepend a) (insertedEverywhere x l))) 🝖[ _≡_ ]-[]
𝐒(length(map (List.prepend a) (insertedEverywhere x l))) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (length-map{f = List.prepend a}{x = insertedEverywhere x l}) ]
𝐒(length(insertedEverywhere x l)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) (insertedEverywhere-length {x = x} {l}) ]
𝐒(𝐒(length(l))) 🝖[ _≡_ ]-[]
𝐒(length(a ⊰ l)) 🝖-end
permutation-length : AllElements(p ↦ length p ≡ length l) (permutations l)
permutation-length{l = l} = AllElements-fn (Function.congruence ⦃ _ ⦄ Proofs.permutes-length-function) (permutations-contains-permutations{l = l})
{-permutations-length : length(permutations l) ≡ length(l) !
permutations-length {l = ∅} = [≡]-intro
permutations-length {l = x ⊰ ∅} = [≡]-intro
permutations-length {l = x ⊰ y ⊰ l} =
length(permutations(x ⊰ y ⊰ l)) 🝖[ _≡_ ]-[]
length(concatMap(insertedEverywhere x) (permutations(y ⊰ l))) 🝖[ _≡_ ]-[ length-concatMap{l = permutations(y ⊰ l)}{f = insertedEverywhere x} ]
foldᵣ (_+_ ∘ length ∘ insertedEverywhere x) 𝟎 (permutations (y ⊰ l)) 🝖[ _≡_ ]-[ {!!} ]
foldᵣ (_+_ ∘ length) 𝟎 (map (insertedEverywhere x) (permutations (y ⊰ l))) 🝖[ _≡_ ]-[ {!!} ]
𝐒(𝐒(length l)) ⋅ (𝐒(length l) ⋅ (length(l)!)) 🝖[ _≡_ ]-[]
length(x ⊰ y ⊰ l)! 🝖-end
-}
{-permutations-length {l = x ⊰ y ⊰ l} with permutations(y ⊰ l) | permutations-length {l = y ⊰ l}
... | ∅ | p = {!!}
... | z ⊰ pyl | p =
length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ (z ⊰ pyl)) 🝖[ _≡_ ]-[]
length(insertedEverywhere x z ++ foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl) 🝖[ _≡_ ]-[ length-[++] {l₁ = insertedEverywhere x z}{l₂ = foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl} ]
length(insertedEverywhere x z) + length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl)) (insertedEverywhere-length {x = x}{l = z}) ]
𝐒(length z) + length(foldᵣ((_++_) ∘ insertedEverywhere x) ∅ pyl) 🝖[ _≡_ ]-[ {!!} ]
𝐒(𝐒(length l)) ⋅ 𝐒(length pyl) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅_)(𝐒(𝐒(length l))) p ]
𝐒(𝐒(length l)) ⋅ (𝐒(length l) ⋅ (length(l) !)) 🝖-end-}
{- TODO: Proof of above
length(concatMap (insertedEverywhere x) (permutations(y ⊰ l)))
foldᵣ((_+_) ∘ length ∘ (insertedEverywhere x)) (permutations(y ⊰ l))
foldᵣ((_+_) ∘ 𝐒 ∘ length) (permutations(y ⊰ l))
foldᵣ((_+_) ∘ 𝐒) (map length(permutations(y ⊰ l)))
foldᵣ((_+_) ∘ 𝐒) (map (const(length(y ⊰ l))) (permutations(y ⊰ l))) -- from permutation-length when map function yields the same value for every element in the list
foldᵣ((_+_) ∘ 𝐒 ∘ const(length(y ⊰ l))) (permutations(y ⊰ l))
foldᵣ((_+_) ∘ const(𝐒 ∘ length(y ⊰ l))) (permutations(y ⊰ l))
𝐒(length(y ⊰ l)) ⋅ length(permutations(y ⊰ l))
𝐒(length(y ⊰ l)) ⋅ (length(y ⊰ l) !)
-}
{- length(permutations (x ⊰ y ⊰ l)) 🝖[ _≡_ ]-[ {!!} ]
-- length(concatMap (insertedEverywhere x) (permutations(y ⊰ l))) 🝖[ _≡_ ]-[ length-concatMap {l = permutations(y ⊰ l)}{f = insertedEverywhere x} ]
-- foldᵣ (_+_ ∘ length ∘ insertedEverywhere x) 𝟎 (permutations(y ⊰ l)) 🝖[ _≡_ ]-[ {!length-foldᵣ {l = permutations(y ⊰ l)}{init = 𝟎}!} ]
𝐒(𝐒(length l)) ⋅ (𝐒(length l) ⋅ (length(l) !)) 🝖[ _≡_ ]-[]
(length(x ⊰ y ⊰ l) !) 🝖-end
-}
| {
"alphanum_fraction": 0.5663248645,
"avg_line_length": 69.9132420091,
"ext": "agda",
"hexsha": "afa7e8621adac1f01652fd5118b3307b5e8c4dc1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/List/Combinatorics/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": "Data/List/Combinatorics/Proofs.agda",
"max_line_length": 305,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/List/Combinatorics/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": 6159,
"size": 15311
} |
{-# OPTIONS --type-in-type #-}
open import Function
open import Data.Nat.Base
open import Data.Bool.Base
open import Data.Product
{-# NO_POSITIVITY_CHECK #-}
record IFix {I : Set} (F : (I -> Set) -> I -> Set) (i : I) : Set where
constructor wrap
field unwrap : F (IFix F) i
open IFix
data Expr : Set -> Set where
Lit : ℕ -> Expr ℕ
Inc : Expr ℕ -> Expr ℕ
IsZ : Expr ℕ -> Expr Bool
Pair : ∀ {A B} -> Expr A -> Expr B -> Expr (A × B)
Fst : ∀ {A B} -> Expr (A × B) -> Expr A
Snd : ∀ {A B} -> Expr (A × B) -> Expr B
-- As usually the pattern vector of a Scott-encoded data type encodes pattern-matching.
ExprF′ : (Set -> Set) -> Set -> Set
ExprF′
= λ Rec I
-> (R : Set -> Set)
-> (ℕ -> R ℕ)
-> (Rec ℕ -> R ℕ)
-> (Rec ℕ -> R Bool)
-> (∀ {A B} -> Rec A -> Rec B -> R (A × B))
-> (∀ {A B} -> Rec (A × B) -> R A)
-> (∀ {A B} -> Rec (A × B) -> R B)
-> R I
Expr′ : Set -> Set
Expr′ = IFix ExprF′
expr-to-expr′ : ∀ {A} -> Expr A -> Expr′ A
expr-to-expr′ (Lit x) = wrap λ R lit inc isZ pair fst snd -> lit x
expr-to-expr′ (Inc x) = wrap λ R lit inc isZ pair fst snd -> inc (expr-to-expr′ x)
expr-to-expr′ (IsZ x) = wrap λ R lit inc isZ pair fst snd -> isZ (expr-to-expr′ x)
expr-to-expr′ (Pair x y) = wrap λ R lit inc isZ pair fst snd -> pair (expr-to-expr′ x) (expr-to-expr′ y)
expr-to-expr′ (Fst p) = wrap λ R lit inc isZ pair fst snd -> fst (expr-to-expr′ p)
expr-to-expr′ (Snd p) = wrap λ R lit inc isZ pair fst snd -> snd (expr-to-expr′ p)
{-# TERMINATING #-}
expr′-to-expr : ∀ {A} -> Expr′ A -> Expr A
expr′-to-expr e =
unwrap
e
Expr
Lit
(Inc ∘ expr′-to-expr)
(IsZ ∘ expr′-to-expr)
(λ x y -> Pair (expr′-to-expr x) (expr′-to-expr y))
(Fst ∘ expr′-to-expr)
(Snd ∘ expr′-to-expr)
isZero : ℕ -> Bool
isZero zero = true
isZero (suc _) = false
{-# TERMINATING #-}
evalExpr′ : ∀ {A} -> Expr′ A -> A
evalExpr′ e =
unwrap
e
id
id
(suc ∘ evalExpr′)
(isZero ∘ evalExpr′)
(λ x y -> (evalExpr′ x , evalExpr′ y))
(proj₁ ∘ evalExpr′)
(proj₂ ∘ evalExpr′)
| {
"alphanum_fraction": 0.541848089,
"avg_line_length": 27.56,
"ext": "agda",
"hexsha": "fea773f2da29b2e175cd7e15ab63abd6c50881d3",
"lang": "Agda",
"max_forks_count": 399,
"max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z",
"max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "AriFordsham/plutus",
"max_forks_repo_path": "notes/fomega/gadts/Expr.agda",
"max_issues_count": 2493,
"max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "AriFordsham/plutus",
"max_issues_repo_path": "notes/fomega/gadts/Expr.agda",
"max_line_length": 104,
"max_stars_count": 1299,
"max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "AriFordsham/plutus",
"max_stars_repo_path": "notes/fomega/gadts/Expr.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z",
"num_tokens": 790,
"size": 2067
} |
------------------------------------------------------------------------
-- Lists
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module List
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Prelude
open import Bijection eq as Bijection using (_↔_)
open Derived-definitions-and-properties eq
open import Equality.Decision-procedures eq
import Equivalence eq as Eq
open import Function-universe eq hiding (_∘_)
open import H-level eq as H-level
open import H-level.Closure eq
open import Monad eq hiding (map)
open import Nat eq
open import Nat.Solver eq
private
variable
a ℓ : Level
A B C : Type a
x y : A
f : A → B
n : ℕ
xs ys zs : List A
ns : List ℕ
------------------------------------------------------------------------
-- Some functions
-- The tail of a list. Returns [] if the list is empty.
tail : List A → List A
tail [] = []
tail (_ ∷ xs) = xs
-- The function take n returns the first n elements of a list (or the
-- entire list, if the list does not contain n elements).
take : ℕ → List A → List A
take zero xs = []
take (suc n) (x ∷ xs) = x ∷ take n xs
take (suc n) xs@[] = xs
-- The function drop n removes the first n elements from a list (or
-- all elements, if the list does not contain n elements).
drop : ℕ → List A → List A
drop zero xs = xs
drop (suc n) (x ∷ xs) = drop n xs
drop (suc n) xs@[] = xs
-- Right fold.
foldr : (A → B → B) → B → List A → B
foldr _⊕_ ε [] = ε
foldr _⊕_ ε (x ∷ xs) = x ⊕ foldr _⊕_ ε xs
-- Left fold.
foldl : (B → A → B) → B → List A → B
foldl _⊕_ ε [] = ε
foldl _⊕_ ε (x ∷ xs) = foldl _⊕_ (ε ⊕ x) xs
-- The length of a list.
length : List A → ℕ
length = foldr (const suc) 0
-- The sum of all the elements in a list of natural numbers.
sum : List ℕ → ℕ
sum = foldr _+_ 0
-- Appends two lists.
infixr 5 _++_
_++_ : List A → List A → List A
xs ++ ys = foldr _∷_ ys xs
-- Maps a function over a list.
map : (A → B) → List A → List B
map f = foldr (λ x ys → f x ∷ ys) []
-- Concatenates a list of lists.
concat : List (List A) → List A
concat = foldr _++_ []
-- "Zips" two lists, using the given function to combine elementsw.
zip-with : (A → B → C) → List A → List B → List C
zip-with f [] _ = []
zip-with f _ [] = []
zip-with f (x ∷ xs) (y ∷ ys) = f x y ∷ zip-with f xs ys
-- "Zips" two lists.
zip : List A → List B → List (A × B)
zip = zip-with _,_
-- Reverses a list.
reverse : List A → List A
reverse = foldl (λ xs x → x ∷ xs) []
-- Replicates the given value the given number of times.
replicate : ℕ → A → List A
replicate zero x = []
replicate (suc n) x = x ∷ replicate n x
-- A filter function.
filter : (A → Bool) → List A → List A
filter p = foldr (λ x xs → if p x then x ∷ xs else xs) []
-- Finds the element at the given position.
index : (xs : List A) → Fin (length xs) → A
index [] ()
index (x ∷ xs) fzero = x
index (x ∷ xs) (fsuc i) = index xs i
-- A lookup function.
lookup : (A → A → Bool) → A → List (A × B) → Maybe B
lookup _≟_ x [] = nothing
lookup _≟_ x ((y , z) ∷ ps) =
if x ≟ y then just z else lookup _≟_ x ps
-- The list nats-< consists of the first n natural numbers in
-- strictly descending order.
nats-< : ℕ → List ℕ
nats-< zero = []
nats-< (suc n) = n ∷ nats-< n
-- A list that includes every tail of the given list (including the
-- list itself) exactly once. Longer tails precede shorter ones.
tails : List A → List (List A)
tails [] = [] ∷ []
tails xxs@(_ ∷ xs) = xxs ∷ tails xs
------------------------------------------------------------------------
-- Some properties
-- If you take the first n elements from xs and append what you get if
-- you drop the first n elements from xs, then you get xs (even if n
-- is larger than the length of xs).
take++drop : ∀ n → take n xs ++ drop n xs ≡ xs
take++drop zero = refl _
take++drop {xs = []} (suc n) = refl _
take++drop {xs = x ∷ xs} (suc n) = cong (x ∷_) (take++drop n)
-- The map function commutes with take n.
map-take : map f (take n xs) ≡ take n (map f xs)
map-take {n = zero} = refl _
map-take {n = suc n} {xs = []} = refl _
map-take {n = suc n} {xs = x ∷ xs} = cong (_ ∷_) map-take
-- The map function commutes with drop n.
map-drop : ∀ n → map f (drop n xs) ≡ drop n (map f xs)
map-drop zero = refl _
map-drop {xs = []} (suc n) = refl _
map-drop {xs = x ∷ xs} (suc n) = map-drop n
-- The function foldr _∷_ [] is pointwise equal to the identity
-- function.
foldr-∷-[] : (xs : List A) → foldr _∷_ [] xs ≡ xs
foldr-∷-[] [] = refl _
foldr-∷-[] (x ∷ xs) = cong (x ∷_) (foldr-∷-[] xs)
-- The empty list is a right identity for the append function.
++-right-identity : (xs : List A) → xs ++ [] ≡ xs
++-right-identity [] = refl _
++-right-identity (x ∷ xs) = cong (x ∷_) (++-right-identity xs)
-- The append function is associative.
++-associative : (xs ys zs : List A) →
xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs
++-associative [] ys zs = refl _
++-associative (x ∷ xs) ys zs = cong (x ∷_) (++-associative xs ys zs)
-- The map function commutes with _++_.
map-++ : (f : A → B) (xs ys : List A) →
map f (xs ++ ys) ≡ map f xs ++ map f ys
map-++ f [] ys = refl _
map-++ f (x ∷ xs) ys = cong (f x ∷_) (map-++ f xs ys)
-- The concat function commutes with _++_.
concat-++ : (xss yss : List (List A)) →
concat (xss ++ yss) ≡ concat xss ++ concat yss
concat-++ [] yss = refl _
concat-++ (xs ∷ xss) yss =
concat ((xs ∷ xss) ++ yss) ≡⟨⟩
xs ++ concat (xss ++ yss) ≡⟨ cong (xs ++_) (concat-++ xss yss) ⟩
xs ++ (concat xss ++ concat yss) ≡⟨ ++-associative xs _ _ ⟩
(xs ++ concat xss) ++ concat yss ≡⟨ refl _ ⟩∎
concat (xs ∷ xss) ++ concat yss ∎
-- A lemma relating foldr and _++_.
foldr-++ :
{c : A → B → B} {n : B} →
∀ xs → foldr c n (xs ++ ys) ≡ foldr c (foldr c n ys) xs
foldr-++ [] = refl _
foldr-++ {ys = ys} {c = c} {n = n} (x ∷ xs) =
foldr c n (x ∷ xs ++ ys) ≡⟨⟩
c x (foldr c n (xs ++ ys)) ≡⟨ cong (c x) (foldr-++ xs) ⟩
c x (foldr c (foldr c n ys) xs) ≡⟨⟩
foldr c (foldr c n ys) (x ∷ xs) ∎
-- A fusion lemma for foldr and map.
foldr∘map :
(_⊕_ : B → C → C) (ε : C) (f : A → B) (xs : List A) →
(foldr _⊕_ ε ∘ map f) xs ≡ foldr (_⊕_ ∘ f) ε xs
foldr∘map _⊕_ ε f [] = ε ∎
foldr∘map _⊕_ ε f (x ∷ xs) = cong (f x ⊕_) (foldr∘map _⊕_ ε f xs)
-- A fusion lemma for length and map.
length∘map :
(f : A → B) (xs : List A) →
(length ∘ map f) xs ≡ length xs
length∘map = foldr∘map _ _
-- A lemma relating index, map and length∘map.
index∘map :
∀ xs {i} →
index (map f xs) i ≡
f (index xs (subst Fin (length∘map f xs) i))
index∘map {f = f} (x ∷ xs) {i} =
index (f x ∷ map f xs) i ≡⟨ lemma i ⟩
f (index (x ∷ xs) (subst (λ n → ⊤ ⊎ Fin n) p i)) ≡⟨⟩
f (index (x ∷ xs) (subst (Fin ∘ suc) p i)) ≡⟨ cong (f ∘ index (_ ∷ xs)) (subst-∘ Fin suc _) ⟩
f (index (x ∷ xs) (subst Fin (cong suc p) i)) ≡⟨⟩
f (index (x ∷ xs) (subst Fin (length∘map f (x ∷ xs)) i)) ∎
where
p = length∘map f xs
lemma :
∀ i →
index (f x ∷ map f xs) i ≡
f (index (x ∷ xs) (subst (λ n → ⊤ ⊎ Fin n) p i))
lemma fzero =
index (f x ∷ map f xs) fzero ≡⟨⟩
f x ≡⟨⟩
f (index (x ∷ xs) fzero) ≡⟨⟩
f (index (x ∷ xs) (inj₁ (subst (λ _ → ⊤) p tt))) ≡⟨ cong (f ∘ index (_ ∷ xs)) $ sym $ push-subst-inj₁ _ Fin ⟩∎
f (index (x ∷ xs) (subst (λ n → ⊤ ⊎ Fin n) p fzero)) ∎
lemma (fsuc i) =
index (f x ∷ map f xs) (fsuc i) ≡⟨⟩
index (map f xs) i ≡⟨ index∘map xs ⟩
f (index xs (subst Fin p i)) ≡⟨⟩
f (index (x ∷ xs) (fsuc (subst Fin p i))) ≡⟨ cong (f ∘ index (_ ∷ xs)) $ sym $ push-subst-inj₂ _ Fin ⟩∎
f (index (x ∷ xs) (subst (λ n → ⊤ ⊎ Fin n) p (fsuc i))) ∎
-- The length function is homomorphic with respect to _++_/_+_.
length-++ : ∀ xs → length (xs ++ ys) ≡ length xs + length ys
length-++ [] = refl _
length-++ (_ ∷ xs) = cong suc (length-++ xs)
-- The sum function is homomorphic with respect to _++_/_+_.
sum-++ : ∀ ms → sum (ms ++ ns) ≡ sum ms + sum ns
sum-++ [] = refl _
sum-++ {ns = ns} (m ∷ ms) =
sum (m ∷ ms ++ ns) ≡⟨⟩
m + sum (ms ++ ns) ≡⟨ cong (m +_) $ sum-++ ms ⟩
m + (sum ms + sum ns) ≡⟨ +-assoc m ⟩
(m + sum ms) + sum ns ≡⟨⟩
sum (m ∷ ms) + sum ns ∎
-- Some lemmas related to reverse.
++-reverse : ∀ xs → reverse xs ++ ys ≡ foldl (flip _∷_) ys xs
++-reverse xs = lemma xs
where
lemma :
∀ xs →
foldl (flip _∷_) ys xs ++ zs ≡
foldl (flip _∷_) (ys ++ zs) xs
lemma [] = refl _
lemma {ys = ys} {zs = zs} (x ∷ xs) =
foldl (flip _∷_) ys (x ∷ xs) ++ zs ≡⟨⟩
foldl (flip _∷_) (x ∷ ys) xs ++ zs ≡⟨ lemma xs ⟩
foldl (flip _∷_) (x ∷ ys ++ zs) xs ≡⟨⟩
foldl (flip _∷_) (ys ++ zs) (x ∷ xs) ∎
reverse-∷ : ∀ xs → reverse (x ∷ xs) ≡ reverse xs ++ x ∷ []
reverse-∷ {x = x} xs =
reverse (x ∷ xs) ≡⟨⟩
foldl (flip _∷_) (x ∷ []) xs ≡⟨ sym $ ++-reverse xs ⟩∎
reverse xs ++ x ∷ [] ∎
reverse-++ : ∀ xs → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs
reverse-++ {ys = ys} [] =
reverse ys ≡⟨ sym $ ++-right-identity _ ⟩∎
reverse ys ++ [] ∎
reverse-++ {ys = ys} (x ∷ xs) =
reverse (x ∷ xs ++ ys) ≡⟨ reverse-∷ (xs ++ _) ⟩
reverse (xs ++ ys) ++ x ∷ [] ≡⟨ cong (_++ _) $ reverse-++ xs ⟩
(reverse ys ++ reverse xs) ++ x ∷ [] ≡⟨ sym $ ++-associative (reverse ys) _ _ ⟩
reverse ys ++ (reverse xs ++ x ∷ []) ≡⟨ cong (reverse ys ++_) $ sym $ reverse-∷ xs ⟩∎
reverse ys ++ reverse (x ∷ xs) ∎
reverse-reverse : (xs : List A) → reverse (reverse xs) ≡ xs
reverse-reverse [] = refl _
reverse-reverse (x ∷ xs) =
reverse (reverse (x ∷ xs)) ≡⟨ cong reverse (reverse-∷ xs) ⟩
reverse (reverse xs ++ x ∷ []) ≡⟨ reverse-++ (reverse xs) ⟩
reverse (x ∷ []) ++ reverse (reverse xs) ≡⟨⟩
x ∷ reverse (reverse xs) ≡⟨ cong (x ∷_) (reverse-reverse xs) ⟩∎
x ∷ xs ∎
map-reverse : ∀ xs → map f (reverse xs) ≡ reverse (map f xs)
map-reverse [] = refl _
map-reverse {f = f} (x ∷ xs) =
map f (reverse (x ∷ xs)) ≡⟨ cong (map f) $ reverse-∷ xs ⟩
map f (reverse xs ++ x ∷ []) ≡⟨ map-++ _ (reverse xs) _ ⟩
map f (reverse xs) ++ f x ∷ [] ≡⟨ cong (_++ _) $ map-reverse xs ⟩
reverse (map f xs) ++ f x ∷ [] ≡⟨ sym $ reverse-∷ (map f xs) ⟩
reverse (f x ∷ map f xs) ≡⟨⟩
reverse (map f (x ∷ xs)) ∎
foldr-reverse :
{c : A → B → B} {n : B} →
∀ xs → foldr c n (reverse xs) ≡ foldl (flip c) n xs
foldr-reverse [] = refl _
foldr-reverse {c = c} {n = n} (x ∷ xs) =
foldr c n (reverse (x ∷ xs)) ≡⟨ cong (foldr c n) (reverse-++ {ys = xs} (x ∷ [])) ⟩
foldr c n (reverse xs ++ x ∷ []) ≡⟨ foldr-++ (reverse xs) ⟩
foldr c (c x n) (reverse xs) ≡⟨ foldr-reverse xs ⟩
foldl (flip c) (c x n) xs ≡⟨⟩
foldl (flip c) n (x ∷ xs) ∎
foldl-reverse :
{c : B → A → B} {n : B} →
∀ xs → foldl c n (reverse xs) ≡ foldr (flip c) n xs
foldl-reverse {c = c} {n = n} xs =
foldl c n (reverse xs) ≡⟨ sym (foldr-reverse (reverse xs)) ⟩
foldr (flip c) n (reverse (reverse xs)) ≡⟨ cong (foldr (flip c) n) (reverse-reverse xs) ⟩∎
foldr (flip c) n xs ∎
length-reverse : (xs : List A) → length (reverse xs) ≡ length xs
length-reverse [] = refl _
length-reverse (x ∷ xs) =
length (reverse (x ∷ xs)) ≡⟨ cong length (reverse-∷ xs) ⟩
length (reverse xs ++ x ∷ []) ≡⟨ length-++ (reverse xs) ⟩
length (reverse xs) + 1 ≡⟨ cong (_+ 1) (length-reverse xs) ⟩
length xs + 1 ≡⟨ +-comm (length xs) ⟩∎
length (x ∷ xs) ∎
sum-reverse : ∀ ns → sum (reverse ns) ≡ sum ns
sum-reverse [] = refl _
sum-reverse (n ∷ ns) =
sum (reverse (n ∷ ns)) ≡⟨ cong sum (reverse-∷ ns) ⟩
sum (reverse ns ++ n ∷ []) ≡⟨ sum-++ (reverse ns) ⟩
sum (reverse ns) + sum (n ∷ []) ≡⟨ cong₂ _+_ (sum-reverse ns) +-right-identity ⟩
sum ns + n ≡⟨ +-comm (sum ns) ⟩∎
sum (n ∷ ns) ∎
-- The functions filter and map commute (kind of).
filter∘map :
(p : B → Bool) (f : A → B) (xs : List A) →
(filter p ∘ map f) xs ≡ (map f ∘ filter (p ∘ f)) xs
filter∘map p f [] = refl _
filter∘map p f (x ∷ xs) with p (f x)
... | true = cong (_ ∷_) (filter∘map p f xs)
... | false = filter∘map p f xs
-- The length of replicate n x is n.
length-replicate : ∀ n → length (replicate n x) ≡ n
length-replicate zero = refl _
length-replicate {x = x} (suc n) =
length (replicate (suc n) x) ≡⟨⟩
suc (length (replicate n x)) ≡⟨ cong suc $ length-replicate n ⟩∎
suc n ∎
-- The sum of replicate m n is m * n.
sum-replicate : ∀ m → sum (replicate m n) ≡ m * n
sum-replicate zero = refl _
sum-replicate {n = n} (suc m) =
sum (replicate (suc m) n) ≡⟨⟩
n + sum (replicate m n) ≡⟨ cong (n +_) $ sum-replicate m ⟩
n + m * n ≡⟨⟩
suc m * n ∎
-- The length of nats-< n is n.
length∘nats-< : ∀ n → length (nats-< n) ≡ n
length∘nats-< zero = 0 ∎
length∘nats-< (suc n) = cong suc (length∘nats-< n)
-- The sum of nats-< n can be expressed without referring to lists.
sum-nats-< : ∀ n → sum (nats-< n) ≡ ⌊ n * pred n /2⌋
sum-nats-< zero = refl _
sum-nats-< (suc zero) = refl _
sum-nats-< (suc (suc n)) =
sum (suc n ∷ nats-< (suc n)) ≡⟨⟩
suc n + sum (nats-< (suc n)) ≡⟨ cong (suc n +_) (sum-nats-< (suc n)) ⟩
suc n + ⌊ suc n * n /2⌋ ≡⟨ sym $ ⌊2*+/2⌋≡ (suc n) ⟩
⌊ 2 * suc n + suc n * n /2⌋ ≡⟨ cong ⌊_/2⌋ (solve 1 (λ n → con 2 :* (con 1 :+ n) :+ (con 1 :+ n) :* n :=
con 1 :+ n :+ (con 1 :+ n :+ n :* (con 1 :+ n)))
(refl _) n) ⟩
⌊ suc n + (suc n + n * suc n) /2⌋ ≡⟨⟩
⌊ suc (suc n) * suc n /2⌋ ∎
-- If xs ++ ys is equal to [], then both lists are.
++≡[]→≡[]×≡[] : ∀ xs → xs ++ ys ≡ [] → xs ≡ [] × ys ≡ []
++≡[]→≡[]×≡[] {ys = []} [] _ = refl _ , refl _
++≡[]→≡[]×≡[] {ys = _ ∷ _} [] ∷≡[] = ⊥-elim (List.[]≢∷ (sym ∷≡[]))
++≡[]→≡[]×≡[] (_ ∷ _) ∷≡[] = ⊥-elim (List.[]≢∷ (sym ∷≡[]))
-- Empty lists are not equal to non-empty lists.
[]≢++∷ : ∀ xs → [] ≢ xs ++ y ∷ ys
[]≢++∷ {y = y} {ys = ys} xs =
[] ≡ xs ++ y ∷ ys ↝⟨ sym ∘ proj₂ ∘ ++≡[]→≡[]×≡[] xs ∘ sym ⟩
[] ≡ y ∷ ys ↝⟨ List.[]≢∷ ⟩□
⊥ □
------------------------------------------------------------------------
-- The list monad
instance
-- The list monad.
raw-monad : Raw-monad (List {a = ℓ})
Raw-monad.return raw-monad x = x ∷ []
Raw-monad._>>=_ raw-monad xs f = concat (map f xs)
monad : Monad (List {a = ℓ})
Monad.raw-monad monad = raw-monad
Monad.left-identity monad x f = foldr-∷-[] (f x)
Monad.right-identity monad xs = lemma xs
where
lemma : ∀ xs → concat (map (_∷ []) xs) ≡ xs
lemma [] = refl _
lemma (x ∷ xs) =
concat (map (_∷ []) (x ∷ xs)) ≡⟨⟩
x ∷ concat (map (_∷ []) xs) ≡⟨ cong (x ∷_) (lemma xs) ⟩∎
x ∷ xs ∎
Monad.associativity monad xs f g = lemma xs
where
lemma : ∀ xs → concat (map (concat ∘ map g ∘ f) xs) ≡
concat (map g (concat (map f xs)))
lemma [] = refl _
lemma (x ∷ xs) =
concat (map (concat ∘ map g ∘ f) (x ∷ xs)) ≡⟨⟩
concat (map g (f x)) ++ concat (map (concat ∘ map g ∘ f) xs) ≡⟨ cong (concat (map g (f x)) ++_) (lemma xs) ⟩
concat (map g (f x)) ++ concat (map g (concat (map f xs))) ≡⟨ sym $ concat-++ (map g (f x)) _ ⟩
concat (map g (f x) ++ map g (concat (map f xs))) ≡⟨ cong concat (sym $ map-++ g (f x) _) ⟩
concat (map g (f x ++ concat (map f xs))) ≡⟨ refl _ ⟩∎
concat (map g (concat (map f (x ∷ xs)))) ∎
------------------------------------------------------------------------
-- Some isomorphisms
-- An unfolding lemma for List.
List↔Maybe[×List] : List A ↔ Maybe (A × List A)
List↔Maybe[×List] = record
{ surjection = record
{ logical-equivalence = record
{ to = λ { [] → inj₁ tt; (x ∷ xs) → inj₂ (x , xs) }
; from = [ (λ _ → []) , uncurry _∷_ ]
}
; right-inverse-of = [ (λ _ → refl _) , (λ _ → refl _) ]
}
; left-inverse-of = λ { [] → refl _; (_ ∷ _) → refl _ }
}
-- Some isomorphisms related to list equality.
[]≡[]↔⊤ : [] ≡ ([] ⦂ List A) ↔ ⊤
[]≡[]↔⊤ =
[] ≡ [] ↔⟨ inverse $ Eq.≃-≡ (Eq.↔⇒≃ List↔Maybe[×List]) ⟩
nothing ≡ nothing ↝⟨ inverse Bijection.≡↔inj₁≡inj₁ ⟩
tt ≡ tt ↝⟨ tt≡tt↔⊤ ⟩□
⊤ □
[]≡∷↔⊥ : [] ≡ x ∷ xs ↔ ⊥ {ℓ = ℓ}
[]≡∷↔⊥ {x = x} {xs = xs} =
[] ≡ x ∷ xs ↔⟨ inverse $ Eq.≃-≡ (Eq.↔⇒≃ List↔Maybe[×List]) ⟩
nothing ≡ just (x , xs) ↝⟨ Bijection.≡↔⊎ ⟩
⊥ ↝⟨ ⊥↔⊥ ⟩□
⊥ □
∷≡[]↔⊥ : x ∷ xs ≡ [] ↔ ⊥ {ℓ = ℓ}
∷≡[]↔⊥ {x = x} {xs = xs} =
x ∷ xs ≡ [] ↝⟨ ≡-comm ⟩
[] ≡ x ∷ xs ↝⟨ []≡∷↔⊥ ⟩□
⊥ □
∷≡∷↔≡×≡ : x ∷ xs ≡ y ∷ ys ↔ x ≡ y × xs ≡ ys
∷≡∷↔≡×≡ {x = x} {xs = xs} {y = y} {ys = ys} =
x ∷ xs ≡ y ∷ ys ↔⟨ inverse $ Eq.≃-≡ (Eq.↔⇒≃ List↔Maybe[×List]) ⟩
just (x , xs) ≡ just (y , ys) ↝⟨ inverse Bijection.≡↔inj₂≡inj₂ ⟩
(x , xs) ≡ (y , ys) ↝⟨ inverse ≡×≡↔≡ ⟩□
x ≡ y × xs ≡ ys □
------------------------------------------------------------------------
-- H-levels
-- If A is inhabited, then List A is not a proposition.
¬-List-propositional : A → ¬ Is-proposition (List A)
¬-List-propositional x h = List.[]≢∷ $ h [] (x ∷ [])
-- H-levels greater than or equal to two are closed under List.
H-level-List : ∀ n → H-level (2 + n) A → H-level (2 + n) (List A)
H-level-List n _ {[]} {[]} =
$⟨ ⊤-contractible ⟩
Contractible ⊤ ↝⟨ H-level-cong _ 0 (inverse []≡[]↔⊤) ⟩
Contractible ([] ≡ []) ↝⟨ H-level.mono (zero≤ (1 + n)) ⟩□
H-level (1 + n) ([] ≡ []) □
H-level-List n h {[]} {y ∷ ys} =
$⟨ ⊥-propositional ⟩
Is-proposition ⊥₀ ↝⟨ H-level-cong _ 1 (inverse []≡∷↔⊥) ⟩
Is-proposition ([] ≡ y ∷ ys) ↝⟨ H-level.mono (suc≤suc (zero≤ n)) ⟩□
H-level (1 + n) ([] ≡ y ∷ ys) □
H-level-List n h {x ∷ xs} {[]} =
$⟨ ⊥-propositional ⟩
Is-proposition ⊥₀ ↝⟨ H-level-cong _ 1 (inverse ∷≡[]↔⊥) ⟩
Is-proposition (x ∷ xs ≡ []) ↝⟨ H-level.mono (suc≤suc (zero≤ n)) ⟩□
H-level (1 + n) (x ∷ xs ≡ []) □
H-level-List n h {x ∷ xs} {y ∷ ys} =
H-level-cong _ (1 + n) (inverse ∷≡∷↔≡×≡)
(×-closure (1 + n) h (H-level-List n h))
| {
"alphanum_fraction": 0.4643319691,
"avg_line_length": 34.2859680284,
"ext": "agda",
"hexsha": "449106820ce15260e69dd6df0c2d6218f11ddef0",
"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/List.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/List.agda",
"max_line_length": 122,
"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/List.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": 7564,
"size": 19303
} |
module Optics.Prism where
open import Agda.Primitive using (Level; _⊔_; lsuc)
open import Data.Product using (_×_; _,_; ∃-syntax; Σ-syntax)
open import Data.Sum using (_⊎_; inj₁; inj₂; fromInj₂)
open import Data.Empty using (⊥-elim)
open import Function.Inverse using (_↔_; inverse)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; module ≡-Reasoning; cong; cong₂; sym)
open import Category.Functor.Arr
open import Category.Functor.Either
open import Category.Profunctor.Star
open import Category.Profunctor.Joker
open import Category.Choice
open import Optics
Prism : ∀ {l} (S T A B : Set l) → Set (lsuc l)
Prism = Optic ChoiceImp
module Prism {l} {S T A B : Set l} (prism : Prism S T A B) where
matching : S → A ⊎ T
matching = matchingOptic S T A B (starChoice eitherApplicative) prism
put : B → T
put = putOptic S T A B (jokerChoice arrFunctor) prism
record LawfulPrism {l} {S A : Set l} (prism' : Prism S S A A) : Set (lsuc l) where
open Prism prism' public
prism : Prism S S A A
prism = prism'
field
matchingput : ∀ (a : A) → matching (put a) ≡ inj₁ a
putmatching : ∀ (s : S) (a : A) → matching s ≡ inj₁ a → put a ≡ s
matchingmatching : ∀ (s t : S) → matching s ≡ inj₂ t → matching t ≡ inj₂ s
matchingWithWitness : (s : S) → (Σ[ a ∈ A ] matching s ≡ inj₁ a) ⊎ (Σ[ t ∈ S ] matching s ≡ inj₂ t)
matchingWithWitness s with matching s
... | inj₁ a = inj₁ (a , refl)
... | inj₂ t = inj₂ (t , refl)
uninjed₁ : ∀ {l₁ l₂} {A : Set l₁} {B : Set l₂} {x x₁ : A} → inj₁ {l₁} {l₂} {A} {B} x ≡ inj₁ {l₁} {l₂} {A} {B} x₁ → x ≡ x₁
uninjed₁ refl = refl
uninjed₂ : ∀ {l₁ l₂} {A : Set l₁} {B : Set l₂} {x x₁ : B} → inj₂ {l₁} {l₂} {A} {B} x ≡ inj₂ {l₁} {l₂} {A} {B} x₁ → x ≡ x₁
uninjed₂ refl = refl
inj₁≢inj₂ : ∀ {l₁ l₂} {A : Set l₁} {B : Set l₂} {x : A} {x₁ : B} → inj₁ x ≢ inj₂ x₁
inj₁≢inj₂ ()
prismIso : ∀ {l} {S A : Set l} {prism : Prism S S A A} → (lawful : LawfulPrism prism) → S ↔ (A ⊎ ∃[ s ] ∃[ t ] (Prism.matching prism s ≡ inj₂ t))
prismIso {_} {S} {A} lawful = inverse to from from∘to to∘from
where
open LawfulPrism lawful
to : S → A ⊎ ∃[ s ] ∃[ t ] (matching s ≡ inj₂ t)
to s with matchingWithWitness s
... | inj₁ (a , _) = inj₁ a
... | inj₂ (t , w) = inj₂ (s , t , w)
from : A ⊎ ∃[ s ] ∃[ t ] (matching s ≡ inj₂ t) → S
from (inj₁ x) = put x
from (inj₂ (s , t , matchs≡injt)) = s
from∘to : (s : S) → from (to s) ≡ s
from∘to s with matchingWithWitness s
... | inj₁ (a , w) = putmatching s a w
... | inj₂ (t , _) = refl
congΣ : ∀ {l₁ l₂} {T : Set l₁} {cmp : Set l₂} (W : T → cmp) (x : cmp) (t t' : T) (w : x ≡ W t) (w' : x ≡ W t') → t ≡ t' → (t , w) ≡ (t' , w')
congΣ _ _ _ _ refl refl refl = refl
to∘from : (elem : A ⊎ ∃[ s ] ∃[ t ] (matching s ≡ inj₂ t)) → to (from elem) ≡ elem
open ≡-Reasoning
to∘from (inj₁ x) with matchingWithWitness (put x)
... | inj₁ ( x₁ , w ) = cong inj₁ (uninjed₁ (inj₁ x₁ ≡⟨ sym w ⟩ matching (put x) ≡⟨ matchingput x ⟩ inj₁ x ∎))
... | inj₂ ( x₁ , w ) = ⊥-elim (inj₁≢inj₂ (inj₁ x ≡⟨ sym (matchingput x) ⟩ matching (put x) ≡⟨ w ⟩ inj₂ x₁ ∎))
to∘from (inj₂ (s , t , w)) with matchingWithWitness s
... | inj₂ (t₁ , w₁) = cong inj₂ (cong (s ,_) (congΣ (λ tᵢ → inj₂ tᵢ) (matching s) t₁ t w₁ w (uninjed₂ (inj₂ t₁ ≡⟨ sym w₁ ⟩ matching s ≡⟨ w ⟩ inj₂ t ∎))))
... | inj₁ (a , w₁) = ⊥-elim (inj₁≢inj₂ (inj₁ a ≡⟨ sym w₁ ⟩ matching s ≡⟨ w ⟩ inj₂ t ∎))
| {
"alphanum_fraction": 0.5452032071,
"avg_line_length": 48.8783783784,
"ext": "agda",
"hexsha": "c60e475323b217bff434afbe806f4878ca2f8608",
"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": "308afeeaa905870dbf1a995fa82e8825dfaf2d74",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crisoagf/agda-optics",
"max_forks_repo_path": "src/Optics/Prism.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74",
"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": "crisoagf/agda-optics",
"max_issues_repo_path": "src/Optics/Prism.agda",
"max_line_length": 185,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crisoagf/agda-optics",
"max_stars_repo_path": "src/Optics/Prism.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1494,
"size": 3617
} |
module product-thms where
open import eq
open import level
open import product
open import unit
open import functions
-- this is called the inspect idiom, in the Agda stdlib
keep : ∀{ℓ}{A : Set ℓ} → (x : A) → Σ A (λ y → x ≡ y)
keep x = ( x , refl )
,inj : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}{a a' : A}{b b' : B} →
(a , b) ≡ (a' , b') → (a ≡ a') ∧ (b ≡ b')
,inj refl = refl , refl
eta-× : ∀{ℓ₁ ℓ₂ ℓ₃}{A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃}{h : A × B → C}
→ (extensionality {ℓ₁ ⊔ ℓ₂}{ℓ₃})
→ (λ c → h (fst c , snd c)) ≡ h
eta-× {A = A}{B}{C}{h} ext = ext eta-×-aux
where
eta-×-aux : ∀{a : Σ A (λ x → B)} → h (fst a , snd a) ≡ h a
eta-×-aux {(a , b)} = refl
eq-× : ∀{ℓ₁ ℓ₂}{A : Set ℓ₁}{B : Set ℓ₂}{a a' : A}{b b' : B}
→ a ≡ a'
→ b ≡ b'
→ (a , b) ≡ (a' , b')
eq-× refl refl = refl
twist-×-iso : ∀{ℓ : level}{U V : Set ℓ}{a : U × V} → (twist-× ∘ twist-×) a ≡ id a
twist-×-iso {a = u , v} = refl
-- This module proves typical isomorphisms about ∧.
module ∧-Isos where
postulate ext-set : ∀{l1 l2 : level} → extensionality {l1} {l2}
∧-unit-l : ∀{ℓ}{A : Set ℓ} → A → A ∧ (⊤ {ℓ})
∧-unit-l x = x , triv
∧-unit-r : ∀{ℓ}{A : Set ℓ} → A → ⊤ ∧ A
∧-unit-r x = twist-× (∧-unit-l x)
∧-unit-l-iso : ∀{ℓ}{A : Set ℓ} → Iso A (A ∧ ⊤)
∧-unit-l-iso {_}{A} = isIso ∧-unit-l fst refl (ext-set aux)
where
aux : {a : A ∧ ⊤} → (fst a , triv) ≡ a
aux {x , triv} = refl
∧-unit-r-iso : ∀{ℓ}{A : Set ℓ} → Iso A (⊤ ∧ A)
∧-unit-r-iso {_}{A} = isIso ∧-unit-r snd refl (ext-set aux)
where
aux : {a : ⊤ ∧ A} → (triv , snd a) ≡ a
aux {triv , x} = refl
∧-assoc₁ : ∀{ℓ}{A B C : Set ℓ} → (A ∧ (B ∧ C)) → ((A ∧ B) ∧ C)
∧-assoc₁ (a , b , c) = ((a , b) , c)
∧-assoc₂ : ∀{ℓ}{A B C : Set ℓ} → ((A ∧ B) ∧ C) → (A ∧ (B ∧ C))
∧-assoc₂ ((a , b) , c) = (a , b , c)
∧-assoc-iso : ∀{ℓ}{A B C : Set ℓ} → Iso (A ∧ (B ∧ C)) ((A ∧ B) ∧ C)
∧-assoc-iso {_}{A}{B}{C} = isIso ∧-assoc₁ ∧-assoc₂ (ext-set aux₁) (ext-set aux₂)
where
aux₁ : {a : A ∧ (B ∧ C)} → ∧-assoc₂ (∧-assoc₁ a) ≡ a
aux₁ {a , (b , c)} = refl
aux₂ : {a : (A ∧ B) ∧ C} → ∧-assoc₁ (∧-assoc₂ a) ≡ a
aux₂ {(a , b) , c} = refl
| {
"alphanum_fraction": 0.4529274005,
"avg_line_length": 29.6527777778,
"ext": "agda",
"hexsha": "f82962f81782fb1827e858e05cc5f0d699b34ab3",
"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": "product-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": "product-thms.agda",
"max_line_length": 82,
"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": "product-thms.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1046,
"size": 2135
} |
{-# OPTIONS --cubical --safe --prop #-}
open import Algebra
open import Prelude
open import Relation.Binary.Equivalence.PropTruncated
module Algebra.Construct.Cayley.Propositional {a} (mon : Monoid a) where
open Monoid mon
record 𝒞 : Type a where
constructor cayley
infixr 7 _⇓_
field
_⇓_ : 𝑆 → 𝑆
small : ∀ x → _⇓_ ε ∙ x ≐ _⇓_ x
open 𝒞 public
⟦_⇓⟧ : 𝒞 → 𝑆
⟦ x ⇓⟧ = x ⇓ ε
⟦_⇑⟧ : 𝑆 → 𝒞
⟦ x ⇑⟧ ⇓ y = x ∙ y
⟦ x ⇑⟧ .small y = ∣ cong (_∙ y) (∙ε x) ∣
ⓔ : 𝒞
ⓔ ⇓ x = x
ⓔ .small x = ∣ ε∙ x ∣
module _ where
open Reasoning
_⊙_ : 𝒞 → 𝒞 → 𝒞
(x ⊙ y) ⇓ z = x ⇓ y ⇓ z
(x ⊙ y) .small z =
x ⇓ y ⇓ ε ∙ z ≐˘⟨ ∙cong (_∙ z) (x .small (y ⇓ ε)) ⟩
x ⇓ ε ∙ y ⇓ ε ∙ z ≡⟨ assoc (x ⇓ ε) (y ⇓ ε) z ⟩
x ⇓ ε ∙ (y ⇓ ε ∙ z) ≐⟨ ∙cong (x ⇓ ε ∙_) (y .small z) ⟩
x ⇓ ε ∙ y ⇓ z ≐⟨ x .small (y ⇓ z) ⟩
x ⇓ y ⇓ z ∎
⊙-assoc : Associative _⊙_
⊙-assoc x y z = refl
ⓔ⊙ : ∀ x → ⓔ ⊙ x ≡ x
ⓔ⊙ x = refl
⊙ⓔ : ∀ x → x ⊙ ⓔ ≡ x
⊙ⓔ x = refl
cayleyMonoid : Monoid a
Monoid.𝑆 cayleyMonoid = 𝒞
Monoid._∙_ cayleyMonoid = _⊙_
Monoid.ε cayleyMonoid = ⓔ
Monoid.assoc cayleyMonoid = ⊙-assoc
Monoid.ε∙ cayleyMonoid = ⓔ⊙
Monoid.∙ε cayleyMonoid = ⊙ⓔ
open import Data.Sigma.Properties
open import Relation.Nullary.Stable
𝒞≡ : {x y : 𝒞} → (∀ z → x ⇓ z ≡ y ⇓ z) → x ≡ y
𝒞≡ { f } { cayley g q } f≡g =
subst
(λ (g′ : 𝑆 → 𝑆) → (q′ : ∀ x → g′ ε ∙ x ≐ g′ x) → f ≡ cayley g′ q′)
(funExt f≡g)
(λ _ → refl)
q
∙-homo : ∀ x y → ⟦ x ∙ y ⇑⟧ ≡ ⟦ x ⇑⟧ ⊙ ⟦ y ⇑⟧
∙-homo x y = 𝒞≡ (assoc x y)
ε-homo : ⟦ ε ⇑⟧ ≡ ⓔ
ε-homo = 𝒞≡ ε∙
homo-to : MonoidHomomorphism mon ⟶ cayleyMonoid
MonoidHomomorphism_⟶_.f homo-to = ⟦_⇑⟧
MonoidHomomorphism_⟶_.∙-homo homo-to = ∙-homo
MonoidHomomorphism_⟶_.ε-homo homo-to = ε-homo
ⓔ-homo : ⟦ ⓔ ⇓⟧ ≡ ε
ⓔ-homo = refl
module _ (sIsStable : ∀ {x y : 𝑆} → Stable (x ≡ y)) where
⊙-homo : ∀ x y → ⟦ x ⊙ y ⇓⟧ ≡ ⟦ x ⇓⟧ ∙ ⟦ y ⇓⟧
⊙-homo x y = sym (unsquash sIsStable (x .small ⟦ y ⇓⟧))
𝒞-iso : 𝒞 ⇔ 𝑆
fun 𝒞-iso = ⟦_⇓⟧
inv 𝒞-iso = ⟦_⇑⟧
rightInv 𝒞-iso = ∙ε
leftInv 𝒞-iso x = 𝒞≡ λ y → unsquash sIsStable (x .small y)
homo-from : MonoidHomomorphism cayleyMonoid ⟶ mon
MonoidHomomorphism_⟶_.f homo-from = ⟦_⇓⟧
MonoidHomomorphism_⟶_.∙-homo homo-from = ⊙-homo
MonoidHomomorphism_⟶_.ε-homo homo-from = ⓔ-homo
| {
"alphanum_fraction": 0.5318202047,
"avg_line_length": 23.1649484536,
"ext": "agda",
"hexsha": "fd14a18395301abbac8171ccf38247c9b07aab4f",
"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": "Algebra/Construct/Cayley/Propositional.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": "Algebra/Construct/Cayley/Propositional.agda",
"max_line_length": 72,
"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": "Algebra/Construct/Cayley/Propositional.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": 1279,
"size": 2247
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Boolean algebra expressions
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Algebra.Properties.BooleanAlgebra.Expression
{b} (B : BooleanAlgebra b b)
where
open BooleanAlgebra B
open import Category.Applicative
import Category.Applicative.Indexed as Applicative
open import Category.Monad
open import Data.Fin using (Fin)
open import Data.Nat
open import Data.Product using (_,_; proj₁; proj₂)
open import Data.Vec as Vec using (Vec)
import Data.Vec.Categorical as VecCat
import Function.Identity.Categorical as IdCat
open import Data.Vec.Properties using (lookup-map)
open import Data.Vec.Relation.Binary.Pointwise.Extensional as PW
using (Pointwise; ext)
open import Function
open import Relation.Binary.PropositionalEquality as P using (_≗_)
import Relation.Binary.Reflection as Reflection
-- Expressions made up of variables and the operations of a boolean
-- algebra.
infixr 7 _and_
infixr 6 _or_
data Expr n : Set b where
var : (x : Fin n) → Expr n
_or_ _and_ : (e₁ e₂ : Expr n) → Expr n
not : (e : Expr n) → Expr n
top bot : Expr n
-- The semantics of an expression, parametrised by an applicative
-- functor.
module Semantics
{F : Set b → Set b}
(A : RawApplicative F)
where
open RawApplicative A
⟦_⟧ : ∀ {n} → Expr n → Vec (F Carrier) n → F Carrier
⟦ var x ⟧ ρ = Vec.lookup ρ x
⟦ e₁ or e₂ ⟧ ρ = pure _∨_ ⊛ ⟦ e₁ ⟧ ρ ⊛ ⟦ e₂ ⟧ ρ
⟦ e₁ and e₂ ⟧ ρ = pure _∧_ ⊛ ⟦ e₁ ⟧ ρ ⊛ ⟦ e₂ ⟧ ρ
⟦ not e ⟧ ρ = pure ¬_ ⊛ ⟦ e ⟧ ρ
⟦ top ⟧ ρ = pure ⊤
⟦ bot ⟧ ρ = pure ⊥
-- flip Semantics.⟦_⟧ e is natural.
module Naturality
{F₁ F₂ : Set b → Set b}
{A₁ : RawApplicative F₁}
{A₂ : RawApplicative F₂}
(f : Applicative.Morphism A₁ A₂)
where
open P.≡-Reasoning
open Applicative.Morphism f
open Semantics A₁ renaming (⟦_⟧ to ⟦_⟧₁)
open Semantics A₂ renaming (⟦_⟧ to ⟦_⟧₂)
open RawApplicative A₁ renaming (pure to pure₁; _⊛_ to _⊛₁_)
open RawApplicative A₂ renaming (pure to pure₂; _⊛_ to _⊛₂_)
natural : ∀ {n} (e : Expr n) → op ∘ ⟦ e ⟧₁ ≗ ⟦ e ⟧₂ ∘ Vec.map op
natural (var x) ρ = begin
op (Vec.lookup ρ x) ≡⟨ P.sym $ lookup-map x op ρ ⟩
Vec.lookup (Vec.map op ρ) x ∎
natural (e₁ or e₂) ρ = begin
op (pure₁ _∨_ ⊛₁ ⟦ e₁ ⟧₁ ρ ⊛₁ ⟦ e₂ ⟧₁ ρ) ≡⟨ op-⊛ _ _ ⟩
op (pure₁ _∨_ ⊛₁ ⟦ e₁ ⟧₁ ρ) ⊛₂ op (⟦ e₂ ⟧₁ ρ) ≡⟨ P.cong₂ _⊛₂_ (op-⊛ _ _) P.refl ⟩
op (pure₁ _∨_) ⊛₂ op (⟦ e₁ ⟧₁ ρ) ⊛₂ op (⟦ e₂ ⟧₁ ρ) ≡⟨ P.cong₂ _⊛₂_ (P.cong₂ _⊛₂_ (op-pure _) (natural e₁ ρ))
(natural e₂ ρ) ⟩
pure₂ _∨_ ⊛₂ ⟦ e₁ ⟧₂ (Vec.map op ρ) ⊛₂ ⟦ e₂ ⟧₂ (Vec.map op ρ) ∎
natural (e₁ and e₂) ρ = begin
op (pure₁ _∧_ ⊛₁ ⟦ e₁ ⟧₁ ρ ⊛₁ ⟦ e₂ ⟧₁ ρ) ≡⟨ op-⊛ _ _ ⟩
op (pure₁ _∧_ ⊛₁ ⟦ e₁ ⟧₁ ρ) ⊛₂ op (⟦ e₂ ⟧₁ ρ) ≡⟨ P.cong₂ _⊛₂_ (op-⊛ _ _) P.refl ⟩
op (pure₁ _∧_) ⊛₂ op (⟦ e₁ ⟧₁ ρ) ⊛₂ op (⟦ e₂ ⟧₁ ρ) ≡⟨ P.cong₂ _⊛₂_ (P.cong₂ _⊛₂_ (op-pure _) (natural e₁ ρ))
(natural e₂ ρ) ⟩
pure₂ _∧_ ⊛₂ ⟦ e₁ ⟧₂ (Vec.map op ρ) ⊛₂ ⟦ e₂ ⟧₂ (Vec.map op ρ) ∎
natural (not e) ρ = begin
op (pure₁ ¬_ ⊛₁ ⟦ e ⟧₁ ρ) ≡⟨ op-⊛ _ _ ⟩
op (pure₁ ¬_) ⊛₂ op (⟦ e ⟧₁ ρ) ≡⟨ P.cong₂ _⊛₂_ (op-pure _) (natural e ρ) ⟩
pure₂ ¬_ ⊛₂ ⟦ e ⟧₂ (Vec.map op ρ) ∎
natural top ρ = begin
op (pure₁ ⊤) ≡⟨ op-pure _ ⟩
pure₂ ⊤ ∎
natural bot ρ = begin
op (pure₁ ⊥) ≡⟨ op-pure _ ⟩
pure₂ ⊥ ∎
-- An example of how naturality can be used: Any boolean algebra can
-- be lifted, in a pointwise manner, to vectors of carrier elements.
lift : ℕ → BooleanAlgebra b b
lift n = record
{ Carrier = Vec Carrier n
; _≈_ = Pointwise _≈_
; _∨_ = zipWith _∨_
; _∧_ = zipWith _∧_
; ¬_ = map ¬_
; ⊤ = pure ⊤
; ⊥ = pure ⊥
; isBooleanAlgebra = record
{ isDistributiveLattice = record
{ isLattice = record
{ isEquivalence = PW.isEquivalence isEquivalence
; ∨-comm = λ _ _ → ext λ i →
solve i 2 (λ x y → x or y , y or x)
(∨-comm _ _) _ _
; ∨-assoc = λ _ _ _ → ext λ i →
solve i 3
(λ x y z → (x or y) or z , x or (y or z))
(∨-assoc _ _ _) _ _ _
; ∨-cong = λ xs≈us ys≈vs → ext λ i →
solve₁ i 4 (λ x y u v → x or y , u or v)
_ _ _ _
(∨-cong (Pointwise.app xs≈us i)
(Pointwise.app ys≈vs i))
; ∧-comm = λ _ _ → ext λ i →
solve i 2 (λ x y → x and y , y and x)
(∧-comm _ _) _ _
; ∧-assoc = λ _ _ _ → ext λ i →
solve i 3
(λ x y z → (x and y) and z ,
x and (y and z))
(∧-assoc _ _ _) _ _ _
; ∧-cong = λ xs≈ys us≈vs → ext λ i →
solve₁ i 4 (λ x y u v → x and y , u and v)
_ _ _ _
(∧-cong (Pointwise.app xs≈ys i)
(Pointwise.app us≈vs i))
; absorptive =
(λ _ _ → ext λ i →
solve i 2 (λ x y → x or (x and y) , x) (∨-absorbs-∧ _ _) _ _) ,
(λ _ _ → ext λ i →
solve i 2 (λ x y → x and (x or y) , x) (∧-absorbs-∨ _ _) _ _)
}
; ∨-∧-distribʳ = λ _ _ _ → ext λ i →
solve i 3
(λ x y z → (y and z) or x ,
(y or x) and (z or x))
(∨-∧-distribʳ _ _ _) _ _ _
}
; ∨-complementʳ = λ _ → ext λ i →
solve i 1 (λ x → x or (not x) , top)
(∨-complementʳ _) _
; ∧-complementʳ = λ _ → ext λ i →
solve i 1 (λ x → x and (not x) , bot)
(∧-complementʳ _) _
; ¬-cong = λ xs≈ys → ext λ i →
solve₁ i 2 (λ x y → not x , not y) _ _
(¬-cong (Pointwise.app xs≈ys i))
}
}
where
open RawApplicative VecCat.applicative
using (pure; zipWith) renaming (_<$>_ to map)
⟦_⟧Id : ∀ {n} → Expr n → Vec Carrier n → Carrier
⟦_⟧Id = Semantics.⟦_⟧ IdCat.applicative
⟦_⟧Vec : ∀ {m n} → Expr n → Vec (Vec Carrier m) n → Vec Carrier m
⟦_⟧Vec = Semantics.⟦_⟧ VecCat.applicative
open module R {n} (i : Fin n) =
Reflection setoid var
(λ e ρ → Vec.lookup (⟦ e ⟧Vec ρ) i)
(λ e ρ → ⟦ e ⟧Id (Vec.map (flip Vec.lookup i) ρ))
(λ e ρ → sym $ reflexive $
Naturality.natural (VecCat.lookup-morphism i) e ρ)
| {
"alphanum_fraction": 0.4321020113,
"avg_line_length": 40.8978494624,
"ext": "agda",
"hexsha": "c7b993a3d87351aa69afd5b8945dbcf48f71d06d",
"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/Algebra/Properties/BooleanAlgebra/Expression.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/Algebra/Properties/BooleanAlgebra/Expression.agda",
"max_line_length": 124,
"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/Algebra/Properties/BooleanAlgebra/Expression.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2575,
"size": 7607
} |
module Syntax where
open import Agda.Builtin.FromNat public
open import Agda.Builtin.FromNeg public
record plus-syntax (A : Set) (B : A → Set) (C : ∀ x → B x → Set) : Set where
infixl 6 _+_
field _+_ : ∀ x (y : B x) → C x y
plus-syntax-simple = λ A B C → plus-syntax A (λ _ → B) (λ _ _ → C)
open plus-syntax {{…}} public
record minus-syntax (A : Set) (B : A → Set) (C : ∀ x → B x → Set) : Set where
infixl 6 _-_
field _-_ : ∀ x (y : B x) → C x y
minus-syntax-simple = λ A B C → minus-syntax A (λ _ → B) (λ _ _ → C)
open minus-syntax {{…}} public
record times-syntax (A : Set) (B : A → Set) (C : ∀ x → B x → Set) : Set where
infixl 7 _*_
field _*_ : ∀ x (y : B x) → C x y
times-syntax-simple = λ A B C → times-syntax A (λ _ → B) (λ _ _ → C)
open times-syntax {{…}} public
record raise-syntax (A : Set) (B : A → Set) (C : ∀ x → B x → Set) : Set where
infixl 8 _^_
field _^_ : ∀ x (y : B x) → C x y
raise-syntax-simple = λ A B C → raise-syntax A (λ _ → B) (λ _ _ → C)
open raise-syntax {{…}} public
| {
"alphanum_fraction": 0.5668292683,
"avg_line_length": 27.7027027027,
"ext": "agda",
"hexsha": "a7f55503d9d2fd3387fb942ace3f45432122b584",
"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": "67ea7b96228c592daf79e800ebe4a7c12ed7221e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "kcsmnt0/numbers",
"max_forks_repo_path": "src/Syntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e",
"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": "kcsmnt0/numbers",
"max_issues_repo_path": "src/Syntax.agda",
"max_line_length": 77,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "67ea7b96228c592daf79e800ebe4a7c12ed7221e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "kcsmnt0/numbers",
"max_stars_repo_path": "src/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2020-01-16T07:16:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-05-20T01:29:41.000Z",
"num_tokens": 381,
"size": 1025
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Lift where
open import Level
open import Categories.Category
open import Categories.Functor using (Functor)
liftC : ∀ {o ℓ e} o′ ℓ′ e′ → Category o ℓ e → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)
liftC o′ ℓ′ e′ C = record
{ Obj = Lift o′ Obj
; _⇒_ = λ X Y → Lift ℓ′ (lower X ⇒ lower Y)
; _≈_ = λ f g → Lift e′ (lower f ≈ lower g)
; id = lift id
; _∘_ = λ f g → lift (lower f ∘ lower g)
; assoc = lift assoc
; sym-assoc = lift sym-assoc
; identityˡ = lift identityˡ
; identityʳ = lift identityʳ
; identity² = lift identity²
; equiv = record
{ refl = lift Equiv.refl
; sym = λ eq → lift (Equiv.sym (lower eq))
; trans = λ eq eq′ → lift (Equiv.trans (lower eq) (lower eq′))
}
; ∘-resp-≈ = λ eq eq′ → lift (∘-resp-≈ (lower eq) (lower eq′))
}
where open Category C
liftF : ∀ {o ℓ e} o′ ℓ′ e′ (C : Category o ℓ e) → Functor C (liftC o′ ℓ′ e′ C)
liftF o′ ℓ′ e′ C = record
{ F₀ = lift
; F₁ = lift
; identity = lift refl
; homomorphism = lift refl
; F-resp-≈ = lift
}
where open Category C
open Equiv
unliftF : ∀ {o ℓ e} o′ ℓ′ e′ (C : Category o ℓ e) → Functor (liftC o′ ℓ′ e′ C) C
unliftF o′ ℓ′ e′ C = record
{ F₀ = lower
; F₁ = lower
; identity = refl
; homomorphism = refl
; F-resp-≈ = lower
}
where open Category C
open Equiv
| {
"alphanum_fraction": 0.5346938776,
"avg_line_length": 28.8235294118,
"ext": "agda",
"hexsha": "a36534426e01626c52469d74e82d913d6ed9950d",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Lift.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Lift.agda",
"max_line_length": 81,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Lift.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 560,
"size": 1470
} |
module L.Base.Id.Properties where
open import L.Base.Id.Core
sym : ∀{a} {A : Set a} {x y : A} → x ≡ y → y ≡ x
sym {x = x}{y = y} = λ p → J (λ a b _ → b ≡ a) (λ _ → refl) x y p
tran : ∀{a} {A : Set a} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
tran {x = x}{y = y}{z = z} =
λ p → J (λ a b p → b ≡ z → a ≡ z) (λ a q → q) x y p
ap : ∀{a b} {A : Set a} {B : Set b} {x y : A}
→ (f : A → B) → x ≡ y → (f x) ≡ (f y)
ap {x = x}{y = y} =
λ f p → J (λ a b p → (f a) ≡ (f b)) (λ u → refl) x y p
transport : ∀{a b} {A : Set a} {x y : A}
→ (B : (x : A) → Set b) → x ≡ y → B x → B y
transport {x = x}{y = y} =
λ B p → J (λ a b p → B a → B b) (λ a q → q) x y p
| {
"alphanum_fraction": 0.3761061947,
"avg_line_length": 32.2857142857,
"ext": "agda",
"hexsha": "4637bf04b8f743fd6b1689b03fd3c3f65d08571c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "borszag/smallib",
"max_forks_repo_path": "src/L/Base/Id/Properties.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "borszag/smallib",
"max_issues_repo_path": "src/L/Base/Id/Properties.agda",
"max_line_length": 65,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "borszag/smallib",
"max_stars_repo_path": "src/L/Base/Id/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 339,
"size": 678
} |
module BadInductionRecursion1 where
data Unit : Set where
unit : Unit
mutual
data D : Set where
d : forall u -> (D′ u -> D′ u) -> D
D′ : Unit -> Set
D′ unit = D
_·_ : D -> D -> D
d unit f · x = f x
ω : D
ω = d unit (\x -> x · x)
Ω : D
Ω = ω · ω
| {
"alphanum_fraction": 0.5018867925,
"avg_line_length": 12.0454545455,
"ext": "agda",
"hexsha": "4bafbfb38a2d9b2565e684c32af7d9bb5bcf4a86",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/BadInductionRecursion1.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/BadInductionRecursion1.agda",
"max_line_length": 39,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/BadInductionRecursion1.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": 112,
"size": 265
} |
------------------------------------------------------------------------------
-- The FOTC co-inductive natural numbers type
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- N.B. This module is re-exported by FOTC.Data.Conat.
-- Adapted from (Sander 1992).
module FOTC.Data.Conat.Type where
open import FOTC.Base
------------------------------------------------------------------------------
-- The FOTC co-inductive natural numbers type (co-inductive predicate
-- for total co-inductive natural)
-- Functional for the NatF predicate.
-- NatF : (D → Set) → D → Set
-- NatF A n = n = zero ∨ (∃[ n' ] n = succ n' ∧ A n')
-- Conat is the greatest fixed-point of NatF (by Conat-out and
-- Conat-coind).
postulate Conat : D → Set
-- Conat is a post-fixed point of NatF, i.e.
--
-- Conat ≤ NatF Conat.
postulate
Conat-out : ∀ {n} → Conat n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n')
{-# ATP axiom Conat-out #-}
-- Conat is the greatest post-fixed point of NatF, i.e.
--
-- ∀ A. A ≤ NatF A ⇒ A ≤ Conat.
--
-- N.B. This is an axiom schema. Because in the automatic proofs we
-- *must* use an instance, we do not add this postulate as an ATP
-- axiom.
postulate
Conat-coind :
(A : D → Set) →
-- A is post-fixed point of NatF.
(∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n')) →
-- Conat is greater than A.
∀ {n} → A n → Conat n
------------------------------------------------------------------------------
-- References
--
-- Sander, Herbert P. (1992). A Logic of Functional Programs with an
-- Application to Concurrency. PhD thesis. Department of Computer
-- Sciences: Chalmers University of Technology and University of
-- Gothenburg.
| {
"alphanum_fraction": 0.5138150903,
"avg_line_length": 31.3666666667,
"ext": "agda",
"hexsha": "ae7f17ba928dddbcaf58585626f4dd87822f0d26",
"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/Type.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Data/Conat/Type.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Data/Conat/Type.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 490,
"size": 1882
} |
module Connectives where
-- Imports
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong)
open Eq.≡-Reasoning
open import Data.Nat using (ℕ)
open import Function using (_∘_)
-- open import plfa.part1.Isomorphism using (_≃_; _≲_; extensionality)
-- open plfa.part1.Isomorphism.≃-Reasoning
postulate
-- 外延性の公理
extensionality : ∀ {A B : Set} {f g : A → B}
→ (∀ (x : A) → f x ≡ g x)
-----------------------
→ f ≡ g
-- 同型
infix 0 _≃_
record _≃_ (A B : Set) : Set where
field
to : A → B
from : B → A
from∘to : ∀ (x : A) → from (to x) ≡ x
to∘from : ∀ (y : B) → to (from y) ≡ y
open _≃_
≃-refl : ∀ {A : Set}
-----
→ A ≃ A
≃-refl =
record
{ to = λ{x → x}
; from = λ{y → y}
; from∘to = λ{x → refl}
; to∘from = λ{y → refl}
}
≃-trans : ∀ {A B C : Set}
→ A ≃ B
→ B ≃ C
-----
→ A ≃ C
≃-trans A≃B B≃C =
record
{ to = to B≃C ∘ to A≃B
; from = from A≃B ∘ from B≃C
; from∘to = λ{x →
begin
(from A≃B ∘ from B≃C) ((to B≃C ∘ to A≃B) x)
≡⟨⟩
from A≃B (from B≃C (to B≃C (to A≃B x)))
≡⟨ cong (from A≃B) (from∘to B≃C (to A≃B x)) ⟩
from A≃B (to A≃B x)
≡⟨ from∘to A≃B x ⟩
x
∎}
; to∘from = λ{y →
begin
(to B≃C ∘ to A≃B) ((from A≃B ∘ from B≃C) y)
≡⟨⟩
to B≃C (to A≃B (from A≃B (from B≃C y)))
≡⟨ cong (to B≃C) (to∘from A≃B (from B≃C y)) ⟩
to B≃C (from B≃C y)
≡⟨ to∘from B≃C y ⟩
y
∎}
}
module ≃-Reasoning where
infix 1 ≃-begin_
infixr 2 _≃⟨_⟩_
infix 3 _≃-∎
≃-begin_ : ∀ {A B : Set}
→ A ≃ B
-----
→ A ≃ B
≃-begin A≃B = A≃B
_≃⟨_⟩_ : ∀ (A : Set) {B C : Set}
→ A ≃ B
→ B ≃ C
-----
→ A ≃ C
A ≃⟨ A≃B ⟩ B≃C = ≃-trans A≃B B≃C
_≃-∎ : ∀ (A : Set)
-----
→ A ≃ A
A ≃-∎ = ≃-refl
open ≃-Reasoning
-- 埋め込み
infix 0 _≲_
record _≲_ (A B : Set) : Set where
field
to : A → B
from : B → A
from∘to : ∀ (x : A) → from (to x) ≡ x
open _≲_
-- Conjunction is product
-- 直積
data _×_ (A B : Set) : Set where
⟨_,_⟩ :
A
→ B
-----
→ A × B
proj₁ : ∀ {A B : Set}
→ A × B
-----
→ A
proj₁ ⟨ x , y ⟩ = x
proj₂ : ∀ {A B : Set}
→ A × B
-----
→ B
proj₂ ⟨ x , y ⟩ = y
record _×′_ (A B : Set) : Set where
field
proj₁′ : A
proj₂′ : B
open _×′_
η-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w
η-× ⟨ x , y ⟩ = refl
infixr 2 _×_
data Bool : Set where
true : Bool
false : Bool
data Tri : Set where
aa : Tri
bb : Tri
cc : Tri
×-count : Bool × Tri → ℕ
×-count ⟨ true , aa ⟩ = 1
×-count ⟨ true , bb ⟩ = 2
×-count ⟨ true , cc ⟩ = 3
×-count ⟨ false , aa ⟩ = 4
×-count ⟨ false , bb ⟩ = 5
×-count ⟨ false , cc ⟩ = 6
×-comm : ∀ {A B : Set} → A × B ≃ B × A
×-comm =
record
{ to = λ{ ⟨ x , y ⟩ → ⟨ y , x ⟩ }
; from = λ{ ⟨ y , x ⟩ → ⟨ x , y ⟩ }
; from∘to = λ{ ⟨ x , y ⟩ → refl }
; to∘from = λ{ ⟨ y , x ⟩ → refl }
}
×-assoc : ∀ {A B C : Set} → (A × B) × C ≃ A × (B × C)
×-assoc =
record
{ to = λ{ ⟨ ⟨ x , y ⟩ , z ⟩ → ⟨ x , ⟨ y , z ⟩ ⟩ }
; from = λ{ ⟨ x , ⟨ y , z ⟩ ⟩ → ⟨ ⟨ x , y ⟩ , z ⟩ }
; from∘to = λ{ ⟨ ⟨ x , y ⟩ , z ⟩ → refl }
; to∘from = λ{ ⟨ x , ⟨ y , z ⟩ ⟩ → refl }
}
-- Truth is unit
data ⊤ : Set where
tt :
--
⊤
η-⊤ : ∀ (w : ⊤) → tt ≡ w
η-⊤ tt = refl
⊤-count : ⊤ → ℕ
⊤-count tt = 1
⊤-identityˡ : ∀ {A : Set} → ⊤ × A ≃ A
⊤-identityˡ =
record
{ to = λ{ ⟨ tt , x ⟩ → x }
; from = λ{ x → ⟨ tt , x ⟩ }
; from∘to = λ{ ⟨ tt , x ⟩ → refl }
; to∘from = λ{ x → refl }
}
⊤-identityʳ : ∀ {A : Set} → (A × ⊤) ≃ A
⊤-identityʳ {A} =
≃-begin
(A × ⊤)
≃⟨ ×-comm ⟩
(⊤ × A)
≃⟨ ⊤-identityˡ ⟩
A
≃-∎
-- Disjunction is sum
-- 直和
data _⊎_ (A B : Set) : Set where
inj₁ :
A
-----
→ A ⊎ B
inj₂ :
B
-----
→ A ⊎ B
case-⊎ : ∀ {A B C : Set}
→ (A → C)
→ (B → C)
→ A ⊎ B
-----------
→ C
case-⊎ f g (inj₁ x) = f x
case-⊎ f g (inj₂ y) = g y
η-⊎ : ∀ {A B : Set} (w : A ⊎ B) → case-⊎ inj₁ inj₂ w ≡ w
η-⊎ (inj₁ x) = refl
η-⊎ (inj₂ y) = refl
uniq-⊎ : ∀ {A B C : Set} (h : A ⊎ B → C) (w : A ⊎ B) →
case-⊎ (h ∘ inj₁) (h ∘ inj₂) w ≡ h w
uniq-⊎ h (inj₁ x) = refl
uniq-⊎ h (inj₂ y) = refl
infixr 1 _⊎_
⊎-count : Bool ⊎ Tri → ℕ
⊎-count (inj₁ true) = 1
⊎-count (inj₁ false) = 2
⊎-count (inj₂ aa) = 3
⊎-count (inj₂ bb) = 4
⊎-count (inj₂ cc) = 5
-- False is empty
data ⊥ : Set where
-- no clauses!
⊥-elim : ∀ {A : Set}
→ ⊥
--
→ A
⊥-elim ()
uniq-⊥ : ∀ {C : Set} (h : ⊥ → C) (w : ⊥) → ⊥-elim w ≡ h w
uniq-⊥ h ()
⊥-count : ⊥ → ℕ
⊥-count ()
-- Implication is function
→-elim : ∀ {A B : Set}
→ (A → B)
→ A
-------
→ B
→-elim L M = L M
η-→ : ∀ {A B : Set} (f : A → B) → (λ (x : A) → f x) ≡ f
η-→ f = refl
→-count : (Bool → Tri) → ℕ
→-count f with f true | f false
... | aa | aa = 1
... | aa | bb = 2
... | aa | cc = 3
... | bb | aa = 4
... | bb | bb = 5
... | bb | cc = 6
... | cc | aa = 7
... | cc | bb = 8
... | cc | cc = 9
currying : ∀ {A B C : Set} → (A → B → C) ≃ (A × B → C)
currying =
record
{ to = λ{ f → λ{ ⟨ x , y ⟩ → f x y }}
; from = λ{ g → λ{ x → λ{ y → g ⟨ x , y ⟩ }}}
; from∘to = λ{ f → refl }
; to∘from = λ{ g → extensionality λ{ ⟨ x , y ⟩ → refl }}
}
→-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B → C) ≃ ((A → C) × (B → C))
→-distrib-⊎ =
record
{ to = λ{ f → ⟨ f ∘ inj₁ , f ∘ inj₂ ⟩ }
; from = λ{ ⟨ g , h ⟩ → λ{ (inj₁ x) → g x ; (inj₂ y) → h y } }
; from∘to = λ{ f → extensionality λ{ (inj₁ x) → refl ; (inj₂ y) → refl } }
; to∘from = λ{ ⟨ g , h ⟩ → refl }
}
→-distrib-× : ∀ {A B C : Set} → (A → B × C) ≃ (A → B) × (A → C)
→-distrib-× =
record
{ to = λ{ f → ⟨ proj₁ ∘ f , proj₂ ∘ f ⟩ }
; from = λ{ ⟨ g , h ⟩ → λ x → ⟨ g x , h x ⟩ }
; from∘to = λ{ f → extensionality λ{ x → η-× (f x) } }
; to∘from = λ{ ⟨ g , h ⟩ → refl }
}
-- Distribution
×-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B) × C ≃ (A × C) ⊎ (B × C)
×-distrib-⊎ =
record
{ to = λ{ ⟨ inj₁ x , z ⟩ → (inj₁ ⟨ x , z ⟩)
; ⟨ inj₂ y , z ⟩ → (inj₂ ⟨ y , z ⟩)
}
; from = λ{ (inj₁ ⟨ x , z ⟩) → ⟨ inj₁ x , z ⟩
; (inj₂ ⟨ y , z ⟩) → ⟨ inj₂ y , z ⟩
}
; from∘to = λ{ ⟨ inj₁ x , z ⟩ → refl
; ⟨ inj₂ y , z ⟩ → refl
}
; to∘from = λ{ (inj₁ ⟨ x , z ⟩) → refl
; (inj₂ ⟨ y , z ⟩) → refl
}
}
⊎-distrib-× : ∀ {A B C : Set} → (A × B) ⊎ C ≲ (A ⊎ C) × (B ⊎ C)
⊎-distrib-× =
record
{ to = λ{ (inj₁ ⟨ x , y ⟩) → ⟨ inj₁ x , inj₁ y ⟩
; (inj₂ z) → ⟨ inj₂ z , inj₂ z ⟩
}
; from = λ{ ⟨ inj₁ x , inj₁ y ⟩ → (inj₁ ⟨ x , y ⟩)
; ⟨ inj₁ x , inj₂ z ⟩ → (inj₂ z)
; ⟨ inj₂ z , _ ⟩ → (inj₂ z)
}
; from∘to = λ{ (inj₁ ⟨ x , y ⟩) → refl
; (inj₂ z) → refl
}
}
| {
"alphanum_fraction": 0.3635863586,
"avg_line_length": 20.6005665722,
"ext": "agda",
"hexsha": "04ebe307bcea6d3d1a57a36fe626da651d02213b",
"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": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "akiomik/plfa-solutions",
"max_forks_repo_path": "part1/connectives/Connectives.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"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": "akiomik/plfa-solutions",
"max_issues_repo_path": "part1/connectives/Connectives.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "akiomik/plfa-solutions",
"max_stars_repo_path": "part1/connectives/Connectives.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z",
"num_tokens": 3457,
"size": 7272
} |
module Numeral.Natural.Oper.Proofs.Order where
open import Functional
open import Logic
open import Logic.Propositional
open import Logic.Propositional.Theorems
open import Numeral.Natural
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Proofs
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Classical
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs
open import Relator.Ordering.Proofs
open import Structure.Function.Domain
open import Structure.Operator
open import Structure.Operator.Properties
open import Structure.Relator.Properties
open import Syntax.Transitivity
[≤]ₗ[+] : ∀{x y : ℕ} → (x + y ≤ x) → (y ≡ 𝟎)
[≤]ₗ[+] {𝟎} = [≤][0]ᵣ
[≤]ₗ[+] {𝐒(x)}{y} (proof) = [≤]ₗ[+] {x} ([≤]-without-[𝐒] {x + y} {x} (proof))
[≤]-with-[+]ᵣ : ∀{x y z : ℕ} → (x ≤ y) → (x + z ≤ y + z)
[≤]-with-[+]ᵣ {_}{_}{𝟎} (proof) = proof
[≤]-with-[+]ᵣ {_}{_}{𝐒(z)} (proof) = [≤]-with-[𝐒] ⦃ [≤]-with-[+]ᵣ {_}{_}{z} (proof) ⦄
[≤]-with-[+]ₗ : ∀{x y z : ℕ} → (x ≤ y) → (z + x ≤ z + y)
[≤]-with-[+]ₗ {.0} {𝟎} {z } min = reflexivity(_≤_)
[≤]-with-[+]ₗ {.0} {𝐒 y} {z} min = [≤]-successor([≤]-with-[+]ₗ {0}{y}{z} [≤]-minimum)
[≤]-with-[+]ₗ {𝐒 x} {𝐒 y} {z} (succ xy ) = [≤]-with-[𝐒] ⦃ [≤]-with-[+]ₗ {x} {y} {z} xy ⦄
[≤]-of-[+]ᵣ : ∀{x y : ℕ} → (y ≤ x + y)
[≤]-of-[+]ᵣ {x} {𝟎} = [≤]-minimum
[≤]-of-[+]ᵣ {𝟎} {𝐒 x} = reflexivity(_≤_)
[≤]-of-[+]ᵣ {𝐒 x} {𝐒 y} = [≤]-with-[𝐒] ⦃ [≤]-of-[+]ᵣ {𝐒 x}{y} ⦄
[≤]-of-[+]ₗ : ∀{x y : ℕ} → (x ≤ x + y)
[≤]-of-[+]ₗ {𝟎} {y} = [≤]-minimum
[≤]-of-[+]ₗ {𝐒 x} {𝟎} = reflexivity(_≤_)
[≤]-of-[+]ₗ {𝐒 x} {𝐒 y} = [≤]-with-[𝐒] ⦃ [≤]-of-[+]ₗ {x}{𝐒 y} ⦄
[≤]-with-[+] : ∀{x₁ y₁ : ℕ} → ⦃ _ : (x₁ ≤ y₁)⦄ → ∀{x₂ y₂ : ℕ} → ⦃ _ : (x₂ ≤ y₂)⦄ → (x₁ + x₂ ≤ y₁ + y₂)
[≤]-with-[+] {x₁} {y₁} ⦃ x1y1 ⦄ {.0} {y₂} ⦃ min ⦄ = transitivity(_≤_) x1y1 [≤]-of-[+]ₗ
[≤]-with-[+] {x₁} {y₁} ⦃ x1y1 ⦄ {𝐒 x₂} {𝐒 y₂} ⦃ succ p ⦄ = succ ([≤]-with-[+] {x₁} {y₁} {x₂} {y₂} ⦃ p ⦄)
[≤]-from-[+] : ∀{ℓ}{P : ℕ → Stmt{ℓ}}{x} → (∀{n} → P(x + n)) → (∀{y} → ⦃ _ : (x ≤ y) ⦄ → P(y))
[≤]-from-[+] {ℓ} {P} {𝟎} anpxn {y} ⦃ [≤]-minimum ⦄ = anpxn{y}
[≤]-from-[+] {ℓ} {P} {𝐒 x} anpxn {𝐒 y} ⦃ succ xy ⦄ = [≤]-from-[+] {ℓ} {P ∘ 𝐒} {x} anpxn {y} ⦃ xy ⦄
[−₀][+]-nullify2 : ∀{x y} → (x ≤ y) ↔ (x + (y −₀ x) ≡ y)
[−₀][+]-nullify2 {x}{y} = [↔]-intro (l{x}{y}) (r{x}{y}) where
l : ∀{x y} → (x ≤ y) ← (x + (y −₀ x) ≡ y)
l {𝟎} {_} _ = [≤]-minimum
l {𝐒(_)}{𝟎} ()
l {𝐒(x)}{𝐒(y)} proof = [≤]-with-[𝐒] ⦃ l{x}{y} (injective(𝐒) proof) ⦄
r : ∀{x y} → (x ≤ y) → (x + (y −₀ x) ≡ y)
r {𝟎} {𝟎} proof = [≡]-intro
r {𝟎} {𝐒(_)} proof = [≡]-intro
r {𝐒(_)}{𝟎} ()
r {𝐒(x)}{𝐒(y)} (succ proof) = [≡]-with(𝐒) (r{x}{y} (proof))
[−₀][+]-nullify2ᵣ : ∀{x y} → (x ≤ y) ↔ ((y −₀ x) + x ≡ y)
[−₀][+]-nullify2ᵣ {x}{y} = [↔]-transitivity [−₀][+]-nullify2 ([≡]-substitution (commutativity(_+_) {x}{y −₀ x}) {_≡ y})
[−₀]-when-0 : ∀{x y} → (x ≤ y) ↔ (x −₀ y ≡ 𝟎)
[−₀]-when-0 {x}{y} = [↔]-intro (l{x}{y}) (r{x}{y}) where
l : ∀{x y} → (x ≤ y) ← (x −₀ y ≡ 𝟎)
l {𝟎} {_} _ = [≤]-minimum
l {𝐒(_)}{𝟎} ()
l {𝐒(x)}{𝐒(y)} proof = [≤]-with-[𝐒] ⦃ l{x}{y} proof ⦄
r : ∀{x y} → (x ≤ y) → (x −₀ y ≡ 𝟎)
r {𝟎} {_} proof = [≡]-intro
r {𝐒(_)}{𝟎} ()
r {𝐒(x)}{𝐒(y)} (succ proof) = r{x}{y} (proof)
[−₀]-lesser-[𝐒]ₗ : ∀{x y} → ((x −₀ 𝐒(y)) ≤ (x −₀ y))
[−₀]-lesser-[𝐒]ᵣ : ∀{x y} → ((x −₀ y) ≤ (𝐒(x) −₀ y))
[−₀]-lesser-[𝐒]ₗ {𝟎} {_} = [≤]-minimum
[−₀]-lesser-[𝐒]ₗ {𝐒(_)}{𝟎} = [≤]-of-[𝐒]
[−₀]-lesser-[𝐒]ₗ {𝐒(x)}{𝐒(y)} = [−₀]-lesser-[𝐒]ᵣ {x}{𝐒(y)}
[−₀]-lesser-[𝐒]ᵣ {𝟎} {_} = [≤]-minimum
[−₀]-lesser-[𝐒]ᵣ {𝐒(x)}{𝟎} = [≤]-of-[𝐒]
[−₀]-lesser-[𝐒]ᵣ {𝐒(x)}{𝐒(y)} = [−₀]-lesser-[𝐒]ₗ {𝐒(x)}{y}
[≤][−₀][𝐒]ₗ : ∀{x y} → ((𝐒(x) −₀ y) ≤ 𝐒(x −₀ y))
[≤][−₀][𝐒]ₗ {x} {𝟎} = reflexivity(_≤_)
[≤][−₀][𝐒]ₗ {𝟎} {𝐒(y)} = [≤]-minimum
[≤][−₀][𝐒]ₗ {𝐒(x)}{𝐒(y)} = [≤][−₀][𝐒]ₗ {x}{y}
[−₀][𝐒]ₗ-equality : ∀{x y} → (x ≥ y) ↔ ((𝐒(x) −₀ y) ≡ 𝐒(x −₀ y))
[−₀][𝐒]ₗ-equality = [↔]-intro l r where
l : ∀{x y} → (x ≥ y) ← ((𝐒(x) −₀ y) ≡ 𝐒(x −₀ y))
l {𝟎} {𝟎} p = [≤]-minimum
l {𝐒 x} {𝟎} p = [≤]-minimum
l {𝐒 x} {𝐒 y} p = [≤]-with-[𝐒] ⦃ l{x}{y} p ⦄
r : ∀{x y} → (x ≥ y) → ((𝐒(x) −₀ y) ≡ 𝐒(x −₀ y))
r {x} {.𝟎} min = [≡]-intro
r {𝐒 x} {𝐒 y} (succ xy) = r xy
[−₀]-lesser : ∀{x y} → ((x −₀ y) ≤ x)
[−₀]-lesser {𝟎} {_} = [≤]-minimum
[−₀]-lesser {𝐒(x)}{𝟎} = reflexivity(_≤_)
[−₀]-lesser {𝐒(x)}{𝐒(y)} = ([−₀]-lesser-[𝐒]ₗ {𝐒(x)}{y}) 🝖 ([−₀]-lesser {𝐒(x)}{y})
-- TODO: Converse is probably also true. One way to prove the equivalence is contraposition of [−₀]-comparison. Another is by [≤]-with-[+]ᵣ and some other stuff, but it seems to require more work
[−₀]-positive : ∀{x y} → (y > x) → (y −₀ x > 0)
[−₀]-positive {𝟎} {𝐒(y)} _ = [≤]-with-[𝐒] ⦃ [≤]-minimum ⦄
[−₀]-positive {𝐒(x)}{𝐒(y)} (succ p) = [−₀]-positive {x}{y} p
[−₀]-nested-sameₗ : ∀{x y} → (x ≥ y) ↔ (x −₀ (x −₀ y) ≡ y)
[−₀]-nested-sameₗ {x}{y} = [↔]-intro (l{x}{y}) (r{x}{y}) where
l : ∀{x y} → (x ≥ y) ← (x −₀ (x −₀ y) ≡ y)
l {x}{y} proof =
y 🝖[ _≤_ ]-[ [≡]-to-[≤] (symmetry(_≡_) proof) ]
x −₀ (x −₀ y) 🝖[ _≤_ ]-[ [−₀]-lesser {x}{x −₀ y} ]
x 🝖[ _≤_ ]-end
r : ∀{x y} → (x ≥ y) → (x −₀ (x −₀ y) ≡ y)
r{x}{y} x≥y =
x −₀ (x −₀ y) 🝖[ _≡_ ]-[ [≡]-with(_−₀ (x −₀ y)) (symmetry(_≡_) ([↔]-to-[→] ([−₀][+]-nullify2 {y}{x}) (x≥y)) 🝖 commutativity(_+_) {y}{x −₀ y}) ]
((x −₀ y) + y) −₀ (x −₀ y) 🝖[ _≡_ ]-[ [−₀]ₗ[+]ₗ-nullify {x −₀ y}{y} ]
y 🝖-end
[+][−₀]-almost-associativity : ∀{x y z} → (y ≥ z) → ((x + y) −₀ z ≡ x + (y −₀ z))
[+][−₀]-almost-associativity {x} {y} {.𝟎} min = [≡]-intro
[+][−₀]-almost-associativity {x} {𝐒 y} {𝐒 z} (succ p) = [+][−₀]-almost-associativity {x}{y}{z} p
[−₀][𝄩]-equality-condition : ∀{x y} → (x ≥ y) ↔ (x −₀ y ≡ x 𝄩 y)
[−₀][𝄩]-equality-condition = [↔]-intro l r where
l : ∀{x y} → (x ≥ y) ← (x −₀ y ≡ x 𝄩 y)
l {_} {𝟎} _ = min
l {𝐒 x} {𝐒 y} p = succ(l p)
r : ∀{x y} → (x ≥ y) → (x −₀ y ≡ x 𝄩 y)
r min = [≡]-intro
r (succ p) = r p
[𝄩]-intro-by[−₀] : ∀{ℓ}{P : ℕ → TYPE(ℓ)} → ∀{x y} → P(x −₀ y) → P(y −₀ x) → P(x 𝄩 y)
[𝄩]-intro-by[−₀] {x = x}{y = y} p1 p2 with [≤][>]-dichotomy {x}{y}
... | [∨]-introₗ le
rewrite [↔]-to-[→] [−₀][𝄩]-equality-condition le
rewrite commutativity(_𝄩_) {x}{y}
= p2
... | [∨]-introᵣ gt
rewrite [↔]-to-[→] [−₀][𝄩]-equality-condition ([≤]-predecessor gt)
= p1
[𝄩]-of-𝐒ₗ : ∀{x y} → (x ≥ y) → (𝐒(x) 𝄩 y ≡ 𝐒(x 𝄩 y))
[𝄩]-of-𝐒ₗ {𝟎} {𝟎} = const [≡]-intro
[𝄩]-of-𝐒ₗ {𝐒 x} {𝟎} = const [≡]-intro
[𝄩]-of-𝐒ₗ {𝐒 x} {𝐒 y} = [𝄩]-of-𝐒ₗ {x} {y} ∘ [≤]-without-[𝐒]
[𝄩]-of-𝐒ᵣ : ∀{x y} → (x ≤ y) → (x 𝄩 𝐒(y) ≡ 𝐒(x 𝄩 y))
[𝄩]-of-𝐒ᵣ {𝟎} {𝟎} = const [≡]-intro
[𝄩]-of-𝐒ᵣ {𝟎} {𝐒 y} = const [≡]-intro
[𝄩]-of-𝐒ᵣ {𝐒 x} {𝐒 y} = [𝄩]-of-𝐒ᵣ {x} {y} ∘ [≤]-without-[𝐒]
[<]-with-[+]ᵣ : ∀{x y z} → (x < y) → (x + z < y + z)
[<]-with-[+]ᵣ = [≤]-with-[+]ᵣ
[<]-with-[+]ₗ : ∀{x y z} → (y < z) → (x + y < x + z)
[<]-with-[+]ₗ {x}{y}{z} = [≤]-with-[+]ₗ {𝐒 y}{z}{x}
[<]-with-[+]-weak : ∀{x₁ x₂ y₁ y₂} → ((x₁ ≤ x₂) ∧ (y₁ < y₂)) ∨ ((x₁ < x₂) ∧ (y₁ ≤ y₂)) → (x₁ + y₁ < x₂ + y₂)
[<]-with-[+]-weak ([∨]-introₗ ([∧]-intro x12 y12)) = [≤]-with-[+] ⦃ x12 ⦄ ⦃ y12 ⦄
[<]-with-[+]-weak ([∨]-introᵣ ([∧]-intro x12 y12)) = [≤]-with-[+] ⦃ x12 ⦄ ⦃ y12 ⦄
[<]-with-[+] : ∀{x₁ x₂ y₁ y₂} → (x₁ < x₂) → (y₁ < y₂) → (x₁ + y₁ < x₂ + y₂)
[<]-with-[+] x12 y12 = [≤]-predecessor ([≤]-with-[+] ⦃ x12 ⦄ ⦃ y12 ⦄)
[≤]-with-[⋅]ᵣ : ∀{a b c} → (a ≤ b) → ((a ⋅ c) ≤ (b ⋅ c))
[≤]-with-[⋅]ᵣ {c = 𝟎} _ = [≤]-minimum
[≤]-with-[⋅]ᵣ {c = 𝐒 c} ab = [≤]-with-[+] ⦃ ab ⦄ ⦃ [≤]-with-[⋅]ᵣ {c = c} ab ⦄
[≤]-with-[⋅]ₗ : ∀{a b c} → (b ≤ c) → ((a ⋅ b) ≤ (a ⋅ c))
[≤]-with-[⋅]ₗ {a}{b}{c}
rewrite commutativity(_⋅_) {a}{b}
rewrite commutativity(_⋅_) {a}{c}
= [≤]-with-[⋅]ᵣ {c = a}
[<]-with-[⋅]ᵣ : ∀{a b c} → (a < b) → ((a ⋅ 𝐒(c)) < (b ⋅ 𝐒(c)))
[<]-with-[⋅]ᵣ {c = 𝟎} = id
[<]-with-[⋅]ᵣ {c = 𝐒 c} = [<]-with-[+] ∘ₛ [<]-with-[⋅]ᵣ {c = c}
[<]-with-[⋅]ₗ : ∀{a b c} → (b < c) → ((𝐒(a) ⋅ b) < (𝐒(a) ⋅ c))
[<]-with-[⋅]ₗ {a}{b}{c}
rewrite commutativity(_⋅_) {𝐒(a)}{b}
rewrite commutativity(_⋅_) {𝐒(a)}{c}
= [<]-with-[⋅]ᵣ {c = a}
[⋅]ᵣ-growing : ∀{n c} → (1 ≤ c) → (n ≤ (c ⋅ n))
[⋅]ᵣ-growing {n}{𝐒 c} = [≤]-with-[⋅]ᵣ {1}{𝐒(c)}{n}
[⋅]ᵣ-strictly-growing : ∀{n c} → (2 ≤ c) → (𝐒(n) < (c ⋅ 𝐒(n)))
[⋅]ᵣ-strictly-growing {n} {1} (succ())
[⋅]ᵣ-strictly-growing {n} {𝐒(𝐒 c)} = [<]-with-[⋅]ᵣ {1}{𝐒(𝐒(c))}{n}
[^]-positive : ∀{a b} → ((𝐒(a) ^ b) > 0)
[^]-positive {a}{𝟎} = reflexivity(_≤_)
[^]-positive {a}{𝐒 b} =
𝐒(a) ^ 𝐒(b) 🝖[ _≥_ ]-[]
𝐒(a) ⋅ (𝐒(a) ^ b) 🝖[ _≥_ ]-[ [<]-with-[⋅]ₗ {a} ([^]-positive {a}{b}) ]
𝐒(𝐒(a) ⋅ 0) 🝖[ _≥_ ]-[ succ min ]
1 🝖[ _≥_ ]-end
[^]ₗ-strictly-growing : ∀{n a b} → (a < b) → ((𝐒(𝐒(n)) ^ a) < (𝐒(𝐒(n)) ^ b))
[^]ₗ-strictly-growing {n} {𝟎} {.(𝐒 b)} (succ {y = b} p) = [≤]-with-[+]ᵣ [≤]-minimum 🝖 [≤]-with-[⋅]ₗ {𝐒(𝐒(n))}{1}{𝐒(𝐒(n)) ^ b} ([^]-positive {𝐒(n)}{b})
[^]ₗ-strictly-growing {n} {𝐒 a} {.(𝐒 b)} (succ {y = b} p) = [<]-with-[⋅]ₗ {𝐒(n)} ([^]ₗ-strictly-growing {n}{a}{b} p)
[^]ₗ-growing : ∀{n a b} → ¬((n ≡ 𝟎) ∧ (a ≡ 𝟎)) → (a ≤ b) → ((n ^ a) ≤ (n ^ b))
[^]ₗ-growing {𝟎} {𝟎} {_} p _ with () ← p([∧]-intro [≡]-intro [≡]-intro)
[^]ₗ-growing {𝟎} {𝐒 a} {𝐒 b} _ _ = min
[^]ₗ-growing {𝐒 𝟎}{a} {b} _ _
rewrite [^]-of-𝟏ₗ {a}
rewrite [^]-of-𝟏ₗ {b}
= succ min
[^]ₗ-growing {𝐒 (𝐒 n)}{a}{b} _ ab with [≤]-to-[<][≡] ab
... | [∨]-introₗ p = sub₂(_<_)(_≤_) ([^]ₗ-strictly-growing {n}{a}{b} p)
... | [∨]-introᵣ [≡]-intro = reflexivity(_≤_)
| {
"alphanum_fraction": 0.413803938,
"avg_line_length": 41.8771929825,
"ext": "agda",
"hexsha": "ee1219792e265b4ce20938a5baf1c291fd7817d0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Natural/Oper/Proofs/Order.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Natural/Oper/Proofs/Order.agda",
"max_line_length": 195,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Natural/Oper/Proofs/Order.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": 5789,
"size": 9548
} |
{-# OPTIONS --without-K #-}
module Pi1 where
open import Data.List
open import Data.Nat
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open import Groupoid
infix 2 _□
infixr 2 _⟷⟨_⟩_
infix 2 _▤
infixr 2 _⇔⟨_⟩_
infixr 10 _◎_
infix 30 _⟷_
infix 4 _∼_ -- homotopy between two paths
infix 4 _≃_ -- type of equivalences
-- Work on ch. on sets and n-levels and n=-2 and n=-1
-- then work on ch. on equivalences
-- then go back to functions are functors; type families are fibrations
-- then work on int construction
-- then work on example from popl
------------------------------------------------------------------------------
-- Level 0:
-- Types at this level are just plain sets with no interesting path structure.
-- The path structure is defined at levels 1 and beyond.
data U : Set where
ZERO : U
ONE : U
PLUS : U → U → U
TIMES : U → U → U
⟦_⟧ : U → Set
⟦ ZERO ⟧ = ⊥
⟦ ONE ⟧ = ⊤
⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧
⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧
-- Programs
-- We use pointed types; programs are "fibers" from functions that map a
-- pointed type to another. In other words, each program takes one particular
-- value to another; if we want to work on another value, we generally use
-- another program.
--
-- We can recover a regular function by collecting all the fibers that
-- compose to the identity permutation.
record U• : Set where
constructor •[_,_]
field
∣_∣ : U
• : ⟦ ∣_∣ ⟧
open U•
-- examples of plain types, values, and pointed types
ZERO• : {absurd : ⟦ ZERO ⟧} → U•
ZERO• {absurd} = •[ ZERO , absurd ]
ONE• : U•
ONE• = •[ ONE , tt ]
BOOL : U
BOOL = PLUS ONE ONE
BOOL² : U
BOOL² = TIMES BOOL BOOL
TRUE : ⟦ BOOL ⟧
TRUE = inj₁ tt
FALSE : ⟦ BOOL ⟧
FALSE = inj₂ tt
BOOL•F : U•
BOOL•F = •[ BOOL , FALSE ]
BOOL•T : U•
BOOL•T = •[ BOOL , TRUE ]
-- The actual programs are the commutative semiring isomorphisms between
-- pointed types.
data _⟷_ : U• → U• → Set where
unite₊ : ∀ {t v} → •[ PLUS ZERO t , inj₂ v ] ⟷ •[ t , v ]
uniti₊ : ∀ {t v} → •[ t , v ] ⟷ •[ PLUS ZERO t , inj₂ v ]
swap1₊ : ∀ {t₁ t₂ v₁} →
•[ PLUS t₁ t₂ , inj₁ v₁ ] ⟷ •[ PLUS t₂ t₁ , inj₂ v₁ ]
swap2₊ : ∀ {t₁ t₂ v₂} →
•[ PLUS t₁ t₂ , inj₂ v₂ ] ⟷ •[ PLUS t₂ t₁ , inj₁ v₂ ]
assocl1₊ : ∀ {t₁ t₂ t₃ v₁} →
•[ PLUS t₁ (PLUS t₂ t₃) , inj₁ v₁ ] ⟷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ]
assocl2₊ : ∀ {t₁ t₂ t₃ v₂} →
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] ⟷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ]
assocl3₊ : ∀ {t₁ t₂ t₃ v₃} →
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] ⟷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ]
assocr1₊ : ∀ {t₁ t₂ t₃ v₁} →
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] ⟷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₁ v₁ ]
assocr2₊ : ∀ {t₁ t₂ t₃ v₂} →
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] ⟷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ]
assocr3₊ : ∀ {t₁ t₂ t₃ v₃} →
•[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ] ⟷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ]
unite⋆ : ∀ {t v} → •[ TIMES ONE t , (tt , v) ] ⟷ •[ t , v ]
uniti⋆ : ∀ {t v} → •[ t , v ] ⟷ •[ TIMES ONE t , (tt , v) ]
swap⋆ : ∀ {t₁ t₂ v₁ v₂} → •[ TIMES t₁ t₂ , (v₁ , v₂) ] ⟷
•[ TIMES t₂ t₁ , (v₂ , v₁) ]
assocl⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} →
•[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] ⟷
•[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ]
assocr⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} →
•[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] ⟷
•[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ]
distz : ∀ {t v absurd} →
•[ TIMES ZERO t , (absurd , v) ] ⟷ •[ ZERO , absurd ]
factorz : ∀ {t v absurd} →
•[ ZERO , absurd ] ⟷ •[ TIMES ZERO t , (absurd , v) ]
dist1 : ∀ {t₁ t₂ t₃ v₁ v₃} →
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] ⟷
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ]
dist2 : ∀ {t₁ t₂ t₃ v₂ v₃} →
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] ⟷
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ]
factor1 : ∀ {t₁ t₂ t₃ v₁ v₃} →
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] ⟷
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ]
factor2 : ∀ {t₁ t₂ t₃ v₂ v₃} →
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] ⟷
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ]
id⟷ : ∀ {t v} → •[ t , v ] ⟷ •[ t , v ]
_◎_ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} →
(•[ t₁ , v₁ ] ⟷ •[ t₂ , v₂ ]) →
(•[ t₂ , v₂ ] ⟷ •[ t₃ , v₃ ]) →
(•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ])
⊕1 : ∀ {t₁ t₂ t₃ t₄ v₁ v₃} →
(•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) →
(•[ PLUS t₁ t₂ , inj₁ v₁ ] ⟷ •[ PLUS t₃ t₄ , inj₁ v₃ ])
⊕2 : ∀ {t₁ t₂ t₃ t₄ v₂ v₄} →
(•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) →
(•[ PLUS t₁ t₂ , inj₂ v₂ ] ⟷ •[ PLUS t₃ t₄ , inj₂ v₄ ])
_⊗_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} →
(•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) →
(•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) →
(•[ TIMES t₁ t₂ , (v₁ , v₂) ] ⟷ •[ TIMES t₃ t₄ , (v₃ , v₄) ])
-- Nicer syntax that shows intermediate values instead of point-free
-- combinators
_⟷⟨_⟩_ : (t₁ : U•) {t₂ : U•} {t₃ : U•} →
(t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃)
_ ⟷⟨ α ⟩ β = α ◎ β
_□ : (t : U•) → {t : U•} → (t ⟷ t)
_□ t = id⟷
-- trace
-- first every combinator (t + t1) <-> (t + t2) can be decomposed into
-- four relations (or injective partial functions):
-- r11 : t1 -> t2
-- r12 : t1 -> t
-- r21 : t -> t2
-- r22 : t -> t
-- c = r11 ∪ (r12 ◎ r22⋆ ◎ r21)
eval : ∀ {t₁ t₂ v₁ v₂} → (•[ t₁ , v₁ ] ⟷ •[ t₂ , v₂ ]) → List U•
eval {t₁ = ZERO} {v₁ = ()} _
eval {t₂ = ZERO} {v₂ = ()} _
eval {t} {PLUS .ZERO .t} {v} {inj₂ .v} uniti₊ =
•[ t , v ] ∷ •[ PLUS ZERO t , inj₂ v ] ∷ []
eval {PLUS .ZERO .t} {t} {inj₂ .v} {v} unite₊ =
•[ PLUS ZERO t , inj₂ v ] ∷ •[ t , v ] ∷ []
eval {PLUS t₁ t₂} {PLUS .t₂ .t₁} {inj₁ v₁} {inj₂ .v₁} swap1₊ =
•[ PLUS t₁ t₂ , inj₁ v₁ ] ∷ •[ PLUS t₂ t₁ , inj₂ v₁ ] ∷ []
eval {PLUS t₁ t₂} {PLUS .t₂ .t₁} {inj₂ v₂} {inj₁ .v₂} swap2₊ =
•[ PLUS t₁ t₂ , inj₂ v₂ ] ∷ •[ PLUS t₂ t₁ , inj₁ v₂ ] ∷ []
eval {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃}
{inj₁ v₁} {inj₁ (inj₁ .v₁)} assocl1₊ =
•[ PLUS t₁ (PLUS t₂ t₃) , inj₁ v₁ ] ∷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] ∷ []
eval {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃}
{inj₂ (inj₁ v₂)} {inj₁ (inj₂ .v₂)} assocl2₊ =
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] ∷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] ∷ []
eval {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃}
{inj₂ (inj₂ v₃)} {inj₂ .v₃} assocl3₊ =
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] ∷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ] ∷ []
eval {PLUS (PLUS .t₁ .t₂) .t₃} {PLUS t₁ (PLUS t₂ t₃)}
{inj₁ (inj₁ .v₁)} {inj₁ v₁} assocr1₊ =
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] ∷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₁ v₁ ] ∷ []
eval {PLUS (PLUS .t₁ .t₂) .t₃} {PLUS t₁ (PLUS t₂ t₃)}
{inj₁ (inj₂ .v₂)} {inj₂ (inj₁ v₂)} assocr2₊ =
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] ∷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] ∷ []
eval {PLUS (PLUS .t₁ .t₂) .t₃} {PLUS t₁ (PLUS t₂ t₃)}
{inj₂ .v₃} {inj₂ (inj₂ v₃)} assocr3₊ =
•[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ] ∷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] ∷ []
eval {t} {TIMES .ONE .t} {v} {(tt , .v)} uniti⋆ =
•[ t , v ] ∷ •[ TIMES ONE t , (tt , v) ] ∷ []
eval {TIMES .ONE .t} {t} {(tt , .v)} {v} unite⋆ =
•[ TIMES ONE t , (tt , v) ] ∷ •[ t , v ] ∷ []
eval {TIMES t₁ t₂} {TIMES .t₂ .t₁} {(v₁ , v₂)} {(.v₂ , .v₁)} swap⋆ =
•[ TIMES t₁ t₂ , (v₁ , v₂) ] ∷ •[ TIMES t₂ t₁ , (v₂ , v₁) ] ∷ []
eval {TIMES t₁ (TIMES t₂ t₃)} {TIMES (TIMES .t₁ .t₂) .t₃}
{(v₁ , (v₂ , v₃))} {((.v₁ , .v₂) , .v₃)} assocl⋆ =
•[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] ∷
•[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] ∷ []
eval {TIMES (TIMES .t₁ .t₂) .t₃} {TIMES t₁ (TIMES t₂ t₃)}
{((.v₁ , .v₂) , .v₃)} {(v₁ , (v₂ , v₃))} assocr⋆ =
•[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] ∷
•[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] ∷ []
eval {TIMES (PLUS t₁ t₂) t₃} {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)}
{(inj₁ v₁ , v₃)} {inj₁ (.v₁ , .v₃)} dist1 =
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] ∷
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] ∷ []
eval {TIMES (PLUS t₁ t₂) t₃} {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)}
{(inj₂ v₂ , v₃)} {inj₂ (.v₂ , .v₃)} dist2 =
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] ∷
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] ∷ []
eval {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} {TIMES (PLUS t₁ t₂) t₃}
{inj₁ (.v₁ , .v₃)} {(inj₁ v₁ , v₃)} factor1 =
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] ∷
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] ∷ []
eval {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} {TIMES (PLUS t₁ t₂) t₃}
{inj₂ (.v₂ , .v₃)} {(inj₂ v₂ , v₃)} factor2 =
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] ∷
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] ∷ []
eval {t} {.t} {v} {.v} id⟷ = •[ t , v ] ∷ •[ t , v ] ∷ []
eval {t₁} {t₃} {v₁} {v₃} (_◎_ {t₂ = t₂} {v₂ = v₂} c₁ c₂) =
eval {t₁} {t₂} {v₁} {v₂} c₁ ++ eval {t₂} {t₃} {v₂} {v₃} c₂
eval {PLUS t₁ t₂} {PLUS t₃ t₄} {inj₁ v₁} {inj₁ v₃} (⊕1 c) =
eval {t₁} {t₃} {v₁} {v₃} c -- tag
eval {PLUS t₁ t₂} {PLUS t₃ t₄} {inj₂ v₂} {inj₂ v₄} (⊕2 c) =
eval {t₂} {t₄} {v₂} {v₄} c -- tag
eval {TIMES t₁ t₂} {TIMES t₃ t₄} {(v₁ , v₂)} {(v₃ , v₄)} (c₁ ⊗ c₂) =
(eval {t₁} {t₃} {v₁} {v₃} c₁) ++ (eval {t₂} {t₄} {v₂} {v₄} c₂)
-- zip
test = eval (•[ BOOL² , (TRUE , TRUE) ]
⟷⟨ dist1 ⟩
•[ PLUS (TIMES ONE BOOL) (TIMES ONE BOOL) , inj₁ (tt , TRUE) ]
⟷⟨ ⊕1 (id⟷ ⊗ swap1₊)⟩
•[ PLUS (TIMES ONE BOOL) (TIMES ONE BOOL) , inj₁ (tt , FALSE) ]
⟷⟨ factor1 ⟩
•[ BOOL² , (TRUE , FALSE) ] □)
-- The above are "fibers". We collect the fibers into functions.
data SWAP₊ {t₁ t₂ v₁ v₂} :
(•[ PLUS t₁ t₂ , inj₁ v₁ ] ⟷ •[ PLUS t₂ t₁ , inj₂ v₁ ]) →
(•[ PLUS t₁ t₂ , inj₂ v₂ ] ⟷ •[ PLUS t₂ t₁ , inj₁ v₂ ]) →
Set where
swap₊ : SWAP₊ swap1₊ swap2₊
Fun : (t₁ t₂ : U) → Set
Fun t₁ t₂ = (v₁ : ⟦ t₁ ⟧) → Σ[ v₂ ∈ ⟦ t₂ ⟧ ] (•[ t₁ , v₁ ] ⟷ •[ t₂ , v₂ ])
NOT : Fun BOOL BOOL
NOT (inj₁ tt) = (FALSE , swap1₊)
NOT (inj₂ tt) = (TRUE , swap2₊)
-- Note that functions are not reversible!!
Squash : Fun BOOL BOOL
Squash (inj₁ x) = inj₂ x , swap1₊
Squash (inj₂ y) = inj₂ y , id⟷
CNOT : Fun BOOL² BOOL²
CNOT (inj₂ tt , b) =
((FALSE , b) , dist2 ◎ (⊕2 id⟷) ◎ factor2)
CNOT (inj₁ tt , inj₂ tt) =
((TRUE , TRUE) , dist1 ◎ (⊕1 (id⟷ ⊗ swap2₊)) ◎ factor1)
CNOT (inj₁ tt , inj₁ tt) =
((TRUE , FALSE) ,
(•[ BOOL² , (TRUE , TRUE) ]
⟷⟨ dist1 ⟩
•[ PLUS (TIMES ONE BOOL) (TIMES ONE BOOL) , inj₁ (tt , TRUE) ]
⟷⟨ ⊕1 (id⟷ ⊗ swap1₊)⟩
•[ PLUS (TIMES ONE BOOL) (TIMES ONE BOOL) , inj₁ (tt , FALSE) ]
⟷⟨ factor1 ⟩
•[ BOOL² , (TRUE , FALSE) ] □))
-- The universe of types is a groupoid. The objects of this groupoid are the
-- pointed types; the morphisms are the programs; and the equivalence of
-- programs is the degenerate observational equivalence that equates every
-- two programs that are extensionally equivalent.
! : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁)
! unite₊ = uniti₊
! uniti₊ = unite₊
! swap1₊ = swap2₊
! swap2₊ = swap1₊
! assocl1₊ = assocr1₊
! assocl2₊ = assocr2₊
! assocl3₊ = assocr3₊
! assocr1₊ = assocl1₊
! assocr2₊ = assocl2₊
! assocr3₊ = assocl3₊
! unite⋆ = uniti⋆
! uniti⋆ = unite⋆
! swap⋆ = swap⋆
! assocl⋆ = assocr⋆
! assocr⋆ = assocl⋆
! distz = factorz
! factorz = distz
! dist1 = factor1
! dist2 = factor2
! factor1 = dist1
! factor2 = dist2
! id⟷ = id⟷
! (c₁ ◎ c₂) = ! c₂ ◎ ! c₁
! (⊕1 c₁) = ⊕1 (! c₁)
! (⊕2 c₂) = ⊕2 (! c₂)
! (c₁ ⊗ c₂) = ! c₁ ⊗ ! c₂
_obs≅_ : {t₁ t₂ : U•} → (c₁ c₂ : t₁ ⟷ t₂) → Set
c₁ obs≅ c₂ = ⊤
UG : 1Groupoid
UG = record
{ set = U•
; _↝_ = _⟷_
; _≈_ = _obs≅_
; id = id⟷
; _∘_ = λ y⟷z x⟷y → x⟷y ◎ y⟷z
; _⁻¹ = !
; lneutr = λ _ → tt
; rneutr = λ _ → tt
; assoc = λ _ _ _ → tt
; equiv = record { refl = tt
; sym = λ _ → tt
; trans = λ _ _ → tt
}
; linv = λ _ → tt
; rinv = λ _ → tt
; ∘-resp-≈ = λ _ _ → tt
}
-- Now let us talk about homotopies and equivalences
-- Two paths starting at the same point are homotopic if they map that point
-- to related points (of course, related by another path)
_∼_ : {t₁ t₂ t₂' : U•} → (p : t₁ ⟷ t₂) → (q : t₁ ⟷ t₂') → Set
_∼_ {t₁} {t₂} {t₂'} p q = (t₂ ⟷ t₂')
refl∼ : {t₁ t₂ : U•} → (p : t₁ ⟷ t₂) → (p ∼ p)
refl∼ {t₁} {t₂} p = id⟷
sym∼ : {t₁ t₂ t₂' : U•} {p : t₁ ⟷ t₂} {q : t₁ ⟷ t₂'} → (p ∼ q) → (q ∼ p)
sym∼ p∼q = ! p∼q
trans∼ : {t₁ t₂ t₂' t₂'' : U•} {p : t₁ ⟷ t₂} {q : t₁ ⟷ t₂'} {r : t₁ ⟷ t₂''} →
(p ∼ q) → (q ∼ r) → (p ∼ r)
trans∼ p∼q q∼r = p∼q ◎ q∼r
module T where
-- Note that paths mapping a point FALSE and TRUE can be homotopic
p : •[ BOOL , FALSE ] ⟷ •[ BOOL , FALSE ]
p = id⟷
q : •[ BOOL , FALSE ] ⟷ •[ BOOL , TRUE ]
q = swap2₊
p∼q : p ∼ q
p∼q = swap2₊
-- equivalences
-- the following makes no sense because I can use id⟷ for α and β
record qinv {t₁ t₂ : U•} (p : t₁ ⟷ t₂) : Set where
constructor mkqinv
field
q : t₂ ⟷ t₁
α : (p ◎ q) ∼ id⟷
β : (q ◎ p) ∼ id⟷
idqinv : {t : U•} → qinv {t} {t} id⟷
idqinv = record {
q = id⟷ ;
α = id⟷ ;
β = id⟷
}
record isequiv {t₁ t₂ : U•} (p : t₁ ⟷ t₂) : Set where
constructor mkisequiv
field
q : t₂ ⟷ t₁
α : (p ◎ q) ∼ id⟷
r : t₂ ⟷ t₁
β : (r ◎ p) ∼ id⟷
equiv₁ : {t₁ t₂ : U•} {p : t₁ ⟷ t₂} → qinv p → isequiv p
equiv₁ (mkqinv iq iα iβ) = mkisequiv iq iα iq iβ
_≃_ : (t₁ t₂ : U•) → Set
t₁ ≃ t₂ = Σ[ p ∈ t₁ ⟷ t₂ ] (isequiv p)
id≃ : {t : U•} → t ≃ t
id≃ = (id⟷ , equiv₁ idqinv)
------------------------------------------------------------------------------
-- Level 1:
-- Types are sets of paths. The paths are defined at level 0. At level 1,
-- there is no interesting 2path structure. From the perspective of level 0,
-- we have points with non-trivial paths between them, i.e., we have a
-- groupoid. The paths cross type boundaries, i.e., we have heterogeneous
-- equality
-- types
data 1U : Set where
1ZERO : 1U -- empty set of paths
1ONE : 1U -- a trivial path
1PLUS : 1U → 1U → 1U -- disjoint union of paths
1TIMES : 1U → 1U → 1U -- pairs of paths
PATH : (t₁ t₂ : U•) → 1U -- level 0 paths between values
-- values
data Path (t₁ t₂ : U•) : Set where
path : (c : t₁ ⟷ t₂) → Path t₁ t₂
1⟦_⟧ : 1U → Set
1⟦ 1ZERO ⟧ = ⊥
1⟦ 1ONE ⟧ = ⊤
1⟦ 1PLUS t₁ t₂ ⟧ = 1⟦ t₁ ⟧ ⊎ 1⟦ t₂ ⟧
1⟦ 1TIMES t₁ t₂ ⟧ = 1⟦ t₁ ⟧ × 1⟦ t₂ ⟧
1⟦ PATH t₁ t₂ ⟧ = Path t₁ t₂
-- examples
T⟷F : Set
T⟷F = Path BOOL•T BOOL•F
F⟷T : Set
F⟷T = Path BOOL•F BOOL•T
p₁ p₂ p₃ p₄ p₅ : T⟷F
p₁ = path swap1₊
p₂ = path (id⟷ ◎ swap1₊)
p₃ = path (swap1₊ ◎ swap2₊ ◎ swap1₊)
p₄ = path (swap1₊ ◎ id⟷)
p₅ = path (uniti⋆ ◎ swap⋆ ◎ (swap1₊ ⊗ id⟷) ◎ swap⋆ ◎ unite⋆)
p₆ : (T⟷F × T⟷F) ⊎ F⟷T
p₆ = inj₁ (p₁ , p₂)
-- Programs map paths to paths. We also use pointed types.
record 1U• : Set where
constructor 1•[_,_]
field
1∣_∣ : 1U
1• : 1⟦ 1∣_∣ ⟧
open 1U•
data _⇔_ : 1U• → 1U• → Set where
unite₊ : ∀ {t v} → 1•[ 1PLUS 1ZERO t , inj₂ v ] ⇔ 1•[ t , v ]
uniti₊ : ∀ {t v} → 1•[ t , v ] ⇔ 1•[ 1PLUS 1ZERO t , inj₂ v ]
swap1₊ : ∀ {t₁ t₂ v₁} →
1•[ 1PLUS t₁ t₂ , inj₁ v₁ ] ⇔ 1•[ 1PLUS t₂ t₁ , inj₂ v₁ ]
swap2₊ : ∀ {t₁ t₂ v₂} →
1•[ 1PLUS t₁ t₂ , inj₂ v₂ ] ⇔ 1•[ 1PLUS t₂ t₁ , inj₁ v₂ ]
assocl1₊ : ∀ {t₁ t₂ t₃ v₁} →
1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₁ v₁ ] ⇔
1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ]
assocl2₊ : ∀ {t₁ t₂ t₃ v₂} →
1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] ⇔
1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ]
assocl3₊ : ∀ {t₁ t₂ t₃ v₃} →
1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] ⇔
1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₂ v₃ ]
assocr1₊ : ∀ {t₁ t₂ t₃ v₁} →
1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] ⇔
1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₁ v₁ ]
assocr2₊ : ∀ {t₁ t₂ t₃ v₂} →
1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] ⇔
1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₁ v₂) ]
assocr3₊ : ∀ {t₁ t₂ t₃ v₃} →
1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₂ v₃ ] ⇔
1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₂ v₃) ]
unite⋆ : ∀ {t v} → 1•[ 1TIMES 1ONE t , (tt , v) ] ⇔ 1•[ t , v ]
uniti⋆ : ∀ {t v} → 1•[ t , v ] ⇔ 1•[ 1TIMES 1ONE t , (tt , v) ]
swap⋆ : ∀ {t₁ t₂ v₁ v₂} →
1•[ 1TIMES t₁ t₂ , (v₁ , v₂) ] ⇔ 1•[ 1TIMES t₂ t₁ , (v₂ , v₁) ]
assocl⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} →
1•[ 1TIMES t₁ (1TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] ⇔
1•[ 1TIMES (1TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ]
assocr⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} →
1•[ 1TIMES (1TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] ⇔
1•[ 1TIMES t₁ (1TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ]
distz : ∀ {t v absurd} →
1•[ 1TIMES 1ZERO t , (absurd , v) ] ⇔ 1•[ 1ZERO , absurd ]
factorz : ∀ {t v absurd} →
1•[ 1ZERO , absurd ] ⇔ 1•[ 1TIMES 1ZERO t , (absurd , v) ]
dist1 : ∀ {t₁ t₂ t₃ v₁ v₃} →
1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] ⇔
1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₁ (v₁ , v₃) ]
dist2 : ∀ {t₁ t₂ t₃ v₂ v₃} →
1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] ⇔
1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₂ (v₂ , v₃) ]
factor1 : ∀ {t₁ t₂ t₃ v₁ v₃} →
1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] ⇔
1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ]
factor2 : ∀ {t₁ t₂ t₃ v₂ v₃} →
1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] ⇔
1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ]
id⇔ : ∀ {t v} → 1•[ t , v ] ⇔ 1•[ t , v ]
_◎_ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} → (1•[ t₁ , v₁ ] ⇔ 1•[ t₂ , v₂ ]) →
(1•[ t₂ , v₂ ] ⇔ 1•[ t₃ , v₃ ]) →
(1•[ t₁ , v₁ ] ⇔ 1•[ t₃ , v₃ ])
⊕1 : ∀ {t₁ t₂ t₃ t₄ v₁ v₃} →
(1•[ t₁ , v₁ ] ⇔ 1•[ t₃ , v₃ ]) →
(1•[ 1PLUS t₁ t₂ , inj₁ v₁ ] ⇔ 1•[ 1PLUS t₃ t₄ , inj₁ v₃ ])
⊕2 : ∀ {t₁ t₂ t₃ t₄ v₂ v₄} →
(1•[ t₂ , v₂ ] ⇔ 1•[ t₄ , v₄ ]) →
(1•[ 1PLUS t₁ t₂ , inj₂ v₂ ] ⇔ 1•[ 1PLUS t₃ t₄ , inj₂ v₄ ])
_⊗_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} →
(1•[ t₁ , v₁ ] ⇔ 1•[ t₃ , v₃ ]) → (1•[ t₂ , v₂ ] ⇔ 1•[ t₄ , v₄ ]) →
(1•[ 1TIMES t₁ t₂ , (v₁ , v₂) ] ⇔ 1•[ 1TIMES t₃ t₄ , (v₃ , v₄) ])
lidl : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} →
1•[ PATH t₁ t₂ , path (id⟷ ◎ c) ] ⇔ 1•[ PATH t₁ t₂ , path c ]
lidr : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} →
1•[ PATH t₁ t₂ , path c ] ⇔ 1•[ PATH t₁ t₂ , path (id⟷ ◎ c) ]
ridl : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} →
1•[ PATH t₁ t₂ , path (c ◎ id⟷) ] ⇔ 1•[ PATH t₁ t₂ , path c ]
ridr : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} →
1•[ PATH t₁ t₂ , path c ] ⇔ 1•[ PATH t₁ t₂ , path (c ◎ id⟷) ]
assocl : ∀ {t₁ t₂ t₃ t₄} →
{c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
1•[ PATH t₁ t₄ , path (c₁ ◎ (c₂ ◎ c₃)) ] ⇔
1•[ PATH t₁ t₄ , path ((c₁ ◎ c₂) ◎ c₃) ]
assocr : ∀ {t₁ t₂ t₃ t₄} →
{c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
1•[ PATH t₁ t₄ , path ((c₁ ◎ c₂) ◎ c₃) ] ⇔
1•[ PATH t₁ t₄ , path (c₁ ◎ (c₂ ◎ c₃)) ]
linv◎l : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂ } →
1•[ PATH t₁ t₁ , path (c ◎ ! c)] ⇔
1•[ PATH t₁ t₁ , path id⟷ ]
linv◎r : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂ } →
1•[ PATH t₁ t₁ , path id⟷ ] ⇔
1•[ PATH t₁ t₁ , path (c ◎ ! c) ]
rinv◎l : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂ } →
1•[ PATH t₂ t₂ , path (! c ◎ c)] ⇔
1•[ PATH t₂ t₂ , path id⟷ ]
rinv◎r : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂ } →
1•[ PATH t₂ t₂ , path id⟷ ] ⇔
1•[ PATH t₂ t₂ , path (! c ◎ c) ]
resp◎ : ∀ {t₁ t₂ t₃} →
{c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} →
(1•[ PATH t₁ t₂ , path c₁ ] ⇔ 1•[ PATH t₁ t₂ , path c₃ ]) →
(1•[ PATH t₂ t₃ , path c₂ ] ⇔ 1•[ PATH t₂ t₃ , path c₄ ]) →
1•[ PATH t₁ t₃ , path (c₁ ◎ c₂) ] ⇔ 1•[ PATH t₁ t₃ , path (c₃ ◎ c₄) ]
1! : {t₁ t₂ : 1U•} → (t₁ ⇔ t₂) → (t₂ ⇔ t₁)
1! unite₊ = uniti₊
1! uniti₊ = unite₊
1! swap1₊ = swap2₊
1! swap2₊ = swap1₊
1! assocl1₊ = assocr1₊
1! assocl2₊ = assocr2₊
1! assocl3₊ = assocr3₊
1! assocr1₊ = assocl1₊
1! assocr2₊ = assocl2₊
1! assocr3₊ = assocl3₊
1! unite⋆ = uniti⋆
1! uniti⋆ = unite⋆
1! swap⋆ = swap⋆
1! assocl⋆ = assocr⋆
1! assocr⋆ = assocl⋆
1! distz = factorz
1! factorz = distz
1! dist1 = factor1
1! dist2 = factor2
1! factor1 = dist1
1! factor2 = dist2
1! id⇔ = id⇔
1! (c₁ ◎ c₂) = 1! c₂ ◎ 1! c₁
1! (⊕1 c₁) = ⊕1 (1! c₁)
1! (⊕2 c₂) = ⊕2 (1! c₂)
1! (c₁ ⊗ c₂) = 1! c₁ ⊗ 1! c₂
1! (resp◎ c₁ c₂) = resp◎ (1! c₁) (1! c₂)
1! ridl = ridr
1! ridr = ridl
1! lidl = lidr
1! lidr = lidl
1! assocl = assocr
1! assocr = assocl
1! linv◎l = linv◎r
1! linv◎r = linv◎l
1! rinv◎l = rinv◎r
1! rinv◎r = rinv◎l
1!≡ : {t₁ t₂ : 1U•} → (c : t₁ ⇔ t₂) → 1! (1! c) ≡ c
1!≡ unite₊ = refl
1!≡ uniti₊ = refl
1!≡ swap1₊ = refl
1!≡ swap2₊ = refl
1!≡ assocl1₊ = refl
1!≡ assocl2₊ = refl
1!≡ assocl3₊ = refl
1!≡ assocr1₊ = refl
1!≡ assocr2₊ = refl
1!≡ assocr3₊ = refl
1!≡ unite⋆ = refl
1!≡ uniti⋆ = refl
1!≡ swap⋆ = refl
1!≡ assocl⋆ = refl
1!≡ assocr⋆ = refl
1!≡ distz = refl
1!≡ factorz = refl
1!≡ dist1 = refl
1!≡ dist2 = refl
1!≡ factor1 = refl
1!≡ factor2 = refl
1!≡ id⇔ = refl
1!≡ (c₁ ◎ c₂) = cong₂ (λ c₁ c₂ → c₁ ◎ c₂) (1!≡ c₁) (1!≡ c₂)
1!≡ (⊕1 c₁) = cong (λ c₁ → ⊕1 c₁) (1!≡ c₁)
1!≡ (⊕2 c₂) = cong (λ c₂ → ⊕2 c₂) (1!≡ c₂)
1!≡ (c₁ ⊗ c₂) = cong₂ (λ c₁ c₂ → c₁ ⊗ c₂) (1!≡ c₁) (1!≡ c₂)
1!≡ lidl = refl
1!≡ lidr = refl
1!≡ ridl = refl
1!≡ ridr = refl
1!≡ (resp◎ c₁ c₂) = cong₂ (λ c₁ c₂ → resp◎ c₁ c₂) (1!≡ c₁) (1!≡ c₂)
1!≡ assocl = refl
1!≡ assocr = refl
1!≡ linv◎l = refl
1!≡ linv◎r = refl
1!≡ rinv◎l = refl
1!≡ rinv◎r = refl
-- better syntax for writing 2paths
_⇔⟨_⟩_ : {t₁ t₂ : U•} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} →
(1•[ PATH t₁ t₂ , path c₁ ] ⇔ 1•[ PATH t₁ t₂ , path c₂ ]) →
(1•[ PATH t₁ t₂ , path c₂ ] ⇔ 1•[ PATH t₁ t₂ , path c₃ ]) →
(1•[ PATH t₁ t₂ , path c₁ ] ⇔ 1•[ PATH t₁ t₂ , path c₃ ])
_ ⇔⟨ α ⟩ β = α ◎ β
_▤ : {t₁ t₂ : U•} → (c : t₁ ⟷ t₂) →
1•[ PATH t₁ t₂ , path c ] ⇔ 1•[ PATH t₁ t₂ , path c ]
_▤ c = id⇔
α₁ : 1•[ PATH BOOL•T BOOL•F , p₁ ] ⇔ 1•[ PATH BOOL•T BOOL•F , p₁ ]
α₁ = id⇔
α₂ : 1•[ PATH BOOL•T BOOL•F , p₁ ] ⇔ 1•[ PATH BOOL•T BOOL•F , p₂ ]
α₂ = lidr
-- level 0 is a groupoid with a non-trivial path equivalence the various inv*
-- rules are not justified by the groupoid proof; they are justified by the
-- need for computational rules. So it is important to have not just a
-- groupoid structure but a groupoid structure that we can compute with. So
-- if we say that we want p ◎ p⁻¹ to be id, we must have computational rules
-- that allow us to derive this for any path p, and similarly for all the
-- other groupoid rules. (cf. The canonicity for 2D type theory by Licata and
-- Harper)
G : 1Groupoid
G = record
{ set = U•
; _↝_ = _⟷_
; _≈_ = λ {t₁} {t₂} c₀ c₁ →
1•[ PATH t₁ t₂ , path c₀ ] ⇔ 1•[ PATH t₁ t₂ , path c₁ ]
; id = id⟷
; _∘_ = λ c₀ c₁ → c₁ ◎ c₀
; _⁻¹ = !
; lneutr = λ _ → ridl
; rneutr = λ _ → lidl
; assoc = λ _ _ _ → assocl
; equiv = record { refl = id⇔
; sym = λ c → 1! c
; trans = λ c₀ c₁ → c₀ ◎ c₁ }
; linv = λ {t₁} {t₂} c → linv◎l
; rinv = λ {t₁} {t₂} c → rinv◎l
; ∘-resp-≈ = λ f⟷h g⟷i → resp◎ g⟷i f⟷h
}
-- We can now ask whether a given space is a set (Def. 3.1.1)
isSet : U → Set
isSet t = (v v' : ⟦ t ⟧) → (p q : •[ t , v ] ⟷ •[ t , v' ]) →
(1•[ PATH •[ t , v ] •[ t , v' ] , path p ] ⇔
1•[ PATH •[ t , v ] •[ t , v' ] , path q ])
0isSet : isSet ZERO
0isSet ()
1isSet : isSet ONE
1isSet tt tt id⟷ id⟷ = id⇔
1isSet tt tt id⟷ (uniti₊ ◎ unite₊) =
id⟷
⇔⟨ rinv◎r ⟩
uniti₊ ◎ unite₊ ▤
1isSet tt tt id⟷ (uniti₊ ◎ (q₂ ◎ q₃)) =
id⟷
⇔⟨ {!!} ⟩
(uniti₊ ◎ (q₂ ◎ q₃)) ▤
1isSet tt tt id⟷ (uniti⋆ ◎ unite⋆) = {!!}
1isSet tt tt id⟷ (uniti⋆ ◎ (q₂ ◎ q₃)) = {!!}
1isSet tt tt id⟷ (id⟷ ◎ id⟷) = {!!}
1isSet tt tt id⟷ (id⟷ ◎ (q₂ ◎ q₃)) = {!!}
1isSet tt tt id⟷ ((q₁ ◎ q₂) ◎ unite₊) = {!!}
1isSet tt tt id⟷ ((q₁ ◎ q₂) ◎ unite⋆) = {!!}
1isSet tt tt id⟷ ((q₁ ◎ q₂) ◎ id⟷) = {!!}
1isSet tt tt id⟷ ((q₁ ◎ q₂) ◎ (q₃ ◎ q₄)) = {!!}
1isSet tt tt (p₁ ◎ p₂) id⟷ = {!!}
1isSet tt tt (p₁ ◎ p₂) (q₁ ◎ q₂) = {!!}
------------------------------------------------------------------------------
-- Level 2 etc.
data 2U : Set where
2ZERO : 2U
2ONE : 2U
2PLUS : 2U → 2U → 2U
2TIMES : 2U → 2U → 2U
1PATH : (t₁ t₂ : 1U•) → 2U
data 1Path (t₁ t₂ : 1U•) : Set where
1path : (c : t₁ ⇔ t₂) → 1Path t₁ t₂
2⟦_⟧ : 2U → Set
2⟦ 2ZERO ⟧ = ⊥
2⟦ 2ONE ⟧ = ⊤
2⟦ 2PLUS t₁ t₂ ⟧ = 2⟦ t₁ ⟧ ⊎ 2⟦ t₂ ⟧
2⟦ 2TIMES t₁ t₂ ⟧ = 2⟦ t₁ ⟧ × 2⟦ t₂ ⟧
2⟦ 1PATH t₁ t₂ ⟧ = 1Path t₁ t₂
record 2U• : Set where
constructor 2•[_,_]
field
2∣_∣ : 2U
2• : 2⟦ 2∣_∣ ⟧
data _2⇔_ : 2U• → 2U• → Set where
id2⇔ : ∀ {t v} → 2•[ t , v ] 2⇔ 2•[ t , v ]
-- and all the remaining combinators...
-- Eckmann-Hilton
Ω : (t : U) → {v : ⟦ t ⟧} → 1U•
Ω t {v} = 1•[ PATH t• t• , path id⟷ ]
where t• = •[ t , v ]
Ω² : (t : U) → {v : ⟦ t ⟧} → 2U•
Ω² t {v} = 2•[ 1PATH t• t• , 1path id⇔ ]
where t• = Ω t {v}
eckmann-hilton : {t : U} {v : ⟦ t ⟧} (α β : (Ω t {v}) ⇔ (Ω t {v})) →
(2•[ 1PATH (Ω t {v}) (Ω t {v}) , 1path (α ◎ β) ] 2⇔
2•[ 1PATH (Ω t {v}) (Ω t {v}) , 1path (β ◎ α) ])
eckmann-hilton {t} {v} α β = {!!}
------------------------------------------------------------------------------
-- Int construction
-- Types are of the form t - t'
record Uℤ : Set where
constructor _-_
field
pos : U
neg : U
open Uℤ
ZEROℤ ONEℤ : Uℤ
ZEROℤ = ZERO - ZERO
ONEℤ = ONE - ZERO
PLUSℤ : Uℤ → Uℤ → Uℤ
PLUSℤ (pos₁ - neg₁) (pos₂ - neg₂) = PLUS pos₁ pos₂ - PLUS neg₁ neg₂
TIMESℤ : Uℤ → Uℤ → Uℤ
TIMESℤ (pos₁ - neg₁) (pos₂ - neg₂) =
PLUS (TIMES pos₁ pos₂) (TIMES neg₁ neg₂) -
PLUS (TIMES pos₁ neg₂) (TIMES neg₁ pos₂)
FLIPℤ : Uℤ → Uℤ
FLIPℤ (pos - neg) = neg - pos
LOLLIℤ : Uℤ → Uℤ → Uℤ
LOLLIℤ (pos₁ - neg₁) (pos₂ - neg₂) = PLUS neg₁ pos₂ - PLUS pos₁ neg₂
-- Pointed types
data Uℤ• : Set where
pos• : (t : Uℤ) → ⟦ pos t ⟧ → Uℤ•
neg• : (t : Uℤ) → ⟦ neg t ⟧ → Uℤ•
ZEROℤ+• : {t : U} {v : ⟦ t ⟧} → Uℤ•
ZEROℤ+• {t} {v} = pos• (t - t) v
ZEROℤ-• : {t : U} {v : ⟦ t ⟧} → Uℤ•
ZEROℤ-• {t} {v} = neg• (t - t) v
PLUS1ℤ• : Uℤ• → Uℤ → Uℤ•
PLUS1ℤ• (pos• t₁ v₁) t₂ = pos• (PLUSℤ t₁ t₂) (inj₁ v₁)
PLUS1ℤ• (neg• t₁ v₁) t₂ = neg• (PLUSℤ t₁ t₂) (inj₁ v₁)
PLUS2ℤ• : Uℤ → Uℤ• → Uℤ•
PLUS2ℤ• t₁ (pos• t₂ v₂) = pos• (PLUSℤ t₁ t₂) (inj₂ v₂)
PLUS2ℤ• t₁ (neg• t₂ v₂) = neg• (PLUSℤ t₁ t₂) (inj₂ v₂)
-- Combinators on pointed types
data _⇄_ : Uℤ• → Uℤ• → Set where
Fwd : ∀ {t₁ t₂ t₃ t₄ v₁ v₃} →
•[ PLUS t₁ t₄ , inj₁ v₁ ] ⟷ •[ PLUS t₂ t₃ , inj₂ v₃ ] →
pos• (t₁ - t₂) v₁ ⇄ pos• (t₃ - t₄) v₃
Bck : ∀ {t₁ t₂ t₃ t₄ v₂ v₄} →
•[ PLUS t₁ t₄ , inj₂ v₄ ] ⟷ •[ PLUS t₂ t₃ , inj₁ v₂ ] →
neg• (t₁ - t₂) v₂ ⇄ neg• (t₃ - t₄) v₄
B2F : ∀ {t v} → neg• (t - t) v ⇄ pos• (t - t) v
F2B : ∀ {t v} → pos• (t - t) v ⇄ neg• (t - t) v
unite₊⇄ : {t : Uℤ•} → PLUS2ℤ• ZEROℤ t ⇄ t
unite₊⇄ {pos• t v} =
Fwd (•[ PLUS (PLUS ZERO (pos t)) (neg t) , inj₁ (inj₂ v) ]
⟷⟨ assocr2₊ ⟩
•[ PLUS ZERO (PLUS (pos t) (neg t)) , inj₂ (inj₁ v) ]
⟷⟨ unite₊ ◎ swap1₊ ⟩
•[ PLUS (neg t) (pos t) , inj₂ v ]
⟷⟨ uniti₊ ⟩
•[ PLUS ZERO (PLUS (neg t) (pos t)) , inj₂ (inj₂ v) ]
⟷⟨ assocl3₊ ⟩
•[ PLUS (PLUS ZERO (neg t)) (pos t) , inj₂ v ] □)
unite₊⇄ {neg• t v} =
Bck (•[ PLUS (PLUS ZERO (pos t)) (neg t) , inj₂ v ]
⟷⟨ assocr3₊ ⟩
•[ PLUS ZERO (PLUS (pos t) (neg t)) , inj₂ (inj₂ v) ]
⟷⟨ unite₊ ◎ swap2₊ ◎ uniti₊ ⟩
•[ PLUS ZERO (PLUS (neg t) (pos t)) , inj₂ (inj₁ v) ]
⟷⟨ assocl2₊ ⟩
•[ PLUS (PLUS ZERO (neg t)) (pos t) , inj₁ (inj₂ v) ] □)
uniti₊⇄ : {t : Uℤ•} → t ⇄ PLUS2ℤ• ZEROℤ t
uniti₊⇄ {pos• t v} =
Fwd (•[ PLUS (pos t) (PLUS ZERO (neg t)) , inj₁ v ]
⟷⟨ assocl1₊ ⟩
•[ PLUS (PLUS (pos t) ZERO) (neg t) , inj₁ (inj₁ v) ]
⟷⟨ swap1₊ ⟩
•[ PLUS (neg t) (PLUS (pos t) ZERO) , inj₂ (inj₁ v) ]
⟷⟨ ⊕2 swap1₊ ⟩
•[ PLUS (neg t) (PLUS ZERO (pos t)) , inj₂ (inj₂ v) ] □)
uniti₊⇄ {neg• t v} =
Bck (•[ PLUS (pos t) (PLUS ZERO (neg t)) , inj₂ (inj₂ v) ]
⟷⟨ ⊕2 swap2₊ ⟩
•[ PLUS (pos t) (PLUS (neg t) ZERO) , inj₂ (inj₁ v) ]
⟷⟨ swap2₊ ⟩
•[ PLUS (PLUS (neg t) ZERO) (pos t) , inj₁ (inj₁ v) ]
⟷⟨ assocr1₊ ⟩
•[ PLUS (neg t) (PLUS ZERO (pos t)) , inj₁ v ] □)
swap1₊⇄ : {t₁ : Uℤ•} {t₂ : Uℤ} → PLUS1ℤ• t₁ t₂ ⇄ PLUS2ℤ• t₂ t₁
swap1₊⇄ {pos• t₁ v₁} {t₂} =
Fwd (•[ PLUS (PLUS (pos t₁) (pos t₂)) (PLUS (neg t₂) (neg t₁)) ,
inj₁ (inj₁ v₁) ]
⟷⟨ {!!} ⟩
•[ PLUS (PLUS (neg t₁) (neg t₂)) (PLUS (pos t₂) (pos t₁)) ,
inj₂ (inj₂ v₁) ] □)
swap1₊⇄ {neg• t₁ v₁} {t₂} =
Bck (•[ PLUS (PLUS (pos t₁) (pos t₂)) (PLUS (neg t₂) (neg t₁)) ,
inj₂ (inj₂ v₁) ]
⟷⟨ {!!} ⟩
•[ PLUS (PLUS (neg t₁) (neg t₂)) (PLUS (pos t₂) (pos t₁)) ,
inj₁ (inj₁ v₁) ] □)
swap2₊⇄ : {t₁ : Uℤ} {t₂ : Uℤ•} → PLUS2ℤ• t₁ t₂ ⇄ PLUS1ℤ• t₂ t₁
swap2₊⇄ {t₁} {pos• t₂ v₂} =
Fwd (•[ PLUS (PLUS (pos t₁) (pos t₂)) (PLUS (neg t₂) (neg t₁)) ,
inj₁ (inj₂ v₂) ]
⟷⟨ {!!} ⟩
•[ PLUS (PLUS (neg t₁) (neg t₂)) (PLUS (pos t₂) (pos t₁)) ,
inj₂ (inj₁ v₂) ] □)
swap2₊⇄ {t₁} {neg• t₂ v₂} =
Bck (•[ PLUS (PLUS (pos t₁) (pos t₂)) (PLUS (neg t₂) (neg t₁)) ,
inj₂ (inj₁ v₂) ]
⟷⟨ {!!} ⟩
•[ PLUS (PLUS (neg t₁) (neg t₂)) (PLUS (pos t₂) (pos t₁)) ,
inj₁ (inj₂ v₂) ] □)
assocl1₊⇄ : {t₁ : Uℤ•} {t₂ t₃ : Uℤ} →
PLUS1ℤ• t₁ (PLUSℤ t₂ t₃) ⇄ PLUS1ℤ• (PLUS1ℤ• t₁ t₂) t₃
assocl1₊⇄ {pos• t₁ v₁} {t₂} {t₃} =
Fwd (•[ PLUS (PLUS (pos t₁) (pos (PLUSℤ t₂ t₃)))
(PLUS (neg (PLUSℤ t₁ t₂)) (neg t₃)) ,
inj₁ (inj₁ v₁) ]
⟷⟨ {!!} ⟩
•[ PLUS (PLUS (neg t₁) (neg (PLUSℤ t₂ t₃)))
(PLUS (pos (PLUSℤ t₁ t₂)) (pos t₃)) ,
inj₂ (inj₁ (inj₁ v₁)) ] □)
assocl1₊⇄ {neg• t₁ v₁} {t₂} {t₃} =
Bck (•[ PLUS (PLUS (pos t₁) (pos (PLUSℤ t₂ t₃)))
(PLUS (neg (PLUSℤ t₁ t₂)) (neg t₃)) ,
inj₂ (inj₁ (inj₁ v₁)) ]
⟷⟨ {!!} ⟩
•[ PLUS (PLUS (neg t₁) (neg (PLUSℤ t₂ t₃)))
(PLUS (pos (PLUSℤ t₁ t₂)) (pos t₃)) ,
inj₁ (inj₁ v₁) ] □)
{--
assocl2₊ : ∀ {t₁ t₂ t₃ v₂} →
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] ⟷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ]
assocl3₊ : ∀ {t₁ t₂ t₃ v₃} →
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] ⟷
•[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ]
assocr1₊ : ∀ {t₁ t₂ t₃ v₁} →
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] ⟷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₁ v₁ ]
assocr2₊ : ∀ {t₁ t₂ t₃ v₂} →
•[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] ⟷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ]
assocr3₊ : ∀ {t₁ t₂ t₃ v₃} →
•[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ] ⟷
•[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ]
unite⋆ : ∀ {t v} → •[ TIMES ONE t , (tt , v) ] ⟷ •[ t , v ]
uniti⋆ : ∀ {t v} → •[ t , v ] ⟷ •[ TIMES ONE t , (tt , v) ]
swap⋆ : ∀ {t₁ t₂ v₁ v₂} →
•[ TIMES t₁ t₂ , (v₁ , v₂) ] ⟷ •[ TIMES t₂ t₁ , (v₂ , v₁) ]
assocl⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} →
•[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] ⟷
•[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ]
assocr⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} →
•[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] ⟷
•[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ]
distz : ∀ {t v absurd} →
•[ TIMES ZERO t , (absurd , v) ] ⟷ •[ ZERO , absurd ]
factorz : ∀ {t v absurd} →
•[ ZERO , absurd ] ⟷ •[ TIMES ZERO t , (absurd , v) ]
dist1 : ∀ {t₁ t₂ t₃ v₁ v₃} →
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] ⟷
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ]
dist2 : ∀ {t₁ t₂ t₃ v₂ v₃} →
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] ⟷
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ]
factor1 : ∀ {t₁ t₂ t₃ v₁ v₃} →
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] ⟷
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ]
factor2 : ∀ {t₁ t₂ t₃ v₂ v₃} →
•[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] ⟷
•[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ]
--}
id⇄ : {t : Uℤ•} → t ⇄ t
id⇄ {pos• t p} = Fwd swap1₊
id⇄ {neg• t n} = Bck swap2₊
{--
_◎⇄_ : {t₁ t₂ t₃ : Uℤ•} → (t₁ ⇄ t₂) → (t₂ ⇄ t₃) → (t₁ ⇄ t₃)
_◎⇄_ {pos• t₁ v₁} {pos• t₂ v₂} {pos• t₃ v₃} (Fwd c₁) (Fwd c₂) =
Fwd (•[ PLUS (pos t₁) (neg t₃) , inj₁ v₁ ]
⟷⟨ {!!} ⟩
•[ PLUS (neg t₁) (pos t₃) , inj₂ v₃ ] □)
-- c₁ : •[ PLUS (pos t₁) (neg t₂) , inj₁ v₁ ] ⟷
-- •[ PLUS (neg t₁) (pos t₂) , inj₂ v₂ ]
-- c₂ : •[ PLUS (pos t₂) (neg t₃) , inj₁ v₂ ] ⟷
-- •[ PLUS (neg t₂) (pos t₃) , inj₂ v₃ ]
_◎⇄_ {pos• (t₁ - t₂) v₁} {pos• (t₃ - .t₃) v₃} {neg• (.t₃ - .t₃) .v₃}
(Fwd c) F2B = {!!}
-- ?7 : pos• (t₁ - t₂) v₁ ⇄ neg• (t₃ - t₃) v₃
Bck c₁ ◎⇄ Bck c₂ = Bck {!!}
Bck c ◎⇄ B2F = {!!}
B2F ◎⇄ Fwd c = {!!}
B2F ◎⇄ F2B = id⇄
F2B ◎⇄ Bck c = {!!}
F2B ◎⇄ B2F = id⇄
--}
{--
_⊕1_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} →
(•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) → (•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) →
(•[ PLUS t₁ t₂ , inj₁ v₁ ] ⟷ •[ PLUS t₃ t₄ , inj₁ v₃ ])
_⊕2_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} →
(•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) → (•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) →
(•[ PLUS t₁ t₂ , inj₂ v₂ ] ⟷ •[ PLUS t₃ t₄ , inj₂ v₄ ])
_⊗_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} →
(•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) → (•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) →
(•[ TIMES t₁ t₂ , (v₁ , v₂) ] ⟷ •[ TIMES t₃ t₄ , (v₃ , v₄) ])
--}
-- trace
η : ∀ {t v} → ZEROℤ+• {t} {v} ⇄ ZEROℤ-• {t} {v}
η = F2B
ε : ∀ {t v} → ZEROℤ-• {t} {v} ⇄ ZEROℤ+• {t} {v}
ε = B2F
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.4568382437,
"avg_line_length": 34.3087512291,
"ext": "agda",
"hexsha": "b3c1b56981849b1bd3b5803aa5bac655af30aeaf",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/PiWithLevels/Pi1.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/PiWithLevels/Pi1.agda",
"max_line_length": 80,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/PiWithLevels/Pi1.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 18065,
"size": 34892
} |
open import Agda.Primitive
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
variable
ℓ : Level
A : Set ℓ
n : Nat
infixr 4 _∷_
data Vec (A : Set) : Nat → Set where
[] : Vec A 0
_∷_ : A → Vec A n → Vec A (suc n)
variable
xs : Vec A n
data T (n : Nat) (f : Nat → Nat) : Set where
it : T n f
appT : ∀ {f} → T n f → Nat
appT {n = n} {f = f} it = f n
length : Vec A n → Nat
length {n = n} _ = n
-- This should not break.
bar : (xs : Vec Nat n) → T n λ { m → m + length xs }
bar xs = it
ys : Vec Nat 5
ys = 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ []
-- Check that it doesn't
no-fail : appT (bar ys) ≡ 10
no-fail = refl
| {
"alphanum_fraction": 0.5552050473,
"avg_line_length": 16.2564102564,
"ext": "agda",
"hexsha": "c50cb5a45ba8ed82b7884f0c17686cb25d6c85b6",
"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/GeneralizeWithPatternLambda.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/GeneralizeWithPatternLambda.agda",
"max_line_length": 52,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/GeneralizeWithPatternLambda.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": 271,
"size": 634
} |
{-# OPTIONS --allow-unsolved-metas #-}
postulate
Foo : Set
record BaseT : Set₁ where
field f : Foo
record ParamT (p : Foo) : Set₁ where
field f : Foo
instance
postulate asBaseT : ∀ {p} → ParamT p → BaseT
-- BaseT.f (asBaseT p) = ParamT.f p
data Bar : Set where
o : Bar
data Baz {{_ : BaseT}} : Bar → Set where
t1 : Baz o
t2 : Baz o → Baz o
t3 : Baz o → Baz o → Baz o
t4 : Baz o → Baz o → Baz o → Baz o
| {
"alphanum_fraction": 0.5938967136,
"avg_line_length": 18.5217391304,
"ext": "agda",
"hexsha": "24b7ff5b3260c72c642e152593389a57eaa91414",
"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/Succeed/Issue1998.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/Succeed/Issue1998.agda",
"max_line_length": 46,
"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/Succeed/Issue1998.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": 160,
"size": 426
} |
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Experiments.NatMinusTwo.ToNatMinusOne where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.NatMinusOne as ℕ₋₁ using (ℕ₋₁)
open import Cubical.Experiments.NatMinusTwo.Base as ℕ₋₂ using (ℕ₋₂; -2+_)
-- Conversions to/from ℕ₋₁
-1+_ : ℕ₋₁ → ℕ₋₂
-1+ (ℕ₋₁.-1+ n) = -2+ n
1+_ : ℕ₋₂ → ℕ₋₁
1+ (-2+ n) = ℕ₋₁.-1+ n
ℕ₋₁→ℕ₋₂ : ℕ₋₁ → ℕ₋₂
ℕ₋₁→ℕ₋₂ (ℕ₋₁.-1+ n) = ℕ₋₂.-1+ n
-- Properties
-1+Path : ℕ₋₁ ≡ ℕ₋₂
-1+Path = isoToPath (iso -1+_ 1+_ (λ _ → refl) (λ _ → refl))
| {
"alphanum_fraction": 0.64013267,
"avg_line_length": 24.12,
"ext": "agda",
"hexsha": "7c30b3b38ae98d64d3da06147806cb7464a413fb",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Experiments/NatMinusTwo/ToNatMinusOne.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Experiments/NatMinusTwo/ToNatMinusOne.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Experiments/NatMinusTwo/ToNatMinusOne.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 280,
"size": 603
} |
-- Andreas, 2016-06-26, issue #2059 reported by IanOrton
-- An irrelevant parameter in a rewrite rule should still
-- be bound by the lhs.
{-# OPTIONS --rewriting #-}
-- {-# OPTIONS -v tc.pos:10 #-}
-- {-# OPTIONS -v tc.polarity:10 #-}
open import Common.Equality
open import Common.Bool
data ⊥ : Set where
⊥-elim : ∀{a}{A : Set a} → .⊥ → A
⊥-elim ()
_∧_ : (a b : Bool) → Bool
true ∧ b = b
false ∧ _ = false
obvious : (b b' : Bool) .(p : b ≡ b' → ⊥) → (b ∧ b') ≡ false
obvious false b' notEq = refl
obvious true false notEq = refl
obvious true true notEq = ⊥-elim (notEq refl)
{-# BUILTIN REWRITE _≡_ #-}
{-# REWRITE obvious #-}
-- Should give error:
-- obvious is not a legal rewrite rule,
-- since the following variables are not bound by the left hand side: p
-- when checking the pragma REWRITE obvious
oops : (b : Bool) → b ∧ b ≡ false
oops b = refl
true≢false : true ≡ false → ⊥
true≢false ()
bot : ⊥
bot = true≢false (oops true)
| {
"alphanum_fraction": 0.6201873049,
"avg_line_length": 21.3555555556,
"ext": "agda",
"hexsha": "382280e6e83b50aa3aedf2c953473e64356b8f7e",
"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/Issue2059i.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/Issue2059i.agda",
"max_line_length": 72,
"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/Issue2059i.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": 324,
"size": 961
} |
module Data.Num.Surjection where
open import Data.Num.Core
open import Data.Num.Continuous
open import Data.Nat
open import Data.Nat.Properties
open import Data.Nat.Properties.Simple
open import Data.Nat.Properties.Extra
open import Data.Fin as Fin
using (Fin; fromℕ≤; inject≤)
renaming (zero to z; suc to s)
open import Data.Fin.Properties using (toℕ-fromℕ≤; bounded)
open import Data.Product
open import Data.Empty using (⊥)
open import Data.Unit using (⊤; tt)
open import Function
open import Function.Surjection hiding (_∘_)
open Surjective
open import Function.Equality using (_⟶_; _⟨$⟩_)
open import Relation.Nullary.Decidable
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_)
open DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl)
-- fromℕ that preserves equality
-- ℕ⟶Num : ∀ {b d o}
-- → (True (Continuous? b (suc d) o))
-- → (val : ℕ)
-- → (True (o ≤? val))
-- → Num b (suc d) o
-- ℕ⟶Num : ∀ b d o → True (Continuous? b (suc d) o) → setoid ℕ ⟶ setoid (Num b (suc d) o)
-- ℕ⟶Num b d o cont = record
-- { _⟨$⟩_ = fromℕ cont
-- ; cong = cong (fromℕ cont)
-- }
--
-- -- Surjective? : ∀ b d o → (True (Continuous? b (suc d) o)) → Dec (Surjective (ℕ⟶Num b d o))
-- -- Surjective? b d o with Continuous? b (suc d) o
-- -- Surjective? b d o | yes cont = {! !}
-- -- Surjective? b d o | no ¬cont = {! !}
--
-- Num⟶ℕ-Surjective : ∀ b d o → (cont : True (Continuous? b (suc d) o)) → Surjective (Num⟶ℕ b (suc d) o)
-- Num⟶ℕ-Surjective b d o cont = record
-- { from = ℕ⟶Num b d o cont
-- ; right-inverse-of = {! toℕ-fromℕ cont !}
-- }
-- Surjective? : ∀ b d o → Dec (Surjective (Num⟶ℕ b d o))
-- Surjective? b d o with surjectionView b d o
-- Surjective? b d o | Surj cond = yes (record
-- { from = ℕ⟶Num b d o
-- ; right-inverse-of = toℕ-fromℕ {b} {d} {o} {SurjCond⇒IsSurj cond}
-- })
-- Surjective? b d o | NonSurj reason = no (NonSurjCond⇏Surjective reason)
--
-- Conditions of surjectiveness
-- data SurjCond : ℕ → ℕ → ℕ → Set where
-- WithZerosUnary : ∀ { d} → (d≥2 : d ≥ 2) → SurjCond 1 d 0
-- WithZeros : ∀ {b d} (b≥2 : b ≥ 2) → (d≥b : d ≥ b) → SurjCond b d 0
-- Zeroless : ∀ {b d} (b≥1 : b ≥ 1) → (d≥b : d ≥ b) → SurjCond b d 1
--
-- -- Conditions of non-surjectiveness
-- data NonSurjCond : ℕ → ℕ → ℕ → Set where
-- Base≡0 : ∀ { d o} → NonSurjCond 0 d o
-- NoDigits : ∀ {b o} → NonSurjCond b 0 o
-- Offset≥2 : ∀ {b d o} → o ≥ 2 → NonSurjCond b d o
-- UnaryWithOnlyZeros : NonSurjCond 1 1 0
-- NotEnoughDigits : ∀ {b d o} → d ≥ 1 → d ≱ b → NonSurjCond b d o
--
-- data SurjectionView : ℕ → ℕ → ℕ → Set where
-- Surj : ∀ {b d o} → SurjCond b d o → SurjectionView b d o
-- NonSurj : ∀ {b d o} → NonSurjCond b d o → SurjectionView b d o
--
--
-- surjectionView : (b d o : ℕ) → SurjectionView b d o
-- surjectionView 0 d o = NonSurj Base≡0
-- surjectionView (suc b) 0 o = NonSurj NoDigits
-- surjectionView (suc b) (suc d) o with suc b ≤? suc d
-- surjectionView 1 1 0 | yes p = NonSurj UnaryWithOnlyZeros
-- surjectionView 1 (suc (suc d)) 0 | yes p = Surj (WithZerosUnary (s≤s (s≤s z≤n)))
-- surjectionView (suc (suc b)) (suc d) 0 | yes p = Surj (WithZeros (s≤s (s≤s z≤n)) p)
-- surjectionView (suc b) (suc d) 1 | yes p = Surj (Zeroless (s≤s z≤n) p)
-- surjectionView (suc b) (suc d) (suc (suc o)) | yes p = NonSurj (Offset≥2 (s≤s (s≤s z≤n)))
-- surjectionView (suc b) (suc d) o | no ¬p = NonSurj (NotEnoughDigits (s≤s z≤n) ¬p)
--
-- IsSurjective : ℕ → ℕ → ℕ → Set
-- IsSurjective b d o with surjectionView b d o
-- IsSurjective b d o | Surj _ = ⊤
-- IsSurjective b d o | NonSurj _ = ⊥
--
-- SurjCond⇒b≥1 : ∀ {b d o} → SurjCond b d o → b ≥ 1
-- SurjCond⇒b≥1 (WithZerosUnary d≥2) = s≤s z≤n
-- SurjCond⇒b≥1 (WithZeros (s≤s b≥1) d≥b) = s≤s z≤n
-- SurjCond⇒b≥1 (Zeroless b≥1 d≥b) = b≥1
--
-- SurjCond⇒d≥b : ∀ {b d o} → SurjCond b d o → d ≥ b
-- SurjCond⇒d≥b (WithZerosUnary (s≤s d≥1)) = s≤s z≤n
-- SurjCond⇒d≥b (WithZeros b≥2 d≥b) = d≥b
-- SurjCond⇒d≥b (Zeroless b≥1 d≥b) = d≥b
--
-- SurjCond⇒IsSurj : ∀ {b d o} → SurjCond b d o → IsSurjective b d o
-- SurjCond⇒IsSurj {b} {d} {o} cond with surjectionView b d o
-- SurjCond⇒IsSurj cond | Surj x = tt
-- SurjCond⇒IsSurj (WithZeros () d≥b) | NonSurj Base≡0
-- SurjCond⇒IsSurj (Zeroless () d≥b) | NonSurj Base≡0
-- SurjCond⇒IsSurj (WithZerosUnary ()) | NonSurj NoDigits
-- SurjCond⇒IsSurj (WithZeros () z≤n) | NonSurj NoDigits
-- SurjCond⇒IsSurj (Zeroless () z≤n) | NonSurj NoDigits
-- SurjCond⇒IsSurj (WithZerosUnary _) | NonSurj (Offset≥2 ())
-- SurjCond⇒IsSurj (WithZeros _ _) | NonSurj (Offset≥2 ())
-- SurjCond⇒IsSurj (Zeroless _ _) | NonSurj (Offset≥2 (s≤s ()))
-- SurjCond⇒IsSurj (WithZerosUnary (s≤s ())) | NonSurj UnaryWithOnlyZeros
-- SurjCond⇒IsSurj (WithZeros (s≤s ()) _) | NonSurj UnaryWithOnlyZeros
-- SurjCond⇒IsSurj (WithZerosUnary _) | NonSurj (NotEnoughDigits d≥1 d≱1) = contradiction d≥1 d≱1
-- SurjCond⇒IsSurj (WithZeros _ d≥b) | NonSurj (NotEnoughDigits _ d≱b) = contradiction d≥b d≱b
-- SurjCond⇒IsSurj (Zeroless _ d≥b) | NonSurj (NotEnoughDigits _ d≱b) = contradiction d≥b d≱b
--
-- ------------------------------------------------------------------------
-- -- Operations on Num (which does not necessary needs to be Surj)
-- ------------------------------------------------------------------------
--
-- starting-digit : ∀ {b d o} → SurjCond b d o → Digit d
-- starting-digit (WithZerosUnary d≥2) = fromℕ≤ {1} d≥2
-- starting-digit (WithZeros b≥2 d≥b) = fromℕ≤ {1} (≤-trans b≥2 d≥b)
-- starting-digit (Zeroless b≥1 d≥b) = fromℕ≤ {0} (≤-trans b≥1 d≥b)
-- 1+ : ∀ {b d o} → Num b d o → Num b d o
-- 1+ {b} {d} {o} xs with surjectionView b d o
-- 1+ ∙ | Surj cond = starting-digit cond ∷ ∙
-- 1+ (x ∷ xs) | Surj cond with greatest x
-- 1+ (x ∷ xs) | Surj cond | yes p = digit+1-b-legacy x (SurjCond⇒b≥1 cond) p ∷ 1+ xs -- carry
-- 1+ (x ∷ xs) | Surj cond | no ¬p = digit+1 x ¬p ∷ xs
-- 1+ ∙ | NonSurj reason = ∙
-- 1+ (x ∷ xs) | NonSurj reason = xs
--
--
-- n+ : ∀ {b d o} → ℕ → Num b d o → Num b d o
-- n+ zero xs = xs
-- n+ (suc n) xs = 1+ (n+ n xs)
--
-- fromℕ : ∀ {b d o} → ℕ → Num b d o
-- fromℕ {b} {d} {o} n with surjectionView b d o
-- fromℕ n | Surj x = n+ n ∙
-- fromℕ n | NonSurj x = ∙
--
--
-- -- fromℕ that preserves equality
-- ℕ⟶Num : ∀ b d o → setoid ℕ ⟶ setoid (Num b d o)
-- ℕ⟶Num b d o = record
-- { _⟨$⟩_ = fromℕ
-- ; cong = cong fromℕ
-- }
--
-- toℕ-digit+1-b : ∀ {d b} (x : Digit d)
-- → (b≥1 : b ≥ 1) → (p : suc (Fin.toℕ x) ≡ d) -- required props
-- → Fin.toℕ (digit+1-b-legacy x b≥1 p) ≡ suc (Fin.toℕ x) ∸ b
-- toℕ-digit+1-b {d} {b} x b≥1 p = toℕ-fromℕ≤ $ start
-- suc (suc (Fin.toℕ x) ∸ b)
-- ≤⟨ s≤s (∸-mono ≤-refl b≥1) ⟩
-- suc (Fin.toℕ x)
-- ≈⟨ p ⟩
-- d
-- □
--
-- ------------------------------------------------------------------------
-- -- toℕ-1+ : toℕ (1+ xs) ≡ suc (toℕ xs)
-- ------------------------------------------------------------------------
--
-- toℕ-1+-x∷xs-greatest-lemma : ∀ {b d o}
-- → (x : Digit d) → (xs : Num b d o)
-- → (cond : SurjCond b d o)
-- → (p : suc (Fin.toℕ x) ≡ d)
-- → (toℕ-1+-xs : toℕ (1+ xs) ≡ suc (toℕ xs))
-- → toℕ (digit+1-b-legacy x (SurjCond⇒b≥1 cond) p ∷ 1+ xs) ≡ suc (toℕ (x ∷ xs))
-- toℕ-1+-x∷xs-greatest-lemma {b} {d} {o} x xs cond p toℕ-1+-xs =
-- begin
-- toℕ (digit+1-b-legacy x (SurjCond⇒b≥1 cond) p ∷ 1+ xs)
-- -- toℕ-fromℕ≤ : toℕ (fromℕ≤ m<n) ≡ m
-- ≡⟨ cong (λ w → o + w + toℕ (1+ xs) * b) (toℕ-fromℕ≤ ((digit+1-b-legacy-lemma x (SurjCond⇒b≥1 cond) p))) ⟩
-- o + (suc (Fin.toℕ x) ∸ b) + toℕ (1+ xs) * b
-- -- induction hypothesis
-- ≡⟨ cong (λ w → o + (suc (Fin.toℕ x) ∸ b) + w * b) toℕ-1+-xs ⟩
-- o + (suc (Fin.toℕ x) ∸ b) + (b + toℕ xs * b)
-- ≡⟨ +-assoc o (suc (Fin.toℕ x) ∸ b) (b + toℕ xs * b) ⟩
-- o + (suc (Fin.toℕ x) ∸ b + (b + toℕ xs * b))
-- ≡⟨ cong (λ w → o + w) (sym (+-assoc (suc (Fin.toℕ x) ∸ b) b (toℕ xs * b))) ⟩
-- o + (suc (Fin.toℕ x) ∸ b + b + toℕ xs * b)
-- ≡⟨ cong (λ w → o + (w + toℕ xs * b)) (+-comm (suc (Fin.toℕ x) ∸ b) b) ⟩
-- o + (b + (suc (Fin.toℕ x) ∸ b) + toℕ xs * b)
-- -- m+n∸m≡n : m + (n ∸ m) ≡ n
-- ≡⟨ cong (λ w → o + (w + toℕ xs * b)) (m+n∸m≡n (
-- start
-- b
-- ≤⟨ SurjCond⇒d≥b cond ⟩
-- d
-- ≈⟨ sym p ⟩
-- suc (Fin.toℕ x)
-- □)) ⟩
-- o + suc (Fin.toℕ x + toℕ xs * b)
-- ≡⟨ +-suc o (Fin.toℕ x + toℕ xs * b) ⟩
-- suc (o + (Fin.toℕ x + toℕ xs * b))
-- ≡⟨ cong suc (sym (+-assoc o (Fin.toℕ x) (toℕ xs * b))) ⟩
-- suc (o + Fin.toℕ x + toℕ xs * b)
-- ∎
--
-- toℕ-1+-x∷xs-not-greatest-lemma : ∀ {b d o}
-- → (x : Digit d) → (xs : Num b d o)
-- → (¬p : suc (Fin.toℕ x) ≢ d)
-- → toℕ (digit+1 x ¬p ∷ xs) ≡ suc (toℕ (x ∷ xs))
-- toℕ-1+-x∷xs-not-greatest-lemma {b} {d} {o} x xs ¬p =
-- begin
-- o + Fin.toℕ (fromℕ≤ (≤∧≢⇒< (bounded x) ¬p)) + toℕ xs * b
-- -- toℕ-fromℕ≤
-- ≡⟨ cong (λ w → o + w + toℕ xs * b) (toℕ-fromℕ≤ (≤∧≢⇒< (bounded x) ¬p)) ⟩
-- o + suc (Fin.toℕ x) + toℕ xs * b
-- ≡⟨ +-assoc o (suc (Fin.toℕ x)) (toℕ xs * b) ⟩
-- o + suc (Fin.toℕ x + toℕ xs * b)
-- ≡⟨ +-suc o (Fin.toℕ x + toℕ xs * b) ⟩
-- suc (o + (Fin.toℕ x + toℕ xs * b))
-- ≡⟨ cong suc (sym (+-assoc o (Fin.toℕ x) (toℕ xs * b))) ⟩
-- suc (o + Fin.toℕ x + toℕ xs * b)
-- ∎
--
-- toℕ-1+ : ∀ {b d o}
-- → {isSurj : IsSurjective b d o}
-- → (xs : Num b d o)
-- → toℕ (1+ xs) ≡ suc (toℕ xs)
-- toℕ-1+ {b} {d} {o} xs with surjectionView b d o
-- toℕ-1+ {1} {d} {0} ∙ | Surj (WithZerosUnary d≥2) =
-- begin
-- Fin.toℕ (fromℕ≤ d≥2) + zero
-- ≡⟨ +-right-identity (Fin.toℕ (fromℕ≤ d≥2)) ⟩
-- Fin.toℕ (fromℕ≤ d≥2)
-- ≡⟨ toℕ-fromℕ≤ d≥2 ⟩
-- suc zero
-- ∎
-- toℕ-1+ {b} {d} {0} ∙ | Surj (WithZeros b≥2 d≥b) =
-- begin
-- Fin.toℕ (fromℕ≤ (≤-trans b≥2 d≥b)) + zero * b
-- ≡⟨ +-right-identity (Fin.toℕ (fromℕ≤ (≤-trans b≥2 d≥b))) ⟩
-- Fin.toℕ (fromℕ≤ (≤-trans b≥2 d≥b))
-- ≡⟨ toℕ-fromℕ≤ (≤-trans b≥2 d≥b) ⟩
-- suc zero
-- ∎
-- toℕ-1+ {b} {d} {_} ∙ | Surj (Zeroless b≥1 d≥b) =
-- begin
-- suc (Fin.toℕ (fromℕ≤ (≤-trans b≥1 d≥b)) + zero)
-- ≡⟨ +-right-identity (suc (Fin.toℕ (fromℕ≤ (≤-trans b≥1 d≥b)))) ⟩
-- suc (Fin.toℕ (fromℕ≤ (≤-trans b≥1 d≥b)))
-- ≡⟨ cong suc (toℕ-fromℕ≤ (≤-trans b≥1 d≥b)) ⟩
-- suc zero
-- ∎
-- toℕ-1+ {b} {d} {o} (x ∷ xs) | Surj condition with greatest x
-- toℕ-1+ {b} {d} {o} (x ∷ xs) | Surj condition | yes p = toℕ-1+-x∷xs-greatest-lemma x xs condition p (toℕ-1+ {isSurj = SurjCond⇒IsSurj condition} xs)
-- toℕ-1+ {b} {d} {o} (x ∷ xs) | Surj condition | no ¬p = toℕ-1+-x∷xs-not-greatest-lemma x xs ¬p
-- toℕ-1+ {isSurj = ()} xs | NonSurj reason
--
-- ------------------------------------------------------------------------
-- -- toℕ-n+ : toℕ (n+ n xs) ≡ n + (toℕ xs)
-- ------------------------------------------------------------------------
--
-- toℕ-n+ : ∀ {b d o}
-- → {isSurj : IsSurjective b d o}
-- → (n : ℕ)
-- → (xs : Num b d o)
-- → toℕ (n+ n xs) ≡ n + (toℕ xs)
-- toℕ-n+ {b} {d} {o} n xs with surjectionView b d o
-- toℕ-n+ zero xs | Surj cond = refl
-- toℕ-n+ (suc n) xs | Surj cond =
-- begin
-- toℕ (n+ (suc n) xs)
-- ≡⟨ refl ⟩
-- toℕ (1+ (n+ n xs))
-- ≡⟨ toℕ-1+ {isSurj = SurjCond⇒IsSurj cond} (n+ n xs) ⟩
-- suc (toℕ (n+ n xs))
-- ≡⟨ cong suc (toℕ-n+ {isSurj = SurjCond⇒IsSurj cond} n xs) ⟩
-- suc (n + toℕ xs)
-- ∎
-- toℕ-n+ {isSurj = ()} n xs | NonSurj reason
--
-- ------------------------------------------------------------------------
-- -- toℕ-fromℕ : toℕ (fromℕ n) ≡ n
-- ------------------------------------------------------------------------
--
-- toℕ-fromℕ : ∀ {b d o}
-- → {isSurjective : IsSurjective b d o}
-- → (n : ℕ)
-- → toℕ (fromℕ {b} {d} {o} n) ≡ n
-- toℕ-fromℕ {b} {d} {o} n with surjectionView b d o
-- toℕ-fromℕ zero | Surj (WithZerosUnary d≥2) = refl
-- toℕ-fromℕ {_} {d} {_} (suc n) | Surj (WithZerosUnary d≥2) =
-- begin
-- toℕ (1+ (n+ {1} {d} {0} n ∙))
-- ≡⟨ toℕ-1+ {1} {d} {0} {SurjCond⇒IsSurj (WithZerosUnary d≥2)} (n+ n ∙) ⟩
-- suc (toℕ (n+ n ∙))
-- ≡⟨ cong suc (toℕ-n+ {1} {d} {0} {SurjCond⇒IsSurj (WithZerosUnary d≥2)} n ∙) ⟩
-- suc (n + zero)
-- ≡⟨ cong suc (+-right-identity n) ⟩
-- suc n
-- ∎
-- toℕ-fromℕ zero | Surj (WithZeros b≥2 d≥b) = refl
-- toℕ-fromℕ {b} {d} {_} (suc n) | Surj (WithZeros b≥2 d≥b) =
-- begin
-- toℕ (1+ (n+ {b} {d} {0} n ∙))
-- ≡⟨ toℕ-1+ {b} {d} {0} {SurjCond⇒IsSurj (WithZeros b≥2 d≥b)} (n+ n ∙) ⟩
-- suc (toℕ (n+ n ∙))
-- ≡⟨ cong suc (toℕ-n+ {b} {d} {0} {SurjCond⇒IsSurj (WithZeros b≥2 d≥b)} n ∙) ⟩
-- suc (n + zero)
-- ≡⟨ cong suc (+-right-identity n) ⟩
-- suc n
-- ∎
-- toℕ-fromℕ {b} {d} {_} zero | Surj (Zeroless b≥1 d≥b) = refl
-- toℕ-fromℕ {b} {d} {_} (suc n) | Surj (Zeroless b≥1 d≥b) =
-- begin
-- toℕ (1+ (n+ {b} {d} {1} n ∙))
-- ≡⟨ toℕ-1+ {b} {d} {1} {SurjCond⇒IsSurj (Zeroless b≥1 d≥b)} (n+ n ∙) ⟩
-- suc (toℕ (n+ n ∙))
-- ≡⟨ cong suc (toℕ-n+ {b} {d} {1} {SurjCond⇒IsSurj (Zeroless b≥1 d≥b)} n ∙) ⟩
-- suc (n + zero)
-- ≡⟨ cong suc (+-right-identity n) ⟩
-- suc n
-- ∎
-- toℕ-fromℕ {isSurjective = ()} n | NonSurj x
--
--
-- ------------------------------------------------------------------------
-- -- Lemmata for proving Spurious cases not surjective
-- ------------------------------------------------------------------------
--
-- NonSurjCond-Base≡0 : ∀ {d o} → (xs : Num 0 d o) → toℕ xs ≢ suc (o + d)
-- NonSurjCond-Base≡0 {d} {o} ∙ ()
-- NonSurjCond-Base≡0 {d} {o} (x ∷ xs) p = contradiction p (<⇒≢ ⟦x∷xs⟧<1+o+d)
-- where
-- ⟦x∷xs⟧<1+o+d : o + Fin.toℕ x + toℕ xs * 0 < suc (o + d)
-- ⟦x∷xs⟧<1+o+d = s≤s $
-- start
-- o + Fin.toℕ x + toℕ xs * zero
-- ≈⟨ cong (λ w → o + Fin.toℕ x + w) (*-right-zero (toℕ xs)) ⟩
-- o + Fin.toℕ x + zero
-- ≈⟨ +-right-identity (o + Fin.toℕ x) ⟩
-- o + Fin.toℕ x
-- ≤⟨ n+-mono o (
-- start
-- Fin.toℕ x
-- ≤⟨ n≤1+n (Fin.toℕ x) ⟩
-- suc (Fin.toℕ x)
-- ≤⟨ bounded x ⟩
-- d
-- □
-- )⟩
-- o + d
-- □
--
-- NonSurjCond-NoDigits : ∀ {b o} → (xs : Num b 0 o) → toℕ xs ≢ 1
-- NonSurjCond-NoDigits ∙ ()
-- NonSurjCond-NoDigits (() ∷ xs)
--
-- NonSurjCond-Offset≥2 : ∀ {b d o} → o ≥ 2 → (xs : Num b d o) → toℕ xs ≢ 1
-- NonSurjCond-Offset≥2 o≥2 ∙ ()
-- NonSurjCond-Offset≥2 {o = 0} () (x ∷ xs) p
-- NonSurjCond-Offset≥2 {o = 1} (s≤s ()) (x ∷ xs) p
-- NonSurjCond-Offset≥2 {o = suc (suc o)} o≥2 (x ∷ xs) ()
--
-- NonSurjCond-UnaryWithOnlyZeros : (xs : Num 1 1 0) → toℕ xs ≢ 1
-- NonSurjCond-UnaryWithOnlyZeros ∙ ()
-- NonSurjCond-UnaryWithOnlyZeros (z ∷ xs) p = contradiction (
-- begin
-- toℕ xs
-- ≡⟨ sym (*-right-identity (toℕ xs)) ⟩
-- toℕ xs * 1
-- ≡⟨ p ⟩
-- suc zero
-- ∎) (NonSurjCond-UnaryWithOnlyZeros xs)
-- NonSurjCond-UnaryWithOnlyZeros (s () ∷ xs)
--
-- NonSurjCond-NotEnoughDigits : ∀ {b d o} → d ≥ 1 → b ≰ d → (xs : Num b d o) → toℕ xs ≢ o + d
-- NonSurjCond-NotEnoughDigits {_} {_} {o} d≥1 b≰d ∙ = <⇒≢ (≤-steps o d≥1)
-- NonSurjCond-NotEnoughDigits {b} {d} {o} d≥1 b≰d (x ∷ xs) p with toℕ xs ≤? 0
-- NonSurjCond-NotEnoughDigits {b} {d} {o} d≥1 b≰d (x ∷ xs) p | yes q =
-- contradiction p (<⇒≢ ⟦x∷xs⟧>o+d)
-- where
-- ⟦xs⟧≡0 : toℕ xs ≡ 0
-- ⟦xs⟧≡0 = ≤0⇒≡0 (toℕ xs) q
-- ⟦x∷xs⟧>o+d : o + Fin.toℕ x + toℕ xs * b < o + d
-- ⟦x∷xs⟧>o+d = start
-- suc (o + Fin.toℕ x + toℕ xs * b)
-- ≈⟨ begin
-- suc (o + Fin.toℕ x + toℕ xs * b)
-- ≡⟨ cong (λ w → suc (o + Fin.toℕ x + w * b)) ⟦xs⟧≡0 ⟩
-- suc (o + Fin.toℕ x + zero)
-- ≡⟨ +-right-identity (suc (o + Fin.toℕ x)) ⟩
-- suc (o + Fin.toℕ x)
-- ≡⟨ sym (+-suc o (Fin.toℕ x)) ⟩
-- o + suc (Fin.toℕ x)
-- ∎ ⟩
-- o + suc (Fin.toℕ x)
-- ≤⟨ n+-mono o (bounded x) ⟩
-- o + d
-- □
--
-- NonSurjCond-NotEnoughDigits {b} {d} {o} d≥1 b≰d (x ∷ xs) p | no ¬q =
-- contradiction p (>⇒≢ ⟦x∷xs⟧>o+d)
-- where
-- ⟦x∷xs⟧>o+d : o + Fin.toℕ x + toℕ xs * b > o + d
-- ⟦x∷xs⟧>o+d = start
-- suc (o + d)
-- ≈⟨ sym (+-suc o d) ⟩
-- o + suc d
-- ≤⟨ n+-mono o (
-- start
-- suc d
-- ≤⟨ ≰⇒> b≰d ⟩
-- b
-- ≈⟨ sym (*-left-identity b) ⟩
-- 1 * b
-- ≤⟨ _*-mono_ {1} {toℕ xs} {b} {b} (≰⇒> ¬q) ≤-refl ⟩
-- toℕ xs * b
-- ≤⟨ n≤m+n (Fin.toℕ x) (toℕ xs * b) ⟩
-- Fin.toℕ x + toℕ xs * b
-- □
-- ) ⟩
-- o + (Fin.toℕ x + toℕ xs * b)
-- ≈⟨ sym (+-assoc o (Fin.toℕ x) (toℕ xs * b)) ⟩
-- o + Fin.toℕ x + toℕ xs * b
-- □
--
-- NonSurjCond⇏Surjective : ∀ {b} {d} {o} → NonSurjCond b d o → ¬ (Surjective (Num⟶ℕ b d o))
-- NonSurjCond⇏Surjective {_} {d} {o} Base≡0 claim =
-- NonSurjCond-Base≡0
-- (from claim ⟨$⟩ suc o + d)
-- (right-inverse-of claim (suc (o + d)))
-- NonSurjCond⇏Surjective NoDigits claim =
-- NonSurjCond-NoDigits
-- (from claim ⟨$⟩ 1)
-- (right-inverse-of claim 1)
-- NonSurjCond⇏Surjective (Offset≥2 p) claim =
-- NonSurjCond-Offset≥2 p
-- (from claim ⟨$⟩ 1)
-- (right-inverse-of claim 1)
-- NonSurjCond⇏Surjective UnaryWithOnlyZeros claim =
-- NonSurjCond-UnaryWithOnlyZeros
-- (from claim ⟨$⟩ 1)
-- (right-inverse-of claim 1)
-- NonSurjCond⇏Surjective {_} {d} {o} (NotEnoughDigits p q) claim =
-- NonSurjCond-NotEnoughDigits p q
-- (from claim ⟨$⟩ o + d)
-- (right-inverse-of claim (o + d))
--
-- SurjCond⇒Surjective : ∀ {b} {d} {o} → SurjCond b d o → Surjective (Num⟶ℕ b d o)
-- SurjCond⇒Surjective {b} {d} {o} cond = record
-- { from = ℕ⟶Num b d o
-- ; right-inverse-of = toℕ-fromℕ {b} {d} {o} {SurjCond⇒IsSurj cond}
-- }
--
-- Surjective? : ∀ b d o → Dec (Surjective (Num⟶ℕ b d o))
-- Surjective? b d o with surjectionView b d o
-- Surjective? b d o | Surj cond = yes (record
-- { from = ℕ⟶Num b d o
-- ; right-inverse-of = toℕ-fromℕ {b} {d} {o} {SurjCond⇒IsSurj cond}
-- })
-- Surjective? b d o | NonSurj reason = no (NonSurjCond⇏Surjective reason)
--
-- ------------------------------------------------------------------------
-- --
-- ------------------------------------------------------------------------
--
-- -- Surjective⇒SurjCond {b} {d} {o} surj = {! !}
-- Surjective⇒SurjCond : ∀ {b} {d} {o}
-- → Surjective (Num⟶ℕ b d o)
-- → SurjCond b d o
-- Surjective⇒SurjCond {b} {d} {o} surj with surjectionView b d o
-- Surjective⇒SurjCond surj | Surj condition = condition
-- Surjective⇒SurjCond surj | NonSurj reason = contradiction surj (NonSurjCond⇏Surjective reason)
--
-- Surjective⇒IsSurj : ∀ {b} {d} {o} → Surjective (Num⟶ℕ b d o) → IsSurjective b d o
-- Surjective⇒IsSurj = SurjCond⇒IsSurj ∘ Surjective⇒SurjCond
--
-- Surjective⇒b≥1 : ∀ {b} {d} {o} → Surjective (Num⟶ℕ b d o) → b ≥ 1
-- Surjective⇒b≥1 = SurjCond⇒b≥1 ∘ Surjective⇒SurjCond
--
-- Surjective⇒d≥b : ∀ {b} {d} {o} → Surjective (Num⟶ℕ b d o) → b ≤ d
-- Surjective⇒d≥b = SurjCond⇒d≥b ∘ Surjective⇒SurjCond
| {
"alphanum_fraction": 0.4581064804,
"avg_line_length": 41.8447580645,
"ext": "agda",
"hexsha": "9af709a0e290294633aaaaf0495a181a59ba7008",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "Data/Num/Surjection.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "Data/Num/Surjection.agda",
"max_line_length": 150,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "Data/Num/Surjection.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 8865,
"size": 20755
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Localization where
open import Cubical.HITs.Localization.Base public
open import Cubical.HITs.Localization.Properties public
| {
"alphanum_fraction": 0.7929292929,
"avg_line_length": 28.2857142857,
"ext": "agda",
"hexsha": "763525ee34fe4122e77834c4cd8388f8a540f941",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/Localization.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/HITs/Localization.agda",
"max_line_length": 55,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/HITs/Localization.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 45,
"size": 198
} |
data ⊥ : Set where
postulate
∞ : ∀ {a} → Set a → Set a
♯_ : ∀ {a} {A : Set a} → (A → ⊥) → ∞ A
♭ : ∀ {a} {A : Set a} → ∞ A → A → ⊥
{-# BUILTIN INFINITY ∞ #-}
{-# BUILTIN SHARP ♯_ #-}
{-# BUILTIN FLAT ♭ #-}
-- Issue #5610: with these bad types for sharp and flat, we can prove
-- false. The reason is that ∞ is assumed to be strictly-positive in
-- the positivity checker (even guarding positive). So making ∞ A
-- isomorphic to A → ⊥ will be contradictory to this assumption.
data D : Set where
wrap : ∞ D → D
lam : (D → ⊥) → D
lam f = wrap (♯ f)
app : D → D → ⊥
app (wrap g) d = ♭ g d
delta : D
delta = lam (λ x → app x x)
omega : ⊥
omega = app delta delta
| {
"alphanum_fraction": 0.5518248175,
"avg_line_length": 21.40625,
"ext": "agda",
"hexsha": "481db3934a50decc157510aa0bedecfc4fa63e8e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Fail/BuiltinSharpBadType.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Fail/BuiltinSharpBadType.agda",
"max_line_length": 69,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Fail/BuiltinSharpBadType.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": 256,
"size": 685
} |
-- Andreas, 2021-08-19, issue #5283, reported by guilhermehas
-- 'tactic' should only appear in attributes and 'C.Tactic' is converted to
-- 'TacticAttribute' there.
-- Other occurrences of 'C.Tactic' should be a scope error.
-- At the time of writing, the scope checker passes it as A.Tactic to the type
-- checker, and that loops on it.
open import Agda.Builtin.Reflection
A : Set
A = tactic ?
-- Should be syntax error.
| {
"alphanum_fraction": 0.7259953162,
"avg_line_length": 28.4666666667,
"ext": "agda",
"hexsha": "4279d9993ad38ce914b601d6fd3d49ac4d4c0206",
"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/Issue5283.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/Issue5283.agda",
"max_line_length": 78,
"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/Issue5283.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": 119,
"size": 427
} |
{-# OPTIONS --allow-unsolved-metas #-}
open import Agda.Builtin.Equality
postulate @0 A : Set
@0 f : (X : Set) → A ≡ X → Set
f X refl = {!!}
| {
"alphanum_fraction": 0.5902777778,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "74ff270fb8a37a6ca37ea3adf88d46104e83dd8a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "Seanpm2001-Agda-lang/agda",
"max_forks_repo_path": "test/Succeed/Issue5765.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "Seanpm2001-Agda-lang/agda",
"max_issues_repo_path": "test/Succeed/Issue5765.agda",
"max_line_length": 38,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Succeed/Issue5765.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z",
"num_tokens": 50,
"size": 144
} |
{-# OPTIONS --no-positivity-check
--no-termination-check
#-}
-- A universe setoids
module Setoid where
import Chain
record True : Set where
data False : Set where
Rel : Set -> Set1
Rel A = A -> A -> Set
Pred : Set -> Set1
Pred A = A -> Set
Resp : {A : Set} -> Rel A -> {B : Set} -> Rel B -> Pred (A -> B)
Resp _R_ _S_ f = forall x y -> x R y -> f x S f y
mutual
infix 40 _=El=_ _=S=_ _=Fam=_
infix 60 _!_
data Setoid : Set where
nat : Setoid
Π : (A : Setoid)(F : Fam A) -> Setoid
Σ : (A : Setoid)(F : Fam A) -> Setoid
data Fam (A : Setoid) : Set where
fam : (F : El A -> Setoid) ->
Resp _=El=_ _=S=_ F -> Fam A
data El : Setoid -> Set where
zero : El nat
suc : El nat -> El nat
ƛ : {A : Setoid}{F : Fam A}
(f : (x : El A) -> El (F ! x)) ->
((x y : El A) -> x =El= y -> f x =El= f y) -> El (Π A F)
_,_ : {A : Setoid}{F : Fam A}(x : El A) -> El (F ! x) -> El (Σ A F)
data _=S=_ : (A B : Setoid) -> Set where
eqNat : nat =S= nat
eqΠ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂} ->
A₂ =S= A₁ -> F₁ =Fam= F₂ -> Π A₁ F₁ =S= Π A₂ F₂
eqΣ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂} ->
A₁ =S= A₂ -> F₁ =Fam= F₂ -> Σ A₁ F₁ =S= Σ A₂ F₂
data _=El=_ : {A B : Setoid} -> El A -> El B -> Set where
eqInNat : {n : El nat} -> n =El= n
eqInΠ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂}
{f₁ : (x : El A₁) -> El (F₁ ! x)}
{pf₁ : (x y : El A₁) -> x =El= y -> f₁ x =El= f₁ y}
{f₂ : (x : El A₂) -> El (F₂ ! x)} ->
{pf₂ : (x y : El A₂) -> x =El= y -> f₂ x =El= f₂ y} ->
A₂ =S= A₁ ->
((x : El A₁)(y : El A₂) -> x =El= y -> f₁ x =El= f₂ y) ->
ƛ f₁ pf₁ =El= ƛ f₂ pf₂
eqInΣ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂}
{x₁ : El A₁}{y₁ : El (F₁ ! x₁)}
{x₂ : El A₂}{y₂ : El (F₂ ! x₂)} ->
F₁ =Fam= F₂ -> x₁ =El= x₂ -> y₁ =El= y₂ -> (x₁ , y₁) =El= (x₂ , y₂)
data _=Fam=_ {A B : Setoid}(F : Fam A)(G : Fam B) : Set where
eqFam : B =S= A -> (forall x y -> x =El= y -> F ! x =S= G ! y) -> F =Fam= G
_!_ : {A : Setoid} -> Fam A -> El A -> Setoid
fam F _ ! x = F x
-- Inversions
famEqDom : {A B : Setoid}{F : Fam A}{G : Fam B} -> F =Fam= G -> B =S= A
famEqDom (eqFam p _) = p
famEqCodom : {A B : Setoid}{F : Fam A}{G : Fam B} -> F =Fam= G ->
(x : El A)(y : El B) -> x =El= y -> F ! x =S= G ! y
famEqCodom (eqFam _ p) = p
eqΠ-inv₁ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂} ->
Π A₁ F₁ =S= Π A₂ F₂ -> A₂ =S= A₁
eqΠ-inv₁ (eqΠ p _) = p
eqΠ-inv₂ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂} ->
Π A₁ F₁ =S= Π A₂ F₂ -> F₁ =Fam= F₂
eqΠ-inv₂ (eqΠ _ p) = p
eqΣ-inv₁ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂} ->
Σ A₁ F₁ =S= Σ A₂ F₂ -> A₁ =S= A₂
eqΣ-inv₁ (eqΣ p _) = p
eqΣ-inv₂ : {A₁ A₂ : Setoid}{F₁ : Fam A₁}{F₂ : Fam A₂} ->
Σ A₁ F₁ =S= Σ A₂ F₂ -> F₁ =Fam= F₂
eqΣ-inv₂ (eqΣ _ p) = p
-- Equivalence proofs and casts
mutual
-- _=Fam=_ is an equivalence
=Fam=-refl : {A : Setoid}{F : Fam A} -> F =Fam= F
=Fam=-refl {F = fam _ p} = eqFam =S=-refl p
=Fam=-sym : {A B : Setoid}{F : Fam A}{G : Fam B} -> F =Fam= G -> G =Fam= F
=Fam=-sym (eqFam B=A F=G) = eqFam (=S=-sym B=A) \x y x=y -> =S=-sym (F=G _ _ (=El=-sym x=y))
=Fam=-trans : {A B C : Setoid}{F : Fam A}{G : Fam B}{H : Fam C} ->
F =Fam= G -> G =Fam= H -> F =Fam= H
=Fam=-trans (eqFam B=A F=G) (eqFam C=B G=H) =
eqFam (=S=-trans C=B B=A) \x y x=y ->
=S=-trans (F=G x (B=A << x) (cast-id _))
(G=H _ y (=El=-trans (=El=-sym (cast-id _)) x=y))
-- _=S=_ is an equivalence
=S=-refl : {A : Setoid} -> A =S= A
=S=-refl {nat} = eqNat
=S=-refl {Π A F} = eqΠ =S=-refl =Fam=-refl
=S=-refl {Σ A F} = eqΣ =S=-refl =Fam=-refl
=S=-sym : {A B : Setoid} -> A =S= B -> B =S= A
=S=-sym eqNat = eqNat
=S=-sym (eqΠ pA pF) = eqΠ (=S=-sym pA) (=Fam=-sym pF)
=S=-sym (eqΣ pA pF) = eqΣ (=S=-sym pA) (=Fam=-sym pF)
=S=-trans : {A B C : Setoid} -> A =S= B -> B =S= C -> A =S= C
=S=-trans eqNat eqNat = eqNat
=S=-trans (eqΠ B=A F=G) (eqΠ C=B G=H) = eqΠ (=S=-trans C=B B=A) (=Fam=-trans F=G G=H)
=S=-trans (eqΣ A=B F=G) (eqΣ B=C G=H) = eqΣ (=S=-trans A=B B=C) (=Fam=-trans F=G G=H)
-- _=El=_ is an equivalence
=El=-refl : {A : Setoid}{x : El A} -> x =El= x
=El=-refl {nat} = eqInNat
=El=-refl {Π A F}{ƛ f pf} = eqInΠ =S=-refl pf
=El=-refl {Σ A F}{x , y} = eqInΣ =Fam=-refl =El=-refl =El=-refl
=El=-sym : {A B : Setoid}{x : El A}{y : El B} -> x =El= y -> y =El= x
=El=-sym eqInNat = eqInNat
=El=-sym (eqInΠ B=A p) = eqInΠ (=S=-sym B=A) \x y x=y -> =El=-sym (p y x (=El=-sym x=y))
=El=-sym (eqInΣ pF px py) = eqInΣ (=Fam=-sym pF) (=El=-sym px) (=El=-sym py)
=El=-trans : {A B C : Setoid}{x : El A}{y : El B}{z : El C} ->
x =El= y -> y =El= z -> x =El= z
=El=-trans eqInNat eqInNat = eqInNat
=El=-trans (eqInΠ B=A f=g) (eqInΠ C=B g=h) =
eqInΠ (=S=-trans C=B B=A) \x y x=y ->
=El=-trans (f=g x (B=A << x) (cast-id _))
(g=h _ y (=El=-trans (=El=-sym (cast-id _)) x=y))
=El=-trans (eqInΣ F₁=F₂ x₁=x₂ y₁=y₂) (eqInΣ F₂=F₃ x₂=x₃ y₂=y₃) =
eqInΣ (=Fam=-trans F₁=F₂ F₂=F₃) (=El=-trans x₁=x₂ x₂=x₃) (=El=-trans y₁=y₂ y₂=y₃)
-- Casting. Important: don't look at the proof!
infix 50 _<<_ _>>_
_<<_ : {A B : Setoid} -> A =S= B -> El B -> El A
_<<_ {nat}{Π _ _} () _
_<<_ {nat}{Σ _ _} () _
_<<_ {Π _ _}{nat} () _
_<<_ {Π _ _}{Σ _ _} () _
_<<_ {Σ _ _}{nat} () _
_<<_ {Σ _ _}{Π _ _} () _
_<<_ {nat}{nat} p x = x
_<<_ {Π A₁ F₁}{Π A₂ F₂} p (ƛ f pf) = ƛ g pg
where
g : (x : El A₁) -> El (F₁ ! x)
g x = let A₂=A₁ = eqΠ-inv₁ p
F₁=F₂ = famEqCodom (eqΠ-inv₂ p) x _ (cast-id _)
in F₁=F₂ << f (A₂=A₁ << x)
pg : (x y : El A₁) -> x =El= y -> g x =El= g y
pg x y x=y = cast-irr _ _ (pf _ _ (cast-irr _ _ x=y))
_<<_ {Σ A₁ F₁}{Σ A₂ F₂} p (x , y) = eqΣ-inv₁ p << x , F₁=F₂ << y
where
F₁=F₂ : F₁ ! (eqΣ-inv₁ p << x) =S= F₂ ! x
F₁=F₂ = famEqCodom (eqΣ-inv₂ p) _ _ (=El=-sym (cast-id _))
_>>_ : {A B : Setoid} -> Fam A -> A =S= B -> Fam B
fam F pF >> A=B = fam G pG
where
G : El _ -> Setoid
G y = F (A=B << y)
pG : forall x y -> x =El= y -> G x =S= G y
pG x y x=y = pF _ _ (cast-irr _ _ x=y)
cast-id : {A B : Setoid}{x : El A}(p : B =S= A) -> x =El= p << x
cast-id eqNat = eqInNat
cast-id {x = x , y } (eqΣ A=B F=G) = eqInΣ (=Fam=-sym F=G) (cast-id _) (cast-id _)
cast-id {x = ƛ f pf} (eqΠ B=A F=G) =
eqInΠ (=S=-sym B=A) \x y x=y ->
proof f x
≡ f (_ << y) by pf _ _ (=El=-trans x=y (cast-id _))
≡ _ << f (_ << y) by cast-id _
qed
where
open Chain El _=El=_ (\x -> =El=-refl) (\x y z -> =El=-trans)
cast-irr : {A₁ A₂ B₁ B₂ : Setoid}{x : El A₁}{y : El A₂}
(p₁ : B₁ =S= A₁)(p₂ : B₂ =S= A₂) -> x =El= y -> p₁ << x =El= p₂ << y
cast-irr {x = x}{y = y} p q x=y =
proof p << x
≡ x by =El=-sym (cast-id _)
≡ y by x=y
≡ q << y by cast-id _
qed
where
open Chain El _=El=_ (\x -> =El=-refl) (\x y z -> =El=-trans)
-- Let's do some overloading
data EqFam : Set -> Set where
el : EqFam Setoid
setoid : EqFam True
fam : EqFam Setoid
[_] : {I : Set} -> EqFam I -> I -> Set
[ el ] A = El A
[ setoid ] _ = Setoid
[ fam ] A = Fam A
_==_ : {I : Set}{eqf : EqFam I}{i j : I} -> [ eqf ] i -> [ eqf ] j -> Set
_==_ {eqf = el } x y = x =El= y
_==_ {eqf = setoid} A B = A =S= B
_==_ {eqf = fam } F G = F =Fam= G
refl : {I : Set}{eqf : EqFam I}{i : I}{x : [ eqf ] i} -> x == x
refl {eqf = el} = =El=-refl
refl {eqf = setoid} = =S=-refl
refl {eqf = fam} = =Fam=-refl
sym : {I : Set}{eqf : EqFam I}{i j : I}{x : [ eqf ] i}{y : [ eqf ] j} -> x == y -> y == x
sym {eqf = el} = =El=-sym
sym {eqf = setoid} = =S=-sym
sym {eqf = fam} = =Fam=-sym
trans : {I : Set}{eqf : EqFam I}{i j k : I}{x : [ eqf ] i}{y : [ eqf ] j}{z : [ eqf ] k} ->
x == y -> y == z -> x == z
trans {eqf = el} = =El=-trans
trans {eqf = setoid} = =S=-trans
trans {eqf = fam} = =Fam=-trans
open module EqChain {I : Set}{eqf : EqFam I} =
Chain ([ eqf ]) _==_ (\x -> refl) (\x y z -> trans)
homo : {A B : Setoid}{x : El A}{y : El B} -> x == y -> A == B
homo eqInNat = eqNat
homo (eqInΠ B=A p) = eqΠ B=A (eqFam B=A \x y x=y -> homo (p x y x=y))
homo (eqInΣ F=G p q) = eqΣ (homo p) F=G
cast-id' : {A B C : Setoid}{x : El A}{y : El B}(p : C == B) -> x == y -> x == p << y
cast-id' C=B x=y = trans x=y (cast-id _)
-- Some helper stuff
K : {A : Setoid} -> Setoid -> Fam A
K B = fam (\_ -> B) (\_ _ _ -> refl)
infixr 20 _==>_
infixl 70 _·_ _∘_ _○_
infixl 90 _#_
!-cong : {A B : Setoid}(F : Fam A)(G : Fam B){x : El A}{y : El B} ->
F == G -> x == y -> F ! x == G ! y
!-cong F G (eqFam B=A F=G) x=y = F=G _ _ x=y
!-cong-R : {A : Setoid}(F : Fam A){x y : El A} ->
x == y -> F ! x == F ! y
!-cong-R F x=y = !-cong F F refl x=y
_==>_ : Setoid -> Setoid -> Setoid
A ==> B = Π A (K B)
_#_ : {A : Setoid}{F : Fam A} -> El (Π A F) -> (x : El A) -> El (F ! x)
ƛ f _ # x = f x
#-cong : {A B : Setoid}{F : Fam A}{G : Fam B}
(f : El (Π A F))(g : El (Π B G)){x : El A}{y : El B} ->
f == g -> x == y -> f # x == g # y
#-cong ._ ._ (eqInΠ _ f=g) x=y = f=g _ _ x=y
#-cong-R : {A : Setoid}{F : Fam A}(f : El (Π A F)){x y : El A} ->
x == y -> f # x == f # y
#-cong-R f p = #-cong f f refl p
id : {A : Setoid} -> El (A ==> A)
id = ƛ (\x -> x) (\_ _ p -> p)
-- Family composition
_○_ : {A B : Setoid} -> Fam A -> El (B ==> A) -> Fam B
F ○ f = fam (\x -> F ! (f # x)) (\x y x=y -> !-cong-R F (#-cong-R f x=y))
lem-○-id : {A : Setoid}{F : Fam A} -> F ○ id == F
lem-○-id {F = F} = eqFam refl \x y x=y -> !-cong-R F x=y
_∘_ : {A B : Setoid}{F : Fam B} -> El (Π B F) -> (g : El (A ==> B)) -> El (Π A (F ○ g))
f ∘ g = ƛ (\x -> f # (g # x)) \x y x=y -> #-cong-R f (#-cong-R g x=y)
lem-∘-id : {A : Setoid}{F : Fam A}(f : El (Π A F)) -> f ∘ id == f
lem-∘-id (ƛ f pf) = eqInΠ refl pf
lem-id-∘ : {A B : Setoid}(f : El (A ==> B)) -> id ∘ f == f
lem-id-∘ (ƛ f pf) = eqInΠ refl pf
-- Simply type composition (not quite a special case of ∘ because of proof relevance)
_·_ : {A B C : Setoid} -> El (B ==> C) -> El (A ==> B) -> El (A ==> C)
f · g = eqΠ refl (eqFam refl \_ _ _ -> refl) << f ∘ g
fst : {A : Setoid}{F : Fam A} -> El (Σ A F) -> El A
fst (x , y) = x
snd : {A : Setoid}{F : Fam A}(p : El (Σ A F)) -> El (F ! fst p)
snd (x , y) = y
fst-eq : {A B : Setoid}{F : Fam A}{G : Fam B}
{x : El (Σ A F)}{y : El (Σ B G)} -> x == y -> fst x == fst y
fst-eq (eqInΣ _ x₁=x₂ _) = x₁=x₂
snd-eq : {A B : Setoid}{F : Fam A}{G : Fam B}
{x : El (Σ A F)}{y : El (Σ B G)} -> x == y -> snd x == snd y
snd-eq (eqInΣ _ _ y₁=y₂) = y₁=y₂
η : {A : Setoid}{F : Fam A}(f : El (Π A F)){pf : (x y : El A) -> x == y -> f # x == f # y} ->
f == ƛ {F = F} (_#_ f) pf
η (ƛ f pf) = eqInΠ refl pf
| {
"alphanum_fraction": 0.4482851986,
"avg_line_length": 34.3034055728,
"ext": "agda",
"hexsha": "cc1caf4d96789ab2eab6caae1b2681b0976b1d78",
"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": "benchmark/cwf/Setoid.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": "benchmark/cwf/Setoid.agda",
"max_line_length": 94,
"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": "benchmark/cwf/Setoid.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5222,
"size": 11080
} |
module Tactic.Reflection.DeBruijn where
open import Prelude hiding (abs)
open import Builtin.Reflection
open import Container.Traversable
record DeBruijn {a} (A : Set a) : Set a where
field
strengthenFrom : (from n : Nat) → A → Maybe A
weakenFrom : (from n : Nat) → A → A
strengthen : Nat → A → Maybe A
strengthen 0 = just
strengthen n = strengthenFrom 0 n
weaken : Nat → A → A
weaken zero = id
weaken n = weakenFrom 0 n
open DeBruijn {{...}} public
patternBindings : List (Arg Pattern) → Nat
patternBindings = binds
where
binds : List (Arg Pattern) → Nat
bind : Pattern → Nat
binds [] = 0
binds (arg _ a ∷ as) = bind a + binds as
bind (con c ps) = binds ps
bind dot = 1
bind (var _) = 1
bind (lit l) = 0
bind (proj x) = 0
bind absurd = 0
private
Str : Set → Set
Str A = Nat → Nat → A → Maybe A
strVar : Str Nat
strVar lo n x = if x <? lo then just x
else if x <? lo + n then nothing
else just (x - n)
strArgs : Str (List (Arg Term))
strArg : Str (Arg Term)
strSort : Str Sort
strClauses : Str (List Clause)
strClause : Str Clause
strAbsTerm : Str (Abs Term)
strAbsType : Str (Abs Type)
strTerm : Str Term
strTerm lo n (var x args) = var <$> strVar lo n x <*> strArgs lo n args
strTerm lo n (con c args) = con c <$> strArgs lo n args
strTerm lo n (def f args) = def f <$> strArgs lo n args
strTerm lo n (meta x args) = meta x <$> strArgs lo n args
strTerm lo n (lam v t) = lam v <$> strAbsTerm lo n t
strTerm lo n (pi a b) = pi <$> strArg lo n a <*> strAbsType lo n b
strTerm lo n (agda-sort s) = agda-sort <$> strSort lo n s
strTerm lo n (lit l) = just (lit l)
strTerm lo n (pat-lam _ _) = just unknown -- todo
strTerm lo n unknown = just unknown
strAbsTerm lo n (abs s t) = abs s <$> strTerm (suc lo) n t
strAbsType lo n (abs s t) = abs s <$> strTerm (suc lo) n t
strArgs lo n [] = just []
strArgs lo n (x ∷ args) = _∷_ <$> strArg lo n x <*> strArgs lo n args
strArg lo n (arg i v) = arg i <$> strTerm lo n v
strSort lo n (set t) = set <$> strTerm lo n t
strSort lo n (lit l) = just (lit l)
strSort lo n unknown = just unknown
strClauses lo k [] = just []
strClauses lo k (c ∷ cs) = _∷_ <$> strClause lo k c <*> strClauses lo k cs
strClause lo k (clause ps b) = clause ps <$> strTerm (lo + patternBindings ps) k b
strClause lo k (absurd-clause ps) = just (absurd-clause ps)
private
Wk : Set → Set
Wk A = Nat → Nat → A → A
wkVar : Wk Nat
wkVar lo k x = if x <? lo then x else x + k
wkArgs : Wk (List (Arg Term))
wkArg : Wk (Arg Term)
wkSort : Wk Sort
wkClauses : Wk (List Clause)
wkClause : Wk Clause
wkAbsTerm : Wk (Abs Term)
wk : Wk Term
wk lo k (var x args) = var (wkVar lo k x) (wkArgs lo k args)
wk lo k (con c args) = con c (wkArgs lo k args)
wk lo k (def f args) = def f (wkArgs lo k args)
wk lo k (meta x args) = meta x (wkArgs lo k args)
wk lo k (lam v t) = lam v (wkAbsTerm lo k t)
wk lo k (pi a b) = pi (wkArg lo k a) (wkAbsTerm lo k b)
wk lo k (agda-sort s) = agda-sort (wkSort lo k s)
wk lo k (lit l) = lit l
wk lo k (pat-lam cs args) = pat-lam (wkClauses lo k cs) (wkArgs lo k args)
wk lo k unknown = unknown
wkAbsTerm lo k (abs s t) = abs s (wk (suc lo) k t)
wkArgs lo k [] = []
wkArgs lo k (x ∷ args) = wkArg lo k x ∷ wkArgs lo k args
wkArg lo k (arg i v) = arg i (wk lo k v)
wkSort lo k (set t) = set (wk lo k t)
wkSort lo k (lit n) = lit n
wkSort lo k unknown = unknown
wkClauses lo k [] = []
wkClauses lo k (c ∷ cs) = wkClause lo k c ∷ wkClauses lo k cs
wkClause lo k (clause ps b) = clause ps (wk (lo + patternBindings ps) k b)
wkClause lo k (absurd-clause ps) = absurd-clause ps
-- Instances --
DeBruijnTraversable : ∀ {a} {F : Set a → Set a} {{_ : Traversable F}}
{A : Set a} {{_ : DeBruijn A}} → DeBruijn (F A)
strengthenFrom {{DeBruijnTraversable}} lo k = traverse (strengthenFrom lo k)
weakenFrom {{DeBruijnTraversable}} lo k = fmap (weakenFrom lo k)
instance
DeBruijnNat : DeBruijn Nat
strengthenFrom {{DeBruijnNat}} = strVar
weakenFrom {{DeBruijnNat}} = wkVar
DeBruijnTerm : DeBruijn Term
strengthenFrom {{DeBruijnTerm}} = strTerm
weakenFrom {{DeBruijnTerm}} = wk
DeBruijnList : ∀ {a} {A : Set a} {{_ : DeBruijn A}} → DeBruijn (List A)
DeBruijnList = DeBruijnTraversable
DeBruijnVec : ∀ {a} {A : Set a} {{_ : DeBruijn A}} {n : Nat} → DeBruijn (Vec A n)
DeBruijnVec = DeBruijnTraversable
DeBruijnArg : {A : Set} {{_ : DeBruijn A}} → DeBruijn (Arg A)
DeBruijnArg = DeBruijnTraversable
DeBruijnMaybe : {A : Set} {{_ : DeBruijn A}} → DeBruijn (Maybe A)
DeBruijnMaybe = DeBruijnTraversable
-- Strip bound names (to ensure _==_ checks α-equality)
-- Doesn't touch pattern variables in pattern lambdas.
mutual
stripBoundNames : Term → Term
stripBoundNames (var x args) = var x (stripArgs args)
stripBoundNames (con c args) = con c (stripArgs args)
stripBoundNames (def f args) = def f (stripArgs args)
stripBoundNames (lam v t) = lam v (stripAbs t)
stripBoundNames (pat-lam cs args) = pat-lam (stripClauses cs) (stripArgs args)
stripBoundNames (pi a b) = pi (stripArg a) (stripAbs b)
stripBoundNames (agda-sort s) = agda-sort (stripSort s)
stripBoundNames (lit l) = lit l
stripBoundNames (meta x args) = meta x (stripArgs args)
stripBoundNames unknown = unknown
private
stripArgs : List (Arg Term) → List (Arg Term)
stripArgs [] = []
stripArgs (x ∷ xs) = stripArg x ∷ stripArgs xs
stripArg : Arg Term → Arg Term
stripArg (arg i t) = arg i (stripBoundNames t)
stripAbs : Abs Term → Abs Term
stripAbs (abs _ t) = abs "" (stripBoundNames t)
stripClauses : List Clause → List Clause
stripClauses [] = []
stripClauses (x ∷ xs) = stripClause x ∷ stripClauses xs
stripClause : Clause → Clause
stripClause (clause ps t) = clause ps (stripBoundNames t)
stripClause (absurd-clause ps) = absurd-clause ps
stripSort : Sort → Sort
stripSort (set t) = set (stripBoundNames t)
stripSort (lit n) = lit n
stripSort unknown = unknown
| {
"alphanum_fraction": 0.6026356589,
"avg_line_length": 33.59375,
"ext": "agda",
"hexsha": "1f04ad447dc6403fa8370b2de18fd6ef1db97fd2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "lclem/agda-prelude",
"max_forks_repo_path": "src/Tactic/Reflection/DeBruijn.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "lclem/agda-prelude",
"max_issues_repo_path": "src/Tactic/Reflection/DeBruijn.agda",
"max_line_length": 89,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "lclem/agda-prelude",
"max_stars_repo_path": "src/Tactic/Reflection/DeBruijn.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2216,
"size": 6450
} |
{-
A Cubical proof of Blakers-Massey Theorem (KANG Rongji, Oct. 2021)
Based on the previous type-theoretic proof described in
Kuen-Bang Hou (Favonia), Eric Finster, Dan Licata, Peter LeFanu Lumsdaine,
"A Mechanization of the Blakers–Massey Connectivity Theorem in Homotopy Type Theory"
(https://arxiv.org/abs/1605.03227)
Also the HoTT-Agda formalization by Favonia:
(https://github.com/HoTT/HoTT-Agda/blob/master/theorems/homotopy/BlakersMassey.agda)
Using cubes explicitly as much as possible.
-}
{-# OPTIONS --safe #-}
module Cubical.Homotopy.BlakersMassey where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Properties
open import Cubical.Foundations.Isomorphism
open Iso
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.HITs.Truncation renaming (hLevelTrunc to Trunc)
open import Cubical.HITs.Pushout hiding (PushoutGenFib)
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.WedgeConnectivity
module BlakersMassey {ℓ₁ ℓ₂ ℓ₃ : Level}
(X : Type ℓ₁)(Y : Type ℓ₂)(Q : X → Y → Type ℓ₃)
{m : HLevel} (leftConn : (x : X) → isConnected (1 + m) (Σ[ y ∈ Y ] Q x y))
{n : HLevel} (rightConn : (y : Y) → isConnected (1 + n) (Σ[ x ∈ X ] Q x y))
where
ℓ : Level
ℓ = ℓ-max (ℓ-max ℓ₁ ℓ₂) ℓ₃
leftFiber : X → Type (ℓ-max ℓ₂ ℓ₃)
leftFiber x = Σ[ y ∈ Y ] Q x y
rightFiber : Y → Type (ℓ-max ℓ₁ ℓ₃)
rightFiber y = Σ[ x ∈ X ] Q x y
{- We use the alternative formulation of pushout with fewer parameters -}
PushoutQ = PushoutGen Q
{- Some preliminary definitions for convenience -}
fiberSquare :
{x₀ x₁ : X}{y₀ : Y}{p : PushoutQ}(q₀₀ : Q x₀ y₀)(q₁₀ : Q x₁ y₀)
→ inl x₁ ≡ p → inl x₀ ≡ p → Type ℓ
fiberSquare q₀₀ q₁₀ r' r = PathP (λ i → push q₀₀ (~ i) ≡ r' i) (sym (push q₁₀)) r
fiberSquarePush :
{x₀ x₁ : X}{y₀ y₁ : Y}(q₀₀ : Q x₀ y₀)(q₁₀ : Q x₁ y₀)(q₁₁ : Q x₁ y₁)
→ inl x₀ ≡ inr y₁ → Type ℓ
fiberSquarePush q₀₀ q₁₀ q₁₁ = fiberSquare q₀₀ q₁₀ (push q₁₁)
fiber' : {x₀ : X}{y₀ : Y}(q₀₀ : Q x₀ y₀){x₁ : X}{p : PushoutQ} → inl x₁ ≡ p → inl x₀ ≡ p → Type ℓ
fiber' {y₀ = y₀} q₀₀ {x₁ = x₁} r' r = Σ[ q₁₀ ∈ Q x₁ y₀ ] fiberSquare q₀₀ q₁₀ r' r
fiber'Push : {x₀ x₁ : X}{y₀ y₁ : Y}(q₀₀ : Q x₀ y₀)(q₁₁ : Q x₁ y₁) → inl x₀ ≡ inr y₁ → Type ℓ
fiber'Push q₀₀ q₁₁ = fiber' q₀₀ (push q₁₁)
leftCodeExtended :
{x₀ : X}{y₀ : Y}(q₀₀ : Q x₀ y₀)
→ (x₁ : X){p : PushoutQ} → inl x₁ ≡ p → inl x₀ ≡ p → Type ℓ
leftCodeExtended {y₀ = y₀} q₀₀ x₁ r' r = Trunc (m + n) (fiber' q₀₀ r' r)
rightCode : {x₀ : X}(y : Y) → Path PushoutQ (inl x₀) (inr y) → Type ℓ
rightCode y r = Trunc (m + n) (fiber push r)
{- Bunch of coherence data that will be used to construct Code -}
{- Definitions of fiber→ -}
module _
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) where
{- (x₀ , q₀₀) = (x₁ , q₁₀) -}
module _
{y₁ : Y}(q₁₁ : Q x₁ y₁)
(r : inl x₁ ≡ inr y₁)
(p : fiberSquarePush q₁₀ q₁₀ q₁₁ r) where
fiber→[q₀₀=q₁₀]-filler : (i j k : I) → PushoutQ
fiber→[q₀₀=q₁₀]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₁₁ (j ∧ k)
; (i = i1) → p k j
; (j = i0) → push q₁₀ (i ∧ ~ k)
; (j = i1) → push q₁₁ k })
(inS (push q₁₀ (i ∧ ~ j))) k'
fiber→[q₀₀=q₁₀] : fiber push r
fiber→[q₀₀=q₁₀] .fst = q₁₁
fiber→[q₀₀=q₁₀] .snd i j = fiber→[q₀₀=q₁₀]-filler i j i1
∣fiber→[q₀₀=q₁₀]∣ : rightCode _ r
∣fiber→[q₀₀=q₁₀]∣ = ∣ fiber→[q₀₀=q₁₀] ∣ₕ
{- (y₁ , q₁₁) = (y₀ , q₁₀) -}
module _
{x₀ : X}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₀)
(p : fiberSquarePush q₀₀ q₁₀ q₁₀ r) where
fiber→[q₁₁=q₁₀]-filler : (i j k : I) → PushoutQ
fiber→[q₁₁=q₁₀]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₀₀ (j ∨ ~ k)
; (i = i1) → p k j
; (j = i0) → push q₀₀ (~ k)
; (j = i1) → push q₁₀ (~ i ∨ k) })
(inS (push q₁₀ (~ i ∨ ~ j))) k'
fiber→[q₁₁=q₁₀] : fiber push r
fiber→[q₁₁=q₁₀] .fst = q₀₀
fiber→[q₁₁=q₁₀] .snd i j = fiber→[q₁₁=q₁₀]-filler i j i1
∣fiber→[q₁₁=q₁₀]∣ : rightCode _ r
∣fiber→[q₁₁=q₁₀]∣ = ∣ fiber→[q₁₁=q₁₀] ∣ₕ
{- q₀₀ = q₁₁ = q₁₀ -}
fiber→[q₀₀=q₁₀=q₁₁]-filler :
(r : inl x₁ ≡ inr y₀)
→ (p : fiberSquarePush q₁₀ q₁₀ q₁₀ r)
→ (i j k l : I) → PushoutQ
fiber→[q₀₀=q₁₀=q₁₁]-filler r p i j k l' =
hfill (λ l → λ { (i = i0) → fiber→[q₀₀=q₁₀]-filler q₁₀ r p j k l
; (i = i1) → fiber→[q₁₁=q₁₀]-filler q₁₀ r p j k l
; (j = i0) → push q₁₀ ((i ∨ (k ∧ l)) ∧ (k ∨ (i ∧ ~ l)))
; (j = i1) → p l k
; (k = i0) → push q₁₀ ((i ∨ j) ∧ ~ l)
; (k = i1) → push q₁₀ ((i ∧ ~ j) ∨ l) })
(inS (push q₁₀ ((i ∨ (~ k ∧ j)) ∧ (~ k ∨ (i ∧ ~ j))))) l'
fiber→[q₀₀=q₁₀=q₁₁] : fiber→[q₀₀=q₁₀] q₁₀ ≡ fiber→[q₁₁=q₁₀] q₁₀
fiber→[q₀₀=q₁₀=q₁₁] i r p .fst = q₁₀
fiber→[q₀₀=q₁₀=q₁₁] i r p .snd j k = fiber→[q₀₀=q₁₀=q₁₁]-filler r p i j k i1
∣fiber→[q₀₀=q₁₀=q₁₁]∣ : ∣fiber→[q₀₀=q₁₀]∣ q₁₀ ≡ ∣fiber→[q₁₁=q₁₀]∣ q₁₀
∣fiber→[q₀₀=q₁₀=q₁₁]∣ i r p = ∣ fiber→[q₀₀=q₁₀=q₁₁] i r p ∣ₕ
{- Definitions of fiber← -}
module _
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) where
{- (x₁ , q₁₁) = (x₀ , q₀₁) -}
module _
{y₀ : Y}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←[q₁₁=q₀₁]-filler : (i j k : I) → PushoutQ
fiber←[q₁₁=q₀₁]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₀₀ (~ j ∧ k)
; (i = i1) → p k j
; (j = i0) → push q₀₀ (~ i ∧ k)
; (j = i1) → push q₀₁ i })
(inS (push q₀₁ (i ∧ j))) k'
fiber←[q₁₁=q₀₁] : fiber'Push q₀₀ q₀₁ r
fiber←[q₁₁=q₀₁] .fst = q₀₀
fiber←[q₁₁=q₀₁] .snd i j = fiber←[q₁₁=q₀₁]-filler i j i1
∣fiber←[q₁₁=q₀₁]∣ : leftCodeExtended q₀₀ _ (push q₀₁) r
∣fiber←[q₁₁=q₀₁]∣ = ∣ fiber←[q₁₁=q₀₁] ∣ₕ
{- (y₀ , q₀₀) = (y₁ , q₀₁) -}
module _
{x₁ : X}(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←[q₀₀=q₀₁]-filler : (i j k : I) → PushoutQ
fiber←[q₀₀=q₀₁]-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₁₁ (~ j ∨ ~ k)
; (i = i1) → p k j
; (j = i0) → push q₀₁ (~ i)
; (j = i1) → push q₁₁ (i ∨ ~ k) })
(inS (push q₀₁ (~ i ∨ j))) k'
fiber←[q₀₀=q₀₁] : fiber'Push q₀₁ q₁₁ r
fiber←[q₀₀=q₀₁] .fst = q₁₁
fiber←[q₀₀=q₀₁] .snd i j = fiber←[q₀₀=q₀₁]-filler i j i1
∣fiber←[q₀₀=q₀₁]∣ : leftCodeExtended q₀₁ _ (push q₁₁) r
∣fiber←[q₀₀=q₀₁]∣ = ∣ fiber←[q₀₀=q₀₁] ∣ₕ
{- q₀₀ = q₀₁ = q₁₁ -}
fiber←[q₀₀=q₀₁=q₁₁]-filler :
(r : inl x₀ ≡ inr y₁)
→ (p : push q₀₁ ≡ r)
→ (i j k l : I) → PushoutQ
fiber←[q₀₀=q₀₁=q₁₁]-filler r p i j k l' =
hfill (λ l → λ { (i = i0) → fiber←[q₁₁=q₀₁]-filler q₀₁ r p j k l
; (i = i1) → fiber←[q₀₀=q₀₁]-filler q₀₁ r p j k l
; (j = i0) → push q₀₁ ((i ∨ (~ k ∧ l)) ∧ (~ k ∨ (i ∧ ~ l)))
; (j = i1) → p l k
; (k = i0) → push q₀₁ ((i ∨ l) ∧ ~ j)
; (k = i1) → push q₀₁ ((i ∧ ~ l) ∨ j) })
(inS (push q₀₁ ((i ∨ (k ∧ j)) ∧ (k ∨ (i ∧ ~ j))))) l'
fiber←[q₀₀=q₀₁=q₁₁] : fiber←[q₁₁=q₀₁] q₀₁ ≡ fiber←[q₀₀=q₀₁] q₀₁
fiber←[q₀₀=q₀₁=q₁₁] i r p .fst = q₀₁
fiber←[q₀₀=q₀₁=q₁₁] i r p .snd j k = fiber←[q₀₀=q₀₁=q₁₁]-filler r p i j k i1
∣fiber←[q₀₀=q₀₁=q₁₁]∣ : ∣fiber←[q₁₁=q₀₁]∣ q₀₁ ≡ ∣fiber←[q₀₀=q₀₁]∣ q₀₁
∣fiber←[q₀₀=q₀₁=q₁₁]∣ i r p = ∣ fiber←[q₀₀=q₀₁=q₁₁] i r p ∣ₕ
{- Definitions of fiber→← -}
module _
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) where
{- (x₀ , q₀₀) = (x₁ , q₁₀) -}
module _
{y₁ : Y}(q₁₁ : Q x₁ y₁)
(r : inl x₁ ≡ inr y₁)
(p : fiberSquarePush q₁₀ q₁₀ q₁₁ r) where
fiber→←[q₀₀=q₁₀]-filler : (i j k l : I) → PushoutQ
fiber→←[q₀₀=q₁₀]-filler i j k l' =
let p' = fiber→[q₀₀=q₁₀] q₁₀ q₁₁ r p .snd in
hfill (λ l → λ { (i = i0) → fiber←[q₁₁=q₀₁]-filler q₁₁ q₁₀ r p' j k l
; (i = i1) → fiber→[q₀₀=q₁₀]-filler q₁₀ q₁₁ r p l k j
; (j = i0) → push q₁₀ (~ k ∧ l)
; (j = i1) → p' l k
; (k = i0) → push q₁₀ (~ j ∧ l)
; (k = i1) → push q₁₁ j })
(inS (push q₁₁ (j ∧ k))) l'
fiber→←[q₀₀=q₁₀] : fiber←[q₁₁=q₀₁] q₁₁ q₁₀ r (fiber→[q₀₀=q₁₀] q₁₀ q₁₁ r p .snd) .snd ≡ p
fiber→←[q₀₀=q₁₀] i j k = fiber→←[q₀₀=q₁₀]-filler i j k i1
{- (y₁ , q₁₁) = (y₀ , q₁₀) -}
module _
{x₀ : X}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₀)
(p : fiberSquarePush q₀₀ q₁₀ q₁₀ r) where
fiber→←[q₁₁=q₁₀]-filler : (i j k l : I) → PushoutQ
fiber→←[q₁₁=q₁₀]-filler i j k l' =
let p' = fiber→[q₁₁=q₁₀] q₁₀ q₀₀ r p .snd in
hfill (λ l → λ { (i = i0) → fiber←[q₀₀=q₀₁]-filler q₀₀ q₁₀ r p' j k l
; (i = i1) → fiber→[q₁₁=q₁₀]-filler q₁₀ q₀₀ r p l k j
; (j = i0) → push q₁₀ (~ k ∨ ~ l)
; (j = i1) → p' l k
; (k = i0) → push q₀₀ (~ j)
; (k = i1) → push q₁₀ (j ∨ ~ l) })
(inS (push q₀₀ (~ j ∨ k))) l'
fiber→←[q₁₁=q₁₀] : fiber←[q₀₀=q₀₁] q₀₀ q₁₀ r (fiber→[q₁₁=q₁₀] q₁₀ q₀₀ r p .snd) .snd ≡ p
fiber→←[q₁₁=q₁₀] i j k = fiber→←[q₁₁=q₁₀]-filler i j k i1
{- q₀₀ = q₁₀ = q₁₁ -}
fiber→←hypercube :
(r : inl x₁ ≡ inr y₀)
→ (p : fiberSquarePush q₁₀ q₁₀ q₁₀ r)
→ PathP (λ i → fiber←[q₀₀=q₀₁=q₁₁] q₁₀ i r (fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd) .snd ≡ p)
(fiber→←[q₀₀=q₁₀] q₁₀ r p) (fiber→←[q₁₁=q₁₀] q₁₀ r p)
fiber→←hypercube r p i j u v =
hcomp (λ l → λ { (i = i0) → fiber→←[q₀₀=q₁₀]-filler q₁₀ r p j u v l
; (i = i1) → fiber→←[q₁₁=q₁₀]-filler q₁₀ r p j u v l
; (j = i0) → fiber←[q₀₀=q₀₁=q₁₁]-filler q₁₀ r (fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd) i u v l
; (j = i1) → fiber→[q₀₀=q₁₀=q₁₁]-filler q₁₀ r p i l v u
; (u = i0) → push q₁₀ ((i ∨ (~ v ∧ l)) ∧ (~ v ∨ (i ∧ ~ l)))
; (u = i1) → fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd l v
; (v = i0) → push q₁₀ ((i ∨ l) ∧ ~ u)
; (v = i1) → push q₁₀ ((i ∧ ~ l) ∨ u) })
(push q₁₀ ((i ∨ (v ∧ u)) ∧ (v ∨ (i ∧ ~ u))))
{- Definitions of fiber←→ -}
module _
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) where
{- (x₁ , q₁₁) = (x₀ , q₀₁) -}
module _
{y₀ : Y}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←→[q₁₁=q₀₁]-filler : (i j k l : I) → PushoutQ
fiber←→[q₁₁=q₀₁]-filler i j k l' =
let p' = fiber←[q₁₁=q₀₁] q₀₁ q₀₀ r p .snd in
hfill (λ l → λ { (i = i0) → fiber→[q₀₀=q₁₀]-filler q₀₀ q₀₁ r p' j k l
; (i = i1) → fiber←[q₁₁=q₀₁]-filler q₀₁ q₀₀ r p l k j
; (j = i0) → push q₀₁ (k ∧ l)
; (j = i1) → p' l k
; (k = i0) → push q₀₀ (j ∧ ~ l)
; (k = i1) → push q₀₁ l })
(inS (push q₀₀ (j ∧ ~ k))) l'
fiber←→[q₁₁=q₀₁] : fiber→[q₀₀=q₁₀] q₀₀ q₀₁ r (fiber←[q₁₁=q₀₁] q₀₁ q₀₀ r p .snd) .snd ≡ p
fiber←→[q₁₁=q₀₁] i j k = fiber←→[q₁₁=q₀₁]-filler i j k i1
{- (y₀ , q₀₀) = (y₁ , q₀₁) -}
module _
{x₁ : X}(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
fiber←→[q₀₀=q₀₁]-filler : (i j k l : I) → PushoutQ
fiber←→[q₀₀=q₀₁]-filler i j k l' =
let p' = fiber←[q₀₀=q₀₁] q₀₁ q₁₁ r p .snd in
hfill (λ l → λ { (i = i0) → fiber→[q₁₁=q₁₀]-filler q₁₁ q₀₁ r p' j k l
; (i = i1) → fiber←[q₀₀=q₀₁]-filler q₀₁ q₁₁ r p l k j
; (j = i0) → push q₀₁ (k ∨ ~ l)
; (j = i1) → p' l k
; (k = i0) → push q₀₁ (~ l)
; (k = i1) → push q₁₁ (~ j ∨ l) })
(inS (push q₁₁ (~ j ∨ ~ k))) l'
fiber←→[q₀₀=q₀₁] : fiber→[q₁₁=q₁₀] q₁₁ q₀₁ r (fiber←[q₀₀=q₀₁] q₀₁ q₁₁ r p .snd) .snd ≡ p
fiber←→[q₀₀=q₀₁] i j k = fiber←→[q₀₀=q₀₁]-filler i j k i1
{- q₀₀ = q₀₁ = q₁₁ -}
fiber←→hypercube :
(r : inl x₀ ≡ inr y₁)
→ (p : push q₀₁ ≡ r)
→ PathP (λ i → fiber→[q₀₀=q₁₀=q₁₁] q₀₁ i r (fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd) .snd ≡ p)
(fiber←→[q₁₁=q₀₁] q₀₁ r p) (fiber←→[q₀₀=q₀₁] q₀₁ r p)
fiber←→hypercube r p i j u v =
hcomp (λ l → λ { (i = i0) → fiber←→[q₁₁=q₀₁]-filler q₀₁ r p j u v l
; (i = i1) → fiber←→[q₀₀=q₀₁]-filler q₀₁ r p j u v l
; (j = i0) → fiber→[q₀₀=q₁₀=q₁₁]-filler q₀₁ r (fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd) i u v l
; (j = i1) → fiber←[q₀₀=q₀₁=q₁₁]-filler q₀₁ r p i l v u
; (u = i0) → push q₀₁ ((i ∨ (v ∧ l)) ∧ (v ∨ (i ∧ ~ l)))
; (u = i1) → fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd l v
; (v = i0) → push q₀₁ ((i ∨ u) ∧ ~ l)
; (v = i1) → push q₀₁ ((i ∧ ~ u) ∨ l) })
(push q₀₁ ((i ∨ (~ v ∧ u)) ∧ (~ v ∨ (i ∧ ~ u))))
module Fiber→
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) =
WedgeConnectivity m n
(leftFiber x₁ , (y₀ , q₁₀)) (leftConn x₁)
(rightFiber y₀ , (x₁ , q₁₀)) (rightConn y₀)
(λ (y₁ , q₁₁) (x₀ , q₀₀) →
(((r : inl x₀ ≡ inr y₁) → fiberSquarePush q₀₀ q₁₀ q₁₁ r → rightCode _ r)
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTrunc _)))
(λ (y₁ , q₁₁) → ∣fiber→[q₀₀=q₁₀]∣ q₁₀ q₁₁)
(λ (x₀ , q₀₀) → ∣fiber→[q₁₁=q₁₀]∣ q₁₀ q₀₀)
(∣fiber→[q₀₀=q₁₀=q₁₁]∣ q₁₀)
fiber→ :
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀)
→ {x₀ : X}(q₀₀ : Q x₀ y₀) → {y₁ : Y}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ fiberSquarePush q₀₀ q₁₀ q₁₁ r → rightCode _ r
fiber→ q₁₀ q₀₀ q₁₁ = Fiber→.extension q₁₀ (_ , q₁₁) (_ , q₀₀)
module Fiber←
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) =
WedgeConnectivity m n
(leftFiber x₀ , (y₁ , q₀₁)) (leftConn x₀)
(rightFiber y₁ , (x₀ , q₀₁)) (rightConn y₁)
(λ (y₀ , q₀₀) (x₁ , q₁₁) →
(((r : inl x₀ ≡ inr y₁) → push q₀₁ ≡ r → leftCodeExtended q₀₀ _ (push q₁₁) r)
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTrunc _)))
(λ (y₀ , q₀₀) → ∣fiber←[q₁₁=q₀₁]∣ q₀₁ q₀₀)
(λ (x₁ , q₁₁) → ∣fiber←[q₀₀=q₀₁]∣ q₀₁ q₁₁)
(∣fiber←[q₀₀=q₀₁=q₁₁]∣ q₀₁)
fiber← :
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁)
→ {y₀ : Y}(q₀₀ : Q x₀ y₀) → {x₁ : X}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ push q₀₁ ≡ r → leftCodeExtended q₀₀ _ (push q₁₁) r
fiber← q₀₁ q₀₀ q₁₁ = Fiber←.extension q₀₁ (_ , q₀₀) (_ , q₁₁)
module _
{x₀ x₁ : X}{y₀ y₁ : Y}
(q₀₀ : Q x₀ y₀)(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁) where
left→rightCodeExtended : leftCodeExtended q₀₀ _ (push q₁₁) r → rightCode _ r
left→rightCodeExtended =
rec (isOfHLevelTrunc _) (λ (q₁₀ , p) → fiber→ q₁₀ q₀₀ q₁₁ r p)
right→leftCodeExtended : rightCode _ r → leftCodeExtended q₀₀ _ (push q₁₁) r
right→leftCodeExtended =
rec (isOfHLevelTrunc _) (λ (q₀₁ , p) → fiber← q₀₁ q₀₀ q₁₁ r p)
{- Definition of one-side homotopy -}
module _
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀) where
{- (x₀ , q₀₀) = (x₁ , q₁₀) -}
module _
{y₁ : Y}(q₁₁ : Q x₁ y₁)
(r : inl x₁ ≡ inr y₁)
(p : fiberSquarePush q₁₀ q₁₀ q₁₁ r) where
∣fiber→←[q₀₀=q₁₀]∣ : right→leftCodeExtended q₁₀ q₁₁ r (fiber→ q₁₀ q₁₀ q₁₁ r p) ≡ ∣ q₁₀ , p ∣ₕ
∣fiber→←[q₀₀=q₁₀]∣ =
(λ i → right→leftCodeExtended q₁₀ q₁₁ r (Fiber→.left q₁₀ (_ , q₁₁) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber←.left q₁₁ (_ , q₁₀) i r (fiber→[q₀₀=q₁₀] q₁₀ q₁₁ r p .snd))
∙ (λ i → ∣ q₁₀ , fiber→←[q₀₀=q₁₀] q₁₀ q₁₁ r p i ∣ₕ)
{- (y₁ , q₁₁) = (y₀ , q₁₀) -}
module _
{x₀ : X}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₀)
(p : fiberSquarePush q₀₀ q₁₀ q₁₀ r) where
∣fiber→←[q₁₁=q₁₀]∣ : right→leftCodeExtended q₀₀ q₁₀ r (fiber→ q₁₀ q₀₀ q₁₀ r p) ≡ ∣ q₁₀ , p ∣ₕ
∣fiber→←[q₁₁=q₁₀]∣ =
(λ i → right→leftCodeExtended q₀₀ q₁₀ r (Fiber→.right q₁₀ (_ , q₀₀) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber←.right q₀₀ (_ , q₁₀) i r (fiber→[q₁₁=q₁₀] q₁₀ q₀₀ r p .snd))
∙ (λ i → ∣ q₁₀ , fiber→←[q₁₁=q₁₀] q₁₀ q₀₀ r p i ∣ₕ)
{- q₀₀ = q₁₁ = q₁₀ -}
module _
(r : inl x₁ ≡ inr y₀)
(p : fiberSquarePush q₁₀ q₁₀ q₁₀ r) where
path→←Square =
(λ i j → right→leftCodeExtended q₁₀ q₁₀ r (Fiber→.homSquare q₁₀ i j r p))
∙₂ (λ i → recUniq {n = m + n} _ _ _)
∙₂ (λ i j → Fiber←.homSquare q₁₀ i j r (fiber→[q₀₀=q₁₀=q₁₁] q₁₀ i r p .snd))
∙₂ (λ i j → ∣ (q₁₀ , fiber→←hypercube q₁₀ r p i j) ∣ₕ)
∣fiber→←[q₀₀=q₁₀=q₁₁]∣ : ∣fiber→←[q₀₀=q₁₀]∣ q₁₀ ≡ ∣fiber→←[q₁₁=q₁₀]∣ q₁₀
∣fiber→←[q₀₀=q₁₀=q₁₁]∣ i r p = path→←Square r p i
fiber→← :
{x₁ : X}{y₀ : Y}(q₁₀ : Q x₁ y₀)
→ {x₀ : X}(q₀₀ : Q x₀ y₀) → {y₁ : Y}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ (p : fiberSquarePush q₀₀ q₁₀ q₁₁ r)
→ right→leftCodeExtended q₀₀ q₁₁ r (fiber→ q₁₀ q₀₀ q₁₁ r p) ≡ ∣ q₁₀ , p ∣ₕ
fiber→← {x₁ = x₁} {y₀ = y₀} q₁₀ q₀₀' q₁₁' =
WedgeConnectivity.extension m n
(leftFiber x₁ , (y₀ , q₁₀)) (leftConn x₁)
(rightFiber y₀ , (x₁ , q₁₀)) (rightConn y₀)
(λ (y₁ , q₁₁) (x₀ , q₀₀) →
(( (r : inl x₀ ≡ inr y₁) → (p : fiberSquarePush q₀₀ q₁₀ q₁₁ r)
→ right→leftCodeExtended q₀₀ q₁₁ r (fiber→ q₁₀ q₀₀ q₁₁ r p) ≡ ∣ q₁₀ , p ∣ₕ )
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTruncPath)))
(λ (y₁ , q₁₁) → ∣fiber→←[q₀₀=q₁₀]∣ q₁₀ q₁₁)
(λ (x₀ , q₀₀) → ∣fiber→←[q₁₁=q₁₀]∣ q₁₀ q₀₀)
(∣fiber→←[q₀₀=q₁₀=q₁₁]∣ q₁₀)
(_ , q₁₁') (_ , q₀₀')
{- Definition of the other side homotopy -}
module _
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁) where
{- (x₁ , q₁₁) = (x₀ , q₀₁) -}
module _
{y₀ : Y}(q₀₀ : Q x₀ y₀)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
∣fiber←→[q₁₁=q₀₁]∣ : left→rightCodeExtended q₀₀ q₀₁ r (fiber← q₀₁ q₀₀ q₀₁ r p) ≡ ∣ q₀₁ , p ∣ₕ
∣fiber←→[q₁₁=q₀₁]∣ =
(λ i → left→rightCodeExtended q₀₀ q₀₁ r (Fiber←.left q₀₁ (_ , q₀₀) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber→.left q₀₀ (_ , q₀₁) i r (fiber←[q₁₁=q₀₁] q₀₁ q₀₀ r p .snd))
∙ (λ i → ∣ q₀₁ , fiber←→[q₁₁=q₀₁] q₀₁ q₀₀ r p i ∣ₕ)
{- (y₀ , q₀₀) = (y₁ , q₀₁) -}
module _
{x₁ : X}(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
∣fiber←→[q₀₀=q₀₁]∣ : left→rightCodeExtended q₀₁ q₁₁ r (fiber← q₀₁ q₀₁ q₁₁ r p) ≡ ∣ q₀₁ , p ∣ₕ
∣fiber←→[q₀₀=q₀₁]∣ =
(λ i → left→rightCodeExtended q₀₁ q₁₁ r (Fiber←.right q₀₁ (_ , q₁₁) i r p))
∙ recUniq {n = m + n} _ _ _
∙ (λ i → Fiber→.right q₁₁ (_ , q₀₁) i r (fiber←[q₀₀=q₀₁] q₀₁ q₁₁ r p .snd))
∙ (λ i → ∣ q₀₁ , fiber←→[q₀₀=q₀₁] q₀₁ q₁₁ r p i ∣ₕ)
{- q₀₀ = q₀₁ = q₁₁ -}
module _
(r : inl x₀ ≡ inr y₁)
(p : push q₀₁ ≡ r) where
path←→Square =
(λ i j → left→rightCodeExtended q₀₁ q₀₁ r (Fiber←.homSquare q₀₁ i j r p))
∙₂ (λ i → recUniq {n = m + n} _ _ _)
∙₂ (λ i j → Fiber→.homSquare q₀₁ i j r (fiber←[q₀₀=q₀₁=q₁₁] q₀₁ i r p .snd))
∙₂ (λ i j → ∣ q₀₁ , fiber←→hypercube q₀₁ r p i j ∣ₕ)
∣fiber←→[q₀₀=q₀₁=q₁₁]∣ : ∣fiber←→[q₁₁=q₀₁]∣ q₀₁ ≡ ∣fiber←→[q₀₀=q₀₁]∣ q₀₁
∣fiber←→[q₀₀=q₀₁=q₁₁]∣ i r p = path←→Square r p i
fiber←→ :
{x₀ : X}{y₁ : Y}(q₀₁ : Q x₀ y₁)
→ {y₀ : Y}(q₀₀ : Q x₀ y₀) → {x₁ : X}(q₁₁ : Q x₁ y₁)
→ (r : inl x₀ ≡ inr y₁)
→ (p : push q₀₁ ≡ r)
→ left→rightCodeExtended q₀₀ q₁₁ r (fiber← q₀₁ q₀₀ q₁₁ r p) ≡ ∣ q₀₁ , p ∣ₕ
fiber←→ {x₀ = x₀} {y₁ = y₁} q₀₁ q₀₀' q₁₁' =
WedgeConnectivity.extension m n
(leftFiber x₀ , (y₁ , q₀₁)) (leftConn x₀)
(rightFiber y₁ , (x₀ , q₀₁)) (rightConn y₁)
(λ (y₀ , q₀₀) (x₁ , q₁₁) →
(( (r : inl x₀ ≡ inr y₁) → (p : push q₀₁ ≡ r)
→ left→rightCodeExtended q₀₀ q₁₁ r (fiber← q₀₁ q₀₀ q₁₁ r p) ≡ ∣ q₀₁ , p ∣ₕ )
, isOfHLevelΠ2 _ (λ x y → isOfHLevelTruncPath)))
(λ (y₀ , q₀₀) → ∣fiber←→[q₁₁=q₀₁]∣ q₀₁ q₀₀)
(λ (x₁ , q₁₁) → ∣fiber←→[q₀₀=q₀₁]∣ q₀₁ q₁₁)
(∣fiber←→[q₀₀=q₀₁=q₁₁]∣ q₀₁)
(_ , q₀₀') (_ , q₁₁')
module _
{x₀ x₁ : X}{y₀ y₁ : Y}
(q₀₀ : Q x₀ y₀)(q₁₁ : Q x₁ y₁)
(r : inl x₀ ≡ inr y₁) where
left→right→leftCodeExtended :
(a : leftCodeExtended q₀₀ _ (push q₁₁) r)
→ right→leftCodeExtended q₀₀ q₁₁ r (left→rightCodeExtended q₀₀ q₁₁ r a) ≡ a
left→right→leftCodeExtended a =
sym (∘rec _ _ _ (right→leftCodeExtended q₀₀ q₁₁ r) a) ∙
(λ i → recId _ (λ (q₁₀ , p) → fiber→← q₁₀ q₀₀ q₁₁ r p) i a)
right→left→rightCodeExtended :
(a : rightCode _ r)
→ left→rightCodeExtended q₀₀ q₁₁ r (right→leftCodeExtended q₀₀ q₁₁ r a) ≡ a
right→left→rightCodeExtended a =
sym (∘rec _ _ _ (left→rightCodeExtended q₀₀ q₁₁ r) a) ∙
(λ i → recId _ (λ (q₀₁ , p) → fiber←→ q₀₁ q₀₀ q₁₁ r p) i a)
left≃rightCodeExtended : leftCodeExtended q₀₀ _ (push q₁₁) r ≃ rightCode y₁ r
left≃rightCodeExtended =
isoToEquiv (iso (left→rightCodeExtended _ _ _) (right→leftCodeExtended _ _ _)
right→left→rightCodeExtended left→right→leftCodeExtended)
{- Definition and properties of Code -}
module _ (x₀ : X)(y₀ : Y)(q₀₀ : Q x₀ y₀) where
leftCode' : (x : X){p : PushoutQ} → inl x ≡ p → inl x₀ ≡ p → Type ℓ
leftCode' x r' = leftCodeExtended q₀₀ x r'
leftCode : (x : X) → inl x₀ ≡ inl x → Type ℓ
leftCode x = leftCode' x refl
fiberPath : {x : X}{y : Y} → (q : Q x y) → leftCode' x (push q) ≡ rightCode y
fiberPath q i r = ua (left≃rightCodeExtended q₀₀ q r) i
pushCode :
{x : X}{y : Y} → (q : Q x y)
→ PathP (λ i → inl x₀ ≡ push q i → Type ℓ) (leftCode x) (rightCode y)
pushCode q i =
hcomp (λ j → λ { (i = i0) → leftCode _
; (i = i1) → fiberPath q j })
(leftCode' _ (λ j → push q (i ∧ j)))
Code : (p : PushoutQ) → inl x₀ ≡ p → Type ℓ
Code (inl x) = leftCode x
Code (inr y) = rightCode y
Code (push q i) = pushCode q i
{- Transportation rule of pushCode -}
transpLeftCode : (y : Y) → (q : Q x₀ y) → (q' : leftCodeExtended q₀₀ _ refl refl) → leftCode' _ (push q) (push q)
transpLeftCode y q q' =
transport (λ i → leftCode' _ (λ j → push q (i ∧ j)) (λ j → push q (i ∧ j))) q'
transpPushCodeβ' :
(y : Y) → (q : Q x₀ y) → (q' : leftCodeExtended q₀₀ _ refl refl)
→ transport (λ i → pushCode q i (λ j → push q (i ∧ j))) q' ≡ left→rightCodeExtended _ _ _ (transpLeftCode y q q')
transpPushCodeβ' y q q' i = transportRefl (left→rightCodeExtended _ _ _ (transpLeftCode y q (transportRefl q' i))) i
module _
{p : PushoutQ}(r : inl x₀ ≡ p) where
fiber-filler : I → Type ℓ
fiber-filler i = fiber' q₀₀ (λ j → r (i ∧ j)) (λ j → r (i ∧ j))
module _
(q : fiberSquare q₀₀ q₀₀ refl refl) where
transpLeftCode-filler : (i j k : I) → PushoutQ
transpLeftCode-filler i j k' =
hfill (λ k → λ { (i = i0) → push q₀₀ (~ j)
; (i = i1) → r (j ∧ k)
; (j = i0) → push q₀₀ (~ i)
; (j = i1) → r (i ∧ k) })
(inS (q i j)) k'
transpLeftCodeβ' :
{p : PushoutQ} → (r : inl x₀ ≡ p) → (q : fiberSquare q₀₀ q₀₀ refl refl)
→ transport (λ i → fiber-filler r i) (q₀₀ , q) ≡ (q₀₀ , λ i j → transpLeftCode-filler r q i j i1)
transpLeftCodeβ' r q =
J (λ p r → transport (λ i → fiber-filler r i) (q₀₀ , q) ≡ (q₀₀ , λ i j → transpLeftCode-filler r q i j i1))
(transportRefl _ ∙ (λ k → (q₀₀ , λ i j → transpLeftCode-filler refl q i j k))) r
transpLeftCodeβ :
(y : Y) → (q : Q x₀ y) → (q' : fiberSquare q₀₀ q₀₀ refl refl)
→ transpLeftCode y q ∣ q₀₀ , q' ∣ₕ ≡ ∣ q₀₀ , (λ i j → transpLeftCode-filler (push q) q' i j i1) ∣ₕ
transpLeftCodeβ y q q' = transportTrunc _ ∙ (λ i → ∣ transpLeftCodeβ' _ q' i ∣ₕ)
transpPushCodeβ :
(y : Y) → (q : Q x₀ y) → (q' : fiberSquare q₀₀ q₀₀ refl refl)
→ transport (λ i → pushCode q i (λ j → push q (i ∧ j))) ∣ q₀₀ , q' ∣ₕ
≡ ∣fiber→[q₀₀=q₁₀]∣ q₀₀ q (push q) (λ i j → transpLeftCode-filler (push q) q' i j i1)
transpPushCodeβ y q q' =
transpPushCodeβ' _ _ _
∙ (λ i → left→rightCodeExtended _ _ _ (transpLeftCodeβ _ _ q' i))
∙ recUniq {n = m + n} _ _ _
∙ (λ i' → Fiber→.left q₀₀ (_ , q) i' (push q) (λ i j → transpLeftCode-filler (push q) q' i j i1))
{- The contractibility of Code -}
centerCode : {p : PushoutQ} → (r : inl x₀ ≡ p) → Code p r
centerCode r =
transport (λ i → Code _ (λ j → r (i ∧ j))) ∣ q₀₀ , (λ i j → push q₀₀ (~ i ∧ ~ j)) ∣ₕ
module _
(y : Y)(q : Q x₀ y) where
transp-filler : (i j k : I) → PushoutQ
transp-filler = transpLeftCode-filler (push q) (λ i' j' → push q₀₀ (~ i' ∧ ~ j'))
transp-square : fiberSquare q₀₀ q₀₀ (push q) (push q)
transp-square i j = transp-filler i j i1
contractionCodeRefl' :
fiber→[q₀₀=q₁₀] q₀₀ q (push q) transp-square .snd ≡ refl
contractionCodeRefl' i j k =
hcomp (λ l → λ { (i = i0) → fiber→[q₀₀=q₁₀]-filler q₀₀ q (push q) transp-square j k l
; (i = i1) → transp-square (~ j ∨ l) k
; (j = i0) → push q (k ∧ (i ∨ l))
; (j = i1) → transp-square l k
; (k = i0) → push q₀₀ (j ∧ ~ l)
; (k = i1) → push q ((i ∧ ~ j) ∨ l) })
(transp-filler (~ j) k i)
contractionCodeRefl : centerCode (push q) ≡ ∣ q , refl ∣ₕ
contractionCodeRefl = transpPushCodeβ _ _ _ ∙ (λ i → ∣ q , contractionCodeRefl' i ∣ₕ)
module _
(y : Y)(r : inl x₀ ≡ inr y) where
contractionCode' : (a : fiber push r) → centerCode r ≡ ∣ a ∣ₕ
contractionCode' (q , p') = J (λ r' p → centerCode r' ≡ ∣ q , p ∣ₕ) (contractionCodeRefl _ q) p'
contractionCode : (a : Code _ r) → centerCode r ≡ a
contractionCode = elim (λ _ → isOfHLevelTruncPath) contractionCode'
isContrCode : isContr (Code _ r)
isContrCode = centerCode r , contractionCode
excision-helper :
(x : X) → Trunc (1 + m) (Σ[ y₀ ∈ Y ] Q x y₀)
→ (y : Y) → (r : inl x ≡ inr y) → isContr (Trunc (m + n) (fiber push r))
excision-helper x y' y r = rec (isProp→isOfHLevelSuc m isPropIsContr) (λ (y₀ , q₀₀) → isContrCode x y₀ q₀₀ y r ) y'
{- The Main Result : Blakers-Massey Homotopy Excision Theorem -}
Excision : (x : X)(y : Y) → isConnectedFun (m + n) (push {x = x} {y = y})
Excision x y = excision-helper x (leftConn x .fst) y
{-
We also give the following version of the theorem: Given a square
g
A --------------> B
|\ ↗ |
| \ ↗ |
| \ ↗ |
f | X | inr
| / |
| / |
| / |
v / v
B -----------> Pushout f g
inl
where X is the pullback of inl and inr
(X := Σ[ (b , c) ∈ B × C ] (inl b ≡ inr c)).
If f in n-connected and g in m-connected, then the diagonal map
A → X is (n+m)-connected
-}
private
shuffleFibIso₁ :
{ℓ ℓ' ℓ'' : Level} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
(f : A → B) (g : A → C) (b : B)
→ Iso (Σ[ c ∈ C ] Σ[ a ∈ A ] (f a ≡ b) × (g a ≡ c))
(Σ[ a ∈ A ] ((Σ[ c ∈ C ] (g a ≡ c)) × (f a ≡ b)))
shuffleFibIso₁ f g b =
compIso (invIso Σ-assoc-Iso)
(compIso (Σ-cong-iso-fst Σ-swap-Iso)
(compIso
(Σ-cong-iso-snd (λ y → Σ-swap-Iso))
(compIso Σ-assoc-Iso
(Σ-cong-iso-snd λ a → invIso Σ-assoc-Iso))))
shuffleFibIso₂ : {ℓ ℓ' ℓ'' : Level} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
(f : A → B) (g : A → C) (x : _)
→ Iso (Σ[ a ∈ A ] ((Σ[ c ∈ C ] (g a ≡ c)) × (f a ≡ x)))
(fiber f x)
shuffleFibIso₂ f g x = Σ-cong-iso-snd
λ a → compIso (Σ-cong-iso-fst
(isContr→Iso (isContrSingl (g a))
isContrUnit))
lUnit×Iso
module BlakersMassey□ {ℓ ℓ' ℓ'' : Level}
{A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
(f : A → B) (g : A → C) (n m : ℕ)
(con-f : isConnectedFun (suc n) f)
(con-g : isConnectedFun (suc m) g) where
{- Some abbreviations and connectivity -}
private
fib = doubleFib f g
B-con : (x : B) → isConnected (suc n) (Σ[ c ∈ C ] (fib x c))
B-con x =
isConnectedRetractFromIso (suc n)
(compIso
(shuffleFibIso₁ f g x)
(shuffleFibIso₂ f g x))
(con-f x)
C-con : (c : C) → isConnected (suc m) (Σ[ b ∈ B ] (fib b c))
C-con c =
isConnectedRetractFromIso (suc m)
(compIso
(compIso (Σ-cong-iso-snd
(λ _ → Σ-cong-iso-snd λ _ → Σ-swap-Iso))
(shuffleFibIso₁ g f c))
(shuffleFibIso₂ g f c))
(con-g c)
open module BM-f-g = BlakersMassey B C fib {m = n} B-con {n = m} C-con
fib× : (B × C) → Type _
fib× (b , c) = fib b c
PushoutGenPath× : B × C → Type _
PushoutGenPath× (b , c) = Path (PushoutGen fib) (inl b) (inr c)
PushoutPath× : B × C → Type _
PushoutPath× (b , c) = Path (Pushout f g) (inl b) (inr c)
{- The function in question -}
toPullback : A → Σ (B × C) PushoutPath×
toPullback a = (f a , g a) , push a
{- We redescribe toPullback as a composition of three maps,
two of which are equivs and one of which is (n+m)-connected -}
Totalfib×→Total : Σ (B × C) fib× → Σ (B × C) PushoutGenPath×
Totalfib×→Total =
TotalFun {A = B × C} {B = fib×} {C = PushoutGenPath×} (λ a → push)
isConnectedTotalFun : isConnectedFun (n + m) Totalfib×→Total
isConnectedTotalFun =
FunConnected→TotalFunConnected (λ _ → push) (n + m) (uncurry BM-f-g.Excision)
TotalPathGen×Iso : Iso (Σ (B × C) PushoutGenPath×) (Σ (B × C) PushoutPath×)
TotalPathGen×Iso =
Σ-cong-iso-snd λ x
→ congIso (invIso (IsoPushoutPushoutGen f g))
Totalfib×Iso : Iso (Σ (B × C) fib×) A
fun Totalfib×Iso ((b , c) , a , p) = a
inv Totalfib×Iso a = (f a , g a) , a , refl , refl
rightInv Totalfib×Iso _ = refl
leftInv Totalfib×Iso ((b , c) , a , (p , q)) i =
((p i) , (q i)) , (a , ((λ j → p (i ∧ j)) , (λ j → q (i ∧ j))))
toPullback' : A → Σ (B × C) PushoutPath×
toPullback' =
(fun TotalPathGen×Iso ∘ Totalfib×→Total) ∘ inv Totalfib×Iso
toPullback'≡toPullback : toPullback' ≡ toPullback
toPullback'≡toPullback =
funExt λ x → ΣPathP (refl , (sym (rUnit (push x))))
isConnected-toPullback : isConnectedFun (n + m) toPullback
isConnected-toPullback =
subst (isConnectedFun (n + m)) toPullback'≡toPullback
(isConnectedComp
(fun TotalPathGen×Iso ∘ Totalfib×→Total)
(inv Totalfib×Iso) (n + m)
(isConnectedComp (fun TotalPathGen×Iso) Totalfib×→Total (n + m)
(isEquiv→isConnected _ (isoToIsEquiv TotalPathGen×Iso) (n + m))
isConnectedTotalFun)
(isEquiv→isConnected _ (isoToIsEquiv (invIso Totalfib×Iso)) (n + m)))
| {
"alphanum_fraction": 0.5023937098,
"avg_line_length": 38.9395061728,
"ext": "agda",
"hexsha": "102791ab74cb8a13c7e30b0781353639f6bb5391",
"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": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FernandoLarrain/cubical",
"max_forks_repo_path": "Cubical/Homotopy/BlakersMassey.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"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": "FernandoLarrain/cubical",
"max_issues_repo_path": "Cubical/Homotopy/BlakersMassey.agda",
"max_line_length": 120,
"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/Homotopy/BlakersMassey.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T21:49:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-05T21:49:23.000Z",
"num_tokens": 14004,
"size": 31541
} |
-- Andreas, 2012-10-09
-- Testcase to ensure we do not fire catch all clause on neutrals in literal matching
module DoNotFireLiteralCatchAllForNeutrals where
{-# BUILTIN STRING String #-}
data ⊥ : Set where
record ⊤ : Set where
constructor trivial
NotNull : String → Set
NotNull "" = ⊥
NotNull s = ⊤ -- never reduces on open terms
allNull : (s : String) → NotNull s
allNull s = trivial -- should fail
bot : ⊥
bot = allNull ""
| {
"alphanum_fraction": 0.7050691244,
"avg_line_length": 21.7,
"ext": "agda",
"hexsha": "e6cd9e9c3f8c946bb065dadcd6b0d9fe50836539",
"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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Fail/DoNotFireLiteralCatchAllForNeutrals.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/DoNotFireLiteralCatchAllForNeutrals.agda",
"max_line_length": 85,
"max_stars_count": 1,
"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/DoNotFireLiteralCatchAllForNeutrals.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z",
"num_tokens": 124,
"size": 434
} |
-- Hurkens' paradox [1].
-- [1] A. Hurkens, A simplification of Girard's paradox.
{-# OPTIONS --type-in-type
#-}
module Hurkens where
⊥ : Set
⊥ = (A : Set) -> A
¬_ : Set -> Set
¬ A = A -> ⊥
P : Set -> Set
P A = A -> Set
U : Set
U = (X : Set) -> (P (P X) -> X) -> P (P X)
τ : P (P U) -> U
τ t = \X f p -> t \x -> p (f (x X f))
σ : U -> P (P U)
σ s = s U \t -> τ t
Δ : P U
Δ = \y -> ¬ ((p : P U) -> σ y p -> p (τ (σ y)))
Ω : U
Ω = τ \p -> (x : U) -> σ x p -> p x
D : Set
D = (p : P U) -> σ Ω p -> p (τ (σ Ω))
lem₁ : (p : P U) -> ((x : U) -> σ x p -> p x) -> p Ω
lem₁ p H1 = H1 Ω \x -> H1 (τ (σ x))
lem₂ : ¬ D
lem₂ = lem₁ Δ \x H2 H3 -> H3 Δ H2 \p -> H3 \y -> p (τ (σ y))
lem₃ : D
lem₃ p = lem₁ \y -> p (τ (σ y))
loop : ⊥
loop = lem₂ lem₃
| {
"alphanum_fraction": 0.406374502,
"avg_line_length": 15.6875,
"ext": "agda",
"hexsha": "411c77fb15c95db9c0c3ad1d95e1cf3b752b26d5",
"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/Hurkens.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/Hurkens.agda",
"max_line_length": 60,
"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/Hurkens.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": 372,
"size": 753
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.