Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- Some derivable properties ------------------------------------------------------------------------ open import Algebra module Algebra.Props.Group (g : Group) where open Group g import Algebra.FunctionProperties as P; open P _≈_ import Relation.Binary.EqReasoning as EqR; open EqR setoid open import Data.Function open import Data.Product ⁻¹-involutive : ∀ x → x ⁻¹ ⁻¹ ≈ x ⁻¹-involutive x = begin x ⁻¹ ⁻¹ ≈⟨ sym $ proj₂ identity _ ⟩ x ⁻¹ ⁻¹ ∙ ε ≈⟨ refl ⟨ ∙-pres-≈ ⟩ sym (proj₁ inverse _) ⟩ x ⁻¹ ⁻¹ ∙ (x ⁻¹ ∙ x) ≈⟨ sym $ assoc _ _ _ ⟩ x ⁻¹ ⁻¹ ∙ x ⁻¹ ∙ x ≈⟨ proj₁ inverse _ ⟨ ∙-pres-≈ ⟩ refl ⟩ ε ∙ x ≈⟨ proj₁ identity _ ⟩ x ∎ left-identity-unique : ∀ x y → x ∙ y ≈ y → x ≈ ε left-identity-unique x y eq = begin x ≈⟨ sym (proj₂ identity x) ⟩ x ∙ ε ≈⟨ refl ⟨ ∙-pres-≈ ⟩ sym (proj₂ inverse y) ⟩ x ∙ (y ∙ y ⁻¹) ≈⟨ sym (assoc x y (y ⁻¹)) ⟩ (x ∙ y) ∙ y ⁻¹ ≈⟨ eq ⟨ ∙-pres-≈ ⟩ refl ⟩ y ∙ y ⁻¹ ≈⟨ proj₂ inverse y ⟩ ε ∎ right-identity-unique : ∀ x y → x ∙ y ≈ x → y ≈ ε right-identity-unique x y eq = begin y ≈⟨ sym (proj₁ identity y) ⟩ ε ∙ y ≈⟨ sym (proj₁ inverse x) ⟨ ∙-pres-≈ ⟩ refl ⟩ (x ⁻¹ ∙ x) ∙ y ≈⟨ assoc (x ⁻¹) x y ⟩ x ⁻¹ ∙ (x ∙ y) ≈⟨ refl ⟨ ∙-pres-≈ ⟩ eq ⟩ x ⁻¹ ∙ x ≈⟨ proj₁ inverse x ⟩ ε ∎ identity-unique : ∀ {x} → Identity x _∙_ → x ≈ ε identity-unique {x} id = left-identity-unique x x (proj₂ id x)
{ "alphanum_fraction": 0.4584398977, "avg_line_length": 35.5454545455, "ext": "agda", "hexsha": "560d422920a64975b67d5758b9e365244c209ca3", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Algebra/Props/Group.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Algebra/Props/Group.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Algebra/Props/Group.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 638, "size": 1564 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.Equivalences2 open import lib.NType2 open import lib.types.Group open import lib.types.Pi open import lib.types.Sigma open import lib.types.Truncation module lib.groups.Homomorphisms where record GroupHom {i j} (G : Group i) (H : Group j) : Type (lsucc (lmax i j)) where constructor group-hom field f : Group.El G → Group.El H pres-comp : ∀ g1 g2 → f (Group.comp G g1 g2) == Group.comp H (f g1) (f g2) abstract pres-ident : f (Group.ident G) == Group.ident H pres-ident = group-cancel-l H (f (Group.ident G)) $ Group.comp H (f (Group.ident G)) (f (Group.ident G)) =⟨ ! (pres-comp (Group.ident G) (Group.ident G)) ⟩ f (Group.comp G (Group.ident G) (Group.ident G)) =⟨ ap f (Group.unitl G (Group.ident G)) ⟩ f (Group.ident G) =⟨ ! (Group.unitr H (f (Group.ident G))) ⟩ Group.comp H (f (Group.ident G)) (Group.ident H) ∎ pres-inv : (g : Group.El G) → f (Group.inv G g) == Group.inv H (f g) pres-inv g = f (Group.inv G g) =⟨ ! (Group.unitr H (f (Group.inv G g))) ⟩ Group.comp H (f (Group.inv G g)) (Group.ident H) =⟨ ! (Group.invr H (f g)) |in-ctx (λ w → Group.comp H (f (Group.inv G g)) w) ⟩ Group.comp H (f (Group.inv G g)) (Group.comp H (f g) (Group.inv H (f g))) =⟨ ! (Group.assoc H (f (Group.inv G g)) (f g) (Group.inv H (f g))) ⟩ Group.comp H (Group.comp H (f (Group.inv G g)) (f g)) (Group.inv H (f g)) =⟨ ! (pres-comp (Group.inv G g) g) ∙ ap f (Group.invl G g) ∙ pres-ident |in-ctx (λ w → Group.comp H w (Group.inv H (f g))) ⟩ Group.comp H (Group.ident H) (Group.inv H (f g)) =⟨ Group.unitl H (Group.inv H (f g)) ⟩ Group.inv H (f g) ∎ ⊙f : Σ (Group.El G → Group.El H) (λ f → f (Group.ident G) == Group.ident H) ⊙f = (f , pres-ident) infix 0 _→ᴳ_ _→ᴳ_ = GroupHom GroupIso : ∀ {i j} (G : Group i) (H : Group j) → Type (lsucc (lmax i j)) GroupIso G H = Σ (G →ᴳ H) (λ φ → is-equiv (GroupHom.f φ)) infix 30 _≃ᴳ_ _≃ᴳ_ = GroupIso idhom : ∀ {i} (G : Group i) → (G →ᴳ G) idhom G = group-hom (idf _) (λ _ _ → idp) idiso : ∀ {i} (G : Group i) → (G ≃ᴳ G) idiso G = (idhom G , idf-is-equiv _) infixr 80 _∘ᴳ_ _∘ᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} → (H →ᴳ K) → (G →ᴳ H) → (G →ᴳ K) (group-hom g g-comp) ∘ᴳ (group-hom f f-comp) = record { f = g ∘ f; pres-comp = λ x₁ x₂ → ap g (f-comp x₁ x₂) ∙ g-comp (f x₁) (f x₂)} infixr 80 _∘eᴳ_ _∘eᴳ_ : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} → H ≃ᴳ K → G ≃ᴳ H → G ≃ᴳ K (φ₂ , ie₂) ∘eᴳ (φ₁ , ie₁) = (φ₂ ∘ᴳ φ₁ , ie₂ ∘ise ie₁) infixl 120 _⁻¹ᴳ _⁻¹ᴳ : ∀ {i j} {G : Group i} {H : Group j} → G ≃ᴳ H → H ≃ᴳ G _⁻¹ᴳ {G = G} {H = H} (φ , ie) = (record { f = is-equiv.g ie; pres-comp = λ h₁ h₂ → ap2 (λ w₁ w₂ → is-equiv.g ie (Group.comp H w₁ w₂)) (! (is-equiv.f-g ie h₁)) (! (is-equiv.f-g ie h₂)) ∙ ! (ap (is-equiv.g ie) (GroupHom.pres-comp φ (is-equiv.g ie h₁) (is-equiv.g ie h₂))) ∙ is-equiv.g-f ie (Group.comp G (is-equiv.g ie h₁) (is-equiv.g ie h₂))} , snd ((_ , ie) ⁻¹)) {- a homomorphism which is an equivalence gives a path between groups -} module _ {i} {G H : Group i} (iso : G ≃ᴳ H) where private module G = Group G module H = Group H module φ = GroupHom (fst iso) ie = snd iso private ap3-lemma : ∀ {i j k l} {C : Type i} {D : C → Type j} {E : C → Type k} {F : Type l} {c₁ c₂ : C} {d₁ : D c₁} {d₂ : D c₂} {e₁ : E c₁} {e₂ : E c₂} (f : (c : C) → D c → E c → F) (p : c₁ == c₂) → (d₁ == d₂ [ D ↓ p ]) → (e₁ == e₂ [ E ↓ p ]) → (f c₁ d₁ e₁ == f c₂ d₂ e₂) ap3-lemma f idp idp idp = idp ap3-lemma-el : ∀ {i} {G H : Group i} (p : Group.El G == Group.El H) (q : Group.El-level G == Group.El-level H [ _ ↓ p ]) (r : Group.group-struct G == Group.group-struct H [ _ ↓ p ]) → ap Group.El (ap3-lemma group p q r) == p ap3-lemma-el idp idp idp = idp abstract group-ua : G == H group-ua = ap3-lemma group (ua (φ.f , ie)) (prop-has-all-paths-↓ has-level-is-prop) (↓-group-structure= (G.El-level) (ua (φ.f , ie)) ident= inv= comp=) where ident= : G.ident == H.ident [ (λ C → C) ↓ ua (φ.f , ie) ] ident= = ↓-idf-ua-in _ φ.pres-ident inv= : G.inv == H.inv [ (λ C → C → C) ↓ ua (φ.f , ie) ] inv= = ↓-→-from-transp $ λ= $ λ a → transport (λ C → C) (ua (φ.f , ie)) (G.inv a) =⟨ to-transp (↓-idf-ua-in _ idp) ⟩ φ.f (G.inv a) =⟨ φ.pres-inv a ⟩ H.inv (φ.f a) =⟨ ap H.inv (! (to-transp (↓-idf-ua-in _ idp))) ⟩ H.inv (transport (λ C → C) (ua (φ.f , ie)) a) ∎ comp=' : (a : G.El) → G.comp a == H.comp (φ.f a) [ (λ C → C → C) ↓ ua (φ.f , ie) ] comp=' a = ↓-→-from-transp $ λ= $ λ b → transport (λ C → C) (ua (φ.f , ie)) (G.comp a b) =⟨ to-transp (↓-idf-ua-in _ idp) ⟩ φ.f (G.comp a b) =⟨ φ.pres-comp a b ⟩ H.comp (φ.f a) (φ.f b) =⟨ ! (to-transp (↓-idf-ua-in _ idp)) |in-ctx (λ w → H.comp (φ.f a) w) ⟩ H.comp (φ.f a) (transport (λ C → C) (ua (φ.f , ie)) b) ∎ comp= : G.comp == H.comp [ (λ C → C → C → C) ↓ ua (φ.f , ie) ] comp= = ↓-→-from-transp $ λ= $ λ a → transport (λ C → C → C) (ua (φ.f , ie)) (G.comp a) =⟨ to-transp (comp=' a) ⟩ H.comp (φ.f a) =⟨ ! (to-transp (↓-idf-ua-in _ idp)) |in-ctx (λ w → H.comp w) ⟩ H.comp (transport (λ C → C) (ua (φ.f , ie)) a) ∎ group-ua-el : ap Group.El group-ua == ua (φ.f , ie) group-ua-el = ap3-lemma-el (ua (φ.f , ie)) _ _ {- equality of homomorphisms -} abstract hom= : ∀ {i j} {G : Group i} {H : Group j} (φ ψ : (G →ᴳ H)) → GroupHom.f φ == GroupHom.f ψ → φ == ψ hom= {H = H} _ _ p = ap (uncurry group-hom) (pair= p (prop-has-all-paths-↓ (Π-level (λ _ → Π-level (λ _ → Group.El-level H _ _))))) hom=-↓ : ∀ {i j k} {A : Type i} {G : A → Group j} {H : A → Group k} {x y : A} {p : x == y} (φ : G x →ᴳ H x) (ψ : G y →ᴳ H y) → GroupHom.f φ == GroupHom.f ψ [ (λ a → Group.El (G a) → Group.El (H a)) ↓ p ] → φ == ψ [ (λ a → G a →ᴳ H a) ↓ p ] hom=-↓ {p = idp} = hom= {- homomorphism from equality of groups -} coeᴳ : ∀ {i} {G H : Group i} → G == H → (G →ᴳ H) coeᴳ idp = idhom _ coe!ᴳ : ∀ {i} {G H : Group i} → G == H → (H →ᴳ G) coe!ᴳ idp = idhom _ coeᴳ-fun : ∀ {i} {G H : Group i} (p : G == H) → GroupHom.f (coeᴳ p) == coe (ap Group.El p) coeᴳ-fun idp = idp coe!ᴳ-fun : ∀ {i} {G H : Group i} (p : G == H) → GroupHom.f (coe!ᴳ p) == coe! (ap Group.El p) coe!ᴳ-fun idp = idp coeᴳ-β : ∀ {i} {G H : Group i} (iso : G ≃ᴳ H) → coeᴳ (group-ua iso) == fst iso coeᴳ-β (φ , ie) = hom= _ _ $ coeᴳ-fun (group-ua (φ , ie)) ∙ ap coe (group-ua-el (φ , ie)) ∙ λ= (coe-β (GroupHom.f φ , ie)) {- algebraic properties -} ∘ᴳ-unit-r : ∀ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) → φ ∘ᴳ idhom G == φ ∘ᴳ-unit-r φ = idp ∘ᴳ-unit-l : ∀ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) → idhom H ∘ᴳ φ == φ ∘ᴳ-unit-l φ = hom= _ _ $ idp ∘ᴳ-assoc : ∀ {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l} (χ : K →ᴳ L) (ψ : H →ᴳ K) (φ : G →ᴳ H) → (χ ∘ᴳ ψ) ∘ᴳ φ == χ ∘ᴳ ψ ∘ᴳ φ ∘ᴳ-assoc χ ψ φ = hom= _ _ $ idp {- homomorphism with kernel zero is injective -} module _ {i j} {G : Group i} {H : Group j} (φ : (G →ᴳ H)) where private module G = Group G module H = Group H module φ = GroupHom φ zero-kernel-injective : ((g : G.El) → φ.f g == H.ident → g == G.ident) → ((g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂) zero-kernel-injective f g₁ g₂ p = ! (group-inv-inv G g₁) ∙ group-inv-unique-r G (G.inv g₁) g₂ (f _ $ φ.f (G.comp (G.inv g₁) g₂) =⟨ φ.pres-comp (G.inv g₁) g₂ ⟩ H.comp (φ.f (G.inv g₁)) (φ.f g₂) =⟨ φ.pres-inv g₁ |in-ctx (λ w → H.comp w (φ.f g₂)) ⟩ H.comp (H.inv (φ.f g₁)) (φ.f g₂) =⟨ p |in-ctx (λ w → H.comp (H.inv w) (φ.f g₂)) ⟩ H.comp (H.inv (φ.f g₂)) (φ.f g₂) =⟨ H.invl (φ.f g₂) ⟩ H.ident ∎) {- constant homomorphism -} module _ where cst-hom : ∀ {i j} {G : Group i} {H : Group j} → (G →ᴳ H) cst-hom {H = H} = group-hom (cst ident) (λ _ _ → ! (unitl _)) where open Group H pre∘-cst-hom : ∀ {i j k} {G : Group i} {H : Group j} {K : Group k} (φ : H →ᴳ K) → φ ∘ᴳ cst-hom {G = G} {H = H} == cst-hom pre∘-cst-hom φ = hom= _ _ (λ= (λ g → GroupHom.pres-ident φ)) {- if an injective homomorphism is merely surjective, then it is - fully surjective -} module _ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where private module G = Group G module H = Group H module φ = GroupHom φ module _ (inj : (g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂) (msurj : (h : H.El) → Trunc -1 (Σ G.El (λ g → φ.f g == h))) where {- a surjective and injective homomorphism is an isomorphism -} module _ {i j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where private module G = Group G module H = Group H module φ = GroupHom φ module _ (inj : (g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂) (surj : (h : H.El) → Trunc -1 (Σ G.El (λ g → φ.f g == h))) where private image-prop : (h : H.El) → is-prop (Σ G.El (λ g → φ.f g == h)) image-prop h = all-paths-is-prop $ λ {(g₁ , p₁) (g₂ , p₂) → pair= (inj g₁ g₂ (p₁ ∙ ! p₂)) (prop-has-all-paths-↓ (H.El-level _ _))} surj-inj-is-equiv : is-equiv φ.f surj-inj-is-equiv = contr-map-is-equiv (λ h → let (g₁ , p₁) = Trunc-rec (image-prop h) (idf _) (surj h) in ((g₁ , p₁) , (λ {(g₂ , p₂) → pair= (inj g₁ g₂ (p₁ ∙ ! p₂)) (prop-has-all-paths-↓ (H.El-level _ _))}))) module _ {i} {G H : Group i} (φ : G →ᴳ H) where private module G = Group G module H = Group H module φ = GroupHom φ module _ (inj : (g₁ g₂ : G.El) → φ.f g₁ == φ.f g₂ → g₁ == g₂) (surj : (h : H.El) → Trunc -1 (Σ G.El (λ g → φ.f g == h))) where surj-inj-iso : G ≃ᴳ H surj-inj-iso = (φ , surj-inj-is-equiv φ inj surj) surj-inj-path : G == H surj-inj-path = group-ua surj-inj-iso {- negation is a homomorphism in an abelian gruop -} inv-hom : ∀ {i} (G : Group i) (G-abelian : is-abelian G) → GroupHom G G inv-hom G G-abelian = record { f = Group.inv G; pres-comp = λ g₁ g₂ → group-inv-comp G g₁ g₂ ∙ G-abelian (Group.inv G g₂) (Group.inv G g₁)} inv-hom-natural : ∀ {i j} {G : Group i} {H : Group j} (G-abelian : is-abelian G) (H-abelian : is-abelian H) (φ : G →ᴳ H) → φ ∘ᴳ inv-hom G G-abelian == inv-hom H H-abelian ∘ᴳ φ inv-hom-natural _ _ φ = hom= _ _ $ λ= $ GroupHom.pres-inv φ {- two homomorphisms into an abelian group can be composed with - the group operation -} module _ {i} {G H : Group i} (H-abelian : is-abelian H) (φ ψ : G →ᴳ H) where private module G = Group G module H = Group H module φ = GroupHom φ module ψ = GroupHom ψ comp-hom : G →ᴳ H comp-hom = record { f = λ g → H.comp (φ.f g) (ψ.f g); pres-comp = λ g₁ g₂ → H.comp (φ.f (G.comp g₁ g₂)) (ψ.f (G.comp g₁ g₂)) =⟨ ap2 H.comp (φ.pres-comp g₁ g₂) (ψ.pres-comp g₁ g₂) ⟩ H.comp (H.comp (φ.f g₁) (φ.f g₂)) (H.comp (ψ.f g₁) (ψ.f g₂)) =⟨ lemma (φ.f g₁) (φ.f g₂) (ψ.f g₁) (ψ.f g₂) ⟩ H.comp (H.comp (φ.f g₁) (ψ.f g₁)) (H.comp (φ.f g₂) (ψ.f g₂)) ∎} where lemma : (h₁ h₂ h₃ h₄ : H.El) → H.comp (H.comp h₁ h₂) (H.comp h₃ h₄) == H.comp (H.comp h₁ h₃) (H.comp h₂ h₄) lemma h₁ h₂ h₃ h₄ = (h₁ □ h₂) □ (h₃ □ h₄) =⟨ H.assoc h₁ h₂ (h₃ □ h₄) ⟩ h₁ □ (h₂ □ (h₃ □ h₄)) =⟨ H-abelian h₃ h₄ |in-ctx (λ w → h₁ □ (h₂ □ w)) ⟩ h₁ □ (h₂ □ (h₄ □ h₃)) =⟨ ! (H.assoc h₂ h₄ h₃) |in-ctx (λ w → h₁ □ w) ⟩ h₁ □ ((h₂ □ h₄) □ h₃) =⟨ H-abelian (h₂ □ h₄) h₃ |in-ctx (λ w → h₁ □ w) ⟩ h₁ □ (h₃ □ (h₂ □ h₄)) =⟨ ! (H.assoc h₁ h₃ (h₂ □ h₄)) ⟩ (h₁ □ h₃) □ (h₂ □ h₄) ∎ where infix 80 _□_ _□_ = H.comp
{ "alphanum_fraction": 0.4928194123, "avg_line_length": 33.9383753501, "ext": "agda", "hexsha": "153bdbea996365ae9bbfd6451b850d302c9b71c0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "core/lib/groups/Homomorphisms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "core/lib/groups/Homomorphisms.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "core/lib/groups/Homomorphisms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5289, "size": 12116 }
{-# OPTIONS --no-unicode #-} data Two : Set where tt ff : Two data Foo : Set where foo : Foo -> Foo -> Foo test1 : Foo → Two test1 x₀ = {!!} test : Foo -> Foo → Two test x1 = {!!}
{ "alphanum_fraction": 0.5425531915, "avg_line_length": 13.4285714286, "ext": "agda", "hexsha": "de3e70ade2f7035f1594b40d2b12fe7ae7ab742a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue3866.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue3866.agda", "max_line_length": 28, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue3866.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 62, "size": 188 }
module UniDB.Morph.ShiftsPrime where open import UniDB.Spec open import UniDB.Basic open import UniDB.Subst open import Function open import Data.Product -------------------------------------------------------------------------------- mutual data Shifts* : MOR where refl : {γ : Dom} → Shifts* γ γ incl : {γ₁ γ₂ : Dom} (ξ : Shifts+ γ₁ γ₂) → Shifts* γ₁ γ₂ data Shifts+ : MOR where step : {γ₁ γ₂ : Dom} (ξ : Shifts* γ₁ γ₂) → Shifts+ γ₁ (suc γ₂) skip : {γ₁ γ₂ : Dom} (ξ : Shifts+ γ₁ γ₂) → Shifts+ (suc γ₁) (suc γ₂) mutual shiftIx* : {γ₁ γ₂ : Dom} (ξ : Shifts* γ₁ γ₂) (i : Ix γ₁) → Ix γ₂ shiftIx* refl i = i shiftIx* (incl ξ) i = shiftIx+ ξ i shiftIx+ : {γ₁ γ₂ : Dom} (ξ : Shifts+ γ₁ γ₂) (i : Ix γ₁) → Ix γ₂ shiftIx+ (skip ξ) zero = zero shiftIx+ (skip ξ) (suc i) = suc (shiftIx+ ξ i) shiftIx+ (step ξ) i = suc (shiftIx* ξ i) mutual _⊙**_ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) → Shifts* γ₁ γ₃ ξ₁ ⊙** refl = ξ₁ ξ₁ ⊙** incl ξ₂ = incl (ξ₁ ⊙*+ ξ₂) _⊙*+_ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) → Shifts+ γ₁ γ₃ refl ⊙*+ ξ₂ = ξ₂ incl ξ₁ ⊙*+ ξ₂ = ξ₁ ⊙++ ξ₂ _⊙+*_ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) → Shifts+ γ₁ γ₃ ξ₁ ⊙+* refl = ξ₁ ξ₁ ⊙+* incl ξ₂ = ξ₁ ⊙++ ξ₂ _⊙++_ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) → Shifts+ γ₁ γ₃ ξ₁ ⊙++ step ξ₂ = step (incl (ξ₁ ⊙+* ξ₂)) step ξ₁ ⊙++ skip ξ₂ = step (incl (ξ₁ ⊙*+ ξ₂)) skip ξ₁ ⊙++ skip ξ₂ = skip (ξ₁ ⊙++ ξ₂) -------------------------------------------------------------------------------- instance iLkShifts* : {T : STX} {{vrT : Vr T}} → Lk T Shifts* lk {{iLkShifts*}} ξ i = vr {_} (shiftIx* ξ i) iLkShifts+ : {T : STX} {{vrT : Vr T}} → Lk T Shifts+ lk {{iLkShifts+}} ξ i = vr {_} (shiftIx+ ξ i) iUpShifts* : Up Shifts* _↑₁ {{iUpShifts*}} refl = refl _↑₁ {{iUpShifts*}} (incl ξ) = incl (skip ξ) _↑_ {{iUpShifts*}} ξ 0 = ξ _↑_ {{iUpShifts*}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁ ↑-zero {{iUpShifts*}} ξ = refl ↑-suc {{iUpShifts*}} ξ δ⁺ = refl iUpShifts+ : Up Shifts+ _↑₁ {{iUpShifts+}} ξ = skip ξ _↑_ {{iUpShifts+}} ξ 0 = ξ _↑_ {{iUpShifts+}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁ ↑-zero {{iUpShifts+}} ξ = refl ↑-suc {{iUpShifts+}} ξ δ⁺ = refl iIdmShifts* : Idm Shifts* idm {{iIdmShifts*}} γ = refl {γ} iWkmShifts* : Wkm Shifts* wkm {{iWkmShifts*}} zero = idm {Shifts*} _ wkm {{iWkmShifts*}} (suc δ) = incl (step (wkm {Shifts*} δ)) iCompShifts* : Comp Shifts* _⊙_ {{iCompShifts*}} = _⊙**_ iCompShifts+ : Comp Shifts+ _⊙_ {{iCompShifts+}} = _⊙++_ -------------------------------------------------------------------------------- suc-inj : {γ : Dom} {i j : Ix γ} → _≡_ {A = Ix (suc γ)} (suc i) (suc j) → i ≡ j suc-inj refl = refl shift₁≠id : {γ : Dom} (ξ : Shifts+ γ γ) → Σ[ i ∈ Ix γ ] shiftIx+ ξ i ≢ i shift₁≠id (skip ξ) with shift₁≠id ξ shift₁≠id (skip ξ) | w , ¬p = suc w , ¬p ∘ suc-inj shift₁≠id (step ξ) = zero , λ () mutual extensionality-shifts* : {γ₁ γ₂ : Dom} (ξ₁ ξ₂ : Shifts* γ₁ γ₂) (hyp : (i : Ix γ₁) → lk {Ix} ξ₁ i ≡ lk {Ix} ξ₂ i) → ξ₁ ≡ ξ₂ extensionality-shifts* refl refl hyp = refl extensionality-shifts* refl (incl ξ₂) hyp with shift₁≠id ξ₂ ... | w , ¬p = case ¬p (sym (hyp w)) of λ() extensionality-shifts* (incl ξ₁) refl hyp with shift₁≠id ξ₁ ... | w , ¬p = case ¬p (hyp w) of λ() extensionality-shifts* (incl ξ₁) (incl ξ₂) hyp = cong incl (extensionality-shifts+ ξ₁ ξ₂ hyp) extensionality-shifts+ : {γ₁ γ₂ : Dom} (ξ₁ ξ₂ : Shifts+ γ₁ γ₂) (hyp : (i : Ix γ₁) → lk {Ix} ξ₁ i ≡ lk {Ix} ξ₂ i) → ξ₁ ≡ ξ₂ extensionality-shifts+ (skip ξ₁) (skip ξ₂) hyp = cong skip (extensionality-shifts+ ξ₁ ξ₂ (suc-inj ∘ hyp ∘ suc)) extensionality-shifts+ (skip ξ₁) (step ξ₂) hyp = case hyp zero of λ() extensionality-shifts+ (step ξ₁) (skip ξ₂) hyp = case hyp zero of λ() extensionality-shifts+ (step ξ₁) (step ξ₂) hyp = cong step (extensionality-shifts* ξ₁ ξ₂ (suc-inj ∘ hyp)) mutual shiftIx-⊙** : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) → (i : Ix γ₁) → shiftIx* (ξ₁ ⊙** ξ₂) i ≡ shiftIx* ξ₂ (shiftIx* ξ₁ i) shiftIx-⊙** ξ₁ refl i = refl shiftIx-⊙** ξ₁ (incl ξ₂) i = shiftIx-⊙*+ ξ₁ ξ₂ i shiftIx-⊙*+ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) → (i : Ix γ₁) → shiftIx+ (ξ₁ ⊙*+ ξ₂) i ≡ shiftIx+ ξ₂ (shiftIx* ξ₁ i) shiftIx-⊙*+ refl ξ₂ i = refl shiftIx-⊙*+ (incl ξ₁) ξ₂ i = shiftIx-⊙++ ξ₁ ξ₂ i shiftIx-⊙+* : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) → (i : Ix γ₁) → shiftIx+ (ξ₁ ⊙+* ξ₂) i ≡ shiftIx* ξ₂ (shiftIx+ ξ₁ i) shiftIx-⊙+* ξ₁ refl i = refl shiftIx-⊙+* ξ₁ (incl ξ₂) i = shiftIx-⊙++ ξ₁ ξ₂ i shiftIx-⊙++ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) → (i : Ix γ₁) → shiftIx+ (ξ₁ ⊙++ ξ₂) i ≡ shiftIx+ ξ₂ (shiftIx+ ξ₁ i) shiftIx-⊙++ ξ₁ (step ξ₂) i = cong suc (shiftIx-⊙+* ξ₁ ξ₂ i) shiftIx-⊙++ (step ξ₁) (skip ξ₂) i = cong suc (shiftIx-⊙*+ ξ₁ ξ₂ i) shiftIx-⊙++ (skip ξ₁) (skip ξ₂) zero = refl shiftIx-⊙++ (skip ξ₁) (skip ξ₂) (suc i) = cong suc (shiftIx-⊙++ ξ₁ ξ₂ i) ⊙**-↑₁ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) → (ξ₁ ⊙** ξ₂) ↑₁ ≡ (ξ₁ ↑₁) ⊙** (ξ₂ ↑₁) ⊙**-↑₁ ξ₁ refl = refl ⊙**-↑₁ refl (incl ξ₂) = refl ⊙**-↑₁ (incl ξ₁) (incl ξ₂) = refl ⊙++-↑₁ : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) → (ξ₁ ⊙++ ξ₂) ↑₁ ≡ (ξ₁ ↑₁) ⊙++ (ξ₂ ↑₁) ⊙++-↑₁ ξ₁ (step ξ₂) = refl ⊙++-↑₁ (step ξ₁) (skip ξ₂) = refl ⊙++-↑₁ (skip ξ₁) (skip ξ₂) = refl mutual ⊙***-assoc : {γ₁ γ₂ γ₃ γ₄ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) (ξ₃ : Shifts* γ₃ γ₄) → (ξ₁ ⊙** (ξ₂ ⊙** ξ₃)) ≡ ((ξ₁ ⊙** ξ₂) ⊙** ξ₃) ⊙***-assoc ξ₁ ξ₂ refl = refl ⊙***-assoc ξ₁ ξ₂ (incl ξ₃) = cong incl (⊙**+-assoc ξ₁ ξ₂ ξ₃) ⊙**+-assoc : {γ₁ γ₂ γ₃ γ₄ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) (ξ₃ : Shifts+ γ₃ γ₄) → (ξ₁ ⊙*+ (ξ₂ ⊙*+ ξ₃)) ≡ ((ξ₁ ⊙** ξ₂) ⊙*+ ξ₃) ⊙**+-assoc ξ₁ refl ξ₃ = refl ⊙**+-assoc ξ₁ (incl ξ₂) ξ₃ = ⊙*++-assoc ξ₁ ξ₂ ξ₃ ⊙*++-assoc : {γ₁ γ₂ γ₃ γ₄ : Dom} (ξ₁ : Shifts* γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) (ξ₃ : Shifts+ γ₃ γ₄) → (ξ₁ ⊙*+ (ξ₂ ⊙++ ξ₃)) ≡ ((ξ₁ ⊙*+ ξ₂) ⊙++ ξ₃) ⊙*++-assoc refl ξ₂ ξ₃ = refl ⊙*++-assoc (incl ξ₁) ξ₂ ξ₃ = ⊙+++-assoc ξ₁ ξ₂ ξ₃ ⊙++*-assoc : {γ₁ γ₂ γ₃ γ₄ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) (ξ₃ : Shifts* γ₃ γ₄) → (ξ₁ ⊙++ (ξ₂ ⊙+* ξ₃)) ≡ ((ξ₁ ⊙++ ξ₂) ⊙+* ξ₃) ⊙++*-assoc ξ₁ ξ₂ refl = refl ⊙++*-assoc ξ₁ ξ₂ (incl ξ₃) = ⊙+++-assoc ξ₁ ξ₂ ξ₃ ⊙+*+-assoc : {γ₁ γ₂ γ₃ γ₄ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts* γ₂ γ₃) (ξ₃ : Shifts+ γ₃ γ₄) → (ξ₁ ⊙++ (ξ₂ ⊙*+ ξ₃)) ≡ ((ξ₁ ⊙+* ξ₂) ⊙++ ξ₃) ⊙+*+-assoc ξ₁ refl ξ₃ = refl ⊙+*+-assoc ξ₁ (incl ξ₂) ξ₃ = ⊙+++-assoc ξ₁ ξ₂ ξ₃ ⊙+++-assoc : {γ₁ γ₂ γ₃ γ₄ : Dom} (ξ₁ : Shifts+ γ₁ γ₂) (ξ₂ : Shifts+ γ₂ γ₃) (ξ₃ : Shifts+ γ₃ γ₄) → (ξ₁ ⊙++ (ξ₂ ⊙++ ξ₃)) ≡ ((ξ₁ ⊙++ ξ₂) ⊙++ ξ₃) ⊙+++-assoc ξ₁ ξ₂ (step ξ₃) = cong (step ∘ incl) (⊙++*-assoc ξ₁ ξ₂ ξ₃) ⊙+++-assoc ξ₁ (step ξ₂) (skip ξ₃) = cong (step ∘ incl) (⊙+*+-assoc ξ₁ ξ₂ ξ₃) ⊙+++-assoc (step ξ₁) (skip ξ₂) (skip ξ₃) = cong (step ∘ incl) (⊙*++-assoc ξ₁ ξ₂ ξ₃) ⊙+++-assoc (skip ξ₁) (skip ξ₂) (skip ξ₃) = cong skip (⊙+++-assoc ξ₁ ξ₂ ξ₃) -------------------------------------------------------------------------------- module _ {T : STX} {{vrT : Vr T}} where instance iLkUpShifts* : {{wkT : Wk T}} {{wkVrT : WkVr T}} → LkUp T Shifts* lk-↑₁-zero {{iLkUpShifts*}} refl = refl lk-↑₁-zero {{iLkUpShifts*}} (incl ξ) = refl lk-↑₁-suc {{iLkUpShifts*}} refl i = sym (wk₁-vr {T} i) lk-↑₁-suc {{iLkUpShifts*}} (incl ξ) i = sym (wk₁-vr {T} (shiftIx+ ξ i)) iLkRenShifts* : LkRen T Shifts* lk-ren {{iLkRenShifts*}} ξ i = refl iLkIdmShifts* : LkIdm T Shifts* lk-idm {{iLkIdmShifts*}} i = refl iLkWkmShifts* : LkWkm T Shifts* lk-wkm {{iLkWkmShifts*}} δ i = cong vr (lem δ i) where lem : {γ : Dom} (δ : Dom) (i : Ix γ) → shiftIx* (wkm {Shifts*} δ) i ≡ wk {Ix} δ i lem zero i = refl lem (suc δ) i = cong suc (lem δ i) iLkCompApShifts* : {{apTT : Ap T T}} {{apVrT : ApVr T}} → LkCompAp T Shifts* lk-⊙-ap {{iLkCompApShifts*}} {Ξ} ξ₁ ξ₂ i = begin vr (lk {Ix} (ξ₁ ⊙ ξ₂) i) ≡⟨ cong vr (shiftIx-⊙** ξ₁ ξ₂ i) ⟩ lk {T} ξ₂ (lk {Ix} ξ₁ i) ≡⟨ sym (ap-vr {T} ξ₂ (lk ξ₁ i)) ⟩ ap {T} ξ₂ (vr (lk {Ix} ξ₁ i)) ∎ -- sym {!ap-vr {T} !} instance iUpIdmShifts* : UpIdm Shifts* idm-↑₁ {{iUpIdmShifts*}} = refl iCompIdmShifts* : CompIdm Shifts* ⊙-idm {{iCompIdmShifts*}} ξ = refl idm-⊙ {{iCompIdmShifts*}} refl = refl idm-⊙ {{iCompIdmShifts*}} (incl ξ) = refl iUpCompShifts* : UpComp Shifts* ⊙-↑₁ {{iUpCompShifts*}} ξ₁ ξ₂ = ⊙**-↑₁ ξ₁ ξ₂ -- extensionality-shifts* ((ξ₁ ⊙ ξ₂) ↑₁) (ξ₁ ↑₁ ⊙ ξ₂ ↑₁) -- (lk≃ {Ix} {Shifts*} {ξ = (ξ₁ ⊙ ξ₂) ↑₁} {ξ₁ ↑₁ ⊙ ξ₂ ↑₁} -- (⊙-↑₁-pointwise {Ix} {{apWkTT = iApWk Ix Ix}} {Shifts*} ξ₁ ξ₂)) iCompAssoc* : CompAssoc Shifts* ⊙-assoc {{iCompAssoc*}} = ⊙***-assoc iUpCompShifts+ : UpComp Shifts+ ⊙-↑₁ {{iUpCompShifts+}} = ⊙++-↑₁ iCompAssoc+ : CompAssoc Shifts+ ⊙-assoc {{iCompAssoc+}} = ⊙+++-assoc -------------------------------------------------------------------------------- {- iWkmHomShifts* : WkmHom Shifts* wkm-zero {{iWkmHomShifts*}} = {!!} wkm-suc {{iWkmHomShifts*}} δ = {!!} -}
{ "alphanum_fraction": 0.5007969398, "avg_line_length": 37.3452380952, "ext": "agda", "hexsha": "d7b76fe6e6584262ab7c164c8bdd5df146043e5d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_path": "UniDB/Morph/ShiftsPrime.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "skeuchel/unidb-agda", "max_issues_repo_path": "UniDB/Morph/ShiftsPrime.agda", "max_line_length": 113, "max_stars_count": null, "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_path": "UniDB/Morph/ShiftsPrime.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4973, "size": 9411 }
------------------------------------------------------------------------ -- Terminating parser combinator interface ------------------------------------------------------------------------ module RecursiveDescent.Coinductive where open import RecursiveDescent.Index import RecursiveDescent.Coinductive.Internal as P open P public using (Parser) open import Data.List open import Data.Bool open import Data.Maybe open import Data.Product.Record hiding (map) import Data.Product as Prod open import Data.Function import Data.BoundedVec.Inefficient as BVec ------------------------------------------------------------------------ -- Run function for the parsers parse : forall {tok i r} -> Parser tok i r -> List tok -> List (Prod._×_ r (List tok)) parse p s = map (Prod.map id BVec.toList) (P.parse _ p (BVec.fromList s)) -- A variant which only returns parses which leave no remaining input. parse-complete : forall {tok i r} -> Parser tok i r -> List tok -> List r parse-complete p s = map Prod.proj₁ (filter (null ∘ Prod.proj₂) (parse p s)) ------------------------------------------------------------------------ -- Exported combinators infixl 40 _∣_ infixl 10 _>>=_ _!>>=_ symbol : forall {tok} -> Parser tok 0I tok symbol = P.symbol return : forall {tok r} -> r -> Parser tok 1I r return = P.ret fail : forall {tok r} -> Parser tok 0I r fail = P.fail _>>=_ : forall {tok e₁ c₁ i₂ r₁ r₂} -> let i₁ = (e₁ , c₁) in Parser tok i₁ r₁ -> (r₁ -> Parser tok i₂ r₂) -> Parser tok (i₁ ·I i₂) r₂ _>>=_ {e₁ = true } = P.bind₀ _>>=_ {e₁ = false} = P.bind₁ -- If the first parser is guaranteed to consume something, then the -- second parser's index can depend on the result of the first parser. _!>>=_ : forall {tok c₁ r₁ r₂} {i₂ : r₁ -> Index} -> let i₁ = (false , c₁) in Parser tok i₁ r₁ -> ((x : r₁) -> Parser tok (i₂ x) r₂) -> Parser tok (i₁ ·I 1I) r₂ _!>>=_ = P.bind₁ _∣_ : forall {tok e₁ c₁ i₂ r} -> let i₁ = (e₁ , c₁) in Parser tok i₁ r -> Parser tok i₂ r -> Parser tok (i₁ ∣I i₂) r _∣_ {e₁ = true } = P.alt₀ _∣_ {e₁ = false} = P.alt₁ _
{ "alphanum_fraction": 0.5455801105, "avg_line_length": 30.1666666667, "ext": "agda", "hexsha": "0835753aa7bdd0e91cd89c08b5fe798d259750d8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/RecursiveDescent/Coinductive.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/RecursiveDescent/Coinductive.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/RecursiveDescent/Coinductive.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 608, "size": 2172 }
open import Type module Formalization.ClassicalPropositionalLogic.TruthTable {ℓₚ}{P : Type{ℓₚ}} where import Lvl open import Data open import Data.Boolean open import Data.Boolean.Operators using () renaming (module Logic to Bool) import Data.Boolean.Proofs as Bool open import Data.Boolean.Stmt open import Data.Boolean.Stmt.Proofs open import Data.Either as Either using (_‖_ ; Left ; Right) open import Data.Tuple as Tuple using () open import Formalization.ClassicalPropositionalLogic.Syntax open import Formalization.ClassicalPropositionalLogic.Semantics open import Functional import Logic.Propositional as Logic import Logic.Propositional.Theorems as Logic open import Logic open import Relator.Equals.Proofs.Equiv import Sets.PredicateSet open Sets.PredicateSet.BoundedQuantifiers private variable ℓ : Lvl.Level -- `_⊧_`, but decidable. eval : Model(P) → Formula(P) → Bool eval env (• p) = env(p) eval env (⊤) = 𝑇 eval env (⊥) = 𝐹 eval env (¬ φ) = Bool.¬(eval env (φ)) eval env (φ ∧ ψ) = eval env (φ) Bool.∧ eval env (ψ) eval env (φ ∨ ψ) = eval env (φ) Bool.∨ eval env (ψ) eval env (φ ⟶ ψ) = eval env (φ) Bool.⟶ eval env (ψ) eval env (φ ⟷ ψ) = eval env (φ) Bool.⟷ eval env (ψ) _⊢_ : Formulas(P){ℓ} → Formula(P) → Stmt Γ ⊢ φ = ∀{𝔐} → (∀ₛ(Γ) (IsTrue ∘ eval 𝔐)) → IsTrue(eval 𝔐 φ) private variable Γ Γ₁ Γ₂ : Formulas(P){ℓ} private variable φ ψ : Formula(P) private variable 𝔐 : Model(P) models-to-eval : (𝔐 ⊧ φ) → IsTrue(eval 𝔐 φ) eval-to-models : IsTrue(eval 𝔐 φ) → (𝔐 ⊧ φ) eval-to-models {φ = • x} p = p eval-to-models {φ = ⊤} p = <> eval-to-models {φ = ⊥} p = p eval-to-models {φ = ¬ φ} p = Logic.[↔]-to-[→] IsTrue.preserves-[!][¬] p ∘ models-to-eval {φ = φ} eval-to-models {φ = φ ∧ ψ} p = Tuple.map (eval-to-models {φ = φ}) (eval-to-models {φ = ψ}) (Logic.[↔]-to-[→] IsTrue.preserves-[&&][∧] p) eval-to-models {φ = φ ∨ ψ} p = Either.map (eval-to-models {φ = φ}) (eval-to-models {φ = ψ}) (Logic.[↔]-to-[→] IsTrue.preserves-[||][∨] p) eval-to-models {φ = φ ⟶ ψ} p = Either.map (Logic.contrapositiveᵣ (models-to-eval {φ = φ}) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[!][¬]) (eval-to-models {φ = ψ}) (Logic.[↔]-to-[→] IsTrue.preserves-[||][∨] ([≡]-substitutionᵣ Bool.[→?]-disjunctive-form {f = IsTrue} p)) eval-to-models {φ = φ ⟷ ψ} p = Either.map (Tuple.map (eval-to-models {φ = φ}) (eval-to-models {φ = ψ}) ∘ (Logic.[↔]-to-[→] IsTrue.preserves-[&&][∧])) (Tuple.map (Logic.contrapositiveᵣ (models-to-eval {φ = φ}) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[!][¬]) (Logic.contrapositiveᵣ (models-to-eval {φ = ψ}) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[!][¬]) ∘ Logic.[↔]-to-[→] IsTrue.preserves-[&&][∧]) (Logic.[↔]-to-[→] IsTrue.preserves-[||][∨] ([≡]-substitutionᵣ Bool.[==]-disjunctive-form {f = IsTrue} p)) models-to-eval {φ = • x} p = p models-to-eval {φ = ⊤} p = <> models-to-eval {φ = ⊥} p = p models-to-eval {φ = ¬ φ} p = Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] (p ∘ eval-to-models {φ = φ}) models-to-eval {φ = φ ∧ ψ} p = Logic.[↔]-to-[←] IsTrue.preserves-[&&][∧] (Tuple.map (models-to-eval {φ = φ}) (models-to-eval {φ = ψ}) p) models-to-eval {φ = φ ∨ ψ} p = Logic.[↔]-to-[←] IsTrue.preserves-[||][∨] (Either.map (models-to-eval {φ = φ}) (models-to-eval {φ = ψ}) p) models-to-eval {φ = φ ⟶ ψ} p = [≡]-substitutionₗ Bool.[→?]-disjunctive-form {f = IsTrue} (Logic.[↔]-to-[←] IsTrue.preserves-[||][∨] (Either.map (Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] ∘ Logic.contrapositiveᵣ (eval-to-models {φ = φ})) (models-to-eval {φ = ψ}) p)) models-to-eval {φ = φ ⟷ ψ} p = [≡]-substitutionₗ Bool.[==]-disjunctive-form {f = IsTrue} (Logic.[↔]-to-[←] IsTrue.preserves-[||][∨] (Either.map (Logic.[↔]-to-[←] IsTrue.preserves-[&&][∧] ∘ Tuple.map (models-to-eval {φ = φ}) (models-to-eval {φ = ψ})) (Logic.[↔]-to-[←] IsTrue.preserves-[&&][∧] ∘ Tuple.map (Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] ∘ Logic.contrapositiveᵣ (eval-to-models {φ = φ})) (Logic.[↔]-to-[←] IsTrue.preserves-[!][¬] ∘ Logic.contrapositiveᵣ (eval-to-models {φ = ψ}))) p)) completeness : (Γ ⊨ φ) → (Γ ⊢ φ) completeness {φ = φ} Γφ {𝔐} a = models-to-eval {φ = φ} (Γφ (\{γ} → eval-to-models {φ = γ} ∘ a)) soundness : (Γ ⊢ φ) → (Γ ⊨ φ) soundness {φ = φ} Γφ {𝔐} a = eval-to-models {φ = φ} (Γφ (\{γ} → models-to-eval {φ = γ} ∘ a))
{ "alphanum_fraction": 0.6053558844, "avg_line_length": 60.8142857143, "ext": "agda", "hexsha": "e222f7b8b8cf27887768126e5c736c01249f44b3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Formalization/ClassicalPropositionalLogic/TruthTable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Formalization/ClassicalPropositionalLogic/TruthTable.agda", "max_line_length": 495, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Formalization/ClassicalPropositionalLogic/TruthTable.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1713, "size": 4257 }
------------------------------------------------------------------------ -- An example that uses natural numbers as names, implemented using -- the coinductive definition of bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Bisimilarity.CCS.Examples.Natural-numbers where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude open import Prelude.Size open import Bijection equality-with-J using (_↔_) open import Equality.Decision-procedures equality-with-J open import Fin equality-with-J open import Function-universe equality-with-J as F hiding (id; _∘_; Distinct↔≢) open import Nat equality-with-J hiding (Distinct) open import Bisimilarity.CCS import Bisimilarity.Equational-reasoning-instances open import Bisimilarity.CCS.Examples open import Equational-reasoning open import Labelled-transition-system.CCS ℕ open import Bisimilarity CCS module _ (μ : Action) where -- Two processes that are strongly bisimilar. P : ∀ {i} → ℕ → Proc i P n = Restricted n ∣ (μ · λ { .force → P (1 + n) }) Q : ∀ {i} → Proc i Q = μ · λ { .force → Q } P∼Q : ∀ {i n} → [ i ] P n ∼ Q P∼Q {n = n} = P n ∼⟨ Restricted∼∅ ∣-cong (refl ·-cong λ { .force → P∼Q }) ⟩ ∅ ∣ Q ∼⟨ ∣-left-identity ⟩■ Q -- Q is not finite. Q-infinite : ¬ Finite Q Q-infinite (action f) = Q-infinite f -- However, Q is regular. Q-regular : Regular Q Q-regular = 1 , (λ _ → Q) , (fzero ,_) ∘ lemma where lemma : ∀ {P} → Subprocess P Q → Equal ∞ P Q lemma (refl eq) = eq lemma (action sub) = lemma sub -- The processes in the family P are not finite. P-infinite : ∀ {n} → ¬ Finite (P n) P-infinite (_ ∣ action f) = P-infinite f -- Furthermore they are irregular. P-irregular : ∀ {n} → ¬ Regular (P n) P-irregular (k , Qs , hyp) = irregular′ k hyp where Regular′ : ℕ → ∀ k → (Fin k → Proc ∞) → Type Regular′ n k Qs = ∀ {Q} → Subprocess Q (P n) → ∃ λ (i : Fin k) → Equal ∞ Q (Qs i) irregular′ : ∀ {n} k {Qs} → ¬ Regular′ n k Qs irregular′ {n} zero {Qs} = Regular′ n zero Qs ↝⟨ _$ refl (Proc-refl _) ⟩ (∃ λ (i : Fin zero) → _) ↝⟨ proj₁ ⟩□ ⊥ □ irregular′ {n} (suc k) {Qs} = Regular′ n (suc k) Qs ↝⟨ lemma₂ ⟩ (∃ λ Qs′ → Regular′ (suc n) k Qs′) ↝⟨ irregular′ k ∘ proj₂ ⟩□ ⊥ □ where lemma₁ : ∀ {Q} m {n} → Subprocess Q (P (1 + m + n)) → ¬ Equal ∞ Q (P n) lemma₁ m (par-right (action sub)) eq = lemma₁ (suc m) sub eq lemma₁ m {n} (refl (⟨ν refl ⟩ _ ∣ _)) (⟨ν suc[m+n]≡n ⟩ _ ∣ _) = ≢1+ _ (n ≡⟨ sym suc[m+n]≡n ⟩ suc (m + n) ≡⟨ cong suc (+-comm m) ⟩∎ suc (n + m) ∎) lemma₁ _ (par-left (refl ())) (_ ∣ _) lemma₁ _ (par-left (restriction (refl ()))) (_ ∣ _) lemma₁ _ (par-left (restriction (action (refl ())))) (_ ∣ _) lemma₁ _ (par-right (refl p)) q with Proc-trans (Proc-sym p) q ... | () lemma₂ : ∀ {n k Qs} → Regular′ n (suc k) Qs → ∃ λ Qs′ → Regular′ (suc n) k Qs′ lemma₂ {n} {k} {Qs} reg = let i , Pn≡Qsi = reg (refl (Proc-refl _)) Fin↔ = Fin↔Fin+≢ i Qs′ = Fin k ↔⟨ Fin↔ ⟩ (∃ λ (j : Fin (suc k)) → Distinct j i) ↝⟨ Qs ∘ proj₁ ⟩□ Proc ∞ □ in Qs′ , λ {Q} → Subprocess Q (P (1 + n)) ↝⟨ (λ sub → reg (par-right (action sub)) , lemma₁ 0 sub) ⟩ (∃ λ (j : Fin (suc k)) → Equal ∞ Q (Qs j)) × ¬ Equal ∞ Q (P n) ↝⟨ (λ { ((j , Q≡Qsj) , Q≢Pn) → ( j , (case j Fin.≟ i of λ where (inj₁ refl) → ⊥-elim $ Q≢Pn (Proc-trans Q≡Qsj (Proc-sym Pn≡Qsi)) (inj₂ j≢i) → _⇔_.from (Distinct↔≢ _) j≢i) ) , Q≡Qsj }) ⟩ (∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) → Equal ∞ Q (Qs (proj₁ j))) ↝⟨ ∃-cong (λ _ → ≡⇒↝ _ $ cong (λ j → Equal ∞ Q (Qs (proj₁ j))) $ sym $ _↔_.right-inverse-of Fin↔ _) ⟩ (∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) → Equal ∞ Q (Qs (proj₁ (_↔_.to Fin↔ (_↔_.from Fin↔ j))))) ↔⟨⟩ (∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) → Equal ∞ Q (Qs′ (_↔_.from Fin↔ j))) ↝⟨ Σ-cong (inverse Fin↔) (λ _ → F.id) ⟩□ (∃ λ (j : Fin k) → Equal ∞ Q (Qs′ j)) □
{ "alphanum_fraction": 0.4042235096, "avg_line_length": 39.9328358209, "ext": "agda", "hexsha": "57feb013454cbc7940373821bb1b821cf951562e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Bisimilarity/CCS/Examples/Natural-numbers.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/up-to", "max_issues_repo_path": "src/Bisimilarity/CCS/Examples/Natural-numbers.agda", "max_line_length": 142, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Bisimilarity/CCS/Examples/Natural-numbers.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1688, "size": 5351 }
import Relation.Binary.EqReasoning as EqReasoning open import SemiNearRingRecords module ZeroLemmas (snr : SemiNearRing) where open SemiNearRing snr -- public open import CommAssocLemmas s _≃s_ _+s_ zers isCommMon hiding (_<+>_) renaming (SA to Ss) zeroˡLemma : ∀ x y → zers *s x +s zers *s y ≃s zers zeroˡLemma x y = begin zers *s x +s zers *s y ≈⟨ zeroˡ x <+> zeroˡ y ⟩ zers +s zers ≈⟨ identityˡs zers ⟩ zers ∎ where open EqReasoning Ss zeroʳLemma : ∀ x y → x *s zers +s y *s zers ≃s zers zeroʳLemma x y = begin x *s zers +s y *s zers ≈⟨ zeroʳ x <+> zeroʳ y ⟩ zers +s zers ≈⟨ identityˡs zers ⟩ zers ∎ where open EqReasoning Ss zeroˡʳLemma : ∀ w x y → w +s (zers *s x +s y *s zers) ≃s w zeroˡʳLemma w x y = begin w +s (zers *s x +s y *s zers) ≈⟨ refls <+> (zeroˡ x <+> zeroʳ y) ⟩ w +s (zers +s zers) ≈⟨ refls <+> identityˡs zers ⟩ w +s zers ≈⟨ identityʳs w ⟩ w ∎ where open EqReasoning Ss -- Some lemmas are needed to eliminate the zers and massage the terms. zeroLemma01 = lemmaCommAssoc01 zeroLemma10 : ∀ {a b c d e} → a +s ( ((zers *s b) +s c) +s (d +s (e *s zers))) ≃s a +s ( c +s d ) zeroLemma10 {a} {b} {c} {d} {e} = refls <+> (begin ((zers *s b) +s c) +s (d +s (e *s zers)) ≈⟨ (zeroˡ b <+> refls) <+> (refls <+> zeroʳ e) ⟩ ( zers +s c) +s (d +s zers) ≈⟨ identityˡs c <+> identityʳs d ⟩ c +s d ∎) where open EqReasoning Ss zeroLemma00 : ∀ {a b c d e} → a +s ((c +s b) +s (d +s (e *s zers)) ) ≃s (a +s b) +s (c +s d) zeroLemma00 {a} {b} {c} {d} {e} = (begin a +s ((c +s b) +s (d +s (e *s zers)) ) ≈⟨ refls <+> (comms c b <+> (refls <+> zeroʳ e)) ⟩ a +s ((b +s c) +s (d +s zers) ) ≈⟨ refls <+> (refls <+> identityʳs d) ⟩ a +s ((b +s c) +s d) ≈⟨ refls <+> assocs b c d ⟩ a +s (b +s (c +s d)) ≈⟨ syms (assocs a b _) ⟩ (a +s b) +s (c +s d) ∎) where open EqReasoning Ss zeroLemma11 : ∀ {a b c d e} → a +s (((zers *s e) +s c) +s (b +s d)) ≃s (a +s b) +s (c +s d) zeroLemma11 {a} {b} {c} {d} {e} = (begin a +s (((zers *s e) +s c) +s (b +s d)) ≈⟨ refls <+> ((zeroˡ e <+> refls) <+> refls) ⟩ a +s ((zers +s c) +s (b +s d)) ≈⟨ refls <+> (identityˡs c <+> refls) ⟩ a +s ( c +s (b +s d)) ≈⟨ refls <+> syms (assocs c b d) ⟩ a +s ((c +s b) +s d) ≈⟨ refls <+> (comms c b <+> refls) ⟩ a +s ((b +s c) +s d) ≈⟨ refls <+> (assocs _ _ _) ⟩ a +s (b +s (c +s d)) ≈⟨ syms (assocs _ _ _) ⟩ (a +s b) +s (c +s d) ∎) where open EqReasoning Ss
{ "alphanum_fraction": 0.4227108631, "avg_line_length": 33.4835164835, "ext": "agda", "hexsha": "f2e61d0f3f1dd2dbf57a3f67dc5b187ab0caf8a9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-29T04:53:48.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-29T04:53:48.000Z", "max_forks_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "DSLsofMath/ValiantAgda", "max_forks_repo_path": "code/ZeroLemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "DSLsofMath/ValiantAgda", "max_issues_repo_path": "code/ZeroLemmas.agda", "max_line_length": 91, "max_stars_count": 3, "max_stars_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "DSLsofMath/ValiantAgda", "max_stars_repo_path": "code/ZeroLemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-15T03:04:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-23T00:41:14.000Z", "num_tokens": 1325, "size": 3047 }
module Data.Finitude.Exponent where open import Data.Finitude open import Data.Fin as Fin using (Fin; toℕ) open import Data.Nat open import Data.Vec as Vec open import Relation.Binary.PropositionalEquality as P open import Data.Nat.DivMod open import Relation.Nullary.Decidable open import Function open import Function.Equality as F using (_⟶_; _⟨$⟩_; _⇨_) open import Function.Inverse as Inv using (module Inverse; Inverse) open import Data.Product open import Data.Sum open import Data.Empty open import Relation.Binary exponent : ∀ {m} {n} → Finitude (P.setoid (Vec (Fin m) n)) (m ^ n) exponent {m} {n} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = to∘from {m}{n} } } where open import Data.Nat.Properties open import Data.Fin.Properties hiding (≤-refl; _≟_; <-cmp) open import Relation.Nullary.Negation shift : ∀ {m n} (i : Fin m)(j : Fin n) → toℕ j + (toℕ i) * n < m * n shift {m}{n} i j = begin suc (toℕ j) + toℕ i * n ≤⟨ +-mono-≤ (toℕ<n j) (≤-refl {(toℕ i) * n}) ⟩ n + toℕ i * n ≤⟨ *-mono-≤ (toℕ<n i) ≤-refl ⟩ m * n ∎ where open ≤-Reasoning to : ∀ {m n} → Vec (Fin m) n → Fin (m ^ n) to [] = Fin.zero to {m}{n = suc n} (i ∷ is) = Fin.fromℕ≤ (shift i (to is)) suci^j≢0 : ∀ i j → suc i ^ j ≢ 0 suci^j≢0 i j eq with i^j≡0⇒i≡0 _ j eq ... | () from : ∀ {m n} → Fin (m ^ n) → Vec (Fin m) n from {m} {zero} i = [] from {zero} {suc n} () from {suc m} {suc n} i with ((toℕ i) divMod (suc m ^ n)) {≢0 = fromWitnessFalse (suci^j≢0 _ n)} from {suc m} {suc n} i | result quotient remainder property = Fin.fromℕ≤ q<sm ∷ from remainder where q<sm : quotient < suc m q<sm = ≰⇒> (λ sm≤q → <⇒≱ (toℕ<n i) (begin (suc m) * (suc m ^ n) ≤⟨ *-mono-≤ sm≤q ≤-refl ⟩ quotient * (suc m ^ n) ≤⟨ +-mono-≤ (z≤n {toℕ remainder}) ≤-refl ⟩ toℕ remainder + quotient * (suc m ^ n) ≡⟨ P.sym property ⟩ toℕ i ∎)) where open ≤-Reasoning ≢→<⊎> : ∀ {m n} → m ≢ n → m < n ⊎ n < m ≢→<⊎> {m}{n} m≢n with <-cmp m n ≢→<⊎> {m} {n} m≢n | tri< m<n _ _ = inj₁ m<n ≢→<⊎> {m} {n} m≢n | tri≈ _ m≡n _ = ⊥-elim (m≢n m≡n) ≢→<⊎> {m} {n} m≢n | tri> _ _ n<m = inj₂ n<m chn : ∀ m → ∀ {k₀ k₁} {r₀ r₁ : Fin m} → toℕ r₀ + k₀ * m ≡ toℕ r₁ + k₁ * m → k₀ ≡ k₁ × r₀ ≡ r₁ chn zero {k₀} {k₁} {()} {r₁} _ chn (suc m) {k₀} {k₁} {r₀} {r₁} eq = k₀≡k₁ , r₀≡r₁ where open ≤-Reasoning contra : k₀ ≢ k₁ → ⊥ contra k₀≢k₁ with ≢→<⊎> k₀≢k₁ ... | inj₁ k₀<k₁ = <⇒≱ (toℕ<n r₀) (+-cancelʳ-≤ (suc m) (toℕ r₀) (begin suc m + k₀ * suc m ≡⟨ refl ⟩ suc k₀ * suc m ≤⟨ *-mono-≤ (m≤m+n (suc k₀) (k₁ ∸ suc k₀)) (≤-refl {suc m}) ⟩ (suc k₀ + (k₁ ∸ suc k₀)) * suc m ≡⟨ P.cong₂ _*_ (m+n∸m≡n k₀<k₁) refl ⟩ k₁ * suc m ≤⟨ n≤m+n (toℕ r₁) (k₁ * suc m) ⟩ toℕ r₁ + k₁ * suc m ≡⟨ P.sym eq ⟩ toℕ r₀ + k₀ * suc m ∎)) ... | inj₂ k₁<k₀ = <⇒≱ (toℕ<n r₁) (+-cancelʳ-≤ (suc m) (toℕ r₁) (begin suc k₁ * suc m ≤⟨ *-mono-≤ (m≤m+n (suc k₁) (k₀ ∸ suc k₁)) (≤-refl {suc m}) ⟩ (suc k₁ + (k₀ ∸ suc k₁)) * suc m ≡⟨ P.cong₂ _*_ (m+n∸m≡n k₁<k₀) refl ⟩ k₀ * suc m ≤⟨ n≤m+n (toℕ r₀) (k₀ * suc m) ⟩ toℕ r₀ + k₀ * suc m ≡⟨ eq ⟩ toℕ r₁ + k₁ * suc m ∎ )) k₀≡k₁ : k₀ ≡ k₁ k₀≡k₁ = decidable-stable (k₀ ≟ k₁) contra r₀≡r₁ : r₀ ≡ r₁ r₀≡r₁ = toℕ-injective (+-cancelʳ-≡ (toℕ r₀) (toℕ r₁) (P.subst (λ k → toℕ r₀ + k * (suc m) ≡ toℕ r₁ + k₁ * (suc m)) k₀≡k₁ eq)) from∘to : ∀ {m n}(is : Vec (Fin m) n) → from (to is) ≡ is from∘to {m} {.0} [] = P.refl from∘to {zero} {.(suc _)} (() ∷ is) from∘to {suc m} {suc n} (i ∷ is) with to (i ∷ is) | P.inspect to (i ∷ is) from∘to {suc m} {suc n} (i ∷ is) | j | Reveal_·_is_.[ eq ] with P.cong toℕ eq ... | eq2 rewrite toℕ-fromℕ≤ (shift i (to is)) with ((toℕ j) divMod (suc m ^ n)) {≢0 = fromWitnessFalse (suci^j≢0 _ n)} ... | result quotient remainder property with chn (suc m ^ n) {toℕ i}{quotient} {to is}{remainder} (trans eq2 property) ... | k₀≡k₁ , r₀≡r₁ rewrite P.sym r₀≡r₁ | from∘to is = P.cong (_∷ is) (toℕ-injective (begin toℕ (Fin.fromℕ≤ _) ≡⟨ toℕ-fromℕ≤ _ ⟩ quotient ≡⟨ P.sym k₀≡k₁ ⟩ toℕ i ∎)) where open ≡-Reasoning to∘from : ∀ {m n}(i : Fin (m ^ n)) → to (from{m}{n} i) ≡ i to∘from {m} {zero} Fin.zero = refl to∘from {m} {zero} (Fin.suc ()) to∘from {zero} {suc n} () to∘from {suc m} {suc n} i with ((toℕ i) divMod (suc m ^ n)) {≢0 = fromWitnessFalse (suci^j≢0 _ n)} to∘from {suc m} {suc n} i | result quotient remainder property = goal where q<sm : quotient < suc m q<sm = ≰⇒> (λ sm≤q → <⇒≱ (toℕ<n i) (begin (suc m) * (suc m ^ n) ≤⟨ *-mono-≤ sm≤q ≤-refl ⟩ quotient * (suc m ^ n) ≤⟨ +-mono-≤ (z≤n {toℕ remainder}) ≤-refl ⟩ toℕ remainder + quotient * (suc m ^ n) ≡⟨ P.sym property ⟩ toℕ i ∎)) where open ≤-Reasoning goal : to (Fin.fromℕ≤ q<sm ∷ from {suc m}{n} remainder) ≡ i goal = toℕ-injective (begin _ ≡⟨ toℕ-fromℕ≤ _ ⟩ toℕ (to (from {suc m} {n} remainder)) + toℕ (Fin.fromℕ≤ q<sm ) * (suc m ^ n) ≡⟨ P.cong₂ (λ r k → toℕ r + k * (suc m ^ n)) (to∘from {suc m} {n} remainder) (toℕ-fromℕ≤ q<sm) ⟩ toℕ remainder + quotient * (suc m ^ n) ≡⟨ P.sym property ⟩ toℕ i ∎) where open ≡-Reasoning ⟶-finitude-toVec : ∀{m n a b p q}{A : Setoid a p}{B : Setoid b q} → Finitude A m → Finitude B n → A ⟶ B → Vec (Fin n) m ⟶-finitude-toVec finA finB f = Vec.tabulate (λ i → (Inverse.to finB F.∘ f F.∘ Inverse.from finA) ⟨$⟩ i ) ⟶-finitude-fromVec : ∀{m n a b p q}{A : Setoid a p}{B : Setoid b q} → Finitude A m → Finitude B n → Vec (Fin n) m → A ⟶ B ⟶-finitude-fromVec {A = SA}{B = SB} finA finB vec = record { _⟨$⟩_ = f ; cong = f-cong } where open module SA = Setoid SA renaming (Carrier to A) using () open module SB = Setoid SB renaming (Carrier to B) using () f : A → B f x = Inverse.from finB ⟨$⟩ Vec.lookup (Inverse.to finA ⟨$⟩ x) vec f-cong : ∀ {x y} → x SA.≈ y → f x SB.≈ f y f-cong {x}{y} x≈y = F.cong (Inverse.from finB) (P.cong (flip Vec.lookup vec) (F.cong (Inverse.to finA) x≈y)) ⟶-finitude↔Vec : ∀{m n a b p q}{A : Setoid a p}{B : Setoid b q} → Finitude A n → Finitude B m → Inverse (A ⇨ B) (P.setoid (Vec (Fin m) n)) Inverse.to (⟶-finitude↔Vec {m} {n} {A = S₁} {S₂} finA finB) ._⟨$⟩_ = ⟶-finitude-toVec finA finB Inverse.to (⟶-finitude↔Vec {m} {n} {A = S₁} {S₂} finA finB) .F.cong {f} {g} eq = tabulate-cong ( λ i → F.cong (Inverse.to finB) (eq ≈₁-refl) ) where open import Data.Vec.Properties open Setoid S₁ renaming (isEquivalence to isEquivalence₁) open IsEquivalence isEquivalence₁ renaming (refl to ≈₁-refl) Inverse.from (⟶-finitude↔Vec finA finB) = P.→-to-⟶ (⟶-finitude-fromVec finA finB) Inv._InverseOf_.left-inverse-of (Inverse.inverse-of (⟶-finitude↔Vec {m = m}{n}{A = S₁} {S₂} finA finB)) f {x}{y} x≈y = begin ⟶-finitude-fromVec finA finB (⟶-finitude-toVec finA finB f) ⟨$⟩ x ≈⟨ F.cong (Inverse.from finB) lemma ⟩ _ ≈⟨ linv₂ _ ⟩ _ ≈⟨ F.cong f (linv₁ x) ⟩ _ ≈⟨ F.cong f x≈y ⟩ f ⟨$⟩ y ∎ where open import Data.Vec.Properties open import Relation.Binary.Reasoning.Setoid (S₂) open Setoid S₁ renaming (isEquivalence to isEquivalence₁) open IsEquivalence isEquivalence₁ renaming (refl to ≈₁-refl; trans to ≈₁-trans) open Setoid S₂ renaming (isEquivalence to isEquivalence₂) open IsEquivalence isEquivalence₂ renaming (refl to ≈₂-refl; trans to ≈₂-trans) F = (Inverse.to finB F.∘ f F.∘ Inverse.from finA) ⟨$⟩_ lemma = lookup∘tabulate F (Inverse.to finA ⟨$⟩ x) linv₁ = finA .Inverse.inverse-of .Inv._InverseOf_.left-inverse-of linv₂ = finB .Inverse.inverse-of .Inv._InverseOf_.left-inverse-of Inv._InverseOf_.right-inverse-of (Inverse.inverse-of (⟶-finitude↔Vec finA finB)) vec = begin _ ≡⟨ tabulate-cong lemma ⟩ _ ≡⟨ tabulate∘lookup vec ⟩ vec ∎ where open import Data.Vec.Properties open P.≡-Reasoning rinv₁ = finA .Inverse.inverse-of .Inv._InverseOf_.right-inverse-of rinv₂ = finB .Inverse.inverse-of .Inv._InverseOf_.right-inverse-of lemma : Inverse.to finB F.∘ (⟶-finitude-fromVec finA finB vec) F.∘ Inverse.from finA ⟨$⟩_ ≗ flip lookup vec lemma i = begin _ ≡⟨ rinv₂ _ ⟩ _ ≡⟨ P.cong (flip lookup vec) (rinv₁ i) ⟩ lookup i vec ∎ ⟶-finitude : ∀{m n a b p q}{A : Setoid a p}{B : Setoid b q} → Finitude A n → Finitude B m → Finitude (A ⇨ B) (m ^ n) ⟶-finitude finA finB = exponent Inv.∘ (⟶-finitude↔Vec finA finB)
{ "alphanum_fraction": 0.4923218673, "avg_line_length": 47.1884057971, "ext": "agda", "hexsha": "e72bf56e86da5a096b5883590b96ff091ea000e4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_path": "src/Data/Finitude/Exponent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tizmd/agda-finitary", "max_issues_repo_path": "src/Data/Finitude/Exponent.agda", "max_line_length": 119, "max_stars_count": null, "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_path": "src/Data/Finitude/Exponent.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3949, "size": 9768 }
module product where open import level ---------------------------------------------------------------------- -- types ---------------------------------------------------------------------- data Σ {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') : Set (ℓ ⊔ ℓ') where _,_ : (a : A) → (b : B a) → Σ A B data Σi {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') : Set (ℓ ⊔ ℓ') where ,_ : {a : A} → (b : B a) → Σi A B _×_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A × B = Σ A (λ x → B) _i×_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A i× B = Σi A (λ x → B) ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- infix 1 Σ-syntax infixr 2 _×_ _i×_ _∧_ infixr 4 _,_ infix 4 ,_ -- This provides the syntax: Σ[ x ∈ A ] B it is taken from the Agda -- standard library. This style is nice when working in Set. Σ-syntax : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b) Σ-syntax = Σ syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B ---------------------------------------------------------------------- -- operations ---------------------------------------------------------------------- fst : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A × B → A fst (a , b) = a snd : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A × B → B snd (a , b) = b ⟨_,_⟩ : ∀{ℓ₁ ℓ₂ ℓ₃ ℓ₄} {A : Set ℓ₁}{B : Set ℓ₂} {C : Set ℓ₃}{D : Set ℓ₄} → (A → C) → (B → D) → (A × B → C × D) ⟨ f , g ⟩ (a , b) = f a , g b twist-× : ∀{ℓ₁ ℓ₂} {A : Set ℓ₁}{B : Set ℓ₂} → A × B → B × A twist-× (a , b) = (b , a) rl-assoc-× : ∀{ℓ₁ ℓ₂ ℓ₃} {A : Set ℓ₁}{B : Set ℓ₂} {C : Set ℓ₃} → A × (B × C) → (A × B) × C rl-assoc-× (a , b , c) = ((a , b) , c) lr-assoc-× : ∀{ℓ₁ ℓ₂ ℓ₃} {A : Set ℓ₁}{B : Set ℓ₂} {C : Set ℓ₃} → (A × B) × C → A × (B × C) lr-assoc-× ((a , b) , c) = (a , b , c) ---------------------------------------------------------------------- -- some logical notation ---------------------------------------------------------------------- _∧_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') _∧_ = _×_ ∃ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') → Set (ℓ ⊔ ℓ') ∃ = Σ ∃i : ∀ {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') → Set (ℓ ⊔ ℓ') ∃i = Σi
{ "alphanum_fraction": 0.2959139785, "avg_line_length": 27.0348837209, "ext": "agda", "hexsha": "751bfd9b3fe852d08b3e3ede13bc1603ee4628ff", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "product.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "product.agda", "max_line_length": 70, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "product.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 921, "size": 2325 }
------------------------------------------------------------------------ -- Fixity and associativity ------------------------------------------------------------------------ module Mixfix.Fixity where open import Data.Fin using (Fin; zero; suc; #_) open import Data.Fin.Properties using (eq?) open import Function.LeftInverse open import Relation.Binary open import Relation.Binary.PropositionalEquality as Eq data Associativity : Set where left : Associativity right : Associativity non : Associativity -- A combination of fixity and associativity. Only infix operators -- have associativity. -- Note that infix is a reserved word. data Fixity : Set where prefx : Fixity infx : (assoc : Associativity) → Fixity postfx : Fixity closed : Fixity Fixity-is-finite : LeftInverse (Eq.setoid Fixity) (Eq.setoid (Fin 6)) Fixity-is-finite = record { from = Eq.→-to-⟶ from ; to = Eq.→-to-⟶ to ; left-inverse-of = left-inverse-of } where to : Fixity → Fin 6 to prefx = # 0 to (infx left) = # 1 to (infx right) = # 2 to (infx non) = # 3 to postfx = # 4 to closed = # 5 from : Fin 6 → Fixity from zero = prefx from (suc zero) = infx left from (suc (suc zero)) = infx right from (suc (suc (suc zero))) = infx non from (suc (suc (suc (suc zero)))) = postfx from (suc (suc (suc (suc (suc zero))))) = closed from (suc (suc (suc (suc (suc (suc ())))))) left-inverse-of : Eq.→-to-⟶ from LeftInverseOf Eq.→-to-⟶ to left-inverse-of prefx = refl left-inverse-of (infx left) = refl left-inverse-of (infx right) = refl left-inverse-of (infx non) = refl left-inverse-of postfx = refl left-inverse-of closed = refl _≟_ : Decidable (_≡_ {A = Fixity}) _≟_ = eq? injection where open LeftInverse Fixity-is-finite
{ "alphanum_fraction": 0.55453149, "avg_line_length": 30.515625, "ext": "agda", "hexsha": "0b558b53e194f7b89ed4453f44b44973a8cb2333", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "Mixfix/Fixity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "Mixfix/Fixity.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "Mixfix/Fixity.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 583, "size": 1953 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core -- Reflexive pairs and reflexive coequalizers -- https://ncatlab.org/nlab/show/reflexive+coequalizer module Categories.Diagram.ReflexivePair {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Categories.Diagram.Coequalizer 𝒞 open Category 𝒞 open HomReasoning open Equiv private variable A B R : Obj -- A reflexive pair can be thought of as a vast generalization of a reflexive relation. -- To see this, consider the case in 'Set' where 'R ⊆ A × A', and 'f' and 'g' are the projections. -- Then, our morphism 's' would have to look something like the diagonal morphism due to the -- restriction it is a section of both 'f' and 'g'. record IsReflexivePair (f g : R ⇒ A) (s : A ⇒ R) : Set e where field sectionₗ : f ∘ s ≈ id sectionᵣ : g ∘ s ≈ id section : f ∘ s ≈ g ∘ s section = sectionₗ ○ ⟺ sectionᵣ record ReflexivePair (f g : R ⇒ A) : Set (ℓ ⊔ e) where field s : A ⇒ R isReflexivePair : IsReflexivePair f g s open IsReflexivePair isReflexivePair public
{ "alphanum_fraction": 0.6934441367, "avg_line_length": 27.7692307692, "ext": "agda", "hexsha": "cf61bf7090437407903f2da98c012bb95e6e28f2", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/ReflexivePair.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/ReflexivePair.agda", "max_line_length": 98, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/ReflexivePair.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 353, "size": 1083 }
------------------------------------------------------------------------ -- A large class of algebraic structures satisfies the property that -- isomorphic instances of a structure are equal (assuming univalence) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- This code has been superseded by more recent developments. See -- README.agda. -- This module has been developed in collaboration with Thierry -- Coquand. open import Equality module Univalence-axiom.Isomorphism-implies-equality {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open import Bijection eq open Derived-definitions-and-properties eq open import Equivalence eq as Eq open import H-level eq open import H-level.Closure eq open import Logical-equivalence open import Prelude open import Univalence-axiom eq ------------------------------------------------------------------------ -- N-ary functions -- N-ary functions. _^_⟶_ : Type → ℕ → Type → Type A ^ zero ⟶ B = B A ^ suc n ⟶ B = A → A ^ n ⟶ B -- N-ary function morphisms. Is-_-ary-morphism : (n : ℕ) {A B : Type} → A ^ n ⟶ A → B ^ n ⟶ B → (A → B) → Type Is- zero -ary-morphism f₁ f₂ m = m f₁ ≡ f₂ Is- suc n -ary-morphism f₁ f₂ m = ∀ x → Is- n -ary-morphism (f₁ x) (f₂ (m x)) m abstract -- If _↔_.to m is a morphism, then _↔_.from m is also a morphism. from-also-_-ary-morphism : (n : ℕ) {A B : Type} (f₁ : A ^ n ⟶ A) (f₂ : B ^ n ⟶ B) (m : A ↔ B) → Is- n -ary-morphism f₁ f₂ (_↔_.to m) → Is- n -ary-morphism f₂ f₁ (_↔_.from m) from-also- zero -ary-morphism f₁ f₂ m is = _↔_.to-from m is from-also- suc n -ary-morphism f₁ f₂ m is = λ x → from-also- n -ary-morphism (f₁ (from x)) (f₂ x) m (subst (λ y → Is- n -ary-morphism (f₁ (from x)) (f₂ y) to) (right-inverse-of x) (is (from x))) where open _↔_ m -- Changes the type of an n-ary function. cast : {A₁ A₂ : Type} → A₁ ≃ A₂ → ∀ n → A₁ ^ n ⟶ A₁ → A₂ ^ n ⟶ A₂ cast A₁≃A₂ zero = _≃_.to A₁≃A₂ cast A₁≃A₂ (suc n) = λ f x → cast A₁≃A₂ n (f (_≃_.from A₁≃A₂ x)) abstract -- Cast simplification lemma. cast-id : {A : Type} → (∀ n → Extensionality′ A (λ _ → A ^ n ⟶ A)) → ∀ n (f : A ^ n ⟶ A) → cast Eq.id n f ≡ f cast-id ext zero f = refl f cast-id ext (suc n) f = ext n $ λ x → cast-id ext n (f x) -- We can express cast as an instance of subst (assuming -- extensionality and univalence). cast-is-subst : (∀ {A : Type} n → Extensionality′ A (λ _ → A ^ n ⟶ A)) → {A₁ A₂ : Type} (univ : Univalence′ A₁ A₂) (A₁≃A₂ : A₁ ≃ A₂) (n : ℕ) (f : A₁ ^ n ⟶ A₁) → cast A₁≃A₂ n f ≡ subst (λ C → C ^ n ⟶ C) (≃⇒≡ univ A₁≃A₂) f cast-is-subst ext univ A₁≃A₂ n = transport-theorem (λ A → A ^ n ⟶ A) (λ A≃B f → cast A≃B n f) (cast-id ext n) univ A₁≃A₂ -- If there is an isomorphism from f₁ to f₂, then the corresponding -- instance of cast maps f₁ to f₂ (assuming extensionality). cast-isomorphism : {A₁ A₂ : Type} → (∀ n → Extensionality′ A₂ (λ _ → A₂ ^ n ⟶ A₂)) → (A₁≃A₂ : A₁ ≃ A₂) (n : ℕ) (f₁ : A₁ ^ n ⟶ A₁) (f₂ : A₂ ^ n ⟶ A₂) → Is- n -ary-morphism f₁ f₂ (_≃_.to A₁≃A₂) → cast A₁≃A₂ n f₁ ≡ f₂ cast-isomorphism ext A₁≃A₂ zero f₁ f₂ is = is cast-isomorphism ext A₁≃A₂ (suc n) f₁ f₂ is = ext n $ λ x → cast A₁≃A₂ n (f₁ (from x)) ≡⟨ cast-isomorphism ext A₁≃A₂ n _ _ (is (from x)) ⟩ f₂ (to (from x)) ≡⟨ cong f₂ (right-inverse-of x) ⟩∎ f₂ x ∎ where open _≃_ A₁≃A₂ -- Combining the results above we get the following: if there is an -- isomorphism from f₁ to f₂, then the corresponding instance of -- subst maps f₁ to f₂ (assuming extensionality and univalence). subst-isomorphism : (∀ {A : Type} n → Extensionality′ A (λ _ → A ^ n ⟶ A)) → {A₁ A₂ : Type} (univ : Univalence′ A₁ A₂) (A₁≃A₂ : A₁ ≃ A₂) (n : ℕ) (f₁ : A₁ ^ n ⟶ A₁) (f₂ : A₂ ^ n ⟶ A₂) → Is- n -ary-morphism f₁ f₂ (_≃_.to A₁≃A₂) → subst (λ A → A ^ n ⟶ A) (≃⇒≡ univ A₁≃A₂) f₁ ≡ f₂ subst-isomorphism ext univ A₁≃A₂ n f₁ f₂ is = subst (λ A → A ^ n ⟶ A) (≃⇒≡ univ A₁≃A₂) f₁ ≡⟨ sym $ cast-is-subst ext univ A₁≃A₂ n f₁ ⟩ cast A₁≃A₂ n f₁ ≡⟨ cast-isomorphism ext A₁≃A₂ n f₁ f₂ is ⟩∎ f₂ ∎ ------------------------------------------------------------------------ -- A class of algebraic structures -- An algebraic structure universe. mutual -- Codes for structures. infixl 5 _+operator_ _+axiom_ data Structure : Type₁ where empty : Structure -- N-ary functions. _+operator_ : Structure → (n : ℕ) → Structure -- Arbitrary /propositional/ axioms. _+axiom_ : (s : Structure) (P : ∃ λ (P : (A : Type) → ⟦ s ⟧ A → Type) → ∀ A s → Is-proposition (P A s)) → Structure -- Interpretation of the codes. ⟦_⟧ : Structure → Type → Type₁ ⟦ empty ⟧ A = ↑ _ ⊤ ⟦ s +operator n ⟧ A = ⟦ s ⟧ A × (A ^ n ⟶ A) ⟦ s +axiom (P , P-prop) ⟧ A = Σ (⟦ s ⟧ A) (P A) -- Top-level interpretation. ⟪_⟫ : Structure → Type₁ ⟪ s ⟫ = ∃ ⟦ s ⟧ -- Morphisms. Is-structure-morphism : (s : Structure) → {A B : Type} → ⟦ s ⟧ A → ⟦ s ⟧ B → (A → B) → Type Is-structure-morphism empty _ _ m = ⊤ Is-structure-morphism (s +axiom _) (s₁ , _) (s₂ , _) m = Is-structure-morphism s s₁ s₂ m Is-structure-morphism (s +operator n) (s₁ , op₁) (s₂ , op₂) m = Is-structure-morphism s s₁ s₂ m × Is- n -ary-morphism op₁ op₂ m -- Isomorphisms. Isomorphism : (s : Structure) → ⟪ s ⟫ → ⟪ s ⟫ → Type Isomorphism s (A₁ , s₁) (A₂ , s₂) = ∃ λ (m : A₁ ↔ A₂) → Is-structure-morphism s s₁ s₂ (_↔_.to m) abstract -- If _↔_.to m is a morphism, then _↔_.from m is also a morphism. from-also-structure-morphism : (s : Structure) → {A B : Type} {s₁ : ⟦ s ⟧ A} {s₂ : ⟦ s ⟧ B} → (m : A ↔ B) → Is-structure-morphism s s₁ s₂ (_↔_.to m) → Is-structure-morphism s s₂ s₁ (_↔_.from m) from-also-structure-morphism empty m = _ from-also-structure-morphism (s +axiom _) m = from-also-structure-morphism s m from-also-structure-morphism (s +operator n) m = Σ-map (from-also-structure-morphism s m) (from-also- n -ary-morphism _ _ m) -- Isomorphic structures are equal (assuming univalence). isomorphic-equal : Univalence′ (Type ²/≡) Type → Univalence lzero → (s : Structure) (s₁ s₂ : ⟪ s ⟫) → Isomorphism s s₁ s₂ → s₁ ≡ s₂ isomorphic-equal univ₁ univ₂ s (A₁ , s₁) (A₂ , s₂) (m , is) = (A₁ , s₁) ≡⟨ Σ-≡,≡→≡ A₁≡A₂ (lemma s s₁ s₂ is) ⟩∎ (A₂ , s₂) ∎ where open _↔_ m -- Extensionality follows from univalence. ext : {A : Type} {B : A → Type} → Extensionality′ A B ext = dependent-extensionality′ univ₁ (λ _ → univ₂) -- The presence of the bijection implies that the structure's -- underlying types are equal (due to univalence). A₁≡A₂ : A₁ ≡ A₂ A₁≡A₂ = _≃_.from (≡≃≃ univ₂) $ ↔⇒≃ m -- We can lift subst-isomorphism to structures by recursion on -- structure codes. lemma : (s : Structure) (s₁ : ⟦ s ⟧ A₁) (s₂ : ⟦ s ⟧ A₂) → Is-structure-morphism s s₁ s₂ to → subst ⟦ s ⟧ A₁≡A₂ s₁ ≡ s₂ lemma empty _ _ _ = refl _ lemma (s +axiom (P , P-prop)) (s₁ , ax₁) (s₂ , ax₂) is = subst (λ A → Σ (⟦ s ⟧ A) (P A)) A₁≡A₂ (s₁ , ax₁) ≡⟨ push-subst-pair′ ⟦ s ⟧ (uncurry P) (lemma s s₁ s₂ is) ⟩ (s₂ , _) ≡⟨ cong (_,_ s₂) $ P-prop _ _ _ _ ⟩∎ (s₂ , ax₂) ∎ lemma (s +operator n) (s₁ , op₁) (s₂ , op₂) (is-s , is-o) = subst (λ A → ⟦ s ⟧ A × (A ^ n ⟶ A)) A₁≡A₂ (s₁ , op₁) ≡⟨ push-subst-pair′ ⟦ s ⟧ (λ { (A , _) → A ^ n ⟶ A }) (lemma s s₁ s₂ is-s) ⟩ (s₂ , subst₂ (λ { (A , _) → A ^ n ⟶ A }) A₁≡A₂ (lemma s s₁ s₂ is-s) op₁) ≡⟨ cong (_,_ s₂) $ subst₂-proj₁ (λ A → A ^ n ⟶ A) ⟩ (s₂ , subst (λ A → A ^ n ⟶ A) A₁≡A₂ op₁) ≡⟨ cong (_,_ s₂) $ subst-isomorphism (λ _ → ext) univ₂ (↔⇒≃ m) n op₁ op₂ is-o ⟩∎ (s₂ , op₂) ∎ ------------------------------------------------------------------------ -- Some example structures -- Example: magmas. magma : Structure magma = empty +operator 2 Magma : Type₁ Magma = ⟪ magma ⟫ private -- An unfolding of Magma. Magma-unfolded : Magma ≡ ∃ λ (A : Type) → ↑ _ ⊤ × (A → A → A) Magma-unfolded = refl _ -- Example: semigroups. The definition uses extensionality to prove -- that the axioms are propositional. Note that one axiom states that -- the underlying type is a set. This assumption is used to prove that -- the other axiom is propositional. semigroup : Extensionality lzero lzero → Structure semigroup ext = empty +axiom ( (λ A _ → Is-set A) , is-set-prop ) +operator 2 +axiom ( (λ { _ (_ , _∙_) → ∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z) }) , assoc-prop ) where is-set-prop = λ _ _ → H-level-propositional ext 2 assoc-prop = λ { _ ((_ , A-set) , _) → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → A-set } Semigroup : Extensionality lzero lzero → Type₁ Semigroup ext = ⟪ semigroup ext ⟫ private -- An unfolding of Semigroup. Semigroup-unfolded : (ext : Extensionality lzero lzero) → Semigroup ext ≡ Σ Type λ A → Σ (Σ (Σ (↑ _ ⊤) λ _ → Is-set A ) λ _ → A → A → A ) λ { (_ , _∙_) → ∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z) } Semigroup-unfolded _ = refl _ -- Example: abelian groups. abelian-group : Extensionality lzero lzero → Structure abelian-group ext = empty -- The underlying type is a set. +axiom ( (λ A _ → Is-set A) , is-set-prop ) -- The binary group operation. +operator 2 -- Commutativity. +axiom ( (λ { _ (_ , _∙_) → ∀ x y → (x ∙ y) ≡ (y ∙ x) }) , comm-prop ) -- Associativity. +axiom ( (λ { _ ((_ , _∙_) , _) → ∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z) }) , assoc-prop ) -- Identity. +operator 0 -- Left identity. +axiom ( (λ { _ ((((_ , _∙_) , _) , _) , e) → ∀ x → (e ∙ x) ≡ x }) , left-identity-prop ) -- Right identity. +axiom ( (λ { _ (((((_ , _∙_) , _) , _) , e) , _) → ∀ x → (x ∙ e) ≡ x }) , right-identity-prop ) -- Inverse. +operator 1 -- Left inverse. +axiom ( (λ { _ (((((((_ , _∙_) , _) , _) , e) , _) , _) , _⁻¹) → ∀ x → ((x ⁻¹) ∙ x) ≡ e }) , left-inverse-prop ) -- Right inverse. +axiom ( (λ { _ ((((((((_ , _∙_) , _) , _) , e) , _) , _) , _⁻¹) , _) → ∀ x → (x ∙ (x ⁻¹)) ≡ e }) , right-inverse-prop ) where is-set-prop = λ _ _ → H-level-propositional ext 2 comm-prop = λ { _ ((_ , A-set) , _) → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → A-set } assoc-prop = λ { _ (((_ , A-set) , _) , _) → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → A-set } left-identity-prop = λ { _ (((((_ , A-set) , _) , _) , _) , _) → Π-closure ext 1 λ _ → A-set } right-identity-prop = λ { _ ((((((_ , A-set) , _) , _) , _) , _) , _) → Π-closure ext 1 λ _ → A-set } left-inverse-prop = λ { _ ((((((((_ , A-set) , _) , _) , _) , _) , _) , _) , _) → Π-closure ext 1 λ _ → A-set } right-inverse-prop = λ { _ (((((((((_ , A-set) , _) , _) , _) , _) , _) , _) , _) , _) → Π-closure ext 1 λ _ → A-set } Abelian-group : Extensionality lzero lzero → Type₁ Abelian-group ext = ⟪ abelian-group ext ⟫ private -- An unfolding of Abelian-group. Note that the inner structure is -- left-nested. Abelian-group-unfolded : (ext : Extensionality lzero lzero) → Abelian-group ext ≡ Σ Type λ A → Σ (Σ (Σ (Σ (Σ (Σ (Σ (Σ (Σ (Σ (↑ _ ⊤) λ _ → Is-set A ) λ _ → A → A → A ) λ { (_ , _∙_) → ∀ x y → (x ∙ y) ≡ (y ∙ x) }) λ { ((_ , _∙_) , _) → ∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z) }) λ _ → A ) λ { ((((_ , _∙_) , _) , _) , e) → ∀ x → (e ∙ x) ≡ x }) λ { (((((_ , _∙_) , _) , _) , e) , _) → ∀ x → (x ∙ e) ≡ x }) λ _ → A → A ) λ { (((((((_ , _∙_) , _) , _) , e) , _) , _) , _⁻¹) → ∀ x → ((x ⁻¹) ∙ x) ≡ e }) λ { ((((((((_ , _∙_) , _) , _) , e) , _) , _) , _⁻¹) , _) → ∀ x → (x ∙ (x ⁻¹)) ≡ e } Abelian-group-unfolded _ = refl _ ------------------------------------------------------------------------ -- Right-nested structures -- Right-nested structures are arguably easier to define (see the -- example below). However, the following class of right-nested -- structures is in some sense different from the class above. Take -- "operator 0 f : Structureʳ Bool", for instance. The /shape/ of f op -- can vary depending on whether the operator op is true or false. -- -- One could perhaps avoid this issue by only considering values of -- type ∀ A → Structureʳ A. However, it is not obvious how to convert -- elements of this type to elements of type Structure in a -- meaning-preserving way. Furthermore it seems to be awkward to -- define things like Is-structure-isomorphism when using values of -- type ∀ A → Structureʳ A (see the definition of -- Is-structure-isomorphismʳ below). -- Codes. (Note that these structures are defined for a single -- underlying type.) data Structureʳ (A : Type) : Type₁ where empty : Structureʳ A -- N-ary functions. operator : (n : ℕ) (s : A ^ n ⟶ A → Structureʳ A) → Structureʳ A -- Arbitrary /propositional/ axioms. axiom : (P : Type) (P-prop : Is-proposition P) (s : P → Structureʳ A) → Structureʳ A -- Interpretation of the codes. ⟦_⟧ʳ : {A : Type} → Structureʳ A → Type₁ ⟦ empty ⟧ʳ = ↑ _ ⊤ ⟦ operator n s ⟧ʳ = ∃ λ op → ⟦ s op ⟧ʳ ⟦ axiom P P-prop s ⟧ʳ = ∃ λ p → ⟦ s p ⟧ʳ -- Top-level interpretation. ⟪_⟫ʳ : (∀ A → Structureʳ A) → Type₁ ⟪ s ⟫ʳ = ∃ λ A → ⟦ s A ⟧ʳ -- The property of being an isomorphism. Is-structure-isomorphismʳ : (s : ∀ A → Structureʳ A) → {A B : Type} → ⟦ s A ⟧ʳ → ⟦ s B ⟧ʳ → A ↔ B → Type Is-structure-isomorphismʳ s {A} {B} S₁ S₂ m = helper (s A) (s B) S₁ S₂ where helper : (s₁ : Structureʳ A) (s₂ : Structureʳ B) → ⟦ s₁ ⟧ʳ → ⟦ s₂ ⟧ʳ → Type helper empty empty _ _ = ⊤ helper (operator n₁ s₁) (operator n₂ s₂) (op₁ , S₁) (op₂ , S₂) = (∃ λ (eq : n₁ ≡ n₂) → Is- n₁ -ary-morphism op₁ (subst (λ n → B ^ n ⟶ B) (sym eq) op₂) (_↔_.to m)) × helper (s₁ op₁) (s₂ op₂) S₁ S₂ helper (axiom P₁ _ s₁) (axiom P₂ _ s₂) (p₁ , S₁) (p₂ , S₂) = helper (s₁ p₁) (s₂ p₂) S₁ S₂ helper empty (operator n s₂) _ _ = ⊥ helper empty (axiom P P-prop s₂) _ _ = ⊥ helper (operator n s₁) empty _ _ = ⊥ helper (operator n s₁) (axiom P P-prop s₂) _ _ = ⊥ helper (axiom P P-prop s₁) empty _ _ = ⊥ helper (axiom P P-prop s₁) (operator n s₂) _ _ = ⊥ -- Example: semigroups. semigroupʳ : Extensionality lzero lzero → ∀ A → Structureʳ A semigroupʳ ext A = axiom (Is-set A) (H-level-propositional ext 2) λ A-set → operator 2 λ _∙_ → axiom (∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z)) (Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → A-set) λ _ → empty Semigroupʳ : Extensionality lzero lzero → Type₁ Semigroupʳ ext = ⟪ semigroupʳ ext ⟫ʳ private -- An unfolding of Semigroupʳ. Semigroupʳ-unfolded : (ext : Extensionality lzero lzero) → Semigroupʳ ext ≡ ∃ λ (A : Type) → ∃ λ (_ : Is-set A) → ∃ λ (_∙_ : A → A → A) → ∃ λ (_ : ∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z)) → ↑ _ ⊤ Semigroupʳ-unfolded _ = refl _
{ "alphanum_fraction": 0.4942115525, "avg_line_length": 29.4121863799, "ext": "agda", "hexsha": "16a8cf61bbbbaa833a47db8440e47190f544c176", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Univalence-axiom/Isomorphism-implies-equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Univalence-axiom/Isomorphism-implies-equality.agda", "max_line_length": 140, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Univalence-axiom/Isomorphism-implies-equality.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 6132, "size": 16412 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Properties.Kleisli where open import Level import Relation.Binary.PropositionalEquality as ≡ open import Categories.Adjoint open import Categories.Adjoint.Properties open import Categories.Category open import Categories.Functor using (Functor; _∘F_) open import Categories.Functor.Equivalence open import Categories.Monad import Categories.Morphism.Reasoning as MR open import Categories.Adjoint.Construction.Kleisli open import Categories.Category.Construction.Kleisli private variable o ℓ e : Level 𝒞 𝒟 : Category o ℓ e module _ {F : Functor 𝒞 𝒟} {G : Functor 𝒟 𝒞} (F⊣G : Adjoint F G) where private T : Monad 𝒞 T = adjoint⇒monad F⊣G 𝒞ₜ : Category _ _ _ 𝒞ₜ = Kleisli T module 𝒞 = Category 𝒞 module 𝒟 = Category 𝒟 module 𝒞ₜ = Category 𝒞ₜ module T = Monad T module F = Functor F module G = Functor G open Adjoint F⊣G -- Maclane's Comparison Functor ComparisonF : Functor 𝒞ₜ 𝒟 ComparisonF = record { F₀ = λ X → F.F₀ X ; F₁ = λ {A} {B} f → 𝒟 [ counit.η (F.F₀ B) ∘ F.F₁ f ] ; identity = zig ; homomorphism = λ {X} {Y} {Z} {f} {g} → begin 𝒟 [ counit.η (F.F₀ Z) ∘ F.F₁ (𝒞 [ 𝒞 [ G.F₁ (counit.η (F.F₀ Z)) ∘ G.F₁ (F.F₁ g)] ∘ f ])] ≈⟨ refl⟩∘⟨ F.homomorphism ⟩ 𝒟 [ counit.η (F.F₀ Z) ∘ 𝒟 [ F.F₁ (𝒞 [ G.F₁ (counit.η (F.F₀ Z)) ∘ G.F₁ (F.F₁ g) ]) ∘ F.F₁ f ] ] ≈⟨ refl⟩∘⟨ F.homomorphism ⟩∘⟨refl ⟩ 𝒟 [ counit.η (F.F₀ Z) ∘ 𝒟 [ 𝒟 [ F.F₁ (G.F₁ (counit.η (F.F₀ Z))) ∘ F.F₁ (G.F₁ (F.F₁ g)) ] ∘ F.F₁ f ] ] ≈⟨ center⁻¹ refl refl ⟩ 𝒟 [ 𝒟 [ counit.η (F.F₀ Z) ∘ F.F₁ (G.F₁ (counit.η (F.F₀ Z))) ] ∘ 𝒟 [ F.F₁ (G.F₁ (F.F₁ g)) ∘ F.F₁ f ] ] ≈⟨ counit.commute (counit.η (F.F₀ Z)) ⟩∘⟨refl ⟩ 𝒟 [ 𝒟 [ counit.η (F.F₀ Z) ∘ (counit.η (F.F₀ (G.F₀ (F.F₀ Z)))) ] ∘ 𝒟 [ F.F₁ (G.F₁ (F.F₁ g)) ∘ F.F₁ f ] ] ≈⟨ extend² (counit.commute (F.F₁ g)) ⟩ 𝒟 [ 𝒟 [ counit.η (F.F₀ Z) ∘ F.F₁ g ] ∘ 𝒟 [ counit.η (F.F₀ Y) ∘ F.F₁ f ] ] ∎ ; F-resp-≈ = λ eq → 𝒟.∘-resp-≈ʳ (F.F-resp-≈ eq) } where open 𝒟.HomReasoning open MR 𝒟 private L = ComparisonF module L = Functor L module Gₜ = Functor (Forgetful T) module Fₜ = Functor (Free T) G∘L≡Forgetful : (G ∘F L) ≡F Forgetful T G∘L≡Forgetful = record { eq₀ = λ X → ≡.refl ; eq₁ = λ {A} {B} f → begin 𝒞 [ 𝒞.id ∘ G.F₁ (𝒟 [ counit.η (F.F₀ B) ∘ F.F₁ f ]) ] ≈⟨ 𝒞.identityˡ ⟩ G.F₁ (𝒟 [ counit.η (F.F₀ B) ∘ F.F₁ f ]) ≈⟨ G.homomorphism ⟩ 𝒞 [ G.F₁ (counit.η (F.F₀ B)) ∘ G.F₁ (F.F₁ f) ] ≈˘⟨ 𝒞.identityʳ ⟩ 𝒞 [ 𝒞 [ G.F₁ (counit.η (F.F₀ B)) ∘ G.F₁ (F.F₁ f) ] ∘ 𝒞.id ] ∎ } where open 𝒞.HomReasoning L∘Free≡F : (L ∘F Free T) ≡F F L∘Free≡F = record { eq₀ = λ X → ≡.refl ; eq₁ = λ {A} {B} f → begin 𝒟 [ 𝒟.id ∘ 𝒟 [ counit.η (F.F₀ B) ∘ F.F₁ (𝒞 [ unit.η B ∘ f ]) ] ] ≈⟨ 𝒟.identityˡ ⟩ 𝒟 [ counit.η (F.F₀ B) ∘ F.F₁ (𝒞 [ unit.η B ∘ f ]) ] ≈⟨ pushʳ F.homomorphism ⟩ 𝒟 [ 𝒟 [ counit.η (F.F₀ B) ∘ F.F₁ (unit.η B) ] ∘ F.F₁ f ] ≈⟨ elimˡ zig ⟩ F.F₁ f ≈˘⟨ 𝒟.identityʳ ⟩ 𝒟 [ F.F₁ f ∘ 𝒟.id ] ∎ } where open 𝒟.HomReasoning open MR 𝒟
{ "alphanum_fraction": 0.5122962963, "avg_line_length": 35.9042553191, "ext": "agda", "hexsha": "321308f0c8ba496717411dd6fd888a1f9064da97", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/Properties/Kleisli.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Construction/Properties/Kleisli.agda", "max_line_length": 157, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Construction/Properties/Kleisli.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1547, "size": 3375 }
module Issue599 where data Bool : Set where true false : Bool -- standard lambda here foo : Bool → Bool foo = ? -- pattern matching lambda here bar : Bool → Bool bar = ?
{ "alphanum_fraction": 0.6761363636, "avg_line_length": 12.5714285714, "ext": "agda", "hexsha": "6902be18944e551a64906001a48dbc4e509197dd", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue599.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue599.agda", "max_line_length": 31, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue599.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 46, "size": 176 }
------------------------------------------------------------------------ -- The halting problem ------------------------------------------------------------------------ module Halting-problem where open import Equality.Propositional.Cubical open import Logical-equivalence using (_⇔_) open import Prelude hiding (const; Decidable) open import Tactic.By.Propositional open import Univalence-axiom open import Equality.Decision-procedures equality-with-J open import Function-universe equality-with-J hiding (id; _∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional equality-with-paths as Trunc hiding (rec) -- To simplify the development, let's work with actual natural numbers -- as variables and constants (see -- Atom.one-can-restrict-attention-to-χ-ℕ-atoms). open import Atom open import Cancellation χ-ℕ-atoms open import Chi χ-ℕ-atoms open import Coding χ-ℕ-atoms open import Compatibility χ-ℕ-atoms open import Computability χ-ℕ-atoms hiding (_∘_) open import Constants χ-ℕ-atoms open import Deterministic χ-ℕ-atoms open import Free-variables χ-ℕ-atoms open import Propositional χ-ℕ-atoms open import Reasoning χ-ℕ-atoms open import Termination χ-ℕ-atoms open import Values χ-ℕ-atoms open χ-atoms χ-ℕ-atoms import Coding.Instances.Nat open import Combinators as χ hiding (id; if_then_else_) open import Internal-coding ------------------------------------------------------------------------ -- The extensional halting problem -- The extensional halting problem is undecidable. extensional-halting-problem : ¬ ∃ λ halts → Closed halts × ∀ p → Closed p → (Terminates p → apply halts (lambda v-underscore p) ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates p → apply halts (lambda v-underscore p) ⇓ ⌜ false ⦂ Bool ⌝) extensional-halting-problem (halts , cl , hyp) = contradiction where terminv : Exp → Exp terminv p = χ.if apply halts (lambda v-underscore p) then loop else ⌜ zero ⌝ terminv-lemma : ∀ {p} → Closed p → Terminates (terminv p) ⇔ ¬ Terminates p terminv-lemma {p} cl-p = record { to = to; from = from } where to : Terminates (terminv p) → ¬ Terminates p to (_ , case _ (there _ (there _ ())) _ _) p⇓ to (_ , case halts⇓false (there _ here) [] _) p⇓ = C.distinct-codes→distinct-names (λ ()) $ proj₁ $ cancel-const $ ⇓-deterministic (proj₁ (hyp p cl-p) p⇓) halts⇓false to (_ , case _ here [] loop⇓) p⇓ = ¬loop⇓ (_ , loop⇓) from : ¬ Terminates p → Terminates (terminv p) from ¬p⇓ = _ , case (proj₂ (hyp p cl-p) ¬p⇓) (there lemma here) [] (const []) where lemma = C.distinct-codes→distinct-names (λ ()) strange : Exp strange = rec v-p (terminv (var v-p)) strange-closed : Closed strange strange-closed = Closed′-closed-under-rec $ if-then-else-closed (Closed′-closed-under-apply (Closed→Closed′ cl) (Closed′-closed-under-lambda (Closed′-closed-under-var (inj₂ (inj₁ refl))))) (Closed→Closed′ loop-closed) (Closed→Closed′ $ rep-closed zero) subst-lemma : terminv (var v-p) [ v-p ← strange ] ≡ terminv strange subst-lemma = terminv (var v-p) [ v-p ← strange ] ≡⟨⟩ χ.if apply ⟨ halts [ v-p ← strange ] ⟩ (lambda v-underscore strange) then loop else ⌜ zero ⌝ ≡⟨ ⟨by⟩ (subst-closed _ _ cl) ⟩ χ.if apply halts (lambda v-underscore strange) then loop else ⌜ zero ⌝ ≡⟨⟩ terminv strange ∎ strange-lemma : Terminates strange ⇔ ¬ Terminates strange strange-lemma = Terminates strange ↝⟨ record { to = λ { (_ , rec p) → _ , p } ; from = Σ-map _ rec } ⟩ Terminates (terminv (var v-p) [ v-p ← strange ]) ↔⟨ ≡⇒↝ bijection (by subst-lemma) ⟩ Terminates (terminv strange) ↝⟨ terminv-lemma strange-closed ⟩ ¬ Terminates strange □ contradiction : ⊥ contradiction = ¬[⇔¬] strange-lemma -- A variant of the statement above. extensional-halting-problem′ : ¬ ∃ λ halts → Closed halts × ∀ p → Closed p → ∃ λ (b : Bool) → apply halts (lambda v-underscore p) ⇓ ⌜ b ⌝ × if b then Terminates p else (¬ Terminates p) extensional-halting-problem′ (halts , cl , hyp) = extensional-halting-problem ( halts , cl , λ _ cl-p → ⇓→⇓true cl-p , ¬⇓→⇓false cl-p ) where ⇓→⇓true : ∀ {p} → Closed p → Terminates p → apply halts (lambda v-underscore p) ⇓ ⌜ true ⦂ Bool ⌝ ⇓→⇓true {p} cl p⇓ with hyp p cl ... | true , halts⇓true , _ = halts⇓true ... | false , _ , ¬p⇓ = ⊥-elim (¬p⇓ p⇓) ¬⇓→⇓false : ∀ {p} → Closed p → ¬ Terminates p → apply halts (lambda v-underscore p) ⇓ ⌜ false ⦂ Bool ⌝ ¬⇓→⇓false {p} cl ¬p⇓ with hyp p cl ... | false , halts⇓false , _ = halts⇓false ... | true , _ , p⇓ = ⊥-elim (¬p⇓ p⇓) -- And another variant. extensional-halting-problem″ : ¬ ∃ λ halts → Closed halts × ∀ p → Closed p → ∥ (∃ λ (b : Bool) → apply halts (lambda v-underscore p) ⇓ ⌜ b ⌝ × if b then Terminates p else (¬ Terminates p)) ∥ extensional-halting-problem″ (halts , cl , hyp) = extensional-halting-problem ( halts , cl , λ _ cl-p → ⇓→⇓true cl-p , ¬⇓→⇓false cl-p ) where ⇓→⇓true : ∀ {p} → Closed p → Terminates p → apply halts (lambda v-underscore p) ⇓ ⌜ true ⦂ Bool ⌝ ⇓→⇓true cl p⇓ = flip (Trunc.rec ⇓-propositional) (hyp _ cl) λ where (false , _ , ¬p⇓) → ⊥-elim (¬p⇓ p⇓) (true , halts⇓true , _) → halts⇓true ¬⇓→⇓false : ∀ {p} → Closed p → ¬ Terminates p → apply halts (lambda v-underscore p) ⇓ ⌜ false ⦂ Bool ⌝ ¬⇓→⇓false cl ¬p⇓ = flip (Trunc.rec ⇓-propositional) (hyp _ cl) λ where (true , _ , p⇓) → ⊥-elim (¬p⇓ p⇓) (false , halts⇓false , _) → halts⇓false ------------------------------------------------------------------------ -- The intensional halting problem with arbitrary or non-standard -- coding relations -- A "termination inversion" function, parametrised by a solution to -- the (generalised) intensional halting problem of self application. terminv : Exp → Exp terminv halts = lambda v-x (χ.if apply halts (var v-x) then loop else ⌜ zero ⌝) -- A generalised variant of the intensional halting problem of -- self-application is not decidable. This variant replaces the coding -- function for expressions with an arbitrary relation, restricted so -- that codes have to be values. Furthermore the statement is changed -- to include the assumption that there is a code for a certain -- "strange" program. generalised-intensional-halting-problem-of-self-application : (Code : Exp → ∃ Value → Type) → ¬ ∃ λ halts → Closed halts × ∃ (Code (terminv halts)) × ∀ p c → Closed p → Code p c → let c′ = proj₁ c in (Terminates (apply p c′) → apply halts c′ ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates (apply p c′) → apply halts c′ ⇓ ⌜ false ⦂ Bool ⌝) generalised-intensional-halting-problem-of-self-application Code (halts , cl , (code-strange , cd) , hyp) = contradiction where terminv-lemma : ∀ p c → Closed p → Code p c → Terminates (apply (terminv halts) (proj₁ c)) ⇔ ¬ Terminates (apply p (proj₁ c)) terminv-lemma p (c , c-vl) cl-p cd-p = record { to = to; from = from } where to : Terminates (apply (terminv halts) c) → ¬ Terminates (apply p c) to (_ , apply lambda _ (case _ here [] loop⇓)) p⇓ = ¬loop⇓ (_ , loop⇓) to (_ , apply lambda _ (case _ (there _ (there _ ())) _ _)) p⇓ to (_ , apply lambda rep-p⇓ (case halts⇓false′ (there _ here) [] _)) p⇓ = C.distinct-codes→distinct-names (λ ()) $ proj₁ $ cancel-const $ ⇓-deterministic (proj₁ (hyp p (c , c-vl) cl-p cd-p) p⇓) halts⇓false where halts⇓false : apply halts c ⇓ ⌜ false ⦂ Bool ⌝ halts⇓false rewrite sym $ values-only-compute-to-themselves c-vl rep-p⇓ = subst (λ e → apply e _ ⇓ _) (subst-closed _ _ cl) halts⇓false′ from : ¬ Terminates (apply p c) → Terminates (apply (terminv halts) c) from ¬p⇓ = _ , apply lambda (values-compute-to-themselves c-vl) (case halts⇓false (there (C.distinct-codes→distinct-names (λ ())) here) [] (const [])) where halts⇓false : apply (halts [ v-x ← c ]) c ⇓ ⌜ false ⦂ Bool ⌝ halts⇓false = subst (λ e → apply e _ ⇓ _) (sym $ subst-closed _ _ cl) (proj₂ (hyp p (c , c-vl) cl-p cd-p) ¬p⇓) strange : Exp strange = apply (terminv halts) (proj₁ code-strange) terminv-closed : Closed (terminv halts) terminv-closed = Closed′-closed-under-lambda $ if-then-else-closed (Closed′-closed-under-apply (Closed→Closed′ cl) (Closed′-closed-under-var (inj₁ refl))) (Closed→Closed′ loop-closed) (Closed→Closed′ $ rep-closed zero) strange-lemma : Terminates strange ⇔ ¬ Terminates strange strange-lemma = terminv-lemma (terminv halts) code-strange terminv-closed cd contradiction : ⊥ contradiction = ¬[⇔¬] strange-lemma -- A coding relation: An expression e that terminates is encoded by -- the representation of true, and an expression e that does not -- terminate is encoded by the representation of false. ⇓-coding : Exp → ∃ Value → Type ⇓-coding e (c , _) = Terminates e × c ≡ ⌜ true ⦂ Bool ⌝ ⊎ ¬ Terminates e × c ≡ ⌜ false ⦂ Bool ⌝ -- When this coding relation is used the intensional halting problem -- with zero arguments is decidable. intensional-halting-problem₀-with-⇓-coding : ∃ λ halts → Closed halts × ∀ p (c@(c′ , _) : ∃ Value) → Closed p → ⇓-coding p c → (Terminates p → apply halts c′ ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates p → apply halts c′ ⇓ ⌜ false ⦂ Bool ⌝) intensional-halting-problem₀-with-⇓-coding = halts , halts-closed , halts-correct where halts : Exp halts = lambda v-p (case (var v-p) (branch c-true [] ⌜ true ⦂ Bool ⌝ ∷ branch c-false [] ⌜ false ⦂ Bool ⌝ ∷ [])) halts-closed : Closed halts halts-closed = from-⊎ (closed? halts) halts-correct : ∀ p (c@(c′ , _) : ∃ Value) → Closed p → ⇓-coding p c → (Terminates p → apply halts c′ ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates p → apply halts c′ ⇓ ⌜ false ⦂ Bool ⌝) halts-correct _ (.(⌜ true ⌝) , _) _ (inj₁ (p⇓ , refl)) = (λ _ → apply lambda (rep⇓rep (true ⦂ Bool)) (case (rep⇓rep (true ⦂ Bool)) here [] (rep⇓rep (true ⦂ Bool)))) , (λ ¬p⇓ → ⊥-elim (¬p⇓ p⇓)) halts-correct _ (.(⌜ false ⌝) , _) _ (inj₂ (¬p⇓ , refl)) = (λ p⇓ → ⊥-elim (¬p⇓ p⇓)) , (λ _ → apply lambda (rep⇓rep (false ⦂ Bool)) (case (rep⇓rep (false ⦂ Bool)) (there (λ ()) here) [] (rep⇓rep (false ⦂ Bool)))) ------------------------------------------------------------------------ -- The intensional halting problem -- The intensional halting problem of self-application. (This -- definition is not used below.) Intensional-halting-problem-of-self-application : Closed-exp →Bool Intensional-halting-problem-of-self-application = as-function-to-Bool₁ (λ { (e , _) → Terminates (apply e ⌜ e ⌝) }) -- The intensional halting problem of self-application is not -- decidable. intensional-halting-problem-of-self-application : ¬ ∃ λ halts → Closed halts × ∀ p → Closed p → (Terminates (apply p ⌜ p ⌝) → apply halts ⌜ p ⌝ ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates (apply p ⌜ p ⌝) → apply halts ⌜ p ⌝ ⇓ ⌜ false ⦂ Bool ⌝) intensional-halting-problem-of-self-application (halts , cl , hyp) = generalised-intensional-halting-problem-of-self-application ⌜⌝-Code ( halts , cl , ( ( ⌜ terminv halts ⌝ , const→value (rep-const (terminv halts)) ) , refl ) , λ { p _ cl-p refl → hyp p cl-p } ) where ⌜⌝-Code : Exp → ∃ Value → Type ⌜⌝-Code e (c , _) = ⌜ e ⌝ ≡ c -- The intensional halting problem with one argument is not decidable. intensional-halting-problem₁ : ¬ ∃ λ halts → Closed halts × ∀ p x → Closed p → Closed x → (Terminates (apply p ⌜ x ⌝) → apply halts ⌜ p , x ⌝ ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates (apply p ⌜ x ⌝) → apply halts ⌜ p , x ⌝ ⇓ ⌜ false ⦂ Bool ⌝) intensional-halting-problem₁ (halts , cl , hyp) = intensional-halting-problem-of-self-application ( halts′ , cl′ , λ p cl-p → Σ-map (lemma p true ∘_) (lemma p false ∘_) (hyp p p cl-p cl-p) ) where arg = const c-pair (var v-p ∷ var v-p ∷ []) halts′ = lambda v-p (apply halts arg) cl′ : Closed halts′ cl′ = Closed′-closed-under-lambda $ Closed′-closed-under-apply (Closed→Closed′ cl) (from-⊎ (closed′? arg (v-p ∷ []))) lemma : (p : Exp) (b : Bool) → apply halts ⌜ p , p ⌝ ⇓ ⌜ b ⌝ → apply halts′ ⌜ p ⌝ ⇓ ⌜ b ⌝ lemma p b halts⇓ = apply halts′ ⌜ p ⌝ ⟶⟨ apply lambda (rep⇓rep p) ⟩ apply ⟨ halts [ v-p ← ⌜ p ⌝ ] ⟩ ⌜ p , p ⌝ ≡⟨ ⟨by⟩ (subst-closed _ _ cl) ⟩⟶ apply halts ⌜ p , p ⌝ ⇓⟨ halts⇓ ⟩■ ⌜ b ⌝ -- The intensional halting problem with zero arguments is not -- decidable. intensional-halting-problem₀ : ¬ ∃ λ halts → Closed halts × ∀ p → Closed p → (Terminates p → apply halts ⌜ p ⌝ ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates p → apply halts ⌜ p ⌝ ⇓ ⌜ false ⦂ Bool ⌝) intensional-halting-problem₀ (halts , cl , hyp) = intensional-halting-problem-of-self-application ( halts′ , cl′ , λ p cl-p → Σ-map (lemma p true ∘_) (lemma p false ∘_) (hyp (apply p ⌜ p ⌝) (Closed′-closed-under-apply (Closed→Closed′ cl-p) (Closed→Closed′ (rep-closed p)))) ) where halts′ = lambda v-p (apply halts ( const c-apply (var v-p ∷ apply internal-code (var v-p) ∷ []))) cl′ : Closed halts′ cl′ = Closed′-closed-under-lambda $ Closed′-closed-under-apply (Closed→Closed′ cl) (Closed′-closed-under-const (λ { _ (inj₁ refl) → Closed′-closed-under-var (inj₁ refl) ; _ (inj₂ (inj₁ refl)) → Closed′-closed-under-apply (Closed→Closed′ internal-code-closed) (Closed′-closed-under-var (inj₁ refl)) ; _ (inj₂ (inj₂ ())) })) abstract lemma : (p : Exp) (b : Bool) → apply halts ⌜ Exp.apply p ⌜ p ⌝ ⌝ ⇓ ⌜ b ⌝ → apply halts′ ⌜ p ⌝ ⇓ ⌜ b ⌝ lemma p b halts⇓ = apply halts′ ⌜ p ⌝ ⟶⟨ apply lambda (rep⇓rep p) ⟩ apply ⟨ halts [ v-p ← ⌜ p ⌝ ] ⟩ (const c-apply ( ⌜ p ⌝ ∷ apply (internal-code [ v-p ← ⌜ p ⌝ ]) ⌜ p ⌝ ∷ [])) ≡⟨ ⟨by⟩ (subst-closed _ _ cl) ⟩⟶ apply halts (const c-apply ( ⌜ p ⌝ ∷ apply ⟨ internal-code [ v-p ← ⌜ p ⌝ ] ⟩ ⌜ p ⌝ ∷ [])) ≡⟨ ⟨by⟩ (subst-closed v-p ⌜ p ⌝ internal-code-closed) ⟩⟶ apply halts (const c-apply ( ⌜ p ⌝ ∷ apply internal-code ⌜ p ⌝ ∷ [])) ⟶⟨ []⇓ (apply→ ∙) (const (rep⇓rep p ∷ internal-code-correct p ∷ [])) ⟩ apply halts (const c-apply (⌜ p ⌝ ∷ ⌜ ⌜ p ⌝ ⦂ Exp ⌝ ∷ [])) ⟶⟨⟩ apply halts ⌜ Exp.apply p ⌜ p ⌝ ⌝ ⇓⟨ halts⇓ ⟩■ ⌜ b ⌝ -- Two statements of the intensional halting problem with zero -- arguments. Intensional-halting-problem₀₁ : Closed-exp →Bool Intensional-halting-problem₀₁ = as-function-to-Bool₁ (Terminates ∘ proj₁) Intensional-halting-problem₀₂ : Closed-exp →Bool Intensional-halting-problem₀₂ = as-function-to-Bool₂ (Terminates ∘ proj₁) Terminates-propositional -- The first variant is not decidable. intensional-halting-problem₀₁ : ¬ Decidable Intensional-halting-problem₀₁ intensional-halting-problem₀₁ (halts , cl , hyp , _) = intensional-halting-problem₀ ( halts , cl , λ p cl-p → (λ p⇓ → apply halts ⌜ p ⌝ ⇓⟨ hyp (p , cl-p) true ((λ _ → refl) , λ ¬p⇓ → ⊥-elim (¬p⇓ p⇓)) ⟩■ ⌜ true ⦂ Bool ⌝) , λ ¬p⇓ → apply halts ⌜ p ⌝ ⇓⟨ hyp (p , cl-p) false ((λ p⇓ → ⊥-elim (¬p⇓ p⇓)) , λ _ → refl) ⟩■ ⌜ false ⦂ Bool ⌝ ) -- The second variant is not decidable. intensional-halting-problem₀₂ : ¬ Decidable Intensional-halting-problem₀₂ intensional-halting-problem₀₂ (halts , cl , hyp , _) = intensional-halting-problem₀ ( halts , cl , λ p cl-p → (λ p⇓ → apply halts ⌜ p ⌝ ⇓⟨ hyp (p , cl-p) true (inj₁ (p⇓ , refl)) ⟩■ ⌜ true ⦂ Bool ⌝) , (λ ¬p⇓ → apply halts ⌜ p ⌝ ⇓⟨ hyp (p , cl-p) false (inj₂ (¬p⇓ , refl)) ⟩■ ⌜ false ⦂ Bool ⌝) ) -- Under the assumption of excluded middle one can prove that -- Intensional-halting-problem₀₁ and Intensional-halting-problem₀₂ are -- pointwise equal. Intensional-halting-problem₀₂→Intensional-halting-problem₀₁ : ∀ {e b} → proj₁ Intensional-halting-problem₀₂ [ e ]= b → proj₁ Intensional-halting-problem₀₁ [ e ]= b Intensional-halting-problem₀₂→Intensional-halting-problem₀₁ (inj₁ (e⇓ , refl)) = (λ _ → refl) , (⊥-elim ∘ (_$ e⇓)) Intensional-halting-problem₀₂→Intensional-halting-problem₀₁ (inj₂ (¬e⇓ , refl)) = (⊥-elim ∘ ¬e⇓) , λ _ → refl Intensional-halting-problem₀₁→Intensional-halting-problem₀₂ : (excluded-middle : (P : Type) → Is-proposition P → Dec P) → ∀ {e} b → proj₁ Intensional-halting-problem₀₁ [ e ]= b → proj₁ Intensional-halting-problem₀₂ [ e ]= b Intensional-halting-problem₀₁→Intensional-halting-problem₀₂ em = λ where true (_ , ¬¬e⇓) → inj₁ ( double-negation-elimination Terminates-propositional (Bool.true≢false ∘ ¬¬e⇓) , refl ) false (¬e⇓ , _) → inj₂ ( Bool.true≢false ∘ sym ∘ ¬e⇓ , refl ) where double-negation-elimination : {P : Type} → Is-proposition P → ¬ ¬ P → P double-negation-elimination P-prop ¬¬p = case em _ P-prop of λ where (inj₁ p) → p (inj₂ ¬p) → ⊥-elim (¬¬p ¬p) ------------------------------------------------------------------------ -- "Half of the halting problem" -- If a (correct) self-interpreter can be implemented, then "half of -- the halting problem" is computable. half-of-the-halting-problem : (eval : Exp) → Closed eval → (∀ p v → Closed p → p ⇓ v → apply eval ⌜ p ⌝ ⇓ ⌜ v ⌝) → (∀ p → Closed p → ¬ Terminates p → ¬ Terminates (apply eval ⌜ p ⌝)) → ∃ λ halts → Closed halts × ∀ p → Closed p → (Terminates p → apply halts ⌜ p ⌝ ⇓ ⌜ true ⦂ Bool ⌝) × (¬ Terminates p → ¬ Terminates (apply halts ⌜ p ⌝)) half-of-the-halting-problem eval cl eval⇓ eval¬⇓ = halts , cl′ , λ p cl-p → lemma₁ p cl-p , lemma₂ p cl-p module Half-of-the-halting-problem where halts = lambda v-p (apply (lambda v-underscore ⌜ true ⦂ Bool ⌝) (apply eval (var v-p))) cl′ : Closed halts cl′ = Closed′-closed-under-lambda $ Closed′-closed-under-apply (from-⊎ (closed′? (lambda v-underscore ⌜ true ⦂ Bool ⌝) _)) (Closed′-closed-under-apply (Closed→Closed′ cl) (Closed′-closed-under-var (inj₁ refl))) lemma₁ : ∀ p → Closed p → Terminates p → apply halts ⌜ p ⌝ ⇓ ⌜ true ⦂ Bool ⌝ lemma₁ p cl-p (v , p⇓v) = apply halts ⌜ p ⌝ ⟶⟨ apply lambda (rep⇓rep p) ⟩ apply (lambda v-underscore ⌜ true ⦂ Bool ⌝) (apply ⟨ eval [ v-p ← ⌜ p ⌝ ] ⟩ ⌜ p ⌝) ≡⟨ ⟨by⟩ (subst-closed _ _ cl) ⟩⟶ apply (lambda v-underscore ⌜ true ⦂ Bool ⌝) (apply eval ⌜ p ⌝) ⇓⟨ apply lambda (eval⇓ p v cl-p p⇓v) (rep⇓rep (true ⦂ Bool)) ⟩■ ⌜ true ⦂ Bool ⌝ halts-eval-inversion : ∀ e → Terminates (apply halts e) → Terminates (apply eval e) halts-eval-inversion e (_ , apply {v₂ = v} lambda e⇓ (apply {v₂ = v₂} _ eval⇓ _)) = _ , (apply eval e ⟶⟨ []⇓ (apply→ ∙) e⇓ ⟩ apply eval v ≡⟨ by (subst-closed _ _ cl) ⟩⟶ apply (eval [ v-p ← v ]) v ⇓⟨ eval⇓ ⟩■ v₂) lemma₂ : ∀ p → Closed p → ¬ Terminates p → ¬ Terminates (apply halts ⌜ p ⌝) lemma₂ p cl-p ¬p⇓ = Terminates (apply halts ⌜ p ⌝) ↝⟨ halts-eval-inversion ⌜ p ⌝ ⟩ Terminates (apply eval ⌜ p ⌝) ↝⟨ eval¬⇓ p cl-p ¬p⇓ ⟩□ ⊥ □ -- Two statements of "half of the halting problem". Half-of-the-halting-problem₁ : Closed-exp ⇀ Bool Half-of-the-halting-problem₁ = as-partial-function-to-Bool₁ (Terminates ∘ proj₁) Half-of-the-halting-problem₂ : Closed-exp ⇀ Bool Half-of-the-halting-problem₂ = as-partial-function-to-Bool₂ (Terminates ∘ proj₁) Terminates-propositional -- If a (correct) self-interpreter can be implemented, then -- Half-of-the-halting-problem₂ is computable. half-of-the-halting-problem₂ : (eval : Exp) → Closed eval → (∀ p v → Closed p → p ⇓ v → apply eval ⌜ p ⌝ ⇓ ⌜ v ⌝) → (∀ p v → Closed p → apply eval ⌜ p ⌝ ⇓ v → ∃ λ v′ → p ⇓ v′ × v ≡ ⌜ v′ ⌝) → Computable Half-of-the-halting-problem₂ half-of-the-halting-problem₂ eval cl eval₁ eval₂ = H.halts , H.cl′ , (λ { (p , cl-p) .true (p⇓ , refl) → H.lemma₁ p cl-p p⇓ }) , (λ { (p , cl-p) v halts⌜p⌝⇓v → true , Σ-map (_, refl) id (lemma₂ p v cl-p halts⌜p⌝⇓v) }) where eval-inversion : ∀ p → Closed p → Terminates (apply eval ⌜ p ⌝) → Terminates p eval-inversion p cl-p = Σ-map id proj₁ ∘ eval₂ p _ cl-p ∘ proj₂ module H = Half-of-the-halting-problem eval cl eval₁ (λ { p cl-p ¬p⇓ → Terminates (apply eval ⌜ p ⌝) ↝⟨ eval-inversion p cl-p ⟩ Terminates p ↝⟨ ¬p⇓ ⟩□ ⊥ □ }) lemma₂ : ∀ p v → Closed p → apply H.halts ⌜ p ⌝ ⇓ v → Terminates p × v ≡ ⌜ true ⦂ Bool ⌝ lemma₂ p v cl-p q@(apply lambda _ (apply lambda _ (const []))) = ( $⟨ _ , q ⟩ Terminates (apply H.halts ⌜ p ⌝) ↝⟨ H.halts-eval-inversion ⌜ p ⌝ ⟩ Terminates (apply eval ⌜ p ⌝) ↝⟨ eval-inversion p cl-p ⟩□ Terminates p □) , refl ------------------------------------------------------------------------ -- Halting with zero -- If the expression terminates with ⌜ zero ⌝ as the result, then this -- (total partial) function returns true. If the expression does not -- terminate with ⌜ zero ⌝ as the result, then the function returns -- false. Halts-with-zero : Closed-exp →Bool Halts-with-zero = as-function-to-Bool₁ (λ { (e , _) → e ⇓ ⌜ zero ⌝ }) -- Halts-with-zero is not decidable. halts-with-zero : ¬ Decidable Halts-with-zero halts-with-zero = Reduction→¬Computable→¬Computable (proj₁ Intensional-halting-problem₀₁) (proj₁ Halts-with-zero) red intensional-halting-problem₀₁ where red : Reduction (proj₁ Intensional-halting-problem₀₁) (proj₁ Halts-with-zero) red (halts-with-zero , cl , hyp₁ , hyp₂) = halts , cl-halts , hyp₁′ , hyp₂′ where argument : Closed-exp → Closed-exp argument (p , cl-p) = apply (lambda v-x (const c-zero [])) p , (Closed′-closed-under-apply (from-⊎ (closed′? (lambda v-x (const c-zero [])) [])) (Closed→Closed′ cl-p)) coded-argument : Exp → Exp coded-argument p = const c-apply ( ⌜ Exp.lambda v-x (const c-zero []) ⌝ ∷ p ∷ []) halts : Exp halts = lambda v-p (apply halts-with-zero (coded-argument (var v-p))) cl-halts : Closed halts cl-halts = Closed′-closed-under-lambda $ Closed′-closed-under-apply (Closed→Closed′ cl) (Closed′-closed-under-const λ where _ (inj₁ refl) → Closed→Closed′ $ rep-closed (Exp.lambda v-x (const c-zero [])) _ (inj₂ (inj₁ refl)) → Closed′-closed-under-var (inj₁ refl) _ (inj₂ (inj₂ ()))) lemma₁ : ∀ p b → proj₁ Intensional-halting-problem₀₁ [ p ]= b → proj₁ Halts-with-zero [ argument p ]= b lemma₁ p true (_ , ¬¬p⇓) = (λ _ → refl) , λ ¬arg-p⇓zero → ¬¬p⇓ λ p⇓ → ¬arg-p⇓zero (proj₁ (argument p) ⇓⟨ apply lambda (proj₂ p⇓) (const []) ⟩■ const c-zero []) lemma₁ p false (¬p⇓ , _) = (λ { (apply _ p⇓ _) → ¬p⇓ (_ , p⇓) }) , λ _ → refl hyp₁′ : ∀ p b → proj₁ Intensional-halting-problem₀₁ [ p ]= b → apply halts ⌜ p ⌝ ⇓ ⌜ b ⌝ hyp₁′ p b halts[p]=b = apply halts ⌜ p ⌝ ⟶⟨ apply lambda (rep⇓rep p) ⟩ apply ⟨ halts-with-zero [ v-p ← ⌜ p ⌝ ] ⟩ (coded-argument ⌜ p ⌝) ≡⟨ ⟨by⟩ (subst-closed _ _ cl) ⟩⟶ apply halts-with-zero (coded-argument ⌜ p ⌝) ⟶⟨⟩ apply halts-with-zero ⌜ argument p ⌝ ⇓⟨ hyp₁ (argument p) b (lemma₁ p _ halts[p]=b) ⟩■ ⌜ b ⌝ pattern coded-argument-⇓ p = const (const (const (const (const (const [] ∷ []) ∷ []) ∷ []) ∷ const (const [] ∷ const [] ∷ []) ∷ []) ∷ p ∷ []) lemma₂ : ∀ p v → apply halts ⌜ p ⌝ ⇓ v → apply halts-with-zero ⌜ argument p ⌝ ⇓ v lemma₂ p v (apply {v₂ = v₂} lambda q r) = apply ⟨ halts-with-zero ⟩ ⌜ argument p ⌝ ≡⟨ ⟨by⟩ (subst-closed _ _ cl) ⟩⟶ apply (halts-with-zero [ v-p ← v₂ ]) (coded-argument ⌜ p ⌝) ⟶⟨ []⇓ (apply→ ∙) (coded-argument-⇓ q) ⟩ apply (halts-with-zero [ v-p ← v₂ ]) (coded-argument v₂) ⇓⟨ r ⟩■ v hyp₂′ : ∀ p v → apply halts ⌜ p ⌝ ⇓ v → ∃ λ v′ → proj₁ Intensional-halting-problem₀₁ [ p ]= v′ × v ≡ ⌜ v′ ⌝ hyp₂′ p v q = Σ-map id (Σ-map (Σ-map (_∘ λ p⇓ → apply lambda (proj₂ p⇓) (const [])) (_∘ λ ¬p⇓ → λ { (apply lambda p⇓ (const [])) → ¬p⇓ (_ , p⇓) })) id) $ hyp₂ (argument p) v (lemma₂ p v q)
{ "alphanum_fraction": 0.5252252918, "avg_line_length": 33.887359199, "ext": "agda", "hexsha": "cf0b4e7eb8767e787179c2016a971ac5c159d2e9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/chi", "max_forks_repo_path": "src/Halting-problem.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/chi", "max_issues_repo_path": "src/Halting-problem.agda", "max_line_length": 140, "max_stars_count": 2, "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/chi", "max_stars_repo_path": "src/Halting-problem.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "num_tokens": 9582, "size": 27076 }
module IrrelevantLambda where postulate A : Set P : .A -> Set f : ._ -> Set f = λ .x -> P x f' = λ .(x : _) -> P x f'' = λ .{x y z : _} -> P x g : ((.A -> Set) -> Set) -> Set g k = k f
{ "alphanum_fraction": 0.4307692308, "avg_line_length": 12.1875, "ext": "agda", "hexsha": "1b875ca296d9633a23ece71fa6cc80140ab2aaad", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "test/succeed/IrrelevantLambda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dagit/agda", "max_issues_repo_path": "test/succeed/IrrelevantLambda.agda", "max_line_length": 31, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/IrrelevantLambda.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 87, "size": 195 }
module Golden.InsertionSort where open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Bool insert : Nat -> List Nat -> List Nat insert a [] = a ∷ [] insert x (a ∷ b) with x < a ... | true = x ∷ a ∷ b ... | false = a ∷ (insert x b) foldr : ∀ {a b : Set} → (a → b → b) → b → List a -> b foldr f ini [] = ini foldr f ini (x ∷ l) = f x (foldr f ini l) insertSort : List Nat -> List Nat insertSort = foldr insert [] atDef : ∀ {a : Set} → a → List a -> Nat -> a atDef def (x ∷ l) zero = x atDef def (x ∷ l) (suc ix) = atDef def l ix atDef def _ _ = def lst : List Nat lst = 4 ∷ 2 ∷ 7 ∷ [] slst : List Nat slst = insertSort lst l0 : Nat l0 = atDef 0 slst 0 l1 : Nat l1 = atDef 0 slst 1 l2 : Nat l2 = atDef 0 slst 2
{ "alphanum_fraction": 0.5893333333, "avg_line_length": 19.2307692308, "ext": "agda", "hexsha": "5c1f2bddf098becec4ac38ce962a5726228749f6", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:48.000Z", "max_forks_repo_forks_event_min_datetime": "2018-05-24T10:45:59.000Z", "max_forks_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-ocaml", "max_forks_repo_path": "test/agda-ocaml/Golden/InsertionSort.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_issues_repo_issues_event_max_datetime": "2018-11-05T21:28:57.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-29T13:37:52.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-ocaml", "max_issues_repo_path": "test/agda-ocaml/Golden/InsertionSort.agda", "max_line_length": 53, "max_stars_count": 48, "max_stars_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-ocaml", "max_stars_repo_path": "test/agda-ocaml/Golden/InsertionSort.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-15T09:08:14.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-29T14:19:31.000Z", "num_tokens": 302, "size": 750 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Universe levels ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Level where -- Levels. open import Agda.Primitive as Prim public using (Level; _⊔_) renaming (lzero to zero; lsuc to suc) -- Lifting. record Lift {a} ℓ (A : Set a) : Set (a ⊔ ℓ) where constructor lift field lower : A open Lift public -- Synonyms 0ℓ : Level 0ℓ = zero
{ "alphanum_fraction": 0.469581749, "avg_line_length": 18.1379310345, "ext": "agda", "hexsha": "b2a8bc33a30c892936780d60f6ed744710532bcf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Level.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Level.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Level.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 123, "size": 526 }
{-# OPTIONS --safe #-} module Cubical.Algebra.MonoidSolver.Solver where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Data.FinData using (Fin) open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.List open import Cubical.Data.Vec using (Vec; lookup) open import Cubical.Algebra.Monoid open import Cubical.Algebra.MonoidSolver.MonoidExpression private variable ℓ : Level module Eval (M : Monoid ℓ) where open MonoidStr (snd M) Env : ℕ → Type ℓ Env n = Vec ⟨ M ⟩ n -- evaluation of an expression (without normalization) ⟦_⟧ : ∀{n} → Expr ⟨ M ⟩ n → Env n → ⟨ M ⟩ ⟦ ε⊗ ⟧ v = ε ⟦ ∣ i ⟧ v = lookup i v ⟦ e₁ ⊗ e₂ ⟧ v = ⟦ e₁ ⟧ v · ⟦ e₂ ⟧ v NormalForm : ℕ → Type _ NormalForm n = List (Fin n) -- normalization of an expression normalize : ∀{n} → Expr ⟨ M ⟩ n → NormalForm n normalize (∣ i) = i ∷ [] normalize ε⊗ = [] normalize (e₁ ⊗ e₂) = (normalize e₁) ++ (normalize e₂) -- evaluation of normalform eval : ∀ {n} → NormalForm n → Env n → ⟨ M ⟩ eval [] v = ε eval (x ∷ xs) v = (lookup x v) · (eval xs v) -- some calculation evalIsHom : ∀ {n} (x y : NormalForm n) (v : Env n) → eval (x ++ y) v ≡ eval x v · eval y v evalIsHom [] y v = sym (·IdL _) evalIsHom (x ∷ xs) y v = cong (λ m → (lookup x v) · m) (evalIsHom xs y v) ∙ ·Assoc _ _ _ module EqualityToNormalform (M : Monoid ℓ) where open Eval M open MonoidStr (snd M) -- proof that evaluation of an expression is invariant under normalization isEqualToNormalform : (n : ℕ) → (e : Expr ⟨ M ⟩ n) → (v : Env n) → eval (normalize e) v ≡ ⟦ e ⟧ v isEqualToNormalform n (∣ i) v = ·IdR _ isEqualToNormalform n ε⊗ v = refl isEqualToNormalform n (e₁ ⊗ e₂) v = eval ((normalize e₁) ++ (normalize e₂)) v ≡⟨ evalIsHom (normalize e₁) (normalize e₂) v ⟩ (eval (normalize e₁) v) · (eval (normalize e₂) v) ≡⟨ cong₂ _·_ (isEqualToNormalform n e₁ v) (isEqualToNormalform n e₂ v) ⟩ ⟦ e₁ ⟧ v · ⟦ e₂ ⟧ v ∎ solve : {n : ℕ} → (e₁ e₂ : Expr ⟨ M ⟩ n) → (v : Env n) → (p : eval (normalize e₁) v ≡ eval (normalize e₂) v) → ⟦ e₁ ⟧ v ≡ ⟦ e₂ ⟧ v solve e₁ e₂ v p = ⟦ e₁ ⟧ v ≡⟨ sym (isEqualToNormalform _ e₁ v) ⟩ eval (normalize e₁) v ≡⟨ p ⟩ eval (normalize e₂) v ≡⟨ isEqualToNormalform _ e₂ v ⟩ ⟦ e₂ ⟧ v ∎ solve : (M : Monoid ℓ) {n : ℕ} (e₁ e₂ : Expr ⟨ M ⟩ n) (v : Eval.Env M n) (p : Eval.eval M (Eval.normalize M e₁) v ≡ Eval.eval M (Eval.normalize M e₂) v) → _ solve M = EqualityToNormalform.solve M
{ "alphanum_fraction": 0.5578256111, "avg_line_length": 31.5057471264, "ext": "agda", "hexsha": "ee962b12a3b059c1242cd047e0320772eaf84306", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/MonoidSolver/Solver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/MonoidSolver/Solver.agda", "max_line_length": 126, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/MonoidSolver/Solver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 980, "size": 2741 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Homotopy.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv.Properties private variable ℓ ℓ' : Level _∼_ : {X : Type ℓ} {Y : X → Type ℓ'} → (f g : (x : X) → Y x) → Type (ℓ-max ℓ ℓ') _∼_ {X = X} f g = (x : X) → f x ≡ g x funExt∼ : {X : Type ℓ} {Y : X → Type ℓ'} {f g : (x : X) → Y x} (H : f ∼ g) → f ≡ g funExt∼ = funExt ∼-refl : {X : Type ℓ} {Y : X → Type ℓ'} {f : (x : X) → Y x} → f ∼ f ∼-refl {f = f} = λ x → refl {x = f x}
{ "alphanum_fraction": 0.5258302583, "avg_line_length": 27.1, "ext": "agda", "hexsha": "b28d357357eb4c8c33ea11b3ed75914d8d3dbcad", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Homotopy/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Homotopy/Base.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Homotopy/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 247, "size": 542 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Categories.Exercises where open import Prelude open import Categories open Category ⦃ ... ⦄ open import Categories.Product open Product public open HasProducts ⦃ ... ⦄ public -- module _ {ℓ₁} {ℓ₂} ⦃ c : Category ℓ₁ ℓ₂ ⦄ ⦃ hp : HasProducts c ⦄ where -- ex17 : (t : Terminal) (x : Ob) → Product.obj (product (fst t) x) ≅ x -- ex17 t x .fst = proj₂ (product (fst t) x) -- ex17 t x .snd .fst = ump (product (fst t) x) (t .snd .fst) Id .fst -- ex17 t x .snd .snd .fst = let p = ump (product (fst t) x) (t .snd .fst) Id .snd .snd ({!!} , {!!}) in {!!} -- ex17 t x .snd .snd .snd = {!!}
{ "alphanum_fraction": 0.5990853659, "avg_line_length": 34.5263157895, "ext": "agda", "hexsha": "5cf1ea892a374826c595f23b8e491bd6c6f6f0ea", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Categories/Exercises.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Categories/Exercises.agda", "max_line_length": 111, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Categories/Exercises.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 241, "size": 656 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Multiplication open import Semirings.Definition open import Rings.Definition open import Setoids.Setoids module Numbers.Integers.RingStructure.Ring where open import Numbers.Integers.Definition public open import Numbers.Integers.Addition public open import Numbers.Integers.Multiplication public *ZCommutative : (a b : ℤ) → a *Z b ≡ b *Z a *ZCommutative (nonneg x) (nonneg y) = applyEquality nonneg (multiplicationNIsCommutative x y) *ZCommutative (nonneg zero) (negSucc y) = refl *ZCommutative (nonneg (succ x)) (negSucc y) = refl *ZCommutative (negSucc x) (nonneg zero) = refl *ZCommutative (negSucc x) (nonneg (succ y)) = refl *ZCommutative (negSucc x) (negSucc y) = applyEquality nonneg (multiplicationNIsCommutative (succ x) (succ y)) *ZleftIdent : (a : ℤ) → (nonneg 1) *Z a ≡ a *ZleftIdent (nonneg x) = applyEquality nonneg (Semiring.commutative ℕSemiring x 0) *ZleftIdent (negSucc x) = applyEquality negSucc (transitivity (Semiring.commutative ℕSemiring (x +N 0) 0) (Semiring.commutative ℕSemiring x 0)) *ZrightIdent : (a : ℤ) → a *Z (nonneg 1) ≡ a *ZrightIdent (nonneg x) = applyEquality nonneg (Semiring.productOneRight ℕSemiring x) *ZrightIdent (negSucc x) = applyEquality negSucc (transitivity (Semiring.commutative ℕSemiring (x +N 0) 0) (Semiring.commutative ℕSemiring x 0)) *ZZeroLeft : (a : ℤ) → nonneg 0 *Z a ≡ nonneg 0 *ZZeroLeft (nonneg x) = refl *ZZeroLeft (negSucc x) = refl *ZZeroRight : (a : ℤ) → a *Z nonneg 0 ≡ nonneg 0 *ZZeroRight (nonneg x) = applyEquality nonneg (Semiring.productZeroRight ℕSemiring x) *ZZeroRight (negSucc x) = refl *ZAssociative : (a b c : ℤ) → a *Z (b *Z c) ≡ (a *Z b) *Z c *ZAssociative (nonneg zero) b c = transitivity (*ZZeroLeft (b *Z c)) (transitivity (equalityCommutative (*ZZeroLeft c)) (applyEquality (_*Z c) (equalityCommutative (*ZZeroLeft b)))) *ZAssociative (nonneg (succ a)) (nonneg zero) c rewrite Semiring.productZeroRight ℕSemiring a | *ZZeroLeft c | Semiring.productZeroRight ℕSemiring a = refl *ZAssociative (nonneg (succ a)) (nonneg (succ b)) (nonneg zero) rewrite Semiring.productZeroRight ℕSemiring b | Semiring.productZeroRight ℕSemiring (b +N a *N succ b) | Semiring.productZeroRight ℕSemiring a = refl *ZAssociative (nonneg (succ a)) (nonneg (succ b)) (nonneg (succ c)) = applyEquality nonneg (Semiring.*Associative ℕSemiring (succ a) (succ b) (succ c)) *ZAssociative (nonneg (succ a)) (nonneg (succ b)) (negSucc x) rewrite productDistributes' b (a *N succ b) x | Semiring.+Associative ℕSemiring x (b *N x) ((a *N succ b) *N x) | equalityCommutative (Semiring.+Associative ℕSemiring ((x +N b *N x) +N b) (a *N ((x +N b *N x) +N b)) a) | equalityCommutative (Semiring.+Associative ℕSemiring (x +N b *N x) ((a *N succ b) *N x) (b +N a *N succ b)) | equalityCommutative (Semiring.+Associative ℕSemiring (x +N b *N x) b (a *N ((x +N b *N x) +N b) +N a)) = applyEquality (λ i → negSucc ((x +N b *N x) +N i)) ans where ans3 : (succ b +N (succ b *N x)) *N a ≡ succ x *N (a *N succ b) ans3 rewrite multiplicationNIsCommutative (succ b) x = transitivity (equalityCommutative (Semiring.*Associative ℕSemiring (succ x) (succ b) a)) (applyEquality (succ x *N_) (multiplicationNIsCommutative (succ b) a)) ans2 : a *N ((x +N b *N x) +N b) +N a ≡ (a *N succ b) +N (a *N succ b) *N x ans2 rewrite multiplicationNIsCommutative (a *N succ b) x | Semiring.commutative ℕSemiring (succ b *N x) b | multiplicationNIsCommutative a (b +N (succ b *N x)) | Semiring.commutative ℕSemiring ((b +N (succ b *N x)) *N a) a = ans3 ans : b +N (a *N ((x +N b *N x) +N b) +N a) ≡ (a *N succ b) *N x +N (b +N a *N succ b) ans rewrite Semiring.commutative ℕSemiring ((a *N succ b) *N x) (b +N a *N succ b) | equalityCommutative (Semiring.+Associative ℕSemiring b (a *N succ b) ((a *N succ b) *N x)) = applyEquality (b +N_) ans2 *ZAssociative (nonneg (succ a)) (negSucc b) (nonneg zero) = applyEquality nonneg (Semiring.productZeroRight ℕSemiring a) *ZAssociative (nonneg (succ a)) (negSucc b) (nonneg (succ c)) = applyEquality negSucc ans where ans4 : (b +N b *N c) +N (a *N b +N (a *N b) *N c) ≡ (b +N a *N b) +N (b *N c +N (a *N b) *N c) ans4 rewrite Semiring.+Associative ℕSemiring (b +N b *N c) (a *N b) ((a *N b) *N c) | Semiring.+Associative ℕSemiring (b +N a *N b) (b *N c) ((a *N b) *N c) = applyEquality (_+N (a *N b) *N c) (transitivity (transitivity (applyEquality (_+N a *N b) (Semiring.commutative ℕSemiring b (b *N c))) (equalityCommutative (Semiring.+Associative ℕSemiring (b *N c) b (a *N b)))) (Semiring.commutative ℕSemiring (b *N c) (b +N a *N b))) ans3 : ((b +N b *N c) +N (a *N b +N (a *N b) *N c)) +N ((c +N a *N c) +N a) ≡ ((b +N a *N b) +N (b *N c +N (a *N b) *N c)) +N ((a +N a *N c) +N c) ans3 rewrite Semiring.commutative ℕSemiring (c +N a *N c) a | Semiring.commutative ℕSemiring c (a *N c) | Semiring.+Associative ℕSemiring a (a *N c) c = applyEquality (λ i → i +N ((a +N a *N c) +N c)) {(b +N b *N c) +N (a *N b +N (a *N b) *N c)} {(b +N a *N b) +N (b *N c +N (a *N b) *N c)} ans4 ans2 : (((b +N c *N b) +N (a *N b +N a *N (c *N b))) +N (c +N a *N c)) +N a ≡ (((b +N a *N b) +N (c *N b +N c *N (a *N b))) +N (a +N c *N a)) +N c ans2 rewrite multiplicationNIsCommutative c b | multiplicationNIsCommutative c (a *N b) | Semiring.*Associative ℕSemiring a b c | multiplicationNIsCommutative c a = transitivity (equalityCommutative (Semiring.+Associative ℕSemiring ((b +N b *N c) +N (a *N b +N (a *N b) *N c)) (c +N a *N c) a)) (transitivity ans3 (Semiring.+Associative ℕSemiring ((b +N a *N b) +N (b *N c +N (a *N b) *N c)) (a +N a *N c) c)) ans : succ a *N ((succ c *N b) +N c) +N a ≡ succ c *N ((succ a *N b) +N a) +N c ans = transitivity (applyEquality (_+N a) (productDistributes (succ a) (succ c *N b) c)) (transitivity (transitivity (applyEquality (λ i → ((((b +N c *N b) +N i) +N (c +N a *N c)) +N a)) (productDistributes a b (c *N b))) (transitivity ans2 (applyEquality (λ i → (((b +N a *N b) +N i) +N (a +N c *N a)) +N c) (equalityCommutative (productDistributes c b (a *N b)))))) (applyEquality (_+N c) (equalityCommutative (productDistributes (succ c) (succ a *N b) a)))) *ZAssociative (nonneg (succ a)) (negSucc b) (negSucc x) = applyEquality nonneg ans where ans : succ a *N (succ b *N succ x) ≡ succ ((succ a *N b) +N a) *N succ x ans rewrite Semiring.commutative ℕSemiring (succ a *N b) a | multiplicationNIsCommutative (succ a) b = transitivity (Semiring.*Associative ℕSemiring (succ a) (succ b) (succ x)) (applyEquality (_*N succ x) {succ a *N succ b} {succ b *N succ a} (multiplicationNIsCommutative (succ a) (succ b))) *ZAssociative (negSucc a) (nonneg zero) c rewrite *ZZeroLeft c = refl *ZAssociative (negSucc a) (nonneg (succ b)) (nonneg zero) rewrite multiplicationNIsCommutative b 0 = refl *ZAssociative (negSucc a) (nonneg (succ b)) (nonneg (succ c)) = applyEquality negSucc ans where ans2 : (d : ℕ) → ((succ b *N d) *N a) +N b *N d ≡ d *N ((succ b *N a) +N b) ans2 d = transitivity (transitivity (applyEquality (((d +N b *N d) *N a) +N_) (multiplicationNIsCommutative b d)) (applyEquality (_+N d *N b) (transitivity (applyEquality (_*N a) {d +N b *N d} {d *N succ b} (multiplicationNIsCommutative (succ b) d)) (equalityCommutative (Semiring.*Associative ℕSemiring d (succ b) a))))) (equalityCommutative (Semiring.+DistributesOver* ℕSemiring d (succ b *N a) b)) ans : (succ (c +N b *N succ c) *N a) +N (c +N b *N succ c) ≡ (succ c *N ((succ b *N a) +N b)) +N c ans rewrite Semiring.commutative ℕSemiring c (b *N succ c) | Semiring.+Associative ℕSemiring (succ (b *N succ c +N c) *N a) (b *N succ c) c | Semiring.commutative ℕSemiring (b *N succ c) c = applyEquality (_+N c) (ans2 (succ c)) *ZAssociative (negSucc a) (nonneg (succ b)) (negSucc c) = applyEquality nonneg ans where ans : succ a *N ((succ ((succ b) *N c)) +N b) ≡ (succ (succ b *N a) +N b) *N succ c ans rewrite Semiring.commutative ℕSemiring (succ b *N a) b | multiplicationNIsCommutative (succ b) a = transitivity (applyEquality (succ a *N_) (applyEquality succ (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring c (b *N c) b)) (applyEquality (c +N_) (transitivity (transitivity (Semiring.commutative ℕSemiring (b *N c) b) (applyEquality (b +N_) (multiplicationNIsCommutative b c))) (multiplicationNIsCommutative (succ c) b)))))) (Semiring.*Associative ℕSemiring (succ a) (succ b) (succ c)) *ZAssociative (negSucc a) (negSucc b) (nonneg zero) rewrite Semiring.productZeroRight ℕSemiring (b +N a *N succ b) = refl *ZAssociative (negSucc a) (negSucc b) (nonneg (succ x)) = applyEquality nonneg (transitivity (applyEquality (succ a *N_) ans) (Semiring.*Associative ℕSemiring (succ a) (succ b) (succ x))) where ans : succ ((succ x *N b) +N x) ≡ (succ b *N succ x) ans rewrite Semiring.commutative ℕSemiring (succ x *N b) x | multiplicationNIsCommutative (succ x) b = refl *ZAssociative (negSucc a) (negSucc b) (negSucc x) = applyEquality negSucc t where l1 : (a b c d e f g : ℕ) → (a +N b) +N d ≡ e +N (f +N g) → (a +N b) +N (c +N d) ≡ (c +N e) +N (f +N g) l1 a b c d e f g pr rewrite Semiring.commutative ℕSemiring c d | Semiring.+Associative ℕSemiring (a +N b) d c | pr | Semiring.commutative ℕSemiring (e +N (f +N g)) c | Semiring.+Associative ℕSemiring c e (f +N g) = refl v : (((succ b) *N succ x) *N a) ≡ (succ x) *N (a *N succ b) v = transitivity (applyEquality (_*N a) (multiplicationNIsCommutative (succ b) (succ x))) (transitivity (equalityCommutative (Semiring.*Associative ℕSemiring (succ x) (succ b) a)) (applyEquality (succ x *N_) (multiplicationNIsCommutative (succ b) a))) u : (a +N (x +N b *N succ x) *N a) +N b *N succ x ≡ (b +N a *N succ b) *N x +N (b +N a *N succ b) u = transitivity (transitivity (transitivity (Semiring.commutative ℕSemiring (a +N (x +N b *N succ x) *N a) (b *N succ x)) (transitivity (applyEquality (_+N (a +N (x +N b *N succ x) *N a)) (multiplicationNIsCommutative b (succ x))) (transitivity (applyEquality ((b +N x *N b) +N_) v) (equalityCommutative (productDistributes (succ x) b (a *N succ b)))))) (applyEquality ((b +N a *N succ b) +N_) (multiplicationNIsCommutative x (b +N a *N succ b)))) (Semiring.commutative ℕSemiring (b +N a *N succ b) ((b +N a *N succ b) *N x)) t : (a +N (x +N b *N succ x) *N a) +N (x +N b *N succ x) ≡ (x +N (b +N a *N succ b) *N x) +N (b +N a *N succ b) t = l1 a ((x +N b *N succ x) *N a) x (b *N succ x) ((b +N (a *N succ b)) *N x) b (a *N succ b) u multLemma : (a b : ℕ) → a *N succ b ≡ a *N b +N a multLemma a b rewrite multiplicationNIsCommutative a (succ b) | Semiring.commutative ℕSemiring a (b *N a) | multiplicationNIsCommutative a b = refl negSucc+Nonneg : (a b : ℕ) → negSucc a ≡ negSucc (a +N b) +Z nonneg b negSucc+Nonneg zero zero = refl negSucc+Nonneg zero (succ b) = negSucc+Nonneg zero b negSucc+Nonneg (succ a) zero rewrite Semiring.commutative ℕSemiring a 0 = refl negSucc+Nonneg (succ a) (succ b) rewrite Semiring.commutative ℕSemiring a (succ b) | Semiring.commutative ℕSemiring b a = negSucc+Nonneg (succ a) b distLemma : (a b : ℕ) → negSucc a *Z nonneg b ≡ negSucc ((a +N b *N a) +N b) +Z nonneg (succ a) distLemma a b rewrite Semiring.commutative ℕSemiring (a +N b *N a) b | Semiring.commutative ℕSemiring a (b *N a) | Semiring.+Associative ℕSemiring b (b *N a) a = transitivity u (transitivity (equalityCommutative (+ZAssociative (negSucc ((b +N b *N a) +N a)) (nonneg a) (nonneg 1))) (applyEquality ((negSucc ((b +N b *N a) +N a)) +Z_) {nonneg a +Z nonneg 1} {nonneg (succ a)} (+ZCommutative (nonneg a) (nonneg 1)))) where v : (a b : ℕ) → negSucc a *Z nonneg b ≡ (negSucc (b +N b *N a)) +Z nonneg 1 v zero zero = refl v zero (succ b) rewrite Semiring.productZeroRight ℕSemiring b = applyEquality negSucc (equalityCommutative (Semiring.sumZeroRight ℕSemiring b)) v (succ a) zero = refl v (succ a) (succ b) = applyEquality negSucc (Semiring.commutative ℕSemiring (succ (a +N b *N succ a)) b) u : negSucc a *Z nonneg b ≡ (negSucc ((b +N b *N a) +N a) +Z nonneg a) +Z nonneg 1 u = transitivity (v a b) (applyEquality (_+Z nonneg 1) (negSucc+Nonneg (b +N b *N a) a)) *ZDistributesOver+Z : (a b c : ℤ) → a *Z (b +Z c) ≡ (a *Z b) +Z (a *Z c) *ZDistributesOver+Z (nonneg zero) b c rewrite *ZZeroLeft (b +Z c) | *ZZeroLeft b | *ZZeroLeft c = refl *ZDistributesOver+Z (nonneg (succ a)) (nonneg zero) (nonneg c) rewrite Semiring.productZeroRight ℕSemiring a = refl *ZDistributesOver+Z (nonneg (succ a)) (nonneg (succ b)) (nonneg c) = applyEquality nonneg (productDistributes (succ a) (succ b) c) *ZDistributesOver+Z (nonneg (succ a)) (nonneg zero) (negSucc c) rewrite Semiring.productZeroRight ℕSemiring a = refl *ZDistributesOver+Z (nonneg (succ a)) (nonneg (succ b)) (negSucc zero) rewrite Semiring.productZeroRight ℕSemiring a = t a where t : (a : ℕ) → nonneg (succ a *N b) ≡ nonneg (succ a *N succ b) +Z negSucc a t zero = refl t (succ a) = transitivity (+Zinherits b (b +N a *N b)) (transitivity (applyEquality (nonneg b +Z_) (t a)) (transitivity (+ZAssociative (nonneg b) (nonneg (succ (b +N a *N succ b))) (negSucc a)) (applyEquality (_+Z negSucc a) {nonneg b +Z nonneg (succ (b +N a *N succ b))} {nonneg (b +N succ (b +N a *N succ b))} (equalityCommutative (+Zinherits b _))))) *ZDistributesOver+Z (nonneg (succ a)) (nonneg (succ x)) (negSucc (succ b)) = transitivity (applyEquality ((nonneg (succ a)) *Z_) (+ZCommutative (nonneg x) (negSucc b))) (transitivity (transitivity (*ZDistributesOver+Z (nonneg (succ a)) (negSucc b) (nonneg x)) t) (+ZCommutative (negSucc ((b +N a *N succ b) +N a)) (nonneg (x +N a *N succ x)))) where t : negSucc ((b +N a *N b) +N a) +Z nonneg (x +N a *N x) ≡ negSucc ((b +N a *N succ b) +N a) +Z nonneg (x +N a *N succ x) t rewrite multLemma a x | multLemma a b | Semiring.+Associative ℕSemiring x (a *N x) a | Semiring.+Associative ℕSemiring b (a *N b) a | Semiring.commutative ℕSemiring (x +N a *N x) a | +Zinherits a (x +N a *N x) | +ZAssociative (negSucc (((b +N a *N b) +N a) +N a)) (nonneg a) (nonneg (x +N a *N x)) = applyEquality (_+Z nonneg (x +N a *N x)) {negSucc ((b +N a *N b) +N a)} {negSucc (((b +N a *N b) +N a) +N a) +Z nonneg a} (negSucc+Nonneg ((b +N a *N b) +N a) a) *ZDistributesOver+Z (nonneg (succ a)) (negSucc b) (nonneg zero) rewrite Semiring.productZeroRight ℕSemiring a = refl *ZDistributesOver+Z (nonneg (succ a)) (negSucc zero) (nonneg (succ x)) rewrite Semiring.productZeroRight ℕSemiring a = t a x where t : (a x : ℕ) → nonneg (succ a *N x) ≡ negSucc a +Z nonneg (succ a *N succ x) t zero x = refl t (succ a) x with t a x ... | bl rewrite +Zinherits x (a *N x) | +Zinherits x (x +N a *N x) = transitivity (transitivity (applyEquality (nonneg x +Z_) (+Zinherits x (a *N x))) (+ZCommutative (nonneg x) (nonneg x +Z nonneg (a *N x)))) (transitivity (applyEquality (_+Z nonneg x) bl) (transitivity (equalityCommutative (+ZAssociative (negSucc a) (nonneg (succ x +N a *N succ x)) (nonneg x))) (applyEquality (λ i → negSucc a +Z nonneg i) {succ (x +N a *N succ x) +N x} {x +N succ (x +N a *N succ x)} (Semiring.commutative ℕSemiring (succ (x +N a *N succ x)) x)))) *ZDistributesOver+Z (nonneg (succ a)) (negSucc (succ b)) (nonneg (succ x)) = transitivity (*ZDistributesOver+Z (nonneg (succ a)) (negSucc b) (nonneg x)) t where t : negSucc ((b +N a *N b) +N a) +Z nonneg (x +N a *N x) ≡ negSucc ((b +N a *N succ b) +N a) +Z nonneg (x +N a *N succ x) t rewrite multLemma a x | multLemma a b | Semiring.+Associative ℕSemiring x (a *N x) a | Semiring.+Associative ℕSemiring b (a *N b) a | Semiring.commutative ℕSemiring (x +N a *N x) a | +Zinherits a (x +N a *N x) | +ZAssociative (negSucc (((b +N a *N b) +N a) +N a)) (nonneg a) (nonneg (x +N a *N x)) = applyEquality (_+Z nonneg (x +N a *N x)) {negSucc ((b +N a *N b) +N a)} {negSucc (((b +N a *N b) +N a) +N a) +Z nonneg a} (negSucc+Nonneg ((b +N a *N b) +N a) a) *ZDistributesOver+Z (nonneg (succ a)) (negSucc b) (negSucc x) = applyEquality negSucc (transitivity (applyEquality (_+N a) (transitivity (productDistributes (succ a) (succ b) x) (applyEquality (_+N (x +N a *N x)) {succ b +N a *N succ b} {succ (b +N a *N b) +N a} (applyEquality succ u)))) (equalityCommutative (Semiring.+Associative ℕSemiring (succ ((b +N a *N b) +N a)) (succ a *N x) a))) where u : b +N a *N succ b ≡ (succ a *N b) +N a u rewrite multiplicationNIsCommutative a (succ b) | Semiring.commutative ℕSemiring a (b *N a) | multiplicationNIsCommutative b a = Semiring.+Associative ℕSemiring b (a *N b) a *ZDistributesOver+Z (negSucc a) (nonneg zero) (nonneg x) = refl *ZDistributesOver+Z (negSucc a) (nonneg zero) (negSucc x) = refl *ZDistributesOver+Z (negSucc a) (nonneg (succ b)) (nonneg zero) rewrite Semiring.commutative ℕSemiring b 0 = refl *ZDistributesOver+Z (negSucc a) (nonneg (succ b)) (nonneg (succ c)) = applyEquality negSucc t where v : a *N b +N a *N succ c ≡ c *N a +N (a +N b *N a) v rewrite multiplicationNIsCommutative b a | Semiring.+Associative ℕSemiring (c *N a) a (a *N b) | Semiring.commutative ℕSemiring (c *N a +N a) (a *N b) | Semiring.commutative ℕSemiring (c *N a) a = applyEquality (λ i → a *N b +N i) (transitivity (multLemma a c) (transitivity (Semiring.commutative ℕSemiring (a *N c) a) (applyEquality (a +N_) (multiplicationNIsCommutative a c)))) u : (a +N (b +N succ c) *N a) +N b ≡ (a +N c *N a) +N ((a +N b *N a) +N b) u rewrite Semiring.+Associative ℕSemiring (a +N c *N a) (a +N b *N a) b | (equalityCommutative (Semiring.+Associative ℕSemiring a (c *N a) (a +N b *N a))) = applyEquality (λ i → (a +N i) +N b) (transitivity (multiplicationNIsCommutative (b +N succ c) a) (transitivity (productDistributes a b (succ c)) v)) t : (a +N (b +N succ c) *N a) +N (b +N succ c) ≡ succ (((a +N b *N a) +N b) +N ((a +N c *N a) +N c)) t rewrite Semiring.+Associative ℕSemiring ((a +N (b +N succ c) *N a)) b (succ c) | Semiring.commutative ℕSemiring ((a +N b *N a) +N b) ((a +N c *N a) +N c) | Semiring.commutative ℕSemiring (a +N c *N a) c | equalityCommutative (Semiring.+Associative ℕSemiring (succ c) (a +N c *N a) ((a +N b *N a) +N b)) | Semiring.commutative ℕSemiring (succ c) ((a +N c *N a) +N ((a +N b *N a) +N b)) = applyEquality (_+N succ c) u *ZDistributesOver+Z (negSucc a) (nonneg (succ b)) (negSucc zero) rewrite Semiring.productOneRight ℕSemiring a = distLemma a b *ZDistributesOver+Z (negSucc a) (nonneg (succ b)) (negSucc (succ c)) = transitivity (*ZDistributesOver+Z (negSucc a) (nonneg b) (negSucc c)) (transitivity (applyEquality (_+Z nonneg (succ (c +N a *N succ c))) (distLemma a b)) (transitivity (equalityCommutative (+ZAssociative (negSucc ((a +N b *N a) +N b)) (nonneg (succ a)) (nonneg (succ (c +N a *N succ c))))) (applyEquality (negSucc ((a +N b *N a) +N b) +Z_) {nonneg (succ (a +N succ (c +N a *N succ c)))} {nonneg (succ (succ (c +N a *N succ (succ c))))} (applyEquality nonneg (t (succ a) (succ c)))))) where t : (x y : ℕ) → x +N x *N y ≡ x *N succ y t x y = transitivity (Semiring.commutative ℕSemiring x (x *N y)) (equalityCommutative (multLemma x y)) *ZDistributesOver+Z (negSucc a) (negSucc b) (nonneg zero) rewrite Semiring.commutative ℕSemiring (b +N a *N succ b) 0 = refl *ZDistributesOver+Z (negSucc a) (negSucc zero) (nonneg (succ b)) = transitivity (distLemma a b) (transitivity (+ZCommutative (negSucc ((a +N b *N a) +N b)) (nonneg (succ a))) (applyEquality (λ i → nonneg (succ i) +Z negSucc ((a +N b *N a) +N b)) (equalityCommutative (Semiring.productOneRight ℕSemiring a)))) *ZDistributesOver+Z (negSucc a) (negSucc (succ c)) (nonneg (succ b)) = transitivity (applyEquality (negSucc a *Z_) (+ZCommutative (negSucc c) (nonneg b))) (transitivity (transitivity (*ZDistributesOver+Z (negSucc a) (nonneg b) (negSucc c)) (transitivity (applyEquality (_+Z nonneg (succ (c +N a *N succ c))) (distLemma a b)) (transitivity (equalityCommutative (+ZAssociative (negSucc ((a +N b *N a) +N b)) (nonneg (succ a)) (nonneg (succ (c +N a *N succ c))))) (applyEquality (negSucc ((a +N b *N a) +N b) +Z_) {nonneg (succ (a +N succ (c +N a *N succ c)))} {nonneg (succ (succ (c +N a *N succ (succ c))))} (applyEquality nonneg (t (succ a) (succ c))))))) (+ZCommutative (negSucc ((a +N b *N a) +N b)) (nonneg (succ (succ (c +N a *N succ (succ c))))))) where t : (x y : ℕ) → x +N x *N y ≡ x *N succ y t x y = transitivity (Semiring.commutative ℕSemiring x (x *N y)) (equalityCommutative (multLemma x y)) *ZDistributesOver+Z (negSucc a) (negSucc b) (negSucc c) = applyEquality nonneg (transitivity (applyEquality (λ i → succ a *N (succ i)) (transitivity (applyEquality succ (Semiring.commutative ℕSemiring b c)) (Semiring.commutative ℕSemiring (succ c) b))) (productDistributes (succ a) (succ b) (succ c))) ℤRing : Ring (reflSetoid ℤ) _+Z_ _*Z_ Ring.additiveGroup ℤRing = ℤGroup Ring.*WellDefined ℤRing refl refl = refl Ring.1R ℤRing = nonneg 1 Ring.groupIsAbelian ℤRing {a} {b} = +ZCommutative a b Ring.*Associative ℤRing {a} {b} {c} = *ZAssociative a b c Ring.*Commutative ℤRing {a} {b} = *ZCommutative a b Ring.*DistributesOver+ ℤRing {a} {b} {c} = *ZDistributesOver+Z a b c Ring.identIsIdent ℤRing {a} = *ZleftIdent a
{ "alphanum_fraction": 0.6556659291, "avg_line_length": 119.3314606742, "ext": "agda", "hexsha": "088f16e078103495db4693838182d16f71fd39a1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Numbers/Integers/RingStructure/Ring.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Numbers/Integers/RingStructure/Ring.agda", "max_line_length": 752, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Numbers/Integers/RingStructure/Ring.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 8259, "size": 21241 }
module Oscar.Data.Term.Injectivity {𝔣} (FunctionName : Set 𝔣) where open import Oscar.Data.Term FunctionName open import Data.Fin open import Data.Nat open import Data.Vec open import Relation.Binary.PropositionalEquality Term-i-inj : ∀ {m} {𝑥₁ 𝑥₂ : Fin m} → i 𝑥₁ ≡ i 𝑥₂ → 𝑥₁ ≡ 𝑥₂ Term-i-inj refl = refl Term-functionName-inj : ∀ {fn₁ fn₂} {n N₁ N₂} {ts₁ : Vec (Term n) N₁} {ts₂ : Vec (Term n) N₂} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → fn₁ ≡ fn₂ Term-functionName-inj refl = refl Term-functionArity-inj : ∀ {fn₁ fn₂} {n N₁ N₂} {ts₁ : Vec (Term n) N₁} {ts₂ : Vec (Term n) N₂} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → N₁ ≡ N₂ Term-functionArity-inj refl = refl Term-functionTerms-inj : ∀ {fn₁ fn₂} {n N} {ts₁ : Vec (Term n) N} {ts₂ : Vec (Term n) N} → Term.function fn₁ ts₁ ≡ Term.function fn₂ ts₂ → ts₁ ≡ ts₂ Term-functionTerms-inj refl = refl Term-forkLeft-inj : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → l₁ ≡ l₂ Term-forkLeft-inj refl = refl Term-forkRight-inj : ∀ {n} {l₁ r₁ l₂ r₂ : Term n} → l₁ fork r₁ ≡ l₂ fork r₂ → r₁ ≡ r₂ Term-forkRight-inj refl = refl
{ "alphanum_fraction": 0.6733031674, "avg_line_length": 39.4642857143, "ext": "agda", "hexsha": "b4091b9dc51de4b83cfd32b9b9ab87f09b667836", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Term/Injectivity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data/Term/Injectivity.agda", "max_line_length": 153, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Term/Injectivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 448, "size": 1105 }
{-# OPTIONS --without-K --exact-split --rewriting --overlapping-instances #-} open import lib.Basics open import lib.NConnected open import lib.NType2 open import lib.types.Truncation open import lib.types.Sigma open import lib.Equivalence open import lib.types.Fin open import lib.types.Coproduct open import Graphs.Definition open import Graphs.Properties open import Coequalizers.Definition open import Coequalizers.Misc open import Groups.Definition open import Coequalizers.PullbackStability open import Coequalizers.PreserveEquivalence open import Coequalizers.EdgeCoproduct open import Graphs.SpanningTreeFinite open import Graphs.SubTrees open import Util.Misc open import Util.DecEq module NielsenSchreier {i : ULevel} where {- We build towards the proof of the finite index Nielsen-Schreier theorem in several steps. -} {- We will first show that subgroups of free higher groups are free higher groupoids. That is, we will show that for any family of types X over ⊤ / A, the total space Σ (⊤ / A) X is equivalent to the coequalizer of a graph. Moveover, we can give an explicit description of the graph. -} module SubgroupsOfFreeHigherGroups (A : Type i) (X : (⊤ / A) → Type i) where instance {- Whenever we need a pair of maps (A × X fhg-base) ⇉ (X fhg-base) we will use the definition below. This applies in this module and wherever it is imported. -} higher-subgp-gph : Graph (A × X fhg-base) (X fhg-base) higher-subgp-gph = record { π₀ = snd ; π₁ = λ {(a , x) → transport X (quot a) x} } to-free-higher-gpd : Σ (⊤ / A) X ≃ (X fhg-base) / (A × X fhg-base) to-free-higher-gpd = Σ (⊤ / A) X ≃⟨ pb-equiv ⁻¹ ⟩ -- coequalizers are stable under pullback (Σ ⊤ (X ∘ c[_])) / (Σ A (X ∘ c[_] ∘ π₀)) ≃⟨ Coeq-emap Σ₁-Unit (ide _) (λ _ → idp) (λ _ → idp) ⟩ (X fhg-base) / (A × X fhg-base) ≃∎ where open PullbackStability A ⊤ X -- contains definition of (Σ ⊤ (X ∘ c[_])) / (Σ A (X ∘ c[_] ∘ π₀)) {- We now show that subgroups of free groups are free groupoids. This is a 1-truncated version of the result above. -} module SubGroupsOfFreeGroups (A : Type i) (X : ∥ ⊤ / A ∥₁ → Type i) ⦃ Xset : {z : ∥ ⊤ / A ∥₁} → is-set (X z) ⦄ where -- we now need to assume X is 0-truncated. open SubgroupsOfFreeHigherGroups A (X ∘ [_]) public -- also defines instance for (X fhg-base) / (A × X fhg-base) to-free-gpd : Σ ∥ ⊤ / A ∥₁ X ≃ ∥ X base / (A × X base) ∥₁ to-free-gpd = Σ ∥ ⊤ / A ∥₁ X ≃⟨ Σ-emap-r (Trunc-elim λ z → ide _) ⟩ Σ ∥ ⊤ / A ∥₁ X' ≃⟨ TruncRecType.flattening-Trunc _ ⟩ ∥ Σ (⊤ / A) (X ∘ [_]) ∥₁ ≃⟨ Trunc-emap to-free-higher-gpd ⟩ ∥ X base / (A × X base) ∥₁ ≃∎ where X'-set : ∥ ⊤ / A ∥₁ → hSet i X'-set = Trunc-rec (λ z → ((X [ z ]) , Xset)) X' = fst ∘ X'-set instance X-≃-gpd : {z : ∥ ⊤ / A ∥₁} → is-gpd (X z ≃ X' z) X-≃-gpd {z} = raise-level 0 (≃-level Xset (snd (X'-set z))) {- A free groupoid with vertex set a definitionally finite set is merely equivalent to a free group. -} strict-fin-free-gpd-is-free-gp : (n : ℕ) → (E : Type i) → (Edec : has-dec-eq E) → ⦃ gph : Graph E (Fin (S n)) ⦄ ⦃ conn : gph-is-connected gph ⦄ → ∥ Σ (Type i) (λ B → ∥ Coeq gph ∥₁ ≃ FreeGroup B) ∥ strict-fin-free-gpd-is-free-gp n E Edec = Trunc-fmap from-spanning-tree-fin (spanning-tree E Edec n) where from-spanning-tree-fin : SpanningTree E (Fin (S n)) (Fin n) (Fin (S n)) → Σ (Type i) (λ B → ∥ Fin (S n) / E ∥₁ ≃ FreeGroup B) from-spanning-tree-fin st = ¬E' , Trunc-emap eq where open SpanningTree st open ExtendSpanningTree E (Fin (S n)) (Fin n) (Fin (S n)) st open CoeqCoprodEquiv (Fin (S n)) (Fin n) ¬E' eq : Fin (S n) / E ≃ ⊤ / ¬E' eq = Fin (S n) / E ≃⟨ spantree-equiv ⟩ Fin (S n) / ((Fin n) ⊔ ¬E') ≃⟨ edge-coproduct-expand ⟩ (Fin (S n) / (Fin n)) / ¬E' ≃⟨ Coeq-emap (contr-equiv-Unit ⟨⟩) (ide _) (λ _ → idp) (λ _ → idp) ⟩ ⊤ / ¬E' ≃∎ {- We generalise the above so that the vertex set only needs to be equivalent to a definitionally finite set. -} fin-free-gpd-is-free-gp : (n : ℕ) → (E : Type i) → (Edec : has-dec-eq E) → (V : Type i) → (Vfin : V ≃ Fin (S n)) → ⦃ gph : Graph E V ⦄ ⦃ conn : gph-is-connected gph ⦄ → ∥ Σ (Type i) (λ B → ∥ Coeq gph ∥₁ ≃ FreeGroup B) ∥ fin-free-gpd-is-free-gp n E Edec V Vfin = Trunc-fmap (λ {(B , e) → B , (e ∘e Trunc-emap coeq-equiv)}) (strict-fin-free-gpd-is-free-gp n E Edec) where instance gph' : Graph E (Fin (S n)) gph' = record { π₀ = (–> Vfin) ∘ π₀ ; π₁ = (–> Vfin) ∘ π₁ } coeq-equiv : (V / E) ≃ (Fin (S n) / E) coeq-equiv = Coeq-emap Vfin (ide E) (λ _ → idp) λ _ → idp instance conn' : gph-is-connected gph' conn' = equiv-preserves-level (Trunc-emap coeq-equiv ) {- We can now prove the finite index version of the Nielsen-Schreier theorem. -} nielsen-schreier-finite-index : (A : Type i) (Adec : has-dec-eq A) -- we are given a type A with decidable equality (X : (FreeGroup A) → Type i) -- together with a covering space over the free group on A, that is a family of types X ... ⦃ conn : is-connected 0 (Σ (FreeGroup A) X) ⦄ -- such that the total space is connected (n : ℕ) (Xfin : X (base) ≃ Fin (S n)) → -- here we do the finite index case ∥ Σ (Type i) (λ B → Σ (FreeGroup A) X ≃ FreeGroup B) ∥ -- then the total space is a free group nielsen-schreier-finite-index A Adec X n Xfin = Trunc-fmap (λ {(B , e) → B , e ∘e to-free-gpd}) -- we compose the two equivalences from earlier (fin-free-gpd-is-free-gp n (A × X base) (×-has-dec-eq Adec (equiv-preserves-dec-eq Xfin Fin-has-dec-eq)) (X base) Xfin) -- earlier we showed that free groupoids with finite vertex set are merely equivalent to free groups where open SubGroupsOfFreeGroups A X -- contains our proof that the subgroup is a free groupoid instance -- we use that X is a set and the free groupoid is connected Xset : {z : (FreeGroup A)} → is-set (X z) Xset {z} = Trunc-elim {P = λ z → is-set (X z)} (Coeq-elim (λ z → is-set (X [ z ])) (λ {unit → equiv-preserves-level (Xfin ⁻¹) ⦃ Fin-is-set ⦄}) λ _ → prop-has-all-paths-↓) z conn2 : is-connected 0 (X base / (A × X base)) conn2 = equiv-preserves-level e where e : ∥ Σ (FreeGroup A) X ∥₀ ≃ ∥ X base / (A × X base) ∥₀ e = ∥ Σ (FreeGroup A) X ∥₀ ≃⟨ Trunc-emap (to-free-gpd ) ⟩ ∥ ∥ X base / (A × X base) ∥₁ ∥₀ ≃⟨ Trunc-fuse _ 0 1 ⟩ ∥ X base / (A × X base) ∥₀ ≃∎
{ "alphanum_fraction": 0.5836046168, "avg_line_length": 41.2073170732, "ext": "agda", "hexsha": "0d8fa65c284151ee79b0304ce020a846e37fa492", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "awswan/nielsenschreier-hott", "max_forks_repo_path": "main/NielsenSchreier.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "awswan/nielsenschreier-hott", "max_issues_repo_path": "main/NielsenSchreier.agda", "max_line_length": 132, "max_stars_count": null, "max_stars_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "awswan/nielsenschreier-hott", "max_stars_repo_path": "main/NielsenSchreier.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2451, "size": 6758 }
{-# OPTIONS --without-K #-} module TypeEquivalences where open import Data.Empty open import Data.Unit open import Data.Unit.Core open import Data.Nat renaming (_⊔_ to _⊔ℕ_) open import Data.Sum renaming (map to _⊎→_) open import Data.Product renaming (map to _×→_) open import Function renaming (_∘_ to _○_) -- explicit using to show how little of HoTT is needed open import SimpleHoTT using (refl; ap; ap2) open import Equivalences ------------------------------------------------------------------------------ -- Type Equivalences -- for each type combinator, define two functions that are inverses, and -- establish an equivalence. These are all in the 'semantic space' with -- respect to Pi combinators. -- swap₊ swap₊ : {A B : Set} → A ⊎ B → B ⊎ A swap₊ (inj₁ a) = inj₂ a swap₊ (inj₂ b) = inj₁ b swapswap₊ : {A B : Set} → swap₊ ○ swap₊ {A} {B} ∼ id swapswap₊ (inj₁ a) = refl (inj₁ a) swapswap₊ (inj₂ b) = refl (inj₂ b) swap₊equiv : {A B : Set} → (A ⊎ B) ≃ (B ⊎ A) swap₊equiv = (swap₊ , equiv₁ (mkqinv swap₊ swapswap₊ swapswap₊)) -- unite₊ and uniti₊ unite₊ : {A : Set} → ⊥ ⊎ A → A unite₊ (inj₁ ()) unite₊ (inj₂ y) = y uniti₊ : {A : Set} → A → ⊥ ⊎ A uniti₊ a = inj₂ a uniti₊∘unite₊ : {A : Set} → uniti₊ ○ unite₊ ∼ id {A = ⊥ ⊎ A} uniti₊∘unite₊ (inj₁ ()) uniti₊∘unite₊ (inj₂ y) = refl (inj₂ y) -- this is so easy, Agda can figure it out by itself (see below) unite₊∙uniti₊ : {A : Set} → unite₊ ○ uniti₊ ∼ id {A = A} unite₊∙uniti₊ = refl unite₊equiv : {A : Set} → (⊥ ⊎ A) ≃ A unite₊equiv = (unite₊ , mkisequiv uniti₊ refl uniti₊ uniti₊∘unite₊) uniti₊equiv : {A : Set} → A ≃ (⊥ ⊎ A) uniti₊equiv = uniti₊ , mkisequiv unite₊ uniti₊∘unite₊ unite₊ unite₊∙uniti₊ -- unite⋆ and uniti⋆ unite⋆ : {A : Set} → ⊤ × A → A unite⋆ (tt , x) = x uniti⋆ : {A : Set} → A → ⊤ × A uniti⋆ x = tt , x uniti⋆∘unite⋆ : {A : Set} → uniti⋆ ○ unite⋆ ∼ id {A = ⊤ × A} uniti⋆∘unite⋆ (tt , x) = refl (tt , x) unite⋆equiv : {A : Set} → (⊤ × A) ≃ A unite⋆equiv = unite⋆ , mkisequiv uniti⋆ refl uniti⋆ uniti⋆∘unite⋆ uniti⋆equiv : {A : Set} → A ≃ (⊤ × A) uniti⋆equiv = uniti⋆ , mkisequiv unite⋆ uniti⋆∘unite⋆ unite⋆ refl -- swap⋆ swap⋆ : {A B : Set} → A × B → B × A swap⋆ (a , b) = (b , a) swapswap⋆ : {A B : Set} → swap⋆ ○ swap⋆ ∼ id {A = A × B} swapswap⋆ (a , b) = refl (a , b) swap⋆equiv : {A B : Set} → (A × B) ≃ (B × A) swap⋆equiv = swap⋆ , mkisequiv swap⋆ swapswap⋆ swap⋆ swapswap⋆ -- assocl₊ and assocr₊ assocl₊ : {A B C : Set} → (A ⊎ (B ⊎ C)) → ((A ⊎ B) ⊎ C) assocl₊ (inj₁ a) = inj₁ (inj₁ a) assocl₊ (inj₂ (inj₁ b)) = inj₁ (inj₂ b) assocl₊ (inj₂ (inj₂ c)) = inj₂ c assocr₊ : {A B C : Set} → ((A ⊎ B) ⊎ C) → (A ⊎ (B ⊎ C)) assocr₊ (inj₁ (inj₁ a)) = inj₁ a assocr₊ (inj₁ (inj₂ b)) = inj₂ (inj₁ b) assocr₊ (inj₂ c) = inj₂ (inj₂ c) assocl₊∘assocr₊ : {A B C : Set} → assocl₊ ○ assocr₊ ∼ id {A = ((A ⊎ B) ⊎ C)} assocl₊∘assocr₊ (inj₁ (inj₁ a)) = refl (inj₁ (inj₁ a)) assocl₊∘assocr₊ (inj₁ (inj₂ b)) = refl (inj₁ (inj₂ b)) assocl₊∘assocr₊ (inj₂ c) = refl (inj₂ c) assocr₊∘assocl₊ : {A B C : Set} → assocr₊ ○ assocl₊ ∼ id {A = (A ⊎ (B ⊎ C))} assocr₊∘assocl₊ (inj₁ a) = refl (inj₁ a) assocr₊∘assocl₊ (inj₂ (inj₁ b)) = refl (inj₂ (inj₁ b)) assocr₊∘assocl₊ (inj₂ (inj₂ c)) = refl (inj₂ (inj₂ c)) assocl₊equiv : {A B C : Set} → (A ⊎ (B ⊎ C)) ≃ ((A ⊎ B) ⊎ C) assocl₊equiv = assocl₊ , mkisequiv assocr₊ assocl₊∘assocr₊ assocr₊ assocr₊∘assocl₊ assocr₊equiv : {A B C : Set} → ((A ⊎ B) ⊎ C) ≃ (A ⊎ (B ⊎ C)) assocr₊equiv = assocr₊ , mkisequiv assocl₊ assocr₊∘assocl₊ assocl₊ assocl₊∘assocr₊ -- assocl⋆ and assocr⋆ assocl⋆ : {A B C : Set} → (A × (B × C)) → ((A × B) × C) assocl⋆ (a , (b , c)) = ((a , b) , c) assocr⋆ : {A B C : Set} → ((A × B) × C) → (A × (B × C)) assocr⋆ ((a , b) , c) = (a , (b , c)) assocl⋆∘assocr⋆ : {A B C : Set} → assocl⋆ ○ assocr⋆ ∼ id {A = ((A × B) × C)} assocl⋆∘assocr⋆ x = refl x assocr⋆∘assocl⋆ : {A B C : Set} → assocr⋆ ○ assocl⋆ ∼ id {A = (A × (B × C))} assocr⋆∘assocl⋆ x = refl x assocl⋆equiv : {A B C : Set} → (A × (B × C)) ≃ ((A × B) × C) assocl⋆equiv = assocl⋆ , mkisequiv assocr⋆ assocl⋆∘assocr⋆ assocr⋆ assocr⋆∘assocl⋆ assocr⋆equiv : {A B C : Set} → ((A × B) × C) ≃ (A × (B × C)) assocr⋆equiv = assocr⋆ , mkisequiv assocl⋆ assocr⋆∘assocl⋆ assocl⋆ assocl⋆∘assocr⋆ -- distz and factorz distz : { A : Set} → (⊥ × A) → ⊥ distz (() , _) factorz : {A : Set} → ⊥ → (⊥ × A) factorz () distz∘factorz : {A : Set} → distz ○ factorz {A} ∼ id distz∘factorz () factorz∘distz : {A : Set} → factorz {A} ○ distz ∼ id factorz∘distz (() , proj₂) distzequiv : {A : Set} → (⊥ × A) ≃ ⊥ distzequiv {A} = distz , mkisequiv factorz (distz∘factorz {A}) factorz factorz∘distz factorzequiv : {A : Set} → ⊥ ≃ (⊥ × A) factorzequiv {A} = factorz , mkisequiv distz factorz∘distz distz (distz∘factorz {A}) -- dist and factor dist : {A B C : Set} → ((A ⊎ B) × C) → (A × C) ⊎ (B × C) dist (inj₁ x , c) = inj₁ (x , c) dist (inj₂ y , c) = inj₂ (y , c) factor : {A B C : Set} → (A × C) ⊎ (B × C) → ((A ⊎ B) × C) factor (inj₁ (a , c)) = inj₁ a , c factor (inj₂ (b , c)) = inj₂ b , c dist∘factor : {A B C : Set} → dist {A} {B} {C} ○ factor ∼ id dist∘factor (inj₁ x) = refl (inj₁ x) dist∘factor (inj₂ y) = refl (inj₂ y) factor∘dist : {A B C : Set} → factor {A} {B} {C} ○ dist ∼ id factor∘dist (inj₁ x , c) = refl (inj₁ x , c) factor∘dist (inj₂ y , c) = refl (inj₂ y , c) distequiv : {A B C : Set} → ((A ⊎ B) × C) ≃ ((A × C) ⊎ (B × C)) distequiv = dist , mkisequiv factor dist∘factor factor factor∘dist factorequiv : {A B C : Set} → ((A × C) ⊎ (B × C)) ≃ ((A ⊎ B) × C) factorequiv = factor , (mkisequiv dist factor∘dist dist dist∘factor) -- ⊕ _⊎∼_ : {A B C D : Set} {f : A → C} {finv : C → A} {g : B → D} {ginv : D → B} → (α : f ○ finv ∼ id) → (β : g ○ ginv ∼ id) → (f ⊎→ g) ○ (finv ⊎→ ginv) ∼ id {A = C ⊎ D} _⊎∼_ α β (inj₁ x) = ap inj₁ (α x) _⊎∼_ α β (inj₂ y) = ap inj₂ (β y) path⊎ : {A B C D : Set} → A ≃ C → B ≃ D → (A ⊎ B) ≃ (C ⊎ D) path⊎ (fp , eqp) (fq , eqq) = Data.Sum.map fp fq , mkisequiv (P.g ⊎→ Q.g) (P.α ⊎∼ Q.α) (P.h ⊎→ Q.h) (P.β ⊎∼ Q.β) where module P = isequiv eqp module Q = isequiv eqq -- ⊗ _×∼_ : {A B C D : Set} {f : A → C} {finv : C → A} {g : B → D} {ginv : D → B} → (α : f ○ finv ∼ id) → (β : g ○ ginv ∼ id) → (f ×→ g) ○ (finv ×→ ginv) ∼ id {A = C × D} _×∼_ α β (x , y) = ap2 _,_ (α x) (β y) path× : {A B C D : Set} → A ≃ C → B ≃ D → (A × B) ≃ (C × D) path× {A} {B} {C} {D} (fp , eqp) (fq , eqq) = Data.Product.map fp fq , mkisequiv (P.g ×→ Q.g) (_×∼_ {A} {B} {C} {D} {fp} {P.g} {fq} {Q.g} P.α Q.α) (P.h ×→ Q.h) (_×∼_ {C} {D} {A} {B} {P.h} {fp} {Q.h} {fq} P.β Q.β) where module P = isequiv eqp module Q = isequiv eqq idequiv : {A : Set} → A ≃ A idequiv = id≃
{ "alphanum_fraction": 0.5256621278, "avg_line_length": 30.3772727273, "ext": "agda", "hexsha": "ad9aa1f41c9676b1dc21aeb2f86b8d32b31a3319", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/OldUnivalence/TypeEquivalences.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/OldUnivalence/TypeEquivalences.agda", "max_line_length": 78, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/OldUnivalence/TypeEquivalences.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3409, "size": 6683 }
{-# OPTIONS --cubical #-} module HyperPositive where open import Prelude infixr 4 _↬_ {-# NO_POSITIVITY_CHECK #-} record _↬_ (A : Type a) (B : Type b) : Type (a ℓ⊔ b) where inductive; constructor hyp field invoke : ((A ↬ B) → A) → B open _↬_ open import Data.List using (List; _∷_; []; foldr) module _ {a b} {A : Type a} {B : Type b} where XT = List (A × B) ↬ (A → List (A × B)) → List (A × B) YT = List (A × B) ↬ (A → List (A × B)) yfld : List B → YT yfld = foldr f n where f : B → YT → YT f y yk .invoke xk x = (x , y) ∷ xk yk n : YT n .invoke _ _ = [] xfld : List A → XT xfld = foldr f n where f : A → XT → XT f x xk yk = yk .invoke xk x n : XT n _ = [] zip : List A → List B → List (A × B) zip xs ys = xfld xs (yfld ys) open import Data.List using (_⋯_) open import Data.List.Syntax _ : zip (1 ⋯ 5) (11 ⋯ 15) ≡ [ 5 ][ (1 , 11) , (2 , 12) , (3 , 13) , (4 , 14) , (5 , 15) ] _ = refl
{ "alphanum_fraction": 0.5135699374, "avg_line_length": 20.8260869565, "ext": "agda", "hexsha": "c49827ae1cfeead682b26b26b48cb604c051b738", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "HyperPositive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "HyperPositive.agda", "max_line_length": 89, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "HyperPositive.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 403, "size": 958 }
open import Relation.Binary.Indexed module Relation.Binary.Indexed.EqReasoning {𝒾} {I : Set 𝒾} {𝒸 ℓ} (S : Setoid I 𝒸 ℓ) where open Setoid S import Relation.Binary.Indexed.PreorderReasoning as PreR open import Relation.Binary.Indexed.Extra using (Setoid⇒Preorder) open PreR (Setoid⇒Preorder S) public renaming ( _∼⟨_⟩_ to _≈⟨_⟩_ ; _≈⟨_⟩_ to _≡⟨_⟩_ ; _≈⟨⟩_ to _≡⟨⟩_ )
{ "alphanum_fraction": 0.6267605634, "avg_line_length": 32.7692307692, "ext": "agda", "hexsha": "648ac0e4e868950234b610991ee730a9c332bc6f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/categories", "max_forks_repo_path": "src/Relation/Binary/Indexed/EqReasoning.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/categories", "max_issues_repo_path": "src/Relation/Binary/Indexed/EqReasoning.agda", "max_line_length": 89, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/categories", "max_stars_repo_path": "src/Relation/Binary/Indexed/EqReasoning.agda", "max_stars_repo_stars_event_max_datetime": "2018-01-04T23:19:30.000Z", "max_stars_repo_stars_event_min_datetime": "2018-01-04T23:19:30.000Z", "num_tokens": 162, "size": 426 }
module Cats.Category.Discrete {li} (I : Set li) where open import Data.Unit using (⊤) open import Level open import Cats.Category.Base open import Cats.Functor using (Functor) Obj : Set li Obj = I data _⇒_ : Obj → Obj → Set where id : ∀ {A} → A ⇒ A _∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C id ∘ id = id Discrete : Category li zero zero Discrete = record { Obj = Obj ; _⇒_ = _⇒_ ; _≈_ = λ _ _ → ⊤ ; id = id ; _∘_ = _∘_ ; equiv = _ ; ∘-resp = _ ; id-r = _ ; id-l = _ ; assoc = _ } functor : ∀ {lo la l≈} {C : Category lo la l≈} → (I → Category.Obj C) → Functor Discrete C functor {C = C} f = record { fobj = f ; fmap = λ { id → C.id } ; fmap-resp = λ { {_} {_} {id} {id} _ → C.≈.refl } ; fmap-id = C.≈.refl ; fmap-∘ = λ { {f = id} {id} → C.id-l } } where module C = Category C
{ "alphanum_fraction": 0.4976905312, "avg_line_length": 17.6734693878, "ext": "agda", "hexsha": "b3b0061aac42c5e6feac8e192eaf82d865213acd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Discrete.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Discrete.agda", "max_line_length": 54, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Discrete.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 349, "size": 866 }
{-# OPTIONS --cubical #-} module Cubical.Categories.Sets where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Categories.Category module _ ℓ where SET : Precategory (ℓ-suc ℓ) ℓ SET .ob = Σ (Type ℓ) isSet SET .hom (A , _) (B , _) = A → B SET .idn _ = λ x → x SET .seq f g = λ x → g (f x) SET .seq-λ f = refl SET .seq-ρ f = refl SET .seq-α f g h = refl module _ {ℓ} where isSetExpIdeal : {A B : Type ℓ} → isSet B → isSet (A → B) isSetExpIdeal B/set = isOfHLevelPi 2 λ _ → B/set isSetLift : {A : Type ℓ} → isSet A → isSet (Lift {ℓ} {ℓ-suc ℓ} A) isSetLift = isOfHLevelLift 2 instance SET-category : isCategory (SET ℓ) SET-category .homIsSet {_} {B , B/set} = isSetExpIdeal B/set
{ "alphanum_fraction": 0.6384915475, "avg_line_length": 26.5172413793, "ext": "agda", "hexsha": "7ad005e44014e064e99115f0aacf32e5ea2d0758", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Categories/Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Categories/Sets.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Categories/Sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 300, "size": 769 }
-- Building some simple tactics using the reflected type checking monad. module _ where open import Common.Reflection open import Common.Prelude hiding (_>>=_) open import Common.Equality open import Agda.Builtin.Sigma -- Some helpers -- quotegoal : (Type → Tactic) → Tactic quotegoal tac hole = inferType hole >>= λ goal → reduce goal >>= λ goal → tac goal hole case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x replicateTC : {A : Set} → Nat → TC A → TC (List A) replicateTC zero m = returnTC [] replicateTC (suc n) m = m >>= λ x → replicateTC n m >>= λ xs → returnTC (x ∷ xs) mapTC! : ∀ {A : Set} → (A → TC ⊤) → List A → TC ⊤ mapTC! f [] = returnTC _ mapTC! f (x ∷ xs) = f x >>= λ _ → mapTC! f xs mapTC!r : ∀ {A} → (A → TC ⊤) → List A → TC ⊤ mapTC!r f [] = returnTC _ mapTC!r f (x ∷ xs) = mapTC! f xs >>= λ _ → f x visibleArity : QName → TC Nat visibleArity q = getType q >>= λ t → returnTC (typeArity t) where typeArity : Type → Nat typeArity (pi (arg (argInfo visible _) _) (abs _ b)) = suc (typeArity b) typeArity (pi _ (abs _ b)) = typeArity b typeArity _ = 0 newMeta! : TC Term newMeta! = newMeta unknown absurdLam : Term absurdLam = extLam (absurdClause (("()" , arg (argInfo visible relevant) unknown) ∷ []) (arg (argInfo visible relevant) absurd ∷ []) ∷ []) [] -- Simple assumption tactic -- assumption-tac : Nat → Nat → Tactic assumption-tac x 0 _ = typeError (strErr "No assumption matched" ∷ []) assumption-tac x (suc n) hole = catchTC (unify hole (var x [])) (assumption-tac (suc x) n hole) macro assumption : Tactic assumption hole = getContext >>= λ Γ → assumption-tac 0 (length Γ) hole test-assumption : ∀ {A B : Set} → A → B → A test-assumption x y = assumption test-assumption₂ : ∀ {A B : Set} → A → B → _ test-assumption₂ x y = assumption -- will pick y -- Solving a goal using only constructors -- tryConstructors : Nat → List QName → Tactic constructors-tac : Nat → Type → Tactic constructors-tac zero _ _ = typeError (strErr "Search depth exhausted" ∷ []) constructors-tac (suc n) (def d vs) hole = getDefinition d >>= λ def → case def of λ { (dataDef _ cs) → tryConstructors n cs hole ; _ → returnTC _ } constructors-tac _ (pi a b) hole = give absurdLam hole constructors-tac _ _ hole = returnTC _ tryConstructors n [] hole = typeError (strErr "No matching constructor term" ∷ []) tryConstructors n (c ∷ cs) hole = visibleArity c >>= λ ar → catchTC (replicateTC ar newMeta! >>= λ vs → unify hole (con c (map (arg (argInfo visible relevant)) vs)) >>= λ _ → mapTC!r (quotegoal (constructors-tac n)) vs) (tryConstructors n cs hole) macro constructors : Tactic constructors = quotegoal (constructors-tac 10) data Any {A : Set} (P : A → Set) : List A → Set where zero : ∀ {x xs} → P x → Any P (x ∷ xs) suc : ∀ {x xs} → Any P xs → Any P (x ∷ xs) infix 1 _∈_ _∈_ : ∀ {A : Set} → A → List A → Set x ∈ xs = Any (x ≡_) xs data Dec (A : Set) : Set where yes : A → Dec A no : (A → ⊥) → Dec A test₁ : 3 ∈ 1 ∷ 2 ∷ 3 ∷ [] test₁ = constructors test₂ : Dec (2 + 3 ≡ 5) test₂ = constructors test₃ : Dec (2 + 2 ≡ 5) test₃ = constructors data Singleton (n : Nat) : Set where it : (m : Nat) → m ≡ n → Singleton n test₄ : Singleton 5 test₄ = constructors -- this works because we solve goals right to left (picking refl before m)
{ "alphanum_fraction": 0.6091458154, "avg_line_length": 29.218487395, "ext": "agda", "hexsha": "dc76b1d957c5e12daeaf369056f7bebebbae288c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/ReflectTC.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/ReflectTC.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/ReflectTC.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1165, "size": 3477 }
------------------------------------------------------------------------ -- Proofs of the map-iterate property and iterate fusion ------------------------------------------------------------------------ module MapIterate where open import Codata.Musical.Notation open import Codata.Musical.Stream as Stream using (Stream; map; zipWith; iterate; _≈_) open Stream.Stream; open Stream._≈_ open import Data.Nat open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; refl) private module SS {A : Set} = Setoid (Stream.setoid A) -- The map-iterate property: map-iterate : {A : Set} (f : A → A) (x : A) → map f (iterate f x) ≈ iterate f (f x) map-iterate f x = refl ∷ ♯ map-iterate f (f x) -- An equality proof language. infixr 5 _∷_ infix 4 _≈P_ _≈W_ infix 3 _∎ infixr 2 _≈⟨_⟩_ data _≈P_ {A : Set} : Stream A → Stream A → Set where _∷_ : ∀ (x : A) {xs ys} (xs≈ys : ∞ (♭ xs ≈P ♭ ys)) → x ∷ xs ≈P x ∷ ys _≈⟨_⟩_ : ∀ (xs : Stream A) {ys zs} (xs≈ys : xs ≈P ys) (ys≈zs : ys ≈P zs) → xs ≈P zs _∎ : (xs : Stream A) → xs ≈P xs zipWith-cong : ∀ (_∙_ : A → A → A) {xs₁ ys₁ xs₂ ys₂} (xs₁≈ys₁ : xs₁ ≈P ys₁) (xs₂≈ys₂ : xs₂ ≈P ys₂) → zipWith _∙_ xs₁ xs₂ ≈P zipWith _∙_ ys₁ ys₂ -- Completeness. completeP : {A : Set} {xs ys : Stream A} → xs ≈ ys → xs ≈P ys completeP (refl ∷ xs≈ys) = _ ∷ ♯ completeP (♭ xs≈ys) -- Weak head normal forms. data _≈W_ {A : Set} : Stream A → Stream A → Set where _∷_ : ∀ x {xs ys} (xs≈ys : ♭ xs ≈P ♭ ys) → x ∷ xs ≈W x ∷ ys transW : {A : Set} {xs ys zs : Stream A} → xs ≈W ys → ys ≈W zs → xs ≈W zs transW (x ∷ xs≈ys) (.x ∷ ys≈zs) = x ∷ (_ ≈⟨ xs≈ys ⟩ ys≈zs) reflW : {A : Set} (xs : Stream A) → xs ≈W xs reflW (x ∷ xs) = x ∷ (♭ xs ∎) zipWith-congW : ∀ {A : Set} (_∙_ : A → A → A) {xs₁ ys₁ xs₂ ys₂} → xs₁ ≈W ys₁ → xs₂ ≈W ys₂ → zipWith _∙_ xs₁ xs₂ ≈W zipWith _∙_ ys₁ ys₂ zipWith-congW _∙_ (x₁ ∷ xs₁≈ys₁) (x₂ ∷ xs₂≈ys₂) = (x₁ ∙ x₂) ∷ zipWith-cong _∙_ xs₁≈ys₁ xs₂≈ys₂ whnf : {A : Set} {xs ys : Stream A} → xs ≈P ys → xs ≈W ys whnf (x ∷ xs≈ys) = x ∷ ♭ xs≈ys whnf (xs ≈⟨ xs≈ys ⟩ ys≈zs) = transW (whnf xs≈ys) (whnf ys≈zs) whnf (xs ∎) = reflW xs whnf (zipWith-cong _∙_ xs₁≈ys₁ xs₂≈ys₂) = zipWith-congW _∙_ (whnf xs₁≈ys₁) (whnf xs₂≈ys₂) -- Soundness. mutual soundW : {A : Set} {xs ys : Stream A} → xs ≈W ys → xs ≈ ys soundW (x ∷ xs≈ys) = refl ∷ ♯ soundP xs≈ys soundP : {A : Set} {xs ys : Stream A} → xs ≈P ys → xs ≈ ys soundP xs≈ys = soundW (whnf xs≈ys) -- A small hack which enables me to write "by definition" below. definition : {A : Set} {xs : Stream A} → xs ≈P xs definition {xs = xs} = xs ∎ by : ∀ {A : Set} {x : A} {xs ys : ∞ (Stream A)} → ♭ xs ≈P ♭ ys → x ∷ xs ≈P x ∷ ys by {x = x} ♭xs≈♭ys = x ∷ ♯ ♭xs≈♭ys -- Iterate preserves equality. iterate-cong : {A : Set} (f : A → A) {x y : A} → x ≡ y → iterate f x ≈P iterate f y iterate-cong f {x} refl = iterate f x ∎ -- Iterate fusion. iterate-fusion : {A B : Set} (h : A → B) (f₁ : A → A) (f₂ : B → B) → ((x : A) → h (f₁ x) ≡ f₂ (h x)) → (x : A) → map h (iterate f₁ x) ≈P iterate f₂ (h x) iterate-fusion h f₁ f₂ hyp x = map h (iterate f₁ x) ≈⟨ by definition ⟩ h x ∷ ♯ map h (iterate f₁ (f₁ x)) ≈⟨ h x ∷ ♯ iterate-fusion h f₁ f₂ hyp (f₁ x) ⟩ h x ∷ ♯ iterate f₂ (h (f₁ x)) ≈⟨ h x ∷ ♯ iterate-cong f₂ (hyp x) ⟩ h x ∷ ♯ iterate f₂ (f₂ (h x)) ≈⟨ by definition ⟩ iterate f₂ (h x) ∎ -- The equation given for fib in StreamProg has a unique solution. fib-rhs : Stream ℕ → Stream ℕ fib-rhs ns = 0 ∷ ♯ zipWith _+_ ns (1 ∷ ♯ ns) fib-unique : ∀ ms ns → ms ≈ fib-rhs ms → ns ≈ fib-rhs ns → ms ≈P ns fib-unique ms ns ms≈ ns≈ = ms ≈⟨ completeP ms≈ ⟩ fib-rhs ms ≈⟨ 0 ∷ ♯ zipWith-cong _+_ (fib-unique ms ns ms≈ ns≈) (1 ∷ ♯ fib-unique ms ns ms≈ ns≈) ⟩ fib-rhs ns ≈⟨ completeP (SS.sym ns≈) ⟩ ns ∎
{ "alphanum_fraction": 0.5065190652, "avg_line_length": 33.5950413223, "ext": "agda", "hexsha": "01c51f153fa9b947f0d9540877594f43c20c5e52", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "MapIterate.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "MapIterate.agda", "max_line_length": 83, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "MapIterate.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 1732, "size": 4065 }
{-# OPTIONS --safe -W noTerminationIssue #-} data ⊥ : Set where bad : ⊥ bad = bad
{ "alphanum_fraction": 0.6071428571, "avg_line_length": 12, "ext": "agda", "hexsha": "0f5fd2ece3b897517ce9e679e6927826390f7833", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue5029.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue5029.agda", "max_line_length": 44, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue5029.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 27, "size": 84 }
module plfa.working.Induction where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_) +-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc zero n p = begin (zero + n) + p ≡⟨⟩ n + p ≡⟨⟩ zero + (n + p) ∎ +-assoc (suc m) n p = begin (suc m + n) + p ≡⟨⟩ suc (m + n) + p ≡⟨⟩ suc ((m + n) + p) ≡⟨ cong suc (+-assoc m n p) ⟩ suc (m + (n + p)) ≡⟨⟩ suc m + (n + p) ∎ +-identity : ∀ (m : ℕ) → m + zero ≡ m +-identity zero = begin zero + zero ≡⟨⟩ zero ∎ +-identity (suc m) = begin (suc m) + zero ≡⟨⟩ suc (m + zero) ≡⟨ cong suc (+-identity m) ⟩ suc m ∎ +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc zero n = begin zero + suc n ≡⟨⟩ suc n ≡⟨⟩ suc (zero + n) ∎ +-suc (suc m) n = begin suc m + suc n ≡⟨⟩ (suc m) + suc n ≡⟨ cong suc (+-suc m n) ⟩ suc (suc m + n) ∎ +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm m zero = begin m + zero ≡⟨ +-identity m ⟩ m ≡⟨⟩ zero + m ∎ +-comm m (suc n) = begin m + suc n ≡⟨ +-suc m n ⟩ suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ suc (n + m) ≡⟨⟩ suc n + m ∎
{ "alphanum_fraction": 0.389307745, "avg_line_length": 17.578313253, "ext": "agda", "hexsha": "0fb711fea744b2395d9a5af9848fa0b2990cf37f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "kaychaks/plfa.github.io", "max_forks_repo_path": "src/plfa/working/Induction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "kaychaks/plfa.github.io", "max_issues_repo_path": "src/plfa/working/Induction.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "kaychaks/plfa.github.io", "max_stars_repo_path": "src/plfa/working/Induction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 660, "size": 1459 }
{-# OPTIONS --sized-types --guardedness #-} -- Note: This module is not meant to be imported. module Js where import Data import Data.Boolean import FFI.IO as FFI main : FFI.IO Data.Unit main = FFI.printStrLn("Okay")
{ "alphanum_fraction": 0.7181818182, "avg_line_length": 18.3333333333, "ext": "agda", "hexsha": "991971e8100b79cdccdba97589697d48484e86a8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Js.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Js.agda", "max_line_length": 49, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Js.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 58, "size": 220 }
module _ where record R : Set₁ where field x : Set g : Set₁ module M (r : R) where open R r f = x g = R
{ "alphanum_fraction": 0.5739130435, "avg_line_length": 8.2142857143, "ext": "agda", "hexsha": "62dc1e9b5a42156d3d32baff36f417230c29c440", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue3010.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue3010.agda", "max_line_length": 22, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue3010.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 46, "size": 115 }
module Examples.Syntax where open import Agda.Builtin.Equality using (_≡_; refl) open import FFI.Data.String using (_++_) open import Luau.Syntax using (var; _$_; return; nil; function_⟨_⟩_end; done; _∙_) open import Luau.Syntax.ToString using (exprToString; blockToString) f = var "f" x = var "x" ex1 : exprToString(f $ x) ≡ "f(x)" ex1 = refl ex2 : blockToString(return nil ∙ done) ≡ "return nil" ex2 = refl ex3 : blockToString(function "f" ⟨ "x" ⟩ return x ∙ done end ∙ return f ∙ done) ≡ "local function f(x)\n" ++ " return x\n" ++ "end\n" ++ "return f" ex3 = refl
{ "alphanum_fraction": 0.6587030717, "avg_line_length": 23.44, "ext": "agda", "hexsha": "8af9bca8b12c78ce8740ee85dae049bf8b9808a8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FreakingBarbarians/luau", "max_forks_repo_path": "prototyping/Examples/Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "FreakingBarbarians/luau", "max_issues_repo_path": "prototyping/Examples/Syntax.agda", "max_line_length": 82, "max_stars_count": 1, "max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FreakingBarbarians/luau", "max_stars_repo_path": "prototyping/Examples/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z", "num_tokens": 199, "size": 586 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cw.CW open import cw.FinCW open import cw.FinBoundary open import cohomology.Theory module cw.cohomology.cochainequiv.HigherCoboundaryCommSquare (OT : OrdinaryTheory lzero) {n} (⊙fin-skel : ⊙FinSkeleton (S (S n))) where open OrdinaryTheory OT open import cw.cohomology.WedgeOfCells OT open import cw.cohomology.reconstructed.HigherCoboundary OT ⊙⦉ ⊙fin-skel ⦊ open import cw.cohomology.cochainequiv.DualizedHigherBoundary OT ⊙fin-skel open import cw.cohomology.cochainequiv.HigherCoboundary OT ⊙fin-skel private fin-skel = ⊙FinSkeleton.skel ⊙fin-skel I = AttachedFinSkeleton.numCells fin-skel ac = ⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero ⊙fin-skel₋₁ = ⊙fcw-init ⊙fin-skel fin-skel₋₁ = ⊙FinSkeleton.skel ⊙fin-skel₋₁ ac₋₁ = ⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel₋₁ lzero abstract rephrase-dualized-higher-boundary-comm-sqr : CommSquareEquiv (λ g <I → Group.sum (C2 0) (λ <I₋₁ → Group.exp (C2 0) (g <I₋₁) (fdegree-last fin-skel <I <I₋₁))) (_∘ᴳ fboundary-last fin-skel) (FreeAbGroup-extend (C2-abgroup 0)) (FreeAbGroup-extend (C2-abgroup 0)) rephrase-dualized-higher-boundary-comm-sqr = comm-sqr (λ g → equiv-adj' (GroupIso.f-equiv (FreeAbGroup-extend-iso (C2-abgroup 0))) (λ= λ <I → ! (rephrase-dualized-higher-boundary-in-degree g <I))) , FreeAbGroup-extend-is-equiv (C2-abgroup 0) , FreeAbGroup-extend-is-equiv (C2-abgroup 0) rephrase-cw-co∂-last-comm-sqr : CommSquareEquiv (λ g <I → Group.sum (C2 0) (λ <I₋₁ → Group.exp (C2 0) (g <I₋₁) (fdegree-last fin-skel <I <I₋₁))) (GroupHom.f cw-co∂-last) (GroupIso.g (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel₋₁ ⦊ ac₋₁)) (GroupIso.g (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel ⦊ ac)) rephrase-cw-co∂-last-comm-sqr = comm-sqr (λ g → equiv-adj' (GroupIso.g-equiv (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel ⦊ ac)) (λ= λ <I → ! (rephrase-cw-co∂-last-in-degree g <I))) , (GroupIso.g-is-equiv (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel₋₁ ⦊ ac₋₁)) , (GroupIso.g-is-equiv (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel ⦊ ac)) higher-coboundary-comm-sqr : CommSquareEquiv (GroupHom.f cw-co∂-last) (_∘ᴳ fboundary-last fin-skel) (FreeAbGroup-extend (C2-abgroup 0) ∘ GroupIso.f (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel₋₁ ⦊ ac₋₁)) (FreeAbGroup-extend (C2-abgroup 0) ∘ GroupIso.f (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel ⦊ ac)) higher-coboundary-comm-sqr = CommSquareEquiv-∘v rephrase-dualized-higher-boundary-comm-sqr (CommSquareEquiv-inverse-v rephrase-cw-co∂-last-comm-sqr) higher-coboundary-comm-sqrᴳ : CommSquareEquivᴳ cw-co∂-last (pre∘ᴳ-hom (C2-abgroup 0) (fboundary-last fin-skel)) (FreeAbGroup-extend-hom (C2-abgroup 0) ∘ᴳ GroupIso.f-hom (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel₋₁ ⦊ ac₋₁)) (FreeAbGroup-extend-hom (C2-abgroup 0) ∘ᴳ GroupIso.f-hom (CXₙ/Xₙ₋₁-diag-β ⊙⦉ ⊙fin-skel ⦊ ac)) higher-coboundary-comm-sqrᴳ = comm-sqrᴳ (fst higher-coboundary-comm-sqr □$_) , snd higher-coboundary-comm-sqr
{ "alphanum_fraction": 0.6636125654, "avg_line_length": 40.7466666667, "ext": "agda", "hexsha": "f6e81be8ac215f1b08d6e8042f66b09492b3560b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/cochainequiv/HigherCoboundaryCommSquare.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/cochainequiv/HigherCoboundaryCommSquare.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/cochainequiv/HigherCoboundaryCommSquare.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1280, "size": 3056 }
module CoinductiveAfterEvaluation where open import Common.Coinduction data Functor : Set where Id : Functor _·_ : Functor → Set → Set Id · A = A data ν (F : Functor) : Set where inn : ∞ (F · ν F) → ν F -- Evaluation is required to see that Id · ν Id is a coinductive type. foo : ∀ F → F · ν F foo Id = inn (♯ foo Id)
{ "alphanum_fraction": 0.6463414634, "avg_line_length": 18.2222222222, "ext": "agda", "hexsha": "c0dfd3cc64284d74e88bcfbc336468ee4e78f713", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/CoinductiveAfterEvaluation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/CoinductiveAfterEvaluation.agda", "max_line_length": 70, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/CoinductiveAfterEvaluation.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 109, "size": 328 }
module Dave.Algebra.Naturals.Definition where open import Dave.Equality public open import Dave.Structures.Monoid public data ℕ : Set where zero : ℕ suc : ℕ → ℕ one = suc zero two = suc one three = suc two four = suc three five = suc four six = suc five seven = suc six eight = suc seven nine = suc eight {-# BUILTIN NATURAL ℕ #-} ℕ-suc-≡ : ∀ {m n : ℕ} → m ≡ n → suc m ≡ suc n ℕ-suc-≡ refl = refl
{ "alphanum_fraction": 0.6108597285, "avg_line_length": 20.0909090909, "ext": "agda", "hexsha": "45ad5374d50f4eb222fa055e7e5db9d97f008217", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_path": "Dave/Algebra/Naturals/Definition.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DavidStahl97/formal-proofs", "max_issues_repo_path": "Dave/Algebra/Naturals/Definition.agda", "max_line_length": 47, "max_stars_count": null, "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_path": "Dave/Algebra/Naturals/Definition.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 152, "size": 442 }
module x07-747Negation-hc where open import Relation.Binary.PropositionalEquality using (_≡_; cong; refl; subst; sym) -- added last open import Data.Nat using (ℕ; zero; suc) open import Data.Empty using (⊥; ⊥-elim) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_; proj₁; proj₂) ------------------------------------------------------------------------------ -- NEGATION : defined as implying false -- import Relation.Nullary using (¬_) ¬_ : Set → Set ¬ A = A → ⊥ infix 3 ¬_ -- if both ¬ A and A hold, then ⊥ holds ¬-elim : ∀ {A : Set} → ¬ A → A --- → ⊥ ¬-elim ¬a a = ¬a a -- double negation introduction (cannot be eliminated in intuitionistic logic) ¬¬-intro : ∀ {A : Set} → A ----- → ¬ ¬ A -- ¬¬-intro a ¬a = ¬a a -- agda with auto split/fill to this ¬¬-intro a = λ ¬a → ¬a a -- easier to understand with ¬ def using anon λ -- triple negation elimination ¬¬¬-elim : ∀ {A : Set} → ¬ ¬ ¬ A ------- → ¬ A -- ¬¬¬-elim ¬¬¬a a = ¬-elim ¬¬¬a (¬¬-intro a) ¬¬¬-elim ¬¬¬a = λ a → ¬-elim ¬¬¬a (¬¬-intro a) -- import Relation.Nullary.Negation using (contraposition) -- one direction of the contrapositive -- the other direction cannot be proved in intuitionistic logic contraposition : ∀ {A B : Set} → (A → B) ----------- → (¬ B → ¬ A) -- contraposition a→b ¬b a = ¬b (a→b a) contraposition a→b = λ ¬b → λ a → ¬b (a→b a) -- not-equal-to _≢_ : ∀ {A : Set} → A → A → Set x ≢ y = ¬ (x ≡ y) _ : 1 ≢ 2 _ = λ () -- a first-order Peano axioms peano : ∀ {m : ℕ} → zero ≢ suc m peano () open import x05-842Isomorphism-hc using (extensionality) -- two proofs of ⊥ → ⊥ -- they look different but are the same (assuming extensionality) id : ⊥ → ⊥ id x = x id′ : ⊥ → ⊥ id′ () id≡id′ : id ≡ id′ id≡id′ = extensionality (λ()) -- assuming extensionality, any two proofs of a negation are the same assimilation : ∀ {A : Set} (¬x ¬x′ : ¬ A) → ¬x ≡ ¬x′ assimilation ¬x ¬x′ = extensionality λ x → ⊥-elim (¬x x) -- BEGIN: Strict inequality (copied from 747Relations). infix 4 _<_ data _<_ : ℕ → ℕ → Set where z<s : ∀ {n : ℕ} ------------ → zero < suc n s<s : ∀ {m n : ℕ} → m < n ------------- → suc m < suc n -- END: Strict inequality (copied from 747Relations). -- NotFourLTThree ¬4<3 : ¬ (4 < 3) ¬4<3 (s<s (s<s (s<s ()))) -- < is irreflexive (never reflexive) ¬n<n : ∀ (n : ℕ) → ¬ (n < n) -- ¬n<n (suc n) (s<s n<n) = ¬n<n n n<n ¬n<n (suc n) = λ { (s<s n<n) → ¬n<n n n<n } -- 747/PLFA exercise: LTTrich (3 points) -- Prove that strict inequality satisfies trichotomy : exactly one of the three possibilities holds. data Trichotomy (m n : ℕ) : Set where is-< : m < n → ¬ m ≡ n → ¬ n < m → Trichotomy m n is-≡ : m ≡ n → ¬ m < n → ¬ n < m → Trichotomy m n is-> : n < m → ¬ m ≡ n → ¬ m < n → Trichotomy m n open import x03-842Relations-hc-2 using (suc-injective; m≡n→sucm≡sucn) inv-s<s : ∀ {m n : ℕ} → suc m < suc n ------------- → m < n inv-s<s (s<s m<n) = m<n <-trichotomy : ∀ (m n : ℕ) → Trichotomy m n <-trichotomy zero zero = is-≡ refl (λ ()) (λ ()) <-trichotomy zero (suc n) = is-< z<s (λ ()) (λ ()) <-trichotomy (suc m) zero = is-> z<s (λ ()) (λ ()) <-trichotomy (suc m) (suc n) with <-trichotomy m n ... | is-< m<n ¬m≡n ¬n<m = is-< (s<s m<n) (λ sucm≡sucn → ¬m≡n (suc-injective sucm≡sucn)) (λ sucn<sucm → ¬n<m (inv-s<s sucn<sucm)) ... | is-≡ m≡n ¬m<n ¬n<m = is-≡ (m≡n→sucm≡sucn m n m≡n) (λ sucm<sucn → ¬m<n (inv-s<s sucm<sucn)) (λ sucn<sucm → ¬n<m (inv-s<s sucn<sucm)) ... | is-> n<m ¬m≡n ¬m<n = is-> (s<s n<m) (λ sucm≡sucn → ¬m≡n (suc-injective sucm≡sucn)) (λ sucm<sucn → ¬m<n (inv-s<s sucm<sucn)) -- PLFA exercise: one of DeMorgan's Laws as isomorphism TODO -- ⊎-dual-× : ∀ {A B : Set} → ¬ (A ⊎ B) ≃ (¬ A) × (¬ B) -- Expand negation as implies-false, then look in 747Relations -- for a law of which this is a special case. -- What about ¬ (A × B) ≃ (¬ A) ⊎ (¬ B)? -- Answer: RHS implies LHS but converse cannot be proved in intuitionistic logic. -- Intuitionistic vs classical logic. -- The law of the excluded middle (LEM, or just em) cannot be proved in intuitionistic logic. -- LEM can be added to intuitionistic logic to get classical logic. -- postulate -- em : ∀ {A : Set} → A ⊎ ¬ A -- 'em-irrefutable' theorem of intuitionistic logic demonstrates -- that 'em' does not give a contradiction? em-irrefutable : ∀ {A : Set} → ¬ ¬ (A ⊎ ¬ A) em-irrefutable = λ z → z (inj₂ (λ x → z (inj₁ x))) -- PLFA exercise: classical equivalences TODO -- Here are four other classical theorems that can be added and are consisstent in IT. -- Prove each is logically equivalent to all the others. -- It is NOT necessary to prove twenty implications, since implication is transitive. -- There is a lot of choice as to how to proceed. -- Excluded Middle em = ∀ {A : Set} → A ⊎ ¬ A -- Double Negation Elimination dne = ∀ {A : Set} → ¬ ¬ A → A -- Peirce’s Law peirce = ∀ {A B : Set} → ((A → B) → A) → A -- Implication as disjunction iad = ∀ {A B : Set} → (A → B) → ¬ A ⊎ B -- De Morgan: dem = ∀ {A B : Set} → ¬ (¬ A × ¬ B) → A ⊎ B -- End of classical five exercise. -- Definition: a formula is stable if double negation holds for it. Stable : Set → Set Stable A = ¬ ¬ A → A -- PLFA exercise: every negated formula is stable. -- This is triple negation elimination. -- PLFA exercise: the conjunction of two stable formulas is stable. -- This is the version of DeMorgan's Law that is a special case, above.
{ "alphanum_fraction": 0.5522151899, "avg_line_length": 30.4171122995, "ext": "agda", "hexsha": "a57ba375ac75c292adbdc8244eac292c9fc6cec3", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation-hc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation-hc.agda", "max_line_length": 100, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation-hc.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 2010, "size": 5688 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Cast {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties import Definition.Typed.Weakening as Twk open import Definition.Typed.EqualityRelation open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution import Definition.LogicalRelation.Weakening as Lwk open import Definition.LogicalRelation.Substitution.Properties import Definition.LogicalRelation.Substitution.Irrelevance as S open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Weakening -- open import Definition.LogicalRelation.Substitution.Introductions.Nat open import Definition.LogicalRelation.Substitution.Introductions.Empty open import Definition.LogicalRelation.ShapeView -- open import Definition.LogicalRelation.Substitution.Introductions.Pi -- open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Definition.LogicalRelation.Substitution.MaybeEmbed open import Definition.LogicalRelation.Substitution.Introductions.Castlemmas open import Tools.Product open import Tools.Empty using (⊥; ⊥-elim) import Tools.Unit as TU import Tools.PropositionalEquality as PE import Data.Nat as Nat ~-irrelevanceTerm : ∀ {t t' u u' A A' r Γ} (eqA : A PE.≡ A') (eqt : t PE.≡ t') (equ : u PE.≡ u') → Γ ⊢ t ~ u ∷ A ^ r → Γ ⊢ t' ~ u' ∷ A' ^ r ~-irrelevanceTerm PE.refl PE.refl PE.refl X = X [cast]irr : ∀ {A B Γ} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ % , ι ⁰ ]) ([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ % , ι ⁰ ]) → ∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ % , ι ⁰ ] / [A]) → (⊢e : Γ ⊢ e ∷ Id (Univ % ⁰) A B ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ % , ι ⁰ ] / [B] [cast]irr {A} {B} ⊢Γ [A] [B] {t} {e} [t] ⊢e = let ⊢A = escape {l = ι ⁰} {A = A} [A] ⊢B = escape {l = ι ⁰} {A = B} [B] ⊢t = escapeTerm {l = ι ⁰} {A = A} [A] [t] in logRelIrr [B] (castⱼ (un-univ ⊢A) (un-univ ⊢B) ⊢e ⊢t) [castext]irr : ∀ {A A′ B B′ Γ} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ % , ι ⁰ ]) ([A′] : Γ ⊩⟨ ι ⁰ ⟩ A′ ^ [ % , ι ⁰ ]) ([A≡A′] : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A′ ^ [ % , ι ⁰ ] / [A]) ([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ % , ι ⁰ ]) ([B′] : Γ ⊩⟨ ι ⁰ ⟩ B′ ^ [ % , ι ⁰ ]) ([B≡B′] : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B′ ^ [ % , ι ⁰ ] / [B]) → (∀ {t t′ e e′} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ % , ι ⁰ ] / [A]) → ([t′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ∷ A′ ^ [ % , ι ⁰ ] / [A′]) → ([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ A ^ [ % , ι ⁰ ] / [A]) → (⊢e : Γ ⊢ e ∷ Id (Univ % ⁰) A B ^ [ % , ι ¹ ]) → (⊢e′ : Γ ⊢ e′ ∷ Id (Univ % ⁰) A′ B′ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ≡ cast ⁰ A′ B′ e′ t′ ∷ B ^ [ % , ι ⁰ ] / [B]) [castext]irr {A} {A′} {B} {B′} ⊢Γ [A] [A′] [A≡A′] [B] [B′] [B≡B′] [t] [t′] [t≡t′] ⊢e ⊢e′ = let ⊢A = escape {l = ι ⁰} {A = A} [A] ⊢B = escape {l = ι ⁰} {A = B} [B] ⊢A′ = escape {l = ι ⁰} {A = A′} [A′] ⊢B′ = escape {l = ι ⁰} {A = B′} [B′] ⊢t = escapeTerm {l = ι ⁰} {A = A} [A] [t] ⊢t′ = escapeTerm {l = ι ⁰} {A = A′} [A′] [t′] in logRelIrrEq [B] (castⱼ (un-univ ⊢A) (un-univ ⊢B) ⊢e ⊢t) (conv (castⱼ (un-univ ⊢A′) (un-univ ⊢B′) ⊢e′ ⊢t′) (sym (≅-eq (escapeEq [B] [B≡B′])))) [cast]Ne : ∀ {A B Γ} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩ne A ^[ ! , ⁰ ]) ([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ ! , ι ⁰ ]) → ∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ ! , ι ⁰ ] / ne [A]) → (⊢e : Γ ⊢ e ∷ Id (Univ ! ⁰) A B ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ ! , ι ⁰ ] / [B] [cast]Ne {A} {B} ⊢Γ (ne K D neK K≡K) [B] {t} {e} [t] ⊢e = let [[ ⊢A , ⊢K , DK ]] = D ⊢A≡K = subset* DK ⊢B = escape {l = ι ⁰} [B] B≅B = ≅-un-univ (escapeEq {l = ι ⁰} [B] (reflEq {l = ι ⁰} [B])) ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) (un-univ≡ ⊢A≡K) (refl (un-univ ⊢B)))) cast~cast = ~-cast K≡K B≅B (≅-conv (escapeTermEq {l = ι ⁰} {A = A} (ne′ K D neK K≡K) (reflEqTerm {l = ι ⁰} (ne′ K D neK K≡K) [t])) ⊢A≡K) ⊢e' ⊢e' in neuTerm:⇒*: {t = cast ⁰ A B e t} [B] (castₙ neK) (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ne′ K D neK K≡K) [t]) (un-univ:⇒*: D)) cast~cast [castext]Ne : ∀ {A A′ B B′ Γ} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩ne A ^[ ! , ⁰ ]) ([A′] : Γ ⊩ne A′ ^[ ! , ⁰ ]) ([A≡A′] : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A′ ^ [ ! , ι ⁰ ] / ne [A]) ([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ ! , ι ⁰ ]) ([B′] : Γ ⊩⟨ ι ⁰ ⟩ B′ ^ [ ! , ι ⁰ ]) ([B≡B′] : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B′ ^ [ ! , ι ⁰ ] / [B]) → (∀ {t t′ e e′} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ ! , ι ⁰ ] / ne [A]) → ([t′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ∷ A′ ^ [ ! , ι ⁰ ] / ne [A′]) → ([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ A ^ [ ! , ι ⁰ ] / ne [A]) → (⊢e : Γ ⊢ e ∷ Id (U ⁰) A B ^ [ % , ι ¹ ]) → (⊢e′ : Γ ⊢ e′ ∷ Id (U ⁰) A′ B′ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ≡ cast ⁰ A′ B′ e′ t′ ∷ B ^ [ ! , ι ⁰ ] / [B]) [castext]Ne {A} {A′} {B} {B′} ⊢Γ (ne K D neK K≡K) (ne K′ D′ neK′ K′≡K′) (ne₌ M D′′ neM K≡M) [B] [B′] [B≡B′] [t] [t′] [t≡t′] ⊢e ⊢e′ = let [A] = ne K D neK K≡K [A′] = ne K′ D′ neK′ K′≡K′ [[ ⊢A , ⊢K , DK ]] = D ⊢A≡K = subset* DK [[ _ , _ , DM ]] = D′′ ⊢A'≡M = subset* DM ⊢A = escape {l = ι ⁰} {A = A} (ne [A]) ⊢B = escape {l = ι ⁰} {A = B} [B] ⊢A′ = escape {l = ι ⁰} {A = A′} (ne [A′]) ⊢B′ = escape {l = ι ⁰} {A = B′} [B′] ⊢t = escapeTerm {l = ι ⁰} {A = A} (ne [A]) [t] ⊢t′ = escapeTerm {l = ι ⁰} {A = A′} (ne [A′]) [t′] t≅t′ = escapeTermEq {l = ι ⁰} {A = A} (ne [A]) [t≡t′] ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) (un-univ≡ ⊢A≡K) (refl (un-univ ⊢B)))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) (un-univ≡ ⊢A'≡M) (refl (un-univ ⊢B′)))) in neuEqTerm:⇒*: [B] (castₙ neK) (castₙ neM) (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ne [A]) [t]) (un-univ:⇒*: D)) (conv:⇒*: (CastRed*Term ⊢B′ ⊢e′ (escapeTerm {l = ι ⁰} (ne [A′]) [t′]) (un-univ:⇒*: D′′)) (sym (≅-eq (escapeEq [B] [B≡B′])))) (~-cast K≡M (≅-un-univ (escapeEq [B] [B≡B′])) (≅-conv t≅t′ (subset* (red D))) ⊢e' ⊢e′') [cast]ℕ : ∀ {A B Γ} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩ℕ A) ([B] : Γ ⊩ℕ B) → ∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ ! , ι ⁰ ] / ℕᵣ [A]) → (⊢e : Γ ⊢ e ∷ Id (Univ ! ⁰) A B ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ ! , ι ⁰ ] / ℕᵣ [B] [cast]ℕ {A} {B} ⊢Γ [[ ⊢A , ⊢ℕ , D ]] [[ ⊢B , ⊢ℕ' , D' ]] {t} {e} (ℕₜ .(suc _) d n≡n (sucᵣ {a} x)) ⊢e = let ⊢t = escapeTerm {l = ι ⁰} (ℕᵣ [[ ⊢A , ⊢ℕ , D ]]) (ℕₜ (suc a) d n≡n (sucᵣ x)) [N] = idRed:*: (univ (ℕⱼ ⊢Γ)) ⊢eℕℕ = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* D)) (un-univ≡ (subset* D')))) ⊢eℕB = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* D)) (refl (un-univ ⊢B)))) rec = [cast]ℕ ⊢Γ (idRed:*: ⊢ℕ) (idRed:*: ⊢ℕ) x ⊢eℕℕ cast≅cast = escapeTermEq {l = ι ⁰} (ℕᵣ (idRed:*: ⊢ℕ)) (reflEqTerm {l = ι ⁰} (ℕᵣ (idRed:*: ⊢ℕ)) rec) in ℕₜ (suc (cast ⁰ ℕ ℕ e a)) ((conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ [[ ⊢A , ⊢ℕ , D ]]) (ℕₜ (suc a) d n≡n (sucᵣ x))) (un-univ:⇒*: [[ ⊢A , ⊢ℕ , D ]])) (transTerm:⇒:* (CastRed*Termℕ ⊢eℕB (conv ⊢t (subset* D)) [[ ⊢B , ⊢ℕ' , D' ]]) (conv:⇒*: (transTerm:⇒:* (CastRed*Termℕℕ ⊢eℕℕ d) (CastRed*Termℕsuc ⊢eℕℕ (escapeTerm {l = ι ⁰} (ℕᵣ (idRed:*: ⊢ℕ)) x))) (sym (subset* D'))))) (subset* D') )) (≅-suc-cong cast≅cast) (Natural-prop.sucᵣ rec) [cast]ℕ {A} {B} ⊢Γ [[ ⊢A , ⊢ℕ , D ]] [[ ⊢B , ⊢ℕ' , D' ]] {t} {e} (ℕₜ .zero d n≡n zeroᵣ) ⊢e = let ⊢t = escapeTerm {l = ι ⁰} (ℕᵣ [[ ⊢A , ⊢ℕ , D ]]) (ℕₜ zero d n≡n zeroᵣ) ⊢eℕℕ = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* D)) (un-univ≡ (subset* D')))) in ℕₜ zero ((conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ [[ ⊢A , ⊢ℕ , D ]]) (ℕₜ zero d n≡n zeroᵣ)) (un-univ:⇒*: [[ ⊢A , ⊢ℕ , D ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* D)) (refl (un-univ ⊢B))))) (conv ⊢t (subset* D)) [[ ⊢B , ⊢ℕ' , D' ]]) (conv:⇒*: (transTerm:⇒:* (CastRed*Termℕℕ ⊢eℕℕ d) (CastRed*Termℕzero ⊢eℕℕ)) (sym (subset* D'))))) (subset* D') )) (≅ₜ-zerorefl ⊢Γ) Natural-prop.zeroᵣ [cast]ℕ {A} {B} ⊢Γ [[ ⊢A , ⊢ℕ , D ]] [[ ⊢B , ⊢ℕ' , D' ]] {t} {e} (ℕₜ n d n≡n (ne x)) ⊢e = let ⊢t = escapeTerm {l = ι ⁰} (ℕᵣ [[ ⊢A , ⊢ℕ , D ]]) (ℕₜ n d n≡n (ne x)) ⊢eℕℕ = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* D)) (un-univ≡ (subset* D')))) neNfₜ nen ⊢n n~n = x in ℕₜ (cast ⁰ ℕ ℕ e n) ((conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ [[ ⊢A , ⊢ℕ , D ]]) (ℕₜ n d n≡n (ne x))) (un-univ:⇒*: [[ ⊢A , ⊢ℕ , D ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* D)) (refl (un-univ ⊢B))))) (conv ⊢t (subset* D)) [[ ⊢B , ⊢ℕ' , D' ]]) (conv:⇒*: (CastRed*Termℕℕ ⊢eℕℕ d) (sym (subset* D'))))) (subset* D') )) (~-to-≅ₜ (~-castℕℕ (wfTerm ⊢n) n~n ⊢eℕℕ ⊢eℕℕ)) (ne (neNfₜ (castℕℕₙ nen) (castⱼ (ℕⱼ (wfTerm ⊢n)) (ℕⱼ (wfTerm ⊢n)) ⊢eℕℕ ⊢n) (~-castℕℕ (wfTerm ⊢n) n~n ⊢eℕℕ ⊢eℕℕ))) [castext]ℕ : ∀ {A A' B B' Γ} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩ℕ A) ([A'] : Γ ⊩ℕ A') ([A≡A′] : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A' ^ [ ! , ι ⁰ ] / ℕᵣ [A]) ([B] : Γ ⊩ℕ B) ([B'] : Γ ⊩ℕ B') ([B≡B′] : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B' ^ [ ! , ι ⁰ ] / ℕᵣ [B]) → ∀ {t t' e e' } → (⊢t : Γ ⊢ t ∷ A ^ [ ! , ι ⁰ ]) → (⊢t′ : Γ ⊢ t' ∷ A' ^ [ ! , ι ⁰ ]) → ([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t' ∷ A ^ [ ! , ι ⁰ ] / ℕᵣ [A]) → (⊢e : Γ ⊢ e ∷ Id (U ⁰) A B ^ [ % , ι ¹ ]) → (⊢e′ : Γ ⊢ e' ∷ Id (U ⁰) A' B' ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ≡ cast ⁰ A' B' e' t' ∷ B ^ [ ! , ι ⁰ ] / ℕᵣ [B] [castext]ℕ ⊢Γ [[ ⊢A , ⊢ℕA , DA ]] [[ ⊢A' , ⊢ℕA' , DA' ]] [A≡A′] [[ ⊢B , ⊢ℕB , DB ]] [[ ⊢B' , ⊢ℕB' , DB' ]] [B≡B′] {t} {t'} {e} {e'} ⊢t ⊢t′ (ℕₜ₌ .(suc a) .(suc a') d d′ k≡k′ (sucᵣ {a} {a'} (ℕₜ₌ k k′ [[ ⊢a , ⊢u , d₁ ]] [[ ⊢a' , ⊢u₁ , d₂ ]] k≡k′₁ prop))) ⊢e ⊢e′ = let ⊢eℕℕ = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* DA)) (un-univ≡ (subset* DB)))) ⊢eℕℕ' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢B') )) (un-univ≡ (subset* DA')) (un-univ≡ (subset* DB')))) ⊢B≡B′ = escapeEq {l = ι ⁰} (ℕᵣ [[ ⊢B , ⊢ℕB , DB ]]) [B≡B′] rec = [castext]ℕ ⊢Γ (idRed:*: ⊢ℕA) (idRed:*: ⊢ℕA) (reflEq {l = ι ⁰} (ℕᵣ (idRed:*: ⊢ℕA))) (idRed:*: ⊢ℕA) (idRed:*: ⊢ℕA) (reflEq {l = ι ⁰} (ℕᵣ (idRed:*: ⊢ℕA))) ⊢a ⊢a' (ℕₜ₌ k k′ [[ ⊢a , ⊢u , d₁ ]] [[ ⊢a' , ⊢u₁ , d₂ ]] k≡k′₁ prop) ⊢eℕℕ ⊢eℕℕ' cast≅cast = escapeTermEq {l = ι ⁰} (ℕᵣ (idRed:*: ⊢ℕA)) rec in ℕₜ₌ (suc (cast ⁰ ℕ ℕ e a)) (suc (cast ⁰ ℕ ℕ e' a')) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B ⊢e ⊢t (un-univ:⇒*: [[ ⊢A , ⊢ℕA , DA ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* DA)) (refl (un-univ ⊢B))))) (conv ⊢t (subset* DA)) [[ ⊢B , ⊢ℕB , DB ]]) (conv:⇒*: (transTerm:⇒:* (CastRed*Termℕℕ ⊢eℕℕ d) (CastRed*Termℕsuc ⊢eℕℕ ⊢a)) (sym (subset* DB))))) (subset* DB)) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B' ⊢e′ ⊢t′ (un-univ:⇒*: [[ ⊢A' , ⊢ℕA' , DA' ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* DA')) (refl (un-univ ⊢B'))))) (conv ⊢t′ (subset* DA')) [[ ⊢B' , ⊢ℕB' , DB' ]]) (conv:⇒*: (transTerm:⇒:* (CastRed*Termℕℕ ⊢eℕℕ' d′) (CastRed*Termℕsuc ⊢eℕℕ' ⊢a')) (sym (subset* DB'))))) (subset* DB')) (≅-suc-cong cast≅cast) (sucᵣ rec) [castext]ℕ ⊢Γ [[ ⊢A , ⊢ℕA , DA ]] [[ ⊢A' , ⊢ℕA' , DA' ]] [A≡A′] [[ ⊢B , ⊢ℕB , DB ]] [[ ⊢B' , ⊢ℕB' , DB' ]] [B≡B′] ⊢t ⊢t′ (ℕₜ₌ .zero .zero d d′ k≡k′ zeroᵣ) ⊢e ⊢e′ = let ⊢eℕℕ = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* DA)) (un-univ≡ (subset* DB)))) ⊢eℕℕ' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢B') )) (un-univ≡ (subset* DA')) (un-univ≡ (subset* DB')))) ⊢B≡B′ = escapeEq {l = ι ⁰} (ℕᵣ [[ ⊢B , ⊢ℕB , DB ]]) [B≡B′] in ℕₜ₌ zero zero (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B ⊢e ⊢t (un-univ:⇒*: [[ ⊢A , ⊢ℕA , DA ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* DA)) (refl (un-univ ⊢B))))) (conv ⊢t (subset* DA)) [[ ⊢B , ⊢ℕB , DB ]]) (conv:⇒*: (transTerm:⇒:* (CastRed*Termℕℕ ⊢eℕℕ d) (CastRed*Termℕzero ⊢eℕℕ)) (sym (subset* DB))))) (subset* DB)) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B' ⊢e′ ⊢t′ (un-univ:⇒*: [[ ⊢A' , ⊢ℕA' , DA' ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* DA')) (refl (un-univ ⊢B'))))) (conv ⊢t′ (subset* DA')) [[ ⊢B' , ⊢ℕB' , DB' ]]) (conv:⇒*: (transTerm:⇒:* (CastRed*Termℕℕ ⊢eℕℕ' d′) (CastRed*Termℕzero ⊢eℕℕ')) (sym (subset* DB'))))) (subset* DB')) (≅ₜ-zerorefl ⊢Γ) zeroᵣ [castext]ℕ ⊢Γ [[ ⊢A , ⊢ℕA , DA ]] [[ ⊢A' , ⊢ℕA' , DA' ]] [A≡A′] [[ ⊢B , ⊢ℕB , DB ]] [[ ⊢B' , ⊢ℕB' , DB' ]] [B≡B′] ⊢t ⊢t′ (ℕₜ₌ k k′ d d′ k≡k′ (ne (neNfₜ₌ neK neM k≡m))) ⊢e ⊢e′ = let ⊢eℕℕ = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ (subset* DA)) (un-univ≡ (subset* DB)))) ⊢eℕℕ' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢B') )) (un-univ≡ (subset* DA')) (un-univ≡ (subset* DB')))) ⊢B≡B′ = escapeEq {l = ι ⁰} (ℕᵣ [[ ⊢B , ⊢ℕB , DB ]]) [B≡B′] in neuEqTerm:⇒*: {l = ι ⁰} (ℕᵣ [[ ⊢B , ⊢ℕB , DB ]]) (castℕℕₙ neK) (castℕℕₙ neM) (transTerm:⇒:* (CastRed*Term ⊢B ⊢e ⊢t (un-univ:⇒*: [[ ⊢A , ⊢ℕA , DA ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) ))(un-univ≡ (subset* DA)) (refl (un-univ ⊢B))))) (conv ⊢t (subset* DA)) [[ ⊢B , ⊢ℕB , DB ]]) (conv:⇒*: (CastRed*Termℕℕ ⊢eℕℕ d) (sym (subset* DB))))) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B' ⊢e′ ⊢t′ (un-univ:⇒*: [[ ⊢A' , ⊢ℕA' , DA' ]])) (transTerm:⇒:* (CastRed*Termℕ (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢B') ))(un-univ≡ (subset* DA')) (refl (un-univ ⊢B'))))) (conv ⊢t′ (subset* DA')) [[ ⊢B' , ⊢ℕB' , DB' ]]) (conv:⇒*: (CastRed*Termℕℕ ⊢eℕℕ' d′) (sym (subset* DB'))))) (sym (≅-eq ⊢B≡B′))) (~-conv (~-castℕℕ ⊢Γ k≡m ⊢eℕℕ ⊢eℕℕ') (sym (subset* DB))) [cast] : ∀ {A B Γ r} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ r , ι ⁰ ]) ([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ r , ι ⁰ ]) → (∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]) → (⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ r , ι ⁰ ] / [B]) × (∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ B ^ [ r , ι ⁰ ] / [B]) → (⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) B A ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ B A e t ∷ A ^ [ r , ι ⁰ ] / [A]) [castext] : ∀ {A A′ B B′ Γ r} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ r , ι ⁰ ]) ([A′] : Γ ⊩⟨ ι ⁰ ⟩ A′ ^ [ r , ι ⁰ ]) ([A≡A′] : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A′ ^ [ r , ι ⁰ ] / [A]) ([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ r , ι ⁰ ]) ([B′] : Γ ⊩⟨ ι ⁰ ⟩ B′ ^ [ r , ι ⁰ ]) ([B≡B′] : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B′ ^ [ r , ι ⁰ ] / [B]) → (∀ {t t′ e e′} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]) → ([t′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ∷ A′ ^ [ r , ι ⁰ ] / [A′]) → ([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ A ^ [ r , ι ⁰ ] / [A]) → (⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ]) → (⊢e′ : Γ ⊢ e′ ∷ Id (Univ r ⁰) A′ B′ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ≡ cast ⁰ A′ B′ e′ t′ ∷ B ^ [ r , ι ⁰ ] / [B]) × (∀ {t t′ e e′} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ B ^ [ r , ι ⁰ ] / [B]) → ([t′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ∷ B′ ^ [ r , ι ⁰ ] / [B′]) → ([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ B ^ [ r , ι ⁰ ] / [B]) → (⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) B A ^ [ % , ι ¹ ]) → (⊢e′ : Γ ⊢ e′ ∷ Id (Univ r ⁰) B′ A′ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ B A e t ≡ cast ⁰ B′ A′ e′ t′ ∷ A ^ [ r , ι ⁰ ] / [A]) [castextShape] : ∀ {A A′ B B′ Γ r} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ r , ι ⁰ ]) ([A′] : Γ ⊩⟨ ι ⁰ ⟩ A′ ^ [ r , ι ⁰ ]) (ShapeA : ShapeView Γ (ι ⁰) (ι ⁰) A A′ [ r , ι ⁰ ] [ r , ι ⁰ ] [A] [A′]) ([A≡A′] : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A′ ^ [ r , ι ⁰ ] / [A]) ([B] : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ r , ι ⁰ ]) ([B′] : Γ ⊩⟨ ι ⁰ ⟩ B′ ^ [ r , ι ⁰ ]) (ShapeB : ShapeView Γ (ι ⁰) (ι ⁰) B B′ [ r , ι ⁰ ] [ r , ι ⁰ ] [B] [B′]) ([B≡B′] : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B′ ^ [ r , ι ⁰ ] / [B]) → (∀ {t t′ e e′} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]) → ([t′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ∷ A′ ^ [ r , ι ⁰ ] / [A′]) → ([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ A ^ [ r , ι ⁰ ] / [A]) → (⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ]) → (⊢e′ : Γ ⊢ e′ ∷ Id (Univ r ⁰) A′ B′ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ≡ cast ⁰ A′ B′ e′ t′ ∷ B ^ [ r , ι ⁰ ] / [B]) × (∀ {t t′ e e′} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ B ^ [ r , ι ⁰ ] / [B]) → ([t′] : Γ ⊩⟨ ι ⁰ ⟩ t′ ∷ B′ ^ [ r , ι ⁰ ] / [B′]) → ([t≡t′] : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t′ ∷ B ^ [ r , ι ⁰ ] / [B]) → (⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) B A ^ [ % , ι ¹ ]) → (⊢e′ : Γ ⊢ e′ ∷ Id (Univ r ⁰) B′ A′ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ B A e t ≡ cast ⁰ B′ A′ e′ t′ ∷ A ^ [ r , ι ⁰ ] / [A]) [cast] ⊢Γ (ℕᵣ x) (ℕᵣ x₁) = (λ [t] ⊢e → [cast]ℕ ⊢Γ x x₁ [t] ⊢e) , (λ [t] ⊢e → [cast]ℕ ⊢Γ x₁ x [t] ⊢e) [cast] {A} {B} ⊢Γ (ℕᵣ x) (ne′ K [[ ⊢B , ⊢K , D ]] neK K≡K) = (λ {t} {e} [t] ⊢e → let ⊢A≡ℕ = let [[ _ , _ , Dx ]] = x in un-univ≡ (subset* Dx) ⊢B≡K = un-univ≡ (subset* D) ⊢A≡ℕ' = let [[ _ , _ , Dx ]] = x in subset* Dx ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) ⊢A≡ℕ' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢A≡ℕ ⊢B≡K)) in neₜ (cast ⁰ ℕ K e t) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) (un-univ:⇒*: x)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢A≡ℕ (refl (un-univ ⊢B))))) ⊢t [[ ⊢B , ⊢K , D ]])) (subset* D) ) (neNfₜ (castℕₙ neK) (castⱼ (ℕⱼ (wf ⊢B)) (un-univ ⊢K) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢A≡ℕ (un-univ≡ (subset* D))))) ⊢t) (~-castℕ (wf ⊢B) K≡K (≅-conv (escapeTermEq {l = ι ⁰} {A = A} (ℕᵣ x) (reflEqTerm {l = ι ⁰} (ℕᵣ x) [t])) ⊢A≡ℕ' ) ⊢e' ⊢e'))) , λ {t} {e} [t] ⊢e → [cast]Ne ⊢Γ (ne K [[ ⊢B , ⊢K , D ]] neK K≡K) (ℕᵣ x) [t] ⊢e [cast] {A} {B} {r = .!} ⊢Γ (ℕᵣ x) (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) = (λ {t} {e} [t] ⊢e → let ⊢A≡ℕ = let [[ _ , _ , Dx ]] = x in un-univ≡ (subset* (red x)) ⊢A≡ℕ' = let [[ _ , _ , Dx ]] = x in subset* (red x) ⊢B≡Π = un-univ≡ (subset* D) ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) ⊢A≡ℕ' t≅t = ≅-conv (escapeTermEq {l = ι ⁰} {A = A} (ℕᵣ x) (reflEqTerm {l = ι ⁰} (ℕᵣ x) [t])) ⊢A≡ℕ' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢A≡ℕ ⊢B≡Π)) cast~cast = ~-castℕΠ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ B≡B) t≅t ⊢e' ⊢e' in neuTerm:⇒*: {t = cast ⁰ A B e t} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) castℕΠₙ (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) (un-univ:⇒*: x)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢A≡ℕ (refl (un-univ ⊢B))))) ⊢t [[ ⊢B , ⊢Π , D ]])) (~-conv cast~cast (sym (subset* D)))) , λ {t} {e} [t] ⊢e → let ⊢B≡Π = un-univ≡ (subset* D) ⊢B≡Π' = subset* D [[ ⊢A , ⊢N , Dx ]] = x ⊢A≡ℕ = subset* Dx ⊢t' = escapeTerm {l = ι ⁰} {A = B} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) [t] ⊢t = conv {B = (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰)} ⊢t' ⊢B≡Π' t≅t = ≅-conv (escapeTermEq {l = ι ⁰} {A = B} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) (reflEqTerm {l = ι ⁰} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) [t])) ⊢B≡Π' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢B≡Π (un-univ≡ ⊢A≡ℕ))) cast~cast = ~-castΠℕ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ B≡B) t≅t ⊢e' ⊢e' in neuTerm:⇒*: {l = ∞} (ℕᵣ x) castΠℕₙ (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A ⊢e ⊢t' (un-univ:⇒*: [[ ⊢B , ⊢Π , D ]])) (CastRed*TermΠ (un-univ ⊢F ) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢B≡Π (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢N , Dx ]])) (refl ⊢A )) (~-conv cast~cast (sym ⊢A≡ℕ)) [cast] {A} {B} ⊢Γ (ne′ K [[ ⊢B , ⊢K , D ]] neK K≡K) (ℕᵣ x) = (λ {t} {e} [t] ⊢e → [cast]Ne ⊢Γ (ne K [[ ⊢B , ⊢K , D ]] neK K≡K) (ℕᵣ x) [t] ⊢e) , (λ {t} {e} [t] ⊢e → let ⊢A≡ℕ = let [[ _ , _ , Dx ]] = x in un-univ≡ (subset* Dx) ⊢A≡ℕ' = let [[ _ , _ , Dx ]] = x in subset* Dx ⊢B≡K = un-univ≡ (subset* D) ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) ⊢A≡ℕ' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢A≡ℕ ⊢B≡K)) in neₜ (cast ⁰ ℕ K e t) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) (un-univ:⇒*: x)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢A≡ℕ (refl (un-univ ⊢B))))) ⊢t [[ ⊢B , ⊢K , D ]])) (subset* D) ) (neNfₜ (castℕₙ neK) (castⱼ (ℕⱼ (wf ⊢B)) (un-univ ⊢K) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢A≡ℕ (un-univ≡ (subset* D))))) ⊢t) (~-castℕ (wf ⊢B) K≡K (≅-conv (escapeTermEq {l = ι ⁰} {A = B} (ℕᵣ x) (reflEqTerm {l = ι ⁰} (ℕᵣ x) [t])) ⊢A≡ℕ' ) ⊢e' ⊢e'))) [cast] {r = !} ⊢Γ (ne x) (ne x₁) = (λ {t} {e} [t] ⊢e → [cast]Ne ⊢Γ x (ne x₁) [t] ⊢e) , λ {t} {e} [t] ⊢e → [cast]Ne ⊢Γ x₁ (ne x) [t] ⊢e [cast] {A} {B} {r = !} ⊢Γ (ne′ K [[ ⊢A , ⊢K , D ]] neK K≡K) (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , DΠ ]] ⊢F ⊢G B≡B [F] [G] G-ext) = (λ {t} {e} [t] ⊢e → [cast]Ne ⊢Γ (ne K [[ ⊢A , ⊢K , D ]] neK K≡K) (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , DΠ ]] ⊢F ⊢G B≡B [F] [G] G-ext) [t] ⊢e) , (λ {t} {e} [t] ⊢e → let ⊢B≡Π = un-univ≡ (subset* DΠ) ⊢B≡Π' = subset* DΠ ⊢A≡K = un-univ≡ (subset* D) [Π] = Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , DΠ ]] ⊢F ⊢G B≡B [F] [G] G-ext ⊢t' = escapeTerm {l = ι ⁰} [Π] [t] ⊢t = conv ⊢t' ⊢B≡Π' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢B≡Π ⊢A≡K)) in neₜ (cast ⁰ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) K e t) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A ⊢e ⊢t' (un-univ:⇒*: [[ ⊢B , ⊢Π , DΠ ]])) (CastRed*TermΠ (un-univ ⊢F) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢B≡Π (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢K , D ]])) (subset* D) ) (neNfₜ (castΠₙ neK) (castⱼ (Πⱼ ≡is≤ PE.refl ▹ ≡is≤ PE.refl ▹ un-univ ⊢F ▹ un-univ ⊢G) (un-univ ⊢K) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢B≡Π (un-univ≡ (subset* D))))) ⊢t) (~-castΠ (≅-un-univ B≡B) K≡K (≅-conv (escapeTermEq {l = ι ⁰} {A = B} [Π] (reflEqTerm {l = ι ⁰} [Π] [t])) ⊢B≡Π' ) ⊢e' ⊢e'))) [cast] {A} {B} ⊢Γ (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) (ℕᵣ x) = (λ {t} {e} [t] ⊢e → let ⊢B≡Π = un-univ≡ (subset* D) ⊢B≡Π' = subset* D [[ ⊢A , ⊢N , Dx ]] = x ⊢A≡ℕ = subset* Dx ⊢t' = escapeTerm {l = ι ⁰} {A = A} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) [t] ⊢t = conv {B = (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰)} ⊢t' ⊢B≡Π' t≅t = ≅-conv (escapeTermEq {l = ι ⁰} {A = A} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) (reflEqTerm {l = ι ⁰} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) [t])) ⊢B≡Π' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢B≡Π (un-univ≡ ⊢A≡ℕ))) cast~cast = ~-castΠℕ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ B≡B) t≅t ⊢e' ⊢e' in neuTerm:⇒*: {l = ∞} {t = cast ⁰ A B e t} (ℕᵣ x) castΠℕₙ (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A ⊢e ⊢t' (un-univ:⇒*: [[ ⊢B , ⊢Π , D ]])) (CastRed*TermΠ (un-univ ⊢F ) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢B≡Π (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢N , Dx ]])) (refl ⊢A )) (~-conv cast~cast (sym ⊢A≡ℕ))) , (λ {t} {e} [t] ⊢e → let ⊢B≡Π = un-univ≡ (subset* D) ⊢A≡ℕ = let [[ _ , _ , Dx ]] = x in un-univ≡ (subset* (red x)) ⊢A≡ℕ' = let [[ _ , _ , Dx ]] = x in subset* (red x) ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) ⊢A≡ℕ' t≅t = ≅-conv (escapeTermEq {l = ι ⁰} {A = B} (ℕᵣ x) (reflEqTerm {l = ι ⁰} (ℕᵣ x) [t])) ⊢A≡ℕ' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢A≡ℕ ⊢B≡Π )) cast~cast = ~-castℕΠ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ B≡B) t≅t ⊢e' ⊢e' in neuTerm:⇒*: {t = cast ⁰ B A e t} (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , D ]] ⊢F ⊢G B≡B [F] [G] G-ext) castℕΠₙ (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ x) [t]) (un-univ:⇒*: x)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢A≡ℕ (refl (un-univ ⊢B))))) ⊢t [[ ⊢B , ⊢Π , D ]])) (~-conv cast~cast (sym (subset* D)))) [cast] {A} {B} {r = !} ⊢Γ (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , DΠ ]] ⊢F ⊢G B≡B [F] [G] G-ext) (ne′ K [[ ⊢A , ⊢K , D ]] neK K≡K) = (λ {t} {e} [t] ⊢e → let ⊢B≡Π = un-univ≡ (subset* DΠ) ⊢A≡K = un-univ≡ (subset* D) ⊢B≡Π' = subset* DΠ [Π] = Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , DΠ ]] ⊢F ⊢G B≡B [F] [G] G-ext ⊢t' = escapeTerm {l = ι ⁰} [Π] [t] ⊢t = conv ⊢t' ⊢B≡Π' ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) ⊢B≡Π ⊢A≡K)) in neₜ (cast ⁰ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) K e t) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A ⊢e ⊢t' (un-univ:⇒*: [[ ⊢B , ⊢Π , DΠ ]])) (CastRed*TermΠ (un-univ ⊢F) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢B≡Π (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢K , D ]])) (subset* D) ) (neNfₜ (castΠₙ neK) (castⱼ (Πⱼ ≡is≤ PE.refl ▹ ≡is≤ PE.refl ▹ un-univ ⊢F ▹ un-univ ⊢G) (un-univ ⊢K) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) ⊢B≡Π (un-univ≡ (subset* D))))) ⊢t) (~-castΠ (≅-un-univ B≡B) K≡K (≅-conv (escapeTermEq {l = ι ⁰} {A = A} [Π] (reflEqTerm {l = ι ⁰} [Π] [t])) ⊢B≡Π' ) ⊢e' ⊢e'))) , (λ {t} {e} [t] ⊢e → [cast]Ne ⊢Γ (ne K [[ ⊢A , ⊢K , D ]] neK K≡K) (Πᵣ′ rF lF lG (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢B , ⊢Π , DΠ ]] ⊢F ⊢G B≡B [F] [G] G-ext) [t] ⊢e) [cast] {r = %} ⊢Γ [A] [B] = [cast]irr ⊢Γ [A] [B] , [cast]irr ⊢Γ [B] [A] [cast] {A} {B} {Γ} {r = !} ⊢Γ (Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) = (λ {t} {e} [t] ⊢e → let [A] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext ⊢A = escape [A] [B] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢B = escape [B] ⊢t = escapeTerm [A] [t] ⊢A≡Π = subset* (red D) ⊢B≡Π = subset* (red D₁) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [A] (reflEqTerm {l = ι ⁰} [A] [t])) ⊢A≡Π ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) (un-univ≡ ⊢A≡Π) (un-univ≡ ⊢B≡Π))) cast~cast = ~-conv (~-castΠΠ%! (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡A) (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₁) ⊢t≡t ⊢e' ⊢e') (sym ⊢B≡Π) in neuTerm:⇒*: {t = cast ⁰ A B e t} [B] castΠΠ%!ₙ (transTerm:⇒:* (CastRed*Term ⊢B ⊢e ⊢t (un-univ:⇒*: D)) (CastRed*TermΠ (un-univ ⊢F ) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ ⊢A≡Π) (refl (un-univ ⊢B))))) (conv ⊢t ⊢A≡Π) D₁)) cast~cast) , (λ {t} {e} [t] ⊢e → let [A] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext ⊢A = escape [A] [B] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢B = escape [B] ⊢t = escapeTerm [B] [t] ⊢A≡Π = subset* (red D) ⊢B≡Π = subset* (red D₁) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [B] (reflEqTerm {l = ι ⁰} [B] [t])) ⊢B≡Π ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) (un-univ≡ ⊢B≡Π) (un-univ≡ ⊢A≡Π))) cast~cast = ~-conv (~-castΠΠ!% (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₁) (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡A) ⊢t≡t ⊢e' ⊢e') (sym ⊢A≡Π) in neuTerm:⇒*: {t = cast ⁰ B A e t} [A] castΠΠ!%ₙ (transTerm:⇒:* (CastRed*Term ⊢A ⊢e ⊢t (un-univ:⇒*: D₁)) (CastRed*TermΠ (un-univ ⊢F₁ ) (un-univ ⊢G₁) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢B≡Π) (refl (un-univ ⊢A))))) (conv ⊢t ⊢B≡Π) D)) cast~cast) [cast] {A} {B} {Γ} {r = !} ⊢Γ (Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) = (λ {t} {e} [t] ⊢e → let [A] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext ⊢A = escape [A] [B] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢B = escape [B] ⊢t = escapeTerm [A] [t] ⊢A≡Π = subset* (red D) ⊢B≡Π = subset* (red D₁) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [A] (reflEqTerm {l = ι ⁰} [A] [t])) ⊢A≡Π ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) (un-univ≡ ⊢A≡Π) (un-univ≡ ⊢B≡Π))) cast~cast = ~-conv (~-castΠΠ!% (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡A) (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₁) ⊢t≡t ⊢e' ⊢e') (sym ⊢B≡Π) in neuTerm:⇒*: {t = cast ⁰ A B e t} [B] castΠΠ!%ₙ (transTerm:⇒:* (CastRed*Term ⊢B ⊢e ⊢t (un-univ:⇒*: D)) (CastRed*TermΠ (un-univ ⊢F ) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B) )) (un-univ≡ ⊢A≡Π) (refl (un-univ ⊢B))))) (conv ⊢t ⊢A≡Π) D₁)) cast~cast) , (λ {t} {e} [t] ⊢e → let [A] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext ⊢A = escape [A] [B] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢B = escape [B] ⊢t = escapeTerm [B] [t] ⊢A≡Π = subset* (red D) ⊢B≡Π = subset* (red D₁) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [B] (reflEqTerm {l = ι ⁰} [B] [t])) ⊢B≡Π ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢B))) (un-univ≡ ⊢B≡Π) (un-univ≡ ⊢A≡Π))) cast~cast = ~-conv (~-castΠΠ%! (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₁) (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡A) ⊢t≡t ⊢e' ⊢e') (sym ⊢A≡Π) in neuTerm:⇒*: {t = cast ⁰ B A e t} [A] castΠΠ%!ₙ (transTerm:⇒:* (CastRed*Term ⊢A ⊢e ⊢t (un-univ:⇒*: D₁)) (CastRed*TermΠ (un-univ ⊢F₁ ) (un-univ ⊢G₁) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢B≡Π) (refl (un-univ ⊢A))))) (conv ⊢t ⊢B≡Π) D)) cast~cast) [cast] {A} {B} {Γ} {r = !} ⊢Γ (Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ′ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) = [cast]₁ , [cast]₂ where module b₁ = cast-ΠΠ-lemmas ⊢Γ ⊢F [F] ⊢F₁ [F₁] (λ [ρ] ⊢Δ → proj₂ ([cast] ⊢Δ ([F] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₂ ([castext] ⊢Δ ([F] [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) (reflEq ([F] [ρ] ⊢Δ)) ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)))) module b₂ = cast-ΠΠ-lemmas ⊢Γ ⊢F₁ [F₁] ⊢F [F] (λ [ρ] ⊢Δ → proj₁ ([cast] ⊢Δ ([F] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₁ ([castext] ⊢Δ ([F] [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) (reflEq ([F] [ρ] ⊢Δ)) ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)))) [A] = (Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) [B] = (Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) [cast]₁ : ∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ ! , ι ⁰ ] / [A]) → (⊢e : Γ ⊢ e ∷ Id (U ⁰) A B ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ ! , ι ⁰ ] / [B] [cast]₁ {t} {e} (f , [[ ⊢t , ⊢f , Df ]] , funf , f≡f , [fext] , [f]) ⊢e = [castΠΠ] where open cast-ΠΠ-lemmas-2 ⊢Γ ⊢A ⊢ΠFG D ⊢F ⊢G A≡A [F] [G] G-ext ⊢B ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢e (λ [ρ] ⊢Δ [x] [y] → proj₁ ([cast] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] → proj₁ ([castext] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G] [ρ] ⊢Δ [x′]) (G-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₁] [ρ] ⊢Δ [y]) ([G₁] [ρ] ⊢Δ [y′]) (G₁-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) ⊢t Df [fext] [f] b₁.[b] b₁.[bext] [cast]₂ : ∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ B ^ [ ! , ι ⁰ ] / [B]) → (⊢e : Γ ⊢ e ∷ Id (U ⁰) B A ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ B A e t ∷ A ^ [ ! , ι ⁰ ] / [A] [cast]₂ {t} {e} (f , [[ ⊢t , ⊢f , Df ]] , funf , f≡f , [fext] , [f]) ⊢e = [castΠΠ] where open cast-ΠΠ-lemmas-2 ⊢Γ ⊢B ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢A ⊢ΠFG D ⊢F ⊢G A≡A [F] [G] G-ext ⊢e (λ [ρ] ⊢Δ [y] [x] → proj₂ ([cast] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [y] [y′] [y≡y′] [x] [x′] [x≡x′] → proj₂ ([castext] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G] [ρ] ⊢Δ [x′]) (G-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₁] [ρ] ⊢Δ [y]) ([G₁] [ρ] ⊢Δ [y′]) (G₁-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) ⊢t Df [fext] [f] b₂.[b] b₂.[bext] [cast] {A} {B} {Γ} {r = !} ⊢Γ (Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ′ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) = [cast]₁ , [cast]₂ where module b₁ = cast-ΠΠ-lemmas ⊢Γ ⊢F [F] ⊢F₁ [F₁] (λ [ρ] ⊢Δ → proj₂ ([cast] ⊢Δ ([F] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₂ ([castext] ⊢Δ ([F] [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) (reflEq ([F] [ρ] ⊢Δ)) ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)))) module b₂ = cast-ΠΠ-lemmas ⊢Γ ⊢F₁ [F₁] ⊢F [F] (λ [ρ] ⊢Δ → proj₁ ([cast] ⊢Δ ([F] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₁ ([castext] ⊢Δ ([F] [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) (reflEq ([F] [ρ] ⊢Δ)) ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)))) [A] = (Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢ΠFG , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) [B] = (Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢B , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) [cast]₁ : ∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ ! , ι ⁰ ] / [A]) → (⊢e : Γ ⊢ e ∷ Id (U ⁰) A B ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ ! , ι ⁰ ] / [B] [cast]₁ {t} {e} (f , [[ ⊢t , ⊢f , Df ]] , funf , f≡f , [fext] , [f]) ⊢e = [castΠΠ] where open cast-ΠΠ-lemmas-2 ⊢Γ ⊢A ⊢ΠFG D ⊢F ⊢G A≡A [F] [G] G-ext ⊢B ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢e (λ [ρ] ⊢Δ [x] [y] → proj₁ ([cast] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] → proj₁ ([castext] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G] [ρ] ⊢Δ [x′]) (G-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₁] [ρ] ⊢Δ [y]) ([G₁] [ρ] ⊢Δ [y′]) (G₁-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) ⊢t Df [fext] [f] b₁.[b] b₁.[bext] [cast]₂ : ∀ {t e} → ([t] : Γ ⊩⟨ ι ⁰ ⟩ t ∷ B ^ [ ! , ι ⁰ ] / [B]) → (⊢e : Γ ⊢ e ∷ Id (U ⁰) B A ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ B A e t ∷ A ^ [ ! , ι ⁰ ] / [A] [cast]₂ {t} {e} (f , [[ ⊢t , ⊢f , Df ]] , funf , f≡f , [fext] , [f]) ⊢e = [castΠΠ] where open cast-ΠΠ-lemmas-2 ⊢Γ ⊢B ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢A ⊢ΠFG D ⊢F ⊢G A≡A [F] [G] G-ext ⊢e (λ [ρ] ⊢Δ [y] [x] → proj₂ ([cast] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [y] [y′] [y≡y′] [x] [x′] [x≡x′] → proj₂ ([castext] ⊢Δ ([G] [ρ] ⊢Δ [x]) ([G] [ρ] ⊢Δ [x′]) (G-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₁] [ρ] ⊢Δ [y]) ([G₁] [ρ] ⊢Δ [y′]) (G₁-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) ⊢t Df [fext] [f] b₂.[b] b₂.[bext] [castextShape] {A₁} {A₂} {A₃} {A₄} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) = let ΠFG′≡ΠFG′₁ = whrDet* (D₂ , Πₙ) (D₂′ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ in ⊥-elim (!≢% (PE.sym rF≡rF′)) [castextShape] {A₁} {A₂} {A₃} {A₄} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) = let ΠFG′≡ΠFG′₁ = whrDet* (D₂ , Πₙ) (D₂′ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ in ⊥-elim (!≢% rF≡rF′) [castextShape] {A₁} {A₂} {A₃} {A₄} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ r1 .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ r2 .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) = let ΠFG′≡ΠFG′₁ = whrDet* (D₄ , Πₙ) (D₄′ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ in ⊥-elim (!≢% rF≡rF′) [castextShape] {A₁} {A₂} {A₃} {A₄} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ r1 .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ r2 .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) = let ΠFG′≡ΠFG′₁ = whrDet* (D₄ , Πₙ) (D₄′ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ in ⊥-elim (!≢% (PE.sym rF≡rF′)) [castextShape] {A₁} {A₂} {A₃} {A₄} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) = ([castext]₁ , [castext]₂) where module b₁ = cast-ΠΠ-lemmas ⊢Γ ⊢F₁ [F₁] ⊢F₃ [F₃] (λ [ρ] ⊢Δ → proj₂ ([cast] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₂ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)) ([F₃] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) (reflEq ([F₃] [ρ] ⊢Δ)))) module b₂ = cast-ΠΠ-lemmas ⊢Γ ⊢F₂ [F₂] ⊢F₄ [F₄] (λ [ρ] ⊢Δ → proj₂ ([cast] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₂ ([castext] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) (reflEq ([F₂] [ρ] ⊢Δ)) ([F₄] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) (reflEq ([F₄] [ρ] ⊢Δ)))) module b₃ = cast-ΠΠ-lemmas ⊢Γ ⊢F₃ [F₃] ⊢F₁ [F₁] (λ [ρ] ⊢Δ → proj₁ ([cast] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₁ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)) ([F₃] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) (reflEq ([F₃] [ρ] ⊢Δ)))) module b₄ = cast-ΠΠ-lemmas ⊢Γ ⊢F₄ [F₄] ⊢F₂ [F₂] (λ [ρ] ⊢Δ → proj₁ ([cast] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₁ ([castext] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) (reflEq ([F₂] [ρ] ⊢Δ)) ([F₄] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) (reflEq ([F₄] [ρ] ⊢Δ)))) [A₁] = (Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) [A₂] = (Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext) [A₁≡A₂] = (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) [A₃] = (Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) [A₄] = (Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext) [A₃≡A₄] = (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) Π≡Π = whrDet* (D₂ , Whnf.Πₙ) (D₂′ , Whnf.Πₙ) F₂≡F₂′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π in x G₂≡G₂′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π in x Π≡Π′ = whrDet* (D₄ , Whnf.Πₙ) (D₄′ , Whnf.Πₙ) F₄≡F₄′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π′ in x G₄≡G₄′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π′ in x A₁≡A₂ = PE.subst₂ (λ X Y → Γ ⊢ Π F₁ ^ ! ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ≅ Π X ^ ! ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₂≡F₂′) (PE.sym G₂≡G₂′) A₁≡A₂′ A₃≡A₄ = PE.subst₂ (λ X Y → Γ ⊢ Π F₃ ^ ! ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ≅ Π X ^ ! ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₄≡F₄′) (PE.sym G₄≡G₄′) A₃≡A₄′ [F₁≡F₂] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ≡ wk ρ X ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ) (PE.sym F₂≡F₂′) [F₁≡F₂′] [F₃≡F₄] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₃ ≡ wk ρ X ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ) (PE.sym F₄≡F₄′) [F₃≡F₄′] [G₁≡G₂] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) (PE.sym G₂≡G₂′) [G₁≡G₂′] [G₃≡G₄] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a]) (PE.sym G₄≡G₄′) [G₃≡G₄′] [b₁≡b₂] : ∀ {ρ Δ e₁₃ e₂₄ x₃ x₄} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e₁₃ ∷ Id (U ⁰) (wk ρ F₁) (wk ρ F₃) ^ [ % , ι ¹ ]) → (Δ ⊢ e₂₄ ∷ Id (U ⁰) (wk ρ F₂) (wk ρ F₄) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x₃ ∷ wk ρ F₃ ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₄ ∷ wk ρ F₄ ^ [ ! , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₃ ≡ x₄ ∷ wk ρ F₃ ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ b₁.b ρ e₁₃ x₃ ≡ b₂.b ρ e₂₄ x₄ ∷ wk ρ F₁ ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ [b₁≡b₂] [ρ] ⊢Δ ⊢e₁₃ ⊢e₂₄ [x₃] [x₄] [x₃≡x₄] = let ⊢e₃₁ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₁] [ρ] ⊢Δ))) (un-univ (escape ([F₃] [ρ] ⊢Δ))) ⊢e₁₃ ⊢e₄₂ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₂] [ρ] ⊢Δ))) (un-univ (escape ([F₄] [ρ] ⊢Δ))) ⊢e₂₄ in proj₂ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ)) [x₃] [x₄] [x₃≡x₄] ⊢e₃₁ ⊢e₄₂ [b₃≡b₄] : ∀ {ρ Δ e₃₁ e₄₂ x₁ x₂} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e₃₁ ∷ Id (U ⁰) (wk ρ F₃) (wk ρ F₁) ^ [ % , ι ¹ ]) → (Δ ⊢ e₄₂ ∷ Id (U ⁰) (wk ρ F₄) (wk ρ F₂) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x₁ ∷ wk ρ F₁ ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₂ ∷ wk ρ F₂ ^ [ ! , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₁ ≡ x₂ ∷ wk ρ F₁ ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ b₃.b ρ e₃₁ x₁ ≡ b₄.b ρ e₄₂ x₂ ∷ wk ρ F₃ ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ [b₃≡b₄] [ρ] ⊢Δ ⊢e₃₁ ⊢e₄₂ [x₁] [x₂] [x₁≡x₂] = let ⊢e₁₃ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₃] [ρ] ⊢Δ))) (un-univ (escape ([F₁] [ρ] ⊢Δ))) ⊢e₃₁ ⊢e₂₄ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₄] [ρ] ⊢Δ))) (un-univ (escape ([F₂] [ρ] ⊢Δ))) ⊢e₄₂ in proj₁ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ)) [x₁] [x₂] [x₁≡x₂] ⊢e₁₃ ⊢e₂₄ [castext]₁ : (∀ {t₁ t₂ e₁₃ e₂₄} → ([t₁] : Γ ⊩⟨ ι ⁰ ⟩ t₁ ∷ A₁ ^ [ ! , ι ⁰ ] / [A₁]) → ([t₁] : Γ ⊩⟨ ι ⁰ ⟩ t₂ ∷ A₂ ^ [ ! , ι ⁰ ] / [A₂]) → ([t₁≡t₂] : Γ ⊩⟨ ι ⁰ ⟩ t₁ ≡ t₂ ∷ A₁ ^ [ ! , ι ⁰ ] / [A₁]) → (⊢e₁₃ : Γ ⊢ e₁₃ ∷ Id (U ⁰) A₁ A₃ ^ [ % , ι ¹ ]) → (⊢e₂₄ : Γ ⊢ e₂₄ ∷ Id (U ⁰) A₂ A₄ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A₁ A₃ e₁₃ t₁ ≡ cast ⁰ A₂ A₄ e₂₄ t₂ ∷ A₃ ^ [ ! , ι ⁰ ] / [A₃]) [castext]₁ {t₁} {t₂} {e₁₃} {e₂₄} (f₁ , [[ ⊢t₁ , ⊢f₁ , Df₁ ]] , funf₁ , f₁≡f₁ , [f₁ext] , [f₁]) (f₂ , [[ ⊢t₂ , ⊢f₂ , Df₂ ]] , funf₂ , f₂≡f₂ , [f₂ext] , [f₂]) (f₁′ , f₂′ , [[ _ , ⊢f₁′ , Df₁′ ]] , [[ _ , ⊢f₂′ , Df₂′ ]] , funf₁′ , funf₂′ , _ , _ , _ , [f₁′≡f₂′]) ⊢e₁₃ ⊢e₂₄ = ( (lam F₃ ▹ g₁.g (step id) (var 0) ^ ⁰) , (lam F₄ ▹ g₂.g (step id) (var 0) ^ ⁰) , g₁.Dg , conv:* g₂.Dg (sym (≅-eq A₃≡A₄)) , lamₙ , lamₙ , g₁≡g₂ , g₁.[castΠΠ] , convTerm₂ [A₃] [A₄] [A₃≡A₄] g₂.[castΠΠ] , [g₁a≡g₂a] ) where f₁≡f₁′ = whrDet*Term (Df₁ , functionWhnf funf₁) (Df₁′ , functionWhnf funf₁′) f₂≡f₂′ = whrDet*Term (Df₂ , functionWhnf funf₂) (Df₂′ , functionWhnf funf₂′) [f₁≡f₂] = PE.subst₂ (λ X Y → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ ! , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ X ∘ a ^ ⁰ ≡ wk ρ Y ∘ a ^ ⁰ ∷ wk (lift ρ) G₁ [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) (PE.sym f₁≡f₁′) (PE.sym f₂≡f₂′) [f₁′≡f₂′] open cast-ΠΠ-lemmas-3 ⊢Γ ⊢A₁ ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢A₂ ⊢ΠF₂G₂ D₂ ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext ⊢A₃ ⊢ΠF₃G₃ D₃ ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext ⊢A₄ ⊢ΠF₄G₄ D₄ ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext A₁≡A₂ A₃≡A₄ [F₁≡F₂] [F₃≡F₄] [G₁≡G₂] [G₃≡G₄] ⊢e₁₃ ⊢e₂₄ ⊢t₁ Df₁ [f₁ext] [f₁] ⊢t₂ Df₂ [f₂ext] [f₂] [f₁≡f₂] (λ [ρ] ⊢Δ [x] [y] → proj₁ ([cast] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₃] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [x] [y] → proj₁ ([cast] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₄] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] → proj₁ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [x′]) (G₁-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₃] [ρ] ⊢Δ [y]) ([G₃] [ρ] ⊢Δ [y′]) (G₃-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] → proj₁ ([castext] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₂] [ρ] ⊢Δ [x′]) (G₂-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₄] [ρ] ⊢Δ [y]) ([G₄] [ρ] ⊢Δ [y′]) (G₄-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [x₁] [x₂] [G₁x₁≡G₂x₂] [x₃] [x₄] [G₃x₃≡G₄x₄] → proj₁ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x₁]) ([G₂] [ρ] ⊢Δ [x₂]) [G₁x₁≡G₂x₂] ([G₃] [ρ] ⊢Δ [x₃]) ([G₄] [ρ] ⊢Δ [x₄]) [G₃x₃≡G₄x₄])) b₁.[b] b₁.[bext] b₂.[b] b₂.[bext] [b₁≡b₂] [castext]₂ : (∀ {t₃ t₄ e₃₁ e₄₂} → ([t₃] : Γ ⊩⟨ ι ⁰ ⟩ t₃ ∷ A₃ ^ [ ! , ι ⁰ ] / [A₃]) → ([t₄] : Γ ⊩⟨ ι ⁰ ⟩ t₄ ∷ A₄ ^ [ ! , ι ⁰ ] / [A₄]) → ([t₃≡t₄] : Γ ⊩⟨ ι ⁰ ⟩ t₃ ≡ t₄ ∷ A₃ ^ [ ! , ι ⁰ ] / [A₃]) → (⊢e₃₁ : Γ ⊢ e₃₁ ∷ Id (U ⁰) A₃ A₁ ^ [ % , ι ¹ ]) → (⊢e₄₂ : Γ ⊢ e₄₂ ∷ Id (U ⁰) A₄ A₂ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A₃ A₁ e₃₁ t₃ ≡ cast ⁰ A₄ A₂ e₄₂ t₄ ∷ A₁ ^ [ ! , ι ⁰ ] / [A₁]) [castext]₂ {t₃} {t₄} {e₃₁} {e₄₂} (f₃ , [[ ⊢t₃ , ⊢f₃ , Df₃ ]] , funf₃ , f₃≡f₃ , [f₃ext] , [f₃]) (f₄ , [[ ⊢t₄ , ⊢f₄ , Df₄ ]] , funf₄ , f₄≡f₄ , [f₄ext] , [f₄]) (f₃′ , f₄′ , [[ _ , ⊢f₃′ , Df₃′ ]] , [[ _ , ⊢f₄′ , Df₄′ ]] , funf₃′ , funf₄′ , _ , _ , _ , [f₃′≡f₄′]) ⊢e₃₁ ⊢e₄₂ = ( (lam F₁ ▹ g₁.g (step id) (var 0) ^ ⁰) , (lam F₂ ▹ g₂.g (step id) (var 0) ^ ⁰) , g₁.Dg , conv:* g₂.Dg (sym (≅-eq A₁≡A₂)) , lamₙ , lamₙ , g₁≡g₂ , g₁.[castΠΠ] , convTerm₂ [A₁] [A₂] [A₁≡A₂] g₂.[castΠΠ] , [g₁a≡g₂a] ) where f₃≡f₃′ = whrDet*Term (Df₃ , functionWhnf funf₃) (Df₃′ , functionWhnf funf₃′) f₄≡f₄′ = whrDet*Term (Df₄ , functionWhnf funf₄) (Df₄′ , functionWhnf funf₄′) [f₃≡f₄] = PE.subst₂ (λ X Y → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ ! , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ X ∘ a ^ ⁰ ≡ wk ρ Y ∘ a ^ ⁰ ∷ wk (lift ρ) G₃ [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a]) (PE.sym f₃≡f₃′) (PE.sym f₄≡f₄′) [f₃′≡f₄′] open cast-ΠΠ-lemmas-3 ⊢Γ ⊢A₃ ⊢ΠF₃G₃ D₃ ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext ⊢A₄ ⊢ΠF₄G₄ D₄ ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext ⊢A₁ ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢A₂ ⊢ΠF₂G₂ D₂ ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext A₃≡A₄ A₁≡A₂ [F₃≡F₄] [F₁≡F₂] [G₃≡G₄] [G₁≡G₂] ⊢e₃₁ ⊢e₄₂ ⊢t₃ Df₃ [f₃ext] [f₃] ⊢t₄ Df₄ [f₄ext] [f₄] [f₃≡f₄] (λ [ρ] ⊢Δ [y] [x] → proj₂ ([cast] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₃] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [y] [x] → proj₂ ([cast] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₄] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [y] [y′] [y≡y′] [x] [x′] [x≡x′] → proj₂ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [x′]) (G₁-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₃] [ρ] ⊢Δ [y]) ([G₃] [ρ] ⊢Δ [y′]) (G₃-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [y] [y′] [y≡y′] [x] [x′] [x≡x′] → proj₂ ([castext] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₂] [ρ] ⊢Δ [x′]) (G₂-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₄] [ρ] ⊢Δ [y]) ([G₄] [ρ] ⊢Δ [y′]) (G₄-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [x₃] [x₄] [G₃x₃≡G₄x₄] [x₁] [x₂] [G₁x₁≡G₂x₂] → proj₂ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x₁]) ([G₂] [ρ] ⊢Δ [x₂]) [G₁x₁≡G₂x₂] ([G₃] [ρ] ⊢Δ [x₃]) ([G₄] [ρ] ⊢Δ [x₄]) [G₃x₃≡G₄x₄])) b₃.[b] b₃.[bext] b₄.[b] b₄.[bext] [b₃≡b₄] [castextShape] {A₁} {A₂} {A₃} {A₄} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) = ([castext]₁ , [castext]₂) where module b₁ = cast-ΠΠ-lemmas ⊢Γ ⊢F₁ [F₁] ⊢F₃ [F₃] (λ [ρ] ⊢Δ → proj₂ ([cast] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₂ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)) ([F₃] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) (reflEq ([F₃] [ρ] ⊢Δ)))) module b₂ = cast-ΠΠ-lemmas ⊢Γ ⊢F₂ [F₂] ⊢F₄ [F₄] (λ [ρ] ⊢Δ → proj₂ ([cast] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₂ ([castext] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) (reflEq ([F₂] [ρ] ⊢Δ)) ([F₄] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) (reflEq ([F₄] [ρ] ⊢Δ)))) module b₃ = cast-ΠΠ-lemmas ⊢Γ ⊢F₃ [F₃] ⊢F₁ [F₁] (λ [ρ] ⊢Δ → proj₁ ([cast] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₁ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₁] [ρ] ⊢Δ) (reflEq ([F₁] [ρ] ⊢Δ)) ([F₃] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) (reflEq ([F₃] [ρ] ⊢Δ)))) module b₄ = cast-ΠΠ-lemmas ⊢Γ ⊢F₄ [F₄] ⊢F₂ [F₂] (λ [ρ] ⊢Δ → proj₁ ([cast] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ))) (λ [ρ] ⊢Δ → proj₁ ([castext] ⊢Δ ([F₂] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) (reflEq ([F₂] [ρ] ⊢Δ)) ([F₄] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) (reflEq ([F₄] [ρ] ⊢Δ)))) [A₁] = (Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) [A₂] = (Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext) [A₁≡A₂] = (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) [A₃] = (Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) [A₄] = (Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext) [A₃≡A₄] = (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) Π≡Π = whrDet* (D₂ , Whnf.Πₙ) (D₂′ , Whnf.Πₙ) F₂≡F₂′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π in x G₂≡G₂′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π in x Π≡Π′ = whrDet* (D₄ , Whnf.Πₙ) (D₄′ , Whnf.Πₙ) F₄≡F₄′ = let x , _ , _ , _ , _ = Π-PE-injectivity Π≡Π′ in x G₄≡G₄′ = let _ , _ , _ , x , _ = Π-PE-injectivity Π≡Π′ in x A₁≡A₂ = PE.subst₂ (λ X Y → Γ ⊢ Π F₁ ^ % ° ⁰ ▹ G₁ ° ⁰ ° ⁰ ≅ Π X ^ % ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₂≡F₂′) (PE.sym G₂≡G₂′) A₁≡A₂′ A₃≡A₄ = PE.subst₂ (λ X Y → Γ ⊢ Π F₃ ^ % ° ⁰ ▹ G₃ ° ⁰ ° ⁰ ≅ Π X ^ % ° ⁰ ▹ Y ° ⁰ ° ⁰ ^ [ ! , ι ⁰ ]) (PE.sym F₄≡F₄′) (PE.sym G₄≡G₄′) A₃≡A₄′ [F₁≡F₂] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₁ ≡ wk ρ X ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ) (PE.sym F₂≡F₂′) [F₁≡F₂′] [F₃≡F₄] = PE.subst (λ X → ∀ {ρ Δ} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ F₃ ≡ wk ρ X ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ) (PE.sym F₄≡F₄′) [F₃≡F₄′] [G₁≡G₂] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₁ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) (PE.sym G₂≡G₂′) [G₁≡G₂′] [G₃≡G₄] = PE.subst (λ X → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk (lift ρ) G₃ [ a ] ≡ wk (lift ρ) X [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a]) (PE.sym G₄≡G₄′) [G₃≡G₄′] [b₁≡b₂] : ∀ {ρ Δ e₁₃ e₂₄ x₃ x₄} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e₁₃ ∷ Id (SProp ⁰) (wk ρ F₁) (wk ρ F₃) ^ [ % , ι ¹ ]) → (Δ ⊢ e₂₄ ∷ Id (SProp ⁰) (wk ρ F₂) (wk ρ F₄) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x₃ ∷ wk ρ F₃ ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₄ ∷ wk ρ F₄ ^ [ % , ι ⁰ ] / [F₄] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₃ ≡ x₄ ∷ wk ρ F₃ ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ b₁.b ρ e₁₃ x₃ ≡ b₂.b ρ e₂₄ x₄ ∷ wk ρ F₁ ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ [b₁≡b₂] [ρ] ⊢Δ ⊢e₁₃ ⊢e₂₄ [x₃] [x₄] [x₃≡x₄] = let ⊢e₃₁ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₁] [ρ] ⊢Δ))) (un-univ (escape ([F₃] [ρ] ⊢Δ))) ⊢e₁₃ ⊢e₄₂ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₂] [ρ] ⊢Δ))) (un-univ (escape ([F₄] [ρ] ⊢Δ))) ⊢e₂₄ in proj₂ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ)) [x₃] [x₄] [x₃≡x₄] ⊢e₃₁ ⊢e₄₂ [b₃≡b₄] : ∀ {ρ Δ e₃₁ e₄₂ x₁ x₂} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → (Δ ⊢ e₃₁ ∷ Id (SProp ⁰) (wk ρ F₃) (wk ρ F₁) ^ [ % , ι ¹ ]) → (Δ ⊢ e₄₂ ∷ Id (SProp ⁰) (wk ρ F₄) (wk ρ F₂) ^ [ % , ι ¹ ]) → (Δ ⊩⟨ ι ⁰ ⟩ x₁ ∷ wk ρ F₁ ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₂ ∷ wk ρ F₂ ^ [ % , ι ⁰ ] / [F₂] [ρ] ⊢Δ) → (Δ ⊩⟨ ι ⁰ ⟩ x₁ ≡ x₂ ∷ wk ρ F₁ ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ b₃.b ρ e₃₁ x₁ ≡ b₄.b ρ e₄₂ x₂ ∷ wk ρ F₃ ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ [b₃≡b₄] [ρ] ⊢Δ ⊢e₃₁ ⊢e₄₂ [x₁] [x₂] [x₁≡x₂] = let ⊢e₁₃ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₃] [ρ] ⊢Δ))) (un-univ (escape ([F₁] [ρ] ⊢Δ))) ⊢e₃₁ ⊢e₂₄ = Idsymⱼ (univ 0<1 ⊢Δ) (un-univ (escape ([F₄] [ρ] ⊢Δ))) (un-univ (escape ([F₂] [ρ] ⊢Δ))) ⊢e₄₂ in proj₁ ([castext] ⊢Δ ([F₁] [ρ] ⊢Δ) ([F₂] [ρ] ⊢Δ) ([F₁≡F₂] [ρ] ⊢Δ) ([F₃] [ρ] ⊢Δ) ([F₄] [ρ] ⊢Δ) ([F₃≡F₄] [ρ] ⊢Δ)) [x₁] [x₂] [x₁≡x₂] ⊢e₁₃ ⊢e₂₄ [castext]₁ : (∀ {t₁ t₂ e₁₃ e₂₄} → ([t₁] : Γ ⊩⟨ ι ⁰ ⟩ t₁ ∷ A₁ ^ [ ! , ι ⁰ ] / [A₁]) → ([t₁] : Γ ⊩⟨ ι ⁰ ⟩ t₂ ∷ A₂ ^ [ ! , ι ⁰ ] / [A₂]) → ([t₁≡t₂] : Γ ⊩⟨ ι ⁰ ⟩ t₁ ≡ t₂ ∷ A₁ ^ [ ! , ι ⁰ ] / [A₁]) → (⊢e₁₃ : Γ ⊢ e₁₃ ∷ Id (U ⁰) A₁ A₃ ^ [ % , ι ¹ ]) → (⊢e₂₄ : Γ ⊢ e₂₄ ∷ Id (U ⁰) A₂ A₄ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A₁ A₃ e₁₃ t₁ ≡ cast ⁰ A₂ A₄ e₂₄ t₂ ∷ A₃ ^ [ ! , ι ⁰ ] / [A₃]) [castext]₁ {t₁} {t₂} {e₁₃} {e₂₄} (f₁ , [[ ⊢t₁ , ⊢f₁ , Df₁ ]] , funf₁ , f₁≡f₁ , [f₁ext] , [f₁]) (f₂ , [[ ⊢t₂ , ⊢f₂ , Df₂ ]] , funf₂ , f₂≡f₂ , [f₂ext] , [f₂]) (f₁′ , f₂′ , [[ _ , ⊢f₁′ , Df₁′ ]] , [[ _ , ⊢f₂′ , Df₂′ ]] , funf₁′ , funf₂′ , _ , _ , _ , [f₁′≡f₂′]) ⊢e₁₃ ⊢e₂₄ = ( (lam F₃ ▹ g₁.g (step id) (var 0) ^ ⁰) , (lam F₄ ▹ g₂.g (step id) (var 0) ^ ⁰) , g₁.Dg , conv:* g₂.Dg (sym (≅-eq A₃≡A₄)) , lamₙ , lamₙ , g₁≡g₂ , g₁.[castΠΠ] , convTerm₂ [A₃] [A₄] [A₃≡A₄] g₂.[castΠΠ] , [g₁a≡g₂a] ) where f₁≡f₁′ = whrDet*Term (Df₁ , functionWhnf funf₁) (Df₁′ , functionWhnf funf₁′) f₂≡f₂′ = whrDet*Term (Df₂ , functionWhnf funf₂) (Df₂′ , functionWhnf funf₂′) [f₁≡f₂] = PE.subst₂ (λ X Y → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₁ ^ [ % , ι ⁰ ] / [F₁] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ X ∘ a ^ ⁰ ≡ wk ρ Y ∘ a ^ ⁰ ∷ wk (lift ρ) G₁ [ a ] ^ [ ! , ι ⁰ ] / [G₁] [ρ] ⊢Δ [a]) (PE.sym f₁≡f₁′) (PE.sym f₂≡f₂′) [f₁′≡f₂′] open cast-ΠΠ-lemmas-3 ⊢Γ ⊢A₁ ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢A₂ ⊢ΠF₂G₂ D₂ ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext ⊢A₃ ⊢ΠF₃G₃ D₃ ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext ⊢A₄ ⊢ΠF₄G₄ D₄ ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext A₁≡A₂ A₃≡A₄ [F₁≡F₂] [F₃≡F₄] [G₁≡G₂] [G₃≡G₄] ⊢e₁₃ ⊢e₂₄ ⊢t₁ Df₁ [f₁ext] [f₁] ⊢t₂ Df₂ [f₂ext] [f₂] [f₁≡f₂] (λ [ρ] ⊢Δ [x] [y] → proj₁ ([cast] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₃] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [x] [y] → proj₁ ([cast] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₄] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] → proj₁ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [x′]) (G₁-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₃] [ρ] ⊢Δ [y]) ([G₃] [ρ] ⊢Δ [y′]) (G₃-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [x] [x′] [x≡x′] [y] [y′] [y≡y′] → proj₁ ([castext] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₂] [ρ] ⊢Δ [x′]) (G₂-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₄] [ρ] ⊢Δ [y]) ([G₄] [ρ] ⊢Δ [y′]) (G₄-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [x₁] [x₂] [G₁x₁≡G₂x₂] [x₃] [x₄] [G₃x₃≡G₄x₄] → proj₁ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x₁]) ([G₂] [ρ] ⊢Δ [x₂]) [G₁x₁≡G₂x₂] ([G₃] [ρ] ⊢Δ [x₃]) ([G₄] [ρ] ⊢Δ [x₄]) [G₃x₃≡G₄x₄])) b₁.[b] b₁.[bext] b₂.[b] b₂.[bext] [b₁≡b₂] [castext]₂ : (∀ {t₃ t₄ e₃₁ e₄₂} → ([t₃] : Γ ⊩⟨ ι ⁰ ⟩ t₃ ∷ A₃ ^ [ ! , ι ⁰ ] / [A₃]) → ([t₄] : Γ ⊩⟨ ι ⁰ ⟩ t₄ ∷ A₄ ^ [ ! , ι ⁰ ] / [A₄]) → ([t₃≡t₄] : Γ ⊩⟨ ι ⁰ ⟩ t₃ ≡ t₄ ∷ A₃ ^ [ ! , ι ⁰ ] / [A₃]) → (⊢e₃₁ : Γ ⊢ e₃₁ ∷ Id (U ⁰) A₃ A₁ ^ [ % , ι ¹ ]) → (⊢e₄₂ : Γ ⊢ e₄₂ ∷ Id (U ⁰) A₄ A₂ ^ [ % , ι ¹ ]) → Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A₃ A₁ e₃₁ t₃ ≡ cast ⁰ A₄ A₂ e₄₂ t₄ ∷ A₁ ^ [ ! , ι ⁰ ] / [A₁]) [castext]₂ {t₃} {t₄} {e₃₁} {e₄₂} (f₃ , [[ ⊢t₃ , ⊢f₃ , Df₃ ]] , funf₃ , f₃≡f₃ , [f₃ext] , [f₃]) (f₄ , [[ ⊢t₄ , ⊢f₄ , Df₄ ]] , funf₄ , f₄≡f₄ , [f₄ext] , [f₄]) (f₃′ , f₄′ , [[ _ , ⊢f₃′ , Df₃′ ]] , [[ _ , ⊢f₄′ , Df₄′ ]] , funf₃′ , funf₄′ , _ , _ , _ , [f₃′≡f₄′]) ⊢e₃₁ ⊢e₄₂ = ( (lam F₁ ▹ g₁.g (step id) (var 0) ^ ⁰) , (lam F₂ ▹ g₂.g (step id) (var 0) ^ ⁰) , g₁.Dg , conv:* g₂.Dg (sym (≅-eq A₁≡A₂)) , lamₙ , lamₙ , g₁≡g₂ , g₁.[castΠΠ] , convTerm₂ [A₁] [A₂] [A₁≡A₂] g₂.[castΠΠ] , [g₁a≡g₂a] ) where f₃≡f₃′ = whrDet*Term (Df₃ , functionWhnf funf₃) (Df₃′ , functionWhnf funf₃′) f₄≡f₄′ = whrDet*Term (Df₄ , functionWhnf funf₄) (Df₄′ , functionWhnf funf₄′) [f₃≡f₄] = PE.subst₂ (λ X Y → ∀ {ρ Δ a} → ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ ι ⁰ ⟩ a ∷ wk ρ F₃ ^ [ % , ι ⁰ ] / [F₃] [ρ] ⊢Δ) → Δ ⊩⟨ ι ⁰ ⟩ wk ρ X ∘ a ^ ⁰ ≡ wk ρ Y ∘ a ^ ⁰ ∷ wk (lift ρ) G₃ [ a ] ^ [ ! , ι ⁰ ] / [G₃] [ρ] ⊢Δ [a]) (PE.sym f₃≡f₃′) (PE.sym f₄≡f₄′) [f₃′≡f₄′] open cast-ΠΠ-lemmas-3 ⊢Γ ⊢A₃ ⊢ΠF₃G₃ D₃ ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext ⊢A₄ ⊢ΠF₄G₄ D₄ ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext ⊢A₁ ⊢ΠF₁G₁ D₁ ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext ⊢A₂ ⊢ΠF₂G₂ D₂ ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext A₃≡A₄ A₁≡A₂ [F₃≡F₄] [F₁≡F₂] [G₃≡G₄] [G₁≡G₂] ⊢e₃₁ ⊢e₄₂ ⊢t₃ Df₃ [f₃ext] [f₃] ⊢t₄ Df₄ [f₄ext] [f₄] [f₃≡f₄] (λ [ρ] ⊢Δ [y] [x] → proj₂ ([cast] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₃] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [y] [x] → proj₂ ([cast] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₄] [ρ] ⊢Δ [y]))) (λ [ρ] ⊢Δ [y] [y′] [y≡y′] [x] [x′] [x≡x′] → proj₂ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x]) ([G₁] [ρ] ⊢Δ [x′]) (G₁-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₃] [ρ] ⊢Δ [y]) ([G₃] [ρ] ⊢Δ [y′]) (G₃-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [y] [y′] [y≡y′] [x] [x′] [x≡x′] → proj₂ ([castext] ⊢Δ ([G₂] [ρ] ⊢Δ [x]) ([G₂] [ρ] ⊢Δ [x′]) (G₂-ext [ρ] ⊢Δ [x] [x′] [x≡x′]) ([G₄] [ρ] ⊢Δ [y]) ([G₄] [ρ] ⊢Δ [y′]) (G₄-ext [ρ] ⊢Δ [y] [y′] [y≡y′]))) (λ [ρ] ⊢Δ [x₃] [x₄] [G₃x₃≡G₄x₄] [x₁] [x₂] [G₁x₁≡G₂x₂] → proj₂ ([castext] ⊢Δ ([G₁] [ρ] ⊢Δ [x₁]) ([G₂] [ρ] ⊢Δ [x₂]) [G₁x₁≡G₂x₂] ([G₃] [ρ] ⊢Δ [x₃]) ([G₄] [ρ] ⊢Δ [x₄]) [G₃x₃≡G₄x₄])) b₃.[b] b₃.[bext] b₄.[b] b₄.[bext] [b₃≡b₄] [castextShape] {A₁} {A₂} {A₃} {A₄} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) = (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let [A₁] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext [A₃] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext [A₂] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext ⊢t = escapeTerm [A₁] [t] ⊢t′ = escapeTerm [A₂] [t′] ⊢A₁≡Π = subset* D₁ ⊢A₃≡Π = subset* D₃ ⊢A₂≡Π = subset* D₂ ⊢A₄≡Π = subset* D₄ ⊢A₃≡A₄ = escapeEq {l = ι ⁰} [A₃] (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [A₁] [t≡t′]) ⊢A₁≡Π ΠFG′≡ΠFG′₂ = whrDet* (D₂ , Πₙ) (D₂′ , Πₙ) F′≡F′₂ , _ , _ , G′≡G′₂ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₂ ΠFG′≡ΠFG′₄ = whrDet* (D₄ , Πₙ) (D₄′ , Πₙ) F′≡F′₄ , _ , _ , G′≡G′₄ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₄ ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ ⊢A₁≡Π) (un-univ≡ ⊢A₃≡Π))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₂ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₂ ⊢A₂≡Π)) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₄ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₄ ⊢A₄≡Π)))) cast~cast = ~-conv (~-castΠΠ!% (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₂′) (un-univ ⊢F₃) (un-univ ⊢G₃) (≅-un-univ A₃≡A₄′) ⊢t≡t ⊢e' ⊢e′') (sym ⊢A₃≡Π) in neuEqTerm:⇒*: {l = ι ⁰} { n = cast ⁰ (Π F₁ ^ ! ° ⁰ ▹ G₁ ° ⁰ ° ⁰) (Π F₃ ^ % ° ⁰ ▹ G₃ ° ⁰ ° ⁰) e t} {n′ = cast ⁰ (Π F₂ ^ ! ° ⁰ ▹ G₂ ° ⁰ ° ⁰) (Π F₄ ^ % ° ⁰ ▹ G₄ ° ⁰ ° ⁰) e′ t′} [A₃] castΠΠ!%ₙ castΠΠ!%ₙ (transTerm:⇒:* (CastRed*Term ⊢A₃ ⊢e ⊢t (un-univ:⇒*: [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]])) (CastRed*TermΠ (un-univ ⊢F₁ ) (un-univ ⊢G₁) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₃) )) (un-univ≡ ⊢A₁≡Π) (refl (un-univ ⊢A₃))))) (conv ⊢t ⊢A₁≡Π) [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A₄ ⊢e′ ⊢t′ (un-univ:⇒*: [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]])) (CastRed*TermΠ (un-univ ⊢F₂ ) (un-univ ⊢G₂) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₄) )) (un-univ≡ ⊢A₂≡Π) (refl (un-univ ⊢A₄))))) (conv ⊢t′ ⊢A₂≡Π) [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]])) (sym (≅-eq ⊢A₃≡A₄))) (~-irrelevanceTerm PE.refl PE.refl (PE.cong₄ (λ X Y X' Y' → cast ⁰ (Π X ^ ! ° ⁰ ▹ Y ° ⁰ ° ⁰) (Π X' ^ % ° ⁰ ▹ Y' ° ⁰ ° ⁰) _ _ ) (PE.sym F′≡F′₂) (PE.sym G′≡G′₂) (PE.sym F′≡F′₄) (PE.sym G′≡G′₄)) cast~cast)), (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let [A₁] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext [A₃] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext [A₄] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext ⊢t = escapeTerm [A₃] [t] ⊢t′ = escapeTerm [A₄] [t′] ⊢A₁≡Π = subset* D₁ ⊢A₃≡Π = subset* D₃ ⊢A₂≡Π = subset* D₂ ⊢A₄≡Π = subset* D₄ ΠFG′≡ΠFG′₂ = whrDet* (D₂ , Πₙ) (D₂′ , Πₙ) ΠFG′≡ΠFG′₄ = whrDet* (D₄ , Πₙ) (D₄′ , Πₙ) ⊢A₁≡A₂ = escapeEq {l = ι ⁰} [A₁] (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [A₃] [t≡t′]) ⊢A₃≡Π F′≡F′₄ , _ , _ , G′≡G′₄ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₄ F′≡F′₂ , _ , _ , G′≡G′₂ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₂ ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ ⊢A₃≡Π) (un-univ≡ ⊢A₁≡Π))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₄ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₄ ⊢A₄≡Π)) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₂ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₂ ⊢A₂≡Π)))) cast~cast = ~-conv (~-castΠΠ%! (un-univ ⊢F₃) (un-univ ⊢G₃) (≅-un-univ A₃≡A₄′) (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₂′) ⊢t≡t ⊢e' ⊢e′') (sym ⊢A₁≡Π) in neuEqTerm:⇒*: {l = ι ⁰} { n = cast ⁰ (Π F₃ ^ % ° ⁰ ▹ G₃ ° ⁰ ° ⁰) (Π F₁ ^ ! ° ⁰ ▹ G₁ ° ⁰ ° ⁰) e t} {n′ = cast ⁰ (Π F₄ ^ % ° ⁰ ▹ G₄ ° ⁰ ° ⁰) (Π F₂ ^ ! ° ⁰ ▹ G₂ ° ⁰ ° ⁰) e′ t′} [A₁] castΠΠ%!ₙ castΠΠ%!ₙ (transTerm:⇒:* (CastRed*Term ⊢A₁ ⊢e ⊢t (un-univ:⇒*: [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]])) (CastRed*TermΠ (un-univ ⊢F₃ ) (un-univ ⊢G₃) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁) )) (un-univ≡ ⊢A₃≡Π) (refl (un-univ ⊢A₁))))) (conv ⊢t ⊢A₃≡Π) [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A₂ ⊢e′ ⊢t′ (un-univ:⇒*: [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]])) (CastRed*TermΠ (un-univ ⊢F₄ ) (un-univ ⊢G₄) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₂) )) (un-univ≡ ⊢A₄≡Π) (refl (un-univ ⊢A₂))))) (conv ⊢t′ ⊢A₄≡Π) [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]])) (sym (≅-eq ⊢A₁≡A₂))) (~-irrelevanceTerm PE.refl PE.refl (PE.cong₄ (λ X Y X' Y' → cast ⁰ (Π X ^ % ° ⁰ ▹ Y ° ⁰ ° ⁰) (Π X' ^ ! ° ⁰ ▹ Y' ° ⁰ ° ⁰) _ _ ) (PE.sym F′≡F′₄) (PE.sym G′≡G′₄) (PE.sym F′≡F′₂) (PE.sym G′≡G′₂)) cast~cast)) [castextShape] {A₃} {A₄} {A₁} {A₂} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext) (Πᵣ % .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext)) (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) _ _ (Πᵥ (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext) (Πᵣ ! .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext)) (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) = (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let [A₁] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext [A₃] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext [A₄] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₄ G₄ [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]] ⊢F₄ ⊢G₄ A₄≡A₄ [F₄] [G₄] G₄-ext ⊢t = escapeTerm [A₃] [t] ⊢t′ = escapeTerm [A₄] [t′] ⊢A₁≡Π = subset* D₁ ⊢A₃≡Π = subset* D₃ ⊢A₂≡Π = subset* D₂ ⊢A₄≡Π = subset* D₄ ΠFG′≡ΠFG′₂ = whrDet* (D₂ , Πₙ) (D₂′ , Πₙ) ΠFG′≡ΠFG′₄ = whrDet* (D₄ , Πₙ) (D₄′ , Πₙ) ⊢A₁≡A₂ = escapeEq {l = ι ⁰} [A₁] (Π₌ F₂′ G₂′ D₂′ A₁≡A₂′ [F₁≡F₂′] [G₁≡G₂′]) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [A₃] [t≡t′]) ⊢A₃≡Π F′≡F′₄ , _ , _ , G′≡G′₄ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₄ F′≡F′₂ , _ , _ , G′≡G′₂ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₂ ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ ⊢A₃≡Π)(un-univ≡ ⊢A₁≡Π) )) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₄ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₄ ⊢A₄≡Π)) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₂ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₂ ⊢A₂≡Π)))) cast~cast = ~-conv (~-castΠΠ%! (un-univ ⊢F₃) (un-univ ⊢G₃) (≅-un-univ A₃≡A₄′) (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₂′) ⊢t≡t ⊢e' ⊢e′') (sym ⊢A₁≡Π) in neuEqTerm:⇒*: {l = ι ⁰} { n = cast ⁰ (Π F₃ ^ % ° ⁰ ▹ G₃ ° ⁰ ° ⁰) (Π F₁ ^ ! ° ⁰ ▹ G₁ ° ⁰ ° ⁰) e t} {n′ = cast ⁰ (Π F₄ ^ % ° ⁰ ▹ G₄ ° ⁰ ° ⁰) (Π F₂ ^ ! ° ⁰ ▹ G₂ ° ⁰ ° ⁰) e′ t′} [A₁] castΠΠ%!ₙ castΠΠ%!ₙ (transTerm:⇒:* (CastRed*Term ⊢A₁ ⊢e ⊢t (un-univ:⇒*: [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]])) (CastRed*TermΠ (un-univ ⊢F₃ ) (un-univ ⊢G₃) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁) )) (un-univ≡ ⊢A₃≡Π) (refl (un-univ ⊢A₁))))) (conv ⊢t ⊢A₃≡Π) [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A₂ ⊢e′ ⊢t′ (un-univ:⇒*: [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]])) (CastRed*TermΠ (un-univ ⊢F₄ ) (un-univ ⊢G₄) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₂) )) (un-univ≡ ⊢A₄≡Π) (refl (un-univ ⊢A₂))))) (conv ⊢t′ ⊢A₄≡Π) [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]])) (sym (≅-eq ⊢A₁≡A₂))) (~-irrelevanceTerm PE.refl PE.refl (PE.cong₄ (λ X Y X' Y' → cast ⁰ (Π X ^ % ° ⁰ ▹ Y ° ⁰ ° ⁰) (Π X' ^ ! ° ⁰ ▹ Y' ° ⁰ ° ⁰) _ _ ) (PE.sym F′≡F′₄) (PE.sym G′≡G′₄) (PE.sym F′≡F′₂) (PE.sym G′≡G′₂)) cast~cast)) , (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let [A₁] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₁ G₁ [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]] ⊢F₁ ⊢G₁ A₁≡A₁ [F₁] [G₁] G₁-ext [A₃] = Πᵣ′ % ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₃ G₃ [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]] ⊢F₃ ⊢G₃ A₃≡A₃ [F₃] [G₃] G₃-ext [A₂] = Πᵣ′ ! ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F₂ G₂ [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]] ⊢F₂ ⊢G₂ A₂≡A₂ [F₂] [G₂] G₂-ext ⊢t = escapeTerm [A₁] [t] ⊢t′ = escapeTerm [A₂] [t′] ⊢A₁≡Π = subset* D₁ ⊢A₃≡Π = subset* D₃ ⊢A₂≡Π = subset* D₂ ⊢A₄≡Π = subset* D₄ ⊢A₃≡A₄ = escapeEq {l = ι ⁰} [A₃] (Π₌ F₄′ G₄′ D₄′ A₃≡A₄′ [F₃≡F₄′] [G₃≡G₄′]) ⊢t≡t = ≅-conv (escapeTermEq {l = ι ⁰} [A₁] [t≡t′]) ⊢A₁≡Π ΠFG′≡ΠFG′₂ = whrDet* (D₂ , Πₙ) (D₂′ , Πₙ) F′≡F′₂ , _ , _ , G′≡G′₂ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₂ ΠFG′≡ΠFG′₄ = whrDet* (D₄ , Πₙ) (D₄′ , Πₙ) F′≡F′₄ , _ , _ , G′≡G′₄ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₄ ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ ⊢A₁≡Π) (un-univ≡ ⊢A₃≡Π))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₁))) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₂ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₂ ⊢A₂≡Π)) (un-univ≡ (PE.subst (λ X → Γ ⊢ A₄ ≡ X ^ [ ! , ι ⁰ ]) ΠFG′≡ΠFG′₄ ⊢A₄≡Π)))) cast~cast = ~-conv (~-castΠΠ!% (un-univ ⊢F₁) (un-univ ⊢G₁) (≅-un-univ A₁≡A₂′) (un-univ ⊢F₃) (un-univ ⊢G₃) (≅-un-univ A₃≡A₄′) ⊢t≡t ⊢e' ⊢e′') (sym ⊢A₃≡Π) in neuEqTerm:⇒*: {l = ι ⁰} { n = cast ⁰ (Π F₁ ^ ! ° ⁰ ▹ G₁ ° ⁰ ° ⁰) (Π F₃ ^ % ° ⁰ ▹ G₃ ° ⁰ ° ⁰) e t} {n′ = cast ⁰ (Π F₂ ^ ! ° ⁰ ▹ G₂ ° ⁰ ° ⁰) (Π F₄ ^ % ° ⁰ ▹ G₄ ° ⁰ ° ⁰) e′ t′} [A₃] castΠΠ!%ₙ castΠΠ!%ₙ (transTerm:⇒:* (CastRed*Term ⊢A₃ ⊢e ⊢t (un-univ:⇒*: [[ ⊢A₁ , ⊢ΠF₁G₁ , D₁ ]])) (CastRed*TermΠ (un-univ ⊢F₁ ) (un-univ ⊢G₁) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A₃) )) (un-univ≡ ⊢A₁≡Π) (refl (un-univ ⊢A₃))))) (conv ⊢t ⊢A₁≡Π) [[ ⊢A₃ , ⊢ΠF₃G₃ , D₃ ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A₄ ⊢e′ ⊢t′ (un-univ:⇒*: [[ ⊢A₂ , ⊢ΠF₂G₂ , D₂ ]])) (CastRed*TermΠ (un-univ ⊢F₂ ) (un-univ ⊢G₂) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A₄) )) (un-univ≡ ⊢A₂≡Π) (refl (un-univ ⊢A₄))))) (conv ⊢t′ ⊢A₂≡Π) [[ ⊢A₄ , ⊢ΠF₄G₄ , D₄ ]])) (sym (≅-eq ⊢A₃≡A₄))) (~-irrelevanceTerm PE.refl PE.refl (PE.cong₄ (λ X Y X' Y' → cast ⁰ (Π X ^ ! ° ⁰ ▹ Y ° ⁰ ° ⁰) (Π X' ^ % ° ⁰ ▹ Y' ° ⁰ ° ⁰) _ _ ) (PE.sym F′≡F′₂) (PE.sym G′≡G′₂) (PE.sym F′≡F′₄) (PE.sym G′≡G′₄)) cast~cast)) [castextShape] {A} {C} {B} {D} {Γ} ⊢Γ .(ℕᵣ ℕA₁) .(ℕᵣ ℕB₁) (ℕᵥ ℕA₁ ℕB₁) [A≡C] .(ℕᵣ ℕA) .(ℕᵣ ℕB) (ℕᵥ ℕA ℕB) [B≡D] = (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → [castext]ℕ ⊢Γ ℕA₁ ℕB₁ [A≡C] ℕA ℕB [B≡D] (escapeTerm {l = ι ⁰} (ℕᵣ ℕA₁) [t]) (escapeTerm {l = ι ⁰} (ℕᵣ ℕB₁) [t′]) [t≡t′] ⊢e ⊢e′ ) , λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → [castext]ℕ ⊢Γ ℕA ℕB [B≡D] ℕA₁ ℕB₁ [A≡C] (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) [t≡t′] ⊢e ⊢e′ [castextShape] {A} {C} {B} {D} {Γ} ⊢Γ .(ne neA) .(ne neB) (ne neA neB) [A≡C] .(ℕᵣ ℕA) .(ℕᵣ ℕB) (ℕᵥ ℕA ℕB) [B≡D] = ([castext]Ne ⊢Γ neA neB [A≡C] (ℕᵣ ℕA) (ℕᵣ ℕB) [B≡D]) , (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ne K [[ ⊢A , ⊢K , D ]] neK K≡K = neA ne₌ K′ [[ ⊢A′ , ⊢K′ , D′ ]] neK' K≡K' = [A≡C] ⊢B≡ℕ = subset* (red ℕA) ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) ⊢B≡ℕ ⊢D≡ℕ = subset* (red ℕB) ⊢t′ = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) ⊢D≡ℕ t≅t′ = escapeTermEq {l = ι ⁰} (ℕᵣ ℕA) [t≡t′] ⊢A≡K = subset* D ⊢C≡K = subset* D′ ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢B≡ℕ) (un-univ≡ ⊢A≡K))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢D≡ℕ) (un-univ≡ ⊢C≡K))) in neₜ₌ (cast ⁰ ℕ K e t) (cast ⁰ ℕ K′ e′ t′) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) (un-univ:⇒*: ℕA)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢B≡ℕ) (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢K , D ]])) (subset* D)) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A′ ⊢e′ (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) (un-univ:⇒*: ℕB)) (CastRed*Termℕ (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A′) )) (un-univ≡ ⊢D≡ℕ) (refl (un-univ ⊢A′))))) ⊢t′ [[ ⊢A′ , ⊢K′ , D′ ]])) (trans (subset* D′) (sym (≅-eq (≅-univ (~-to-≅ₜ K≡K')))))) (neNfₜ₌ (castℕₙ neK) (castℕₙ neK') (~-castℕ ⊢Γ K≡K' (≅-conv t≅t′ ⊢B≡ℕ) ⊢e' ⊢e′'))) [castextShape] {A} {C} {B} {D} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ rF .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF′ .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′)) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′]) .(ℕᵣ ℕA) .(ℕᵣ ℕB) (ℕᵥ ℕA ℕB) [B≡D] = (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ΠA = Πᵣ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext ΠB = Πᵣ rF′ ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′ ⊢A≡Π = subset* DΠA [[ _ , _ , DB ]] = ℕA ⊢B≡ℕ = subset* DB [[ _ , _ , DD ]] = ℕB ⊢D≡ℕ = subset* DD ⊢t = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) ⊢A≡Π ⊢C≡Π = subset* DΠB ⊢t′ = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) ⊢C≡Π t≅t′ = escapeTermEq {l = ι ⁰} (Πᵣ ΠA) [t≡t′] ΠFG′≡ΠFG′₁ = whrDet* (DΠB , Πₙ) (D₌ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ ⊢B = escape {l = ι ⁰} (ℕᵣ ℕA) ⊢D = escape {l = ι ⁰} (ℕᵣ ℕB) ⊢B≡D = escapeEq {l = ι ⁰} (ℕᵣ ℕA) [B≡D] ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢A≡Π) (un-univ≡ ⊢B≡ℕ))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ (PE.subst (λ X → Γ ⊢ C ≡ X ^ [ ! , ι ⁰ ]) (PE.cong₃ (λ X Y Z → Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) F′≡F′₁ rF≡rF′ G′≡G′₁) ⊢C≡Π)) (un-univ≡ ⊢D≡ℕ))) cast~cast = ~-irrelevanceTerm PE.refl PE.refl (PE.cong₃ (λ X Y Z → cast ⁰ (Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) _ _ _ ) (PE.sym F′≡F′₁) (PE.sym rF≡rF′) (PE.sym G′≡G′₁) ) (~-castΠℕ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡B) (≅-conv t≅t′ ⊢A≡Π) ⊢e' ⊢e′') in neuEqTerm:⇒*: {l = ι ⁰} { n = cast ⁰ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) ℕ e t} {n′ = cast ⁰ (Π F′ ^ rF′ ° ⁰ ▹ G′ ° ⁰ ° ⁰) ℕ e′ t′} (ℕᵣ ℕA) castΠℕₙ castΠℕₙ (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) (un-univ:⇒*: [[ ⊢A , ⊢Π , DΠA ]])) (CastRed*TermΠ (un-univ ⊢F) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢A≡Π) (refl (un-univ ⊢B))))) ⊢t ℕA)) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢D ⊢e′ (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) (un-univ:⇒*: [[ ⊢C , ⊢Π′ , DΠB ]])) (CastRed*TermΠ (un-univ ⊢F′) (un-univ ⊢G′) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢C) )) (un-univ≡ ⊢C≡Π) (refl (un-univ ⊢D))))) ⊢t′ ℕB)) (sym (≅-eq ⊢B≡D))) (~-conv cast~cast (sym (subset* (red ℕA))))), λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ΠA = Πᵣ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext ⊢A≡Π = subset* DΠA ⊢B≡ℕ = subset* (red ℕA) ⊢D≡ℕ = subset* (red ℕB) ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) ⊢B≡ℕ ⊢C≡Π = subset* DΠB ⊢t′ = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) ⊢D≡ℕ t≅t′ = escapeTermEq {l = ι ⁰} (ℕᵣ ℕA) [t≡t′] ΠFG′≡ΠFG′₁ = whrDet* (DΠB , Πₙ) (D₌ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ ⊢B = escape {l = ι ⁰} (ℕᵣ ℕA) ⊢D = escape {l = ι ⁰} (ℕᵣ ℕB) ⊢A≡C = escapeEq {l = ι ⁰} (Πᵣ ΠA) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′]) ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢B≡ℕ) (un-univ≡ ⊢A≡Π))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢D≡ℕ) (un-univ≡ (PE.subst (λ X → Γ ⊢ C ≡ X ^ [ ! , ι ⁰ ]) (PE.cong₃ (λ X Y Z → Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) F′≡F′₁ rF≡rF′ G′≡G′₁) ⊢C≡Π)))) cast~cast = ~-irrelevanceTerm PE.refl PE.refl (PE.cong₃ (λ X Y Z → cast ⁰ _ (Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) _ _ ) (PE.sym F′≡F′₁) (PE.sym rF≡rF′) (PE.sym G′≡G′₁) ) (~-castℕΠ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡B) (≅-conv t≅t′ ⊢B≡ℕ) ⊢e' ⊢e′') in neuEqTerm:⇒*: { n = cast ⁰ ℕ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) e t} {n′ = cast ⁰ ℕ (Π F′ ^ rF′ ° ⁰ ▹ G′ ° ⁰ ° ⁰) e′ t′} (Πᵣ ΠA) castℕΠₙ castℕΠₙ (transTerm:⇒:* (CastRed*Term ⊢A ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) (un-univ:⇒*: ℕA)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢B≡ℕ) (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢Π , DΠA ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢C ⊢e′ (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) (un-univ:⇒*: ℕB)) (CastRed*Termℕ (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢C) )) (un-univ≡ ⊢D≡ℕ) (refl (un-univ ⊢C))))) ⊢t′ [[ ⊢C , ⊢Π′ , DΠB ]])) (sym (≅-eq ⊢A≡C))) (~-conv cast~cast (sym (subset* DΠA))) [castextShape] {A} {C} {B} {D} {Γ} ⊢Γ .(ℕᵣ ℕA) .(ℕᵣ ℕB) (ℕᵥ ℕA ℕB) [A≡C] .(ne neA) .(ne neB) (ne neA neB) [B≡D] = (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ne K [[ ⊢A , ⊢K , D ]] neK K≡K = neA ne₌ K′ [[ ⊢A′ , ⊢K′ , D′ ]] neK' K≡K' = [B≡D] ⊢B≡ℕ = subset* (red ℕA) ⊢A≡K = subset* D ⊢C≡K = subset* D′ ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) ⊢B≡ℕ ⊢D≡ℕ = subset* (red ℕB) ⊢t′ = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) ⊢D≡ℕ t≅t′ = escapeTermEq {l = ι ⁰} (ℕᵣ ℕA) [t≡t′] ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢B≡ℕ) (un-univ≡ ⊢A≡K))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢D≡ℕ) (un-univ≡ ⊢C≡K))) in neₜ₌ (cast ⁰ ℕ K e t) (cast ⁰ ℕ K′ e′ t′) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) (un-univ:⇒*: ℕA)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢B≡ℕ) (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢K , D ]])) (subset* D)) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢A′ ⊢e′ (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) (un-univ:⇒*: ℕB)) (CastRed*Termℕ (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A′) )) (un-univ≡ ⊢D≡ℕ) (refl (un-univ ⊢A′))))) ⊢t′ [[ ⊢A′ , ⊢K′ , D′ ]])) (trans (subset* D′) (sym (≅-eq (≅-univ (~-to-≅ₜ K≡K')))))) (neNfₜ₌ (castℕₙ neK) (castℕₙ neK') (~-castℕ ⊢Γ K≡K' (≅-conv t≅t′ ⊢B≡ℕ) ⊢e' ⊢e′'))) , ([castext]Ne ⊢Γ neA neB [B≡D] (ℕᵣ ℕA) (ℕᵣ ℕB) [A≡C]) [castextShape] {A} {C} {B} {D} {Γ} {r = !} ⊢Γ .(ne neA₁) .(ne neB₁) (ne neA₁ neB₁) [A≡C] .(ne neA) .(ne neB) (ne neA neB) [B≡D] = ([castext]Ne ⊢Γ neA₁ neB₁ [A≡C] (ne neA) (ne neB) [B≡D]) , ([castext]Ne ⊢Γ neA neB [B≡D] (ne neA₁) (ne neB₁) [A≡C]) [castextShape] {A} {C} {B} {D} {Γ} {r = !} ⊢Γ _ _ (Πᵥ (Πᵣ rF .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF′ .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′)) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′]) .(ne neA) .(ne neB) (ne neA neB) [B≡D] = (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ne K [[ ⊢B , ⊢K , D ]] neK K≡K = neA ne₌ K′ [[ ⊢D , ⊢K′ , D′ ]] neK' K≡K' = [B≡D] ΠA = Πᵣ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext ΠB = Πᵣ rF′ ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′ ⊢A≡Π = subset* DΠA ⊢B≡K = subset* D ⊢D≡K = subset* D′ ⊢t = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) ⊢A≡Π ⊢C≡Π = subset* DΠB ⊢t′ = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) ⊢C≡Π t≅t′ = escapeTermEq {l = ι ⁰} (Πᵣ ΠA) [t≡t′] ΠFG′≡ΠFG′₁ = whrDet* (DΠB , Πₙ) (D₌ , Πₙ) ⊢B≡D = escapeEq {l = ι ⁰} (ne neA) [B≡D] F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢A≡Π) (un-univ≡ ⊢B≡K))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ (PE.subst (λ X → Γ ⊢ C ≡ X ^ [ ! , ι ⁰ ]) (PE.cong₃ (λ X Y Z → Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) F′≡F′₁ rF≡rF′ G′≡G′₁) ⊢C≡Π)) (un-univ≡ ⊢D≡K))) in neuEqTerm:⇒*: {l = ι ⁰} {n = cast ⁰ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) K e t} {n′ = cast ⁰ (Π F′ ^ rF′ ° ⁰ ▹ G′ ° ⁰ ° ⁰) K′ e′ t′} (ne neA) (castΠₙ neK) (castΠₙ neK') (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) (un-univ:⇒*: [[ ⊢A , ⊢Π , DΠA ]])) (CastRed*TermΠ (un-univ ⊢F) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢A≡Π) (refl (un-univ ⊢B))))) ⊢t [[ ⊢B , ⊢K , D ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢D ⊢e′ (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) (un-univ:⇒*: [[ ⊢C , ⊢Π′ , DΠB ]])) (CastRed*TermΠ (un-univ ⊢F′) (un-univ ⊢G′) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢C) )) (un-univ≡ ⊢C≡Π) (refl (un-univ ⊢D))))) ⊢t′ [[ ⊢D , ⊢K′ , D′ ]])) (sym (≅-eq ⊢B≡D))) (~-irrelevanceTerm PE.refl PE.refl (PE.cong₃ (λ X Y Z → cast ⁰ (Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) _ _ _ ) (PE.sym F′≡F′₁) (PE.sym rF≡rF′) (PE.sym G′≡G′₁) ) (~-conv (~-castΠ (≅-un-univ A≡B) K≡K' (≅-conv t≅t′ ⊢A≡Π) ⊢e' ⊢e′') (sym (subset* D))))) , ([castext]Ne ⊢Γ neA neB [B≡D] (Πᵣ′ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ′ rF′ ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′])) [castextShape] {A} {C} {B} {D} {Γ} {r = !} ⊢Γ .(ℕᵣ ℕA) .(ℕᵣ ℕB) (ℕᵥ ℕA ℕB) [B≡D] _ _ (Πᵥ (Πᵣ rF .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF′ .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′)) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′]) = (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ΠA = Πᵣ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext ⊢A≡Π = subset* DΠA ⊢B≡ℕ = subset* (red ℕA) ⊢D≡ℕ = subset* (red ℕB) ⊢t = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) ⊢B≡ℕ ⊢C≡Π = subset* DΠB ⊢t′ = conv (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) ⊢D≡ℕ t≅t′ = escapeTermEq {l = ι ⁰} (ℕᵣ ℕA) [t≡t′] ΠFG′≡ΠFG′₁ = whrDet* (DΠB , Πₙ) (D₌ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ ⊢B = escape {l = ι ⁰} (ℕᵣ ℕA) ⊢D = escape {l = ι ⁰} (ℕᵣ ℕB) ⊢A≡C = escapeEq {l = ι ⁰} (Πᵣ ΠA) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′]) ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢B≡ℕ) (un-univ≡ ⊢A≡Π))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢D≡ℕ) (un-univ≡ (PE.subst (λ X → Γ ⊢ D ≡ X ^ [ ! , ι ⁰ ]) (PE.cong₃ (λ X Y Z → Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) F′≡F′₁ rF≡rF′ G′≡G′₁) ⊢C≡Π)))) cast~cast = ~-irrelevanceTerm PE.refl PE.refl (PE.cong₃ (λ X Y Z → cast ⁰ _ (Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) _ _ ) (PE.sym F′≡F′₁) (PE.sym rF≡rF′) (PE.sym G′≡G′₁) ) (~-castℕΠ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡B) (≅-conv t≅t′ ⊢B≡ℕ) ⊢e' ⊢e′') in neuEqTerm:⇒*: {l = ι ⁰} { n = cast ⁰ ℕ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) e t} {n′ = cast ⁰ ℕ (Π F′ ^ rF′ ° ⁰ ▹ G′ ° ⁰ ° ⁰) e′ t′} (Πᵣ ΠA) castℕΠₙ castℕΠₙ (transTerm:⇒:* (CastRed*Term ⊢A ⊢e (escapeTerm {l = ι ⁰} (ℕᵣ ℕA) [t]) (un-univ:⇒*: ℕA)) (CastRed*Termℕ (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢B≡ℕ) (refl (un-univ ⊢A))))) ⊢t [[ ⊢A , ⊢Π , DΠA ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢C ⊢e′ (escapeTerm {l = ι ⁰} (ℕᵣ ℕB) [t′]) (un-univ:⇒*: ℕB)) (CastRed*Termℕ (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢C) )) (un-univ≡ ⊢D≡ℕ) (refl (un-univ ⊢C))))) ⊢t′ [[ ⊢C , ⊢Π′ , DΠB ]])) (sym (≅-eq ⊢A≡C))) (~-conv cast~cast (sym (subset* DΠA)))) , (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ΠA = Πᵣ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext ΠB = Πᵣ rF′ ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′ ⊢A≡Π = subset* DΠA ⊢t = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) ⊢A≡Π ⊢C≡Π = subset* DΠB ⊢t′ = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) ⊢C≡Π t≅t′ = escapeTermEq {l = ι ⁰} (Πᵣ ΠA) [t≡t′] ΠFG′≡ΠFG′₁ = whrDet* (DΠB , Πₙ) (D₌ , Πₙ) F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ ⊢B = escape {l = ι ⁰} (ℕᵣ ℕA) ⊢D = escape {l = ι ⁰} (ℕᵣ ℕB) ⊢B≡ℕ = subset* (red ℕA) ⊢D≡ℕ = subset* (red ℕB) ⊢B≡D = escapeEq {l = ι ⁰} (ℕᵣ ℕA) [B≡D] ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢A≡Π) (un-univ≡ ⊢B≡ℕ))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ (PE.subst (λ X → Γ ⊢ D ≡ X ^ [ ! , ι ⁰ ]) (PE.cong₃ (λ X Y Z → Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) F′≡F′₁ rF≡rF′ G′≡G′₁) ⊢C≡Π)) (un-univ≡ ⊢D≡ℕ))) cast~cast = ~-irrelevanceTerm PE.refl PE.refl (PE.cong₃ (λ X Y Z → cast ⁰ (Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) _ _ _ ) (PE.sym F′≡F′₁) (PE.sym rF≡rF′) (PE.sym G′≡G′₁) ) (~-castΠℕ (un-univ ⊢F) (un-univ ⊢G) (≅-un-univ A≡B) (≅-conv t≅t′ ⊢A≡Π) ⊢e' ⊢e′') in neuEqTerm:⇒*: {l = ι ⁰} { n = cast ⁰ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) ℕ e t} {n′ = cast ⁰ (Π F′ ^ rF′ ° ⁰ ▹ G′ ° ⁰ ° ⁰) ℕ e′ t′} (ℕᵣ ℕA) castΠℕₙ castΠℕₙ (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) (un-univ:⇒*: [[ ⊢A , ⊢Π , DΠA ]])) (CastRed*TermΠ (un-univ ⊢F) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢A≡Π) (refl (un-univ ⊢B))))) ⊢t ℕA)) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢D ⊢e′ (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) (un-univ:⇒*: [[ ⊢C , ⊢Π′ , DΠB ]])) (CastRed*TermΠ (un-univ ⊢F′) (un-univ ⊢G′) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢C) )) (un-univ≡ ⊢C≡Π) (refl (un-univ ⊢D))))) ⊢t′ ℕB)) (sym (≅-eq ⊢B≡D))) (~-conv cast~cast (sym (subset* (red ℕA))))) [castextShape] {A} {C} {B} {D} {Γ} {r = !} ⊢Γ .(ne neA) .(ne neB) (ne neA neB) [B≡D] _ _ (Πᵥ (Πᵣ rF .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF′ .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′)) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′]) = ([castext]Ne ⊢Γ neA neB [B≡D] (Πᵣ′ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ′ rF′ ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′) (Π₌ F′₁ G′₁ D₌ A≡B [F≡F′] [G≡G′])) , (λ {t} {t′} {e} {e′} [t] [t′] [t≡t′] ⊢e ⊢e′ → let ne K [[ ⊢B , ⊢K , DB ]] neK K≡K = neA ne₌ K′ [[ ⊢D , ⊢K′ , D′ ]] neK' K≡K' = [B≡D] ΠA = Πᵣ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G [[ ⊢A , ⊢Π , DΠA ]] ⊢F ⊢G A≡A [F] [G] G-ext ΠB = Πᵣ rF′ ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F′ G′ [[ ⊢C , ⊢Π′ , DΠB ]] ⊢F′ ⊢G′ C≡C [F]′ [G]′ G-ext′ ⊢A≡Π = subset* DΠA ⊢t = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) ⊢A≡Π ⊢C≡Π = subset* DΠB ⊢t′ = conv (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) ⊢C≡Π t≅t′ = escapeTermEq {l = ι ⁰} (Πᵣ ΠA) [t≡t′] ΠFG′≡ΠFG′₁ = whrDet* (DΠB , Πₙ) (D₌ , Πₙ) ⊢B≡K = subset* DB ⊢D≡K = subset* D′ ⊢B≡D = escapeEq {l = ι ⁰} (ne neA) [B≡D] F′≡F′₁ , rF≡rF′ , _ , G′≡G′₁ , _ = Π-PE-injectivity ΠFG′≡ΠFG′₁ ⊢e' = conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ ⊢A≡Π) (un-univ≡ ⊢B≡K))) ⊢e′' = conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢A))) (un-univ≡ (PE.subst (λ X → Γ ⊢ D ≡ X ^ [ ! , ι ⁰ ]) (PE.cong₃ (λ X Y Z → Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) F′≡F′₁ rF≡rF′ G′≡G′₁) ⊢C≡Π)) (un-univ≡ ⊢D≡K))) in neuEqTerm:⇒*: {l = ι ⁰} {n = cast ⁰ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) K e t} {n′ = cast ⁰ (Π F′ ^ rF′ ° ⁰ ▹ G′ ° ⁰ ° ⁰) K′ e′ t′} (ne neA) (castΠₙ neK) (castΠₙ neK') (transTerm:⇒:* (CastRed*Term ⊢B ⊢e (escapeTerm {l = ι ⁰} (Πᵣ ΠA) [t]) (un-univ:⇒*: [[ ⊢A , ⊢Π , DΠA ]])) (CastRed*TermΠ (un-univ ⊢F) (un-univ ⊢G) (conv ⊢e (univ (Id-cong (refl (univ 0<1 (wf ⊢A) )) (un-univ≡ ⊢A≡Π) (refl (un-univ ⊢B))))) ⊢t [[ ⊢B , ⊢K , DB ]])) (conv:⇒*: (transTerm:⇒:* (CastRed*Term ⊢D ⊢e′ (escapeTerm {l = ι ⁰} (Πᵣ ΠB) [t′]) (un-univ:⇒*: [[ ⊢C , ⊢Π′ , DΠB ]])) (CastRed*TermΠ (un-univ ⊢F′) (un-univ ⊢G′) (conv ⊢e′ (univ (Id-cong (refl (univ 0<1 (wf ⊢C) )) (un-univ≡ ⊢C≡Π) (refl (un-univ ⊢D))))) ⊢t′ [[ ⊢D , ⊢K′ , D′ ]])) (sym (≅-eq ⊢B≡D))) (~-irrelevanceTerm PE.refl PE.refl (PE.cong₃ (λ X Y Z → cast ⁰ (Π X ^ Y ° ⁰ ▹ Z ° ⁰ ° ⁰) _ _ _ ) (PE.sym F′≡F′₁) (PE.sym rF≡rF′) (PE.sym G′≡G′₁) ) (~-conv (~-castΠ (≅-un-univ A≡B) K≡K' (≅-conv t≅t′ ⊢A≡Π) ⊢e' ⊢e′') (sym (subset* DB))))) [castextShape] {A} {C} {B} {D} {Γ} {r = %} ⊢Γ [A] [C] _ [A≡C] [B] [D] _ [B≡D] = [castext]irr {A} {C} {B} {D} {Γ} ⊢Γ [A] [C] [A≡C] [B] [D] [B≡D] , [castext]irr {B} {D} {A} {C} {Γ} ⊢Γ [B] [D] [B≡D] [A] [C] [A≡C] [castext] {A} {C} {B} {D} {Γ} ⊢Γ [A] [C] [A≡C] [B] [D] [B≡D] = [castextShape] ⊢Γ [A] [C] (goodCases [A] [C] [A≡C]) [A≡C] [B] [D] (goodCases [B] [D] [B≡D]) [B≡D] cast∞ : ∀ {A B r t e Γ} (⊢Γ : ⊢ Γ) ([U] : Γ ⊩⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ]) ([AU] : Γ ⊩⟨ ∞ ⟩ A ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([BU] : Γ ⊩⟨ ∞ ⟩ B ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([A] : Γ ⊩⟨ ∞ ⟩ A ^ [ r , ι ⁰ ]) ([B] : Γ ⊩⟨ ∞ ⟩ B ^ [ r , ι ⁰ ]) ([t] : Γ ⊩⟨ ∞ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]) ([Id] : Γ ⊩⟨ ∞ ⟩ Id (Univ r ⁰) A B ^ [ % , ι ¹ ]) → ([e] : Γ ⊩⟨ ∞ ⟩ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] / [Id] ) → Γ ⊩⟨ ∞ ⟩ cast ⁰ A B e t ∷ B ^ [ r , ι ⁰ ] / [B] cast∞ {A} {B} {r} {t} {e} {Γ} ⊢Γ [U] [AU] [BU] [A] [B] [t] [Id] [e] = let [A]′ : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ r , ι ⁰ ] [A]′ = univEq [U] [AU] [B]′ : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ r , ι ⁰ ] [B]′ = univEq [U] [BU] [t]′ : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]′ [t]′ = irrelevanceTerm [A] (emb ∞< (emb emb< [A]′)) [t] ⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] ⊢e = escapeTerm [Id] [e] x : Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ∷ B ^ [ r , ι ⁰ ] / [B]′ x = proj₁ ([cast] ⊢Γ [A]′ [B]′) [t]′ ⊢e in irrelevanceTerm (emb ∞< (emb emb< [B]′)) [B] x castext∞ : ∀ {A A' B B' r t t' e e' Γ} (⊢Γ : ⊢ Γ) ([U] : Γ ⊩⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ]) ([U'] : Γ ⊩⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ]) ([AU] : Γ ⊩⟨ ∞ ⟩ A ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([AU'] : Γ ⊩⟨ ∞ ⟩ A' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([BU] : Γ ⊩⟨ ∞ ⟩ B ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U']) ([BU'] : Γ ⊩⟨ ∞ ⟩ B' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U']) ([UA≡UA'] : Γ ⊩⟨ ∞ ⟩ A ≡ A' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([UB≡UB'] : Γ ⊩⟨ ∞ ⟩ B ≡ B' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U']) ([A] : Γ ⊩⟨ ∞ ⟩ A ^ [ r , ι ⁰ ]) ([A'] : Γ ⊩⟨ ∞ ⟩ A' ^ [ r , ι ⁰ ]) ([B] : Γ ⊩⟨ ∞ ⟩ B ^ [ r , ι ⁰ ]) ([B'] : Γ ⊩⟨ ∞ ⟩ B' ^ [ r , ι ⁰ ]) ([t] : Γ ⊩⟨ ∞ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]) ([t'] : Γ ⊩⟨ ∞ ⟩ t' ∷ A' ^ [ r , ι ⁰ ] / [A']) ([t≡t'] : Γ ⊩⟨ ∞ ⟩ t ≡ t' ∷ A ^ [ r , ι ⁰ ] / [A]) ([Id] : Γ ⊩⟨ ∞ ⟩ Id (Univ r ⁰) A B ^ [ % , ι ¹ ]) → ([Id'] : Γ ⊩⟨ ∞ ⟩ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ]) → ([e] : Γ ⊩⟨ ∞ ⟩ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] / [Id] ) → ([e'] : Γ ⊩⟨ ∞ ⟩ e' ∷ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ] / [Id'] ) → Γ ⊩⟨ ∞ ⟩ cast ⁰ A B e t ≡ cast ⁰ A' B' e' t' ∷ B ^ [ r , ι ⁰ ] / [B] castext∞ {A} {A'} {B} {B'} {r} {t} {t'} {e} {e'} {Γ} ⊢Γ [U] [U'] [AU] [AU'] [BU] [BU'] [UA≡UA'] [UB≡UB'] [A] [A'] [B] [B'] [t] [t'] [t≡t'] [Id] [Id'] [e] [e'] = let [A]′ : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ r , ι ⁰ ] [A]′ = univEq [U] [AU] [A']′ : Γ ⊩⟨ ι ⁰ ⟩ A' ^ [ r , ι ⁰ ] [A']′ = univEq [U] [AU'] [t]′ : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]′ [t]′ = irrelevanceTerm [A] (emb ∞< (emb emb< [A]′)) [t] [B]′ : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ r , ι ⁰ ] [B]′ = univEq [U'] [BU] [B']′ : Γ ⊩⟨ ι ⁰ ⟩ B' ^ [ r , ι ⁰ ] [B']′ = univEq [U'] [BU'] [A≡A']′ : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A' ^ [ r , ι ⁰ ] / [A]′ [A≡A']′ = univEqEq [U] [A]′ [UA≡UA'] [B≡B']′ : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B' ^ [ r , ι ⁰ ] / [B]′ [B≡B']′ = univEqEq [U'] [B]′ [UB≡UB'] [t']′ : Γ ⊩⟨ ι ⁰ ⟩ t' ∷ A' ^ [ r , ι ⁰ ] / [A']′ [t']′ = irrelevanceTerm [A'] (emb ∞< (emb emb< [A']′)) [t'] [t≡t']′ : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t' ∷ A ^ [ r , ι ⁰ ] / [A]′ [t≡t']′ = irrelevanceEqTerm [A] (emb ∞< (emb emb< [A]′)) [t≡t'] ⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] ⊢e = escapeTerm [Id] [e] ⊢e' : Γ ⊢ e' ∷ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ] ⊢e' = escapeTerm [Id'] [e'] x : Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ≡ cast ⁰ A' B' e' t' ∷ B ^ [ r , ι ⁰ ] / [B]′ x = proj₁ ([castext] ⊢Γ [A]′ [A']′ [A≡A']′ [B]′ [B']′ [B≡B']′) [t]′ [t']′ [t≡t']′ ⊢e ⊢e' in irrelevanceEqTerm (emb ∞< (emb emb< [B]′)) [B] x castext∞' : ∀ {A A' B B' r t t' e e' Γ} (⊢Γ : ⊢ Γ) ([U] : Γ ⊩⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ]) ([U'] : Γ ⊩⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ]) ([AU] : Γ ⊩⟨ ∞ ⟩ A ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([AU'] : Γ ⊩⟨ ∞ ⟩ A' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U']) ([BU] : Γ ⊩⟨ ∞ ⟩ B ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([BU'] : Γ ⊩⟨ ∞ ⟩ B' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U']) ([UA≡UA'] : Γ ⊩⟨ ∞ ⟩ A ≡ A' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([UB≡UB'] : Γ ⊩⟨ ∞ ⟩ B ≡ B' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [U]) ([A] : Γ ⊩⟨ ∞ ⟩ A ^ [ r , ι ⁰ ]) ([A'] : Γ ⊩⟨ ∞ ⟩ A' ^ [ r , ι ⁰ ]) ([B] : Γ ⊩⟨ ∞ ⟩ B ^ [ r , ι ⁰ ]) ([B'] : Γ ⊩⟨ ∞ ⟩ B' ^ [ r , ι ⁰ ]) ([t] : Γ ⊩⟨ ∞ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]) ([t'] : Γ ⊩⟨ ∞ ⟩ t' ∷ A' ^ [ r , ι ⁰ ] / [A']) ([t≡t'] : Γ ⊩⟨ ∞ ⟩ t ≡ t' ∷ A ^ [ r , ι ⁰ ] / [A]) ([Id] : Γ ⊩⟨ ∞ ⟩ Id (Univ r ⁰) A B ^ [ % , ι ¹ ]) → ([Id'] : Γ ⊩⟨ ∞ ⟩ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ]) → ([e] : Γ ⊩⟨ ∞ ⟩ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] / [Id] ) → ([e'] : Γ ⊩⟨ ∞ ⟩ e' ∷ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ] / [Id'] ) → Γ ⊩⟨ ∞ ⟩ cast ⁰ A B e t ≡ cast ⁰ A' B' e' t' ∷ B ^ [ r , ι ⁰ ] / [B] castext∞' {A} {A'} {B} {B'} {r} {t} {t'} {e} {e'} {Γ} ⊢Γ [U] [U'] [AU] [AU'] [BU] [BU'] [UA≡UA'] [UB≡UB'] [A] [A'] [B] [B'] [t] [t'] [t≡t'] [Id] [Id'] [e] [e'] = let [A]′ : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ r , ι ⁰ ] [A]′ = univEq [U] [AU] [A']′ : Γ ⊩⟨ ι ⁰ ⟩ A' ^ [ r , ι ⁰ ] [A']′ = univEq [U'] [AU'] [t]′ : Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [A]′ [t]′ = irrelevanceTerm [A] (emb ∞< (emb emb< [A]′)) [t] [B]′ : Γ ⊩⟨ ι ⁰ ⟩ B ^ [ r , ι ⁰ ] [B]′ = univEq [U] [BU] [B']′ : Γ ⊩⟨ ι ⁰ ⟩ B' ^ [ r , ι ⁰ ] [B']′ = univEq [U'] [BU'] [A≡A']′ : Γ ⊩⟨ ι ⁰ ⟩ A ≡ A' ^ [ r , ι ⁰ ] / [A]′ [A≡A']′ = univEqEq [U] [A]′ [UA≡UA'] [B≡B']′ : Γ ⊩⟨ ι ⁰ ⟩ B ≡ B' ^ [ r , ι ⁰ ] / [B]′ [B≡B']′ = univEqEq [U] [B]′ [UB≡UB'] [t']′ : Γ ⊩⟨ ι ⁰ ⟩ t' ∷ A' ^ [ r , ι ⁰ ] / [A']′ [t']′ = irrelevanceTerm [A'] (emb ∞< (emb emb< [A']′)) [t'] [t≡t']′ : Γ ⊩⟨ ι ⁰ ⟩ t ≡ t' ∷ A ^ [ r , ι ⁰ ] / [A]′ [t≡t']′ = irrelevanceEqTerm [A] (emb ∞< (emb emb< [A]′)) [t≡t'] ⊢e : Γ ⊢ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] ⊢e = escapeTerm [Id] [e] ⊢e' : Γ ⊢ e' ∷ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ] ⊢e' = escapeTerm [Id'] [e'] x : Γ ⊩⟨ ι ⁰ ⟩ cast ⁰ A B e t ≡ cast ⁰ A' B' e' t' ∷ B ^ [ r , ι ⁰ ] / [B]′ x = proj₁ ([castext] ⊢Γ [A]′ [A']′ [A≡A']′ [B]′ [B']′ [B≡B']′) [t]′ [t']′ [t≡t']′ ⊢e ⊢e' in irrelevanceEqTerm (emb ∞< (emb emb< [B]′)) [B] x abstract castᵗᵛ : ∀ {A B r t e Γ} ([Γ] : ⊩ᵛ Γ) ([U] : Γ ⊩ᵛ⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ]) ([AU] : Γ ⊩ᵛ⟨ ∞ ⟩ A ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U]) ([BU] : Γ ⊩ᵛ⟨ ∞ ⟩ B ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U]) ([A] : Γ ⊩ᵛ⟨ ∞ ⟩ A ^ [ r , ι ⁰ ] / [Γ]) ([B] : Γ ⊩ᵛ⟨ ∞ ⟩ B ^ [ r , ι ⁰ ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ∞ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [Γ] / [A]) ([Id] : Γ ⊩ᵛ⟨ ∞ ⟩ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] / [Γ]) → ([e] : Γ ⊩ᵛ⟨ ∞ ⟩ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] / [Γ] / [Id] ) → Γ ⊩ᵛ⟨ ∞ ⟩ cast ⁰ A B e t ∷ B ^ [ r , ι ⁰ ] / [Γ] / [B] castᵗᵛ {A} {B} {t} {e} {Γ} [Γ] [U] [AU] [BU] [A] [B] [t] [Id] [e] ⊢Δ [σ] = cast∞ ⊢Δ (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([AU] ⊢Δ [σ])) (proj₁ ([BU] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([B] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([Id] ⊢Δ [σ])) (proj₁ ([e] ⊢Δ [σ])) , λ [σ′] [σ≡σ′] → castext∞' ⊢Δ (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([U] ⊢Δ [σ′])) (proj₁ ([AU] ⊢Δ [σ])) (proj₁ ([AU] ⊢Δ [σ′])) (proj₁ ([BU] ⊢Δ [σ])) (proj₁ ([BU] ⊢Δ [σ′])) (proj₂ ([AU] ⊢Δ [σ]) [σ′] [σ≡σ′]) (proj₂ ([BU] ⊢Δ [σ]) [σ′] [σ≡σ′]) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ′])) (proj₁ ([B] ⊢Δ [σ])) (proj₁ ([B] ⊢Δ [σ′])) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ′])) (proj₂ ([t] ⊢Δ [σ]) [σ′] [σ≡σ′]) (proj₁ ([Id] ⊢Δ [σ])) (proj₁ ([Id] ⊢Δ [σ′])) (proj₁ ([e] ⊢Δ [σ])) (proj₁ ([e] ⊢Δ [σ′])) cast-congᵗᵛ : ∀ {A A' B B' t t' e e' r Γ} ([Γ] : ⊩ᵛ Γ) → ([U] : Γ ⊩ᵛ⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ]) ([U'] : Γ ⊩ᵛ⟨ ∞ ⟩ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ]) ([AU] : Γ ⊩ᵛ⟨ ∞ ⟩ A ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U]) ([AU'] : Γ ⊩ᵛ⟨ ∞ ⟩ A' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U]) ([BU] : Γ ⊩ᵛ⟨ ∞ ⟩ B ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U']) ([BU'] : Γ ⊩ᵛ⟨ ∞ ⟩ B' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U']) ([UA≡UA'] : Γ ⊩ᵛ⟨ ∞ ⟩ A ≡ A' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U]) ([UB≡UB'] : Γ ⊩ᵛ⟨ ∞ ⟩ B ≡ B' ∷ Univ r ⁰ ^ [ ! , ι ¹ ] / [Γ] / [U']) ([A] : Γ ⊩ᵛ⟨ ∞ ⟩ A ^ [ r , ι ⁰ ] / [Γ]) ([A'] : Γ ⊩ᵛ⟨ ∞ ⟩ A' ^ [ r , ι ⁰ ] / [Γ]) ([B] : Γ ⊩ᵛ⟨ ∞ ⟩ B ^ [ r , ι ⁰ ] / [Γ]) ([B'] : Γ ⊩ᵛ⟨ ∞ ⟩ B' ^ [ r , ι ⁰ ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ∞ ⟩ t ∷ A ^ [ r , ι ⁰ ] / [Γ] / [A]) ([t'] : Γ ⊩ᵛ⟨ ∞ ⟩ t' ∷ A' ^ [ r , ι ⁰ ] / [Γ] / [A']) ([t≡t']ₜ : Γ ⊩ᵛ⟨ ∞ ⟩ t ≡ t' ∷ A ^ [ r , ι ⁰ ] / [Γ] / [A] ) ([Id] : Γ ⊩ᵛ⟨ ∞ ⟩ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] / [Γ]) ([e] : Γ ⊩ᵛ⟨ ∞ ⟩ e ∷ Id (Univ r ⁰) A B ^ [ % , ι ¹ ] / [Γ] / [Id] ) ([Id'] : Γ ⊩ᵛ⟨ ∞ ⟩ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ] / [Γ]) ([e'] : Γ ⊩ᵛ⟨ ∞ ⟩ e' ∷ Id (Univ r ⁰) A' B' ^ [ % , ι ¹ ] / [Γ] / [Id'] ) → Γ ⊩ᵛ⟨ ∞ ⟩ cast ⁰ A B e t ≡ cast ⁰ A' B' e' t' ∷ B ^ [ r , ι ⁰ ] / [Γ] / [B] cast-congᵗᵛ [Γ] [U] [U'] [AU] [AU'] [BU] [BU'] [UA≡UA'] [UB≡UB'] [A] [A'] [B] [B'] [t] [t'] [t≡t']ₜ [Id] [e] [Id'] [e'] ⊢Δ [σ] = castext∞ ⊢Δ (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([U'] ⊢Δ [σ])) (proj₁ ([AU] ⊢Δ [σ])) (proj₁ ([AU'] ⊢Δ [σ])) (proj₁ ([BU] ⊢Δ [σ])) (proj₁ ([BU'] ⊢Δ [σ])) ([UA≡UA'] ⊢Δ [σ]) ([UB≡UB'] ⊢Δ [σ]) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([A'] ⊢Δ [σ])) (proj₁ ([B] ⊢Δ [σ])) (proj₁ ([B'] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([t'] ⊢Δ [σ])) ([t≡t']ₜ ⊢Δ [σ]) (proj₁ ([Id] ⊢Δ [σ])) (proj₁ ([Id'] ⊢Δ [σ])) (proj₁ ([e] ⊢Δ [σ])) (proj₁ ([e'] ⊢Δ [σ]))
{ "alphanum_fraction": 0.3536947905, "avg_line_length": 72.684244373, "ext": "agda", "hexsha": "c07e03e8fe5d3c389a6f9bd9dbbfa291673626ac", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Cast.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Cast.agda", "max_line_length": 267, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Cast.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 66158, "size": 113024 }
module Issue277 where data D : Set where d : D abstract x : D x = d -- Normalise x using the Emacs mode, at the top-level. Result: d. The -- result should be x. Agda.Interaction.GhciTop.cmd_compute_toplevel -- receives the right arguments, so the problem does not lie in the -- Emacs Lisp code. y : D y = {!x!} -- Normalisation works correctly in the goal.
{ "alphanum_fraction": 0.6972972973, "avg_line_length": 19.4736842105, "ext": "agda", "hexsha": "17df2e091aacafeba275a4b3fc578b0ddaa8d284", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue277.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue277.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue277.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 107, "size": 370 }
{-# OPTIONS --without-K --safe #-} -- Mentioned in passing here: -- https://ncatlab.org/nlab/show/slice+2-category open import Categories.Bicategory using (Bicategory) module Categories.Bicategory.Construction.LaxSlice {o ℓ e t} (𝒞 : Bicategory o ℓ e t) where open import Data.Product using (_,_) open import Function using (_$_) open import Level using (_⊔_) open import Categories.Bicategory.Extras 𝒞 open Shorthands open import Categories.Category using () renaming (Category to 1Category) open import Categories.Functor using (Functor) open Functor using (F₀) open import Categories.Functor.Bifunctor using (Bifunctor) open import Categories.Functor.Construction.Constant using (const) import Categories.Morphism.Reasoning as MR open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; niHelper) record SliceObj (X : Obj) : Set (t ⊔ o) where constructor sliceobj field {Y} : Obj arr : Y ⇒₁ X module SliceHom (A : Obj) where record Slice⇒₁ (X Y : SliceObj A) : Set (o ⊔ ℓ) where constructor slicearr₁ private module X = SliceObj X module Y = SliceObj Y field {h} : X.Y ⇒₁ Y.Y Δ : X.arr ⇒₂ (Y.arr ∘₁ h) record Slice⇒₂ {X Y : SliceObj A} (J K : Slice⇒₁ X Y) : Set (ℓ ⊔ e) where constructor slicearr₂ private module Y = SliceObj Y module J = Slice⇒₁ J module K = Slice⇒₁ K field {ϕ} : J.h ⇒₂ K.h E : K.Δ ≈ (Y.arr ▷ ϕ ∘ᵥ J.Δ) _∘ᵥ/_ : ∀ {X Y : SliceObj A}{J K L : Slice⇒₁ X Y} → Slice⇒₂ K L → Slice⇒₂ J K → Slice⇒₂ J L _∘ᵥ/_ {X}{Y}{J}{K}{L} (slicearr₂ {ϕ = ϕ} E) (slicearr₂ {ϕ = ψ} F) = slicearr₂ {ϕ = ϕ ∘ᵥ ψ} $ begin L.Δ ≈⟨ E ⟩ (Y.arr ▷ ϕ ∘ᵥ K.Δ) ≈⟨ refl⟩∘⟨ F ⟩ Y.arr ▷ ϕ ∘ᵥ (Y.arr ▷ ψ ∘ᵥ J.Δ) ≈⟨ pullˡ ∘ᵥ-distr-▷ ⟩ Y.arr ▷ (ϕ ∘ᵥ ψ) ∘ᵥ J.Δ ∎ where module X = SliceObj X module Y = SliceObj Y module J = Slice⇒₁ J module K = Slice⇒₁ K module L = Slice⇒₁ L open 1Category (hom X.Y A) open HomReasoning open Equiv open MR (hom X.Y A) SliceHomCat : SliceObj A → SliceObj A → 1Category (o ⊔ ℓ) (ℓ ⊔ e) e SliceHomCat X Y = record { Obj = Slice⇒₁ X Y ; _⇒_ = Slice⇒₂ ; _≈_ = λ (slicearr₂ {ϕ} _) (slicearr₂ {ψ} _) → ϕ ≈ ψ ; id = slice-id _ ; _∘_ = _∘ᵥ/_ ; assoc = hom.assoc ; sym-assoc = hom.sym-assoc ; identityˡ = hom.identityˡ ; identityʳ = hom.identityʳ ; identity² = hom.identity² ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = hom.∘-resp-≈ } where open hom.Equiv module X = SliceObj X module Y = SliceObj Y slice-id : ∀ (J : Slice⇒₁ X Y) → Slice⇒₂ J J slice-id J = slicearr₂ $ begin J.Δ ≈˘⟨ identity₂ˡ ⟩ id₂ ∘ᵥ J.Δ ≈˘⟨ ▷id₂ ⟩∘⟨refl ⟩ (Y.arr ▷ id₂) ∘ J.Δ ∎ where module J = Slice⇒₁ J open 1Category (hom X.Y A) open HomReasoning _⊚₀/_ : ∀ {X Y Z : SliceObj A} → Slice⇒₁ Y Z → Slice⇒₁ X Y → Slice⇒₁ X Z _⊚₀/_ {X}{Y}{Z} J K = slicearr₁ ((α⇒ ∘ᵥ J.Δ ◁ K.h) ∘ᵥ K.Δ) where module K = Slice⇒₁ K module J = Slice⇒₁ J _⊚₁/_ : ∀ {X Y Z : SliceObj A} → {J J' : Slice⇒₁ Y Z} → {K K' : Slice⇒₁ X Y} → Slice⇒₂ J J' → Slice⇒₂ K K' → Slice⇒₂ (J ⊚₀/ K) (J' ⊚₀/ K') _⊚₁/_ {X}{Y}{Z}{J'}{J}{K'}{K} δ γ = slicearr₂ $ begin (α⇒ ∘ᵥ J.Δ ◁ K.h) ∘ᵥ K.Δ ≈⟨ (refl⟩∘⟨ γ.E) ⟩ (α⇒ ∘ᵥ J.Δ ◁ K.h) ∘ᵥ (Y.arr ▷ γ.ϕ ∘ᵥ K'.Δ) ≈⟨ ((refl⟩∘⟨ δ.E ⟩⊚⟨refl) ⟩∘⟨refl) ⟩ (α⇒ ∘ᵥ (Z.arr ▷ δ.ϕ ∘ᵥ J'.Δ) ◁ K.h) ∘ᵥ (Y.arr ▷ γ.ϕ ∘ᵥ K'.Δ) ≈˘⟨ (((refl⟩∘⟨ ∘ᵥ-distr-◁ ) ⟩∘⟨refl)) ⟩ (α⇒ ∘ᵥ ((Z.arr ▷ δ.ϕ) ◁ K.h ∘ᵥ J'.Δ ◁ K.h)) ∘ᵥ (Y.arr ▷ γ.ϕ ∘ᵥ K'.Δ) ≈⟨ pullʳ (center (sym ◁-▷-exchg)) ⟩ α⇒ ∘ᵥ (Z.arr ▷ δ.ϕ) ◁ K.h ∘ᵥ (Z.arr ⊚₀ J'.h ▷ γ.ϕ ∘ᵥ J'.Δ ◁ K'.h) ∘ᵥ K'.Δ ≈⟨ pushʳ ( pullˡ (pullˡ (sym ⊚.homomorphism)) ) ⟩ (α⇒ ∘ᵥ (Z.arr ▷ δ.ϕ ∘ᵥ id₂) ⊚₁ (id₂ ∘ᵥ γ.ϕ) ∘ᵥ J'.Δ ◁ K'.h) ∘ᵥ K'.Δ ≈⟨ ((refl⟩∘⟨ (identity₂ʳ ⟩⊚⟨ identity₂ˡ ⟩∘⟨refl)) ⟩∘⟨refl) ⟩ (α⇒ ∘ᵥ ((Z.arr ▷ δ.ϕ) ⊚₁ γ.ϕ) ∘ᵥ J'.Δ ◁ K'.h) ∘ᵥ K'.Δ ≈⟨ pushˡ (pullˡ (⊚-assoc.⇒.commute ((id₂ , δ.ϕ) , γ.ϕ))) ⟩ (Z.arr ▷ δ.ϕ ⊚₁ γ.ϕ ∘ᵥ α⇒) ∘ᵥ J'.Δ ◁ K'.h ∘ᵥ K'.Δ ≈⟨ pullʳ (sym assoc) ⟩ (Z.arr ▷ δ.ϕ ⊚₁ γ.ϕ) ∘ᵥ ((α⇒ ∘ᵥ J'.Δ ◁ K'.h) ∘ᵥ K'.Δ) ∎ where module X = SliceObj X module Y = SliceObj Y module Z = SliceObj Z module J = Slice⇒₁ J module J' = Slice⇒₁ J' module K = Slice⇒₁ K module K' = Slice⇒₁ K' module γ = Slice⇒₂ γ module δ = Slice⇒₂ δ open 1Category (hom X.Y A) open HomReasoning open MR (hom X.Y A) open Equiv id/ : ∀ {X : SliceObj A} → Slice⇒₁ X X id/ = slicearr₁ ρ⇐ _⊚/_ : ∀ {X Y Z : SliceObj A} → Bifunctor (SliceHomCat Y Z) (SliceHomCat X Y) (SliceHomCat X Z) _⊚/_ {X}{Y}{Z} = record { F₀ = λ (J , K) → J ⊚₀/ K ; F₁ = λ (δ , γ) → δ ⊚₁/ γ ; identity = ⊚.identity ; homomorphism = ⊚.homomorphism ; F-resp-≈ = ⊚.F-resp-≈ } where module X = SliceObj X module Y = SliceObj Y module Z = SliceObj Z α⇒/ : ∀ {W X Y Z}(J : Slice⇒₁ Y Z) (K : Slice⇒₁ X Y) (L : Slice⇒₁ W X) → Slice⇒₂ ((J ⊚₀/ K) ⊚₀/ L) (J ⊚₀/ (K ⊚₀/ L)) α⇒/ {W}{X}{Y}{Z} J K L = slicearr₂ $ begin (α⇒ ∘ᵥ J.Δ ◁ K.h ⊚₀ L.h) ∘ᵥ ((α⇒ ∘ᵥ K.Δ ◁ L.h) ∘ᵥ L.Δ ) ≈⟨ pullʳ (center⁻¹ (sym α⇒-◁-∘₁) refl) ⟩ α⇒ ∘ᵥ (α⇒ ∘ᵥ J.Δ ◁ K.h ◁ L.h) ∘ᵥ K.Δ ◁ L.h ∘ᵥ L.Δ ≈⟨ pullˡ (pullˡ (sym pentagon)) ⟩ ((Z.arr ▷ α⇒ ∘ᵥ α⇒ ∘ᵥ α⇒ ◁ L.h) ∘ᵥ J.Δ ◁ K.h ◁ L.h) ∘ᵥ (K.Δ ◁ L.h ∘ᵥ L.Δ) ≈⟨ pullˡ (pushˡ (pull-last ∘ᵥ-distr-◁ )) ⟩ (Z.arr ▷ α⇒ ∘ᵥ (α⇒ ∘ᵥ ((α⇒ ∘ᵥ J.Δ ◁ K.h) ◁ L.h)) ∘ᵥ K.Δ ◁ L.h) ∘ᵥ L.Δ ≈⟨ pushˡ (pushʳ (pullʳ ∘ᵥ-distr-◁)) ⟩ ((Z.arr ▷ α⇒ ∘ᵥ α⇒)) ∘ᵥ (((α⇒ ∘ᵥ J.Δ ◁ K.h) ∘ᵥ K.Δ) ◁ L.h) ∘ᵥ L.Δ ≈⟨ pullʳ (pushʳ refl) ⟩ Z.arr ▷ α⇒ ∘ᵥ ((α⇒ ∘ᵥ (((α⇒ ∘ᵥ J.Δ ◁ K.h)) ∘ᵥ K.Δ) ◁ L.h) ∘ᵥ L.Δ) ∎ where module W = SliceObj W module X = SliceObj X module Y = SliceObj Y module Z = SliceObj Z module J = Slice⇒₁ J module K = Slice⇒₁ K module L = Slice⇒₁ L open 1Category (hom W.Y A) open HomReasoning open MR (hom W.Y A) open hom.Equiv λ⇒/ : ∀ {X Y} (J : Slice⇒₁ X Y) → Slice⇒₂ (id/ ⊚₀/ J) J λ⇒/ {X}{Y} J = slicearr₂ $ begin J.Δ ≈⟨ introˡ id₂◁ ⟩ (id₂ ◁ J.h) ∘ᵥ J.Δ ≈˘⟨ (unitʳ.iso.isoʳ (Y.arr , _) ⟩⊚⟨refl ⟩∘⟨refl) ⟩ ((ρ⇒ ∘ᵥ ρ⇐) ◁ J.h) ∘ᵥ J.Δ ≈˘⟨ (∘ᵥ-distr-◁ ⟩∘⟨refl) ⟩ (ρ⇒ ◁ J.h ∘ᵥ ρ⇐ ◁ J.h) ∘ᵥ J.Δ ≈⟨ pushˡ (sym triangle ⟩∘⟨ refl) ⟩ (Y.arr ▷ λ⇒ ∘ᵥ α⇒) ∘ᵥ ρ⇐ ◁ J.h ∘ᵥ J.Δ ≈⟨ pullʳ (sym assoc) ⟩ Y.arr ▷ λ⇒ ∘ᵥ (α⇒ ∘ᵥ ρ⇐ ◁ J.h) ∘ᵥ J.Δ ∎ where module X = SliceObj X module Y = SliceObj Y module J = Slice⇒₁ J open 1Category (hom X.Y A) open HomReasoning open MR (hom X.Y A) open hom.Equiv ρ⇒/ : ∀{X}{Y} (J : Slice⇒₁ X Y) → Slice⇒₂ (J ⊚₀/ id/) J ρ⇒/ {X}{Y} J = slicearr₂ $ begin J.Δ ≈⟨ introʳ (unitʳ.iso.isoʳ _) ⟩ J.Δ ∘ᵥ ρ⇒ ∘ᵥ ρ⇐ ≈⟨ pullˡ (sym ρ⇒-∘ᵥ-◁) ⟩ (ρ⇒ ∘ᵥ J.Δ ◁ id₁) ∘ᵥ ρ⇐ ≈⟨ unitorʳ-coherence ⟩∘⟨refl ⟩∘⟨refl ⟩ ((Y.arr ▷ ρ⇒ ∘ᵥ α⇒) ∘ᵥ J.Δ ◁ id₁) ∘ᵥ ρ⇐ ≈⟨ pushˡ assoc ⟩ Y.arr ▷ ρ⇒ ∘ᵥ (α⇒ ∘ᵥ J.Δ ◁ id₁) ∘ᵥ ρ⇐ ∎ where module X = SliceObj X module Y = SliceObj Y module J = Slice⇒₁ J open 1Category (hom X.Y A) open HomReasoning open MR (hom X.Y A) open hom.Equiv slice-inv : ∀ {X}{Y}{J : Slice⇒₁ X Y}{K} (α : Slice⇒₂ J K) → (f : Slice⇒₁.h K ⇒₂ Slice⇒₁.h J) → (f ∘ᵥ (Slice⇒₂.ϕ α) ≈ id₂) → Slice⇒₂ K J slice-inv {X}{Y}{J}{K} α f p = slicearr₂ $ begin J.Δ ≈⟨ introˡ ▷id₂ ⟩ (Y.arr ▷ id₂) ∘ᵥ J.Δ ≈˘⟨ (refl⟩⊚⟨ p ⟩∘⟨refl) ⟩ (Y.arr ▷ (f ∘ᵥ α.ϕ)) ∘ᵥ J.Δ ≈˘⟨ (∘ᵥ-distr-▷ ⟩∘⟨refl) ⟩ (Y.arr ▷ f ∘ᵥ Y.arr ▷ α.ϕ) ∘ᵥ J.Δ ≈⟨ pullʳ (sym α.E) ⟩ Y.arr ▷ f ∘ᵥ K.Δ ∎ where module X = SliceObj X module Y = SliceObj Y module J = Slice⇒₁ J module K = Slice⇒₁ K module α = Slice⇒₂ α open 1Category (hom X.Y A) open HomReasoning open MR (hom X.Y A) open hom.Equiv LaxSlice : Obj → Bicategory (o ⊔ ℓ) (ℓ ⊔ e) e (o ⊔ t) LaxSlice A = record { enriched = record { Obj = SliceObj A ; hom = SliceHomCat ; id = const id/ ; ⊚ = _⊚/_ ; ⊚-assoc = niHelper (record { η = λ ((J , K) , L) → α⇒/ J K L ; η⁻¹ = λ ((J , K) , L) → slice-inv (α⇒/ J K L) α⇐ (⊚-assoc.iso.isoˡ _) ; commute = λ f → ⊚-assoc.⇒.commute _ ; iso = λ _ → record { isoˡ = ⊚-assoc.iso.isoˡ _ ; isoʳ = ⊚-assoc.iso.isoʳ _ } }) ; unitˡ = niHelper (record { η = λ (_ , J) → λ⇒/ J ; η⁻¹ = λ (_ , J) → slice-inv (λ⇒/ J) λ⇐ (unitˡ.iso.isoˡ _) ; commute = λ _ → λ⇒-∘ᵥ-▷ ; iso = λ _ → record { isoˡ = unitˡ.iso.isoˡ _ ; isoʳ = unitˡ.iso.isoʳ _ } }) ; unitʳ = niHelper (record { η = λ (J , _) → ρ⇒/ J ; η⁻¹ = λ (J , _) → slice-inv (ρ⇒/ J) ρ⇐ (unitʳ.iso.isoˡ _) ; commute = λ _ → ρ⇒-∘ᵥ-◁ ; iso = λ _ → record { isoˡ = unitʳ.iso.isoˡ _ ; isoʳ = unitʳ.iso.isoʳ _ } }) } ; triangle = triangle ; pentagon = pentagon } where open SliceHom A
{ "alphanum_fraction": 0.4632368043, "avg_line_length": 40.0740740741, "ext": "agda", "hexsha": "a18a90536af0171cc7e14e8cf0a574c1be7e24d8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_path": "src/Categories/Bicategory/Construction/LaxSlice.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "maxsnew/agda-categories", "max_issues_repo_path": "src/Categories/Bicategory/Construction/LaxSlice.agda", "max_line_length": 140, "max_stars_count": null, "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_path": "src/Categories/Bicategory/Construction/LaxSlice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4888, "size": 9738 }
module L.Base.Id.Core where -- Use the builtin _≡_ and refl open import Agda.Builtin.Equality public J : ∀{a c} {A : Set a} → (C : (x y : A) → x ≡ y → Set c) → ((x : A) → C x x refl) → (M N : A) → (P : M ≡ N ) → C M N P J C c M .M refl = c M
{ "alphanum_fraction": 0.4601449275, "avg_line_length": 19.7142857143, "ext": "agda", "hexsha": "c869f62d408216cc422dcfa6051c75082057c122", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "borszag/smallib", "max_forks_repo_path": "src/L/Base/Id/Core.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "borszag/smallib", "max_issues_repo_path": "src/L/Base/Id/Core.agda", "max_line_length": 56, "max_stars_count": null, "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "borszag/smallib", "max_stars_repo_path": "src/L/Base/Id/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 107, "size": 276 }
open import Prelude open import Nat module List where -- lets us omit a bunch of parens infixr 99 _::_ infixr 9 _++_ -- standard definition of polymorphic lists data List (A : Set) : Set where [] : List A _::_ : A → List A → List A {-# BUILTIN LIST List #-} -- shorthand notation for small lists [_] : {A : Set} → A → List A [ x ] = x :: [] -- list append _++_ : {A : Set} → List A → List A → List A [] ++ l2 = l2 x :: l1 ++ l2 = x :: (l1 ++ l2)
{ "alphanum_fraction": 0.5419222904, "avg_line_length": 20.375, "ext": "agda", "hexsha": "132c87b9e0a19e951487c657d4c0348f3b076d59", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "List.agda", "max_line_length": 45, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 171, "size": 489 }
module plfa.Relations where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open import Data.Nat using (ℕ ; zero; suc; _+_) open import Data.Nat.Properties using (+-comm) data _≤_ : ℕ → ℕ → Set where z≤n : ∀ { n : ℕ } --------- → zero ≤ n s≤s : ∀ { m n : ℕ } → m ≤ n --------------- → suc m ≤ suc n infix 4 _≤_ _ : 2 ≤ 4 _ = s≤s (s≤s z≤n) _ : 2 ≤ 4 _ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2})) _ : 2 ≤ 4 _ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} (z≤n {n = 2})) _ : 2 ≤ 4 _ = s≤s {n = 3} (s≤s {n = 2} z≤n) inv-s≤s : ∀ { m n : ℕ } → suc m ≤ suc n ------------- → m ≤ n inv-s≤s (s≤s m≤n) = m≤n inv-z≤n : ∀ { m : ℕ } → m ≤ zero -------- → m ≡ zero inv-z≤n z≤n = refl -- @practice: exercise `orderings` start -- _⊆_ relations has partial order property but not total order -- adjacency relation has preorder property but not partial order -- @practice: exercise `orderings` end -- 自反: reflexive - refl -- 传递: transitive - trans -- 反对称: anti-symmetric - antisym -- 完全: total - total ≤-refl : ∀ { n : ℕ } ----- → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s ≤-refl ≤-trans : ∀ { m n p : ℕ } → m ≤ n → n ≤ p ----- → m ≤ p ≤-trans z≤n _ = z≤n ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)
{ "alphanum_fraction": 0.4839939024, "avg_line_length": 18.2222222222, "ext": "agda", "hexsha": "b5968ad4c5f834a37712c538e5b5d9a410f59255", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-15T01:26:23.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-15T01:26:23.000Z", "max_forks_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lonelyhentai/workspace", "max_forks_repo_path": "fp/agda/plfa/Relations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lonelyhentai/workspace", "max_issues_repo_path": "fp/agda/plfa/Relations.agda", "max_line_length": 65, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2a996af58d6b9be5d608ed040267398bcf72403b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lonelyhentai/workspace", "max_stars_repo_path": "fp/agda/plfa/Relations.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-15T01:26:19.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-26T16:37:38.000Z", "num_tokens": 610, "size": 1312 }
{- 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 -} {-# OPTIONS --allow-unsolved-metas #-} open import LibraBFT.Prelude open import LibraBFT.Base.PKCS open import LibraBFT.Concrete.Obligations open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Impl.Consensus.Types open import LibraBFT.Impl.NetworkMsg open import LibraBFT.Impl.Util.Crypto open EpochConfig open import LibraBFT.Yasm.Yasm (ℓ+1 0ℓ) EpochConfig epochId authorsN ConcSysParms NodeId-PK-OK -- In this module, we will prove a structural property that any new signed message produced by an -- honest handler from a reachable state correctly identifies the sender, and is for a valid epoch -- of which that sender is a member. It is postulated for now, because the property does not yet -- hold for our fake implementation that does not actually comply. A proof outline and notes are -- included below, which we can finish once we do have a compliant implementation. module LibraBFT.Impl.Properties.Aux where -- This proof is complete except for pieces that are directly about the handlers. Our -- fake/simple handler does not yet obey the needed properties, so we can't finish this yet. impl-sps-avp : StepPeerState-AllValidParts -- In our fake/simple implementation, init and handling V and C msgs do not send any messages impl-sps-avp _ hpk (step-init ix) m∈outs part⊂m ver = ⊥-elim (¬Any[] m∈outs) impl-sps-avp _ hpk (step-msg {sndr , V vm} _ _) m∈outs _ _ = ⊥-elim (¬Any[] m∈outs) impl-sps-avp _ hpk (step-msg {sndr , C cm} _ _) m∈outs _ _ = ⊥-elim (¬Any[] m∈outs) -- These aren't true yet, because processProposalMsgM sends fake votes that don't follow the rules for ValidPartForPK impl-sps-avp preach hpk (step-msg {sndr , P pm} m∈pool ps≡) m∈outs v⊂m ver with m∈outs -- Handler sends at most one vote, so it can't be "there" ...| there {xs = xs} imp = ⊥-elim (¬Any[] imp) ...| here refl with v⊂m ...| vote∈qc vs∈qc rbld≈ qc∈m with qc∈m ...| xxx = {!x!} -- We will prove that votes represented in the SyncInfo of a -- proposal message were sent before, so these will be inj₂. -- This will be based on an invariant of the implementation, for -- example that the QCs included in the SyncInfo of a VoteMsg have -- been sent before. We will need to use hash injectivity and -- signature injectivity to ensure a different vote was not sent -- previously with the same signature. impl-sps-avp {pk = pk} {α = α} {st = st} preach hpk (step-msg {sndr , P pm} m∈pool ps≡) m∈outs v⊂m ver | here refl | vote∈vm {si} with MsgWithSig∈? {pk} {ver-signature ver} {msgPool st} ...| yes msg∈ = inj₂ msg∈ ...| no msg∉ = inj₁ ((mkValidSenderForPK {! epoch !} -- We will need an invariant that says the epoch -- used by a voter is "in range". (EC-lookup' (availEpochs st) {!!}) refl {! !} -- The implementation will need to check that the voter is a member of -- the epoch of the message it's sending. ) , msg∉)
{ "alphanum_fraction": 0.6045576408, "avg_line_length": 61.1475409836, "ext": "agda", "hexsha": "cb8de75c462e3281d28c3085d5633902ac4e8754", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "haroldcarr/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Impl/Properties/Aux.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "haroldcarr/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Impl/Properties/Aux.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "haroldcarr/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Impl/Properties/Aux.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 976, "size": 3730 }
{-# OPTIONS --cubical --safe --prop #-} module Relation.Binary.Equivalence.PropTruncated where open import Prelude open import Relation.Nullary.Stable infix 4 _≐_ data _≐_ {a} {A : Type a} (x y : A) : Prop a where ∣_∣ : x ≡ y → x ≐ y data ∙⊥ : Prop where private variable x y z : A rerel : ∙⊥ → ⊥ rerel () ∙refute : x ≐ y → (x ≡ y → ⊥) → ∙⊥ ∙refute ∣ x≡y ∣ x≢y with x≢y x≡y ∙refute ∣ x≡y ∣ x≢y | () refute : x ≐ y → ¬ (¬ (x ≡ y)) refute x≐y x≢y = rerel (∙refute x≐y x≢y) unsquash : Stable (x ≡ y) → x ≐ y → x ≡ y unsquash st x≐y = st (refute x≐y) ∙refl : x ≐ x ∙refl = ∣ refl ∣ ∙trans : x ≐ y → y ≐ z → x ≐ z ∙trans ∣ xy ∣ (∣_∣ yz) = ∣_∣ (xy ; yz) ∙sym : x ≐ y → y ≐ x ∙sym (∣_∣ p) = ∣_∣ (sym p) ∙cong : (f : A → B) → x ≐ y → f x ≐ f y ∙cong f ∣ x≡y ∣ = ∣ cong f x≡y ∣ module Reasoning where infixr 2 ≐˘⟨⟩-syntax ≐⟨∙⟩-syntax ≐˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≐ z → y ≐ x → x ≐ z ≐˘⟨⟩-syntax _ y≡z y≡x = ∙trans (∙sym y≡x) y≡z syntax ≐˘⟨⟩-syntax x y≡z y≡x = x ≐˘⟨ y≡x ⟩ y≡z ≐⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≐ z → x ≐ y → x ≐ z ≐⟨∙⟩-syntax _ y≡z x≡y = ∙trans x≡y y≡z syntax ≐⟨∙⟩-syntax x y≡z x≡y = x ≐⟨ x≡y ⟩ y≡z _≐⟨⟩_ : ∀ (x : A) {y} → x ≐ y → x ≐ y _ ≐⟨⟩ x≡y = x≡y infix 2.5 _∎ _∎ : ∀ {A : Type a} (x : A) → x ≐ x _∎ x = ∙refl infixr 2 ≡˘⟨⟩-syntax ≡⟨∙⟩-syntax ≡˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≐ z → y ≡ x → x ≐ z ≡˘⟨⟩-syntax _ y≡z y≡x = ∙trans (∣_∣ (sym y≡x)) y≡z syntax ≡˘⟨⟩-syntax x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z ≡⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≐ z → x ≡ y → x ≐ z ≡⟨∙⟩-syntax _ y≡z x≡y = ∙trans ∣ x≡y ∣ y≡z syntax ≡⟨∙⟩-syntax x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z
{ "alphanum_fraction": 0.4517516902, "avg_line_length": 21.6933333333, "ext": "agda", "hexsha": "7c5af67176f88afd8eb1909e2f79eb536e437592", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Relation/Binary/Equivalence/PropTruncated.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Relation/Binary/Equivalence/PropTruncated.agda", "max_line_length": 55, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Relation/Binary/Equivalence/PropTruncated.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 1015, "size": 1627 }
open import Mockingbird.Forest using (Forest) -- Mockingbirds, Warblers, and Starlings module Mockingbird.Problems.Chapter12 {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Product using (_×_; _,_; proj₁; ∃-syntax) open import Function using (_$_) open import Mockingbird.Forest.Birds forest import Mockingbird.Problems.Chapter11 forest as Chapter₁₁ open Forest forest problem₁ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ → HasDoubleMockingbird problem₁ = record { M₂ = B ∙ M ; isDoubleMockingbird = λ x y → begin B ∙ M ∙ x ∙ y ≈⟨ isBluebird M x y ⟩ M ∙ (x ∙ y) ≈⟨ isMockingbird (x ∙ y) ⟩ x ∙ y ∙ (x ∙ y) ∎ } problem₂-BCM : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → HasLark problem₂-BCM = record { L = C ∙ B ∙ M ; isLark = λ x y → begin C ∙ B ∙ M ∙ x ∙ y ≈⟨ congʳ $ isCardinal B M x ⟩ B ∙ x ∙ M ∙ y ≈⟨ isBluebird x M y ⟩ x ∙ (M ∙ y) ≈⟨ congˡ $ isMockingbird y ⟩ x ∙ (y ∙ y) ∎ } where instance hasCardinal = Chapter₁₁.problem₂₁′ problem₂-BRM : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → HasLark problem₂-BRM = record { L = R ∙ M ∙ B ; isLark = λ x y → begin R ∙ M ∙ B ∙ x ∙ y ≈⟨ congʳ $ isRobin M B x ⟩ B ∙ x ∙ M ∙ y ≈⟨ isBluebird x M y ⟩ x ∙ (M ∙ y) ≈⟨ congˡ $ isMockingbird y ⟩ x ∙ (y ∙ y) ∎ } where instance hasRobin = Chapter₁₁.problem₂₀ problem₃ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasWarbler ⦄ → HasLark problem₃ = record { L = B ∙ W ∙ B ; isLark = λ x y → begin B ∙ W ∙ B ∙ x ∙ y ≈⟨ congʳ $ isBluebird W B x ⟩ W ∙ (B ∙ x) ∙ y ≈⟨ isWarbler (B ∙ x) y ⟩ B ∙ x ∙ y ∙ y ≈⟨ isBluebird x y y ⟩ x ∙ (y ∙ y) ∎ } problem₄ : ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasQueerBird ⦄ → HasLark problem₄ = record { L = Q ∙ M ; isLark = λ x y → begin Q ∙ M ∙ x ∙ y ≈⟨ isQueerBird M x y ⟩ x ∙ (M ∙ y) ≈⟨ congˡ $ isMockingbird y ⟩ x ∙ (y ∙ y) ∎ } problem₅ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasRobin ⦄ ⦃ _ : HasMockingbird ⦄ → HasConverseWarbler problem₅ = record { W′ = M₂ ∙ R ; isConverseWarbler = λ x y → begin M₂ ∙ R ∙ x ∙ y ≈⟨ congʳ $ isDoubleMockingbird R x ⟩ R ∙ x ∙ (R ∙ x) ∙ y ≈⟨ isRobin x (R ∙ x) y ⟩ R ∙ x ∙ y ∙ x ≈⟨ isRobin x y x ⟩ y ∙ x ∙ x ∎ } where instance hasDoubleMockingbird = problem₁ problem₆′ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasConverseWarbler ⦄ → HasWarbler problem₆′ = record { W = C ∙ W′ ; isWarbler = λ x y → begin C ∙ W′ ∙ x ∙ y ≈⟨ isCardinal W′ x y ⟩ W′ ∙ y ∙ x ≈⟨ isConverseWarbler y x ⟩ x ∙ y ∙ y ∎ } problem₆ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasRobin ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasMockingbird ⦄ → HasWarbler problem₆ = record { W = C ∙ (B ∙ M ∙ R) ; isWarbler = λ x y → begin C ∙ (B ∙ M ∙ R) ∙ x ∙ y ≈⟨⟩ C ∙ (M₂ ∙ R) ∙ x ∙ y ≈⟨⟩ C ∙ W′ ∙ x ∙ y ≈⟨⟩ W ∙ x ∙ y ≈⟨ isWarbler x y ⟩ x ∙ y ∙ y ∎ } where instance hasDoubleMockingbird = problem₁ hasConverseWarbler = problem₅ hasWarbler = problem₆′ problem₇ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → HasWarbler problem₇ = record { W = B ∙ (T ∙ (B ∙ M ∙ (B ∙ B ∙ T))) ∙ (B ∙ B ∙ T) ; isWarbler = λ x y → begin B ∙ (T ∙ (B ∙ M ∙ (B ∙ B ∙ T))) ∙ (B ∙ B ∙ T) ∙ x ∙ y ≈˘⟨ congʳ $ congʳ $ isWarbler′ ⟩ W ∙ x ∙ y ≈⟨ isWarbler x y ⟩ x ∙ y ∙ y ∎ } where instance hasRobin = Chapter₁₁.problem₂₀ hasCardinal = Chapter₁₁.problem₂₁-bonus hasWarbler = problem₆ isWarbler′ : W ≈ B ∙ (T ∙ (B ∙ M ∙ (B ∙ B ∙ T))) ∙ (B ∙ B ∙ T) isWarbler′ = begin W ≈⟨⟩ C ∙ (B ∙ M ∙ R) ≈⟨⟩ C ∙ (B ∙ M ∙ (B ∙ B ∙ T)) ≈⟨⟩ B ∙ (T ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T) ∙ (B ∙ M ∙ (B ∙ B ∙ T)) ≈⟨ isBluebird (T ∙ (B ∙ B ∙ T)) (B ∙ B ∙ T) (B ∙ M ∙ (B ∙ B ∙ T)) ⟩ T ∙ (B ∙ B ∙ T) ∙ (B ∙ B ∙ T ∙ (B ∙ M ∙ (B ∙ B ∙ T))) ≈⟨ isThrush (B ∙ B ∙ T) (B ∙ B ∙ T ∙ (B ∙ M ∙ (B ∙ B ∙ T))) ⟩ B ∙ B ∙ T ∙ (B ∙ M ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T) ≈⟨ congʳ $ isBluebird B T (B ∙ M ∙ (B ∙ B ∙ T)) ⟩ B ∙ (T ∙ (B ∙ M ∙ (B ∙ B ∙ T))) ∙ (B ∙ B ∙ T) ∎ -- TODO: other expression in problem 7. -- NOTE: the bluebird B is not necessary. problem₈ : ⦃ _ : HasThrush ⦄ ⦃ _ : HasWarbler ⦄ → HasMockingbird problem₈ = record { M = W ∙ T ; isMockingbird = λ x → begin W ∙ T ∙ x ≈⟨ isWarbler T x ⟩ T ∙ x ∙ x ≈⟨ isThrush x x ⟩ x ∙ x ∎ } problem₉-W* : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → HasWarblerOnceRemoved problem₉-W* = record { W* = B ∙ W ; isWarblerOnceRemoved = λ x y z → begin B ∙ W ∙ x ∙ y ∙ z ≈⟨ congʳ $ isBluebird W x y ⟩ W ∙ (x ∙ y) ∙ z ≈⟨ isWarbler (x ∙ y) z ⟩ x ∙ y ∙ z ∙ z ∎ } where instance hasWarbler = problem₇ problem₉-W** : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → HasWarblerTwiceRemoved problem₉-W** = record { W** = B ∙ W* ; isWarblerTwiceRemoved = λ x y z w → begin B ∙ W* ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ isBluebird W* x y ⟩ W* ∙ (x ∙ y) ∙ z ∙ w ≈⟨ isWarblerOnceRemoved (x ∙ y) z w ⟩ x ∙ y ∙ z ∙ w ∙ w ∎ } where instance hasWarbler = problem₇ hasWarblerOnceRemoved = problem₉-W* problem₁₀ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasWarbler ⦄ → HasHummingbird problem₁₀ = record { H = B ∙ W ∙ (B ∙ C) ; isHummingbird = λ x y z → begin B ∙ W ∙ (B ∙ C) ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird W (B ∙ C) x ⟩ W ∙ (B ∙ C ∙ x) ∙ y ∙ z ≈⟨ congʳ $ isWarbler (B ∙ C ∙ x) y ⟩ B ∙ C ∙ x ∙ y ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird C x y ⟩ C ∙ (x ∙ y) ∙ y ∙ z ≈⟨ isCardinal (x ∙ y) y z ⟩ x ∙ y ∙ z ∙ y ∎ } problem₁₁ : ⦃ _ : HasRobin ⦄ ⦃ _ : HasHummingbird ⦄ → HasWarbler problem₁₁ = problem₆′ where instance hasCardinal = Chapter₁₁.problem₂₁ hasConverseWarbler : HasConverseWarbler hasConverseWarbler = record { W′ = H ∙ R ; isConverseWarbler = λ x y → begin H ∙ R ∙ x ∙ y ≈⟨ isHummingbird R x y ⟩ R ∙ x ∙ y ∙ x ≈⟨ isRobin x y x ⟩ y ∙ x ∙ x ∎ } problem₁₂ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → HasStarling problem₁₂ = record { S = W** ∙ G ; isStarling = λ x y z → begin W** ∙ G ∙ x ∙ y ∙ z ≈⟨ isWarblerTwiceRemoved G x y z ⟩ G ∙ x ∙ y ∙ z ∙ z ≈⟨ isGoldfinch x y z z ⟩ x ∙ z ∙ (y ∙ z) ∎ } where instance hasWarblerTwiceRemoved = problem₉-W** hasGoldfinch = Chapter₁₁.problem₄₇ problem₁₃ : ⦃ _ : HasStarling ⦄ ⦃ _ : HasRobin ⦄ → HasHummingbird problem₁₃ = record { H = S ∙ R ; isHummingbird = λ x y z → begin S ∙ R ∙ x ∙ y ∙ z ≈⟨ congʳ $ isStarling R x y ⟩ R ∙ y ∙ (x ∙ y) ∙ z ≈⟨ isRobin y (x ∙ y) z ⟩ x ∙ y ∙ z ∙ y ∎ } problem₁₄-SR : ⦃ _ : HasStarling ⦄ ⦃ _ : HasRobin ⦄ → HasWarbler problem₁₄-SR = record { W = R ∙ (S ∙ R ∙ R) ∙ R ; isWarbler = λ x y → begin R ∙ (S ∙ R ∙ R) ∙ R ∙ x ∙ y ≈˘⟨ congʳ $ congʳ $ isRobin R R (S ∙ R ∙ R) ⟩ R ∙ R ∙ R ∙ (S ∙ R ∙ R) ∙ x ∙ y ≈⟨⟩ C ∙ (S ∙ R ∙ R) ∙ x ∙ y ≈⟨⟩ C ∙ (H ∙ R) ∙ x ∙ y ≈⟨⟩ W ∙ x ∙ y ≈⟨ isWarbler x y ⟩ x ∙ y ∙ y ∎ } where instance hasCardinal = Chapter₁₁.problem₂₁ hasHummingbird = problem₁₃ hasWarbler = problem₁₁ problem₁₄-SC : ⦃ _ : HasStarling ⦄ ⦃ _ : HasCardinal ⦄ → HasWarbler problem₁₄-SC = record { W = C ∙ (S ∙ (C ∙ C) ∙ (C ∙ C)) ; isWarbler = λ x y → begin C ∙ (S ∙ (C ∙ C) ∙ (C ∙ C)) ∙ x ∙ y ≈⟨⟩ C ∙ (S ∙ R ∙ R) ∙ x ∙ y ≈⟨ isCardinal (S ∙ R ∙ R) x y ⟩ S ∙ R ∙ R ∙ y ∙ x ≈⟨ congʳ $ isStarling R R y ⟩ R ∙ y ∙ (R ∙ y) ∙ x ≈⟨ isRobin y (R ∙ y) x ⟩ R ∙ y ∙ x ∙ y ≈⟨ isRobin y x y ⟩ x ∙ y ∙ y ∎ } where instance hasRobin = Chapter₁₁.problem₂₃ problem₁₅ : ⦃ _ : HasThrush ⦄ ⦃ _ : HasStarling ⦄ → HasWarbler problem₁₅ = record { W = S ∙ T ; isWarbler = λ x y → begin S ∙ T ∙ x ∙ y ≈⟨ isStarling T x y ⟩ T ∙ y ∙ (x ∙ y) ≈⟨ isThrush y (x ∙ y) ⟩ x ∙ y ∙ y ∎ } problem₁₆ : ⦃ _ : HasThrush ⦄ ⦃ _ : HasStarling ⦄ → HasMockingbird problem₁₆ = record { M = S ∙ T ∙ T ; isMockingbird = λ x → begin S ∙ T ∙ T ∙ x ≈⟨ isStarling T T x ⟩ T ∙ x ∙ (T ∙ x) ≈⟨ isThrush x (T ∙ x) ⟩ T ∙ x ∙ x ≈⟨ isThrush x x ⟩ x ∙ x ∎ } module Exercises where exercise₁-a : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → ∃[ G₁ ] (∀ x y z w v → G₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ y ∙ v ∙ (z ∙ w)) exercise₁-a = ( D₁ ∙ C* , λ x y z w v → begin D₁ ∙ C* ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ isDickcissel C* x y z w ⟩ C* ∙ x ∙ y ∙ (z ∙ w) ∙ v ≈⟨ isCardinalOnceRemoved x y (z ∙ w) v ⟩ x ∙ y ∙ v ∙ (z ∙ w) ∎ ) where instance hasCardinal = Chapter₁₁.problem₂₁′ hasCardinalOnceRemoved = Chapter₁₁.problem₃₁ hasDickcissel = Chapter₁₁.problem₉ -- Note: in the solutions, the bluebird is used, but the exercise does not -- state that the bluebird may be used. exercise₁-b : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ → ∃[ G₁ ] (∀ x y z w v → G₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ y ∙ v ∙ (z ∙ w)) → ∃[ G₂ ] (∀ x y z w → G₂ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ (x ∙ w) ∙ (y ∙ z)) exercise₁-b (G₁ , isG₁) = ( G₁ ∙ (B ∙ M) , λ x y z w → begin G₁ ∙ (B ∙ M) ∙ x ∙ y ∙ z ∙ w ≈⟨ isG₁ (B ∙ M) x y z w ⟩ B ∙ M ∙ x ∙ w ∙ (y ∙ z) ≈⟨ congʳ $ isBluebird M x w ⟩ M ∙ (x ∙ w) ∙ (y ∙ z) ≈⟨ congʳ $ isMockingbird (x ∙ w) ⟩ x ∙ w ∙ (x ∙ w) ∙ (y ∙ z) ∎ ) exercise₁-c : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasIdentity ⦄ → ∃[ I₂ ] (∀ x → I₂ ∙ x ≈ x ∙ I ∙ I) exercise₁-c = ( B ∙ (T ∙ I) ∙ (T ∙ I) , λ x → begin B ∙ (T ∙ I) ∙ (T ∙ I) ∙ x ≈⟨ isBluebird (T ∙ I) (T ∙ I) x ⟩ T ∙ I ∙ (T ∙ I ∙ x) ≈⟨ isThrush I (T ∙ I ∙ x) ⟩ T ∙ I ∙ x ∙ I ≈⟨ congʳ $ isThrush I x ⟩ x ∙ I ∙ I ∎ ) exercise₁-d : ⦃ _ : HasIdentity ⦄ ⦃ _ : HasFinch ⦄ → (hasI₂ : ∃[ I₂ ] (∀ x → I₂ ∙ x ≈ x ∙ I ∙ I)) → ∀ x → proj₁ hasI₂ ∙ (F ∙ x) ≈ x exercise₁-d (I₂ , isI₂) x = begin I₂ ∙ (F ∙ x) ≈⟨ isI₂ (F ∙ x) ⟩ F ∙ x ∙ I ∙ I ≈⟨ isFinch x I I ⟩ I ∙ I ∙ x ≈⟨ congʳ $ isIdentity I ⟩ I ∙ x ≈⟨ isIdentity x ⟩ x ∎ exercise₁-e : ⦃ _ : HasFinch ⦄ ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasIdentity ⦄ → (hasG₂ : ∃[ G₂ ] (∀ x y z w → G₂ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ (x ∙ w) ∙ (y ∙ z))) → (hasI₂ : ∃[ I₂ ] (∀ x → I₂ ∙ x ≈ x ∙ I ∙ I)) → IsWarbler (proj₁ hasG₂ ∙ F ∙ (Q ∙ proj₁ hasI₂)) exercise₁-e (G₂ , isG₂) (I₂ , isI₂) x y = begin G₂ ∙ F ∙ (Q ∙ I₂) ∙ x ∙ y ≈⟨ isG₂ F (Q ∙ I₂) x y ⟩ F ∙ y ∙ (F ∙ y) ∙ (Q ∙ I₂ ∙ x) ≈⟨ isFinch y (F ∙ y) (Q ∙ I₂ ∙ x) ⟩ Q ∙ I₂ ∙ x ∙ (F ∙ y) ∙ y ≈⟨ congʳ $ isQueerBird I₂ x (F ∙ y) ⟩ x ∙ (I₂ ∙ (F ∙ y)) ∙ y ≈⟨ congʳ $ congˡ $ exercise₁-d (I₂ , isI₂) y ⟩ x ∙ y ∙ y ∎ exercise₂ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasWarbler ⦄ → IsStarling (B ∙ (B ∙ (B ∙ W) ∙ C) ∙ (B ∙ B)) exercise₂ x y z = begin B ∙ (B ∙ (B ∙ W) ∙ C) ∙ (B ∙ B) ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird (B ∙ (B ∙ W) ∙ C) (B ∙ B) x ⟩ B ∙ (B ∙ W) ∙ C ∙ (B ∙ B ∙ x) ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird (B ∙ W) C (B ∙ B ∙ x) ⟩ B ∙ W ∙ (C ∙ (B ∙ B ∙ x)) ∙ y ∙ z ≈⟨ congʳ $ isBluebird W (C ∙ (B ∙ B ∙ x)) y ⟩ W ∙ (C ∙ (B ∙ B ∙ x) ∙ y) ∙ z ≈⟨ isWarbler (C ∙ (B ∙ B ∙ x) ∙ y) z ⟩ C ∙ (B ∙ B ∙ x) ∙ y ∙ z ∙ z ≈⟨ congʳ $ isCardinal (B ∙ B ∙ x) y z ⟩ B ∙ B ∙ x ∙ z ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird B x z ⟩ B ∙ (x ∙ z) ∙ y ∙ z ≈⟨ isBluebird (x ∙ z) y z ⟩ x ∙ z ∙ (y ∙ z) ∎ exercise₃ : ⦃ _ : HasStarling ⦄ ⦃ _ : HasBluebird ⦄ → HasPhoenix exercise₃ = record { Φ = B ∙ (B ∙ S) ∙ B ; isPhoenix = λ x y z w → begin B ∙ (B ∙ S) ∙ B ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird (B ∙ S) B x ⟩ B ∙ S ∙ (B ∙ x) ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ isBluebird S (B ∙ x) y ⟩ S ∙ (B ∙ x ∙ y) ∙ z ∙ w ≈⟨ isStarling (B ∙ x ∙ y) z w ⟩ B ∙ x ∙ y ∙ w ∙ (z ∙ w) ≈⟨ congʳ $ isBluebird x y w ⟩ x ∙ (y ∙ w) ∙ (z ∙ w) ∎ } exercise₄ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasWarbler ⦄ → HasPsiBird exercise₄ = record { Ψ = H* ∙ D₂ ; isPsiBird = λ x y z w → begin H* ∙ D₂ ∙ x ∙ y ∙ z ∙ w ≈⟨⟩ B ∙ H ∙ D₂ ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird H D₂ x ⟩ H ∙ (D₂ ∙ x) ∙ y ∙ z ∙ w ≈⟨ congʳ $ isHummingbird (D₂ ∙ x) y z ⟩ D₂ ∙ x ∙ y ∙ z ∙ y ∙ w ≈⟨ isDovekie x y z y w ⟩ x ∙ (y ∙ z) ∙ (y ∙ w) ∎ } where instance hasHummingbird = problem₁₀ hasDovekie = Chapter₁₁.problem₁₁ H* = B ∙ H -- NOTE: my copy of the book contains a mistake (looking at the given -- solutions): it says Γxyzwv = y(zw)(xywv) instead of Γxyzwv = y(zw)(xyzwv). exercise₅-a : ⦃ _ : HasPhoenix ⦄ ⦃ _ : HasBluebird ⦄ → ∃[ Γ ] (∀ x y z w v → Γ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ y ∙ (z ∙ w) ∙ (x ∙ y ∙ z ∙ w ∙ v)) exercise₅-a = ( Φ ∙ (Φ ∙ (Φ ∙ B)) ∙ B , λ x y z w v → begin Φ ∙ (Φ ∙ (Φ ∙ B)) ∙ B ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ congʳ $ isPhoenix (Φ ∙ (Φ ∙ B)) B x y ⟩ Φ ∙ (Φ ∙ B) ∙ (B ∙ y) ∙ (x ∙ y) ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ isPhoenix (Φ ∙ B) (B ∙ y) (x ∙ y) z ⟩ Φ ∙ B ∙ (B ∙ y ∙ z) ∙ (x ∙ y ∙ z) ∙ w ∙ v ≈⟨ congʳ $ isPhoenix B (B ∙ y ∙ z) (x ∙ y ∙ z) w ⟩ B ∙ (B ∙ y ∙ z ∙ w) ∙ (x ∙ y ∙ z ∙ w) ∙ v ≈⟨ isBluebird (B ∙ y ∙ z ∙ w) (x ∙ y ∙ z ∙ w) v ⟩ B ∙ y ∙ z ∙ w ∙ (x ∙ y ∙ z ∙ w ∙ v) ≈⟨ congʳ $ isBluebird y z w ⟩ y ∙ (z ∙ w) ∙ (x ∙ y ∙ z ∙ w ∙ v) ∎ ) exercise₅-b : ⦃ _ : HasKestrel ⦄ → ∃[ Γ ] (∀ x y z w v → Γ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ y ∙ (z ∙ w) ∙ (x ∙ y ∙ z ∙ w ∙ v)) → HasPsiBird exercise₅-b (Γ , isΓ) = record { Ψ = Γ ∙ (K ∙ K) ; isPsiBird = λ x y z w → begin Γ ∙ (K ∙ K) ∙ x ∙ y ∙ z ∙ w ≈⟨ isΓ (K ∙ K) x y z w ⟩ x ∙ (y ∙ z) ∙ (K ∙ K ∙ x ∙ y ∙ z ∙ w) ≈⟨ congˡ $ congʳ $ congʳ $ congʳ $ isKestrel K x ⟩ x ∙ (y ∙ z) ∙ (K ∙ y ∙ z ∙ w) ≈⟨ congˡ $ congʳ $ isKestrel y z ⟩ x ∙ (y ∙ z) ∙ (y ∙ w) ∎ } exercise₅ : ⦃ _ : HasPhoenix ⦄ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasKestrel ⦄ → HasPsiBird exercise₅ = exercise₅-b exercise₅-a exercise₆-a : ⦃ _ : HasStarling ⦄ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → ∃[ S′ ] (∀ x y z → S′ ∙ x ∙ y ∙ z ≈ y ∙ z ∙ (x ∙ z)) exercise₆-a = ( C ∙ S , λ x y z → begin C ∙ S ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal S x y ⟩ S ∙ y ∙ x ∙ z ≈⟨ isStarling y x z ⟩ y ∙ z ∙ (x ∙ z) ∎ ) where instance hasCardinal = Chapter₁₁.problem₂₁′ exercise₆-b : ⦃ _ : HasIdentity ⦄ → ∃[ S′ ] (∀ x y z → S′ ∙ x ∙ y ∙ z ≈ y ∙ z ∙ (x ∙ z)) → HasWarbler exercise₆-b (S′ , isS′) = record { W = S′ ∙ I ; isWarbler = λ x y → begin S′ ∙ I ∙ x ∙ y ≈⟨ isS′ I x y ⟩ x ∙ y ∙ (I ∙ y) ≈⟨ congˡ $ isIdentity y ⟩ x ∙ y ∙ y ∎ } exercise₇ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasWarbler ⦄ → ∃[ Q̂ ] IsStarling (C ∙ Q̂ ∙ W) exercise₇ = let Q̂ = Q ∙ (Q ∙ Q ∙ (Q ∙ Q)) ∙ Q in ( Q̂ , λ x y z → begin C ∙ Q̂ ∙ W ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isCardinal Q̂ W x ⟩ Q̂ ∙ x ∙ W ∙ y ∙ z ≈⟨⟩ Q ∙ (Q ∙ Q ∙ (Q ∙ Q)) ∙ Q ∙ x ∙ W ∙ y ∙ z ≈⟨ congʳ $ congʳ $ congʳ $ isQueerBird (Q ∙ Q ∙ (Q ∙ Q)) Q x ⟩ Q ∙ (Q ∙ Q ∙ (Q ∙ Q) ∙ x) ∙ W ∙ y ∙ z ≈⟨ congʳ $ isQueerBird (Q ∙ Q ∙ (Q ∙ Q) ∙ x) W y ⟩ W ∙ (Q ∙ Q ∙ (Q ∙ Q) ∙ x ∙ y) ∙ z ≈⟨ isWarbler (Q ∙ Q ∙ (Q ∙ Q) ∙ x ∙ y) z ⟩ Q ∙ Q ∙ (Q ∙ Q) ∙ x ∙ y ∙ z ∙ z ≈⟨ congʳ $ congʳ $ congʳ $ isQueerBird Q (Q ∙ Q) x ⟩ Q ∙ Q ∙ (Q ∙ x) ∙ y ∙ z ∙ z ≈⟨ congʳ $ congʳ $ isQueerBird Q (Q ∙ x) y ⟩ Q ∙ x ∙ (Q ∙ y) ∙ z ∙ z ≈⟨ congʳ $ isQueerBird x (Q ∙ y) z ⟩ Q ∙ y ∙ (x ∙ z) ∙ z ≈⟨ isQueerBird y (x ∙ z) z ⟩ x ∙ z ∙ (y ∙ z) ∎ )
{ "alphanum_fraction": 0.4241068766, "avg_line_length": 40.5, "ext": "agda", "hexsha": "3841c6848ceee83f70c07201ef3c09d7675f00a6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Problems/Chapter12.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Problems/Chapter12.agda", "max_line_length": 132, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Problems/Chapter12.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 8460, "size": 16767 }
module Syntax where open import Data.List using (List; []; _∷_; _++_; lookup; length) open import Data.Product using (Σ; Σ-syntax; proj₁; proj₂) open import Data.Unit renaming (⊤ to top) open import Data.Empty renaming (⊥ to bot) open import Level using (suc; _⊔_) module PType {ℓ} (Gr : Set ℓ) where infixr 10 _*_ infixr 9 _=>_ data Type : Set ℓ where ⌊_⌋ : Gr -> Type Unit : Type _*_ : Type -> Type -> Type _=>_ : Type -> Type -> Type record Sorting : Set ℓ where field dom : Type cod : Type Context : Set ℓ Context = List Type record Signature ℓ₁ ℓ₂ : Set (suc (ℓ₁ ⊔ ℓ₂)) where field Gr : Set ℓ₁ Func : Set ℓ₂ open PType Gr public field sorting : Func -> Sorting dom : Func -> Type dom f = Sorting.dom (sorting f) cod : Func -> Type cod f = Sorting.cod (sorting f) module Term {ℓ₁ ℓ₂} (Sg : Signature ℓ₁ ℓ₂) where open Signature Sg infix 3 _⊨_ infix 8 _∙_ infix 3 _⊢_ infixl 4 _[_] data _⊨_ : Context -> Context -> Set (ℓ₁ ⊔ ℓ₂) data _⊢_ : Context -> Type -> Set (ℓ₁ ⊔ ℓ₂) data _⊨_ where id : forall {Γ} -> Γ ⊨ Γ -- identity morphism _∙_ : forall {Γ Γ′ Γ′′} -> Γ′ ⊨ Γ′′ -> Γ ⊨ Γ′ -> Γ ⊨ Γ′′ -- composition of morphisms weaken : forall {Γ A} -> A ∷ Γ ⊨ Γ -- the first projection ext : forall {Γ Γ′ A} -> Γ ⊨ Γ′ -> Γ ⊢ A -> Γ ⊨ A ∷ Γ′ -- the unique morphism into the product ! : forall {Γ} -> Γ ⊨ [] -- the unique morphism into the terminal object data _⊢_ where func : forall {Γ} (f : Func) -> Γ ⊢ dom f -> Γ ⊢ cod f var : forall {Γ A} -> A ∷ Γ ⊢ A unit : forall {Γ} -> Γ ⊢ Unit pair : forall {Γ A B} -> Γ ⊢ A -> Γ ⊢ B -> Γ ⊢ A * B fst : forall {Γ A B} -> Γ ⊢ A * B -> Γ ⊢ A snd : forall {Γ A B} -> Γ ⊢ A * B -> Γ ⊢ B abs : forall {Γ A B} -> A ∷ Γ ⊢ B -> Γ ⊢ A => B app : forall {Γ A B} -> Γ ⊢ A => B -> Γ ⊢ A -> Γ ⊢ B _[_] : forall {Γ Γ′ A} -> Γ′ ⊢ A -> Γ ⊨ Γ′ -> Γ ⊢ A infix 10 _×id′ _×id′ : forall {Γ Γ′} {A} -> Γ ⊨ Γ′ -> A ∷ Γ ⊨ A ∷ Γ′ γ ×id′ = ext (γ ∙ weaken) var
{ "alphanum_fraction": 0.5285784074, "avg_line_length": 24.6626506024, "ext": "agda", "hexsha": "f710728d2edc5af922b30b0bf38865e09d769185", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "elpinal/exsub-ccc", "max_forks_repo_path": "Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "elpinal/exsub-ccc", "max_issues_repo_path": "Syntax.agda", "max_line_length": 98, "max_stars_count": 3, "max_stars_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "elpinal/exsub-ccc", "max_stars_repo_path": "Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T13:30:48.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-05T06:16:32.000Z", "num_tokens": 842, "size": 2047 }
-- Andreas, 2019-02-25, issue #3588 -- C-c C-r (refine) produces unqualified constructor, but only -- a qualified constructor is accepted in this place. -- {-# OPTIONS -v interaction.intro:100 #-} -- {-# OPTIONS -v scope.inverse:100 #-} -- {-# OPTIONS -v toConcrete:50 #-} module Issue3588 where module M (_ : Set₁) where data D : Set where c : D data P : D → Set where c : P c open M Set using (D; P) open M.D test : P c test = {!!} -- C-c C-r -- "c" suggested by refine, but rejected by reload or give -- correct: P.c
{ "alphanum_fraction": 0.6220183486, "avg_line_length": 20.1851851852, "ext": "agda", "hexsha": "edddb5fcb3e5faf3769a90638092398297ba6707", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue3588.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue3588.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue3588.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 170, "size": 545 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LogicalFramework.NonIntuitionistic where infix 6 ¬_ infixr 5 _∧_ infixr 4 _∨_ postulate ⊥ : Set ⊥-elim : {A : Set} → ⊥ → A -- Disjunction. postulate _∨_ : Set → Set → Set inj₁ : {A B : Set} → A → A ∨ B inj₂ : {A B : Set} → B → A ∨ B case : {A B C : Set} → (A → C) → (B → C) → A ∨ B → C -- Conjunction. postulate _∧_ : Set → Set → Set _,_ : {A B : Set} → A → B → A ∧ B ∧-proj₁ : {A B : Set} → A ∧ B → A ∧-proj₂ : {A B : Set} → A ∧ B → B -- Negation. -- The underscore allows to write for example '¬ ¬ A' instead of '¬ (¬ A)'. ¬_ : Set → Set ¬ A = A → ⊥ module pem→¬-elim where -- The principle of the excluded middle. postulate pem : ∀ {A} → A ∨ ¬ A -- The principle of indirect proof (proof by contradiction). ¬-elim : ∀ {A} → (¬ A → ⊥) → A ¬-elim h = case (λ a → a) (λ ¬a → ⊥-elim (h ¬a)) pem module ¬-elim→pem where -- The principle of indirect proof (proof by contradiction). postulate ¬-elim : ∀ {A} → (¬ A → ⊥) → A helper₁ : {A : Set} → ¬ (A ∨ ¬ A) → ¬ A ∧ ¬ ¬ A helper₁ h = (λ a → h (inj₁ a)) , (λ ¬a → h (inj₂ ¬a)) helper₂ : {A : Set} → ¬ A ∧ ¬ ¬ A → ⊥ helper₂ h = ∧-proj₂ h (∧-proj₁ h) helper₃ : {A : Set} → ¬ (A ∨ ¬ A) → ⊥ helper₃ h = helper₂ (helper₁ h) -- The principle of the excluded middle. pem : ∀ {A} → A ∨ ¬ A pem = ¬-elim helper₃
{ "alphanum_fraction": 0.4990085922, "avg_line_length": 24.8032786885, "ext": "agda", "hexsha": "6a29c2c358d9dd3bddc7235139ae918feee6f591", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/thesis/report/LogicalFramework/NonIntuitionistic.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/thesis/report/LogicalFramework/NonIntuitionistic.agda", "max_line_length": 75, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/thesis/report/LogicalFramework/NonIntuitionistic.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 600, "size": 1513 }
-- Generalized variables in datatype (and record) parameters module _ where open import Agda.Primitive open import Agda.Builtin.Nat module NotParameterised where variable ℓ : Level A : Set ℓ x y : A m n : Nat data Vec (A : Set ℓ) : Nat → Set ℓ where [] : Vec A zero _∷_ : A → Vec A n → Vec A (suc n) variable xs : Vec A n -- n should be generalized as an index here data All (P : A → Set ℓ) : Vec A n → Set ℓ where [] : All P [] _∷_ : P x → All P xs → All P (x ∷ xs) infix 2 _∈_ -- need an occurrence of ℓ in the params to not generalize it as an index, -- so we bind A explicitly data _∈_ {A : Set ℓ} (x : A) : Vec A n → Set ℓ where zero : x ∈ x ∷ xs suc : x ∈ xs → x ∈ y ∷ xs lookup : {P : A → Set ℓ} → All P xs → x ∈ xs → P x lookup (x ∷ _) zero = x lookup (_ ∷ xs) (suc i) = lookup xs i -- Check that we can do the same in a parameterised module module Parameterised (Dummy : Set) where variable ℓ : Level A : Set ℓ x y : A m n : Nat data Vec (A : Set ℓ) : Nat → Set ℓ where [] : Vec A zero _∷_ : A → Vec A n → Vec A (suc n) variable xs : Vec A n -- n should be generalized as an index here data All (P : A → Set ℓ) : Vec A n → Set ℓ where [] : All P [] _∷_ : P x → All P xs → All P (x ∷ xs) infix 2 _∈_ -- need an occurrence of ℓ in the params to not generalize it as an index, -- so we bind A explicitly data _∈_ {A : Set ℓ} (x : A) : Vec A n → Set ℓ where zero : x ∈ x ∷ xs suc : x ∈ xs → x ∈ y ∷ xs lookup : {P : A → Set ℓ} → All P xs → x ∈ xs → P x lookup (x ∷ _) zero = x lookup (_ ∷ xs) (suc i) = lookup xs i
{ "alphanum_fraction": 0.5489033788, "avg_line_length": 23.7605633803, "ext": "agda", "hexsha": "dcbe4853d786413d9d8249b745de852e217a1e57", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue3296.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue3296.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3296.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 637, "size": 1687 }
-- {-# OPTIONS -v interaction.give:20 #-} -- Reported by stevan.andjelkovic, Yesterday (17 hours ago) -- Trying to give the expression in the goal gives the following error: -- tt != tt p a of type Prop -- when checking that the expression (λ x y → ?) has type -- ({o : ⊤} (p : ⊤) → ⊥ → ⊤) record _▷_ (I O : Set) : Set₁ where constructor _◃_/_ field Parameter : (o : O) → Set Arity : ∀ {o} (p : Parameter o) → Set input : ∀ {o} (p : Parameter o) (a : Arity p) → I open _▷_ public data ⊥ : Set where record ⊤ : Set where constructor tt --data ⊤ : Set where -- tt : ⊤ Abort : ⊤ ▷ ⊤ Abort = (λ _ → ⊤) ◃ (λ _ → ⊥) / {!!λ x y → {!!}!}
{ "alphanum_fraction": 0.5414201183, "avg_line_length": 21.8064516129, "ext": "agda", "hexsha": "2923552eb8b680b1f789ad49c3368c6fece33a1a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue1360.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue1360.agda", "max_line_length": 71, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1360.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 249, "size": 676 }
{-# OPTIONS --universe-polymorphism #-} open import Level open import Categories.Category open import Categories.Product module Categories.Product.Projections {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) where open import Categories.Functor open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap) ∏₁ : Functor (Product C D) C ∏₁ = record { F₀ = proj₁ ; F₁ = proj₁ ; identity = refl ; homomorphism = refl ; F-resp-≡ = proj₁ } where open Category.Equiv C ∏₂ : Functor (Product C D) D ∏₂ = record { F₀ = proj₂ ; F₁ = proj₂ ; identity = refl ; homomorphism = refl ; F-resp-≡ = proj₂ } where open Category.Equiv D
{ "alphanum_fraction": 0.5526641884, "avg_line_length": 22.4166666667, "ext": "agda", "hexsha": "39e679ffb1b06aa589bb716e887bee6ab30aec6c", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Product/Projections.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Product/Projections.agda", "max_line_length": 81, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Product/Projections.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 257, "size": 807 }
{-# OPTIONS --safe #-} module Cubical.Categories.Instances.Sets where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Data.Unit open import Cubical.Data.Sigma using (ΣPathP) open import Cubical.Categories.Category open import Cubical.Categories.Functor open import Cubical.Categories.NaturalTransformation open import Cubical.Categories.Limits open Category module _ ℓ where SET : Category (ℓ-suc ℓ) ℓ ob SET = hSet ℓ Hom[_,_] SET (A , _) (B , _) = A → B id SET x = x _⋆_ SET f g x = g (f x) ⋆IdL SET f = refl ⋆IdR SET f = refl ⋆Assoc SET f g h = refl isSetHom SET {A} {B} = isSetΠ (λ _ → snd B) private variable ℓ ℓ' : Level open Functor -- Hom functors _[-,_] : (C : Category ℓ ℓ') → (c : C .ob) → Functor (C ^op) (SET ℓ') (C [-, c ]) .F-ob x = (C [ x , c ]) , C .isSetHom (C [-, c ]) .F-hom f k = f ⋆⟨ C ⟩ k (C [-, c ]) .F-id = funExt λ _ → C .⋆IdL _ (C [-, c ]) .F-seq _ _ = funExt λ _ → C .⋆Assoc _ _ _ _[_,-] : (C : Category ℓ ℓ') → (c : C .ob)→ Functor C (SET ℓ') (C [ c ,-]) .F-ob x = (C [ c , x ]) , C .isSetHom (C [ c ,-]) .F-hom f k = k ⋆⟨ C ⟩ f (C [ c ,-]) .F-id = funExt λ _ → C .⋆IdR _ (C [ c ,-]) .F-seq _ _ = funExt λ _ → sym (C .⋆Assoc _ _ _) module _ {C : Category ℓ ℓ'} {F : Functor C (SET ℓ')} where open NatTrans -- natural transformations by pre/post composition preComp : {x y : C .ob} → (f : C [ x , y ]) → C [ x ,-] ⇒ F → C [ y ,-] ⇒ F preComp f α .N-ob c k = (α ⟦ c ⟧) (f ⋆⟨ C ⟩ k) preComp f α .N-hom {x = c} {d} k = (λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ (l ⋆⟨ C ⟩ k))) ≡[ i ]⟨ (λ l → (α ⟦ d ⟧) (⋆Assoc C f l k (~ i))) ⟩ (λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ l ⋆⟨ C ⟩ k)) ≡[ i ]⟨ (λ l → (α .N-hom k) i (f ⋆⟨ C ⟩ l)) ⟩ (λ l → (F ⟪ k ⟫) ((α ⟦ c ⟧) (f ⋆⟨ C ⟩ l))) ∎ -- properties -- TODO: move to own file open CatIso renaming (inv to cInv) open Iso Iso→CatIso : ∀ {A B : (SET ℓ) .ob} → Iso (fst A) (fst B) → CatIso (SET ℓ) A B Iso→CatIso is .mor = is .fun Iso→CatIso is .cInv = is .inv Iso→CatIso is .sec = funExt λ b → is .rightInv b -- is .rightInv Iso→CatIso is .ret = funExt λ b → is .leftInv b -- is .rightInv -- SET is complete -- notes: -- didn't need to restrict to *finite* diagrams , why is that required in Set theoretic? -- didn't use coinduction here because Agda didn't like me referencing 'cone' frome 'up' (termination check) open NatTrans isCompleteSET : ∀ {ℓJ ℓJ'} → complete' {ℓJ = ℓJ} {ℓJ'} (SET (ℓ-max ℓJ ℓJ')) isCompleteSET J K = record { head = head' ; islim = record { cone = cone' ; up = up' } } where -- the limit is defined as the Set of all cones with head Unit head' = Cone K (Unit* , isOfHLevelLift 2 isSetUnit) , isSetNatTrans -- the legs are defined by taking a cone to its component at j cone' : Cone K head' cone' .N-ob j μ = (μ ⟦ j ⟧) tt* -- Naturality follows from naturality of the Unit cone cone' .N-hom {x = i} {j} f = funExt λ μ → (μ ⟦ j ⟧) tt* ≡[ i ]⟨ (μ .N-hom f i) tt* ⟩ (K ⟪ f ⟫) ((μ ⟦ i ⟧) tt*) ∎ -- Given another cone α, we want a unique function f from α → cone' which factors it -- factorization property enforces that (cone' ⟦ j ⟧ ● f) ≡ α ⟦ j ⟧ -- but cone' ⟦ j ⟧ simply takes the jth component the output Cone K Unit from f -- so this enforces that for all x ∈ A, (f x) ⟦ j ⟧ ≡ α ⟦ j ⟧ x -- this determines the *only* possible factoring morphism up' : ∀ {A} (α : Cone K A) → cone' uniquelyFactors α up' {A} α = (f , fact) , unique where f : fst A → Cone K (Unit* , isOfHLevelLift 2 isSetUnit) f x = natTrans (λ j _ → α .N-ob j x) (λ {m} {n} f → funExt λ μ i → α .N-hom f i x) fact : α ≡ (f ◼ cone') fact = makeNatTransPath refl -- I LOVE DEFINITIONAL EQUALITY unique : (τ : cone' factors α) → (f , fact) ≡ τ unique (f' , fact') = ΣPathP (f≡f' , fact≡fact') where f≡f' : f ≡ f' f≡f' = funExt λ x → makeNatTransPath (funExt λ _ → sym eq2) where -- the factorization property enforces that f' must have the same behavior as f eq1 : ∀ {x j} → ((cone' ⟦ j ⟧) (f' x)) ≡ (α ⟦ j ⟧) x eq1 {x} {j} i = ((fact' (~ i)) ⟦ j ⟧) x eq2 : ∀ {x j} → (f' x) ⟦ j ⟧ ≡ λ _ → (α ⟦ j ⟧) x -- = (f x) ⟦ j ⟧ eq2 {x} {j} = funExt λ _ → eq1 -- follows from Set having homsets fact≡fact' : PathP (λ i → α ≡ ((f≡f' i) ◼ cone')) fact fact' fact≡fact' = isOfHLevel→isOfHLevelDep 1 (λ β → isSetNatTrans α β) fact fact' λ i → (f≡f' i) ◼ cone'
{ "alphanum_fraction": 0.5246861925, "avg_line_length": 34.8905109489, "ext": "agda", "hexsha": "ff9483450ce5aede51fe72ba983285e34645c06b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lpw25/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/Sets.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/Sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1858, "size": 4780 }
-- Andreas, 2014-01-09, extend parser of typed bindings to allow hiding postulate _≡_ : ∀{A : Set} (a b : A) → Set List : Set → Set _++_ : ∀{A : Set} (xs ys : List A) → List A assoc : ∀{A : Set} (xs {ys} {zs} : List A) → ((xs ++ ys) ++ zs) ≡ (xs ++ (ys ++ zs)) assoc1 : ∀{A : Set} (xs {ys zs} : List A) → ((xs ++ ys) ++ zs) ≡ (xs ++ (ys ++ zs)) test : (xs {ys zs} _ us : Set) → Set test1 : .(xs {ys zs} _ us : Set) → Set test2 : ..(xs {ys zs} _ us : Set) → Set
{ "alphanum_fraction": 0.4761904762, "avg_line_length": 40.25, "ext": "agda", "hexsha": "aefba935dbdcd0d07676bfc17659dcd5b1251432", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue1391.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue1391.agda", "max_line_length": 86, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue1391.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 211, "size": 483 }
{-# OPTIONS --without-K --safe #-} module Data.Nat.Base where open import Agda.Builtin.Nat public using (_+_; _*_; zero; suc) renaming (Nat to ℕ; _-_ to _∸_) open import Level data Ordering : ℕ → ℕ → Type where less : ∀ m k → Ordering m (suc (m + k)) equal : ∀ m → Ordering m m greater : ∀ m k → Ordering (suc (m + k)) m compare : ∀ m n → Ordering m n compare zero zero = equal zero compare (suc m) zero = greater zero m compare zero (suc n) = less zero n compare (suc m) (suc n) with compare m n ... | less m k = less (suc m) k ... | equal m = equal (suc m) ... | greater n k = greater (suc n) k
{ "alphanum_fraction": 0.5854037267, "avg_line_length": 25.76, "ext": "agda", "hexsha": "bc62f6e1c86918a82055c60efbaf5009cd63c5f1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Nat/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Nat/Base.agda", "max_line_length": 44, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Nat/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 219, "size": 644 }
open import OutsideIn.Prelude open import OutsideIn.X module OutsideIn.Inference.Solver(x : X) where import OutsideIn.Inference.Separator as S import OutsideIn.Expressions as E import OutsideIn.Constraints as C open import Data.Bool renaming (_∧_ to _and_) open E(x) open S(x) open X(x) open C(x) private module PlusN-m {n} = Monad (PlusN-is-monad {n}) module QC-f = Functor (qconstraint-is-functor) module Ax-f = Functor (axiomscheme-is-functor) module Type-f = Functor (type-is-functor) module Type-m = Monad (type-is-monad) mutual data _,_solvI►_ {x : Set}⦃ eq : Eq x ⦄(Q : AxiomScheme x)(Qg : QConstraint x) : {s : Shape} → Implications x s → Set where I-ε : Q , Qg solvI► imp-ε I-∧ : ∀ {r₁ r₂}{a : Implications x r₁}{b : Implications x r₂} → Q , Qg solvI► a → Q , Qg solvI► b → Q , Qg solvI► (a imp-∧ b) I-i : ∀ {r}{n}{Qv}{C : SeparatedConstraint _ r}{n′}{θ} → ( let peq = (PlusN-eq {n} eq) in Q , Qg ∧ Qv , n solv► C ↝ n′ , ε , θ) → Q , Qg solvI► imp (∃ n · Qv ⊃ C) data _,_,_solv►_↝_,_,_ {x : Set}⦃ eq : Eq x ⦄(Q : AxiomScheme x)(Qg : QConstraint x)(n : ℕ) : {s : Shape} → (SeparatedConstraint (x ⨁ n) s) → (m : ℕ) → (Qr : QConstraint (x ⨁ m)) → (θ : x ⨁ n → Type (x ⨁ m)) → Set where SOLVE : ∀ {s}{simpl}{imps : Implications _ s}{m}{Qr}{θ} → simplifier eq n Q Qg simpl ≡ m , Qr , solved Qr θ → let peq = (PlusN-eq {m} eq) in (Ax-f.map (PlusN-m.unit {m}) Q) , (Qr ∧ QC-f.map (PlusN-m.unit {m}) Qg) solvI► substituteImp θ imps → Q , Qg , n solv► SC simpl imps ↝ m , Qr , θ solveImps : {x : Set}{s : Shape} → (eq : Eq x) → (Q : AxiomScheme x) → (Qg : QConstraint x) → (C : Implications x s) → Ⓢ (Q , Qg solvI► C) solver′ : {x : Set}{s : Shape} → (eq : Eq x) → (n : ℕ) → (Q : AxiomScheme x) → (Qg : QConstraint x) → (C : SeparatedConstraint (x ⨁ n) s) → Ⓢ (∃ (λ m → ∃ (λ θ → Q , Qg , n solv► C ↝ m , ε , θ))) solver′ eq n axioms given (SC simpl imps) with simplifier eq n axioms given simpl | inspect (simplifier eq n axioms given) simpl ... | m , ε? , solved .ε? θ | iC prf with is-ε ε? solver′ eq n axioms given (SC simpl imps) | m , .ε , solved .ε θ | iC prf | yes refl = solveImps (PlusN-eq {m} eq) (Ax-f.map (PlusN-m.unit {m}) axioms) ( ε ∧ QC-f.map (PlusN-m.unit {m}) given) (substituteImp θ imps) >>= λ impP → suc (m , θ , SOLVE prf impP) where open Monad(Ⓢ-is-monad) ... | no isntε = zero solveImps eq Q Qg imp-ε = suc I-ε solveImps eq Q Qg (a imp-∧ b) = solveImps eq Q Qg a >>= λ a′ → solveImps eq Q Qg b >>= λ b′ → suc (I-∧ a′ b′) where open Monad(Ⓢ-is-monad) solveImps eq Q Qg (imp (∃ n · Qv ⊃ C)) = solver′ eq n Q (Qg ∧ Qv) C >>= λ { (m , θ , prf) → suc (I-i prf) } where open Monad(Ⓢ-is-monad) solver : {x : Set}{s : Shape} → (eq : Eq x) → (n : ℕ) → (Q : AxiomScheme x) → (Qg : QConstraint x) → (C : SeparatedConstraint (x ⨁ n) s) → Ⓢ (∃ (λ m → ∃ (λ Qr → ∃ (λ θ → Q , Qg , n solv► C ↝ m , Qr , θ)))) solver eq n Q Qg (SC simpl imps) with simplifier eq n Q Qg simpl | inspect (simplifier eq n Q Qg) simpl ... | m , Qr , solved .Qr θ | iC prf = solveImps (PlusN-eq {m} eq) (Ax-f.map (PlusN-m.unit {m}) Q) (Qr ∧ QC-f.map (PlusN-m.unit {m}) Qg) (substituteImp θ imps) >>= λ prf′ → suc (m , Qr , θ , SOLVE prf prf′) where open Monad(Ⓢ-is-monad)
{ "alphanum_fraction": 0.4729051681, "avg_line_length": 58.6176470588, "ext": "agda", "hexsha": "88f3ccd8c79c9bbdfdc53658964afe75d99c416c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "liamoc/outside-in", "max_forks_repo_path": "OutsideIn/Inference/Solver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "liamoc/outside-in", "max_issues_repo_path": "OutsideIn/Inference/Solver.agda", "max_line_length": 144, "max_stars_count": 2, "max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "liamoc/outside-in", "max_stars_repo_path": "OutsideIn/Inference/Solver.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z", "num_tokens": 1434, "size": 3986 }
module Data.Boolean.Proofs where import Lvl open import Data open import Data.Boolean import Data.Boolean.Operators open Data.Boolean.Operators.Logic using (_⊼_ ; _⊽_ ; _⊕_) open Data.Boolean.Operators.Programming open import Data.Either as Either using (_‖_ ; Left ; Right) open import Functional open import Logic.IntroInstances open import Logic.Propositional as Logic using (_∨_ ; _∧_ ; ¬_ ; _↔_ ; [⊤]-intro ; [↔]-intro ; [⊥]-elim ; [↔]-to-[←] ; [↔]-to-[→]) open import Logic.Predicate open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Operator.Monoid import Structure.Operator.Names as Names open import Structure.Operator.Properties open import Type private variable ℓ : Lvl.Level private variable T : Type{ℓ} private variable P : Bool → Type{ℓ} private variable a b c t f : Bool private variable x y : Bool private variable pt pf : ∀{b} → P(b) --------------------------------------------- -- Eliminator module _ {pt pf : T} where elim-nested : (elim pt pf (elim t f b) ≡ elim{T = const T} (elim pt pf t) (elim pt pf f) b) elim-nested{t = t}{f = f}{b = b} = elim{T = b ↦ (elim pt pf (elim t f b) ≡ elim(elim pt pf t) (elim pt pf f) b)} [≡]-intro [≡]-intro b module _ {x : T} where elim-redundant : (elim{T = const T} x x b ≡ x) elim-redundant{b = b} = elim{T = b ↦ elim x x b ≡ x} [≡]-intro [≡]-intro b elim-inverse : (elim 𝑇 𝐹 b ≡ b) elim-inverse{b = b} = elim{T = b ↦ elim 𝑇 𝐹 b ≡ b} [≡]-intro [≡]-intro b elim-anti-inverse : (elim 𝐹 𝑇 b ≡ ! b) elim-anti-inverse {𝑇} = [≡]-intro elim-anti-inverse {𝐹} = [≡]-intro --------------------------------------------- -- Negation [!]-no-fixpoints : ∀{b} → (! b ≢ b) [!]-no-fixpoints {𝑇} () [!]-no-fixpoints {𝐹} () [!!]-elim : ∀{a} → (!(! a) ≡ a) [!!]-elim {𝑇} = [≡]-intro [!!]-elim {𝐹} = [≡]-intro {-# REWRITE [!!]-elim #-} --------------------------------------------- -- Idempotence [&&]-idempotence-raw : ∀{a} → (a && a ≡ a) [&&]-idempotence-raw {𝑇} = [≡]-intro [&&]-idempotence-raw {𝐹} = [≡]-intro {-# REWRITE [&&]-idempotence-raw #-} instance [&&]-idempotence : Idempotence(_&&_) Idempotence.proof([&&]-idempotence) = [&&]-idempotence-raw [||]-idempotence-raw : ∀{a} → (a || a ≡ a) [||]-idempotence-raw {𝑇} = [≡]-intro [||]-idempotence-raw {𝐹} = [≡]-intro {-# REWRITE [||]-idempotence-raw #-} instance [||]-idempotence : Idempotence(_||_) Idempotence.proof([||]-idempotence) = [||]-idempotence-raw --------------------------------------------- -- Left anti-identities [==]-anti-identityₗ : ∀{a} → (𝐹 == a ≡ ! a) [==]-anti-identityₗ {𝑇} = [≡]-intro [==]-anti-identityₗ {𝐹} = [≡]-intro {-# REWRITE [==]-anti-identityₗ #-} [!=]-anti-identityₗ : ∀{a} → (𝑇 != a ≡ ! a) [!=]-anti-identityₗ {𝑇} = [≡]-intro [!=]-anti-identityₗ {𝐹} = [≡]-intro {-# REWRITE [!=]-anti-identityₗ #-} --------------------------------------------- -- Right anti-identities [==]-anti-identityᵣ : ∀{a} → (a == 𝐹 ≡ ! a) [==]-anti-identityᵣ {𝑇} = [≡]-intro [==]-anti-identityᵣ {𝐹} = [≡]-intro {-# REWRITE [==]-anti-identityᵣ #-} [!=]-anti-identityᵣ : ∀{a} → (a != 𝑇 ≡ ! a) [!=]-anti-identityᵣ {𝑇} = [≡]-intro [!=]-anti-identityᵣ {𝐹} = [≡]-intro {-# REWRITE [!=]-anti-identityᵣ #-} --------------------------------------------- -- Left identities [||]-identityₗ-raw : ∀{a} → (𝐹 || a ≡ a) [||]-identityₗ-raw {𝑇} = [≡]-intro [||]-identityₗ-raw {𝐹} = [≡]-intro {-# REWRITE [||]-identityₗ-raw #-} instance [||]-identityₗ : Identityₗ(_||_)(𝐹) Identityₗ.proof([||]-identityₗ) = [||]-identityₗ-raw [&&]-identityₗ-raw : ∀{a} → (𝑇 && a ≡ a) [&&]-identityₗ-raw {𝑇} = [≡]-intro [&&]-identityₗ-raw {𝐹} = [≡]-intro {-# REWRITE [&&]-identityₗ-raw #-} instance [&&]-identityₗ : Identityₗ(_&&_)(𝑇) Identityₗ.proof([&&]-identityₗ) = [&&]-identityₗ-raw [==]-identityₗ-raw : ∀{a} → (𝑇 == a ≡ a) [==]-identityₗ-raw {𝑇} = [≡]-intro [==]-identityₗ-raw {𝐹} = [≡]-intro {-# REWRITE [==]-identityₗ-raw #-} instance [==]-identityₗ : Identityₗ(_==_)(𝑇) Identityₗ.proof([==]-identityₗ) = [==]-identityₗ-raw [!=]-identityₗ-raw : ∀{a} → (𝐹 != a ≡ a) [!=]-identityₗ-raw {𝑇} = [≡]-intro [!=]-identityₗ-raw {𝐹} = [≡]-intro {-# REWRITE [!=]-identityₗ-raw #-} instance [!=]-identityₗ : Identityₗ(_!=_)(𝐹) Identityₗ.proof([!=]-identityₗ) = [!=]-identityₗ-raw --------------------------------------------- -- Left absorbers [||]-absorberₗ-raw : ∀{a} → (𝑇 || a ≡ 𝑇) [||]-absorberₗ-raw {𝑇} = [≡]-intro [||]-absorberₗ-raw {𝐹} = [≡]-intro {-# REWRITE [||]-absorberₗ-raw #-} instance [||]-absorberₗ : Absorberₗ(_||_)(𝑇) Absorberₗ.proof([||]-absorberₗ) {a} = [||]-absorberₗ-raw {a} [&&]-absorberₗ-raw : ∀{a} → (𝐹 && a ≡ 𝐹) [&&]-absorberₗ-raw {𝑇} = [≡]-intro [&&]-absorberₗ-raw {𝐹} = [≡]-intro {-# REWRITE [&&]-absorberₗ-raw #-} instance [&&]-absorberₗ : Absorberₗ(_&&_)(𝐹) Absorberₗ.proof([&&]-absorberₗ) {a} = [&&]-absorberₗ-raw {a} --------------------------------------------- -- Right identities [||]-identityᵣ-raw : ∀{a} → (a || 𝐹 ≡ a) [||]-identityᵣ-raw {𝑇} = [≡]-intro [||]-identityᵣ-raw {𝐹} = [≡]-intro {-# REWRITE [||]-identityᵣ-raw #-} instance [||]-identityᵣ : Identityᵣ(_||_)(𝐹) Identityᵣ.proof([||]-identityᵣ) = [||]-identityᵣ-raw [&&]-identityᵣ-raw : ∀{a} → (a && 𝑇 ≡ a) [&&]-identityᵣ-raw {𝑇} = [≡]-intro [&&]-identityᵣ-raw {𝐹} = [≡]-intro {-# REWRITE [&&]-identityᵣ-raw #-} instance [&&]-identityᵣ : Identityᵣ(_&&_)(𝑇) Identityᵣ.proof([&&]-identityᵣ) = [&&]-identityᵣ-raw [==]-identityᵣ-raw : ∀{a} → (a == 𝑇 ≡ a) [==]-identityᵣ-raw {𝑇} = [≡]-intro [==]-identityᵣ-raw {𝐹} = [≡]-intro {-# REWRITE [==]-identityᵣ-raw #-} instance [==]-identityᵣ : Identityᵣ(_==_)(𝑇) Identityᵣ.proof([==]-identityᵣ) = [==]-identityᵣ-raw [!=]-identityᵣ-raw : ∀{a} → (a != 𝐹 ≡ a) [!=]-identityᵣ-raw {𝑇} = [≡]-intro [!=]-identityᵣ-raw {𝐹} = [≡]-intro {-# REWRITE [!=]-identityᵣ-raw #-} instance [!=]-identityᵣ : Identityᵣ(_!=_)(𝐹) Identityᵣ.proof([!=]-identityᵣ) = [!=]-identityᵣ-raw --------------------------------------------- -- Identities instance [||]-identity : Identity(_||_)(𝐹) [||]-identity = record{} instance [&&]-identity : Identity(_&&_)(𝑇) [&&]-identity = record{} instance [==]-identity : Identity(_==_)(𝑇) [==]-identity = record{} instance [!=]-identity : Identity(_!=_)(𝐹) [!=]-identity = record{} --------------------------------------------- -- Right absorbers [||]-absorberᵣ-raw : ∀{a} → (a || 𝑇 ≡ 𝑇) [||]-absorberᵣ-raw {𝑇} = [≡]-intro [||]-absorberᵣ-raw {𝐹} = [≡]-intro {-# REWRITE [||]-absorberᵣ-raw #-} instance [||]-absorberᵣ : Absorberᵣ(_||_)(𝑇) Absorberᵣ.proof([||]-absorberᵣ) {a} = [||]-absorberᵣ-raw {a} [&&]-absorberᵣ-raw : ∀{a} → (a && 𝐹 ≡ 𝐹) [&&]-absorberᵣ-raw {𝑇} = [≡]-intro [&&]-absorberᵣ-raw {𝐹} = [≡]-intro {-# REWRITE [&&]-absorberᵣ-raw #-} instance [&&]-absorberᵣ : Absorberᵣ(_&&_)(𝐹) Absorberᵣ.proof([&&]-absorberᵣ) {a} = [&&]-absorberᵣ-raw {a} --------------------------------------------- -- Associativity instance [||]-associativity : Associativity(_||_) Associativity.proof([||]-associativity) = proof where proof : Names.Associativity(_||_) proof {𝑇}{𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝑇}{𝐹} = [≡]-intro proof {𝑇}{𝐹}{𝑇} = [≡]-intro proof {𝑇}{𝐹}{𝐹} = [≡]-intro proof {𝐹}{𝑇}{𝑇} = [≡]-intro proof {𝐹}{𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹}{𝐹} = [≡]-intro instance [&&]-associativity : Associativity(_&&_) Associativity.proof([&&]-associativity) = proof where proof : Names.Associativity(_&&_) proof {𝑇}{𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝑇}{𝐹} = [≡]-intro proof {𝑇}{𝐹}{𝑇} = [≡]-intro proof {𝑇}{𝐹}{𝐹} = [≡]-intro proof {𝐹}{𝑇}{𝑇} = [≡]-intro proof {𝐹}{𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹}{𝐹} = [≡]-intro instance [==]-associativity : Associativity(_==_) Associativity.proof([==]-associativity) = proof where proof : Names.Associativity(_==_) proof {𝑇}{𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝑇}{𝐹} = [≡]-intro proof {𝑇}{𝐹}{𝑇} = [≡]-intro proof {𝑇}{𝐹}{𝐹} = [≡]-intro proof {𝐹}{𝑇}{𝑇} = [≡]-intro proof {𝐹}{𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹}{𝐹} = [≡]-intro instance [!=]-associativity : Associativity(_!=_) Associativity.proof([!=]-associativity) = proof where proof : Names.Associativity(_!=_) proof {𝑇}{𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝑇}{𝐹} = [≡]-intro proof {𝑇}{𝐹}{𝑇} = [≡]-intro proof {𝑇}{𝐹}{𝐹} = [≡]-intro proof {𝐹}{𝑇}{𝑇} = [≡]-intro proof {𝐹}{𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹}{𝐹} = [≡]-intro --------------------------------------------- -- Other [⊼]-pseudo-associativity : (!(a ⊼ b) ⊼ c ≡ a ⊼ !(b ⊼ c)) [⊼]-pseudo-associativity {𝑇} {𝑇} {𝑇} = [≡]-intro [⊼]-pseudo-associativity {𝑇} {𝑇} {𝐹} = [≡]-intro [⊼]-pseudo-associativity {𝑇} {𝐹} {𝑇} = [≡]-intro [⊼]-pseudo-associativity {𝑇} {𝐹} {𝐹} = [≡]-intro [⊼]-pseudo-associativity {𝐹} {𝑇} {𝑇} = [≡]-intro [⊼]-pseudo-associativity {𝐹} {𝑇} {𝐹} = [≡]-intro [⊼]-pseudo-associativity {𝐹} {𝐹} {𝑇} = [≡]-intro [⊼]-pseudo-associativity {𝐹} {𝐹} {𝐹} = [≡]-intro [⊼]-to-conjunction : (!(a ⊼ b) ≡ a && b) [⊼]-to-conjunction {𝑇} {𝑇} = [≡]-intro [⊼]-to-conjunction {𝑇} {𝐹} = [≡]-intro [⊼]-to-conjunction {𝐹} {𝑇} = [≡]-intro [⊼]-to-conjunction {𝐹} {𝐹} = [≡]-intro [⊼]-to-negation : (b ⊼ b ≡ ! b) [⊼]-to-negation {𝑇} = [≡]-intro [⊼]-to-negation {𝐹} = [≡]-intro [⊼]-pseudo-absorptionₗ : (a ⊼ (a ⊼ b) ≡ a ⊼ (! b)) [⊼]-pseudo-absorptionₗ {𝑇} {𝑇} = [≡]-intro [⊼]-pseudo-absorptionₗ {𝑇} {𝐹} = [≡]-intro [⊼]-pseudo-absorptionₗ {𝐹} {𝑇} = [≡]-intro [⊼]-pseudo-absorptionₗ {𝐹} {𝐹} = [≡]-intro [⊼]-pseudo-absorptionᵣ : ((a ⊼ b) ⊼ b ≡ (! a) ⊼ b) [⊼]-pseudo-absorptionᵣ {𝑇} {𝑇} = [≡]-intro [⊼]-pseudo-absorptionᵣ {𝑇} {𝐹} = [≡]-intro [⊼]-pseudo-absorptionᵣ {𝐹} {𝑇} = [≡]-intro [⊼]-pseudo-absorptionᵣ {𝐹} {𝐹} = [≡]-intro [⊼]-pseudo-pseudo-absorptionₗ : (((! a) ⊼ b) ⊼ (a ⊼ b) ≡ b) [⊼]-pseudo-pseudo-absorptionₗ {𝑇} {𝑇} = [≡]-intro [⊼]-pseudo-pseudo-absorptionₗ {𝑇} {𝐹} = [≡]-intro [⊼]-pseudo-pseudo-absorptionₗ {𝐹} {𝑇} = [≡]-intro [⊼]-pseudo-pseudo-absorptionₗ {𝐹} {𝐹} = [≡]-intro [⊼]-pseudo-pseudo-absorptionᵣ : ((a ⊼ (! b)) ⊼ (a ⊼ b) ≡ a) [⊼]-pseudo-pseudo-absorptionᵣ {𝑇} {𝑇} = [≡]-intro [⊼]-pseudo-pseudo-absorptionᵣ {𝑇} {𝐹} = [≡]-intro [⊼]-pseudo-pseudo-absorptionᵣ {𝐹} {𝑇} = [≡]-intro [⊼]-pseudo-pseudo-absorptionᵣ {𝐹} {𝐹} = [≡]-intro [⊽]-pseudo-associativity : (!(a ⊽ b) ⊽ c ≡ a ⊽ !(b ⊽ c)) [⊽]-pseudo-associativity {𝑇} {𝑇} {𝑇} = [≡]-intro [⊽]-pseudo-associativity {𝑇} {𝑇} {𝐹} = [≡]-intro [⊽]-pseudo-associativity {𝑇} {𝐹} {𝑇} = [≡]-intro [⊽]-pseudo-associativity {𝑇} {𝐹} {𝐹} = [≡]-intro [⊽]-pseudo-associativity {𝐹} {𝑇} {𝑇} = [≡]-intro [⊽]-pseudo-associativity {𝐹} {𝑇} {𝐹} = [≡]-intro [⊽]-pseudo-associativity {𝐹} {𝐹} {𝑇} = [≡]-intro [⊽]-pseudo-associativity {𝐹} {𝐹} {𝐹} = [≡]-intro [⊽]-to-disjunction : (!(a ⊽ b) ≡ a || b) [⊽]-to-disjunction {𝑇} {𝑇} = [≡]-intro [⊽]-to-disjunction {𝑇} {𝐹} = [≡]-intro [⊽]-to-disjunction {𝐹} {𝑇} = [≡]-intro [⊽]-to-disjunction {𝐹} {𝐹} = [≡]-intro [⊽]-to-negation : (b ⊽ b ≡ ! b) [⊽]-to-negation {𝑇} = [≡]-intro [⊽]-to-negation {𝐹} = [≡]-intro [⊽]-pseudo-absorptionₗ : (a ⊽ (a ⊽ b) ≡ a ⊽ (! b)) [⊽]-pseudo-absorptionₗ {𝑇} {𝑇} = [≡]-intro [⊽]-pseudo-absorptionₗ {𝑇} {𝐹} = [≡]-intro [⊽]-pseudo-absorptionₗ {𝐹} {𝑇} = [≡]-intro [⊽]-pseudo-absorptionₗ {𝐹} {𝐹} = [≡]-intro [⊽]-pseudo-absorptionᵣ : ((a ⊽ b) ⊽ b ≡ (! a) ⊽ b) [⊽]-pseudo-absorptionᵣ {𝑇} {𝑇} = [≡]-intro [⊽]-pseudo-absorptionᵣ {𝑇} {𝐹} = [≡]-intro [⊽]-pseudo-absorptionᵣ {𝐹} {𝑇} = [≡]-intro [⊽]-pseudo-absorptionᵣ {𝐹} {𝐹} = [≡]-intro [⊽]-pseudo-pseudo-absorptionₗ : (((! a) ⊽ b) ⊽ (a ⊽ b) ≡ b) [⊽]-pseudo-pseudo-absorptionₗ {𝑇} {𝑇} = [≡]-intro [⊽]-pseudo-pseudo-absorptionₗ {𝑇} {𝐹} = [≡]-intro [⊽]-pseudo-pseudo-absorptionₗ {𝐹} {𝑇} = [≡]-intro [⊽]-pseudo-pseudo-absorptionₗ {𝐹} {𝐹} = [≡]-intro [⊽]-pseudo-pseudo-absorptionᵣ : ((a ⊽ (! b)) ⊽ (a ⊽ b) ≡ a) [⊽]-pseudo-pseudo-absorptionᵣ {𝑇} {𝑇} = [≡]-intro [⊽]-pseudo-pseudo-absorptionᵣ {𝑇} {𝐹} = [≡]-intro [⊽]-pseudo-pseudo-absorptionᵣ {𝐹} {𝑇} = [≡]-intro [⊽]-pseudo-pseudo-absorptionᵣ {𝐹} {𝐹} = [≡]-intro --------------------------------------------- -- Commutativity instance [||]-commutativity : Commutativity(_||_) Commutativity.proof([||]-commutativity) = proof where proof : Names.Commutativity(_||_) proof {𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹} = [≡]-intro instance [&&]-commutativity : Commutativity(_&&_) Commutativity.proof([&&]-commutativity) = proof where proof : Names.Commutativity(_&&_) proof {𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹} = [≡]-intro instance [==]-commutativity : Commutativity(_==_) Commutativity.proof([==]-commutativity) = proof where proof : Names.Commutativity(_==_) proof {𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹} = [≡]-intro instance [!=]-commutativity : Commutativity(_!=_) Commutativity.proof([!=]-commutativity) = proof where proof : Names.Commutativity(_!=_) proof {𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹} = [≡]-intro instance [⊼]-commutativity : Commutativity(_⊼_) Commutativity.proof([⊼]-commutativity) = proof where proof : Names.Commutativity(_⊼_) proof {𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹} = [≡]-intro instance [⊽]-commutativity : Commutativity(_⊽_) Commutativity.proof([⊽]-commutativity) = proof where proof : Names.Commutativity(_⊽_) proof {𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹} = [≡]-intro instance [⊕]-commutativity : Commutativity(_⊕_) Commutativity.proof([⊕]-commutativity) = proof where proof : Names.Commutativity(_⊕_) proof {𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹} = [≡]-intro instance [&&][||]-distributivityₗ : Distributivityₗ(_&&_)(_||_) Distributivityₗ.proof([&&][||]-distributivityₗ) = proof where proof : Names.Distributivityₗ(_&&_)(_||_) proof {𝑇}{𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝑇}{𝐹} = [≡]-intro proof {𝑇}{𝐹}{𝑇} = [≡]-intro proof {𝑇}{𝐹}{𝐹} = [≡]-intro proof {𝐹}{𝑇}{𝑇} = [≡]-intro proof {𝐹}{𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹}{𝐹} = [≡]-intro instance [||][&&]-distributivityₗ : Distributivityₗ(_||_)(_&&_) Distributivityₗ.proof([||][&&]-distributivityₗ) = proof where proof : Names.Distributivityₗ(_||_)(_&&_) proof {𝑇}{𝑇}{𝑇} = [≡]-intro proof {𝑇}{𝑇}{𝐹} = [≡]-intro proof {𝑇}{𝐹}{𝑇} = [≡]-intro proof {𝑇}{𝐹}{𝐹} = [≡]-intro proof {𝐹}{𝑇}{𝑇} = [≡]-intro proof {𝐹}{𝑇}{𝐹} = [≡]-intro proof {𝐹}{𝐹}{𝑇} = [≡]-intro proof {𝐹}{𝐹}{𝐹} = [≡]-intro instance [||]-oppositeFunctionₗ : ComplementFunctionₗ(_||_)(!) ComplementFunctionₗ.proof([||]-oppositeFunctionₗ) = proof where proof : Names.InverseFunctionₗ(_||_)(𝑇)(!) proof {𝑇} = [≡]-intro proof {𝐹} = [≡]-intro instance [||]-oppositeFunctionᵣ : ComplementFunctionᵣ(_||_)(!) ComplementFunctionᵣ.proof([||]-oppositeFunctionᵣ) = proof where proof : Names.InverseFunctionᵣ(_||_)(𝑇)(!) proof {𝑇} = [≡]-intro proof {𝐹} = [≡]-intro instance [&&]-oppositeFunctionₗ : ComplementFunctionₗ(_&&_)(!) ComplementFunctionₗ.proof([&&]-oppositeFunctionₗ) = proof where proof : Names.InverseFunctionₗ(_&&_)(𝐹)(!) proof {𝑇} = [≡]-intro proof {𝐹} = [≡]-intro instance [&&]-oppositeFunctionᵣ : ComplementFunctionᵣ(_&&_)(!) ComplementFunctionᵣ.proof([&&]-oppositeFunctionᵣ) = proof where proof : Names.InverseFunctionᵣ(_&&_)(𝐹)(!) proof {𝑇} = [≡]-intro proof {𝐹} = [≡]-intro --------------------------------------------- -- Algebraic structures instance [&&]-monoid : Monoid(_&&_) [&&]-monoid = record{} instance [||]-monoid : Monoid(_||_) [||]-monoid = record{} instance [==]-monoid : Monoid(_==_) [==]-monoid = record{} instance [!=]-monoid : Monoid(_!=_) [!=]-monoid = record{} -- TODO: Set algebra --------------------------------------------- -- Inverting inverted-[==][!=] : ∀{a b} → (!(a == b) ≡ (a != b)) inverted-[==][!=] {𝑇}{𝑇} = [≡]-intro inverted-[==][!=] {𝑇}{𝐹} = [≡]-intro inverted-[==][!=] {𝐹}{𝑇} = [≡]-intro inverted-[==][!=] {𝐹}{𝐹} = [≡]-intro inverted-[!=][==] : ∀{a b} → (!(a != b) ≡ (a == b)) inverted-[!=][==] {𝑇}{𝑇} = [≡]-intro inverted-[!=][==] {𝑇}{𝐹} = [≡]-intro inverted-[!=][==] {𝐹}{𝑇} = [≡]-intro inverted-[!=][==] {𝐹}{𝐹} = [≡]-intro --------------------------------------------- -- Rules of classical logic -- A boolean operation is either true or false bivalence : ∀{a} → ((a ≡ 𝑇) ∨ (a ≡ 𝐹)) bivalence {𝑇} = Logic.[∨]-introₗ [≡]-intro bivalence {𝐹} = Logic.[∨]-introᵣ [≡]-intro -- A boolean operation is not both true and false at the same time disjointness : ∀{a} → ¬((a ≡ 𝑇) ∧ (a ≡ 𝐹)) disjointness {𝑇} (Logic.[∧]-intro [≡]-intro ()) disjointness {𝐹} (Logic.[∧]-intro () [≡]-intro) [→?]-disjunctive-form : ∀{a b} → ((a →? b) ≡ ((! a) || b)) [→?]-disjunctive-form {𝑇} {𝑇} = [≡]-intro [→?]-disjunctive-form {𝑇} {𝐹} = [≡]-intro [→?]-disjunctive-form {𝐹} {𝑇} = [≡]-intro [→?]-disjunctive-form {𝐹} {𝐹} = [≡]-intro [==]-disjunctive-form : ∀{a b} → ((a == b) ≡ ((a && b) || ((! a) && (! b)))) [==]-disjunctive-form {𝑇} {𝑇} = [≡]-intro [==]-disjunctive-form {𝑇} {𝐹} = [≡]-intro [==]-disjunctive-form {𝐹} {𝑇} = [≡]-intro [==]-disjunctive-form {𝐹} {𝐹} = [≡]-intro module 𝑇 where [∧]-intro : ∀{a b} → (a ≡ 𝑇) → (b ≡ 𝑇) → ((a && b) ≡ 𝑇) [∧]-intro [≡]-intro [≡]-intro = [≡]-intro [∨]-introₗ : ∀{a b} → (a ≡ 𝑇) → ((a || b) ≡ 𝑇) [∨]-introₗ {_}{𝑇} [≡]-intro = [≡]-intro [∨]-introₗ {_}{𝐹} [≡]-intro = [≡]-intro [∨]-introᵣ : ∀{a b} → (b ≡ 𝑇) → ((a || b) ≡ 𝑇) [∨]-introᵣ {𝑇}{_} [≡]-intro = [≡]-intro [∨]-introᵣ {𝐹}{_} [≡]-intro = [≡]-intro [∧]-elimₗ : ∀{a b} → ((a && b) ≡ 𝑇) → (a ≡ 𝑇) [∧]-elimₗ {𝑇}{𝑇} [≡]-intro = [≡]-intro [∧]-elimₗ {𝑇}{𝐹} () [∧]-elimₗ {𝐹}{𝑇} () [∧]-elimₗ {𝐹}{𝐹} () [∧]-elimᵣ : ∀{a b} → ((a && b) ≡ 𝑇) → (b ≡ 𝑇) [∧]-elimᵣ {𝑇}{𝑇} [≡]-intro = [≡]-intro [∧]-elimᵣ {𝑇}{𝐹} () [∧]-elimᵣ {𝐹}{𝑇} () [∧]-elimᵣ {𝐹}{𝐹} () [∨]-elim : ∀{a b}{ℓ₂}{φ : Type{ℓ₂}} → ((a ≡ 𝑇) → φ) → ((b ≡ 𝑇) → φ) → ((a || b) ≡ 𝑇) → φ [∨]-elim {𝑇}{𝑇}{_} f _ [≡]-intro = f [≡]-intro [∨]-elim {𝑇}{𝐹}{_} f _ [≡]-intro = f [≡]-intro [∨]-elim {𝐹}{𝑇}{_} _ f [≡]-intro = f [≡]-intro [∨]-elim {𝐹}{𝐹}{_} _ f () [¬]-intro : ∀{a} → (a ≡ 𝐹) → (! a ≡ 𝑇) [¬]-intro [≡]-intro = [≡]-intro [¬]-elim : ∀{a} → (! a ≡ 𝑇) → (a ≡ 𝐹) [¬]-elim {𝑇} () [¬]-elim {𝐹} [≡]-intro = [≡]-intro [¬¬]-elim : ∀{a} → (!(! a) ≡ 𝑇) → (a ≡ 𝑇) [¬¬]-elim {𝑇} [≡]-intro = [≡]-intro [¬¬]-elim {𝐹} () preserves-[&&][∧] : ∀{a b} → ((a && b) ≡ 𝑇) ↔ (a ≡ 𝑇)∧(b ≡ 𝑇) preserves-[&&][∧] = [↔]-intro (\{(Logic.[∧]-intro l r) → [∧]-intro l r}) (proof ↦ Logic.[∧]-intro ([∧]-elimₗ proof) ([∧]-elimᵣ proof)) preserves-[||][∨] : ∀{a b} → ((a || b) ≡ 𝑇) ↔ (a ≡ 𝑇)∨(b ≡ 𝑇) preserves-[||][∨] = [↔]-intro (Logic.[∨]-elim [∨]-introₗ [∨]-introᵣ) ([∨]-elim Logic.[∨]-introₗ Logic.[∨]-introᵣ) preserves-[!][¬] : ∀{a} → (! a ≡ 𝑇) ↔ ¬(a ≡ 𝑇) preserves-[!][¬] {a} = [↔]-intro (l{a}) (r{a}) where l : ∀{a} → (! a ≡ 𝑇) ← ¬(a ≡ 𝑇) l {𝐹} _ = [≡]-intro l {𝑇} f = [⊥]-elim (f [≡]-intro) r : ∀{a} → (! a ≡ 𝑇) → ¬(a ≡ 𝑇) r {𝑇} () _ r {𝐹} _ () [≡]-transfer : ∀{a b} → ((a == b) ≡ 𝑇) ↔ (a ≡ b) [≡]-transfer {𝑇}{𝑇} = [↔]-intro (_ ↦ [≡]-intro) (_ ↦ [≡]-intro) [≡]-transfer {𝐹}{𝑇} = [↔]-intro (\()) (\()) [≡]-transfer {𝑇}{𝐹} = [↔]-intro (\()) (\()) [≡]-transfer {𝐹}{𝐹} = [↔]-intro (_ ↦ [≡]-intro) (_ ↦ [≡]-intro) [≢]-transfer : ∀{a b} → ((a != b) ≡ 𝑇) ↔ (a ≢ b) [≢]-transfer {𝑇}{𝑇} = [↔]-intro (ab ↦ [⊥]-elim(ab [≡]-intro)) (\()) [≢]-transfer {𝐹}{𝑇} = [↔]-intro (_ ↦ [≡]-intro) (_ ↦ \()) [≢]-transfer {𝑇}{𝐹} = [↔]-intro (_ ↦ [≡]-intro) (_ ↦ \()) [≢]-transfer {𝐹}{𝐹} = [↔]-intro (ab ↦ [⊥]-elim(ab [≡]-intro)) (\()) module 𝐹 where [∧]-introₗ : ∀{a b} → (a ≡ 𝐹) → ((a && b) ≡ 𝐹) [∧]-introₗ {_}{𝑇} [≡]-intro = [≡]-intro [∧]-introₗ {_}{𝐹} [≡]-intro = [≡]-intro [∧]-introᵣ : ∀{a b} → (b ≡ 𝐹) → ((a && b) ≡ 𝐹) [∧]-introᵣ {𝑇}{_} [≡]-intro = [≡]-intro [∧]-introᵣ {𝐹}{_} [≡]-intro = [≡]-intro [∨]-intro : ∀{a b} → (a ≡ 𝐹) → (b ≡ 𝐹) → ((a || b) ≡ 𝐹) [∨]-intro [≡]-intro [≡]-intro = [≡]-intro [¬]-intro : ∀{a} → (! a ≡ 𝑇) → (a ≡ 𝐹) [¬]-intro = 𝑇.[¬]-elim [¬]-elim : ∀{a} → (a ≡ 𝐹) → (! a ≡ 𝑇) [¬]-elim = 𝑇.[¬]-intro [≢][𝑇]-is-[𝐹] : ∀{a} → (a ≢ 𝑇) ↔ (a ≡ 𝐹) [≢][𝑇]-is-[𝐹] {a} = [↔]-intro (l{a}) (r{a}) where r : ∀{a} → (a ≢ 𝑇) → (a ≡ 𝐹) r {𝑇} (a≢𝑇) = [⊥]-elim ((a≢𝑇) ([≡]-intro)) r {𝐹} (a≢𝑇) = [≡]-intro l : ∀{a} → (a ≢ 𝑇) ← (a ≡ 𝐹) l {𝑇} () l {𝐹} (a≡𝐹) () [≢][𝐹]-is-[𝑇] : ∀{a} → (a ≢ 𝐹) ↔ (a ≡ 𝑇) [≢][𝐹]-is-[𝑇] {a} = [↔]-intro (l{a}) (r{a}) where r : ∀{a} → (a ≢ 𝐹) → (a ≡ 𝑇) r {𝑇} (a≢𝐹) = [≡]-intro r {𝐹} (a≢𝐹) = [⊥]-elim ((a≢𝐹) ([≡]-intro)) l : ∀{a} → (a ≢ 𝐹) ← (a ≡ 𝑇) l {𝑇} (a≡𝑇) () l {𝐹} () --------------------------------------------- -- If-statements module _ {ℓ₁ ℓ₂} {T : Type{ℓ₁}} {x y : T} {P : T → Type{ℓ₂}} where if-intro : ∀{B} → ((B ≡ 𝑇) → P(x)) → ((B ≡ 𝐹) → P(y)) → P(if B then x else y) if-intro {𝑇} px py = px [≡]-intro if-intro {𝐹} px py = py [≡]-intro module _ {ℓ₁ ℓ₂ ℓ₃} {T : Type{ℓ₁}} {x y : T} {P : T → Type{ℓ₂}} {Q : Bool → Type{ℓ₃}} where if-elim : ∀{B} → P(if B then x else y) → (P(x) → Q(𝑇)) → (P(y) → Q(𝐹)) → Q(B) if-elim{𝑇} p pxq pyq = pxq p if-elim{𝐹} p pxq pyq = pyq p module _ {ℓ₁ ℓ₂ ℓ₃} {T : Type{ℓ₁}} {x y : T} {P : T → Type{ℓ₂}} {Q : Type{ℓ₃}} where if-bool-elim : ∀{B} → P(if B then x else y) → (P(x) → (B ≡ 𝑇) → Q) → (P(y) → (B ≡ 𝐹) → Q) → Q if-bool-elim{𝑇} p pxq pyq = pxq p [≡]-intro if-bool-elim{𝐹} p pxq pyq = pyq p [≡]-intro module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {T : Type{ℓ₁}} {P : T → Type{ℓ₂}} {X : Type{ℓ₃}} {Y : Type{ℓ₄}} (nxy : X → Y → Logic.⊥) where either-bool-left : (xy : (X ∨ Y)) → (X ↔ (Either.isRight(xy) ≡ 𝐹)) either-bool-left xy with bivalence{Either.isRight(xy)} either-bool-left (Left x) | Right f = [↔]-intro (const x) (const f) either-bool-left (Right y) | Left t = [↔]-intro (\()) (x ↦ empty(nxy x y)) either-bool-right : (xy : (X ∨ Y)) → (Y ↔ (Either.isRight(xy) ≡ 𝑇)) either-bool-right xy with bivalence{Either.isRight(xy)} either-bool-right (Left x) | Right f = [↔]-intro (\()) (y ↦ empty(nxy x y)) either-bool-right (Right y) | Left t = [↔]-intro (const y) (const t) module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {T : Type{ℓ₁}} {P : T → Type{ℓ₂}} {X : Type{ℓ₃}} {Y : Type{ℓ₄}} where either-bool-leftₗ : (xy : (X ∨ Y)) → (X ← (Either.isRight(xy) ≡ 𝐹)) either-bool-leftₗ xy with bivalence{Either.isRight(xy)} either-bool-leftₗ (Left x) | Right f = const x either-bool-leftₗ (Right y) | Left t = \() either-bool-rightₗ : (xy : (X ∨ Y)) → (Y ← (Either.isRight(xy) ≡ 𝑇)) either-bool-rightₗ xy with bivalence{Either.isRight(xy)} either-bool-rightₗ (Left x) | Right f = \() either-bool-rightₗ (Right y) | Left t = const y if-not-either-bool-intro : ∀{x y : T} → (X → P(x)) → (Y → P(y)) → (xy : (X ∨ Y)) → P(if not(Either.isRight(xy)) then x else y) if-not-either-bool-intro {x}{y} xp yp xy = if-intro {x = x}{y = y} (xp ∘ either-bool-leftₗ xy ∘ 𝑇.[¬]-elim) (yp ∘ either-bool-rightₗ xy ∘ 𝑇.[¬¬]-elim ∘ 𝐹.[¬]-elim) module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {T : Type{ℓ₁}} {P : T → Type{ℓ₂}} {X : Type{ℓ₃}} {Y : Type{ℓ₄}} where if-either-bool-intro : ∀{x y : T} → (X → P(x)) → (Y → P(y)) → (xy : (X ∨ Y)) → P(if Either.isRight(xy) then y else x) if-either-bool-intro {x}{y} xp yp xy = if-intro {x = y}{y = x} (yp ∘ either-bool-rightₗ {P = P} xy) (xp ∘ either-bool-leftₗ {P = P} xy) --------------------------------------------- -- The predicate of if-statements module _ {ℓ} {T : Type{ℓ}} {x y : T} where if-and : ∀{B₁ B₂} → (if (B₁ && B₂) then x else y ≡ if B₁ then (if B₂ then x else y) else y) if-and {𝐹}{𝐹} = [≡]-intro if-and {𝐹}{𝑇} = [≡]-intro if-and {𝑇}{𝐹} = [≡]-intro if-and {𝑇}{𝑇} = [≡]-intro if-or : ∀{B₁ B₂} → (if (B₁ || B₂) then x else y ≡ if B₁ then x else if B₂ then x else y) if-or {𝐹}{𝐹} = [≡]-intro if-or {𝐹}{𝑇} = [≡]-intro if-or {𝑇}{𝐹} = [≡]-intro if-or {𝑇}{𝑇} = [≡]-intro if-not : ∀{B} → (if (! B) then x else y ≡ if B then y else x) if-not {𝐹} = [≡]-intro if-not {𝑇} = [≡]-intro --------------------------------------------- -- The results of if-statements module _ {ℓ} {T : Type{ℓ}} {x : T} {B} where if-then-redundant : (if B then x else x ≡ x) if-then-redundant = elim-redundant{b = B} module _ {ℓ} {T : Type{ℓ}} {B} where if-then-bool-inverse : (if B then 𝑇 else 𝐹 ≡ B) if-then-bool-inverse = elim-inverse{b = B} if-then-bool-anti-inverse : (if B then 𝐹 else 𝑇 ≡ ! B) if-then-bool-anti-inverse = elim-anti-inverse{b = B}
{ "alphanum_fraction": 0.499939313, "avg_line_length": 33.0883534137, "ext": "agda", "hexsha": "51aaccc2b889f3fad7b9d9a094e5a3913434fd1a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/Boolean/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/Boolean/Proofs.agda", "max_line_length": 165, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/Boolean/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 12444, "size": 24717 }
open import Agda.Builtin.Equality open import Agda.Builtin.Nat data ⊤ : Set where tt : ⊤ foo : Nat → ⊤ → ⊤ foo 0 tt = tt foo (suc n) tt = foo n tt -- NB tail-recursive test : foo 100000 tt ≡ tt test = refl -- memory blows up here
{ "alphanum_fraction": 0.6483050847, "avg_line_length": 16.8571428571, "ext": "agda", "hexsha": "9c4279dc0c7cb243fac5d3391df455a79f984676", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2147.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2147.agda", "max_line_length": 46, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2147.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 86, "size": 236 }
module Issue2486.Import where open import Issue2486.Haskell {-# FOREIGN GHC import qualified MAlonzo.Code.Issue2486.Haskell #-} data MyList (A : Set) : Set where [] : MyList A _::_ : A → MyList A → MyList A {-# COMPILE GHC MyList = data MAlonzo.Code.Issue2486.Haskell.MyList ( MAlonzo.Code.Issue2486.Haskell.Nil | MAlonzo.Code.Issue2486.Haskell.Cons ) #-}
{ "alphanum_fraction": 0.7252747253, "avg_line_length": 30.3333333333, "ext": "agda", "hexsha": "faf965f9ffe04c0e3da13ed81a2445b04d39a1ee", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Compiler/simple/Issue2486/Import.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Compiler/simple/Issue2486/Import.agda", "max_line_length": 148, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Compiler/simple/Issue2486/Import.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 114, "size": 364 }
{-# OPTIONS --allow-unsolved-metas #-} module FLutil where open import Level hiding ( suc ; zero ) open import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ ; _≟_) open import Data.Fin.Properties hiding ( <-trans ; ≤-refl ; ≤-trans ; ≤-irrelevant ; _≟_ ) renaming ( <-cmp to <-fcmp ) open import Data.Fin.Permutation -- hiding ([_,_]) open import Data.Nat -- using (ℕ; suc; zero; s≤s ; z≤n ) open import Data.Nat.Properties as DNP open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Data.List using (List; []; _∷_ ; length ; _++_ ; tail ) renaming (reverse to rev ) open import Data.Product open import Relation.Nullary open import Data.Empty open import Relation.Binary.Core open import Relation.Binary.Definitions open import logic open import nat infixr 100 _::_ data FL : (n : ℕ )→ Set where f0 : FL 0 _::_ : { n : ℕ } → Fin (suc n ) → FL n → FL (suc n) data _f<_ : {n : ℕ } (x : FL n ) (y : FL n) → Set where f<n : {m : ℕ } {xn yn : Fin (suc m) } {xt yt : FL m} → xn Data.Fin.< yn → (xn :: xt) f< ( yn :: yt ) f<t : {m : ℕ } {xn : Fin (suc m) } {xt yt : FL m} → xt f< yt → (xn :: xt) f< ( xn :: yt ) FLeq : {n : ℕ } {xn yn : Fin (suc n)} {x : FL n } {y : FL n} → xn :: x ≡ yn :: y → ( xn ≡ yn ) × (x ≡ y ) FLeq refl = refl , refl FLpos : {n : ℕ} → FL (suc n) → Fin (suc n) FLpos (x :: _) = x f-<> : {n : ℕ } {x : FL n } {y : FL n} → x f< y → y f< x → ⊥ f-<> (f<n x) (f<n x₁) = nat-<> x x₁ f-<> (f<n x) (f<t lt2) = nat-≡< refl x f-<> (f<t lt) (f<n x) = nat-≡< refl x f-<> (f<t lt) (f<t lt2) = f-<> lt lt2 f-≡< : {n : ℕ } {x : FL n } {y : FL n} → x ≡ y → y f< x → ⊥ f-≡< refl (f<n x) = nat-≡< refl x f-≡< refl (f<t lt) = f-≡< refl lt FLcmp : {n : ℕ } → Trichotomous {Level.zero} {FL n} _≡_ _f<_ FLcmp f0 f0 = tri≈ (λ ()) refl (λ ()) FLcmp (xn :: xt) (yn :: yt) with <-fcmp xn yn ... | tri< a ¬b ¬c = tri< (f<n a) (λ eq → nat-≡< (cong toℕ (proj₁ (FLeq eq)) ) a) (λ lt → f-<> lt (f<n a) ) ... | tri> ¬a ¬b c = tri> (λ lt → f-<> lt (f<n c) ) (λ eq → nat-≡< (cong toℕ (sym (proj₁ (FLeq eq)) )) c) (f<n c) ... | tri≈ ¬a refl ¬c with FLcmp xt yt ... | tri< a ¬b ¬c₁ = tri< (f<t a) (λ eq → ¬b (proj₂ (FLeq eq) )) (λ lt → f-<> lt (f<t a) ) ... | tri≈ ¬a₁ refl ¬c₁ = tri≈ (λ lt → f-≡< refl lt ) refl (λ lt → f-≡< refl lt ) ... | tri> ¬a₁ ¬b c = tri> (λ lt → f-<> lt (f<t c) ) (λ eq → ¬b (proj₂ (FLeq eq) )) (f<t c) f<-trans : {n : ℕ } { x y z : FL n } → x f< y → y f< z → x f< z f<-trans {suc n} (f<n x) (f<n x₁) = f<n ( Data.Fin.Properties.<-trans x x₁ ) f<-trans {suc n} (f<n x) (f<t y<z) = f<n x f<-trans {suc n} (f<t x<y) (f<n x) = f<n x f<-trans {suc n} (f<t x<y) (f<t y<z) = f<t (f<-trans x<y y<z) infixr 250 _f<?_ _f<?_ : {n : ℕ} → (x y : FL n ) → Dec (x f< y ) x f<? y with FLcmp x y ... | tri< a ¬b ¬c = yes a ... | tri≈ ¬a refl ¬c = no ( ¬a ) ... | tri> ¬a ¬b c = no ( ¬a ) _f≤_ : {n : ℕ } (x : FL n ) (y : FL n) → Set _f≤_ x y = (x ≡ y ) ∨ (x f< y ) FL0 : {n : ℕ } → FL n FL0 {zero} = f0 FL0 {suc n} = zero :: FL0 fmax : { n : ℕ } → FL n fmax {zero} = f0 fmax {suc n} = fromℕ< a<sa :: fmax {n} fmax< : { n : ℕ } → {x : FL n } → ¬ (fmax f< x ) fmax< {suc n} {x :: y} (f<n lt) = nat-≤> (fmax1 x) lt where fmax1 : {n : ℕ } → (x : Fin (suc n)) → toℕ x ≤ toℕ (fromℕ< {n} a<sa) fmax1 {zero} zero = z≤n fmax1 {suc n} zero = z≤n fmax1 {suc n} (suc x) = s≤s (fmax1 x) fmax< {suc n} {x :: y} (f<t lt) = fmax< {n} {y} lt fmax¬ : { n : ℕ } → {x : FL n } → ¬ ( x ≡ fmax ) → x f< fmax fmax¬ {zero} {f0} ne = ⊥-elim ( ne refl ) fmax¬ {suc n} {x} ne with FLcmp x fmax ... | tri< a ¬b ¬c = a ... | tri≈ ¬a b ¬c = ⊥-elim ( ne b) ... | tri> ¬a ¬b c = ⊥-elim (fmax< c) x≤fmax : {n : ℕ } → {x : FL n} → x f≤ fmax x≤fmax {n} {x} with FLcmp x fmax ... | tri< a ¬b ¬c = case2 a ... | tri≈ ¬a b ¬c = case1 b ... | tri> ¬a ¬b c = ⊥-elim ( fmax< c ) open import Data.Nat.Properties using ( ≤-trans ; <-trans ) fsuc : { n : ℕ } → (x : FL n ) → x f< fmax → FL n fsuc {n} (x :: y) (f<n lt) = fromℕ< fsuc1 :: y where fsuc1 : suc (toℕ x) < n fsuc1 = Data.Nat.Properties.≤-trans (s≤s lt) ( s≤s ( toℕ≤pred[n] (fromℕ< a<sa)) ) fsuc (x :: y) (f<t lt) = x :: fsuc y lt open import fin flist1 : {n : ℕ } (i : ℕ) → i < suc n → List (FL n) → List (FL n) → List (FL (suc n)) flist1 zero i<n [] _ = [] flist1 zero i<n (a ∷ x ) z = ( zero :: a ) ∷ flist1 zero i<n x z flist1 (suc i) (s≤s i<n) [] z = flist1 i (Data.Nat.Properties.<-trans i<n a<sa) z z flist1 (suc i) i<n (a ∷ x ) z = ((fromℕ< i<n ) :: a ) ∷ flist1 (suc i) i<n x z flist : {n : ℕ } → FL n → List (FL n) flist {zero} f0 = f0 ∷ [] flist {suc n} (x :: y) = flist1 n a<sa (flist y) (flist y) FL1 : List ℕ → List ℕ FL1 [] = [] FL1 (x ∷ y) = suc x ∷ FL1 y FL→plist : {n : ℕ} → FL n → List ℕ FL→plist {0} f0 = [] FL→plist {suc n} (zero :: y) = zero ∷ FL1 (FL→plist y) FL→plist {suc n} (suc x :: y) with FL→plist y ... | [] = zero ∷ [] ... | x1 ∷ t = suc x1 ∷ FL2 x t where FL2 : {n : ℕ} → Fin n → List ℕ → List ℕ FL2 zero y = zero ∷ FL1 y FL2 (suc i) [] = zero ∷ [] FL2 (suc i) (x ∷ y) = suc x ∷ FL2 i y tt0 = (# 2) :: (# 1) :: (# 0) :: zero :: f0 tt1 = FL→plist tt0 open _∧_ find-zero : {n i : ℕ} → List ℕ → i < n → Fin n ∧ List ℕ find-zero [] i<n = record { proj1 = fromℕ< i<n ; proj2 = [] } find-zero x (s≤s z≤n) = record { proj1 = fromℕ< (s≤s z≤n) ; proj2 = x } find-zero (zero ∷ y) (s≤s (s≤s i<n)) = record { proj1 = fromℕ< (s≤s (s≤s i<n)) ; proj2 = y } find-zero (suc x ∷ y) (s≤s (s≤s i<n)) with find-zero y (s≤s i<n) ... | record { proj1 = i ; proj2 = y1 } = record { proj1 = suc i ; proj2 = suc x ∷ y1 } plist→FL : {n : ℕ} → List ℕ → FL n -- wrong implementation plist→FL {zero} [] = f0 plist→FL {suc n} [] = zero :: plist→FL {n} [] plist→FL {zero} x = f0 plist→FL {suc n} x with find-zero x a<sa ... | record { proj1 = i ; proj2 = y } = i :: plist→FL y tt2 = 2 ∷ 1 ∷ 0 ∷ 3 ∷ [] tt3 : FL 4 tt3 = plist→FL tt2 tt4 = FL→plist tt3 tt5 = plist→FL {4} (FL→plist tt0) -- maybe FL→iso can be easier using this ... -- FL→plist-iso : {n : ℕ} → (f : FL n ) → plist→FL (FL→plist f ) ≡ f -- FL→plist-iso = {!!} -- FL→plist-inject : {n : ℕ} → (f g : FL n ) → FL→plist f ≡ FL→plist g → f ≡ g -- FL→plist-inject = {!!} open import Relation.Binary as B hiding (Decidable; _⇔_) open import Data.Sum.Base as Sum -- inj₁ open import Relation.Nary using (⌊_⌋) open import Data.List.Fresh hiding ([_]) FList : (n : ℕ ) → Set FList n = List# (FL n) ⌊ _f<?_ ⌋ fr1 : FList 3 fr1 = ((# 0) :: ((# 0) :: ((# 0 ) :: f0))) ∷# ((# 0) :: ((# 1) :: ((# 0 ) :: f0))) ∷# ((# 1) :: ((# 0) :: ((# 0 ) :: f0))) ∷# ((# 2) :: ((# 0) :: ((# 0 ) :: f0))) ∷# ((# 2) :: ((# 1) :: ((# 0 ) :: f0))) ∷# [] open import Data.Product open import Relation.Nullary.Decidable hiding (⌊_⌋) -- open import Data.Bool hiding (_<_ ; _≤_ ) open import Data.Unit.Base using (⊤ ; tt) -- fresh a [] = ⊤ -- fresh a (x ∷# xs) = R a x × fresh a xs -- toWitness -- ttf< : {n : ℕ } → {x a : FL n } → x f< a → T (isYes (x f<? a)) -- ttf< {n} {x} {a} x<a with x f<? a -- ... | yes y = subst (λ k → Data.Bool.T k ) refl tt -- ... | no nn = ⊥-elim ( nn x<a ) ttf : {n : ℕ } {x a : FL (n)} → x f< a → (y : FList (n)) → fresh (FL (n)) ⌊ _f<?_ ⌋ a y → fresh (FL (n)) ⌊ _f<?_ ⌋ x y ttf _ [] fr = Level.lift tt ttf {_} {x} {a} lt (cons a₁ y x1) (lift lt1 , x2 ) = (Level.lift (fromWitness (ttf1 lt1 lt ))) , ttf (ttf1 lt1 lt) y x1 where ttf1 : True (a f<? a₁) → x f< a → x f< a₁ ttf1 t x<a = f<-trans x<a (toWitness t) -- by https://gist.github.com/aristidb/1684202 FLinsert : {n : ℕ } → FL n → FList n → FList n FLfresh : {n : ℕ } → (a x : FL (suc n) ) → (y : FList (suc n) ) → a f< x → fresh (FL (suc n)) ⌊ _f<?_ ⌋ a y → fresh (FL (suc n)) ⌊ _f<?_ ⌋ a (FLinsert x y) FLinsert {zero} f0 y = f0 ∷# [] FLinsert {suc n} x [] = x ∷# [] FLinsert {suc n} x (cons a y x₁) with FLcmp x a ... | tri≈ ¬a b ¬c = cons a y x₁ ... | tri< lt ¬b ¬c = cons x ( cons a y x₁) ( Level.lift (fromWitness lt ) , ttf lt y x₁) FLinsert {suc n} x (cons a [] x₁) | tri> ¬a ¬b lt = cons a ( x ∷# [] ) ( Level.lift (fromWitness lt) , Level.lift tt ) FLinsert {suc n} x (cons a y yr) | tri> ¬a ¬b a<x = cons a (FLinsert x y) (FLfresh a x y a<x yr ) FLfresh a x [] a<x (Level.lift tt) = Level.lift (fromWitness a<x) , Level.lift tt FLfresh a x (cons b [] (Level.lift tt)) a<x (Level.lift a<b , a<y) with FLcmp x b ... | tri< x<b ¬b ¬c = Level.lift (fromWitness a<x) , Level.lift a<b , Level.lift tt ... | tri≈ ¬a refl ¬c = Level.lift (fromWitness a<x) , Level.lift tt ... | tri> ¬a ¬b b<x = Level.lift a<b , Level.lift (fromWitness (f<-trans (toWitness a<b) b<x)) , Level.lift tt FLfresh a x (cons b y br) a<x (Level.lift a<b , a<y) with FLcmp x b ... | tri< x<b ¬b ¬c = Level.lift (fromWitness a<x) , Level.lift a<b , ttf (toWitness a<b) y br ... | tri≈ ¬a refl ¬c = Level.lift (fromWitness a<x) , ttf a<x y br FLfresh a x (cons b [] br) a<x (Level.lift a<b , a<y) | tri> ¬a ¬b b<x = Level.lift a<b , Level.lift (fromWitness (f<-trans (toWitness a<b) b<x)) , Level.lift tt FLfresh a x (cons b (cons a₁ y x₁) br) a<x (Level.lift a<b , a<y) | tri> ¬a ¬b b<x = Level.lift a<b , FLfresh a x (cons a₁ y x₁) a<x a<y fr6 = FLinsert ((# 1) :: ((# 1) :: ((# 0 ) :: f0))) fr1 open import Data.List.Fresh.Relation.Unary.Any open import Data.List.Fresh.Relation.Unary.All x∈FLins : {n : ℕ} → (x : FL n ) → (xs : FList n) → Any (x ≡_) (FLinsert x xs) x∈FLins {zero} f0 [] = here refl x∈FLins {zero} f0 (cons f0 xs x) = here refl x∈FLins {suc n} x [] = here refl x∈FLins {suc n} x (cons a xs x₁) with FLcmp x a ... | tri< x<a ¬b ¬c = here refl ... | tri≈ ¬a b ¬c = here b x∈FLins {suc n} x (cons a [] x₁) | tri> ¬a ¬b a<x = there ( here refl ) x∈FLins {suc n} x (cons a (cons a₁ xs x₂) x₁) | tri> ¬a ¬b a<x = there ( x∈FLins x (cons a₁ xs x₂) ) nextAny : {n : ℕ} → {x h : FL n } → {L : FList n} → {hr : fresh (FL n) ⌊ _f<?_ ⌋ h L } → Any (x ≡_) L → Any (x ≡_) (cons h L hr ) nextAny (here x₁) = there (here x₁) nextAny (there any) = there (there any) insAny : {n : ℕ} → {x h : FL n } → (xs : FList n) → Any (x ≡_) xs → Any (x ≡_) (FLinsert h xs) insAny {zero} {f0} {f0} (cons a L xr) (here refl) = here refl insAny {zero} {f0} {f0} (cons a L xr) (there any) = insAny {zero} {f0} {f0} L any insAny {suc n} {x} {h} (cons a L xr) any with FLcmp h a ... | tri< x<a ¬b ¬c = there any ... | tri≈ ¬a b ¬c = any insAny {suc n} {a} {h} (cons a [] (Level.lift tt)) (here refl) | tri> ¬a ¬b c = here refl insAny {suc n} {x} {h} (cons a (cons a₁ L x₁) xr) (here refl) | tri> ¬a ¬b c = here refl insAny {suc n} {x} {h} (cons a (cons a₁ L x₁) xr) (there any) | tri> ¬a ¬b c = there (insAny (cons a₁ L x₁) any) -- FLinsert membership module FLMB { n : ℕ } where FL-Setoid : Setoid Level.zero Level.zero FL-Setoid = record { Carrier = FL n ; _≈_ = _≡_ ; isEquivalence = record { sym = sym ; refl = refl ; trans = trans }} open import Data.List.Fresh.Membership.Setoid FL-Setoid FLinsert-mb : (x : FL n ) → (xs : FList n) → x ∈ FLinsert x xs FLinsert-mb x xs = x∈FLins {n} x xs
{ "alphanum_fraction": 0.5135476879, "avg_line_length": 40.7058823529, "ext": "agda", "hexsha": "02b4588e2ea60d4703a02e3999c125427e6a5afb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_path": "src/FLutil.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/Galois", "max_issues_repo_path": "src/FLutil.agda", "max_line_length": 130, "max_stars_count": 1, "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_path": "src/FLutil.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "num_tokens": 4989, "size": 11072 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The partiality monad ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --guardedness #-} module Category.Monad.Partiality where open import Codata.Musical.Notation open import Category.Monad open import Data.Bool.Base using (Bool; false; true) open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Product as Prod hiding (map) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Function open import Function.Equivalence using (_⇔_; equivalence) open import Level using (_⊔_) open import Relation.Binary as B hiding (Rel) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Nullary open import Relation.Nullary.Decidable hiding (map) open import Relation.Nullary.Negation ------------------------------------------------------------------------ -- The partiality monad data _⊥ {a} (A : Set a) : Set a where now : (x : A) → A ⊥ later : (x : ∞ (A ⊥)) → A ⊥ monad : ∀ {f} → RawMonad {f = f} _⊥ monad = record { return = now ; _>>=_ = _>>=_ } where _>>=_ : ∀ {A B} → A ⊥ → (A → B ⊥) → B ⊥ now x >>= f = f x later x >>= f = later (♯ (♭ x >>= f)) private module M {f} = RawMonad (monad {f}) -- Non-termination. never : ∀ {a} {A : Set a} → A ⊥ never = later (♯ never) -- run x for n steps peels off at most n "later" constructors from x. run_for_steps : ∀ {a} {A : Set a} → A ⊥ → ℕ → A ⊥ run now x for n steps = now x run later x for zero steps = later x run later x for suc n steps = run ♭ x for n steps -- Is the computation done? isNow : ∀ {a} {A : Set a} → A ⊥ → Bool isNow (now x) = true isNow (later x) = false ------------------------------------------------------------------------ -- Kinds -- The partiality monad comes with two forms of equality (weak and -- strong) and one ordering. Strong equality is stronger than the -- ordering, which is stronger than weak equality. -- The three relations are defined using a single data type, indexed -- by a "kind". data OtherKind : Set where geq weak : OtherKind data Kind : Set where strong : Kind other : (k : OtherKind) → Kind -- Kind equality is decidable. infix 4 _≟-Kind_ _≟-Kind_ : Decidable (_≡_ {A = Kind}) _≟-Kind_ strong strong = yes P.refl _≟-Kind_ strong (other k) = no λ() _≟-Kind_ (other k) strong = no λ() _≟-Kind_ (other geq) (other geq) = yes P.refl _≟-Kind_ (other geq) (other weak) = no λ() _≟-Kind_ (other weak) (other geq) = no λ() _≟-Kind_ (other weak) (other weak) = yes P.refl -- A predicate which is satisfied only for equalities. Note that, for -- concrete inputs, this predicate evaluates to ⊤ or ⊥. Equality : Kind → Set Equality k = False (k ≟-Kind other geq) ------------------------------------------------------------------------ -- Equality/ordering module Equality {a ℓ} {A : Set a} -- The "return type". (_∼_ : A → A → Set ℓ) where -- The three relations. data Rel : Kind → A ⊥ → A ⊥ → Set (a ⊔ ℓ) where now : ∀ {k x y} (x∼y : x ∼ y) → Rel k (now x) (now y) later : ∀ {k x y} (x∼y : ∞ (Rel k (♭ x) (♭ y))) → Rel k (later x) (later y) laterʳ : ∀ {x y} (x≈y : Rel (other weak) x (♭ y) ) → Rel (other weak) x (later y) laterˡ : ∀ {k x y} (x∼y : Rel (other k) (♭ x) y ) → Rel (other k) (later x) y infix 4 _≅_ _≳_ _≲_ _≈_ _≅_ : A ⊥ → A ⊥ → Set _ _≅_ = Rel strong _≳_ : A ⊥ → A ⊥ → Set _ _≳_ = Rel (other geq) _≲_ : A ⊥ → A ⊥ → Set _ _≲_ = flip _≳_ _≈_ : A ⊥ → A ⊥ → Set _ _≈_ = Rel (other weak) -- x ⇓ y means that x terminates with y. infix 4 _⇓[_]_ _⇓_ _⇓[_]_ : A ⊥ → Kind → A → Set _ x ⇓[ k ] y = Rel k x (now y) _⇓_ : A ⊥ → A → Set _ x ⇓ y = x ⇓[ other weak ] y -- x ⇓ means that x terminates. infix 4 _⇓ _⇓ : A ⊥ → Set _ x ⇓ = ∃ λ v → x ⇓ v -- x ⇑ means that x does not terminate. infix 4 _⇑[_] _⇑ _⇑[_] : A ⊥ → Kind → Set _ x ⇑[ k ] = Rel k x never _⇑ : A ⊥ → Set _ x ⇑ = x ⇑[ other weak ] ------------------------------------------------------------------------ -- Lemmas relating the three relations module _ {a ℓ} {A : Set a} {_∼_ : A → A → Set ℓ} where open Equality _∼_ using (Rel; _≅_; _≳_; _≲_; _≈_; _⇓[_]_; _⇑[_]) open Equality.Rel -- All relations include strong equality. ≅⇒ : ∀ {k} {x y : A ⊥} → x ≅ y → Rel k x y ≅⇒ (now x∼y) = now x∼y ≅⇒ (later x≅y) = later (♯ ≅⇒ (♭ x≅y)) -- The weak equality includes the ordering. ≳⇒ : ∀ {k} {x y : A ⊥} → x ≳ y → Rel (other k) x y ≳⇒ (now x∼y) = now x∼y ≳⇒ (later x≳y) = later (♯ ≳⇒ (♭ x≳y)) ≳⇒ (laterˡ x≳y) = laterˡ (≳⇒ x≳y ) -- Weak equality includes the other relations. ⇒≈ : ∀ {k} {x y : A ⊥} → Rel k x y → x ≈ y ⇒≈ {strong} = ≅⇒ ⇒≈ {other geq} = ≳⇒ ⇒≈ {other weak} = id -- The relations agree for non-terminating computations. never⇒never : ∀ {k₁ k₂} {x : A ⊥} → Rel k₁ x never → Rel k₂ x never never⇒never (later x∼never) = later (♯ never⇒never (♭ x∼never)) never⇒never (laterʳ x≈never) = never⇒never x≈never never⇒never (laterˡ x∼never) = later (♯ never⇒never x∼never) -- The "other" relations agree when the right-hand side is a value. now⇒now : ∀ {k₁ k₂} {x} {y : A} → Rel (other k₁) x (now y) → Rel (other k₂) x (now y) now⇒now (now x∼y) = now x∼y now⇒now (laterˡ x∼now) = laterˡ (now⇒now x∼now) ------------------------------------------------------------------------ -- Later can be dropped laterʳ⁻¹ : ∀ {k} {x : A ⊥} {y} → Rel (other k) x (later y) → Rel (other k) x (♭ y) laterʳ⁻¹ (later x∼y) = laterˡ (♭ x∼y) laterʳ⁻¹ (laterʳ x≈y) = x≈y laterʳ⁻¹ (laterˡ x∼ly) = laterˡ (laterʳ⁻¹ x∼ly) laterˡ⁻¹ : ∀ {x} {y : A ⊥} → later x ≈ y → ♭ x ≈ y laterˡ⁻¹ (later x≈y) = laterʳ (♭ x≈y) laterˡ⁻¹ (laterʳ lx≈y) = laterʳ (laterˡ⁻¹ lx≈y) laterˡ⁻¹ (laterˡ x≈y) = x≈y later⁻¹ : ∀ {k} {x y : ∞ (A ⊥)} → Rel k (later x) (later y) → Rel k (♭ x) (♭ y) later⁻¹ (later x∼y) = ♭ x∼y later⁻¹ (laterʳ lx≈y) = laterˡ⁻¹ lx≈y later⁻¹ (laterˡ x∼ly) = laterʳ⁻¹ x∼ly ------------------------------------------------------------------------ -- The relations are equivalences or partial orders, given suitable -- assumptions about the underlying relation module Equivalence where -- Reflexivity. refl : Reflexive _∼_ → ∀ {k} → Reflexive (Rel k) refl refl-∼ {x = now v} = now refl-∼ refl refl-∼ {x = later x} = later (♯ refl refl-∼) -- Symmetry. sym : Symmetric _∼_ → ∀ {k} → Equality k → Symmetric (Rel k) sym sym-∼ eq (now x∼y) = now (sym-∼ x∼y) sym sym-∼ eq (later x∼y) = later (♯ sym sym-∼ eq (♭ x∼y)) sym sym-∼ eq (laterʳ x≈y) = laterˡ (sym sym-∼ eq x≈y ) sym sym-∼ eq (laterˡ {weak} x≈y) = laterʳ (sym sym-∼ eq x≈y ) sym sym-∼ () (laterˡ {geq} x≳y) -- Transitivity. private module Trans (trans-∼ : Transitive _∼_) where now-trans : ∀ {k x y} {v : A} → Rel k x y → Rel k y (now v) → Rel k x (now v) now-trans (now x∼y) (now y∼z) = now (trans-∼ x∼y y∼z) now-trans (laterˡ x∼y) y∼z = laterˡ (now-trans x∼y y∼z) now-trans x∼ly (laterˡ y∼z) = now-trans (laterʳ⁻¹ x∼ly) y∼z mutual later-trans : ∀ {k} {x y : A ⊥} {z} → Rel k x y → Rel k y (later z) → Rel k x (later z) later-trans (later x∼y) ly∼lz = later (♯ trans (♭ x∼y) (later⁻¹ ly∼lz)) later-trans (laterˡ x∼y) y∼lz = later (♯ trans x∼y (laterʳ⁻¹ y∼lz)) later-trans (laterʳ x≈y) ly≈lz = later-trans x≈y (laterˡ⁻¹ ly≈lz) later-trans x≈y (laterʳ y≈z) = laterʳ ( trans x≈y y≈z ) trans : ∀ {k} {x y z : A ⊥} → Rel k x y → Rel k y z → Rel k x z trans {z = now v} x∼y y∼v = now-trans x∼y y∼v trans {z = later z} x∼y y∼lz = later-trans x∼y y∼lz open Trans public using (trans) -- All the relations are preorders. preorder : IsPreorder _≡_ _∼_ → Kind → Preorder _ _ _ preorder pre k = record { Carrier = A ⊥ ; _≈_ = _≡_ ; _∼_ = Rel k ; isPreorder = record { isEquivalence = P.isEquivalence ; reflexive = refl′ ; trans = Equivalence.trans (IsPreorder.trans pre) } } where refl′ : ∀ {k} {x y : A ⊥} → x ≡ y → Rel k x y refl′ P.refl = Equivalence.refl (IsPreorder.refl pre) private preorder′ : IsEquivalence _∼_ → Kind → Preorder _ _ _ preorder′ equiv = preorder (Setoid.isPreorder (record { isEquivalence = equiv })) -- The two equalities are equivalence relations. setoid : IsEquivalence _∼_ → (k : Kind) {eq : Equality k} → Setoid _ _ setoid equiv k {eq} = record { Carrier = A ⊥ ; _≈_ = Rel k ; isEquivalence = record { refl = Pre.refl ; sym = Equivalence.sym (IsEquivalence.sym equiv) eq ; trans = Pre.trans } } where module Pre = Preorder (preorder′ equiv k) -- The order is a partial order, with strong equality as the -- underlying equality. ≳-poset : IsEquivalence _∼_ → Poset _ _ _ ≳-poset equiv = record { Carrier = A ⊥ ; _≈_ = _≅_ ; _≤_ = _≳_ ; isPartialOrder = record { antisym = antisym ; isPreorder = record { isEquivalence = S.isEquivalence ; reflexive = ≅⇒ ; trans = Pre.trans } } } where module S = Setoid (setoid equiv strong) module Pre = Preorder (preorder′ equiv (other geq)) antisym : {x y : A ⊥} → x ≳ y → x ≲ y → x ≅ y antisym (now x∼y) (now _) = now x∼y antisym (later x≳y) (later x≲y) = later (♯ antisym (♭ x≳y) (♭ x≲y)) antisym (later x≳y) (laterˡ x≲ly) = later (♯ antisym (♭ x≳y) (laterʳ⁻¹ x≲ly)) antisym (laterˡ x≳ly) (later x≲y) = later (♯ antisym (laterʳ⁻¹ x≳ly) (♭ x≲y)) antisym (laterˡ x≳ly) (laterˡ x≲ly) = later (♯ antisym (laterʳ⁻¹ x≳ly) (laterʳ⁻¹ x≲ly)) -- Equational reasoning. module Reasoning (isEquivalence : IsEquivalence _∼_) where private module Pre {k} = Preorder (preorder′ isEquivalence k) module S {k eq} = Setoid (setoid isEquivalence k {eq}) infix 3 _∎ infixr 2 _≡⟨_⟩_ _≅⟨_⟩_ _≳⟨_⟩_ _≈⟨_⟩_ _≡⟨_⟩_ : ∀ {k} x {y z : A ⊥} → x ≡ y → Rel k y z → Rel k x z _ ≡⟨ P.refl ⟩ y∼z = y∼z _≅⟨_⟩_ : ∀ {k} x {y z : A ⊥} → x ≅ y → Rel k y z → Rel k x z _ ≅⟨ x≅y ⟩ y∼z = Pre.trans (≅⇒ x≅y) y∼z _≳⟨_⟩_ : ∀ {k} x {y z : A ⊥} → x ≳ y → Rel (other k) y z → Rel (other k) x z _ ≳⟨ x≳y ⟩ y∼z = Pre.trans (≳⇒ x≳y) y∼z _≈⟨_⟩_ : ∀ x {y z : A ⊥} → x ≈ y → y ≈ z → x ≈ z _ ≈⟨ x≈y ⟩ y≈z = Pre.trans x≈y y≈z sym : ∀ {k} {eq : Equality k} {x y : A ⊥} → Rel k x y → Rel k y x sym {eq = eq} = S.sym {eq = eq} _∎ : ∀ {k} (x : A ⊥) → Rel k x x x ∎ = Pre.refl ------------------------------------------------------------------------ -- Lemmas related to now and never -- Now is not never. now≉never : ∀ {k} {x : A} → ¬ Rel k (now x) never now≉never (laterʳ hyp) = now≉never hyp -- A partial value is either now or never (classically, when the -- underlying relation is reflexive). now-or-never : Reflexive _∼_ → ∀ {k} (x : A ⊥) → ¬ ¬ ((∃ λ y → x ⇓[ other k ] y) ⊎ x ⇑[ other k ]) now-or-never refl x = helper <$> excluded-middle where open RawMonad ¬¬-Monad not-now-is-never : (x : A ⊥) → (∄ λ y → x ≳ now y) → x ≳ never not-now-is-never (now x) hyp with hyp (-, now refl) ... | () not-now-is-never (later x) hyp = later (♯ not-now-is-never (♭ x) (hyp ∘ Prod.map id laterˡ)) helper : Dec (∃ λ y → x ≳ now y) → _ helper (yes ≳now) = inj₁ $ Prod.map id ≳⇒ ≳now helper (no ≵now) = inj₂ $ ≳⇒ $ not-now-is-never x ≵now ------------------------------------------------------------------------ -- Map-like results -- Map. map : ∀ {_∼′_ : A → A → Set a} {k} → _∼′_ ⇒ _∼_ → Equality.Rel _∼′_ k ⇒ Equality.Rel _∼_ k map ∼′⇒∼ (now x∼y) = now (∼′⇒∼ x∼y) map ∼′⇒∼ (later x∼y) = later (♯ map ∼′⇒∼ (♭ x∼y)) map ∼′⇒∼ (laterʳ x≈y) = laterʳ (map ∼′⇒∼ x≈y) map ∼′⇒∼ (laterˡ x∼y) = laterˡ (map ∼′⇒∼ x∼y) -- If a statement can be proved using propositional equality as the -- underlying relation, then it can also be proved for any other -- reflexive underlying relation. ≡⇒ : Reflexive _∼_ → ∀ {k x y} → Equality.Rel _≡_ k x y → Rel k x y ≡⇒ refl-∼ = map (flip (P.subst (_∼_ _)) refl-∼) ------------------------------------------------------------------------ -- Steps -- The number of later constructors (steps) in the terminating -- computation x. steps : ∀ {k} {x : A ⊥} {y} → x ⇓[ k ] y → ℕ steps (now _) = zero steps .{x = later x} (laterˡ {x = x} x⇓) = suc (steps {x = ♭ x} x⇓) module Steps {trans-∼ : Transitive _∼_} where left-identity : ∀ {k x y} {z : A} (x≅y : x ≅ y) (y⇓z : y ⇓[ k ] z) → steps (Equivalence.trans trans-∼ (≅⇒ x≅y) y⇓z) ≡ steps y⇓z left-identity (now _) (now _) = P.refl left-identity (later x≅y) (laterˡ y⇓z) = P.cong suc $ left-identity (♭ x≅y) y⇓z right-identity : ∀ {k x} {y z : A} (x⇓y : x ⇓[ k ] y) (y≈z : now y ⇓[ k ] z) → steps (Equivalence.trans trans-∼ x⇓y y≈z) ≡ steps x⇓y right-identity (now x∼y) (now y∼z) = P.refl right-identity (laterˡ x∼y) (now y∼z) = P.cong suc $ right-identity x∼y (now y∼z) ------------------------------------------------------------------------ -- Laws related to bind -- Never is a left and right "zero" of bind. left-zero : {B : Set a} (f : B → A ⊥) → let open M in (never >>= f) ≅ never left-zero f = later (♯ left-zero f) right-zero : ∀ {B} (x : B ⊥) → let open M in (x >>= λ _ → never) ≅ never right-zero (later x) = later (♯ right-zero (♭ x)) right-zero (now x) = never≅never where never≅never : never ≅ never never≅never = later (♯ never≅never) -- Now is a left and right identity of bind (for a reflexive -- underlying relation). left-identity : Reflexive _∼_ → ∀ {B} (x : B) (f : B → A ⊥) → let open M in (now x >>= f) ≅ f x left-identity refl-∼ x f = Equivalence.refl refl-∼ right-identity : Reflexive _∼_ → (x : A ⊥) → let open M in (x >>= now) ≅ x right-identity refl (now x) = now refl right-identity refl (later x) = later (♯ right-identity refl (♭ x)) -- Bind is associative (for a reflexive underlying relation). associative : Reflexive _∼_ → ∀ {B C} (x : C ⊥) (f : C → B ⊥) (g : B → A ⊥) → let open M in (x >>= f >>= g) ≅ (x >>= λ y → f y >>= g) associative refl-∼ (now x) f g = Equivalence.refl refl-∼ associative refl-∼ (later x) f g = later (♯ associative refl-∼ (♭ x) f g) module _ {s ℓ} {A B : Set s} {_∼A_ : A → A → Set ℓ} {_∼B_ : B → B → Set ℓ} where open Equality private open module EqA = Equality _∼A_ using () renaming (_⇓[_]_ to _⇓[_]A_; _⇑[_] to _⇑[_]A) open module EqB = Equality _∼B_ using () renaming (_⇓[_]_ to _⇓[_]B_; _⇑[_] to _⇑[_]B) -- Bind preserves all the relations. _>>=-cong_ : ∀ {k} {x₁ x₂ : A ⊥} {f₁ f₂ : A → B ⊥} → let open M in Rel _∼A_ k x₁ x₂ → (∀ {x₁ x₂} → x₁ ∼A x₂ → Rel _∼B_ k (f₁ x₁) (f₂ x₂)) → Rel _∼B_ k (x₁ >>= f₁) (x₂ >>= f₂) now x₁∼x₂ >>=-cong f₁∼f₂ = f₁∼f₂ x₁∼x₂ later x₁∼x₂ >>=-cong f₁∼f₂ = later (♯ (♭ x₁∼x₂ >>=-cong f₁∼f₂)) laterʳ x₁≈x₂ >>=-cong f₁≈f₂ = laterʳ (x₁≈x₂ >>=-cong f₁≈f₂) laterˡ x₁∼x₂ >>=-cong f₁∼f₂ = laterˡ (x₁∼x₂ >>=-cong f₁∼f₂) -- Inversion lemmas for bind. >>=-inversion-⇓ : Reflexive _∼A_ → ∀ {k} x {f : A → B ⊥} {y} → let open M in (x>>=f⇓ : (x >>= f) ⇓[ k ]B y) → ∃ λ z → ∃₂ λ (x⇓ : x ⇓[ k ]A z) (fz⇓ : f z ⇓[ k ]B y) → steps x⇓ + steps fz⇓ ≡ steps x>>=f⇓ >>=-inversion-⇓ refl (now x) fx⇓ = (x , now refl , fx⇓ , P.refl) >>=-inversion-⇓ refl (later x) (laterˡ x>>=f⇓) = Prod.map id (Prod.map laterˡ (Prod.map id (P.cong suc))) $ >>=-inversion-⇓ refl (♭ x) x>>=f⇓ >>=-inversion-⇑ : IsEquivalence _∼A_ → ∀ {k} x {f : A → B ⊥} → let open M in Rel _∼B_ (other k) (x >>= f) never → ¬ ¬ (x ⇑[ other k ]A ⊎ ∃ λ y → x ⇓[ other k ]A y × f y ⇑[ other k ]B) >>=-inversion-⇑ eqA {k} x {f} ∼never = helper <$> now-or-never IsEqA.refl x where open RawMonad ¬¬-Monad using (_<$>_) open M using (_>>=_) open Reasoning eqA module IsEqA = IsEquivalence eqA k≳ = other geq is-never : ∀ {x y} → x ⇓[ k≳ ]A y → (x >>= f) ⇑[ k≳ ]B → ∃ λ z → (y ∼A z) × f z ⇑[ k≳ ]B is-never (now x∼y) = λ fx⇑ → (_ , IsEqA.sym x∼y , fx⇑) is-never (laterˡ ≳now) = is-never ≳now ∘ later⁻¹ helper : (∃ λ y → x ⇓[ k≳ ]A y) ⊎ x ⇑[ k≳ ]A → x ⇑[ other k ]A ⊎ ∃ λ y → x ⇓[ other k ]A y × f y ⇑[ other k ]B helper (inj₂ ≳never) = inj₁ (≳⇒ ≳never) helper (inj₁ (y , ≳now)) with is-never ≳now (never⇒never ∼never) ... | (z , y∼z , fz⇑) = inj₂ (z , ≳⇒ (x ≳⟨ ≳now ⟩ now y ≅⟨ now y∼z ⟩ now z ∎) , ≳⇒ fz⇑) module _ {ℓ} {A B : Set ℓ} {_∼_ : B → B → Set ℓ} where open Equality -- A variant of _>>=-cong_. _≡->>=-cong_ : ∀ {k} {x₁ x₂ : A ⊥} {f₁ f₂ : A → B ⊥} → let open M in Rel _≡_ k x₁ x₂ → (∀ x → Rel _∼_ k (f₁ x) (f₂ x)) → Rel _∼_ k (x₁ >>= f₁) (x₂ >>= f₂) _≡->>=-cong_ {k} {f₁ = f₁} {f₂} x₁≈x₂ f₁≈f₂ = x₁≈x₂ >>=-cong λ {x} x≡x′ → P.subst (λ y → Rel _∼_ k (f₁ x) (f₂ y)) x≡x′ (f₁≈f₂ x) ------------------------------------------------------------------------ -- Productivity checker workaround -- The monad can be awkward to use, due to the limitations of guarded -- coinduction. The following code provides a (limited) workaround. module Workaround {a} where infixl 1 _>>=_ data _⊥P : Set a → Set (Level.suc a) where now : ∀ {A} (x : A) → A ⊥P later : ∀ {A} (x : ∞ (A ⊥P)) → A ⊥P _>>=_ : ∀ {A B} (x : A ⊥P) (f : A → B ⊥P) → B ⊥P private data _⊥W : Set a → Set (Level.suc a) where now : ∀ {A} (x : A) → A ⊥W later : ∀ {A} (x : A ⊥P) → A ⊥W mutual _>>=W_ : ∀ {A B} → A ⊥W → (A → B ⊥P) → B ⊥W now x >>=W f = whnf (f x) later x >>=W f = later (x >>= f) whnf : ∀ {A} → A ⊥P → A ⊥W whnf (now x) = now x whnf (later x) = later (♭ x) whnf (x >>= f) = whnf x >>=W f mutual private ⟦_⟧W : ∀ {A} → A ⊥W → A ⊥ ⟦ now x ⟧W = now x ⟦ later x ⟧W = later (♯ ⟦ x ⟧P) ⟦_⟧P : ∀ {A} → A ⊥P → A ⊥ ⟦ x ⟧P = ⟦ whnf x ⟧W -- The definitions above make sense. ⟦_⟧P is homomorphic with -- respect to now, later and _>>=_. module Correct where private open module Eq {A : Set a} = Equality {A = A} _≡_ open module R {A : Set a} = Reasoning (P.isEquivalence {A = A}) now-hom : ∀ {A} (x : A) → ⟦ now x ⟧P ≅ now x now-hom x = now x ∎ later-hom : ∀ {A} (x : ∞ (A ⊥P)) → ⟦ later x ⟧P ≅ later (♯ ⟦ ♭ x ⟧P) later-hom x = later (♯ (⟦ ♭ x ⟧P ∎)) mutual private >>=-homW : ∀ {A B} (x : B ⊥W) (f : B → A ⊥P) → ⟦ x >>=W f ⟧W ≅ M._>>=_ ⟦ x ⟧W (λ y → ⟦ f y ⟧P) >>=-homW (now x) f = ⟦ f x ⟧P ∎ >>=-homW (later x) f = later (♯ >>=-hom x f) >>=-hom : ∀ {A B} (x : B ⊥P) (f : B → A ⊥P) → ⟦ x >>= f ⟧P ≅ M._>>=_ ⟦ x ⟧P (λ y → ⟦ f y ⟧P) >>=-hom x f = >>=-homW (whnf x) f ------------------------------------------------------------------------ -- An alternative, but equivalent, formulation of equality/ordering module AlternativeEquality {a ℓ} where private El : Setoid a ℓ → Set _ El = Setoid.Carrier Eq : ∀ S → B.Rel (El S) _ Eq = Setoid._≈_ open Equality using (Rel) open Equality.Rel infix 4 _∣_≅P_ _∣_≳P_ _∣_≈P_ infix 3 _∎ infixr 2 _≡⟨_⟩_ _≅⟨_⟩_ _≳⟨_⟩_ _≳⟨_⟩≅_ _≳⟨_⟩≈_ _≈⟨_⟩≅_ _≈⟨_⟩≲_ infixl 1 _>>=_ mutual -- Proof "programs". _∣_≅P_ : ∀ S → B.Rel (El S ⊥) _ _∣_≅P_ = flip RelP strong _∣_≳P_ : ∀ S → B.Rel (El S ⊥) _ _∣_≳P_ = flip RelP (other geq) _∣_≈P_ : ∀ S → B.Rel (El S ⊥) _ _∣_≈P_ = flip RelP (other weak) data RelP S : Kind → B.Rel (El S ⊥) (Level.suc (a ⊔ ℓ)) where -- Congruences. now : ∀ {k x y} (xRy : x ⟨ Eq S ⟩ y) → RelP S k (now x) (now y) later : ∀ {k x y} (x∼y : ∞ (RelP S k (♭ x) (♭ y))) → RelP S k (later x) (later y) _>>=_ : ∀ {S′ : Setoid a ℓ} {k} {x₁ x₂} {f₁ f₂ : El S′ → El S ⊥} → let open M in (x₁∼x₂ : RelP S′ k x₁ x₂) (f₁∼f₂ : ∀ {x y} → x ⟨ Eq S′ ⟩ y → RelP S k (f₁ x) (f₂ y)) → RelP S k (x₁ >>= f₁) (x₂ >>= f₂) -- Ordering/weak equality. laterʳ : ∀ {x y} (x≈y : RelP S (other weak) x (♭ y)) → RelP S (other weak) x (later y) laterˡ : ∀ {k x y} (x∼y : RelP S (other k) (♭ x) y) → RelP S (other k) (later x) y -- Equational reasoning. Note that including full transitivity -- for weak equality would make _∣_≈P_ trivial; a similar -- problem applies to _∣_≳P_ (A ∣ never ≳P now x would be -- provable). Instead the definition of RelP includes limited -- notions of transitivity, similar to weak bisimulation up-to -- various things. _∎ : ∀ {k} x → RelP S k x x sym : ∀ {k x y} {eq : Equality k} (x∼y : RelP S k x y) → RelP S k y x _≡⟨_⟩_ : ∀ {k} x {y z} (x≡y : x ≡ y) (y∼z : RelP S k y z) → RelP S k x z _≅⟨_⟩_ : ∀ {k} x {y z} (x≅y : S ∣ x ≅P y) (y∼z : RelP S k y z) → RelP S k x z _≳⟨_⟩_ : let open Equality (Eq S) in ∀ x {y z} (x≳y : x ≳ y) (y≳z : S ∣ y ≳P z) → S ∣ x ≳P z _≳⟨_⟩≅_ : ∀ x {y z} (x≳y : S ∣ x ≳P y) (y≅z : S ∣ y ≅P z) → S ∣ x ≳P z _≳⟨_⟩≈_ : ∀ x {y z} (x≳y : S ∣ x ≳P y) (y≈z : S ∣ y ≈P z) → S ∣ x ≈P z _≈⟨_⟩≅_ : ∀ x {y z} (x≈y : S ∣ x ≈P y) (y≅z : S ∣ y ≅P z) → S ∣ x ≈P z _≈⟨_⟩≲_ : ∀ x {y z} (x≈y : S ∣ x ≈P y) (y≲z : S ∣ z ≳P y) → S ∣ x ≈P z -- If any of the following transitivity-like rules were added to -- RelP, then RelP and Rel would no longer be equivalent: -- -- x ≳P y → y ≳P z → x ≳P z -- x ≳P y → y ≳ z → x ≳P z -- x ≲P y → y ≈P z → x ≈P z -- x ≈P y → y ≳P z → x ≈P z -- x ≲ y → y ≈P z → x ≈P z -- x ≈P y → y ≳ z → x ≈P z -- x ≈P y → y ≈P z → x ≈P z -- x ≈P y → y ≈ z → x ≈P z -- x ≈ y → y ≈P z → x ≈P z -- -- The reason is that any of these rules would make it possible -- to derive that never and now x are related. -- RelP is complete with respect to Rel. complete : ∀ {S k} {x y : El S ⊥} → Equality.Rel (Eq S) k x y → RelP S k x y complete (now xRy) = now xRy complete (later x∼y) = later (♯ complete (♭ x∼y)) complete (laterʳ x≈y) = laterʳ (complete x≈y) complete (laterˡ x∼y) = laterˡ (complete x∼y) -- RelP is sound with respect to Rel. private -- Proof WHNFs. data RelW S : Kind → B.Rel (El S ⊥) (Level.suc (a ⊔ ℓ)) where now : ∀ {k x y} (xRy : x ⟨ Eq S ⟩ y) → RelW S k (now x) (now y) later : ∀ {k x y} (x∼y : RelP S k (♭ x) (♭ y)) → RelW S k (later x) (later y) laterʳ : ∀ {x y} (x≈y : RelW S (other weak) x (♭ y)) → RelW S (other weak) x (later y) laterˡ : ∀ {k x y} (x∼y : RelW S (other k) (♭ x) y) → RelW S (other k) (later x) y -- WHNFs can be turned into programs. program : ∀ {S k x y} → RelW S k x y → RelP S k x y program (now xRy) = now xRy program (later x∼y) = later (♯ x∼y) program (laterˡ x∼y) = laterˡ (program x∼y) program (laterʳ x≈y) = laterʳ (program x≈y) -- Lemmas for WHNFs. _>>=W_ : ∀ {A B k x₁ x₂} {f₁ f₂ : El A → El B ⊥} → RelW A k x₁ x₂ → (∀ {x y} → x ⟨ Eq A ⟩ y → RelW B k (f₁ x) (f₂ y)) → RelW B k (M._>>=_ x₁ f₁) (M._>>=_ x₂ f₂) now xRy >>=W f₁∼f₂ = f₁∼f₂ xRy later x∼y >>=W f₁∼f₂ = later (x∼y >>= program ∘ f₁∼f₂) laterʳ x≈y >>=W f₁≈f₂ = laterʳ (x≈y >>=W f₁≈f₂) laterˡ x∼y >>=W f₁∼f₂ = laterˡ (x∼y >>=W f₁∼f₂) reflW : ∀ {S k} x → RelW S k x x reflW {S} (now x) = now (Setoid.refl S) reflW (later x) = later (♭ x ∎) symW : ∀ {S k x y} → Equality k → RelW S k x y → RelW S k y x symW {S} eq (now xRy) = now (Setoid.sym S xRy) symW eq (later x≈y) = later (sym {eq = eq} x≈y) symW eq (laterʳ x≈y) = laterˡ (symW eq x≈y) symW eq (laterˡ {weak} x≈y) = laterʳ (symW eq x≈y) symW () (laterˡ {geq} x≈y) trans≅W : ∀ {S x y z} → RelW S strong x y → RelW S strong y z → RelW S strong x z trans≅W {S} (now xRy) (now yRz) = now (Setoid.trans S xRy yRz) trans≅W (later x≅y) (later y≅z) = later (_ ≅⟨ x≅y ⟩ y≅z) trans≳-W : ∀ {S x y z} → let open Equality (Eq S) in x ≳ y → RelW S (other geq) y z → RelW S (other geq) x z trans≳-W {S} (now xRy) (now yRz) = now (Setoid.trans S xRy yRz) trans≳-W (later x≳y) (later y≳z) = later (_ ≳⟨ ♭ x≳y ⟩ y≳z) trans≳-W (later x≳y) (laterˡ y≳z) = laterˡ (trans≳-W (♭ x≳y) y≳z) trans≳-W (laterˡ x≳y) y≳z = laterˡ (trans≳-W x≳y y≳z) -- Strong equality programs can be turned into WHNFs. whnf≅ : ∀ {S x y} → S ∣ x ≅P y → RelW S strong x y whnf≅ (now xRy) = now xRy whnf≅ (later x≅y) = later (♭ x≅y) whnf≅ (x₁≅x₂ >>= f₁≅f₂) = whnf≅ x₁≅x₂ >>=W λ xRy → whnf≅ (f₁≅f₂ xRy) whnf≅ (x ∎) = reflW x whnf≅ (sym x≅y) = symW _ (whnf≅ x≅y) whnf≅ (x ≡⟨ P.refl ⟩ y≅z) = whnf≅ y≅z whnf≅ (x ≅⟨ x≅y ⟩ y≅z) = trans≅W (whnf≅ x≅y) (whnf≅ y≅z) -- More transitivity lemmas. _⟨_⟩≅_ : ∀ {S k} x {y z} → RelP S k x y → S ∣ y ≅P z → RelP S k x z _⟨_⟩≅_ {k = strong} x x≅y y≅z = x ≅⟨ x≅y ⟩ y≅z _⟨_⟩≅_ {k = other geq} x x≳y y≅z = x ≳⟨ x≳y ⟩≅ y≅z _⟨_⟩≅_ {k = other weak} x x≈y y≅z = x ≈⟨ x≈y ⟩≅ y≅z trans∼≅W : ∀ {S k x y z} → RelW S k x y → RelW S strong y z → RelW S k x z trans∼≅W {S} (now xRy) (now yRz) = now (Setoid.trans S xRy yRz) trans∼≅W (later x∼y) (later y≅z) = later (_ ⟨ x∼y ⟩≅ y≅z) trans∼≅W (laterʳ x≈y) (later y≅z) = laterʳ (trans∼≅W x≈y (whnf≅ y≅z)) trans∼≅W (laterˡ x∼y) y≅z = laterˡ (trans∼≅W x∼y y≅z) trans≅∼W : ∀ {S k x y z} → RelW S strong x y → RelW S k y z → RelW S k x z trans≅∼W {S} (now xRy) (now yRz) = now (Setoid.trans S xRy yRz) trans≅∼W (later x≅y) (later y∼z) = later (_ ≅⟨ x≅y ⟩ y∼z) trans≅∼W (later x≅y) (laterˡ y∼z) = laterˡ (trans≅∼W (whnf≅ x≅y) y∼z) trans≅∼W x≅y (laterʳ ly≈z) = laterʳ (trans≅∼W x≅y ly≈z) -- Order programs can be turned into WHNFs. whnf≳ : ∀ {S x y} → S ∣ x ≳P y → RelW S (other geq) x y whnf≳ (now xRy) = now xRy whnf≳ (later x∼y) = later (♭ x∼y) whnf≳ (laterˡ x≲y) = laterˡ (whnf≳ x≲y) whnf≳ (x₁∼x₂ >>= f₁∼f₂) = whnf≳ x₁∼x₂ >>=W λ xRy → whnf≳ (f₁∼f₂ xRy) whnf≳ (x ∎) = reflW x whnf≳ (sym {eq = ()} x≅y) whnf≳ (x ≡⟨ P.refl ⟩ y≳z) = whnf≳ y≳z whnf≳ (x ≅⟨ x≅y ⟩ y≳z) = trans≅∼W (whnf≅ x≅y) (whnf≳ y≳z) whnf≳ (x ≳⟨ x≳y ⟩ y≳z) = trans≳-W x≳y (whnf≳ y≳z) whnf≳ (x ≳⟨ x≳y ⟩≅ y≅z) = trans∼≅W (whnf≳ x≳y) (whnf≅ y≅z) -- Another transitivity lemma. trans≳≈W : ∀ {S x y z} → RelW S (other geq) x y → RelW S (other weak) y z → RelW S (other weak) x z trans≳≈W {S} (now xRy) (now yRz) = now (Setoid.trans S xRy yRz) trans≳≈W (later x≳y) (later y≈z) = later (_ ≳⟨ x≳y ⟩≈ y≈z) trans≳≈W (laterˡ x≳y) y≈z = laterˡ (trans≳≈W x≳y y≈z) trans≳≈W x≳y (laterʳ y≈z) = laterʳ (trans≳≈W x≳y y≈z) trans≳≈W (later x≳y) (laterˡ y≈z) = laterˡ (trans≳≈W (whnf≳ x≳y) y≈z) -- All programs can be turned into WHNFs. whnf : ∀ {S k x y} → RelP S k x y → RelW S k x y whnf (now xRy) = now xRy whnf (later x∼y) = later (♭ x∼y) whnf (laterʳ x≈y) = laterʳ (whnf x≈y) whnf (laterˡ x∼y) = laterˡ (whnf x∼y) whnf (x₁∼x₂ >>= f₁∼f₂) = whnf x₁∼x₂ >>=W λ xRy → whnf (f₁∼f₂ xRy) whnf (x ∎) = reflW x whnf (sym {eq = eq} x≈y) = symW eq (whnf x≈y) whnf (x ≡⟨ P.refl ⟩ y∼z) = whnf y∼z whnf (x ≅⟨ x≅y ⟩ y∼z) = trans≅∼W (whnf x≅y) (whnf y∼z) whnf (x ≳⟨ x≳y ⟩ y≳z) = trans≳-W x≳y (whnf y≳z) whnf (x ≳⟨ x≳y ⟩≅ y≅z) = trans∼≅W (whnf x≳y) (whnf y≅z) whnf (x ≳⟨ x≳y ⟩≈ y≈z) = trans≳≈W (whnf x≳y) (whnf y≈z) whnf (x ≈⟨ x≈y ⟩≅ y≅z) = trans∼≅W (whnf x≈y) (whnf y≅z) whnf (x ≈⟨ x≈y ⟩≲ y≲z) = symW _ (trans≳≈W (whnf y≲z) (symW _ (whnf x≈y))) mutual -- Soundness. private soundW : ∀ {S k x y} → RelW S k x y → Rel (Eq S) k x y soundW (now xRy) = now xRy soundW (later x∼y) = later (♯ sound x∼y) soundW (laterʳ x≈y) = laterʳ (soundW x≈y) soundW (laterˡ x∼y) = laterˡ (soundW x∼y) sound : ∀ {S k x y} → RelP S k x y → Rel (Eq S) k x y sound x∼y = soundW (whnf x∼y) -- RelP and Rel are equivalent (when the underlying relation is an -- equivalence). correct : ∀ {S k x y} → RelP S k x y ⇔ Rel (Eq S) k x y correct = equivalence sound complete ------------------------------------------------------------------------ -- Another lemma -- Bind is "idempotent". idempotent : ∀ {ℓ} {A : Set ℓ} (B : Setoid ℓ ℓ) → let open M; open Setoid B using (_≈_; Carrier); open Equality _≈_ in (x : A ⊥) (f : A → A → Carrier ⊥) → (x >>= λ y′ → x >>= λ y″ → f y′ y″) ≳ (x >>= λ y′ → f y′ y′) idempotent {A = A} B x f = sound (idem x) where open AlternativeEquality hiding (_>>=_) open M open Equality.Rel using (laterˡ) open Equivalence using (refl) idem : (x : A ⊥) → B ∣ (x >>= λ y′ → x >>= λ y″ → f y′ y″) ≳P (x >>= λ y′ → f y′ y′) idem (now x) = f x x ∎ idem (later x) = later (♯ ( (♭ x >>= λ y′ → later x >>= λ y″ → f y′ y″) ≳⟨ (refl P.refl {x = ♭ x} ≡->>=-cong λ _ → laterˡ (refl (Setoid.refl B))) ⟩ (♭ x >>= λ y′ → ♭ x >>= λ y″ → f y′ y″) ≳⟨ idem (♭ x) ⟩≅ (♭ x >>= λ y′ → f y′ y′) ∎)) ------------------------------------------------------------------------ -- Example private module Example where open Data.Nat open Workaround -- McCarthy's f91: f91′ : ℕ → ℕ ⊥P f91′ n with n ≤? 100 ... | yes _ = later (♯ (f91′ (11 + n) >>= f91′)) ... | no _ = now (n ∸ 10) f91 : ℕ → ℕ ⊥ f91 n = ⟦ f91′ n ⟧P
{ "alphanum_fraction": 0.4652084324, "avg_line_length": 34.2508143322, "ext": "agda", "hexsha": "db7e927e55d2ac5867f4d39288d1886e60c3eb8c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Category/Monad/Partiality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Category/Monad/Partiality.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Category/Monad/Partiality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 13774, "size": 31545 }
open import Algebra using (CommutativeMonoid) open import Relation.Binary.Structures using (IsEquivalence) open import Relation.Binary.PropositionalEquality using () renaming (cong to ≡-cong) module AKS.Exponentiation {c ℓ} (M : CommutativeMonoid c ℓ) where open import AKS.Nat using (ℕ; _+_; _<_) open ℕ open import AKS.Nat using (ℕ⁺; ℕ+; ⟅_⇓⟆) open import AKS.Nat using (Acc; acc; <-well-founded) open import AKS.Binary using (2*; 𝔹; 𝔹⁺; ⟦_⇑⟧; ⟦_⇓⟧; ⟦_⇑⟧⁺; ⟦_⇓⟧⁺; ℕ→𝔹→ℕ; ⌈log₂_⌉) open 𝔹 open 𝔹⁺ open CommutativeMonoid M using (_≈_; isEquivalence; setoid; ε; _∙_; ∙-cong; ∙-congˡ; identityˡ; identityʳ; assoc; comm) renaming (Carrier to C) open IsEquivalence isEquivalence using (refl; sym) open import Relation.Binary.Reasoning.Setoid setoid _^ⁱ_ : C → ℕ → C x ^ⁱ zero = ε x ^ⁱ suc n = x ∙ x ^ⁱ n ^ⁱ-homo : ∀ x n m → x ^ⁱ (n + m) ≈ x ^ⁱ n ∙ x ^ⁱ m ^ⁱ-homo x zero m = sym (identityˡ (x ^ⁱ m)) ^ⁱ-homo x (suc n) m = begin x ∙ x ^ⁱ (n + m) ≈⟨ ∙-congˡ (^ⁱ-homo x n m) ⟩ x ∙ (x ^ⁱ n ∙ x ^ⁱ m) ≈⟨ sym (assoc _ _ _) ⟩ x ∙ x ^ⁱ n ∙ x ^ⁱ m ∎ ∙-^ⁱ-dist : ∀ x y n → (x ∙ y) ^ⁱ n ≈ x ^ⁱ n ∙ y ^ⁱ n ∙-^ⁱ-dist x y zero = sym (identityˡ ε) ∙-^ⁱ-dist x y (suc n) = begin x ∙ y ∙ ((x ∙ y) ^ⁱ n) ≈⟨ ∙-congˡ (∙-^ⁱ-dist x y n) ⟩ x ∙ y ∙ (x ^ⁱ n ∙ y ^ⁱ n) ≈⟨ assoc _ _ _ ⟩ x ∙ (y ∙ (x ^ⁱ n ∙ y ^ⁱ n)) ≈⟨ ∙-congˡ (comm _ _) ⟩ x ∙ (x ^ⁱ n ∙ y ^ⁱ n ∙ y) ≈⟨ ∙-congˡ (assoc _ _ _) ⟩ x ∙ (x ^ⁱ n ∙ (y ^ⁱ n ∙ y)) ≈⟨ ∙-congˡ (∙-congˡ (comm _ _)) ⟩ x ∙ (x ^ⁱ n ∙ (y ∙ y ^ⁱ n)) ≈⟨ sym (assoc _ _ _) ⟩ x ∙ (x ^ⁱ n) ∙ (y ∙ (y ^ⁱ n)) ∎ _^ᵇ⁺_ : C → 𝔹⁺ → C x ^ᵇ⁺ 𝕓1ᵇ = x x ^ᵇ⁺ (b 0ᵇ) = (x ∙ x) ^ᵇ⁺ b x ^ᵇ⁺ (b 1ᵇ) = x ∙ (x ∙ x) ^ᵇ⁺ b _^ᵇ_ : C → 𝔹 → C x ^ᵇ 𝕓0ᵇ = ε x ^ᵇ (+ b) = x ^ᵇ⁺ b _^⁺_ : C → ℕ⁺ → C x ^⁺ n = x ^ᵇ⁺ ⟦ n ⇑⟧⁺ _^_ : C → ℕ → C x ^ n = x ^ᵇ ⟦ n ⇑⟧ x^n≈x^ⁱn : ∀ x n → x ^ n ≈ x ^ⁱ n x^n≈x^ⁱn x n = begin x ^ n ≈⟨ loop x ⟦ n ⇑⟧ ⟩ x ^ⁱ ⟦ ⟦ n ⇑⟧ ⇓⟧ ≡⟨ ≡-cong (λ t → x ^ⁱ t) (ℕ→𝔹→ℕ n) ⟩ x ^ⁱ n ∎ where even : ∀ x b → (x ∙ x) ^ᵇ⁺ b ≈ x ^ⁱ 2* ⟦ b ⇓⟧⁺ loop⁺ : ∀ x b → x ^ᵇ⁺ b ≈ x ^ⁱ ⟦ b ⇓⟧⁺ even x b = begin (x ∙ x) ^ᵇ⁺ b ≈⟨ loop⁺ (x ∙ x) b ⟩ (x ∙ x) ^ⁱ ⟦ b ⇓⟧⁺ ≈⟨ ∙-^ⁱ-dist x x ⟦ b ⇓⟧⁺ ⟩ x ^ⁱ ⟦ b ⇓⟧⁺ ∙ x ^ⁱ ⟦ b ⇓⟧⁺ ≈⟨ sym (^ⁱ-homo x ⟦ b ⇓⟧⁺ ⟦ b ⇓⟧⁺) ⟩ x ^ⁱ 2* ⟦ b ⇓⟧⁺ ∎ loop⁺ x 𝕓1ᵇ = sym (identityʳ x) loop⁺ x (b 0ᵇ) = even x b loop⁺ x (b 1ᵇ) = ∙-congˡ (even x b) loop : ∀ x b → x ^ᵇ b ≈ x ^ⁱ ⟦ b ⇓⟧ loop x 𝕓0ᵇ = refl loop x (+ b) = loop⁺ x b ^-homo : ∀ x n m → x ^ (n + m) ≈ x ^ n ∙ x ^ m ^-homo x n m = begin x ^ (n + m) ≈⟨ x^n≈x^ⁱn x (n + m) ⟩ x ^ⁱ (n + m) ≈⟨ ^ⁱ-homo x n m ⟩ x ^ⁱ n ∙ x ^ⁱ m ≈⟨ ∙-cong (sym (x^n≈x^ⁱn x n)) (sym (x^n≈x^ⁱn x m)) ⟩ x ^ n ∙ x ^ m ∎ x^n≈x^⁺n : ∀ x n → x ^ ⟅ n ⇓⟆ ≈ x ^⁺ n x^n≈x^⁺n x (ℕ+ n) = refl ^-^⁺-homo : ∀ x n m → x ^ (n + ⟅ m ⇓⟆) ≈ x ^ n ∙ x ^⁺ m ^-^⁺-homo x n (ℕ+ m) = ^-homo x n (suc m)
{ "alphanum_fraction": 0.459092533, "avg_line_length": 30.4239130435, "ext": "agda", "hexsha": "e22f1821f0125cf31d31849138b8d8399bf76f83", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Exponentiation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Exponentiation.agda", "max_line_length": 96, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Exponentiation.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 1797, "size": 2799 }
{-# OPTIONS --cubical --safe --postfix-projections --guardedness #-} open import Algebra open import Prelude open import Relation.Binary open import WellFounded open import Algebra.Monus open import Data.Maybe module Control.Comonad.IntervalHeap {s} (mon : TMAPOM s) (wf : WellFounded (TMAPOM._<_ mon)) (cancel : Cancellativeˡ (TMAPOM._∙_ mon)) where open TMAPOM mon mutual record Heap (A : Type a) : Type (s ℓ⊔ a) where inductive; constructor _◃_ field hd : A tl : Next A record Next {a} (A : Type a) : Type (s ℓ⊔ a) where coinductive; constructor ⟪_⟫ field next : Span A data Span {a} (A : Type a) : Type (s ℓ⊔ a) where [] : Span A until : (s : 𝑆) → (s≢ε : s ≢ ε) → (xs : Heap A) → Span A open Heap public open Next public State : Type a → Type _ State A = 𝑆 → A × 𝑆 pop′ : (s : 𝑆) → Acc _<_ s → Heap A → A × 𝑆 pop′ s₂ a xs with xs .tl .next pop′ s₂ a xs | [] = xs .hd , ε pop′ s₂ a xs | until s₁ s₁≢ε ys with s₁ ≤? s₂ pop′ s₂ a xs | until s₁ s₁≢ε ys | no s₁≰s₂ = xs .hd , fst (<⇒≤ s₁≰s₂) pop′ s₂ (acc wf) xs | until s₁ s₁≢ε ys | yes (k₁ , s₂≡s₁∙k₁) = pop′ k₁ (wf k₁ lemma) ys where lemma : k₁ < s₂ lemma (k₂ , k₁≡s₂∙k₂) = s₁≢ε (zeroSumFree s₁ k₂ (sym (cancel k₁ _ _ p))) where p : k₁ ∙ ε ≡ k₁ ∙ (s₁ ∙ k₂) p = ∙ε k₁ ; k₁≡s₂∙k₂ ; cong (_∙ k₂) s₂≡s₁∙k₁ ; cong (_∙ k₂) (comm s₁ k₁) ; assoc k₁ s₁ k₂ pop : Heap A → State A pop xs s = pop′ s (wf s) xs mutual stepFrom : State A → (s : 𝑆) → Dec (s ≡ ε) → Span A stepFrom f s (yes p) = [] stepFrom f s (no ¬p) = until s ¬p (tabulate (f ∘ (s ∙_))) tabulate : State A → Heap A tabulate f = let x , s = f ε in x ◃ λ where .next → stepFrom f s (s ≟ ε) pop-ε : (xs : Heap A) (a : Acc _<_ ε) → pop′ ε a xs .fst ≡ xs .hd pop-ε xs _ with xs .tl .next pop-ε xs _ | [] = refl pop-ε xs _ | until s s≢ε ys with s ≤? ε pop-ε xs _ | until s s≢ε ys | no s≰ε = refl pop-ε xs _ | until s s≢ε ys | yes s≤ε = ⊥-elim (s≢ε (antisym s≤ε (positive s))) -- slide : Heap A → Heap A -- slide xs with xs .tl .next -- slide xs | [] = xs -- slide xs | [] = [] -- pop-tl : ∀ (x : A) s₁ (s₁≢ε : s₁ ≢ ε) xs s₂ → pop (x ◃ ⟪ until s₁ s₁≢ε xs ⟫) (s₁ ∙ s₂) ≡ pop xs s₂ -- pop-tl x s₁ s₁≢ε xs s₂ with s₁ ≤? (s₁ ∙ s₂) -- pop-tl x s₁ s₁≢ε xs s₂ | no s₁≰s₁∙s₂ = ⊥-elim (s₁≰s₁∙s₂ (s₂ , refl)) -- pop-tl x s₁ s₁≢ε xs s₂ | yes (k , s₁≤s₁∙s₂) = -- let p = cancel s₁ s₂ k s₁≤s₁∙s₂ -- in {!!} ; cong (λ w → pop′ s₂ w xs) (isPropAcc {!!} (wf s₂)) -- seg-leftInv′ : (x : Heap A) → tabulate (pop x) ≡ x -- seg-leftInv′ x = {!!} -- mutual -- seg-leftInv′ : (xs : Heap A) → stepFrom (pop xs) (pop xs ε .snd) (pop xs ε .snd ≟ ε) ≡ xs .tl .next -- seg-leftInv′ (x ◃ xs) with pop (x ◃ xs) ε .snd ≟ ε -- seg-leftInv′ (x ◃ xs) | yes s≡ε = {!!} -- seg-leftInv′ (x ◃ xs) | no s≢ε = {!!} -- seg-leftInv : (x : Heap A) → tabulate (pop x) ≡ x -- seg-leftInv (x ◃ xs) i .hd = pop-ε (x ◃ xs) (wf ε) i -- seg-leftInv (x ◃ xs) i .tl .next = seg-leftInv′ (x ◃ xs) i -- state-iso : Heap A ⇔ State A -- state-iso .fun = pop -- state-iso .inv = tabulate -- state-iso .rightInv = {!!} -- state-iso .leftInv = {!!}
{ "alphanum_fraction": 0.5495987159, "avg_line_length": 30.8415841584, "ext": "agda", "hexsha": "7c93b93f4bda6a98141cc8fd48f41532e4269051", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Control/Comonad/IntervalHeap.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Control/Comonad/IntervalHeap.agda", "max_line_length": 104, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Control/Comonad/IntervalHeap.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 1421, "size": 3115 }
------------------------------------------------------------------------------ -- First-order logic ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOL.README where ------------------------------------------------------------------------------ -- Description -- Formalization of first-order logic using Agda's inductive notions. ------------------------------------------------------------------------------ -- Definition of the connectives and quantifiers open import FOL.Base -- Propositional logic theorems open import FOL.ExclusiveDisjunction.TheoremsATP open import FOL.ExclusiveDisjunction.TheoremsI open import FOL.PropositionalLogic.TheoremsATP open import FOL.PropositionalLogic.TheoremsI -- First-order logic theorems open import FOL.TheoremsATP open import FOL.TheoremsI -- Logical schemata open import FOL.SchemataATP -- Non-empty domains open import FOL.NonEmptyDomain.TheoremsATP open import FOL.NonEmptyDomain.TheoremsI -- Non-intuitionistic logic theorems open import FOL.NonIntuitionistic.TheoremsATP open import FOL.NonIntuitionistic.TheoremsI
{ "alphanum_fraction": 0.5772230889, "avg_line_length": 31.2682926829, "ext": "agda", "hexsha": "05e3d8a76afbd7abe5a8df9066711549f0d60e52", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOL/README.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOL/README.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOL/README.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 257, "size": 1282 }
{-# OPTIONS --without-K #-} module NTypes.Contractible where open import Equivalence open import Types isContr : ∀ {a} → Set a → Set _ isContr A = Σ A λ x → (y : A) → x ≡ y contr→eq-⊤ : ∀ {a} {A : Set a} → isContr A → A ≃ ⊤ contr→eq-⊤ h = (λ _ → _) , ((λ _ → π₁ h) , λ _ → refl) , ((λ _ → π₁ h) , π₂ h) eq-⊤→contr : ∀ {a} {A : Set a} → A ≃ ⊤ → isContr A eq-⊤→contr (f , (g , α) , (h , β)) = h _ , β pp-space-contr : ∀ {a} {A : Set a} (x : A) → isContr (Σ A λ y → x ≡ y) pp-space-contr {A = A} x = (x , refl) , λ y → J (λ x y p → Id (Σ A (λ y → x ≡ y)) (x , refl) (y , p)) (λ _ → refl) _ _ (π₂ y)
{ "alphanum_fraction": 0.4592, "avg_line_length": 24.0384615385, "ext": "agda", "hexsha": "805ec56f6d9a3442ae1dd3c56f88dc48b64d7098", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_path": "src/NTypes/Contractible.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_path": "src/NTypes/Contractible.agda", "max_line_length": 59, "max_stars_count": null, "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_path": "src/NTypes/Contractible.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 296, "size": 625 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.NatMinusOne.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Univalence open import Cubical.Data.Nat open import Cubical.Data.NatMinusOne.Base open import Cubical.Reflection.StrictEquiv -1+Path : ℕ ≡ ℕ₋₁ -1+Path = ua e where unquoteDecl e = declStrictEquiv e -1+_ 1+_
{ "alphanum_fraction": 0.7711442786, "avg_line_length": 28.7142857143, "ext": "agda", "hexsha": "f89c3bb03dfbf4684de198531ea9227b13f422dc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Data/NatMinusOne/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Data/NatMinusOne/Properties.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Data/NatMinusOne/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 120, "size": 402 }
{- Delay operator. -} module TemporalOps.Delay where open import CategoryTheory.Categories open import CategoryTheory.Instances.Reactive open import CategoryTheory.Functor open import CategoryTheory.CartesianStrength open import TemporalOps.Common open import TemporalOps.Next open import Data.Nat.Properties using (+-identityʳ ; +-comm ; +-assoc ; +-suc) open import Relation.Binary.HeterogeneousEquality as ≅ using (_≅_ ; ≅-to-≡) import Relation.Binary.PropositionalEquality as ≡ open import Data.Product open import Data.Sum -- General iteration -- iter f n v = fⁿ(v) iter : (τ -> τ) -> ℕ -> τ -> τ iter F zero A = A iter F (suc n) A = F (iter F n A) -- Multi-step delay delay_by_ : τ -> ℕ -> τ delay A by zero = A delay A by suc n = ▹ (delay A by n) infix 67 delay_by_ -- || Lemmas for the delay operator -- Extra delay is cancelled out by extra waiting. delay-+ : ∀{A} -> (n l k : ℕ) -> delay A by (n + l) at (n + k) ≡ delay A by l at k delay-+ zero l k = refl delay-+ (suc n) = delay-+ n -- || Derived lemmas - they can all be expressed in terms of delay-+, -- || but they are given explicitly for simplicity. -- Delay by n is cancelled out by waiting n extra steps. delay-+-left0 : ∀{A} -> (n k : ℕ) -> delay A by n at (n + k) ≡ A at k delay-+-left0 zero k = refl delay-+-left0 (suc n) k = delay-+-left0 n k -- delay-+-left0 can be converted to delay-+ (heterogeneously). delay-+-left0-eq : ∀{A : τ} -> (n l : ℕ) -> Proof-≡ (delay-+-left0 {A} n l) (delay-+ {A} n 0 l) delay-+-left0-eq zero l v v′ pf = ≅-to-≡ pf delay-+-left0-eq (suc n) l = delay-+-left0-eq n l -- Extra delay by n steps is cancelled out by waiting for n steps. delay-+-right0 : ∀{A} -> (n l : ℕ) -> delay A by (n + l) at n ≡ delay A by l at 0 delay-+-right0 zero l = refl delay-+-right0 (suc n) l = delay-+-right0 n l -- Delaying by n is the same as delaying by (n + 0) delay-+0-left : ∀{A} -> (k n : ℕ) -> delay A by k at n ≡ delay A by (k + 0) at n delay-+0-left {A} k n rewrite +-identityʳ k = refl -- If the delay is greater than the wait amount, we get unit delay-⊤ : ∀{A} -> (n k : ℕ) -> ⊤ at n ≡ delay A by (n + suc k) at n delay-⊤ {A} n k = sym (delay-+-right0 n (suc k)) -- Associativity of arguments in the delay lemma delay-assoc-sym : ∀{A} (n k l j : ℕ) -> Proof-≅ (sym (delay-+ {A} n (k + l) (k + j))) (sym (delay-+ {A} (n + k) l j)) delay-assoc-sym zero zero l j v v′ pr = pr delay-assoc-sym zero (suc k) l j = delay-assoc-sym zero k l j delay-assoc-sym (suc n) k l j = delay-assoc-sym n k l j -- Functor instance for delay F-delay : ℕ -> Endofunctor ℝeactive F-delay k = record { omap = delay_by k ; fmap = fmap-delay k ; fmap-id = λ {_ n a} -> fmap-delay-id k {_} {n} {a} ; fmap-∘ = fmap-delay-∘ k ; fmap-cong = fmap-delay-cong k } where -- Lifting of delay fmap-delay : {A B : τ} -> (k : ℕ) -> A ⇴ B -> delay A by k ⇴ delay B by k fmap-delay zero f = f fmap-delay (suc k) f = Functor.fmap F-▹ (fmap-delay k f) -- Delay preserves identities fmap-delay-id : ∀ (k : ℕ) {A : τ} {n : ℕ} {a : (delay A by k) n} -> (fmap-delay k id at n) a ≡ a fmap-delay-id zero = refl fmap-delay-id (suc k) {A} {zero} = refl fmap-delay-id (suc k) {A} {suc n} = fmap-delay-id k {A} {n} -- Delay preserves composition fmap-delay-∘ : ∀ (k : ℕ) {A B C : τ} {g : B ⇴ C} {f : A ⇴ B} {n : ℕ} {a : (delay A by k) n} -> (fmap-delay k (g ∘ f) at n) a ≡ (fmap-delay k g ∘ fmap-delay k f at n) a fmap-delay-∘ zero = refl fmap-delay-∘ (suc k) {n = zero} = refl fmap-delay-∘ (suc k) {n = suc n} = fmap-delay-∘ k {n = n} -- Delay is congruent fmap-delay-cong : ∀ (k : ℕ) {A B : τ} {f f′ : A ⇴ B} -> ({n : ℕ} {a : A at n} -> f n a ≡ f′ n a) -> ({n : ℕ} {a : delay A by k at n} -> (fmap-delay k f at n) a ≡ (fmap-delay k f′ at n) a) fmap-delay-cong zero e = e fmap-delay-cong (suc k) e {zero} = refl fmap-delay-cong (suc k) e {suc n} = fmap-delay-cong k e -- || Lemmas for the interaction of fmap and delay-+ -- Lifted version of the delay-+ lemma -- Arguments have different types, so we need heterogeneous equality fmap-delay-+ : ∀ {A B : τ} {f : A ⇴ B} (n k l : ℕ) -> Fun-≅ (Functor.fmap (F-delay (n + k)) f at (n + l)) (Functor.fmap (F-delay k) f at l) fmap-delay-+ zero k l v .v ≅.refl = ≅.refl fmap-delay-+ (suc n) k l v v′ pf = fmap-delay-+ n k l v v′ pf -- Specialised version with v of type delay A by (n + k) at (n + l) -- Uses explicit rewrites and homogeneous equality fmap-delay-+-n+k : ∀ {A B : τ} {f : A ⇴ B} (n k l : ℕ) -> (v : delay A by (n + k) at (n + l)) -> rew (delay-+ n k l) ((Functor.fmap (F-delay (n + k)) f at (n + l)) v) ≡ (Functor.fmap (F-delay k) f at l) (rew (delay-+ n k l) v) fmap-delay-+-n+k {A} n k l v = ≅-to-rew-≡ (fmap-delay-+ n k l v v′ v≅v′) (delay-+ n k l) where v′ : delay A by k at l v′ = rew (delay-+ n k l) v v≅v′ : v ≅ v′ v≅v′ = rew-to-≅ (delay-+ n k l) -- Lifted delay lemma with delay-+-left0 fmap-delay-+-n+0 : ∀ {A B : τ} {f : A ⇴ B} (n l : ℕ) -> {v : delay A by n at (n + l)} -> rew (delay-+-left0 n l) ((Functor.fmap (F-delay n) f at (n + l)) v) ≡ f l (rew (delay-+-left0 n l) v) fmap-delay-+-n+0 {A} zero l = refl fmap-delay-+-n+0 {A} (suc n) l = fmap-delay-+-n+0 n l -- Specialised version with v of type delay A by k at l -- Uses explicit rewrites and homogeneous equality fmap-delay-+-k : ∀ {A B : τ} {f : A ⇴ B} (n k l : ℕ) ->(v : delay A by k at l) -> Functor.fmap (F-delay (n + k)) f (n + l) (rew (sym (delay-+ n k l)) v) ≡ rew (sym (delay-+ n k l)) (Functor.fmap (F-delay k) f l v) fmap-delay-+-k {A} {B} {f} n k l v = sym (≅-to-rew-≡ (≅.sym (fmap-delay-+ n k l v′ v v≅v′)) (sym (delay-+ n k l))) where v′ : delay A by (n + k) at (n + l) v′ = rew (sym (delay-+ n k l)) v v≅v′ : v′ ≅ v v≅v′ = ≅.sym (rew-to-≅ (sym (delay-+ n k l))) -- Delay is a Cartesian functor F-cart-delay : ∀ k -> CartesianFunctor (F-delay k) ℝeactive-cart ℝeactive-cart F-cart-delay k = record { u = u-delay k ; m = m-delay k ; m-nat₁ = m-nat₁-delay k ; m-nat₂ = m-nat₂-delay k ; associative = assoc-delay k ; unital-right = unit-right-delay k ; unital-left = λ {B} {n} {a} -> unit-left-delay k {B} {n} {a} } where open CartesianFunctor F-cart-▹ u-delay : ∀ k -> ⊤ ⇴ delay ⊤ by k u-delay zero = λ n _ → top.tt u-delay (suc k) zero top.tt = top.tt u-delay (suc k) (suc n) top.tt = u-delay k n top.tt m-delay : ∀ k (A B : τ) -> (delay A by k ⊗ delay B by k) ⇴ delay (A ⊗ B) by k m-delay zero A B = λ n x → x m-delay (suc k) A B = Functor.fmap F-▹ (m-delay k A B) ∘ m (delay A by k) (delay B by k) m-nat₁-delay : ∀ k {A B C : τ} (f : A ⇴ B) -> Functor.fmap (F-delay k) (f * id) ∘ m-delay k A C ≈ m-delay k B C ∘ Functor.fmap (F-delay k) f * id m-nat₁-delay zero f = refl m-nat₁-delay (suc k) f {zero} = refl m-nat₁-delay (suc k) f {suc n} = m-nat₁-delay k f m-nat₂-delay : ∀ k {A B C : τ} (f : A ⇴ B) -> Functor.fmap (F-delay k) (id * f) ∘ m-delay k C A ≈ m-delay k C B ∘ id * Functor.fmap (F-delay k) f m-nat₂-delay zero f = refl m-nat₂-delay (suc k) f {zero} = refl m-nat₂-delay (suc k) f {suc n} = m-nat₂-delay k f assoc-delay : ∀ k {A B C : τ} -> m-delay k A (B ⊗ C) ∘ id * m-delay k B C ∘ assoc-right ≈ Functor.fmap (F-delay k) assoc-right ∘ m-delay k (A ⊗ B) C ∘ m-delay k A B * id assoc-delay zero = refl assoc-delay (suc k) {A} {B} {C} {zero} = refl assoc-delay (suc k) {A} {B} {C} {suc n} = assoc-delay k unit-right-delay : ∀ k {A : τ} -> Functor.fmap (F-delay k) unit-right ∘ m-delay k A ⊤ ∘ (id * u-delay k) ≈ unit-right unit-right-delay zero {A} {n} = refl unit-right-delay (suc k) {A} {zero} = refl unit-right-delay (suc k) {A} {suc n} = unit-right-delay k unit-left-delay : ∀ k {B : τ} -> Functor.fmap (F-delay k) unit-left ∘ m-delay k ⊤ B ∘ (u-delay k * id) ≈ unit-left unit-left-delay zero = refl unit-left-delay (suc k) {B} {zero} = refl unit-left-delay (suc k) {B} {suc n} = unit-left-delay k m-delay-+-n+0 : ∀ {A B} k l {a b} -> (rew (delay-+-left0 k l) (CartesianFunctor.m (F-cart-delay k) A B (k + l) (a , b))) ≡ (rew (delay-+-left0 k l) a , rew (delay-+-left0 k l) b) m-delay-+-n+0 zero l = refl m-delay-+-n+0 (suc k) l = m-delay-+-n+0 k l m-delay-+-sym : ∀ {A B} k l m{a b} -> rew (sym (delay-+ k m l)) (CartesianFunctor.m (F-cart-delay m) A B l (a , b)) ≡ CartesianFunctor.m (F-cart-delay (k + m)) A B (k + l) ((rew (sym (delay-+ k m l)) a) , (rew (sym (delay-+ k m l)) b)) m-delay-+-sym zero l m = refl m-delay-+-sym (suc k) l m = m-delay-+-sym k l m
{ "alphanum_fraction": 0.5362779483, "avg_line_length": 39.1587982833, "ext": "agda", "hexsha": "31b1ef007ea97811c8be9e7d1dd1dd7cb4bea132", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/TemporalOps/Delay.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/TemporalOps/Delay.agda", "max_line_length": 95, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/TemporalOps/Delay.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 3460, "size": 9124 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Truncation.Properties where open import Cubical.Data.NatMinusOne open import Cubical.HITs.Truncation.Base open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.HLevels open import Cubical.Foundations.Univalence open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.Equiv.PathSplit open isPathSplitEquiv open import Cubical.Modalities.Modality open Modality open import Cubical.Data.Empty.Base as ⊥ renaming (rec to ⊥rec ; elim to ⊥elim) open import Cubical.Data.Nat hiding (elim) open import Cubical.Data.Sigma open import Cubical.Data.Bool open import Cubical.Data.Unit open import Cubical.HITs.Sn.Base open import Cubical.HITs.S1 open import Cubical.HITs.Susp open import Cubical.HITs.Nullification as Null hiding (rec; elim) open import Cubical.HITs.PropositionalTruncation as PropTrunc renaming (∥_∥ to ∥_∥₁; ∣_∣ to ∣_∣₁; squash to squash₁) using () open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₂; ∣_∣₂; squash₂) open import Cubical.HITs.GroupoidTruncation as GpdTrunc using (∥_∥₃; ∣_∣₃; squash₃) open import Cubical.HITs.2GroupoidTruncation as 2GpdTrunc using (∥_∥₄; ∣_∣₄; squash₄) private variable ℓ ℓ' : Level A : Type ℓ B : Type ℓ' sphereFill : (n : ℕ) (f : S₊ n → A) → Type _ sphereFill {A = A} n f = Σ[ top ∈ A ] ((x : S₊ n) → top ≡ f x) isSphereFilled : ℕ → Type ℓ → Type ℓ isSphereFilled n A = (f : S₊ n → A) → sphereFill n f isSphereFilled∥∥ : {n : ℕ} → isSphereFilled n (HubAndSpoke A n) isSphereFilled∥∥ f = (hub f) , (spoke f) isSphereFilled→isOfHLevel : (n : ℕ) → isSphereFilled n A → isOfHLevel (suc n) A isSphereFilled→isOfHLevel {A = A} zero h x y = sym (snd (h f) true) ∙ snd (h f) false where f : Bool → A f true = x f false = y isSphereFilled→isOfHLevel {A = A} (suc zero) h x y = J (λ y q → (p : x ≡ y) → q ≡ p) (helper x) where helper : (x : A) (p : x ≡ x) → refl ≡ p helper x p i j = hcomp (λ k → λ { (i = i0) → h S¹→A .snd base k ; (i = i1) → p j ; (j = i0) → h S¹→A .snd base (i ∨ k) ; (j = i1) → h S¹→A .snd base (i ∨ k)}) (h S¹→A .snd (loop j) i) where S¹→A : S¹ → A S¹→A base = x S¹→A (loop i) = p i isSphereFilled→isOfHLevel {A = A} (suc (suc n)) h x y = isSphereFilled→isOfHLevel (suc n) (helper h x y) where helper : {n : ℕ} → isSphereFilled (suc (suc n)) A → (x y : A) → isSphereFilled (suc n) (x ≡ y) helper {n = n} h x y f = sym (snd (h f') north) ∙ (snd (h f') south) , r where f' : Susp (S₊ (suc n)) → A f' north = x f' south = y f' (merid u i) = f u i r : (s : S₊ (suc n)) → sym (snd (h f') north) ∙ (snd (h f') south) ≡ f s r s i j = hcomp (λ k → λ { (i = i1) → snd (h f') (merid s j) k ; (j = i0) → snd (h f') north (k ∨ (~ i)) ; (j = i1) → snd (h f') south k }) (snd (h f') north (~ i ∧ ~ j)) isOfHLevel→isSphereFilled : (n : ℕ) → isOfHLevel (suc n) A → isSphereFilled n A isOfHLevel→isSphereFilled zero h f = (f true) , (λ _ → h _ _) isOfHLevel→isSphereFilled {A = A} (suc zero) h f = (f base) , toPropElim (λ _ → h _ _) refl isOfHLevel→isSphereFilled {A = A} (suc (suc n)) h = helper λ x y → isOfHLevel→isSphereFilled (suc n) (h x y) where helper : {n : ℕ} → ((x y : A) → isSphereFilled (suc n) (x ≡ y)) → isSphereFilled (suc (suc n)) A helper {n = n} h f = f north , r where r : (x : S₊ (suc (suc n))) → f north ≡ f x r north = refl r south = h (f north) (f south) (λ x → cong f (merid x)) .fst r (merid x i) j = hcomp (λ k → λ { (i = i0) → f north ; (i = i1) → h (f north) (f south) (λ x → cong f (merid x)) .snd x (~ k) j ; (j = i0) → f north ; (j = i1) → f (merid x i) }) (f (merid x (i ∧ j))) isOfHLevelTrunc : (n : ℕ) → isOfHLevel n (∥ A ∥ n) isOfHLevelTrunc zero = isOfHLevelUnit* 0 isOfHLevelTrunc (suc n) = isSphereFilled→isOfHLevel n isSphereFilled∥∥ rec : {n : HLevel} {B : Type ℓ'} → isOfHLevel (suc n) B → (A → B) → hLevelTrunc (suc n) A → B rec h g ∣ x ∣ = g x rec {n = n} {B = B} hB g (hub f) = isOfHLevel→isSphereFilled n hB (λ x → rec hB g (f x)) .fst rec {n = n} hB g (spoke f x i) = isOfHLevel→isSphereFilled n hB (λ x → rec hB g (f x)) .snd x i elim : {n : ℕ} {B : ∥ A ∥ (suc n) → Type ℓ'} (hB : (x : ∥ A ∥ (suc n)) → isOfHLevel (suc n) (B x)) (g : (a : A) → B (∣ a ∣)) (x : ∥ A ∥ (suc n)) → B x elim hB g (∣ a ∣ ) = g a elim {B = B} hB g (hub f) = isOfHLevel→isSphereFilled _ (hB (hub f)) (λ x → subst B (sym (spoke f x)) (elim hB g (f x)) ) .fst elim {B = B} hB g (spoke f x i) = toPathP {A = λ i → B (spoke f x (~ i))} (sym (isOfHLevel→isSphereFilled _ (hB (hub f)) (λ x → subst B (sym (spoke f x)) (elim hB g (f x))) .snd x)) (~ i) elim2 : {n : ℕ} {B : ∥ A ∥ (suc n) → ∥ A ∥ (suc n) → Type ℓ'} (hB : ((x y : ∥ A ∥ (suc n)) → isOfHLevel (suc n) (B x y))) (g : (a b : A) → B ∣ a ∣ ∣ b ∣) (x y : ∥ A ∥ (suc n)) → B x y elim2 {n = n} hB g = elim (λ _ → isOfHLevelΠ (suc n) (λ _ → hB _ _)) λ a → elim (λ _ → hB _ _) (λ b → g a b) elim3 : {n : ℕ} {B : (x y z : ∥ A ∥ (suc n)) → Type ℓ'} (hB : ((x y z : ∥ A ∥ (suc n)) → isOfHLevel (suc n) (B x y z))) (g : (a b c : A) → B (∣ a ∣) ∣ b ∣ ∣ c ∣) (x y z : ∥ A ∥ (suc n)) → B x y z elim3 {n = n} hB g = elim2 (λ _ _ → isOfHLevelΠ (suc n) (hB _ _)) λ a b → elim (λ _ → hB _ _ _) (λ c → g a b c) isContr→isContr∥ : (n : ℕ) → isContr A → isContr (∥ A ∥ n) isContr→isContr∥ zero _ = tt* , (λ _ _ → tt*) isContr→isContr∥ (suc n) contr = ∣ fst contr ∣ , (elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) (λ a i → ∣ snd contr a i ∣)) isOfHLevelMin→isOfHLevel : {n m : ℕ} → isOfHLevel (min n m) A → isOfHLevel n A × isOfHLevel m A isOfHLevelMin→isOfHLevel {n = zero} {m = m} h = h , isContr→isOfHLevel m h isOfHLevelMin→isOfHLevel {n = suc n} {m = zero} h = (isContr→isOfHLevel (suc n) h) , h isOfHLevelMin→isOfHLevel {A = A} {n = suc n} {m = suc m} h = subst (λ x → isOfHLevel x A) (helper n m) (isOfHLevelPlus (suc n ∸ (suc (min n m))) h) , subst (λ x → isOfHLevel x A) ((λ i → m ∸ (minComm n m i) + suc (minComm n m i)) ∙ helper m n) (isOfHLevelPlus (suc m ∸ (suc (min n m))) h) where helper : (n m : ℕ) → n ∸ min n m + suc (min n m) ≡ suc n helper zero zero = refl helper zero (suc m) = refl helper (suc n) zero = cong suc (+-comm n 1) helper (suc n) (suc m) = +-suc _ _ ∙ cong suc (helper n m) ΣTruncElim : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {n m : ℕ} {B : (x : ∥ A ∥ (suc n)) → Type ℓ'} {C : (Σ[ a ∈ (∥ A ∥ (suc n)) ] (∥ B a ∥ (suc m))) → Type ℓ''} → ((x : (Σ[ a ∈ (∥ A ∥ (suc n)) ] (∥ B a ∥ (suc m)))) → isOfHLevel (min (suc n) (suc m)) (C x)) → ((a : A) (b : B (∣ a ∣)) → C (∣ a ∣ , ∣ b ∣)) → (x : (Σ[ a ∈ (∥ A ∥ (suc n)) ] (∥ B a ∥ (suc m)))) → (C x) ΣTruncElim {n = n} {m = m} {B = B} {C = C} hB g (a , b) = elim {B = λ a → (b : (∥ B a ∥ (suc m))) → C (a , b)} (λ x → isOfHLevelΠ (suc n) λ b → isOfHLevelMin→isOfHLevel (hB (x , b)) .fst ) (λ a → elim (λ _ → isOfHLevelMin→isOfHLevel (hB (∣ a ∣ , _)) .snd) λ b → g a b) a b truncIdempotentIso : (n : ℕ) → isOfHLevel n A → Iso (∥ A ∥ n) A truncIdempotentIso zero hA = isContr→Iso (isOfHLevelUnit* 0) hA Iso.fun (truncIdempotentIso (suc n) hA) = rec hA λ a → a Iso.inv (truncIdempotentIso (suc n) hA) = ∣_∣ Iso.rightInv (truncIdempotentIso (suc n) hA) _ = refl Iso.leftInv (truncIdempotentIso (suc n) hA) = elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ _ → refl truncIdempotent≃ : (n : ℕ) → isOfHLevel n A → ∥ A ∥ n ≃ A truncIdempotent≃ n hA = isoToEquiv (truncIdempotentIso n hA) truncIdempotent : (n : ℕ) → isOfHLevel n A → ∥ A ∥ n ≡ A truncIdempotent n hA = ua (truncIdempotent≃ n hA) HLevelTruncModality : ∀ {ℓ} (n : HLevel) → Modality ℓ isModal (HLevelTruncModality n) = isOfHLevel n isModalIsProp (HLevelTruncModality n) = isPropIsOfHLevel n ◯ (HLevelTruncModality n) = hLevelTrunc n ◯-isModal (HLevelTruncModality n) = isOfHLevelTrunc n η (HLevelTruncModality zero) _ = tt* η (HLevelTruncModality (suc n)) = ∣_∣ ◯-elim (HLevelTruncModality zero) cB _ tt* = cB tt* .fst ◯-elim (HLevelTruncModality (suc n)) = elim ◯-elim-β (HLevelTruncModality zero) cB f a = cB tt* .snd (f a) ◯-elim-β (HLevelTruncModality (suc n)) = λ _ _ _ → refl ◯-=-isModal (HLevelTruncModality zero) x y = (isOfHLevelUnit* 1 x y) , (isOfHLevelUnit* 2 x y _) ◯-=-isModal (HLevelTruncModality (suc n)) = isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) -- universal property univTrunc : ∀ {ℓ} (n : HLevel) {B : TypeOfHLevel ℓ n} → Iso (hLevelTrunc n A → B .fst) (A → B .fst) univTrunc zero {B , lev} = isContr→Iso (isOfHLevelΠ 0 (λ _ → lev)) (isOfHLevelΠ 0 λ _ → lev) Iso.fun (univTrunc (suc n) {B , lev}) g a = g ∣ a ∣ Iso.inv (univTrunc (suc n) {B , lev}) = rec lev Iso.rightInv (univTrunc (suc n) {B , lev}) b = refl Iso.leftInv (univTrunc (suc n) {B , lev}) b = funExt (elim (λ x → isOfHLevelPath _ lev _ _) λ a → refl) -- functorial action map : {n : HLevel} {B : Type ℓ'} (g : A → B) → hLevelTrunc n A → hLevelTrunc n B map {n = zero} g = λ _ → tt* map {n = suc n} g = rec (isOfHLevelTrunc _) (λ a → ∣ g a ∣) mapCompIso : {n : HLevel} {B : Type ℓ'} → (Iso A B) → Iso (hLevelTrunc n A) (hLevelTrunc n B) mapCompIso {n = zero} {B} _ = isContr→Iso (isOfHLevelUnit* 0) (isOfHLevelUnit* 0) Iso.fun (mapCompIso {n = (suc n)} g) = map (Iso.fun g) Iso.inv (mapCompIso {n = (suc n)} g) = map (Iso.inv g) Iso.rightInv (mapCompIso {n = (suc n)} g) = elim (λ x → isOfHLevelPath _ (isOfHLevelTrunc _) _ _) λ b → cong ∣_∣ (Iso.rightInv g b) Iso.leftInv (mapCompIso {n = (suc n)} g) = elim (λ x → isOfHLevelPath _ (isOfHLevelTrunc _) _ _) λ a → cong ∣_∣ (Iso.leftInv g a) mapId : {n : HLevel} → ∀ t → map {n = n} (idfun A) t ≡ t mapId {n = 0} tt* = refl mapId {n = (suc n)} = elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) (λ _ → refl) -- equivalences to prop/set/groupoid truncations propTruncTrunc1Iso : Iso ∥ A ∥₁ (∥ A ∥ 1) Iso.fun propTruncTrunc1Iso = PropTrunc.rec (isOfHLevelTrunc 1) ∣_∣ Iso.inv propTruncTrunc1Iso = rec squash₁ ∣_∣₁ Iso.rightInv propTruncTrunc1Iso = elim (λ _ → isOfHLevelPath 1 (isOfHLevelTrunc 1) _ _) (λ _ → refl) Iso.leftInv propTruncTrunc1Iso = PropTrunc.elim (λ _ → isOfHLevelPath 1 squash₁ _ _) (λ _ → refl) propTrunc≃Trunc1 : ∥ A ∥₁ ≃ ∥ A ∥ 1 propTrunc≃Trunc1 = isoToEquiv propTruncTrunc1Iso propTrunc≡Trunc1 : ∥ A ∥₁ ≡ ∥ A ∥ 1 propTrunc≡Trunc1 = ua propTrunc≃Trunc1 setTruncTrunc2Iso : Iso ∥ A ∥₂ (∥ A ∥ 2) Iso.fun setTruncTrunc2Iso = SetTrunc.rec (isOfHLevelTrunc 2) ∣_∣ Iso.inv setTruncTrunc2Iso = rec squash₂ ∣_∣₂ Iso.rightInv setTruncTrunc2Iso = elim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (λ _ → refl) Iso.leftInv setTruncTrunc2Iso = SetTrunc.elim (λ _ → isOfHLevelPath 2 squash₂ _ _) (λ _ → refl) setTrunc≃Trunc2 : ∥ A ∥₂ ≃ ∥ A ∥ 2 setTrunc≃Trunc2 = isoToEquiv setTruncTrunc2Iso propTrunc≡Trunc2 : ∥ A ∥₂ ≡ ∥ A ∥ 2 propTrunc≡Trunc2 = ua setTrunc≃Trunc2 groupoidTruncTrunc3Iso : Iso ∥ A ∥₃ (∥ A ∥ 3) Iso.fun groupoidTruncTrunc3Iso = GpdTrunc.rec (isOfHLevelTrunc 3) ∣_∣ Iso.inv groupoidTruncTrunc3Iso = rec squash₃ ∣_∣₃ Iso.rightInv groupoidTruncTrunc3Iso = elim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) (λ _ → refl) Iso.leftInv groupoidTruncTrunc3Iso = GpdTrunc.elim (λ _ → isOfHLevelPath 3 squash₃ _ _) (λ _ → refl) groupoidTrunc≃Trunc3 : ∥ A ∥₃ ≃ ∥ A ∥ 3 groupoidTrunc≃Trunc3 = isoToEquiv groupoidTruncTrunc3Iso groupoidTrunc≡Trunc3 : ∥ A ∥₃ ≡ ∥ A ∥ 3 groupoidTrunc≡Trunc3 = ua groupoidTrunc≃Trunc3 2GroupoidTruncTrunc4Iso : Iso ∥ A ∥₄ (∥ A ∥ 4) Iso.fun 2GroupoidTruncTrunc4Iso = 2GpdTrunc.rec (isOfHLevelTrunc 4) ∣_∣ Iso.inv 2GroupoidTruncTrunc4Iso = rec squash₄ ∣_∣₄ Iso.rightInv 2GroupoidTruncTrunc4Iso = elim (λ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _) (λ _ → refl) Iso.leftInv 2GroupoidTruncTrunc4Iso = 2GpdTrunc.elim (λ _ → isOfHLevelPath 4 squash₄ _ _) (λ _ → refl) 2GroupoidTrunc≃Trunc4 : ∥ A ∥₄ ≃ ∥ A ∥ 4 2GroupoidTrunc≃Trunc4 = isoToEquiv 2GroupoidTruncTrunc4Iso 2GroupoidTrunc≡Trunc4 : ∥ A ∥₄ ≡ ∥ A ∥ 4 2GroupoidTrunc≡Trunc4 = ua 2GroupoidTrunc≃Trunc4 isContr→isContrTrunc : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A → isContr (hLevelTrunc n A) isContr→isContrTrunc zero contr = isOfHLevelUnit* 0 isContr→isContrTrunc (suc n) contr = ∣ fst contr ∣ , (elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ a → cong ∣_∣ (snd contr a)) truncOfProdIso : (n : ℕ) → Iso (hLevelTrunc n (A × B)) (hLevelTrunc n A × hLevelTrunc n B) truncOfProdIso 0 = isContr→Iso (isOfHLevelUnit* 0) (isOfHLevel× 0 (isOfHLevelUnit* 0) (isOfHLevelUnit* 0)) Iso.fun (truncOfProdIso (suc n)) = rec (isOfHLevelΣ (suc n) (isOfHLevelTrunc (suc n)) (λ _ → isOfHLevelTrunc (suc n))) λ {(a , b) → ∣ a ∣ , ∣ b ∣} Iso.inv (truncOfProdIso (suc n)) (a , b) = rec (isOfHLevelTrunc (suc n)) (λ a → rec (isOfHLevelTrunc (suc n)) (λ b → ∣ a , b ∣) b) a Iso.rightInv (truncOfProdIso (suc n)) (a , b) = elim {B = λ a → Iso.fun (truncOfProdIso (suc n)) (Iso.inv (truncOfProdIso (suc n)) (a , b)) ≡ (a , b)} (λ _ → isOfHLevelPath (suc n) (isOfHLevelΣ (suc n) (isOfHLevelTrunc (suc n)) (λ _ → isOfHLevelTrunc (suc n))) _ _) (λ a → elim {B = λ b → Iso.fun (truncOfProdIso (suc n)) (Iso.inv (truncOfProdIso (suc n)) (∣ a ∣ , b)) ≡ (∣ a ∣ , b)} (λ _ → isOfHLevelPath (suc n) (isOfHLevelΣ (suc n) (isOfHLevelTrunc (suc n)) (λ _ → isOfHLevelTrunc (suc n))) _ _) (λ b → refl) b) a Iso.leftInv (truncOfProdIso (suc n)) = elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ a → refl ---- ∥ Ω A ∥ ₙ ≡ Ω ∥ A ∥ₙ₊₁ ---- {- Proofs of Theorem 7.3.12. and Corollary 7.3.13. in the HoTT book -} module ΩTrunc {X : Type ℓ} {n : HLevel} where {- We define the fibration P to show a more general result -} P : ∥ X ∥ (2 + n) → ∥ X ∥ (2 + n) → Type ℓ P x y = elim2 (λ _ _ → isOfHLevelTypeOfHLevel (suc n)) (λ a b → ∥ a ≡ b ∥ (suc n) , isOfHLevelTrunc (suc n)) x y .fst {- We will need P to be of hLevel n + 3 -} hLevelP : (a b : ∥ X ∥ (2 + n)) → isOfHLevel (2 + n) (P a b) hLevelP = elim2 (λ x y → isProp→isOfHLevelSuc (suc n) (isPropIsOfHLevel (2 + n))) (λ a b → isOfHLevelSuc (suc n) (isOfHLevelTrunc (suc n))) {- decode function from P x y to x ≡ y -} decode-fun : (x y : ∥ X ∥ (2 + n)) → P x y → x ≡ y decode-fun = elim2 (λ u v → isOfHLevelΠ (2 + n)(λ _ → isOfHLevelSuc (2 + n) (isOfHLevelTrunc (2 + n)) u v)) decode* where decode* : (u v : X) → P ∣ u ∣ ∣ v ∣ → Path (∥ X ∥ (2 + n)) ∣ u ∣ ∣ v ∣ decode* u v = rec (isOfHLevelTrunc (2 + n) ∣ u ∣ ∣ v ∣) (cong ∣_∣) {- auxiliary function r used to define encode -} r : (u : ∥ X ∥ (2 + n)) → P u u r = elim (λ x → hLevelP x x) (λ a → ∣ refl ∣) {- encode function from x ≡ y to P x y -} encode-fun : (x y : ∥ X ∥ (2 + n)) → x ≡ y → P x y encode-fun x y p = subst (P x) p (r x) {- We need the following two lemmas on the functions behaviour for refl -} dec-refl : (x : ∥ X ∥ (2 + n)) → decode-fun x x (r x) ≡ refl dec-refl = elim (λ x → isOfHLevelSuc (1 + n) (isOfHLevelSuc (1 + n) (isOfHLevelTrunc (2 + n) x x) (decode-fun x x (r x)) refl)) (λ _ → refl) enc-refl : (x : ∥ X ∥ (2 + n)) → encode-fun x x refl ≡ r x enc-refl x = transportRefl (r x) {- decode-fun is a right-inverse -} P-rinv : (u v : ∥ X ∥ (2 + n)) (x : Path (∥ X ∥ (2 + n)) u v) → decode-fun u v (encode-fun u v x) ≡ x P-rinv u v = J (λ y p → decode-fun u y (encode-fun u y p) ≡ p) (cong (decode-fun u u) (enc-refl u) ∙ dec-refl u) {- decode-fun is a left-inverse -} P-linv : (u v : ∥ X ∥ (2 + n)) (x : P u v) → encode-fun u v (decode-fun u v x) ≡ x P-linv = elim2 (λ x y → isOfHLevelΠ (2 + n) (λ z → isOfHLevelSuc (2 + n) (hLevelP x y) _ _)) helper where helper : (a b : X) (p : P ∣ a ∣ ∣ b ∣) → encode-fun _ _ (decode-fun ∣ a ∣ ∣ b ∣ p) ≡ p helper a b = elim (λ x → hLevelP ∣ a ∣ ∣ b ∣ _ _) (J (λ y p → encode-fun ∣ a ∣ ∣ y ∣ (decode-fun _ _ ∣ p ∣) ≡ ∣ p ∣) (enc-refl ∣ a ∣)) {- The final Iso established -} IsoFinal : (x y : ∥ X ∥ (2 + n)) → Iso (x ≡ y) (P x y) Iso.fun (IsoFinal x y) = encode-fun x y Iso.inv (IsoFinal x y) = decode-fun x y Iso.rightInv (IsoFinal x y) = P-linv x y Iso.leftInv (IsoFinal x y) = P-rinv x y PathIdTruncIso : {a b : A} (n : HLevel) → Iso (Path (∥ A ∥ (suc n)) ∣ a ∣ ∣ b ∣) (∥ a ≡ b ∥ n) PathIdTruncIso zero = isContr→Iso ((isOfHLevelTrunc 1 _ _) , isOfHLevelPath 1 (isOfHLevelTrunc 1) ∣ _ ∣ ∣ _ ∣ _) (isOfHLevelUnit* 0) PathIdTruncIso (suc n) = ΩTrunc.IsoFinal ∣ _ ∣ ∣ _ ∣ PathIdTrunc : {a b : A} (n : HLevel) → (Path (∥ A ∥ (suc n)) ∣ a ∣ ∣ b ∣) ≡ (∥ a ≡ b ∥ n) PathIdTrunc n = isoToPath (PathIdTruncIso n) PathΩ : {a : A} (n : HLevel) → (Path (∥ A ∥ (suc n)) ∣ a ∣ ∣ a ∣) ≡ (∥ a ≡ a ∥ n) PathΩ n = PathIdTrunc n {- Special case using direct defs of truncations -} PathIdTrunc₀Iso : {a b : A} → Iso (∣ a ∣₂ ≡ ∣ b ∣₂) ∥ a ≡ b ∥₁ PathIdTrunc₀Iso = compIso (congIso setTruncTrunc2Iso) (compIso (ΩTrunc.IsoFinal ∣ _ ∣ ∣ _ ∣) (invIso propTruncTrunc1Iso)) ------------------------- truncOfTruncIso : (n m : HLevel) → Iso (hLevelTrunc n A) (hLevelTrunc n (hLevelTrunc (m + n) A)) truncOfTruncIso zero m = isContr→Iso (isOfHLevelUnit* 0) (isOfHLevelUnit* 0) Iso.fun (truncOfTruncIso (suc n) zero) = rec (isOfHLevelTrunc (suc n)) λ a → ∣ ∣ a ∣ ∣ Iso.fun (truncOfTruncIso (suc n) (suc m)) = rec (isOfHLevelTrunc (suc n)) λ a → ∣ ∣ a ∣ ∣ Iso.inv (truncOfTruncIso (suc n) zero) = rec (isOfHLevelTrunc (suc n)) (rec (isOfHLevelTrunc (suc n)) λ a → ∣ a ∣) Iso.inv (truncOfTruncIso (suc n) (suc m)) = rec (isOfHLevelTrunc (suc n)) (rec (isOfHLevelPlus (suc m) (isOfHLevelTrunc (suc n))) λ a → ∣ a ∣) Iso.rightInv (truncOfTruncIso (suc n) zero) = elim (λ x → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _ ) (elim (λ x → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _ ) λ a → refl) Iso.rightInv (truncOfTruncIso (suc n) (suc m)) = elim (λ x → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _ ) (elim (λ x → isOfHLevelPath ((suc m) + (suc n)) (isOfHLevelPlus (suc m) (isOfHLevelTrunc (suc n))) _ _ ) λ a → refl) Iso.leftInv (truncOfTruncIso (suc n) zero) = elim (λ x → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ a → refl Iso.leftInv (truncOfTruncIso (suc n) (suc m)) = elim (λ x → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ a → refl truncOfTruncEq : (n m : ℕ) → (hLevelTrunc n A) ≃ (hLevelTrunc n (hLevelTrunc (m + n) A)) truncOfTruncEq n m = isoToEquiv (truncOfTruncIso n m) truncOfTruncIso2 : (n m : HLevel) → Iso (hLevelTrunc (m + n) (hLevelTrunc n A)) (hLevelTrunc n A) truncOfTruncIso2 n m = truncIdempotentIso (m + n) (isOfHLevelPlus m (isOfHLevelTrunc n)) truncOfΣIso : ∀ {ℓ ℓ'} (n : HLevel) {A : Type ℓ} {B : A → Type ℓ'} → Iso (hLevelTrunc n (Σ A B)) (hLevelTrunc n (Σ A λ x → hLevelTrunc n (B x))) truncOfΣIso zero = idIso Iso.fun (truncOfΣIso (suc n)) = map λ {(a , b) → a , ∣ b ∣} Iso.inv (truncOfΣIso (suc n)) = rec (isOfHLevelTrunc (suc n)) (uncurry λ a → rec (isOfHLevelTrunc (suc n)) λ b → ∣ a , b ∣) Iso.rightInv (truncOfΣIso (suc n)) = elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) (uncurry λ a → elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ b → refl) Iso.leftInv (truncOfΣIso (suc n)) = elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ {(a , b) → refl}
{ "alphanum_fraction": 0.5617206983, "avg_line_length": 46.5446428571, "ext": "agda", "hexsha": "092e8ccef93699412e372083c163f0f552aa5694", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "21cf7a1c292ea39dac1a0151b70088c36e7f9143", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shlevy/cubical", "max_forks_repo_path": "Cubical/HITs/Truncation/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "21cf7a1c292ea39dac1a0151b70088c36e7f9143", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shlevy/cubical", "max_issues_repo_path": "Cubical/HITs/Truncation/Properties.agda", "max_line_length": 146, "max_stars_count": null, "max_stars_repo_head_hexsha": "21cf7a1c292ea39dac1a0151b70088c36e7f9143", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shlevy/cubical", "max_stars_repo_path": "Cubical/HITs/Truncation/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8840, "size": 20852 }
module GetTypes where open import Level using () renaming (zero to ℓ₀) open import Data.Nat using (ℕ) open import Data.List using (List ; map) open import Data.Vec using (Vec) renaming (map to mapV) open import Function using (_∘_ ; id) open import Relation.Binary.PropositionalEquality using (_≗_) open import Structures using (Shaped ; module Shaped) open import Instances using (VecShaped) module ListList where record Get : Set₁ where field get : {A : Set} → List A → List A free-theorem : {α β : Set} → (f : α → β) → get ∘ map f ≗ map f ∘ get module VecVec where record Get : Set₁ where field getlen : ℕ → ℕ get : {A : Set} {n : ℕ} → Vec A n → Vec A (getlen n) free-theorem : {α β : Set} (f : α → β) {n : ℕ} → get {_} {n} ∘ mapV f ≗ mapV f ∘ get module PartialVecVec where record Get : Set₁ where field I : Set gl₁ : I → ℕ gl₂ : I → ℕ get : {A : Set} {i : I} → Vec A (gl₁ i) → Vec A (gl₂ i) free-theorem : {α β : Set} → (f : α → β) → {i : I} → get {_} {i} ∘ mapV f ≗ mapV f ∘ get VecVec-to-PartialVecVec : VecVec.Get → PartialVecVec.Get VecVec-to-PartialVecVec G = record { I = ℕ ; gl₁ = id ; gl₂ = getlen ; get = get ; free-theorem = free-theorem } where open VecVec.Get G module PartialShapeShape where record Get : Set₁ where field SourceShape : Set SourceContainer : Set → SourceShape → Set SourceShapeT : Shaped SourceShape SourceContainer ViewShape : Set ViewContainer : Set → ViewShape → Set ViewShapeT : Shaped ViewShape ViewContainer I : Set gl₁ : I → SourceShape gl₂ : I → ViewShape open Shaped SourceShapeT using () renaming (fmap to fmapS) open Shaped ViewShapeT using () renaming (fmap to fmapV) field get : {A : Set} {i : I} → SourceContainer A (gl₁ i) → ViewContainer A (gl₂ i) free-theorem : {α β : Set} → (f : α → β) → {i : I} → get {_} {i} ∘ fmapS f ≗ fmapV f ∘ get open Shaped SourceShapeT public using () renaming (fmap to fmapS) open Shaped ViewShapeT public using () renaming (fmap to fmapV) PartialVecVec-to-PartialShapeShape : PartialVecVec.Get → PartialShapeShape.Get PartialVecVec-to-PartialShapeShape G = record { SourceShapeT = VecShaped ; ViewShapeT = VecShaped ; I = I ; gl₁ = gl₁ ; gl₂ = gl₂ ; get = get ; free-theorem = free-theorem } where open PartialVecVec.Get G
{ "alphanum_fraction": 0.6202118989, "avg_line_length": 31.0632911392, "ext": "agda", "hexsha": "83f6845c1dc5f0ae859ce7aa312b6536797d28ed", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jvoigtlaender/bidiragda", "max_forks_repo_path": "GetTypes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jvoigtlaender/bidiragda", "max_issues_repo_path": "GetTypes.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jvoigtlaender/bidiragda", "max_stars_repo_path": "GetTypes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 796, "size": 2454 }
------------------------------------------------------------------------ -- The Agda standard library -- -- An inductive definition of the sublist relation with respect to a -- setoid. This is a generalisation of what is commonly known as Order -- Preserving Embeddings (OPE). ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Setoid; Rel) module Data.List.Relation.Binary.Sublist.Setoid {c ℓ} (S : Setoid c ℓ) where open import Level using (_⊔_) open import Data.List.Base using (List; []; _∷_) import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality import Data.List.Relation.Binary.Sublist.Heterogeneous as Heterogeneous import Data.List.Relation.Binary.Sublist.Heterogeneous.Core as HeterogeneousCore import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties as HeterogeneousProperties open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) open Setoid S renaming (Carrier to A) open SetoidEquality S ------------------------------------------------------------------------ -- Definition infix 4 _⊆_ _⊆_ : Rel (List A) (c ⊔ ℓ) _⊆_ = Heterogeneous.Sublist _≈_ ------------------------------------------------------------------------ -- Re-export definitions and operations from heterogeneous sublists open HeterogeneousCore _≈_ using ([]; _∷_; _∷ʳ_) public open Heterogeneous {R = _≈_} hiding (Sublist; []; _∷_; _∷ʳ_) public renaming (toAny to to∈; fromAny to from∈) ------------------------------------------------------------------------ -- Relational properties holding for Setoid case ⊆-reflexive : _≋_ ⇒ _⊆_ ⊆-reflexive = HeterogeneousProperties.fromPointwise ⊆-refl : Reflexive _⊆_ ⊆-refl = HeterogeneousProperties.refl refl ⊆-trans : Transitive _⊆_ ⊆-trans = HeterogeneousProperties.trans trans ⊆-antisym : Antisymmetric _≋_ _⊆_ ⊆-antisym = HeterogeneousProperties.antisym (λ x≈y _ → x≈y) ⊆-isPreorder : IsPreorder _≋_ _⊆_ ⊆-isPreorder = record { isEquivalence = ≋-isEquivalence ; reflexive = ⊆-reflexive ; trans = ⊆-trans } ⊆-isPartialOrder : IsPartialOrder _≋_ _⊆_ ⊆-isPartialOrder = record { isPreorder = ⊆-isPreorder ; antisym = ⊆-antisym } ⊆-preorder : Preorder c (c ⊔ ℓ) (c ⊔ ℓ) ⊆-preorder = record { isPreorder = ⊆-isPreorder } ⊆-poset : Poset c (c ⊔ ℓ) (c ⊔ ℓ) ⊆-poset = record { isPartialOrder = ⊆-isPartialOrder }
{ "alphanum_fraction": 0.6156670747, "avg_line_length": 29.8902439024, "ext": "agda", "hexsha": "6140d6dddb1514717e72729d6eb42bb916d2d10d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 731, "size": 2451 }
module Structure.Function where import Lvl open import Lang.Instance open import Logic.Predicate open import Logic open import Structure.Function.Names open import Structure.Setoid open import Type private variable ℓ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ : Lvl.Level private variable A B : Type{ℓ} -- The function `f` "(behaves like)/is a function" in the context of `_≡_` from the Equiv instance. -- `congruence` is the defining property of a function. module _ ⦃ equiv-A : Equiv{ℓₗ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₗ₂}(B) ⦄ (f : A → B) where record Function : Stmt{Lvl.of(A) Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} where constructor intro field congruence : Congruence₁(f) congruence₁ = inst-fn Function.congruence _→ᶠⁿ_ : (A : Setoid{ℓₗ₁}{ℓₒ₁}) → (B : Setoid{ℓₗ₂}{ℓₒ₂}) → Type{ℓₒ₁ Lvl.⊔ ℓₒ₂ Lvl.⊔ ℓₗ₁ Lvl.⊔ ℓₗ₂} ([∃]-intro A) →ᶠⁿ ([∃]-intro B) = ∃(Function{A = A}{B = B})
{ "alphanum_fraction": 0.6859122402, "avg_line_length": 29.8620689655, "ext": "agda", "hexsha": "a2a9cbd1902a76146f319f34940613462b1c8506", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Function.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Function.agda", "max_line_length": 99, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Function.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 389, "size": 866 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Prod.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function -- Here we define an inductive version of the product type, see below -- for its uses. -- See `Cubical.Data.Sigma` for `_×_` defined as a special case of -- sigma types, which is the generally preferred one. -- If × is defined using Σ then transp/hcomp will be compute -- "negatively", that is, they won't reduce unless we project out the -- first of second component. This is not always what we want so this -- implementation is done using a datatype which computes positively. private variable ℓ ℓ' : Level data _×_ (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where _,_ : A → B → A × B infixr 5 _×_ proj₁ : {A : Type ℓ} {B : Type ℓ'} → A × B → A proj₁ (x , _) = x proj₂ : {A : Type ℓ} {B : Type ℓ'} → A × B → B proj₂ (_ , x) = x private variable A : Type ℓ B C : A → Type ℓ intro : (∀ a → B a) → (∀ a → C a) → ∀ a → B a × C a intro f g a = f a , g a map : {B : Type ℓ} {D : B → Type ℓ'} → (∀ a → C a) → (∀ b → D b) → (x : A × B) → C (proj₁ x) × D (proj₂ x) map f g = intro (f ∘ proj₁) (g ∘ proj₂) ×-η : {A : Type ℓ} {B : Type ℓ'} (x : A × B) → x ≡ ((proj₁ x) , (proj₂ x)) ×-η (x , x₁) = refl
{ "alphanum_fraction": 0.5971705138, "avg_line_length": 25.8269230769, "ext": "agda", "hexsha": "6b88b3c5a078427cee78057abc65cbd796d7b504", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Prod/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Prod/Base.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Prod/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 488, "size": 1343 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Concrete.System.Parameters import LibraBFT.Concrete.Properties.VotesOnce as VO import LibraBFT.Concrete.Properties.LockedRound as LR open import LibraBFT.Impl.Consensus.Types hiding (EpochConfigFor) open EpochConfig open import LibraBFT.Yasm.Yasm (ℓ+1 0ℓ) EpochConfig epochId authorsN ConcSysParms NodeId-PK-OK -- This module collects in one place the obligations an -- implementation must meet in order to enjoy the properties -- proved in Abstract.Properties. module LibraBFT.Concrete.Obligations where record ImplObligations : Set₁ where field -- Structural obligations: sps-cor : StepPeerState-AllValidParts -- Semantic obligations: -- -- VotesOnce: vo₁ : VO.ImplObligation₁ vo₂ : VO.ImplObligation₂ -- LockedRound: lr₁ : LR.ImplObligation₁
{ "alphanum_fraction": 0.7468916519, "avg_line_length": 35.1875, "ext": "agda", "hexsha": "9b739f4321b963744042be19b3ece027b3d26433", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "haroldcarr/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Concrete/Obligations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "haroldcarr/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Concrete/Obligations.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "haroldcarr/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Concrete/Obligations.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 302, "size": 1126 }
open import Nat open import Prelude open import contexts open import dynamics-core open import canonical-value-forms module canonical-boxed-forms where canonical-boxed-forms-num : ∀{Δ d} → Δ , ∅ ⊢ d :: num → d boxedval → Σ[ n ∈ Nat ] (d == N n) canonical-boxed-forms-num (TAVar _) (BVVal ()) canonical-boxed-forms-num wt (BVVal v) = canonical-value-forms-num wt v -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for boxed values at arrow type data cbf-arr : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where CBFALam : ∀{Δ d τ1 τ2} → Σ[ x ∈ Nat ] Σ[ d' ∈ ihexp ] ((d == (·λ x ·[ τ1 ] d')) × (Δ , ■ (x , τ1) ⊢ d' :: τ2) ) → cbf-arr Δ d τ1 τ2 CBFACastArr : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ] ((d == (d' ⟨ τ1' ==> τ2' ⇒ τ1 ==> τ2 ⟩)) × (τ1' ==> τ2' ≠ τ1 ==> τ2) × (Δ , ∅ ⊢ d' :: τ1' ==> τ2') × (d' boxedval) ) → cbf-arr Δ d τ1 τ2 canonical-boxed-forms-arr : ∀{Δ d τ1 τ2 } → Δ , ∅ ⊢ d :: (τ1 ==> τ2) → d boxedval → cbf-arr Δ d τ1 τ2 canonical-boxed-forms-arr (TAVar x₁) (BVVal ()) canonical-boxed-forms-arr (TALam f wt) (BVVal v) = CBFALam (canonical-value-forms-arr (TALam f wt) v) canonical-boxed-forms-arr (TAAp wt wt₁) (BVVal ()) canonical-boxed-forms-arr (TAEHole x x₁) (BVVal ()) canonical-boxed-forms-arr (TANEHole x wt x₁) (BVVal ()) canonical-boxed-forms-arr (TACast wt x) (BVVal ()) canonical-boxed-forms-arr (TACast wt x) (BVArrCast x₁ bv) = CBFACastArr (_ , _ , _ , refl , x₁ , wt , bv) canonical-boxed-forms-arr (TAFailedCast x x₁ x₂ x₃) (BVVal ()) -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for boxed values at sum type data cbf-sum : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where CBFSInl : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] ((d == (inl τ2 d')) × (Δ , ∅ ⊢ d' :: τ1) × (d boxedval) ) → cbf-sum Δ d τ1 τ2 CBFSInr : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] ((d == (inr τ1 d')) × (Δ , ∅ ⊢ d' :: τ2) × (d boxedval) ) → cbf-sum Δ d τ1 τ2 CBFSCastSum : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ] ((d == (d' ⟨ τ1' ⊕ τ2' ⇒ τ1 ⊕ τ2 ⟩)) × (τ1' ⊕ τ2' ≠ τ1 ⊕ τ2) × (Δ , ∅ ⊢ d' :: τ1' ⊕ τ2') × (d' boxedval) ) → cbf-sum Δ d τ1 τ2 canonical-boxed-forms-sum : ∀{Δ d τ1 τ2 } → Δ , ∅ ⊢ d :: (τ1 ⊕ τ2) → d boxedval → cbf-sum Δ d τ1 τ2 canonical-boxed-forms-sum (TAInl wt) x = CBFSInl (_ , refl , wt , x) canonical-boxed-forms-sum (TAInr wt) x = CBFSInr (_ , refl , wt , x) canonical-boxed-forms-sum (TACast wt x₁) (BVSumCast x bv) = CBFSCastSum (_ , _ , _ , refl , x , wt , bv) canonical-boxed-forms-sum (TAVar x₁) (BVVal ()) canonical-boxed-forms-sum (TAAp wt wt₁) (BVVal ()) canonical-boxed-forms-sum (TACase wt _ wt₁ _ wt₂) (BVVal ()) canonical-boxed-forms-sum (TAFst wt) (BVVal ()) canonical-boxed-forms-sum (TASnd wt) (BVVal ()) canonical-boxed-forms-sum (TAEHole x₁ x₂) (BVVal ()) canonical-boxed-forms-sum (TANEHole x₁ wt x₂) (BVVal ()) canonical-boxed-forms-sum (TACast wt x₁) (BVVal ()) canonical-boxed-forms-sum (TAFailedCast wt x₁ x₂ x₃) (BVVal ()) -- this type gives somewhat nicer syntax for the output of the canonical -- forms lemma for boxed values at product type data cbf-prod : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where CBFPPair : ∀{Δ d τ1 τ2} → Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] ((d == ⟨ d1 , d2 ⟩) × (Δ , ∅ ⊢ d1 :: τ1) × (Δ , ∅ ⊢ d2 :: τ2) × (d1 boxedval) × (d2 boxedval) ) → cbf-prod Δ d τ1 τ2 CBFPCastProd : ∀{Δ d τ1 τ2} → Σ[ d' ∈ ihexp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ] ((d == (d' ⟨ τ1' ⊠ τ2' ⇒ τ1 ⊠ τ2 ⟩)) × (τ1' ⊠ τ2' ≠ τ1 ⊠ τ2) × (Δ , ∅ ⊢ d' :: τ1' ⊠ τ2') × (d' boxedval) ) → cbf-prod Δ d τ1 τ2 canonical-boxed-forms-prod : ∀{Δ d τ1 τ2 } → Δ , ∅ ⊢ d :: (τ1 ⊠ τ2) → d boxedval → cbf-prod Δ d τ1 τ2 canonical-boxed-forms-prod (TAPair wt wt₁) (BVVal (VPair x x₁)) = CBFPPair (_ , _ , refl , wt , wt₁ , BVVal x , BVVal x₁) canonical-boxed-forms-prod (TAPair wt wt₁) (BVPair bv bv₁) = CBFPPair (_ , _ , refl , wt , wt₁ , bv , bv₁) canonical-boxed-forms-prod (TACast wt x) (BVProdCast x₁ bv) = CBFPCastProd (_ , _ , _ , refl , x₁ , wt , bv) canonical-boxed-forms-hole : ∀{Δ d} → Δ , ∅ ⊢ d :: ⦇-⦈ → d boxedval → Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] ((d == d' ⟨ τ' ⇒ ⦇-⦈ ⟩) × (τ' ground) × (Δ , ∅ ⊢ d' :: τ')) canonical-boxed-forms-hole (TAVar x₁) (BVVal ()) canonical-boxed-forms-hole (TAAp wt wt₁) (BVVal ()) canonical-boxed-forms-hole (TAEHole x x₁) (BVVal ()) canonical-boxed-forms-hole (TANEHole x wt x₁) (BVVal ()) canonical-boxed-forms-hole (TACast wt x) (BVVal ()) canonical-boxed-forms-hole (TACast wt x) (BVHoleCast x₁ bv) = _ , _ , refl , x₁ , wt canonical-boxed-forms-hole (TAFailedCast x x₁ x₂ x₃) (BVVal ()) canonical-boxed-forms-coverage : ∀{Δ d τ} → Δ , ∅ ⊢ d :: τ → d boxedval → τ ≠ num → ((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ==> τ2)) → ((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ⊕ τ2)) → ((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ⊠ τ2)) → τ ≠ ⦇-⦈ → ⊥ canonical-boxed-forms-coverage TANum bv nn na ns np nh = nn refl canonical-boxed-forms-coverage (TAPlus wt wt₁) bv nn na ns np nh = nn refl canonical-boxed-forms-coverage (TALam x wt) bv nn na ns np nh = na _ _ refl canonical-boxed-forms-coverage (TAAp wt wt₁) (BVVal ()) nn na ns np nh canonical-boxed-forms-coverage (TAInl wt) bv nn na ns np nh = ns _ _ refl canonical-boxed-forms-coverage (TAInr wt) bv nn na ns np nh = ns _ _ refl canonical-boxed-forms-coverage (TACase wt _ wt₁ _ wt₂) (BVVal ()) nn na ns np nh canonical-boxed-forms-coverage (TAEHole x x₁) (BVVal ()) nn na ns np nh canonical-boxed-forms-coverage (TANEHole x wt x₁) (BVVal ()) nn na ns np nh canonical-boxed-forms-coverage (TACast wt x) (BVArrCast x₁ bv) nn na ns np nh = na _ _ refl canonical-boxed-forms-coverage (TACast wt x) (BVSumCast x₁ bv) nn na ns np nh = ns _ _ refl canonical-boxed-forms-coverage (TACast wt x) (BVProdCast x₁ bv) nn na ns np nh = np _ _ refl canonical-boxed-forms-coverage (TACast wt x) (BVHoleCast x₁ bv) nn na ns np nh = nh refl canonical-boxed-forms-coverage (TAFailedCast wt x x₁ x₂) (BVVal ()) nn na ns np nh canonical-boxed-forms-coverage (TAPair wt wt₁) bv nn na ns np nh = np _ _ refl canonical-boxed-forms-coverage (TAFst wt) (BVVal ()) nn na ns np nh canonical-boxed-forms-coverage (TASnd wt) (BVVal ()) nn na ns np nh
{ "alphanum_fraction": 0.5090715048, "avg_line_length": 46.85, "ext": "agda", "hexsha": "522453afc150c4a6d116a0244f27ceea53ab38f8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "canonical-boxed-forms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "canonical-boxed-forms.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "canonical-boxed-forms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2751, "size": 7496 }
------------------------------------------------------------------------ -- The Maybe type ------------------------------------------------------------------------ module Data.Maybe where ------------------------------------------------------------------------ -- The type open import Data.Maybe.Core public ------------------------------------------------------------------------ -- Some operations open import Data.Bool using (Bool; true; false) open import Data.Unit using (⊤) boolToMaybe : Bool → Maybe ⊤ boolToMaybe true = just _ boolToMaybe false = nothing maybeToBool : ∀ {A} → Maybe A → Bool maybeToBool (just _) = true maybeToBool nothing = false -- A non-dependent eliminator. maybe : {a b : Set} → (a → b) → b → Maybe a → b maybe j n (just x) = j x maybe j n nothing = n maybe₀₁ : {a : Set} {b : Set₁} → (a → b) → b → Maybe a → b maybe₀₁ j n (just x) = j x maybe₀₁ j n nothing = n ------------------------------------------------------------------------ -- Maybe monad open import Data.Function open import Category.Functor open import Category.Monad open import Category.Monad.Identity functor : RawFunctor Maybe functor = record { _<$>_ = λ f → maybe (just ∘ f) nothing } monadT : ∀ {M} → RawMonad M → RawMonad (λ A → M (Maybe A)) monadT M = record { return = M.return ∘ just ; _>>=_ = λ m f → M._>>=_ m (maybe f (M.return nothing)) } where module M = RawMonad M monad : RawMonad Maybe monad = monadT IdentityMonad monadZero : RawMonadZero Maybe monadZero = record { monad = monad ; ∅ = nothing } monadPlus : RawMonadPlus Maybe monadPlus = record { monadZero = monadZero ; _∣_ = _∣_ } where _∣_ : ∀ {a} → Maybe a → Maybe a → Maybe a nothing ∣ y = y just x ∣ y = just x ------------------------------------------------------------------------ -- Equality open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl) drop-just : ∀ {A} {x y : A} → just x ≡ just y → x ≡ y drop-just refl = refl decSetoid : ∀ {A} → Decidable (_≡_ {A}) → DecSetoid decSetoid {A} _A-≟_ = PropEq.decSetoid _≟_ where _≟_ : Decidable (_≡_ {Maybe A}) just x ≟ just y with x A-≟ y just x ≟ just .x | yes refl = yes refl just x ≟ just y | no x≢y = no (x≢y ∘ drop-just) just x ≟ nothing = no λ() nothing ≟ just y = no λ() nothing ≟ nothing = yes refl ------------------------------------------------------------------------ -- Any and All open import Data.Product using (_,_) open import Data.Empty using (⊥) import Relation.Nullary.Decidable as Dec data Any {A} (P : A → Set) : Maybe A → Set where just : ∀ {x} (px : P x) → Any P (just x) data All {A} (P : A → Set) : Maybe A → Set where just : ∀ {x} (px : P x) → All P (just x) nothing : All P nothing IsJust : ∀ {A} → Maybe A → Set IsJust = Any (λ _ → ⊤) IsNothing : ∀ {A} → Maybe A → Set IsNothing = All (λ _ → ⊥) private drop-just-Any : ∀ {A} {P : A → Set} {x} → Any P (just x) → P x drop-just-Any (just px) = px drop-just-All : ∀ {A} {P : A → Set} {x} → All P (just x) → P x drop-just-All (just px) = px anyDec : ∀ {A} {P : A → Set} → (∀ x → Dec (P x)) → (x : Maybe A) → Dec (Any P x) anyDec p nothing = no λ() anyDec p (just x) = Dec.map (just , drop-just-Any) (p x) allDec : ∀ {A} {P : A → Set} → (∀ x → Dec (P x)) → (x : Maybe A) → Dec (All P x) allDec p nothing = yes nothing allDec p (just x) = Dec.map (just , drop-just-All) (p x)
{ "alphanum_fraction": 0.5140160183, "avg_line_length": 26.0895522388, "ext": "agda", "hexsha": "62828201cf4b5463fd4cb57db1676e1487c7df29", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/Maybe.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/Maybe.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/Maybe.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 1112, "size": 3496 }
open import Agda.Builtin.Reflection open import Agda.Builtin.Unit open import Agda.Builtin.String open import Agda.Builtin.Nat open import Agda.Builtin.List infixl 5 _>>=_ _>>=_ = bindTC pure = returnTC defToTerm : Name → Definition → List (Arg Term) → Term defToTerm _ (function cs) as = pat-lam cs as defToTerm _ (data-cons d) as = con d as defToTerm _ _ _ = unknown derefImmediate : Term → TC Term derefImmediate (def f args) = getDefinition f >>= λ f' → pure (defToTerm f f' args) derefImmediate x = pure x macro reflect : ∀ {ℓ} {t : Set ℓ} → t → Type → TC ⊤ reflect {_} {t} x ty = quoteTC x >>= derefImmediate >>= λ x' → quoteTC t >>= checkType x' >>= quoteTC >>= unify ty -- reflect {_} {t} x ty = quoteTC x >>= derefImmediate >>= quoteTC >>= unify ty data Maybe {ℓ} (t : Set ℓ) : Set ℓ where just : t → Maybe t nothing : Maybe t listToMaybe : ∀ {ℓ} {t : Set ℓ} → List t → Maybe t listToMaybe [] = nothing listToMaybe (x ∷ _) = just x record Show {ℓ} (t : Set ℓ) : Set ℓ where field show : t → String open Show {{...}} instance showN : Show Nat showN = record { show = λ _ → "nat" } mShow : ∀ {ℓ} {t : Set ℓ} → {{_ : Show t}} → Show (Maybe t) mShow = record { show = λ { (just x) → show x ; _ → "nothing" } } prog : String prog = let x : List Nat x = 3 ∷ [] in show (listToMaybe x) example : Term example = reflect prog
{ "alphanum_fraction": 0.6076759062, "avg_line_length": 22.6935483871, "ext": "agda", "hexsha": "a249df29f6553f040bb789ae3a9d9be4a4c5c19f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2404.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2404.agda", "max_line_length": 116, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2404.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 483, "size": 1407 }
{-# OPTIONS --without-K #-} open import HoTT.Base module HoTT.Base.Inspect where open variables data Inspect {i j} {A : 𝒰 i} {P : A → 𝒰 j} (f : Π A P) (x : A) (y : P x) : 𝒰 (i ⊔ j) where [_] : y == f x → Inspect f x y inspect : (f : Π A P) (x : A) → Inspect f x (f x) inspect f x = [ refl ]
{ "alphanum_fraction": 0.5387205387, "avg_line_length": 22.8461538462, "ext": "agda", "hexsha": "aceb7c5db2d122df1ed6db035efc011b945466cd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Base/Inspect.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Base/Inspect.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Base/Inspect.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 125, "size": 297 }
{- Next step operator. -} module TemporalOps.Next where open import CategoryTheory.Categories open import CategoryTheory.Instances.Reactive open import CategoryTheory.Functor open import CategoryTheory.CartesianStrength open import TemporalOps.Common open import Data.Product open import Data.Sum -- One-step delay operator. ▹_ : τ -> τ (▹ A) zero = ⊤ zero (▹ A) (suc n) = A n infixr 70 ▹_ -- Functor instance for ▹ F-▹ : Endofunctor ℝeactive F-▹ = record { omap = ▹_ ; fmap = fmap-▹ ; fmap-id = λ {_ n} -> fmap-▹-id {n = n} ; fmap-∘ = λ {_ _ _ _ _ n} -> fmap-▹-∘ {n = n} ; fmap-cong = fmap-▹-cong } where -- Lifting of ▹ fmap-▹ : {A B : τ} -> A ⇴ B -> ▹ A ⇴ ▹ B fmap-▹ f zero = λ _ → top.tt fmap-▹ f (suc n) = f n -- ▹ preserves identities fmap-▹-id : ∀ {A : τ} {n : ℕ} {a : ▹ A at n} -> (fmap-▹ id at n) a ≡ a fmap-▹-id {n = zero} = refl fmap-▹-id {n = suc n} = refl -- ▹ preserves composition fmap-▹-∘ : ∀ {A B C : τ} {g : B ⇴ C} {f : A ⇴ B} {n : ℕ} {a : ▹ A at n} -> (fmap-▹ (g ∘ f) at n) a ≡ (fmap-▹ g ∘ fmap-▹ f at n) a fmap-▹-∘ {n = zero} = refl fmap-▹-∘ {n = suc n} = refl -- ▹ is congruent fmap-▹-cong : ∀{A B : τ} {f f′ : A ⇴ B} -> ({n : ℕ} {a : A at n} -> f n a ≡ f′ n a) -> ({n : ℕ} {a : ▹ A at n} -> (fmap-▹ f at n) a ≡ (fmap-▹ f′ at n) a) fmap-▹-cong e {zero} = refl fmap-▹-cong e {suc n} = e -- ▹ is a Cartesian functor F-cart-▹ : CartesianFunctor F-▹ ℝeactive-cart ℝeactive-cart F-cart-▹ = record { u = u-▹ ; m = m-▹ ; m-nat₁ = m-nat₁-▹ ; m-nat₂ = m-nat₂-▹ ; associative = λ {A}{B}{C}{n}{a} -> assoc-▹ {A}{B}{C}{n}{a} ; unital-right = λ {A}{n}{a} -> unit-right-▹ {A}{n}{a} ; unital-left = λ {A}{n}{a} -> unit-left-▹ {A}{n}{a} } where open Functor F-▹ u-▹ : ⊤ ⇴ ▹ ⊤ u-▹ zero t = top.tt u-▹ (suc n) t = top.tt m-▹ : ∀(A B : τ) -> ▹ A ⊗ ▹ B ⇴ ▹ (A ⊗ B) m-▹ A B zero _ = top.tt m-▹ A B (suc n) p = p m-nat₁-▹ : ∀{A B C : τ} (f : A ⇴ B) -> fmap (f * id) ∘ m-▹ A C ≈ m-▹ B C ∘ fmap f * id m-nat₁-▹ f {zero} {a} = refl m-nat₁-▹ f {suc n} {a} = refl m-nat₂-▹ : ∀{A B C : τ} (f : A ⇴ B) -> fmap (id * f) ∘ m-▹ C A ≈ m-▹ C B ∘ id * fmap f m-nat₂-▹ f {zero} {a} = refl m-nat₂-▹ f {suc n} {a} = refl assoc-▹ : ∀{A B C : τ} -> m-▹ A (B ⊗ C) ∘ id * m-▹ B C ∘ assoc-right ≈ fmap assoc-right ∘ m-▹ (A ⊗ B) C ∘ m-▹ A B * id assoc-▹ {A} {B} {C} {zero} {a} = refl assoc-▹ {A} {B} {C} {suc n} {(▹A , ▹B) , ▹C} = refl unit-right-▹ : ∀{A : τ} -> fmap unit-right ∘ m-▹ A ⊤ ∘ (id * u-▹) ≈ unit-right unit-right-▹ {A} {zero} {a} = refl unit-right-▹ {A} {suc n} {a} = refl unit-left-▹ : ∀{A : τ} -> fmap unit-left ∘ m-▹ ⊤ A ∘ (u-▹ * id) ≈ unit-left unit-left-▹ {A} {zero} {a} = refl unit-left-▹ {A} {suc n} {a} = refl -- ▹ preserves coproducts sum-▹ : ∀{A B : τ} -> (▹ A ⊕ ▹ B) ⇴ ▹ (A ⊕ B) sum-▹ zero v = top.tt sum-▹ (suc n) v = v
{ "alphanum_fraction": 0.4422030099, "avg_line_length": 29.7428571429, "ext": "agda", "hexsha": "f2e71734f3f863aa01a0ff81d629d2c1c94c5048", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/TemporalOps/Next.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/TemporalOps/Next.agda", "max_line_length": 75, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/TemporalOps/Next.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 1470, "size": 3123 }
module Luau.RuntimeType where open import Luau.Value using (Value; nil; addr; number) data RuntimeType : Set where function : RuntimeType number : RuntimeType nil : RuntimeType valueType : Value → RuntimeType valueType nil = nil valueType (addr x) = function valueType (number x) = number
{ "alphanum_fraction": 0.755033557, "avg_line_length": 21.2857142857, "ext": "agda", "hexsha": "25c0283aaf0574ff8f73a44028c48dce4cbc5647", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Luau/RuntimeType.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Luau/RuntimeType.agda", "max_line_length": 55, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Luau/RuntimeType.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 79, "size": 298 }
------------------------------------------------------------------------ -- An abstraction of various forms of recursion/induction ------------------------------------------------------------------------ -- Note: The types in this module can perhaps be easier to understand -- if they are normalised. Note also that Agda can do the -- normalisation for you. module Induction where open import Relation.Unary -- A RecStruct describes the allowed structure of recursion. The -- examples in Induction.Nat should explain what this is all about. RecStruct : Set → Set₁ RecStruct a = Pred a → Pred a -- A recursor builder constructs an instance of a recursion structure -- for a given input. RecursorBuilder : ∀ {a} → RecStruct a → Set₁ RecursorBuilder {a} Rec = (P : Pred a) → Rec P ⊆′ P → Universal (Rec P) -- A recursor can be used to actually compute/prove something useful. Recursor : ∀ {a} → RecStruct a → Set₁ Recursor {a} Rec = (P : Pred a) → Rec P ⊆′ P → Universal P -- And recursors can be constructed from recursor builders. build : ∀ {a} {Rec : RecStruct a} → RecursorBuilder Rec → Recursor Rec build builder P f x = f x (builder P f x) -- We can repeat the exercise above for subsets of the type we are -- recursing over. SubsetRecursorBuilder : ∀ {a} → Pred a → RecStruct a → Set₁ SubsetRecursorBuilder {a} Q Rec = (P : Pred a) → Rec P ⊆′ P → Q ⊆′ Rec P SubsetRecursor : ∀ {a} → Pred a → RecStruct a → Set₁ SubsetRecursor {a} Q Rec = (P : Pred a) → Rec P ⊆′ P → Q ⊆′ P subsetBuild : ∀ {a} {Q : Pred a} {Rec : RecStruct a} → SubsetRecursorBuilder Q Rec → SubsetRecursor Q Rec subsetBuild builder P f x q = f x (builder P f x q)
{ "alphanum_fraction": 0.6180637544, "avg_line_length": 33.88, "ext": "agda", "hexsha": "3daa6eaaa841dee44715702df3e32949bee02987", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Induction.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Induction.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Induction.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 453, "size": 1694 }
------------------------------------------------------------------------ -- An equality postulate which evaluates ------------------------------------------------------------------------ module Relation.Binary.PropositionalEquality.TrustMe where open import Relation.Binary.PropositionalEquality private primitive primTrustMe : {A : Set}{a b : A} → a ≡ b -- trustMe {a = x} {b = y} evaluates to refl if x and y are -- definitionally equal. -- -- For an example of the use of trustMe, see Data.String._≟_. trustMe : {A : Set}{a b : A} → a ≡ b trustMe = primTrustMe
{ "alphanum_fraction": 0.5235602094, "avg_line_length": 28.65, "ext": "agda", "hexsha": "f363eed87fd5767c0b9738406e3f575045ae7105", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality/TrustMe.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality/TrustMe.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/PropositionalEquality/TrustMe.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 131, "size": 573 }
-- As reported by Andreas on 2017-01-23 open import Common.Equality open import Common.Product data Bool : Set where true false : Bool f : (x y : Bool) → Bool f true y = y -- f false x = true -- Missing case test : let X : Bool → Bool → Bool X = {! f !} in (∀{x y} → X (f false x) y ≡ y) × (X false false ≡ true) test = refl , refl -- If we add the missing clause f false x = true, then X has -- for instance solution f.
{ "alphanum_fraction": 0.606741573, "avg_line_length": 21.1904761905, "ext": "agda", "hexsha": "02c3a20fd7799c36b0a33e9d685b0d0d470aa20d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2426.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2426.agda", "max_line_length": 60, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2426.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 144, "size": 445 }
open import Prelude hiding (lift; id) module Implicits.Syntax.LNMetaType where open import Implicits.Syntax.Type open import Data.Nat as Nat mutual data MetaSType (m : ℕ) : Set where tvar : ℕ → MetaSType m mvar : Fin m → MetaSType m _→'_ : (a b : MetaType m) → MetaSType m tc : ℕ → MetaSType m data MetaType (m : ℕ) : Set where _⇒_ : (a b : MetaType m) → MetaType m ∀' : MetaType m → MetaType m simpl : MetaSType m → MetaType m mutual open-meta : ∀ {m} → ℕ → MetaType m → MetaType (suc m) open-meta k (a ⇒ b) = open-meta k a ⇒ open-meta k b open-meta k (∀' a) = ∀' (open-meta (suc k) a ) open-meta k (simpl x) = simpl (open-st k x) where open-st : ∀ {m} → ℕ → MetaSType m → MetaSType (suc m) open-st k (tvar x) with Nat.compare x k open-st .(suc (x N+ k)) (tvar x) | less .x k = tvar x open-st k (tvar .k) | equal .k = mvar zero open-st k (tvar .(suc (k N+ x))) | greater .k x = tvar (k N+ x) open-st k (mvar x) = mvar (suc x) open-st k (a →' b) = open-meta k a →' open-meta k b open-st k (tc x) = tc x mutual data TClosedS {m} (n : ℕ) : MetaSType m → Set where tvar : ∀ {x} → (x N< n) → TClosedS n (tvar x) mvar : ∀ {x} → TClosedS n (mvar x) _→'_ : ∀ {a b} → TClosed n a → TClosed n b → TClosedS n (a →' b) tc : ∀ {c} → TClosedS n (tc c) data TClosed {m} (n : ℕ) : MetaType m → Set where _⇒_ : ∀ {a b} → TClosed n a → TClosed n b → TClosed n (a ⇒ b) ∀' : ∀ {a} → TClosed (suc n) a → TClosed n (∀' a) simpl : ∀ {τ} → TClosedS n τ → TClosed n (simpl τ) to-meta : ∀ {ν} → Type ν → MetaType zero to-meta (simpl (tc x)) = simpl (tc x) to-meta (simpl (tvar n)) = simpl (tvar (toℕ n)) to-meta (simpl (a →' b)) = simpl (to-meta a →' to-meta b) to-meta (a ⇒ b) = to-meta a ⇒ to-meta b to-meta (∀' a) = ∀' (to-meta a) from-meta : ∀ {ν} {a : MetaType zero} → TClosed ν a → Type ν from-meta (a ⇒ b) = from-meta a ⇒ from-meta b from-meta (∀' a) = ∀' (from-meta a) from-meta (simpl (tvar x)) = simpl (tvar (fromℕ≤ x)) from-meta (simpl (mvar {()})) from-meta (simpl (a →' b)) = simpl (from-meta a →' from-meta b) from-meta (simpl (tc {c})) = simpl (tc c)
{ "alphanum_fraction": 0.5551992671, "avg_line_length": 34.6507936508, "ext": "agda", "hexsha": "8ef70e007ce91a270562c45ba54db41d5a5fc2e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Syntax/LNMetaType.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Syntax/LNMetaType.agda", "max_line_length": 69, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Syntax/LNMetaType.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 868, "size": 2183 }
{-# OPTIONS --safe #-} module Cubical.Experiments.HAEquivInt where open import Cubical.Experiments.HAEquivInt.Base public
{ "alphanum_fraction": 0.7903225806, "avg_line_length": 20.6666666667, "ext": "agda", "hexsha": "819a03aac3ca75a338b679bf8e29f0f5f39bf804", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Experiments/HAEquivInt.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Experiments/HAEquivInt.agda", "max_line_length": 54, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Experiments/HAEquivInt.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 29, "size": 124 }
----------------------------------------------------------------------- -- The Agda standard library -- -- Properties of the heterogeneous sublist relation ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Binary.Sublist.Heterogeneous.Properties where open import Data.Empty open import Data.List.Relation.Unary.Any using (Any; here; there) open import Data.List.Base as List hiding (map; _∷ʳ_) import Data.List.Properties as Lₚ open import Data.List.Relation.Unary.Any.Properties using (here-injective; there-injective) open import Data.List.Relation.Binary.Pointwise as Pw using (Pointwise; []; _∷_) open import Data.List.Relation.Binary.Sublist.Heterogeneous open import Data.Maybe.Relation.Unary.All as MAll using (nothing; just) open import Data.Nat using (ℕ; _≤_; _≥_); open ℕ; open _≤_ import Data.Nat.Properties as ℕₚ open import Data.Product using (_×_; uncurry) open import Function open import Function.Bijection using (_⤖_; bijection) open import Function.Equivalence using (_⇔_ ; equivalence) open import Relation.Nullary using (yes; no; ¬_) open import Relation.Nullary.Negation using (¬?) import Relation.Nullary.Decidable as Dec open import Relation.Unary as U using (Pred; _⊆_) open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- Injectivity of constructors module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where ∷-injectiveˡ : ∀ {x y xs ys} {px qx : R x y} {pxs qxs : Sublist R xs ys} → (Sublist R (x ∷ xs) (y ∷ ys) ∋ px ∷ pxs) ≡ (qx ∷ qxs) → px ≡ qx ∷-injectiveˡ P.refl = P.refl ∷-injectiveʳ : ∀ {x y xs ys} {px qx : R x y} {pxs qxs : Sublist R xs ys} → (Sublist R (x ∷ xs) (y ∷ ys) ∋ px ∷ pxs) ≡ (qx ∷ qxs) → pxs ≡ qxs ∷-injectiveʳ P.refl = P.refl ∷ʳ-injective : ∀ {y xs ys} {pxs qxs : Sublist R xs ys} → (Sublist R xs (y ∷ ys) ∋ y ∷ʳ pxs) ≡ (y ∷ʳ qxs) → pxs ≡ qxs ∷ʳ-injective P.refl = P.refl module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where length-mono-≤ : ∀ {as bs} → Sublist R as bs → length as ≤ length bs length-mono-≤ [] = z≤n length-mono-≤ (y ∷ʳ rs) = ℕₚ.≤-step (length-mono-≤ rs) length-mono-≤ (r ∷ rs) = s≤s (length-mono-≤ rs) ------------------------------------------------------------------------ -- Conversion to and from Pointwise (proto-reflexivity) fromPointwise : Pointwise R ⇒ Sublist R fromPointwise [] = [] fromPointwise (p ∷ ps) = p ∷ fromPointwise ps toPointwise : ∀ {as bs} → length as ≡ length bs → Sublist R as bs → Pointwise R as bs toPointwise {bs = []} eq [] = [] toPointwise {bs = b ∷ bs} eq (r ∷ rs) = r ∷ toPointwise (ℕₚ.suc-injective eq) rs toPointwise {bs = b ∷ bs} eq (b ∷ʳ rs) = ⊥-elim $ ℕₚ.<-irrefl eq (s≤s (length-mono-≤ rs)) ------------------------------------------------------------------------ -- Various functions' outputs are sublists -- These lemmas are generalisations of results of the form `f xs ⊆ xs`. -- (where _⊆_ stands for Sublist R). If R is reflexive then we can indeed -- obtain `f xs ⊆ xs` from `xs ⊆ ys → f xs ⊆ ys`. The other direction is -- only true if R is both reflexive and transitive. module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where tail-Sublist : ∀ {as bs} → Sublist R as bs → MAll.All (λ as → Sublist R as bs) (tail as) tail-Sublist [] = nothing tail-Sublist (b ∷ʳ ps) = MAll.map (b ∷ʳ_) (tail-Sublist ps) tail-Sublist (p ∷ ps) = just (_ ∷ʳ ps) take-Sublist : ∀ {as bs} n → Sublist R as bs → Sublist R (take n as) bs take-Sublist n (y ∷ʳ rs) = y ∷ʳ take-Sublist n rs take-Sublist zero rs = minimum _ take-Sublist (suc n) [] = [] take-Sublist (suc n) (r ∷ rs) = r ∷ take-Sublist n rs drop-Sublist : ∀ n → Sublist R ⇒ (Sublist R ∘′ drop n) drop-Sublist n (y ∷ʳ rs) = y ∷ʳ drop-Sublist n rs drop-Sublist zero rs = rs drop-Sublist (suc n) [] = [] drop-Sublist (suc n) (r ∷ rs) = _ ∷ʳ drop-Sublist n rs module _ {a b r p} {A : Set a} {B : Set b} {R : REL A B r} {P : Pred A p} (P? : U.Decidable P) where takeWhile-Sublist : ∀ {as bs} → Sublist R as bs → Sublist R (takeWhile P? as) bs takeWhile-Sublist [] = [] takeWhile-Sublist (y ∷ʳ rs) = y ∷ʳ takeWhile-Sublist rs takeWhile-Sublist {a ∷ as} (r ∷ rs) with P? a ... | yes pa = r ∷ takeWhile-Sublist rs ... | no ¬pa = minimum _ dropWhile-Sublist : ∀ {as bs} → Sublist R as bs → Sublist R (dropWhile P? as) bs dropWhile-Sublist [] = [] dropWhile-Sublist (y ∷ʳ rs) = y ∷ʳ dropWhile-Sublist rs dropWhile-Sublist {a ∷ as} (r ∷ rs) with P? a ... | yes pa = _ ∷ʳ dropWhile-Sublist rs ... | no ¬pa = r ∷ rs filter-Sublist : ∀ {as bs} → Sublist R as bs → Sublist R (filter P? as) bs filter-Sublist [] = [] filter-Sublist (y ∷ʳ rs) = y ∷ʳ filter-Sublist rs filter-Sublist {a ∷ as} (r ∷ rs) with P? a ... | yes pa = r ∷ filter-Sublist rs ... | no ¬pa = _ ∷ʳ filter-Sublist rs ------------------------------------------------------------------------ -- Various functions are increasing wrt _⊆_ -- We write f⁺ for the proof that `xs ⊆ ys → f xs ⊆ f ys` -- and f⁻ for the one that `f xs ⊆ f ys → xs ⊆ ys`. module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where ------------------------------------------------------------------------ -- _∷_ ∷ˡ⁻ : ∀ {a as bs} → Sublist R (a ∷ as) bs → Sublist R as bs ∷ˡ⁻ (y ∷ʳ rs) = y ∷ʳ ∷ˡ⁻ rs ∷ˡ⁻ (r ∷ rs) = _ ∷ʳ rs ∷ʳ⁻ : ∀ {a as b bs} → ¬ R a b → Sublist R (a ∷ as) (b ∷ bs) → Sublist R (a ∷ as) bs ∷ʳ⁻ ¬r (y ∷ʳ rs) = rs ∷ʳ⁻ ¬r (r ∷ rs) = ⊥-elim (¬r r) ∷⁻ : ∀ {a as b bs} → Sublist R (a ∷ as) (b ∷ bs) → Sublist R as bs ∷⁻ (y ∷ʳ rs) = ∷ˡ⁻ rs ∷⁻ (x ∷ rs) = rs module _ {a b c d r} {A : Set a} {B : Set b} {C : Set c} {D : Set d} {R : REL C D r} where ------------------------------------------------------------------------ -- map map⁺ : ∀ {as bs} (f : A → C) (g : B → D) → Sublist (λ a b → R (f a) (g b)) as bs → Sublist R (List.map f as) (List.map g bs) map⁺ f g [] = [] map⁺ f g (y ∷ʳ rs) = g y ∷ʳ map⁺ f g rs map⁺ f g (r ∷ rs) = r ∷ map⁺ f g rs map⁻ : ∀ {as bs} (f : A → C) (g : B → D) → Sublist R (List.map f as) (List.map g bs) → Sublist (λ a b → R (f a) (g b)) as bs map⁻ {[]} {bs} f g rs = minimum _ map⁻ {a ∷ as} {[]} f g () map⁻ {a ∷ as} {b ∷ bs} f g (_ ∷ʳ rs) = b ∷ʳ map⁻ f g rs map⁻ {a ∷ as} {b ∷ bs} f g (r ∷ rs) = r ∷ map⁻ f g rs module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where ------------------------------------------------------------------------ -- _++_ ++⁺ : ∀ {as bs cs ds} → Sublist R as bs → Sublist R cs ds → Sublist R (as ++ cs) (bs ++ ds) ++⁺ [] cds = cds ++⁺ (y ∷ʳ abs) cds = y ∷ʳ ++⁺ abs cds ++⁺ (ab ∷ abs) cds = ab ∷ ++⁺ abs cds ++⁻ : ∀ {as bs cs ds} → length as ≡ length bs → Sublist R (as ++ cs) (bs ++ ds) → Sublist R cs ds ++⁻ {[]} {[]} eq rs = rs ++⁻ {a ∷ as} {b ∷ bs} eq rs = ++⁻ (ℕₚ.suc-injective eq) (∷⁻ rs) ++⁻ {[]} {_ ∷ _} () ++⁻ {_ ∷ _} {[]} () ++ˡ : ∀ {as bs} (cs : List B) → Sublist R as bs → Sublist R as (cs ++ bs) ++ˡ zs = ++⁺ (minimum zs) ++ʳ : ∀ {as bs} (cs : List B) → Sublist R as bs → Sublist R as (bs ++ cs) ++ʳ cs [] = minimum cs ++ʳ cs (y ∷ʳ rs) = y ∷ʳ ++ʳ cs rs ++ʳ cs (r ∷ rs) = r ∷ ++ʳ cs rs ------------------------------------------------------------------------ -- take / drop take⁺ : ∀ {m n as bs} → m ≤ n → Pointwise R as bs → Sublist R (take m as) (take n bs) take⁺ z≤n ps = minimum _ take⁺ (s≤s m≤n) [] = [] take⁺ (s≤s m≤n) (p ∷ ps) = p ∷ take⁺ m≤n ps drop⁺ : ∀ {m n as bs} → m ≥ n → Sublist R as bs → Sublist R (drop m as) (drop n bs) drop⁺ {m} z≤n rs = drop-Sublist m rs drop⁺ (s≤s m≥n) [] = [] drop⁺ (s≤s m≥n) (y ∷ʳ rs) = drop⁺ (ℕₚ.≤-step m≥n) rs drop⁺ (s≤s m≥n) (r ∷ rs) = drop⁺ m≥n rs drop⁺-≥ : ∀ {m n as bs} → m ≥ n → Pointwise R as bs → Sublist R (drop m as) (drop n bs) drop⁺-≥ m≥n pw = drop⁺ m≥n (fromPointwise pw) drop⁺-⊆ : ∀ {as bs} m → Sublist R as bs → Sublist R (drop m as) (drop m bs) drop⁺-⊆ m = drop⁺ (ℕₚ.≤-refl {m}) module _ {a b r p q} {A : Set a} {B : Set b} {R : REL A B r} {P : Pred A p} {Q : Pred B q} (P? : U.Decidable P) (Q? : U.Decidable Q) where ⊆-takeWhile-Sublist : ∀ {as bs} → (∀ {a b} → R a b → P a → Q b) → Pointwise R as bs → Sublist R (takeWhile P? as) (takeWhile Q? bs) ⊆-takeWhile-Sublist rp⇒q [] = [] ⊆-takeWhile-Sublist {a ∷ as} {b ∷ bs} rp⇒q (p ∷ ps) with P? a | Q? b ... | yes pa | yes qb = p ∷ ⊆-takeWhile-Sublist rp⇒q ps ... | yes pa | no ¬qb = ⊥-elim $ ¬qb $ rp⇒q p pa ... | no ¬pa | yes qb = minimum _ ... | no ¬pa | no ¬qb = [] ⊇-dropWhile-Sublist : ∀ {as bs} → (∀ {a b} → R a b → Q b → P a) → Pointwise R as bs → Sublist R (dropWhile P? as) (dropWhile Q? bs) ⊇-dropWhile-Sublist rq⇒p [] = [] ⊇-dropWhile-Sublist {a ∷ as} {b ∷ bs} rq⇒p (p ∷ ps) with P? a | Q? b ... | yes pa | yes qb = ⊇-dropWhile-Sublist rq⇒p ps ... | yes pa | no ¬qb = b ∷ʳ dropWhile-Sublist P? (fromPointwise ps) ... | no ¬pa | yes qb = ⊥-elim $ ¬pa $ rq⇒p p qb ... | no ¬pa | no ¬qb = p ∷ fromPointwise ps ⊆-filter-Sublist : ∀ {as bs} → (∀ {a b} → R a b → P a → Q b) → Sublist R as bs → Sublist R (filter P? as) (filter Q? bs) ⊆-filter-Sublist rp⇒q [] = [] ⊆-filter-Sublist rp⇒q (y ∷ʳ rs) with Q? y ... | yes qb = y ∷ʳ ⊆-filter-Sublist rp⇒q rs ... | no ¬qb = ⊆-filter-Sublist rp⇒q rs ⊆-filter-Sublist {a ∷ as} {b ∷ bs} rp⇒q (r ∷ rs) with P? a | Q? b ... | yes pa | yes qb = r ∷ ⊆-filter-Sublist rp⇒q rs ... | yes pa | no ¬qb = ⊥-elim $ ¬qb $ rp⇒q r pa ... | no ¬pa | yes qb = _ ∷ʳ ⊆-filter-Sublist rp⇒q rs ... | no ¬pa | no ¬qb = ⊆-filter-Sublist rp⇒q rs module _ {a r p} {A : Set a} {R : Rel A r} {P : Pred A p} (P? : U.Decidable P) where takeWhile-filter : ∀ {as} → Pointwise R as as → Sublist R (takeWhile P? as) (filter P? as) takeWhile-filter [] = [] takeWhile-filter {a ∷ as} (p ∷ ps) with P? a ... | yes pa = p ∷ takeWhile-filter ps ... | no ¬pa = minimum _ filter-dropWhile : ∀ {as} → Pointwise R as as → Sublist R (filter P? as) (dropWhile (¬? ∘ P?) as) filter-dropWhile [] = [] filter-dropWhile {a ∷ as} (p ∷ ps) with P? a ... | yes pa = p ∷ filter-Sublist P? (fromPointwise ps) ... | no ¬pa = filter-dropWhile ps ------------------------------------------------------------------------ -- reverse module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where reverseAcc⁺ : ∀ {as bs cs ds} → Sublist R as bs → Sublist R cs ds → Sublist R (reverseAcc cs as) (reverseAcc ds bs) reverseAcc⁺ [] cds = cds reverseAcc⁺ (y ∷ʳ abs) cds = reverseAcc⁺ abs (y ∷ʳ cds) reverseAcc⁺ (r ∷ abs) cds = reverseAcc⁺ abs (r ∷ cds) reverse⁺ : ∀ {as bs} → Sublist R as bs → Sublist R (reverse as) (reverse bs) reverse⁺ rs = reverseAcc⁺ rs [] reverse⁻ : ∀ {as bs} → Sublist R (reverse as) (reverse bs) → Sublist R as bs reverse⁻ {as} {bs} p = cast (reverse⁺ p) where cast = P.subst₂ (Sublist R) (Lₚ.reverse-involutive as) (Lₚ.reverse-involutive bs) ------------------------------------------------------------------------ -- Inversion lemmas module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} {a as b bs} where ∷⁻¹ : R a b → Sublist R as bs ⇔ Sublist R (a ∷ as) (b ∷ bs) ∷⁻¹ r = equivalence (r ∷_) ∷⁻ ∷ʳ⁻¹ : ¬ R a b → Sublist R (a ∷ as) bs ⇔ Sublist R (a ∷ as) (b ∷ bs) ∷ʳ⁻¹ ¬r = equivalence (_ ∷ʳ_) (∷ʳ⁻ ¬r) ------------------------------------------------------------------------ -- Irrelevant special case module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} where Sublist-[]-irrelevant : U.Irrelevant (Sublist R []) Sublist-[]-irrelevant [] [] = P.refl Sublist-[]-irrelevant (y ∷ʳ p) (.y ∷ʳ q) = P.cong (y ∷ʳ_) (Sublist-[]-irrelevant p q) ------------------------------------------------------------------------ -- (to/from)Any is a bijection toAny-injective : ∀ {xs x} {p q : Sublist R [ x ] xs} → toAny p ≡ toAny q → p ≡ q toAny-injective {p = y ∷ʳ p} {y ∷ʳ q} = P.cong (y ∷ʳ_) ∘′ toAny-injective ∘′ there-injective toAny-injective {p = _ ∷ p} {_ ∷ q} = P.cong₂ (flip _∷_) (Sublist-[]-irrelevant p q) ∘′ here-injective toAny-injective {p = _ ∷ʳ _} {_ ∷ _} = λ () toAny-injective {p = _ ∷ _} {_ ∷ʳ _} = λ () fromAny-injective : ∀ {xs x} {p q : Any (R x) xs} → fromAny {R = R} p ≡ fromAny q → p ≡ q fromAny-injective {p = here px} {here qx} = P.cong here ∘′ ∷-injectiveˡ fromAny-injective {p = there p} {there q} = P.cong there ∘′ fromAny-injective ∘′ ∷ʳ-injective fromAny-injective {p = here _} {there _} = λ () fromAny-injective {p = there _} {here _} = λ () toAny∘fromAny≗id : ∀ {xs x} (p : Any (R x) xs) → toAny (fromAny {R = R} p) ≡ p toAny∘fromAny≗id (here px) = P.refl toAny∘fromAny≗id (there p) = P.cong there (toAny∘fromAny≗id p) Sublist-[x]-bijection : ∀ {x xs} → (Sublist R [ x ] xs) ⤖ (Any (R x) xs) Sublist-[x]-bijection = bijection toAny fromAny toAny-injective toAny∘fromAny≗id ------------------------------------------------------------------------ -- Relational properties module _ {a r} {A : Set a} {R : Rel A r} where reflexive : Reflexive R → _≡_ ⇒ Sublist R reflexive R-refl P.refl = fromPointwise (Pw.refl R-refl) refl : Reflexive R → Reflexive (Sublist R) refl R-refl = reflexive R-refl P.refl module _ {a b c r s t} {A : Set a} {B : Set b} {C : Set c} {R : REL A B r} {S : REL B C s} {T : REL A C t} where trans : Trans R S T → Trans (Sublist R) (Sublist S) (Sublist T) trans rs⇒t [] [] = [] trans rs⇒t rs (y ∷ʳ ss) = y ∷ʳ trans rs⇒t rs ss trans rs⇒t (y ∷ʳ rs) (s ∷ ss) = _ ∷ʳ trans rs⇒t rs ss trans rs⇒t (r ∷ rs) (s ∷ ss) = rs⇒t r s ∷ trans rs⇒t rs ss module _ {a b r s e} {A : Set a} {B : Set b} {R : REL A B r} {S : REL B A s} {E : REL A B e} where open ℕₚ.≤-Reasoning antisym : Antisym R S E → Antisym (Sublist R) (Sublist S) (Pointwise E) antisym rs⇒e [] [] = [] antisym rs⇒e (r ∷ rs) (s ∷ ss) = rs⇒e r s ∷ antisym rs⇒e rs ss -- impossible cases antisym rs⇒e (_∷ʳ_ {xs} {ys₁} y rs) (_∷ʳ_ {ys₂} {zs} z ss) = ⊥-elim $ ℕₚ.<-irrefl P.refl $ begin length (y ∷ ys₁) ≤⟨ length-mono-≤ ss ⟩ length zs ≤⟨ ℕₚ.n≤1+n (length zs) ⟩ length (z ∷ zs) ≤⟨ length-mono-≤ rs ⟩ length ys₁ ∎ antisym rs⇒e (_∷ʳ_ {xs} {ys₁} y rs) (_∷_ {y} {ys₂} {z} {zs} s ss) = ⊥-elim $ ℕₚ.<-irrefl P.refl $ begin length (z ∷ zs) ≤⟨ length-mono-≤ rs ⟩ length ys₁ ≤⟨ length-mono-≤ ss ⟩ length zs ∎ antisym rs⇒e (_∷_ {x} {xs} {y} {ys₁} r rs) (_∷ʳ_ {ys₂} {zs} z ss) = ⊥-elim $ ℕₚ.<-irrefl P.refl $ begin length (y ∷ ys₁) ≤⟨ length-mono-≤ ss ⟩ length xs ≤⟨ length-mono-≤ rs ⟩ length ys₁ ∎ module _ {a b r} {A : Set a} {B : Set b} {R : REL A B r} (R? : Decidable R) where sublist? : Decidable (Sublist R) sublist? [] ys = yes (minimum ys) sublist? (x ∷ xs) [] = no λ () sublist? (x ∷ xs) (y ∷ ys) with R? x y ... | yes r = Dec.map (∷⁻¹ r) (sublist? xs ys) ... | no ¬r = Dec.map (∷ʳ⁻¹ ¬r) (sublist? (x ∷ xs) ys) module _ {a e r} {A : Set a} {E : Rel A e} {R : Rel A r} where isPreorder : IsPreorder E R → IsPreorder (Pointwise E) (Sublist R) isPreorder ER-isPreorder = record { isEquivalence = Pw.isEquivalence ER.isEquivalence ; reflexive = fromPointwise ∘ Pw.map ER.reflexive ; trans = trans ER.trans } where module ER = IsPreorder ER-isPreorder isPartialOrder : IsPartialOrder E R → IsPartialOrder (Pointwise E) (Sublist R) isPartialOrder ER-isPartialOrder = record { isPreorder = isPreorder ER.isPreorder ; antisym = antisym ER.antisym } where module ER = IsPartialOrder ER-isPartialOrder isDecPartialOrder : IsDecPartialOrder E R → IsDecPartialOrder (Pointwise E) (Sublist R) isDecPartialOrder ER-isDecPartialOrder = record { isPartialOrder = isPartialOrder ER.isPartialOrder ; _≟_ = Pw.decidable ER._≟_ ; _≤?_ = sublist? ER._≤?_ } where module ER = IsDecPartialOrder ER-isDecPartialOrder module _ {a e r} where preorder : Preorder a e r → Preorder _ _ _ preorder ER-preorder = record { isPreorder = isPreorder ER.isPreorder } where module ER = Preorder ER-preorder poset : Poset a e r → Poset _ _ _ poset ER-poset = record { isPartialOrder = isPartialOrder ER.isPartialOrder } where module ER = Poset ER-poset decPoset : DecPoset a e r → DecPoset _ _ _ decPoset ER-poset = record { isDecPartialOrder = isDecPartialOrder ER.isDecPartialOrder } where module ER = DecPoset ER-poset
{ "alphanum_fraction": 0.5140529532, "avg_line_length": 39.7800925926, "ext": "agda", "hexsha": "e58d46657b7d4c3f11d703353331f6b725e5b0cf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Heterogeneous/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Heterogeneous/Properties.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Heterogeneous/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6746, "size": 17185 }
module Tactic.Nat.Subtract.Exp where open import Prelude open import Tactic.Nat.Exp open import Tactic.Nat.NF open import Container.Bag open import Data.TreeRep infixl 6 _⟨+⟩_ _⟨-⟩_ infixl 7 _⟨*⟩_ data SubExp : Set where var : (x : Var) → SubExp lit : (n : Nat) → SubExp _⟨+⟩_ _⟨-⟩_ _⟨*⟩_ : (a b : SubExp) → SubExp infix 4 _:≡_ _:<_ data Eqn : Set where _:≡_ : (a b : SubExp) → Eqn _:<_ : (a b : SubExp) → Eqn ⟦_⟧se : SubExp → Env Var → Nat ⟦ var x ⟧se ρ = ρ x ⟦ lit n ⟧se ρ = n ⟦ e₁ ⟨+⟩ e₂ ⟧se ρ = ⟦ e₁ ⟧se ρ + ⟦ e₂ ⟧se ρ ⟦ e₁ ⟨-⟩ e₂ ⟧se ρ = ⟦ e₁ ⟧se ρ - ⟦ e₂ ⟧se ρ ⟦ e₁ ⟨*⟩ e₂ ⟧se ρ = ⟦ e₁ ⟧se ρ * ⟦ e₂ ⟧se ρ ⟦_⟧eqn : Eqn → Env Var → Set ⟦ e₁ :≡ e₂ ⟧eqn ρ = ⟦ e₁ ⟧se ρ ≡ ⟦ e₂ ⟧se ρ ⟦ e₁ :< e₂ ⟧eqn ρ = ⟦ e₁ ⟧se ρ < ⟦ e₂ ⟧se ρ data SubAtom : Set SubNF : Set SubNF = NF SubAtom data SubAtom where var : Var → SubAtom _⟨-⟩_ : (a b : SubNF) → SubAtom ⟦_⟧sn : SubNF → Env Var → Nat ⟦_⟧st : Tm SubAtom → Env Var → Nat ⟦_⟧sa : SubAtom → Env Var → Nat ⟦ var x ⟧sa ρ = ρ x ⟦ a ⟨-⟩ b ⟧sa ρ = ⟦ a ⟧sn ρ - ⟦ b ⟧sn ρ ⟦ [] ⟧st ρ = 1 ⟦ t ∷ ts ⟧st ρ = ⟦ t ⟧sa ρ * ⟦ ts ⟧st ρ ⟦ [] ⟧sn ρ = 0 ⟦ (k , ts) ∷ n ⟧sn ρ = k * ⟦ ts ⟧st ρ + ⟦ n ⟧sn ρ ⟦_⟧sns : SubNF → Env Var → Nat ⟦_⟧sts : Tm SubAtom → Env Var → Nat ⟦_⟧sas : SubAtom → Env Var → Nat ⟦ var x ⟧sas ρ = ρ x ⟦ a ⟨-⟩ b ⟧sas ρ = ⟦ a ⟧sns ρ - ⟦ b ⟧sns ρ ⟦ [] ⟧sts ρ = 1 ⟦ t ∷ [] ⟧sts ρ = ⟦ t ⟧sas ρ ⟦ t ∷ ts ⟧sts ρ = ⟦ t ⟧sas ρ * ⟦ ts ⟧sts ρ ⟦ [] ⟧sns ρ = 0 ⟦ (k , ts) ∷ [] ⟧sns ρ = k * ⟦ ts ⟧sts ρ ⟦ (k , ts) ∷ n ⟧sns ρ = k * ⟦ ts ⟧sts ρ + ⟦ n ⟧sns ρ atomEnv : Env Var → Env SubAtom atomEnv ρ x = ⟦ x ⟧sa ρ atomEnvS : Env Var → Env SubAtom atomEnvS ρ x = ⟦ x ⟧sas ρ instance EncodeSubAtom : TreeEncoding SubAtom EncodeSubAtom = treeEncoding enc dec emb where enc : SubAtom → TreeRep encNF : SubNF → TreeRep encNFs : SubNF → List TreeRep encTm : Tm SubAtom → List TreeRep enc (var x) = node x [] enc (a ⟨-⟩ b) = node 0 (encNF a ∷ encNF b ∷ []) encNF n = node 0 (encNFs n) encNFs [] = [] encNFs ((n , t) ∷ ns) = node n (encTm t) ∷ encNFs ns encTm [] = [] encTm (x ∷ xs) = enc x ∷ encTm xs dec : TreeRep → Maybe SubAtom decNF : TreeRep → Maybe SubNF decNFs : List TreeRep → Maybe SubNF decTm : List TreeRep → Maybe (Tm SubAtom) dec (node x []) = just (var x) dec (node _ (t ∷ t₁ ∷ [])) = _⟨-⟩_ <$> decNF t <*> decNF t₁ dec _ = nothing decNF (leaf _) = nothing decNF (node _ ts) = decNFs ts decNFs (node n ts ∷ ts₁) = _∷_ <$> (_,_ n <$> decTm ts) <*> decNFs ts₁ decNFs _ = just [] decTm [] = just [] decTm (x ∷ ts) = _∷_ <$> dec x <*> decTm ts emb : ∀ a → dec (enc a) ≡ just a embNFs : ∀ n → decNFs (encNFs n) ≡ just n embTm : ∀ t → decTm (encTm t) ≡ just t emb (var x) = refl emb (a ⟨-⟩ b) = _⟨-⟩_ =$= embNFs a =*= embNFs b embNFs [] = refl embNFs ((n , t) ∷ ns) = _∷_ =$= (_,_ n =$= embTm t) =*= embNFs ns embTm [] = refl embTm (x ∷ xs) = _∷_ =$= emb x =*= embTm xs EqSubAtom : Eq SubAtom EqSubAtom = EqByTreeEncoding OrdSubAtom : Ord SubAtom OrdSubAtom = OrdByTreeEncoding _-nf′_ : SubNF → SubNF → SubNF a -nf′ b = case cancel a b of λ where (x , []) → x ([] , _) → [] (a′ , b′) → [ 1 , [ a′ ⟨-⟩ b′ ] ] data IsSubtraction : SubNF → Set where _⟨-⟩_ : ∀ a b → IsSubtraction [ 1 , [ a ⟨-⟩ b ] ] no : ∀ {a} → IsSubtraction a is-subtraction : ∀ a → IsSubtraction a is-subtraction [ 1 , [ a ⟨-⟩ b ] ] = a ⟨-⟩ b is-subtraction a = no infixl 6 _-nf_ infixl 7 _*nf₁_ _*tm_ _*ktm_ _*ktm′_ _-nf_ : SubNF → SubNF → SubNF a -nf b with is-subtraction a _ -nf c | a ⟨-⟩ b = a -nf′ (b +nf c) a -nf b | no = a -nf′ b data IsSubtractionTm : Nat × Tm SubAtom → Set where _⟨-⟩_ : ∀ a b → IsSubtractionTm (1 , [ a ⟨-⟩ b ]) no : ∀ {a} → IsSubtractionTm a is-subtraction-tm : ∀ a → IsSubtractionTm a is-subtraction-tm (1 , [ a ⟨-⟩ b ]) = a ⟨-⟩ b is-subtraction-tm a = no _*nf₁_ : SubNF → SubNF → SubNF _*ktm′_ : Nat × Tm SubAtom → SubNF → SubNF _*tm_ : Nat × Tm SubAtom → Nat × Tm SubAtom → SubNF s *tm t with is-subtraction-tm t s *tm _ | b ⟨-⟩ c = s *ktm′ b -nf s *ktm′ c (a , x) *tm (b , y) | no = [ a * b , merge x y ] t *ktm′ [] = [] t *ktm′ (x ∷ a) = t *tm x +nf t *ktm′ a _*ktm_ : Nat × Tm SubAtom → SubNF → SubNF t *ktm a with is-subtraction-tm t _ *ktm c | a ⟨-⟩ b = a *nf₁ c -nf b *nf₁ c t *ktm a | no = t *ktm′ a [] *nf₁ b = [] (t ∷ a) *nf₁ b = t *ktm b +nf (a *nf₁ b) normSub : SubExp → SubNF normSub (var x) = [ 1 , [ var x ] ] normSub (lit 0) = [] normSub (lit n) = [ n , [] ] normSub (e ⟨+⟩ e₁) = normSub e +nf normSub e₁ normSub (e ⟨-⟩ e₁) = normSub e -nf normSub e₁ normSub (e ⟨*⟩ e₁) = normSub e *nf₁ normSub e₁
{ "alphanum_fraction": 0.5061349693, "avg_line_length": 25.7368421053, "ext": "agda", "hexsha": "6394b1bde4dceb7fb8fe8e87c0502d06feb2d9ce", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Tactic/Nat/Subtract/Exp.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Tactic/Nat/Subtract/Exp.agda", "max_line_length": 76, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Tactic/Nat/Subtract/Exp.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 2288, "size": 4890 }
postulate @0 A : Set _ : @0 Set → (Set → Set) → Set _ = λ @0 where A G → G A
{ "alphanum_fraction": 0.487804878, "avg_line_length": 11.7142857143, "ext": "agda", "hexsha": "715c22c00982f7df75f569a128c48d590c9bba2b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue4525a.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue4525a.agda", "max_line_length": 30, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue4525a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 38, "size": 82 }
-- New NO_POSITIVITY_CHECK pragma for data definitions and mutual -- blocks -- Skipping a single data definition. {-# NO_POSITIVITY_CHECK #-} data D : Set where lam : (D → D) → D
{ "alphanum_fraction": 0.7032967033, "avg_line_length": 22.75, "ext": "agda", "hexsha": "03f778c25227b2704c20d7240576f207fc049d22", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue1614a.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue1614a.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue1614a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 48, "size": 182 }
import Agda.Builtin.Nat as Nat public f : let open Nat public in Nat → Nat f x = x
{ "alphanum_fraction": 0.7023809524, "avg_line_length": 16.8, "ext": "agda", "hexsha": "24d37d225a982f0b8185a7a17533b3ef3e328fe3", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/uselesspublic.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/uselesspublic.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/uselesspublic.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 27, "size": 84 }
{-# OPTIONS --without-K #-} module sets.nat.properties where open import equality.core open import equality.calculus open import equality.reasoning open import function.isomorphism.core open import sets.nat.core open import sets.empty +-left-unit : ∀ n → 0 + n ≡ n +-left-unit n = refl +-right-unit : ∀ n → n + 0 ≡ n +-right-unit zero = refl +-right-unit (suc n) = ap suc (+-right-unit n) +-associativity : ∀ n m p → n + m + p ≡ n + (m + p) +-associativity 0 m p = refl +-associativity (suc n) m p = ap suc (+-associativity n m p) +-left-cancel : ∀ n → injective (_+_ n) +-left-cancel 0 p = p +-left-cancel (suc n) p = +-left-cancel n (ap pred p) right-distr : ∀ n m p → (n + m) * p ≡ n * p + m * p right-distr 0 m p = refl right-distr (suc n) m p = begin p + (n + m) * p ≡⟨ ap (_+_ p) (right-distr n m p) ⟩ p + (n * p + m * p) ≡⟨ sym (+-associativity p (n * p) (m * p)) ⟩ p + n * p + m * p ∎ where open ≡-Reasoning *-left-unit : ∀ n → 1 * n ≡ n *-left-unit n = +-right-unit n *-right-unit : ∀ n → n * 1 ≡ n *-right-unit zero = refl *-right-unit (suc n) = ap suc (*-right-unit n) *-associativity : ∀ n m p → n * m * p ≡ n * (m * p) *-associativity 0 m p = refl *-associativity (suc n) m p = right-distr m (n * m) p · ap (λ z → (m * p) + z) (*-associativity n m p) +-commutativity : ∀ n m → n + m ≡ m + n +-commutativity 0 m = sym (+-right-unit m) +-commutativity (suc n) m = begin suc (n + m) ≡⟨ ap suc (+-commutativity n m) ⟩ suc (m + n) ≡⟨ lem m n ⟩ m + suc n ∎ where open ≡-Reasoning lem : ∀ n m → suc n + m ≡ n + suc m lem 0 m = refl lem (suc n) m = ap suc (lem n m) left-distr : ∀ n m p → n * (m + p) ≡ n * m + n * p left-distr 0 m p = refl left-distr (suc n) m p = begin m + p + n * (m + p) ≡⟨ +-associativity m p _ ⟩ m + (p + n * (m + p)) ≡⟨ ap (λ z → m + (p + z)) (left-distr n m p) ⟩ m + (p + (n * m + n * p)) ≡⟨ ap (_+_ m) (sym (+-associativity p (n * m) _)) ⟩ m + (p + n * m + n * p) ≡⟨ ap (λ z → m + (z + n * p)) (+-commutativity p (n * m)) ⟩ m + (n * m + p + n * p) ≡⟨ ap (_+_ m) (+-associativity (n * m) p _) ⟩ m + (n * m + (p + n * p)) ≡⟨ sym (+-associativity m (n * m) _) ⟩ m + n * m + (p + n * p) ∎ where open ≡-Reasoning left-zero : ∀ n → 0 * n ≡ 0 left-zero n = refl right-zero : ∀ n → n * 0 ≡ 0 right-zero 0 = refl right-zero (suc n) = right-zero n *-commutativity : ∀ n m → n * m ≡ m * n *-commutativity 0 m = sym (right-zero m) *-commutativity (suc n) m = begin m + n * m ≡⟨ ap₂ _+_ (sym (*-right-unit m)) (*-commutativity n m) ⟩ m * 1 + m * n ≡⟨ sym (left-distr m 1 n) ⟩ m * suc n ∎ where open ≡-Reasoning suc-fixpoint : ∀ {n} → ¬ (suc n ≡ n) suc-fixpoint {zero} () suc-fixpoint {suc n} p = suc-fixpoint (suc-inj p)
{ "alphanum_fraction": 0.5077628793, "avg_line_length": 25.7636363636, "ext": "agda", "hexsha": "bcbcdbff0d0819e8636415eeb79e3ceae227ec22", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/nat/properties.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/nat/properties.agda", "max_line_length": 60, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets/nat/properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 1182, "size": 2834 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Monoidal.Structure where open import Level open import Categories.Category open import Categories.Category.Monoidal.Core record MonoidalCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field U : Category o ℓ e monoidal : Monoidal U module U = Category U module monoidal = Monoidal monoidal open U public open monoidal public
{ "alphanum_fraction": 0.7149758454, "avg_line_length": 20.7, "ext": "agda", "hexsha": "ac815f46ce1aeb841dbc7e6ab09da3365a9519b5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Category/Monoidal/Structure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Category/Monoidal/Structure.agda", "max_line_length": 59, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Category/Monoidal/Structure.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 108, "size": 414 }
-- Andreas, 2019-07-23, issue #3932 -- -- Mutual blocks are not supported in mutual blocks module _ where module M where mutual A : Set1 A = Set mutual B : Set1 B = A module N where mutual A : Set1 A = Set mutual A = Set module O where mutual A : Set1 mutual A = Set -- WAS: internal errors -- EXPECTED ERRORS: -- -- * mutual blocks in mutual blocks are not supported -- -- * The following names are declared but not accompanied by a definition: A -- when scope checking the declaration -- module O where
{ "alphanum_fraction": 0.6170940171, "avg_line_length": 13.6046511628, "ext": "agda", "hexsha": "3ebeb45f80dd0e368061d977d53ab35b5b4a8209", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue3932.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue3932.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3932.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 165, "size": 585 }
-- Andreas, 2021-11-19, issue #5657 reported by J Barrett -- Regression in 2.6.2: internal error instead of error message record R : Set₁ where field A : Set postulate r : R open R r fail : Set fail = r .A -- WAS: -- An internal error has occurred. Please report this as a bug. -- Location of the error: __IMPOSSIBLE__, called at src/full/Agda/TypeChecking/Rules/Application.hs:968 -- Expected: -- Set should be a function type, but it isn't -- when checking that r is a valid argument to a function of type Set
{ "alphanum_fraction": 0.7225433526, "avg_line_length": 25.95, "ext": "agda", "hexsha": "d437e38e60805a17bc6738725eef67da7da8c01f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue5657.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue5657.agda", "max_line_length": 103, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue5657.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 148, "size": 519 }
{- Day 3 input -} module a3-input where open import Data.Nat open import Data.List hiding (lookup;allFin) renaming (map to mapList) open import Data.Vec input : List (Vec ℕ 12) input = (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ (0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ 0 ∷ []) ∷ (1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ []) ∷ (0 ∷ 1 ∷ 1 ∷ 0 ∷ 0 ∷ 1 ∷ 1 ∷ 1 ∷ 0 ∷ 1 ∷ 0 ∷ 1 ∷ []) ∷ []
{ "alphanum_fraction": 0.1753800358, "avg_line_length": 68.2485207101, "ext": "agda", "hexsha": "88143783e34bb30388c0e8712062ac7d2831dec6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "834bc9e291a76bdbcd58cbff9805161f1b1cfe71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "felixwellen/adventOfCode", "max_forks_repo_path": "a3-input.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "834bc9e291a76bdbcd58cbff9805161f1b1cfe71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "felixwellen/adventOfCode", "max_issues_repo_path": "a3-input.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "834bc9e291a76bdbcd58cbff9805161f1b1cfe71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "felixwellen/adventOfCode", "max_stars_repo_path": "a3-input.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 65048, "size": 69204 }
module Generic.Function.Elim where open import Generic.Core AllAny : ∀ {ι α β γ δ} {I : Set ι} {A : Set α} {C : I -> Set γ} -> (B : I -> A -> Set β) -> (∀ x -> (∀ {j} -> B j x -> C j) -> Set δ) -> (xs : List A) -> (∀ {j} -> Any (B j) xs -> C j) -> Set δ AllAny B D [] k = ⊤ AllAny B D (x ∷ []) k = D x k AllAny B D (x ∷ y ∷ xs) k = D x (k ∘ inj₁) × AllAny B D (y ∷ xs) (k ∘ inj₂) data VarView {ι β} {I : Set ι} : Desc I β -> Set where yes-var : ∀ {i} -> VarView (var i) no-var : ∀ {D} -> VarView D varView : ∀ {ι β} {I : Set ι} -> (D : Desc I β) -> VarView D varView (var i) = yes-var varView D = no-var mutual Hyp : ∀ {ι β γ} {I : Set ι} {B} -> (∀ {i} -> B i -> Set γ) -> (D : Desc I β) -> ⟦ D ⟧ B -> Set (β ⊔ γ) Hyp {β = β} C (var i) y = Lift β (C y) Hyp C (π i q D) f = Hypᵇ i C D f Hyp C (D ⊛ E) (x , y) = Hyp C D x × Hyp C E y Hypᵇ : ∀ {ι α β γ δ q q′} {I : Set ι} {B} i -> (∀ {i} -> B i -> Set γ) -> (D : Binder α β δ i q′ I) -> ⟦ i / D ⟧ᵇ q B -> Set (β ⊔ γ) Hypᵇ {γ = γ} {q = q} i C (coerce (A , D)) f = Coerce′ (cong (γ ⊔_) q) $ Pi i A λ x -> Hyp C (D x) (appPi i (uncoerce′ q f) x) mutual Elim : ∀ {ι β γ} {I : Set ι} {B} -> (∀ {i} -> B i -> Set γ) -> (D : Desc I β) -> (∀ {j} -> Extend D B j -> B j) -> Set (β ⊔ γ) Elim {β = β} C (var i) k = Lift β (C (k lrefl)) Elim C (π i q D) k = Elimᵇ i C D k Elim C (D ⊛ E) k with varView D ... | yes-var = ∀ {x} -> C x -> Elim C E (k ∘ _,_ x) ... | no-var = ∀ {x} -> Hyp C D x -> Elim C E (k ∘ _,_ x) Elimᵇ : ∀ {ι α β γ δ q q′} {I : Set ι} {B} i -> (∀ {i} -> B i -> Set γ) -> (D : Binder α β δ i q′ I) -> (∀ {j} -> Extendᵇ i D q B j -> B j) -> Set (β ⊔ γ) Elimᵇ {γ = γ} {q = q} i C (coerce (A , D)) k = Coerce′ (cong (γ ⊔_) q) $ Pi i A λ x -> Elim C (D x) (k ∘ coerce′ q ∘ _,_ x) module _ {ι β γ} {I : Set ι} {D₀ : Data (Desc I β)} (C : ∀ {j} -> μ D₀ j -> Set γ) where K : Name -> Type -> Type -> (Ds : List (Desc I β)) -> All (const Name) Ds -> Set (ι ⊔ β) K d a b Ds ns = ∀ {j} -> Node D₀ (packData d a b Ds ns) j -> μ D₀ j Elims : ∀ d a b (Ds : List (Desc I β)) ns -> K d a b Ds ns -> Set (β ⊔ γ) Elims d a b Ds ns = AllAny (λ j D -> Extend D (μ D₀) j) (Elim C) Ds module _ (hs : Elims (dataName D₀) (parsTele D₀) (indsTele D₀) (consTypes D₀) (consNames D₀) node) where {-# TERMINATING #-} mutual elimHyp : (D : Desc I β) -> (d : ⟦ D ⟧ (μ D₀)) -> Hyp C D d elimHyp (var i) d = lift (elim d) elimHyp (π i q D) f = elimHypᵇ i D f elimHyp (D ⊛ E) (x , y) = elimHyp D x , elimHyp E y elimHypᵇ : ∀ {α δ q q′} i -> (D : Binder α β δ i q′ I) -> (f : ⟦ i / D ⟧ᵇ q (μ D₀)) -> Hypᵇ i C D f elimHypᵇ {q = q} i (coerce (A , D)) f = coerce′ (cong (_⊔_ γ) q) (lamPi i λ x -> elimHyp (D x) (appPi i (uncoerce′ q f) x)) elimExtend : ∀ {j} -> (D : Desc I β) {k : ∀ {j} -> Extend D (μ D₀) j -> μ D₀ j} -> Elim C D k -> (e : Extend D (μ D₀) j) -> C (k e) elimExtend (var i) z lrefl = lower z elimExtend (π i q D) h p = elimExtendᵇ i D h p elimExtend (D ⊛ E) h (d , e) with varView D ... | yes-var = elimExtend E (h (elim d)) e ... | no-var = elimExtend E (h (elimHyp D d)) e elimExtendᵇ : ∀ {α δ q q′ j} i -> (D : Binder α β δ i q′ I) {k : ∀ {j} -> Extendᵇ i D q (μ D₀) j -> μ D₀ j} -> Elimᵇ i C D k -> (p : Extendᵇ i D q (μ D₀) j) -> C (k p) elimExtendᵇ {q = q} i (coerce (A , D)) h p with p | inspectUncoerce′ q p ... | _ | (x , e) , refl = elimExtend (D x) (appPi i (uncoerce′ (cong (γ ⊔_) q) h) x) e elimAny : ∀ {j} (Ds : List (Desc I β)) d a b ns {k : K d a b Ds ns} -> Elims d a b Ds ns k -> (a : Node D₀ (packData d a b Ds ns) j) -> C (k a) elimAny [] d a b tt tt () elimAny (D ∷ []) d a b (n , ns) h e = elimExtend D h e elimAny (D ∷ E ∷ Ds) d a b (n , ns) (h , hs) (inj₁ e) = elimExtend D h e elimAny (D ∷ E ∷ Ds) d a b (n , ns) (h , hs) (inj₂ r) = elimAny (E ∷ Ds) d a b ns hs r elim : ∀ {j} -> (d : μ D₀ j) -> C d elim (node e) = elimAny (consTypes D₀) (dataName D₀) (parsTele D₀) (indsTele D₀) (consNames D₀) hs e
{ "alphanum_fraction": 0.3941212999, "avg_line_length": 41.6465517241, "ext": "agda", "hexsha": "eeea1bb5c941c7f548371e74fe2ca7585d639295", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Function/Elim.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Function/Elim.agda", "max_line_length": 95, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Function/Elim.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 1977, "size": 4831 }
{-# OPTIONS --without-K #-} open import lib.Base open import lib.PathGroupoid open import lib.PathFunctor open import lib.NType module lib.Equivalences where {- We use the half-adjoint definition of equivalences (but this fact should be invisible to the user of the library). The constructor of the type of equivalences is [equiv], it takes two maps and the two proofs that the composites are equal: [equiv to from to-from from-to] The type of equivalences between two types [A] and [B] can be written either [A ≃ B] or [Equiv A B]. Given an equivalence [e] : [A ≃ B], you can extract the two maps as follows: [–> e] : [A → B] and [<– e] : [B → A] (the dash is an en dash) The proofs that the composites are the identities are [<–-inv-l] and [<–-inv-r]. The identity equivalence on [A] is [ide A], the composition of two equivalences is [_∘e_] (function composition order) and the inverse of an equivalence is [_⁻¹] -} module _ {i} {j} {A : Type i} {B : Type j} where record is-equiv (f : A → B) : Type (lmax i j) where field g : B → A f-g : (b : B) → f (g b) == b g-f : (a : A) → g (f a) == a adj : (a : A) → ap f (g-f a) == f-g (f a) abstract adj' : (b : B) → ap g (f-g b) == g-f (g b) adj' b = anti-whisker-left (ap g (f-g (f (g b)))) $ ! $ ap g (f-g (f (g b))) ∙ g-f (g b) =⟨ ! $ htpy-natural-app=idf f-g b |in-ctx (λ p → ap g p ∙ g-f (g b)) ⟩ ap g (ap (f ∘ g) (f-g b)) ∙ g-f (g b) =⟨ ! $ ap-∘ g (f ∘ g) (f-g b) |in-ctx (λ p → p ∙ g-f (g b)) ⟩ ap (g ∘ f ∘ g) (f-g b) ∙ g-f (g b) =⟨ htpy-natural (g-f ∘ g) (f-g b) ⟩ g-f (g (f (g b))) ∙ ap g (f-g b) =⟨ ! $ htpy-natural-app=idf g-f (g b) |in-ctx (λ p → p ∙ ap g (f-g b)) ⟩ ap (g ∘ f) (g-f (g b)) ∙ ap g (f-g b) =⟨ ap-∘ g f (g-f (g b)) |in-ctx (λ p → p ∙ ap g (f-g b)) ⟩ ap g (ap f (g-f (g b))) ∙ ap g (f-g b) =⟨ adj (g b) |in-ctx (λ p → ap g p ∙ ap g (f-g b)) ⟩ ap g (f-g (f (g b))) ∙ ap g (f-g b) ∎ {- In order to prove that something is an equivalence, you have to give an inverse and a proof that it’s an inverse (you don’t need the adj part). [is-eq] is a very, very bad name. -} is-eq : (f : A → B) (g : B → A) (f-g : (b : B) → f (g b) == b) (g-f : (a : A) → g (f a) == a) → is-equiv f is-eq f g f-g g-f = record {g = g; f-g = f-g'; g-f = g-f; adj = adj} where f-g' : (b : B) → f (g b) == b f-g' b = ! (ap (f ∘ g) (f-g b)) ∙ ap f (g-f (g b)) ∙ f-g b adj : (a : A) → ap f (g-f a) == f-g' (f a) adj a = ap f (g-f a) =⟨ ! (!-inv-l (ap (f ∘ g) (f-g (f a)))) |in-ctx (λ q → q ∙ ap f (g-f a)) ⟩ (! (ap (f ∘ g) (f-g (f a))) ∙ ap (f ∘ g) (f-g (f a))) ∙ ap f (g-f a) =⟨ ∙-assoc (! (ap (f ∘ g) (f-g (f a)))) (ap (f ∘ g) (f-g (f a))) _ ⟩ ! (ap (f ∘ g) (f-g (f a))) ∙ ap (f ∘ g) (f-g (f a)) ∙ ap f (g-f a) =⟨ lemma |in-ctx (λ q → ! (ap (f ∘ g) (f-g (f a))) ∙ q) ⟩ ! (ap (f ∘ g) (f-g (f a))) ∙ ap f (g-f (g (f a))) ∙ f-g (f a) ∎ where lemma : ap (f ∘ g) (f-g (f a)) ∙ ap f (g-f a) == ap f (g-f (g (f a))) ∙ f-g (f a) lemma = ap (f ∘ g) (f-g (f a)) ∙ ap f (g-f a) =⟨ htpy-natural-app=idf f-g (f a) |in-ctx (λ q → q ∙ ap f (g-f a)) ⟩ f-g (f (g (f a))) ∙ ap f (g-f a) =⟨ ! (ap-idf (ap f (g-f a))) |in-ctx (λ q → f-g (f (g (f a))) ∙ q) ⟩ f-g (f (g (f a))) ∙ ap (idf B) (ap f (g-f a)) =⟨ ! (htpy-natural f-g (ap f (g-f a))) ⟩ ap (f ∘ g) (ap f (g-f a)) ∙ f-g (f a) =⟨ ap-∘ f g (ap f (g-f a)) |in-ctx (λ q → q ∙ f-g (f a)) ⟩ ap f (ap g (ap f (g-f a))) ∙ f-g (f a) =⟨ ∘-ap g f (g-f a) ∙ htpy-natural-app=idf g-f a |in-ctx (λ q → ap f q ∙ f-g (f a)) ⟩ ap f (g-f (g (f a))) ∙ f-g (f a) ∎ infix 30 _≃_ _≃_ : ∀ {i j} (A : Type i) (B : Type j) → Type (lmax i j) A ≃ B = Σ (A → B) is-equiv Equiv = _≃_ module _ {i} {j} {A : Type i} {B : Type j} where equiv : (f : A → B) (g : B → A) (f-g : (b : B) → f (g b) == b) (g-f : (a : A) → g (f a) == a) → A ≃ B equiv f g f-g g-f = (f , is-eq f g f-g g-f) –> : (e : A ≃ B) → (A → B) –> e = fst e <– : (e : A ≃ B) → (B → A) <– e = is-equiv.g (snd e) <–-inv-l : (e : A ≃ B) (a : A) → (<– e (–> e a) == a) <–-inv-l e a = is-equiv.g-f (snd e) a <–-inv-r : (e : A ≃ B) (b : B) → (–> e (<– e b) == b) <–-inv-r e b = is-equiv.f-g (snd e) b <–-inv-adj : (e : A ≃ B) (a : A) → ap (–> e) (<–-inv-l e a) == <–-inv-r e (–> e a) <–-inv-adj e a = is-equiv.adj (snd e) a <–-inv-adj' : (e : A ≃ B) (b : B) → ap (<– e) (<–-inv-r e b) == <–-inv-l e (<– e b) <–-inv-adj' e b = is-equiv.adj' (snd e) b -- Equivalences are "injective" equiv-inj : (e : A ≃ B) {x y : A} → (–> e x == –> e y → x == y) equiv-inj e {x} {y} p = ! (<–-inv-l e x) ∙ ap (<– e) p ∙ <–-inv-l e y idf-is-equiv : ∀ {i} (A : Type i) → is-equiv (idf A) idf-is-equiv A = is-eq _ (idf A) (λ _ → idp) (λ _ → idp) ide : ∀ {i} (A : Type i) → A ≃ A ide A = equiv (idf A) (idf A) (λ _ → idp) (λ _ → idp) infixr 80 _∘e_ infixr 80 _∘ise_ _∘e_ : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} → B ≃ C → A ≃ B → A ≃ C e1 ∘e e2 = ((–> e1 ∘ –> e2) , record {g = (<– e2 ∘ <– e1); f-g = (λ c → ap (–> e1) (<–-inv-r e2 (<– e1 c)) ∙ <–-inv-r e1 c); g-f = (λ a → ap (<– e2) (<–-inv-l e1 (–> e2 a)) ∙ <–-inv-l e2 a); adj = λ a → ap (–> e1 ∘ –> e2) (ap (<– e2) (<–-inv-l e1 (–> e2 a)) ∙ <–-inv-l e2 a) =⟨ ap-∘ (–> e1) (–> e2) (ap (<– e2) (<–-inv-l e1 (–> e2 a)) ∙ <–-inv-l e2 a) ⟩ ap (–> e1) (ap (–> e2) (ap (<– e2) (<–-inv-l e1 (–> e2 a)) ∙ <–-inv-l e2 a)) =⟨ ap-∙ (–> e2) (ap (<– e2) (<–-inv-l e1 (–> e2 a))) (<–-inv-l e2 a) |in-ctx ap (–> e1) ⟩ ap (–> e1) (ap (–> e2) (ap (<– e2) (<–-inv-l e1 (–> e2 a))) ∙ ap (–> e2) (<–-inv-l e2 a)) =⟨ ! (ap-∘ (–> e2) (<– e2) (<–-inv-l e1 (–> e2 a))) ∙2 <–-inv-adj e2 a |in-ctx ap (–> e1) ⟩ ap (–> e1) (ap (–> e2 ∘ <– e2) (<–-inv-l e1 (–> e2 a)) ∙ <–-inv-r e2 (–> e2 a)) =⟨ htpy-natural (<–-inv-r e2) (<–-inv-l e1 (–> e2 a)) |in-ctx ap (–> e1) ⟩ ap (–> e1) (<–-inv-r e2 (<– e1 ((–> e1 ∘ –> e2) a)) ∙ ap (λ z → z) (<–-inv-l e1 (–> e2 a))) =⟨ <–-inv-r e2 (<– e1 ((–> e1 ∘ –> e2) a)) ∙ₗ ap-idf (<–-inv-l e1 (–> e2 a)) |in-ctx ap (–> e1) ⟩ ap (–> e1) (<–-inv-r e2 (<– e1 ((–> e1 ∘ –> e2) a)) ∙ <–-inv-l e1 (–> e2 a)) =⟨ ap-∙ (–> e1) (<–-inv-r e2 (<– e1 ((–> e1 ∘ –> e2) a))) (<–-inv-l e1 (–> e2 a)) ⟩ ap (–> e1) (<–-inv-r e2 (<– e1 ((–> e1 ∘ –> e2) a))) ∙ ap (–> e1) (<–-inv-l e1 (–> e2 a)) =⟨ ap (–> e1) (<–-inv-r e2 (<– e1 ((–> e1 ∘ –> e2) a))) ∙ₗ (<–-inv-adj e1 (–> e2 a)) ⟩ ap (–> e1) (<–-inv-r e2 (<– e1 ((–> e1 ∘ –> e2) a))) ∙ <–-inv-r e1 ((–> e1 ∘ –> e2) a) ∎}) _∘ise_ : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} {f : A → B} {g : B → C} → is-equiv g → is-equiv f → is-equiv (g ∘ f) i1 ∘ise i2 = snd ((_ , i1) ∘e (_ , i2)) infix 120 _⁻¹ _⁻¹ : ∀ {i j} {A : Type i} {B : Type j} → (A ≃ B) → (B ≃ A) e ⁻¹ = equiv (<– e) (–> e) (<–-inv-l e) (<–-inv-r e) {- Equational reasoning for equivalences -} infix 15 _≃∎ infixr 10 _≃⟨_⟩_ _≃⟨_⟩_ : ∀ {i j k} (A : Type i) {B : Type j} {C : Type k} → A ≃ B → B ≃ C → A ≃ C A ≃⟨ u ⟩ v = v ∘e u _≃∎ : ∀ {i} (A : Type i) → A ≃ A _≃∎ = ide {- lifting is an equivalence -} lower-equiv : ∀ {i j} {A : Type i} → Lift {j = j} A ≃ A lower-equiv = equiv lower lift (λ _ → idp) (λ _ → idp) {- Any contractible type is equivalent to (all liftings of) the unit type -} module _ {i} {A : Type i} (h : is-contr A) where contr-equiv-Unit : A ≃ Unit contr-equiv-Unit = equiv (λ _ → unit) (λ _ → fst h) (λ _ → idp) (snd h) contr-equiv-LiftUnit : ∀ {j} → A ≃ Lift {j = j} Unit contr-equiv-LiftUnit = lower-equiv ⁻¹ ∘e contr-equiv-Unit {- An equivalence induces an equivalence on the path spaces -} module _ {i j} {A : Type i} {B : Type j} (e : A ≃ B) where private abstract left-inverse : {x y : A} (p : x == y) → equiv-inj e (ap (–> e) p) == p left-inverse idp = !-inv-l (<–-inv-l e _) right-inverse : {x y : A} (p : –> e x == –> e y) → ap (–> e) (equiv-inj e p) == p right-inverse {x} {y} p = ap f (! (g-f x) ∙ ap g p ∙ (g-f y)) =⟨ ap-∙ f (! (g-f x)) (ap g p ∙ (g-f y)) ⟩ ap f (! (g-f x)) ∙ ap f (ap g p ∙ (g-f y)) =⟨ ap-∙ f (ap g p) (g-f y) |in-ctx (λ q → ap f (! (g-f x)) ∙ q) ⟩ ap f (! (g-f x)) ∙ ap f (ap g p) ∙ ap f (g-f y) =⟨ ∘-ap f g p |in-ctx (λ q → ap f (! (g-f x)) ∙ q ∙ ap f (g-f y)) ⟩ ap f (! (g-f x)) ∙ ap (f ∘ g) p ∙ ap f (g-f y) =⟨ adj y |in-ctx (λ q → ap f (! (g-f x)) ∙ ap (f ∘ g) p ∙ q) ⟩ ap f (! (g-f x)) ∙ ap (f ∘ g) p ∙ (f-g (f y)) =⟨ ap-! f (g-f x) |in-ctx (λ q → q ∙ ap (f ∘ g) p ∙ (f-g (f y))) ⟩ ! (ap f (g-f x)) ∙ ap (f ∘ g) p ∙ (f-g (f y)) =⟨ adj x |in-ctx (λ q → ! q ∙ ap (f ∘ g) p ∙ (f-g (f y))) ⟩ ! (f-g (f x)) ∙ ap (f ∘ g) p ∙ (f-g (f y)) =⟨ htpy-natural f-g p |in-ctx (λ q → ! (f-g (f x)) ∙ q) ⟩ ! (f-g (f x)) ∙ (f-g (f x)) ∙ ap (idf B) p =⟨ ! (∙-assoc (! (f-g (f x))) (f-g (f x)) (ap (idf B) p)) ∙ ap (λ q → q ∙ ap (idf B) p) (!-inv-l (f-g (f x))) ∙ ap-idf p ⟩ p ∎ where f : A → B f = fst e open is-equiv (snd e) equiv-ap : (x y : A) → (x == y) ≃ (–> e x == –> e y) equiv-ap x y = equiv (ap (–> e)) (equiv-inj e) right-inverse left-inverse {- Equivalent types have the same truncation level -} equiv-preserves-level : ∀ {i j} {A : Type i} {B : Type j} {n : ℕ₋₂} (e : A ≃ B) → (has-level n A → has-level n B) equiv-preserves-level {n = ⟨-2⟩} e (x , p) = (–> e x , (λ y → ap (–> e) (p _) ∙ <–-inv-r e y)) equiv-preserves-level {n = S n} e c = λ x y → equiv-preserves-level (equiv-ap (e ⁻¹) x y ⁻¹) (c (<– e x) (<– e y)) {- This is a collection of type equivalences involving basic type formers. We exclude Empty since Π₁-Empty requires λ=. -} module _ {j} {B : Unit → Type j} where Σ₁-Unit : Σ Unit B ≃ B unit Σ₁-Unit = equiv (λ {(unit , b) → b}) (λ b → (unit , b)) (λ _ → idp) (λ _ → idp) Π₁-Unit : Π Unit B ≃ B unit Π₁-Unit = equiv (λ f → f unit) (λ b _ → b) (λ _ → idp) (λ _ → idp) module _ {i} {A : Type i} where Σ₂-Unit : Σ A (λ _ → Unit) ≃ A Σ₂-Unit = equiv fst (λ a → (a , unit)) (λ _ → idp) (λ _ → idp) Π₂-Unit : Π A (λ _ → Unit) ≃ Unit Π₂-Unit = equiv (λ _ → unit) (λ _ _ → unit) (λ _ → idp) (λ _ → idp) module _ {i j k} {A : Type i} {B : A → Type j} {C : (a : A) → B a → Type k} where Σ-assoc : Σ (Σ A B) (uncurry C) ≃ Σ A (λ a → Σ (B a) (C a)) Σ-assoc = equiv (λ {((a , b) , c) → (a , (b , c))}) (λ {(a , (b , c)) → ((a , b) , c)}) (λ _ → idp) (λ _ → idp) curry-equiv : Π (Σ A B) (uncurry C) ≃ Π A (λ a → Π (B a) (C a)) curry-equiv = equiv curry uncurry (λ _ → idp) (λ _ → idp) {- The type-theoretic axiom of choice -} choice : Π A (λ a → Σ (B a) (λ b → C a b)) ≃ Σ (Π A B) (λ g → Π A (λ a → C a (g a))) choice = equiv f g (λ _ → idp) (λ _ → idp) where f = λ c → ((λ a → fst (c a)) , (λ a → snd (c a))) g = λ d → (λ a → (fst d a , snd d a)) {- Homotopy fibers -} hfiber : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) (y : B) → Type (lmax i j) hfiber {A = A} f y = Σ A (λ x → f x == y)
{ "alphanum_fraction": 0.4231275792, "avg_line_length": 40.9676258993, "ext": "agda", "hexsha": "ce0eabb334f2da7ca9ccbfe64af6cc8cc33aefad", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "core/lib/Equivalences.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "core/lib/Equivalences.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "core/lib/Equivalences.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5416, "size": 11389 }