hexsha
stringlengths
40
40
size
int64
3
1.05M
ext
stringclasses
163 values
lang
stringclasses
53 values
max_stars_repo_path
stringlengths
3
945
max_stars_repo_name
stringlengths
4
112
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
945
max_issues_repo_name
stringlengths
4
113
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
116k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
945
max_forks_repo_name
stringlengths
4
113
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
3
1.05M
avg_line_length
float64
1
966k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
3863534789cc47fa55b9d7331c07a5687676224d
25
agda
Agda
test/interaction/Issue2217/M.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue2217/M.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue2217/M.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue2217.M where
12.5
24
0.84
22328209efeebad14a270a06b810de5cb386d949
9,098
agda
Agda
theorems/homotopy/PushoutSplit.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
theorems/homotopy/PushoutSplit.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
theorems/homotopy/PushoutSplit.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.PushoutSplit where -- g h -- D --> B --> C K = A ⊔^D B / (f,g) d₁ = A <- D -> B -- f| | | L = K ⊔^B C / (right,h) d₂ = K <- B -> C -- v v v d = A <- D -> C -- A --> K --> L -- module PushoutRSplit {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : D → A) (g : D → B) (h : B → C) where private d₁ : Span d₁ = span A B D f g d₂ : Span d₂ = span (Pushout d₁) C B right h d : Span d = span A C D f (h ∘ g) split-span-map : SpanMap d d₂ split-span-map = span-map left (idf C) g (comm-sqr λ a → glue a) (comm-sqr λ _ → idp) module Split = PushoutFmap split-span-map split : Pushout d → Pushout d₂ split = Split.f inner-span-map : SpanMap d₁ d inner-span-map = span-map (idf A) h (idf D) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp) module Inner = PushoutFmap inner-span-map inner : Pushout d₁ → Pushout d inner = Inner.f module Merge = PushoutRec {d = d₂} {D = Pushout d} inner right (λ _ → idp) merge : Pushout d₂ → Pushout d merge = Merge.f private square-extend-tr : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ b : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (q : a₁₀ == b) → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ (p₋₀ ∙ q) p₋₁ (! q ∙' p₁₋) square-extend-tr idp ids = ids split-inner : (k : Pushout d₁) → split (inner k) == left k split-inner = Pushout-elim (λ a → idp) (λ b → ! (glue b)) (λ d → ↓-='-from-square $ (ap-∘ split inner (glue d) ∙ ap (ap split) (Inner.glue-β d) ∙ Split.glue-β d) ∙v⊡ square-extend-tr (glue (g d)) vid-square) abstract split-merge : (l : Pushout d₂) → split (merge l) == l split-merge = Pushout-elim split-inner (λ c → idp) (λ b → ↓-∘=idf-from-square split merge $ ap (ap split) (Merge.glue-β b) ∙v⊡ bl-square (glue b)) merge-split : (l : Pushout d) → merge (split l) == l merge-split = Pushout-elim (λ a → idp) (λ c → idp) (λ d → ↓-∘=idf-in' merge split $ ap merge (ap split (glue d)) =⟨ ap (ap merge) (Split.glue-β d) ⟩ ap merge (ap left (glue d) ∙ glue (g d)) =⟨ ap-∙ merge (ap left (glue d)) (glue (g d)) ⟩ ap merge (ap left (glue d)) ∙ ap merge (glue (g d)) =⟨ ap2 _∙_ (∘-ap merge left (glue d)) (Merge.glue-β (g d)) ⟩ ap inner (glue d) ∙ idp =⟨ ∙-unit-r _ ⟩ ap inner (glue d) =⟨ Inner.glue-β d ⟩ glue d ∎) split-equiv : Pushout d ≃ Pushout d₂ split-equiv = equiv split merge split-merge merge-split {- two-pushouts-left : lift ∘ left == left ∘ left [ (λ E → (A → E)) ↓ two-pushouts ] two-pushouts-left = codomain-over-equiv _ _ two-pushouts-right : lift ∘ right == right [ (λ E → (D → E)) ↓ two-pushouts ] two-pushouts-right = codomain-over-equiv _ _ two-pushouts-inner : lift ∘ inner == left [ (λ E → (Pushout d₁ → E)) ↓ two-pushouts ] two-pushouts-inner = codomain-over-equiv _ _ ▹ λ= split-inner -} rsplit-equiv = PushoutRSplit.split-equiv -- h -- D --> C K = A ⊔^D C / (f,h) d₁ = A <- D -> C -- f| | L = B ⊔^A K / (g,left) d₂ = B <- A -> K -- v v d = B <- D -> C -- A --> K -- g| | -- v v -- B --> L module PushoutLSplit {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : D → A) (g : A → B) (h : D → C) where private d₁ : Span d₁ = span A C D f h d₂ : Span d₂ = span B (Pushout d₁) A g left d : Span d = span B C D (g ∘ f) h split-span-map : SpanMap d d₂ split-span-map = span-map (idf B) right f (comm-sqr λ _ → idp) (comm-sqr λ d → ! (glue d)) module Split = PushoutFmap split-span-map split : Pushout d → Pushout d₂ split = Split.f inner-span-map : SpanMap d₁ d inner-span-map = span-map g (idf C) (idf D) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp) module Inner = PushoutFmap inner-span-map inner : Pushout d₁ → Pushout d inner = Inner.f module Merge = PushoutRec {d = d₂} {D = Pushout d} left inner (λ _ → idp) merge : Pushout d₂ → Pushout d merge = Merge.f private square-extend-tl : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ b : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (q : b == a₀₀) → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square (q ∙' p₀₋) (q ∙' p₋₀) p₋₁ p₁₋ square-extend-tl idp ids = ids split-inner : (k : Pushout d₁) → split (inner k) == right k split-inner = Pushout-elim (λ a → glue a) (λ c → idp) (λ d → ↓-='-from-square $ (ap-∘ split inner (glue d) ∙ ap (ap split) (Inner.glue-β d) ∙ Split.glue-β d ∙ ap (λ p → glue (f d) ∙' ap right p) (!-! (glue d))) ∙v⊡ square-extend-tl (glue (f d)) vid-square) abstract split-merge : (l : Pushout d₂) → split (merge l) == l split-merge = Pushout-elim (λ b → idp) split-inner (λ a → ↓-∘=idf-from-square split merge $ ap (ap split) (Merge.glue-β a) ∙v⊡ br-square (glue a)) merge-split : (l : Pushout d) → merge (split l) == l merge-split = Pushout-elim (λ b → idp) (λ c → idp) (λ d → ↓-∘=idf-in' merge split $ ap merge (ap split (glue d)) =⟨ ap (ap merge) (Split.glue-β d) ⟩ ap merge (glue (f d) ∙' ap right (! (! (glue d)))) =⟨ ap-∙' merge (glue (f d)) (ap right (! (! (glue d)))) ⟩ ap merge (glue (f d)) ∙' ap merge (ap right (! (! (glue d)))) =⟨ ap2 _∙'_ (Merge.glue-β (f d)) (∘-ap merge right (! (! (glue d)))) ⟩ idp ∙' ap inner (! (! (glue d))) =⟨ ∙'-unit-l _ ⟩ ap inner (! (! (glue d))) =⟨ ap (ap inner) (!-! (glue d)) ⟩ ap inner (glue d) =⟨ Inner.glue-β d ⟩ glue d ∎) split-equiv : Pushout d ≃ Pushout d₂ split-equiv = equiv split merge split-merge merge-split lsplit-equiv = PushoutLSplit.split-equiv {- TODO Update this part -- g h -- Y --> Z --> W K = X ⊔^Y Y / (f,g) ps₁ = X <- Y -> Z -- f| | | L = Z ⊔^Z W / (left,h) ps₂ = K <- Z -> W -- v v v ps = X <- Y -> W -- X --> K --> L -- module TwoPushoutsPtd {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (f : Y ⊙→ X) (g : Y ⊙→ Z) (h : Z ⊙→ W) where private ps₁ = ⊙span X Z Y f g ps₂ = ⊙span (⊙Pushout ps₁) W Z (⊙right ps₁) h ps = ⊙span X W Y f (h ⊙∘ g) open TwoPushoutsEquiv (fst f) (fst g) (fst h) two-pushouts-ptd : ⊙Lift {j = lmax l (lmax k (lmax j i))} (⊙Pushout ps) == ⊙Pushout ps₂ two-pushouts-ptd = ⊙ua (two-pushouts-equiv ∘e lift-equiv) idp two-pushouts-⊙left : ⊙lift ⊙∘ ⊙left ps == ⊙left ps₂ ⊙∘ ⊙left ps₁ [ (λ V → X ⊙→ V) ↓ two-pushouts-ptd ] two-pushouts-⊙left = codomain-over-⊙equiv _ _ _ two-pushouts-⊙right : ⊙lift ⊙∘ ⊙right ps == ⊙right ps₂ [ (λ V → W ⊙→ V) ↓ two-pushouts-ptd ] two-pushouts-⊙right = codomain-over-⊙equiv _ _ _ ▹ pair= idp (lemma f g h) where lemma : {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (f : Y ⊙→ X) (g : Y ⊙→ Z) (h : Z ⊙→ W) → ap (TwoPushoutsEquiv.split (fst f) (fst g) (fst h) ∘ lower {j = lmax l (lmax k (lmax j i))}) (snd (⊙lift ⊙∘ ⊙right (⊙span X W Y f (h ⊙∘ g)))) ∙ idp == ap right (! (snd h)) ∙ ! (glue (pt Z)) ∙' ap left (snd (⊙right (⊙span X Z Y f g))) lemma {Y = Y} (f , idp) (g , idp) (h , idp) = ap (2P.split ∘ lower) (ap lift (! (glue (pt Y))) ∙ idp) ∙ idp =⟨ ∙-unit-r _ ⟩ ap (2P.split ∘ lower) (ap lift (! (glue (pt Y))) ∙ idp) =⟨ ∙-unit-r _ |in-ctx (ap (2P.split ∘ lower)) ⟩ ap (2P.split ∘ lower) (ap lift (! (glue (pt Y)))) =⟨ ∘-ap (2P.split ∘ lower) lift _ ⟩ ap 2P.split (! (glue (pt Y))) =⟨ ap-! 2P.split (glue (pt Y)) ⟩ ! (ap 2P.split (glue (pt Y))) =⟨ 2P.Split.glue-β (pt Y) |in-ctx ! ⟩ ! (ap left (glue (pt Y)) ∙ glue (g (pt Y))) =⟨ !-∙ (ap left (glue (pt Y))) (glue (g (pt Y))) ⟩ ! (glue (g (pt Y))) ∙ ! (ap left (glue (pt Y))) =⟨ !-ap left (glue (pt Y)) |in-ctx (λ w → ! (glue (g (pt Y))) ∙ w) ⟩ ! (glue (g (pt Y))) ∙ ap left (! (glue (pt Y))) =⟨ ∙=∙' (! (glue (g (pt Y)))) (ap left (! (glue (pt Y)))) ⟩ ! (glue (g (pt Y))) ∙' ap left (! (glue (pt Y))) ∎ where module 2P = TwoPushoutsEquiv f g h two-pushouts-⊙inner : ⊙lift ⊙∘ (inner , idp) == ⊙left ps₂ [ (λ V → ⊙Pushout ps₁ ⊙→ V) ↓ two-pushouts-ptd ] two-pushouts-⊙inner = codomain-over-⊙equiv _ _ _ ▹ ⊙λ= split-inner idp -} {- open TwoPushoutsEquiv using () renaming (split-equiv to vsplit-pushouts-equiv) -- two-pushouts; two-pushouts-left; two-pushouts-right; two-pushouts-inner open TwoPushoutsPtd using (two-pushouts-ptd; two-pushouts-⊙left; two-pushouts-⊙right; two-pushouts-⊙inner) -}
32.035211
92
0.491976
20d1f7c753ac8f6f2e2a67f8318e619f3d3531b8
487
agda
Agda
test/Succeed/Issue1523d.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
3
2015-03-28T14:51:03.000Z
2015-12-07T20:14:00.000Z
test/Succeed/Issue1523d.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
3
2018-11-14T15:31:44.000Z
2019-04-01T19:39:26.000Z
test/Succeed/Issue1523d.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2015-09-15T14:36:15.000Z
2015-09-15T14:36:15.000Z
open import Common.Size postulate A : Set f : Size → A -- k < j ==> ∃ l < j works : ∀ i (j : Size< (↑ i)) (k : Size< j) → (((l : Size< j) → A) → A) → A works i j k ret = ret λ l → f l -- k < j <= i ==> ∃ l < i test1 : ∀ i (j : Size< (↑ i)) (k : Size< j) → (((l : Size< i) → A) → A) → A test1 i j k ret = ret λ l → f l -- k' < k < j <= i + 1 ==> ∃ l < i test : ∀ i (j : Size< (↑ ↑ i)) (k : Size< j) (k' : Size< k) → (((l : Size< i) → A) → A) → A test i j k k' ret = ret λ l → f l
27.055556
91
0.400411
add755fff0317b85e5f7caef69daf38297e8f4f2
5,600
agda
Agda
Categories/Object/Products/N-ary.agda
copumpkin/categories
36f4181d751e2ecb54db219911d8c69afe8ba892
[ "BSD-3-Clause" ]
98
2015-04-15T14:57:33.000Z
2022-03-08T05:20:36.000Z
Categories/Object/Products/N-ary.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
19
2015-05-23T06:47:10.000Z
2019-08-09T16:31:40.000Z
Categories/Object/Products/N-ary.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
23
2015-02-05T13:03:09.000Z
2021-11-11T13:50:56.000Z
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category open import Categories.Object.Products module Categories.Object.Products.N-ary {o ℓ e} (C : Category o ℓ e) (P : Products C) where open Category C open Products P open Equiv import Categories.Object.Product open Categories.Object.Product C import Categories.Object.BinaryProducts open Categories.Object.BinaryProducts C import Categories.Object.BinaryProducts.N-ary import Categories.Object.Terminal open Categories.Object.Terminal C open import Data.Nat open import Data.Vec open import Data.Vec.Properties open import Data.Product.N-ary hiding ([]) import Level open import Relation.Binary.PropositionalEquality as PropEq using () renaming (_≡_ to _≣_ ; refl to ≣-refl ; sym to ≣-sym ; cong to ≣-cong ) open BinaryProducts binary module NonEmpty = Categories.Object.BinaryProducts.N-ary C binary open Terminal terminal Prod : {n : ℕ} → Vec Obj n → Obj Prod { zero} [] = ⊤ Prod {suc n} As = NonEmpty.Prod As -- This whole module is made a great deal more heinous than it should be -- by the fact that "xs ++ [] ≣ xs" is ill-typed, so I have to repeatedly -- prove trivial corrolaries of that fact without using it directly. -- I don't really know how to deal with that in a sane way. πˡ : {n m : ℕ} → (As : Vec Obj n) → (Bs : Vec Obj m) → Prod (As ++ Bs) ⇒ Prod As πˡ { zero} [] Bs = ! πˡ { suc n} (A ∷ As) (B ∷ Bs) = NonEmpty.πˡ (A ∷ As) (B ∷ Bs) πˡ { suc zero} (A ∷ []) [] = id πˡ {suc (suc n)} (A ∷ As) [] = ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ πʳ : {n m : ℕ} → (As : Vec Obj n) → (Bs : Vec Obj m) → Prod (As ++ Bs) ⇒ Prod Bs πʳ [] Bs = id πʳ (A ∷ As) (B ∷ Bs) = NonEmpty.πʳ (A ∷ As) (B ∷ Bs) πʳ As [] = ! glue : {n m : ℕ}{X : Obj} → (As : Vec Obj n) → (Bs : Vec Obj m) → (f : X ⇒ Prod As) → (g : X ⇒ Prod Bs) → X ⇒ Prod (As ++ Bs) glue { zero} [] Bs f g = g glue { suc n} (A ∷ As) (B ∷ Bs) f g = NonEmpty.glue (A ∷ As) (B ∷ Bs) f g glue { suc zero} (A ∷ []) [] f g = f glue {suc (suc n)} (A ∷ As) [] f g = ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩ open HomReasoning .commuteˡ : {n m : ℕ}{X : Obj} → (As : Vec Obj n) → (Bs : Vec Obj m) → {f : X ⇒ Prod As} → {g : X ⇒ Prod Bs} → πˡ As Bs ∘ glue As Bs f g ≡ f commuteˡ { zero} [] Bs {f}{g} = !-unique₂ (! ∘ g) f commuteˡ { suc n} (A ∷ As) (B ∷ Bs) {f}{g} = NonEmpty.commuteˡ (A ∷ As) (B ∷ Bs) commuteˡ { suc zero} (A ∷ []) [] {f}{g} = identityˡ commuteˡ {suc (suc n)} (A ∷ As) [] {f}{g} = begin ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩ ↓⟨ ⟨⟩∘ ⟩ ⟨ π₁ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩ , (πˡ As [] ∘ π₂) ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩ ⟩ ↓⟨ ⟨⟩-congʳ assoc ⟩ ⟨ π₁ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩ , πˡ As [] ∘ π₂ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩ ⟩ ↓⟨ ⟨⟩-cong₂ commute₁ (∘-resp-≡ʳ commute₂) ⟩ ⟨ π₁ ∘ f , πˡ As [] ∘ glue As [] (π₂ ∘ f) g ⟩ ↓⟨ ⟨⟩-congʳ (commuteˡ As []) ⟩ ⟨ π₁ ∘ f , π₂ ∘ f ⟩ ↓⟨ g-η ⟩ f ∎ .commuteʳ : {n m : ℕ}{X : Obj} → (As : Vec Obj n) → (Bs : Vec Obj m) → {f : X ⇒ Prod As} → {g : X ⇒ Prod Bs} → πʳ As Bs ∘ glue As Bs f g ≡ g commuteʳ { zero} [] Bs {f}{g} = identityˡ commuteʳ { suc n} (A ∷ As) (B ∷ Bs) {f}{g} = NonEmpty.commuteʳ (A ∷ As) (B ∷ Bs) commuteʳ { suc zero} (A ∷ []) [] {f}{g} = !-unique₂ (! ∘ f) g commuteʳ {suc (suc n)} (A ∷ As) [] {f}{g} = !-unique₂ (! ∘ glue (A ∷ As) [] f g) g .N-universal : {n m : ℕ}{X : Obj} → (As : Vec Obj n) → (Bs : Vec Obj m) → {f : X ⇒ Prod As} → {g : X ⇒ Prod Bs} → {h : X ⇒ Prod (As ++ Bs) } → πˡ As Bs ∘ h ≡ f → πʳ As Bs ∘ h ≡ g → glue As Bs f g ≡ h N-universal { zero} [] Bs {f}{g}{h} h-commuteˡ h-commuteʳ = trans (sym h-commuteʳ) identityˡ N-universal { suc n} (A ∷ As) (B ∷ Bs) {f}{g}{h} h-commuteˡ h-commuteʳ = NonEmpty.N-universal (A ∷ As) (B ∷ Bs) h-commuteˡ h-commuteʳ N-universal { suc zero} (A ∷ []) [] {f}{g}{h} h-commuteˡ h-commuteʳ = trans (sym h-commuteˡ) identityˡ N-universal {suc (suc n)} (A ∷ As) [] {f}{g}{h} h-commuteˡ h-commuteʳ = begin ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩ ↓⟨ ⟨⟩-congʳ (N-universal As [] π₂∘h-commuteˡ π₂∘h-commuteʳ) ⟩ ⟨ π₁ ∘ f , π₂ ∘ h ⟩ ↑⟨ ⟨⟩-congˡ π₁∘h-commuteˡ ⟩ ⟨ π₁ ∘ h , π₂ ∘ h ⟩ ↓⟨ g-η ⟩ h ∎ where -- h-commuteˡ : ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ h ≡ f -- h-commuteʳ : (πʳ As [] ∘ π₂) ∘ h ≡ g π₁∘h-commuteˡ : π₁ ∘ h ≡ π₁ ∘ f π₁∘h-commuteˡ = begin π₁ ∘ h ↑⟨ commute₁ ⟩∘⟨ refl ⟩ (π₁ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩) ∘ h ↓⟨ assoc ⟩ π₁ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ h ↓⟨ refl ⟩∘⟨ h-commuteˡ ⟩ π₁ ∘ f ∎ π₂∘h-commuteˡ : πˡ As [] ∘ π₂ ∘ h ≡ π₂ ∘ f π₂∘h-commuteˡ = begin πˡ As [] ∘ π₂ ∘ h ↑⟨ assoc ⟩ (πˡ As [] ∘ π₂) ∘ h ↑⟨ commute₂ ⟩∘⟨ refl ⟩ (π₂ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩) ∘ h ↓⟨ assoc ⟩ π₂ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ h ↓⟨ refl ⟩∘⟨ h-commuteˡ ⟩ π₂ ∘ f ∎ π₂∘h-commuteʳ : πʳ As [] ∘ π₂ ∘ h ≡ g π₂∘h-commuteʳ = !-unique₂ (πʳ As [] ∘ π₂ ∘ h) g isProduct : {n m : ℕ} → (As : Vec Obj n) → (Bs : Vec Obj m) → Product (Prod As) (Prod Bs) isProduct {n}{m} As Bs = record { A×B = Prod (As ++ Bs) ; π₁ = πˡ As Bs ; π₂ = πʳ As Bs ; ⟨_,_⟩ = glue As Bs ; commute₁ = commuteˡ As Bs ; commute₂ = commuteʳ As Bs ; universal = N-universal As Bs }
29.319372
138
0.488571
1e64a8c9fbddf781180a29064b45744359dbb0f2
4,080
agda
Agda
Cubical/Algebra/Group/Instances/Bool.agda
howsiyu/cubical
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
[ "MIT" ]
1
2022-03-05T00:29:41.000Z
2022-03-05T00:29:41.000Z
Cubical/Algebra/Group/Instances/Bool.agda
snu-development/cubical
58f2d0dd07e51f8aa5b348a522691097b6695d1c
[ "MIT" ]
null
null
null
Cubical/Algebra/Group/Instances/Bool.agda
snu-development/cubical
58f2d0dd07e51f8aa5b348a522691097b6695d1c
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.Bool where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Data.Bool renaming (Bool to BoolType) open import Cubical.Data.Empty renaming (rec to ⊥-rec) open import Cubical.Data.Sum hiding (map ; rec) open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Monoid open import Cubical.Algebra.Semigroup open import Cubical.Relation.Nullary open GroupStr open IsGroup open IsMonoid open IsSemigroup renaming (assoc to assoc') Bool : Group₀ fst Bool = BoolType 1g (snd Bool) = true (snd Bool GroupStr.· false) false = true (snd Bool GroupStr.· false) true = false (snd Bool GroupStr.· true) y = y (inv (snd Bool)) x = x is-set (isSemigroup (isMonoid (isGroup (snd Bool)))) = isSetBool assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) false false false = refl assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) false false true = refl assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) false true false = refl assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) false true true = refl assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) true false false = refl assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) true false true = refl assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) true true false = refl assoc' (isSemigroup (isMonoid (isGroup (snd Bool)))) true true true = refl identity (IsGroup.isMonoid (isGroup (snd Bool))) false = refl , refl identity (IsGroup.isMonoid (isGroup (snd Bool))) true = refl , refl inverse (isGroup (snd Bool)) false = refl , refl inverse (isGroup (snd Bool)) true = refl , refl -- Proof that any Group equivalent to Bool as types is also isomorphic to Bool as groups. open GroupStr renaming (assoc to assocG) module _ {ℓ : Level} {A : Group ℓ} (e : Iso (fst A) BoolType) where private discreteA : Discrete (typ A) discreteA = IsoPresDiscrete (invIso e) _≟_ _·A_ = GroupStr._·_ (snd A) -A_ = GroupStr.inv (snd A) IsoABool : Iso BoolType (typ A) IsoABool with (Iso.fun e (1g (snd A))) ≟ true ... | yes p = invIso e ... | no p = compIso notIso (invIso e) true→1 : Iso.fun IsoABool true ≡ 1g (snd A) true→1 with (Iso.fun e (1g (snd A))) ≟ true ... | yes p = sym (cong (Iso.inv e) p) ∙ Iso.leftInv e _ ... | no p = sym (cong (Iso.inv e) (¬true→false (Iso.fun e (1g (snd A))) p)) ∙ Iso.leftInv e (1g (snd A)) decA : (x : typ A) → (x ≡ 1g (snd A)) ⊎ (x ≡ Iso.fun IsoABool false) decA x with (Iso.inv IsoABool x) ≟ false | discreteA x (1g (snd A)) ... | yes p | yes q = inl q ... | yes p | no q = inr (sym (Iso.rightInv IsoABool x) ∙ cong (Iso.fun (IsoABool)) p) ... | no p | no q = inr (⊥-rec (q (sym (Iso.rightInv IsoABool x) ∙∙ cong (Iso.fun IsoABool) (¬false→true _ p) ∙∙ true→1))) ... | no p | yes q = inl q ≅Bool : GroupIso Bool A ≅Bool .fst = IsoABool ≅Bool .snd = makeIsGroupHom homHelp where homHelp : _ homHelp false false with discreteA (Iso.fun IsoABool false) (1g (snd A)) | (decA ((Iso.fun IsoABool false) ·A Iso.fun IsoABool false)) ... | yes p | _ = true→1 ∙∙ sym (GroupStr.rid (snd A) (1g (snd A))) ∙∙ cong₂ (_·A_) (sym p) (sym p) ... | no p | inl x = true→1 ∙ sym x ... | no p | inr x = true→1 ∙∙ sym (helper _ x) ∙∙ sym x where helper : (x : typ A) → x ·A x ≡ x → x ≡ (1g (snd A)) helper x p = sym (GroupStr.rid (snd A) x) ∙∙ cong (x ·A_) (sym (inverse (snd A) x .fst)) ∙∙ assocG (snd A) x x (-A x) ∙∙ cong (_·A (-A x)) p ∙∙ inverse (snd A) x .fst homHelp false true = sym (GroupStr.rid (snd A) _) ∙ cong (Iso.fun IsoABool false ·A_) (sym true→1) homHelp true y = sym (GroupStr.lid (snd A) _) ∙ cong (_·A (Iso.fun IsoABool y)) (sym true→1)
43.404255
107
0.627941
c7c32ed14cc3e08e37fdf6b0b31c706d87eef14d
1,674
agda
Agda
src/Relation/Ternary/Separation/Morphisms.agda
laMudri/linear.agda
461077552d88141ac1bba044aa55b65069c3c6c0
[ "MIT" ]
34
2019-12-20T13:57:50.000Z
2021-02-03T15:22:33.000Z
src/Relation/Ternary/Separation/Morphisms.agda
laMudri/linear.agda
461077552d88141ac1bba044aa55b65069c3c6c0
[ "MIT" ]
null
null
null
src/Relation/Ternary/Separation/Morphisms.agda
laMudri/linear.agda
461077552d88141ac1bba044aa55b65069c3c6c0
[ "MIT" ]
2
2020-01-30T14:15:14.000Z
2020-05-23T00:34:36.000Z
module Relation.Ternary.Separation.Morphisms where open import Level open import Function open import Relation.Unary open import Relation.Binary.PropositionalEquality open import Relation.Ternary.Separation open import Data.Product open import Function using (_∘_) record Morphism {a b} (A : Set a) (B : Set b) {{r : RawSep A}} {u} {{s₁ : IsUnitalSep r u}} {{rb : RawSep B}} : Set (a ⊔ suc b) where field j : A → B -- j "commutes" with _⊎_ j-⊎ : ∀ {Φ₁ Φ₂ Φ} → Φ₁ ⊎ Φ₂ ≣ Φ → j Φ₁ ⊎ j Φ₂ ≣ j Φ j-⊎⁻ : ∀ {Φ₁ Φ₂ Φ} → j Φ₁ ⊎ j Φ₂ ≣ Φ → ∃ λ Φ' → Φ ≡ j Φ' × Φ₁ ⊎ Φ₂ ≣ Φ' instance _ = s₁ infixr 8 _⇒ⱼ_ _⇒ⱼ_ : ∀ {p q} → Pred A p → Pred B q → Pred A _ P ⇒ⱼ Q = P ⇒ (Q ∘ j) infixr 8 _─✴ⱼ_ _─✴ⱼ_ : ∀ {p q} → Pred A p → Pred B q → Pred B _ P ─✴ⱼ Q = P ─✴[ j ] Q {- Such a morphism on SAs induces a functor on SA-predicates -} module _ where data J {p} (P : Pred A p) : Pred B (a ⊔ p) where inj : ∀ {Φ} → P Φ → J P (j Φ) jstar : ∀ {p q} {P : Pred A p} {Q : Pred A q} → ∀[ J (P ✴ Q) ⇒ J P ✴ J Q ] jstar (inj (p ×⟨ σ ⟩ q)) = inj p ×⟨ j-⊎ σ ⟩ inj q jmap : ∀ {p q} {P : Pred A p} {Q : Pred A q} → ∀[ (P ─✴ Q) ⇒ⱼ (J P ─✴ J Q) ] app (jmap f) (inj px) σ with j-⊎⁻ σ ... | _ , refl , σ' = inj (app f px σ') wanditⱼ : ∀ {p q} {P : Pred A p} {Q : Pred B q} → ∀[ P ⇒ⱼ Q ] → (P ─✴ⱼ Q) (j u) app (wanditⱼ f) px σ with j-⊎⁻ σ ... | _ , refl , σ' with ⊎-id⁻ˡ σ' ... | refl = f px {- identity morphism -} module _ {a} {A : Set a} {{r : RawSep A}} {u} {{s₁ : IsUnitalSep r u}} where instance id-morph : Morphism A A id-morph = record { j = id ; j-⊎ = id ; j-⊎⁻ = λ x → -, refl , x }
28.372881
81
0.502389
383852814ec86ae25548f71486937d0669896736
2,788
agda
Agda
Cubical/Foundations/Equiv/BiInvertible.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Foundations/Equiv/BiInvertible.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Foundations/Equiv/BiInvertible.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{- Some theory about Bi-Invertible Equivalences - BiInvEquiv to Iso - BiInvEquiv to Equiv - BiInvEquiv to HAEquiv - Iso to BiInvEquiv -} {-# OPTIONS --safe #-} module Cubical.Foundations.Equiv.BiInvertible where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint record BiInvEquiv {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where constructor biInvEquiv field fun : A → B invr : B → A invr-rightInv : section fun invr invl : B → A invl-leftInv : retract fun invl invr≡invl : ∀ b → invr b ≡ invl b invr≡invl b = invr b ≡⟨ sym (invl-leftInv (invr b)) ⟩ invl (fun (invr b)) ≡⟨ cong invl (invr-rightInv b) ⟩ invl b ∎ invr-leftInv : retract fun invr invr-leftInv a = invr≡invl (fun a) ∙ (invl-leftInv a) invr≡invl-leftInv : ∀ a → PathP (λ j → invr≡invl (fun a) j ≡ a) (invr-leftInv a) (invl-leftInv a) invr≡invl-leftInv a j i = compPath-filler' (invr≡invl (fun a)) (invl-leftInv a) (~ j) i invl-rightInv : section fun invl invl-rightInv a = sym (cong fun (invr≡invl a)) ∙ (invr-rightInv a) invr≡invl-rightInv : ∀ a → PathP (λ j → fun (invr≡invl a j) ≡ a) (invr-rightInv a) (invl-rightInv a) invr≡invl-rightInv a j i = compPath-filler' (sym (cong fun (invr≡invl a))) (invr-rightInv a) j i module _ {ℓ} {A B : Type ℓ} (e : BiInvEquiv A B) where open BiInvEquiv e biInvEquiv→Iso-right : Iso A B Iso.fun biInvEquiv→Iso-right = fun Iso.inv biInvEquiv→Iso-right = invr Iso.rightInv biInvEquiv→Iso-right = invr-rightInv Iso.leftInv biInvEquiv→Iso-right = invr-leftInv biInvEquiv→Iso-left : Iso A B Iso.fun biInvEquiv→Iso-left = fun Iso.inv biInvEquiv→Iso-left = invl Iso.rightInv biInvEquiv→Iso-left = invl-rightInv Iso.leftInv biInvEquiv→Iso-left = invl-leftInv biInvEquiv→Equiv-right biInvEquiv→Equiv-left : A ≃ B biInvEquiv→Equiv-right = fun , isoToIsEquiv biInvEquiv→Iso-right biInvEquiv→Equiv-left = fun , isoToIsEquiv biInvEquiv→Iso-left -- since Iso.rightInv ends up getting modified during iso→HAEquiv, in some sense biInvEquiv→Iso-left -- is the most natural choice for forming a HAEquiv from a BiInvEquiv biInvEquiv→HAEquiv : HAEquiv A B biInvEquiv→HAEquiv = iso→HAEquiv biInvEquiv→Iso-left module _ {ℓ} {A B : Type ℓ} (i : Iso A B) where open Iso i iso→BiInvEquiv : BiInvEquiv A B BiInvEquiv.fun iso→BiInvEquiv = fun BiInvEquiv.invr iso→BiInvEquiv = inv BiInvEquiv.invr-rightInv iso→BiInvEquiv = rightInv BiInvEquiv.invl iso→BiInvEquiv = inv BiInvEquiv.invl-leftInv iso→BiInvEquiv = leftInv
33.590361
102
0.682209
9a0115180f2518e07b116f91b8cb8fa090d294e3
1,014
agda
Agda
n2o/Network/WebSocket.agda
o4/n2o
d7903dfffcd66ae174eed9347afe008f892b2491
[ "BSD-3-Clause" ]
3
2018-11-30T11:37:10.000Z
2019-01-02T06:37:47.000Z
n2o/Network/WebSocket.agda
o4/n2o
d7903dfffcd66ae174eed9347afe008f892b2491
[ "BSD-3-Clause" ]
null
null
null
n2o/Network/WebSocket.agda
o4/n2o
d7903dfffcd66ae174eed9347afe008f892b2491
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --cubical #-} module n2o.Network.WebSocket where open import proto.Base open import proto.IO open import n2o.Network.Internal {-# FOREIGN GHC import Network.N2O.Web.WebSockets #-} data N2OProto (A : Set) : Set where Io : ByteString Strict → ByteString Strict → N2OProto A Nop : N2OProto A Cx : Set → Set Cx = Context N2OProto CxHandler : Set → Set CxHandler a = Cx a → Cx a -- mkHandler : ∀ {A : Set} (h : Set → IO A) → Set → IO A -- mkHandler h m = h m >> return Empty -- TODO : monad instance for Result postulate runServer : ∀ {A : Set} → String → ℤ → Context N2OProto A → IO ⊤ {-# COMPILE GHC Cx = Network.N2O.Web.WebSockets.Cx #-} {-# COMPILE GHC CxHandler = Network.N2O.Web.WebSockets.CxHandler #-} {-# COMPILE GHC runServer = Network.N2O.Web.WebSockets.runServer #-} {-# COMPILE GHC N2OProto = data Network.N2O.Web.Websockets.N2OProto ( Io | Nop ) #-}
30.727273
85
0.593688
1e5d5f9a8e48b21a88b838de4821164c72146144
1,986
agda
Agda
src/Generics/Constructions/Cong.agda
flupe/generics
db764f858d908aa39ea4901669a6bbce1525f757
[ "MIT" ]
11
2021-04-08T15:10:20.000Z
2022-02-05T09:35:17.000Z
src/Generics/Constructions/Cong.agda
flupe/generics
db764f858d908aa39ea4901669a6bbce1525f757
[ "MIT" ]
4
2021-09-13T07:33:50.000Z
2022-01-14T10:48:30.000Z
src/Generics/Constructions/Cong.agda
flupe/generics
db764f858d908aa39ea4901669a6bbce1525f757
[ "MIT" ]
3
2021-04-08T08:32:42.000Z
2022-01-14T10:35:16.000Z
{-# OPTIONS --safe #-} open import Generics.Prelude hiding (lookup; pi; curry) open import Generics.Telescope open import Generics.Desc open import Generics.All open import Generics.HasDesc import Generics.Helpers as Helpers open import Relation.Binary.HeterogeneousEquality.Core using (_≅_; refl) module Generics.Constructions.Cong {P I ℓ} {A : Indexed P I ℓ} (H : HasDesc {P} {I} {ℓ} A) {p} where open HasDesc H private variable V : ExTele P i i₁ i₂ : ⟦ I ⟧tel p v v₁ v₂ : ⟦ V ⟧tel p ----------------------- -- Type of congruences levelCongCon : (C : ConDesc P V I) → Level levelCongCon (var _) = ℓ levelCongCon (π {ℓ} _ _ C) = ℓ ⊔ levelCongCon C levelCongCon (A ⊗ B) = levelIndArg A ℓ ⊔ levelCongCon B CongCon : (C : ConDesc P V I) (mk₁ : ∀ {i₁} → ⟦ C ⟧Con A′ (p , v₁ , i₁) → ⟦ D ⟧Data A′ (p , i₁)) (mk₂ : ∀ {i₂} → ⟦ C ⟧Con A′ (p , v₂ , i₂) → ⟦ D ⟧Data A′ (p , i₂)) → Set (levelCongCon C) -- If non-inductive arguments are equal CongCon (π (n , ai) S C) mk₁ mk₂ = {s₁ : < relevance ai > S _} {s₂ : < relevance ai > S _} → s₁ ≅ s₂ → CongCon C (λ x → mk₁ (s₁ , x)) (λ x → mk₂ (s₂ , x)) -- And inductive arguments are equal CongCon (A ⊗ B) mk₁ mk₂ = {f₁ : ⟦ A ⟧IndArg A′ _} {f₂ : ⟦ A ⟧IndArg A′ _} → f₁ ≅ f₂ → CongCon B (λ x → mk₁ (f₁ , x)) (λ x → mk₂ (f₂ , x)) -- Then applying the constructor to both sets should lead -- to equal values CongCon (var f) mk₁ mk₂ = constr (mk₁ refl) ≅ constr (mk₂ refl) Cong : ∀ k → Set (levelCongCon (lookupCon D k)) Cong k = CongCon (lookupCon D k) (k ,_) (k ,_) ---------------------- -- Generic congruence deriveCong : ∀ k → Cong k deriveCong k = congCon (lookupCon D k) where congCon : (C : ConDesc P V I) {mk : ∀ {i} → ⟦ C ⟧Con A′ (p , v , i) → ⟦ D ⟧Data A′ (p , i)} → CongCon C mk mk congCon (var f) = refl congCon (π ai S C) refl = congCon C congCon (A ⊗ B) refl = congCon B
27.205479
76
0.559416
1e4a863180e8508eb23bcd679e7fbdc9af038e00
3,214
agda
Agda
Cubical/ZCohomology/Groups/WedgeOfSpheres.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/ZCohomology/Groups/WedgeOfSpheres.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/ZCohomology/Groups/WedgeOfSpheres.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.Groups.WedgeOfSpheres where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.Groups.Unit open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.Wedge open import Cubical.ZCohomology.Groups.Connected open import Cubical.Data.Int renaming (_+_ to _ℤ+_) open import Cubical.HITs.Sn open import Cubical.HITs.S1 open import Cubical.Foundations.Prelude open import Cubical.HITs.Susp open import Cubical.HITs.Wedge open import Cubical.HITs.Pushout open import Cubical.HITs.Truncation renaming (elim to trElim) hiding (map ; elim2) open import Cubical.Algebra.Group open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim) S¹⋁S¹ : Type₀ S¹⋁S¹ = S₊∙ 1 ⋁ S₊∙ 1 S²⋁S¹⋁S¹ : Type₀ S²⋁S¹⋁S¹ = S₊∙ 2 ⋁ (S¹⋁S¹ , inl base) ------------- H⁰(S¹⋁S¹) ------------ H⁰-S¹⋁S¹ : GroupIso (coHomGr 0 S¹⋁S¹) intGroup H⁰-S¹⋁S¹ = H⁰-connected (inl base) (wedgeConnected _ _ (Sn-connected 0) (Sn-connected 0)) ------------- H¹(S¹⋁S¹) ------------ H¹-S¹⋁S¹ : GroupIso (coHomGr 1 S¹⋁S¹) (dirProd intGroup intGroup) H¹-S¹⋁S¹ = (Hⁿ-⋁ _ _ 0) □ dirProdGroupIso coHom1S1≃ℤ coHom1S1≃ℤ ------------- H⁰(S²⋁S¹⋁S¹) --------- H⁰-S²⋁S¹⋁S¹ : GroupIso (coHomGr 0 S²⋁S¹⋁S¹) intGroup H⁰-S²⋁S¹⋁S¹ = H⁰-connected (inl north) (wedgeConnected _ _ (Sn-connected 1) (wedgeConnected _ _ (Sn-connected 0) (Sn-connected 0))) ------------- H¹(S²⋁S¹⋁S¹) --------- H¹-S²⋁S¹⋁S¹ : GroupIso (coHomGr 1 S²⋁S¹⋁S¹) (dirProd intGroup intGroup) H¹-S²⋁S¹⋁S¹ = Hⁿ-⋁ (S₊∙ 2) (S¹⋁S¹ , inl base) 0 □ dirProdGroupIso (H¹-Sⁿ≅0 0) H¹-S¹⋁S¹ □ lUnitGroupIso ------------- H²(S²⋁S¹⋁S¹) --------- H²-S²⋁S¹⋁S¹ : GroupIso (coHomGr 2 S²⋁S¹⋁S¹) intGroup H²-S²⋁S¹⋁S¹ = compGroupIso (Hⁿ-⋁ _ _ 1) (dirProdGroupIso {B = trivialGroup} (Hⁿ-Sⁿ≅ℤ 1) ((Hⁿ-⋁ _ _ 1) □ dirProdGroupIso (Hⁿ-S¹≅0 0) (Hⁿ-S¹≅0 0) □ rUnitGroupIso) □ rUnitGroupIso) private open import Cubical.Data.Int open import Cubical.Foundations.Equiv open import Cubical.Data.Sigma to₂ : coHom 2 S²⋁S¹⋁S¹ → Int to₂ = GroupHom.fun (GroupIso.map H²-S²⋁S¹⋁S¹) from₂ : Int → coHom 2 S²⋁S¹⋁S¹ from₂ = GroupIso.inv H²-S²⋁S¹⋁S¹ to₁ : coHom 1 S²⋁S¹⋁S¹ → Int × Int to₁ = GroupHom.fun (GroupIso.map H¹-S²⋁S¹⋁S¹) from₁ : Int × Int → coHom 1 S²⋁S¹⋁S¹ from₁ = GroupIso.inv H¹-S²⋁S¹⋁S¹ to₀ : coHom 0 S²⋁S¹⋁S¹ → Int to₀ = GroupHom.fun (GroupIso.map H⁰-S²⋁S¹⋁S¹) from₀ : Int → coHom 0 S²⋁S¹⋁S¹ from₀ = GroupIso.inv H⁰-S²⋁S¹⋁S¹ {- -- Compute pretty fast test1 : to₁ (from₁ (1 , 0) +ₕ from₁ (0 , 1)) ≡ (1 , 1) test1 = refl -- Computes, but only when computing some smaller numbers first test2 : to₁ (from₁ (50 , 3) +ₕ from₁ (2 , -2)) ≡ (52 , 1) test2 = refl test3 : to₂ (from₂ 0) ≡ 0 test3 = refl test4 : to₂ (from₂ 3) ≡ 3 test4 = refl -- Does not compute: test5 : to₂ (from₂ 1 +ₕ from₂ 1) ≡ 2 test5 = refl -- This does however compute with the induced addition test5' : to₂ (induced+ H²-S²⋁S¹⋁S¹ (from₂ 1) (from₂ 1)) ≡ 2 test5' = refl -}
30.037383
93
0.648413
9a3f4af52680adc29da1e16dcbf780108b74bcda
486
agda
Agda
test/Fail/Issue4631AsPatternShadowsConstructor.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue4631AsPatternShadowsConstructor.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue4631AsPatternShadowsConstructor.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2020-05-01, issue #4631 -- -- We should not allow @-patterns to shadow constructors! open import Agda.Builtin.Bool test : Set → Set test true@_ = true -- WAS: succees -- EXPECTED: -- -- Bool !=< Set -- when checking that the expression true has type Set -- -- ———— Warning(s) ———————————————————————————————————————————— -- Name bound in @-pattern ignored because it shadows constructor -- when scope checking the left-hand side test true@A in the -- definition of test
23.142857
65
0.62963
1dc5c4e0373b86e05aee18611cf973c54436e6a8
453
agda
Agda
test/Succeed/Issue4721b.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue4721b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue4721b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --rewriting --allow-unsolved-metas #-} open import Agda.Builtin.Equality using (_≡_) open import Agda.Builtin.Equality.Rewrite postulate cast : (A B : Set) → A → B cast-rew : (A : Set) (x : A) → cast A A x ≡ x {-# REWRITE cast-rew #-} postulate A : Set x y : A data D (B : A → Set) (b : B y) : Set where con : cast (B x) (B y) ? ≡ b → D B b record R (B : A → Set) (b : B y) : Set where field eq : cast (B x) (B y) ? ≡ b
21.571429
50
0.556291
38da35db2e60e89063a2df1ba307b8fda0be629f
6,886
agda
Agda
agda/Avionics/SafetyEnvelopes.agda
helq/safety-envelopes-sentinels
bf518286f9d06dc6ea91e111be6ddedb3e2b728f
[ "BSD-3-Clause" ]
null
null
null
agda/Avionics/SafetyEnvelopes.agda
helq/safety-envelopes-sentinels
bf518286f9d06dc6ea91e111be6ddedb3e2b728f
[ "BSD-3-Clause" ]
null
null
null
agda/Avionics/SafetyEnvelopes.agda
helq/safety-envelopes-sentinels
bf518286f9d06dc6ea91e111be6ddedb3e2b728f
[ "BSD-3-Clause" ]
1
2020-09-20T00:36:09.000Z
2020-09-20T00:36:09.000Z
module Avionics.SafetyEnvelopes where open import Data.Bool using (Bool; true; false; _∧_; _∨_) open import Data.List using (List; []; _∷_; any; map; foldl; length) open import Data.List.Relation.Unary.Any as Any using (Any) open import Data.List.Relation.Unary.All as All using (All) open import Data.Maybe using (Maybe; just; nothing; is-just; _>>=_) open import Data.Nat using (ℕ; zero; suc) open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong; subst; sym) open import Relation.Unary using (_∈_) open import Relation.Nullary using (yes; no; ¬_) open import Relation.Nullary.Decidable using (fromWitnessFalse) open import Avionics.Real using (ℝ; _+_; _-_; _*_; _÷_; _^_; _<ᵇ_; _≤ᵇ_; _≤_; _<_; _<?_; _≤?_; _≟_; 1/_; 0ℝ; 1ℝ; 2ℝ; 1/2; _^2; √_; fromℕ) --open import Avionics.Product using (_×_; ⟨_,_⟩; proj₁; proj₂) open import Avionics.Probability using (Dist; NormalDist; ND; BiNormalDist) sum : List ℝ → ℝ sum = foldl _+_ 0ℝ inside : NormalDist → ℝ → ℝ → Bool inside nd z x = ((μ - z * σ) <ᵇ x) ∧ (x <ᵇ (μ + z * σ)) where open NormalDist nd using (μ; σ) mahalanobis1 : ℝ → ℝ → ℝ → ℝ mahalanobis1 u v IV = √((u - v) * IV * (u - v)) inside' : NormalDist → ℝ → ℝ → Bool inside' nd z x = mahalanobis1 μ x σ²-¹ <ᵇ z where open NormalDist nd using (μ; σ) σ²-¹ = 1/ (σ * σ) mahalanobis2 : (ℝ × ℝ) → (ℝ × ℝ) → (ℝ × ℝ × ℝ × ℝ) → ℝ --mahalanobis2 u v VI = ... mahalanobis2 ⟨ u₁ , u₂ ⟩ ⟨ v₁ , v₂ ⟩ ⟨ iv₁₁ , ⟨ iv₁₂ , ⟨ iv₂₁ , iv₂₂ ⟩ ⟩ ⟩ = √ ⟨u-v⟩IV⟨u-v⟩' where x₁ = u₁ - v₁ x₂ = u₂ - v₂ ⟨u-v⟩IV⟨u-v⟩' = (x₁ * x₁ * iv₁₁ + x₁ * x₂ * iv₁₂ + x₁ * x₂ * iv₂₁ + x₂ * x₂ * iv₂₂) insideBiv : BiNormalDist → ℝ → (ℝ × ℝ) → Bool insideBiv bnd z x = mahalanobis2 μ x Σ-¹ <ᵇ z where open BiNormalDist bnd using (μ; Σ-¹) FlightState = (ℝ × ℝ) record Model : Set where field -- Flight states SM : List FlightState -- Map from flight states to Normal Distributions fM : List (FlightState × (NormalDist × ℝ)) -- Every flight state must be represented in the map fM .fMisMap₁ : All (λ θ → Any (λ θ,ND → proj₁ θ,ND ≡ θ) fM ) SM .fMisMap₂ : All (λ θ,ND → Any (λ θ → proj₁ θ,ND ≡ θ) SM ) fM .lenSM>0 : length SM ≢ 0 --.lenfM>0 : length fM ≢ 0 -- this is the result of the bijection above and .lenSM>0 z-predictable' : List NormalDist → ℝ → ℝ → ℝ × Bool z-predictable' nds z x = ⟨ x , any (λ nd → inside nd z x) nds ⟩ z-predictable : Model → ℝ → ℝ → ℝ × Bool z-predictable M z x = z-predictable' (map (proj₁ ∘ proj₂) (Model.fM M)) z x -- sample-z-predictable : List NormalDist → ℝ → ℝ → List ℝ → Maybe (ℝ × ℝ × Bool) sample-z-predictable nds zμ zσ [] = nothing sample-z-predictable nds zμ zσ (_ ∷ []) = nothing sample-z-predictable nds zμ zσ xs@(_ ∷ _ ∷ _) = just ⟨ mean , ⟨ var_est , any inside'' nds ⟩ ⟩ where n = fromℕ (length xs) mean = (sum xs ÷ n) var_est = (sum (map (λ{x →(x - mean)^2}) xs) ÷ (n - 1ℝ)) inside'' : NormalDist → Bool inside'' nd = ((μ - zμ * σ) <ᵇ mean) ∧ (mean <ᵇ (μ + zμ * σ)) ∧ (σ^2 - zσ * std[σ^2] <ᵇ var) ∧ (var <ᵇ σ^2 + zσ * std[σ^2]) where open NormalDist nd using (μ; σ) σ^2 = σ ^2 --Var[σ^2] = 2 * (σ^2)^2 / n std[σ^2] = (√ 2ℝ) * (σ^2 ÷ (√ n)) -- Notice that the estimated variance here is computed assuming `μ` -- it's the mean of the distribution. This is so that Cramer-Rao -- lower bound can be applied to it var = (sum (map (λ{x →(x - μ)^2}) xs) ÷ n) nonneg-cf : ℝ → ℝ × Bool nonneg-cf x = ⟨ x , 0ℝ ≤ᵇ x ⟩ data StallClasses : Set where Stall NoStall Uncertain : StallClasses P[stall]f⟨_|stall⟩_ : ℝ → List (ℝ × ℝ × Dist ℝ) → ℝ P[stall]f⟨ x |stall⟩ pbs = sum (map unpack pbs) where unpack : ℝ × ℝ × Dist ℝ → ℝ unpack ⟨ P[θ] , ⟨ P[stall|θ] , dist ⟩ ⟩ = pdf x * P[θ] * P[stall|θ] where open Dist dist using (pdf) f⟨_⟩_ : ℝ → List (ℝ × ℝ × Dist ℝ) → ℝ f⟨ x ⟩ pbs = sum (map unpack pbs) where unpack : ℝ × ℝ × Dist ℝ → ℝ unpack ⟨ P[θ] , ⟨ _ , dist ⟩ ⟩ = pdf x * P[θ] where open Dist dist using (pdf) -- There should be a proof showing that the resulting value will always be in the interval [0,1] P[_|X=_]_ : StallClasses → ℝ → List (ℝ × ℝ × Dist ℝ) → Maybe ℝ P[ Stall |X= x ] pbs with f⟨ x ⟩ pbs ≟ 0ℝ ... | yes _ = nothing ... | no _ = just (((P[stall]f⟨ x |stall⟩ pbs) ÷ (f⟨ x ⟩ pbs))) P[ NoStall |X= x ] pbs with f⟨ x ⟩ pbs ≟ 0ℝ ... | yes _ = nothing ... | no _ = just (1ℝ - ((P[stall]f⟨ x |stall⟩ pbs) ÷ (f⟨ x ⟩ pbs))) P[ Uncertain |X= _ ] _ = nothing postulate -- TODO: Find out how to prove this! -- It probably requires to prove that P[Stall|X=x] + P[NoStall|X=x] ≡ 1 Stall≡1-NoStall : ∀ {x pbs p} → P[ Stall |X= x ] pbs ≡ just p → P[ NoStall |X= x ] pbs ≡ just (1ℝ - p) NoStall≡1-Stall : ∀ {x pbs p} → P[ NoStall |X= x ] pbs ≡ just p → P[ Stall |X= x ] pbs ≡ just (1ℝ - p) -- Main assumptions -- * 0.5 < τ ≤ 1 -- * 0 ≤ p ≤ 1 -- Of course, these assumptions are never explicit in the code. But note -- that, only the first assumption can be broken by an user bad input. The -- second assumption stems for probability theory, yet not proven but -- should be true ≤p→¬≤1-p : ∀ {τ p} -- This first line are the assumptions. From them, the rest should follow → 1/2 < τ → τ ≤ 1ℝ -- 0.5 < τ ≤ 1 → 0ℝ ≤ p → p ≤ 1ℝ -- 0 ≤ p ≤ 1 → τ ≤ p → ¬ τ ≤ (1ℝ - p) ≤1-p→¬≤p : ∀ {τ p} → 1/2 < τ → τ ≤ 1ℝ -- 0.5 < τ ≤ 1 → 0ℝ ≤ p → p ≤ 1ℝ -- 0 ≤ p ≤ 1 → τ ≤ (1ℝ - p) → ¬ τ ≤ p classify'' : List (ℝ × ℝ × Dist ℝ) → ℝ → ℝ → StallClasses classify'' pbs τ x with P[ Stall |X= x ] pbs ... | nothing = Uncertain ... | just p with τ ≤? p | τ ≤? (1ℝ - p) ... | yes _ | no _ = Stall ... | no _ | yes _ = NoStall ... | _ | _ = Uncertain -- the only missing case is `no _ | no _`, `yes _ | yes _` is not possible M→pbs : Model → List (ℝ × ℝ × Dist ℝ) M→pbs M = map convert (Model.fM M) where n = fromℕ (length (Model.fM M)) convert : (ℝ × ℝ) × (NormalDist × ℝ) → ℝ × ℝ × Dist ℝ convert ⟨ _ , ⟨ nd , P[stall|c] ⟩ ⟩ = ⟨ 1/ n , ⟨ P[stall|c] , dist ⟩ ⟩ where open NormalDist nd using (dist) classify : Model → ℝ → ℝ → StallClasses classify M = classify'' (M→pbs M) no-uncertain : StallClasses → Bool no-uncertain Uncertain = false no-uncertain _ = true τ-confident : Model → ℝ → ℝ → Bool τ-confident M τ = no-uncertain ∘ classify M τ safety-envelope : Model → ℝ → ℝ → ℝ → Bool safety-envelope M z τ x = proj₂ (z-predictable M z x) ∧ τ-confident M τ x
36.62766
117
0.550973
c71e83444a2e8f6324a33fd76d3d17f0d0612ed9
5,549
agda
Agda
src/PiCalculus/Syntax.agda
guilhermehas/typing-linear-pi
0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a
[ "MIT" ]
26
2020-05-02T23:32:11.000Z
2022-03-14T15:18:23.000Z
src/PiCalculus/Syntax.agda
guilhermehas/typing-linear-pi
0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a
[ "MIT" ]
1
2022-03-15T09:16:14.000Z
2022-03-15T09:16:14.000Z
src/PiCalculus/Syntax.agda
guilhermehas/typing-linear-pi
0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a
[ "MIT" ]
3
2021-01-25T13:57:13.000Z
2022-03-14T16:24:07.000Z
{-# OPTIONS --safe --without-K #-} open import Data.Char.Base using (Char) open import Data.List.Base using (List; []; _∷_) module PiCalculus.Syntax where Name : Set Name = List Char module Raw where infixr 20 _∥_ infixr 15 ⦅ν_⦆_ infixr 10 _⦅_⦆_ _⟨_⟩_ data Raw : Set where 𝟘 : Raw ⦅ν_⦆_ : Name → Raw → Raw _∥_ : Raw → Raw → Raw _⦅_⦆_ : Name → Name → Raw → Raw _⟨_⟩_ : Name → Name → Raw → Raw module Scoped where open import Data.Fin.Base open import Data.Nat.Base infixr 20 _∥_ infixr 15 ν infixr 10 _⦅⦆_ _⟨_⟩_ private variable n : ℕ data Scoped : ℕ → Set where 𝟘 : Scoped n ν : Scoped (suc n) → ⦃ name : Name ⦄ → Scoped n _∥_ : Scoped n → Scoped n → Scoped n _⦅⦆_ : Fin n → Scoped (suc n) → ⦃ name : Name ⦄ → Scoped n _⟨_⟩_ : Fin n → Fin n → Scoped n → Scoped n module Conversion where private open Raw open Scoped open import Level using (Lift; _⊔_) open import Function using (_∘_) open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable using (isYes; True; toWitness) open import Relation.Nullary.Product using (_×-dec_) open import Relation.Nullary.Negation using (¬?) import Data.Vec.Base as Vec import Data.Char.Base as Char import Data.Char.Properties as Charₚ import Data.List.Base as List import Data.List.Properties as Listₚ import Data.String.Base as String import Data.String.Properties as Stringₚ import Data.Nat.Show as ℕₛ import Data.Vec.Membership.DecPropositional as DecPropositional open import Data.Empty using (⊥) open import Data.Bool.Base using (true; false; if_then_else_) open import Data.Product using (_,_; _×_) open import Data.Unit using (⊤; tt) open import Data.Nat.Base using (ℕ; zero; suc) open import Data.Fin.Base using (Fin; zero; suc) open import Data.String.Base using (_++_) open import Data.Vec.Membership.Propositional using (_∈_; _∉_) open import Data.Vec.Relation.Unary.Any using (here; there) open Vec using (Vec; []; _∷_) _∈?_ = DecPropositional._∈?_ (Listₚ.≡-dec Charₚ._≟_) variable n m : ℕ Ctx : ℕ → Set Ctx = Vec Name count : Name → Ctx n → ℕ count name = Vec.count (Listₚ.≡-dec Charₚ._≟_ name) toChars : Name × ℕ → List Char.Char toChars (x , i) = x List.++ ('^' ∷ ℕₛ.charsInBase 10 i) repr : ∀ x (xs : Vec Name n) → Name repr x xs = toChars (x , (count x xs)) apply : Ctx n → Ctx n apply [] = [] apply (x ∷ xs) = repr x xs ∷ apply xs WellScoped : Ctx n → Raw → Set WellScoped ctx 𝟘 = ⊤ WellScoped ctx (⦅ν x ⦆ P) = WellScoped (x ∷ ctx) P WellScoped ctx (P ∥ Q) = WellScoped ctx P × WellScoped ctx Q WellScoped ctx (x ⦅ y ⦆ P) = (x ∈ ctx) × WellScoped (y ∷ ctx) P WellScoped ctx (x ⟨ y ⟩ P) = (x ∈ ctx) × (y ∈ ctx) × WellScoped ctx P WellScoped? : (ctx : Ctx n) (P : Raw) → Dec (WellScoped ctx P) WellScoped? ctx 𝟘 = yes tt WellScoped? ctx (⦅ν x ⦆ P) = WellScoped? (x ∷ ctx) P WellScoped? ctx (P ∥ Q) = WellScoped? ctx P ×-dec WellScoped? ctx Q WellScoped? ctx (x ⦅ y ⦆ P) = x ∈? ctx ×-dec WellScoped? (y ∷ ctx) P WellScoped? ctx (x ⟨ y ⟩ P) = x ∈? ctx ×-dec y ∈? ctx ×-dec WellScoped? ctx P NotShadowed : Ctx n → Raw → Set NotShadowed ctx 𝟘 = ⊤ NotShadowed ctx (⦅ν name ⦆ P) = name ∉ ctx × NotShadowed (name ∷ ctx) P NotShadowed ctx (P ∥ Q) = NotShadowed ctx P × NotShadowed ctx Q NotShadowed ctx (x ⦅ y ⦆ P) = y ∉ ctx × NotShadowed (y ∷ ctx) P NotShadowed ctx (x ⟨ y ⟩ P) = NotShadowed ctx P NotShadowed? : (ctx : Ctx n) (P : Raw) → Dec (NotShadowed ctx P) NotShadowed? ctx 𝟘 = yes tt NotShadowed? ctx (⦅ν name ⦆ P) = ¬? (name ∈? ctx) ×-dec NotShadowed? (name ∷ ctx) P NotShadowed? ctx (P ∥ Q) = NotShadowed? ctx P ×-dec NotShadowed? ctx Q NotShadowed? ctx (x ⦅ y ⦆ P) = ¬? (y ∈? ctx) ×-dec NotShadowed? (y ∷ ctx) P NotShadowed? ctx (x ⟨ y ⟩ P) = NotShadowed? ctx P ∈toFin : ∀ {a} {A : Set a} {x} {xs : Vec A n} → x ∈ xs → Fin n ∈toFin (here px) = zero ∈toFin (there x∈xs) = suc (∈toFin x∈xs) fromRaw' : (ctx : Ctx n) (P : Raw) → WellScoped ctx P → Scoped n fromRaw' ctx 𝟘 tt = 𝟘 fromRaw' ctx (⦅ν x ⦆ P) wsP = ν (fromRaw' (x ∷ ctx) P wsP) ⦃ x ⦄ fromRaw' ctx (P ∥ Q) (wsP , wsQ) = fromRaw' ctx P wsP ∥ fromRaw' ctx Q wsQ fromRaw' ctx (x ⦅ y ⦆ P) (x∈ctx , wsP) = (∈toFin x∈ctx ⦅⦆ fromRaw' (y ∷ ctx) P wsP) ⦃ y ⦄ fromRaw' ctx (x ⟨ y ⟩ P) (x∈ctx , y∈ctx , wsP) = ∈toFin x∈ctx ⟨ ∈toFin y∈ctx ⟩ fromRaw' ctx P wsP fromRaw : (ctx : Ctx n) (P : Raw) → ⦃ _ : True (WellScoped? ctx P) ⦄ → Scoped n fromRaw ctx P ⦃ p ⦄ = fromRaw' ctx P (toWitness p) toRaw : Ctx n → Scoped n → Raw toRaw ctx 𝟘 = 𝟘 toRaw ctx (ν P ⦃ name ⦄) = ⦅ν repr name ctx ⦆ toRaw (name ∷ ctx) P toRaw ctx (P ∥ Q) = toRaw ctx P ∥ toRaw ctx Q toRaw ctx ((x ⦅⦆ P) ⦃ name ⦄) = let ctx' = apply ctx in Vec.lookup ctx' x ⦅ repr name ctx ⦆ toRaw (name ∷ ctx) P toRaw ctx (x ⟨ y ⟩ P) = let ctx' = apply ctx in Vec.lookup ctx' x ⟨ Vec.lookup ctx' y ⟩ toRaw ctx P map : ∀ {a} (B : Scoped n → Set a) (ctx : Vec Name n) (P : Raw) → Set a map B ctx P with WellScoped? ctx P map B ctx P | yes wsP = B (fromRaw' ctx P wsP) map B ctx P | no _ = Lift _ ⊥ map₂ : ∀ {a} (B : Scoped n → Scoped n → Set a) (ctx : Vec Name n) (P Q : Raw) → Set a map₂ B ctx P Q with WellScoped? ctx P | WellScoped? ctx Q map₂ B ctx P Q | yes wsP | yes wsQ = B (fromRaw' ctx P wsP) (fromRaw' ctx Q wsQ) map₂ B ctx P Q | _ | _ = Lift _ ⊥
33.427711
87
0.597225
cb19637a9f5179415875ccc4391a9b8ff29f8c6e
27,009
agda
Agda
Constructive/Axiom/Properties/Base.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
3
2020-04-07T17:49:42.000Z
2020-04-21T00:03:43.000Z
Constructive/Axiom/Properties/Base.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
Constructive/Axiom/Properties/Base.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Equivalence between omniscience principles ------------------------------------------------------------------------ -- http://math.fau.edu/lubarsky/Separating%20LLPO.pdf -- https://pdfs.semanticscholar.org/deb5/23b6078032c845d8041ee6a5383fec41191c.pdf -- http://www.math.lmu.de/~schwicht/pc16transparencies/ishihara/lecture1.pdf -- https://ncatlab.org/nlab/show/weak+excluded+middle ------------------------------------------------------------------------ -- -> : implication -- <=> : equivalence -- ∧ : conjunction {- EM <=> DNE <=> Peirce <=> MI <=> DEM₁ <=> DEM₂-----┐ | | | | v | | v v EM⁻¹ <=> DNE⁻¹ | | DGP ¬ ¬ EM <=> DNS | | | | | v | | WEM <=> DEM₃ <=> DN-distrib-⊎ v v | LPO KS-------------┐ / \ | \ / \ | \ v v v v Σ-Call/CC <=> MP WLPO <=> Σ-Π-DGP -> PFP -> WPFP |\ | | \ v | \ LLPO <=> Σ-DGP <=> Π-DGP | \ | v v v WMP MP∨ -} -- WLPO ∧ MP -> LPO -- WLPO ∧ WMP -> LPO -- WMP ∧ MP∨ -> MP -- WPFP ∧ MP -> LPO -- WPFP ∧ MP∨ -> WLPO -- WPFP ∧ LLPO -> WLPO -- Inhabited ∧ LPO <=> Searchable -- MR <=> Σ-Σ-Peirce ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --exact-split #-} module Constructive.Axiom.Properties.Base where -- agda-stdlib open import Axiom.Extensionality.Propositional open import Level renaming (suc to lsuc; zero to lzero) open import Data.Bool using (Bool; true; false; not) open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit using (⊤; tt) open import Data.Sum as Sum open import Data.Product as Prod open import Data.Nat as ℕ using (ℕ; zero; suc; _≤_; s≤s; z≤n; _≤?_; _+_; _*_) import Data.Nat.Properties as ℕₚ import Data.Nat.Induction as ℕInd open import Data.Fin using (Fin) import Data.Fin.Properties as Finₚ open import Function.Base import Function.Equality as Eq import Function.Equivalence as Eqv import Function.LeftInverse as LInv -- TODO use new packages import Induction.WellFounded as Ind open import Relation.Binary using (tri≈; tri<; tri>; Rel; Trichotomous) open import Relation.Binary.PropositionalEquality hiding (Extensionality) -- TODO remove open import Relation.Nullary using (¬_; Dec; yes; no) open import Relation.Nullary.Decidable using (⌊_⌋) -- agda-misc open import Constructive.Axiom import Constructive.Axiom.Properties.Base.Lemma as Lemma open import Constructive.Combinators open import Constructive.Common open import TypeTheory.HoTT.Data.Sum.Properties using (isProp-⊎) open import TypeTheory.HoTT.Relation.Nullary.Negation.Properties using (isProp-¬) -- Properties aclt : ∀ {a b p} {A : Set a} {B : Set b} → ACLT A B p aclt f = (λ x → proj₁ (f x)) , (λ x → proj₂ (f x)) lower-dne : ∀ a b → DNE (a ⊔ b) → DNE a lower-dne a b dne = lower ∘′ dne ∘′ DN-map (lift {ℓ = b}) lower-wem : ∀ a b → WEM (a ⊔ b) → WEM a lower-wem a b wem with wem ... | inj₁ ¬Lx = inj₁ λ x → ¬Lx (lift {ℓ = b} x) ... | inj₂ ¬¬Lx = inj₂ λ ¬A → ¬¬Lx λ LA → ¬A (lower LA) -- LPO for finite set lpo-Fin : ∀ {n p} → LPO (Fin n) p lpo-Fin = dec⇒dec⊎ ∘ Finₚ.any? ∘ DecU⇒decidable dec-dns-i : ∀ {a p} {A : Set a} {P : A → Set p} → DecU P → DNS-i P dec-dns-i P? ∀¬¬P = DN-intro (P?⇒∀¬¬P→∀P P? ∀¬¬P) -- TODO -- dns-Fin : ∀ {n p} → DNS (Fin n) p ------------------------------------------------------------------------ -- Equivalence between classical proposition ------------------------------------------------------------------------ -- DNE <=> EM dne⇒em : ∀ {a} → DNE a → EM a dne⇒em dne = dne DN-Dec⊎ em⇒dne : ∀ {a} → EM a → DNE a em⇒dne em = A⊎B→¬B→A em -- Peirce => DNE, EM => Peirce peirce⇒dne : ∀ {a b} → Peirce a b → DNE a peirce⇒dne peirce ¬¬A = peirce {B = Lift _ ⊥} λ A→B → ⊥-elim (¬¬A λ x → lower $ A→B x) em⇒peirce : ∀ {a b} → EM a → Peirce a b em⇒peirce em f = Sum.[ id , [[A→B]→A]→¬A→A f ] em -- DEM₁ => EM, DNE => DEM₁ dem₁⇒em : ∀ {a} → DEM₁ a a → EM a dem₁⇒em dem₁ = dem₁ (uncurry (flip _$_)) dne⇒dem₁ : ∀ {a b} → DNE (a ⊔ b) → DEM₁ a b dne⇒dem₁ dne g = dne (g ∘ ¬[A⊎B]→¬A׬B) -- DNE <=> DEM₂ dne⇒dem₂ : ∀ {a} → DNE a → DEM₂ a a dne⇒dem₂ dne f = Prod.map dne dne $ ¬[A⊎B]→¬A׬B f dem₂⇒dne : ∀ {a} → DEM₂ a lzero → DNE a dem₂⇒dne dem₂ ¬¬A = uncurry id (dem₂ Sum.[ (λ f → ¬¬A (f ∘′ const)) , _$ tt ]) -- DNE => DEM₃ dne⇒dem₃ : ∀ {a b} → DNE (a ⊔ b) → DEM₃ a b dne⇒dem₃ dne ¬[A×B] = dne (¬[A×B]→¬¬[¬A⊎¬B] ¬[A×B]) -- Converse of contraposition dne⇒contraposition-converse : ∀ {a b} → DNE a → {A : Set a} {B : Set b} → (¬ A → ¬ B) → B → A dne⇒contraposition-converse dne ¬A→¬B b = dne $ contraposition ¬A→¬B (DN-intro b) contraposition-converse⇒dne : ∀ {a} → ({A B : Set a} → (¬ A → ¬ B) → B → A) → DNE a contraposition-converse⇒dne f = f DN-intro -- MI <=> EM mi⇒em : ∀ {a} → MI a a → EM a mi⇒em f = Sum.swap $ f id em⇒mi : ∀ {a b} → EM a → MI a b em⇒mi em f = Sum.swap $ Sum.map₁ f em -- EM <=> [¬A→B]→A⊎B em⇒[¬A→B]→A⊎B : ∀ {a b} → EM a → {A : Set a} {B : Set b} → (¬ A → B) → A ⊎ B em⇒[¬A→B]→A⊎B em f = Sum.map₂ f em [¬A→B]→A⊎B⇒em : ∀ {a} → ({A B : Set a} → (¬ A → B) → A ⊎ B) → EM a [¬A→B]→A⊎B⇒em f = f id -- Properties of WEM em⇒wem : ∀ {a} → EM a → WEM a em⇒wem em {A = A} = em {A = ¬ A} -- WEM <=> DEM₃ wem⇒dem₃ : ∀ {a} → WEM a → DEM₃ a a wem⇒dem₃ wem ¬[A×B] with wem | wem ... | inj₁ ¬A | _ = inj₁ ¬A ... | inj₂ ¬¬A | inj₁ ¬B = inj₂ ¬B ... | inj₂ ¬¬A | inj₂ ¬¬B = ⊥-elim $ DN-undistrib-× (¬¬A , ¬¬B) ¬[A×B] dem₃⇒wem : ∀ {a} → DEM₃ a a → WEM a dem₃⇒wem dem₃ = dem₃ ¬[A׬A] dgp-i⇒DN-distrib-⊎-i : ∀ {a b} {A : Set a} {B : Set b} → DGP-i A B → ¬ ¬ (A ⊎ B) → ¬ ¬ A ⊎ ¬ ¬ B dgp-i⇒DN-distrib-⊎-i dgp-i ¬¬[A⊎B] = Sum.map (λ B→A ¬A → ¬¬[A⊎B] Sum.[ ¬A , contraposition B→A ¬A ]) (λ A→B ¬B → ¬¬[A⊎B] Sum.[ contraposition A→B ¬B , ¬B ]) (Sum.swap dgp-i) -- WEM <=> DN-distrib-⊎ wem⇒DN-distrib-⊎ : ∀ {a b} → WEM (a ⊔ b) → {A : Set a} {B : Set b} → ¬ ¬ (A ⊎ B) → ¬ ¬ A ⊎ ¬ ¬ B wem⇒DN-distrib-⊎ {a} {b} wem ¬¬[A⊎B] with lower-wem a b wem | lower-wem b a wem ... | inj₁ ¬A | inj₁ ¬B = ⊥-elim $ ¬¬[A⊎B] (¬A׬B→¬[A⊎B] (¬A , ¬B)) ... | inj₁ ¬A | inj₂ ¬¬B = inj₂ ¬¬B ... | inj₂ ¬¬A | _ = inj₁ ¬¬A DN-distrib-⊎⇒wem : ∀ {a} → ({A B : Set a} → ¬ ¬ (A ⊎ B) → ¬ ¬ A ⊎ ¬ ¬ B) → WEM a DN-distrib-⊎⇒wem DN-distrib-⊎ = Sum.swap $ Sum.map₂ TN-to-N $ DN-distrib-⊎ DN-Dec⊎ -- WEM-i ∧ Stable => Dec⊎ wem-i∧stable⇒dec⊎ : ∀ {a} {A : Set a} → WEM-i A → Stable A → Dec⊎ A wem-i∧stable⇒dec⊎ (inj₁ x) stable = inj₂ x wem-i∧stable⇒dec⊎ (inj₂ y) stable = inj₁ (stable y) -- EM => DGP => WEM em⇒dgp : ∀ {a b} → EM (a ⊔ b) → DGP a b em⇒dgp em = em⇒[¬A→B]→A⊎B em ¬[A→B]→B→A dgp-i⇒dem₃-i : ∀ {a b} {A : Set a} {B : Set b} → DGP-i A B → DEM₃-i A B dgp-i⇒dem₃-i dgp-i ¬[A×B] = Sum.map (λ A→B → contraposition (λ x → x , A→B x) ¬[A×B]) (λ B→A → contraposition (λ y → B→A y , y) ¬[A×B]) dgp-i dgp⇒dem₃ : ∀ {a b} → DGP a b → DEM₃ a b dgp⇒dem₃ dgp ¬[A×B] = dgp-i⇒dem₃-i dgp ¬[A×B] dgp⇒wem : ∀ {a} → DGP a a → WEM a dgp⇒wem dgp = dem₃⇒wem $ dgp⇒dem₃ dgp -- Properties of DNS -- DNE => DNS dne⇒dns : ∀ {a p} {A : Set a} → DNE (a ⊔ p) → DNS A (a ⊔ p) dne⇒dns dne f = λ x → x λ y → dne (f y) -- DNS <=> ¬ ¬ EM dns⇒¬¬em : ∀ {a} → ({A : Set (lsuc a)} → DNS A a) → ¬ ¬ EM a dns⇒¬¬em dns = DN-map (λ x {A} → x A) $ dns (λ _ → DN-Dec⊎) ¬¬em⇒dns : ∀ {a} → ¬ ¬ EM a → ({A : Set a} → DNS A a) ¬¬em⇒dns ¬¬em = λ ∀x→¬¬Px ¬[∀x→Px] → ¬¬em λ em → ¬[∀x→Px] (λ x → em⇒dne em (∀x→¬¬Px x)) -- call/cc is classical call/cc⇒dne : ∀ {a} → Call/CC a → DNE a call/cc⇒dne call/cc ¬¬A = call/cc λ ¬A → ⊥-elim (¬¬A ¬A) em⇒call/cc : ∀ {a} → EM a → Call/CC a em⇒call/cc em ¬A→A = Sum.[ id , ¬A→A ] em -- DNE <=> ¬[A׬B]→A→B dne⇒¬[A׬B]→A→B : ∀ {a b} → DNE (a ⊔ b) → {A : Set a} {B : Set b} → ¬ (A × ¬ B) → A → B dne⇒¬[A׬B]→A→B dne = dne λ x → x λ y z → ⊥-elim (y (z , (λ w → x λ u v → w))) ¬[A׬B]→A→B⇒dne : ∀ {a} → ({A B : Set a} → ¬ (A × ¬ B) → A → B) → DNE a ¬[A׬B]→A→B⇒dne f ¬¬A = f (uncurry id) ¬¬A -- EM <=> [A→B]→¬A⊎B em⇒[A→B]→¬A⊎B : ∀ {a b} → EM b → {A : Set a} {B : Set b} → (A → B) → ¬ A ⊎ B em⇒[A→B]→¬A⊎B em f = Sum.swap (Sum.map₂ (contraposition f) em) [A→B]→¬A⊎B⇒em : ∀ {a} → ({A B : Set a} → (A → B) → ¬ A ⊎ B) → EM a [A→B]→¬A⊎B⇒em f = Sum.swap (f id) dne⇒¬[A→¬B]→A×B : ∀ {a b} → DNE (a ⊔ b) → {A : Set a} {B : Set b} → ¬ (A → ¬ B) → A × B dne⇒¬[A→¬B]→A×B dne f = dne λ ¬[A×B] → f λ x y → ¬[A×B] (x , y) -- the counterexample principle dne⇒¬[A→B]→A׬B : ∀ {a b} → DNE (a ⊔ b) → {A B : Set a} {B : Set b} → ¬ (A → B) → A × ¬ B dne⇒¬[A→B]→A׬B dne f = dne λ ¬[A׬B] → f λ x → ⊥-elim (¬[A׬B] (x , (λ y → f (const y)))) ¬[A→B]→A׬B⇒dne : ∀ {a} → ({A B : Set a} → ¬ (A → B) → A × ¬ B) → DNE a ¬[A→B]→A׬B⇒dne {a} f ¬¬A with f {B = Lift a ⊥} λ A→L⊥ → ¬¬A λ x → lower $ A→L⊥ x ... | x , _ = x dne⇒ip : ∀ {a b c} → DNE (a ⊔ b ⊔ c) → IP a b c dne⇒ip dne q f = dne (DN-ip q f) -- Properties of DNE⁻¹ and EM⁻¹ em⇒em⁻¹ : ∀ {a} → EM a → EM⁻¹ a em⇒em⁻¹ em _ = em -- DNE⁻¹ <=> EM⁻¹ dne⁻¹⇒em⁻¹ : ∀ {a} → Extensionality a lzero → DNE⁻¹ a → EM⁻¹ a dne⁻¹⇒em⁻¹ ext dne⁻¹ isP = dne⁻¹ isP′ DN-Dec⊎ where isP′ : ∀ x y → x ≡ y isP′ = isProp-⊎ ¬[A׬A] isP (isProp-¬ ext) em⁻¹⇒dne⁻¹ : ∀ {a} → EM⁻¹ a → DNE⁻¹ a em⁻¹⇒dne⁻¹ em⁻¹ isP = dec⊎⇒stable (em⁻¹ isP) ----------------------------------------------------------------------- -- Properties of LPO, LLPO, WLPO, MP, MP⊎, WMP, KS, PFP, WPFP, Σ-DGP, -- Π-DGP, Σ-Π-DGP, Σ-Call/CC ----------------------------------------------------------------------- ----------------------------------------------------------------------- -- Convert between alternative forms -- MP <=> MR mp⇒mr : ∀ {a p} {A : Set a} → MP A p → MR A p mp⇒mr mp P? ¬¬∃P = P?⇒∃¬¬P→∃P P? $ mp (¬-DecU P?) (¬¬∃P→¬∀¬P ¬¬∃P) mr⇒mp : ∀ {a p} {A : Set a} → MR A p → MP A p mr⇒mp mr P? ¬∀P = mr (¬-DecU P?) (P?⇒¬∀P→¬¬∃¬P P? ¬∀P) -- WLPO <=> WLPO-Alt wlpo⇒wlpo-Alt : ∀ {a p} {A : Set a} → WLPO A p → WLPO-Alt A p wlpo⇒wlpo-Alt wlpo P? = Sum.map ∀¬P→¬∃P ¬∀¬P→¬¬∃P (wlpo (¬-DecU P?)) wlpo-Alt⇒wlpo : ∀ {a p} {A : Set a} → WLPO-Alt A p → WLPO A p wlpo-Alt⇒wlpo wlpo-Alt P? = Sum.map (P?⇒¬∃¬P→∀P P?) ¬¬∃¬P→¬∀P (wlpo-Alt (¬-DecU P?)) -- MP⊎ <=> MP⊎-Alt mp⊎⇒mp⊎-Alt : ∀ {a p} {A : Set a} → MP⊎ A p → MP⊎-Alt A p mp⊎⇒mp⊎-Alt mp⊎ P? Q? = Sum.map (contraposition ∀P→¬∃¬P) (contraposition ∀P→¬∃¬P) ∘′ mp⊎ (¬-DecU P?) (¬-DecU Q?) ∘′ contraposition (Prod.map (P?⇒¬∃¬P→∀P P?) (P?⇒¬∃¬P→∀P Q?)) mp⊎-Alt⇒mp⊎ : ∀ {a p} {A : Set a} → MP⊎-Alt A p → MP⊎ A p mp⊎-Alt⇒mp⊎ mp⊎-Alt P? Q? = Sum.map (contraposition ¬∃P→∀¬P) (contraposition ¬∃P→∀¬P) ∘′ mp⊎-Alt (¬-DecU P?) (¬-DecU Q?) ∘′ contraposition (Prod.map ∀¬P→¬∃P ∀¬P→¬∃P) -- MP⊎ <=> MP∨ mp⊎⇒mp∨ : ∀ {a p} {A : Set a} → MP⊎ A p → MP∨ A p mp⊎⇒mp∨ mp⊎ P? Q? ¬¬∃x→Px⊎Qx = mp⊎ P? Q? ([¬¬∃x→Px⊎Qx]→¬[¬∃P׬∃Q] ¬¬∃x→Px⊎Qx) mp∨⇒mp⊎ : ∀ {a p} {A : Set a} → MP∨ A p → MP⊎ A p mp∨⇒mp⊎ mp∨ P? Q? ¬[¬∃P׬∃Q] = mp∨ P? Q? (¬[¬∃P׬∃Q]→¬¬∃x→Px⊎Qx ¬[¬∃P׬∃Q]) -- LLPO <=> LLPO-Alt llpo⇒llpo-Alt : ∀ {a p} {A : Set a} → LLPO A p → LLPO-Alt A p llpo⇒llpo-Alt llpo P? Q? = Sum.map (P?⇒¬∃¬P→∀P P?) (P?⇒¬∃¬P→∀P Q?) ∘′ llpo (¬-DecU P?) (¬-DecU Q?) ∘′ contraposition (¬A׬B→¬[A⊎B] ∘ Prod.map ∃¬P→¬∀P ∃¬P→¬∀P) llpo-Alt⇒llpo : ∀ {a p} {A : Set a} → LLPO-Alt A p → LLPO A p llpo-Alt⇒llpo llpo-Alt P? Q? = Sum.map ∀¬P→¬∃P ∀¬P→¬∃P ∘′ llpo-Alt (¬-DecU P?) (¬-DecU Q?) ∘′ DN-map (Sum.map ¬∃P→∀¬P ¬∃P→∀¬P) ∘′ ¬[A×B]→¬¬[¬A⊎¬B] -- LLPO <=> LLPO-ℕ llpo⇒llpo-ℕ : ∀ {p} → LLPO ℕ p → LLPO-ℕ p llpo⇒llpo-ℕ llpo P? ∀mn→m≢n→Pm⊎Pn with llpo (λ n → ¬-DecU P? (2 * n)) (λ n → ¬-DecU P? (1 + 2 * n)) (uncurry (Lemma.lemma₁ ∀mn→m≢n→Pm⊎Pn)) ... | inj₁ ¬∃n→¬P2n = inj₁ (P?⇒¬∃¬P→∀P (λ n → P? (2 * n)) ¬∃n→¬P2n) ... | inj₂ ¬∃n→¬P1+2n = inj₂ (P?⇒¬∃¬P→∀P (λ n → P? (suc (2 * n))) ¬∃n→¬P1+2n) private module _ {p} {P Q : ℕ → Set p} (P? : DecU P) (Q? : DecU Q) where combine : DecU (λ n → Sum.[ P , Q ] (Lemma.parity n)) combine n with Lemma.parity n ... | inj₁ m = P? m ... | inj₂ m = Q? m {- lemma : ¬ (∃ P × ∃ Q) → ∀ m n → m ≢ n → Sum.[ (λ o → ¬ P o) , (λ o → ¬ Q o) ] (Lemma.parity m) ⊎ Sum.[ (λ o → ¬ P o) , (λ o → ¬ Q o) ] (Lemma.parity n) lemma _ m n m≢n with Lemma.parity n | inspect Lemma.parity n | Lemma.parity m | inspect Lemma.parity m ... | inj₁ o | [ eq₁ ] | inj₁ p | [ eq₂ ] = {! !} ... | inj₁ o | [ eq₁ ] | inj₂ p | [ eq₂ ] = {! !} ... | inj₂ o | [ eq₁ ] | inj₁ p | [ eq₂ ] = {! !} ... | inj₂ o | [ eq₁ ] | inj₂ p | [ eq₂ ] = {! !} llpo-ℕ⇒llpo-Alt : ∀ {p} → LLPO-ℕ p → LLPO-Alt ℕ p llpo-ℕ⇒llpo-Alt llpo-ℕ P? Q? ¬¬[∀P⊎∀Q] with llpo-ℕ (combine P? Q?) {! !} ... | inj₁ ∀n→[P,Q]parity[2*n] = inj₁ λ n → subst Sum.[ _ , _ ] (Lemma.parity-even n) (∀n→[P,Q]parity[2*n] n) ... | inj₂ ∀n→[P,Q]parity[1+2*n] = inj₂ λ n → subst Sum.[ _ , _ ] (Lemma.parity-odd n) (∀n→[P,Q]parity[1+2*n] n) -} ----------------------------------------------------------------------- -- Implications -- EM => LPO em⇒lpo : ∀ {a p} {A : Set a} → EM (a ⊔ p) → LPO A p em⇒lpo em _ = em -- LPO => LLPO lpo⇒llpo : ∀ {a p} {A : Set a} → LPO A p → LLPO A p lpo⇒llpo lpo P? Q? ¬[∃P×∃Q] with lpo P? | lpo Q? ... | inj₁ ∃P | inj₁ ∃Q = contradiction (∃P , ∃Q) ¬[∃P×∃Q] ... | inj₁ ∃P | inj₂ ¬∃Q = inj₂ ¬∃Q ... | inj₂ ¬∃P | _ = inj₁ ¬∃P -- LPO <=> WLPO-Alt ∧ MR lpo⇒wlpo-Alt : ∀ {a p} {A : Set a} → LPO A p → WLPO-Alt A p lpo⇒wlpo-Alt lpo P? = ¬-dec⊎ (lpo P?) lpo⇒mr : ∀ {a p} {A : Set a} → LPO A p → MR A p lpo⇒mr lpo P? = dec⊎⇒stable (lpo P?) wlpo-Alt∧mr⇒lpo : ∀ {a p} {A : Set a} → WLPO-Alt A p → MR A p → LPO A p wlpo-Alt∧mr⇒lpo wlpo-Alt mr P? = wem-i∧stable⇒dec⊎ (wlpo-Alt P?) (mr P?) -- WLPO => LLPO-Alt wlpo⇒llpo-Alt : ∀ {a p} {A : Set a} → WLPO A p → LLPO-Alt A p wlpo⇒llpo-Alt wlpo P? Q? ¬¬[∀P⊎∀Q] with wlpo P? | wlpo Q? ... | inj₁ ∀P | _ = inj₁ ∀P ... | inj₂ ¬∀P | inj₁ ∀Q = inj₂ ∀Q ... | inj₂ ¬∀P | inj₂ ¬∀Q = contradiction (¬A׬B→¬[A⊎B] (¬∀P , ¬∀Q)) ¬¬[∀P⊎∀Q] -- WEM => WLPO-Alt wem⇒wlpo-Alt : ∀ {a p} {A : Set a} → WEM (a ⊔ p) → WLPO-Alt A p wem⇒wlpo-Alt wem P? = wem -- (WMP ∧ MP∨) <=> MR mr⇒wmp : ∀ {a p} {A : Set a} → MR A p → WMP A p mr⇒wmp mr {P = P} P? pp = mr P? $ Sum.[ id , (λ ¬¬∃x→Px׬Px _ → f ¬¬∃x→Px׬Px) ] (pp P?) where f : ¬ ¬ ∃ (λ x → P x × ¬ P x) → ⊥ f ¬¬∃x→Px׬Px = ⊥-stable $ DN-map (¬[A׬A] ∘ proj₂) ¬¬∃x→Px׬Px -- MR => MP∨ mr⇒mp∨ : ∀ {a p} {A : Set a} → MR A p → MP∨ A p mr⇒mp∨ mr {P = P} {Q = Q} P? Q? ¬¬∃x→Px⊎Qx = Sum.map DN-intro DN-intro $ ∃-distrib-⊎ $ mr {P = λ x → P x ⊎ Q x} (DecU-⊎ P? Q?) ¬¬∃x→Px⊎Qx -- WMP ∧ MP∨ => MR -- α = P, β = Q, γ = R in [2] wmp∧mp∨⇒mr : ∀ {a p} {A : Set a} → WMP A p → MP∨ A p → MR A p wmp∧mp∨⇒mr {a} {p} {A} wmp mp∨ {P = P} P? ¬¬∃P = wmp P? Lem.¬¬∃Q⊎¬¬∃R where module Lem {Q : A → Set p} (Q? : DecU Q) where R : A → Set p R x = P x × ¬ Q x ¬¬∃x→Qx⊎Rx : ¬ ¬ ∃ λ x → Q x ⊎ R x ¬¬∃x→Qx⊎Rx = DN-map f ¬¬∃P where f : ∃ P → ∃ (λ x → Q x ⊎ (P x × ¬ Q x)) f (x , Px) = x , Sum.map₂ (Px ,_) (Q? x) R? : DecU R R? = DecU-× P? (¬-DecU Q?) ¬¬∃Q⊎¬¬∃R : ¬ ¬ ∃ Q ⊎ ¬ ¬ ∃ R ¬¬∃Q⊎¬¬∃R = mp∨ Q? R? ¬¬∃x→Qx⊎Rx -- Properties that required to prove `llpo⇒Σ-dgp` record HasProperties {a} r p (A : Set a) : Set (a ⊔ lsuc r ⊔ lsuc p) where field _<_ : Rel A r <-cmp : Trichotomous _≡_ _<_ <-any-dec : {P : A → Set p} → DecU P → DecU (λ n → ∃ λ m → (m < n) × P m) <-wf : Ind.WellFounded _<_ private ¬∃¬→∀ : ∀ {P : A → Set p} {x} → DecU P → ¬ (∃ λ y → y < x × ¬ P y) → ∀ y → y < x → P y ¬∃¬→∀ {x} P? ¬∃y→y<x׬Py y y<x = DecU⇒stable P? y λ ¬Py → ¬∃y→y<x׬Py (y , (y<x , ¬Py)) <-all-dec : {P : A → Set p} → DecU P → DecU (λ n → ∀ i → i < n → P i) <-all-dec P? n with <-any-dec (¬-DecU P?) n ... | inj₁ (m , m<n , ¬Pm) = inj₂ λ ∀i→i<n→Pi → ¬Pm (∀i→i<n→Pi m m<n) ... | inj₂ ¬∃m→m<n׬Pm = inj₁ (¬∃¬→∀ P? ¬∃m→m<n׬Pm) First : (A → Set p) → A → Set (a ⊔ p ⊔ r) First P x = (∀ y → y < x → ¬ P y) × P x First? : {P : A → Set p} → DecU P → DecU (First P) First? P? = DecU-× (<-all-dec (¬-DecU P?)) P? None : (A → Set p) → A → Set (a ⊔ p ⊔ r) None P x = (∀ y → y < x → ¬ P y) × ¬ P x None? : {P : A → Set p} → DecU P → DecU (None P) None? P? = DecU-× (<-all-dec (¬-DecU P?)) (¬-DecU P?) ∃⊎None : {P : A → Set p} → DecU P → ∀ x → ∃ P ⊎ None P x ∃⊎None P? x with P? x | <-any-dec P? x ... | inj₁ Px | _ = inj₁ (x , Px) ... | inj₂ ¬Px | inj₁ (y , _ , Py) = inj₁ (y , Py) ... | inj₂ ¬Px | inj₂ ¬∃ = inj₂ ((λ y y<x Py → ¬∃ (y , (y<x , Py))) , ¬Px) findFirst : {P : A → Set p} → DecU P → ∃ P → ∃ (First P) findFirst {P} P? (x , Px) = go x (<-wf x) Px where go : ∀ x → Ind.Acc _<_ x → P x → ∃ λ y → (∀ i → i < y → ¬ P i) × P y go x (Ind.acc rs) Px with <-any-dec P? x ... | inj₁ (y , y<x , Py) = go y (rs y y<x) Py ... | inj₂ ¬∃y→y<x×Py = x , (λ i i<x Pi → ¬∃y→y<x×Py (i , (i<x , Pi))) , Px First-unique : ∀ {P : A → Set p} {x y} → First P x → First P y → x ≡ y First-unique {P} {x} {y} (∀i→i<x→¬Pi , Px) (∀i→i<y→¬Pi , Py) with <-cmp x y ... | tri< x<y _ _ = contradiction Px (∀i→i<y→¬Pi x x<y) ... | tri≈ _ x≡y _ = x≡y ... | tri> _ _ x>y = contradiction Py (∀i→i<x→¬Pi y x>y) module HasPropertiesLemma {P Q : A → Set p} (P? : DecU P) (Q? : DecU Q) where R S : A → Set (r ⊔ p ⊔ a) R x = First P x × None Q x S x = First Q x × None P x R? : DecU R R? = DecU-× (First? P?) (None? Q?) S? : DecU S S? = DecU-× (First? Q?) (None? P?) ¬[∃R×∃S] : ¬ (∃ R × ∃ S) ¬[∃R×∃S] ((x , (∀i→i<x→¬Pi , Px) , ∀i→i<x→¬Qi , ¬Qx) , (y , (∀i→i<y→¬Qi , Qy) , ∀i→i<y→¬Pi , ¬Py )) with <-cmp x y ... | tri< x<y _ _ = ∀i→i<y→¬Pi x x<y Px ... | tri≈ _ x≡y _ = ¬Py (subst P x≡y Px) ... | tri> _ _ y<x = ∀i→i<x→¬Qi y y<x Qy ¬∃R→∃P→∃Q : ¬ ∃ R → ∃ P → ∃ Q ¬∃R→∃P→∃Q ¬∃R ∃P with findFirst P? ∃P ¬∃R→∃P→∃Q ¬∃R ∃P | x , firstP with ∃⊎None Q? x ¬∃R→∃P→∃Q ¬∃R ∃P | x , firstP | inj₁ ∃Q = ∃Q ¬∃R→∃P→∃Q ¬∃R ∃P | x , firstP | inj₂ noneQ = contradiction (x , firstP , noneQ) ¬∃R ¬∃S→∃Q→∃P : ¬ ∃ S → ∃ Q → ∃ P ¬∃S→∃Q→∃P ¬∃S ∃Q with findFirst Q? ∃Q ¬∃S→∃Q→∃P ¬∃S ∃Q | x , firstQ with ∃⊎None P? x ¬∃S→∃Q→∃P ¬∃S ∃Q | x , firstQ | inj₁ ∃P = ∃P ¬∃S→∃Q→∃P ¬∃S ∃Q | x , firstQ | inj₂ noneP = contradiction (x , firstQ , noneP) ¬∃S -- Proposition 8.6.1. [1] -- Σ-DGP <=> LLPO llpo⇒Σ-dgp : ∀ {r p a} {A : Set a} → HasProperties r p A → LLPO A (p ⊔ a ⊔ r) → Σ-DGP A p llpo⇒Σ-dgp has llpo {P = P} {Q} P? Q? = Sum.map ¬∃R→∃P→∃Q ¬∃S→∃Q→∃P ¬∃R⊎¬∃S where open HasProperties has open HasPropertiesLemma P? Q? ¬∃R⊎¬∃S : ¬ ∃ R ⊎ ¬ ∃ S ¬∃R⊎¬∃S = llpo R? S? ¬[∃R×∃S] Σ-dgp⇒llpo : ∀ {a p} {A : Set a} → Σ-DGP A p → LLPO A p Σ-dgp⇒llpo Σ-dgp P? Q? ¬[∃P×∃Q] = dgp-i⇒dem₃-i (Σ-dgp P? Q?) ¬[∃P×∃Q] -- Σ-DGP => MP∨ Σ-dgp⇒mp∨ : ∀ {p a} {A : Set a} → Σ-DGP A p → MP∨ A p Σ-dgp⇒mp∨ Σ-dgp {P = P} {Q} P? Q? ¬¬[∃x→Px⊎Qx] = ¬¬∃P⊎¬¬∃Q where ¬¬[∃P⊎∃Q] : ¬ ¬ (∃ P ⊎ ∃ Q) ¬¬[∃P⊎∃Q] = DN-map ∃-distrib-⊎ ¬¬[∃x→Px⊎Qx] ¬¬∃P⊎¬¬∃Q : ¬ ¬ ∃ P ⊎ ¬ ¬ ∃ Q ¬¬∃P⊎¬¬∃Q = dgp-i⇒DN-distrib-⊎-i (Σ-dgp P? Q?) ¬¬[∃P⊎∃Q] -- Σ-DGP => Π-DGP Σ-dgp⇒Π-dgp : ∀ {p a} {A : Set a} → Σ-DGP A p → Π-DGP A p Σ-dgp⇒Π-dgp Σ-dgp P? Q? = Sum.map (P?⇒[∃¬P→∃¬Q]→∀Q→∀P Q?) (P?⇒[∃¬P→∃¬Q]→∀Q→∀P P?) (Σ-dgp (¬-DecU Q?) (¬-DecU P?)) -- Π-DGP => LLPO-Alt Π-dgp⇒llpo-Alt : ∀ {a p} {A : Set a} → Π-DGP A p → LLPO-Alt A p Π-dgp⇒llpo-Alt Π-dgp P? Q? = Sum.map (P?⇒¬¬∀P→∀P P?) (P?⇒¬¬∀P→∀P Q?) ∘′ dgp-i⇒DN-distrib-⊎-i (Π-dgp P? Q?) -- LLPO => MP∨ llpo⇒mp∨ : ∀ {r p a} {A : Set a} → HasProperties r p A → LLPO A (p ⊔ a ⊔ r) → MP∨ A p llpo⇒mp∨ has llpo = Σ-dgp⇒mp∨ (llpo⇒Σ-dgp has llpo) ℕ-hasProperties : ∀ p → HasProperties lzero p ℕ ℕ-hasProperties _ = record { _<_ = ℕ._<_ ; <-cmp = ℕₚ.<-cmp ; <-any-dec = Lemma.ℕ<-any-dec ; <-wf = ℕInd.<-wellFounded } ℕ-llpo⇒mp∨ : ∀ {p} → LLPO ℕ p → MP∨ ℕ p ℕ-llpo⇒mp∨ = llpo⇒mp∨ (ℕ-hasProperties _) ℕ-llpo⇒Σ-dgp : ∀ {p} → LLPO ℕ p → Σ-DGP ℕ p ℕ-llpo⇒Σ-dgp = llpo⇒Σ-dgp (ℕ-hasProperties _) -- Proposition 8.6.1. [1] -- WLPO <=> Σ-Π-DGP wlpo⇒Σ-Π-dgp : ∀ {a p} {A : Set a} → WLPO A p → Σ-Π-DGP A p wlpo⇒Σ-Π-dgp wlpo P? Q? with wlpo Q? ... | inj₁ ∀Q = inj₁ λ _ → ∀Q ... | inj₂ ¬∀Q = inj₂ λ ∀Q → ⊥-elim $ ¬∀Q ∀Q Σ-Π-dgp⇒wlpo : ∀ {a p} {A : Set a} → Σ-Π-DGP A p → WLPO A p Σ-Π-dgp⇒wlpo Σ-Π-dgp P? with Σ-Π-dgp (¬-DecU P?) P? ... | inj₁ ∃¬P→∀P = inj₁ (P?⇒[∃¬P→∀P]→∀P P? ∃¬P→∀P) ... | inj₂ ∀P→∃¬P = inj₂ λ ∀P → ∃¬P→¬∀P (∀P→∃¬P ∀P) ∀P -- Question 15 [1] -- MR <=> Σ-Call/CC mr⇒Σ-call/cc : ∀ {a p} {A : Set a} → MR A p → Σ-Call/CC A p mr⇒Σ-call/cc mr P? = mr P? ∘′ [¬A→A]→¬¬A Σ-call/cc⇒mr : ∀ {a p} {A : Set a} → Σ-Call/CC A p → MR A p Σ-call/cc⇒mr Σ-call/cc P? ¬¬∃P = Σ-call/cc P? λ ¬∃P → ⊥-elim $ ¬¬∃P ¬∃P -- Question 15 [1] -- MR <=> Σ-Σ-Peirce mr⇒Σ-Σ-peirce : ∀ {a p} {A : Set a} → MR A p → Σ-Σ-Peirce A p mr⇒Σ-Σ-peirce mr P? Q? [∃P→∃Q]→∃P = mr P? ([[A→B]→A]→¬¬A [∃P→∃Q]→∃P) Σ-Σ-peirce⇒mr : ∀ {a p} {A : Set a} → Σ-Σ-Peirce A p → MR A p Σ-Σ-peirce⇒mr {A = A} Σ-Σ-peirce P? = [[[A→B]→A]→A]→¬B→¬¬A→A (Σ-Σ-peirce {Q = λ _ → Lift _ ⊥} P? (λ _ → inj₂ lower)) f where f : Σ A (λ _ → Lift _ ⊥) → ⊥ f (_ , ()) -- MR => Σ-Π-Peirce mr⇒Σ-Π-peirce : ∀ {a p} {A : Set a} → MR A p → Σ-Π-Peirce A p mr⇒Σ-Π-peirce mr P? Q? [∃P→∀Q]→∃P = mr P? ([[A→B]→A]→¬¬A [∃P→∀Q]→∃P) -- Inhabited ∧ Σ-Π-peirce => MR inhabited∧Σ-Π-peirce⇒mr : ∀ {a p} {A : Set a} → Inhabited A → Σ-Π-Peirce A p → MR A p inhabited∧Σ-Π-peirce⇒mr {p = p} {A} inhabited Σ-Π-peirce P? = [[[A→B]→A]→A]→¬B→¬¬A→A (Σ-Π-peirce {Q = λ _ → Lift _ ⊥} P? (λ _ → inj₂ lower)) f where f : ¬ ((x : A) → Lift p ⊥) f ∀x→L⊥ = lower (∀x→L⊥ inhabited) -- Proposition 6.4.1. [1] -- WMP ∧ WLPO-Alt => LPO wmp∧wlpo-Alt⇒lpo : ∀ {a p} {A : Set a} → WMP A p → WLPO-Alt A p → LPO A p wmp∧wlpo-Alt⇒lpo {a} {p} {A} wmp wlpo-Alt {P = P} P? with wlpo-Alt P? ... | inj₁ ¬∃P = inj₂ ¬∃P ... | inj₂ ¬¬∃P = inj₁ (wmp P? Lem.res) where module Lem {Q : A → Set p} (Q? : DecU Q) where R : A → Set p R x = P x × ¬ Q x R? : DecU R R? = DecU-× P? (¬-DecU Q?) ¬∃R⊎¬¬∃R : ¬ ∃ R ⊎ ¬ ¬ ∃ R ¬∃R⊎¬¬∃R = wlpo-Alt R? res : ¬ ¬ ∃ Q ⊎ (¬ ¬ ∃ λ x → P x × ¬ Q x) res = Sum.map₁ (λ ¬∃R ¬∃Q → ¬¬∃P (f ¬∃R ¬∃Q)) ¬∃R⊎¬¬∃R where f : ¬ ∃ R → ¬ ∃ Q → ¬ ∃ P f ¬∃R ¬∃Q (x , Px) = ¬∃R (x , (Px , ¬∃P→∀¬P ¬∃Q x)) -- direct proof of WLPO => MP⊎ wlpo-Alt⇒mp⊎ : ∀ {a p} {A : Set a} → WLPO-Alt A p → MP⊎ A p wlpo-Alt⇒mp⊎ wlpo-Alt P? Q? ¬[¬∃P׬∃Q] with wlpo-Alt P? | wlpo-Alt Q? ... | inj₁ ¬∃P | inj₁ ¬∃Q = ⊥-elim $ ¬[¬∃P׬∃Q] (¬∃P , ¬∃Q) ... | inj₁ ¬∃P | inj₂ ¬¬∃Q = inj₂ ¬¬∃Q ... | inj₂ ¬¬∃P | _ = inj₁ ¬¬∃P -- EM => KS em⇒ks : ∀ {a p} q {A : Set a} (x : A) → EM p → KS A p q em⇒ks q x em P with em {A = P} em⇒ks q x em P | inj₁ xP = (λ _ → Lift q ⊤) , (λ _ → inj₁ (lift tt)) , ((λ _ → x , lift tt) , (λ _ → xP)) em⇒ks q x em P | inj₂ ¬P = (λ _ → Lift q ⊥) , (λ _ → inj₂ lower) , ((λ xP → ⊥-elim $ ¬P xP) , (λ A×L⊥ → ⊥-elim $ lower $ proj₂ A×L⊥)) -- KS => PFP ks⇒pfp : ∀ {a p q} {A : Set a} → KS A (a ⊔ p) q → PFP A p q ks⇒pfp ks {P = P} P? = ks (∀ x → P x) -- PFP => WPFP pfp⇒wpfp : ∀ {a p q} {A : Set a} → PFP A p q → WPFP A p q pfp⇒wpfp pfp {P = P} P? with pfp P? ... | Q , Q? , ∀P→∃Q , ∃Q→∀P = (λ x → ¬ Q x) , (¬-DecU Q? , (f , g)) where f : (∀ x → P x) → ¬ (∀ x → ¬ Q x) f ∀P = ∃P→¬∀¬P (∀P→∃Q ∀P) g : (¬ (∀ x → ¬ Q x)) → ∀ x → P x g = P?⇒[∃Q→∀P]→¬∀¬Q→∀P P? ∃Q→∀P -- WLPO => PFP wlpo⇒pfp : ∀ {a p} q {A : Set a} → Inhabited A → WLPO A p → PFP A p q wlpo⇒pfp {p = p} q xA wlpo {P = P} P? with wlpo P? ... | inj₁ ∀P = (λ _ → Lift q ⊤) , (λ _ → inj₁ (lift tt)) , (f , g) where f : (∀ x → P x) → ∃ λ x → Lift q ⊤ f _ = xA , lift tt g : (∃ λ x → Lift q ⊤) → (∀ x → P x) g _ = ∀P ... | inj₂ ¬∀P = (λ _ → Lift q ⊥) , (λ _ → inj₂ lower) , f , g where f : (∀ x → P x) → ∃ (λ x → Lift q ⊥) f ∀P = ⊥-elim $ ¬∀P ∀P g : ∃ (λ x → Lift q ⊥) → ∀ x → P x g (x , L⊥) = ⊥-elim $ lower L⊥ -- WLPO => WPFP wlpo⇒wpfp : ∀ {a p} q {A : Set a} → Inhabited A → WLPO A p → WPFP A p q wlpo⇒wpfp q xA wlpo = pfp⇒wpfp (wlpo⇒pfp q xA wlpo) -- Proposition 6.2.3 [1] -- WPFP ∧ MP⊎-Alt => WLPO wpfp∧mp⊎-Alt⇒wlpo : ∀ {a p} {A : Set a} → WPFP A p p → MP⊎-Alt A p → WLPO A p wpfp∧mp⊎-Alt⇒wlpo wpfp mp⊎-Alt {P = P} P? with wpfp P? ... | Q , Q? , ∀P→¬∀Q , ¬∀Q→∀P = Sum.map₁ ¬∀Q→∀P (Sum.swap ¬∀P⊎¬∀Q) where ¬[∀P×∀Q] : ¬ ((∀ x → P x) × (∀ x → Q x)) ¬[∀P×∀Q] (∀P , ∀Q) = ∀P→¬∀Q ∀P ∀Q ¬∀P⊎¬∀Q : ¬ (∀ x → P x) ⊎ ¬ (∀ x → Q x) ¬∀P⊎¬∀Q = mp⊎-Alt P? Q? ¬[∀P×∀Q] -- WPFP ∧ LLPO-Alt => WLPO wpfp∧llpo-Alt⇒wlpo : ∀ {a p} {A : Set a} → WPFP A p p → LLPO-Alt A p → WLPO A p wpfp∧llpo-Alt⇒wlpo wpfp llpo-Alt {P = P} P? with wpfp P? ... | Q , Q? , ∀P→¬∀Q , ¬∀Q→∀P = Sum.map₂ (λ ∀Q ∀P → ∀P→¬∀Q ∀P ∀Q) ∀P⊎∀Q where ∀P⊎∀Q : (∀ x → P x) ⊎ (∀ x → Q x) ∀P⊎∀Q = llpo-Alt P? Q? (DN-map (Sum.swap ∘′ Sum.map₂ ¬∀Q→∀P) DN-Dec⊎) -- WPFP ∧ MR <=> LPO wpfp∧mr⇒lpo : ∀ {a p} {A : Set a} → WPFP A p p → MR A p → LPO A p wpfp∧mr⇒lpo wpfp mr = wlpo-Alt∧mr⇒lpo (wlpo⇒wlpo-Alt (wpfp∧mp⊎-Alt⇒wlpo wpfp (mp⊎⇒mp⊎-Alt (mp∨⇒mp⊎ (mr⇒mp∨ mr))))) mr -- Proposition 1.2.1.2 in [1] {- lpo⇒P1212 : ∀ {p} → LPO ℕ p → {P : ℕ → Set p} → DecU P → (∃ λ N → ∀ n → N ≤ n → ¬ P n) ⊎ (Σ (ℕ → ℕ) λ k → ∀ n → P (k n)) lpo⇒P1212 {p} lpo {P} P? = {! !} where R : ℕ → Set p R k = ∀ n → k ≤ n → ¬ P n -- use lpo R? : DecU R R? k = ? -} -- Searchable set -- Searchable <=> Inhabited ∧ LPO searchable⇒lpo : ∀ {a p} {A : Set a} → Searchable A p → LPO A p searchable⇒lpo searchable P? with searchable (¬-DecU P?) ... | x₀ , ¬Px₀→∀¬P = Sum.[ (λ Px₀ → inj₁ (x₀ , Px₀)) , (λ ¬Px₀ → inj₂ (∀¬P→¬∃P (¬Px₀→∀¬P ¬Px₀))) ]′ (P? x₀) searchable⇒inhabited : ∀ {a p} {A : Set a} → Searchable A p → Inhabited A searchable⇒inhabited {p = p} searchable = proj₁ (searchable {P = λ _ → Lift p ⊤} λ _ → inj₁ (lift tt)) inhabited∧lpo⇒searchable : ∀ {a p} {A : Set a} → Inhabited A → LPO A p → Searchable A p inhabited∧lpo⇒searchable inhabited lpo P? with lpo (¬-DecU P?) ... | inj₁ (x , ¬Px) = x , (λ Px → contradiction Px ¬Px) ... | inj₂ ¬∃¬P = inhabited , (λ _ → P?⇒¬∃¬P→∀P P? ¬∃¬P) -- [1] Hannes Diener "Constructive Reverse Mathematics" -- [2] Hajime lshihara "Markov’s principle, Church’s thesis and LindeUf’s theorem"
34.626923
88
0.443778
2e3ac8301d278f34f08820d90270c386b77aa02d
1,343
agda
Agda
src/Extensions/ListFirstFunctional.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
4
2019-04-05T17:57:11.000Z
2021-05-07T04:08:41.000Z
src/Extensions/ListFirstFunctional.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
src/Extensions/ListFirstFunctional.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
module Extensions.ListFirstFunctional where open import Prelude hiding (_⊔_) open import Level private lemma : ∀ {a b} {A : Set a} {P : A → Set b} (decP : ∀ a → (Dec $ P a)) v {x y} → any decP (x List.∷ v) ≡ yes (there {x = x} y) → ¬ P x lemma decP v {x} {y} eq p with decP x lemma decP v () p | yes _ lemma decP v eq p | no ¬p = ¬p p -- first is functionally defined as the element matched by 'any' First : ∀ {a b} {A : Set a} {P : A → Set b} (decP : ∀ a → (Dec $ P a)) → List A → Set (a ⊔ b) First f v = ∃ λ m → any f v ≡ yes m private There : ∀ {a b} {A : Set a} {P : A → Set b} {f v} → (f : First {P = P} f v) → Set There (here px , _) = ⊥ There (there _ , _) = ⊤ head-first : ∀ {a b} {A : Set a} {P : A → Set b} {f v} → First {P = P} f v → A head-first (here {x} _ , _) = x head-first (there {x} _ , _) = x -- we can recover the negative evidence even though Any does not "save it" for there-instances there⟶¬x' : ∀ {a b} {A : Set a} {P : A → Set b} {decP v} → (f : First {P = P} decP v) → {x : There f} → ¬ P (head-first f) there⟶¬x' (here px , proj₂) {x = ()} there⟶¬x' {P = P} {decP = decP} (there {x = x'} {xs = xs} tail , proj₂) px with lemma decP xs there⟶¬x' {P = P} {decP = decP} (there {x = x'} {xs = xs} tail , proj₂) px | ¬px = ¬px proj₂ px
41.96875
95
0.513031
31e459ca9abe5eb71cd4c842ac31f91cbcb963e3
399
agda
Agda
src/sets/nat/ordering/lt/level.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
20
2015-06-12T12:20:17.000Z
2022-02-01T11:25:54.000Z
src/sets/nat/ordering/lt/level.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T14:32:16.000Z
2016-10-26T11:57:26.000Z
src/sets/nat/ordering/lt/level.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T12:17:00.000Z
2019-05-04T19:31:00.000Z
{-# OPTIONS --without-K #-} module sets.nat.ordering.lt.level where open import sum open import equality.core open import hott.level.core open import hott.level.closure open import sets.nat.core open import sets.nat.ordering.lt.core open import sets.nat.ordering.leq.level open import sets.empty open import container.core open import container.w <-level : ∀ {m n} → h 1 (m < n) <-level = ≤-level
23.470588
39
0.75188
571f29542df1a855b804784faf8afe3cffbd5bbb
502
agda
Agda
agda-stdlib/src/Data/List/Kleene.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/List/Kleene.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/List/Kleene.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- An alternative definition of mutually-defined lists and non-empty -- lists, using the Kleene star and plus. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Kleene where ------------------------------------------------------------------------ -- Types and basic operations open import Data.List.Kleene.Base public
31.375
72
0.416335
13a21780132a4a0b943de2357f0fb9a265e9551c
1,194
agda
Agda
Cubical/Algebra/DirectSum/DirectSumFun/Base.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/DirectSum/DirectSumFun/Base.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/DirectSum/DirectSumFun/Base.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.DirectSum.DirectSumFun.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat renaming (_+_ to _+n_ ; _·_ to _·n_) open import Cubical.Data.Nat.Order open import Cubical.Data.Sigma open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.Algebra.AbGroup private variable ℓ : Level open AbGroupStr ----------------------------------------------------------------------------- -- Definition AlmostNullProof : (G : ℕ → Type ℓ) → (Gstr : (n : ℕ) → AbGroupStr (G n)) → (f : (n : ℕ) → G n) → (k : ℕ) → Type ℓ AlmostNullProof G Gstr f k = (n : ℕ) → k < n → f n ≡ 0g (Gstr n) AlmostNull : (G : ℕ → Type ℓ) → (Gstr : (n : ℕ) → AbGroupStr (G n)) → (f : (n : ℕ) → G n) → Type ℓ AlmostNull G Gstr f = Σ[ k ∈ ℕ ] AlmostNullProof G Gstr f k AlmostNullP : (G : ℕ → Type ℓ) → (Gstr : (n : ℕ) → AbGroupStr (G n)) → (f : (n : ℕ) → G n) → Type ℓ AlmostNullP G Gstr f = ∥ (AlmostNull G Gstr f) ∥₁ ⊕Fun : (G : ℕ → Type ℓ) → (Gstr : (n : ℕ) → AbGroupStr (G n)) → Type ℓ ⊕Fun G Gstr = Σ[ f ∈ ((n : ℕ) → G n) ] AlmostNullP G Gstr f
32.27027
77
0.563652
1e8f959b01a69f9a59a9c23c0cc451fd257139b7
1,001
agda
Agda
agda-stdlib/src/Data/Vec/Membership/Propositional.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/Vec/Membership/Propositional.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/Vec/Membership/Propositional.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- Data.Vec.Any.Membership instantiated with propositional equality, -- along with some additional definitions. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Membership.Propositional {a} {A : Set a} where open import Data.Vec.Base using (Vec) open import Data.Vec.Relation.Unary.Any using (Any) open import Relation.Binary.PropositionalEquality using (setoid; subst) import Data.Vec.Membership.Setoid as SetoidMembership ------------------------------------------------------------------------ -- Re-export contents of setoid membership open SetoidMembership (setoid A) public hiding (lose) ------------------------------------------------------------------------ -- Other operations lose : ∀ {p} {P : A → Set p} {x n} {xs : Vec A n} → x ∈ xs → P x → Any P xs lose = SetoidMembership.lose (setoid A) (subst _)
35.75
75
0.516484
2ff86ab0b2115c4e7d15e3a0c47f99fd3c51c488
899
agda
Agda
Setoids/Functions/Lemmas.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
4
2019-08-08T12:44:19.000Z
2022-01-28T06:04:15.000Z
Setoids/Functions/Lemmas.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
14
2019-01-06T21:11:59.000Z
2020-04-11T11:03:39.000Z
Setoids/Functions/Lemmas.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
1
2021-11-29T13:23:07.000Z
2021-11-29T13:23:07.000Z
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Setoids.Setoids open import Setoids.Subset open import Setoids.Functions.Definition open import Sets.EquivalenceRelations module Setoids.Functions.Lemmas {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {f : A → B} (w : WellDefined S T f) where inverseImagePred : {e : _} → {pred : B → Set e} → (sub : subset T pred) → A → Set (b ⊔ d ⊔ e) inverseImagePred {pred = pred} subset a = Sg B (λ b → (pred b) && (Setoid._∼_ T (f a) b)) inverseImageWellDefined : {e : _} {pred : B → Set e} → (sub : subset T pred) → subset S (inverseImagePred sub) inverseImageWellDefined sub {x} {y} x=y (b , (predB ,, fx=b)) = f x , (sub (symmetric fx=b) predB ,, symmetric (w x=y)) where open Setoid T open Equivalence eq
44.95
157
0.649611
3d17c16ff7d4b02453742d2fb6e541d145a740ba
865
agda
Agda
unused/EffectUtil.agda
Zalastax/singly-typed-actors
ae541df13d069df4eb1464f29fbaa9804aad439f
[ "MIT" ]
1
2019-10-29T09:30:26.000Z
2019-10-29T09:30:26.000Z
unused/EffectUtil.agda
Zalastax/singly-typed-actors
ae541df13d069df4eb1464f29fbaa9804aad439f
[ "MIT" ]
null
null
null
unused/EffectUtil.agda
Zalastax/singly-typed-actors
ae541df13d069df4eb1464f29fbaa9804aad439f
[ "MIT" ]
null
null
null
module EffectUtil where open import Data.List open import Data.List.All open import Data.List.Any open import Level open import Relation.Binary.PropositionalEquality hiding ([_]) open import Function open import Category.Monad open import Data.Product -- open import EffectUtil open import Membership-equality hiding (_⊆_; set) infix 3 _⊆_ -- Sublist without re-ordering, to be improved later... data _⊆_ {a}{A : Set a} : List A → List A → Set a where [] : ∀ {ys} → [] ⊆ ys keep : ∀ {x xs ys} → xs ⊆ ys → x ∷ xs ⊆ x ∷ ys skip : ∀ {x xs ys} → xs ⊆ ys → xs ⊆ x ∷ ys singleton-⊆ : ∀ {a} {A : Set a} {x : A} {xs : List A} → x ∈ xs → [ x ] ⊆ xs singleton-⊆ (here refl) = keep [] singleton-⊆ (there mem) = skip (singleton-⊆ mem) reflexive-⊆ : ∀ {a} {A : Set a} {xs : List A} → xs ⊆ xs reflexive-⊆ {xs = []} = [] reflexive-⊆ {xs = x ∷ xs} = keep reflexive-⊆
28.833333
75
0.621965
9a5451a0b8e69df0a43021905385f478782367eb
5,050
agda
Agda
Cubical/HITs/Ints/BiInvInt/Properties.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/HITs/Ints/BiInvInt/Properties.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
Cubical/HITs/Ints/BiInvInt/Properties.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Ints.BiInvInt.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Nat hiding (_+_; +-comm) open import Cubical.Data.Int open import Cubical.Data.Bool open import Cubical.HITs.Ints.BiInvInt.Base -- addition _+ᴮ_ : BiInvInt → BiInvInt → BiInvInt m +ᴮ zero = m m +ᴮ suc n = suc (m +ᴮ n) m +ᴮ predr n = predr (m +ᴮ n) m +ᴮ predl n = predl (m +ᴮ n) m +ᴮ suc-predr n i = suc-predr (m +ᴮ n) i m +ᴮ predl-suc n i = predl-suc (m +ᴮ n) i -- properties of addition +ᴮ-assoc : ∀ l m n → (l +ᴮ m) +ᴮ n ≡ l +ᴮ (m +ᴮ n) +ᴮ-assoc l m zero i = l +ᴮ m +ᴮ-assoc l m (suc n) i = suc (+ᴮ-assoc l m n i) +ᴮ-assoc l m (predr n) i = predr (+ᴮ-assoc l m n i) +ᴮ-assoc l m (predl n) i = predl (+ᴮ-assoc l m n i) +ᴮ-assoc l m (suc-predr n i) j = suc-predr (+ᴮ-assoc l m n j) i +ᴮ-assoc l m (predl-suc n i) j = predl-suc (+ᴮ-assoc l m n j) i +ᴮ-unitʳ : ∀ n → n +ᴮ zero ≡ n +ᴮ-unitʳ n i = n +ᴮ-unitˡ : ∀ n → zero +ᴮ n ≡ n +ᴮ-unitˡ zero i = zero +ᴮ-unitˡ (suc n) i = suc (+ᴮ-unitˡ n i) +ᴮ-unitˡ (predr n) i = predr (+ᴮ-unitˡ n i) +ᴮ-unitˡ (predl n) i = predl (+ᴮ-unitˡ n i) +ᴮ-unitˡ (suc-predr n i) j = suc-predr (+ᴮ-unitˡ n j) i +ᴮ-unitˡ (predl-suc n i) j = predl-suc (+ᴮ-unitˡ n j) i -- TODO: a direct proof of commutatitivty -- (for now, we use Data.Int) fwd-+≡+ᴮ : ∀ m n → fwd (m + n) ≡ (fwd m) +ᴮ (fwd n) fwd-+≡+ᴮ m (pos zero) = refl fwd-+≡+ᴮ m (pos (suc n)) = fwd-sucInt (m +pos n) ∙ cong suc (fwd-+≡+ᴮ m (pos n)) fwd-+≡+ᴮ m (negsuc zero) = fwd-predInt m fwd-+≡+ᴮ m (negsuc (suc n)) = fwd-predInt (m +negsuc n) ∙ cong pred (fwd-+≡+ᴮ m (negsuc n)) +ᴮ≡+ : ∀ m n → m +ᴮ n ≡ fwd ((bwd m) + (bwd n)) +ᴮ≡+ m n = sym (fwd-+≡+ᴮ (bwd m) (bwd n) ∙ (λ i → (fwd-bwd m i) +ᴮ (fwd-bwd n i))) +ᴮ-comm : ∀ m n → m +ᴮ n ≡ n +ᴮ m +ᴮ-comm m n = +ᴮ≡+ m n ∙ cong fwd (+-comm (bwd m) (bwd n)) ∙ sym (+ᴮ≡+ n m) -- some of the lemmas needed for a direct proof +ᴮ-comm are corollaries of +ᴮ-comm suc-+ᴮ : ∀ m n → (suc m) +ᴮ n ≡ suc (m +ᴮ n) suc-+ᴮ m n = +ᴮ-comm (suc m) n ∙ (λ i → suc (+ᴮ-comm n m i)) -- suc-+ᴮ m zero i = suc m -- suc-+ᴮ m (suc n) i = suc (suc-+ᴮ m n i) -- suc-+ᴮ m (predr n) = cong predr (suc-+ᴮ m n) ∙ predr-suc (m +ᴮ n) ∙ sym (suc-predr (m +ᴮ n)) -- suc-+ᴮ m (predl n) = cong predl (suc-+ᴮ m n) ∙ predl-suc (m +ᴮ n) ∙ sym (suc-predl (m +ᴮ n)) -- suc-+ᴮ m (suc-predr n i) j = {!!} -- suc-+ᴮ m (predl-suc n i) j = {!!} predr-+ᴮ : ∀ m n → (predr m) +ᴮ n ≡ predr (m +ᴮ n) predr-+ᴮ m n = +ᴮ-comm (predr m) n ∙ (λ i → predr (+ᴮ-comm n m i)) predl-+ᴮ : ∀ m n → (predl m) +ᴮ n ≡ predl (m +ᴮ n) predl-+ᴮ m n = +ᴮ-comm (predl m) n ∙ (λ i → predl (+ᴮ-comm n m i)) -- +ᴮ-comm : ∀ m n → n +ᴮ m ≡ m +ᴮ n -- +ᴮ-comm m zero = +ᴮ-unitˡ m -- +ᴮ-comm m (suc n) = suc-+ᴮ n m ∙ cong suc (+ᴮ-comm m n) -- +ᴮ-comm m (predr n) = predr-+ᴮ n m ∙ cong predr (+ᴮ-comm m n) -- +ᴮ-comm m (predl n) = predl-+ᴮ n m ∙ cong predl (+ᴮ-comm m n) -- +ᴮ-comm m (suc-predr n i) j = {!!} -- +ᴮ-comm m (predl-suc n i) j = {!!} -- negation / subtraction -ᴮ_ : BiInvInt → BiInvInt -ᴮ zero = zero -ᴮ suc n = predl (-ᴮ n) -ᴮ predr n = suc (-ᴮ n) -ᴮ predl n = suc (-ᴮ n) -ᴮ suc-predr n i = predl-suc (-ᴮ n) i -ᴮ predl-suc n i = suc-predl (-ᴮ n) i _-ᴮ_ : BiInvInt → BiInvInt → BiInvInt m -ᴮ n = m +ᴮ (-ᴮ n) -- TODO: properties of negation -- +ᴮ-invˡ : ∀ n → (-ᴮ n) +ᴮ n ≡ zero -- +ᴮ-invˡ zero = refl -- +ᴮ-invˡ (suc n) = (λ i → suc (predl-+ᴮ (-ᴮ n) n i)) ∙ (λ i → suc-pred (+ᴮ-invˡ n i) i) -- +ᴮ-invˡ (predr n) = (λ i → predr (suc-+ᴮ (-ᴮ n) n i)) ∙ (λ i → predr-suc (+ᴮ-invˡ n i) i) -- +ᴮ-invˡ (predl n) = (λ i → predl (suc-+ᴮ (-ᴮ n) n i)) ∙ (λ i → predl-suc (+ᴮ-invˡ n i) i) -- +ᴮ-invˡ (suc-predr n i) j = {!!} -- +ᴮ-invˡ (predl-suc n i) j = {!!} -- +ᴮ-invʳ : ∀ n → n +ᴮ (-ᴮ n) ≡ zero -- +ᴮ-invʳ n = {!!} -- natural injections from ℕ posᴮ : ℕ → BiInvInt posᴮ zero = zero posᴮ (suc n) = suc (posᴮ n) negᴮ : ℕ → BiInvInt negᴮ zero = zero negᴮ (suc n) = pred (negᴮ n) -- absolute value and sign -- (Note that there doesn't appear to be any way around using -- bwd here! Any direct proof ends up doing the same work...) absᴮ : BiInvInt → ℕ absᴮ n = abs (bwd n) sgnᴮ : BiInvInt → Bool sgnᴮ n = sgn (bwd n) -- TODO: a direct definition of multiplication using +ᴮ-invˡ/ʳ -- (for now we use abs and sgn, as in agda's stdlib) _*ᴮ_ : BiInvInt → BiInvInt → BiInvInt m *ᴮ n = caseBool posᴮ negᴮ (sgnᴮ m and sgnᴮ n) (absᴮ m * absᴮ n) -- m *ᴮ zero = zero -- m *ᴮ suc n = (m *ᴮ n) +ᴮ m -- m *ᴮ predr n = (m *ᴮ n) -ᴮ m -- m *ᴮ predl n = (m *ᴮ n) -ᴮ m -- m *ᴮ suc-predr n i = ( +ᴮ-assoc (m *ᴮ n) (-ᴮ m) m -- ∙ cong ((m *ᴮ n) +ᴮ_) (+ᴮ-invˡ m) -- ∙ +ᴮ-unitʳ (m *ᴮ n)) i -- m *ᴮ predl-suc n i = ( +ᴮ-assoc (m *ᴮ n) m (-ᴮ m) -- ∙ cong ((m *ᴮ n) +ᴮ_) (+ᴮ-invʳ m) -- ∙ +ᴮ-unitʳ (m *ᴮ n)) i
33.892617
100
0.51901
2ecbe5323a80add6bb68aeff5884e41ba7dee25d
748
agda
Agda
Graph/Walk.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Graph/Walk.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Graph/Walk.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
open import Type module Graph.Walk {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where import Lvl open import Graph{ℓ₁}{ℓ₂}(V) import Structure.Relator.Names as Names module _ (_⟶_ : Graph) where -- A path is matching directed edges connected to each other in a finite sequence. -- This is essentially a list of edges where the ends match. -- The terminology is that a walk is a sequence of connected edges and it visits all its vertices. -- Note: Walk is a generalized "List" for categories instead of the usual List which is for monoids. -- Note: Walk is equivalent to the reflexive-transitive closure. data Walk : V → V → Type{ℓ₁ Lvl.⊔ ℓ₂} where at : Names.Reflexivity(Walk) prepend : ∀{a b c} → (a ⟶ b) → (Walk b c) → (Walk a c)
41.555556
102
0.688503
addd4fb3dbbcd06ab42b4154900c3a6b064e7dad
711
agda
Agda
Cubical/Algebra/AbGroup/Instances/Unit.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/AbGroup/Instances/Unit.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/AbGroup/Instances/Unit.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.AbGroup.Instances.Unit where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Unit renaming (Unit* to UnitType) open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Group.Instances.Unit using (UnitGroup) open import Cubical.Algebra.Group.Base using (GroupStr) private variable ℓ : Level open AbGroupStr open IsAbGroup UnitAbGroup : AbGroup ℓ fst UnitAbGroup = UnitType 0g (snd UnitAbGroup) = tt* _+_ (snd UnitAbGroup) = λ _ _ → tt* - snd UnitAbGroup = λ _ → tt* isGroup (isAbGroup (snd UnitAbGroup)) = GroupStr.isGroup (snd UnitGroup) +Comm (isAbGroup (snd UnitAbGroup)) = λ _ _ → refl
26.333333
72
0.763713
59d3773fc633d117360040174f707dd4fcc17349
216
agda
Agda
TypeTheory/HoTT/Data/Empty/Properties.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
3
2020-04-07T17:49:42.000Z
2020-04-21T00:03:43.000Z
TypeTheory/HoTT/Data/Empty/Properties.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
TypeTheory/HoTT/Data/Empty/Properties.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} module TypeTheory.HoTT.Data.Empty.Properties where -- agda-stdlib open import Data.Empty -- agda-misc open import TypeTheory.HoTT.Base isProp-⊥ : isProp ⊥ isProp-⊥ x = ⊥-elim x
16.615385
50
0.703704
1e12795a1de1b23355a346ad926a900d1c06a654
10,211
agda
Agda
formalization/agda/Spire/Examples/PropositionalLevDesc.agda
spire/spire
3d67f137ee9423b7e6f8593634583998cd692353
[ "BSD-3-Clause" ]
43
2015-05-28T23:25:33.000Z
2022-03-08T17:10:59.000Z
formalization/agda/Spire/Examples/PropositionalLevDesc.agda
spire/spire
3d67f137ee9423b7e6f8593634583998cd692353
[ "BSD-3-Clause" ]
null
null
null
formalization/agda/Spire/Examples/PropositionalLevDesc.agda
spire/spire
3d67f137ee9423b7e6f8593634583998cd692353
[ "BSD-3-Clause" ]
1
2015-08-17T21:00:07.000Z
2015-08-17T21:00:07.000Z
{-# OPTIONS --type-in-type #-} open import Data.Unit open import Data.Product hiding ( curry ; uncurry ) open import Data.List hiding ( concat ) open import Data.String open import Relation.Binary.PropositionalEquality module Spire.Examples.PropositionalLevDesc where ---------------------------------------------------------------------- Label : Set Label = String Enum : Set Enum = List Label data Tag : Enum → Set where here : ∀{l E} → Tag (l ∷ E) there : ∀{l E} → Tag E → Tag (l ∷ E) Cases : (E : Enum) (P : Tag E → Set) → Set Cases [] P = ⊤ Cases (l ∷ E) P = P here × Cases E λ t → P (there t) case : (E : Enum) (P : Tag E → Set) (cs : Cases E P) (t : Tag E) → P t case (l ∷ E) P (c , cs) here = c case (l ∷ E) P (c , cs) (there t) = case E (λ t → P (there t)) cs t UncurriedCases : (E : Enum) (P : Tag E → Set) (X : Set) → Set UncurriedCases E P X = Cases E P → X CurriedCases : (E : Enum) (P : Tag E → Set) (X : Set) → Set CurriedCases [] P X = X CurriedCases (l ∷ E) P X = P here → CurriedCases E (λ t → P (there t)) X curryCases : (E : Enum) (P : Tag E → Set) (X : Set) (f : UncurriedCases E P X) → CurriedCases E P X curryCases [] P X f = f tt curryCases (l ∷ E) P X f = λ c → curryCases E (λ t → P (there t)) X (λ cs → f (c , cs)) uncurryCases : (E : Enum) (P : Tag E → Set) (X : Set) (f : CurriedCases E P X) → UncurriedCases E P X uncurryCases [] P X x tt = x uncurryCases (l ∷ E) P X f (c , cs) = uncurryCases E (λ t → P (there t)) X (f c) cs ---------------------------------------------------------------------- data Desc (I : Set) : Set₁ where `End : (i : I) → Desc I `Rec : (i : I) (D : Desc I) → Desc I `Arg : (A : Set) (B : A → Desc I) → Desc I `RecFun : (A : Set) (B : A → I) (D : Desc I) → Desc I ISet : Set → Set₁ ISet I = I → Set El : (I : Set) (D : Desc I) (X : ISet I) → ISet I El I (`End j) X i = j ≡ i El I (`Rec j D) X i = X j × El I D X i El I (`Arg A B) X i = Σ A (λ a → El I (B a) X i) El I (`RecFun A B D) X i = ((a : A) → X (B a)) × El I D X i Hyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (i : I) (xs : El I D X i) → Set Hyps I (`End j) X P i q = ⊤ Hyps I (`Rec j D) X P i (x , xs) = P j x × Hyps I D X P i xs Hyps I (`Arg A B) X P i (a , b) = Hyps I (B a) X P i b Hyps I (`RecFun A B D) X P i (f , xs) = ((a : A) → P (B a) (f a)) × Hyps I D X P i xs ---------------------------------------------------------------------- TagDesc : (I : Set) → Set TagDesc I = Σ Enum (λ E → Cases E (λ _ → Desc I)) toCase : (I : Set) (E,cs : TagDesc I) → Tag (proj₁ E,cs) → Desc I toCase I (E , cs) = case E (λ _ → Desc I) cs toDesc : (I : Set) → TagDesc I → Desc I toDesc I (E , cs) = `Arg (Tag E) (toCase I (E , cs)) ---------------------------------------------------------------------- UncurriedEl : (I : Set) (D : Desc I) (X : ISet I) → Set UncurriedEl I D X = {i : I} → El I D X i → X i CurriedEl : (I : Set) (D : Desc I) (X : ISet I) → Set CurriedEl I (`End i) X = X i CurriedEl I (`Rec j D) X = (x : X j) → CurriedEl I D X CurriedEl I (`Arg A B) X = (a : A) → CurriedEl I (B a) X CurriedEl I (`RecFun A B D) X = ((a : A) → X (B a)) → CurriedEl I D X curryEl : (I : Set) (D : Desc I) (X : ISet I) (cn : UncurriedEl I D X) → CurriedEl I D X curryEl I (`End i) X cn = cn refl curryEl I (`Rec i D) X cn = λ x → curryEl I D X (λ xs → cn (x , xs)) curryEl I (`Arg A B) X cn = λ a → curryEl I (B a) X (λ xs → cn (a , xs)) curryEl I (`RecFun A B D) X cn = λ f → curryEl I D X (λ xs → cn (f , xs)) uncurryEl : (I : Set) (D : Desc I) (X : ISet I) (cn : CurriedEl I D X) → UncurriedEl I D X uncurryEl I (`End i) X cn refl = cn uncurryEl I (`Rec i D) X cn (x , xs) = uncurryEl I D X (cn x) xs uncurryEl I (`Arg A B) X cn (a , xs) = uncurryEl I (B a) X (cn a) xs uncurryEl I (`RecFun A B D) X cn (f , xs) = uncurryEl I D X (cn f) xs ---------------------------------------------------------------------- CasesD : (I : Set) (E : Enum) → Set CasesD I E = Cases E (λ _ → Desc I) Args : (I : Set) (E : Enum) (t : Tag E) (cs : CasesD I E) → Desc I Args I E t cs = case E (λ _ → Desc I) cs t ---------------------------------------------------------------------- data μ (I : Set) (E : Enum) (cs : CasesD I E) : I → Set where con : (t : Tag E) → UncurriedEl I (Args I E t cs) (μ I E cs) con2 : (I : Set) (E : Enum) (cs : CasesD I E) (t : Tag E) → CurriedEl I (Args I E t cs) (μ I E cs) con2 I E cs t = curryEl I (Args I E t cs) (μ I E cs) (con t) ---------------------------------------------------------------------- UncurriedHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : {i : I} → El I D X i → X i) → Set UncurriedHyps I D X P cn = (i : I) (xs : El I D X i) → Hyps I D X P i xs → P i (cn xs) CurriedHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl I D X) → Set CurriedHyps I (`End i) X P cn = P i (cn refl) CurriedHyps I (`Rec i D) X P cn = (x : X i) → P i x → CurriedHyps I D X P (λ xs → cn (x , xs)) CurriedHyps I (`Arg A B) X P cn = (a : A) → CurriedHyps I (B a) X P (λ xs → cn (a , xs)) CurriedHyps I (`RecFun A B D) X P cn = (f : (a : A) → X (B a)) (ihf : (a : A) → P (B a) (f a)) → CurriedHyps I D X P (λ xs → cn (f , xs)) curryHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl I D X) (pf : UncurriedHyps I D X P cn) → CurriedHyps I D X P cn curryHyps I (`End i) X P cn pf = pf i refl tt curryHyps I (`Rec i D) X P cn pf = λ x ih → curryHyps I D X P (λ xs → cn (x , xs)) (λ i xs ihs → pf i (x , xs) (ih , ihs)) curryHyps I (`Arg A B) X P cn pf = λ a → curryHyps I (B a) X P (λ xs → cn (a , xs)) (λ i xs ihs → pf i (a , xs) ihs) curryHyps I (`RecFun A B D) X P cn pf = λ f ihf → curryHyps I D X P (λ xs → cn (f , xs)) (λ i xs ihs → pf i (f , xs) (ihf , ihs)) uncurryHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl I D X) (pf : CurriedHyps I D X P cn) → UncurriedHyps I D X P cn uncurryHyps I (`End .i) X P cn pf i refl tt = pf uncurryHyps I (`Rec j D) X P cn pf i (x , xs) (ih , ihs) = uncurryHyps I D X P (λ ys → cn (x , ys)) (pf x ih) i xs ihs uncurryHyps I (`Arg A B) X P cn pf i (a , xs) ihs = uncurryHyps I (B a) X P (λ ys → cn (a , ys)) (pf a) i xs ihs uncurryHyps I (`RecFun A B D) X P cn pf i (f , xs) (ihf , ihs) = uncurryHyps I D X P (λ ys → cn (f , ys)) (pf f ihf) i xs ihs ---------------------------------------------------------------------- ind : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) (pcon : (t : Tag E) → UncurriedHyps I (Args I E t cs) (μ I E cs) P (con t)) (i : I) (x : μ I E cs i) → P i x hyps : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) (pcon : (t : Tag E) → UncurriedHyps I (Args I E t cs) (μ I E cs) P (con t)) (D : Desc I) (i : I) (xs : El I D (μ I E cs) i) → Hyps I D (μ I E cs) P i xs ind I E cs P pcon i (con t as) = pcon t i as (hyps I E cs P pcon (Args I E t cs) i as) hyps I E cs P pcon (`End j) i q = tt hyps I E cs P pcon (`Rec j A) i (x , xs) = ind I E cs P pcon j x , hyps I E cs P pcon A i xs hyps I E cs P pcon (`Arg A B) i (a , b) = hyps I E cs P pcon (B a) i b hyps I E cs P pcon (`RecFun A B D) i (f , xs) = (λ a → ind I E cs P pcon (B a) (f a)) , hyps I E cs P pcon D i xs ---------------------------------------------------------------------- ind2 : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) (pcon : (t : Tag E) → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t)) (i : I) (x : μ I E cs i) → P i x ind2 I E cs P pcon i x = ind I E cs P (λ t → uncurryHyps I (Args I E t cs) (μ I E cs) P (con t) (pcon t)) i x elim : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) → let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) X = (i : I) (x : μ I E cs i) → P i x in UncurriedCases E Q X elim I E cs P ds i x = let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) in ind2 I E cs P (case E Q ds) i x elim2 : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) → let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) X = (i : I) (x : μ I E cs i) → P i x in CurriedCases E Q X elim2 I E cs P = let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) X = (i : I) (x : μ I E cs i) → P i x in curryCases E Q X (elim I E cs P) ---------------------------------------------------------------------- ℕT : Enum ℕT = "zero" ∷ "suc" ∷ [] VecT : Enum VecT = "nil" ∷ "cons" ∷ [] ℕD : CasesD ⊤ ℕT ℕD = `End tt , `Rec tt (`End tt) , tt ℕ : ⊤ → Set ℕ = μ ⊤ ℕT ℕD zero : ℕ tt zero = con here refl suc : ℕ tt → ℕ tt suc n = con (there here) (n , refl) zero2 : ℕ tt zero2 = con2 ⊤ ℕT ℕD here suc2 : ℕ tt → ℕ tt suc2 = con2 ⊤ ℕT ℕD (there here) VecD : (A : Set) → CasesD (ℕ tt) VecT VecD A = `End zero , `Arg (ℕ tt) (λ n → `Arg A λ _ → `Rec n (`End (suc n))) , tt Vec : (A : Set) (n : ℕ tt) → Set Vec A n = μ (ℕ tt) VecT (VecD A) n nil : (A : Set) → Vec A zero nil A = con here refl cons : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n) cons A n x xs = con (there here) (n , x , xs , refl) nil2 : (A : Set) → Vec A zero nil2 A = con2 (ℕ tt) VecT (VecD A) here cons2 : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n) cons2 A = con2 (ℕ tt) VecT (VecD A) (there here) ---------------------------------------------------------------------- module GenericEliminator where add : ℕ tt → ℕ tt → ℕ tt add = elim2 ⊤ ℕT ℕD _ (λ n → n) (λ m ih n → suc (ih n)) tt mult : ℕ tt → ℕ tt → ℕ tt mult = elim2 ⊤ ℕT ℕD _ (λ n → zero) (λ m ih n → add n (ih n)) tt append : (A : Set) (m : ℕ tt) (xs : Vec A m) (n : ℕ tt) (ys : Vec A n) → Vec A (add m n) append A = elim2 (ℕ tt) VecT (VecD A) _ (λ n ys → ys) (λ m x xs ih n ys → cons A (add m n) x (ih n ys)) concat : (A : Set) (m n : ℕ tt) (xss : Vec (Vec A m) n) → Vec A (mult n m) concat A m = elim2 (ℕ tt) VecT (VecD (Vec A m)) _ (nil A) (λ n xs xss ih → append A m xs (mult n m) ih) ----------------------------------------------------------------------
31.613003
113
0.475468
31460d818940fda73e0dd65baffce182a8ebab63
337
agda
Agda
test/Succeed/LevelMetaLeqZero.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/LevelMetaLeqZero.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/LevelMetaLeqZero.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2016-09-28, solve _ <= lzero. -- {-# OPTIONS -v tc.conv.nat:40 #-} open import Common.Level data C : Set₁ where c : Set _ → C -- This meta should be solved to lzero. -- ERROR WAS: -- Failed to solve the following constraints: -- [0] lsuc _0 =< lsuc lzero -- REASON: -- Non-canonical lzero in level constraint solver
22.466667
56
0.655786
38c116a2d7b253dbe09365e987de665dc8145e6c
4,820
agda
Agda
examples/GUIgeneric/GUIModel.agda
stephanadls/state-dependent-gui
2bc84cb14a568b560acb546c440cbe0ddcbb2a01
[ "MIT" ]
2
2020-07-31T15:37:39.000Z
2020-07-31T17:20:59.000Z
examples/GUIgeneric/GUIModel.agda
stephanadls/state-dependent-gui
2bc84cb14a568b560acb546c440cbe0ddcbb2a01
[ "MIT" ]
null
null
null
examples/GUIgeneric/GUIModel.agda
stephanadls/state-dependent-gui
2bc84cb14a568b560acb546c440cbe0ddcbb2a01
[ "MIT" ]
null
null
null
module GUIgeneric.GUIModel where open import GUIgeneric.Prelude renaming (inj₁ to secondButton; inj₂ to firstButton; WxColor to Color) hiding (IOInterfaceˢ) open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) --; ComponentEls to Frame) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib open import StateSizedIO.writingOOsUsingIOVers4ReaderMethods open import StateSizedIO.Base open import GUIgeneric.GUIExample -- hiding (HandlerGUIObject) open IOInterfaceˢ public open import Data.Product -- How many trivial io commands such as putStrLn are ignored in the model skippedIOcmds : ℕ skippedIOcmds = 2 data MethodStarted (f : Frame) (prop : properties f) (obj : HandlerObject ∞ f) : Set where notStarted : MethodStarted f prop obj started : (m : methodsG f) (pr : IO' GuiLev1Interface ∞ StateAndGuiObj) → MethodStarted f prop obj data ModelGuiState : Set where state : (f : Frame) (prop : properties f) (obj : HandlerObject ∞ f) (m : MethodStarted f prop obj) → ModelGuiState modelGuiCommand : (s : ModelGuiState) → Set modelGuiCommand (state g prop obj notStarted) = methodsG g modelGuiCommand (state g prop obj (started m (do' c f))) = GuiLev1Response c modelGuiCommand (state g prop obj (started m (return' a))) = ⊤ -- modelGuiResponse : Set -- modelGuiResponse = ⊤ handlerReturnTypeToStateAndGuiObj : (g : Frame) (prop : properties g) (obj : HandlerObject ∞ g) (res : Σ[ r ∈ returnType g ] IOObjectˢ GuiLev1Interface handlerInterface ∞ (nextStateFrame g r)) → StateAndGuiObj handlerReturnTypeToStateAndGuiObj g prop obj (noChange , obj') = g , prop , obj' handlerReturnTypeToStateAndGuiObj g prop obj (changedAttributes prop' , obj') = g , prop' , obj' handlerReturnTypeToStateAndGuiObj g prop obj (changedGUI g' prop' , obj') = g' , prop' , obj' modelGuiNextProgramStarted : (g : Frame) (prop : properties g) (obj : HandlerObject ∞ g) (m : methodsG g) → IO GuiLev1Interface ∞ StateAndGuiObj modelGuiNextProgramStarted g prop obj m = fmap ∞ (handlerReturnTypeToStateAndGuiObj g prop obj ) (obj .method m) modelGuiNextProgramStarted' : (g : Frame) (prop : properties g) (obj : HandlerObject ∞ g) (m : methodsG g) → IO' GuiLev1Interface ∞ StateAndGuiObj modelGuiNextProgramStarted' s prop obj m = force (modelGuiNextProgramStarted s prop obj m) modelGuiNextaux : (g : Frame)(prop : properties g)(obj : HandlerObject ∞ g) (m : methodsG g)(pr : IO' GuiLev1Interface ∞ StateAndGuiObj) (skippedCms : ℕ) → ModelGuiState modelGuiNextaux g prop obj m (do' (putStrLn s) f) (suc n) = modelGuiNextaux g prop obj m (force (f _)) n modelGuiNextaux g prop obj m (do' c' f) n = state g prop obj (started m (do' c' f)) modelGuiNextaux g prop obj m (return' (gNew , propNew , objNew)) n = state gNew propNew objNew notStarted modelGuiNext : (s : ModelGuiState) (c : modelGuiCommand s) → ModelGuiState modelGuiNext (state g prop obj notStarted) m = modelGuiNextaux g prop obj m (modelGuiNextProgramStarted' g prop obj m) skippedIOcmds modelGuiNext (state g prop obj (started m (do' c' f))) c = modelGuiNextaux g prop obj m (force (f c)) skippedIOcmds modelGuiNext (state g prop obj (started m (return' (gNew , propNew , objNew)))) c = state gNew propNew objNew notStarted modelGuiInterface : IOInterfaceˢ IOStateˢ modelGuiInterface = ModelGuiState Commandˢ modelGuiInterface = modelGuiCommand Responseˢ modelGuiInterface s m = ⊤ IOnextˢ modelGuiInterface s m r = modelGuiNext s m _-gui->_ : (s s' : ModelGuiState ) → Set s -gui-> s' = IOˢindₚ modelGuiInterface ⊤ s s' data _-gui->¹_ (s : ModelGuiState ) : (s' : ModelGuiState)→ Set where step : (c : modelGuiCommand s) → s -gui->¹ modelGuiNext s c nextGui : (s : ModelGuiState)(c : modelGuiCommand s) → ModelGuiState nextGui s c = modelGuiNext s c modelToIOprog : (s : ModelGuiState) → Maybe (IO' GuiLev1Interface ∞ StateAndGuiObj) modelToIOprog (state g prop obj notStarted) = nothing modelToIOprog (state g prop obj (started s pr)) = just pr nextGuiProg : (s : ModelGuiState)(c : modelGuiCommand s) → Maybe (IO' GuiLev1Interface ∞ StateAndGuiObj) nextGuiProg s c = modelToIOprog (nextGui s c)
39.186992
123
0.634855
13d249f7b3d88fbadd843df4df4ae2b5cae1fba8
35
agda
Agda
test/Fail/Issue5781a.agda
sseefried/agda
6b13364d36eeb60d8ec15eaf8effe23c73401900
[ "BSD-2-Clause" ]
1
2022-03-05T00:25:14.000Z
2022-03-05T00:25:14.000Z
test/Fail/Issue5781a.agda
SNU-2D/agda
b5b3b1657556f720a7310cb7744edb1fac71eaf4
[ "BSD-2-Clause" ]
6
2021-10-18T08:12:24.000Z
2021-11-24T08:31:10.000Z
test/Fail/Issue5781a.agda
SNU-2D/agda
b5b3b1657556f720a7310cb7744edb1fac71eaf4
[ "BSD-2-Clause" ]
null
null
null
{-# OPTIONS --profile=notclose #-}
17.5
34
0.628571
c7741a73d121ef6afaaf365d43336418df430add
80
agda
Agda
test/Succeed/Issue117.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue117.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue117.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue117 where Set′ = Set record ⊤ : Set′ where data ⊥ : Set′ where
10
21
0.6375
9ad5c24947113936e65368d6cbacb092ba2bd72c
4,059
agda
Agda
Monads/CatofAdj/TermAdjHom.agda
jmchapman/Relative-Monads
74707d3538bf494f4bd30263d2f5515a84733865
[ "MIT" ]
21
2015-07-30T01:25:12.000Z
2021-02-13T18:02:18.000Z
Monads/CatofAdj/TermAdjHom.agda
jmchapman/Relative-Monads
74707d3538bf494f4bd30263d2f5515a84733865
[ "MIT" ]
3
2019-01-13T13:12:33.000Z
2019-05-29T09:50:26.000Z
Monads/CatofAdj/TermAdjHom.agda
jmchapman/Relative-Monads
74707d3538bf494f4bd30263d2f5515a84733865
[ "MIT" ]
1
2019-11-04T21:33:13.000Z
2019-11-04T21:33:13.000Z
open import Categories open import Monads open import Level import Monads.CatofAdj module Monads.CatofAdj.TermAdjHom {c d} {C : Cat {c}{d}} (M : Monad C) (A : Cat.Obj (Monads.CatofAdj.CatofAdj M {c ⊔ d}{c ⊔ d})) where open import Library open import Functors open import Adjunctions open import Monads.EM M open Monads.CatofAdj M open import Monads.CatofAdj.TermAdjObj M open Cat open Fun open Adj open Monad open ObjAdj K' : Fun (D A) (D EMObj) K' = record { OMap = λ X → record { acar = OMap (R (adj A)) X; astr = λ Z f → subst (λ Z → Hom C Z (OMap (R (adj A)) X)) (fcong Z (cong OMap (law A))) (HMap (R (adj A)) (right (adj A) f)); alaw1 = λ {Z} {f} → alaw1lem (TFun M) (L (adj A)) (R (adj A)) (law A) (η M) (right (adj A)) (left (adj A)) (ηlaw A) (natleft (adj A) (iden C) (right (adj A) f) (iden (D A))) (lawb (adj A) f); alaw2 = λ {Z} {W} {k} {f} → alaw2lem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (natright (adj A)) (bindlaw A {_}{_}{k})}; HMap = λ {X} {Y} f → record { amor = HMap (R (adj A)) f; ahom = λ {Z} {g} → ahomlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (natright (adj A))}; fid = AlgMorphEq (fid (R (adj A))); fcomp = AlgMorphEq (fcomp (R (adj A)))} Llaw' : K' ○ L (adj A) ≅ L (adj EMObj) Llaw' = FunctorEq _ _ (ext (λ X → AlgEq (fcong X (cong OMap (law A))) ((ext λ Z → dext (λ {f} {f'} p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p))))) (iext λ X → iext λ Y → ext λ f → AlgMorphEq' (AlgEq (fcong X (cong OMap (law A))) ((ext λ Z → dext (λ {f₁} {f'} p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p)))) (AlgEq (fcong Y (cong OMap (law A))) ((ext λ Z → dext (λ {f₁} {f'} p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p)))) (dcong (refl {x = f}) (ext (λ _ → cong₂ (Hom C) (fcong X (cong OMap (law A))) (fcong Y (cong OMap (law A))))) (dicong (refl {x = Y}) (ext (λ z → cong (λ F → Hom C X z → Hom C (F X) (F z)) (cong OMap (law A)))) (dicong (refl {x = X}) (ext (λ z → cong (λ F → ∀ {y} → Hom C z y → Hom C (F z) (F y)) (cong OMap (law A)))) (cong HMap (law A)))))) Rlaw' : R (adj A) ≅ R (adj EMObj) ○ K' Rlaw' = FunctorEq _ _ refl refl rightlaw' : {X : Obj C} {Y : Obj (D A)} {f : Hom C X (OMap (R (adj A)) Y)} → HMap K' (right (adj A) f) ≅ right (adj EMObj) {X} {OMap K' Y} (subst (Hom C X) (fcong Y (cong OMap Rlaw')) f) rightlaw' {X = X}{Y = Y}{f = f} = AlgMorphEq' (AlgEq (fcong X (cong OMap (law A))) (ext λ Z → dext (λ p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p ))) refl (trans (cong (λ (f₁ : Hom C X (OMap (R (adj A)) Y)) → HMap (R (adj A)) (right (adj A) f₁)) (sym (stripsubst (Hom C X) f (fcong Y (cong OMap Rlaw')))) ) (sym (stripsubst (λ Z → Hom C Z (OMap (R (adj A)) Y)) ( ((HMap (R (adj A)) (right (adj A) (subst (Hom C X) (fcong Y (cong (λ r → OMap r) Rlaw')) f))))) (fcong X (cong OMap (law A)))))) EMHom : Hom CatofAdj A EMObj EMHom = record { K = K'; Llaw = Llaw'; Rlaw = Rlaw'; rightlaw = rightlaw'}
26.187097
183
0.426952
31c82f794054c4950cbffab2de3886443b694563
581
agda
Agda
agda/Categories/Coequalizer.agda
oisdk/combinatorics-paper
3c176d4690566d81611080e9378f5a178b39b851
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
agda/Categories/Coequalizer.agda
oisdk/combinatorics-paper
3c176d4690566d81611080e9378f5a178b39b851
[ "MIT" ]
null
null
null
agda/Categories/Coequalizer.agda
oisdk/combinatorics-paper
3c176d4690566d81611080e9378f5a178b39b851
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --cubical --safe #-} open import Prelude open import Categories module Categories.Coequalizer {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) where open Category C private variable h i : X ⟶ Y record Coequalizer (f g : X ⟶ Y) : Type (ℓ₁ ℓ⊔ ℓ₂) where field {obj} : Ob arr : Y ⟶ obj equality : arr · f ≡ arr · g coequalize : ∀ {H} {h : Y ⟶ H} → h · f ≡ h · g → obj ⟶ H universal : ∀ {H} {h : Y ⟶ H} {eq : h · f ≡ h · g} → h ≡ coequalize eq · arr unique : ∀ {H} {h : Y ⟶ H} {i : obj ⟶ H} {eq : h · f ≡ h · g} → h ≡ i · arr → i ≡ coequalize eq
24.208333
103
0.516351
ad73ec5a8958ff1c660d07a10b03842f62cbd08d
221
agda
Agda
test/Succeed/Issue5434.agda
favonia/agda
8d433b967567c08afe15d04a5cb63b6f6d8884ee
[ "BSD-2-Clause" ]
null
null
null
test/Succeed/Issue5434.agda
favonia/agda
8d433b967567c08afe15d04a5cb63b6f6d8884ee
[ "BSD-2-Clause" ]
6
2021-10-18T08:12:24.000Z
2021-11-24T08:31:10.000Z
test/Succeed/Issue5434.agda
antoinevanmuylder/agda
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
[ "BSD-2-Clause" ]
null
null
null
{-# OPTIONS --two-level --cubical-compatible #-} open import Agda.Primitive data D₁ : SSet → SSet (lsuc lzero) where c : (@0 A : SSet) → A → D₁ A data D₂ : Set → SSet (lsuc lzero) where c : (@0 A : Set) → A → D₂ A
22.1
48
0.59276
c77316ddb606bc0c9057bfb248e0faa3ed51937d
381
agda
Agda
test/Fail/Issue998b.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue998b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue998b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
postulate A : Set data D : Set → Set₁ where d : (A : Set) → D A f : Set → D A f A = d A -- Expected error: -- A != A of type Set -- (because one is a variable and one a defined identifier) -- when checking that the expression d A has type D A -- Jesper, 2018-12-10: New error: -- A != Issue998a.A of type Set -- when checking that the expression d A has type D Issue998a.A
21.166667
63
0.648294
1e27337f8096ea758e263e65196eb4421c19dbfe
1,668
agda
Agda
test/Succeed/Issue2151-ClauseTelescope.agda
MxmUrw/agda
6ede01fa854c5472e54f7d1799ca2c08ed316129
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue2151-ClauseTelescope.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue2151-ClauseTelescope.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Sigma open import Agda.Builtin.List open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) data Fin : Nat → Set where zero : {n : Nat} → Fin (suc n) suc : {n : Nat} → Fin n → Fin (suc n) test : (x : Nat) (y : Fin x) {z : Nat} → x ≡ suc z → Set test .(suc z) y {z} refl = Nat -- Telescope: (z : Nat) (y : Fin (suc z)) -- agda rep: ("z" , Nat) ("y" , Fin (suc @0)) -- Patterns: test .(suc @1) @0 @1 refl = ? macro testDef : Term → TC _ testDef goal = do d ← getDefinition (quote test) `d ← quoteTC d unify `d goal foo : Definition foo = testDef arg-info′ : Visibility → ArgInfo arg-info′ v = arg-info v (modality relevant quantity-ω) fooTest : foo ≡ function (clause (("z" , arg (arg-info′ hidden) (def (quote Nat) [])) ∷ ("y" , arg (arg-info′ visible) (def (quote Fin) (arg (arg-info′ visible) (con (quote Nat.suc) (arg (arg-info′ visible) (var 0 []) ∷ [])) ∷ []))) ∷ []) (arg (arg-info′ visible) (dot (con (quote Nat.suc) (arg (arg-info′ visible) (var 1 []) ∷ []))) ∷ arg (arg-info′ visible) (var 0) ∷ arg (arg-info′ hidden) (var 1) ∷ arg (arg-info′ visible) (con (quote refl) []) ∷ []) (def (quote Nat) []) ∷ []) fooTest = refl defBar : (name : Name) → TC _ defBar x = do function cls ← returnTC foo where _ → typeError [] defineFun x cls bar : (x : Nat) (y : Fin x) {z : Nat} → x ≡ suc z → Set unquoteDef bar = defBar bar
26.0625
64
0.522782
1e99e39a0ba23cf4e779968b7e33bce7daea5e21
11,947
agda
Agda
ProcessPreservation.agda
danelahman/higher-order-aeff-agda
b41df71f4456666aab4bd14e13d285c31af80ff6
[ "MIT" ]
2
2021-08-17T15:00:34.000Z
2022-02-05T18:50:26.000Z
ProcessPreservation.agda
danelahman/modal-aeff-agda
b41df71f4456666aab4bd14e13d285c31af80ff6
[ "MIT" ]
null
null
null
ProcessPreservation.agda
danelahman/modal-aeff-agda
b41df71f4456666aab4bd14e13d285c31af80ff6
[ "MIT" ]
null
null
null
open import Data.List renaming (_∷_ to _∷ₗ_ ; [_] to [_]ₗ) open import Data.Maybe open import Data.Product open import Data.Sum open import AEff open import EffectAnnotations open import Preservation open import Renamings open import Substitutions open import Types open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary module ProcessPreservation where -- REDUCTION OF PROCESS TYPES infix 10 _⇝_ data _⇝_ : {o o' : O} → PType o → PType o' → Set where id : {X : VType} {o : O} {i : I} → ---------------------- X ‼ o , i ⇝ X ‼ o , i act : {X : VType} {o o' o'' : O} {i i' i'' : I} → (ops : List Σₛ) → (op : Σₛ) → (o' , i') ≡ ops ↓↓ₑ (o , i) → (o'' , i'') ≡ ((ops ++ [ op ]ₗ) ↓↓ₑ (o , i)) → ---------------------------------------------- (X ‼ o' , i') ⇝ (X ‼ o'' , i'') par : {o o' o'' o''' : O} {PP : PType o} {QQ : PType o'} {PP' : PType o''} {QQ' : PType o'''} → PP ⇝ PP' → QQ ⇝ QQ' → ---------------------- (PP ∥ QQ) ⇝ (PP' ∥ QQ') spawn-l : {X Y : VType} {o o' : O} {i i' : I} → ------------------------------------------- (Y ‼ o' , i') ⇝ (X ‼ o , i) ∥ (Y ‼ o' , i') spawn-r : {X Y : VType} {o o' : O} {i i' : I} → ------------------------------------------- (Y ‼ o' , i') ⇝ (Y ‼ o' , i') ∥ (X ‼ o , i) -- REDUCTION OF PROCESS TYPES IS REFLEXIVE ⇝-refl : {o : O} {PP : PType o} → PP ⇝ PP ⇝-refl {o} {X ‼ o , i} = id ⇝-refl {.(_ ∪ₒ _)} {PP ∥ QQ} = par ⇝-refl ⇝-refl -- ACTION OF INTERRUPTS ON GENERAL PROCESS TYPES IS A REDUCTION ⇝-↓ₚ : {o : O} {PP : PType o} {op : Σₛ} → -------------- PP ⇝ op ↓ₚ PP ⇝-↓ₚ {.o} {X ‼ o , i} {op} = act [] op refl refl ⇝-↓ₚ {.(_ ∪ₒ _)} {PP ∥ QQ} {op} = par ⇝-↓ₚ ⇝-↓ₚ -- ACTION OF INTERRUPTS PRESERVES PROCESS TYPE REDUCTION ⇝-↓ₚ-cong : {o o' : O} {PP : PType o} {QQ : PType o'} {op : Σₛ} → PP ⇝ QQ → -------------------- op ↓ₚ PP ⇝ op ↓ₚ QQ ⇝-↓ₚ-cong id = id ⇝-↓ₚ-cong {_} {_} {_} {_} {op} (act {_} {o} {o'} {o''} {i} {i'} {i''} ops op' p q) = act {o = o} {i = i} (op ∷ₗ ops) op' (cong (λ oi → op ↓ₑ oi) p) (cong (λ oi → op ↓ₑ oi) q) ⇝-↓ₚ-cong (par p q) = par (⇝-↓ₚ-cong p) (⇝-↓ₚ-cong q) ⇝-↓ₚ-cong spawn-l = spawn-l ⇝-↓ₚ-cong spawn-r = spawn-r -- PROCESS TYPE REDUCTION INCREASES SIGNAL INDEX inj-proj₁ : {X Y : Set} {xy xy' : X × Y} → xy ≡ xy' → proj₁ xy ≡ proj₁ xy' inj-proj₁ refl = refl ⇝-⊑ₒ : {o o' : O} {PP : PType o} {QQ : PType o'} → PP ⇝ QQ → ------------------ o ⊑ₒ o' ⇝-⊑ₒ id = ⊑ₒ-refl ⇝-⊑ₒ (act {_} {o} {o'} {o''} {i} ops op p q) with inj-proj₁ p | inj-proj₁ q ... | r | s = subst (λ o → o ⊑ₒ o'') (sym r) (subst (λ o'' → proj₁ (ops ↓↓ₑ (o , i)) ⊑ₒ o'') (sym s) (subst (λ v → proj₁ (ops ↓↓ₑ (o , i)) ⊑ₒ proj₁ v) (sym (↓↓ₑ-act ops [ op ]ₗ)) (↓↓ₑ-⊑ₒ-act ops op))) ⇝-⊑ₒ (par p q) = ∪ₒ-fun (⇝-⊑ₒ p) (⇝-⊑ₒ q) ⇝-⊑ₒ (spawn-l) = ∪ₒ-inr ⇝-⊑ₒ (spawn-r) = ∪ₒ-inl -- EVALUATION CONTEXTS FOR PROCESSES infix 10 _⊢F⦂_ data _⊢F⦂_ (Γ : Ctx) : {o : O} → PType o → Set where [-] : {o : O} → {PP : PType o} → -------------- Γ ⊢F⦂ PP _∥ₗ_ : {o o' : O} {PP : PType o} {QQ : PType o'} → Γ ⊢F⦂ PP → Γ ⊢P⦂ QQ → ------------------ Γ ⊢F⦂ (PP ∥ QQ) _∥ᵣ_ : {o o' : O} {PP : PType o} {QQ : PType o'} → Γ ⊢P⦂ PP → Γ ⊢F⦂ QQ → ------------------ Γ ⊢F⦂ (PP ∥ QQ) ↑ : {o : O} {PP : PType o} → (op : Σₛ) → op ∈ₒ o → Γ ⊢V⦂ proj₁ (payload op) → Γ ⊢F⦂ PP → ---------------------- Γ ⊢F⦂ PP ↓ : {o : O} {PP : PType o} (op : Σₛ) → Γ ⊢V⦂ proj₁ (payload op) → Γ ⊢F⦂ PP → ---------------------- Γ ⊢F⦂ op ↓ₚ PP -- FINDING THE TYPE OF THE HOLE OF A WELL-TYPED PROCESS EVALUATION CONTEXT hole-ty-f : {Γ : Ctx} {o : O} {PP : PType o} → Γ ⊢F⦂ PP → Σ[ o' ∈ O ] (PType o') hole-ty-f {_} {o} {PP} [-] = o , PP hole-ty-f (_∥ₗ_ {o} {o'} {PP} {QQ} F Q) = proj₁ (hole-ty-f F) , proj₂ (hole-ty-f F) hole-ty-f (_∥ᵣ_ {o} {o'} {PP} {QQ} P F) = proj₁ (hole-ty-f F) , proj₂ (hole-ty-f F) hole-ty-f (↑ op p V F) = proj₁ (hole-ty-f F) , proj₂ (hole-ty-f F) hole-ty-f (↓ op V F) = proj₁ (hole-ty-f F) , proj₂ (hole-ty-f F) -- FILLING A WELL-TYPED PROCESS EVALUATION CONTEXT infix 30 _[_]f _[_]f : {Γ : Ctx} {o : O} {PP : PType o} → (F : Γ ⊢F⦂ PP) → (P : Γ ⊢P⦂ proj₂ (hole-ty-f F)) → Γ ⊢P⦂ PP [-] [ P ]f = P (F ∥ₗ Q) [ P ]f = (F [ P ]f) ∥ Q (Q ∥ᵣ F) [ P ]f = Q ∥ (F [ P ]f) (↑ op p V F) [ P ]f = ↑ op p V (F [ P ]f) (↓ op V F) [ P ]f = ↓ op V (F [ P ]f) -- TYPES OF WELL-TYPED PROCESS EVALUATION CONTEXTS ALSO REDUCE ⇝-f-⇝ : {Γ : Ctx} {o o' : O} {PP : PType o} {QQ : PType o'} → (F : Γ ⊢F⦂ PP) → proj₂ (hole-ty-f F) ⇝ QQ → ------------------------------------------ Σ[ o'' ∈ O ] Σ[ RR ∈ PType o'' ] (PP ⇝ RR) ⇝-f-⇝ {_} {_} {o'} {_} {QQ} [-] p = o' , QQ , p ⇝-f-⇝ (_∥ₗ_ {o} {o'} {PP} {QQ} F Q) p with ⇝-f-⇝ F p ... | o'' , RR , q = (o'' ∪ₒ o') , (RR ∥ QQ) , par q ⇝-refl ⇝-f-⇝ (_∥ᵣ_ {o} {o'} {PP} {QQ} P F) p with ⇝-f-⇝ F p ... | o'' , RR , q = (o ∪ₒ o'') , (PP ∥ RR) , par ⇝-refl q ⇝-f-⇝ (↑ op p V F) q with ⇝-f-⇝ F q ... | o'' , RR , r = o'' , RR , r ⇝-f-⇝ (↓ op V F) p with ⇝-f-⇝ F p ... | o'' , RR , q = proj₁ (op ↓ₚₚ RR) , (op ↓ₚ RR) , ⇝-↓ₚ-cong q ⇝-f-∈ₒ : {Γ : Ctx} {o o' : O} {PP : PType o} {QQ : PType o'} (F : Γ ⊢F⦂ PP) → (p : proj₂ (hole-ty-f F) ⇝ QQ) → -------------------------------- o ⊑ₒ proj₁ (⇝-f-⇝ F p) ⇝-f-∈ₒ [-] p = ⇝-⊑ₒ p ⇝-f-∈ₒ (F ∥ₗ Q) p = ∪ₒ-fun (⇝-f-∈ₒ F p) ⊑ₒ-refl ⇝-f-∈ₒ (P ∥ᵣ F) p = ∪ₒ-fun ⊑ₒ-refl (⇝-f-∈ₒ F p) ⇝-f-∈ₒ (↑ op p V F) q = ⇝-f-∈ₒ F q ⇝-f-∈ₒ (↓ {o} {PP} op V F) p = ⇝-f-∈ₒ-aux (⇝-f-⇝ F p) refl where ⇝-f-∈ₒ-aux : (orp : Σ[ o'' ∈ O ] Σ[ RR ∈ PType o'' ] (PP ⇝ RR)) → orp ≡ ⇝-f-⇝ F p → ---------------------------------------------------- proj₁ (op ↓ₚₚ PP) ⊑ₒ proj₁ (op ↓ₚₚ proj₁ (proj₂ orp)) ⇝-f-∈ₒ-aux (o'' , RR , r) q = ⇝-⊑ₒ (⇝-↓ₚ-cong r) ⇝-f : {Γ : Ctx} {o o' : O} {PP : PType o} {QQ : PType o'} → (F : Γ ⊢F⦂ PP) → (p : proj₂ (hole-ty-f F) ⇝ QQ) → --------------------------------- Γ ⊢F⦂ (proj₁ (proj₂ (⇝-f-⇝ F p))) ⇝-f [-] p = [-] ⇝-f (F ∥ₗ Q) p with ⇝-f F p ... | q = q ∥ₗ Q ⇝-f (Q ∥ᵣ F) p with ⇝-f F p ... | q = Q ∥ᵣ q ⇝-f (↑ op p V F) q with ⇝-f F q ... | r = ↑ op (⇝-f-∈ₒ F q op p) V r ⇝-f (↓ op V F) p with ⇝-f F p ... | q = ↓ op V q ⇝-f-tyₒ : {Γ : Ctx} {o o' : O} {PP : PType o} {QQ : PType o'} → (F : Γ ⊢F⦂ PP) → (p : proj₂ (hole-ty-f F) ⇝ QQ) → -------------------------------- o' ≡ proj₁ (hole-ty-f (⇝-f F p)) ⇝-f-tyₒ [-] p = refl ⇝-f-tyₒ (F ∥ₗ Q) p = ⇝-f-tyₒ F p ⇝-f-tyₒ (P ∥ᵣ F) p = ⇝-f-tyₒ F p ⇝-f-tyₒ (↑ op p V F) q = ⇝-f-tyₒ F q ⇝-f-tyₒ (↓ op V F) p = ⇝-f-tyₒ F p ⇝-f-ty : {Γ : Ctx} {o o' : O} {PP : PType o} {QQ : PType o'} → (F : Γ ⊢F⦂ PP) → (p : proj₂ (hole-ty-f F) ⇝ QQ) → -------------------------------------- subst (λ o → PType o) (⇝-f-tyₒ F p) QQ ≡ proj₂ (hole-ty-f (⇝-f F p)) ⇝-f-ty [-] p = refl ⇝-f-ty (F ∥ₗ Q) p = ⇝-f-ty F p ⇝-f-ty (P ∥ᵣ F) p = ⇝-f-ty F p ⇝-f-ty (↑ op p V F) q = ⇝-f-ty F q ⇝-f-ty (↓ op V F) p = ⇝-f-ty F p -- AUXILIARY TWO-LEVEL INDEXED SUBSTITUTION subst-i : {X : Set} {x x' : X} → (Y : X → Set) → {y : Y x} {y' : Y x'} → (Z : (x : X) → Y x → Set) → (p : x ≡ x') → subst Y p y ≡ y' → Z x y → Z x' y' subst-i Y Z refl refl z = z -- SMALL-STEP OPERATIONAL SEMANTICS FOR WELL-TYPED PROCESSES -- (ADDITIONALLY SERVES AS THE PRESERVATION THEOREM) infix 10 _[_]↝_ data _[_]↝_ {Γ : Ctx} : {o o' : O} {PP : PType o} {QQ : PType o'} → Γ ⊢P⦂ PP → PP ⇝ QQ → Γ ⊢P⦂ QQ → Set where -- RUNNING INDIVIDUAL COMPUTATIONS run : {X : VType} {o : O} {i : I} {M N : Γ ⊢C⦂ X ! (o , i)} → M ↝ N → --------------------------- (run M) [ id ]↝ (run N) -- BROADCAST RULES ↑-∥ₗ : {o o' : O} {PP : PType o} {QQ : PType o'} {op : Σₛ} → (p : op ∈ₒ o) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (P : Γ ⊢P⦂ PP) → (Q : Γ ⊢P⦂ QQ) → ------------------------------------------ ((↑ op p V P) ∥ Q) [ par ⇝-refl (⇝-↓ₚ {op = op}) ]↝ ↑ op (∪ₒ-inl op p) V (P ∥ ↓ op V Q) ↑-∥ᵣ : {o o' : O} {PP : PType o} {QQ : PType o'} {op : Σₛ} → (p : op ∈ₒ o') → (V : Γ ⊢V⦂ proj₁ (payload op)) → (P : Γ ⊢P⦂ PP) → (Q : Γ ⊢P⦂ QQ) → ------------------------------------------ (P ∥ (↑ op p V Q)) [ par (⇝-↓ₚ {op = op}) ⇝-refl ]↝ ↑ op (∪ₒ-inr op p) V (↓ op V P ∥ Q) -- INTERRUPT PROPAGATION RULES ↓-run : {X : VType} {o : O} {i : I} {op : Σₛ} → (V : Γ ⊢V⦂ proj₁ (payload op)) → (M : Γ ⊢C⦂ X ! (o , i)) → ----------------------------- ↓ op V (run M) [ id ]↝ run (↓ op V M) ↓-∥ : {o o' : O} {PP : PType o} {QQ : PType o'} {op : Σₛ} (V : Γ ⊢V⦂ proj₁ (payload op)) → (P : Γ ⊢P⦂ PP) → (Q : Γ ⊢P⦂ QQ) → ----------------------------- ↓ op V (P ∥ Q) [ ⇝-refl ]↝ ((↓ op V P) ∥ (↓ op V Q)) ↓-↑ : {o : O} {PP : PType o} {op : Σₛ} {op' : Σₛ} → (p : op' ∈ₒ o) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (W : Γ ⊢V⦂ proj₁ (payload op')) → (P : Γ ⊢P⦂ PP) → ----------------------------------- ↓ op V (↑ op' p W P) [ ⇝-refl ]↝ ↑ op' (↓ₚₚ-⊑ₒ PP op' p) W (↓ op V P) -- SIGNAL HOISTING RULE ↑ : {X : VType} {o : O} {i : I} → {op : Σₛ} → (p : op ∈ₒ o) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (M : Γ ⊢C⦂ X ! (o , i)) → -------------------------------- run (↑ op p V M) [ id ]↝ ↑ op p V (run M) -- PROCESS SPAWNING RULE spawn : {X Y : VType} {o o' : O} {i i' : I} → (M : Γ ■ ⊢C⦂ X ! (o , i)) → (N : Γ ⊢C⦂ Y ! (o' , i')) → --------------------------- run (spawn M N) [ spawn-l ]↝ run (■-str-c {Γ' = []} M) ∥ run N -- EVALUATION CONTEXT RULE context : {o o' : O} {PP : PType o} {QQ : PType o'} (F : Γ ⊢F⦂ PP) → {P : Γ ⊢P⦂ proj₂ (hole-ty-f F)} {Q : Γ ⊢P⦂ QQ} {r : proj₂ (hole-ty-f F) ⇝ QQ} → P [ r ]↝ Q → ----------------------------------------------------------------------------- F [ P ]f [ proj₂ (proj₂ (⇝-f-⇝ F r)) ]↝ (⇝-f F r) [ subst-i PType (λ o QQ → Γ ⊢P⦂ QQ) (⇝-f-tyₒ F r) (⇝-f-ty F r) Q ]f
25.36518
109
0.323094
a0029b462db9ecac743633ac015f71b72ee97954
5,102
agda
Agda
Univalence/FinEquivEquivPlusTimes.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
14
2015-08-18T21:40:15.000Z
2021-05-05T01:07:57.000Z
Univalence/FinEquivEquivPlusTimes.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
4
2018-06-07T16:27:41.000Z
2021-10-29T20:41:23.000Z
Univalence/FinEquivEquivPlusTimes.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
3
2016-05-29T01:56:33.000Z
2019-09-10T09:47:13.000Z
{-# OPTIONS --without-K #-} module FinEquivEquivPlusTimes where open import Data.Product using (_×_; proj₁; proj₂) open import Equiv using (refl∼; sym∼; sym≃; _⊎≃_; id≃; _≃_; _●_; _×≃_; qinv) open import FinEquivPlusTimes using (F0≃⊥; module Plus; module Times) open Plus using (⊎≃+; +≃⊎) open Times using (×≃*; *≃×) open import FinEquivTypeEquiv using (_fin≃_; module PlusE; module TimesE; module PlusTimesE) open PlusE using (_+F_; unite+; uniti+; unite+r; uniti+r; assocr+; assocl+; swap+; sswap+) open TimesE using (_*F_; unite*; uniti*; unite*r; uniti*r; assocr*; assocl*; swap*; sswap*) open PlusTimesE using (distz; factorz; distzr; factorzr; dist; factor; distl; factorl) open import EquivEquiv open import TypeEquiv using (unite₊equiv; unite₊′equiv; assocl₊equiv) open import Data.Empty using (⊥) open import Data.Unit using (⊤) open import Data.Nat using (ℕ; _+_; _*_) open import Data.Fin using (Fin) open import Data.Sum using (_⊎_) open import Data.Product using (_,_) import Relation.Binary.PropositionalEquality as P using (refl) import TypeEquivEquiv as T using ( -- much lower down 0×0≃0) ------------------------------------------------------------------------------ -- Equivalences for distributivity distl-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → distl {m'} {n'} {o'} ● (f *F (g +F h)) ≋ ((f *F g) +F (f *F h)) ● distl {m} {n} {o} distl-nat = {!!} factorl-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → factorl {m'} {n'} {o'} ● ((f *F g) +F (f *F h)) ≋ (f *F (g +F h)) ● factorl {m} {n} {o} factorl-nat = {!!} dist-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → dist {m'} {n'} {o'} ● ((f +F g) *F h) ≋ ((f *F h) +F (g *F h)) ● dist {m} {n} {o} dist-nat = {!!} factor-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → factor {m'} {n'} {o'} ● ((f *F h) +F (g *F h)) ≋ ((f +F g) *F h) ● factor {m} {n} {o} factor-nat = {!!} distzr-nat : {m n : ℕ} {f : m fin≃ n} {g : 0 fin≃ 0} → distzr {n} ● (f *F g) ≋ g ● distzr {m} distzr-nat = {!!} factorzr-nat : {m n : ℕ} {f : m fin≃ n} {g : 0 fin≃ 0} → factorzr {n} ● g ≋ (f *F g) ● factorzr {m} factorzr-nat = {!!} distz-nat : {m n : ℕ} → {f : m fin≃ n} → {g : 0 fin≃ 0} → distz {n} ● (g *F f) ≋ g ● distz {m} distz-nat = {!!} factorz-nat : {m n : ℕ} → {f : m fin≃ n} → {g : 0 fin≃ 0} → factorz {n} ● g ≋ (g *F f) ● factorz {m} factorz-nat = {!!} A×[B⊎C]≃[A×C]⊎[A×B] : {m n o : ℕ} → distl {m} {o} {n} ● (id≃ {A = Fin m} *F swap+ {n} {o}) ≋ swap+ {m * n} {m * o} ● distl {m} {n} {o} A×[B⊎C]≃[A×C]⊎[A×B] = {!!} [A⊎B]×C≃[C×A]⊎[C×B] : {m n o : ℕ} → (swap* {m} {o} +F swap* {n} {o}) ● dist {m} {n} {o} ≋ distl {o} {m} {n} ● swap* {m + n} {o} [A⊎B]×C≃[C×A]⊎[C×B] = {!!} [A⊎B⊎C]×D≃[A×D⊎B×D]⊎C×D : {m n o p : ℕ} → (dist {m} {n} {p} +F id≃ {A = Fin (o * p)}) ● dist {m + n} {o} {p} ● (assocl+ {m} {n} {o} *F id≃ {A = Fin p}) ≋ assocl+ {m * p} {n * p} {o * p} ● (id≃ {A = Fin (m * p)} +F dist {n} {o} {p}) ● dist {m} {n + o} {p} [A⊎B⊎C]×D≃[A×D⊎B×D]⊎C×D = {!!} A×B×[C⊎D]≃[A×B]×C⊎[A×B]×D : {m n o p : ℕ} → distl {m * n} {o} {p} ● assocl* {m} {n} {o + p} ≋ (assocl* {m} {n} {o} +F assocl* {m} {n} {p}) ● distl {m} {n * o} {n * p} ● (id≃ {A = Fin m} *F distl {n} {o} {p}) A×B×[C⊎D]≃[A×B]×C⊎[A×B]×D = {!!} [A⊎B]×[C⊎D]≃[[A×C⊎B×C]⊎A×D]⊎B×D : {m n o p : ℕ} → assocl+ {(m * o) + (n * o)} {m * p} {n * p} ● (dist {m} {n} {o} +F dist {m} {n} {p}) ● distl {m + n} {o} {p} ≋ (assocl+ {m * o} {n * o} {m * p} +F id≃ {A = Fin (n * p)}) ● ((id≃ {A = Fin (m * o)} +F swap+ {m * p} {n * o}) +F id≃ {A = Fin (n * p)}) ● (assocr+ {m * o} {m * p} {n * o} +F id≃ {A = Fin (n * p)}) ● assocl+ {(m * o) + (m * p)} {n * o} {n * p} ● (distl {m} {o} {p} +F distl {n} {o} {p}) ● dist {m} {n} {o + p} [A⊎B]×[C⊎D]≃[[A×C⊎B×C]⊎A×D]⊎B×D = {!!} -- can't be done via equational reasoning!?!? -- cannot even dig into T.0×0≃0 as f≋ is abstract 0×0≃0 : distz {0} ≋ distzr {0} 0×0≃0 = eq (λ {()}) (λ {()}) -- wow, talk about low-level reasoning! 0×[A⊎B]≃0 : {m n : ℕ} → distz {m + n} ≋ unite+ ● (distz {m} +F distz {n}) ● distl {0} {m} {n} 0×[A⊎B]≃0 = {!!} 0×1≃0 : unite*r ≋ distz {1} 0×1≃0 = {!!} A×0≃0 : {m : ℕ} → distzr {m} ≋ distz {m} ● swap* {m} {0} A×0≃0 = {!!} 0×A×B≃0 : {m n : ℕ} → distz {m * n} ≋ distz {n} ● (distz {m} *F id≃ {A = Fin n}) ● assocl* {0} {m} {n} 0×A×B≃0 = {!!} A×0×B≃0 : {m n : ℕ} → distzr {m} ● (id≃ {A = Fin m} *F distz {n}) ≋ distz {n} ● (distzr {m} *F id≃ {A = Fin n}) ● assocl* {m} {0} {n} A×0×B≃0 = {!!} A×[0+B]≃A×B : {m n : ℕ} → (id≃ {A = Fin m} *F unite+ {n}) ≋ unite+ ● (distzr {m} +F id≃) ● distl {m} {0} {n} A×[0+B]≃A×B = {!!} 1×[A⊎B]≃A⊎B : {m n : ℕ} → unite* ≋ (unite* {m} +F unite* {n}) ● distl {1} {m} {n} 1×[A⊎B]≃A⊎B = {!!} ------------------------------------------------------------------------------
34.013333
83
0.431791
2e7c81c3447bdefce0cdd4b0d23b94b38bd8168b
347
agda
Agda
test/Succeed/Issue3795.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue3795.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue3795.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite data Unit : Set where ∗ : Unit postulate A : Set a b c : Unit → A a→b : a ∗ ≡ b ∗ a→c : ∀ x → a x ≡ c x a→c' : a ∗ ≡ c ∗ -- for global confluence checker b→c : b ∗ ≡ c ∗ {-# REWRITE a→b a→c a→c' b→c #-}
20.411765
56
0.567723
1e35a433db87e183602d7729744a58f21ee19f5f
616
agda
Agda
src/Prelude.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
4
2019-04-05T17:57:11.000Z
2021-05-07T04:08:41.000Z
src/Prelude.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
src/Prelude.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
module Prelude where open import Data.Nat public open import Data.Nat.Properties.Simple public open import Data.Fin using (Fin; #_; suc; zero) public open import Data.Unit using (tt; ⊤) public open import Data.Empty public open import Data.Bool using (true; false; Bool) public open import Data.Product public using (∃; ∃₂; _×_; _,_; proj₁; proj₂; ,_) public open import Relation.Binary.PropositionalEquality hiding ([_]) public open ≡-Reasoning public open import Relation.Nullary public open import Relation.Nullary.Decidable using (True) public open import Function using (_∘_; _$_; id; const; flip) public
30.8
80
0.766234
138bf89465418eb348948458309ba3cef7393ef9
26,306
agda
Agda
src/main.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
src/main.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
src/main.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
module main where open import lib import string-format -- for parser for Cedille open import cedille-types -- for parser for options files import options-types import cedille-options -- for parser for Cedille comments & whitespace import cws-types open import constants open import general-util open import json createOptionsFile : (dot-ced-dir : string) → IO ⊤ createOptionsFile dot-ced-dir = let ops-fp = combineFileNames dot-ced-dir options-file-name in createDirectoryIfMissing ff (takeDirectory ops-fp) >> withFile ops-fp WriteMode (flip hPutRope (cedille-options.options-to-rope cedille-options.default-options)) str-bool-to-𝔹 : options-types.str-bool → 𝔹 str-bool-to-𝔹 options-types.StrBoolTrue = tt str-bool-to-𝔹 options-types.StrBoolFalse = ff opts-to-options : filepath → options-types.opts → IO cedille-options.options opts-to-options ofp (options-types.OptsCons (options-types.Lib fps) ops) = opts-to-options ofp ops >>= λ ops → paths-to-stringset fps >>=r λ ip → record ops { include-path = ip } where paths-to-stringset : options-types.paths → IO (𝕃 string × stringset) paths-to-stringset (options-types.PathsCons fp fps) = let rfp = combineFileNames (takeDirectory (takeDirectory ofp)) fp in paths-to-stringset fps >>= λ ps → doesDirectoryExist rfp >>= λ rfpₑ → doesDirectoryExist fp >>= λ fpₑ → (if rfpₑ then (canonicalizePath rfp >>= λ rfp → return (cedille-options.include-path-insert rfp ps)) else return ps) >>= λ ps → if fpₑ then (canonicalizePath fp >>= λ fp → return (cedille-options.include-path-insert fp ps)) else return ps paths-to-stringset options-types.PathsNil = return ([] , empty-stringset) opts-to-options ofp (options-types.OptsCons (options-types.UseCedeFiles b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { use-cede-files = str-bool-to-𝔹 b } opts-to-options ofp (options-types.OptsCons (options-types.MakeRktFiles b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { make-rkt-files = str-bool-to-𝔹 b } opts-to-options ofp (options-types.OptsCons (options-types.GenerateLogs b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { generate-logs = str-bool-to-𝔹 b } opts-to-options ofp (options-types.OptsCons (options-types.ShowQualifiedVars b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { show-qualified-vars = str-bool-to-𝔹 b } opts-to-options ofp (options-types.OptsCons (options-types.EraseTypes b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { erase-types = str-bool-to-𝔹 b } opts-to-options ofp (options-types.OptsCons (options-types.DatatypeEncoding e) ops) = opts-to-options ofp ops >>=r λ ops → record ops { datatype-encoding = e } opts-to-options ofp options-types.OptsNil = return cedille-options.default-options -- helper function to try to parse the options file processOptions : filepath → string → IO (string ⊎ cedille-options.options) processOptions filename s with options-types.scanOptions s ...| options-types.Left cs = return (inj₁ ("Parse error in file " ^ filename ^ " " ^ cs ^ ".")) ...| options-types.Right (options-types.File oo) = opts-to-options filename oo >>= λ opts → if cedille-options.options.make-rkt-files opts then return ∘ inj₁ $ "Racket compilation disabled, please set to false in " ^ filename ^ "." else (return ∘ inj₂ $ opts) getOptionsFile : (filepath : string) → string getOptionsFile fp = combineFileNames (dot-cedille-directory fp) options-file-name findOptionsFile' : (filepath : string) → IO (maybe string) findOptionsFile' fp = traverseParents fp (fp-fuel fp) >>= λ where fpc?@(just fpc) → return fpc? nothing → getHomeDirectory >>= canonicalizePath >>= getOptions? where getOptions? : (filepath : string) → IO ∘ maybe $ string getOptions? fp = let fpc = getOptionsFile fp in doesFileExist fpc >>= λ where ff → return nothing tt → return ∘ just $ fpc traverseParents : string → ℕ → IO (maybe string) traverseParents fp 0 = return nothing traverseParents fp (suc n) = getOptions? fp >>= λ where nothing → traverseParents (takeDirectory fp) n fpc?@(just fpc) → return fpc? fp-fuel : (filepath : string) → ℕ fp-fuel fp = pred ∘' length ∘' splitPath $ fp findOptionsFile : IO (maybe string) findOptionsFile = getCurrentDirectory >>= canonicalizePath >>= findOptionsFile' readOptions : maybe string → IO (string × cedille-options.options) readOptions nothing = getHomeDirectory >>= canonicalizePath >>= λ home → createOptionsFile (dot-cedille-directory home) >>r dot-cedille-directory home , cedille-options.default-options readOptions (just fp) = readFiniteFile fp >>= λ fc → processOptions fp fc >>= λ where (inj₁ err) → putStrLn (global-error-string err) >>r fp , cedille-options.default-options (inj₂ ops) → return (fp , ops) module main-with-options (compileTime : UTC) (options-filepath : filepath) (options : cedille-options.options) where open import ctxt open import monad-instances open import process-cmd options {IO} open import parser open import spans options {IO} open import syntax-util open import to-string options open import toplevel-state options {IO} import interactive-cmds open import rkt options open import elaboration options logFilepath : IO filepath logFilepath = getHomeDirectory >>=r λ home → combineFileNames (dot-cedille-directory home) "log" maybeClearLogFile : IO ⊤ maybeClearLogFile = if cedille-options.options.generate-logs options then logFilepath >>= clearFile else return triv logRope : rope → IO ⊤ logRope s with cedille-options.options.generate-logs options ...| ff = return triv ...| tt = getCurrentTime >>= λ time → logFilepath >>= λ fn → withFile fn AppendMode λ hdl → hPutRope hdl ([[ "([" ^ utcToString time ^ "] " ]] ⊹⊹ s ⊹⊹ [[ ")\n" ]]) logMsg : (message : string) → IO ⊤ logMsg msg = logRope [[ msg ]] sendProgressUpdate : string → IO ⊤ sendProgressUpdate msg = putStr "progress: " >> putStr msg >> putStr "\n" progressUpdate : (filename : string) → (do-check : 𝔹) → IO ⊤ progressUpdate filename do-check = sendProgressUpdate ((if do-check then "Checking " else "Skipping ") ^ filename) fileBaseName : filepath → string fileBaseName fn = base-filename (takeFileName fn) {------------------------------------------------------------------------------- .cede support -------------------------------------------------------------------------------} cede-suffix = ".cede" rkt-suffix = ".rkt" ced-aux-filename : (suffix ced-path : filepath) → filepath ced-aux-filename sfx ced-path = let dir = takeDirectory ced-path in combineFileNames (dot-cedille-directory dir) (fileBaseName ced-path ^ sfx) cede-filename = ced-aux-filename cede-suffix rkt-filename = ced-aux-filename rkt-suffix maybe-write-aux-file : include-elt → (create-dot-ced-if-missing : IO ⊤) → (filename file-suffix : filepath) → (cedille-options.options → 𝔹) → (include-elt → 𝔹) → rope → IO ⊤ maybe-write-aux-file ie mk-dot-ced fn sfx f f' r with f options && ~ f' ie ...| ff = return triv ...| tt = mk-dot-ced >> logMsg ("Starting writing " ^ sfx ^ " file " ^ fn) >> writeRopeToFile fn r >> logMsg ("Finished writing " ^ sfx ^ " file " ^ fn) write-aux-files : toplevel-state → filepath → IO ⊤ write-aux-files s filename with get-include-elt-if s filename ...| nothing = return triv ...| just ie = let dot-ced = createDirectoryIfMissing ff (dot-cedille-directory (takeDirectory filename)) in maybe-write-aux-file ie dot-ced (cede-filename filename) cede-suffix cedille-options.options.use-cede-files include-elt.cede-up-to-date ((if include-elt.err ie then [[ "e" ]] else [[]]) ⊹⊹ include-elt-spans-to-rope ie) >> maybe-write-aux-file ie dot-ced (rkt-filename filename) rkt-suffix cedille-options.options.make-rkt-files include-elt.rkt-up-to-date (to-rkt-file filename (toplevel-state.Γ s) ie rkt-filename) -- we assume the cede file is known to exist at this point read-cede-file : (ced-path : filepath) → IO (𝔹 × string) read-cede-file ced-path = let cede = cede-filename ced-path in logMsg ("Started reading .cede file " ^ cede) >> get-file-contents cede >>= finish >≯ logMsg ("Finished reading .cede file " ^ cede) where finish : maybe string → IO (𝔹 × string) finish nothing = return (tt , global-error-string ("Could not read the file " ^ cede-filename ced-path ^ ".")) finish (just ss) with string-to-𝕃char ss finish (just ss) | ('e' :: ss') = forceFileRead ss >>r tt , 𝕃char-to-string ss' finish (just ss) | _ = forceFileRead ss >>r ff , ss add-cedille-extension : string → string add-cedille-extension x = x ^ "." ^ cedille-extension -- Allows you to say "import FOO.BAR.BAZ" rather than "import FOO/BAR/BAZ" replace-dots : filepath → filepath replace-dots s = 𝕃char-to-string (h (string-to-𝕃char s)) where h : 𝕃 char → 𝕃 char h ('.' :: '.' :: cs) = '.' :: '.' :: h cs h ('.' :: cs) = pathSeparator :: h cs h (c :: cs) = c :: h cs h [] = [] find-imported-file : (dirs : 𝕃 filepath) → (unit-name : string) → IO (maybe filepath) find-imported-file [] unit-name = return nothing find-imported-file (dir :: dirs) unit-name = let e = combineFileNames dir (add-cedille-extension unit-name) in doesFileExist e >>= λ where ff → find-imported-file dirs unit-name tt → canonicalizePath e >>=r just find-imported-files : (dirs : 𝕃 filepath) → (imports : 𝕃 string) → IO (𝕃 (string × filepath)) find-imported-files dirs (u :: us) = find-imported-file dirs (replace-dots u) >>= λ where nothing → logMsg ("Error finding file: " ^ replace-dots u) >> find-imported-files dirs us (just fp) → logMsg ("Found import: " ^ fp) >> find-imported-files dirs us >>=r (u , fp) ::_ find-imported-files dirs [] = return [] {- new parser test integration -} reparse : toplevel-state → filepath → IO toplevel-state reparse st filename = doesFileExist filename >>= λ fileExists → (if fileExists then (readFiniteFile filename >>= λ source → getCurrentTime >>= λ time → processText source >>= λ ie → return (set-last-parse-time-include-elt ie time) >>=r λ ie -> set-source-include-elt ie source) else return (error-include-elt ("The file " ^ filename ^ " could not be opened for reading."))) >>=r set-include-elt st filename where processText : string → IO include-elt processText x with parseStart x processText x | Left (Left cs) = return (error-span-include-elt ("Error in file " ^ filename ^ ".") "Lexical error." cs) processText x | Left (Right cs) = return (error-span-include-elt ("Error in file " ^ filename ^ ".") "Parsing error." cs) processText x | Right t with cws-types.scanComments x processText x | Right t | t2 = find-imported-files (fst (cedille-options.include-path-insert (takeDirectory filename) (toplevel-state.include-path st))) (get-imports t) >>= λ deps → logMsg ("deps for file " ^ filename ^ ": " ^ 𝕃-to-string (λ {(a , b) → "short: " ^ a ^ ", long: " ^ b}) ", " deps) >>r new-include-elt filename deps t t2 nothing reparse-file : filepath → toplevel-state → IO toplevel-state reparse-file filename s = reparse s filename >>=r λ s → set-include-elt s filename (set-cede-file-up-to-date-include-elt (set-do-type-check-include-elt (get-include-elt s filename) tt) ff) infixl 1 _&&>>_ _&&>>_ : IO 𝔹 → IO 𝔹 → IO 𝔹 (a &&>> b) = a >>= λ a → if a then b else return ff aux-up-to-date : filepath → toplevel-state → IO toplevel-state aux-up-to-date filename s = let rkt = rkt-filename filename in doesFileExist rkt &&>> fileIsOlder filename rkt >>=r (set-include-elt s filename ∘ (set-rkt-file-up-to-date-include-elt (get-include-elt s filename))) ie-up-to-date : filepath → include-elt → IO 𝔹 ie-up-to-date filename ie = getModificationTime filename >>=r λ mt → maybe-else ff (λ lpt → lpt utc-after mt) (include-elt.last-parse-time ie) import-changed : toplevel-state → filepath → (import-file : string) → IO 𝔹 import-changed s filename import-file = let dtc = include-elt.do-type-check (get-include-elt s import-file) cede = cede-filename filename cede' = cede-filename import-file in case cedille-options.options.use-cede-files options of λ where ff → return dtc tt → doesFileExist cede &&>> doesFileExist cede' >>= λ where ff → return ff tt → fileIsOlder cede cede' >>=r λ fio → dtc || fio any-imports-changed : toplevel-state → filepath → (imports : 𝕃 string) → IO 𝔹 any-imports-changed s filename [] = return ff any-imports-changed s filename (h :: t) = import-changed s filename h >>= λ where tt → return tt ff → any-imports-changed s filename t file-after-compile : filepath → IO 𝔹 file-after-compile fn = getModificationTime fn >>= λ mt → case mt utc-after compileTime of λ where tt → doesFileExist options-filepath &&>> fileIsOlder options-filepath fn ff → return ff ensure-ast-depsh : filepath → toplevel-state → IO toplevel-state ensure-ast-depsh filename s with get-include-elt-if s filename ...| just ie = ie-up-to-date filename ie >>= λ where ff → reparse-file filename s tt → return s ...| nothing = let cede = cede-filename filename in return (cedille-options.options.use-cede-files options) &&>> doesFileExist cede &&>> fileIsOlder filename cede &&>> file-after-compile cede >>= λ where ff → reparse-file filename s tt → reparse s filename >>= λ s → read-cede-file filename >>= λ where (err , ss) → return (set-include-elt s filename (set-do-type-check-include-elt (set-need-to-add-symbols-to-context-include-elt (set-spans-string-include-elt (get-include-elt s filename) err ss) tt) ff)) {- helper function for update-asts, which keeps track of the files we have seen so we avoid importing the same file twice, and also avoid following cycles in the import graph. -} {-# TERMINATING #-} update-astsh : stringset {- seen already -} → toplevel-state → filepath → IO (stringset {- seen already -} × toplevel-state) update-astsh seen s filename = if stringset-contains seen filename then return (seen , s) else (ensure-ast-depsh filename s >>= aux-up-to-date filename >>= cont (stringset-insert seen filename)) where cont : stringset → toplevel-state → IO (stringset × toplevel-state) cont seen s with get-include-elt s filename cont seen s | ie with include-elt.deps ie cont seen s | ie | ds = proc seen s ds where proc : stringset → toplevel-state → 𝕃 string → IO (stringset × toplevel-state) proc seen s [] = any-imports-changed s filename ds >>=r λ changed → seen , set-include-elt s filename (set-do-type-check-include-elt ie (include-elt.do-type-check ie || changed)) proc seen s (d :: ds) = update-astsh seen s d >>= λ p → proc (fst p) (snd p) ds {- this function updates the ast associated with the given filename in the toplevel state. So if we do not have an up-to-date .cede file (i.e., there is no such file at all, or it is older than the given file), reparse the file. We do this recursively for all dependencies (i.e., imports) of the file. -} update-asts : toplevel-state → filepath → IO toplevel-state update-asts s filename = update-astsh empty-stringset s filename >>=r snd log-files-to-check : toplevel-state → IO ⊤ log-files-to-check s = logRope ([[ "\n" ]] ⊹⊹ (h (trie-mappings (toplevel-state.is s)))) where h : 𝕃 (string × include-elt) → rope h [] = [[]] h ((fn , ie) :: t) = [[ "file: " ]] ⊹⊹ [[ fn ]] ⊹⊹ [[ "\nadd-symbols: " ]] ⊹⊹ [[ 𝔹-to-string (include-elt.need-to-add-symbols-to-context ie) ]] ⊹⊹ [[ "\ndo-type-check: " ]] ⊹⊹ [[ 𝔹-to-string (include-elt.do-type-check ie) ]] ⊹⊹ [[ "\n\n" ]] ⊹⊹ h t {- this function checks the given file (if necessary), updates .cede and .rkt files (again, if necessary), and replies on stdout if appropriate -} checkFile : toplevel-state → filepath → (should-print-spans : 𝔹) → IO toplevel-state checkFile s filename should-print-spans = update-asts s filename >>= λ s → log-files-to-check s >> logMsg (𝕃-to-string (λ {(im , fn) → "im: " ^ im ^ ", fn: " ^ fn}) "; " (trie-mappings (include-elt.import-to-dep (get-include-elt s filename)))) >> process-file progressUpdate s filename (fileBaseName filename) >>= finish where reply : toplevel-state → IO ⊤ reply s with get-include-elt-if s filename reply s | nothing = putStrLn (global-error-string ("Internal error looking up information for file " ^ filename ^ ".")) reply s | just ie = if should-print-spans then putRopeLn (include-elt-spans-to-rope ie) else return triv finish : toplevel-state × mod-info → IO toplevel-state finish (s @ (mk-toplevel-state ip mod is Γ) , ret-mod) = logMsg ("Started reply for file " ^ filename) >> -- Lazy, so checking has not been calculated yet? reply s >> logMsg ("Finished reply for file " ^ filename) >> logMsg ("Files with updated spans:\n" ^ 𝕃-to-string (λ x → x) "\n" mod) >> let Γ = ctxt-set-current-mod Γ ret-mod in writeo mod >>r -- Should process-file now always add files to the list of modified ones because now the cede-/rkt-up-to-date fields take care of whether to rewrite them? mk-toplevel-state ip mod is Γ where writeo : 𝕃 string → IO ⊤ writeo [] = return triv writeo (f :: us) = writeo us >> -- let ie = get-include-elt s f in write-aux-files s f -- (if cedille-options.options.make-rkt-files options && ~ include-elt.rkt-up-to-date ie then (write-rkt-file f (toplevel-state.Γ s) ie rkt-filename) else return triv) -- this is the function that handles requests (from the frontend) on standard input {-# TERMINATING #-} readCommandsFromFrontend : toplevel-state → IO ⊤ readCommandsFromFrontend s = getLine >>= λ input → logMsg ("Frontend input: " ^ input) >> let input-list : 𝕃 string input-list = (string-split (undo-escape-string input) delimiter) in (handleCommands input-list s) >>= λ s → readCommandsFromFrontend s where delimiter : char delimiter = '§' errorCommand : 𝕃 string → toplevel-state → IO ⊤ errorCommand ls s = putStrLn (global-error-string "Invalid command sequence \\\\\"" ^ (𝕃-to-string (λ x → x) ", " ls) ^ "\\\\\".") debugCommand : toplevel-state → IO ⊤ debugCommand s = putStrLn (escape-string (toplevel-state-to-string s)) checkCommand : 𝕃 string → toplevel-state → IO toplevel-state checkCommand (input :: []) s = canonicalizePath input >>= λ input-filename → checkFile (set-include-path s (cedille-options.include-path-insert (takeDirectory input-filename) (toplevel-state.include-path s))) input-filename tt {- should-print-spans -} checkCommand ls s = errorCommand ls s >>r s createArchive-h : toplevel-state → trie json → 𝕃 string → json createArchive-h s t (filename :: filenames) with trie-contains t filename | get-include-elt-if s filename ...| ff | just ie = createArchive-h s (trie-insert t filename $ include-elt-to-archive ie) (filenames ++ include-elt.deps ie) ...| _ | _ = createArchive-h s t filenames createArchive-h s t [] = json-object t createArchive : toplevel-state → string → json createArchive s filename = createArchive-h s empty-trie (filename :: []) archiveCommand : 𝕃 string → toplevel-state → IO toplevel-state archiveCommand (input :: []) s = canonicalizePath input >>= λ filename → update-asts s filename >>= λ s → process-file (λ _, _ → return triv) s filename (fileBaseName filename) >>= λ { (s , _) → return (createArchive s filename) >>= λ archive → putRopeLn (json-to-rope archive) >>r s } archiveCommand ls s = errorCommand ls s >>r s {- findCommand : 𝕃 string → toplevel-state → IO toplevel-state findCommand (symbol :: []) s = putStrLn (find-symbols-to-JSON symbol (toplevel-state-lookup-occurrences symbol s)) >>= λ x → return s findCommand _ s = errorCommand s -} handleCommands : 𝕃 string → toplevel-state → IO toplevel-state handleCommands ("progress stub" :: xs) = return handleCommands ("status ping" :: xs) s = putStrLn "idle" >> return s handleCommands ("check" :: xs) s = checkCommand xs s handleCommands ("debug" :: []) s = debugCommand s >>r s handleCommands ("elaborate" :: x :: x' :: []) s = elab-all s x x' >>r s handleCommands ("interactive" :: xs) s = interactive-cmds.interactive-cmd options xs s >>r s handleCommands ("archive" :: xs) s = archiveCommand xs s -- handleCommands ("find" :: xs) s = findCommand xs s handleCommands xs s = errorCommand xs s >>r s -- function to process command-line arguments processArgs : 𝕃 string → IO ⊤ -- this is the case for when we are called with a single command-line argument, the name of the file to process processArgs (input-filename :: []) = canonicalizePath input-filename >>= λ input-filename → checkFile (new-toplevel-state (cedille-options.include-path-insert (takeDirectory input-filename) (cedille-options.options.include-path options))) input-filename ff {- should-print-spans -} >>= finish input-filename where finish : string → toplevel-state → IO ⊤ finish input-filename s = return triv {- let ie = get-include-elt s input-filename in if include-elt.err ie then (putRopeLn (include-elt-spans-to-rope ie)) else return triv -} -- this is the case where we will go into a loop reading commands from stdin, from the fronted processArgs [] = readCommandsFromFrontend (new-toplevel-state (cedille-options.options.include-path options)) -- all other cases are errors processArgs xs = putStrLn ("Run with the name of one file to process, or run with no command-line arguments and enter the\n" ^ "names of files one at a time followed by newlines (this is for the emacs mode).") main' : 𝕃 string → IO ⊤ main' args = maybeClearLogFile >> logMsg ("Started Cedille process (compiled at: " ^ utcToString compileTime ^ ")") >> processArgs args postulate initializeStdinToUTF8 : IO ⊤ setStdinNewlineMode : IO ⊤ compileTime : UTC templatesDir : filepath {-# FOREIGN GHC {-# LANGUAGE TemplateHaskell #-} #-} {-# FOREIGN GHC import qualified System.IO #-} {-# FOREIGN GHC import qualified Data.Time.Clock #-} {-# FOREIGN GHC import qualified Data.Time.Format #-} {-# FOREIGN GHC import qualified Data.Time.Clock.POSIX #-} {-# FOREIGN GHC import qualified Language.Haskell.TH.Syntax #-} {-# COMPILE GHC initializeStdinToUTF8 = System.IO.hSetEncoding System.IO.stdin System.IO.utf8 #-} {-# COMPILE GHC setStdinNewlineMode = System.IO.hSetNewlineMode System.IO.stdin System.IO.universalNewlineMode #-} {-# COMPILE GHC compileTime = maybe (Data.Time.Clock.POSIX.posixSecondsToUTCTime (fromIntegral 0)) id (Data.Time.Format.parseTimeM True Data.Time.Format.defaultTimeLocale "%s" $(Language.Haskell.TH.Syntax.runIO (Data.Time.Clock.getCurrentTime >>= \ t -> return (Language.Haskell.TH.Syntax.LitE (Language.Haskell.TH.Syntax.StringL (Data.Time.Format.formatTime Data.Time.Format.defaultTimeLocale "%s" t))))) :: Maybe Data.Time.Clock.UTCTime) #-} record cedille-args : Set where constructor mk-cedille-args field opts-file : maybe filepath files : 𝕃 string getCedilleArgs : IO cedille-args getCedilleArgs = getArgs >>= λ args → filterArgs args (mk-cedille-args nothing []) where is-opts-flag = "--options" =string_ bad-flag : IO ⊤ bad-flag = putStrLn "Warning: Flag --options should be followed by a Cedille options file" -- allow for later --options to override earlier. This is a bash idiom filterArgs : 𝕃 string → cedille-args → IO cedille-args filterArgs [] args = return args filterArgs (x :: []) args = if is-opts-flag x then bad-flag >> return args else (return $ record args {files = x :: cedille-args.files args}) filterArgs (x :: y :: xs) args = if is-opts-flag x then filterArgs xs (record args { opts-file = just y}) else filterArgs (y :: xs) (record args { files = x :: cedille-args.files args}) -- main entrypoint for the backend main : IO ⊤ main = initializeStdoutToUTF8 >> initializeStdinToUTF8 >> setStdoutNewlineMode >> setStdinNewlineMode >> setToLineBuffering >> getCedilleArgs >>= λ args → let (mk-cedille-args optsf fs) = args in (case optsf of λ where nothing → findOptionsFile >>= readOptions (just opts) → readOptions $ just opts) >>= λ o → main-with-options.main' compileTime (fst o) (snd o) fs
48.091408
251
0.63324
ad7aee3d93ae0180f52442b57c5590c3a9d264c7
167
agda
Agda
Agda/00-preamble.agda
tadejpetric/HoTT-Intro
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
[ "CC-BY-4.0" ]
null
null
null
Agda/00-preamble.agda
tadejpetric/HoTT-Intro
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
[ "CC-BY-4.0" ]
null
null
null
Agda/00-preamble.agda
tadejpetric/HoTT-Intro
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
[ "CC-BY-4.0" ]
null
null
null
{-# OPTIONS --without-K #-} module 00-preamble where open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) public UU : (i : Level) → Set (lsuc i) UU i = Set i
18.555556
65
0.652695
1e6dc9bb7eb1ee240a8eac5a8387b9bfab07298f
3,941
agda
Agda
Cubical/Functions/Fibration.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/Functions/Fibration.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/Functions/Fibration.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Functions.Fibration where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels using (isOfHLevel→isOfHLevelDep) open import Cubical.Foundations.Function open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.Properties open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Path open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Data.Sigma private variable ℓ ℓb : Level B : Type ℓb module FiberIso {ℓ} (p⁻¹ : B → Type ℓ) (x : B) where p : Σ B p⁻¹ → B p = fst fwd : fiber p x → p⁻¹ x fwd ((x' , y) , q) = subst (λ z → p⁻¹ z) q y bwd : p⁻¹ x → fiber p x bwd y = (x , y) , refl fwd-bwd : ∀ x → fwd (bwd x) ≡ x fwd-bwd y = transportRefl y bwd-fwd : ∀ x → bwd (fwd x) ≡ x bwd-fwd ((x' , y) , q) i = h (r i) where h : Σ[ s ∈ singl x ] p⁻¹ (s .fst) → fiber p x h ((x , p) , y) = (x , y) , sym p r : Path (Σ[ s ∈ singl x ] p⁻¹ (s .fst)) ((x , refl ) , subst p⁻¹ q y) ((x' , sym q) , y ) r = ΣPathP (isContrSingl x .snd (x' , sym q) , toPathP (transport⁻Transport (λ i → p⁻¹ (q i)) y)) -- HoTT Lemma 4.8.1 fiberEquiv : fiber p x ≃ p⁻¹ x fiberEquiv = isoToEquiv (iso fwd bwd fwd-bwd bwd-fwd) open FiberIso using (fiberEquiv) public module _ {ℓ} {E : Type ℓ} (p : E → B) where -- HoTT Lemma 4.8.2 totalEquiv : E ≃ Σ B (fiber p) totalEquiv = isoToEquiv isom where isom : Iso E (Σ B (fiber p)) Iso.fun isom x = p x , x , refl Iso.inv isom (b , x , q) = x Iso.leftInv isom x i = x Iso.rightInv isom (b , x , q) i = q i , x , λ j → q (i ∧ j) module _ (B : Type ℓb) (ℓ : Level) where private ℓ' = ℓ-max ℓb ℓ -- HoTT Theorem 4.8.3 fibrationEquiv : (Σ[ E ∈ Type ℓ' ] (E → B)) ≃ (B → Type ℓ') fibrationEquiv = isoToEquiv isom where isom : Iso (Σ[ E ∈ Type ℓ' ] (E → B)) (B → Type ℓ') Iso.fun isom (E , p) = fiber p Iso.inv isom p⁻¹ = Σ B p⁻¹ , fst Iso.rightInv isom p⁻¹ i x = ua (fiberEquiv p⁻¹ x) i Iso.leftInv isom (E , p) i = ua e (~ i) , fst ∘ ua-unglue e (~ i) where e = totalEquiv p module ForSets {E : Type ℓ} {isSetB : isSet B} (f : E → B) where module _ {x x'} {px : x ≡ x'} {a' : fiber f x} {b' : fiber f x'} where -- fibers are equal when their representatives are equal fibersEqIfRepsEq : fst a' ≡ fst b' → PathP (λ i → fiber f (px i)) a' b' fibersEqIfRepsEq p = ΣPathP (p , (isOfHLevel→isOfHLevelDep 1 (λ (v , w) → isSetB (f v) w) (snd a') (snd b') (λ i → (p i , px i)))) -- The path type in a fiber of f is equivalent to a fiber of (cong f) open import Cubical.Foundations.Function fiberPath : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {f : A → B} {b : B} (h h' : fiber f b) → (Σ[ p ∈ (fst h ≡ fst h') ] (PathP (λ i → f (p i) ≡ b) (snd h) (snd h'))) ≡ fiber (cong f) (h .snd ∙∙ refl ∙∙ sym (h' .snd)) fiberPath h h' = cong (Σ (h .fst ≡ h' .fst)) (funExt λ p → flipSquarePath ∙ PathP≡doubleCompPathʳ _ _ _ _) fiber≡ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {f : A → B} {b : B} (h h' : fiber f b) → (h ≡ h') ≡ fiber (cong f) (h .snd ∙∙ refl ∙∙ sym (h' .snd)) fiber≡ {f = f} {b = b} h h' = ΣPath≡PathΣ ⁻¹ ∙ fiberPath h h' FibrationStr : (B : Type ℓb) → Type ℓ → Type (ℓ-max ℓ ℓb) FibrationStr B A = A → B Fibration : (B : Type ℓb) → (ℓ : Level) → Type (ℓ-max ℓb (ℓ-suc ℓ)) Fibration {ℓb = ℓb} B ℓ = Σ[ A ∈ Type ℓ ] FibrationStr B A
37.179245
106
0.520934
adc0e86cf51f73b4fcec57fd0ff1f8fb5ee22bc8
3,209
agda
Agda
vendor/stdlib/src/Data/Integer/Properties.agda
isabella232/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
56
2015-01-20T02:11:42.000Z
2021-12-21T17:02:19.000Z
vendor/stdlib/src/Data/Integer/Properties.agda
larrytheliquid/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
1
2022-03-12T12:17:51.000Z
2022-03-12T12:17:51.000Z
vendor/stdlib/src/Data/Integer/Properties.agda
isabella232/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
3
2015-07-21T16:37:58.000Z
2022-03-12T11:54:10.000Z
------------------------------------------------------------------------ -- Some properties about integers ------------------------------------------------------------------------ module Data.Integer.Properties where open import Algebra import Algebra.Morphism as Morphism open import Data.Empty open import Data.Function open import Data.Integer hiding (suc) open import Data.Nat as ℕ renaming (_*_ to _ℕ*_) import Data.Nat.Properties as ℕ open import Data.Sign as Sign using () renaming (_*_ to _S*_) import Data.Sign.Properties as SignProp open import Relation.Binary.PropositionalEquality open ≡-Reasoning open Morphism.Definitions ℤ ℕ _≡_ -- Some properties relating sign and ∣_∣ to _◃_. sign-◃ : ∀ s n → sign (s ◃ suc n) ≡ s sign-◃ Sign.- _ = refl sign-◃ Sign.+ _ = refl sign-cong : ∀ {s₁ s₂ n₁ n₂} → s₁ ◃ suc n₁ ≡ s₂ ◃ suc n₂ → s₁ ≡ s₂ sign-cong {s₁} {s₂} {n₁} {n₂} eq = begin s₁ ≡⟨ sym $ sign-◃ s₁ n₁ ⟩ sign (s₁ ◃ suc n₁) ≡⟨ cong sign eq ⟩ sign (s₂ ◃ suc n₂) ≡⟨ sign-◃ s₂ n₂ ⟩ s₂ ∎ abs-◃ : ∀ s n → ∣ s ◃ n ∣ ≡ n abs-◃ _ zero = refl abs-◃ Sign.- (suc n) = refl abs-◃ Sign.+ (suc n) = refl abs-cong : ∀ {s₁ s₂ n₁ n₂} → s₁ ◃ n₁ ≡ s₂ ◃ n₂ → n₁ ≡ n₂ abs-cong {s₁} {s₂} {n₁} {n₂} eq = begin n₁ ≡⟨ sym $ abs-◃ s₁ n₁ ⟩ ∣ s₁ ◃ n₁ ∣ ≡⟨ cong ∣_∣ eq ⟩ ∣ s₂ ◃ n₂ ∣ ≡⟨ abs-◃ s₂ n₂ ⟩ n₂ ∎ -- ∣_∣ commutes with multiplication. abs-*-commute : Homomorphic₂ ∣_∣ _*_ _ℕ*_ abs-*-commute i j = abs-◃ _ _ -- Multiplication is right cancellative for non-zero integers. cancel-*-right : ∀ i j k → k ≢ + 0 → i * k ≡ j * k → i ≡ j cancel-*-right i j k ≢0 eq with signAbs k cancel-*-right i j .(+ 0) ≢0 eq | s ◂ zero = ⊥-elim (≢0 refl) cancel-*-right i j .(s ◃ suc n) ≢0 eq | s ◂ suc n with ∣ s ◃ suc n ∣ | abs-◃ s (suc n) | sign (s ◃ suc n) | sign-◃ s n ... | .(suc n) | refl | .s | refl = ◃-cong (sign-i≡sign-j i j eq) $ ℕ.cancel-*-right ∣ i ∣ ∣ j ∣ $ abs-cong eq where sign-i≡sign-j : ∀ i j → sign i S* s ◃ ∣ i ∣ ℕ* suc n ≡ sign j S* s ◃ ∣ j ∣ ℕ* suc n → sign i ≡ sign j sign-i≡sign-j i j eq with signAbs i | signAbs j sign-i≡sign-j .(+ 0) .(+ 0) eq | s₁ ◂ zero | s₂ ◂ zero = refl sign-i≡sign-j .(+ 0) .(s₂ ◃ suc n₂) eq | s₁ ◂ zero | s₂ ◂ suc n₂ with ∣ s₂ ◃ suc n₂ ∣ | abs-◃ s₂ (suc n₂) ... | .(suc n₂) | refl with abs-cong {s₁} {sign (s₂ ◃ suc n₂) S* s} {0} {suc n₂ ℕ* suc n} eq ... | () sign-i≡sign-j .(s₁ ◃ suc n₁) .(+ 0) eq | s₁ ◂ suc n₁ | s₂ ◂ zero with ∣ s₁ ◃ suc n₁ ∣ | abs-◃ s₁ (suc n₁) ... | .(suc n₁) | refl with abs-cong {sign (s₁ ◃ suc n₁) S* s} {s₁} {suc n₁ ℕ* suc n} {0} eq ... | () sign-i≡sign-j .(s₁ ◃ suc n₁) .(s₂ ◃ suc n₂) eq | s₁ ◂ suc n₁ | s₂ ◂ suc n₂ with ∣ s₁ ◃ suc n₁ ∣ | abs-◃ s₁ (suc n₁) | sign (s₁ ◃ suc n₁) | sign-◃ s₁ n₁ | ∣ s₂ ◃ suc n₂ ∣ | abs-◃ s₂ (suc n₂) | sign (s₂ ◃ suc n₂) | sign-◃ s₂ n₂ ... | .(suc n₁) | refl | .s₁ | refl | .(suc n₂) | refl | .s₂ | refl = SignProp.cancel-*-right s₁ s₂ (sign-cong eq)
36.465909
83
0.480524
1e49de6db67f41a330cd6e373679a47a894d0f08
2,486
agda
Agda
theorems/cohomology/Sigma.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/cohomology/Sigma.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/cohomology/Sigma.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.PtdMapSequence open import homotopy.CofiberSequence open import groups.Exactness open import groups.ExactSequence open import groups.HomSequence open import cohomology.Theory module cohomology.Sigma {i} (CT : CohomologyTheory i) (n : ℤ) (X : Ptd i) (Y : de⊙ X → Ptd i) where open CohomologyTheory CT open import cohomology.PtdMapSequence CT {- Cⁿ(Σx:X.Y) = Cⁿ(⋁x:X.Y) × Cⁿ(X). The proof is by constructing a - splitting exact sequence 0 → Cⁿ(⋁x:X.Y) → Cⁿ(Σx:X.Y) → Cⁿ(X) - by observing that the map [select : x ↦ (x, pt Yₓ)] has a left inverse - and satisfies [Cofiber select == ⋁x:X.Y. -} ⊙select : X ⊙→ ⊙Σ X Y ⊙select = (bigwedge-f Y , idp) ⊙Σbwin : ⊙Σ X Y ⊙→ ⊙BigWedge Y ⊙Σbwin = ⊙cfcod' ⊙select private abstract cst-C-Σbwin-is-exact : is-exact (cst-hom {G = C n (⊙Susp (de⊙ X))}) (C-fmap n ⊙Σbwin) cst-C-Σbwin-is-exact = equiv-preserves-exact {φ₁ = cst-hom {G = C n (⊙Susp (de⊙ X))}} {ξG = C-fmap n (⊙Susp-to-⊙Cof² ⊙select)} {ξH = idhom _} {ξK = idhom _} (comm-sqrᴳ λ x → CEl-fmap n (⊙cfcod²' ⊙select) x =⟨ ! $ CEl-fmap-idf n $ CEl-fmap n (⊙cfcod²' ⊙select) x ⟩ CEl-fmap n (⊙idf _) (CEl-fmap n (⊙cfcod²' ⊙select) x) =⟨ C-comm-square n (extract-glue-cod²-comm-sqr ⊙select) □$ᴳ x ⟩ CEl-fmap n ⊙extract-glue (CEl-fmap n (⊙Susp-to-⊙Cof² ⊙select) x) =⟨ CEl-fmap-const n (extract-glue-from-BigWedge-is-const Y) _ ⟩ Cident n _ =∎) (comm-sqrᴳ λ _ → idp) (C-isemap n (⊙Susp-to-⊙Cof² ⊙select) (snd (Cof²-equiv-Susp ⊙select ⁻¹))) (idf-is-equiv _) (idf-is-equiv _) (C-exact n ⊙Σbwin) χ : C n X →ᴳ C n (⊙Σ X Y) χ = C-fmap n (⊙fstᵈ Y) abstract select-χ-is-idf : ∀ s → CEl-fmap n ⊙select (GroupHom.f χ s) == s select-χ-is-idf = CEl-fmap-inverse n ⊙select (⊙fstᵈ Y) λ _ → idp C-Σ : C n (⊙Σ X Y) ≃ᴳ C n (⊙BigWedge Y) ×ᴳ C n X C-Σ = Exact.φ-inj-and-ψ-has-rinv-split (C-exact n ⊙select) (C-is-abelian n _) (Exact.φ-const-implies-ψ-is-inj cst-C-Σbwin-is-exact (λ _ → idp)) χ select-χ-is-idf {- ⊙Σbwin-over : CF-hom n ⊙Σbwin == ×ᴳ-inl [ (λ G → GroupHom (C n (⊙BigWedge Y)) G) ↓ path ] ⊙Σbwin-over = SER.φ-over-iso ⊙select-over : CF-hom n ⊙select == ×ᴳ-snd {G = C n (⊙BigWedge Y)} [ (λ G → GroupHom G (C n X)) ↓ path ] ⊙select-over = SER.ψ-over-iso open CofSelect public using (select; ⊙select; ⊙Σbwin) -}
32.710526
89
0.588496
1aad90e551c04c0fbcf5d12ed8c213ce6e23e597
964
agda
Agda
Cubical/Categories/Category.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Categories/Category.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Categories/Category.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical #-} module Cubical.Categories.Category where open import Cubical.Foundations.Prelude record Precategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where no-eta-equality field ob : Type ℓ hom : ob → ob → Type ℓ' idn : ∀ x → hom x x seq : ∀ {x y z} (f : hom x y) (g : hom y z) → hom x z seq-λ : ∀ {x y : ob} (f : hom x y) → seq (idn x) f ≡ f seq-ρ : ∀ {x y} (f : hom x y) → seq f (idn y) ≡ f seq-α : ∀ {u v w x} (f : hom u v) (g : hom v w) (h : hom w x) → seq (seq f g) h ≡ seq f (seq g h) open Precategory public record isCategory {ℓ ℓ'} (𝒞 : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where field homIsSet : ∀ {x y} → isSet (𝒞 .hom x y) open isCategory public _^op : ∀ {ℓ ℓ'} → Precategory ℓ ℓ' → Precategory ℓ ℓ' (𝒞 ^op) .ob = 𝒞 .ob (𝒞 ^op) .hom x y = 𝒞 .hom y x (𝒞 ^op) .idn = 𝒞 .idn (𝒞 ^op) .seq f g = 𝒞 .seq g f (𝒞 ^op) .seq-λ = 𝒞 .seq-ρ (𝒞 ^op) .seq-ρ = 𝒞 .seq-λ (𝒞 ^op) .seq-α f g h = sym (𝒞 .seq-α _ _ _)
28.352941
101
0.53527
12710ad22d035df3dd0a1ffb83216335fb494499
859
agda
Agda
src/Categories/Category/Lift.agda
glittershark/agda-categories
2128fab9e8d341364cbf784bb17c547bf73891de
[ "MIT" ]
null
null
null
src/Categories/Category/Lift.agda
glittershark/agda-categories
2128fab9e8d341364cbf784bb17c547bf73891de
[ "MIT" ]
null
null
null
src/Categories/Category/Lift.agda
glittershark/agda-categories
2128fab9e8d341364cbf784bb17c547bf73891de
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} module Categories.Category.Lift where open import Level open import Categories.Category 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
30.678571
81
0.547148
c7f13a0c9fb65124eeefccfacc68871319a4fafe
1,142
agda
Agda
Cubical/HITs/Interval/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/HITs/Interval/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/HITs/Interval/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Interval.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude data Interval : Type₀ where zero : Interval one : Interval seg : zero ≡ one isContrInterval : isContr Interval isContrInterval = (zero , (λ x → rem x)) where rem : (x : Interval) → zero ≡ x rem zero = refl rem one = seg rem (seg i) j = seg (i ∧ j) funExtInterval : ∀ {ℓ} (A B : Type ℓ) (f g : A → B) → ((x : A) → f x ≡ g x) → f ≡ g funExtInterval A B f g p = λ i x → hmtpy x (seg i) where hmtpy : A → Interval → B hmtpy x zero = f x hmtpy x one = g x hmtpy x (seg i) = p x i elim : (A : Interval → Type₀) (x : A zero) (y : A one) (p : PathP (λ i → A (seg i)) x y) → (x : Interval) → A x elim A x y p zero = x elim A x y p one = y elim A x y p (seg i) = p i -- Note that this is not definitional (it is not proved by refl) intervalEta : ∀ {A : Type₀} (f : Interval → A) → elim _ (f zero) (f one) (λ i → f (seg i)) ≡ f intervalEta f i zero = f zero intervalEta f i one = f one intervalEta f i (seg j) = f (seg j)
28.55
94
0.577933
a02f75789e3792ecf17a8368e8d47a451524d0bf
2,165
agda
Agda
Categories/Fam.agda
copumpkin/categories
36f4181d751e2ecb54db219911d8c69afe8ba892
[ "BSD-3-Clause" ]
98
2015-04-15T14:57:33.000Z
2022-03-08T05:20:36.000Z
Categories/Fam.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
19
2015-05-23T06:47:10.000Z
2019-08-09T16:31:40.000Z
Categories/Fam.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
23
2015-02-05T13:03:09.000Z
2021-11-11T13:50:56.000Z
module Categories.Fam where open import Level open import Relation.Binary using (Rel) import Relation.Binary.HeterogeneousEquality as Het open Het using (_≅_) renaming (refl to ≣-refl) open import Categories.Support.PropositionalEquality open import Categories.Category module Fam {a b : Level} where record Fam : Set (suc a ⊔ suc b) where constructor _,_ field U : Set a T : U → Set b open Fam public record Hom (A B : Fam) : Set (a ⊔ b) where constructor _,_ field f : U A → U B φ : (x : U A) → T A x → T B (f x) record _≡Fam_ {X Y} (f g : (Hom X Y)) : Set (a ⊔ b) where constructor _,_ field f≡g : {x : _} → Hom.f f x ≣ Hom.f g x φ≡γ : {x : _} {bx : _} → Hom.φ f x bx ≅ Hom.φ g x bx module Eq = _≡Fam_ Cat : Category (suc a ⊔ suc b) (a ⊔ b) (a ⊔ b) Cat = record { Obj = Fam; _⇒_ = Hom; _≡_ = _≡Fam_; id = id′; _∘_ = _∘′_; assoc = ≣-refl , ≣-refl; identityˡ = ≣-refl , ≣-refl; identityʳ = ≣-refl , ≣-refl; equiv = record { refl = ≣-refl , ≣-refl; sym = \ { (f≡g , φ≡γ) → ≣-sym f≡g , Het.sym φ≡γ }; trans = λ {(f≡g , φ≡γ) (g≡h , γ≡η) → ≣-trans f≡g g≡h , Het.trans φ≡γ γ≡η} }; ∘-resp-≡ = ∘-resp-≡′ } where id′ : {A : Fam} → Hom A A id′ = (\ x → x) , (\ x bx → bx) _∘′_ : {A B C : Fam} → Hom B C → Hom A B → Hom A C _∘′_ (f , φ) (g , γ) = (λ x → f (g x)) , (λ x bx → φ (g x) (γ x bx)) sym′ : ∀ {X Y} → Relation.Binary.Symmetric (_≡Fam_ {X} {Y}) sym′ {Ax , Bx} {Ay , By} {f , φ} {g , γ} (f≡g , φ≡γ) = ≣-sym f≡g , Het.sym φ≡γ ∘-resp-≡′ : {A B C : Fam} {f h : Hom B C} {g i : Hom A B} → f ≡Fam h → g ≡Fam i → (f ∘′ g) ≡Fam (h ∘′ i) ∘-resp-≡′ {f = (f , φ)} {g , γ} {h , η} {i , ι} (f≡g , φ≡γ) (h≡i , η≡ι) = ≣-trans f≡g (≣-cong g h≡i) , Het.trans φ≡γ (Het.cong₂ γ (Het.≡-to-≅ h≡i) η≡ι) open Category Cat public Fam : ∀ a b → Category (suc a ⊔ suc b) (a ⊔ b) (a ⊔ b) Fam a b = Fam.Cat {a} {b}
31.838235
109
0.444342
fbef15478ef6c16bc1a73078abb932a92836970d
2,857
agda
Agda
src/Categories/Diagram/Coequalizer.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Diagram/Coequalizer.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Diagram/Coequalizer.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core using (Category) module Categories.Diagram.Coequalizer {o ℓ e} (𝒞 : Category o ℓ e) where open Category 𝒞 open HomReasoning open import Categories.Morphism 𝒞 open import Categories.Morphism.Reasoning 𝒞 open import Level open import Function using (_$_) private variable A B C : Obj h i j k : A ⇒ B record IsCoequalizer {E} (f g : A ⇒ B) (arr : B ⇒ E) : Set (o ⊔ ℓ ⊔ e) where field equality : arr ∘ f ≈ arr ∘ g coequalize : {h : B ⇒ C} → h ∘ f ≈ h ∘ g → E ⇒ C universal : {h : B ⇒ C} {eq : h ∘ f ≈ h ∘ g} → h ≈ coequalize eq ∘ arr unique : {h : B ⇒ C} {i : E ⇒ C} {eq : h ∘ f ≈ h ∘ g} → h ≈ i ∘ arr → i ≈ coequalize eq unique′ : (eq eq′ : h ∘ f ≈ h ∘ g) → coequalize eq ≈ coequalize eq′ unique′ eq eq′ = unique universal id-coequalize : id ≈ coequalize equality id-coequalize = unique (⟺ identityˡ) coequalize-resp-≈ : ∀ {eq : h ∘ f ≈ h ∘ g} {eq′ : i ∘ f ≈ i ∘ g} → h ≈ i → coequalize eq ≈ coequalize eq′ coequalize-resp-≈ {h = h} {i = i} {eq = eq} {eq′ = eq′} h≈i = unique $ begin i ≈˘⟨ h≈i ⟩ h ≈⟨ universal ⟩ coequalize eq ∘ arr ∎ coequalize-resp-≈′ : (eq : h ∘ f ≈ h ∘ g) → (eq′ : i ∘ f ≈ i ∘ g) → h ≈ i → j ≈ coequalize eq → k ≈ coequalize eq′ → j ≈ k coequalize-resp-≈′ {j = j} {k = k} eq eq′ h≈i eqj eqk = begin j ≈⟨ eqj ⟩ coequalize eq ≈⟨ coequalize-resp-≈ h≈i ⟩ coequalize eq′ ≈˘⟨ eqk ⟩ k ∎ record Coequalizer (f g : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where field {obj} : Obj arr : B ⇒ obj isCoequalizer : IsCoequalizer f g arr open IsCoequalizer isCoequalizer public -- Proving this via duality arguments is kind of annoying, as ≅ does not behave nicely in -- concert with op. up-to-iso : (coe₁ coe₂ : Coequalizer h i) → Coequalizer.obj coe₁ ≅ Coequalizer.obj coe₂ up-to-iso coe₁ coe₂ = record { from = repack coe₁ coe₂ ; to = repack coe₂ coe₁ ; iso = record { isoˡ = repack-cancel coe₂ coe₁ ; isoʳ = repack-cancel coe₁ coe₂ } } where open Coequalizer repack : (coe₁ coe₂ : Coequalizer h i) → obj coe₁ ⇒ obj coe₂ repack coe₁ coe₂ = coequalize coe₁ (equality coe₂) repack∘ : (coe₁ coe₂ coe₃ : Coequalizer h i) → repack coe₂ coe₃ ∘ repack coe₁ coe₂ ≈ repack coe₁ coe₃ repack∘ coe₁ coe₂ coe₃ = unique coe₁ (⟺ (glueTrianglesˡ (⟺ (universal coe₂)) (⟺ (universal coe₁)))) -- unique e₃ (⟺ (glueTrianglesʳ (⟺ (universal e₃)) (⟺ (universal e₂)))) repack-cancel : (e₁ e₂ : Coequalizer h i) → repack e₁ e₂ ∘ repack e₂ e₁ ≈ id repack-cancel coe₁ coe₂ = repack∘ coe₂ coe₁ coe₂ ○ ⟺ (id-coequalize coe₂) IsCoequalizer⇒Coequalizer : IsCoequalizer h i k → Coequalizer h i IsCoequalizer⇒Coequalizer {k = k} is-coe = record { arr = k ; isCoequalizer = is-coe }
33.22093
175
0.59118
046fbd63e84ca8d75a4adaaef004d386f76519d0
8,010
agda
Agda
src/Categories/Category/Instance/Properties/Posets.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
src/Categories/Category/Instance/Properties/Posets.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
null
null
null
src/Categories/Category/Instance/Properties/Posets.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Properties.Posets where open import Level using (_⊔_; Lift; lift) open import Data.Unit using (⊤; tt) open import Data.Product as Prod using (_,_; <_,_>) renaming (_×_ to _|×|_) open import Function using (flip) open import Relation.Binary using (IsPartialOrder; Poset) open import Relation.Binary.OrderMorphism using (id; _∘_) renaming (_⇒-Poset_ to _⇒_) open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) open import Categories.Category import Categories.Category.CartesianClosed as CCC import Categories.Category.CartesianClosed.Canonical as Canonical open import Categories.Category.Instance.Posets open import Categories.Functor using (Functor; Endofunctor) open import Categories.Utils.Product open Poset renaming (_≈_ to ₍_₎_≈_; _≤_ to ₍_₎_≤_) open _⇒_ -- The pointwise partial order on order preserving maps. -- -- (See the Exponential module below for the definition of the -- exponential/hom object based on this order.) module Pointwise {a₁ a₂ a₃ b₁ b₂ b₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where infix 4 _≤°_ _≤°_ : (f g : A ⇒ B) → Set (a₁ ⊔ b₃) f ≤° g = ∀ {x} → ₍ B ₎ fun f x ≤ fun g x ≤°-isPartialOrder : IsPartialOrder _≗_ _≤°_ ≤°-isPartialOrder = record { isPreorder = record { isEquivalence = ≗-isEquivalence ; reflexive = λ f≗g → reflexive B f≗g ; trans = λ f≤g g≤h → trans B f≤g g≤h } ; antisym = λ f≤g g≤f → antisym B f≤g g≤f } module ≤° = IsPartialOrder ≤°-isPartialOrder open Pointwise -- Poset has a duality involution: the poset obtained by reversing the -- partial order is again a poset. module Opposite where -- NOTE: we flip the direction of the underlying equality _≈_ as -- well, so that |op (op A) ≡ A| definitionally. op : ∀ {a₁ a₂ a₃} → Poset a₁ a₂ a₃ → Poset a₁ a₂ a₃ op A = record { Carrier = Carrier A ; _≈_ = flip ₍ A ₎_≈_ ; _≤_ = flip ₍ A ₎_≤_ ; isPartialOrder = record { isPreorder = record { isEquivalence = record { refl = Eq.refl A ; sym = Eq.sym A ; trans = flip (Eq.trans A) } ; reflexive = reflexive A ; trans = flip (trans A) } ; antisym = antisym A } } module _ {a₁ a₂ a₃} {A : Poset a₁ a₂ a₃} where op-involutive : op (op A) ≡ A op-involutive = ≡.refl module _ {b₁ b₂ b₃} {B : Poset b₁ b₂ b₃} where op₁ : A ⇒ B → op A ⇒ op B op₁ f = record { fun = fun f ; monotone = monotone f } op₂ : {f g : A ⇒ B} → f ≤° g → op₁ g ≤° op₁ f op₂ f≤g = f≤g -- op induces an endofunctor on Posets op-functor : ∀ {a₁ a₂ a₃} → Endofunctor (Posets a₁ a₂ a₃) op-functor = record { F₀ = op ; F₁ = op₁ ; identity = λ {A} → Eq.refl A ; homomorphism = λ {_ _ C} → Eq.refl C ; F-resp-≈ = λ {_ B} x≈y → Eq.sym B x≈y } module op {a₁ a₂ a₃} = Functor (op-functor {a₁} {a₂} {a₃}) -- The category of posets has terminal objects. module Terminals where unit : ∀ a₁ a₂ a₃ → Poset a₁ a₂ a₃ unit a₁ a₂ a₃ = record { Carrier = Lift a₁ ⊤ ; _≈_ = λ _ _ → Lift a₂ ⊤ ; _≤_ = λ _ _ → Lift a₃ ⊤ } module _ {a₁ a₂ a₃ b₁ b₂ b₃} {B : Poset b₁ b₂ b₃} where ! : B ⇒ unit a₁ a₂ a₃ ! = _ !-unique : (f : B ⇒ unit a₁ a₂ a₃) → ! ≗ f !-unique f = _ open Terminals -- The category of posets has products. module Products where infixr 2 _×_ _×_ : ∀ {a₁ a₂ a₃ b₁ b₂ b₃} → Poset a₁ a₂ a₃ → Poset b₁ b₂ b₃ → Poset (a₁ ⊔ b₁) (a₂ ⊔ b₂) (a₃ ⊔ b₃) A × B = record { Carrier = Carrier A |×| Carrier B ; _≈_ = ₍ A ₎_≈_ -< _|×|_ >- ₍ B ₎_≈_ ; _≤_ = ₍ A ₎_≤_ -< _|×|_ >- ₍ B ₎_≤_ ; isPartialOrder = record { isPreorder = record { isEquivalence = record { refl = Eq.refl A , Eq.refl B ; sym = Prod.map (Eq.sym A) (Eq.sym B) ; trans = Prod.zip (Eq.trans A) (Eq.trans B) } ; reflexive = Prod.map (reflexive A) (reflexive B) ; trans = Prod.zip (trans A) (trans B) } ; antisym = Prod.zip (antisym A) (antisym B) } } module _ {a₁ a₂ a₃ b₁ b₂ b₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where π₁ : (A × B) ⇒ A π₁ = record { fun = Prod.proj₁ ; monotone = Prod.proj₁ } π₂ : (A × B) ⇒ B π₂ = record { fun = Prod.proj₂ ; monotone = Prod.proj₂ } module _ {c₁ c₂ c₃} {C : Poset c₁ c₂ c₃} where infix 11 ⟨_,_⟩ ⟨_,_⟩ : C ⇒ A → C ⇒ B → C ⇒ (A × B) ⟨ f , g ⟩ = record { fun = < fun f , fun g > ; monotone = < monotone f , monotone g > } π₁-comp : {f : C ⇒ A} {g : C ⇒ B} → π₁ ∘ ⟨ f , g ⟩ ≗ f π₁-comp = Eq.refl A π₂-comp : {f : C ⇒ A} {g : C ⇒ B} → π₂ ∘ ⟨ f , g ⟩ ≗ g π₂-comp = Eq.refl B ⟨,⟩-unique : {f : C ⇒ A} {g : C ⇒ B} {h : C ⇒ (A × B)} → π₁ ∘ h ≗ f → π₂ ∘ h ≗ g → ⟨ f , g ⟩ ≗ h ⟨,⟩-unique hyp₁ hyp₂ {x} = Eq.sym A hyp₁ , Eq.sym B hyp₂ infixr 2 _×₁_ _×₁_ : ∀ {a₁ a₂ a₃ b₁ b₂ b₃ c₁ c₂ c₃ d₁ d₂ d₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} {C : Poset c₁ c₂ c₃} {D : Poset d₁ d₂ d₃} → A ⇒ C → B ⇒ D → (A × B) ⇒ (C × D) f ×₁ g = ⟨ f ∘ π₁ , g ∘ π₂ ⟩ open Products -- The category of posets has exponential objects. -- -- It's easier to define exponentials with respect to the *canonical* -- product. The more generic version can then be given by appealing -- to uniqueness (up to iso) of products. module Exponentials where -- Use arrow rather than exponential notation for readability. infixr 9 _⇨_ _⇨_ : ∀ {a₁ a₂ a₃ b₁ b₂ b₃} → Poset a₁ a₂ a₃ → Poset b₁ b₂ b₃ → Poset (a₁ ⊔ a₃ ⊔ b₁ ⊔ b₃) (a₁ ⊔ b₂) (a₁ ⊔ b₃) A ⇨ B = record { Carrier = A ⇒ B ; _≈_ = _≗_ ; _≤_ = _≤°_ ; isPartialOrder = ≤°-isPartialOrder } module _ {a₁ a₂ a₃ b₁ b₂ b₃} {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where eval : (A ⇨ B × A) ⇒ B eval = record { fun = λ{ (f , x) → fun f x } ; monotone = λ{ {f , _} (f≤g , x≤y) → trans B (monotone f x≤y) f≤g } } module _ {c₁ c₂ c₃} {C : Poset c₁ c₂ c₃} where curry : (C × A) ⇒ B → C ⇒ (A ⇨ B) curry f = record { fun = λ x → record { fun = Prod.curry (fun f) x ; monotone = Prod.curry (monotone f) (refl C) } ; monotone = λ x≤y → monotone f (x≤y , refl A) } eval-comp : {f : (C × A) ⇒ B} → eval ∘ (curry f ×₁ id) ≗ f eval-comp = Eq.refl B curry-resp-≗ : {f g : (C × A) ⇒ B} → f ≗ g → curry f ≗ curry g curry-resp-≗ hyp = hyp curry-unique : {f : C ⇒ (A ⇨ B)} {g : (C × A) ⇒ B} → eval ∘ (f ×₁ id) ≗ g → f ≗ curry g curry-unique hyp = hyp open Exponentials -- The category of posets is cartesian closed. Posets-CanonicallyCCC : ∀ {a} → Canonical.CartesianClosed (Posets a a a) Posets-CanonicallyCCC = record { ! = ! ; π₁ = π₁ ; π₂ = π₂ ; ⟨_,_⟩ = ⟨_,_⟩ ; !-unique = !-unique ; π₁-comp = λ {_ _ f _ g} → π₁-comp {f = f} {g} ; π₂-comp = λ {_ _ f _ g} → π₂-comp {f = f} {g} ; ⟨,⟩-unique = λ {_ _ _ f g h} → ⟨,⟩-unique {f = f} {g} {h} ; eval = eval ; curry = curry ; eval-comp = λ {_ _ _ f} → eval-comp {f = f} ; curry-resp-≈ = λ {_ _ _ f g} → curry-resp-≗ {f = f} {g} ; curry-unique = λ {_ _ _ f g} → curry-unique {f = f} {g} } module CanonicallyCartesianClosed {a} = Canonical.CartesianClosed (Posets-CanonicallyCCC {a}) Posets-CCC : ∀ {a} → CCC.CartesianClosed (Posets a a a) Posets-CCC = Canonical.Equivalence.fromCanonical _ Posets-CanonicallyCCC module CartesianClosed {a} = CCC.CartesianClosed (Posets-CCC {a})
30
78
0.523096
319d97de71c9bed2bdfeadd123477bf96789dbe9
2,571
agda
Agda
Cubical/Algebra/RingSolver/Examples.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
1
2022-02-05T01:25:26.000Z
2022-02-05T01:25:26.000Z
Cubical/Algebra/RingSolver/Examples.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
null
null
null
Cubical/Algebra/RingSolver/Examples.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.RingSolver.Examples where open import Cubical.Foundations.Prelude open import Cubical.Data.Int.Base hiding (_+_ ; _·_ ; _-_) open import Cubical.Data.List open import Cubical.Algebra.CommRing open import Cubical.Algebra.RingSolver.Reflection private variable ℓ : Level module Test (R : CommRing ℓ) where open CommRingStr (snd R) _ : 0r ≡ 0r _ = solve R _ : 1r · (1r + 0r) ≡ (1r · 0r) + 1r _ = solve R _ : 1r · 0r + (1r - 1r) ≡ 0r - 0r _ = solve R _ : (x : fst R) → x ≡ x _ = solve R _ : (x y : fst R) → x ≡ x _ = solve R _ : (x y : fst R) → x + y ≡ y + x _ = solve R _ : (x y : fst R) → (x + y) · (x - y) ≡ x · x - y · y _ = solve R {- A bigger example, copied from the other example files: -} _ : (x y z : (fst R)) → (x + y) · (x + y) · (x + y) · (x + y) ≡ x · x · x · x + (fromℤ R 4) · x · x · x · y + (fromℤ R 6) · x · x · y · y + (fromℤ R 4) · x · y · y · y + y · y · y · y _ = solve R {- Examples that used to fail (see #513): -} _ : (x : (fst R)) → x · 0r ≡ 0r _ = solve R _ : (x y z : (fst R)) → x · (y - z) ≡ x · y - x · z _ = solve R {- Keep in mind, that the solver can lead to wrong error locations. For example, the commented code below tries to solve an equation that does not hold, with the result of an error at the wrong location. _ : (x y : (fst R)) → x ≡ y _ = solve R -} module TestInPlaceSolving (R : CommRing ℓ) where open CommRingStr (snd R) testWithOneVariabl : (x : fst R) → x + 0r ≡ 0r + x testWithOneVariabl x = solveInPlace R (x ∷ []) testEquationalReasoning : (x : fst R) → x + 0r ≡ 0r + x testEquationalReasoning x = x + 0r ≡⟨solveIn R withVars (x ∷ []) ⟩ 0r + x ∎ testWithTwoVariables : (x y : fst R) → x + y ≡ y + x testWithTwoVariables x y = x + y ≡⟨solveIn R withVars (x ∷ y ∷ []) ⟩ y + x ∎ {- So far, solving during equational reasoning has a serious restriction: The solver identifies variables by deBruijn indices and the variables appearing in the equations to solve need to have indices 0,...,n. This entails that in the following code, the order of 'p' and 'x' cannot be switched. -} testEquationalReasoning' : (p : (y : fst R) → 0r + y ≡ 1r) (x : fst R) → x + 0r ≡ 1r testEquationalReasoning' p x = x + 0r ≡⟨solveIn R withVars (x ∷ []) ⟩ 0r + x ≡⟨ p x ⟩ 1r ∎
26.234694
91
0.533644
1ead09884169fcc6397abdc5fce3982eee7b4000
1,183
agda
Agda
test/Fail/Issue399.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue399.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue399.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- 2011-04-12 AIM XIII fixed this issue by freezing metas after declaration (Andreas & Ulf) module Issue399 where open import Common.Prelude record MyMonadPlus m : Set₁ where field mzero : {a : Set} → m a → List a mplus : {a : Set} → m a → m a → List a -- this produces an unsolved meta variable, because it is not clear which -- level m has. m could be in Set -> Set or in Set -> Set1 -- if you uncomment the rest of the files, you get unsolved metas here {- Old error, without freezing: --Emacs error: and the 10th line is the above line --/home/j/dev/apps/haskell/agda/learn/bug-in-record.agda:10,36-39 --Set != Set₁ --when checking that the expression m a has type Set₁ -} mymaybemzero : {a : Set} → Maybe a → List a mymaybemzero nothing = [] mymaybemzero (just x) = x ∷ [] mymaybemplus : {a : Set} → Maybe a → Maybe a → List a mymaybemplus x y = (mymaybemzero x) ++ (mymaybemzero y) -- the following def gives a type error because of unsolved metas in MyMonadPlus -- if you uncomment it, you see m in MyMonadPlus yellow mymaybeMonadPlus : MyMonadPlus Maybe mymaybeMonadPlus = record { mzero = mymaybemzero ; mplus = mymaybemplus }
35.848485
91
0.690617
3830f492e0a01049f071c03cc3d7993c47e5f22b
3,783
agda
Agda
test/Succeed/Generalize.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Generalize.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Generalize.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --without-K --rewriting #-} module Generalize where open import Agda.Primitive -- Generalization in definitions module Definitions where variable ℓ : Level A B C : Set ℓ A₀ B₀ : Set a b c : A -- Function signature id : A → A id x = x -- Module signature module M (a : A) where identity = a -- Data parameters and constructors data Eq (a : A) : A → Setω where refl : Eq a a trans : Eq a b → Eq b c → Eq a c record R (a : A) : Set₁ where field fld : B₀ open M a alias = fld K : B → C → B K x _ = x field fld₁ : B₀ -- Original content (postulates only) data _≡_ {ℓ}{A : Set ℓ} (x : A) : A → Set ℓ where refl : x ≡ x infix 4 _≡_ {-# BUILTIN REWRITE _≡_ #-} ------------------------------------------------------------------ postulate Con : Set postulate Ty : (Γ : Con) → Set postulate Tms : (Γ Δ : Con) → Set postulate Tm : (Γ : Con)(A : Ty Γ) → Set ------------------------------------------------------------------ variable {Γ Δ Θ} : Con postulate • : Con -- • is \bub postulate _▹_ : ∀ Γ → Ty Γ → Con -- ▹ is \tw2 infixl 5 _▹_ variable {A B C} : Ty _ postulate _∘ᵀ_ : Ty Δ → Tms Γ Δ → Ty Γ infixl 6 _∘ᵀ_ variable {σ δ ν} : Tms _ _ postulate _∘_ : Tms Θ Δ → Tms Γ Θ → Tms Γ Δ infixr 7 _∘_ postulate id : Tms Γ Γ postulate ε : Tms Γ • postulate _,_ : (σ : Tms Γ Δ) → Tm Γ (A ∘ᵀ σ) → Tms Γ (Δ ▹ A) infixl 5 _,_ postulate π₁ : Tms Γ (Δ ▹ A) → Tms Γ Δ variable {t u v} : Tm _ _ postulate π₂ : (σ : Tms Γ (Δ ▹ A)) → Tm Γ (A ∘ᵀ π₁ σ) postulate _∘ᵗ_ : Tm Δ A → (σ : Tms Γ Δ) → Tm Γ (A ∘ᵀ σ) infixl 6 _∘ᵗ_ postulate ass : (σ ∘ δ) ∘ ν ≡ σ ∘ δ ∘ ν {-# REWRITE ass #-} postulate idl : id ∘ δ ≡ δ {-# REWRITE idl #-} postulate idr : δ ∘ id ≡ δ {-# REWRITE idr #-} postulate εη : δ ≡ ε -- can't rewrite, so we specialize this in the next two cases postulate εηid : id ≡ ε {-# REWRITE εηid #-} postulate εη∘ : ε ∘ δ ≡ ε {-# REWRITE εη∘ #-} postulate ,β₁ : π₁ (δ , t) ≡ δ {-# REWRITE ,β₁ #-} postulate ,β₂ : π₂ (δ , t) ≡ t {-# REWRITE ,β₂ #-} postulate ,η : (π₁ δ , π₂ δ) ≡ δ {-# REWRITE ,η #-} postulate [id]ᵀ : A ∘ᵀ id ≡ A {-# REWRITE [id]ᵀ #-} postulate [∘]ᵀ : A ∘ᵀ δ ∘ᵀ σ ≡ A ∘ᵀ δ ∘ σ {-# REWRITE [∘]ᵀ #-} postulate ,∘ : (δ , t) ∘ σ ≡ δ ∘ σ , t ∘ᵗ σ {-# REWRITE ,∘ #-} postulate [∘]ᵗ : t ∘ᵗ σ ∘ᵗ δ ≡ t ∘ᵗ σ ∘ δ {-# REWRITE [∘]ᵗ #-} postulate π₁∘ : π₁ δ ∘ σ ≡ π₁ (δ ∘ σ) {-# REWRITE π₁∘ #-} postulate π₂∘ : π₂ δ ∘ᵗ σ ≡ π₂ (δ ∘ σ) {-# REWRITE π₂∘ #-} postulate ∘id : t ∘ᵗ id ≡ t {-# REWRITE ∘id #-} _↑_ : ∀ σ A → Tms (Γ ▹ A ∘ᵀ σ) (Δ ▹ A) σ ↑ A = σ ∘ π₁ id , π₂ id ⟨_⟩ : Tm Γ A → Tms Γ (Γ ▹ A) ⟨ t ⟩ = id , t ------------------------------------------------------------------ postulate U : Ty Γ variable {a b c} : Tm _ U postulate El : Tm Γ U → Ty Γ postulate U[] : U ∘ᵀ σ ≡ U {-# REWRITE U[] #-} postulate El[] : El a ∘ᵀ σ ≡ El (a ∘ᵗ σ) {-# REWRITE El[] #-} ------------------------------------------------------------------ postulate Π : (a : Tm Γ U) → Ty (Γ ▹ El a) → Ty Γ postulate Π[] : Π a B ∘ᵀ σ ≡ Π (a ∘ᵗ σ) (B ∘ᵀ σ ↑ El a) {-# REWRITE Π[] #-} postulate app : Tm Γ (Π a B) → Tm (Γ ▹ El a) B postulate app[] : app t ∘ᵗ (σ ↑ El a) ≡ app (t ∘ᵗ σ) {-# REWRITE app[] #-}
26.270833
102
0.407084
22d5661f29f47946a06ebae8bba755c7e0082fb6
6,204
agda
Agda
LibraBFT/Yasm/AvailableEpochs.agda
haroldcarr/bft-consensus-agda
34e4627855fb198665d0c98f377403a906ba75d7
[ "UPL-1.0" ]
null
null
null
LibraBFT/Yasm/AvailableEpochs.agda
haroldcarr/bft-consensus-agda
34e4627855fb198665d0c98f377403a906ba75d7
[ "UPL-1.0" ]
null
null
null
LibraBFT/Yasm/AvailableEpochs.agda
haroldcarr/bft-consensus-agda
34e4627855fb198665d0c98f377403a906ba75d7
[ "UPL-1.0" ]
null
null
null
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude import Data.Vec.Relation.Unary.All as Vec-All import Data.Fin as Fin -- This module defines the EpochConfigs available in the system, along -- with a function to add a new EpochConfig and some properties that -- facilitate proofs across state transitions that add an EpochConfig. module LibraBFT.Yasm.AvailableEpochs (NodeId : Set) (ℓ-EC : Level) (EpochConfig : Set ℓ-EC) (epochId : EpochConfig → ℕ) (authorsN : EpochConfig → ℕ) where open import LibraBFT.Yasm.Base ℓ-EC EpochConfig epochId authorsN fin-lower-toℕ : ∀{e}(i : Fin (suc e))(prf : e ≢ toℕ i) → toℕ (Fin.lower₁ i prf) ≡ toℕ i fin-lower-toℕ {zero} zero prf = ⊥-elim (prf refl) fin-lower-toℕ {suc e} zero prf = refl fin-lower-toℕ {suc e} (suc i) prf = cong suc (fin-lower-toℕ i (prf ∘ cong suc)) toℕ-correct : ∀{n}(i : Fin n) → toℕ i < n toℕ-correct zero = s≤s z≤n toℕ-correct (suc i) = s≤s (toℕ-correct i) toℕ-inject₁-≡ : ∀{n}(i : Fin n) → toℕ i ≡ toℕ (Fin.inject₁ i) toℕ-inject₁-≡ zero = refl toℕ-inject₁-≡ (suc i) = cong suc (toℕ-inject₁-≡ i) lower₁-inject₁-id : ∀{n}(i : Fin n)(prf : n ≢ toℕ (Fin.inject₁ i)) → Fin.lower₁ (Fin.inject₁ i) prf ≡ i lower₁-inject₁-id zero prf = refl lower₁-inject₁-id (suc i) prf = cong suc (lower₁-inject₁-id i (prf ∘ cong suc)) fromℕ-≤-step-natural : ∀{n m}(prf : n < m) → fromℕ< (≤-step prf) ≡ Fin.inject₁ (fromℕ< prf) fromℕ-≤-step-natural (s≤s z≤n) = refl fromℕ-≤-step-natural (s≤s (s≤s prf)) = cong suc (fromℕ-≤-step-natural (s≤s prf)) Vec-All-lookup∘tabulate : ∀{n}{A : Set}{v : Vec A n}{ℓ : Level}{P : A → Set ℓ} → (f : (x : Fin n) → P (Vec-lookup v x))(i : Fin n) → Vec-All.lookup {P = P} i (Vec-All.tabulate {xs = v} f) ≡ f i Vec-All-lookup∘tabulate {v = v₀ ∷ vs} f zero = refl Vec-All-lookup∘tabulate {v = v₀ ∷ vs} f (suc i) = Vec-All-lookup∘tabulate (f ∘ suc) i subst-elim : {A : Set}{ℓ : Level}(P : A → Set ℓ){a₀ a₁ : A} → (prf : a₀ ≡ a₁)(x : P a₁) → subst P prf (subst P (sym prf) x) ≡ x subst-elim _ refl x = refl -- Available epochs consist of a vector of EpochConfigs with -- the correct epoch ids. AvailableEpochs : ℕ → Set ℓ-EC AvailableEpochs = Vec-All (EpochConfigFor ∘ toℕ) ∘ Vec-allFin lookup : ∀{e} → AvailableEpochs e → (ix : Fin e) → EpochConfigFor (toℕ ix) lookup 𝓔s ix = subst EpochConfigFor (cong toℕ (Vec-lookup∘tabulate id ix)) (Vec-All-lookup ix 𝓔s) lookup' : ∀{e} → AvailableEpochs e → Fin e → EpochConfig lookup' 𝓔s ix = EpochConfigFor.epochConfig (lookup 𝓔s ix) lookup'' : ∀{e m} → AvailableEpochs e → m < e → EpochConfig lookup'' 𝓔s ix = lookup' 𝓔s (fromℕ< ix) lookup-𝓔s-injective : ∀ {e m1 m2} → (𝓔s : AvailableEpochs e) → (p1 : m1 < e) → (p2 : m2 < e) → m1 ≡ m2 → lookup'' 𝓔s p1 ≡ lookup'' 𝓔s p2 lookup-𝓔s-injective {e} 𝓔s p1 p2 refl = cong (lookup'' 𝓔s) (<-irrelevant p1 p2) -- The /transpose/ of append is defined by the semantics of a lookup -- over an append; the /append/ function below is defined by tabulating this -- monster. appendᵀ : ∀{e} → EpochConfigFor e → AvailableEpochs e → (i : Fin (suc e)) → EpochConfigFor (toℕ i) appendᵀ {e} ecf al i with e ≟ℕ toℕ i ...| yes e≡i = subst EpochConfigFor e≡i ecf ...| no prf = subst EpochConfigFor (trans (cong toℕ (Vec-lookup∘tabulate id (Fin.lower₁ i prf))) (fin-lower-toℕ i prf)) (Vec-All-lookup (Fin.lower₁ i prf) al) -- Append is defined by tabulating appendᵀ append : ∀{e} → EpochConfigFor e → AvailableEpochs e → AvailableEpochs (suc e) append {e} ecf al = Vec-All.tabulate (λ i → subst (EpochConfigFor) (sym (cong toℕ (Vec-lookup∘tabulate id i))) (appendᵀ ecf al i)) lookup-append-lemma : ∀{e}(𝓔s : AvailableEpochs e)(𝓔 : EpochConfigFor e)(ix : Fin (suc e)) → lookup (append 𝓔 𝓔s) ix ≡ appendᵀ 𝓔 𝓔s ix lookup-append-lemma al ecf ix rewrite Vec-All-lookup∘tabulate {v = zero ∷ Vec-tabulate suc} {P = EpochConfigFor ∘ toℕ} (λ i → subst EpochConfigFor (sym (cong toℕ (Vec-lookup∘tabulate id i))) (appendᵀ ecf al i)) ix = subst-elim EpochConfigFor (cong toℕ (Vec-lookup∘tabulate id ix)) (appendᵀ ecf al ix) -- Ok, let's bring in the big guns import Relation.Binary.HeterogeneousEquality as HE append-inject₁-lemma : ∀{e}(𝓔s : AvailableEpochs e)(𝓔 : EpochConfigFor e)(ix : Fin e) → appendᵀ 𝓔 𝓔s (Fin.inject₁ ix) ≅ lookup 𝓔s ix append-inject₁-lemma {e} 𝓔s 𝓔 ix with e ≟ℕ (toℕ (Fin.inject₁ ix)) ...| yes abs = ⊥-elim (<⇒≢ (toℕ-correct ix) (trans (toℕ-inject₁-≡ ix) (sym abs))) ...| no prf = HE.trans (HE.≡-subst-removable EpochConfigFor (trans (cong toℕ (Vec-lookup∘tabulate id (Fin.lower₁ (Fin-inject₁ ix) prf))) (fin-lower-toℕ (Fin.inject₁ ix) prf)) (Vec-All-lookup (Fin.lower₁ (Fin.inject₁ ix) prf) 𝓔s)) (HE.trans (≅-cong (λ P → Vec-All-lookup P 𝓔s) (HE.≡-to-≅ (lower₁-inject₁-id ix prf))) (HE.sym (HE.≡-subst-removable EpochConfigFor (cong toℕ (Vec-lookup∘tabulate id ix)) (Vec-All-lookup ix 𝓔s)))) lookup''-≤-step-lemma : ∀{e m}(𝓔s : AvailableEpochs e)(𝓔 : EpochConfigFor e)(prf : m < e) → lookup'' (append 𝓔 𝓔s) (≤-step prf) ≡ lookup'' 𝓔s prf lookup''-≤-step-lemma al ecf prf rewrite fromℕ-≤-step-natural prf | lookup-append-lemma al ecf (Fin.inject₁ (fromℕ< prf)) = ECF-cong (append-inject₁-lemma al ecf (fromℕ< prf)) (sym (toℕ-inject₁-≡ (fromℕ< prf))) where ECF-cong : ∀{e e'}{ef : EpochConfigFor e}{ef' : EpochConfigFor e'} → ef ≅ ef' → e ≡ e' → EpochConfigFor.epochConfig ef ≡ EpochConfigFor.epochConfig ef' ECF-cong {e} {e'} {ef} {ef'} HE.refl refl = refl
46.646617
111
0.602192
2eab3cb58e3354763db92efc968e2dc73f9ba5f8
287
agda
Agda
test/Succeed/MeasureMutual.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/MeasureMutual.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/MeasureMutual.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- In a mutual block, either all or none must have a MEASURE declaration. module _ where open import Common.Prelude mutual {-# MEASURE n #-} f : (n : Nat) → Nat f zero = zero f (suc n) = g n {-# MEASURE n #-} g : (n : Nat) → Nat g zero = zero g (suc n) = suc (f n)
15.105263
73
0.571429
591d54bb6a43c369069bb7c1d91322165abcef76
527
agda
Agda
test/Compiler/simple/String.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
test/Compiler/simple/String.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
test/Compiler/simple/String.agda
redfish64/autonomic-agda
c0ae7d20728b15d7da4efff6ffadae6fe4590016
[ "BSD-3-Clause" ]
null
null
null
module String where open import Common.IO open import Common.List open import Common.String open import Common.Unit testString : String testString = "To boldly go where no man gone before" printList : {A : Set} -> (A -> IO Unit) -> List A -> IO Unit printList p [] = return unit printList p (x ∷ xs) = p x ,, printList p xs main : IO Unit main = putStrLn testString ,, printList printChar (stringToList testString) ,, putStrLn "" ,, putStrLn (fromList (stringToList testString)) ,, return unit
21.08
60
0.681214
1cdf4b0d396c68edbc31461190b0c4126a433a76
574
agda
Agda
agda-stdlib/src/Data/List/Relation/BagAndSetEquality.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/List/Relation/BagAndSetEquality.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/List/Relation/BagAndSetEquality.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.BagAndSetEquality directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.BagAndSetEquality where open import Data.List.Relation.Binary.BagAndSetEquality public {-# WARNING_ON_IMPORT "Data.List.Relation.BagAndSetEquality was deprecated in v1.0. Use Data.List.Relation.Binary.BagAndSetEquality instead." #-}
31.888889
72
0.583624
9a08f0c6f7adbf3a8974031fc211de8cd979cfbd
1,735
agda
Agda
Cubical/Data/Vec/NAry.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Data/Vec/NAry.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Data/Vec/NAry.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{-# OPTIONS --safe #-} module Cubical.Data.Vec.NAry where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Data.Nat open import Cubical.Data.Vec.Base private variable ℓ ℓ' : Level A : Type ℓ B : Type ℓ' nAryLevel : Level → Level → ℕ → Level nAryLevel ℓ₁ ℓ₂ zero = ℓ₂ nAryLevel ℓ₁ ℓ₂ (suc n) = ℓ-max ℓ₁ (nAryLevel ℓ₁ ℓ₂ n) nAryOp : (n : ℕ) → Type ℓ → Type ℓ' → Type (nAryLevel ℓ ℓ' n) nAryOp zero A B = B nAryOp (suc n) A B = A → nAryOp n A B _$ⁿ_ : ∀ {n} → nAryOp n A B → (Vec A n → B) f $ⁿ [] = f f $ⁿ (x ∷ xs) = f x $ⁿ xs curryⁿ : ∀ {n} → (Vec A n → B) → nAryOp n A B curryⁿ {n = zero} f = f [] curryⁿ {n = suc n} f x = curryⁿ (λ xs → f (x ∷ xs)) $ⁿ-curryⁿ : ∀ {n} (f : Vec A n → B) → _$ⁿ_ (curryⁿ f) ≡ f $ⁿ-curryⁿ {n = zero} f = funExt λ { [] → refl } $ⁿ-curryⁿ {n = suc n} f = funExt λ { (x ∷ xs) i → $ⁿ-curryⁿ {n = n} (λ ys → f (x ∷ ys)) i xs} curryⁿ-$ⁿ : ∀ {n} (f : nAryOp {ℓ = ℓ} {ℓ' = ℓ'} n A B) → curryⁿ {A = A} {B = B} (_$ⁿ_ f) ≡ f curryⁿ-$ⁿ {n = zero} f = refl curryⁿ-$ⁿ {n = suc n} f = funExt λ x → curryⁿ-$ⁿ {n = n} (f x) nAryOp≃VecFun : ∀ {n} → nAryOp n A B ≃ (Vec A n → B) nAryOp≃VecFun {n = n} = isoToEquiv f where f : Iso (nAryOp n A B) (Vec A n → B) Iso.fun f = _$ⁿ_ Iso.inv f = curryⁿ Iso.rightInv f = $ⁿ-curryⁿ Iso.leftInv f = curryⁿ-$ⁿ {n = n} -- In order to apply ua to nAryOp≃VecFun we probably need to change -- the base-case of nAryLevel to "ℓ-max ℓ₁ ℓ₂". This will make it -- necessary to add lots of Lifts in zero cases so it's not done yet, -- but if the Path is ever needed then it might be worth to do.
30.982143
93
0.591931
9a85e2af15d6e02d3cec06192c38a9003f7ba52f
256
agda
Agda
problems/UniverseCollapse/Verifier.agda
danr/agder
ece25bed081a24f02e9f85056d05933eae2afabf
[ "BSD-3-Clause" ]
1
2021-05-17T12:07:03.000Z
2021-05-17T12:07:03.000Z
problems/UniverseCollapse/Verifier.agda
danr/agder
ece25bed081a24f02e9f85056d05933eae2afabf
[ "BSD-3-Clause" ]
null
null
null
problems/UniverseCollapse/Verifier.agda
danr/agder
ece25bed081a24f02e9f85056d05933eae2afabf
[ "BSD-3-Clause" ]
null
null
null
module Verifier (down : Set₁ -> Set) (up : Set → Set₁) (iso : ∀ {A} → down (up A) -> A) (osi : ∀ {A} → up (down A) -> A) where import UniverseCollapse as UC open UC down up iso osi using (anything) check : (A : Set) -> A check = anything
21.333333
42
0.558594
9a8ae940936d8b376be9601d733037f5633eca88
64
agda
Agda
test/Fail/Issue4373/A.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue4373/A.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue4373/A.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue4373.A where postulate T : Set instance t : T
9.142857
24
0.6875
4b6336843edd74997942d3a1af4cee2650bdb5c8
6,279
agda
Agda
src/Categories/Adjoint/Alternatives.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Adjoint/Alternatives.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Adjoint/Alternatives.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Adjoint.Alternatives where open import Level open import Categories.Adjoint open import Categories.Category open import Categories.Functor renaming (id to idF) open import Categories.NaturalTransformation import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level C D : Category o ℓ e module _ (L : Functor C D) (R : Functor D C) where private module C = Category C module D = Category D module L = Functor L module R = Functor R record FromUnit : Set (levelOfTerm L ⊔ levelOfTerm R) where field unit : NaturalTransformation idF (R ∘F L) module unit = NaturalTransformation unit field θ : ∀ {X Y} → C [ X , R.₀ Y ] → D [ L.₀ X , Y ] commute : ∀ {X Y} (g : C [ X , R.₀ Y ]) → g C.≈ R.₁ (θ g) C.∘ unit.η X unique : ∀ {X Y} {f : D [ L.₀ X , Y ]} {g : C [ X , R.₀ Y ]} → g C.≈ R.₁ f C.∘ unit.η X → θ g D.≈ f module _ where open C.HomReasoning open MR C θ-natural : ∀ {X Y Z} (f : D [ Y , Z ]) (g : C [ X , R.₀ Y ]) → θ (R.₁ f C.∘ g) D.≈ θ (R.₁ f) D.∘ L.₁ g θ-natural {X} {Y} f g = unique eq where eq : R.₁ f C.∘ g C.≈ R.₁ (θ (R.₁ f) D.∘ L.₁ g) C.∘ unit.η X eq = begin R.₁ f C.∘ g ≈⟨ commute (R.₁ f) ⟩∘⟨refl ⟩ (R.₁ (θ (R.₁ f)) C.∘ unit.η (R.F₀ Y)) C.∘ g ≈⟨ C.assoc ⟩ R.₁ (θ (R.₁ f)) C.∘ unit.η (R.₀ Y) C.∘ g ≈⟨ pushʳ (unit.commute g) ⟩ (R.₁ (θ (R.₁ f)) C.∘ R.₁ (L.₁ g)) C.∘ unit.η X ≈˘⟨ R.homomorphism ⟩∘⟨refl ⟩ R.₁ (θ (R.₁ f) D.∘ L.₁ g) C.∘ unit.η X ∎ θ-cong : ∀ {X Y} {f g : C [ X , R.₀ Y ]} → f C.≈ g → θ f D.≈ θ g θ-cong eq = unique (eq ○ commute _) θ-natural′ : ∀ {X Y} (g : C [ X , R.₀ Y ]) → θ g D.≈ θ C.id D.∘ L.₁ g θ-natural′ g = θ-cong (introˡ R.identity) ○ θ-natural D.id g ○ D.∘-resp-≈ˡ (θ-cong R.identity) where open D.HomReasoning open MR C counit : NaturalTransformation (L ∘F R) idF counit = ntHelper record { η = λ d → θ C.id ; commute = λ f → begin θ C.id D.∘ L.₁ (R.₁ f) ≈˘⟨ θ-natural′ (R.₁ f) ⟩ θ (R.₁ f) ≈⟨ unique (CH.⟺ (MR.cancelʳ C (CH.⟺ (commute C.id))) CH.○ CH.⟺ (C.∘-resp-≈ˡ R.homomorphism)) ⟩ f D.∘ θ C.id ∎ } where open D.HomReasoning module CH = C.HomReasoning unique′ : ∀ {X Y} {f g : D [ L.₀ X , Y ]} (h : C [ X , R.₀ Y ]) → h C.≈ R.₁ f C.∘ unit.η X → h C.≈ R.₁ g C.∘ unit.η X → f D.≈ g unique′ _ eq₁ eq₂ = ⟺ (unique eq₁) ○ unique eq₂ where open D.HomReasoning zig : ∀ {A} → θ C.id D.∘ L.F₁ (unit.η A) D.≈ D.id zig {A} = unique′ (unit.η A) (commute (unit.η A) ○ (C.∘-resp-≈ˡ (R.F-resp-≈ (θ-natural′ (unit.η A))))) (introˡ R.identity) where open C.HomReasoning open MR C L⊣R : L ⊣ R L⊣R = record { unit = unit ; counit = counit ; zig = zig ; zag = C.Equiv.sym (commute C.id) } record FromCounit : Set (levelOfTerm L ⊔ levelOfTerm R) where field counit : NaturalTransformation (L ∘F R) idF module counit = NaturalTransformation counit field θ : ∀ {X Y} → D [ L.₀ X , Y ] → C [ X , R.₀ Y ] commute : ∀ {X Y} (g : D [ L.₀ X , Y ]) → g D.≈ counit.η Y D.∘ L.₁ (θ g) unique : ∀ {X Y} {f : C [ X , R.₀ Y ]} {g : D [ L.₀ X , Y ]} → g D.≈ counit.η Y D.∘ L.₁ f → θ g C.≈ f module _ where open D.HomReasoning open MR D θ-natural : ∀ {X Y Z} (f : C [ X , Y ]) (g : D [ L.₀ Y , Z ]) → θ (g D.∘ L.₁ f) C.≈ R.₁ g C.∘ θ (L.₁ f) θ-natural {X} {Y} {Z} f g = unique eq where eq : g D.∘ L.₁ f D.≈ counit.η Z D.∘ L.₁ (R.₁ g C.∘ θ (L.₁ f)) eq = begin g D.∘ L.₁ f ≈⟨ pushʳ (commute (L.₁ f)) ⟩ (g D.∘ counit.η (L.F₀ Y)) D.∘ L.F₁ (θ (L.F₁ f)) ≈⟨ pushˡ (counit.sym-commute g) ⟩ counit.η Z D.∘ L.₁ (R.₁ g) D.∘ L.₁ (θ (L.₁ f)) ≈˘⟨ refl⟩∘⟨ L.homomorphism ⟩ counit.η Z D.∘ L.₁ (R.₁ g C.∘ θ (L.₁ f)) ∎ θ-cong : ∀ {X Y} {f g : D [ L.₀ X , Y ]} → f D.≈ g → θ f C.≈ θ g θ-cong eq = unique (eq ○ commute _) θ-natural′ : ∀ {X Y} (g : D [ L.₀ X , Y ]) → θ g C.≈ R.₁ g C.∘ θ D.id θ-natural′ g = θ-cong (introʳ L.identity) ○ θ-natural C.id g ○ C.∘-resp-≈ʳ (θ-cong L.identity) where open C.HomReasoning open MR D unit : NaturalTransformation idF (R ∘F L) unit = ntHelper record { η = λ _ → θ D.id ; commute = λ f → begin θ D.id C.∘ f ≈˘⟨ unique (DH.⟺ (cancelˡ (DH.⟺ (commute D.id))) DH.○ D.∘-resp-≈ʳ (DH.⟺ L.homomorphism)) ⟩ θ (L.₁ f) ≈⟨ θ-natural′ (L.₁ f) ⟩ R.₁ (L.₁ f) C.∘ θ D.id ∎ } where open C.HomReasoning module DH = D.HomReasoning open MR D unique′ : ∀ {X Y} {f g : C [ X , R.₀ Y ]} (h : D [ L.₀ X , Y ]) → h D.≈ counit.η Y D.∘ L.₁ f → h D.≈ counit.η Y D.∘ L.₁ g → f C.≈ g unique′ _ eq₁ eq₂ = ⟺ (unique eq₁) ○ unique eq₂ where open C.HomReasoning zag : ∀ {B} → R.F₁ (counit.η B) C.∘ θ D.id C.≈ C.id zag {B} = unique′ (counit.η B) (⟺ (cancelʳ (⟺ (commute D.id))) ○ pushˡ (counit.sym-commute (counit.η B)) ○ D.∘-resp-≈ʳ (⟺ L.homomorphism)) (introʳ L.identity) where open D.HomReasoning open MR D L⊣R : L ⊣ R L⊣R = record { unit = unit ; counit = counit ; zig = D.Equiv.sym (commute D.id) ; zag = zag } module _ {L : Functor C D} {R : Functor D C} where fromUnit : FromUnit L R → L ⊣ R fromUnit = FromUnit.L⊣R fromCounit : FromCounit L R → L ⊣ R fromCounit = FromCounit.L⊣R
37.375
131
0.437649
231af088296786b8be4bf4aff68187682791b568
25,913
agda
Agda
src/Categories/Functor/Monoidal/PointwiseTensor.agda
yourboynico/agda-categories
6a087c592dbe58fc4bd9d02e1be9b94a9e138aca
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Functor/Monoidal/PointwiseTensor.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Functor/Monoidal/PointwiseTensor.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Monoidal using (SymmetricMonoidalCategory) -- The monoidal structure of a monoidal catgeory D -- lifted pointwise to monoidal functors F : C → D. module Categories.Functor.Monoidal.PointwiseTensor {o o′ ℓ ℓ′ e e′} {C : SymmetricMonoidalCategory o ℓ e} {D : SymmetricMonoidalCategory o′ ℓ′ e′} where open import Level using (_⊔_) open import Data.Product using (_,_) private module C = SymmetricMonoidalCategory C module D = SymmetricMonoidalCategory D open import Categories.Category using (module Commutation) open import Categories.Category.Product using (_⁂_) import Categories.Category.Construction.Core as Core import Categories.Functor as Func open import Categories.Category.Monoidal.Properties using (module Kelly's) open import Categories.Category.Monoidal.Braided.Properties D.braided as BraidedProps using (braiding-coherence) open import Categories.Category.Monoidal.Reasoning D.monoidal open import Categories.Category.Monoidal.Utilities D.monoidal open import Categories.Functor.Construction.Constant using (const) open import Categories.Functor.Monoidal.Tensor using (module LaxSymmetric; module StrongSymmetric) import Categories.Functor.Monoidal.Symmetric as SF open import Categories.Morphism.Reasoning D.U open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper) import Categories.NaturalTransformation.Monoidal.Symmetric as SMNT import Categories.NaturalTransformation.NaturalIsomorphism as NI import Categories.NaturalTransformation.NaturalIsomorphism.Monoidal.Symmetric as SMNI open D hiding (U) renaming (unitorˡ to λᵢ; unitorʳ to ρᵢ; associator to αᵢ) open Commutation D.U open Core.Shorthands D.U open Kelly's D.monoidal open Shorthands -- for λ⇒, ρ⇒, α⇒, ... open BraidedProps.Shorthands -- for σ⇒, ... module Underlying where open Func hiding (id) open NI private infix 4 _⇛_ _⇛_ = NaturalTransformation infixr 10 _⊗̇₀_ _⊗̇₁_ -- The pointwise tensor product of two functors. -- -- NOTE: the definition of _⊗̇₀_ is a manual expansion of the functor -- composition -- -- F ⊗̇₀ G = ⊗ ∘ (F × G) ∘ Δ -- -- where Δ : D → D × D is the diagonal functor. _⊗̇₀_ : (F G : Functor C.U D.U) → Functor C.U D.U F ⊗̇₀ G = record { F₀ = λ X → F.₀ X ⊗₀ G.₀ X ; F₁ = λ f → F.₁ f ⊗₁ G.₁ f ; identity = (F.identity ⟩⊗⟨ G.identity) ○ ⊗.identity ; homomorphism = (F.homomorphism ⟩⊗⟨ G.homomorphism) ○ ⊗.homomorphism ; F-resp-≈ = λ eq → F.F-resp-≈ eq ⟩⊗⟨ G.F-resp-≈ eq } where module F = Functor F module G = Functor G _⊗̇₁_ : {F₁ F₂ G₁ G₂ : Functor C.U D.U} → F₁ ⇛ F₂ → G₁ ⇛ G₂ → F₁ ⊗̇₀ G₁ ⇛ F₂ ⊗̇₀ G₂ _⊗̇₁_ {F₁} {F₂} {G₁} {G₂} β γ = ntHelper (record { η = λ X → β.η X ⊗₁ γ.η X ; commute = λ {X Y} f → begin β.η Y ⊗₁ γ.η Y ∘ F₁.₁ f ⊗₁ G₁.₁ f ≈˘⟨ ⊗.homomorphism ⟩ (β.η Y ∘ F₁.₁ f) ⊗₁ (γ.η Y ∘ G₁.₁ f) ≈⟨ β.commute f ⟩⊗⟨ γ.commute f ⟩ (F₂.₁ f ∘ β.η X) ⊗₁ (G₂.₁ f ∘ γ.η X) ≈⟨ ⊗.homomorphism ⟩ F₂.₁ f ⊗₁ G₂.₁ f ∘ β.η X ⊗₁ γ.η X ∎ }) where module F₁ = Functor F₁ module F₂ = Functor F₂ module G₁ = Functor G₁ module G₂ = Functor G₂ module β = NaturalTransformation β module γ = NaturalTransformation γ -- The constant functor to the unit in D. unitF : Functor C.U D.U unitF = const D.unit module unitF = Functor unitF unitF-⊗-homo : D.⊗ ∘F (unitF ⁂ unitF) ≃ unitF ∘F C.⊗ unitF-⊗-homo = niHelper (record { η = λ _ → λ⇒ ; η⁻¹ = λ _ → λ⇐ ; commute = λ _ → begin λ⇒ ∘ id ⊗₁ id ≈⟨ refl⟩∘⟨ ⊗.identity ⟩ λ⇒ ∘ id ≈⟨ id-comm ⟩ id ∘ λ⇒ ∎ ; iso = λ _ → λᵢ.iso }) module unitF-⊗-homo = NaturalIsomorphism unitF-⊗-homo -- The pointwise tensor product and the unit functor induce a -- symmetric monoidal structure on symmetric monoidal functors. ⊗̇-unitorˡ : {F : Functor C.U D.U} → unitF ⊗̇₀ F ≃ F ⊗̇-unitorˡ {F} = niHelper (record { η = λ _ → λ⇒ ; η⁻¹ = λ _ → λ⇐ ; commute = λ _ → unitorˡ-commute-from ; iso = λ _ → λᵢ.iso }) ⊗̇-unitorʳ : {F : Functor C.U D.U} → F ⊗̇₀ unitF ≃ F ⊗̇-unitorʳ {F} = niHelper (record { η = λ _ → ρ⇒ ; η⁻¹ = λ _ → ρ⇐ ; commute = λ _ → unitorʳ-commute-from ; iso = λ _ → ρᵢ.iso }) ⊗̇-associator : {F G H : Functor C.U D.U} → (F ⊗̇₀ G) ⊗̇₀ H ≃ F ⊗̇₀ (G ⊗̇₀ H) ⊗̇-associator {F} {G} {H} = niHelper (record { η = λ _ → α⇒ ; η⁻¹ = λ _ → α⇐ ; commute = λ _ → assoc-commute-from ; iso = λ _ → αᵢ.iso }) ⊗̇-braiding : {F G : Functor C.U D.U} → F ⊗̇₀ G ≃ G ⊗̇₀ F ⊗̇-braiding {F} {G} = niHelper (record { η = λ X → braiding.⇒.η (F.₀ X , G.₀ X) ; η⁻¹ = λ X → braiding.⇐.η (F.₀ X , G.₀ X) ; commute = λ f → braiding.⇒.commute (F.₁ f , G.₁ f) ; iso = λ X → braiding.iso (F.₀ X , G.₀ X) }) where module F = Functor F module G = Functor G -- Shorthands for the interchange map that makes ⊗ a strong symmetric -- monoidal functor. open StrongSymmetric D.symmetric using ()renaming ( ⊗-SymmetricMonoidalFunctor to ⊗ˢ ; ⊗-homo-iso to i-iso′ ; ⊗-homo-selfInverse to i-selfInverse ) private module ⊗ˢ = SF.Strong.SymmetricMonoidalFunctor ⊗ˢ module interchange = ⊗ˢ.⊗-homo i = interchange.FX≅GX i⇒ = λ {W X Y Z} → interchange.⇒.η ((W , X) , (Y , Z)) i⇐ = λ {W X Y Z} → interchange.⇐.η ((W , X) , (Y , Z)) module Lax where open SF.Lax open SMNT.Lax using (SymmetricMonoidalNaturalTransformation) open SMNI.Lax using (SymmetricMonoidalNaturalIsomorphism; _≃_) private infix 4 _⇛_ _⇛_ = SymmetricMonoidalNaturalTransformation infixr 10 _⊗̇₀_ _⊗̇₁_ -- The pointwise tensor product of lax symmetric monoidal functors. -- -- NOTE: the definition of _⊗̇₀_ is a manual expansion of the -- (lax monoidal) functor composition -- -- F ⊗̇₀ G = ⊗ ∘ (F × G) ∘ Δ -- -- with Δ : D → D × D the diagonal functor. We could define _⊗̇₀_ in -- this way but that would clutter the definition of ε and ⊗-homo -- with extra identities that then need to be dealt with elsewhere -- (e.g. in the definition of _⊗̇₁_ below. In principle, _⊗̇₁_ should -- be similarly definable as a composition of (monoidal) natural -- transformations, but the Agda type checker seems to choke on -- definitions involving compositions of natural transformations. _⊗̇₀_ : (F G : SymmetricMonoidalFunctor C D) → SymmetricMonoidalFunctor C D F ⊗̇₀ G = record { F = F.F Underlying.⊗̇₀ G.F ; isBraidedMonoidal = record { isMonoidal = record { ε = F.ε ⊗₁ G.ε ∘ λ⇐ ; ⊗-homo = ntHelper (record { η = λ _ → Fh ⊗₁ Gh ∘ i⇒ ; commute = λ{ (f , g) → commute f g } }) ; associativity = associativity ; unitaryˡ = unitaryˡ ; unitaryʳ = unitaryʳ } ; braiding-compat = braiding-compat } } where module F = SymmetricMonoidalFunctor F module G = SymmetricMonoidalFunctor G Fh = λ {X Y} → F.⊗-homo.η (X , Y) Gh = λ {X Y} → G.⊗-homo.η (X , Y) Cλ⇒ = λ {X} → C.braided.unitorˡ.from {X} Cρ⇒ = λ {X} → C.braided.unitorʳ.from {X} Cα⇒ = λ {X Y Z} → C.braided.associator.from {X} {Y} {Z} Cσ⇒ = λ {X Y} → C.braided.braiding.⇒.η (X , Y) commute : ∀ {W X Y Z} (f : W C.⇒ X) (g : Y C.⇒ Z) → (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.₁ f ⊗₁ G.₁ f) ⊗₁ (F.₁ g ⊗₁ G.₁ g) ≈ F.₁ (f C.⊗₁ g) ⊗₁ G.₁ (f C.⊗₁ g) ∘ (Fh ⊗₁ Gh) ∘ i⇒ commute f g = begin (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.₁ f ⊗₁ G.₁ f) ⊗₁ (F.₁ g ⊗₁ G.₁ g) ≈⟨ pullʳ (interchange.⇒.commute ((F.₁ f , G.₁ f) , (F.₁ g , G.₁ g))) ⟩ Fh ⊗₁ Gh ∘ (F.₁ f ⊗₁ F.₁ g) ⊗₁ (G.₁ f ⊗₁ G.₁ g) ∘ i⇒ ≈˘⟨ pushˡ ⊗.homomorphism ⟩ (Fh ∘ F.₁ f ⊗₁ F.₁ g) ⊗₁ (Gh ∘ G.₁ f ⊗₁ G.₁ g) ∘ i⇒ ≈⟨ F.⊗-homo.commute (f , g) ⟩⊗⟨ G.⊗-homo.commute (f , g) ⟩∘⟨refl ⟩ (F.₁ (f C.⊗₁ g) ∘ Fh) ⊗₁ (G.₁ (f C.⊗₁ g) ∘ Gh) ∘ i⇒ ≈⟨ pushˡ ⊗.homomorphism ⟩ F.₁ (f C.⊗₁ g) ⊗₁ G.₁ (f C.⊗₁ g) ∘ (Fh ⊗₁ Gh) ∘ i⇒ ∎ associativity : ∀ {X Y Z} → [ ((F.₀ X ⊗₀ G.₀ X) ⊗₀ (F.₀ Y ⊗₀ G.₀ Y)) ⊗₀ (F.₀ Z ⊗₀ G.₀ Z) ⇒ F.₀ (X C.⊗₀ (Y C.⊗₀ Z)) ⊗₀ G.₀ (X C.⊗₀ (Y C.⊗₀ Z)) ]⟨ F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (Fh ⊗₁ Gh ∘ i⇒) ⊗₁ id ≈ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (Fh ⊗₁ Gh ∘ i⇒) ∘ α⇒ ⟩ associativity = begin F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (Fh ⊗₁ Gh ∘ i⇒) ⊗₁ id ≈⟨ refl⟩∘⟨ pullʳ (refl⟩∘⟨ split₁ˡ) ⟩ F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ Fh ⊗₁ Gh ∘ i⇒ ∘ (Fh ⊗₁ Gh) ⊗₁ id ∘ i⇒ ⊗₁ id ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl ⟩ F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ Fh ⊗₁ Gh ∘ i⇒ ∘ (Fh ⊗₁ Gh) ⊗₁ (id ⊗₁ id) ∘ i⇒ ⊗₁ id ≈⟨ refl⟩∘⟨ refl⟩∘⟨ extendʳ (interchange.⇒.commute ((Fh , Gh) , (id , id))) ⟩ F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ Fh ⊗₁ Gh ∘ (Fh ⊗₁ id) ⊗₁ (Gh ⊗₁ id) ∘ i⇒ ∘ i⇒ ⊗₁ id ≈˘⟨ refl⟩∘⟨ pushˡ ⊗.homomorphism ⟩ F.₁ Cα⇒ ⊗₁ G.₁ Cα⇒ ∘ (Fh ∘ Fh ⊗₁ id) ⊗₁ (Gh ∘ Gh ⊗₁ id) ∘ i⇒ ∘ i⇒ ⊗₁ id ≈⟨ extendʳ (parallel (F.associativity ○ sym-assoc) (G.associativity ○ sym-assoc)) ⟩ (Fh ∘ id ⊗₁ Fh) ⊗₁ (Gh ∘ id ⊗₁ Gh) ∘ α⇒ ⊗₁ α⇒ ∘ i⇒ ∘ i⇒ ⊗₁ id ≈⟨ ⊗.homomorphism ⟩∘⟨ ⊗ˢ.associativity ⟩ ((Fh ⊗₁ Gh) ∘ (id ⊗₁ Fh) ⊗₁ (id ⊗₁ Gh)) ∘ i⇒ ∘ id ⊗₁ i⇒ ∘ α⇒ ≈˘⟨ pushʳ (extendʳ (interchange.⇒.commute ((id , id) , (Fh , Gh)))) ⟩ (Fh ⊗₁ Gh) ∘ i⇒ ∘ (id ⊗₁ id) ⊗₁ (Fh ⊗₁ Gh) ∘ id ⊗₁ i⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩ (Fh ⊗₁ Gh) ∘ i⇒ ∘ id ⊗₁ (Fh ⊗₁ Gh) ∘ id ⊗₁ i⇒ ∘ α⇒ ≈˘⟨ pullʳ (refl⟩∘⟨ pushˡ split₂ˡ) ⟩ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (Fh ⊗₁ Gh ∘ i⇒) ∘ α⇒ ∎ unitaryˡ : ∀ {X} → [ unit ⊗₀ (F.₀ X ⊗₀ G.₀ X) ⇒ F.₀ X ⊗₀ G.₀ X ]⟨ F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε ∘ λ⇐) ⊗₁ id ≈ λ⇒ ⟩ unitaryˡ = begin F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε ∘ λ⇐) ⊗₁ id ≈⟨ refl⟩∘⟨ refl⟩∘⟨ split₁ˡ ⟩ F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε) ⊗₁ id ∘ λ⇐ ⊗₁ id ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl ⟩ F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (F.ε ⊗₁ G.ε) ⊗₁ (id ⊗₁ id) ∘ λ⇐ ⊗₁ id ≈⟨ refl⟩∘⟨ pullʳ (extendʳ (interchange.⇒.commute ((F.ε , G.ε) , (id , id)))) ⟩ F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ Fh ⊗₁ Gh ∘ (F.ε ⊗₁ id) ⊗₁ (G.ε ⊗₁ id) ∘ i⇒ ∘ λ⇐ ⊗₁ id ≈˘⟨ refl⟩∘⟨ pushˡ ⊗.homomorphism ⟩ F.₁ Cλ⇒ ⊗₁ G.₁ Cλ⇒ ∘ (Fh ∘ F.ε ⊗₁ id) ⊗₁ (Gh ∘ G.ε ⊗₁ id) ∘ i⇒ ∘ λ⇐ ⊗₁ id ≈˘⟨ pushˡ ⊗.homomorphism ⟩ (F.₁ Cλ⇒ ∘ Fh ∘ F.ε ⊗₁ id) ⊗₁ (G.₁ Cλ⇒ ∘ Gh ∘ G.ε ⊗₁ id) ∘ i⇒ ∘ λ⇐ ⊗₁ id ≈⟨ F.unitaryˡ ⟩⊗⟨ G.unitaryˡ ⟩∘⟨refl ⟩ λ⇒ ⊗₁ λ⇒ ∘ i⇒ ∘ λ⇐ ⊗₁ id ≈⟨ ⊗ˢ.unitaryˡ ⟩ λ⇒ ∎ unitaryʳ : ∀ {X} → [ (F.₀ X ⊗₀ G.₀ X) ⊗₀ unit ⇒ F.₀ X ⊗₀ G.₀ X ]⟨ F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (F.ε ⊗₁ G.ε ∘ λ⇐) ≈ ρ⇒ ⟩ unitaryʳ = begin F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (F.ε ⊗₁ G.ε ∘ λ⇐) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ split₂ˡ ⟩ F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ id ⊗₁ (F.ε ⊗₁ G.ε) ∘ id ⊗₁ λ⇐ ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩ F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ⊗₁ Gh ∘ i⇒) ∘ (id ⊗₁ id) ⊗₁ (F.ε ⊗₁ G.ε) ∘ id ⊗₁ λ⇐ ≈⟨ refl⟩∘⟨ pullʳ (extendʳ (interchange.⇒.commute ((id , id) , (F.ε , G.ε)))) ⟩ F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ Fh ⊗₁ Gh ∘ (id ⊗₁ F.ε) ⊗₁ (id ⊗₁ G.ε) ∘ i⇒ ∘ id ⊗₁ λ⇐ ≈˘⟨ refl⟩∘⟨ pushˡ ⊗.homomorphism ⟩ F.₁ Cρ⇒ ⊗₁ G.₁ Cρ⇒ ∘ (Fh ∘ id ⊗₁ F.ε) ⊗₁ (Gh ∘ id ⊗₁ G.ε) ∘ i⇒ ∘ id ⊗₁ λ⇐ ≈˘⟨ pushˡ ⊗.homomorphism ⟩ (F.₁ Cρ⇒ ∘ Fh ∘ id ⊗₁ F.ε) ⊗₁ (G.₁ Cρ⇒ ∘ Gh ∘ id ⊗₁ G.ε) ∘ i⇒ ∘ id ⊗₁ λ⇐ ≈⟨ F.unitaryʳ ⟩⊗⟨ G.unitaryʳ ⟩∘⟨refl ⟩ ρ⇒ ⊗₁ ρ⇒ ∘ i⇒ ∘ id ⊗₁ λ⇐ ≈⟨ ⊗ˢ.unitaryʳ ⟩ ρ⇒ ∎ braiding-compat = λ {X Y} → begin F.₁ Cσ⇒ ⊗₁ G.₁ Cσ⇒ ∘ Fh {X} {Y} ⊗₁ Gh {X} {Y} ∘ i⇒ ≈⟨ extendʳ (parallel F.braiding-compat G.braiding-compat) ⟩ (Fh ⊗₁ Gh) ∘ σ⇒ ⊗₁ σ⇒ ∘ i⇒ ≈⟨ pushʳ ⊗ˢ.braiding-compat ⟩ (Fh ⊗₁ Gh ∘ i⇒) ∘ σ⇒ ∎ _⊗̇₁_ : {F₁ F₂ G₁ G₂ : SymmetricMonoidalFunctor C D} → F₁ ⇛ F₂ → G₁ ⇛ G₂ → F₁ ⊗̇₀ G₁ ⇛ F₂ ⊗̇₀ G₂ _⊗̇₁_ {F₁} {F₂} {G₁} {G₂} β γ = record { U = β.U Underlying.⊗̇₁ γ.U ; isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = ⊗-homo-compat } } where module F₁ = SymmetricMonoidalFunctor F₁ module F₂ = SymmetricMonoidalFunctor F₂ module G₁ = SymmetricMonoidalFunctor G₁ module G₂ = SymmetricMonoidalFunctor G₂ module β = SymmetricMonoidalNaturalTransformation β module γ = SymmetricMonoidalNaturalTransformation γ ε-compat = begin β.η C.unit ⊗₁ γ.η C.unit ∘ F₁.ε ⊗₁ G₁.ε ∘ λ⇐ ≈˘⟨ pushˡ ⊗.homomorphism ⟩ (β.η C.unit ∘ F₁.ε) ⊗₁ (γ.η C.unit ∘ G₁.ε) ∘ λ⇐ ≈⟨ β.ε-compat ⟩⊗⟨ γ.ε-compat ⟩∘⟨refl ⟩ F₂.ε ⊗₁ G₂.ε ∘ λ⇐ ∎ ⊗-homo-compat = λ {X Y} → begin β.η (X C.⊗₀ Y) ⊗₁ γ.η (X C.⊗₀ Y) ∘ F₁.⊗-homo.η (X , Y) ⊗₁ G₁.⊗-homo.η (X , Y) ∘ i⇒ ≈˘⟨ pushˡ ⊗.homomorphism ⟩ (β.η (X C.⊗₀ Y) ∘ F₁.⊗-homo.η (X , Y)) ⊗₁ (γ.η (X C.⊗₀ Y) ∘ G₁.⊗-homo.η (X , Y)) ∘ i⇒ ≈⟨ β.⊗-homo-compat ⟩⊗⟨ γ.⊗-homo-compat ⟩∘⟨refl ⟩ (F₂.⊗-homo.η (X , Y) ∘ β.η X ⊗₁ β.η Y) ⊗₁ (G₂.⊗-homo.η (X , Y) ∘ γ.η X ⊗₁ γ.η Y) ∘ i⇒ ≈⟨ pushˡ ⊗.homomorphism ⟩ F₂.⊗-homo.η (X , Y) ⊗₁ G₂.⊗-homo.η (X , Y) ∘ (β.η X ⊗₁ β.η Y) ⊗₁ (γ.η X ⊗₁ γ.η Y) ∘ i⇒ ≈˘⟨ pullʳ (interchange.⇒.commute ((β.η X , γ.η X) , (β.η Y , γ.η Y))) ⟩ (F₂.⊗-homo.η (X , Y) ⊗₁ G₂.⊗-homo.η (X , Y) ∘ i⇒) ∘ (β.η X ⊗₁ γ.η X) ⊗₁ (β.η Y ⊗₁ γ.η Y) ∎ -- The constant functor to the unit in D is (lax) monoidal. unitF : SymmetricMonoidalFunctor C D unitF = record { F = Underlying.unitF ; isBraidedMonoidal = record { isMonoidal = record { ε = id ; ⊗-homo = Underlying.unitF-⊗-homo.F⇒G ; associativity = begin id ∘ λ⇒ ∘ λ⇒ ⊗₁ id ≈⟨ identityˡ ⟩ λ⇒ ∘ λ⇒ ⊗₁ id ≈˘⟨ refl⟩∘⟨ coherence₁ ⟩ λ⇒ ∘ λ⇒ ∘ α⇒ ≈˘⟨ extendʳ unitorˡ-commute-from ⟩ λ⇒ ∘ id ⊗₁ λ⇒ ∘ α⇒ ∎ ; unitaryˡ = begin id ∘ λ⇒ ∘ id ⊗₁ id ≈⟨ identityˡ ⟩ λ⇒ ∘ id ⊗₁ id ≈⟨ refl⟩∘⟨ ⊗.identity ⟩ λ⇒ ∘ id ≈⟨ identityʳ ⟩ λ⇒ ∎ ; unitaryʳ = begin id ∘ λ⇒ ∘ id ⊗₁ id ≈⟨ identityˡ ⟩ λ⇒ ∘ id ⊗₁ id ≈⟨ refl⟩∘⟨ ⊗.identity ⟩ λ⇒ ∘ id ≈⟨ identityʳ ⟩ λ⇒ ≈⟨ coherence₃ ⟩ ρ⇒ ∎ } ; braiding-compat = begin id ∘ λ⇒ ≈⟨ identityˡ ⟩ λ⇒ ≈⟨ coherence₃ ⟩ ρ⇒ ≈˘⟨ braiding-coherence ⟩ λ⇒ ∘ braiding.⇒.η _ ∎ } } module unitF = SymmetricMonoidalFunctor unitF -- The pointwise tensor product and the unit functor induce a -- symmetric monoidal structure on symmetric monoidal functors. ⊗̇-unitorˡ : {F : SymmetricMonoidalFunctor C D} → unitF ⊗̇₀ F ≃ F ⊗̇-unitorˡ {F} = record { U = Underlying.⊗̇-unitorˡ ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = ⊗-homo-compat } } where open SymmetricMonoidalFunctor F ε-compat = begin λ⇒ ∘ id ⊗₁ ε ∘ λ⇐ ≈⟨ extendʳ unitorˡ-commute-from ⟩ ε ∘ λ⇒ ∘ λ⇐ ≈⟨ elimʳ λᵢ.isoʳ ⟩ ε ∎ ⊗-homo-compat = λ {X Y} → let h = ⊗-homo.η (X , Y) in begin λ⇒ ∘ λ⇒ ⊗₁ h ∘ i⇒ ≈⟨ pullˡ (refl⟩∘⟨ serialize₂₁) ⟩ (λ⇒ ∘ id ⊗₁ h ∘ λ⇒ ⊗₁ id) ∘ i⇒ ≈⟨ extendʳ unitorˡ-commute-from ⟩∘⟨ i-selfInverse ⟩ (h ∘ λ⇒ ∘ λ⇒ ⊗₁ id) ∘ i⇐ ≈˘⟨ pushʳ (switch-fromtoʳ i (switch-tofromʳ (λᵢ ⊗ᵢ idᵢ) (assoc ○ ⊗ˢ.unitaryˡ))) ⟩ h ∘ λ⇒ ⊗₁ λ⇒ ∎ ⊗̇-unitorʳ : {F : SymmetricMonoidalFunctor C D} → F ⊗̇₀ unitF ≃ F ⊗̇-unitorʳ {F} = record { U = Underlying.⊗̇-unitorʳ ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = ⊗-homo-compat } } where open SymmetricMonoidalFunctor F ε-compat = begin ρ⇒ ∘ ε ⊗₁ id ∘ λ⇐ ≈⟨ extendʳ unitorʳ-commute-from ⟩ ε ∘ ρ⇒ ∘ λ⇐ ≈˘⟨ refl⟩∘⟨ coherence₃ ⟩∘⟨refl ⟩ ε ∘ λ⇒ ∘ λ⇐ ≈⟨ elimʳ λᵢ.isoʳ ⟩ ε ∎ ⊗-homo-compat = λ {X Y} → let h = ⊗-homo.η (X , Y) in begin ρ⇒ ∘ h ⊗₁ λ⇒ ∘ i⇒ ≈⟨ pullˡ (refl⟩∘⟨ serialize₁₂) ⟩ (ρ⇒ ∘ h ⊗₁ id ∘ id ⊗₁ λ⇒) ∘ i⇒ ≈⟨ extendʳ unitorʳ-commute-from ⟩∘⟨ i-selfInverse ⟩ (h ∘ ρ⇒ ∘ id ⊗₁ λ⇒) ∘ i⇐ ≈˘⟨ pushʳ (switch-fromtoʳ i (switch-tofromʳ (idᵢ ⊗ᵢ λᵢ) (assoc ○ ⊗ˢ.unitaryʳ))) ⟩ h ∘ ρ⇒ ⊗₁ ρ⇒ ∎ ⊗̇-associator : {F G H : SymmetricMonoidalFunctor C D} → (F ⊗̇₀ G) ⊗̇₀ H ≃ F ⊗̇₀ (G ⊗̇₀ H) ⊗̇-associator {F} {G} {H} = record { U = Underlying.⊗̇-associator ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = ⊗-homo-compat } } where module F = SymmetricMonoidalFunctor F module G = SymmetricMonoidalFunctor G module H = SymmetricMonoidalFunctor H Fh = λ {X Y} → F.⊗-homo.η (X , Y) Gh = λ {X Y} → G.⊗-homo.η (X , Y) Hh = λ {X Y} → H.⊗-homo.η (X , Y) ε-compat = begin α⇒ ∘ (F.ε ⊗₁ G.ε ∘ λ⇐) ⊗₁ H.ε ∘ λ⇐ ≈⟨ pullˡ (pushʳ split₁ʳ) ⟩ ((α⇒ ∘ (F.ε ⊗₁ G.ε) ⊗₁ H.ε) ∘ λ⇐ ⊗₁ id) ∘ λ⇐ ≈⟨ pushˡ assoc-commute-from ⟩∘⟨refl ⟩ (F.ε ⊗₁ (G.ε ⊗₁ H.ε) ∘ α⇒ ∘ λ⇐ ⊗₁ id) ∘ λ⇐ ≈⟨ (refl⟩∘⟨ helper) ⟩∘⟨refl ⟩ (F.ε ⊗₁ (G.ε ⊗₁ H.ε) ∘ id ⊗₁ λ⇐) ∘ λ⇐ ≈˘⟨ split₂ʳ ⟩∘⟨refl ⟩ F.ε ⊗₁ (G.ε ⊗₁ H.ε ∘ λ⇐) ∘ λ⇐ ∎ where helper = begin α⇒ ∘ λ⇐ ⊗₁ id ≈⟨ refl⟩∘⟨ coherence-inv₃ ⟩⊗⟨refl ⟩ α⇒ ∘ ρ⇐ ⊗₁ id ≈˘⟨ conjugate-from (ρᵢ ⊗ᵢ idᵢ) (idᵢ ⊗ᵢ λᵢ) (identityˡ ○ ⟺ triangle) ⟩ id ⊗₁ λ⇐ ∘ id ≈⟨ identityʳ ⟩ id ⊗₁ λ⇐ ∎ ⊗-homo-compat = λ {X Y} → begin α⇒ ∘ (Fh {X} {Y} ⊗₁ Gh {X} {Y} ∘ i⇒) ⊗₁ Hh {X} {Y} ∘ i⇒ ≈⟨ refl⟩∘⟨ (refl⟩∘⟨ i-selfInverse) ⟩⊗⟨refl ⟩∘⟨ i-selfInverse ⟩ α⇒ ∘ (Fh ⊗₁ Gh ∘ i⇐) ⊗₁ Hh ∘ i⇐ ≈⟨ refl⟩∘⟨ pushˡ split₁ʳ ⟩ α⇒ ∘ (Fh ⊗₁ Gh) ⊗₁ Hh ∘ i⇐ ⊗₁ id ∘ i⇐ ≈⟨ extendʳ assoc-commute-from ⟩ Fh ⊗₁ (Gh ⊗₁ Hh) ∘ α⇒ ∘ i⇐ ⊗₁ id ∘ i⇐ ≈˘⟨ refl⟩∘⟨ conjugate-from (i ∘ᵢ i ⊗ᵢ idᵢ) (i ∘ᵢ idᵢ ⊗ᵢ i) (⊗ˢ.associativity ○ sym-assoc) ⟩ Fh ⊗₁ (Gh ⊗₁ Hh) ∘ (id ⊗₁ i⇐ ∘ i⇐) ∘ α⇒ ⊗₁ α⇒ ≈˘⟨ pushˡ (pushˡ split₂ʳ) ⟩ (Fh ⊗₁ (Gh ⊗₁ Hh ∘ i⇐) ∘ i⇐) ∘ α⇒ ⊗₁ α⇒ ≈˘⟨ (refl⟩⊗⟨ (refl⟩∘⟨ i-selfInverse) ⟩∘⟨ i-selfInverse) ⟩∘⟨refl ⟩ (Fh ⊗₁ (Gh ⊗₁ Hh ∘ i⇒) ∘ i⇒) ∘ α⇒ ⊗₁ α⇒ ∎ ⊗̇-braiding : {F G : SymmetricMonoidalFunctor C D } → F ⊗̇₀ G ≃ G ⊗̇₀ F ⊗̇-braiding {F} {G} = record { U = Underlying.⊗̇-braiding ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = ⊗-homo-compat } } where module F = SymmetricMonoidalFunctor F module G = SymmetricMonoidalFunctor G Fh = λ {X Y} → F.⊗-homo.η (X , Y) Gh = λ {X Y} → G.⊗-homo.η (X , Y) ε-compat = begin σ⇒ ∘ F.ε ⊗₁ G.ε ∘ λ⇐ ≈⟨ extendʳ (braiding.⇒.commute (F.ε , G.ε)) ⟩ G.ε ⊗₁ F.ε ∘ σ⇒ ∘ λ⇐ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ coherence-inv₃ ⟩ G.ε ⊗₁ F.ε ∘ σ⇒ ∘ ρ⇐ ≈˘⟨ refl⟩∘⟨ conjugate-from ρᵢ λᵢ (identityˡ ○ ⟺ braiding-coherence) ⟩ G.ε ⊗₁ F.ε ∘ λ⇐ ∘ id ≈⟨ refl⟩∘⟨ identityʳ ⟩ G.ε ⊗₁ F.ε ∘ λ⇐ ∎ ⊗-homo-compat : ∀ {X Y} → σ⇒ ∘ Fh {X} {Y} ⊗₁ Gh {X} {Y} ∘ i⇒ ≈ (Gh ⊗₁ Fh ∘ i⇒) ∘ σ⇒ ⊗₁ σ⇒ ⊗-homo-compat {X} {Y} = begin σ⇒ ∘ Fh ⊗₁ Gh ∘ i⇒ ≈⟨ extendʳ (braiding.⇒.commute (Fh , Gh)) ⟩ Gh ⊗₁ Fh ∘ σ⇒ ∘ i⇒ ≈⟨ pushʳ (conjugate-to i-iso′ i-iso′ (⟺ ⊗ˢ.braiding-compat)) ⟩ (Gh ⊗₁ Fh ∘ i⇒) ∘ σ⇒ ⊗₁ σ⇒ ∎ module ⊗̇-unitorˡ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorˡ {F}) module ⊗̇-unitorʳ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorʳ {F}) module ⊗̇-associator {F} {G} {H} = SymmetricMonoidalNaturalIsomorphism (⊗̇-associator {F} {G} {H}) module ⊗̇-braiding {F} {G} = SymmetricMonoidalNaturalIsomorphism (⊗̇-braiding {F} {G}) module Strong where open SF.Strong open SMNT.Strong using (SymmetricMonoidalNaturalTransformation) open SMNI.Strong using (SymmetricMonoidalNaturalIsomorphism; _≃_) open SymmetricMonoidalFunctor using () renaming (laxSymmetricMonoidalFunctor to laxSMF) private infix 4 _⇛_ _⇛_ = SymmetricMonoidalNaturalTransformation infixr 10 _⊗̇₀_ _⊗̇₁_ -- The pointwise tensor product of strong symmetric monoidal functors. _⊗̇₀_ : (F G : SymmetricMonoidalFunctor C D) → SymmetricMonoidalFunctor C D F ⊗̇₀ G = record { F = F.F Underlying.⊗̇₀ G.F ; isBraidedMonoidal = record { isStrongMonoidal = record { ε = F.ε ⊗ᵢ G.ε ∘ᵢ ⊗ˢ.ε ; ⊗-homo = niHelper (record { η = ⊗-homoᵢ.from ; η⁻¹ = ⊗-homoᵢ.to ; commute = ⊗-homo.commute ; iso = ⊗-homoᵢ.iso }) ; associativity = associativity ; unitaryˡ = unitaryˡ ; unitaryʳ = unitaryʳ } ; braiding-compat = braiding-compat } } where module F = SymmetricMonoidalFunctor F module G = SymmetricMonoidalFunctor G ⊗-homoᵢ = λ XY → F.⊗-homo.FX≅GX {XY} ⊗ᵢ G.⊗-homo.FX≅GX {XY} ∘ᵢ i module ⊗-homoᵢ XY = _≅_ (⊗-homoᵢ XY) open SF.Lax.SymmetricMonoidalFunctor (laxSMF F Lax.⊗̇₀ laxSMF G) _⊗̇₁_ : {F₁ F₂ G₁ G₂ : SymmetricMonoidalFunctor C D} → F₁ ⇛ F₂ → G₁ ⇛ G₂ → F₁ ⊗̇₀ G₁ ⇛ F₂ ⊗̇₀ G₂ _⊗̇₁_ β γ = record { U = β.U Underlying.⊗̇₁ γ.U ; isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat } } where module β = SymmetricMonoidalNaturalTransformation β module γ = SymmetricMonoidalNaturalTransformation γ open SMNT.Lax.SymmetricMonoidalNaturalTransformation (β.laxSNT Lax.⊗̇₁ γ.laxSNT) -- The constant functor to the unit in D is (strong) monoidal. unitF : SymmetricMonoidalFunctor C D unitF = record { F = Underlying.unitF ; isBraidedMonoidal = record { isStrongMonoidal = record { ε = idᵢ ; ⊗-homo = Underlying.unitF-⊗-homo ; associativity = λ {X Y Z} → Lax.unitF.associativity {X = X} {Y} {Z} ; unitaryˡ = λ {X} → Lax.unitF.unitaryˡ {X = X} ; unitaryʳ = λ {X} → Lax.unitF.unitaryʳ {X = X} } ; braiding-compat = λ {X Y} → Lax.unitF.braiding-compat {X = X} {Y} } } module unitF = SymmetricMonoidalFunctor unitF -- The pointwise tensor product and the unit functor induce a -- symmetric monoidal structure on symmetric monoidal functors. ⊗̇-unitorˡ : {F : SymmetricMonoidalFunctor C D} → unitF ⊗̇₀ F ≃ F ⊗̇-unitorˡ {F} = record { U = U ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y} } } where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-unitorˡ {F = laxSMF F}) ⊗̇-unitorʳ : {F : SymmetricMonoidalFunctor C D} → F ⊗̇₀ unitF ≃ F ⊗̇-unitorʳ {F} = record { U = U ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y} } } where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-unitorʳ {F = laxSMF F}) ⊗̇-associator : {F G H : SymmetricMonoidalFunctor C D} → (F ⊗̇₀ G) ⊗̇₀ H ≃ F ⊗̇₀ (G ⊗̇₀ H) ⊗̇-associator {F} {G} {H} = record { U = U ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y} } } where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-associator {F = laxSMF F} {laxSMF G} {laxSMF H}) ⊗̇-braiding : {F G : SymmetricMonoidalFunctor C D } → F ⊗̇₀ G ≃ G ⊗̇₀ F ⊗̇-braiding {F} {G} = record { U = U ; F⇒G-isMonoidal = record { ε-compat = ε-compat ; ⊗-homo-compat = λ {X Y} → ⊗-homo-compat {X = X} {Y} } } where open SMNI.Lax.SymmetricMonoidalNaturalIsomorphism (Lax.⊗̇-braiding {F = laxSMF F} {laxSMF G}) module ⊗̇-unitorˡ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorˡ {F}) module ⊗̇-unitorʳ {F} = SymmetricMonoidalNaturalIsomorphism (⊗̇-unitorʳ {F}) module ⊗̇-associator {F} {G} {H} = SymmetricMonoidalNaturalIsomorphism (⊗̇-associator {F} {G} {H}) module ⊗̇-braiding {F} {G} = SymmetricMonoidalNaturalIsomorphism (⊗̇-braiding {F} {G})
38.676119
116
0.490989
1382c208a5db00a07191f649c4e8f331e43814e7
581
agda
Agda
test/Succeed/Issue2782.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue2782.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue2782.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality module Issue2782 where module Interval where private data I' : Set where Izero' : I' Ione' : I' I : Set I = I' Izero : I Izero = Izero' Ione : I Ione = Ione' {-- postulate Iseg : Izero ≡ Ione --} -- Fails when run with --safe flag in command-line unquoteDecl Iseg = declarePostulate (vArg Iseg) (def (quote _≡_) (vArg (def (quote Izero) []) ∷ vArg (def (quote Ione) []) ∷ [])) open Interval public pf : Izero ≡ Ione pf = Iseg
16.6
131
0.623064
044216caacbe88053b43076c064a4759ceea1dc9
1,087
agda
Agda
Cubical/Data/Equality.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Data/Equality.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Data/Equality.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{- This module converts between the path equality and the inductively define equality types. - _≡c_ stands for "c"ubical equality. - _≡p_ stands for "p"ropositional equality. TODO: reconsider naming scheme. -} {-# OPTIONS --safe #-} module Cubical.Data.Equality where open import Cubical.Foundations.Prelude renaming ( _≡_ to _≡c_ ; refl to reflc ) public open import Agda.Builtin.Equality renaming ( _≡_ to _≡p_ ; refl to reflp ) public open import Cubical.Foundations.Isomorphism private variable ℓ : Level A : Type ℓ x y z : A ptoc : x ≡p y → x ≡c y ptoc reflp = reflc ctop : x ≡c y → x ≡p y ctop p = transport (cong (λ u → _ ≡p u) p) reflp ptoc-ctop : (p : x ≡c y) → ptoc (ctop p) ≡c p ptoc-ctop p = J (λ _ h → ptoc (ctop h) ≡c h) (cong ptoc (transportRefl reflp)) p ctop-ptoc : (p : x ≡p y) → ctop (ptoc p) ≡c p ctop-ptoc {x = x} reflp = transportRefl reflp p≅c : {x y : A} → Iso (x ≡c y) (x ≡p y) p≅c = iso ctop ptoc ctop-ptoc ptoc-ctop p-c : {x y : A} → (x ≡c y) ≡c (x ≡p y) p-c = isoToPath p≅c p=c : {x y : A} → (x ≡c y) ≡p (x ≡p y) p=c = ctop p-c
21.313725
68
0.627415
dc2195168e2cf1aa46609141717a6b6e09817bc1
4,563
agda
Agda
src/Categories/Adjoint/Instance/PosetCore.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
src/Categories/Adjoint/Instance/PosetCore.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
null
null
null
src/Categories/Adjoint/Instance/PosetCore.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Adjoint.Instance.PosetCore where -- The adjunction between the "forgetful" functor from Posets to -- Setoids and the core functor for posets. open import Level using (_⊔_) import Function open import Function.Equality using (Π; _⟶_) open import Relation.Binary using (Setoid; Poset) open import Relation.Binary.OrderMorphism using (_⇒-Poset_) renaming (_∘_ to _∙_) open import Categories.Adjoint using (_⊣_) import Categories.Adjoint.Instance.0-Truncation as Setd import Categories.Adjoint.Instance.01-Truncation as Pos open import Categories.Category using (Category) open import Categories.Category.Construction.Thin open import Categories.Category.Instance.Posets using (fun-resp-≈; Posets) open import Categories.Category.Instance.Setoids using (Setoids) open import Categories.Functor.Instance.Core using () renaming (Core to CatCore) import Categories.Functor.Instance.Core as Cat open import Categories.Functor using (Functor; _∘F_; id) import Categories.Morphism as Morphism open import Categories.Morphism.IsoEquiv using (⌞_⌟) open import Categories.NaturalTransformation using (ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_; niHelper) open Π open _⇒-Poset_ -- The "forgetful" functor from Setoids to Posets (forgetting symmetry). Forgetful : ∀ {c ℓ} → Functor (Setoids c ℓ) (Posets c ℓ ℓ) Forgetful = record { F₀ = Forgetful₀ ; F₁ = λ f → record { fun = _⟨$⟩_ f ; monotone = cong f } ; identity = λ {S} → refl S ; homomorphism = λ {_ _ S} → refl S ; F-resp-≈ = λ {S _} f≗g → f≗g (refl S) } where Forgetful₀ : ∀ {c ℓ} → Setoid c ℓ → Poset c ℓ ℓ Forgetful₀ S = record { _≈_ = _≈_ ; _≤_ = _≈_ ; isPartialOrder = record { isPreorder = record { isEquivalence = isEquivalence ; reflexive = Function.id ; trans = trans } ; antisym = Function.const } } where open Setoid S open Setoid -- The "core" functor from Posets to Setoids. -- -- This functor simply forgets the _≤_ relation, mapping a Poset to -- the Setoid over which it is defined. This Setoid is the "core" of -- the Poset in the sense that the "equality" _≈_ associated with the -- Poset is really an equivalence, and antisymmetry ensures that this -- equivalence is equivalent to the symmetric core of _≤_. Core : ∀ {c ℓ₁ ℓ₂} → Functor (Posets c ℓ₁ ℓ₂) (Setoids c ℓ₁) Core = record { F₀ = λ A → record { isEquivalence = isEquivalence A } ; F₁ = λ f → record { _⟨$⟩_ = fun f ; cong = fun-resp-≈ f } ; identity = Function.id ; homomorphism = λ {_ _ _ f g} → fun-resp-≈ (g ∙ f) ; F-resp-≈ = λ {_ B} {f _} f≗g x≈y → Eq.trans B (fun-resp-≈ f x≈y) f≗g } where open Poset -- Core is right-adjoint to the forgetful functor CoreAdj : ∀ {o ℓ} → Forgetful ⊣ Core {o} {ℓ} {ℓ} CoreAdj = record { unit = ntHelper record { η = unit ; commute = cong } ; counit = ntHelper record { η = counit ; commute = λ {_ B} _ → Eq.refl B } ; zig = λ {S} → Setoid.refl S ; zag = Function.id } where open Poset open Functor Core using () renaming (F₀ to Core₀; F₁ to Core₁) open Functor Forgetful using () renaming (F₀ to U₀ ; F₁ to U₁) unit : ∀ S → S ⟶ Core₀ (U₀ S) unit S = record { _⟨$⟩_ = Function.id ; cong = Function.id } counit : ∀ A → U₀ (Core₀ A) ⇒-Poset A counit C = record { fun = Function.id ; monotone = reflexive C } -- The core functor commutes with inclusion, i.e. the core of a thin -- category is the 0-Groupoid generated by the associated equivalence. -- -- Note that the core functor does not commute with truncation, -- because the latter forgets too much (there are many more isos in -- the (0,1)-truncated category). Core-commutes : ∀ {c ℓ} e → Setd.Inclusion e ∘F Core ≃ Cat.Core ∘F Pos.Inclusion {c} {ℓ ⊔ e} {ℓ} e Core-commutes e = niHelper record { η = λ A → record { F₀ = Function.id ; F₁ = EqIsIso.≈⇒≅ e A } ; η⁻¹ = λ A → record { F₀ = Function.id ; F₁ = EqIsIso.≅⇒≈ e A } ; commute = λ {A B} f → let open Morphism (Thin e B) in niHelper record { η = λ _ → ≅.refl ; η⁻¹ = λ _ → ≅.refl } ; iso = λ A → let open Poset A open Morphism (Thin e A) in record { isoˡ = niHelper record { η = λ _ → Eq.refl ; η⁻¹ = λ _ → Eq.refl } ; isoʳ = niHelper record { η = λ _ → ≅.refl ; η⁻¹ = λ _ → ≅.refl } } }
37.401639
81
0.630068
222f8f0118e6165a20a7754318dc4ce54cc9f0e9
3,073
agda
Agda
examples/arith/DivMod.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2018-10-10T17:08:44.000Z
2018-10-10T17:08:44.000Z
examples/arith/DivMod.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
examples/arith/DivMod.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
module DivMod where -- From examples/simple-lib open import Lib.Vec open import Lib.Nat open import Lib.Id open import Lib.Logic open import Lib.Fin -- Certified implementation of division and modulo module Direct where data DivMod : Nat -> Nat -> Set where dm : forall {b} q (r : Fin b) -> DivMod (toNat r + q * b) b getQ : forall {a b} -> DivMod a b -> Nat getQ (dm q _) = q getR : forall {a b} -> DivMod a b -> Nat getR (dm _ r) = toNat r divModˢ : (a b : Nat) -> DivMod a (suc b) divModˢ zero b = dm 0 zero divModˢ (suc a) b with divModˢ a b divModˢ (suc ._) b | dm q r with maxView r divModˢ (suc ._) b | dm q .(fromNat b) | theMax with toNat (fromNat b) | lem-toNat-fromNat b ... | .b | refl = dm {suc b} (suc q) zero divModˢ (suc ._) b | dm q .(weaken i) | notMax i with toNat (weaken i) | lem-toNat-weaken i ... | .(toNat i) | refl = dm q (suc i) divMod : (a b : Nat){nz : NonZero b} -> DivMod a b divMod a zero {} divMod a (suc b) = divModˢ a b -- Let's try the inductive version. Less obvious that this one is correct. module Inductive where data DivMod : Nat -> Nat -> Set where dmZ : forall {b} (i : Fin b) -> DivMod (toNat i) b dmS : forall {a b} -> DivMod a b -> DivMod (b + a) b getQ : forall {a b} -> DivMod a b -> Nat getQ (dmZ _) = 0 getQ (dmS d) = suc (getQ d) getR : forall {a b} -> DivMod a b -> Nat getR (dmZ r) = toNat r getR (dmS d) = getR d data BoundView (n : Nat) : Nat -> Set where below : (i : Fin n) -> BoundView n (toNat i) above : forall a -> BoundView n (n + a) boundView : (a b : Nat) -> BoundView a b boundView zero b = above b boundView (suc a) zero = below zero boundView (suc a) (suc b) with boundView a b boundView (suc a) (suc .(toNat i)) | below i = below (suc i) boundView (suc a) (suc .(a + k)) | above k = above k data _≤_ : Nat -> Nat -> Set where leqZ : forall {n} -> zero ≤ n leqS : forall {n m} -> n ≤ m -> suc n ≤ suc m ≤-suc : forall {a b} -> a ≤ b -> a ≤ suc b ≤-suc leqZ = leqZ ≤-suc (leqS p) = leqS (≤-suc p) plus-≤ : forall a {b c} -> a + b ≤ c -> b ≤ c plus-≤ zero p = p plus-≤ (suc a) (leqS p) = ≤-suc (plus-≤ a p) ≤-refl : forall {a} -> a ≤ a ≤-refl {zero} = leqZ ≤-refl {suc n} = leqS ≤-refl -- Recursion over a bound on a (needed for termination). divModˢ : forall {size} a b -> a ≤ size -> DivMod a (suc b) divModˢ a b prf with boundView (suc b) a divModˢ .(toNat r) b _ | below r = dmZ r divModˢ .(suc b + k) b (leqS prf) | above k = dmS (divModˢ k b (plus-≤ b prf)) divMod : forall a b {nz : NonZero b} -> DivMod a b divMod a zero {} divMod a (suc b) = divModˢ a b ≤-refl -- We ought to prove that the inductive version behaves the same as the -- direct version... but that's more work than we're willing to spend. open Inductive _div_ : (a b : Nat){nz : NonZero b} -> Nat _div_ a b {nz} = getQ (divMod a b {nz}) _mod_ : (a b : Nat){nz : NonZero b} -> Nat _mod_ a b {nz} = getR (divMod a b {nz})
30.127451
80
0.575334
9ab04215902086144c88112aa3616eac5c15994b
2,041
agda
Agda
src/Categories/Theory/Lawvere.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
src/Categories/Theory/Lawvere.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
null
null
null
src/Categories/Theory/Lawvere.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
{-# OPTIONS --without-K --safe #-} -- a categorical (i.e. non-skeletal) version of Lawvere Theory, -- as per https://ncatlab.org/nlab/show/Lawvere+theory module Categories.Theory.Lawvere where open import Data.Nat using (ℕ) open import Data.Product using (Σ; _,_) open import Level open import Categories.Category.Cartesian.Structure open import Categories.Category using (Category; _[_,_]) open import Categories.Category.Instance.Setoids open import Categories.Category.Monoidal.Instance.Setoids using (Setoids-CartesianCategory) open import Categories.Category.Product open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Functor.Cartesian open import Categories.Functor.Cartesian.Properties import Categories.Morphism as Mor open import Categories.NaturalTransformation using (NaturalTransformation) private variable o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ : Level record FiniteProduct (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where field T : CartesianCategory o ℓ e module T = CartesianCategory T open Mor T.U field generic : T.Obj field obj-iso-to-generic-power : ∀ x → Σ ℕ (λ n → x ≅ T.power generic n) record LT-Hom (T₁ : FiniteProduct o ℓ e) (T₂ : FiniteProduct o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where private module T₁ = FiniteProduct T₁ module T₂ = FiniteProduct T₂ field cartF : CartesianF T₁.T T₂.T module cartF = CartesianF cartF LT-id : {A : FiniteProduct o ℓ e} → LT-Hom A A LT-id = record { cartF = idF-CartesianF _ } LT-∘ : {A : FiniteProduct o ℓ e} {B : FiniteProduct o′ ℓ′ e′} {C : FiniteProduct o″ ℓ″ e″} → LT-Hom B C → LT-Hom A B → LT-Hom A C LT-∘ G H = record { cartF = ∘-CartesianF (cartF G) (cartF H) } where open LT-Hom record T-Algebra (FP : FiniteProduct o ℓ e) : Set (o ⊔ ℓ ⊔ e ⊔ suc (ℓ′ ⊔ e′)) where private module FP = FiniteProduct FP field cartF : CartesianF FP.T (Setoids-CartesianCategory ℓ′ e′) module cartF = CartesianF cartF mod : Functor FP.T.U (Setoids ℓ′ e′) mod = cartF.F
29.57971
109
0.693288
4b5f6690a2af7589675fc8dde407913c58bd4011
284
agda
Agda
test/Fail/WithoutK2.agda
favonia/agda
8d433b967567c08afe15d04a5cb63b6f6d8884ee
[ "BSD-2-Clause" ]
null
null
null
test/Fail/WithoutK2.agda
favonia/agda
8d433b967567c08afe15d04a5cb63b6f6d8884ee
[ "BSD-2-Clause" ]
6
2021-10-18T08:12:24.000Z
2021-11-24T08:31:10.000Z
test/Fail/WithoutK2.agda
antoinevanmuylder/agda
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
[ "BSD-2-Clause" ]
null
null
null
{-# OPTIONS --cubical-compatible #-} module WithoutK2 where -- Equality defined with two indices. data _≡_ {A : Set} : A → A → Set where refl : ∀ x → x ≡ x K : {A : Set} (P : {x : A} → x ≡ x → Set) → (∀ x → P (refl x)) → ∀ {x} (x≡x : x ≡ x) → P x≡x K P p (refl x) = p x
20.285714
43
0.485915
ad7854e8260a3f41c21aeb90a49fe4af8f3278b7
6,210
agda
Agda
theorems/cw/DegreeByProjection.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/cw/DegreeByProjection.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/cw/DegreeByProjection.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.Bouquet open import homotopy.SphereEndomorphism open import groups.SphereEndomorphism open import groups.CoefficientExtensionality open import cw.CW open import cw.WedgeOfCells module cw.DegreeByProjection {i} where module DegreeAboveOne {n : ℕ} (skel : Skeleton {i} (S (S n))) (dec : has-cells-with-dec-eq skel) -- the cells at the upper and lower dimensions (upper : cells-last skel) (lower : cells-last (cw-init skel)) where private lower-skel = cw-init skel lower-cells = cells-nth lteS skel lower-dec = cells-nth-has-dec-eq lteS skel dec degree-map : Sphere (S n) → Sphere (S n) degree-map = bwproj lower-dec lower ∘ <– (Bouquet-equiv-Xₙ/Xₙ₋₁ lower-skel) ∘ cfcod ∘ attaching-last skel upper degree : ℤ degree = Trunc-⊙SphereS-endo-degree n (Trunc-⊙SphereS-endo-in n [ degree-map ]) module DegreeAtOne (skel : Skeleton {i} 1) (dec : has-cells-with-dec-eq skel) -- the cells at the upper and lower dimensions (line : cells-last skel) (point : cells-last (cw-init skel)) where private points-dec-eq = cells-nth-has-dec-eq (inr ltS) skel dec endpoint = attaching-last skel -- When [true] matches, [true] will be sent to [false], -- which is bad. degree-true : ℤ degree-true with points-dec-eq point (endpoint line true) degree-true | inl _ = -1 degree-true | inr _ = 0 -- When [false] matches, [false] will be sent to [false], -- which is good. degree-false : ℤ degree-false with points-dec-eq point (endpoint line false) degree-false | inl _ = 1 degree-false | inr _ = 0 degree : ℤ degree = degree-true ℤ+ degree-false degree-last : ∀ {n} (skel : Skeleton {i} (S n)) → has-cells-with-dec-eq skel → cells-last skel → cells-last (cw-init skel) → ℤ degree-last {n = O} = DegreeAtOne.degree degree-last {n = S _} = DegreeAboveOne.degree degree-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) → has-cells-with-dec-eq skel → cells-nth Sm≤n skel → cells-last (cw-init (cw-take Sm≤n skel)) → ℤ degree-nth Sm≤n skel dec = degree-last (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec) has-degrees-with-finite-support : ∀ {n} (skel : Skeleton {i} n) → has-cells-with-dec-eq skel → Type i has-degrees-with-finite-support {n = O} _ _ = Lift ⊤ has-degrees-with-finite-support {n = S n} skel dec = has-degrees-with-finite-support (cw-init skel) (init-has-cells-with-dec-eq skel dec) × ∀ upper → has-finite-support (cells-nth-has-dec-eq (inr ltS) skel dec) (degree-last skel dec upper) init-has-degrees-with-finite-support : ∀ {n} (skel : Skeleton {i} (S n)) dec → has-degrees-with-finite-support skel dec → has-degrees-with-finite-support (cw-init skel) (init-has-cells-with-dec-eq skel dec) init-has-degrees-with-finite-support skel dec fin-sup = fst fin-sup take-has-degrees-with-finite-support : ∀ {m n} (m≤n : m ≤ n) (skel : Skeleton {i} n) dec → has-degrees-with-finite-support skel dec → has-degrees-with-finite-support (cw-take m≤n skel) (take-has-cells-with-dec-eq m≤n skel dec) take-has-degrees-with-finite-support (inl idp) skel dec fin-sup = fin-sup take-has-degrees-with-finite-support (inr ltS) skel dec fin-sup = init-has-degrees-with-finite-support skel dec fin-sup take-has-degrees-with-finite-support (inr (ltSR lt)) skel dec fin-sup = take-has-degrees-with-finite-support (inr lt) (cw-init skel) (init-has-cells-with-dec-eq skel dec) (init-has-degrees-with-finite-support skel dec fin-sup) degree-last-has-finite-support : ∀ {n} (skel : Skeleton {i} (S n)) dec → has-degrees-with-finite-support skel dec → ∀ upper → has-finite-support (cells-last-has-dec-eq (cw-init skel) (init-has-cells-with-dec-eq skel dec)) (degree-last skel dec upper) degree-last-has-finite-support skel dec fin-sup = snd fin-sup degree-nth-has-finite-support : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec → has-degrees-with-finite-support skel dec → ∀ upper → has-finite-support (cells-last-has-dec-eq (cw-init (cw-take Sm≤n skel)) (init-has-cells-with-dec-eq (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec))) (degree-nth Sm≤n skel dec upper) degree-nth-has-finite-support Sm≤n skel dec fin-sup = degree-last-has-finite-support (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec) (take-has-degrees-with-finite-support Sm≤n skel dec fin-sup) -- the following are named [boundary'] because it is not extended to the free groups open FreeAbelianGroup boundary'-last : ∀ {n} (skel : Skeleton {i} (S n)) dec → has-degrees-with-finite-support skel dec → cells-last skel → FreeAbelianGroup.El (cells-last (cw-init skel)) boundary'-last skel dec fin-sup upper = fst ((snd fin-sup) upper) boundary-last : ∀ {n} (skel : Skeleton {i} (S n)) dec → has-degrees-with-finite-support skel dec → FreeAbGroup.grp (cells-last skel) →ᴳ FreeAbGroup.grp (cells-last (cw-init skel)) boundary-last skel dec fin-sup = Freeness.extend (cells-last skel) (FreeAbelianGroup.FreeAbGroup (cells-last (cw-init skel))) (boundary'-last skel dec fin-sup) boundary'-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec → has-degrees-with-finite-support skel dec → cells-nth Sm≤n skel → FreeAbelianGroup.El (cells-last (cw-init (cw-take Sm≤n skel))) boundary'-nth Sm≤n skel dec fin-sup = boundary'-last (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec) (take-has-degrees-with-finite-support Sm≤n skel dec fin-sup) boundary-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec → has-degrees-with-finite-support skel dec → FreeAbGroup.grp (cells-nth Sm≤n skel) →ᴳ FreeAbGroup.grp (cells-last (cw-init (cw-take Sm≤n skel))) boundary-nth Sm≤n skel dec fin-sup = Freeness.extend (cells-nth Sm≤n skel) (FreeAbGroup (cells-last (cw-init (cw-take Sm≤n skel)))) (boundary'-nth Sm≤n skel dec fin-sup)
41.959459
103
0.65475
1a4dcaca22fdf6d7c42777b9501e20c8cc8b6209
2,996
agda
Agda
Cats/Category/Fun/Facts/Product.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
24
2017-11-03T15:18:57.000Z
2021-08-06T05:00:46.000Z
Cats/Category/Fun/Facts/Product.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
null
null
null
Cats/Category/Fun/Facts/Product.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
1
2019-03-18T15:35:07.000Z
2019-03-18T15:35:07.000Z
{-# OPTIONS --without-K --safe #-} module Cats.Category.Fun.Facts.Product where open import Data.Product using (_,_) open import Cats.Category open import Cats.Category.Fun as Fun using (_↝_) open import Cats.Category.Constructions.Product using (HasBinaryProducts) open import Cats.Functor using (Functor) open import Cats.Trans using (Trans) import Cats.Category.Fun.Facts.Terminal as Terminal open Functor open Trans module Build {lo la l≈ lo′ la′ l≈′} (C : Category lo la l≈) (D : Category lo′ la′ l≈′) {{D× : HasBinaryProducts D}} where infixr 2 _×_ _×′_ ⟨_,_⟩ private module D = Category D module D× = HasBinaryProducts D× open D.≈ open Category (C ↝ D) _×_ : (F G : Obj) → Obj F × G = record { fobj = λ c → fobj F c D×.× fobj G c ; fmap = λ f → D×.⟨ fmap F f × fmap G f ⟩ ; fmap-resp = λ f≈g → D×.⟨×⟩-resp (fmap-resp F f≈g) (fmap-resp G f≈g) ; fmap-id = trans (D×.⟨×⟩-resp (fmap-id F) (fmap-id G)) D×.⟨×⟩-id ; fmap-∘ = trans D×.⟨×⟩-∘ (D×.⟨×⟩-resp (fmap-∘ F) (fmap-∘ G)) } projl : ∀ {F G} → F × G ⇒ F projl = record { component = λ c → D×.projl ; natural = D×.⟨×⟩-projl } projr : ∀ {F G} → F × G ⇒ G projr = record { component = λ c → D×.projr ; natural = D×.⟨×⟩-projr } ⟨_,_⟩ : ∀ {F G X} → X ⇒ F → X ⇒ G → X ⇒ F × G ⟨_,_⟩ α β = record { component = λ c → D×.⟨ component α c , component β c ⟩ ; natural = λ {c} {d} {f} → trans D×.⟨,⟩-∘ (trans (D×.⟨,⟩-resp (natural α) (natural β)) (sym D×.⟨×⟩-⟨,⟩)) } ⟨,⟩-projl : ∀ {F G X} {α : X ⇒ F} (β : X ⇒ G) → α ≈ projl ∘ ⟨ α , β ⟩ ⟨,⟩-projl β = Fun.≈-intro (sym D×.⟨,⟩-projl) ⟨,⟩-projr : ∀ {F G X} (α : X ⇒ F) {β : X ⇒ G} → β ≈ projr ∘ ⟨ α , β ⟩ ⟨,⟩-projr α = Fun.≈-intro (sym D×.⟨,⟩-projr) ⟨,⟩-unique : ∀ {F G X} {α : X ⇒ F} {β : X ⇒ G} {u} → α ≈ projl ∘ u → β ≈ projr ∘ u → ⟨ α , β ⟩ ≈ u ⟨,⟩-unique (Fun.≈-intro pl) (Fun.≈-intro pr) = Fun.≈-intro (D×.⟨,⟩-unique pl pr) isBinaryProduct : ∀ {F G} → IsBinaryProduct (F × G) projl projr isBinaryProduct α β = record { arr = ⟨ α , β ⟩ ; prop = (⟨,⟩-projl β , ⟨,⟩-projr α) ; unique = λ { (eql , eqr) → ⟨,⟩-unique eql eqr } } _×′_ : (F G : Obj) → BinaryProduct F G F ×′ G = mkBinaryProduct projl projr isBinaryProduct private open module Build′ {lo la l≈ lo′ la′ l≈′} {C : Category lo la l≈} {D : Category lo′ la′ l≈′} = Build C D public instance hasBinaryProducts : ∀ {lo la l≈ lo′ la′ l≈′} → {C : Category lo la l≈} {D : Category lo′ la′ l≈′} → {{D× : HasBinaryProducts D}} → HasBinaryProducts (C ↝ D) hasBinaryProducts = record { _×′_ = _×′_ } hasFiniteProducts : ∀ {lo la l≈ lo′ la′ l≈′} → {C : Category lo la l≈} {D : Category lo′ la′ l≈′} → {{D× : HasFiniteProducts D}} → HasFiniteProducts (C ↝ D) hasFiniteProducts = record { hasTerminal = Terminal.hasTerminal } -- record {} doesn't work for some reason.
25.606838
73
0.522363
a05a7848e29db3363ead95e9f1210553e3a2163c
1,964
agda
Agda
Algebra/Construct/Cayley.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
Algebra/Construct/Cayley.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
null
null
null
Algebra/Construct/Cayley.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --cubical --safe #-} open import Algebra open import Prelude open import HITs.PropositionalTruncation open import HITs.PropositionalTruncation.Sugar module Algebra.Construct.Cayley {a} (mon : Monoid a) where open Monoid mon 𝒞 : Type a 𝒞 = Σ[ f ⦂ (𝑆 → 𝑆) ] × ∀ x → ∥ f ε ∙ x ≡ f x ∥ ⟦_⇓⟧ : 𝒞 → 𝑆 ⟦ x ⇓⟧ = x .fst ε ⟦_⇑⟧ : 𝑆 → 𝒞 ⟦ x ⇑⟧ .fst y = x ∙ y ⟦ x ⇑⟧ .snd y = ∣ cong (_∙ y) (∙ε x) ∣ ⓔ : 𝒞 ⓔ .fst x = x ⓔ .snd x = ∣ ε∙ x ∣ open import Relation.Binary open import HITs.PropositionalTruncation.Equivalence open import Relation.Binary.Equivalence.Reasoning (trunc-equivalence (≡-equivalence {A = 𝑆})) _⊙_ : 𝒞 → 𝒞 → 𝒞 (x ⊙ y) .fst z = x .fst (y .fst z) (x ⊙ y) .snd z = x .fst (y .fst ε) ∙ z ≋˘⟨ cong (_∙ z) ∥$∥ (x .snd (y .fst ε)) ⟩ x .fst ε ∙ y .fst ε ∙ z ≡⟨ assoc (x .fst ε) (y .fst ε) z ⟩ x .fst ε ∙ (y .fst ε ∙ z) ≋⟨ cong (x .fst ε ∙_) ∥$∥ (y .snd z) ⟩ x .fst ε ∙ y .fst z ≋⟨ x .snd (y .fst z) ⟩ x .fst (y .fst z) ∎ ⊙-assoc : Associative _⊙_ ⊙-assoc x y z i .fst k = x .fst (y .fst (z .fst k)) ⊙-assoc x y z i .snd k = squash (((x ⊙ y) ⊙ z) .snd k) ((x ⊙ (y ⊙ z)) .snd k) i ⓔ⊙ : ∀ x → ⓔ ⊙ x ≡ x ⓔ⊙ x i .fst y = x .fst y ⓔ⊙ x i .snd y = squash ((ⓔ ⊙ x) .snd y) (x .snd y) i ⊙ⓔ : ∀ x → x ⊙ ⓔ ≡ x ⊙ⓔ x i .fst y = x .fst y ⊙ⓔ x i .snd y = squash ((x ⊙ ⓔ) .snd y) (x .snd y) i cayleyMonoid : Monoid a Monoid.𝑆 cayleyMonoid = 𝒞 Monoid._∙_ cayleyMonoid = _⊙_ Monoid.ε cayleyMonoid = ⓔ Monoid.assoc cayleyMonoid = ⊙-assoc Monoid.ε∙ cayleyMonoid = ⓔ⊙ Monoid.∙ε cayleyMonoid = ⊙ⓔ open import Data.Sigma.Properties module _ (sIsSet : isSet 𝑆) where 𝒞-leftInv-fst : ∀ x y → ⟦ ⟦ x ⇓⟧ ⇑⟧ .fst y ≡ x .fst y 𝒞-leftInv-fst x y = rec (sIsSet (x .fst ε ∙ y) (x .fst y)) id (x .snd y) 𝒞-leftInv : ∀ x → ⟦ ⟦ x ⇓⟧ ⇑⟧ ≡ x 𝒞-leftInv x = Σ≡Prop (λ f xs ys → funExt λ x → squash (xs x) (ys x)) (funExt (𝒞-leftInv-fst x)) 𝒞-iso : 𝒞 ⇔ 𝑆 fun 𝒞-iso = ⟦_⇓⟧ inv 𝒞-iso = ⟦_⇑⟧ rightInv 𝒞-iso = ∙ε leftInv 𝒞-iso = 𝒞-leftInv
26.540541
97
0.541242
9a00091f0a70a57d3e3c27d78e57d08473a6d707
1,632
agda
Agda
agda-stdlib/src/Data/Fin/Induction.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/Fin/Induction.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/Fin/Induction.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- Induction over Fin ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin.Induction where open import Data.Nat.Base using (ℕ) open import Data.Nat.Induction using (<′-wellFounded) open import Data.Fin.Base using (_≺_) open import Data.Fin.Properties open import Induction open import Induction.WellFounded as WF ------------------------------------------------------------------------ -- Re-export accessability open WF public using (Acc; acc) ------------------------------------------------------------------------ -- Complete induction based on _≺_ ≺-Rec : ∀ {ℓ} → RecStruct ℕ ℓ ℓ ≺-Rec = WfRec _≺_ ≺-wellFounded : WellFounded _≺_ ≺-wellFounded = Subrelation.wellFounded ≺⇒<′ <′-wellFounded module _ {ℓ} where open WF.All ≺-wellFounded ℓ public renaming ( wfRecBuilder to ≺-recBuilder ; wfRec to ≺-rec ) hiding (wfRec-builder) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.15 ≺-rec-builder = ≺-recBuilder {-# WARNING_ON_USAGE ≺-rec-builder "Warning: ≺-rec-builder was deprecated in v0.15. Please use ≺-recBuilder instead." #-} ≺-well-founded = ≺-wellFounded {-# WARNING_ON_USAGE ≺-well-founded "Warning: ≺-well-founded was deprecated in v0.15. Please use ≺-wellFounded instead." #-}
28.137931
72
0.514093
06ded89befcffc8410d94fcecd5820712041111b
2,070
agda
Agda
Data/FingerTree.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
Data/FingerTree.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
null
null
null
Data/FingerTree.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --cubical --safe #-} open import Prelude open import Algebra module Data.FingerTree {ℓ} (mon : Monoid ℓ) where open Monoid mon record Measured {a} (A : Type a) : Type (a ℓ⊔ ℓ) where constructor measured field μ : A → 𝑆 open Measured ⦃ ... ⦄ public data Digit {a} (A : Type a) : Type a where D₁ : A → Digit A D₂ : A → A → Digit A D₃ : A → A → A → Digit A data Node {a} (A : Type a) : Type a where N₂ : A → A → Node A N₃ : A → A → A → Node A instance measuredDigit : ⦃ _ : Measured A ⦄ → Measured (Digit A) measuredDigit = measured λ { (D₁ x) → μ x ; (D₂ x x₁) → μ x ∙ μ x₁ ; (D₃ x x₁ x₂) → μ x ∙ μ x₁ ∙ μ x₂ } instance measuredNode : ⦃ _ : Measured A ⦄ → Measured (Node A) measuredNode = measured λ { (N₂ x x₁) → μ x ∙ μ x₁ ; (N₃ x x₁ x₂) → μ x ∙ μ x₁ ∙ μ x₂ } record ⟪_⟫ (A : Type a) ⦃ _ : Measured A ⦄ : Type (a ℓ⊔ ℓ) where constructor recd field val : A mem : 𝑆 prf : μ val ≡ mem open ⟪_⟫ public memo : ⦃ _ : Measured A ⦄ → A → ⟪ A ⟫ memo x = recd x (μ x) refl instance measuredMemo : ⦃ _ : Measured A ⦄ → Measured ⟪ A ⟫ measuredMemo = measured mem mutual record Deep {a} (A : Type a) ⦃ _ : Measured A ⦄ : Type (a ℓ⊔ ℓ) where pattern constructor more inductive field lbuff : Digit A tree : Tree ⟪ Node A ⟫ rbuff : Digit A data Tree {a} (A : Type a) ⦃ _ : Measured A ⦄ : Type (a ℓ⊔ ℓ) where empty : Tree A single : A → Tree A deep : ⟪ Deep A ⟫ → Tree A μ-deep : ∀ {a} {A : Type a} ⦃ _ : Measured A ⦄ → Deep A → 𝑆 μ-deep (more l x r) = μ l ∙ (μ-tree x ∙ μ r) μ-tree : ∀ {a} {A : Type a} ⦃ _ : Measured A ⦄ → Tree A → 𝑆 μ-tree empty = ε μ-tree (single x) = μ x μ-tree (deep xs) = xs .mem instance Measured-Deep : ∀ {a} {A : Type a} → ⦃ _ : Measured A ⦄ → Measured (Deep A) Measured-Deep = measured μ-deep instance Measured-Tree : ∀ {a} {A : Type a} → ⦃ _ : Measured A ⦄ → Measured (Tree A) Measured-Tree = measured μ-tree open Deep
24.069767
79
0.535749
1e07186d6eefe2fb2326d5eeb5083f51f7857ebd
4,596
agda
Agda
Cubical/Data/Nat/Properties.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Data/Nat/Properties.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Data/Nat/Properties.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
1
2021-03-12T20:08:45.000Z
2021-03-12T20:08:45.000Z
{-# OPTIONS --no-exact-split --safe #-} module Cubical.Data.Nat.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Nat.Base open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Sigma open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq private variable l m n : ℕ min : ℕ → ℕ → ℕ min zero m = zero min (suc n) zero = zero min (suc n) (suc m) = suc (min n m) minComm : (n m : ℕ) → min n m ≡ min m n minComm zero zero = refl minComm zero (suc m) = refl minComm (suc n) zero = refl minComm (suc n) (suc m) = cong suc (minComm n m) max : ℕ → ℕ → ℕ max zero m = m max (suc n) zero = suc n max (suc n) (suc m) = suc (max n m) maxComm : (n m : ℕ) → max n m ≡ max m n maxComm zero zero = refl maxComm zero (suc m) = refl maxComm (suc n) zero = refl maxComm (suc n) (suc m) = cong suc (maxComm n m) znots : ¬ (0 ≡ suc n) znots eq = subst (caseNat ℕ ⊥) eq 0 snotz : ¬ (suc n ≡ 0) snotz eq = subst (caseNat ⊥ ℕ) eq 0 injSuc : suc m ≡ suc n → m ≡ n injSuc p = cong predℕ p discreteℕ : Discrete ℕ discreteℕ zero zero = yes refl discreteℕ zero (suc n) = no znots discreteℕ (suc m) zero = no snotz discreteℕ (suc m) (suc n) with discreteℕ m n ... | yes p = yes (cong suc p) ... | no p = no (λ x → p (injSuc x)) isSetℕ : isSet ℕ isSetℕ = Discrete→isSet discreteℕ -- Arithmetic facts about predℕ suc-predℕ : ∀ n → ¬ n ≡ 0 → n ≡ suc (predℕ n) suc-predℕ zero p = ⊥.rec (p refl) suc-predℕ (suc n) p = refl -- Arithmetic facts about + +-zero : ∀ m → m + 0 ≡ m +-zero zero = refl +-zero (suc m) = cong suc (+-zero m) +-suc : ∀ m n → m + suc n ≡ suc (m + n) +-suc zero n = refl +-suc (suc m) n = cong suc (+-suc m n) +-comm : ∀ m n → m + n ≡ n + m +-comm m zero = +-zero m +-comm m (suc n) = (+-suc m n) ∙ (cong suc (+-comm m n)) -- Addition is associative +-assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o +-assoc zero _ _ = refl +-assoc (suc m) n o = cong suc (+-assoc m n o) inj-m+ : m + l ≡ m + n → l ≡ n inj-m+ {zero} p = p inj-m+ {suc m} p = inj-m+ (injSuc p) inj-+m : l + m ≡ n + m → l ≡ n inj-+m {l} {m} {n} p = inj-m+ ((+-comm m l) ∙ (p ∙ (+-comm n m))) m+n≡n→m≡0 : m + n ≡ n → m ≡ 0 m+n≡n→m≡0 {n = zero} = λ p → (sym (+-zero _)) ∙ p m+n≡n→m≡0 {n = suc n} p = m+n≡n→m≡0 (injSuc ((sym (+-suc _ n)) ∙ p)) m+n≡0→m≡0×n≡0 : m + n ≡ 0 → (m ≡ 0) × (n ≡ 0) m+n≡0→m≡0×n≡0 {zero} = refl ,_ m+n≡0→m≡0×n≡0 {suc m} p = ⊥.rec (snotz p) -- Arithmetic facts about · 0≡m·0 : ∀ m → 0 ≡ m · 0 0≡m·0 zero = refl 0≡m·0 (suc m) = 0≡m·0 m ·-suc : ∀ m n → m · suc n ≡ m + m · n ·-suc zero n = refl ·-suc (suc m) n = cong suc ( n + m · suc n ≡⟨ cong (n +_) (·-suc m n) ⟩ n + (m + m · n) ≡⟨ +-assoc n m (m · n) ⟩ (n + m) + m · n ≡⟨ cong (_+ m · n) (+-comm n m) ⟩ (m + n) + m · n ≡⟨ sym (+-assoc m n (m · n)) ⟩ m + (n + m · n) ∎ ) ·-comm : ∀ m n → m · n ≡ n · m ·-comm zero n = 0≡m·0 n ·-comm (suc m) n = cong (n +_) (·-comm m n) ∙ sym (·-suc n m) ·-distribʳ : ∀ m n o → (m · o) + (n · o) ≡ (m + n) · o ·-distribʳ zero _ _ = refl ·-distribʳ (suc m) n o = sym (+-assoc o (m · o) (n · o)) ∙ cong (o +_) (·-distribʳ m n o) ·-distribˡ : ∀ o m n → (o · m) + (o · n) ≡ o · (m + n) ·-distribˡ o m n = (λ i → ·-comm o m i + ·-comm o n i) ∙ ·-distribʳ m n o ∙ ·-comm (m + n) o ·-assoc : ∀ m n o → m · (n · o) ≡ (m · n) · o ·-assoc zero _ _ = refl ·-assoc (suc m) n o = cong (n · o +_) (·-assoc m n o) ∙ ·-distribʳ n (m · n) o ·-identityˡ : ∀ m → 1 · m ≡ m ·-identityˡ m = +-zero m ·-identityʳ : ∀ m → m · 1 ≡ m ·-identityʳ zero = refl ·-identityʳ (suc m) = cong suc (·-identityʳ m) 0≡n·sm→0≡n : 0 ≡ n · suc m → 0 ≡ n 0≡n·sm→0≡n {n = zero} p = refl 0≡n·sm→0≡n {n = suc n} p = ⊥.rec (znots p) inj-·sm : l · suc m ≡ n · suc m → l ≡ n inj-·sm {zero} {m} {n} p = 0≡n·sm→0≡n p inj-·sm {l} {m} {zero} p = sym (0≡n·sm→0≡n (sym p)) inj-·sm {suc l} {m} {suc n} p = cong suc (inj-·sm (inj-m+ {m = suc m} p)) inj-sm· : suc m · l ≡ suc m · n → l ≡ n inj-sm· {m} {l} {n} p = inj-·sm (·-comm l (suc m) ∙ p ∙ ·-comm (suc m) n) -- Arithmetic facts about ∸ zero∸ : ∀ n → zero ∸ n ≡ zero zero∸ zero = refl zero∸ (suc _) = refl ∸-cancelˡ : ∀ k m n → (k + m) ∸ (k + n) ≡ m ∸ n ∸-cancelˡ zero = λ _ _ → refl ∸-cancelˡ (suc k) = ∸-cancelˡ k ∸-cancelʳ : ∀ m n k → (m + k) ∸ (n + k) ≡ m ∸ n ∸-cancelʳ m n k = (λ i → +-comm m k i ∸ +-comm n k i) ∙ ∸-cancelˡ k m n ∸-distribʳ : ∀ m n k → (m ∸ n) · k ≡ m · k ∸ n · k ∸-distribʳ m zero k = refl ∸-distribʳ zero (suc n) k = sym (zero∸ (k + n · k)) ∸-distribʳ (suc m) (suc n) k = ∸-distribʳ m n k ∙ sym (∸-cancelˡ k (m · k) (n · k))
27.195266
92
0.519582
1ef1c0f550520e7d6c329b785c085a832631537d
1,151
agda
Agda
src/Categories/Functor/Core.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Functor/Core.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Functor/Core.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Functor.Core where open import Level open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) private variable o ℓ e o′ ℓ′ e′ : Level record Functor (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where eta-equality private module C = Category C private module D = Category D field F₀ : C.Obj → D.Obj F₁ : ∀ {A B} (f : C [ A , B ]) → D [ F₀ A , F₀ B ] identity : ∀ {A} → D [ F₁ (C.id {A}) ≈ D.id ] homomorphism : ∀ {X Y Z} {f : C [ X , Y ]} {g : C [ Y , Z ]} → D [ F₁ (C [ g ∘ f ]) ≈ D [ F₁ g ∘ F₁ f ] ] F-resp-≈ : ∀ {A B} {f g : C [ A , B ]} → C [ f ≈ g ] → D [ F₁ f ≈ F₁ g ] -- nice shorthands ₀ = F₀ ₁ = F₁ op : Functor C.op D.op op = record { F₀ = F₀ ; F₁ = F₁ ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = F-resp-≈ } private op-involutive : {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → (F : Functor C D) → Functor.op (Functor.op F) ≡ F op-involutive _ = ≡.refl
26.159091
114
0.50391
a090a7abc08b6a64533178b760242aa36a0bf993
89
agda
Agda
src/Human/Empty.agda
MaisaMilena/JuiceMaker
b509eb4c4014605facfb4ee5c807cd07753d4477
[ "MIT" ]
6
2019-03-29T17:35:20.000Z
2020-11-28T05:46:27.000Z
src/Human/Empty.agda
MaisaMilena/AgdaCalculator
e977a5f2a005682cee123568b49462dd7d7b11ad
[ "MIT" ]
null
null
null
src/Human/Empty.agda
MaisaMilena/AgdaCalculator
e977a5f2a005682cee123568b49462dd7d7b11ad
[ "MIT" ]
null
null
null
module Human.Empty where data Empty : Set where void : ∀ {P : Set} → Empty → P void ()
12.714286
30
0.629213
9a35e1b8d0e650c28bed051016c6286fa22f13ee
841
agda
Agda
src/Partiality-monad/Coinductive.agda
nad/partiality-monad
f69749280969f9093e5e13884c6feb0ad2506eae
[ "MIT" ]
2
2020-05-21T22:59:18.000Z
2020-07-03T08:56:08.000Z
src/Partiality-monad/Coinductive.agda
nad/partiality-monad
f69749280969f9093e5e13884c6feb0ad2506eae
[ "MIT" ]
null
null
null
src/Partiality-monad/Coinductive.agda
nad/partiality-monad
f69749280969f9093e5e13884c6feb0ad2506eae
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- The delay monad quotiented by weak bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --sized-types #-} module Partiality-monad.Coinductive where open import Equality.Propositional.Cubical open import Prelude hiding (⊥) open import Prelude.Size open import H-level.Truncation.Propositional equality-with-paths open import Quotient equality-with-paths open import Delay-monad open import Delay-monad.Bisimilarity -- The partiality monad, defined as the delay monad quotiented by -- (propositionally truncated) weak bisimilarity. _⊥ : ∀ {a} → Type a → Type a A ⊥ = Delay A ∞ / λ x y → ∥ x ≈ y ∥ -- The partiality monad is a set. ⊥-is-set : ∀ {a} {A : Type a} → Is-set (A ⊥) ⊥-is-set = /-is-set
29
72
0.595719
4bbf937d8af3ae3e9062e468a9987d5ba128e4af
446
agda
Agda
agda/OList.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
6
2015-05-21T12:50:35.000Z
2021-08-24T22:11:15.000Z
agda/OList.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
agda/OList.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
module OList {A : Set}(_≤_ : A → A → Set) where open import Data.List open import Bound.Lower A open import Bound.Lower.Order _≤_ data OList : Bound → Set where onil : {b : Bound} → OList b :< : {b : Bound}{x : A} → LeB b (val x) → OList (val x) → OList b forget : {b : Bound} → OList b → List A forget onil = [] forget ( :< {x = x} _ xs) = x ∷ forget xs
21.238095
47
0.482063
188ea5caefc6ade4addd9535b1cf9bbde7e39296
4,510
agda
Agda
Agda/SAT-solver.agda
jonsterling/HoTT-Intro
7457d00fbd2c0a993b01cd2b3dbc4f259213845e
[ "CC-BY-4.0" ]
333
2018-09-26T08:33:30.000Z
2022-03-22T23:50:15.000Z
Agda/SAT-solver.agda
jonsterling/HoTT-Intro
7457d00fbd2c0a993b01cd2b3dbc4f259213845e
[ "CC-BY-4.0" ]
8
2019-06-18T04:16:04.000Z
2020-10-16T15:27:01.000Z
Agda/SAT-solver.agda
jonsterling/HoTT-Intro
7457d00fbd2c0a993b01cd2b3dbc4f259213845e
[ "CC-BY-4.0" ]
30
2018-09-26T09:08:57.000Z
2022-03-16T00:33:50.000Z
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-} module SAT-solver where import 12-univalence open 12-univalence public {- The literates are atomic propositions or negations thereof. We simply use the natural numbers to encode the atomic propositions, and we use the booleans to tell whether it should be negated or not. -} Literate = ℕ × bool neg-Literate : Literate → Literate neg-Literate (pair n b) = pair n (neg-𝟚 b) zero-true-Literate : Literate zero-true-Literate = pair zero-ℕ true truth-value-Literate : (ℕ → bool) → Literate → bool truth-value-Literate f (pair n true) = f n truth-value-Literate f (pair n false) = neg-𝟚 (f n) bool-Eq-ℕ : ℕ → ℕ → bool bool-Eq-ℕ zero-ℕ zero-ℕ = true bool-Eq-ℕ zero-ℕ (succ-ℕ n) = false bool-Eq-ℕ (succ-ℕ m) zero-ℕ = false bool-Eq-ℕ (succ-ℕ m) (succ-ℕ n) = bool-Eq-ℕ m n bool-Eq-𝟚 : bool → bool → bool bool-Eq-𝟚 true true = true bool-Eq-𝟚 true false = false bool-Eq-𝟚 false true = false bool-Eq-𝟚 false false = true bool-Eq-Literate : Literate → Literate → bool bool-Eq-Literate (pair m x) (pair n y) = conjunction-𝟚 (bool-Eq-ℕ m n) (bool-Eq-𝟚 x y) {- Clauses are finite disjunctions of literates. We simply encode them using lists of literates. -} Clause = list Literate clause-Literate : Literate → Clause clause-Literate l = cons l nil is-literate-Clause : Clause → UU lzero is-literate-Clause c = Σ Literate (λ l → Id (clause-Literate l) c) zero-true-Clause = clause-Literate zero-true-Literate truth-value-Clause : (ℕ → bool) → Clause → bool truth-value-Clause f nil = false truth-value-Clause f (cons l c) = disjunction-𝟚 (truth-value-Literate f l) (truth-value-Clause f c) contains-Clause : Literate → Clause → bool contains-Clause l nil = false contains-Clause l (cons l' c) = disjunction-𝟚 (bool-Eq-Literate l l') (contains-Clause l c) if-then-else : {l : Level} {A : UU l} → bool → A → A → A if-then-else true x y = x if-then-else false x y = y if-then-else-dep : {l1 l2 : Level} {A : UU l1} (B : A → UU l2) (b : bool) {x y : A} (u : Id b true → B x) (v : Id b false → B y) → B (if-then-else b x y) if-then-else-dep B true u v = u refl if-then-else-dep B false u v = v refl {- We write a function that simplifies a clause in the following way: * simplified clauses do not contain any literate more than once. * if a simplified clause contains a literate and its negation, then it is of the form l ∨ ¬l. -} simplify-Clause : Clause → Clause simplify-Clause nil = nil simplify-Clause (cons l c) = if-then-else ( contains-Clause (neg-Literate l) c) ( cons l (cons (neg-Literate l) nil)) ( if-then-else ( contains-Clause l c) ( simplify-Clause c) ( cons l (simplify-Clause c))) is-satisfiable-Clause : Clause → UU lzero is-satisfiable-Clause c = Σ (ℕ → bool) (λ f → Id (truth-value-Clause f c) true) {- We show that any non-empty disjunctive clause is satisfiable. -} right-true-law-disjunction-𝟚 : (b : bool) → Id (disjunction-𝟚 b true) true right-true-law-disjunction-𝟚 true = refl right-true-law-disjunction-𝟚 false = refl left-true-law-disjunction-𝟚 : (b : bool) → Id (disjunction-𝟚 true b) true left-true-law-disjunction-𝟚 true = refl left-true-law-disjunction-𝟚 false = refl is-satisfiable-cons-Clause : ( l : Literate) (c : Clause) → is-satisfiable-Clause (cons l c) is-satisfiable-cons-Clause (pair n true) c = pair ( const ℕ bool true) ( left-true-law-disjunction-𝟚 (truth-value-Clause (const ℕ bool true) c)) is-satisfiable-cons-Clause (pair n false) c = pair ( const ℕ bool false) ( left-true-law-disjunction-𝟚 (truth-value-Clause (const ℕ bool false) c)) {- Formulas in conjunctive normal form are finite conjunctions of clauses, as defined above. Therefore we encode them as lists of clauses. -} CNF = list Clause truth-value-CNF : (ℕ → bool) → CNF → bool truth-value-CNF f nil = true truth-value-CNF f (cons c φ) = conjunction-𝟚 (truth-value-Clause f c) (truth-value-CNF f φ) {- A formula φ is in conjunctive normal form is said to be satisfiable if there is a map ℕ → bool which evaluates φ to true. -} is-satisfiable-CNF : CNF → UU lzero is-satisfiable-CNF φ = Σ (ℕ → bool) (λ f → Id (truth-value-CNF f φ) true) contains-CNF : (l : Literate) (φ : CNF) → bool contains-CNF l nil = false contains-CNF l (cons c φ) = disjunction-𝟚 (contains-Clause l c) (contains-CNF l φ) contains simplify-CNF : CNF → CNF simplify-CNF nil = nil simplify-CNF (cons c φ) = cons (simplify-Clause c) (simplify-CNF φ)
31.985816
79
0.685809
2915072e45a98bd53e78795cb3c043eab97e756b
158
agda
Agda
test/Fail/Negative2.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Negative2.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Negative2.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Negative2 where data Tree (A : Set) : Set where leaf : Tree A node : (A -> Tree A) -> Tree A data Bad : Set where bad : Tree Bad -> Bad
15.8
34
0.582278
20aad6ce089d86b2754c8dc1a1d1b0ae6f7c5160
8,074
agda
Agda
old/Structure/Logic/Classical/NaturalDeduction/Proofs.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
old/Structure/Logic/Classical/NaturalDeduction/Proofs.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
old/Structure/Logic/Classical/NaturalDeduction/Proofs.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
import Structure.Logic.Classical.NaturalDeduction module Structure.Logic.Classical.NaturalDeduction.Proofs {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ where open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic) open import Functional hiding (Domain) -- TODO: Move the ones which are constructive [↔]-with-[∧]ₗ : ∀{a₁ a₂ b} → Proof(a₁ ⟷ a₂) → Proof((a₁ ∧ b) ⟷ (a₂ ∧ b)) [↔]-with-[∧]ₗ (proof) = ([↔].intro (a₂b ↦ [∧].intro (([↔].elimₗ proof) ([∧].elimₗ a₂b)) ([∧].elimᵣ a₂b)) (a₁b ↦ [∧].intro (([↔].elimᵣ proof) ([∧].elimₗ a₁b)) ([∧].elimᵣ a₁b)) ) [↔]-with-[∧]ᵣ : ∀{a b₁ b₂} → Proof(b₁ ⟷ b₂) → Proof((a ∧ b₁) ⟷ (a ∧ b₂)) [↔]-with-[∧]ᵣ (proof) = ([↔].intro (ab₂ ↦ [∧].intro ([∧].elimₗ ab₂) (([↔].elimₗ proof) ([∧].elimᵣ ab₂))) (ab₁ ↦ [∧].intro ([∧].elimₗ ab₁) (([↔].elimᵣ proof) ([∧].elimᵣ ab₁))) ) [↔]-with-[∧] : ∀{a₁ a₂ b₁ b₂} → Proof(a₁ ⟷ a₂) → Proof(b₁ ⟷ b₂) → Proof((a₁ ∧ b₁) ⟷ (a₂ ∧ b₂)) [↔]-with-[∧] (a₁a₂) (b₁b₂) = ([↔].intro (a₂b₂ ↦ [∧].intro (([↔].elimₗ a₁a₂) ([∧].elimₗ a₂b₂)) (([↔].elimₗ b₁b₂) ([∧].elimᵣ a₂b₂))) (a₁b₁ ↦ [∧].intro (([↔].elimᵣ a₁a₂) ([∧].elimₗ a₁b₁)) (([↔].elimᵣ b₁b₂) ([∧].elimᵣ a₁b₁))) ) [↔]-with-[∨]ₗ : ∀{a₁ a₂ b} → Proof(a₁ ⟷ a₂) → Proof((a₁ ∨ b) ⟷ (a₂ ∨ b)) [↔]-with-[∨]ₗ (proof) = ([↔].intro ([∨].elim([∨].introₗ ∘ ([↔].elimₗ proof)) [∨].introᵣ) ([∨].elim([∨].introₗ ∘ ([↔].elimᵣ proof)) [∨].introᵣ) ) [↔]-with-[∨]ᵣ : ∀{a b₁ b₂} → Proof(b₁ ⟷ b₂) → Proof((a ∨ b₁) ⟷ (a ∨ b₂)) [↔]-with-[∨]ᵣ (proof) = ([↔].intro ([∨].elim [∨].introₗ ([∨].introᵣ ∘ ([↔].elimₗ proof))) ([∨].elim [∨].introₗ ([∨].introᵣ ∘ ([↔].elimᵣ proof))) ) [↔]-with-[∨] : ∀{a₁ a₂ b₁ b₂} → Proof(a₁ ⟷ a₂) → Proof(b₁ ⟷ b₂) → Proof((a₁ ∨ b₁) ⟷ (a₂ ∨ b₂)) [↔]-with-[∨] (a₁a₂) (b₁b₂) = ([↔].intro ([∨].elim ([∨].introₗ ∘ ([↔].elimₗ a₁a₂)) ([∨].introᵣ ∘ ([↔].elimₗ b₁b₂))) ([∨].elim ([∨].introₗ ∘ ([↔].elimᵣ a₁a₂)) ([∨].introᵣ ∘ ([↔].elimᵣ b₁b₂))) ) [↔]-with-[∀] : ∀{f g} → (∀{x} → Proof(f(x) ⟷ g(x))) → Proof((∀ₗ f) ⟷ (∀ₗ g)) [↔]-with-[∀] (proof) = ([↔].intro (allg ↦ [∀].intro(\{x} → [↔].elimₗ (proof{x}) ([∀].elim(allg){x}))) (allf ↦ [∀].intro(\{x} → [↔].elimᵣ (proof{x}) ([∀].elim(allf){x}))) ) [↔]-with-[∃] : ∀{f g} → (∀{x} → Proof(f(x) ⟷ g(x))) → Proof((∃ₗ f) ⟷ (∃ₗ g)) [↔]-with-[∃] (proof) = ([↔].intro ([∃].elim(\{x} → gx ↦ [∃].intro{_}{x}([↔].elimₗ (proof{x}) (gx)))) ([∃].elim(\{x} → fx ↦ [∃].intro{_}{x}([↔].elimᵣ (proof{x}) (fx)))) ) -- [→]-with-[∀] : ∀{p f g} → (∀{x} → Proof(f(x) ⟶ g(x))) → Proof((∀ₗ f) ⟶ (∀ₗ g)) -- [→]-with-[∀] (proof) = -- [→]-with-[∀] : ∀{p f g} → (∀{x} → Proof(f(x) ⟶ g(x))) → Proof(∀ₗ(x ↦ p(x) ⟶ f(x))) → Proof(∀ₗ(x ↦ p(x) ⟶ g(x))) -- [→]-with-[∀] (proof) = [∨][∧]-distributivityₗ : ∀{a b c} → Proof((a ∨ (b ∧ c)) ⟷ (a ∨ b)∧(a ∨ c)) [∨][∧]-distributivityₗ = ([↔].intro (a∨b∧a∨c ↦ ([∨].elim (a ↦ [∨].introₗ a) (b ↦ ([∨].elim (a ↦ [∨].introₗ a) (c ↦ [∨].introᵣ([∧].intro b c)) ([∧].elimᵣ a∨b∧a∨c) ) ) ([∧].elimₗ a∨b∧a∨c) ) ) (a∨b∧c ↦ ([∨].elim (a ↦ [∧].intro([∨].introₗ a)([∨].introₗ a)) (b∧c ↦ [∧].intro([∨].introᵣ([∧].elimₗ b∧c))([∨].introᵣ([∧].elimᵣ b∧c))) (a∨b∧c) ) ) ) [∨][∧]-distributivityᵣ : ∀{a b c} → Proof(((a ∧ b) ∨ c) ⟷ (a ∨ c)∧(b ∨ c)) [∨][∧]-distributivityᵣ = ([↔].intro (a∨c∧b∨c ↦ ([∨].elim (a ↦ ([∨].elim (b ↦ [∨].introₗ([∧].intro a b)) (c ↦ [∨].introᵣ c) ([∧].elimᵣ a∨c∧b∨c) ) ) (c ↦ [∨].introᵣ c) ([∧].elimₗ a∨c∧b∨c) ) ) (a∧b∨c ↦ ([∨].elim (a∧b ↦ [∧].intro([∨].introₗ([∧].elimₗ a∧b))([∨].introₗ([∧].elimᵣ a∧b))) (c ↦ [∧].intro([∨].introᵣ c)([∨].introᵣ c)) (a∧b∨c) ) ) ) [∧][∨]-distributivityₗ : ∀{a b c} → Proof((a ∧ (b ∨ c)) ⟷ (a ∧ b)∨(a ∧ c)) [∧][∨]-distributivityₗ = ([↔].intro (a∧b∨a∧c ↦ ([∨].elim (a∧b ↦ [∧].intro([∧].elimₗ a∧b)([∨].introₗ([∧].elimᵣ a∧b))) (a∧c ↦ [∧].intro([∧].elimₗ a∧c)([∨].introᵣ([∧].elimᵣ a∧c))) (a∧b∨a∧c) ) ) (a∧b∨c ↦ ([∨].elim (b ↦ [∨].introₗ([∧].intro([∧].elimₗ a∧b∨c)(b))) (c ↦ [∨].introᵣ([∧].intro([∧].elimₗ a∧b∨c)(c))) ([∧].elimᵣ a∧b∨c) ) ) ) [∧][∨]-distributivityᵣ : ∀{a b c} → Proof(((a ∨ b) ∧ c) ⟷ (a ∧ c)∨(b ∧ c)) [∧][∨]-distributivityᵣ = ([↔].intro (a∧c∨b∧c ↦ ([∨].elim (a∧c ↦ [∧].intro([∨].introₗ([∧].elimₗ a∧c))([∧].elimᵣ a∧c)) (b∧c ↦ [∧].intro([∨].introᵣ([∧].elimₗ b∧c))([∧].elimᵣ b∧c)) (a∧c∨b∧c) ) ) (a∨b∧c ↦ ([∨].elim (a ↦ [∨].introₗ([∧].intro(a)([∧].elimᵣ a∨b∧c))) (b ↦ [∨].introᵣ([∧].intro(b)([∧].elimᵣ a∨b∧c))) ([∧].elimₗ a∨b∧c) ) ) ) postulate [≡]-substitute-this-is-almost-trivial : ∀{φ : Domain → Formula}{a b} → Proof(((a ≡ b) ∧ φ(a)) ⟷ φ(b)) postulate [→][∧]-distributivityₗ : ∀{X Y Z} → Proof((X ⟶ (Y ∧ Z)) ⟷ ((X ⟶ Y) ∧ (X ⟶ Z))) postulate [∀]-unrelatedₗ-[→] : ∀{P : Domain → Formula}{Q : Formula} → Proof(∀ₗ(x ↦ (P(x) ⟶ Q)) ⟷ (∃ₗ(x ↦ P(x)) ⟶ Q)) postulate [∀]-unrelatedᵣ-[→] : ∀{P : Formula}{Q : Domain → Formula} → Proof(∀ₗ(x ↦ (P ⟶ Q(x))) ⟷ (P ⟶ ∀ₗ(x ↦ Q(x)))) postulate [∃]-unrelatedₗ-[→] : ∀{P : Domain → Formula}{Q : Formula} → Proof(∃ₗ(x ↦ (P(x) ⟶ Q)) ⟷ (∀ₗ(x ↦ P(x)) ⟶ Q)) postulate [∃]-unrelatedᵣ-[→] : ∀{P : Formula}{Q : Domain → Formula} → Proof(∃ₗ(x ↦ (P ⟶ Q(x))) ⟷ (P ⟶ ∃ₗ(x ↦ Q(x)))) -- TODO: Is equivalence unprovable? I think so Unique-unrelatedᵣ-[→]ᵣ : ∀{P : Formula}{Q : Domain → Formula} → Proof(Unique(x ↦ (P ⟶ Q(x))) ⟶ (P ⟶ Unique(x ↦ Q(x)))) Unique-unrelatedᵣ-[→]ᵣ {P}{Q} = [→].intro(uniquepq ↦ [→].intro(p ↦ [∀].intro(\{x} → [∀].intro(\{y} → [→].intro(qxqy ↦ ([→].elim ([∀].elim([∀].elim uniquepq{x}){y}) (([↔].elimᵣ [→][∧]-distributivityₗ) ([→].intro(p ↦ qxqy))) ) ))))) -- Proving these equivalent: -- ∀ₗ(x ↦ ∀ₗ(y ↦ (P ⟶ Q(x)) ∧ (P ⟶ Q(y)) ⟶ (x ≡ y)) -- P ⟶ ∀ₗ(x ↦ ∀ₗ(y ↦ Q(x) ∧ Q(y) ⟶ (x ≡ y)) -- test : Proof(∀ₗ(x ↦ ∀ₗ(y ↦ (P ⟶ Q(x)) ∧ (P ⟶ Q(y)) ⟶ (x ≡ y))) ⟷ ∀ₗ(x ↦ ∀ₗ(y ↦ (P ⟶ Q(x) ∧ Q(y)) ⟶ (x ≡ y)))) -- test = ([↔]-with-[∀] ([↔]-with-[∀] ([→][∧]-distributivityₗ))) -- TODO: Is left provable? Above left seems unprovable [∃!]-unrelatedᵣ-[→]ᵣ : ∀{P : Formula}{Q : Domain → Formula} → Proof(∃ₗ!(x ↦ (P ⟶ Q(x))) ⟶ (P ⟶ ∃ₗ!(x ↦ Q(x)))) [∃!]-unrelatedᵣ-[→]ᵣ {P}{Q} = ([→].intro(proof ↦ ([↔].elimₗ [→][∧]-distributivityₗ) ([∧].intro (([↔].elimᵣ [∃]-unrelatedᵣ-[→]) ([∧].elimₗ proof)) (([→].elim Unique-unrelatedᵣ-[→]ᵣ) ([∧].elimᵣ proof)) ) )) -- TODO: I think this is similar to the skolemization process of going from ∀∃ to ∃function∀ [∃]-fn-witness : ∀{P : Domain → Domain → Formula} → ⦃ _ : Proof(∀ₗ(x ↦ ∃ₗ(y ↦ P(x)(y)))) ⦄ → Domain → Domain [∃]-fn-witness{P} ⦃ proof ⦄ (x) = [∃]-witness ⦃ [∀].elim(proof){x} ⦄ [∃]-fn-proof : ∀{P : Domain → Domain → Formula} → ⦃ p : Proof(∀ₗ(x ↦ ∃ₗ(y ↦ P(x)(y)))) ⦄ → Proof(∀ₗ(x ↦ P(x)([∃]-fn-witness{P} ⦃ p ⦄ (x)))) [∃]-fn-proof{P} ⦃ proof ⦄ = ([∀].intro(\{x} → [∃]-proof {P(x)} ⦃ [∀].elim proof{x} ⦄ )) [∃!]-fn-witness : ∀{P : Domain → Domain → Formula} → ⦃ _ : Proof(∀ₗ(x ↦ ∃ₗ!(y ↦ P(x)(y)))) ⦄ → Domain → Domain [∃!]-fn-witness{P} ⦃ proof ⦄ (x) = [∃!]-witness ⦃ [∀].elim(proof){x} ⦄ {- [∃!]-fn-proof : ∀{P : Domain → Domain → Formula} → ⦃ p : Proof(∀ₗ(x ↦ ∃ₗ!(y ↦ P(x)(y)))) ⦄ → Proof(∀ₗ(x ↦ P(x)([∃!]-fn-witness{P} ⦃ p ⦄ (x)))) [∃!]-fn-proof{P} ⦃ proof ⦄ = ([∀].intro(\{x} → [∃!]-proof {P(x)} ⦃ [∀].elim proof{x} ⦄ )) -} [∃!]-fn-proof : ∀{P : Domain → Domain → Formula} → ⦃ p : Proof(∀ₗ(x ↦ ∃ₗ!(y ↦ P(x)(y)))) ⦄ → ∀{x} → Proof(P(x)([∃!]-fn-witness{P} ⦃ p ⦄ (x))) [∃!]-fn-proof{P} ⦃ proof ⦄ {x} = [∃!]-proof {P(x)} ⦃ [∀].elim proof{x} ⦄ postulate [∃!]-fn-unique : ∀{P : Domain → Domain → Formula} → ⦃ p : Proof(∀ₗ(x ↦ ∃ₗ!(y ↦ P(x)(y)))) ⦄ → ∀{x} → Proof(∀ₗ(y ↦ P(x)(y) ⟶ (y ≡ [∃!]-fn-witness{P} ⦃ p ⦄ (x))))
35.412281
170
0.421724
0b80e4c416d56691f7c308b956144d4c1c27152d
2,112
agda
Agda
src/PiCalculus/Utils.agda
guilhermehas/typing-linear-pi
0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a
[ "MIT" ]
26
2020-05-02T23:32:11.000Z
2022-03-14T15:18:23.000Z
src/PiCalculus/Utils.agda
guilhermehas/typing-linear-pi
0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a
[ "MIT" ]
1
2022-03-15T09:16:14.000Z
2022-03-15T09:16:14.000Z
src/PiCalculus/Utils.agda
guilhermehas/typing-linear-pi
0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a
[ "MIT" ]
3
2021-01-25T13:57:13.000Z
2022-03-14T16:24:07.000Z
{-# OPTIONS --safe --without-K #-} open import Level using (_⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; trans; subst₂) open import Function using (_∘_) open import Relation.Nullary.Negation using (contradiction) module PiCalculus.Utils where module ListInv {a} {A : Set a} where open import Data.List as List using (List; []; _∷_; [_]; _++_) import Data.List.Properties as Listₚ import Data.List.Membership.Propositional.Properties as ∈ₚ import Data.List.Relation.Unary.Any.Properties as Anyₚ open import Data.List.Relation.Unary.Any using (Any; here; there) open import Data.List.Membership.Propositional using (_∈_; _∉_) open import Data.List.Relation.Binary.Equality.Propositional {A = A} using (_≋_; []; _∷_; ≋⇒≡; ≡⇒≋; ≋-refl) inv-++ˡ' : ∀ lx ly {rx ry} s → s ∉ lx → s ∉ ly → lx ++ [ s ] ++ rx ≋ ly ++ [ s ] ++ ry → lx ≋ ly inv-++ˡ' [] [] s ∉lx ∉ly eq = [] inv-++ˡ' [] (x ∷ ly) .x ∉lx ∉ly (refl ∷ eq) = contradiction (here refl) ∉ly inv-++ˡ' (x ∷ lx) [] .x ∉lx ∉ly (refl ∷ eq) = contradiction (here refl) ∉lx inv-++ˡ' (x ∷ lx) (.x ∷ ly) s ∉lx ∉ly (refl ∷ eq) rewrite ≋⇒≡ (inv-++ˡ' lx ly s (∉lx ∘ there) (∉ly ∘ there) eq) = ≋-refl inv-++ˡ : ∀ lx ly {rx ry} s → s ∉ lx → s ∉ ly → lx ++ [ s ] ++ rx ≡ ly ++ [ s ] ++ ry → lx ≡ ly inv-++ˡ lx ly s ∉lx ∉ly = ≋⇒≡ ∘ inv-++ˡ' lx ly s ∉lx ∉ly ∘ ≡⇒≋ inv-++ʳ : ∀ lx ly {rx ry} s → s ∉ rx → s ∉ ry → lx ++ [ s ] ++ rx ≡ ly ++ [ s ] ++ ry → rx ≡ ry inv-++ʳ lx ly {rx} {ry} s ∉rx ∉ry = Listₚ.reverse-injective ∘ inv-++ˡ (List.reverse rx) (List.reverse ry) s (∉rx ∘ Anyₚ.reverse⁻) (∉ry ∘ Anyₚ.reverse⁻) ∘ subst₂ _≡_ (do-reverse lx _) (do-reverse ly _) ∘ cong List.reverse where do-reverse : ∀ (lx rx : List A) {s} → List.reverse (lx ++ [ s ] ++ rx) ≡ List.reverse rx ++ [ s ] ++ List.reverse lx do-reverse lx rx {s} = trans (Listₚ.reverse-++-commute lx _) (trans (cong (_++ List.reverse lx) (Listₚ.unfold-reverse s rx)) (Listₚ.++-assoc (List.reverse rx) _ _))
51.512195
109
0.552083
4b9e3bdbf1fc6a095c9c2a551ce299877d42db38
368
agda
Agda
test/Succeed/Issue1436-15.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue1436-15.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue1436-15.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module _ where module A where infix 2 _↑ infix 1 c data D : Set where ● : D _↑ : D → D c : {x y : D} → D syntax c {x = x} {y = y} = x ↓ y module B where infix 3 c data D : Set where c : {y x : D} → D syntax c {y = y} {x = x} = y ↓ x open A open B accepted : A.D → A.D accepted (● ↑ ↓ x) = ● ↑ ↓ x accepted _ = ● ↑ ↓ ●
12.266667
34
0.445652
1eabd3083954600d45ec71f31144b52d6ee2f662
283
agda
Agda
data/expression/DoBlock3.agda
msuperdock/agda-unused
f327f9aab8dcb07022b857736d8201906bba02e9
[ "MIT" ]
6
2020-10-29T09:38:43.000Z
2022-03-01T16:38:05.000Z
data/expression/DoBlock3.agda
msuperdock/agda-unused
f327f9aab8dcb07022b857736d8201906bba02e9
[ "MIT" ]
null
null
null
data/expression/DoBlock3.agda
msuperdock/agda-unused
f327f9aab8dcb07022b857736d8201906bba02e9
[ "MIT" ]
1
2022-03-01T16:38:14.000Z
2022-03-01T16:38:14.000Z
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
7.648649
21
0.367491
9a2adba0157799ba6ec30a415c883358f83f5c5b
786
agda
Agda
test/Compiler/simple/PrimSeq.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Compiler/simple/PrimSeq.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Compiler/simple/PrimSeq.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module _ where open import Agda.Builtin.Nat using (mod-helper) open import Common.Prelude open import Common.Equality _mod_ : Nat → Nat → Nat n mod zero = 0 n mod suc m = mod-helper 0 m n m {-# INLINE _mod_ #-} primitive primForce : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) → (∀ x → B x) → B x primForceLemma : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) (f : ∀ x → B x) → primForce x f ≡ f x force = primForce forceLemma = primForceLemma infixr 0 _$!_ _$!_ : ∀ {a b} {A : Set a} {B : A → Set b} → (∀ x → B x) → ∀ x → B x f $! x = force x f -- Memory leak without proper seq -- pow′ : Nat → Nat → Nat pow′ zero acc = acc pow′ (suc n) acc = pow′ n $! (acc + acc) mod 234576373 pow : Nat → Nat pow n = pow′ n 1 main : IO Unit main = printNat (pow 5000000)
21.833333
100
0.56743
1355b4e704879de9f96923564ceabe7067c153e8
873
agda
Agda
src/Categories/Category/Regular.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Category/Regular.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Category/Regular.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Category.Regular where -- https://ncatlab.org/nlab/show/regular+category -- https://en.wikipedia.org/wiki/Regular_category open import Level open import Categories.Category.Core open import Categories.Category.Complete.Finitely using (FinitelyComplete) open import Categories.Diagram.Coequalizer open import Categories.Diagram.KernelPair open import Categories.Diagram.Pullback open import Categories.Morphism.Regular record Regular {o ℓ e : Level} (𝒞 : Category o ℓ e) : Set (suc (o ⊔ ℓ ⊔ e)) where open Category 𝒞 open Pullback field finitely-complete : FinitelyComplete 𝒞 coeq-of-kernelpairs : {A B : Obj} (f : A ⇒ B) (kp : KernelPair 𝒞 f) → Coequalizer 𝒞 (p₁ kp) (p₂ kp) pullback-of-regularepi-is-regularepi : {A B C : Obj} (f : B ⇒ A) {g : C ⇒ A} (p : Pullback 𝒞 f g) → RegularEpi 𝒞 (p₂ p)
33.576923
123
0.719359
38ecb7e232fb7aba6f33c6cae7a4c27925ec76ee
2,614
agda
Agda
Dave/Structures/Monoid.agda
DavidStahl97/formal-proofs
05213fb6ab1f51f770f9858b61526ba950e06232
[ "MIT" ]
null
null
null
Dave/Structures/Monoid.agda
DavidStahl97/formal-proofs
05213fb6ab1f51f770f9858b61526ba950e06232
[ "MIT" ]
null
null
null
Dave/Structures/Monoid.agda
DavidStahl97/formal-proofs
05213fb6ab1f51f770f9858b61526ba950e06232
[ "MIT" ]
null
null
null
module Dave.Structures.Monoid where open import Dave.Structures.Semigroup public record Identity {A : Set} (_·_ : op₂ A) (e : A) : Set where field left : left-identity _·_ e right : right-identity _·_ e record IsMonoid {A : Set} (_·_ : op₂ A) (e : A) : Set where field semigroup : IsSemigroup _·_ identity : Identity _·_ e record Monoid : Set₁ where field Carrier : Set _·_ : op₂ Carrier e : Carrier isMonoid : IsMonoid _·_ e record IsCommutativeMonoid {A : Set} (_·_ : op₂ A) (e : A) : Set where field isSemigroup : IsSemigroup _·_ leftIdentity : left-identity _·_ e comm : commutative _·_ rightIdentity : right-identity _·_ e rightIdentity m = begin m · e ≡⟨ comm m e ⟩ e · m ≡⟨ leftIdentity m ⟩ m ∎ identity : Identity _·_ e Identity.left identity = leftIdentity Identity.right identity = rightIdentity isMonoid : IsMonoid _·_ e IsMonoid.semigroup isMonoid = isSemigroup IsMonoid.identity isMonoid = identity swap021 : ∀ (m n p : A) → (m · n) · p ≡ (m · p) · n swap021 m n p = begin (m · n) · p ≡⟨ IsSemigroup.assoc isSemigroup m n p ⟩ m · (n · p) ≡⟨ cong (λ a → m · a) (comm n p) ⟩ m · (p · n) ≡⟨ sym (IsSemigroup.assoc isSemigroup m p n) ⟩ (m · p) · n ∎ swap102 : ∀ (m n p : A) → (m · n) · p ≡ (n · m) · p swap102 m n p = begin (m · n) · p ≡⟨ cong (λ a → a · p) (comm m n) ⟩ (n · m) · p ∎ swap120 : ∀ (m n p : A) → (m · n) · p ≡ (n · m) · p swap120 m n p = begin (m · n) · p ≡⟨ cong (λ a → a · p) (comm m n) ⟩ (n · m) · p ∎ swap210 : ∀ (m n p : A) → (m · n) · p ≡ (p · n) · m swap210 m n p = begin (m · n) · p ≡⟨ comm (m · n) p ⟩ p · (m · n) ≡⟨ cong (λ a → p · a) (comm m n) ⟩ p · (n · m) ≡⟨ sym (IsSemigroup.assoc isSemigroup p n m) ⟩ (p · n) · m ∎ swap201 : ∀ (m n p : A) → (m · n) · p ≡ (p · m) · n swap201 m n p = begin (m · n) · p ≡⟨ comm (m · n) p ⟩ p · (m · n) ≡⟨ sym (IsSemigroup.assoc isSemigroup p m n) ⟩ (p · m) · n ∎ record CommutativeMonoid : Set₁ where field Carrier : Set _·_ : op₂ Carrier e : Carrier isCommutativeMonoid : IsCommutativeMonoid _·_ e
34.394737
74
0.45065
04869b80eae23dd33e1a262879cd22d74f908371
1,661
agda
Agda
Tools/PropositionalEquality.agda
Vtec234/logrel-mltt
4746894adb5b8edbddc8463904ee45c2e9b29b69
[ "MIT" ]
null
null
null
Tools/PropositionalEquality.agda
Vtec234/logrel-mltt
4746894adb5b8edbddc8463904ee45c2e9b29b69
[ "MIT" ]
null
null
null
Tools/PropositionalEquality.agda
Vtec234/logrel-mltt
4746894adb5b8edbddc8463904ee45c2e9b29b69
[ "MIT" ]
null
null
null
-- Martin-Löf identity type without the K axiom -- (we do not assume uniqueness of identity proofs). {-# OPTIONS --without-K --safe #-} module Tools.PropositionalEquality where -- We reexport Agda's builtin equality type. open import Tools.Empty public import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) public open Eq.≡-Reasoning public -- Inequality. infix 4 _≢_ _≢_ : {A : Set} → A → A → Set a ≢ b = a ≡ b → ⊥ -- Symmetry. sym : {A : Set} {a b : A} → a ≡ b → b ≡ a sym = Eq.sym -- Transitivity. trans : {A : Set} {a b c : A} → a ≡ b → b ≡ c → a ≡ c trans = Eq.trans -- Non-dependent congruence rules. cong : {A B : Set} {a b : A} (f : A → B) → a ≡ b → f a ≡ f b cong f refl = refl cong₂ : ∀ {A B C : Set} {a a′ b b′} (f : A → B → C) → a ≡ a′ → b ≡ b′ → f a b ≡ f a′ b′ cong₂ f refl refl = refl cong₃ : ∀ {A B C D : Set} {a a′ b b′ c c′} (f : A → B → C → D) → a ≡ a′ → b ≡ b′ → c ≡ c′ → f a b c ≡ f a′ b′ c′ cong₃ f refl refl refl = refl cong₄ : ∀ {A B C D E : Set} {a a′ b b′ c c′ d d′} (f : A → B → C → D → E) → a ≡ a′ → b ≡ b′ → c ≡ c′ → d ≡ d′ → f a b c d ≡ f a′ b′ c′ d′ cong₄ f refl refl refl refl = refl -- Substitution (type-cast). subst : {A : Set} {a b : A} (F : A → Set) → a ≡ b → F a → F b subst F refl f = f -- Two substitutions simultaneously. subst₂ : ∀ {A B : Set} {a a′ b b′} (F : A → B → Set) → a ≡ a′ → b ≡ b′ → F a b → F a′ b′ subst₂ F refl refl f = f -- Three substitutions simultaneously. subst₃ : ∀ {A B C : Set} {a a′ b b′ c c′} (F : A → B → C → Set) → a ≡ a′ → b ≡ b′ → c ≡ c′ → F a b c → F a′ b′ c′ subst₃ F refl refl refl f = f
24.426471
67
0.51174
131a3ec8758c9d5c4f52cb6816cb762b66d741ca
1,153
agda
Agda
Cubical/Algebra/Group/Instances/Int.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
1
2021-10-31T17:32:49.000Z
2021-10-31T17:32:49.000Z
Cubical/Algebra/Group/Instances/Int.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
Cubical/Algebra/Group/Instances/Int.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.Int where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Data.Int renaming (_+_ to _+ℤ_ ; _-_ to _-ℤ_; -_ to -ℤ_ ; _·_ to _·ℤ_) open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open GroupStr ℤGroup : Group₀ fst ℤGroup = ℤ 1g (snd ℤGroup) = 0 _·_ (snd ℤGroup) = _+ℤ_ inv (snd ℤGroup) = -ℤ_ isGroup (snd ℤGroup) = isGroupℤ where abstract isGroupℤ : IsGroup (pos 0) (_+ℤ_) (-ℤ_) isGroupℤ = makeIsGroup isSetℤ +Assoc (λ _ → refl) (+Comm 0) -Cancel -Cancel' ℤHom : (n : ℤ) → GroupHom ℤGroup ℤGroup fst (ℤHom n) x = n ·ℤ x snd (ℤHom n) = makeIsGroupHom λ x y → ·DistR+ n x y negEquivℤ : GroupEquiv ℤGroup ℤGroup fst negEquivℤ = isoToEquiv (iso (GroupStr.inv (snd ℤGroup)) (GroupStr.inv (snd ℤGroup)) (GroupTheory.invInv ℤGroup) (GroupTheory.invInv ℤGroup)) snd negEquivℤ = makeIsGroupHom -Dist+
25.622222
63
0.670425
582f6bf57d952459dfd8f960179e9cd8962eddbc
714
agda
Agda
test/nform.agda
jonaprieto/agda-prop
a1730062a6aaced2bb74878c1071db06477044ae
[ "MIT" ]
13
2017-05-01T16:45:41.000Z
2022-01-17T03:33:12.000Z
test/nform.agda
jonaprieto/agda-prop
a1730062a6aaced2bb74878c1071db06477044ae
[ "MIT" ]
18
2017-03-08T14:33:10.000Z
2017-12-18T16:34:21.000Z
test/nform.agda
jonaprieto/agda-prop
a1730062a6aaced2bb74878c1071db06477044ae
[ "MIT" ]
2
2017-03-30T16:41:56.000Z
2017-12-01T17:01:25.000Z
module nform where open import Data.PropFormula (3) public open import Data.PropFormula.NormalForms 3 public open import Relation.Binary.PropositionalEquality using (_≡_; refl) p : PropFormula p = Var (# 0) q : PropFormula q = Var (# 1) r : PropFormula r = Var (# 2) φ : PropFormula φ = ¬ ((p ∧ (p ⊃ q)) ⊃ q) -- (p ∧ q) ∨ (¬ r) cnfφ : PropFormula cnfφ = ¬ q ∧ (p ∧ (¬ p ∨ q)) postulate p1 : ∅ ⊢ φ p2 : ∅ ⊢ cnfφ p2 = cnf-lem p1 -- thm-cnf p1 {- p3 : cnf φ ≡ cnfφ p3 = refl ψ : PropFormula ψ = (¬ r) ∨ (p ∧ q) cnfψ : PropFormula cnfψ = (¬ r ∨ p) ∧ (¬ r ∨ q) p5 : cnf ψ ≡ cnfψ p5 = refl -} to5 = (¬ p) ∨ ((¬ q) ∨ r) from5 = (¬ p) ∨ (r ∨ ((¬ q) ∧ p)) test : ⌊ eq (cnf from5) to5 ⌋ ≡ false test = refl
15.191489
67
0.55042
c79b131aaa71c05f6f643fe1423d2837032a4c4c
440
agda
Agda
agda/TreeSort/Everything.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
6
2015-05-21T12:50:35.000Z
2021-08-24T22:11:15.000Z
agda/TreeSort/Everything.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
agda/TreeSort/Everything.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
open import Relation.Binary.Core module TreeSort.Everything {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import TreeSort.Impl1.Correctness.Order _≤_ tot≤ trans≤ open import TreeSort.Impl1.Correctness.Permutation _≤_ tot≤ open import TreeSort.Impl2.Correctness.Order _≤_ tot≤ trans≤ open import TreeSort.Impl2.Correctness.Permutation _≤_ tot≤
33.846154
60
0.665909
ad23cf4a1a6d78fc5f551cebc29ed928a4436bcc
4,104
agda
Agda
src/ODC.agda
shinji-kono/zf-in-agda
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
[ "MIT" ]
5
2019-10-02T13:46:23.000Z
2021-01-10T13:27:48.000Z
src/ODC.agda
shinji-kono/zf-in-agda
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
[ "MIT" ]
null
null
null
src/ODC.agda
shinji-kono/zf-in-agda
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
[ "MIT" ]
null
null
null
{-# OPTIONS --allow-unsolved-metas #-} open import Level open import Ordinals module ODC {n : Level } (O : Ordinals {n} ) where open import zf open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) open import Relation.Binary.PropositionalEquality open import Data.Nat.Properties open import Data.Empty open import Relation.Nullary open import Relation.Binary open import Relation.Binary.Core import OrdUtil open import logic open import nat import OD import ODUtil open inOrdinal O open OD O open OD.OD open OD._==_ open ODAxiom odAxiom open ODUtil O open Ordinals.Ordinals O open Ordinals.IsOrdinals isOrdinal open Ordinals.IsNext isNext open OrdUtil O open HOD open _∧_ postulate -- mimimul and x∋minimal is an Axiom of choice minimal : (x : HOD ) → ¬ (x =h= od∅ )→ HOD -- this should be ¬ (x =h= od∅ )→ ∃ ox → x ∋ Ord ox ( minimum of x ) x∋minimal : (x : HOD ) → ( ne : ¬ (x =h= od∅ ) ) → odef x ( & ( minimal x ne ) ) -- minimality (may proved by ε-induction with LEM) minimal-1 : (x : HOD ) → ( ne : ¬ (x =h= od∅ ) ) → (y : HOD ) → ¬ ( odef (minimal x ne) (& y)) ∧ (odef x (& y) ) -- -- Axiom of choice in intutionistic logic implies the exclude middle -- https://plato.stanford.edu/entries/axiom-choice/#AxiChoLog -- pred-od : ( p : Set n ) → HOD pred-od p = record { od = record { def = λ x → (x ≡ o∅) ∧ p } ; odmax = osuc o∅; <odmax = λ x → subst (λ k → k o< osuc o∅) (sym (proj1 x)) <-osuc } ppp : { p : Set n } { a : HOD } → pred-od p ∋ a → p ppp {p} {a} d = proj2 d p∨¬p : ( p : Set n ) → p ∨ ( ¬ p ) -- assuming axiom of choice p∨¬p p with is-o∅ ( & (pred-od p )) p∨¬p p | yes eq = case2 (¬p eq) where ps = pred-od p eqo∅ : ps =h= od∅ → & ps ≡ o∅ eqo∅ eq = subst (λ k → & ps ≡ k) ord-od∅ ( cong (λ k → & k ) (==→o≡ eq)) lemma : ps =h= od∅ → p → ⊥ lemma eq p0 = ¬x<0 {& ps} (eq→ eq record { proj1 = eqo∅ eq ; proj2 = p0 } ) ¬p : (& ps ≡ o∅) → p → ⊥ ¬p eq = lemma ( subst₂ (λ j k → j =h= k ) *iso o∅≡od∅ ( o≡→== eq )) p∨¬p p | no ¬p = case1 (ppp {p} {minimal ps (λ eq → ¬p (eqo∅ eq))} lemma) where ps = pred-od p eqo∅ : ps =h= od∅ → & ps ≡ o∅ eqo∅ eq = subst (λ k → & ps ≡ k) ord-od∅ ( cong (λ k → & k ) (==→o≡ eq)) lemma : ps ∋ minimal ps (λ eq → ¬p (eqo∅ eq)) lemma = x∋minimal ps (λ eq → ¬p (eqo∅ eq)) decp : ( p : Set n ) → Dec p -- assuming axiom of choice decp p with p∨¬p p decp p | case1 x = yes x decp p | case2 x = no x ∋-p : (A x : HOD ) → Dec ( A ∋ x ) ∋-p A x with p∨¬p ( A ∋ x ) -- LEM ∋-p A x | case1 t = yes t ∋-p A x | case2 t = no (λ x → t x) double-neg-eilm : {A : Set n} → ¬ ¬ A → A -- we don't have this in intutionistic logic double-neg-eilm {A} notnot with decp A -- assuming axiom of choice ... | yes p = p ... | no ¬p = ⊥-elim ( notnot ¬p ) open _⊆_ power→⊆ : ( A t : HOD) → Power A ∋ t → t ⊆ A power→⊆ A t PA∋t = record { incl = λ {x} t∋x → double-neg-eilm (t1 t∋x) } where t1 : {x : HOD } → t ∋ x → ¬ ¬ (A ∋ x) t1 = power→ A t PA∋t OrdP : ( x : Ordinal ) ( y : HOD ) → Dec ( Ord x ∋ y ) OrdP x y with trio< x (& y) OrdP x y | tri< a ¬b ¬c = no ¬c OrdP x y | tri≈ ¬a refl ¬c = no ( o<¬≡ refl ) OrdP x y | tri> ¬a ¬b c = yes c open import zfc HOD→ZFC : ZFC HOD→ZFC = record { ZFSet = HOD ; _∋_ = _∋_ ; _≈_ = _=h=_ ; ∅ = od∅ ; Select = Select ; isZFC = isZFC } where -- infixr 200 _∈_ -- infixr 230 _∩_ _∪_ isZFC : IsZFC (HOD ) _∋_ _=h=_ od∅ Select isZFC = record { choice-func = choice-func ; choice = choice } where -- Axiom of choice ( is equivalent to the existence of minimal in our case ) -- ∀ X [ ∅ ∉ X → (∃ f : X → ⋃ X ) → ∀ A ∈ X ( f ( A ) ∈ A ) ] choice-func : (X : HOD ) → {x : HOD } → ¬ ( x =h= od∅ ) → ( X ∋ x ) → HOD choice-func X {x} not X∋x = minimal x not choice : (X : HOD ) → {A : HOD } → ( X∋A : X ∋ A ) → (not : ¬ ( A =h= od∅ )) → A ∋ choice-func X not X∋A choice X {A} X∋A not = x∋minimal A not
31.813953
116
0.520224
577ec28f2c92044f77b32d467385ef9be88304c8
135
agda
Agda
stdlib-exts/Class/Functor.agda
WhatisRT/meta-cedille
62fa6f36e4555360d94041113749bbb6d291691c
[ "MIT" ]
35
2019-06-13T07:44:50.000Z
2021-10-12T22:59:10.000Z
stdlib-exts/Class/Functor.agda
WhatisRT/meta-cedille
62fa6f36e4555360d94041113749bbb6d291691c
[ "MIT" ]
10
2019-06-13T17:44:43.000Z
2020-04-25T15:29:17.000Z
stdlib-exts/Class/Functor.agda
WhatisRT/meta-cedille
62fa6f36e4555360d94041113749bbb6d291691c
[ "MIT" ]
2
2019-06-27T23:12:48.000Z
2021-10-20T10:46:20.000Z
module Class.Functor where open import Category.Functor using () renaming (RawFunctor to Functor) public open Functor {{...}} public
22.5
77
0.762963
57da3c7eb2baec75e0925cad734fd0a63e98934f
14,311
agda
Agda
src/Source/Term.agda
JLimperg/msc-thesis-code
104cddc6b65386c7e121c13db417aebfd4b7a863
[ "MIT" ]
5
2021-04-13T21:31:17.000Z
2021-06-26T06:37:31.000Z
src/Source/Term.agda
JLimperg/msc-thesis-code
104cddc6b65386c7e121c13db417aebfd4b7a863
[ "MIT" ]
null
null
null
src/Source/Term.agda
JLimperg/msc-thesis-code
104cddc6b65386c7e121c13db417aebfd4b7a863
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} module Source.Term where open import Source.Size as S using ( Size ; _<_ ; Δ ; Δ′ ; Δ″ ; Ω ; Ω′ ; Ω″ ; n ; m ; o ; b ; v0 ; v1 ; ⋆ ) open import Source.Size.Substitution.Theory open import Source.Size.Substitution.Canonical as SC using () renaming ( Sub⊢ to Subₛ⊢ ) open import Source.Size.Substitution.Universe as SU using ( ⟨_⟩ ) renaming ( Sub⊢ᵤ to Subₛ⊢ᵤ ) open import Source.Type as T using ( Type ; Ctx ; T ; U ; V ; Γ ; Γ′ ; Γ″ ; Ψ ; Ψ′ ; Ψ″ ; SubTheory-Type ; SubTheory-Ctx ) open import Util.Prelude hiding (id ; _∘_) open Ctx open S.Ctx open S.Size open S.Var open Type infix 0 _,_⊢_∶_ _,_⊢ₓ_∶_ Sub⊢ infix 3 _⊇_ infixl 5 sub-syntax-Termₛ sub-syntax-Subₛ sub-syntax-Term sub-syntax-⊇ infixr 6 Λ_,_ Λₛ_,_ infixl 7 _·_ _·ₛ_ Var : Set Var = ℕ variable x y : Var data Term Δ : Set where var : (x : Var) → Term Δ Λ_,_ : (T : Type Δ) (t : Term Δ) → Term Δ _·_ : (t u : Term Δ) → Term Δ Λₛ_,_ : (n : Size Δ) (t : Term (Δ ∙ n)) → Term Δ _·ₛ_ : (t : Term Δ) (m : Size Δ) → Term Δ zero : (n : Size Δ) → Term Δ suc : (n m : Size Δ) (i : Term Δ) → Term Δ cons : (i : Term Δ) (n : Size Δ) (is : Term Δ) → Term Δ head : (n : Size Δ) (is : Term Δ) → Term Δ tail : (n : Size Δ) (is : Term Δ) (m : Size Δ) → Term Δ caseNat : (T : Type Δ) (n : Size Δ) (i : Term Δ) (z : Term Δ) (s : Term Δ) → Term Δ fix : (T : Type (Δ ∙ ⋆)) (t : Term Δ) (n : Size Δ) → Term Δ variable t u v w i is z s t′ u′ v′ w′ i′ is′ z′ s′ : Term Δ data _,_⊢ₓ_∶_ : ∀ Δ (Γ : Ctx Δ) (x : Var) (T : Type Δ) → Set where zero : Δ , Γ ∙ T ⊢ₓ zero ∶ T suc : (⊢x : Δ , Γ ⊢ₓ x ∶ T) → Δ , Γ ∙ U ⊢ₓ suc x ∶ T data _,_⊢_∶_ : ∀ Δ (Γ : Ctx Δ) (t : Term Δ) (T : Type Δ) → Set where var : (⊢x : Δ , Γ ⊢ₓ x ∶ T) → Δ , Γ ⊢ var x ∶ T abs : (⊢t : Δ , Γ ∙ T ⊢ t ∶ U) → Δ , Γ ⊢ Λ T , t ∶ T ⇒ U app : (⊢t : Δ , Γ ⊢ t ∶ T ⇒ U) → (⊢u : Δ , Γ ⊢ u ∶ T) → Δ , Γ ⊢ t · u ∶ U absₛ : (⊢t : Δ ∙ n , Ψ ⊢ t ∶ T) → Ψ ≡ Γ [ SC.Wk ] → Δ , Γ ⊢ Λₛ n , t ∶ Π n , T appₛ : (m<n : m < n) → (⊢t : Δ , Γ ⊢ t ∶ (Π n , T)) → U ≡ T [ SC.Sing m ] → Δ , Γ ⊢ t ·ₛ m ∶ U zero : (n<⋆ : n < ⋆) → Δ , Γ ⊢ zero n ∶ Nat n suc : (n<⋆ : n < ⋆) → (m<n : m < n) → (⊢i : Δ , Γ ⊢ i ∶ Nat m) → Δ , Γ ⊢ suc n m i ∶ Nat n cons : (n<⋆ : n < ⋆) → (⊢i : Δ , Γ ⊢ i ∶ Nat ∞) → (⊢is : Δ , Γ ⊢ is ∶ Π n , Stream v0) → Δ , Γ ⊢ cons i n is ∶ Stream n head : (n<⋆ : n < ⋆) → (⊢is : Δ , Γ ⊢ is ∶ Stream n) → Δ , Γ ⊢ head n is ∶ Nat ∞ tail : (n<⋆ : n < ⋆) → (m<n : m < n) → (⊢is : Δ , Γ ⊢ is ∶ Stream n) → Δ , Γ ⊢ tail n is m ∶ Stream m caseNat : (n<⋆ : n < ⋆) → (⊢i : Δ , Γ ⊢ i ∶ Nat n) → (⊢z : Δ , Γ ⊢ z ∶ T) → (⊢s : Δ , Γ ⊢ s ∶ Π n , Nat v0 ⇒ U) → U ≡ T [ SC.Wk ] → Δ , Γ ⊢ caseNat T n i z s ∶ T fix : (n<⋆ : n < ⋆) → (⊢t : Δ , Γ ⊢ t ∶ Π ⋆ , (Π v0 , U) ⇒ T) → U ≡ T [ SC.Skip ] → V ≡ T [ SC.Sing n ] → Δ , Γ ⊢ fix T t n ∶ V subₛ : SC.Sub Δ Ω → Term Ω → Term Δ subₛ σ (var x) = var x subₛ σ (Λ T , t) = Λ T [ σ ] , subₛ σ t subₛ σ (t · u) = subₛ σ t · subₛ σ u subₛ σ (Λₛ n , t) = Λₛ n [ σ ] , subₛ (SC.Lift σ) t subₛ σ (t ·ₛ m) = subₛ σ t ·ₛ (m [ σ ]) subₛ σ (zero n) = zero (n [ σ ]) subₛ σ (suc n m i) = suc (n [ σ ]) (m [ σ ]) (subₛ σ i) subₛ σ (cons i n is) = cons (subₛ σ i) (n [ σ ]) (subₛ σ is) subₛ σ (head n is) = head (n [ σ ]) (subₛ σ is) subₛ σ (tail n is m) = tail (n [ σ ]) (subₛ σ is) (m [ σ ]) subₛ σ (caseNat T n i z s) = caseNat (T [ σ ]) (n [ σ ]) (subₛ σ i) (subₛ σ z) (subₛ σ s) subₛ σ (fix T t n) = fix (T [ SC.Lift σ ]) (subₛ σ t) (n [ σ ]) sub-syntax-Termₛ = subₛ syntax sub-syntax-Termₛ σ t = t [ σ ]ₛ abstract subₛ-resp-⊢ₓ : ∀ {σ} → σ ∶ Δ ⇒ Ω → Ω , Γ ⊢ₓ x ∶ T → Δ , Γ [ σ ] ⊢ₓ x ∶ T [ σ ] subₛ-resp-⊢ₓ ⊢σ zero = zero subₛ-resp-⊢ₓ ⊢σ (suc ⊢x) = suc (subₛ-resp-⊢ₓ ⊢σ ⊢x) subₛ-resp-⊢ : ∀ {σ} → σ ∶ Δ ⇒ Ω → Ω , Γ ⊢ t ∶ T → Δ , Γ [ σ ] ⊢ subₛ σ t ∶ T [ σ ] subₛ-resp-⊢ ⊢σ (var ⊢x) = var (subₛ-resp-⊢ₓ ⊢σ ⊢x) subₛ-resp-⊢ ⊢σ (abs ⊢t) = abs (subₛ-resp-⊢ ⊢σ ⊢t) subₛ-resp-⊢ ⊢σ (app ⊢t ⊢u) = app (subₛ-resp-⊢ ⊢σ ⊢t) (subₛ-resp-⊢ ⊢σ ⊢u) subₛ-resp-⊢ {Δ} {Γ = Γ} {σ = σ} ⊢σ (absₛ {Ψ = Ψ} ⊢t p) = absₛ (subₛ-resp-⊢ (SC.Lift⊢ ⊢σ refl) ⊢t) eq where eq : Ψ [ SC.Lift σ ] ≡ Γ [ σ ] [ SC.Wk ] eq = trans (cong (λ Ψ → Ψ [ SC.Lift σ ]) p) ([>>]″ (SC.Lift σ) SC.Wk SC.Wk σ Γ SC.Lift>>Wk) subₛ-resp-⊢ {σ = σ} ⊢σ (appₛ {m = m} {T = T} {U = U} m<n ⊢t p) = appₛ (SC.sub-resp-< ⊢σ m<n) (subₛ-resp-⊢ ⊢σ ⊢t) eq where eq : U [ σ ] ≡ T [ SC.Lift σ ] [ SC.Sing (m [ σ ]) ] eq = trans (cong (λ U → U [ σ ]) p) ([>>]″ _ _ _ _ _ (sym (SC.Sing>>Lift m))) subₛ-resp-⊢ ⊢σ (zero n<⋆) = zero (SC.sub-resp-< ⊢σ n<⋆) subₛ-resp-⊢ ⊢σ (suc n<⋆ m<n ⊢i) = suc (SC.sub-resp-< ⊢σ n<⋆) (SC.sub-resp-< ⊢σ m<n) (subₛ-resp-⊢ ⊢σ ⊢i) subₛ-resp-⊢ ⊢σ (cons n<⋆ ⊢i ⊢is) = cons (SC.sub-resp-< ⊢σ n<⋆) (subₛ-resp-⊢ ⊢σ ⊢i) (subₛ-resp-⊢ ⊢σ ⊢is) subₛ-resp-⊢ ⊢σ (head n<⋆ ⊢is) = head (SC.sub-resp-< ⊢σ n<⋆) (subₛ-resp-⊢ ⊢σ ⊢is) subₛ-resp-⊢ ⊢σ (tail n<⋆ m<n ⊢is) = tail (SC.sub-resp-< ⊢σ n<⋆) (SC.sub-resp-< ⊢σ m<n) (subₛ-resp-⊢ ⊢σ ⊢is) subₛ-resp-⊢ {σ = σ} ⊢σ (caseNat {T = T} {U = U} n<⋆ ⊢i ⊢z ⊢s p) = caseNat (SC.sub-resp-< ⊢σ n<⋆) (subₛ-resp-⊢ ⊢σ ⊢i) (subₛ-resp-⊢ ⊢σ ⊢z) (subₛ-resp-⊢ ⊢σ ⊢s) eq where eq : U [ SC.Lift σ ] ≡ T [ σ ] [ SC.Wk ] eq = trans (cong (λ U → U [ SC.Lift σ ]) p) ([>>]″ _ _ _ _ _ SC.Lift>>Wk) subₛ-resp-⊢ {σ = σ} ⊢σ (fix {n = n} {U = U} {T = T} {V = V} n<⋆ ⊢t p q) = fix (SC.sub-resp-< ⊢σ n<⋆) (subₛ-resp-⊢ ⊢σ ⊢t) eq₀ eq₁ where eq₀ : U [ SC.Lift (SC.Lift σ) ] ≡ T [ SC.Lift σ ] [ SC.Skip ] eq₀ = trans (cong (λ U → U [ SC.Lift (SC.Lift σ) ]) p) ([>>]″ _ _ _ _ _ SC.LiftLift>>Skip) eq₁ : V [ σ ] ≡ T [ SC.Lift σ ] [ SC.Sing (n [ σ ]) ] eq₁ = trans (cong (λ V → V [ σ ]) q) ([>>]″ _ _ _ _ _ (sym (SC.Sing>>Lift n))) subₛ-Id : (t : Term Δ) → subₛ SC.Id t ≡ t subₛ-Id (var x) = refl subₛ-Id (Λ T , t) = cong₂ Λ_,_ ([Id] T) (subₛ-Id t) subₛ-Id (t · u) = cong₂ _·_ (subₛ-Id t) (subₛ-Id u) subₛ-Id (Λₛ n , t) rewrite [Id] n | subₛ-Id t = refl subₛ-Id (t ·ₛ m) = cong₂ _·ₛ_ (subₛ-Id t) ([Id] m) subₛ-Id (zero n) = cong zero ([Id] n) subₛ-Id (suc n m i) rewrite [Id] n | [Id] m | subₛ-Id i = refl subₛ-Id (cons i n is) rewrite subₛ-Id i | [Id] n | subₛ-Id is = refl subₛ-Id (head n is) = cong₂ head ([Id] n) (subₛ-Id is) subₛ-Id (tail n is m) rewrite [Id] n | subₛ-Id is | [Id] m = refl subₛ-Id (caseNat T n i z s) rewrite [Id] T | [Id] n | subₛ-Id i | subₛ-Id z | subₛ-Id s = refl subₛ-Id (fix T t n) rewrite [Id] T | subₛ-Id t | [Id] n = refl subₛ->> : ∀ (σ : SC.Sub Δ Δ′) (τ : SC.Sub Δ′ Δ″) t → subₛ (σ SC.>> τ) t ≡ subₛ σ (subₛ τ t) subₛ->> σ τ (var x) = refl subₛ->> σ τ (Λ T , t) = cong₂ Λ_,_ ([>>] σ τ T) (subₛ->> σ τ t) subₛ->> σ τ (t · u) = cong₂ _·_ (subₛ->> σ τ t) (subₛ->> σ τ u) subₛ->> σ τ (Λₛ n , t) rewrite [>>] σ τ n = cong (λ t → Λₛ SC.sub σ (SC.sub τ n) , t) (trans (cong (λ σ → subₛ σ t) (sym (SC.Lift>>Lift {n = n [ τ ]}))) (subₛ->> (SC.Lift σ) (SC.Lift τ) t)) subₛ->> σ τ (t ·ₛ m) = cong₂ _·ₛ_ (subₛ->> σ τ t) ([>>] σ τ m) subₛ->> σ τ (zero n) = cong zero ([>>] σ τ n) subₛ->> σ τ (suc n m i) rewrite [>>] σ τ n | [>>] σ τ m | subₛ->> σ τ i = refl subₛ->> σ τ (cons i n is) rewrite subₛ->> σ τ i | [>>] σ τ n | subₛ->> σ τ is = refl subₛ->> σ τ (head n is) rewrite [>>] σ τ n | subₛ->> σ τ is = refl subₛ->> σ τ (tail n is m) rewrite [>>] σ τ n | subₛ->> σ τ is | [>>] σ τ m = refl subₛ->> σ τ (caseNat T n i z s) rewrite [>>] σ τ T | [>>] σ τ n | subₛ->> σ τ i | subₛ->> σ τ z | subₛ->> σ τ s = refl subₛ->> σ τ (fix T t n) rewrite subₛ->> σ τ t | [>>] σ τ n = cong (λ T → fix T (subₛ σ (subₛ τ t)) (n [ τ ] [ σ ])) ([>>]′ _ _ _ _ (sym SC.Lift>>Lift)) subₛᵤ : SU.Sub Δ Ω → Term Ω → Term Δ subₛᵤ σ = subₛ ⟨ σ ⟩ abstract subₛᵤ-resp-⊢ : ∀ {σ} → σ ∶ Δ ⇒ᵤ Ω → Ω , Γ ⊢ t ∶ T → Δ , Γ [ σ ]ᵤ ⊢ subₛᵤ σ t ∶ T [ σ ]ᵤ subₛᵤ-resp-⊢ ⊢σ ⊢t = subₛ-resp-⊢ (SU.⟨⟩-resp-⊢ ⊢σ) ⊢t subₛᵤ-Id : (t : Term Δ) → subₛᵤ SU.Id t ≡ t subₛᵤ-Id t = subₛ-Id t subₛᵤ->> : ∀ (σ : SU.Sub Δ Δ′) (τ : SU.Sub Δ′ Δ″) t → subₛᵤ (σ SU.>> τ) t ≡ subₛᵤ σ (subₛᵤ τ t) subₛᵤ->> σ τ t = subₛ->> ⟨ σ ⟩ ⟨ τ ⟩ t data _⊇_ {Δ} : (Γ Ψ : Ctx Δ) → Set where [] : [] ⊇ [] keep : (α : Γ ⊇ Ψ) (T : Type Δ) → Γ ∙ T ⊇ Ψ ∙ T weak : (α : Γ ⊇ Ψ) (T : Type Δ) → Γ ∙ T ⊇ Ψ variable α β γ : Γ ⊇ Ψ sub⊇ : (σ : SC.Sub Δ Ω) → Γ ⊇ Ψ → Γ [ σ ] ⊇ Ψ [ σ ] sub⊇ σ [] = [] sub⊇ σ (keep α T) = keep (sub⊇ σ α) (T [ σ ]) sub⊇ σ (weak α T) = weak (sub⊇ σ α) (T [ σ ]) sub-syntax-⊇ = sub⊇ syntax sub-syntax-⊇ σ α = α [ σ ]α renV : Γ ⊇ Ψ → Var → Var renV [] x = x -- impossible if x is well-scoped renV (keep α T) zero = zero renV (keep α T) (suc x) = suc (renV α x) renV (weak α T) x = suc (renV α x) ren : {Γ Ψ : Ctx Δ} → Γ ⊇ Ψ → Term Δ → Term Δ ren α (var x) = var (renV α x) ren α (Λ T , t) = Λ T , ren (keep α T) t ren α (t · u) = ren α t · ren α u ren α (Λₛ n , t) = Λₛ n , ren (α [ SC.Wk ]α) t ren α (t ·ₛ m) = ren α t ·ₛ m ren α (zero n) = zero n ren α (suc n m i) = suc n m (ren α i) ren α (cons i n is) = cons (ren α i) n (ren α is) ren α (head n is) = head n (ren α is) ren α (tail n is m) = tail n (ren α is) m ren α (caseNat T n i z s) = caseNat T n (ren α i) (ren α z) (ren α s) ren α (fix T t n) = fix T (ren α t) n abstract renV-resp-⊢ₓ : (α : Γ ⊇ Ψ) → Δ , Ψ ⊢ₓ x ∶ T → Δ , Γ ⊢ₓ renV α x ∶ T renV-resp-⊢ₓ (keep α T) zero = zero renV-resp-⊢ₓ (keep α T) (suc ⊢x) = suc (renV-resp-⊢ₓ α ⊢x) renV-resp-⊢ₓ (weak α T) ⊢x = suc (renV-resp-⊢ₓ α ⊢x) ren-resp-⊢ : (α : Γ ⊇ Ψ) → Δ , Ψ ⊢ t ∶ T → Δ , Γ ⊢ ren α t ∶ T ren-resp-⊢ α (var ⊢x) = var (renV-resp-⊢ₓ α ⊢x) ren-resp-⊢ α (abs ⊢t) = abs (ren-resp-⊢ (keep α _) ⊢t) ren-resp-⊢ α (app ⊢t ⊢u) = app (ren-resp-⊢ α ⊢t) (ren-resp-⊢ α ⊢u) ren-resp-⊢ α (absₛ ⊢t refl) = absₛ (ren-resp-⊢ (α [ SC.Wk ]α) ⊢t) refl ren-resp-⊢ α (appₛ m<n ⊢t p) = appₛ m<n (ren-resp-⊢ α ⊢t) p ren-resp-⊢ α (zero n<⋆) = zero n<⋆ ren-resp-⊢ α (suc n<⋆ m<n ⊢i) = suc n<⋆ m<n (ren-resp-⊢ α ⊢i) ren-resp-⊢ α (cons n<⋆ ⊢i ⊢is) = cons n<⋆ (ren-resp-⊢ α ⊢i) (ren-resp-⊢ α ⊢is) ren-resp-⊢ α (head n<⋆ ⊢is) = head n<⋆ (ren-resp-⊢ α ⊢is) ren-resp-⊢ α (tail n<⋆ m<n ⊢is) = tail n<⋆ m<n (ren-resp-⊢ α ⊢is) ren-resp-⊢ α (caseNat n<⋆ ⊢i ⊢z ⊢s p) = caseNat n<⋆ (ren-resp-⊢ α ⊢i) (ren-resp-⊢ α ⊢z) (ren-resp-⊢ α ⊢s) p ren-resp-⊢ α (fix n<⋆ ⊢t p q) = fix n<⋆ (ren-resp-⊢ α ⊢t) p q Id⊇ : (Γ : Ctx Δ) → Γ ⊇ Γ Id⊇ [] = [] Id⊇ (Γ ∙ T) = keep (Id⊇ Γ) T Wk⊇ : ∀ (Γ : Ctx Δ) T → Γ ∙ T ⊇ Γ Wk⊇ Γ T = weak (Id⊇ Γ) _ data Sub {Δ} (Γ : Ctx Δ) : (Ψ : Ctx Δ) → Set where [] : Sub Γ [] Snoc : (ν : Sub Γ Ψ) (t : Term Δ) → Sub Γ (Ψ ∙ T) variable ν φ : Sub Γ Ψ data Sub⊢ {Δ} (Γ : Ctx Δ) : ∀ Ψ → Sub Γ Ψ → Set where [] : Sub⊢ Γ [] [] Snoc : (⊢ν : Sub⊢ Γ Ψ ν) (⊢t : Δ , Γ ⊢ t ∶ T) → Sub⊢ Γ (Ψ ∙ T) (Snoc ν t) syntax Sub⊢ Γ Ψ ν = ν ∶ Γ ⇛ Ψ Weaken : Sub Γ Ψ → Sub (Γ ∙ T) Ψ Weaken [] = [] Weaken {Γ = Γ} {T = T} (Snoc ν t) = Snoc (Weaken ν) (ren (Wk⊇ Γ T) t) abstract Weaken⊢ : ν ∶ Γ ⇛ Ψ → Weaken ν ∶ Γ ∙ T ⇛ Ψ Weaken⊢ [] = [] Weaken⊢ (Snoc ⊢ν ⊢t) = Snoc (Weaken⊢ ⊢ν) (ren-resp-⊢ (Wk⊇ _ _) ⊢t) Lift : Sub Γ Ψ → ∀ T → Sub (Γ ∙ T) (Ψ ∙ T) Lift σ T = Snoc (Weaken σ) (var zero) abstract Lift⊢ : ν ∶ Γ ⇛ Ψ → Lift ν T ∶ Γ ∙ T ⇛ Ψ ∙ T Lift⊢ ⊢ν = Snoc (Weaken⊢ ⊢ν) (var zero) Id : Sub Γ Γ Id {Γ = []} = [] Id {Γ = Γ ∙ T} = Lift Id T abstract Id⊢ : Id ∶ Γ ⇛ Γ Id⊢ {Γ = []} = [] Id⊢ {Γ = Γ ∙ T} = Snoc (Weaken⊢ Id⊢) (var zero) Wk : Sub (Γ ∙ T) Γ Wk = Weaken Id abstract Wk⊢ : Wk ∶ Γ ∙ T ⇛ Γ Wk⊢ = Weaken⊢ Id⊢ Fill : ∀ (Γ : Ctx Δ) T → Term Δ → Sub Γ (Γ ∙ T) Fill Γ T t = Snoc Id t abstract Fill⊢ : Δ , Γ ⊢ t ∶ T → Fill Γ T t ∶ Γ ⇛ Γ ∙ T Fill⊢ ⊢t = Snoc Id⊢ ⊢t subν : (σ : SC.Sub Δ Ω) → Sub Γ Ψ → Sub (Γ [ σ ]) (Ψ [ σ ]) subν σ [] = [] subν σ (Snoc ν t) = Snoc (subν σ ν) (t [ σ ]ₛ) abstract subν-resp-⊢ : ∀ {σ} → σ ∶ Δ ⇒ Ω → ν ∶ Γ ⇛ Ψ → subν σ ν ∶ Γ [ σ ] ⇛ Ψ [ σ ] subν-resp-⊢ ⊢σ [] = [] subν-resp-⊢ ⊢σ (Snoc ⊢ν ⊢t) = Snoc (subν-resp-⊢ ⊢σ ⊢ν) (subₛ-resp-⊢ ⊢σ ⊢t) sub-syntax-Subₛ = subν syntax sub-syntax-Subₛ σ ν = ν [ σ ]ν subV : Sub {Δ} Γ Ψ → Var → Term Δ subV [] x = var x -- impossible if x is well-scoped subV (Snoc ν t) zero = t subV (Snoc ν t) (suc x) = subV ν x sub : Sub {Δ} Γ Ψ → Term Δ → Term Δ sub ν (var x) = subV ν x sub ν (Λ T , t) = Λ T , sub (Lift ν T) t sub ν (t · u) = sub ν t · sub ν u sub ν (Λₛ n , t) = Λₛ n , sub (ν [ SC.Wk ]ν) t sub ν (t ·ₛ m) = sub ν t ·ₛ m sub ν (zero n) = zero n sub ν (suc n m i) = suc n m (sub ν i) sub ν (cons i n is) = cons (sub ν i) n (sub ν is) sub ν (head n is) = head n (sub ν is) sub ν (tail n is m) = tail n (sub ν is) m sub ν (caseNat T n i z s) = caseNat T n (sub ν i) (sub ν z) (sub ν s) sub ν (fix T t n) = fix T (sub ν t) n sub-syntax-Term = sub syntax sub-syntax-Term ν t = t [ ν ]t abstract subV-resp-⊢ : ν ∶ Γ ⇛ Ψ → Δ , Ψ ⊢ₓ x ∶ T → Δ , Γ ⊢ subV ν x ∶ T subV-resp-⊢ (Snoc ⊢ν ⊢t) zero = ⊢t subV-resp-⊢ (Snoc ⊢ν ⊢t) (suc ⊢x) = subV-resp-⊢ ⊢ν ⊢x sub-resp-⊢ : ν ∶ Γ ⇛ Ψ → Δ , Ψ ⊢ t ∶ T → Δ , Γ ⊢ sub ν t ∶ T sub-resp-⊢ ⊢ν (var ⊢x) = subV-resp-⊢ ⊢ν ⊢x sub-resp-⊢ ⊢ν (abs ⊢t) = abs (sub-resp-⊢ (Lift⊢ ⊢ν) ⊢t) sub-resp-⊢ ⊢ν (app ⊢t ⊢u) = app (sub-resp-⊢ ⊢ν ⊢t) (sub-resp-⊢ ⊢ν ⊢u) sub-resp-⊢ ⊢ν (absₛ ⊢t refl) = absₛ (sub-resp-⊢ (subν-resp-⊢ SC.Wk⊢ ⊢ν) ⊢t) refl sub-resp-⊢ ⊢ν (appₛ m<n ⊢t p) = appₛ m<n (sub-resp-⊢ ⊢ν ⊢t) p sub-resp-⊢ ⊢ν (zero n<⋆) = zero n<⋆ sub-resp-⊢ ⊢ν (suc n<⋆ m<n ⊢i) = suc n<⋆ m<n (sub-resp-⊢ ⊢ν ⊢i) sub-resp-⊢ ⊢ν (cons n<⋆ ⊢i ⊢is) = cons n<⋆ (sub-resp-⊢ ⊢ν ⊢i) (sub-resp-⊢ ⊢ν ⊢is) sub-resp-⊢ ⊢ν (head n<⋆ ⊢is) = head n<⋆ (sub-resp-⊢ ⊢ν ⊢is) sub-resp-⊢ ⊢ν (tail n<⋆ m<n ⊢is) = tail n<⋆ m<n (sub-resp-⊢ ⊢ν ⊢is) sub-resp-⊢ ⊢ν (caseNat n<⋆ ⊢i ⊢z ⊢s p) = caseNat n<⋆ (sub-resp-⊢ ⊢ν ⊢i) (sub-resp-⊢ ⊢ν ⊢z) (sub-resp-⊢ ⊢ν ⊢s) p sub-resp-⊢ ⊢ν (fix n<⋆ ⊢t p q) = fix n<⋆ (sub-resp-⊢ ⊢ν ⊢t) p q
28.005871
77
0.457201
adde4aca29a803bf16228c42d7f2b6ff59f47484
346
agda
Agda
test/Fail/Erased-cubical-Module-application.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Erased-cubical-Module-application.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Erased-cubical-Module-application.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --erased-cubical #-} -- Modules that use --cubical can be imported when --erased-cubical is -- used. import Erased-cubical-Module-application.Cubical module EC = Erased-cubical-Module-application.Cubical Set -- However, definitions from such modules can only be used in erased -- contexts. _ : {A : Set} → A → EC.∥ A ∥ _ = EC.∣_∣
24.714286
70
0.702312
38ab8427361e291e972b7e558861120dce91148b
1,873
agda
Agda
Cubical/HITs/Pushout/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/HITs/Pushout/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/HITs/Pushout/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Pushout.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Data.Unit open import Cubical.HITs.Susp.Base data Pushout {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} (f : A → B) (g : A → C) : Type (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) where inl : B → Pushout f g inr : C → Pushout f g push : (a : A) → inl (f a) ≡ inr (g a) -- Suspension defined as a pushout PushoutSusp : ∀ {ℓ} (A : Type ℓ) → Type ℓ PushoutSusp A = Pushout {A = A} {B = Unit} {C = Unit} (λ _ → tt) (λ _ → tt) PushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A → Susp A PushoutSusp→Susp (inl _) = north PushoutSusp→Susp (inr _) = south PushoutSusp→Susp (push a i) = merid a i Susp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} → Susp A → PushoutSusp A Susp→PushoutSusp north = inl tt Susp→PushoutSusp south = inr tt Susp→PushoutSusp (merid a i) = push a i Susp→PushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} (x : Susp A) → PushoutSusp→Susp (Susp→PushoutSusp x) ≡ x Susp→PushoutSusp→Susp north = refl Susp→PushoutSusp→Susp south = refl Susp→PushoutSusp→Susp (merid _ _) = refl PushoutSusp→Susp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} (x : PushoutSusp A) → Susp→PushoutSusp (PushoutSusp→Susp x) ≡ x PushoutSusp→Susp→PushoutSusp (inl _) = refl PushoutSusp→Susp→PushoutSusp (inr _) = refl PushoutSusp→Susp→PushoutSusp (push _ _) = refl PushoutSusp≃Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≃ Susp A PushoutSusp≃Susp = isoToEquiv (iso PushoutSusp→Susp Susp→PushoutSusp Susp→PushoutSusp→Susp PushoutSusp→Susp→PushoutSusp) PushoutSusp≡Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≡ Susp A PushoutSusp≡Susp = isoToPath (iso PushoutSusp→Susp Susp→PushoutSusp Susp→PushoutSusp→Susp PushoutSusp→Susp→PushoutSusp)
36.72549
120
0.666311
504cd87cb07acde8d67dd599d5184e1731e1b601
870
agda
Agda
Cubical/Data/Nat/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Data/Nat/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Data/Nat/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-exact-split --safe #-} module Cubical.Data.Nat.Base where open import Cubical.Core.Primitives open import Agda.Builtin.Nat public using (zero; suc; _+_; _*_) renaming (Nat to ℕ) open import Cubical.Data.Nat.Literals public predℕ : ℕ → ℕ predℕ zero = zero predℕ (suc n) = n caseNat : ∀ {ℓ} → {A : Type ℓ} → (a0 aS : A) → ℕ → A caseNat a0 aS zero = a0 caseNat a0 aS (suc n) = aS doubleℕ : ℕ → ℕ doubleℕ zero = zero doubleℕ (suc x) = suc (suc (doubleℕ x)) -- doublesℕ n m = 2^n * m doublesℕ : ℕ → ℕ → ℕ doublesℕ zero m = m doublesℕ (suc n) m = doublesℕ n (doubleℕ m) -- iterate iter : ∀ {ℓ} {A : Type ℓ} → ℕ → (A → A) → A → A iter zero f z = z iter (suc n) f z = f (iter n f z) elim : ∀ {ℓ} {A : ℕ → Type ℓ} → A zero → ((n : ℕ) → A n → A (suc n)) → (n : ℕ) → A n elim a₀ _ zero = a₀ elim a₀ f (suc n) = f n (elim a₀ f n)
21.75
52
0.581609
2fd7d8ab431811536ba6233fcde6d9451d078704
125
agda
Agda
test/Compiler/simple/Erased-cubical-Pattern-matching-Cubical.agda
sseefried/agda
6b13364d36eeb60d8ec15eaf8effe23c73401900
[ "BSD-2-Clause" ]
1
2022-02-05T01:20:23.000Z
2022-02-05T01:20:23.000Z
test/Compiler/simple/Erased-cubical-Pattern-matching-Cubical.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
6
2021-10-18T08:12:24.000Z
2021-11-24T08:31:10.000Z
test/Compiler/simple/Erased-cubical-Pattern-matching-Cubical.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
null
null
null
{-# OPTIONS --cubical --save-metas #-} module Erased-cubical-Pattern-matching-Cubical where data D : Set where c₁ c₂ : D
17.857143
52
0.696
2ec6c12d7356dfec67585893dd4bcf085ea812fe
2,028
agda
Agda
test/succeed/UniversePolymorphism.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2019-11-27T04:41:05.000Z
2019-11-27T04:41:05.000Z
test/succeed/UniversePolymorphism.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
test/succeed/UniversePolymorphism.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
{-# OPTIONS --universe-polymorphism #-} module UniversePolymorphism where postulate Level : Set lzero : Level lsuc : Level → Level max : Level → Level → Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO lzero #-} {-# BUILTIN LEVELSUC lsuc #-} {-# BUILTIN LEVELMAX max #-} data Nat : Set where zero : Nat suc : Nat → Nat infixr 40 _∷_ data Vec {i}(A : Set i) : Nat → Set i where [] : Vec {i} A zero _∷_ : ∀ {n} → A → Vec {i} A n → Vec {i} A (suc n) map : ∀ {n a b}{A : Set a}{B : Set b} → (A → B) → Vec A n → Vec B n map f [] = [] map f (x ∷ xs) = f x ∷ map f xs vec : ∀ {n a}{A : Set a} → A → Vec A n vec {zero} _ = [] vec {suc n} x = x ∷ vec x _<*>_ : ∀ {n a b}{A : Set a}{B : Set b} → Vec (A → B) n → Vec A n → Vec B n [] <*> [] = [] (f ∷ fs) <*> (x ∷ xs) = f x ∷ (fs <*> xs) flip : ∀ {a b c}{A : Set a}{B : Set b}{C : Set c} → (A → B → C) → B → A → C flip f x y = f y x module Zip where Fun : ∀ {n a} → Vec (Set a) n → Set a → Set a Fun [] B = B Fun (A ∷ As) B = A → Fun As B app : ∀ {n m a}(As : Vec (Set a) n)(B : Set a) → Vec (Fun As B) m → Fun (map (flip Vec m) As) (Vec B m) app [] B bs = bs app (A ∷ As) B fs = λ as → app As B (fs <*> as) zipWith : ∀ {n m a}(As : Vec (Set a) n)(B : Set a) → Fun As B → Fun (map (flip Vec m) As) (Vec B m) zipWith As B f = app As B (vec f) zipWith₃ : ∀ {n a}{A B C D : Set a} → (A → B → C → D) → Vec A n → Vec B n → Vec C n → Vec D n zipWith₃ = zipWith (_ ∷ _ ∷ _ ∷ []) _ data Σ {a b}(A : Set a)(B : A → Set b) : Set (max a b) where _,_ : (x : A)(y : B x) → Σ A B fst : ∀ {a b}{A : Set a}{B : A → Set b} → Σ A B → A fst (x , y) = x snd : ∀ {a b}{A : Set a}{B : A → Set b}(p : Σ A B) → B (fst p) snd (x , y) = y -- Normal Σ List : ∀ {a} → Set a → Set a List A = Σ _ (Vec A) nil : ∀ {a}{A : Set a} → List A nil = _ , [] cons : ∀ {a}{A : Set a} → A → List A → List A cons x (_ , xs) = _ , x ∷ xs AnyList : ∀ {i} → Set (lsuc i) AnyList {i} = Σ (Set i) (List {i})
25.35
95
0.461045