Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K #-}
module PathStructure.Empty where
open import Equivalence
open import Types
split-path : {x y : ⊥} → x ≡ y → ⊥
split-path = J (λ _ _ _ → ⊥) id _ _
merge-path : {x y : ⊥} → ⊥ → x ≡ y
merge-path = 0-elim
split-merge-eq : {x y : ⊥} → (x ≡ y) ≃ ⊥
split-merge-eq
= split-path
, (merge-path , λ b → 0-elim b)
, (merge-path , J
(λ _ _ p → merge-path (split-path p) ≡ p)
(λ b → 0-elim b) _ _)
| {
"alphanum_fraction": 0.5437788018,
"avg_line_length": 21.7,
"ext": "agda",
"hexsha": "10088c6888bc6db111fe4d5bc49ad4efaf1630f4",
"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/PathStructure/Empty.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/PathStructure/Empty.agda",
"max_line_length": 47,
"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/PathStructure/Empty.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 174,
"size": 434
} |
module Interpreter where
open import Agda.Builtin.IO using (IO)
open import Agda.Builtin.Int using (pos)
open import Agda.Builtin.Unit using (⊤)
open import FFI.IO using (getContents; putStrLn; _>>=_; _>>_)
open import FFI.Data.Aeson using (Value; eitherDecode)
open import FFI.Data.Either using (Left; Right)
open import FFI.Data.String using (String; _++_)
open import FFI.Data.Text.Encoding using (encodeUtf8)
open import FFI.System.Exit using (exitWith; ExitFailure)
open import Luau.Syntax using (Block)
open import Luau.Syntax.FromJSON using (blockFromJSON)
open import Luau.Syntax.ToString using (blockToString)
open import Luau.Run using (run; return; done; error)
open import Luau.RuntimeError.ToString using (errToStringᴮ)
open import Luau.Value.ToString using (valueToString)
runBlock : ∀ {a} → Block a → IO ⊤
runBlock block with run block
runBlock block | return V D = putStrLn (valueToString V)
runBlock block | done D = putStrLn "nil"
runBlock block | error E D = putStrLn (errToStringᴮ E)
runJSON : Value → IO ⊤
runJSON value with blockFromJSON(value)
runJSON value | (Left err) = putStrLn ("Luau error: " ++ err) >> exitWith (ExitFailure (pos 1))
runJSON value | (Right block) = runBlock block
runString : String → IO ⊤
runString txt with eitherDecode (encodeUtf8 txt)
runString txt | (Left err) = putStrLn ("JSON error: " ++ err) >> exitWith (ExitFailure (pos 1))
runString txt | (Right value) = runJSON value
main : IO ⊤
main = getContents >>= runString
| {
"alphanum_fraction": 0.7484787018,
"avg_line_length": 37.9230769231,
"ext": "agda",
"hexsha": "fe311e57820c3003fc37dbfaa90bb0fb21789564",
"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/Interpreter.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/Interpreter.agda",
"max_line_length": 95,
"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/Interpreter.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 401,
"size": 1479
} |
------------------------------------------------------------------------
-- Propositional truncation
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
-- Partly following the HoTT book.
-- The module is parametrised by a notion of equality. The higher
-- constructor of the HIT defining the propositional truncation uses
-- path equality, but the supplied notion of equality is used for many
-- other things.
import Equality.Path as P
module H-level.Truncation.Propositional
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq hiding (elim)
open import Dec
open import Prelude
open import Logical-equivalence using (_⇔_)
open import Bijection equality-with-J as Bijection using (_↔_)
open import Embedding equality-with-J as Embedding hiding (id; _∘_)
open import Equality.Decidable-UIP equality-with-J
open import Equality.Path.Isomorphisms eq
open import Equivalence equality-with-J as Eq
using (_≃_; Is-equivalence)
open import Equivalence.Erased equality-with-J using (_≃ᴱ_)
open import Equivalence.Erased.Contractible-preimages equality-with-J
as ECP using (_⁻¹ᴱ_)
open import Equivalence-relation equality-with-J
open import Erased.Cubical eq as E
using (Erased; erased; Very-stableᴱ-≡; Erased-singleton)
import Erased.Stability equality-with-J as ES
open import Function-universe equality-with-J as F hiding (id; _∘_)
open import H-level equality-with-J as H-level
open import H-level.Closure equality-with-J
import H-level.Truncation.Church equality-with-J as Trunc
open import H-level.Truncation.Propositional.Erased eq as TE
using (∥_∥ᴱ; Surjectiveᴱ)
open import Injection equality-with-J using (_↣_)
open import Monad equality-with-J
open import Preimage equality-with-J as Preimage using (_⁻¹_)
open import Surjection equality-with-J as Surjection
using (_↠_; Split-surjective)
private
variable
a b c d p r ℓ : Level
A A₁ A₂ B B₁ B₂ C D : Type a
P Q : A → Type p
R : A → A → Type r
A↠B f k s x y : A
-- Propositional truncation.
data ∥_∥ (A : Type a) : Type a where
∣_∣ : A → ∥ A ∥
truncation-is-propositionᴾ : P.Is-proposition ∥ A ∥
-- The truncation produces propositions.
truncation-is-proposition : Is-proposition ∥ A ∥
truncation-is-proposition =
_↔_.from (H-level↔H-level 1) truncation-is-propositionᴾ
-- A dependent eliminator, expressed using paths.
record Elimᴾ′ {A : Type a} (P : ∥ A ∥ → Type p) : Type (a ⊔ p) where
no-eta-equality
field
∣∣ʳ : (x : A) → P ∣ x ∣
truncation-is-propositionʳ :
(p : P x) (q : P y) →
P.[ (λ i → P (truncation-is-propositionᴾ x y i)) ] p ≡ q
open Elimᴾ′ public
elimᴾ′ : Elimᴾ′ P → (x : ∥ A ∥) → P x
elimᴾ′ {A = A} {P = P} e = helper
where
module E′ = Elimᴾ′ e
helper : (x : ∥ A ∥) → P x
helper ∣ x ∣ = E′.∣∣ʳ x
helper (truncation-is-propositionᴾ x y i) =
E′.truncation-is-propositionʳ (helper x) (helper y) i
-- A possibly more useful dependent eliminator, expressed using paths.
record Elimᴾ {A : Type a} (P : ∥ A ∥ → Type p) : Type (a ⊔ p) where
no-eta-equality
field
∣∣ʳ : (x : A) → P ∣ x ∣
truncation-is-propositionʳ :
(x : ∥ A ∥) → P.Is-proposition (P x)
open Elimᴾ public
elimᴾ : Elimᴾ P → (x : ∥ A ∥) → P x
elimᴾ e = elimᴾ′ e′
where
module E′ = Elimᴾ e
e′ : Elimᴾ′ _
e′ .∣∣ʳ = E′.∣∣ʳ
e′ .truncation-is-propositionʳ _ _ =
P.heterogeneous-irrelevance E′.truncation-is-propositionʳ
-- A non-dependent eliminator, expressed using paths.
record Recᴾ (A : Type a) (B : Type b) : Type (a ⊔ b) where
no-eta-equality
field
∣∣ʳ : A → B
truncation-is-propositionʳ : P.Is-proposition B
open Recᴾ public
recᴾ : Recᴾ A B → ∥ A ∥ → B
recᴾ r = elimᴾ e
where
module R = Recᴾ r
e : Elimᴾ _
e .∣∣ʳ = R.∣∣ʳ
e .truncation-is-propositionʳ _ = R.truncation-is-propositionʳ
-- A dependently typed eliminator.
record Elim′ {A : Type a} (P : ∥ A ∥ → Type p) : Type (a ⊔ p) where
no-eta-equality
field
∣∣ʳ : (x : A) → P ∣ x ∣
truncation-is-propositionʳ :
(x : ∥ A ∥) → Is-proposition (P x)
open Elim′ public
elim′ : Elim′ P → (x : ∥ A ∥) → P x
elim′ e = elimᴾ e′
where
module E′ = Elim′ e
e′ : Elimᴾ _
e′ .∣∣ʳ = E′.∣∣ʳ
e′ .truncation-is-propositionʳ =
_↔_.to (H-level↔H-level 1) ∘ E′.truncation-is-propositionʳ
elim :
(P : ∥ A ∥ → Type p) →
(∀ x → Is-proposition (P x)) →
((x : A) → P ∣ x ∣) →
(x : ∥ A ∥) → P x
elim _ p f = elim′ λ where
.∣∣ʳ → f
.truncation-is-propositionʳ → p
-- Primitive "recursion".
record Rec′ (A : Type a) (B : Type b) : Type (a ⊔ b) where
no-eta-equality
field
∣∣ʳ : A → B
truncation-is-propositionʳ : Is-proposition B
open Rec′ public
rec′ : Rec′ A B → ∥ A ∥ → B
rec′ r = recᴾ r′
where
module R = Rec′ r
r′ : Recᴾ _ _
r′ .∣∣ʳ = R.∣∣ʳ
r′ .truncation-is-propositionʳ =
_↔_.to (H-level↔H-level 1) R.truncation-is-propositionʳ
rec : Is-proposition B → (A → B) → ∥ A ∥ → B
rec p f = rec′ λ where
.∣∣ʳ → f
.truncation-is-propositionʳ → p
-- A map function.
∥∥-map : (A → B) → ∥ A ∥ → ∥ B ∥
∥∥-map f = rec truncation-is-proposition (∣_∣ ∘ f)
-- The propositional truncation defined here is isomorphic to the one
-- defined in H-level.Truncation.Church.
∥∥↔∥∥ :
∀ ℓ {a} {A : Type a} →
∥ A ∥ ↔ Trunc.∥ A ∥ 1 (a ⊔ ℓ)
∥∥↔∥∥ ℓ = record
{ surjection = record
{ logical-equivalence = record
{ to = rec (Trunc.truncation-has-correct-h-level 1 ext)
Trunc.∣_∣₁
; from = lower {ℓ = ℓ} ∘
Trunc.rec 1
(↑-closure 1 truncation-is-proposition)
(lift ∘ ∣_∣)
}
; right-inverse-of = λ _ →
Trunc.truncation-has-correct-h-level 1 ext _ _
}
; left-inverse-of = λ _ → truncation-is-proposition _ _
}
-- If A is merely inhabited (with erased proofs), then A is merely
-- inhabited.
∥∥ᴱ→∥∥ : ∥ A ∥ᴱ → ∥ A ∥
∥∥ᴱ→∥∥ = TE.rec λ where
.TE.∣∣ʳ → ∣_∣
.TE.truncation-is-propositionʳ → truncation-is-proposition
-- In an erased context the propositional truncation operator defined
-- in H-level.Truncation.Propositional.Erased is equivalent to the one
-- defined here.
@0 ∥∥ᴱ≃∥∥ : ∥ A ∥ᴱ ≃ ∥ A ∥
∥∥ᴱ≃∥∥ = Eq.⇔→≃
TE.truncation-is-proposition
truncation-is-proposition
∥∥ᴱ→∥∥
(rec TE.truncation-is-proposition TE.∣_∣)
mutual
-- If A and B are logically equivalent, then functions of any kind can
-- be constructed from ∥ A ∥ to ∥ B ∥.
∥∥-cong-⇔ : ∀ {k} → A ⇔ B → ∥ A ∥ ↝[ k ] ∥ B ∥
∥∥-cong-⇔ A⇔B = ∥∥-cong-⇔′ (∣_∣ ∘ _⇔_.to A⇔B) (∣_∣ ∘ _⇔_.from A⇔B)
-- A variant of the previous result.
∥∥-cong-⇔′ : ∀ {k} → (A → ∥ B ∥) → (B → ∥ A ∥) → ∥ A ∥ ↝[ k ] ∥ B ∥
∥∥-cong-⇔′ A→∥B∥ B→∥A∥ =
from-equivalence $
Eq.⇔→≃
truncation-is-proposition
truncation-is-proposition
(rec truncation-is-proposition A→∥B∥)
(rec truncation-is-proposition B→∥A∥)
-- The truncation operator preserves all kinds of functions.
private
∥∥-cong-↣ : A ↣ B → ∥ A ∥ ↣ ∥ B ∥
∥∥-cong-↣ f = record
{ to = ∥∥-map (_↣_.to f)
; injective = λ _ → truncation-is-proposition _ _
}
∥∥-cong : A ↝[ k ] B → ∥ A ∥ ↝[ k ] ∥ B ∥
∥∥-cong {k = implication} = ∥∥-map
∥∥-cong {k = logical-equivalence} = ∥∥-cong-⇔
∥∥-cong {k = surjection} = ∥∥-cong-⇔ ∘ _↠_.logical-equivalence
∥∥-cong {k = bijection} = ∥∥-cong-⇔ ∘ from-isomorphism
∥∥-cong {k = equivalence} = ∥∥-cong-⇔ ∘ from-isomorphism
∥∥-cong {k = equivalenceᴱ} = ∥∥-cong-⇔ ∘ _≃ᴱ_.logical-equivalence
∥∥-cong {k = injection} = ∥∥-cong-↣
∥∥-cong {k = embedding} =
_↔_.to (↣↔Embedding ext
(mono₁ 1 truncation-is-proposition)
(mono₁ 1 truncation-is-proposition)) ∘
∥∥-cong-↣ ∘ Embedding.injection
-- A form of idempotence for binary sums.
idempotent : ∥ A ⊎ A ∥ ↔ ∥ A ∥
idempotent = ∥∥-cong-⇔ (record { to = [ id , id ]; from = inj₁ })
-- A generalised flattening lemma.
flatten′ :
(F : (Type ℓ → Type ℓ) → Type f) →
(∀ {G H} → (∀ {A} → G A → H A) → F G → F H) →
(F ∥_∥ → ∥ F id ∥) →
∥ F ∥_∥ ∥ ↔ ∥ F id ∥
flatten′ _ map f = record
{ surjection = record
{ logical-equivalence = record
{ to = rec truncation-is-proposition f
; from = ∥∥-map (map ∣_∣)
}
; right-inverse-of = λ _ → truncation-is-proposition _ _
}
; left-inverse-of = λ _ → truncation-is-proposition _ _
}
-- Nested truncations can be flattened.
flatten : ∥ ∥ A ∥ ∥ ↔ ∥ A ∥
flatten {A = A} = flatten′ (λ F → F A) (λ f → f) id
private
-- Another flattening lemma, given as an example of how flatten′ can
-- be used.
∥∃∥∥∥↔∥∃∥ : {B : A → Type b} →
∥ ∃ (∥_∥ ∘ B) ∥ ↔ ∥ ∃ B ∥
∥∃∥∥∥↔∥∃∥ {B = B} =
flatten′ (λ F → ∃ (F ∘ B))
(λ f → Σ-map id f)
(uncurry λ x → ∥∥-map (x ,_))
-- A universe-polymorphic variant of bind.
infixl 5 _>>=′_
_>>=′_ : ∥ A ∥ → (A → ∥ B ∥) → ∥ B ∥
x >>=′ f = _↔_.to flatten (∥∥-map f x)
-- The universe-polymorphic variant of bind is associative.
>>=′-associative :
(x : ∥ A ∥) {f : A → ∥ B ∥} {g : B → ∥ C ∥} →
x >>=′ (λ x → f x >>=′ g) ≡ x >>=′ f >>=′ g
>>=′-associative x {f} {g} = elim
(λ x → x >>=′ (λ x₁ → f x₁ >>=′ g) ≡ x >>=′ f >>=′ g)
(λ _ → ⇒≡ 1 truncation-is-proposition)
(λ _ → refl _)
x
instance
-- The propositional truncation operator is a monad.
raw-monad : ∀ {ℓ} → Raw-monad (∥_∥ {a = ℓ})
Raw-monad.return raw-monad = ∣_∣
Raw-monad._>>=_ raw-monad = _>>=′_
monad : ∀ {ℓ} → Monad (∥_∥ {a = ℓ})
Monad.raw-monad monad = raw-monad
Monad.left-identity monad x f = refl _
Monad.associativity monad x _ _ = >>=′-associative x
Monad.right-identity monad = elim
_
(λ _ → ⇒≡ 1 truncation-is-proposition)
(λ _ → refl _)
-- Surjectivity.
Surjective :
{A : Type a} {B : Type b} →
(A → B) → Type (a ⊔ b)
Surjective f = ∀ b → ∥ f ⁻¹ b ∥
-- The property Surjective f is a proposition.
Surjective-propositional : {f : A → B} → Is-proposition (Surjective f)
Surjective-propositional =
Π-closure ext 1 λ _ →
truncation-is-proposition
-- In an erased context surjectivity with erased proofs is equivalent
-- to surjectivity.
--
-- It appears to me as if neither direction of this equivalence can be
-- established if the erasure annotation is removed.
@0 Surjectiveᴱ≃Surjective : Surjectiveᴱ f ≃ Surjective f
Surjectiveᴱ≃Surjective {f = f} =
(∀ y → ∥ f ⁻¹ᴱ y ∥ᴱ) ↝⟨ (∀-cong ext λ _ → ∥∥ᴱ≃∥∥) ⟩
(∀ y → ∥ f ⁻¹ᴱ y ∥) ↝⟨ (∀-cong ext λ _ → ∥∥-cong (inverse ECP.⁻¹≃⁻¹ᴱ)) ⟩□
(∀ y → ∥ f ⁻¹ y ∥) □
-- The function ∣_∣ is surjective.
∣∣-surjective : Surjective (∣_∣ {A = A})
∣∣-surjective = elim
_
(λ _ → truncation-is-proposition)
(λ x → ∣ x , refl _ ∣)
-- Split surjective functions are surjective.
Split-surjective→Surjective :
{f : A → B} → Split-surjective f → Surjective f
Split-surjective→Surjective s = λ b → ∣ s b ∣
-- Being both surjective and an embedding is equivalent to being an
-- equivalence.
--
-- This is Corollary 4.6.4 from the first edition of the HoTT book
-- (the proof is perhaps not quite identical).
surjective×embedding≃equivalence :
{f : A → B} →
(Surjective f × Is-embedding f) ≃ Is-equivalence f
surjective×embedding≃equivalence {f = f} =
(Surjective f × Is-embedding f) ↔⟨ ∀-cong ext (λ _ → ∥∥↔∥∥ lzero) ×-cong F.id ⟩
(Trunc.Surjective _ f × Is-embedding f) ↝⟨ Trunc.surjective×embedding≃equivalence lzero ext ⟩□
Is-equivalence f □
-- If the underlying type is a proposition, then truncations of the
-- type are isomorphic to the type itself.
∥∥↔ : Is-proposition A → ∥ A ∥ ↔ A
∥∥↔ A-prop = record
{ surjection = record
{ logical-equivalence = record
{ to = rec A-prop id
; from = ∣_∣
}
; right-inverse-of = λ _ → refl _
}
; left-inverse-of = λ _ → truncation-is-proposition _ _
}
-- A type is a proposition if it is equivalent to the propositional
-- truncation of some type.
≃∥∥→Is-proposition : A ≃ ∥ B ∥ → Is-proposition A
≃∥∥→Is-proposition A≃∥B∥ a₁ a₂ = $⟨ truncation-is-proposition _ _ ⟩
_≃_.to A≃∥B∥ a₁ ≡ _≃_.to A≃∥B∥ a₂ ↝⟨ Eq.≃-≡ A≃∥B∥ ⟩□
a₁ ≡ a₂ □
-- A simple isomorphism involving propositional truncation.
∥∥×↔ : ∥ A ∥ × A ↔ A
∥∥×↔ =
drop-⊤-left-× λ a →
_⇔_.to contractible⇔↔⊤ $
propositional⇒inhabited⇒contractible
truncation-is-proposition
∣ a ∣
-- A variant of ∥∥×↔, introduced to ensure that the right-inverse-of
-- proof is, by definition, simple.
∥∥×≃ : (∥ A ∥ × A) ≃ A
∥∥×≃ = Eq.↔→≃
proj₂
(λ x → ∣ x ∣ , x)
refl
(λ _ → cong (_, _) (truncation-is-proposition _ _))
_ : _≃_.right-inverse-of ∥∥×≃ x ≡ refl _
_ = refl _
-- A variant of ∥∥×≃.
Erased-∥∥×≃ : (Erased ∥ A ∥ × A) ≃ A
Erased-∥∥×≃ = Eq.↔→≃
proj₂
(λ x → E.[ ∣ x ∣ ] , x)
refl
(λ (_ , x) →
cong (_, x) (E.[]-cong E.[ truncation-is-proposition _ _ ]))
_ : _≃_.right-inverse-of Erased-∥∥×≃ x ≡ refl _
_ = refl _
-- ∥_∥ commutes with _×_.
∥∥×∥∥↔∥×∥ : (∥ A ∥ × ∥ B ∥) ↔ ∥ A × B ∥
∥∥×∥∥↔∥×∥ = record
{ surjection = record
{ logical-equivalence = record
{ from = λ p → ∥∥-map proj₁ p , ∥∥-map proj₂ p
; to = λ { (x , y) →
rec truncation-is-proposition
(λ x → rec truncation-is-proposition
(λ y → ∣ x , y ∣)
y)
x }
}
; right-inverse-of = λ _ → truncation-is-proposition _ _
}
; left-inverse-of = λ _ →
×-closure 1 truncation-is-proposition
truncation-is-proposition
_ _
}
-- Variants of proj₁-closure.
private
H-level-×₁-lemma :
(A → ∥ B ∥) →
∀ n → H-level (suc n) (A × B) → H-level (suc n) A
H-level-×₁-lemma inhabited n h =
[inhabited⇒+]⇒+ n λ a →
rec (H-level-propositional ext (suc n))
(λ b → proj₁-closure (λ _ → b) (suc n) h)
(inhabited a)
H-level-×₁ :
(A → ∥ B ∥) →
∀ n → H-level n (A × B) → H-level n A
H-level-×₁ inhabited zero h =
propositional⇒inhabited⇒contractible
(H-level-×₁-lemma inhabited 0 (mono₁ 0 h))
(proj₁ (proj₁ h))
H-level-×₁ inhabited (suc n) =
H-level-×₁-lemma inhabited n
H-level-×₂ :
(B → ∥ A ∥) →
∀ n → H-level n (A × B) → H-level n B
H-level-×₂ {B = B} {A = A} inhabited n =
H-level n (A × B) ↝⟨ H-level.respects-surjection (from-bijection ×-comm) n ⟩
H-level n (B × A) ↝⟨ H-level-×₁ inhabited n ⟩□
H-level n B □
-- If A is merely inhabited, then the truncation of A is isomorphic to
-- the unit type.
inhabited⇒∥∥↔⊤ : ∥ A ∥ → ∥ A ∥ ↔ ⊤
inhabited⇒∥∥↔⊤ ∥a∥ =
_⇔_.to contractible⇔↔⊤ $
propositional⇒inhabited⇒contractible
truncation-is-proposition
∥a∥
-- If A is not inhabited, then the propositional truncation of A is
-- isomorphic to the empty type.
not-inhabited⇒∥∥↔⊥ : ¬ A → ∥ A ∥ ↔ ⊥ {ℓ = ℓ}
not-inhabited⇒∥∥↔⊥ {A = A} =
¬ A ↝⟨ (λ ¬a ∥a∥ → rec ⊥-propositional ¬a ∥a∥) ⟩
¬ ∥ A ∥ ↝⟨ inverse ∘ Bijection.⊥↔uninhabited ⟩□
∥ A ∥ ↔ ⊥ □
-- The negation of the truncation of A is isomorphic to the negation
-- of A.
¬∥∥↔¬ : ¬ ∥ A ∥ ↔ ¬ A
¬∥∥↔¬ {A = A} = record
{ surjection = record
{ logical-equivalence = record
{ to = λ f → f ∘ ∣_∣
; from = rec ⊥-propositional
}
; right-inverse-of = λ _ → ¬-propositional ext _ _
}
; left-inverse-of = λ _ → ¬-propositional ext _ _
}
-- The function λ R x y → ∥ R x y ∥ preserves Is-equivalence-relation.
∥∥-preserves-Is-equivalence-relation :
Is-equivalence-relation R →
Is-equivalence-relation (λ x y → ∥ R x y ∥)
∥∥-preserves-Is-equivalence-relation R-equiv = record
{ reflexive = ∣ reflexive ∣
; symmetric = symmetric ⟨$⟩_
; transitive = λ p q → transitive ⟨$⟩ p ⊛ q
}
where
open Is-equivalence-relation R-equiv
mutual
-- The propositional truncation's universal property.
universal-property :
Is-proposition B →
(∥ A ∥ → B) ≃ (A → B)
universal-property B-prop = universal-property-Π (λ _ → B-prop)
-- A generalisation of the universal property.
universal-property-Π :
(∀ x → Is-proposition (P x)) →
((x : ∥ A ∥) → P x) ≃ ((x : A) → P ∣ x ∣)
universal-property-Π {A = A} {P = P} P-prop =
((x : ∥ A ∥) → P x) ↝⟨ Eq.⇔→≃ prop truncation-is-proposition
(λ f → ∣ f ∘ ∣_∣ ∣) (rec prop (elim _ P-prop)) ⟩
∥ ((x : A) → P ∣ x ∣) ∥ ↔⟨ ∥∥↔ (Π-closure ext 1 λ _ → P-prop _) ⟩□
((x : A) → P ∣ x ∣) □
where
prop = Π-closure ext 1 λ _ → P-prop _
private
-- The universal property computes in the right way.
_ :
(B-prop : Is-proposition B)
(f : ∥ A ∥ → B) →
_≃_.to (universal-property B-prop) f ≡ f ∘ ∣_∣
_ = λ _ _ → refl _
_ :
(B-prop : Is-proposition B)
(f : A → B) (x : A) →
_≃_.from (universal-property B-prop) f ∣ x ∣ ≡ f x
_ = λ _ _ _ → refl _
-- If there is a function f : A → ∥ B ∥, then f is an equivalence if
-- and only if the second projection from A × B is an equivalence.
equivalence-to-∥∥≃proj₂-equivalence :
(f : A → ∥ B ∥) →
Is-equivalence f ≃ Is-equivalence (proj₂ ⦂ (A × B → B))
equivalence-to-∥∥≃proj₂-equivalence {A = A} {B = B} f = Eq.⇔→≃
(Eq.propositional ext _)
(Eq.propositional ext _)
(λ eq → _≃_.is-equivalence
(A × B ↝⟨ (×-cong₁ λ _ → Eq.⟨ _ , eq ⟩) ⟩
∥ B ∥ × B ↝⟨ ∥∥×≃ ⟩□
B □))
from
where
from : Is-equivalence proj₂ → Is-equivalence f
from eq = _≃_.is-equivalence $ Eq.⇔→≃
A-prop
truncation-is-proposition
_
(rec A-prop (proj₁ ∘ _≃_.from Eq.⟨ _ , eq ⟩))
where
A-prop₁ : B → Is-proposition A
A-prop₁ b a₁ a₂ = $⟨ refl _ ⟩
b ≡ b ↔⟨⟩
proj₂ (a₁ , b) ≡ proj₂ (a₂ , b) ↔⟨ Eq.≃-≡ Eq.⟨ _ , eq ⟩ ⟩
(a₁ , b) ≡ (a₂ , b) ↝⟨ cong proj₁ ⟩□
a₁ ≡ a₂ □
A-prop : Is-proposition A
A-prop = [inhabited⇒+]⇒+ 0
(A ↝⟨ f ⟩
∥ B ∥ ↝⟨ rec (H-level-propositional ext 1) A-prop₁ ⟩□
Is-proposition A □)
-- There is an equivalence between "A is equivalent to ∥ B ∥" and
-- "there is a function from A to ∥ B ∥ and the second projection is
-- an equivalence from A × B to B".
≃∥∥≃→∥∥×proj₂-equivalence :
(A ≃ ∥ B ∥) ≃ ((A → ∥ B ∥) × Is-equivalence (proj₂ ⦂ (A × B → B)))
≃∥∥≃→∥∥×proj₂-equivalence {A = A} {B = B} =
A ≃ ∥ B ∥ ↔⟨ Eq.≃-as-Σ ⟩
(∃ λ (f : A → ∥ B ∥) → Is-equivalence f) ↝⟨ ∃-cong equivalence-to-∥∥≃proj₂-equivalence ⟩□
(A → ∥ B ∥) × Is-equivalence (proj₂ ⦂ (A × B → B)) □
-- The following three results come from "Generalizations of Hedberg's
-- Theorem" by Kraus, Escardó, Coquand and Altenkirch.
-- Types with constant endofunctions are "h-stable" (meaning that
-- "mere inhabitance" implies inhabitance).
constant-endofunction⇒h-stable : {f : A → A} → Constant f → ∥ A ∥ → A
constant-endofunction⇒h-stable {A = A} {f = f} c =
∥ A ∥ ↝⟨ rec (fixpoint-lemma f c) (λ x → f x , c (f x) x) ⟩
(∃ λ (x : A) → f x ≡ x) ↝⟨ proj₁ ⟩□
A □
-- Having a constant endofunction is logically equivalent to being
-- h-stable.
constant-endofunction⇔h-stable :
(∃ λ (f : A → A) → Constant f) ⇔ (∥ A ∥ → A)
constant-endofunction⇔h-stable = record
{ to = λ { (_ , c) → constant-endofunction⇒h-stable c }
; from = λ f → f ∘ ∣_∣ , λ x y →
f ∣ x ∣ ≡⟨ cong f $ truncation-is-proposition _ _ ⟩∎
f ∣ y ∣ ∎
}
-- A type is a set if and only if it is "h-separated" (which means
-- that all its equality types are h-stable).
Is-set⇔h-separated :
Is-set A ⇔ ((x y : A) → ∥ x ≡ y ∥ → x ≡ y)
Is-set⇔h-separated {A = A} = record
{ to = λ A-set _ _ → rec A-set id
; from =
((x y : A) → ∥ x ≡ y ∥ → x ≡ y) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ →
_⇔_.from constant-endofunction⇔h-stable) ⟩
((x y : A) → ∃ λ (f : x ≡ y → x ≡ y) → Constant f) ↝⟨ constant⇒set ⟩□
Is-set A □
}
-- If A is decided, then ∥ A ∥ is decided.
Dec→Dec-∥∥ : Dec A → Dec ∥ A ∥
Dec→Dec-∥∥ (yes a) = yes ∣ a ∣
Dec→Dec-∥∥ (no ¬A) = no (_↔_.from ¬∥∥↔¬ ¬A)
-- If a binary relation can be decided, then the propositional
-- truncation of the relation can also be decided.
decidable→decidable-∥∥ :
{P : A → B → Type p} →
((x : A) (y : B) → Dec (P x y)) →
((x : A) (y : B) → Dec ∥ P x y ∥)
decidable→decidable-∥∥ dec =
λ x y → Dec→Dec-∥∥ (dec x y)
-- If A is decided, then one can convert between ∥ A ∥ and A.
Dec→∥∥⇔ :
Dec A → ∥ A ∥ ⇔ A
Dec→∥∥⇔ _ ._⇔_.from = ∣_∣
Dec→∥∥⇔ (yes a) ._⇔_.to = λ _ → a
Dec→∥∥⇔ (no ¬A) ._⇔_.to = ⊥-elim ∘ rec ⊥-propositional ¬A
-- Variants of the following two lemmas were communicated to me by
-- Nicolai Kraus. They are closely related to Lemma 2.1 in his paper
-- "The General Universal Property of the Propositional Truncation".
-- A variant of ∥∥×≃.
drop-∥∥ :
{B : A → Type b} →
(A → ∥ C ∥) →
(∥ C ∥ → ∀ x → B x) ≃ (∀ x → B x)
drop-∥∥ {C = C} {B = B} inh =
Eq.with-other-inverse
((∥ C ∥ → ∀ a → B a) ↔⟨ Π-comm ⟩
(∀ a → ∥ C ∥ → B a) ↝⟨ (∀-cong ext λ a → drop-⊤-left-Π ext (inhabited⇒∥∥↔⊤ (inh a))) ⟩□
(∀ a → B a) □)
(λ f _ → f)
(λ f → ⟨ext⟩ λ _ → ⟨ext⟩ λ a →
_ ≡⟨ subst-const _ ⟩∎
f a ∎)
-- Another variant of ∥∥×≃.
push-∥∥ :
{B : A → Type b} {C : (∀ x → B x) → Type c} →
(A → ∥ D ∥) →
(∥ D ∥ → ∃ λ (f : ∀ x → B x) → C f) ≃
(∃ λ (f : ∀ x → B x) → ∥ D ∥ → C f)
push-∥∥ {D = D} {B = B} {C = C} inh =
(∥ D ∥ → ∃ λ (f : ∀ c → B c) → C f) ↔⟨ ΠΣ-comm ⟩
(∃ λ (f : ∥ D ∥ → ∀ c → B c) → ∀ b → C (f b)) ↝⟨ (Σ-cong-contra (inverse $ drop-∥∥ inh) λ _ → F.id) ⟩□
(∃ λ (f : ∀ c → B c) → ∥ D ∥ → C f) □
-- Having a coherently constant function into a groupoid is equivalent
-- to having a function from a propositionally truncated type into the
-- groupoid. This result is Proposition 2.3 in "The General Universal
-- Property of the Propositional Truncation" by Kraus.
Coherently-constant :
{A : Type a} {B : Type b} →
(A → B) → Type (a ⊔ b)
Coherently-constant f =
∃ λ (c : Constant f) →
∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃
coherently-constant-function≃∥inhabited∥⇒inhabited :
{A : Type a} {B : Type b} →
H-level 3 B →
(∃ λ (f : A → B) → Coherently-constant f) ≃ (∥ A ∥ → B)
coherently-constant-function≃∥inhabited∥⇒inhabited
{a = a} {b = b} {A = A} {B} B-groupoid =
(∃ λ (f : A → B) → Coherently-constant f) ↝⟨ Trunc.coherently-constant-function≃∥inhabited∥⇒inhabited lzero ext B-groupoid ⟩
(Trunc.∥ A ∥ 1 (a ⊔ b) → B) ↝⟨ →-cong₁ ext (inverse $ ∥∥↔∥∥ (a ⊔ b)) ⟩□
(∥ A ∥ → B) □
private
-- One direction of the proposition above computes in the right way.
to-coherently-constant-function≃∥inhabited∥⇒inhabited :
(h : H-level 3 B)
(f : ∃ λ (f : A → B) → Coherently-constant f) (x : A) →
_≃_.to (coherently-constant-function≃∥inhabited∥⇒inhabited h)
f ∣ x ∣ ≡
proj₁ f x
to-coherently-constant-function≃∥inhabited∥⇒inhabited _ _ _ = refl _
-- Having a constant function into a set is equivalent to having a
-- function from a propositionally truncated type into the set. The
-- statement of this result is that of Proposition 2.2 in "The General
-- Universal Property of the Propositional Truncation" by Kraus, but
-- it uses a different proof: as observed by Kraus this result follows
-- from Proposition 2.3.
constant-function≃∥inhabited∥⇒inhabited :
{A : Type a} {B : Type b} →
Is-set B →
(∃ λ (f : A → B) → Constant f) ≃ (∥ A ∥ → B)
constant-function≃∥inhabited∥⇒inhabited
{a = a} {b = b} {A = A} {B} B-set =
(∃ λ (f : A → B) → Constant f) ↝⟨ Trunc.constant-function≃∥inhabited∥⇒inhabited lzero ext B-set ⟩
(Trunc.∥ A ∥ 1 (a ⊔ b) → B) ↝⟨ →-cong₁ ext (inverse $ ∥∥↔∥∥ (a ⊔ b)) ⟩□
(∥ A ∥ → B) □
private
-- One direction of the proposition above computes in the right way.
to-constant-function≃∥inhabited∥⇒inhabited :
(B-set : Is-set B)
(f : ∃ λ (f : A → B) → Constant f) (x : A) →
_≃_.to (constant-function≃∥inhabited∥⇒inhabited B-set) f ∣ x ∣ ≡
proj₁ f x
to-constant-function≃∥inhabited∥⇒inhabited _ _ _ = refl _
-- The axiom of choice, in one of the alternative forms given in the
-- HoTT book (§3.8).
Axiom-of-choice : (a b : Level) → Type (lsuc (a ⊔ b))
Axiom-of-choice a b =
{A : Type a} {B : A → Type b} →
Is-set A → (∀ x → ∥ B x ∥) → ∥ (∀ x → B x) ∥
-- The axiom of choice can be turned into a bijection.
choice-bijection :
{A : Type a} {B : A → Type b} →
Axiom-of-choice a b → Is-set A →
(∀ x → ∥ B x ∥) ↔ ∥ (∀ x → B x) ∥
choice-bijection choice A-set = record
{ surjection = record
{ logical-equivalence = record
{ to = choice A-set
; from = λ f x → ∥∥-map (_$ x) f
}
; right-inverse-of = λ _ → truncation-is-proposition _ _
}
; left-inverse-of = λ _ →
(Π-closure ext 1 λ _ →
truncation-is-proposition) _ _
}
-- The axiom of countable choice, stated in a corresponding way.
Axiom-of-countable-choice : (b : Level) → Type (lsuc b)
Axiom-of-countable-choice b =
{B : ℕ → Type b} → (∀ x → ∥ B x ∥) → ∥ (∀ x → B x) ∥
-- The axiom of countable choice can be turned into a bijection.
countable-choice-bijection :
{B : ℕ → Type b} →
Axiom-of-countable-choice b →
(∀ x → ∥ B x ∥) ↔ ∥ (∀ x → B x) ∥
countable-choice-bijection cc = record
{ surjection = record
{ logical-equivalence = record
{ to = cc
; from = λ f x → ∥∥-map (_$ x) f
}
; right-inverse-of = λ _ → truncation-is-proposition _ _
}
; left-inverse-of = λ _ →
(Π-closure ext 1 λ _ →
truncation-is-proposition) _ _
}
------------------------------------------------------------------------
-- Definitions related to truncated binary sums
-- Truncated binary sums.
infixr 1 _∥⊎∥_
_∥⊎∥_ : Type a → Type b → Type (a ⊔ b)
A ∥⊎∥ B = ∥ A ⊎ B ∥
-- Introduction rules.
∣inj₁∣ : A → A ∥⊎∥ B
∣inj₁∣ = ∣_∣ ∘ inj₁
∣inj₂∣ : B → A ∥⊎∥ B
∣inj₂∣ = ∣_∣ ∘ inj₂
-- _∥⊎∥_ is pointwise propositional.
∥⊎∥-propositional : Is-proposition (A ∥⊎∥ B)
∥⊎∥-propositional = truncation-is-proposition
-- _∥⊎∥_ preserves all kinds of functions.
infixr 1 _∥⊎∥-cong_
_∥⊎∥-cong_ : A₁ ↝[ k ] A₂ → B₁ ↝[ k ] B₂ → A₁ ∥⊎∥ B₁ ↝[ k ] A₂ ∥⊎∥ B₂
A₁↝A₂ ∥⊎∥-cong B₁↝B₂ = ∥∥-cong (A₁↝A₂ ⊎-cong B₁↝B₂)
-- _∥⊎∥_ is commutative.
∥⊎∥-comm : A ∥⊎∥ B ↔ B ∥⊎∥ A
∥⊎∥-comm = ∥∥-cong ⊎-comm
-- If one truncates the types to the left or right of _∥⊎∥_, then one
-- ends up with an isomorphic type.
truncate-left-∥⊎∥ : A ∥⊎∥ B ↔ ∥ A ∥ ∥⊎∥ B
truncate-left-∥⊎∥ =
inverse $ flatten′ (λ F → F _ ⊎ _) (λ f → ⊎-map f id) [ ∥∥-map inj₁ , ∣inj₂∣ ]
truncate-right-∥⊎∥ : A ∥⊎∥ B ↔ A ∥⊎∥ ∥ B ∥
truncate-right-∥⊎∥ {A = A} {B = B} =
A ∥⊎∥ B ↝⟨ ∥⊎∥-comm ⟩
B ∥⊎∥ A ↝⟨ truncate-left-∥⊎∥ ⟩
∥ B ∥ ∥⊎∥ A ↝⟨ ∥⊎∥-comm ⟩□
A ∥⊎∥ ∥ B ∥ □
-- _∥⊎∥_ is associative.
∥⊎∥-assoc : A ∥⊎∥ (B ∥⊎∥ C) ↔ (A ∥⊎∥ B) ∥⊎∥ C
∥⊎∥-assoc {A = A} {B = B} {C = C} =
∥ A ⊎ ∥ B ⊎ C ∥ ∥ ↝⟨ inverse truncate-right-∥⊎∥ ⟩
∥ A ⊎ B ⊎ C ∥ ↝⟨ ∥∥-cong ⊎-assoc ⟩
∥ (A ⊎ B) ⊎ C ∥ ↝⟨ truncate-left-∥⊎∥ ⟩□
∥ ∥ A ⊎ B ∥ ⊎ C ∥ □
-- ⊥ is a left and right identity of _∥⊎∥_ if the other argument is a
-- proposition.
∥⊎∥-left-identity : Is-proposition A → ⊥ {ℓ = ℓ} ∥⊎∥ A ↔ A
∥⊎∥-left-identity {A = A} A-prop =
∥ ⊥ ⊎ A ∥ ↝⟨ ∥∥-cong ⊎-left-identity ⟩
∥ A ∥ ↝⟨ ∥∥↔ A-prop ⟩□
A □
∥⊎∥-right-identity : Is-proposition A → A ∥⊎∥ ⊥ {ℓ = ℓ} ↔ A
∥⊎∥-right-identity {A = A} A-prop =
A ∥⊎∥ ⊥ ↔⟨ ∥⊎∥-comm ⟩
⊥ ∥⊎∥ A ↔⟨ ∥⊎∥-left-identity A-prop ⟩□
A □
-- _∥⊎∥_ is idempotent for propositions.
∥⊎∥-idempotent : Is-proposition A → A ∥⊎∥ A ↔ A
∥⊎∥-idempotent {A = A} A-prop =
∥ A ⊎ A ∥ ↝⟨ idempotent ⟩
∥ A ∥ ↝⟨ ∥∥↔ A-prop ⟩□
A □
-- Sometimes a truncated binary sum is isomorphic to one of its
-- summands.
drop-left-∥⊎∥ :
Is-proposition B → (A → B) → A ∥⊎∥ B ↔ B
drop-left-∥⊎∥ B-prop A→B =
_≃_.bijection $
Eq.⇔→≃ ∥⊎∥-propositional B-prop
(rec B-prop [ to-implication A→B , id ]) ∣inj₂∣
drop-right-∥⊎∥ :
Is-proposition A → (B → A) → A ∥⊎∥ B ↔ A
drop-right-∥⊎∥ {A = A} {B = B} A-prop B→A =
A ∥⊎∥ B ↝⟨ ∥⊎∥-comm ⟩
B ∥⊎∥ A ↝⟨ drop-left-∥⊎∥ A-prop B→A ⟩□
A □
drop-⊥-right-∥⊎∥ :
Is-proposition A → ¬ B → A ∥⊎∥ B ↔ A
drop-⊥-right-∥⊎∥ A-prop ¬B =
drop-right-∥⊎∥ A-prop (⊥-elim ∘ ¬B)
drop-⊥-left-∥⊎∥ :
Is-proposition B → ¬ A → A ∥⊎∥ B ↔ B
drop-⊥-left-∥⊎∥ B-prop ¬A =
drop-left-∥⊎∥ B-prop (⊥-elim ∘ ¬A)
-- A type of functions from a truncated binary sum to a family of
-- propositions can be expressed as a binary product of function
-- types.
Π∥⊎∥↔Π×Π :
(∀ x → Is-proposition (P x)) →
((x : A ∥⊎∥ B) → P x)
↔
((x : A) → P (∣inj₁∣ x)) × ((y : B) → P (∣inj₂∣ y))
Π∥⊎∥↔Π×Π {A = A} {B = B} {P = P} P-prop =
((x : A ∥⊎∥ B) → P x) ↔⟨ universal-property-Π P-prop ⟩
((x : A ⊎ B) → P ∣ x ∣) ↝⟨ Π⊎↔Π×Π ext ⟩□
((x : A) → P (∣inj₁∣ x)) × ((y : B) → P (∣inj₂∣ y)) □
-- Two distributivity laws for Σ and _∥⊎∥_.
Σ-∥⊎∥-distrib-left :
Is-proposition A →
Σ A (λ x → P x ∥⊎∥ Q x) ↔ Σ A P ∥⊎∥ Σ A Q
Σ-∥⊎∥-distrib-left {P = P} {Q = Q} A-prop =
(∃ λ x → ∥ P x ⊎ Q x ∥) ↝⟨ inverse $ ∥∥↔ (Σ-closure 1 A-prop λ _ → ∥⊎∥-propositional) ⟩
∥ (∃ λ x → ∥ P x ⊎ Q x ∥) ∥ ↝⟨ flatten′ (λ F → (∃ λ x → F (P x ⊎ Q x))) (λ f → Σ-map id f) (uncurry λ x → ∥∥-map (x ,_)) ⟩
∥ (∃ λ x → P x ⊎ Q x) ∥ ↝⟨ ∥∥-cong ∃-⊎-distrib-left ⟩□
∥ ∃ P ⊎ ∃ Q ∥ □
Σ-∥⊎∥-distrib-right :
(∀ x → Is-proposition (P x)) →
Σ (A ∥⊎∥ B) P ↔ Σ A (P ∘ ∣inj₁∣) ∥⊎∥ Σ B (P ∘ ∣inj₂∣)
Σ-∥⊎∥-distrib-right {A = A} {B = B} {P = P} P-prop =
_≃_.bijection $
Eq.⇔→≃ prop₂ prop₁
(uncurry $
elim _ (λ _ → Π-closure ext 1 λ _ → prop₁) λ where
(inj₁ x) y → ∣ inj₁ (x , y) ∣
(inj₂ x) y → ∣ inj₂ (x , y) ∣)
(rec prop₂ [ Σ-map ∣inj₁∣ id , Σ-map ∣inj₂∣ id ])
where
prop₁ = ∥⊎∥-propositional
prop₂ = Σ-closure 1 ∥⊎∥-propositional P-prop
-- A variant of one of De Morgan's laws.
¬∥⊎∥¬↔¬× :
Dec (¬ A) → Dec (¬ B) →
¬ A ∥⊎∥ ¬ B ↔ ¬ (A × B)
¬∥⊎∥¬↔¬× {A = A} {B = B} dec-¬A dec-¬B = record
{ surjection = record
{ logical-equivalence = record
{ to = rec (¬-propositional ext) ¬⊎¬→׬
; from = ∣_∣ ∘ _↠_.from (¬⊎¬↠¬× ext dec-¬A dec-¬B)
}
; right-inverse-of = λ _ → ¬-propositional ext _ _
}
; left-inverse-of = λ _ → ∥⊎∥-propositional _ _
}
-- If ∥ A ∥ is decided, then A ∥⊎∥ B is equivalent to A ∥⊎∥ ¬ A × B.
∥⊎∥≃∥⊎∥¬× :
Dec ∥ A ∥ →
(A ∥⊎∥ B) ≃ (A ∥⊎∥ ¬ A × B)
∥⊎∥≃∥⊎∥¬× (yes ∥A∥) = Eq.⇔→≃
∥⊎∥-propositional
∥⊎∥-propositional
(const (∥∥-map inj₁ ∥A∥))
(id ∥⊎∥-cong proj₂)
∥⊎∥≃∥⊎∥¬× (no ¬∥A∥) = Eq.⇔→≃
∥⊎∥-propositional
∥⊎∥-propositional
(id ∥⊎∥-cong (¬∥A∥ ∘ ∣_∣) ,_)
(id ∥⊎∥-cong proj₂)
-- If ∥ B ∥ is decided, then A ∥⊎∥ B is equivalent to ¬ B × A ∥⊎∥ B.
∥⊎∥≃¬×∥⊎∥ :
Dec ∥ B ∥ →
(A ∥⊎∥ B) ≃ (¬ B × A ∥⊎∥ B)
∥⊎∥≃¬×∥⊎∥ {B = B} {A = A} dec-∥B∥ =
A ∥⊎∥ B ↔⟨ ∥⊎∥-comm ⟩
B ∥⊎∥ A ↝⟨ ∥⊎∥≃∥⊎∥¬× dec-∥B∥ ⟩
B ∥⊎∥ ¬ B × A ↔⟨ ∥⊎∥-comm ⟩□
¬ B × A ∥⊎∥ B □
------------------------------------------------------------------------
-- Code related to Erased-singleton
-- A corollary of erased-singleton-with-erased-center-propositional.
↠→↔Erased-singleton :
{@0 y : B}
(A↠B : A ↠ B) →
Very-stableᴱ-≡ B →
∥ (∃ λ (x : A) → Erased (_↠_.to A↠B x ≡ y)) ∥ ↔ Erased-singleton y
↠→↔Erased-singleton {A = A} {y = y} A↠B s =
∥ (∃ λ (x : A) → Erased (_↠_.to A↠B x ≡ y)) ∥ ↝⟨ ∥∥-cong-⇔ (Surjection.Σ-cong-⇔ A↠B λ _ → F.id) ⟩
∥ Erased-singleton y ∥ ↝⟨ ∥∥↔ (E.erased-singleton-with-erased-center-propositional s) ⟩□
Erased-singleton y □
mutual
-- The right-to-left direction of the previous lemma does not depend
-- on the assumption of stability.
↠→Erased-singleton→ :
{@0 y : B}
(A↠B : A ↠ B) →
Erased-singleton y →
∥ (∃ λ (x : A) → Erased (_↠_.to A↠B x ≡ y)) ∥
↠→Erased-singleton→ = _ -- Agda can infer the definition.
_ : _↔_.from (↠→↔Erased-singleton A↠B s) x ≡
↠→Erased-singleton→ A↠B x
_ = refl _
-- A corollary of Σ-Erased-Erased-singleton↔ and ↠→↔Erased-singleton.
Σ-Erased-∥-Σ-Erased-≡-∥↔ :
(A↠B : A ↠ B) →
Very-stableᴱ-≡ B →
(∃ λ (x : Erased B) →
∥ (∃ λ (y : A) → Erased (_↠_.to A↠B y ≡ erased x)) ∥) ↔
B
Σ-Erased-∥-Σ-Erased-≡-∥↔ {A = A} {B = B} A↠B s =
(∃ λ (x : Erased B) →
∥ (∃ λ (y : A) → Erased (_↠_.to A↠B y ≡ erased x)) ∥) ↝⟨ (∃-cong λ _ → ↠→↔Erased-singleton A↠B s) ⟩
(∃ λ (x : Erased B) → Erased-singleton (erased x)) ↝⟨ E.Σ-Erased-Erased-singleton↔ ⟩□
B □
mutual
-- Again the right-to-left direction of the previous lemma does not
-- depend on the assumption of stability.
→Σ-Erased-∥-Σ-Erased-≡-∥ :
(A↠B : A ↠ B) →
B →
∃ λ (x : Erased B) →
∥ (∃ λ (y : A) → Erased (_↠_.to A↠B y ≡ erased x)) ∥
→Σ-Erased-∥-Σ-Erased-≡-∥ = _ -- Agda can infer the definition.
_ : _↔_.from (Σ-Erased-∥-Σ-Erased-≡-∥↔ A↠B s) x ≡
→Σ-Erased-∥-Σ-Erased-≡-∥ A↠B x
_ = refl _
-- In an erased context the left-to-right direction of
-- Σ-Erased-∥-Σ-Erased-≡-∥↔ returns the erased first component.
@0 to-Σ-Erased-∥-Σ-Erased-≡-∥↔≡ :
∀ (A↠B : A ↠ B) (s : Very-stableᴱ-≡ B) x →
_↔_.to (Σ-Erased-∥-Σ-Erased-≡-∥↔ A↠B s) x ≡ erased (proj₁ x)
to-Σ-Erased-∥-Σ-Erased-≡-∥↔≡ A↠B s (E.[ x ] , y) =
_↔_.to (Σ-Erased-∥-Σ-Erased-≡-∥↔ A↠B s) (E.[ x ] , y) ≡⟨⟩
proj₁ (_↔_.to (↠→↔Erased-singleton A↠B s) y) ≡⟨ erased (proj₂ (_↔_.to (↠→↔Erased-singleton A↠B s) y)) ⟩∎
x ∎
| {
"alphanum_fraction": 0.5261153587,
"avg_line_length": 30.3170515098,
"ext": "agda",
"hexsha": "03858ee63aed33d85bfb08109a4bbc8b4c5c0431",
"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/H-level/Truncation/Propositional.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/H-level/Truncation/Propositional.agda",
"max_line_length": 127,
"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/H-level/Truncation/Propositional.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": 15121,
"size": 34137
} |
-- Andreas, 2016-04-18 Issue 1834 regression (extracted from larger test case)
-- {-# OPTIONS -v tc.cover:30 #-}
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
record Stream (A : Set) : Set where
coinductive
constructor _∷_
field
head : A
tail : Stream A
open Stream
weird' : (n : ℕ) → Stream ℕ
head (weird' zero) = zero
tail (weird' zero) = weird' zero
( weird' (suc n)) = n ∷ tail (weird' n)
| {
"alphanum_fraction": 0.5976470588,
"avg_line_length": 21.25,
"ext": "agda",
"hexsha": "5640fba4e06c633ec6c2b8272cff8f0951a3884a",
"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/Issue1834e.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/Issue1834e.agda",
"max_line_length": 78,
"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/Issue1834e.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": 153,
"size": 425
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Unary.Subtype where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Relation.Unary
open import Cubical.Data.Nat
private
variable
a ℓ ℓ′ : Level
A : Type a
Subtype : (P : Pred A ℓ) → Type _
Subtype {A = A} P = Σ[ x ∈ A ] x ∈ P
module _ (P : Pred A ℓ) where
isOfHLevelSubtype : ∀ n → isOfHLevel (suc n) A → isOfHLevel (suc n) (Subtype P)
isOfHLevelSubtype n hA = isOfHLevelΣ (suc n) hA (λ _ → isProp→isOfHLevelSuc n (isProp[ P ] _))
isSetSubtype : isSet A → isSet (Subtype P)
isSetSubtype = isOfHLevelSubtype 1
inclusion : (P : Pred A ℓ) (Q : Pred A ℓ′) → P ⊆ Q → Subtype P → Subtype Q
inclusion P Q P⊆Q = λ (x , Px) → (x , P⊆Q Px)
⇔-equiv : (P : Pred A ℓ) (Q : Pred A ℓ′) → P ⇔ Q → Subtype P ≃ Subtype Q
⇔-equiv P Q (P⊆Q , Q⊆P) = isoToEquiv (iso (inclusion P Q P⊆Q) (inclusion Q P Q⊆P)
(λ (x , Qx) → cong (x ,_) (Q x .snd _ _))
(λ (x , Px) → cong (x ,_) (P x .snd _ _))
)
| {
"alphanum_fraction": 0.5781376518,
"avg_line_length": 33.3783783784,
"ext": "agda",
"hexsha": "423a01fd8d0710c6574be872c18279ff31b7baa3",
"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": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Relation/Unary/Subtype.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"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": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Relation/Unary/Subtype.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Relation/Unary/Subtype.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 458,
"size": 1235
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Functions.FunExtEquiv where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.CartesianKanOps
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Vec
open import Cubical.Data.Nat
open import Cubical.Reflection.StrictEquiv
private
variable
ℓ ℓ₁ ℓ₂ ℓ₃ : Level
-- Function extensionality is an equivalence
module _ {A : Type ℓ} {B : A → I → Type ℓ₁}
{f : (x : A) → B x i0} {g : (x : A) → B x i1} where
funExtEquiv : (∀ x → PathP (B x) (f x) (g x)) ≃ PathP (λ i → ∀ x → B x i) f g
unquoteDef funExtEquiv = defStrictEquiv funExtEquiv funExt funExt⁻
funExtPath : (∀ x → PathP (B x) (f x) (g x)) ≡ PathP (λ i → ∀ x → B x i) f g
funExtPath = ua funExtEquiv
funExtIso : Iso (∀ x → PathP (B x) (f x) (g x)) (PathP (λ i → ∀ x → B x i) f g)
funExtIso = iso funExt funExt⁻ (λ x → refl {x = x}) (λ x → refl {x = x})
-- Function extensionality for binary functions
funExt₂ : {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → I → Type ℓ₂}
{f : (x : A) → (y : B x) → C x y i0}
{g : (x : A) → (y : B x) → C x y i1}
→ ((x : A) (y : B x) → PathP (C x y) (f x y) (g x y))
→ PathP (λ i → ∀ x y → C x y i) f g
funExt₂ p i x y = p x y i
-- Function extensionality for binary functions is an equivalence
module _ {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → I → Type ℓ₂}
{f : (x : A) → (y : B x) → C x y i0}
{g : (x : A) → (y : B x) → C x y i1} where
private
appl₂ : PathP (λ i → ∀ x y → C x y i) f g → ∀ x y → PathP (C x y) (f x y) (g x y)
appl₂ eq x y i = eq i x y
funExt₂Equiv : (∀ x y → PathP (C x y) (f x y) (g x y)) ≃ (PathP (λ i → ∀ x y → C x y i) f g)
unquoteDef funExt₂Equiv = defStrictEquiv funExt₂Equiv funExt₂ appl₂
funExt₂Path : (∀ x y → PathP (C x y) (f x y) (g x y)) ≡ (PathP (λ i → ∀ x y → C x y i) f g)
funExt₂Path = ua funExt₂Equiv
-- Function extensionality for ternary functions
funExt₃ : {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}
{D : (x : A) → (y : B x) → C x y → I → Type ℓ₃}
{f : (x : A) → (y : B x) → (z : C x y) → D x y z i0}
{g : (x : A) → (y : B x) → (z : C x y) → D x y z i1}
→ ((x : A) (y : B x) (z : C x y) → PathP (D x y z) (f x y z) (g x y z))
→ PathP (λ i → ∀ x y z → D x y z i) f g
funExt₃ p i x y z = p x y z i
-- Function extensionality for ternary functions is an equivalence
module _ {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}
{D : (x : A) → (y : B x) → C x y → I → Type ℓ₃}
{f : (x : A) → (y : B x) → (z : C x y) → D x y z i0}
{g : (x : A) → (y : B x) → (z : C x y) → D x y z i1} where
private
appl₃ : PathP (λ i → ∀ x y z → D x y z i) f g → ∀ x y z → PathP (D x y z) (f x y z) (g x y z)
appl₃ eq x y z i = eq i x y z
funExt₃Equiv : (∀ x y z → PathP (D x y z) (f x y z) (g x y z)) ≃ (PathP (λ i → ∀ x y z → D x y z i) f g)
unquoteDef funExt₃Equiv = defStrictEquiv funExt₃Equiv funExt₃ appl₃
funExt₃Path : (∀ x y z → PathP (D x y z) (f x y z) (g x y z)) ≡ (PathP (λ i → ∀ x y z → D x y z i) f g)
funExt₃Path = ua funExt₃Equiv
-- n-ary non-dependent funext
nAryFunExt : {X : Type ℓ} {Y : I → Type ℓ₁} (n : ℕ) (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))
→ ((xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs))
→ PathP (λ i → nAryOp n X (Y i)) fX fY
nAryFunExt zero fX fY p = p []
nAryFunExt (suc n) fX fY p i x = nAryFunExt n (fX x) (fY x) (λ xs → p (x ∷ xs)) i
-- n-ary funext⁻
nAryFunExt⁻ : (n : ℕ) {X : Type ℓ} {Y : I → Type ℓ₁} (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))
→ PathP (λ i → nAryOp n X (Y i)) fX fY
→ ((xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs))
nAryFunExt⁻ zero fX fY p [] = p
nAryFunExt⁻ (suc n) fX fY p (x ∷ xs) = nAryFunExt⁻ n (fX x) (fY x) (λ i → p i x) xs
nAryFunExtEquiv : (n : ℕ) {X : Type ℓ} {Y : I → Type ℓ₁} (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))
→ ((xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs)) ≃ PathP (λ i → nAryOp n X (Y i)) fX fY
nAryFunExtEquiv n {X} {Y} fX fY = isoToEquiv (iso (nAryFunExt n fX fY) (nAryFunExt⁻ n fX fY)
(linv n fX fY) (rinv n fX fY))
where
linv : (n : ℕ) (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))
(p : PathP (λ i → nAryOp n X (Y i)) fX fY)
→ nAryFunExt n fX fY (nAryFunExt⁻ n fX fY p) ≡ p
linv zero fX fY p = refl
linv (suc n) fX fY p i j x = linv n (fX x) (fY x) (λ k → p k x) i j
rinv : (n : ℕ) (fX : nAryOp n X (Y i0)) (fY : nAryOp n X (Y i1))
(p : (xs : Vec X n) → PathP Y (fX $ⁿ xs) (fY $ⁿ map (λ x → x) xs))
→ nAryFunExt⁻ n fX fY (nAryFunExt n fX fY p) ≡ p
rinv zero fX fY p i [] = p []
rinv (suc n) fX fY p i (x ∷ xs) = rinv n (fX x) (fY x) (λ ys i → p (x ∷ ys) i) i xs
-- Funext when the domain also depends on the interval
funExtDep : {A : I → Type ℓ} {B : (i : I) → A i → Type ℓ₁}
{f : (x : A i0) → B i0 x} {g : (x : A i1) → B i1 x}
→ ({x₀ : A i0} {x₁ : A i1} (p : PathP A x₀ x₁) → PathP (λ i → B i (p i)) (f x₀) (g x₁))
→ PathP (λ i → (x : A i) → B i x) f g
funExtDep {A = A} {B} {f} {g} h i x =
comp
(λ k → B i (coei→i A i x k))
(λ k → λ
{ (i = i0) → f (coei→i A i0 x k)
; (i = i1) → g (coei→i A i1 x k)
})
(h (λ j → coei→j A i j x) i)
funExtDep⁻ : {A : I → Type ℓ} {B : (i : I) → A i → Type ℓ₁}
{f : (x : A i0) → B i0 x} {g : (x : A i1) → B i1 x}
→ PathP (λ i → (x : A i) → B i x) f g
→ ({x₀ : A i0} {x₁ : A i1} (p : PathP A x₀ x₁) → PathP (λ i → B i (p i)) (f x₀) (g x₁))
funExtDep⁻ q p i = q i (p i)
funExtDepEquiv : {A : I → Type ℓ} {B : (i : I) → A i → Type ℓ₁}
{f : (x : A i0) → B i0 x} {g : (x : A i1) → B i1 x}
→ ({x₀ : A i0} {x₁ : A i1} (p : PathP A x₀ x₁) → PathP (λ i → B i (p i)) (f x₀) (g x₁))
≃ PathP (λ i → (x : A i) → B i x) f g
funExtDepEquiv {A = A} {B} {f} {g} = isoToEquiv isom
where
open Iso
isom : Iso _ _
isom .fun = funExtDep
isom .inv = funExtDep⁻
isom .rightInv q m i x =
comp
(λ k → B i (coei→i A i x (k ∨ m)))
(λ k → λ
{ (i = i0) → f (coei→i A i0 x (k ∨ m))
; (i = i1) → g (coei→i A i1 x (k ∨ m))
; (m = i1) → q i x
})
(q i (coei→i A i x m))
isom .leftInv h m p i =
comp
(λ k → B i (lemi→i m k))
(λ k → λ
{ (i = i0) → f (lemi→i m k)
; (i = i1) → g (lemi→i m k)
; (m = i1) → h p i
})
(h (λ j → lemi→j j m) i)
where
lemi→j : ∀ j → coei→j A i j (p i) ≡ p j
lemi→j j =
coei→j (λ k → coei→j A i k (p i) ≡ p k) i j (coei→i A i (p i))
lemi→i : PathP (λ m → lemi→j i m ≡ p i) (coei→i A i (p i)) refl
lemi→i =
sym (coei→i (λ k → coei→j A i k (p i) ≡ p k) i (coei→i A i (p i)))
◁ λ m k → lemi→j i (m ∨ k)
heteroHomotopy≃Homotopy : {A : I → Type ℓ} {B : (i : I) → Type ℓ₁}
{f : A i0 → B i0} {g : A i1 → B i1}
→ ({x₀ : A i0} {x₁ : A i1} → PathP A x₀ x₁ → PathP B (f x₀) (g x₁))
≃ ((x₀ : A i0) → PathP B (f x₀) (g (transport (λ i → A i) x₀)))
heteroHomotopy≃Homotopy {A = A} {B} {f} {g} = isoToEquiv isom
where
open Iso
isom : Iso _ _
isom .fun h x₀ = h (isContrSinglP A x₀ .fst .snd)
isom .inv k {x₀} {x₁} p =
subst (λ fib → PathP B (f x₀) (g (fib .fst))) (isContrSinglP A x₀ .snd (x₁ , p)) (k x₀)
isom .rightInv k = funExt λ x₀ →
cong (λ α → subst (λ fib → PathP B (f x₀) (g (fib .fst))) α (k x₀))
(isProp→isSet isPropSinglP (isContrSinglP A x₀ .fst) _
(isContrSinglP A x₀ .snd (isContrSinglP A x₀ .fst))
refl)
∙ transportRefl (k x₀)
isom .leftInv h j {x₀} {x₁} p =
transp
(λ i → PathP B (f x₀) (g (isContrSinglP A x₀ .snd (x₁ , p) (i ∨ j) .fst)))
j
(h (isContrSinglP A x₀ .snd (x₁ , p) j .snd))
| {
"alphanum_fraction": 0.4953703704,
"avg_line_length": 41.4093264249,
"ext": "agda",
"hexsha": "10377696692f89008752fa02c3aff712c836de87",
"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/Functions/FunExtEquiv.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/Functions/FunExtEquiv.agda",
"max_line_length": 106,
"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/Functions/FunExtEquiv.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3800,
"size": 7992
} |
module Data.Num.Bijection where
open import Data.Num.Core
open import Data.Num.Surjection
open import Data.Num.Injection
open import Data.Nat
open import Data.Empty using (⊥)
open import Data.Unit using (⊤; tt)
open import Function.Bijection
open Bijective
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Nullary.Negation
data BijectionView : ℕ → ℕ → ℕ → Set where
Bij : ∀ {b d o} → SurjCond b d o → InjCond b d o → BijectionView b d o
NonSurj : ∀ {b d o} → NonSurjCond b d o → BijectionView b d o
NonInj : ∀ {b d o} → NonInjCond b d o → BijectionView b d o
bijectionView : (b d o : ℕ) → BijectionView b d o
bijectionView b d o with surjectionView b d o | injectionView b d o
bijectionView b d o | Surj c₁ | Inj c₂ = Bij c₁ c₂
bijectionView b d o | Surj _ | NonInj c₁ = NonInj c₁
bijectionView b d o | NonSurj c₁ | _ = NonSurj c₁
IsBijective : ℕ → ℕ → ℕ → Set
IsBijective b d o with bijectionView b d o
IsBijective b d o | Bij _ _ = ⊤
IsBijective b d o | NonSurj _ = ⊥
IsBijective b d o | NonInj _ = ⊥
SurjCond∧InjCond⇒Bijective : ∀ {b} {d} {o} → SurjCond b d o → InjCond b d o → Bijective (Num⟶ℕ b d o)
SurjCond∧InjCond⇒Bijective surjCond injCond = record
{ injective = InjCond⇒Injective injCond
; surjective = SurjCond⇒Surjective surjCond
}
NonSurjCond⇏Bijective : ∀ {b} {d} {o} → NonSurjCond b d o → ¬ (Bijective (Num⟶ℕ b d o))
NonSurjCond⇏Bijective reason claim = NonSurjCond⇏Surjective reason (surjective claim)
NonInjCond⇏Bijective : ∀ {b} {d} {o} → NonInjCond b d o → ¬ (Bijective (Num⟶ℕ b d o))
NonInjCond⇏Bijective reason claim = NonInjCond⇏Injective reason (injective claim)
Bijective? : ∀ b d o → Dec (Bijective (Num⟶ℕ b d o))
Bijective? b d o with bijectionView b d o
Bijective? b d o | Bij surjCond injCond = yes (record
{ injective = InjCond⇒Injective injCond
; surjective = SurjCond⇒Surjective surjCond
})
Bijective? b d o | NonSurj reason = no (NonSurjCond⇏Bijective reason)
Bijective? b d o | NonInj reason = no (NonInjCond⇏Bijective reason)
| {
"alphanum_fraction": 0.6862281117,
"avg_line_length": 38.4181818182,
"ext": "agda",
"hexsha": "93e8abedc9ce1c9c7d5c59fc06216f38f6d382b5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "Data/Num/Bijection.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "Data/Num/Bijection.agda",
"max_line_length": 101,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "Data/Num/Bijection.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 765,
"size": 2113
} |
module Utils where
open import Relation.Binary.PropositionalEquality
open import Data.List
listHeadEq : ∀ {α} {A : Set α} {x y : A} -> {xt yt : List A} -> x ∷ xt ≡ y ∷ yt -> x ≡ y
listHeadEq refl = refl
listTailEq : ∀ {α} {A : Set α} {x y : A} -> {xt yt : List A} -> x ∷ xt ≡ y ∷ yt -> xt ≡ yt
listTailEq refl = refl
| {
"alphanum_fraction": 0.5887850467,
"avg_line_length": 26.75,
"ext": "agda",
"hexsha": "4eb6f6edfe1ea4f4b0ef948913d389983179fd77",
"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": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "JoeyEremondi/agda-parikh",
"max_forks_repo_path": "Utils.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea",
"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": "JoeyEremondi/agda-parikh",
"max_issues_repo_path": "Utils.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "JoeyEremondi/agda-parikh",
"max_stars_repo_path": "Utils.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 122,
"size": 321
} |
module trie where
open import bool
open import char
open import list
open import maybe
open import product
open import string
open import unit
cal : Set → Set
cal A = 𝕃 (char × A)
empty-cal : ∀{A : Set} → cal A
empty-cal = []
cal-lookup : ∀ {A : Set} → cal A → char → maybe A
cal-lookup [] _ = nothing
cal-lookup ((c , a) :: l) c' with c =char c'
... | tt = just a
... | ff = cal-lookup l c'
cal-insert : ∀ {A : Set} → cal A → char → A → cal A
cal-insert [] c a = (c , a) :: []
cal-insert ((c' , a') :: l) c a with c =char c'
... | tt = (c , a) :: l
... | ff = (c' , a') :: (cal-insert l c a)
cal-remove : ∀ {A : Set} → cal A → char → cal A
cal-remove [] _ = []
cal-remove ((c , a) :: l) c' with c =char c'
... | tt = cal-remove l c'
... | ff = (c , a) :: cal-remove l c'
cal-add : ∀{A : Set} → cal A → char → A → cal A
cal-add l c a = (c , a) :: l
test-cal-insert = cal-insert (('a' , 1) :: ('b' , 2) :: []) 'b' 20
data trie (A : Set) : Set where
Node : maybe A → cal (trie A) → trie A
empty-trie : ∀{A : Set} → trie A
empty-trie = (Node nothing empty-cal)
trie-lookup-h : ∀{A : Set} → trie A → 𝕃 char → maybe A
trie-lookup-h (Node odata ts) (c :: cs) with cal-lookup ts c
trie-lookup-h (Node odata ts) (c :: cs) | nothing = nothing
trie-lookup-h (Node odata ts) (c :: cs) | just t = trie-lookup-h t cs
trie-lookup-h (Node odata ts) [] = odata
trie-lookup : ∀{A : Set} → trie A → string → maybe A
trie-lookup t s = trie-lookup-h t (string-to-𝕃char s)
trie-contains : ∀{A : Set} → trie A → string → 𝔹
trie-contains t s with trie-lookup t s
trie-contains t s | nothing = ff
trie-contains t s | just _ = tt
trie-insert-h : ∀{A : Set} → trie A → 𝕃 char → A → trie A
trie-insert-h (Node odata ts) [] x = (Node (just x) ts)
trie-insert-h (Node odata ts) (c :: cs) x with cal-lookup ts c
trie-insert-h (Node odata ts) (c :: cs) x | just t =
(Node odata (cal-insert ts c (trie-insert-h t cs x)))
trie-insert-h (Node odata ts) (c :: cs) x | nothing =
(Node odata (cal-add ts c (trie-insert-h empty-trie cs x)))
trie-insert : ∀{A : Set} → trie A → string → A → trie A
trie-insert t s x = trie-insert-h t (string-to-𝕃char s) x
trie-remove-h : ∀{A : Set} → trie A → 𝕃 char → trie A
trie-remove-h (Node odata ts) (c :: cs) with cal-lookup ts c
trie-remove-h (Node odata ts) (c :: cs) | nothing = Node odata ts
trie-remove-h (Node odata ts) (c :: cs) | just t = Node odata (cal-insert ts c (trie-remove-h t cs))
trie-remove-h (Node odata ts) [] = Node nothing ts
trie-remove : ∀{A : Set} → trie A → string → trie A
trie-remove t s = trie-remove-h t (string-to-𝕃char s)
trie-map : ∀{A B : Set} → (A → B) → trie A → trie B
trie-cal-map : ∀{A B : Set} → (A → B) → cal (trie A) → cal (trie B)
trie-map f (Node x x₁) = Node (maybe-map f x) (trie-cal-map f x₁)
trie-cal-map f [] = []
trie-cal-map f ((c , t) :: cs) =
(c , trie-map f t) :: trie-cal-map f cs
trie-to-string-h : ∀{A : Set} → string → (A → string) → trie A → 𝕃 char → string
trie-cal-to-string-h : ∀{A : Set} → string → (A → string) → cal (trie A) → 𝕃 char → string
trie-to-string-h sep d (Node (just x) c) prev-str =
(𝕃char-to-string (reverse prev-str)) ^ sep ^ (d x) ^ "\n" ^ (trie-cal-to-string-h sep d c prev-str)
trie-to-string-h sep d (Node nothing c) prev-str = trie-cal-to-string-h sep d c prev-str
trie-cal-to-string-h sep d [] prev-str = ""
trie-cal-to-string-h sep d ((c , t) :: cs) prev-str =
(trie-to-string-h sep d t (c :: prev-str)) ^ (trie-cal-to-string-h sep d cs prev-str)
{- trie-to-string sep d t returns a string representation of the trie t,
where each mapping from string s to data x is printed as
s sep d x
where sep is a string and d returns a string for any element A of the trie. -}
trie-to-string : ∀{A : Set} → string → (A → string) → trie A → string
trie-to-string sep d t = trie-to-string-h sep d t []
trie-mappings-h : ∀{A : Set} → trie A → 𝕃 char → 𝕃 (string × A)
trie-cal-mappings-h : ∀{A : Set} → cal (trie A) → 𝕃 char → 𝕃 (string × A)
trie-mappings-h (Node (just x) c) prev-str = (𝕃char-to-string (reverse prev-str) , x) :: (trie-cal-mappings-h c prev-str)
trie-mappings-h (Node nothing c) prev-str = (trie-cal-mappings-h c prev-str)
trie-cal-mappings-h [] prev-str = []
trie-cal-mappings-h ((c , t) :: cs) prev-str = trie-mappings-h t (c :: prev-str) ++ (trie-cal-mappings-h cs prev-str)
trie-mappings : ∀{A : Set} → trie A → 𝕃 (string × A)
trie-mappings t = trie-mappings-h t []
-- return a list of all the strings which have associated data in the trie
trie-strings : ∀{A : Set} → trie A → 𝕃 string
trie-strings t = map fst (trie-mappings t)
trie-nonempty : ∀{A : Set} → trie A → 𝔹
trie-cal-nonempty : ∀{A : Set} → cal (trie A) → 𝔹
trie-nonempty (Node (just x) t) = tt
trie-nonempty (Node nothing c) = trie-cal-nonempty c
trie-cal-nonempty [] = ff
trie-cal-nonempty ((a , t) :: c) = trie-nonempty t || trie-cal-nonempty c
----------------------------------------------------------------------
-- stringset
----------------------------------------------------------------------
stringset : Set
stringset = trie ⊤
stringset-contains : stringset → string → 𝔹
stringset-contains ss s = trie-contains ss s
stringset-insert : stringset → string → stringset
stringset-insert ss s = trie-insert ss s triv
stringset-remove : stringset → string → stringset
stringset-remove ss s = trie-remove ss s
stringset-insert𝕃 : stringset → 𝕃 char → stringset
stringset-insert𝕃 ss s = trie-insert-h ss s triv
empty-stringset : stringset
empty-stringset = empty-trie
stringset-insert* : stringset → 𝕃 string → stringset
stringset-insert* s [] = s
stringset-insert* s (x :: xs) = stringset-insert (stringset-insert* s xs) x
stringset-strings : ∀{A : Set} → trie A → 𝕃 string
stringset-strings t = map fst (trie-mappings t)
| {
"alphanum_fraction": 0.6070620978,
"avg_line_length": 37.8223684211,
"ext": "agda",
"hexsha": "624e6cea54e6f1ee1d40744004c65a5f33b806c7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "trie.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "trie.agda",
"max_line_length": 121,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "trie.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1919,
"size": 5749
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
-- TODO Is it possible to have a more generic [→-group] construction?
module groups.ToOmega where
⊙→Ω-group-structure : ∀ {i j} (X : Ptd i) (Y : Ptd j)
→ GroupStructure (X ⊙→ ⊙Ω Y)
⊙→Ω-group-structure X Y = record {M} where
module M where
ident : (X ⊙→ ⊙Ω Y)
ident = ⊙cst
comp : (X ⊙→ ⊙Ω Y) → (X ⊙→ ⊙Ω Y) → (X ⊙→ ⊙Ω Y)
comp F G = ⊙Ω-∙ ⊙∘ ⊙fanout F G
inv : (X ⊙→ ⊙Ω Y) → (X ⊙→ ⊙Ω Y)
inv F = (! ∘ fst F) , ap ! (snd F)
abstract
unit-l-lemma : ∀ {i} {A : Type i} {x : A} {p : x == x} (α : p == idp)
→ ⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt {a₀ = idp} idp α) idp == α
unit-l-lemma idp = idp
unit-l : ∀ G → comp ident G == G
unit-l G = ⊙λ=' (λ _ → idp) (unit-l-lemma (snd G))
assoc-lemma : ∀ {i} {A : Type i} {x : A} {p q r : x == x}
(α : p == idp) (β : q == idp) (γ : r == idp)
→ ⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt (⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt α β) idp) γ) idp
== ⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt α (⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt β γ) idp)) idp
[ _== idp ↓ ∙-assoc p q r ]
assoc-lemma idp idp idp = idp
assoc : ∀ F G H → comp (comp F G) H == comp F (comp G H)
assoc F G H = ⊙λ='
(λ x → ∙-assoc (fst F x) (fst G x) (fst H x))
(assoc-lemma (snd F) (snd G) (snd H))
inv-l-lemma : ∀ {i} {A : Type i} {x : A} {p : x == x} (α : p == idp)
→ ⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt (ap ! α) α) idp == idp [ _== idp ↓ !-inv-l p ]
inv-l-lemma idp = idp
inv-l : ∀ F → comp (inv F) F == ident
inv-l F = ⊙λ=' (!-inv-l ∘ fst F) (inv-l-lemma (snd F))
Trunc-⊙→Ω-group : ∀ {i j} (X : Ptd i) (Y : Ptd j) → Group (lmax i j)
Trunc-⊙→Ω-group X Y = Trunc-group (⊙→Ω-group-structure X Y)
{- [Trunc-→Ω-group] is functorial in the first argument -}
⊙→Ω-group-structure-fmap-dom : ∀ {i j k} {X : Ptd i} {Y : Ptd j}
(f : X ⊙→ Y) (Z : Ptd k)
→ (⊙→Ω-group-structure Y Z →ᴳˢ ⊙→Ω-group-structure X Z)
⊙→Ω-group-structure-fmap-dom F Z = group-structure-hom (_⊙∘ F)
(λ g₁ g₂ → ⊙λ= (⊙∘-assoc ⊙Ω-∙ (⊙fanout g₁ g₂) F)
∙ ap (⊙Ω-∙ ⊙∘_) (⊙fanout-pre∘ g₁ g₂ F))
Trunc-⊙→Ω-group-fmap-dom : ∀ {i j k} {X : Ptd i} {Y : Ptd j}
(f : X ⊙→ Y) (Z : Ptd k)
→ (Trunc-⊙→Ω-group Y Z →ᴳ Trunc-⊙→Ω-group X Z)
Trunc-⊙→Ω-group-fmap-dom F Z =
Trunc-group-fmap $ ⊙→Ω-group-structure-fmap-dom F Z
⊙→Ω-group-structure-emap-dom : ∀ {i j k} {X : Ptd i} {Y : Ptd j}
(e : X ⊙≃ Y) (Z : Ptd k)
→ (⊙→Ω-group-structure Y Z ≃ᴳˢ ⊙→Ω-group-structure X Z)
⊙→Ω-group-structure-emap-dom (F , F-is-equiv) Z =
⊙→Ω-group-structure-fmap-dom F Z , pre⊙∘-is-equiv (F , F-is-equiv)
Trunc-⊙→Ω-group-emap-dom : ∀ {i j k} {X : Ptd i} {Y : Ptd j}
(e : X ⊙≃ Y) (Z : Ptd k)
→ (Trunc-⊙→Ω-group Y Z ≃ᴳ Trunc-⊙→Ω-group X Z)
Trunc-⊙→Ω-group-emap-dom F Z =
Trunc-group-emap $ ⊙→Ω-group-structure-emap-dom F Z
Trunc-⊙→Ω-group-fmap-dom-idf : ∀ {i j} {X : Ptd i} (Y : Ptd j)
→ Trunc-⊙→Ω-group-fmap-dom (⊙idf X) Y == idhom (Trunc-⊙→Ω-group X Y)
Trunc-⊙→Ω-group-fmap-dom-idf Y = group-hom= $ λ= $ Trunc-elim (λ _ → idp)
Trunc-⊙→Ω-group-fmap-dom-∘ : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
(g : Y ⊙→ Z) (f : X ⊙→ Y) (W : Ptd l)
→ Trunc-⊙→Ω-group-fmap-dom (g ⊙∘ f) W
== Trunc-⊙→Ω-group-fmap-dom f W ∘ᴳ Trunc-⊙→Ω-group-fmap-dom g W
Trunc-⊙→Ω-group-fmap-dom-∘ g f W = group-hom= $ λ= $
Trunc-elim (λ h → ap [_] (! (⊙λ= $ ⊙∘-assoc h g f)))
⊙→Ω-group-structure-fmap-codom : ∀ {i j k} (X : Ptd i) {Y : Ptd j} {Z : Ptd k}
→ Y ⊙→ Z → (⊙→Ω-group-structure X Y →ᴳˢ ⊙→Ω-group-structure X Z)
⊙→Ω-group-structure-fmap-codom X {Y} {Z} F = group-structure-hom
(⊙Ω-fmap F ⊙∘_)
(λ G H → ⊙λ=' (λ x → Ω-fmap-∙ F ((fst G) x) ((fst H) x))
(lemma (snd F) (snd G) (snd H)))
where
abstract
lemma : ∀ {ptZ : de⊙ Z} (α : (fst F) (pt Y) == ptZ)
{gpt hpt : Ω Y} (β : gpt == idp) (γ : hpt == idp)
→ ⊙∘-pt (Ω-fmap (fst F , α)) (⊙∘-pt (fst ⊙Ω-∙) (⊙fanout-pt β γ) idp) (snd (⊙Ω-fmap (fst F , α)))
== ⊙∘-pt (fst ⊙Ω-∙)
(⊙fanout-pt
(⊙∘-pt (Ω-fmap (fst F , α)) β (snd (⊙Ω-fmap (fst F , α))))
(⊙∘-pt (Ω-fmap (fst F , α)) γ (snd (⊙Ω-fmap (fst F , α))))
) idp
[ _== idp ↓ Ω-fmap-∙ (fst F , α) gpt hpt ]
lemma idp idp idp = idp
Trunc-⊙→Ω-group-fmap-codom : ∀ {i j k} (X : Ptd i) {Y : Ptd j} {Z : Ptd k}
→ Y ⊙→ Z → Trunc-⊙→Ω-group X Y →ᴳ Trunc-⊙→Ω-group X Z
Trunc-⊙→Ω-group-fmap-codom X = Trunc-group-fmap ∘ ⊙→Ω-group-structure-fmap-codom X
⊙→Ω-group-structure-emap-codom : ∀ {i j k} (X : Ptd i) {Y : Ptd j} {Z : Ptd k}
→ Y ⊙≃ Z → ⊙→Ω-group-structure X Y ≃ᴳˢ ⊙→Ω-group-structure X Z
⊙→Ω-group-structure-emap-codom X (F , F-is-equiv) =
⊙→Ω-group-structure-fmap-codom X F , post⊙∘-is-equiv (⊙Ω-emap (F , F-is-equiv))
Trunc-⊙→Ω-group-emap-codom : ∀ {i j k} (X : Ptd i) {Y : Ptd j} {Z : Ptd k}
→ Y ⊙≃ Z → Trunc-⊙→Ω-group X Y ≃ᴳ Trunc-⊙→Ω-group X Z
Trunc-⊙→Ω-group-emap-codom X = Trunc-group-emap ∘ ⊙→Ω-group-structure-emap-codom X
-- TODO Check naming convensions.
-- TODO Use [CommSquareᴳ].
Trunc-⊙→Ω-group-fmap-nat : ∀ {i₀ i₁ j₀ j₁}
{X₀ : Ptd i₀} {X₁ : Ptd i₁} {Y₀ : Ptd j₀} {Y₁ : Ptd j₁}
(F : X₀ ⊙→ X₁) (G : Y₀ ⊙→ Y₁)
→ Trunc-⊙→Ω-group-fmap-dom F Y₁ ∘ᴳ Trunc-⊙→Ω-group-fmap-codom X₁ G
== Trunc-⊙→Ω-group-fmap-codom X₀ G ∘ᴳ Trunc-⊙→Ω-group-fmap-dom F Y₀
Trunc-⊙→Ω-group-fmap-nat F G = group-hom= $ λ= $ Trunc-elim
(λ k → ap [_] $ ⊙λ= $ ⊙∘-assoc (⊙Ω-fmap G) k F)
{- Not used.
Trunc-⊙→Ω-group-emap-nat : ∀ {i₀ i₁ j₀ j₁}
{X₀ : Ptd i₀} {X₁ : Ptd i₁} {Y₀ : Ptd j₀} {Y₁ : Ptd j₁}
(F : X₀ ⊙≃ X₁) (G : Y₀ ⊙≃ Y₁)
→ Trunc-⊙→Ω-group-emap-dom F Y₁ ∘ᴳ Trunc-⊙→Ω-group-emap-codom X₁ G
== Trunc-⊙→Ω-group-emap-codom X₀ G ∘ᴳ Trunc-⊙→Ω-group-emap-dom F Y₀
Trunc-⊙→Ω-group-emap-nat F G = group-hom=-to-iso= $ Trunc-⊙→Ω-group-fmap-nat F G
-}
{- Pointed maps out of bool -}
Trunc-⊙Bool→Ω-iso-π₁ : ∀ {i} (X : Ptd i)
→ Trunc-⊙→Ω-group ⊙Bool X ≃ᴳ πS 0 X
Trunc-⊙Bool→Ω-iso-π₁ {i} X = Trunc-group-emap (≃-to-≃ᴳˢ (⊙Bool→-equiv-idf (⊙Ω X)) (λ _ _ → idp))
| {
"alphanum_fraction": 0.5079967024,
"avg_line_length": 41.8275862069,
"ext": "agda",
"hexsha": "e93d4af8f94d512bab79a1220e0664d48e63822f",
"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/groups/ToOmega.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/groups/ToOmega.agda",
"max_line_length": 107,
"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/groups/ToOmega.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3150,
"size": 6065
} |
module Proc where
open import Basics
module ProcDef (U : Set)(T : U -> Set)(Name : U -> Set) where
LT : U -> Set
LT a = Lift (T a)
record Tran (a b : U) : Set where
field
upV : T b -> LT a
downV : T a -> LT b
mapLT : {a b : U} -> (T a -> LT b) -> List (T a) -> List (T b)
mapLT f [] = []
mapLT f (x :: xs) with f x
... | bot = mapLT f xs
... | lift y = y :: mapLT f xs
infixr 40 _!_ _!_+_
infix 40 >_
infixr 30 _||_ _/|_
data Proc (a : U) : Set where
o : Proc a
>_ : (T a -> Proc a) -> Proc a
_!_ : LT a -> Proc a -> Proc a
_!_+_ : LT a -> Proc a -> (T a -> Proc a) -> Proc a
_||_ : Proc a -> Proc a -> Proc a
_/|_ : {b : U} -> Tran a b -> Proc b -> Proc a
def : Name a -> Proc a
Env : Set
Env = (a : U) -> Name a -> Proc a
record Param : Set1 where
field
U : Set
T : U -> Set
Name : U -> Set
env : ProcDef.Env U T Name
module Process (param : Param) where
private open module Par = Param param public
private open module Pro = ProcDef U T Name public
infixr 40 _!g_ _!_+g_
infix 40 >g_
infixr 30 _||g_ _/|g_
data Guard {a : U} : Proc a -> Set where
og : Guard o
>g_ : (f : T a -> Proc a) -> Guard (> f)
_!g_ : (w : LT a)(p : Proc a) -> Guard (w ! p)
_!_+g_ : (w : LT a)(p : Proc a)(f : T a -> Proc a) -> Guard (w ! p + f)
_||g_ : {p1 p2 : Proc a} -> Guard p1 -> Guard p2 -> Guard (p1 || p2)
_/|g_ : {b : U}(φ : Tran a b){p : Proc b} -> Guard p -> Guard (φ /| p)
defg : (x : Name a) -> Guard (env a x) -> Guard (def x)
infix 20 _-[_]->_ _-!_!->_
open Tran
data _-[_]->_ {a : U} : Proc a -> LT a -> Proc a -> Set where
qtau : {p : Proc a} -> p -[ bot ]-> p
rx-o : {v : T a} -> o -[ lift v ]-> o
rx-! : {v : T a}{w : LT a}{p : Proc a} -> w ! p -[ lift v ]-> w ! p
rx-> : {v : T a}{f : T a -> Proc a} -> > f -[ lift v ]-> f v
rx-+ : {v : T a}{w : LT a}{p : Proc a}{f : T a -> Proc a} ->
w ! p + f -[ lift v ]-> f v
rx-|| : {v : T a}{p1 p2 p1' p2' : Proc a} ->
p1 -[ lift v ]-> p1' ->
p2 -[ lift v ]-> p2' ->
p1 || p2 -[ lift v ]-> p1' || p2'
rx-/| : {v : T a}{b : U}{φ : Tran a b}{q q' : Proc b} ->
q -[ downV φ v ]-> q' ->
φ /| q -[ lift v ]-> φ /| q'
rx-def : {v : T a}{p : Proc a}{x : Name a} ->
env a x -[ lift v ]-> p ->
def x -[ lift v ]-> p
data _-!_!->_ {a : U} : Proc a -> LT a -> Proc a -> Set where
tx-! : {w : LT a}{p : Proc a} -> w ! p -! w !-> p
tx-+ : {w : LT a}{p : Proc a}{f : T a -> Proc a} ->
w ! p + f -! w !-> p
tx-!| : {w : LT a}{p p' q q' : Proc a} ->
p -! w !-> p' -> q -[ w ]-> q' ->
p || q -! w !-> p' || q'
tx-|! : {w : LT a}{p p' q q' : Proc a} ->
p -[ w ]-> p' -> q -! w !-> q' ->
p || q -! w !-> p' || q'
tx-/| : {b : U}{w : LT b}{φ : Tran a b}{q q' : Proc b} ->
q -! w !-> q' ->
φ /| q -! upV φ =<< w !-> φ /| q'
tx-def : {w : LT a}{p : Proc a}{x : Name a} ->
env a x -! w !-> p ->
def x -! w !-> p
data Silent {a : U} : Proc a -> Set where
silent-o : Silent o
silent-> : {f : T a -> Proc a} -> Silent (> f)
silent-|| : {p1 p2 : Proc a} ->
Silent p1 -> Silent p2 -> Silent (p1 || p2)
silent-def : {x : Name a} ->
Silent (env _ x) -> Silent (def x)
silent-/| : {b : U}{φ : Tran a b}{p : Proc b} ->
Silent p -> Silent (φ /| p)
infixr 40 _>!>_ _>*>_
data _-[_]->*_ {a : U} : Proc a -> List (T a) -> Proc a -> Set where
rnop : {p : Proc a} -> p -[ [] ]->* p
_>?>_ : {p q r : Proc a}{x : T a}{xs : List (T a)} ->
p -[ lift x ]-> q ->
q -[ xs ]->* r ->
p -[ x :: xs ]->* r
rx-||* : forall {a xs}{p1 p2 q1 q2 : Proc a} ->
p1 -[ xs ]->* p2 ->
q1 -[ xs ]->* q2 ->
p1 || q1 -[ xs ]->* p2 || q2
rx-||* rnop rnop = rnop
rx-||* (s1 >?> t1) (s2 >?> t2) = rx-|| s1 s2 >?> rx-||* t1 t2
rx-/|* : forall {a b xs}{φ : Tran a b}{p q : Proc b} ->
p -[ mapLT (downV φ) xs ]->* q ->
φ /| p -[ xs ]->* φ /| q
rx-/|* {xs = []} rnop = rnop
rx-/|* {xs = x :: xs}{φ = φ} t with it (downV φ x) refl
rx-/|* {xs = x :: xs}{φ}{p}{q} t | it bot eq =
rx-/| (lem₁ eq) >?> rx-/|* (lem₂ eq t)
where
lem₁ : forall {w} -> w == bot -> p -[ w ]-> p
lem₁ refl = qtau
lem₂ : downV φ x == bot ->
p -[ mapLT (downV φ) (x :: xs) ]->* q ->
p -[ mapLT (downV φ) xs ]->* q
lem₂ eq h with downV φ x
lem₂ refl h | .bot = h
rx-/|* {a}{b}{x :: xs}{φ}{p}{q} t | it (lift y) eq =
rx-/| (lem₁ eq t) >?> rx-/|* (lem₂ eq t)
where
Eqn = downV φ x == lift y
Asm = p -[ mapLT (downV φ) (x :: xs) ]->* q
r : Eqn -> Asm -> Proc b
r eq t with downV φ x
r refl (_>?>_ {q = q} _ _) | ._ = q
lem₁ : (eq : Eqn)(h : Asm) -> p -[ downV φ x ]-> r eq h
lem₁ eq t with downV φ x
lem₁ refl (s >?> _) | ._ = s
lem₂ : (eq : Eqn)(h : Asm) -> r eq h -[ mapLT (downV φ) xs ]->* q
lem₂ eq t with downV φ x
lem₂ refl (_ >?> t) | ._ = t
data _-!_!->*_ {a : U} : Proc a -> List (T a) -> Proc a -> Set where
tnop : {p : Proc a} -> p -! [] !->* p
_>!>_ : {p q r : Proc a}{x : T a}{xs : List (T a)} ->
p -! lift x !-> q ->
q -! xs !->* r ->
p -! x :: xs !->* r
_>*>_ : {p q r : Proc a}{xs : List (T a)} ->
p -! bot !-> q ->
q -! xs !->* r ->
p -! xs !->* r
| {
"alphanum_fraction": 0.3695393507,
"avg_line_length": 33.6171428571,
"ext": "agda",
"hexsha": "749fd76a37d14b4917a98bba7984d0c7afa25834",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/cbs/Proc.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/cbs/Proc.agda",
"max_line_length": 78,
"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": "examples/outdated-and-incorrect/cbs/Proc.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 2371,
"size": 5883
} |
open import Relation.Binary.Core
module Bound.Total.Order.Properties {A : Set}
(_≤_ : A → A → Set)
(trans≤ : Transitive _≤_) where
open import Bound.Total A
open import Bound.Total.Order _≤_
lemma-LeB≤ : {x y : A} → LeB (val x) (val y) → x ≤ y
lemma-LeB≤ (lexy x≤y) = x≤y
transLeB : {a b c : Bound} → LeB a b → LeB b c → LeB a c
transLeB lebx _ = lebx
transLeB _ lext = lext
transLeB (lexy x≤y) (lexy y≤z) = lexy (trans≤ x≤y y≤z)
| {
"alphanum_fraction": 0.5889830508,
"avg_line_length": 27.7647058824,
"ext": "agda",
"hexsha": "decf09f47383d76f2cb80da7aa5276469bdc4f61",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/Bound/Total/Order/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/Bound/Total/Order/Properties.agda",
"max_line_length": 56,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/Bound/Total/Order/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 190,
"size": 472
} |
module STLC.Examples where
-- This file contains a few example programs for the definitional
-- interpreter for STLC in Section 2.
open import Data.Maybe.Base
open import Data.List.Base
open import Data.List.Relation.Unary.Any
open import Data.List.Relation.Unary.All
open import Data.List.Membership.Propositional
open import Data.Integer hiding (suc)
open import Relation.Binary.PropositionalEquality -- for de Bruijn numerals
open import STLC.Semantics
-- The identity function: λ x . x
--
-- Variables are represented as de Bruijn indices, assumed to have
-- been elaborated from a surface language with names to the nameless
-- representation used in the abstract syntax in `STLC.Semantics`.
idexpr : Expr [] (unit ⇒ unit)
idexpr = ƛ (var (here refl))
-- id () = ()
test-idexpr : eval 2 (idexpr · unit) [] ≡ just unit
test-idexpr = refl
-- curried addition: λ x . λ y . y + x
curry+ : Expr [] (int ⇒ (int ⇒ int))
curry+ = ƛ (ƛ (iop _+_ (var (here refl)) (var (there (here refl)))))
-- 1 + 1 = 2
test-curry+ : eval 3 ((curry+ · (num (+ 1))) · (num (+ 1))) [] ≡ just (num (+ 2))
test-curry+ = refl
| {
"alphanum_fraction": 0.696122633,
"avg_line_length": 30.8055555556,
"ext": "agda",
"hexsha": "ec6b4ce640fa4c7e32ae4efd3fcaa67737fdfe1d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/STLC/Examples.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/STLC/Examples.agda",
"max_line_length": 81,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/STLC/Examples.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 326,
"size": 1109
} |
------------------------------------------------------------------------------
-- The predicate names are translated as constant names
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module PredicateNameConstantName where
postulate
D : Set
P : D → Set
postulate foo : ∀ d → P d → P d
{-# ATP prove foo #-}
| {
"alphanum_fraction": 0.4003868472,
"avg_line_length": 28.7222222222,
"ext": "agda",
"hexsha": "6979273f99aea9236aba678f14bfdb47eddbf47a",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Succeed/fol-theorems/PredicateNameConstantName.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Succeed/fol-theorems/PredicateNameConstantName.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Succeed/fol-theorems/PredicateNameConstantName.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 86,
"size": 517
} |
module Simple where
postulate
Nat : Set
zero : Nat
-- we want
-- ?0 zero = zero
-- and then
-- ?0 x = x
| {
"alphanum_fraction": 0.5289256198,
"avg_line_length": 9.3076923077,
"ext": "agda",
"hexsha": "4ddf0f5570945680f97f490fc3691cee7b02c8e5",
"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": "notes/papers/implicit/examples/Simple.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": "notes/papers/implicit/examples/Simple.agda",
"max_line_length": 19,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "notes/papers/implicit/examples/Simple.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": 45,
"size": 121
} |
module Data.QuadTree.Implementation.PropDepthRelation where
open import Haskell.Prelude
open import Data.Logic
---- Properties of depth
lteTransitiveWeird : (x y d : Nat) -> IsTrue (x < y) -> (y <= d) ≡ ((x <= d) && (y <= d))
lteTransitiveWeird zero zero zero xlty = refl
lteTransitiveWeird zero zero (suc d) xlty = refl
lteTransitiveWeird zero (suc y) zero xlty = refl
lteTransitiveWeird zero (suc y) (suc d) xlty = refl
lteTransitiveWeird (suc x) (suc y) zero xlty = refl
lteTransitiveWeird (suc x) (suc y) (suc d) xlty = lteTransitiveWeird x y d xlty
lteTransitiveWeirdInv : (x y d : Nat) -> IsFalse (x < y) -> (x <= d) ≡ ((x <= d) && (y <= d))
lteTransitiveWeirdInv zero zero zero xnlty = refl
lteTransitiveWeirdInv zero zero (suc d) xnlty = refl
lteTransitiveWeirdInv (suc x) zero zero xnlty = refl
lteTransitiveWeirdInv (suc x) zero (suc d) xnlty =
begin
(suc x <= suc d)
=⟨ sym $ boolAndTrue (suc x <= suc d) ⟩
(suc x <= suc d) && true
=⟨⟩
((suc x <= suc d) && (zero <= suc d))
end
lteTransitiveWeirdInv (suc x) (suc y) zero xnlty = refl
lteTransitiveWeirdInv (suc x) (suc y) (suc d) xnlty = lteTransitiveWeirdInv x y d xnlty
ifComparisonMap : (x y d : Nat) -> ((x <= d) && (y <= d)) ≡ (if x < y then (y <= d) else (x <= d))
ifComparisonMap x y d = ifc x < y
then (λ {{xlty}} ->
begin
(x <= d) && (y <= d)
=⟨ sym $ lteTransitiveWeird x y d xlty ⟩
y <= d
=⟨ sym $ ifTrue (x < y) xlty ⟩
(if x < y then (y <= d) else (x <= d))
end
)
else (λ {{xnlty}} ->
begin
(x <= d) && (y <= d)
=⟨ sym $ lteTransitiveWeirdInv x y d xnlty ⟩
x <= d
=⟨ sym $ ifFalse (x < y) xnlty ⟩
(if x < y then (y <= d) else (x <= d))
end
)
propMaxLte : (x y d : Nat) -> ((x <= d) && (y <= d)) ≡ (max x y <= d)
propMaxLte x y d =
begin
(x <= d) && (y <= d)
=⟨ ifComparisonMap x y d ⟩
(if x < y then (y <= d) else (x <= d))
=⟨ propFnIf (λ v -> v <= d) ⟩
(if x < y then y else x) <= d
=⟨⟩
max x y <= d
end
propAndMap : (a b c d : Bool) -> a ≡ c -> b ≡ d -> (a && b) ≡ (c && d)
propAndMap false false false false ac bd = refl
propAndMap false true false true ac bd = refl
propAndMap true false true false ac bd = refl
propAndMap true true true true ac bd = refl
propMaxLte4 : (w x y z d : Nat) -> (((w <= d) && (x <= d)) && ((y <= d) && (z <= d))) ≡ (max (max w x) (max y z) <= d)
propMaxLte4 w x y z d =
begin
((w <= d) && (x <= d)) && ((y <= d) && (z <= d))
=⟨ propAndMap ((w <= d) && (x <= d)) ((y <= d) && (z <= d)) (max w x <= d) (max y z <= d) (propMaxLte w x d) (propMaxLte y z d) ⟩
(max w x <= d) && (max y z <= d)
=⟨ propMaxLte (if w < x then x else w) (if y < z then z else y) d ⟩
(max (max w x) (max y z) <= d)
end
| {
"alphanum_fraction": 0.5452891961,
"avg_line_length": 34.7974683544,
"ext": "agda",
"hexsha": "1a2eb7f674ec4561c12315c884c154bf40eaf02f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "JonathanBrouwer/research-project",
"max_forks_repo_path": "src/Data/QuadTree/Implementation/PropDepthRelation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "JonathanBrouwer/research-project",
"max_issues_repo_path": "src/Data/QuadTree/Implementation/PropDepthRelation.agda",
"max_line_length": 131,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "JonathanBrouwer/research-project",
"max_stars_repo_path": "src/Data/QuadTree/Implementation/PropDepthRelation.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z",
"num_tokens": 1120,
"size": 2749
} |
open import trie-core
open import string
open import maybe
module trie-functions (trie-lookup : ∀{A : Set} → trie A → string → maybe A)
(trie-insert : ∀{A : Set} → trie A → string → A → trie A)
(trie-remove : ∀{A : Set} → trie A → string → trie A) where
open import bool
open import char
open import list
open import product
open import unit
open import eq
open import nat
trie-contains : ∀{A : Set} → trie A → string → 𝔹
trie-contains t s with trie-lookup t s
trie-contains t s | nothing = ff
trie-contains t s | just _ = tt
trie-map : ∀{A B : Set} → (A → B) → trie A → trie B
trie-cal-map : ∀{A B : Set} → (A → B) → cal (trie A) → cal (trie B)
trie-map f (Node x x₁) = Node (maybe-map f x) (trie-cal-map f x₁)
trie-cal-map f [] = []
trie-cal-map f ((c , t) :: cs) =
(c , trie-map f t) :: trie-cal-map f cs
trie-to-string-h : ∀{A : Set} → string → (A → string) → trie A → 𝕃 char → string
trie-cal-to-string-h : ∀{A : Set} → string → (A → string) → cal (trie A) → 𝕃 char → string
trie-to-string-h sep d (Node (just x) c) prev-str =
(𝕃char-to-string (reverse prev-str)) ^ sep ^ (d x) ^ "\n" ^ (trie-cal-to-string-h sep d c prev-str)
trie-to-string-h sep d (Node nothing c) prev-str = trie-cal-to-string-h sep d c prev-str
trie-cal-to-string-h sep d [] prev-str = ""
trie-cal-to-string-h sep d ((c , t) :: cs) prev-str =
(trie-to-string-h sep d t (c :: prev-str)) ^ (trie-cal-to-string-h sep d cs prev-str)
{- trie-to-string sep d t returns a string representation of the trie t,
where each mapping from string s to data x is printed as
s sep d x
where sep is a string and d returns a string for any element A of the trie. -}
trie-to-string : ∀{A : Set} → string → (A → string) → trie A → string
trie-to-string sep d t = trie-to-string-h sep d t []
trie-mappings-h : ∀{A : Set} → trie A → 𝕃 char → 𝕃 (string × A)
trie-cal-mappings-h : ∀{A : Set} → cal (trie A) → 𝕃 char → 𝕃 (string × A)
trie-mappings-h (Node (just x) c) prev-str = (𝕃char-to-string (reverse prev-str) , x) :: (trie-cal-mappings-h c prev-str)
trie-mappings-h (Node nothing c) prev-str = (trie-cal-mappings-h c prev-str)
trie-cal-mappings-h [] prev-str = []
trie-cal-mappings-h ((c , t) :: cs) prev-str = trie-mappings-h t (c :: prev-str) ++ (trie-cal-mappings-h cs prev-str)
trie-mappings : ∀{A : Set} → trie A → 𝕃 (string × A)
trie-mappings t = trie-mappings-h t []
-- return a list of all the strings which have associated data in the trie
trie-strings : ∀{A : Set} → trie A → 𝕃 string
trie-strings t = map fst (trie-mappings t)
trie-size : ∀{A : Set} → trie A → ℕ
trie-size t = length (trie-strings t)
trie-nonempty : ∀{A : Set} → trie A → 𝔹
trie-cal-nonempty : ∀{A : Set} → cal (trie A) → 𝔹
trie-nonempty (Node (just x) t) = tt
trie-nonempty (Node nothing c) = trie-cal-nonempty c
trie-cal-nonempty [] = ff
trie-cal-nonempty ((a , t) :: c) = trie-nonempty t || trie-cal-nonempty c
----------------------------------------------------------------------
-- list-tries, which map strings to lists of values
----------------------------------------------------------------------
𝕃trie : Set → Set
𝕃trie A = trie (𝕃 A)
𝕃trie-lookup : ∀{A : Set} → 𝕃trie A → string → 𝕃 A
𝕃trie-lookup t s with trie-lookup t s
... | nothing = []
... | just l = l
𝕃trie-add : ∀{A : Set} → trie (𝕃 A) → string → A → trie (𝕃 A)
𝕃trie-add t s a = trie-insert t s (a :: 𝕃trie-lookup t s)
𝕃trie-add* : ∀{A : Set} → trie (𝕃 A) → string → 𝕃 A → trie (𝕃 A)
𝕃trie-add* t s aa = trie-insert t s (aa ++ 𝕃trie-lookup t s)
----------------------------------------------------------------------
-- stringset
----------------------------------------------------------------------
stringset : Set
stringset = trie ⊤
stringset-contains : stringset → string → 𝔹
stringset-contains ss s = trie-contains ss s
stringset-insert : stringset → string → stringset
stringset-insert ss s = trie-insert ss s triv
stringset-remove : stringset → string → stringset
stringset-remove ss s = trie-remove ss s
stringset-insert𝕃 : stringset → 𝕃 char → stringset
stringset-insert𝕃 ss s = trie-insert-h ss s triv
empty-stringset : stringset
empty-stringset = empty-trie
stringset-insert* : stringset → 𝕃 string → stringset
stringset-insert* s [] = s
stringset-insert* s (x :: xs) = stringset-insert (stringset-insert* s xs) x
stringset-strings : ∀{A : Set} → trie A → 𝕃 string
stringset-strings t = map fst (trie-mappings t)
| {
"alphanum_fraction": 0.5981012658,
"avg_line_length": 38.4695652174,
"ext": "agda",
"hexsha": "c8e7f9fd09f4ae9358271a2d390eb0cdbec52129",
"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": "trie-functions.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": "trie-functions.agda",
"max_line_length": 121,
"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": "trie-functions.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": 1392,
"size": 4424
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties satisfied by decidable total orders
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Relation.Binary.Properties.DecTotalOrder
{d₁ d₂ d₃} (DT : DecTotalOrder d₁ d₂ d₃) where
open DecTotalOrder DT hiding (trans)
import Relation.Binary.Construct.Converse as Converse
import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict
import Relation.Binary.Properties.TotalOrder totalOrder as TotalOrderProperties
open import Relation.Nullary using (¬_)
------------------------------------------------------------------------
-- _≥_ - the flipped relation is also a total order
open TotalOrderProperties public
using
( _≥_
; ≥-refl
; ≥-reflexive
; ≥-trans
; ≥-antisym
; ≥-total
; ≥-isPreorder
; ≥-isPartialOrder
; ≥-isTotalOrder
; ≥-preorder
; ≥-poset
; ≥-totalOrder
)
≥-isDecTotalOrder : IsDecTotalOrder _≈_ _≥_
≥-isDecTotalOrder = Converse.isDecTotalOrder isDecTotalOrder
≥-decTotalOrder : DecTotalOrder _ _ _
≥-decTotalOrder = record
{ isDecTotalOrder = ≥-isDecTotalOrder
}
open DecTotalOrder ≥-decTotalOrder public
using () renaming (_≤?_ to _≥?_)
------------------------------------------------------------------------
-- _<_ - the strict version is a strict total order
open TotalOrderProperties public
using
( _<_
; <-resp-≈
; <-respʳ-≈
; <-respˡ-≈
; <-irrefl
; <-asym
; <-trans
; <-isStrictPartialOrder
; <-strictPartialOrder
; <⇒≉
; ≤∧≉⇒<
; <⇒≱
; ≤⇒≯
; ≰⇒>
)
<-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_
<-isStrictTotalOrder = ToStrict.<-isStrictTotalOrder₂ isDecTotalOrder
<-strictTotalOrder : StrictTotalOrder _ _ _
<-strictTotalOrder = record
{ isStrictTotalOrder = <-isStrictTotalOrder
}
open StrictTotalOrder <-strictTotalOrder public
using () renaming (compare to <-compare)
≮⇒≥ : ∀ {x y} → ¬ (x < y) → y ≤ x
≮⇒≥ = ToStrict.≮⇒≥ Eq.sym _≟_ reflexive total
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.2
strictTotalOrder = <-strictTotalOrder
{-# WARNING_ON_USAGE strictTotalOrder
"Warning: strictTotalOrder was deprecated in v1.2.
Please use <-strictTotalOrder instead."
#-}
| {
"alphanum_fraction": 0.58290463,
"avg_line_length": 25.27,
"ext": "agda",
"hexsha": "63fa479d0df25e014101a611344f71ef21fe0d14",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Properties/DecTotalOrder.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Properties/DecTotalOrder.agda",
"max_line_length": 79,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Properties/DecTotalOrder.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": 707,
"size": 2527
} |
{-# OPTIONS --without-K #-}
module hott.level.sets where
open import hott.level.sets.core public
open import hott.level.sets.extra public
| {
"alphanum_fraction": 0.7625899281,
"avg_line_length": 23.1666666667,
"ext": "agda",
"hexsha": "c7087d8b323fb7f77839b439afcdb1f51a5f70bc",
"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/hott/level/sets.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/hott/level/sets.agda",
"max_line_length": 40,
"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/hott/level/sets.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": 31,
"size": 139
} |
module Basics where
id : ∀ {a}{A : Set a} → A → A
id x = x
_∘_ : ∀ {a b c}{A : Set a}{B : Set b}{C : Set c} → (f : B → C) → (g : A → B) → (A → C)
f ∘ g = λ x → f (g x)
| {
"alphanum_fraction": 0.3882352941,
"avg_line_length": 21.25,
"ext": "agda",
"hexsha": "2b47fd2923a78c5c6033591120beaa903b922763",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CodaFi/HoTT-Exercises",
"max_forks_repo_path": "Basics.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CodaFi/HoTT-Exercises",
"max_issues_repo_path": "Basics.agda",
"max_line_length": 86,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CodaFi/HoTT-Exercises",
"max_stars_repo_path": "Basics.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 86,
"size": 170
} |
{-# OPTIONS --cubical --allow-unsolved-metas #-}
open import Agda.Builtin.Cubical.Path
open import Agda.Primitive.Cubical
open import Agda.Builtin.Bool
postulate
Index : Set
i : Index
data D : Index → Set where
c : D i
cong : {A B : Set} (x y : A) (f : A → B) → x ≡ y → f x ≡ f y
cong _ _ f x≡y = λ i → f (x≡y i)
refl : {A : Set} {x : A} → x ≡ x
refl {x = x} = λ _ → x
subst :
{A : Set} {x y : A}
(P : A → Set) → x ≡ y → P x → P y
subst P eq p = primTransp (λ i → P (eq i)) i0 p
postulate
subst-refl :
{A : Set} {x : A} (P : A → Set) {p : P x} →
subst P refl p ≡ p
f : {i : Index} (xs : D i) → D i
f c = c
works : f (subst D refl c) ≡ c
works = cong (subst D refl c) c f (subst-refl D)
-- There is no type error here, just a meta to solve.
-- The original problem was assuming injectivity of f.
should-work-too : f (subst D refl c) ≡ c
should-work-too = cong _ _ f (subst-refl D)
| {
"alphanum_fraction": 0.5655021834,
"avg_line_length": 22.3414634146,
"ext": "agda",
"hexsha": "26e52fb3cea8e9729f5e15ee7e23ed3f112aae58",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Succeed/Issue5579.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Succeed/Issue5579.agda",
"max_line_length": 60,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Succeed/Issue5579.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": 364,
"size": 916
} |
open import Oscar.Prelude
open import Oscar.Class
module Oscar.Class.Reflexivity where
module Reflexivity'
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)
(x : 𝔒)
= ℭLASS (_∼_) (x ∼ x)
module Reflexivity
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)
where
class = ∀ {x} → Reflexivity'.class _∼_ x
type = ∀ {x} → Reflexivity'.type _∼_ x
method : ⦃ _ : class ⦄ → type
method = Reflexivity'.method _∼_ _
module _
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}
where
reflexivity = Reflexivity.method _∼_
ε = reflexivity
module _
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)
where
reflexivity[_] = Reflexivity.method _∼_
ε[_] = reflexivity
| {
"alphanum_fraction": 0.5670261941,
"avg_line_length": 18.5428571429,
"ext": "agda",
"hexsha": "e9db95795dfa7328e75765713b10f12ca5b48b3e",
"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-3/src/Oscar/Class/Reflexivity.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-3/src/Oscar/Class/Reflexivity.agda",
"max_line_length": 42,
"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-3/src/Oscar/Class/Reflexivity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 322,
"size": 649
} |
-- Andreas, 2019-07-23, issue #3937 reported by gallais
f : let ... = ? in ?
f = ?
-- WAS: internal error
-- Expected: Could not parse the left-hand side ...
| {
"alphanum_fraction": 0.6211180124,
"avg_line_length": 17.8888888889,
"ext": "agda",
"hexsha": "3a745194d2e9034a9ae04a348a686b1751848201",
"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/Issue3937.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/Issue3937.agda",
"max_line_length": 55,
"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/Issue3937.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": 161
} |
{-
Definition of a basis of a distributive lattice as a generating sub-meet-semilattice
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.DistLattice.Basis where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Powerset
open import Cubical.Functions.Embedding
open import Cubical.Data.Sigma
open import Cubical.Data.Nat using (ℕ ; zero ; suc)
open import Cubical.Data.FinData
open import Cubical.Data.Bool
open import Cubical.Structures.Axioms
open import Cubical.Structures.Auto
open import Cubical.Structures.Macro
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Monoid.BigOp
open import Cubical.Algebra.CommMonoid
open import Cubical.Algebra.Semilattice
open import Cubical.Algebra.Lattice
open import Cubical.Algebra.DistLattice
open import Cubical.Algebra.DistLattice.BigOps
private
variable
ℓ : Level
module _ (L' : DistLattice ℓ) where
private L = fst L'
open DistLatticeStr (snd L')
open Join L'
record IsGenSublattice (M : Semilattice ℓ) (e : fst M → L) : Type ℓ where
constructor
isgensublattice
open SemilatticeStr (snd M) renaming (ε to 0s ; _·_ to _∧s_)
field
isInj : ∀ x y → e x ≡ e y → x ≡ y
pres0 : e 0s ≡ 0l
resp∧ : ∀ x y → e (x ∧s y) ≡ e x ∧l e y
⋁Gen : ∀ (x : L) → ∃[ n ∈ ℕ ] Σ[ α ∈ FinVec (fst M) n ] (⋁ (e ∘ α) ≡ x)
-- TODO: prove equivalence with the more set-theoretical definition
record IsBasis (S : ℙ L) : Type ℓ where
constructor
isbasis
field
contains1 : 1l ∈ S
∧lClosed : ∀ (x y : L) → x ∈ S → y ∈ S → x ∧l y ∈ S
⋁Basis : ∀ (x : L) → ∃[ n ∈ ℕ ] Σ[ α ∈ FinVec L n ] (∀ i → α i ∈ S) × (⋁ α ≡ x)
open IsBasis
open SemilatticeStr
Basis→MeetSemilattice : (S : ℙ L) → IsBasis S → Semilattice ℓ
fst (Basis→MeetSemilattice S isBasisS) = Σ[ l ∈ L ] (l ∈ S)
ε (snd (Basis→MeetSemilattice S isBasisS)) = 1l , isBasisS .contains1
_·_ (snd (Basis→MeetSemilattice S isBasisS)) x y = fst x ∧l fst y
, isBasisS .∧lClosed _ _ (snd x) (snd y)
isSemilattice (snd (Basis→MeetSemilattice S isBasisS)) = makeIsSemilattice
(isSetΣ (isSetDistLattice L') λ _ → isProp→isSet (S _ .snd))
(λ _ _ _ → Σ≡Prop (λ _ → S _ .snd) (∧lAssoc _ _ _))
(λ _ → Σ≡Prop (λ _ → S _ .snd) (∧lRid _))
(λ _ → Σ≡Prop (λ _ → S _ .snd) (∧lLid _))
(λ _ _ → Σ≡Prop (λ _ → S _ .snd) (∧lComm _ _))
λ _ → Σ≡Prop (λ _ → S _ .snd) (∧lIdem _)
| {
"alphanum_fraction": 0.6739598278,
"avg_line_length": 34.85,
"ext": "agda",
"hexsha": "da44dab48cce379edaa8fc523e70d381b338869e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/Algebra/DistLattice/Basis.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/Algebra/DistLattice/Basis.agda",
"max_line_length": 90,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/Algebra/DistLattice/Basis.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z",
"num_tokens": 985,
"size": 2788
} |
module WellTypedTermsModel where
open import Library
open import WellTypedTerms
open import RMonads.REM
open import FunctorCat
open import Categories.Sets
-- interpretation of types
Val : Ty → Set
Val ι = ⊤
Val (σ ⇒ τ) = Val σ → Val τ
-- interpretation of contexts
Env : Con → Set
Env Γ = ∀{σ} → Var Γ σ → Val σ
_<<_ : ∀{Γ σ} → Env Γ → Val σ → Env (Γ < σ)
(γ << v) vz = v
(γ << v) (vs x) = γ x
-- intepretation of terms
eval : ∀{Γ σ} → Env Γ → Tm Γ σ → Val σ
eval γ (var x) = γ x
eval γ (app t u) = eval γ t (eval γ u)
eval γ (lam t) = λ v → eval (γ << v) t
substeval : ∀{σ τ}(p : σ ≅ τ){Γ : Con}{γ : Env Γ}(t : Tm Γ σ) →
(subst Val p ∘ eval γ) t ≅ (eval γ ∘ subst (Tm Γ) p) t
substeval refl t = refl
wk<< : ∀{Γ Δ}(α : Ren Γ Δ)(β : Env Δ){σ}(v : Val σ) →
∀{ρ}(y : Var (Γ < σ) ρ) →
((β ∘ α) << v) y ≅ (β << v) (wk α y)
wk<< α β v vz = refl
wk<< α β v (vs y) = refl
reneval : ∀{Γ Δ σ}(α : Ren Γ Δ)(β : Env Δ)(t : Tm Γ σ) →
eval (β ∘ α) t ≅ (eval β ∘ ren α) t
reneval α β (var x) = refl
reneval α β (app t u) =
proof
eval (β ∘ α) t (eval (β ∘ α) u)
≅⟨ cong₂ (λ f x → f x) (reneval α β t) (reneval α β u) ⟩
eval β (ren α t) (eval β (ren α u))
∎
reneval α β (lam t) = ext λ v →
proof
eval ((β ∘ α) << v) t
≅⟨ cong (λ (γ : Env _) → eval γ t) (iext λ _ → ext (wk<< α β v)) ⟩
eval ((β << v) ∘ wk α) t
≅⟨ reneval (wk α) (β << v) t ⟩
eval (β << v) (ren (wk α) t)
∎
lifteval : ∀{Γ Δ σ τ}(α : Sub Γ Δ)(β : Env Δ)(v : Val σ)(y : Var (Γ < σ) τ) →
((eval β ∘ α) << v) y ≅ (eval (β << v) ∘ lift α) y
lifteval α β v vz = refl
lifteval α β v (vs x) =
proof
eval β (α x)
≅⟨ reneval vs (β << v) (α x) ⟩
eval (β << v) (ren vs (α x))
∎
subeval : ∀{Γ Δ σ}(α : Sub Γ Δ)(β : Env Δ)(t : Tm Γ σ) →
eval (eval β ∘ α) t ≅ (eval β ∘ sub α) t
subeval α β (var x) = refl
subeval α β (app t u) =
proof
eval (eval β ∘ α) t (eval (eval β ∘ α) u)
≅⟨ cong₂ (λ f x → f x) (subeval α β t) (subeval α β u) ⟩
eval β (sub α t) (eval β (sub α u))
∎
subeval α β (lam t) = ext λ v →
proof
eval ((eval β ∘ α) << v) t
≅⟨ cong (λ (γ : Env _) → eval γ t) (iext λ _ → ext (lifteval α β v)) ⟩
eval (eval (β << v) ∘ lift α) t
≅⟨ subeval (lift α) (β << v) t ⟩
eval (β << v) (sub (lift α) t)
∎
modelRAlg : RAlg TmRMonad
modelRAlg = record {
acar = Val;
astr = λ {Γ} → λ γ → eval γ;
alaw1 = refl;
alaw2 = λ {Γ Δ α γ} → iext λ σ → ext (subeval α γ)}
| {
"alphanum_fraction": 0.4869530309,
"avg_line_length": 26.5,
"ext": "agda",
"hexsha": "371e7732834f3d6f41dddd27911384d0bc24af8f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jmchapman/Relative-Monads",
"max_forks_repo_path": "WellTypedTermsModel.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jmchapman/Relative-Monads",
"max_issues_repo_path": "WellTypedTermsModel.agda",
"max_line_length": 77,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jmchapman/Relative-Monads",
"max_stars_repo_path": "WellTypedTermsModel.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z",
"num_tokens": 1148,
"size": 2491
} |
module Class.Traversable where
open import Class.Monad
open import Level
record Traversable {a} (T : Set a -> Set a) : Set (suc a) where
field
sequence : ∀ {M : Set a -> Set a} {{_ : Monad M}} {A : Set a} -> T (M A) -> M (T A)
open Traversable {{...}} public
| {
"alphanum_fraction": 0.6044776119,
"avg_line_length": 24.3636363636,
"ext": "agda",
"hexsha": "9389a9054e49961697562ad12228e77920a52901",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
"max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "WhatisRT/meta-cedille",
"max_forks_repo_path": "stdlib-exts/Class/Traversable.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "WhatisRT/meta-cedille",
"max_issues_repo_path": "stdlib-exts/Class/Traversable.agda",
"max_line_length": 87,
"max_stars_count": 35,
"max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "WhatisRT/meta-cedille",
"max_stars_repo_path": "stdlib-exts/Class/Traversable.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z",
"num_tokens": 87,
"size": 268
} |
open import Coinduction using ( ♯_ )
open import Data.Bool using ( Bool ; true ; false ; not )
open import Data.ByteString using ( null )
open import Data.ByteString.UTF8 using ( fromString ) renaming ( span to #span )
open import Data.Natural using ( Natural )
open import Data.Product using ( _×_ ; _,_ )
open import Data.Char using ( Char )
open import System.IO.Transducers.Lazy using ( _⇒_ ; inp ; out ; done ; _⟫_ ; π₁ ; π₂ ; _[&]_ )
open import System.IO.Transducers.Weight using ( weight )
open import System.IO.Transducers.Stateful using ( loop )
open import System.IO.Transducers.Session using ( ⟨_⟩ ; _&_ ; ¿ ; * ; _&*_ ; Bytes ; Bytes' ; Strings )
open import System.IO.Transducers.Strict using ( _⇛_ )
module System.IO.Transducers.UTF8 where
mutual
-- TODO: span isn't doing the right thing when char boundaries fail to line up with bytestring boundaries
span+ : (Char → Bool) → Bytes' ⇛ (Bytes & Bytes)
span+ φ x with #span φ x
span+ φ x | (x₁ , x₂) with null x₁ | null x₂
span+ φ x | (x₁ , x₂) | true | true = inp (♯ span φ)
span+ φ x | (x₁ , x₂) | true | false = out false (out true (out x₂ done))
span+ φ x | (x₁ , x₂) | false | true = out true (out x₁ (inp (♯ span φ)))
span+ φ x | (x₁ , x₂) | false | false = out true (out x₁ (out false (out true (out x₂ done))))
span : (Char → Bool) → Bytes ⇛ (Bytes & Bytes)
span φ false = out false (out false done)
span φ true = inp (♯ span+ φ)
break : (Char → Bool) → Bytes ⇛ (Bytes & Bytes)
break φ = span (λ x → not (φ x))
mutual
nonempty+ : Bytes' & Bytes ⇛ ¿ Bytes & Bytes
nonempty+ x with null x
nonempty+ x | true = inp (♯ nonempty)
nonempty+ x | false = out true (out true (out x done))
nonempty : Bytes & Bytes ⇛ ¿ Bytes & Bytes
nonempty true = inp (♯ nonempty+)
nonempty false = out false done
split? : (Char → Bool) → Bytes ⇒ (¿ Bytes & Bytes)
split? φ = inp (♯ span φ) ⟫ π₂ {Bytes} ⟫ inp (♯ break φ) ⟫ inp (♯ nonempty)
split : (Char → Bool) → Bytes ⇒ * Bytes
split φ = loop {Bytes} (split? φ) ⟫ π₁
-- TODO: decode
encode : Strings ⇛ Bytes
encode true = out true (inp (♯ λ s → out (fromString s) (inp (♯ encode))))
encode false = out false done
| {
"alphanum_fraction": 0.634774609,
"avg_line_length": 37.4827586207,
"ext": "agda",
"hexsha": "1a5fecbbd8f24dba85be9882a80052a07a2a1735",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/System/IO/Transducers/UTF8.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"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": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/System/IO/Transducers/UTF8.agda",
"max_line_length": 107,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/System/IO/Transducers/UTF8.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z",
"num_tokens": 704,
"size": 2174
} |
module Text.Greek.SBLGNT.2Thess where
open import Data.List
open import Text.Greek.Bible
open import Text.Greek.Script
open import Text.Greek.Script.Unicode
ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β : List (Word)
ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β =
word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "2Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (Σ ∷ ι ∷ ∙λ ∷ ο ∷ υ ∷ α ∷ ν ∷ ὸ ∷ ς ∷ []) "2Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ς ∷ []) "2Thess.1.1"
∷ word (τ ∷ ῇ ∷ []) "2Thess.1.1"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "2Thess.1.1"
∷ word (Θ ∷ ε ∷ σ ∷ σ ∷ α ∷ ∙λ ∷ ο ∷ ν ∷ ι ∷ κ ∷ έ ∷ ω ∷ ν ∷ []) "2Thess.1.1"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.1"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.1"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.1.1"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.1"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "2Thess.1.1"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "2Thess.1.2"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.2"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "2Thess.1.2"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.2"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.2"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.1.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.2"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.2"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.2"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.2"
∷ word (Ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "2Thess.1.3"
∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.1.3"
∷ word (τ ∷ ῷ ∷ []) "2Thess.1.3"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.3"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.1.3"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.1.3"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ἄ ∷ ξ ∷ ι ∷ ό ∷ ν ∷ []) "2Thess.1.3"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.1.3"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ α ∷ υ ∷ ξ ∷ ά ∷ ν ∷ ε ∷ ι ∷ []) "2Thess.1.3"
∷ word (ἡ ∷ []) "2Thess.1.3"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.3"
∷ word (π ∷ ∙λ ∷ ε ∷ ο ∷ ν ∷ ά ∷ ζ ∷ ε ∷ ι ∷ []) "2Thess.1.3"
∷ word (ἡ ∷ []) "2Thess.1.3"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ []) "2Thess.1.3"
∷ word (ἑ ∷ ν ∷ ὸ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ἑ ∷ κ ∷ ά ∷ σ ∷ τ ∷ ο ∷ υ ∷ []) "2Thess.1.3"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.1.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.3"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.1.3"
∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "2Thess.1.4"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ γ ∷ κ ∷ α ∷ υ ∷ χ ∷ ᾶ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4"
∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ι ∷ ς ∷ []) "2Thess.1.4"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.1.4"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ῆ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.4"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.4"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.4"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (δ ∷ ι ∷ ω ∷ γ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.4"
∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "2Thess.1.4"
∷ word (θ ∷ ∙λ ∷ ί ∷ ψ ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.4"
∷ word (α ∷ ἷ ∷ ς ∷ []) "2Thess.1.4"
∷ word (ἀ ∷ ν ∷ έ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.1.4"
∷ word (ἔ ∷ ν ∷ δ ∷ ε ∷ ι ∷ γ ∷ μ ∷ α ∷ []) "2Thess.1.5"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.5"
∷ word (δ ∷ ι ∷ κ ∷ α ∷ ί ∷ α ∷ ς ∷ []) "2Thess.1.5"
∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ὸ ∷ []) "2Thess.1.5"
∷ word (κ ∷ α ∷ τ ∷ α ∷ ξ ∷ ι ∷ ω ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.5"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.5"
∷ word (β ∷ α ∷ σ ∷ ι ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.1.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.5"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.1.5"
∷ word (ἧ ∷ ς ∷ []) "2Thess.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.5"
∷ word (π ∷ ά ∷ σ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.1.5"
∷ word (ε ∷ ἴ ∷ π ∷ ε ∷ ρ ∷ []) "2Thess.1.6"
∷ word (δ ∷ ί ∷ κ ∷ α ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.6"
∷ word (π ∷ α ∷ ρ ∷ ὰ ∷ []) "2Thess.1.6"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.1.6"
∷ word (ἀ ∷ ν ∷ τ ∷ α ∷ π ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.6"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.6"
∷ word (θ ∷ ∙λ ∷ ί ∷ β ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.6"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.6"
∷ word (θ ∷ ∙λ ∷ ῖ ∷ ψ ∷ ι ∷ ν ∷ []) "2Thess.1.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.7"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.7"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.7"
∷ word (θ ∷ ∙λ ∷ ι ∷ β ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.1.7"
∷ word (ἄ ∷ ν ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.7"
∷ word (μ ∷ ε ∷ θ ∷ []) "2Thess.1.7"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.7"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.7"
∷ word (τ ∷ ῇ ∷ []) "2Thess.1.7"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ ύ ∷ ψ ∷ ε ∷ ι ∷ []) "2Thess.1.7"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.7"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (ἀ ∷ π ∷ []) "2Thess.1.7"
∷ word (ο ∷ ὐ ∷ ρ ∷ α ∷ ν ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (μ ∷ ε ∷ τ ∷ []) "2Thess.1.7"
∷ word (ἀ ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ω ∷ ν ∷ []) "2Thess.1.7"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.7"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.7"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.8"
∷ word (φ ∷ ∙λ ∷ ο ∷ γ ∷ ὶ ∷ []) "2Thess.1.8"
∷ word (π ∷ υ ∷ ρ ∷ ό ∷ ς ∷ []) "2Thess.1.8"
∷ word (δ ∷ ι ∷ δ ∷ ό ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.1.8"
∷ word (ἐ ∷ κ ∷ δ ∷ ί ∷ κ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.8"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.8"
∷ word (μ ∷ ὴ ∷ []) "2Thess.1.8"
∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ σ ∷ ι ∷ []) "2Thess.1.8"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "2Thess.1.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.8"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.8"
∷ word (μ ∷ ὴ ∷ []) "2Thess.1.8"
∷ word (ὑ ∷ π ∷ α ∷ κ ∷ ο ∷ ύ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.8"
∷ word (τ ∷ ῷ ∷ []) "2Thess.1.8"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ῳ ∷ []) "2Thess.1.8"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.8"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.8"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.8"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.8"
∷ word (ο ∷ ἵ ∷ τ ∷ ι ∷ ν ∷ ε ∷ ς ∷ []) "2Thess.1.9"
∷ word (δ ∷ ί ∷ κ ∷ η ∷ ν ∷ []) "2Thess.1.9"
∷ word (τ ∷ ί ∷ σ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.9"
∷ word (ὄ ∷ ∙λ ∷ ε ∷ θ ∷ ρ ∷ ο ∷ ν ∷ []) "2Thess.1.9"
∷ word (α ∷ ἰ ∷ ώ ∷ ν ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.9"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.9"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ώ ∷ π ∷ ο ∷ υ ∷ []) "2Thess.1.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.9"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.9"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.1.9"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.9"
∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "2Thess.1.9"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.9"
∷ word (ἰ ∷ σ ∷ χ ∷ ύ ∷ ο ∷ ς ∷ []) "2Thess.1.9"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.9"
∷ word (ὅ ∷ τ ∷ α ∷ ν ∷ []) "2Thess.1.10"
∷ word (ἔ ∷ ∙λ ∷ θ ∷ ῃ ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ δ ∷ ο ∷ ξ ∷ α ∷ σ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.10"
∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.1.10"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.10"
∷ word (θ ∷ α ∷ υ ∷ μ ∷ α ∷ σ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.10"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.1.10"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.1.10"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ θ ∷ η ∷ []) "2Thess.1.10"
∷ word (τ ∷ ὸ ∷ []) "2Thess.1.10"
∷ word (μ ∷ α ∷ ρ ∷ τ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.1.10"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ φ ∷ []) "2Thess.1.10"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.10"
∷ word (τ ∷ ῇ ∷ []) "2Thess.1.10"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ ᾳ ∷ []) "2Thess.1.10"
∷ word (ἐ ∷ κ ∷ ε ∷ ί ∷ ν ∷ ῃ ∷ []) "2Thess.1.10"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.1.11"
∷ word (ὃ ∷ []) "2Thess.1.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ό ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "2Thess.1.11"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.1.11"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.11"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.1.11"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.1.11"
∷ word (ἀ ∷ ξ ∷ ι ∷ ώ ∷ σ ∷ ῃ ∷ []) "2Thess.1.11"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.1.11"
∷ word (κ ∷ ∙λ ∷ ή ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.11"
∷ word (ὁ ∷ []) "2Thess.1.11"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.1.11"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (π ∷ ∙λ ∷ η ∷ ρ ∷ ώ ∷ σ ∷ ῃ ∷ []) "2Thess.1.11"
∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "2Thess.1.11"
∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.1.11"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ω ∷ σ ∷ ύ ∷ ν ∷ η ∷ ς ∷ []) "2Thess.1.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.11"
∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "2Thess.1.11"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "2Thess.1.11"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.11"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ι ∷ []) "2Thess.1.11"
∷ word (ὅ ∷ π ∷ ω ∷ ς ∷ []) "2Thess.1.12"
∷ word (ἐ ∷ ν ∷ δ ∷ ο ∷ ξ ∷ α ∷ σ ∷ θ ∷ ῇ ∷ []) "2Thess.1.12"
∷ word (τ ∷ ὸ ∷ []) "2Thess.1.12"
∷ word (ὄ ∷ ν ∷ ο ∷ μ ∷ α ∷ []) "2Thess.1.12"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.12"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.12"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.12"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.1.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.12"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.1.12"
∷ word (ἐ ∷ ν ∷ []) "2Thess.1.12"
∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2Thess.1.12"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.1.12"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.1.12"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ν ∷ []) "2Thess.1.12"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.1.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.1.12"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.1.12"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.1.12"
∷ word (Ἐ ∷ ρ ∷ ω ∷ τ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.2.1"
∷ word (δ ∷ ὲ ∷ []) "2Thess.2.1"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.1"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.2.1"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "2Thess.2.1"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.1"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.1"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.1"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.1"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ υ ∷ ν ∷ α ∷ γ ∷ ω ∷ γ ∷ ῆ ∷ ς ∷ []) "2Thess.2.1"
∷ word (ἐ ∷ π ∷ []) "2Thess.2.1"
∷ word (α ∷ ὐ ∷ τ ∷ ό ∷ ν ∷ []) "2Thess.2.1"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.2"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.2"
∷ word (μ ∷ ὴ ∷ []) "2Thess.2.2"
∷ word (τ ∷ α ∷ χ ∷ έ ∷ ω ∷ ς ∷ []) "2Thess.2.2"
∷ word (σ ∷ α ∷ ∙λ ∷ ε ∷ υ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.2"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.2"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.2.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.2"
∷ word (ν ∷ ο ∷ ὸ ∷ ς ∷ []) "2Thess.2.2"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "2Thess.2.2"
∷ word (θ ∷ ρ ∷ ο ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.2"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.2"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ υ ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ τ ∷ ε ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ []) "2Thess.2.2"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.2.2"
∷ word (ὡ ∷ ς ∷ []) "2Thess.2.2"
∷ word (δ ∷ ι ∷ []) "2Thess.2.2"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.2"
∷ word (ὡ ∷ ς ∷ []) "2Thess.2.2"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.2"
∷ word (ἐ ∷ ν ∷ έ ∷ σ ∷ τ ∷ η ∷ κ ∷ ε ∷ ν ∷ []) "2Thess.2.2"
∷ word (ἡ ∷ []) "2Thess.2.2"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ []) "2Thess.2.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.2"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.2"
∷ word (μ ∷ ή ∷ []) "2Thess.2.3"
∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.2.3"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.3"
∷ word (ἐ ∷ ξ ∷ α ∷ π ∷ α ∷ τ ∷ ή ∷ σ ∷ ῃ ∷ []) "2Thess.2.3"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.2.3"
∷ word (μ ∷ η ∷ δ ∷ έ ∷ ν ∷ α ∷ []) "2Thess.2.3"
∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ο ∷ ν ∷ []) "2Thess.2.3"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.3"
∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "2Thess.2.3"
∷ word (μ ∷ ὴ ∷ []) "2Thess.2.3"
∷ word (ἔ ∷ ∙λ ∷ θ ∷ ῃ ∷ []) "2Thess.2.3"
∷ word (ἡ ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ π ∷ ο ∷ σ ∷ τ ∷ α ∷ σ ∷ ί ∷ α ∷ []) "2Thess.2.3"
∷ word (π ∷ ρ ∷ ῶ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.2.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ῇ ∷ []) "2Thess.2.3"
∷ word (ὁ ∷ []) "2Thess.2.3"
∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ς ∷ []) "2Thess.2.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ ν ∷ ο ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.3"
∷ word (ὁ ∷ []) "2Thess.2.3"
∷ word (υ ∷ ἱ ∷ ὸ ∷ ς ∷ []) "2Thess.2.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.3"
∷ word (ἀ ∷ π ∷ ω ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.3"
∷ word (ὁ ∷ []) "2Thess.2.4"
∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ κ ∷ ε ∷ ί ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.2.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.4"
∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ α ∷ ι ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.2.4"
∷ word (ἐ ∷ π ∷ ὶ ∷ []) "2Thess.2.4"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "2Thess.2.4"
∷ word (∙λ ∷ ε ∷ γ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ν ∷ []) "2Thess.2.4"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ἢ ∷ []) "2Thess.2.4"
∷ word (σ ∷ έ ∷ β ∷ α ∷ σ ∷ μ ∷ α ∷ []) "2Thess.2.4"
∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "2Thess.2.4"
∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.4"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ν ∷ α ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.2.4"
∷ word (κ ∷ α ∷ θ ∷ ί ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.4"
∷ word (ἀ ∷ π ∷ ο ∷ δ ∷ ε ∷ ι ∷ κ ∷ ν ∷ ύ ∷ ν ∷ τ ∷ α ∷ []) "2Thess.2.4"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.4"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.4"
∷ word (ἔ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.2.4"
∷ word (θ ∷ ε ∷ ό ∷ ς ∷ []) "2Thess.2.4"
∷ word (ο ∷ ὐ ∷ []) "2Thess.2.5"
∷ word (μ ∷ ν ∷ η ∷ μ ∷ ο ∷ ν ∷ ε ∷ ύ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.2.5"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.5"
∷ word (ἔ ∷ τ ∷ ι ∷ []) "2Thess.2.5"
∷ word (ὢ ∷ ν ∷ []) "2Thess.2.5"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.2.5"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.5"
∷ word (τ ∷ α ∷ ῦ ∷ τ ∷ α ∷ []) "2Thess.2.5"
∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ ο ∷ ν ∷ []) "2Thess.2.5"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.2.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.6"
∷ word (ν ∷ ῦ ∷ ν ∷ []) "2Thess.2.6"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.6"
∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ο ∷ ν ∷ []) "2Thess.2.6"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "2Thess.2.6"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.6"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.6"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.6"
∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "2Thess.2.6"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.6"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.6"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.6"
∷ word (κ ∷ α ∷ ι ∷ ρ ∷ ῷ ∷ []) "2Thess.2.6"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.2.7"
∷ word (μ ∷ υ ∷ σ ∷ τ ∷ ή ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "2Thess.2.7"
∷ word (ἤ ∷ δ ∷ η ∷ []) "2Thess.2.7"
∷ word (ἐ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ε ∷ ῖ ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.7"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.7"
∷ word (ἀ ∷ ν ∷ ο ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.7"
∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "2Thess.2.7"
∷ word (ὁ ∷ []) "2Thess.2.7"
∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ω ∷ ν ∷ []) "2Thess.2.7"
∷ word (ἄ ∷ ρ ∷ τ ∷ ι ∷ []) "2Thess.2.7"
∷ word (ἕ ∷ ω ∷ ς ∷ []) "2Thess.2.7"
∷ word (ἐ ∷ κ ∷ []) "2Thess.2.7"
∷ word (μ ∷ έ ∷ σ ∷ ο ∷ υ ∷ []) "2Thess.2.7"
∷ word (γ ∷ έ ∷ ν ∷ η ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.7"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.8"
∷ word (τ ∷ ό ∷ τ ∷ ε ∷ []) "2Thess.2.8"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ υ ∷ φ ∷ θ ∷ ή ∷ σ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "2Thess.2.8"
∷ word (ὁ ∷ []) "2Thess.2.8"
∷ word (ἄ ∷ ν ∷ ο ∷ μ ∷ ο ∷ ς ∷ []) "2Thess.2.8"
∷ word (ὃ ∷ ν ∷ []) "2Thess.2.8"
∷ word (ὁ ∷ []) "2Thess.2.8"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.2.8"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "2Thess.2.8"
∷ word (ἀ ∷ ν ∷ ε ∷ ∙λ ∷ ε ∷ ῖ ∷ []) "2Thess.2.8"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.8"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "2Thess.2.8"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8"
∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.8"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.8"
∷ word (κ ∷ α ∷ τ ∷ α ∷ ρ ∷ γ ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "2Thess.2.8"
∷ word (τ ∷ ῇ ∷ []) "2Thess.2.8"
∷ word (ἐ ∷ π ∷ ι ∷ φ ∷ α ∷ ν ∷ ε ∷ ί ∷ ᾳ ∷ []) "2Thess.2.8"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.8"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.8"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.8"
∷ word (ο ∷ ὗ ∷ []) "2Thess.2.9"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.2.9"
∷ word (ἡ ∷ []) "2Thess.2.9"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ τ ∷ []) "2Thess.2.9"
∷ word (ἐ ∷ ν ∷ έ ∷ ρ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2Thess.2.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.9"
∷ word (Σ ∷ α ∷ τ ∷ α ∷ ν ∷ ᾶ ∷ []) "2Thess.2.9"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.9"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.2.9"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ι ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.9"
∷ word (σ ∷ η ∷ μ ∷ ε ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.9"
∷ word (τ ∷ έ ∷ ρ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.9"
∷ word (ψ ∷ ε ∷ ύ ∷ δ ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.10"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.10"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ π ∷ ά ∷ τ ∷ ῃ ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ δ ∷ ι ∷ κ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.10"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ∙λ ∷ υ ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ ν ∷ θ ∷ []) "2Thess.2.10"
∷ word (ὧ ∷ ν ∷ []) "2Thess.2.10"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "2Thess.2.10"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.2.10"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.10"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.2.10"
∷ word (ἐ ∷ δ ∷ έ ∷ ξ ∷ α ∷ ν ∷ τ ∷ ο ∷ []) "2Thess.2.10"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.10"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.10"
∷ word (σ ∷ ω ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.2.10"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ύ ∷ ς ∷ []) "2Thess.2.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.11"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.11"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "2Thess.2.11"
∷ word (π ∷ έ ∷ μ ∷ π ∷ ε ∷ ι ∷ []) "2Thess.2.11"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.2.11"
∷ word (ὁ ∷ []) "2Thess.2.11"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.11"
∷ word (ἐ ∷ ν ∷ έ ∷ ρ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2Thess.2.11"
∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ η ∷ ς ∷ []) "2Thess.2.11"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.11"
∷ word (τ ∷ ὸ ∷ []) "2Thess.2.11"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῦ ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.11"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.2.11"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.11"
∷ word (ψ ∷ ε ∷ ύ ∷ δ ∷ ε ∷ ι ∷ []) "2Thess.2.11"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.2.12"
∷ word (κ ∷ ρ ∷ ι ∷ θ ∷ ῶ ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.12"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12"
∷ word (ο ∷ ἱ ∷ []) "2Thess.2.12"
∷ word (μ ∷ ὴ ∷ []) "2Thess.2.12"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12"
∷ word (τ ∷ ῇ ∷ []) "2Thess.2.12"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "2Thess.2.12"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.2.12"
∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ή ∷ σ ∷ α ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.2.12"
∷ word (τ ∷ ῇ ∷ []) "2Thess.2.12"
∷ word (ἀ ∷ δ ∷ ι ∷ κ ∷ ί ∷ ᾳ ∷ []) "2Thess.2.12"
∷ word (Ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.2.13"
∷ word (δ ∷ ὲ ∷ []) "2Thess.2.13"
∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.2.13"
∷ word (ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "2Thess.2.13"
∷ word (τ ∷ ῷ ∷ []) "2Thess.2.13"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "2Thess.2.13"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "2Thess.2.13"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.2.13"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.13"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὶ ∷ []) "2Thess.2.13"
∷ word (ἠ ∷ γ ∷ α ∷ π ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.2.13"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "2Thess.2.13"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.13"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.2.13"
∷ word (ε ∷ ἵ ∷ ∙λ ∷ α ∷ τ ∷ ο ∷ []) "2Thess.2.13"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.13"
∷ word (ὁ ∷ []) "2Thess.2.13"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.13"
∷ word (ἀ ∷ π ∷ α ∷ ρ ∷ χ ∷ ὴ ∷ ν ∷ []) "2Thess.2.13"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.13"
∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.2.13"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.13"
∷ word (ἁ ∷ γ ∷ ι ∷ α ∷ σ ∷ μ ∷ ῷ ∷ []) "2Thess.2.13"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.2.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.13"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "2Thess.2.13"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.13"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.14"
∷ word (ὃ ∷ []) "2Thess.2.14"
∷ word (ἐ ∷ κ ∷ ά ∷ ∙λ ∷ ε ∷ σ ∷ ε ∷ ν ∷ []) "2Thess.2.14"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.14"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.14"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.14"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.14"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.2.14"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ ο ∷ ί ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.14"
∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "2Thess.2.14"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.2.14"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.14"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.2.14"
∷ word (ἄ ∷ ρ ∷ α ∷ []) "2Thess.2.15"
∷ word (ο ∷ ὖ ∷ ν ∷ []) "2Thess.2.15"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.2.15"
∷ word (σ ∷ τ ∷ ή ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.15"
∷ word (κ ∷ ρ ∷ α ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.2.15"
∷ word (π ∷ α ∷ ρ ∷ α ∷ δ ∷ ό ∷ σ ∷ ε ∷ ι ∷ ς ∷ []) "2Thess.2.15"
∷ word (ἃ ∷ ς ∷ []) "2Thess.2.15"
∷ word (ἐ ∷ δ ∷ ι ∷ δ ∷ ά ∷ χ ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.2.15"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ υ ∷ []) "2Thess.2.15"
∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "2Thess.2.15"
∷ word (δ ∷ ι ∷ []) "2Thess.2.15"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.2.15"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.15"
∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.2.16"
∷ word (δ ∷ ὲ ∷ []) "2Thess.2.16"
∷ word (ὁ ∷ []) "2Thess.2.16"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.2.16"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.16"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "2Thess.2.16"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.2.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "2Thess.2.16"
∷ word (ὁ ∷ []) "2Thess.2.16"
∷ word (π ∷ α ∷ τ ∷ ὴ ∷ ρ ∷ []) "2Thess.2.16"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.16"
∷ word (ὁ ∷ []) "2Thess.2.16"
∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ή ∷ σ ∷ α ∷ ς ∷ []) "2Thess.2.16"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.2.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16"
∷ word (δ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.2.16"
∷ word (π ∷ α ∷ ρ ∷ ά ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.2.16"
∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ α ∷ ν ∷ []) "2Thess.2.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.16"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "2Thess.2.16"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὴ ∷ ν ∷ []) "2Thess.2.16"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.16"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ τ ∷ ι ∷ []) "2Thess.2.16"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ έ ∷ σ ∷ α ∷ ι ∷ []) "2Thess.2.17"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.2.17"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.2.17"
∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.2.17"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.17"
∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ α ∷ ι ∷ []) "2Thess.2.17"
∷ word (ἐ ∷ ν ∷ []) "2Thess.2.17"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "2Thess.2.17"
∷ word (ἔ ∷ ρ ∷ γ ∷ ῳ ∷ []) "2Thess.2.17"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.2.17"
∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "2Thess.2.17"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ῷ ∷ []) "2Thess.2.17"
∷ word (Τ ∷ ὸ ∷ []) "2Thess.3.1"
∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ὸ ∷ ν ∷ []) "2Thess.3.1"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ ύ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.1"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.1"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "2Thess.3.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.1"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.1"
∷ word (ὁ ∷ []) "2Thess.3.1"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ς ∷ []) "2Thess.3.1"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.1"
∷ word (τ ∷ ρ ∷ έ ∷ χ ∷ ῃ ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.1"
∷ word (δ ∷ ο ∷ ξ ∷ ά ∷ ζ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.1"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.1"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.2"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.2"
∷ word (ῥ ∷ υ ∷ σ ∷ θ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.2"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἀ ∷ τ ∷ ό ∷ π ∷ ω ∷ ν ∷ []) "2Thess.3.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.2"
∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ῶ ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ω ∷ ν ∷ []) "2Thess.3.2"
∷ word (ο ∷ ὐ ∷ []) "2Thess.3.2"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.2"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.2"
∷ word (ἡ ∷ []) "2Thess.3.2"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "2Thess.3.2"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.3"
∷ word (δ ∷ έ ∷ []) "2Thess.3.3"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.3.3"
∷ word (ὁ ∷ []) "2Thess.3.3"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.3"
∷ word (ὃ ∷ ς ∷ []) "2Thess.3.3"
∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ ε ∷ ι ∷ []) "2Thess.3.3"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.3"
∷ word (φ ∷ υ ∷ ∙λ ∷ ά ∷ ξ ∷ ε ∷ ι ∷ []) "2Thess.3.3"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.3"
∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ο ∷ ῦ ∷ []) "2Thess.3.3"
∷ word (π ∷ ε ∷ π ∷ ο ∷ ί ∷ θ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.4"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.4"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.4"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.3.4"
∷ word (ἐ ∷ φ ∷ []) "2Thess.3.4"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.4"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.4"
∷ word (ἃ ∷ []) "2Thess.3.4"
∷ word (π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.4"
∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.3.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.4"
∷ word (π ∷ ο ∷ ι ∷ ή ∷ σ ∷ ε ∷ τ ∷ ε ∷ []) "2Thess.3.4"
∷ word (ὁ ∷ []) "2Thess.3.5"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.5"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.5"
∷ word (κ ∷ α ∷ τ ∷ ε ∷ υ ∷ θ ∷ ύ ∷ ν ∷ α ∷ ι ∷ []) "2Thess.3.5"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.5"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "2Thess.3.5"
∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.3.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.5"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.5"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "2Thess.3.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.5"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.5"
∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ὴ ∷ ν ∷ []) "2Thess.3.5"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.5"
∷ word (Π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.6"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.6"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.6"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.6"
∷ word (ὀ ∷ ν ∷ ό ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "2Thess.3.6"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.6"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.6"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (σ ∷ τ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.6"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ῦ ∷ []) "2Thess.3.6"
∷ word (ἀ ∷ τ ∷ ά ∷ κ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.6"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "2Thess.3.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.6"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.6"
∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2Thess.3.6"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ρ ∷ ά ∷ δ ∷ ο ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.3.6"
∷ word (ἣ ∷ ν ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ρ ∷ ε ∷ ∙λ ∷ ά ∷ β ∷ ο ∷ σ ∷ α ∷ ν ∷ []) "2Thess.3.6"
∷ word (π ∷ α ∷ ρ ∷ []) "2Thess.3.6"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.6"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "2Thess.3.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.7"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "2Thess.3.7"
∷ word (π ∷ ῶ ∷ ς ∷ []) "2Thess.3.7"
∷ word (δ ∷ ε ∷ ῖ ∷ []) "2Thess.3.7"
∷ word (μ ∷ ι ∷ μ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.7"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.7"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.7"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.3.7"
∷ word (ἠ ∷ τ ∷ α ∷ κ ∷ τ ∷ ή ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.7"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.7"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.7"
∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ []) "2Thess.3.8"
∷ word (δ ∷ ω ∷ ρ ∷ ε ∷ ὰ ∷ ν ∷ []) "2Thess.3.8"
∷ word (ἄ ∷ ρ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ φ ∷ ά ∷ γ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.8"
∷ word (π ∷ α ∷ ρ ∷ ά ∷ []) "2Thess.3.8"
∷ word (τ ∷ ι ∷ ν ∷ ο ∷ ς ∷ []) "2Thess.3.8"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.8"
∷ word (κ ∷ ό ∷ π ∷ ῳ ∷ []) "2Thess.3.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.8"
∷ word (μ ∷ ό ∷ χ ∷ θ ∷ ῳ ∷ []) "2Thess.3.8"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.8"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.3.8"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.8"
∷ word (τ ∷ ὸ ∷ []) "2Thess.3.8"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.8"
∷ word (ἐ ∷ π ∷ ι ∷ β ∷ α ∷ ρ ∷ ῆ ∷ σ ∷ α ∷ ί ∷ []) "2Thess.3.8"
∷ word (τ ∷ ι ∷ ν ∷ α ∷ []) "2Thess.3.8"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.8"
∷ word (ο ∷ ὐ ∷ χ ∷ []) "2Thess.3.9"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.9"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "2Thess.3.9"
∷ word (ἔ ∷ χ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.9"
∷ word (ἐ ∷ ξ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "2Thess.3.9"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "2Thess.3.9"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.9"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "2Thess.3.9"
∷ word (τ ∷ ύ ∷ π ∷ ο ∷ ν ∷ []) "2Thess.3.9"
∷ word (δ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.9"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.9"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "2Thess.3.9"
∷ word (τ ∷ ὸ ∷ []) "2Thess.3.9"
∷ word (μ ∷ ι ∷ μ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.9"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.10"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2Thess.3.10"
∷ word (ὅ ∷ τ ∷ ε ∷ []) "2Thess.3.10"
∷ word (ἦ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.10"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2Thess.3.10"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2Thess.3.10"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "2Thess.3.10"
∷ word (π ∷ α ∷ ρ ∷ η ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.10"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.10"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "2Thess.3.10"
∷ word (ε ∷ ἴ ∷ []) "2Thess.3.10"
∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.3.10"
∷ word (ο ∷ ὐ ∷ []) "2Thess.3.10"
∷ word (θ ∷ έ ∷ ∙λ ∷ ε ∷ ι ∷ []) "2Thess.3.10"
∷ word (ἐ ∷ ρ ∷ γ ∷ ά ∷ ζ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.10"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "2Thess.3.10"
∷ word (ἐ ∷ σ ∷ θ ∷ ι ∷ έ ∷ τ ∷ ω ∷ []) "2Thess.3.10"
∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.11"
∷ word (γ ∷ ά ∷ ρ ∷ []) "2Thess.3.11"
∷ word (τ ∷ ι ∷ ν ∷ α ∷ ς ∷ []) "2Thess.3.11"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "2Thess.3.11"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.11"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.11"
∷ word (ἀ ∷ τ ∷ ά ∷ κ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.11"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "2Thess.3.11"
∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.3.11"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.3.11"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ ε ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "2Thess.3.11"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2Thess.3.12"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.12"
∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "2Thess.3.12"
∷ word (π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.12"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.12"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "2Thess.3.12"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.12"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "2Thess.3.12"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.12"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.12"
∷ word (ἡ ∷ σ ∷ υ ∷ χ ∷ ί ∷ α ∷ ς ∷ []) "2Thess.3.12"
∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "2Thess.3.12"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἄ ∷ ρ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.12"
∷ word (ἐ ∷ σ ∷ θ ∷ ί ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "2Thess.3.12"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "2Thess.3.13"
∷ word (δ ∷ έ ∷ []) "2Thess.3.13"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "2Thess.3.13"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.13"
∷ word (ἐ ∷ γ ∷ κ ∷ α ∷ κ ∷ ή ∷ σ ∷ η ∷ τ ∷ ε ∷ []) "2Thess.3.13"
∷ word (κ ∷ α ∷ ∙λ ∷ ο ∷ π ∷ ο ∷ ι ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2Thess.3.13"
∷ word (Ε ∷ ἰ ∷ []) "2Thess.3.14"
∷ word (δ ∷ έ ∷ []) "2Thess.3.14"
∷ word (τ ∷ ι ∷ ς ∷ []) "2Thess.3.14"
∷ word (ο ∷ ὐ ∷ χ ∷ []) "2Thess.3.14"
∷ word (ὑ ∷ π ∷ α ∷ κ ∷ ο ∷ ύ ∷ ε ∷ ι ∷ []) "2Thess.3.14"
∷ word (τ ∷ ῷ ∷ []) "2Thess.3.14"
∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "2Thess.3.14"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.14"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.3.14"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.3.14"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "2Thess.3.14"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ ν ∷ []) "2Thess.3.14"
∷ word (σ ∷ η ∷ μ ∷ ε ∷ ι ∷ ο ∷ ῦ ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.14"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.14"
∷ word (σ ∷ υ ∷ ν ∷ α ∷ ν ∷ α ∷ μ ∷ ί ∷ γ ∷ ν ∷ υ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2Thess.3.14"
∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2Thess.3.14"
∷ word (ἵ ∷ ν ∷ α ∷ []) "2Thess.3.14"
∷ word (ἐ ∷ ν ∷ τ ∷ ρ ∷ α ∷ π ∷ ῇ ∷ []) "2Thess.3.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "2Thess.3.15"
∷ word (μ ∷ ὴ ∷ []) "2Thess.3.15"
∷ word (ὡ ∷ ς ∷ []) "2Thess.3.15"
∷ word (ἐ ∷ χ ∷ θ ∷ ρ ∷ ὸ ∷ ν ∷ []) "2Thess.3.15"
∷ word (ἡ ∷ γ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ ε ∷ []) "2Thess.3.15"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2Thess.3.15"
∷ word (ν ∷ ο ∷ υ ∷ θ ∷ ε ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "2Thess.3.15"
∷ word (ὡ ∷ ς ∷ []) "2Thess.3.15"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ό ∷ ν ∷ []) "2Thess.3.15"
∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.16"
∷ word (δ ∷ ὲ ∷ []) "2Thess.3.16"
∷ word (ὁ ∷ []) "2Thess.3.16"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.16"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "2Thess.3.16"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ς ∷ []) "2Thess.3.16"
∷ word (δ ∷ ῴ ∷ η ∷ []) "2Thess.3.16"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2Thess.3.16"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "2Thess.3.16"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ν ∷ []) "2Thess.3.16"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "2Thess.3.16"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "2Thess.3.16"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.16"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "2Thess.3.16"
∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ῳ ∷ []) "2Thess.3.16"
∷ word (ὁ ∷ []) "2Thess.3.16"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "2Thess.3.16"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.16"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.16"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.16"
∷ word (Ὁ ∷ []) "2Thess.3.17"
∷ word (ἀ ∷ σ ∷ π ∷ α ∷ σ ∷ μ ∷ ὸ ∷ ς ∷ []) "2Thess.3.17"
∷ word (τ ∷ ῇ ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ μ ∷ ῇ ∷ []) "2Thess.3.17"
∷ word (χ ∷ ε ∷ ι ∷ ρ ∷ ὶ ∷ []) "2Thess.3.17"
∷ word (Π ∷ α ∷ ύ ∷ ∙λ ∷ ο ∷ υ ∷ []) "2Thess.3.17"
∷ word (ὅ ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2Thess.3.17"
∷ word (σ ∷ η ∷ μ ∷ ε ∷ ῖ ∷ ο ∷ ν ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ ν ∷ []) "2Thess.3.17"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "2Thess.3.17"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ῇ ∷ []) "2Thess.3.17"
∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "2Thess.3.17"
∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ω ∷ []) "2Thess.3.17"
∷ word (ἡ ∷ []) "2Thess.3.18"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "2Thess.3.18"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "2Thess.3.18"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.18"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2Thess.3.18"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "2Thess.3.18"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "2Thess.3.18"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2Thess.3.18"
∷ []
| {
"alphanum_fraction": 0.3695183321,
"avg_line_length": 46.8688327316,
"ext": "agda",
"hexsha": "0ee3ca34c200c76c1853cf00370049847677d4db",
"lang": "Agda",
"max_forks_count": 5,
"max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z",
"max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "scott-fleischman/GreekGrammar",
"max_forks_repo_path": "agda/Text/Greek/SBLGNT/2Thess.agda",
"max_issues_count": 13,
"max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "scott-fleischman/GreekGrammar",
"max_issues_repo_path": "agda/Text/Greek/SBLGNT/2Thess.agda",
"max_line_length": 91,
"max_stars_count": 44,
"max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "scott-fleischman/GreekGrammar",
"max_stars_repo_path": "agda/Text/Greek/SBLGNT/2Thess.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z",
"num_tokens": 27646,
"size": 38948
} |
open import Data.Empty
open import Data.Maybe
open import Data.Product
open import Data.Unit
open import Axiom.Extensionality.Propositional
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary
open import Relation.Nullary.Negation
open import EffectAnnotations
open import Types
module AEff where
-- ARITY ASSIGNMENT TO SIGNATURES OF SIGNALS, INTERRUPTS, AND BASE CONSTANTS
postulate payload : Σₛ → Σ VType (λ X → mobile X) -- payload type assignment for signal and interrupt names
postulate Σ-base : Set -- set of base constants
postulate ar-base : Σ-base → BType -- arity assignment to base constants
-- CONTEXTS
data Ctx : Set where
[] : Ctx
_∷_ : Ctx → VType → Ctx
_■ : Ctx → Ctx
infixl 35 _∷_
infixl 35 _■
_++ₖ_ : Ctx → Ctx → Ctx
Γ ++ₖ [] = Γ
Γ ++ₖ (Γ' ∷ X) = (Γ ++ₖ Γ') ∷ X
Γ ++ₖ (Γ' ■) = (Γ ++ₖ Γ') ■
infixl 30 _++ₖ_
-- VARIABLES IN CONTEXTS (I.E., DE BRUIJN INDICES)
data _∈_ (X : VType) : Ctx → Set where
Hd : {Γ : Ctx} → X ∈ (Γ ∷ X)
Tl-v : {Γ : Ctx} {Y : VType} → X ∈ Γ → X ∈ (Γ ∷ Y)
Tl-■ : {Γ : Ctx} → mobile X → X ∈ Γ → X ∈ (Γ ■)
-- DERIVATIONS OF WELL-TYPED TERMS
mutual
data _⊢V⦂_ (Γ : Ctx) : VType → Set where
`_ : {X : VType} →
X ∈ Γ →
-------------
Γ ⊢V⦂ X
´_ : (c : Σ-base) →
--------------
Γ ⊢V⦂ ``(ar-base c)
⋆ : Γ ⊢V⦂ 𝟙
ƛ : {X : VType}
{C : CType} →
Γ ∷ X ⊢C⦂ C →
-------------
Γ ⊢V⦂ X ⇒ C
⟨_⟩ : {X : VType} →
Γ ⊢V⦂ X →
-------------
Γ ⊢V⦂ ⟨ X ⟩
□ : {X : VType} →
Γ ■ ⊢V⦂ X →
-------------
Γ ⊢V⦂ □ X
infix 40 _·_
data _⊢C⦂_ (Γ : Ctx) : CType → Set where
return : {X : VType}
{o : O}
{i : I} →
Γ ⊢V⦂ X →
-----------------
Γ ⊢C⦂ X ! (o , i)
let=_`in_ : {X Y : VType}
{o : O}
{i : I} →
Γ ⊢C⦂ X ! (o , i) →
Γ ∷ X ⊢C⦂ Y ! (o , i) →
-----------------------
Γ ⊢C⦂ Y ! (o , i)
_·_ : {X : VType}
{C : CType} →
Γ ⊢V⦂ X ⇒ C →
Γ ⊢V⦂ X →
-------------
Γ ⊢C⦂ C
↑ : {X : VType}
{o : O}
{i : I} →
(op : Σₛ) →
op ∈ₒ o →
Γ ⊢V⦂ proj₁ (payload op) →
Γ ⊢C⦂ X ! (o , i) →
--------------------------
Γ ⊢C⦂ X ! (o , i)
↓ : {X : VType}
{o : O}
{i : I}
(op : Σₛ) →
Γ ⊢V⦂ proj₁ (payload op) →
Γ ⊢C⦂ X ! (o , i) →
--------------------------
Γ ⊢C⦂ X ! op ↓ₑ (o , i)
promise_∣_↦_`in_ : {X Y : VType}
{o o' : O}
{i i' : I} →
(op : Σₛ) →
(o' , i') ⊑ lkpᵢ op i →
Γ ∷ proj₁ (payload op) ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op ↦ just (o' , i') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o' , i') →
Γ ∷ ⟨ X ⟩ ⊢C⦂ Y ! (o , i) →
---------------------------------------------------------------------------------------------------
Γ ⊢C⦂ Y ! (o , i)
await_until_ : {X : VType}
{C : CType} →
Γ ⊢V⦂ ⟨ X ⟩ →
Γ ∷ X ⊢C⦂ C →
--------------
Γ ⊢C⦂ C
unbox_`in_ : {X : VType}
{C : CType} →
Γ ⊢V⦂ □ X →
Γ ∷ X ⊢C⦂ C →
-------------
Γ ⊢C⦂ C
spawn : {C D : CType} →
Γ ■ ⊢C⦂ C →
Γ ⊢C⦂ D →
---------------------
Γ ⊢C⦂ D
coerce : {X : VType}
{o o' : O}
{i i' : I} →
o ⊑ₒ o' →
i ⊑ᵢ i' →
Γ ⊢C⦂ X ! (o , i) →
-------------------
Γ ⊢C⦂ X ! (o' , i')
-- DERIVATIONS OF WELL-TYPED PROCESSES
infix 10 _⊢P⦂_
data _⊢P⦂_ (Γ : Ctx) : {o : O} → PType o → Set where
run : {X : VType}
{o : O}
{i : I} →
Γ ⊢C⦂ X ! (o , i) →
-------------------
Γ ⊢P⦂ X ‼ o , i
_∥_ : {o o' : O}
{PP : PType o} →
{QQ : PType o'} →
Γ ⊢P⦂ PP →
Γ ⊢P⦂ QQ →
-----------------
Γ ⊢P⦂ (PP ∥ QQ)
↑ : {o : O} →
{PP : PType o}
(op : Σₛ) →
op ∈ₒ o →
Γ ⊢V⦂ (proj₁ (payload op)) →
Γ ⊢P⦂ PP →
----------------------------
Γ ⊢P⦂ PP
↓ : {o : O}
{PP : PType o}
(op : Σₛ) →
Γ ⊢V⦂ (proj₁ (payload op)) →
Γ ⊢P⦂ PP →
----------------------------
Γ ⊢P⦂ op ↓ₚ PP
-- ADMISSIBLE TYPING RULES
■-dup-var : {Γ Γ' : Ctx} {X : VType} →
X ∈ (Γ ■ ++ₖ Γ') →
--------------------------
X ∈ (Γ ■ ■ ++ₖ Γ')
■-dup-var {Γ} {[]} (Tl-■ p x) =
Tl-■ p (Tl-■ p x)
■-dup-var {Γ} {Γ' ∷ Y} Hd =
Hd
■-dup-var {Γ} {Γ' ∷ Y} (Tl-v x) =
Tl-v (■-dup-var x)
■-dup-var {Γ} {Γ' ■} (Tl-■ p x) =
Tl-■ p (■-dup-var x)
mutual
■-dup-v : {Γ Γ' : Ctx} {X : VType} →
(Γ ■ ++ₖ Γ') ⊢V⦂ X →
--------------------------
(Γ ■ ■ ++ₖ Γ') ⊢V⦂ X
■-dup-v (` x) =
` ■-dup-var x
■-dup-v (´ c) =
´ c
■-dup-v ⋆ =
⋆
■-dup-v (ƛ M) =
ƛ (■-dup-c M)
■-dup-v ⟨ V ⟩ =
⟨ ■-dup-v V ⟩
■-dup-v (□ V) =
□ (■-dup-v {Γ' = _ ■} V)
■-dup-c : {Γ Γ' : Ctx} {C : CType} →
(Γ ■ ++ₖ Γ') ⊢C⦂ C →
--------------------------
(Γ ■ ■ ++ₖ Γ') ⊢C⦂ C
■-dup-c (return V) =
return (■-dup-v V)
■-dup-c (let= M `in N) =
let= (■-dup-c M) `in (■-dup-c N)
■-dup-c (V · W) =
(■-dup-v V) · (■-dup-v W)
■-dup-c (↑ op p V M) =
↑ op p (■-dup-v V) (■-dup-c M)
■-dup-c (↓ op V M) =
↓ op (■-dup-v V) (■-dup-c M)
■-dup-c (promise op ∣ x ↦ M `in N) =
promise op ∣ x ↦ (■-dup-c M) `in (■-dup-c N)
■-dup-c (await V until M) =
await (■-dup-v V) until (■-dup-c M)
■-dup-c (unbox V `in M) =
unbox (■-dup-v V) `in (■-dup-c M)
■-dup-c (spawn M N) =
spawn (■-dup-c {Γ' = _ ■} M) (■-dup-c N)
■-dup-c (coerce p q M) =
coerce p q (■-dup-c M)
■-wk : {Γ : Ctx} {X : VType} →
mobile X →
Γ ⊢V⦂ X →
-----------------------
Γ ■ ⊢V⦂ X
■-wk p (` x) =
` Tl-■ p x
■-wk p (´ c) =
´ c
■-wk p ⋆ =
⋆
■-wk p (□ V) =
□ (■-dup-v {_} {[]} V)
■-str-var : {Γ Γ' : Ctx} {X : VType} →
X ∈ Γ ■ ++ₖ Γ' →
--------------------------
X ∈ Γ ++ₖ Γ'
■-str-var {Γ} {[]} (Tl-■ p x) =
x
■-str-var {Γ} {Γ' ∷ Y} Hd =
Hd
■-str-var {Γ} {Γ' ∷ Y} (Tl-v x) =
Tl-v (■-str-var x)
■-str-var {Γ} {Γ' ■} (Tl-■ p x) =
Tl-■ p (■-str-var x)
mutual
■-str-v : {Γ Γ' : Ctx} {X : VType} →
Γ ■ ++ₖ Γ' ⊢V⦂ X →
-----------------------
Γ ++ₖ Γ' ⊢V⦂ X
■-str-v (` x) =
` ■-str-var x
■-str-v (´ c) =
´ c
■-str-v ⋆ =
⋆
■-str-v (ƛ M) =
ƛ (■-str-c M)
■-str-v ⟨ V ⟩ =
⟨ ■-str-v V ⟩
■-str-v {Γ} {Γ'} (□ V) =
□ (■-str-v {Γ' = _ ■} V)
■-str-c : {Γ Γ' : Ctx} {C : CType} →
Γ ■ ++ₖ Γ' ⊢C⦂ C →
-----------------------
Γ ++ₖ Γ' ⊢C⦂ C
■-str-c (return V) =
return (■-str-v V)
■-str-c (let= M `in N) =
let= (■-str-c M) `in (■-str-c N)
■-str-c (V · W) =
(■-str-v V) · (■-str-v W)
■-str-c (↑ op p V M) =
↑ op p (■-str-v V) (■-str-c M)
■-str-c (↓ op V M) =
↓ op (■-str-v V) (■-str-c M)
■-str-c (promise op ∣ r ↦ M `in N) =
promise op ∣ r ↦ (■-str-c M) `in (■-str-c N)
■-str-c (await V until M) =
await (■-str-v V) until (■-str-c M)
■-str-c (unbox V `in M) =
unbox (■-str-v V) `in (■-str-c M)
■-str-c (spawn M N) =
spawn (■-str-c {Γ' = _ ■} M) (■-str-c N)
■-str-c (coerce p q M) =
coerce p q (■-str-c M)
| {
"alphanum_fraction": 0.286977492,
"avg_line_length": 24.8091168091,
"ext": "agda",
"hexsha": "fe94faf124d7ab5b4be3063f08310682e1ca8329",
"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": "b41df71f4456666aab4bd14e13d285c31af80ff6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "danelahman/modal-aeff-agda",
"max_forks_repo_path": "AEff.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b41df71f4456666aab4bd14e13d285c31af80ff6",
"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": "danelahman/modal-aeff-agda",
"max_issues_repo_path": "AEff.agda",
"max_line_length": 122,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "b41df71f4456666aab4bd14e13d285c31af80ff6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "danelahman/higher-order-aeff-agda",
"max_stars_repo_path": "AEff.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T18:50:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-08-17T15:00:34.000Z",
"num_tokens": 3350,
"size": 8708
} |
module BadInductionRecursion3 where
data Bool : Set where
false : Bool
true : Bool
data Two : Bool -> Set where
zero : Two false
suc : Two false -> Two true
mutual
data D : Set where
d : forall u -> D′ true u -> D
D′ : forall b -> Two b -> Set
D′ ._ zero = D
D′ ._ (suc n) = D′ _ n -> Bool
_·_ : D -> D -> D
d (suc zero) f · x = f x
ω : D
ω = d (suc zero) (\x -> x · x)
Ω : D
Ω = ω · ω
| {
"alphanum_fraction": 0.5250596659,
"avg_line_length": 14.9642857143,
"ext": "agda",
"hexsha": "80520ea886ac69eb9769268a3887c649d88e7b22",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Fail/BadInductionRecursion3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Fail/BadInductionRecursion3.agda",
"max_line_length": 35,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/BadInductionRecursion3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 168,
"size": 419
} |
-- MIT License
-- Copyright (c) 2021 Luca Ciccone and Luca Padovani
-- Permission is hereby granted, free of charge, to any person
-- obtaining a copy of this software and associated documentation
-- files (the "Software"), to deal in the Software without
-- restriction, including without limitation the rights to use,
-- copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following
-- conditions:
-- The above copyright notice and this permission notice shall be
-- included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-- OTHER DEALINGS IN THE SOFTWARE.
{-# OPTIONS --guardedness --sized-types #-}
open import Size
open import Data.Empty
open import Data.Product
open import Data.Sum
open import Data.List using ([]; _∷_; _∷ʳ_; _++_)
open import Codata.Thunk
open import Relation.Nullary
open import Relation.Nullary.Negation using (contraposition)
open import Relation.Unary using (_∈_; _⊆_)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (Star; ε; _◅_; return)
open import Function.Base using (case_of_)
open import Common
module FairSubtyping {ℙ : Set} (message : Message ℙ) where
open import Trace message
open import SessionType message
open import Transitions message
open import Session message
open import Compliance message
open import HasTrace message
open import TraceInclusion message
open import Convergence message
open import FairCompliance message
data FairSub : SessionType -> SessionType -> Size -> Set where
nil<|any : ∀{T i} -> FairSub nil T i
end<|def : ∀{T S i} (e : End T) (def : Defined S) -> FairSub T S i
inp<|inp :
∀{f g i}
(con : inp f ↓ inp g)
(inc : dom f ⊆ dom g)
(F : (x : ℙ) -> Thunk (FairSub (f x .force) (g x .force)) i) ->
FairSub (inp f) (inp g) i
out<|out :
∀{f g i}
(con : out f ↓ out g)
(W : Witness g)
(inc : dom g ⊆ dom f)
(F : ∀{x} (!x : x ∈ dom g) -> Thunk (FairSub (f x .force) (g x .force)) i) ->
FairSub (out f) (out g) i
_<|_ : SessionType -> SessionType -> Set
_<|_ T S = FairSub T S ∞
-- sub-defined : ∀{T S} -> T <| S -> Defined T -> Defined S
-- sub-defined (end<|def _ def) _ = def
-- sub-defined (inp<|inp _ _) _ = inp
-- sub-defined (out<|out _ _ _) _ = out
fs->convergence : ∀{T S} -> T <| S -> T ↓ S
fs->convergence nil<|any = inclusion->convergence nil<=any
fs->convergence (end<|def e def) = inclusion->convergence (end<=def e def)
fs->convergence (inp<|inp con inc F) = con
fs->convergence (out<|out con W inc F) = con
fc-not-transition+end :
∀{R R' T α} ->
FairComplianceS (R # T) ->
Transition R α R' ->
End T ->
⊥
fc-not-transition+end comp inp (inp U) with comp ε
... | _ , ε , win#def () _
... | _ , sync () inp ◅ _ , _
fc-not-transition+end comp inp (out U) with comp ε
... | _ , ε , win#def () _
... | _ , sync _ (out fx) ◅ _ , _ = ⊥-elim (U _ fx)
fc-not-transition+end comp (out fx) (inp V) with comp ε
... | _ , ε , win#def (out U) _ = ⊥-elim (U _ fx)
... | _ , sync (out _) inp ◅ reds , win#def w def =
let _ , rr , tr = unzip-red* reds in
⊥-elim (V _ (transitions+defined->defined tr def))
fc-not-transition+end comp (out fx) (out _) with comp ε
... | _ , ε , win#def (out U) _ = ⊥-elim (U _ fx)
... | _ , sync () (out _) ◅ _ , _
sub-red :
∀{T S S' R R' α} ->
FairComplianceS (R # T) ->
T <| S ->
Transition R (co-action α) R' ->
Transition S α S' ->
∃[ T' ] (Transition T α T' × T' <| S')
sub-red comp nil<|any _ _ with comp ε
... | _ , ε , win#def _ ()
... | _ , sync _ () ◅ _ , _
sub-red comp (end<|def e _) r _ = ⊥-elim (fc-not-transition+end comp r e)
sub-red comp (inp<|inp con inc F) (out {h} hx) (inp {f}) = _ , inp , F _ .force
sub-red comp (out<|out con W inc F) inp (out fx) = _ , out (inc fx) , F fx .force
sub-red* :
∀{T S S' R R' φ} ->
FairComplianceS (R # T) ->
T <| S ->
Transitions R (co-trace φ) R' ->
Transitions S φ S' ->
∃[ T' ] (Transitions T φ T' × T' <| S')
sub-red* comp sub refl refl = _ , refl , sub
sub-red* comp sub (step r rr) (step s sr) =
let _ , t , sub' = sub-red comp sub r s in
let comp' = fc-transitions (step r refl) (step t refl) comp in
let _ , tr , sub'' = sub-red* comp' sub' rr sr in
_ , step t tr , sub''
sub-sound : ∀{T S R} -> FairComplianceS (R # T) -> T <| S -> FairComplianceS (R # S)
sub-sound comp sub {_ # _} reds =
let _ , rr , sr = unzip-red* reds in
let _ , tr , sub' = sub-red* comp sub rr sr in
let comp' = fair-compliance-red* comp (zip-red* rr tr) in
con-sound (fs->convergence sub') comp'
| {
"alphanum_fraction": 0.6400622932,
"avg_line_length": 35.1849315068,
"ext": "agda",
"hexsha": "39f267993556ab7f39f70882b16b61889cf6c3b8",
"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": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "boystrange/FairSubtypingAgda",
"max_forks_repo_path": "src/FairSubtyping.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"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": "boystrange/FairSubtypingAgda",
"max_issues_repo_path": "src/FairSubtyping.agda",
"max_line_length": 94,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "boystrange/FairSubtypingAgda",
"max_stars_repo_path": "src/FairSubtyping.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z",
"num_tokens": 1644,
"size": 5137
} |
-- Algorithmic equality.
{-# OPTIONS --safe #-}
module Definition.Conversion where
open import Definition.Untyped
open import Definition.Typed
open import Tools.Nat
import Tools.PropositionalEquality as PE
infix 10 _⊢_~_↑_^_
infix 10 _⊢_[conv↑]_^_
infix 10 _⊢_[conv↓]_^_
infix 10 _⊢_[conv↑]_∷_^_
infix 10 _⊢_[conv↓]_∷_^_
infix 10 _⊢_[genconv↑]_∷_^_
mutual
-- Neutral equality.
data _⊢_~_↑!_^_ (Γ : Con Term) : (k l A : Term) → TypeLevel → Set where
var-refl : ∀ {x y A l}
→ Γ ⊢ var x ∷ A ^ [ ! , l ]
→ x PE.≡ y
→ Γ ⊢ var x ~ var y ↑! A ^ l
app-cong : ∀ {k l t v F rF lF lG G lΠ}
→ Γ ⊢ k ~ l ↓! Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ ι lΠ
→ Γ ⊢ t [genconv↑] v ∷ F ^ [ rF , ι lF ]
→ Γ ⊢ k ∘ t ^ lΠ ~ l ∘ v ^ lΠ ↑! G [ t ] ^ ι lG
natrec-cong : ∀ {k l h g a₀ b₀ F G lF}
→ Γ ∙ ℕ ^ [ ! , ι ⁰ ] ⊢ F [conv↑] G ^ [ ! , ι lF ]
→ Γ ⊢ a₀ [conv↑] b₀ ∷ F [ zero ] ^ ι lF
→ Γ ⊢ h [conv↑] g ∷ Π ℕ ^ ! ° ⁰ ▹ (F ^ ! ° lF ▹▹ F [ suc (var 0) ]↑ ° lF ° lF) ° lF ° lF ^ ι lF
→ Γ ⊢ k ~ l ↓! ℕ ^ ι ⁰
→ Γ ⊢ natrec lF F a₀ h k ~ natrec lF G b₀ g l ↑! F [ k ] ^ ι lF
Emptyrec-cong : ∀ {k l F G ll lEmpty}
→ Γ ⊢ F [conv↑] G ^ [ ! , ι ll ]
→ Γ ⊢ k ~ l ↑% Empty lEmpty ^ ι lEmpty
→ Γ ⊢ Emptyrec ll lEmpty F k ~ Emptyrec ll lEmpty G l ↑! F ^ ι ll
Id-cong : ∀ {l A A' t t' u u'}
→ Γ ⊢ A ~ A' ↓! U l ^ next l
→ Γ ⊢ t [conv↑] t' ∷ A ^ ι l
→ Γ ⊢ u [conv↑] u' ∷ A ^ ι l
→ Γ ⊢ Id A t u ~ Id A' t' u' ↑! SProp l ^ next l
Id-ℕ : ∀ {t t' u u'}
→ Γ ⊢ t ~ t' ↓! ℕ ^ ι ⁰
→ Γ ⊢ u [conv↑] u' ∷ ℕ ^ ι ⁰
→ Γ ⊢ Id ℕ t u ~ Id ℕ t' u' ↑! SProp ⁰ ^ next ⁰
Id-ℕ0 : ∀ {t t'}
→ Γ ⊢ t ~ t' ↓! ℕ ^ ι ⁰
→ Γ ⊢ Id ℕ zero t ~ Id ℕ zero t' ↑! SProp ⁰ ^ next ⁰
Id-ℕS : ∀ {t t' u u'}
→ Γ ⊢ t [conv↑] t' ∷ ℕ ^ ι ⁰
→ Γ ⊢ u ~ u' ↓! ℕ ^ ι ⁰
→ Γ ⊢ Id ℕ (suc t) u ~ Id ℕ (suc t') u' ↑! SProp ⁰ ^ next ⁰
Id-U : ∀ {t t' u u'}
→ Γ ⊢ t ~ t' ↓! U ⁰ ^ ι ¹
→ Γ ⊢ u [conv↑] u' ∷ U ⁰ ^ ι ¹
→ Γ ⊢ Id (U ⁰) t u ~ Id (U ⁰) t' u' ↑! SProp ¹ ^ next ¹
Id-Uℕ : ∀ {t t'}
→ Γ ⊢ t ~ t' ↓! U ⁰ ^ ι ¹
→ Γ ⊢ Id (U ⁰) ℕ t ~ Id (U ⁰) ℕ t' ↑! SProp ¹ ^ next ¹
Id-UΠ : ∀ {A rA B A' B' t t'}
→ Γ ⊢ Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹
→ Γ ⊢ t ~ t' ↓! U ⁰ ^ ι ¹
→ Γ ⊢ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰ ) t ~ Id (U ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰ ) t' ↑! SProp ¹ ^ next ¹
cast-cong : ∀ {A A' B B' t t' e e'}
→ Γ ⊢ A ~ A' ↓! U ⁰ ^ next ⁰
→ Γ ⊢ B [conv↑] B' ∷ U ⁰ ^ ι ¹
→ Γ ⊢ t [conv↑] t' ∷ A ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) A B) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) A' B') ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ A B e t ~ cast ⁰ A' B' e' t' ↑! B ^ ι ⁰
cast-ℕ : ∀ {A A' t t' e e'}
→ Γ ⊢ A ~ A' ↓! U ⁰ ^ next ⁰
→ Γ ⊢ t [conv↑] t' ∷ ℕ ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) ℕ A) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) ℕ A') ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ ℕ A e t ~ cast ⁰ ℕ A' e' t' ↑! A ^ ι ⁰
cast-ℕℕ : ∀ {t t' e e'}
→ Γ ⊢ t ~ t' ↓! ℕ ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) ℕ ℕ) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) ℕ ℕ) ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ ℕ ℕ e t ~ cast ⁰ ℕ ℕ e' t' ↑! ℕ ^ ι ⁰
cast-Π : ∀ {A rA P A' P' B B' t t' e e'}
→ Γ ⊢ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ next ⁰
→ Γ ⊢ B ~ B' ↓! U ⁰ ^ next ⁰
→ Γ ⊢ t [conv↑] t' ∷ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) B) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) B') ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) B e t ~ cast ⁰ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) B' e' t' ↑! B ^ ι ⁰
cast-Πℕ : ∀ {A rA P A' P' t t' e e'}
→ Γ ⊢ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹
→ Γ ⊢ t [conv↑] t' ∷ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) ℕ) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) ℕ) ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) ℕ e t ~ cast ⁰ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) ℕ e' t' ↑! ℕ ^ ι ⁰
cast-ℕΠ : ∀ {A rA P A' P' t t' e e'}
→ Γ ⊢ Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹
→ Γ ⊢ t [conv↑] t' ∷ ℕ ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) ℕ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) ℕ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ ℕ (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) e t ~ cast ⁰ ℕ (Π A' ^ rA ° ⁰ ▹ P' ° ⁰ ° ⁰ ) e' t' ↑! (Π A ^ rA ° ⁰ ▹ P ° ⁰ ° ⁰ ) ^ ι ⁰
cast-ΠΠ%! : ∀ {A P A' P' B Q B' Q' t t' e e'}
→ Γ ⊢ Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ % ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹
→ Γ ⊢ Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ [conv↑] Π B' ^ ! ° ⁰ ▹ Q' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹
→ Γ ⊢ t [conv↑] t' ∷ Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ % ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ ! ° ⁰ ▹ Q' ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ (Π A ^ % ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ ) e t ~
cast ⁰ (Π A' ^ % ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ ! ° ⁰ ▹ Q' ° ⁰ ° ⁰ ) e' t' ↑! (Π B ^ ! ° ⁰ ▹ Q ° ⁰ ° ⁰ ) ^ ι ⁰
cast-ΠΠ!% : ∀ {A P A' P' B Q B' Q' t t' e e'}
→ Γ ⊢ Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ [conv↑] Π A' ^ ! ° ⁰ ▹ P' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹
→ Γ ⊢ Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ [conv↑] Π B' ^ % ° ⁰ ▹ Q' ° ⁰ ° ⁰ ∷ U ⁰ ^ ι ¹
→ Γ ⊢ t [conv↑] t' ∷ Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ ^ ι ⁰
→ Γ ⊢ e ∷ (Id (U ⁰) (Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ]
→ Γ ⊢ e' ∷ (Id (U ⁰) (Π A' ^ ! ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ % ° ⁰ ▹ Q' ° ⁰ ° ⁰ )) ^ [ % , next ⁰ ]
→ Γ ⊢ cast ⁰ (Π A ^ ! ° ⁰ ▹ P ° ⁰ ° ⁰ ) (Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ ) e t ~
cast ⁰ (Π A' ^ ! ° ⁰ ▹ P' ° ⁰ ° ⁰ ) (Π B' ^ % ° ⁰ ▹ Q' ° ⁰ ° ⁰ ) e' t' ↑! (Π B ^ % ° ⁰ ▹ Q ° ⁰ ° ⁰ ) ^ ι ⁰
record _⊢_~_↑%_^_ (Γ : Con Term) (k l A : Term) (ll : TypeLevel) : Set where
inductive
constructor %~↑
field
⊢k : Γ ⊢ k ∷ A ^ [ % , ll ]
⊢l : Γ ⊢ l ∷ A ^ [ % , ll ]
data _⊢_~_↑_^_ (Γ : Con Term) : (k l A : Term) → TypeInfo → Set where
~↑! : ∀ {k l A ll} → Γ ⊢ k ~ l ↑! A ^ ll → Γ ⊢ k ~ l ↑ A ^ [ ! , ll ]
~↑% : ∀ {k l A ll} → Γ ⊢ k ~ l ↑% A ^ ll → Γ ⊢ k ~ l ↑ A ^ [ % , ll ]
-- Neutral equality with types in WHNF.
record _⊢_~_↓!_^_ (Γ : Con Term) (k l B : Term) (ll : TypeLevel) : Set where
inductive
constructor [~]
field
A : Term
D : Γ ⊢ A ⇒* B ^ [ ! , ll ]
whnfB : Whnf B
k~l : Γ ⊢ k ~ l ↑! A ^ ll
-- Type equality.
record _⊢_[conv↑]_^_ (Γ : Con Term) (A B : Term) (rA : TypeInfo) : Set where
inductive
constructor [↑]
field
A′ B′ : Term
D : Γ ⊢ A ⇒* A′ ^ rA
D′ : Γ ⊢ B ⇒* B′ ^ rA
whnfA′ : Whnf A′
whnfB′ : Whnf B′
A′<>B′ : Γ ⊢ A′ [conv↓] B′ ^ rA
-- Type equality with types in WHNF.
data _⊢_[conv↓]_^_ (Γ : Con Term) : (A B : Term) → TypeInfo → Set where
U-refl : ∀ {r r' }
→ r PE.≡ r' -- needed for K issues
→ ⊢ Γ → Γ ⊢ Univ r ¹ [conv↓] Univ r' ¹ ^ [ ! , next ¹ ]
univ : ∀ {A B r l}
→ Γ ⊢ A [conv↓] B ∷ Univ r l ^ next l
→ Γ ⊢ A [conv↓] B ^ [ r , ι l ]
-- Term equality.
record _⊢_[conv↑]_∷_^_ (Γ : Con Term) (t u A : Term) (l : TypeLevel) : Set where
inductive
constructor [↑]ₜ
field
B t′ u′ : Term
D : Γ ⊢ A ⇒* B ^ [ ! , l ]
d : Γ ⊢ t ⇒* t′ ∷ B ^ l
d′ : Γ ⊢ u ⇒* u′ ∷ B ^ l
whnfB : Whnf B
whnft′ : Whnf t′
whnfu′ : Whnf u′
t<>u : Γ ⊢ t′ [conv↓] u′ ∷ B ^ l
-- Term equality with types and terms in WHNF.
data _⊢_[conv↓]_∷_^_ (Γ : Con Term) : (t u A : Term) (l : TypeLevel) → Set where
U-refl : ∀ {r r' }
→ r PE.≡ r' -- needed for K issues
→ ⊢ Γ → Γ ⊢ Univ r ⁰ [conv↓] Univ r' ⁰ ∷ U ¹ ^ next ¹
ne : ∀ {r K L lU l}
→ Γ ⊢ K ~ L ↓! Univ r lU ^ l
→ Γ ⊢ K [conv↓] L ∷ Univ r lU ^ l
ℕ-refl : ⊢ Γ → Γ ⊢ ℕ [conv↓] ℕ ∷ U ⁰ ^ next ⁰
Empty-refl : ∀ {l ll} → ll PE.≡ next l → ⊢ Γ → Γ ⊢ Empty l [conv↓] Empty l ∷ SProp l ^ ll
Π-cong : ∀ {F G H E rF rH rΠ lF lH lG lE lΠ ll}
→ ll PE.≡ next lΠ
→ rF PE.≡ rH -- needed for K issues
→ lF PE.≡ lH -- needed for K issues
→ lG PE.≡ lE -- needed for K issues
→ lF ≤ lΠ
→ lG ≤ lΠ
→ Γ ⊢ F ^ [ rF , ι lF ]
→ Γ ⊢ F [conv↑] H ∷ Univ rF lF ^ next lF
→ Γ ∙ F ^ [ rF , ι lF ] ⊢ G [conv↑] E ∷ Univ rΠ lG ^ next lG
→ Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° lΠ [conv↓] Π H ^ rH ° lH ▹ E ° lE ° lΠ ∷ Univ rΠ lΠ ^ ll
∃-cong : ∀ {F G H E l ll}
→ ll PE.≡ next l
→ Γ ⊢ F ^ [ % , ι l ]
→ Γ ⊢ F [conv↑] H ∷ SProp l ^ next l
→ Γ ∙ F ^ [ % , ι l ] ⊢ G [conv↑] E ∷ SProp l ^ next l
→ Γ ⊢ ∃ F ▹ G [conv↓] ∃ H ▹ E ∷ SProp l ^ ll
ℕ-ins : ∀ {k l}
→ Γ ⊢ k ~ l ↓! ℕ ^ ι ⁰
→ Γ ⊢ k [conv↓] l ∷ ℕ ^ ι ⁰
ne-ins : ∀ {k l M N ll}
→ Γ ⊢ k ∷ N ^ [ ! , ι ll ]
→ Γ ⊢ l ∷ N ^ [ ! , ι ll ]
→ Neutral N
→ Γ ⊢ k ~ l ↓! M ^ ι ll
→ Γ ⊢ k [conv↓] l ∷ N ^ ι ll
zero-refl : ⊢ Γ → Γ ⊢ zero [conv↓] zero ∷ ℕ ^ ι ⁰
suc-cong : ∀ {m n}
→ Γ ⊢ m [conv↑] n ∷ ℕ ^ ι ⁰
→ Γ ⊢ suc m [conv↓] suc n ∷ ℕ ^ ι ⁰
η-eq : ∀ {f g F G rF lF lG l}
→ lF ≤ l
→ lG ≤ l
→ Γ ⊢ F ^ [ rF , ι lF ]
→ Γ ⊢ f ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ]
→ Γ ⊢ g ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ [ ! , ι l ]
→ Function f
→ Function g
→ Γ ∙ F ^ [ rF , ι lF ] ⊢ wk1 f ∘ var 0 ^ l [conv↑] wk1 g ∘ var 0 ^ l ∷ G ^ ι lG
→ Γ ⊢ f [conv↓] g ∷ Π F ^ rF ° lF ▹ G ° lG ° l ^ ι l
_⊢_[genconv↑]_∷_^_ : (Γ : Con Term) (t u A : Term) (r : TypeInfo) → Set
_⊢_[genconv↑]_∷_^_ Γ k l A [ ! , ll ] = Γ ⊢ k [conv↑] l ∷ A ^ ll
_⊢_[genconv↑]_∷_^_ Γ k l A [ % , ll ] = Γ ⊢ k ~ l ↑% A ^ ll
var-refl′ : ∀ {Γ x A rA ll}
→ Γ ⊢ var x ∷ A ^ [ rA , ll ]
→ Γ ⊢ var x ~ var x ↑ A ^ [ rA , ll ]
var-refl′ {rA = !} ⊢x = ~↑! (var-refl ⊢x PE.refl)
var-refl′ {rA = %} ⊢x = ~↑% (%~↑ ⊢x ⊢x)
| {
"alphanum_fraction": 0.3270518889,
"avg_line_length": 46.4605809129,
"ext": "agda",
"hexsha": "21e9a449e68be768a1335d9b446fd28988cf3607",
"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/Conversion.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/Conversion.agda",
"max_line_length": 144,
"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/Conversion.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": 5764,
"size": 11197
} |
{-# OPTIONS --cubical --safe #-}
module Data.Array.Skew where
open import Prelude
open import Data.Binary.Skew
open import Data.List
open import Data.Nat using (_+_)
private
variable
p : Level
P : ℕ → Type p
n : ℕ
ns : 𝔹
infixl 6 _∔_
_∔_ : ℕ → ℕ → ℕ
zero ∔ m = m
suc n ∔ m = n ∔ suc m
infixl 4 _⊕_
_⊕_ : (ℕ → Type p) → ℕ → ℕ → Type p
_⊕_ P n m = P (n ∔ m)
data Spine⁺ {p} (P : ℕ → Type p) : 𝔹 → Type p where
nil : Spine⁺ P []
conss : ∀ n → P n → Spine⁺ (P ⊕ suc n) ns → Spine⁺ P (n ∷ ns)
data Spine {p} (P : ℕ → Type p) : 𝔹 → Type p where
nil : Spine P []
conss : ∀ n → P n → Spine⁺ (P ⊕ n) ns → Spine P (n ∷ ns)
-- cons : (∀ {m} → P m → P m → P (suc m)) → P zero → Spine P ns → Spine P (inc ns)
-- cons _*_ x nil = conss zero x nil
-- cons _*_ x (conss n x₁ nil) = conss zero x (conss n x₁ nil)
-- cons _*_ x (conss n x₁ (conss zero x₂ xs)) = conss (suc n) (x₁ * x₁) xs
-- cons _*_ x (conss n x₁ (conss (suc m) x₂ xs)) = conss zero x (conss n x₁ (conss m x₂ {!!}))
| {
"alphanum_fraction": 0.5454545455,
"avg_line_length": 25.6666666667,
"ext": "agda",
"hexsha": "1bc753a262148715f188b88c27ae4fceb16508d5",
"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/Array/Skew.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/Array/Skew.agda",
"max_line_length": 94,
"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/Array/Skew.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": 444,
"size": 1001
} |
-- Issue #2814 reported by tomjack on 2017-10-18
{-# OPTIONS --cubical --rewriting --confluence-check #-}
-- prelude stolen from Saizan/cubical-demo
open import Agda.Primitive.Cubical public
open import Agda.Builtin.Cubical.Path
Path = _≡_
refl : ∀ {ℓ} {A : Set ℓ} {x : A} → x ≡ x
refl {x = x} = λ _ → x
postulate
Rewrite : ∀ {ℓ} {A : Set ℓ} → A → A → Set
{-# BUILTIN REWRITE Rewrite #-}
module Good where
postulate
Unit : Set
unit : Unit
module UnitElim (P : Unit → Set) (unit* : P unit) where
postulate
Unit-elim : (x : Unit) → P x
unit-β : Rewrite (Unit-elim unit) unit*
open UnitElim public
{-# REWRITE unit-β #-}
test₁ : {C : Set} {c₀ : C} → Path {A = C} (Unit-elim (λ _ → C) c₀ unit) c₀
test₁ = refl
test₂ : {C : Set} {c₀ : C} → Path {A = Path c₀ c₀} (λ j → Unit-elim (λ _ → C) c₀ unit) refl
test₂ = refl
-- same code, but with a dummy module parameter
module Bad (Dummy : Set) where
postulate
Unit : Set
unit : Unit
module UnitElim (P : Unit → Set) (unit* : P unit) where
postulate
Unit-elim : (x : Unit) → P x
unit-β : Rewrite (Unit-elim unit) unit*
open UnitElim public
{-# REWRITE unit-β #-}
test₁ : {C : Set} {c₀ : C} → Path {A = C} (Unit-elim (λ _ → C) c₀ unit) c₀
test₁ = refl
test₂ : {C : Set} {c₀ : C} → Path {A = Path c₀ c₀} (λ j → Unit-elim (λ _ → C) c₀ unit) refl
test₂ = refl
-- WAS:
-- Unit-elim (λ _ → .C) .c₀ unit != .c₀ of type .C
-- when checking that the expression refl has type
-- Path (λ j → Unit-elim (λ _ → .C) .c₀ unit) refl
-- SHOULD: succeed
| {
"alphanum_fraction": 0.5865567533,
"avg_line_length": 23.8939393939,
"ext": "agda",
"hexsha": "dea126c7452b50019645d87756c500e2c6f5af32",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Succeed/Issue2814.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Succeed/Issue2814.agda",
"max_line_length": 93,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Succeed/Issue2814.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": 588,
"size": 1577
} |
{-# OPTIONS --copatterns --sized-types #-}
{- M types done properly coinductive -}
module NewM where
open import Size
open import Coinduction
open import Data.Product
open import Function
open import Data.M as M
record M' {i : Size} (A : Set) (B : A → Set) : Set where
coinductive
field
d : ∀ {j : Size< i} → Σ A (λ x → (B x → M' {j} A B))
open M'
f : ∀{i} → {A : Set} {B : A → Set} → M A B → M' {i} A B
proj₁ (d (f x)) = head x
proj₂ (d (f x)) = f ∘ tail x
g : {A : Set} {B : A → Set} → M' A B → M A B
g x = inf (proj₁ (d x)) (λ b → ♯ g (proj₂ (d x) b))
| {
"alphanum_fraction": 0.5528169014,
"avg_line_length": 23.6666666667,
"ext": "agda",
"hexsha": "2a3b8e6046135c8eba88bde10724929908b5d0c9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "TypeTheory/Container/NewM.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "TypeTheory/Container/NewM.agda",
"max_line_length": 56,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "TypeTheory/Container/NewM.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 228,
"size": 568
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Consequences.Substitution where
open import Definition.Untyped
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.EqRelInstance
open import Definition.Typed.Weakening
open import Definition.Typed.Consequences.Syntactic
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Irrelevance
open import Definition.LogicalRelation.Fundamental
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Well-formed substitution of types.
substitution : ∀ {A Γ Δ σ} → Γ ⊢ A → Δ ⊢ˢ σ ∷ Γ → ⊢ Δ → Δ ⊢ subst σ A
substitution A σ ⊢Δ with fundamental A | fundamentalSubst (wf A) ⊢Δ σ
substitution A σ ⊢Δ | [Γ] , [A] | [Γ]′ , [σ] =
escape (proj₁ ([A] ⊢Δ (irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ])))
-- Well-formed substitution of type equality.
substitutionEq : ∀ {A B Γ Δ σ σ′}
→ Γ ⊢ A ≡ B → Δ ⊢ˢ σ ≡ σ′ ∷ Γ → ⊢ Δ → Δ ⊢ subst σ A ≡ subst σ′ B
substitutionEq A≡B σ ⊢Δ with fundamentalEq A≡B | fundamentalSubstEq (wfEq A≡B) ⊢Δ σ
substitutionEq A≡B σ ⊢Δ | [Γ] , [A] , [B] , [A≡B] | [Γ]′ , [σ] , [σ′] , [σ≡σ′] =
let [σ]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ]
[σ′]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ′]
[σ≡σ′]′ = irrelevanceSubstEq [Γ]′ [Γ] ⊢Δ ⊢Δ [σ] [σ]′ [σ≡σ′]
in escapeEq (proj₁ ([A] ⊢Δ [σ]′))
(transEq (proj₁ ([A] ⊢Δ [σ]′)) (proj₁ ([B] ⊢Δ [σ]′))
(proj₁ ([B] ⊢Δ [σ′]′)) ([A≡B] ⊢Δ [σ]′)
(proj₂ ([B] ⊢Δ [σ]′) [σ′]′ [σ≡σ′]′))
-- Well-formed substitution of terms.
substitutionTerm : ∀ {t A Γ Δ σ}
→ Γ ⊢ t ∷ A → Δ ⊢ˢ σ ∷ Γ → ⊢ Δ → Δ ⊢ subst σ t ∷ subst σ A
substitutionTerm t σ ⊢Δ with fundamentalTerm t | fundamentalSubst (wfTerm t) ⊢Δ σ
substitutionTerm t σ ⊢Δ | [Γ] , [A] , [t] | [Γ]′ , [σ] =
let [σ]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ]
in escapeTerm (proj₁ ([A] ⊢Δ [σ]′)) (proj₁ ([t] ⊢Δ [σ]′))
-- Well-formed substitution of term equality.
substitutionEqTerm : ∀ {t u A Γ Δ σ σ′}
→ Γ ⊢ t ≡ u ∷ A → Δ ⊢ˢ σ ≡ σ′ ∷ Γ → ⊢ Δ
→ Δ ⊢ subst σ t ≡ subst σ′ u ∷ subst σ A
substitutionEqTerm t≡u σ≡σ′ ⊢Δ with fundamentalTermEq t≡u
| fundamentalSubstEq (wfEqTerm t≡u) ⊢Δ σ≡σ′
... | [Γ] , modelsTermEq [A] [t] [u] [t≡u] | [Γ]′ , [σ] , [σ′] , [σ≡σ′] =
let [σ]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ]
[σ′]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ′]
[σ≡σ′]′ = irrelevanceSubstEq [Γ]′ [Γ] ⊢Δ ⊢Δ [σ] [σ]′ [σ≡σ′]
in escapeTermEq (proj₁ ([A] ⊢Δ [σ]′))
(transEqTerm (proj₁ ([A] ⊢Δ [σ]′)) ([t≡u] ⊢Δ [σ]′)
(proj₂ ([u] ⊢Δ [σ]′) [σ′]′ [σ≡σ′]′))
-- Reflexivity of well-formed substitution.
substRefl : ∀ {σ Γ Δ}
→ Δ ⊢ˢ σ ∷ Γ
→ Δ ⊢ˢ σ ≡ σ ∷ Γ
substRefl id = id
substRefl (σ , x) = substRefl σ , refl x
-- Weakening of well-formed substitution.
wkSubst′ : ∀ {ρ σ Γ Δ Δ′} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ) (⊢Δ′ : ⊢ Δ′)
([ρ] : ρ ∷ Δ′ ⊆ Δ)
([σ] : Δ ⊢ˢ σ ∷ Γ)
→ Δ′ ⊢ˢ ρ •ₛ σ ∷ Γ
wkSubst′ ε ⊢Δ ⊢Δ′ ρ id = id
wkSubst′ (_∙_ {Γ} {A} ⊢Γ ⊢A) ⊢Δ ⊢Δ′ ρ (tailσ , headσ) =
wkSubst′ ⊢Γ ⊢Δ ⊢Δ′ ρ tailσ
, PE.subst (λ x → _ ⊢ _ ∷ x) (wk-subst A) (wkTerm ρ ⊢Δ′ headσ)
-- Weakening of well-formed substitution by one.
wk1Subst′ : ∀ {F σ Γ Δ} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ)
(⊢F : Δ ⊢ F)
([σ] : Δ ⊢ˢ σ ∷ Γ)
→ (Δ ∙ F) ⊢ˢ wk1Subst σ ∷ Γ
wk1Subst′ {F} {σ} {Γ} {Δ} ⊢Γ ⊢Δ ⊢F [σ] =
wkSubst′ ⊢Γ ⊢Δ (⊢Δ ∙ ⊢F) (step id) [σ]
-- Lifting of well-formed substitution.
liftSubst′ : ∀ {F σ Γ Δ} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ)
(⊢F : Γ ⊢ F)
([σ] : Δ ⊢ˢ σ ∷ Γ)
→ (Δ ∙ subst σ F) ⊢ˢ liftSubst σ ∷ Γ ∙ F
liftSubst′ {F} {σ} {Γ} {Δ} ⊢Γ ⊢Δ ⊢F [σ] =
let ⊢Δ∙F = ⊢Δ ∙ substitution ⊢F [σ] ⊢Δ
in wkSubst′ ⊢Γ ⊢Δ ⊢Δ∙F (step id) [σ]
, var ⊢Δ∙F (PE.subst (λ x → 0 ∷ x ∈ (Δ ∙ subst σ F))
(wk-subst F) here)
-- Well-formed identity substitution.
idSubst′ : ∀ {Γ} (⊢Γ : ⊢ Γ)
→ Γ ⊢ˢ idSubst ∷ Γ
idSubst′ ε = id
idSubst′ (_∙_ {Γ} {A} ⊢Γ ⊢A) =
wk1Subst′ ⊢Γ ⊢Γ ⊢A (idSubst′ ⊢Γ)
, PE.subst (λ x → Γ ∙ A ⊢ _ ∷ x) (wk1-tailId A) (var (⊢Γ ∙ ⊢A) here)
-- Well-formed substitution composition.
substComp′ : ∀ {σ σ′ Γ Δ Δ′} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ) (⊢Δ′ : ⊢ Δ′)
([σ] : Δ′ ⊢ˢ σ ∷ Δ)
([σ′] : Δ ⊢ˢ σ′ ∷ Γ)
→ Δ′ ⊢ˢ σ ₛ•ₛ σ′ ∷ Γ
substComp′ ε ⊢Δ ⊢Δ′ [σ] id = id
substComp′ (_∙_ {Γ} {A} ⊢Γ ⊢A) ⊢Δ ⊢Δ′ [σ] ([tailσ′] , [headσ′]) =
substComp′ ⊢Γ ⊢Δ ⊢Δ′ [σ] [tailσ′]
, PE.subst (λ x → _ ⊢ _ ∷ x) (substCompEq A)
(substitutionTerm [headσ′] [σ] ⊢Δ′)
-- Well-formed singleton substitution of terms.
singleSubst : ∀ {A t Γ} → Γ ⊢ t ∷ A → Γ ⊢ˢ sgSubst t ∷ Γ ∙ A
singleSubst {A} t =
let ⊢Γ = wfTerm t
in idSubst′ ⊢Γ , PE.subst (λ x → _ ⊢ _ ∷ x) (PE.sym (subst-id A)) t
-- Well-formed singleton substitution of term equality.
singleSubstEq : ∀ {A t u Γ} → Γ ⊢ t ≡ u ∷ A
→ Γ ⊢ˢ sgSubst t ≡ sgSubst u ∷ Γ ∙ A
singleSubstEq {A} t =
let ⊢Γ = wfEqTerm t
in substRefl (idSubst′ ⊢Γ) , PE.subst (λ x → _ ⊢ _ ≡ _ ∷ x) (PE.sym (subst-id A)) t
-- Well-formed singleton substitution of terms with lifting.
singleSubst↑ : ∀ {A t Γ} → Γ ∙ A ⊢ t ∷ wk1 A → Γ ∙ A ⊢ˢ consSubst (wk1Subst idSubst) t ∷ Γ ∙ A
singleSubst↑ {A} t with wfTerm t
... | ⊢Γ ∙ ⊢A = wk1Subst′ ⊢Γ ⊢Γ ⊢A (idSubst′ ⊢Γ)
, PE.subst (λ x → _ ∙ A ⊢ _ ∷ x) (wk1-tailId A) t
-- Well-formed singleton substitution of term equality with lifting.
singleSubst↑Eq : ∀ {A t u Γ} → Γ ∙ A ⊢ t ≡ u ∷ wk1 A
→ Γ ∙ A ⊢ˢ consSubst (wk1Subst idSubst) t ≡ consSubst (wk1Subst idSubst) u ∷ Γ ∙ A
singleSubst↑Eq {A} t with wfEqTerm t
... | ⊢Γ ∙ ⊢A = substRefl (wk1Subst′ ⊢Γ ⊢Γ ⊢A (idSubst′ ⊢Γ))
, PE.subst (λ x → _ ∙ A ⊢ _ ≡ _ ∷ x) (wk1-tailId A) t
-- Helper lemmas for single substitution
substType : ∀ {t F G Γ} → Γ ∙ F ⊢ G → Γ ⊢ t ∷ F → Γ ⊢ G [ t ]
substType {t} {F} {G} ⊢G ⊢t =
let ⊢Γ = wfTerm ⊢t
in substitution ⊢G (singleSubst ⊢t) ⊢Γ
substTypeEq : ∀ {t u F G E Γ} → Γ ∙ F ⊢ G ≡ E → Γ ⊢ t ≡ u ∷ F → Γ ⊢ G [ t ] ≡ E [ u ]
substTypeEq {F = F} ⊢G ⊢t =
let ⊢Γ = wfEqTerm ⊢t
in substitutionEq ⊢G (singleSubstEq ⊢t) ⊢Γ
substTerm : ∀ {F G t f Γ} → Γ ∙ F ⊢ f ∷ G → Γ ⊢ t ∷ F → Γ ⊢ f [ t ] ∷ G [ t ]
substTerm {F} {G} {t} {f} ⊢f ⊢t =
let ⊢Γ = wfTerm ⊢t
in substitutionTerm ⊢f (singleSubst ⊢t) ⊢Γ
substTypeΠ : ∀ {t F G Γ} → Γ ⊢ Π F ▹ G → Γ ⊢ t ∷ F → Γ ⊢ G [ t ]
substTypeΠ ΠFG t with syntacticΠ ΠFG
substTypeΠ ΠFG t | F , G = substType G t
subst↑Type : ∀ {t F G Γ}
→ Γ ∙ F ⊢ G
→ Γ ∙ F ⊢ t ∷ wk1 F
→ Γ ∙ F ⊢ G [ t ]↑
subst↑Type ⊢G ⊢t = substitution ⊢G (singleSubst↑ ⊢t) (wfTerm ⊢t)
subst↑TypeEq : ∀ {t u F G E Γ}
→ Γ ∙ F ⊢ G ≡ E
→ Γ ∙ F ⊢ t ≡ u ∷ wk1 F
→ Γ ∙ F ⊢ G [ t ]↑ ≡ E [ u ]↑
subst↑TypeEq ⊢G ⊢t = substitutionEq ⊢G (singleSubst↑Eq ⊢t) (wfEqTerm ⊢t)
| {
"alphanum_fraction": 0.5134601832,
"avg_line_length": 40.3125,
"ext": "agda",
"hexsha": "49f2d9db3adfe48a6ffe0396c7a1b263b6684a3c",
"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": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Vtec234/logrel-mltt",
"max_forks_repo_path": "Definition/Typed/Consequences/Substitution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"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": "Vtec234/logrel-mltt",
"max_issues_repo_path": "Definition/Typed/Consequences/Substitution.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Vtec234/logrel-mltt",
"max_stars_repo_path": "Definition/Typed/Consequences/Substitution.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3359,
"size": 7095
} |
{- Binary natural numbers (Anders Mörtberg, Jan. 2019)
This file defines two representations of binary numbers. We prove that
they are equivalent to unary numbers and univalence is then used to
transport both programs and properties between the representations.
This is an example of how having computational univalence can be
useful for practical programming.
The first definition is [Binℕ] and the numbers are essentially lists
of 0/1 with no trailing zeroes (in little-endian format). The main
definitions and examples are:
- Equivalence between Binℕ and ℕ ([Binℕ≃ℕ]) with an equality obtained
using univalence ([Binℕ≡ℕ]).
- Addition on Binℕ defined by transporting addition on ℕ to Binℕ
([_+Binℕ_]) along Binℕ≡ℕ together with a proof that addition on Binℕ
is associative obtained by transporting the proof for ℕ ([+Binℕ-assoc]).
- Functions testing whether a binary number is odd or even in O(1)
([oddBinℕ], [evenBinℕ]) and the corresponding functions for ℕ
obtained by transport. Proof that odd numbers are not even
transported from Binℕ to ℕ ([oddℕnotEvenℕ]).
- An example of the structure identity principle for natural number
structures ([NatImpl]). We first prove that Binℕ≡ℕ lifts to natural
number structures ([NatImplℕ≡Binℕ]) and we then use this to
transport "+-suc : m + suc n ≡ suc (m + n)" from ℕ to Binℕ ([+Binℕ-suc]).
- An example of program/data refinement using the structure identity
principle where we transport a property that is infeasible to prove
by computation for ℕ ([propDoubleℕ]):
2^20 * 2^10 = 2^5 * (2^15 * 2^10)
from the corresponding result on Binℕ which is proved instantly by
refl ([propDoubleBinℕ]).
These examples are inspired from an old cubicaltt formalization:
https://github.com/mortberg/cubicaltt/blob/master/examples/binnat.ctt
which itself is based on an even older cubical formalization (from 2014):
https://github.com/simhu/cubical/blob/master/examples/binnat.cub
The second representation is more non-standard and inspired by:
https://github.com/RedPRL/redtt/blob/master/library/cool/nats.red
Only some of the experiments have been done for this representation,
but it has the virtue of being a bit simpler to prove equivalent to
ℕ. The same representation can be found in:
http://www.cs.bham.ac.uk/~mhe/agda-new/BinaryNaturals.html
-}
{-# OPTIONS --cubical --no-exact-split --safe #-}
module Cubical.Data.BinNat.BinNat where
open import Cubical.Core.Glue
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat
open import Cubical.Data.Bool
open import Cubical.Data.Empty
open import Cubical.Relation.Nullary
-- Positive binary numbers
data Pos : Type₀ where
pos1 : Pos
x0 : Pos → Pos
x1 : Pos → Pos
sucPos : Pos → Pos
sucPos pos1 = x0 pos1
sucPos (x0 ps) = x1 ps
sucPos (x1 ps) = x0 (sucPos ps)
Pos→ℕ : Pos → ℕ
Pos→ℕ pos1 = suc zero
Pos→ℕ (x0 ps) = doubleℕ (Pos→ℕ ps)
Pos→ℕ (x1 ps) = suc (doubleℕ (Pos→ℕ ps))
posInd : {P : Pos → Type₀} → P pos1 → ((p : Pos) → P p → P (sucPos p)) → (p : Pos) → P p
posInd {P} h1 hs ps = f ps
where
H : (p : Pos) → P (x0 p) → P (x0 (sucPos p))
H p hx0p = hs (x1 p) (hs (x0 p) hx0p)
f : (ps : Pos) → P ps
f pos1 = h1
f (x0 ps) = posInd (hs pos1 h1) H ps
f (x1 ps) = hs (x0 ps) (posInd (hs pos1 h1) H ps)
Pos→ℕsucPos : (p : Pos) → Pos→ℕ (sucPos p) ≡ suc (Pos→ℕ p)
Pos→ℕsucPos pos1 = refl
Pos→ℕsucPos (x0 p) = refl
Pos→ℕsucPos (x1 p) = λ i → doubleℕ (Pos→ℕsucPos p i)
zero≠Pos→ℕ : (p : Pos) → ¬ (zero ≡ Pos→ℕ p)
zero≠Pos→ℕ p = posInd (λ prf → znots prf) hs p
where
hs : (p : Pos) → ¬ (zero ≡ Pos→ℕ p) → zero ≡ Pos→ℕ (sucPos p) → ⊥
hs p neq ieq = ⊥-elim (znots (ieq ∙ (Pos→ℕsucPos p)))
ℕ→Pos : ℕ → Pos
ℕ→Pos zero = pos1
ℕ→Pos (suc zero) = pos1
ℕ→Pos (suc (suc n)) = sucPos (ℕ→Pos (suc n))
ℕ→PosSuc : ∀ n → ¬ (zero ≡ n) → ℕ→Pos (suc n) ≡ sucPos (ℕ→Pos n)
ℕ→PosSuc zero neq = ⊥-elim (neq refl)
ℕ→PosSuc (suc n) neq = refl
Pos→ℕ→Pos : (p : Pos) → ℕ→Pos (Pos→ℕ p) ≡ p
Pos→ℕ→Pos p = posInd refl hs p
where
hs : (p : Pos) → ℕ→Pos (Pos→ℕ p) ≡ p → ℕ→Pos (Pos→ℕ (sucPos p)) ≡ sucPos p
hs p hp =
ℕ→Pos (Pos→ℕ (sucPos p)) ≡⟨ cong ℕ→Pos (Pos→ℕsucPos p) ⟩
ℕ→Pos (suc (Pos→ℕ p)) ≡⟨ ℕ→PosSuc (Pos→ℕ p) (zero≠Pos→ℕ p) ⟩
sucPos (ℕ→Pos (Pos→ℕ p)) ≡⟨ cong sucPos hp ⟩
sucPos p ∎
ℕ→Pos→ℕ : (n : ℕ) → Pos→ℕ (ℕ→Pos (suc n)) ≡ suc n
ℕ→Pos→ℕ zero = refl
ℕ→Pos→ℕ (suc n) =
Pos→ℕ (sucPos (ℕ→Pos (suc n))) ≡⟨ Pos→ℕsucPos (ℕ→Pos (suc n)) ⟩
suc (Pos→ℕ (ℕ→Pos (suc n))) ≡⟨ cong suc (ℕ→Pos→ℕ n) ⟩
suc (suc n) ∎
-- Binary numbers
data Binℕ : Type₀ where
binℕ0 : Binℕ
binℕpos : Pos → Binℕ
ℕ→Binℕ : ℕ → Binℕ
ℕ→Binℕ zero = binℕ0
ℕ→Binℕ (suc n) = binℕpos (ℕ→Pos (suc n))
Binℕ→ℕ : Binℕ → ℕ
Binℕ→ℕ binℕ0 = zero
Binℕ→ℕ (binℕpos x) = Pos→ℕ x
ℕ→Binℕ→ℕ : (n : ℕ) → Binℕ→ℕ (ℕ→Binℕ n) ≡ n
ℕ→Binℕ→ℕ zero = refl
ℕ→Binℕ→ℕ (suc zero) = refl
ℕ→Binℕ→ℕ (suc (suc n)) =
Pos→ℕ (sucPos (ℕ→Pos (suc n))) ≡⟨ Pos→ℕsucPos (ℕ→Pos (suc n)) ⟩
suc (Pos→ℕ (ℕ→Pos (suc n))) ≡⟨ cong suc (ℕ→Binℕ→ℕ (suc n)) ⟩
suc (suc n) ∎
Binℕ→ℕ→Binℕ : (n : Binℕ) → ℕ→Binℕ (Binℕ→ℕ n) ≡ n
Binℕ→ℕ→Binℕ binℕ0 = refl
Binℕ→ℕ→Binℕ (binℕpos p) = posInd refl (λ p _ → rem p) p
where
rem : (p : Pos) → ℕ→Binℕ (Pos→ℕ (sucPos p)) ≡ binℕpos (sucPos p)
rem p =
ℕ→Binℕ (Pos→ℕ (sucPos p)) ≡⟨ cong ℕ→Binℕ (Pos→ℕsucPos p) ⟩
binℕpos (ℕ→Pos (suc (Pos→ℕ p))) ≡⟨ cong binℕpos ((ℕ→PosSuc (Pos→ℕ p) (zero≠Pos→ℕ p)) ∙
(cong sucPos (Pos→ℕ→Pos p))) ⟩
binℕpos (sucPos p) ∎
Binℕ≃ℕ : Binℕ ≃ ℕ
Binℕ≃ℕ = isoToEquiv (iso Binℕ→ℕ ℕ→Binℕ ℕ→Binℕ→ℕ Binℕ→ℕ→Binℕ)
-- Use univalence (in fact only "ua") to get an equality from the
-- above equivalence
Binℕ≡ℕ : Binℕ ≡ ℕ
Binℕ≡ℕ = ua Binℕ≃ℕ
sucBinℕ : Binℕ → Binℕ
sucBinℕ binℕ0 = binℕpos pos1
sucBinℕ (binℕpos x) = binℕpos (sucPos x)
Binℕ→ℕsuc : (x : Binℕ) → suc (Binℕ→ℕ x) ≡ Binℕ→ℕ (sucBinℕ x)
Binℕ→ℕsuc binℕ0 = refl
Binℕ→ℕsuc (binℕpos x) = sym (Pos→ℕsucPos x)
-- We can transport addition on ℕ to Binℕ
_+Binℕ_ : Binℕ → Binℕ → Binℕ
_+Binℕ_ = transport (λ i → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i)) _+_
-- Test: 4 + 1 = 5
private
_ : binℕpos (x0 (x0 pos1)) +Binℕ binℕpos pos1 ≡ binℕpos (x1 (x0 pos1))
_ = refl
-- It is easy to test if binary numbers are odd
oddBinℕ : Binℕ → Bool
oddBinℕ binℕ0 = false
oddBinℕ (binℕpos pos1) = true
oddBinℕ (binℕpos (x0 _)) = false
oddBinℕ (binℕpos (x1 _)) = true
evenBinℕ : Binℕ → Bool
evenBinℕ n = oddBinℕ (sucBinℕ n)
-- And prove the following property (without induction)
oddBinℕnotEvenBinℕ : (n : Binℕ) → oddBinℕ n ≡ not (evenBinℕ n)
oddBinℕnotEvenBinℕ binℕ0 = refl
oddBinℕnotEvenBinℕ (binℕpos pos1) = refl
oddBinℕnotEvenBinℕ (binℕpos (x0 x)) = refl
oddBinℕnotEvenBinℕ (binℕpos (x1 x)) = refl
-- It is also easy to define and prove the property for unary numbers,
-- however the definition uses recursion and the proof induction
private
oddn : ℕ → Bool
oddn zero = true
oddn (suc x) = not (oddn x)
evenn : ℕ → Bool
evenn n = not (oddn n)
oddnSuc : (n : ℕ) → oddn n ≡ not (evenn n)
oddnSuc zero = refl
oddnSuc (suc n) = cong not (oddnSuc n)
-- So what we can do instead is to transport the odd test from Binℕ to
-- ℕ along the equality
oddℕ : ℕ → Bool
oddℕ = transport (λ i → Binℕ≡ℕ i → Bool) oddBinℕ
evenℕ : ℕ → Bool
evenℕ = transport (λ i → Binℕ≡ℕ i → Bool) evenBinℕ
-- We can then also transport the property
oddℕnotEvenℕ : (n : ℕ) → oddℕ n ≡ not (evenℕ n)
oddℕnotEvenℕ =
let -- We first build a path from oddBinℕ to oddℕ. When i=1 this is
-- "transp (λ j → Binℕ≡ℕ j → Bool) i0 oddBinℕ" (i.e. oddℕ)
oddp : PathP (λ i → Binℕ≡ℕ i → Bool) oddBinℕ oddℕ
oddp i = transp (λ j → Binℕ≡ℕ (i ∧ j) → Bool) (~ i) oddBinℕ
-- We then build a path from evenBinℕ to evenℕ
evenp : PathP (λ i → Binℕ≡ℕ i → Bool) evenBinℕ evenℕ
evenp i = transp (λ j → Binℕ≡ℕ (i ∧ j) → Bool) (~ i) evenBinℕ
in -- Then transport oddBinℕnotEvenBinℕ in a suitable equality type
-- When i=0 this is "(n : Binℕ) → oddBinℕ n ≡ not (evenBinℕ n)"
-- When i=1 this is "(n : ℕ) → oddℕ n ≡ not (evenℕ n)"
transport (λ i → (n : Binℕ≡ℕ i) → oddp i n ≡ not (evenp i n)) oddBinℕnotEvenBinℕ
-- We can do the same for natural numbers:
-- First construct the path
addp : PathP (λ i → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i) → Binℕ≡ℕ (~ i)) _+_ _+Binℕ_
addp i = transp (λ j → Binℕ≡ℕ (~ i ∨ ~ j) → Binℕ≡ℕ (~ i ∨ ~ j) → Binℕ≡ℕ (~ i ∨ ~ j)) (~ i) _+_
-- Then transport associativity:
+Binℕ-assoc : ∀ m n o → m +Binℕ (n +Binℕ o) ≡ (m +Binℕ n) +Binℕ o
+Binℕ-assoc =
transport (λ i → (m n o : Binℕ≡ℕ (~ i))
→ addp i m (addp i n o) ≡ addp i (addp i m n) o) +-assoc
-- We can also define what it means to be an implementation of natural
-- numbers and use this to transport properties between different
-- implementation of natural numbers. This can be seen as a special
-- case of the structure identity principle: any property that holds
-- for one structure also holds for an equivalent one.
-- An implementation of natural numbers (i.e. a "natural number
-- structure") has a zero and successor.
record NatImpl (A : Type₀) : Type₀ where
field
z : A
s : A → A
open NatImpl
NatImplℕ : NatImpl ℕ
z NatImplℕ = zero
s NatImplℕ = suc
NatImplBinℕ : NatImpl Binℕ
z NatImplBinℕ = binℕ0
s NatImplBinℕ = sucBinℕ
-- Using the equality between binary and unary numbers we can get an
-- equality between the two implementations of the NatImpl interface
NatImplℕ≡Binℕ : PathP (λ i → NatImpl (Binℕ≡ℕ (~ i))) NatImplℕ NatImplBinℕ
z (NatImplℕ≡Binℕ i) = transp (λ j → Binℕ≡ℕ (~ i ∨ ~ j)) (~ i) zero
s (NatImplℕ≡Binℕ i) =
λ x → glue (λ { (i = i0) → suc x
; (i = i1) → sucBinℕ x })
-- We need to do use and hcomp to do and endpoint
-- correction as "suc (unglue x)" connects "suc x"
-- with "suc (Binℕ→ℕ x)" along i (which makes sense as
-- x varies from ℕ to Binℕ along i), but we need
-- something from "suc x" to "Binℕ→ℕ (sucBinℕ x)" for
-- the glue to be well-formed
(hcomp (λ j → λ { (i = i0) → suc x
; (i = i1) → Binℕ→ℕsuc x j })
(suc (unglue (i ∨ ~ i) x)))
-- We then use this to transport +-suc from unary to binary numbers
+Binℕ-suc : ∀ m n → m +Binℕ sucBinℕ n ≡ sucBinℕ (m +Binℕ n)
+Binℕ-suc =
transport (λ i → (m n : Binℕ≡ℕ (~ i))
→ addp i m (NatImplℕ≡Binℕ i .s n) ≡ NatImplℕ≡Binℕ i .s (addp i m n)) +-suc
-- Doubling experiment: we define a notion of "doubling structure" and
-- transport a proof that is proved directly using refl for binary
-- numbers to unary numbers. This is an example of program/data
-- refinement: we can use univalence to prove properties about
-- inefficient data-structures using efficient ones.
-- Doubling structures
record Double {ℓ} (A : Type ℓ) : Type (ℓ-suc ℓ) where
field
-- doubling function computing 2 * x
double : A → A
-- element to double
elt : A
open Double
-- Compute: 2^n * x
doubles : ∀ {ℓ} {A : Type ℓ} (D : Double A) → ℕ → A → A
doubles D n x = iter n (double D) x
Doubleℕ : Double ℕ
double Doubleℕ = doubleℕ
elt Doubleℕ = n1024
where
-- 1024 = 2^8 * 2^2 = 2^10
n1024 : ℕ
n1024 = doublesℕ 8 4
-- The doubling operation on binary numbers is O(1), while for unary
-- numbers it is O(n). What is of course even more problematic is that
-- we cannot handle very big unary natural numbers, but with binary
-- there is no problem to represent very big numbers
doubleBinℕ : Binℕ → Binℕ
doubleBinℕ binℕ0 = binℕ0
doubleBinℕ (binℕpos x) = binℕpos (x0 x)
DoubleBinℕ : Double Binℕ
double DoubleBinℕ = doubleBinℕ
elt DoubleBinℕ = bin1024
where
-- 1024 = 2^10 = 10000000000₂
bin1024 : Binℕ
bin1024 = binℕpos (x0 (x0 (x0 (x0 (x0 (x0 (x0 (x0 (x0 (x0 pos1))))))))))
-- As these function don't commute strictly we have to prove it
-- separately and insert it in the proof of DoubleBinℕ≡Doubleℕ below
-- (just like we had to in NatImplℕ≡NatImplBinℕ
Binℕ→ℕdouble : (x : Binℕ) → doubleℕ (Binℕ→ℕ x) ≡ Binℕ→ℕ (doubleBinℕ x)
Binℕ→ℕdouble binℕ0 = refl
Binℕ→ℕdouble (binℕpos x) = refl
-- We use the equality between Binℕ and ℕ to get an equality of
-- doubling structures
DoubleBinℕ≡Doubleℕ : PathP (λ i → Double (Binℕ≡ℕ i)) DoubleBinℕ Doubleℕ
double (DoubleBinℕ≡Doubleℕ i) =
λ x → glue (λ { (i = i0) → doubleBinℕ x
; (i = i1) → doubleℕ x })
(hcomp (λ j → λ { (i = i0) → Binℕ→ℕdouble x j
; (i = i1) → doubleℕ x })
(doubleℕ (unglue (i ∨ ~ i) x)))
elt (DoubleBinℕ≡Doubleℕ i) = transp (λ j → Binℕ≡ℕ (i ∨ ~ j)) i (Doubleℕ .elt)
-- We can now use transport to prove a property that is too slow to
-- check with unary numbers. We define the property we want to check
-- as a record so that Agda does not try to unfold it eagerly.
record propDouble {ℓ} {A : Type ℓ} (D : Double A) : Type ℓ where
field
-- 2^20 * e = 2^5 * (2^15 * e)
proof : doubles D 20 (elt D) ≡ doubles D 5 (doubles D 15 (elt D))
open propDouble
-- The property we want to prove takes too long to typecheck for ℕ:
-- propDoubleℕ : propDouble Doubleℕ
-- propDoubleℕ = refl
-- With binary numbers it is instant
propDoubleBinℕ : propDouble DoubleBinℕ
proof propDoubleBinℕ = refl
-- By transporting the proof along the equality we then get it for
-- unary numbers
propDoubleℕ : propDouble Doubleℕ
propDoubleℕ = transport (λ i → propDouble (DoubleBinℕ≡Doubleℕ i)) propDoubleBinℕ
--------------------------------------------------------------------------------
--
-- Alternative encoding of binary natural numbers inspired by:
-- https://github.com/RedPRL/redtt/blob/master/library/cool/nats.red
--
-- This representation makes the equivalence with ℕ a bit easier to
-- prove, but the doubling example wouldn't work as nicely as we
-- cannot define it as an O(1) operation
data binnat : Type₀ where
zero : binnat -- 0
consOdd : binnat → binnat -- 2^n + 1
consEven : binnat → binnat -- 2^{n+1}
binnat→ℕ : binnat → ℕ
binnat→ℕ zero = 0
binnat→ℕ (consOdd n) = suc (doubleℕ (binnat→ℕ n))
binnat→ℕ (consEven n) = suc (suc (doubleℕ (binnat→ℕ n)))
suc-binnat : binnat → binnat
suc-binnat zero = consOdd zero
suc-binnat (consOdd n) = consEven n
suc-binnat (consEven n) = consOdd (suc-binnat n)
ℕ→binnat : ℕ → binnat
ℕ→binnat zero = zero
ℕ→binnat (suc n) = suc-binnat (ℕ→binnat n)
binnat→ℕ-suc : (n : binnat) → binnat→ℕ (suc-binnat n) ≡ suc (binnat→ℕ n)
binnat→ℕ-suc zero = refl
binnat→ℕ-suc (consOdd n) = refl
binnat→ℕ-suc (consEven n) = λ i → suc (doubleℕ (binnat→ℕ-suc n i))
ℕ→binnat→ℕ : (n : ℕ) → binnat→ℕ (ℕ→binnat n) ≡ n
ℕ→binnat→ℕ zero = refl
ℕ→binnat→ℕ (suc n) = (binnat→ℕ-suc (ℕ→binnat n)) ∙ (cong suc (ℕ→binnat→ℕ n))
suc-ℕ→binnat-double : (n : ℕ) → suc-binnat (ℕ→binnat (doubleℕ n)) ≡ consOdd (ℕ→binnat n)
suc-ℕ→binnat-double zero = refl
suc-ℕ→binnat-double (suc n) = λ i → suc-binnat (suc-binnat (suc-ℕ→binnat-double n i))
binnat→ℕ→binnat : (n : binnat) → ℕ→binnat (binnat→ℕ n) ≡ n
binnat→ℕ→binnat zero = refl
binnat→ℕ→binnat (consOdd n) =
(suc-ℕ→binnat-double (binnat→ℕ n)) ∙ (cong consOdd (binnat→ℕ→binnat n))
binnat→ℕ→binnat (consEven n) =
(λ i → suc-binnat (suc-ℕ→binnat-double (binnat→ℕ n) i)) ∙ (cong consEven (binnat→ℕ→binnat n))
ℕ≃binnat : ℕ ≃ binnat
ℕ≃binnat = isoToEquiv (iso ℕ→binnat binnat→ℕ binnat→ℕ→binnat ℕ→binnat→ℕ)
ℕ≡binnat : ℕ ≡ binnat
ℕ≡binnat = ua ℕ≃binnat
-- We can transport addition on ℕ to binnat
_+binnat_ : binnat → binnat → binnat
_+binnat_ = transport (λ i → ℕ≡binnat i → ℕ≡binnat i → ℕ≡binnat i) _+_
-- Test: 4 + 1 = 5
_ : consEven (consOdd zero) +binnat consOdd zero ≡ consOdd (consEven zero)
_ = refl
oddbinnat : binnat → Bool
oddbinnat zero = false
oddbinnat (consOdd _) = true
oddbinnat (consEven _) = false
oddℕ' : ℕ → Bool
oddℕ' = transport (λ i → ℕ≡binnat (~ i) → Bool) oddbinnat
-- The NatImpl example for this representation of binary numbers
private
NatImplbinnat : NatImpl binnat
z NatImplbinnat = zero
s NatImplbinnat = suc-binnat
-- Note that the s case is a bit simpler as no end-point correction
-- is necessary (things commute strictly)
NatImplℕ≡NatImplbinnat : PathP (λ i → NatImpl (ℕ≡binnat i)) NatImplℕ NatImplbinnat
z (NatImplℕ≡NatImplbinnat i) = transp (λ j → ℕ≡binnat (i ∨ ~ j)) i zero
s (NatImplℕ≡NatImplbinnat i) =
λ x → glue (λ { (i = i0) → suc x
; (i = i1) → suc-binnat x })
(suc-binnat (unglue (i ∨ ~ i) x))
oddSuc : (n : binnat) → oddbinnat n ≡ not (oddbinnat (suc-binnat n))
oddSuc zero = refl
oddSuc (consOdd _) = refl
oddSuc (consEven _) = refl
oddℕSuc' : (n : ℕ) → oddℕ' n ≡ not (oddℕ' (suc n))
oddℕSuc' =
let eq : (i : I) → ℕ≡binnat (~ i) → Bool
eq i = transp (λ j → ℕ≡binnat (~ i ∨ ~ j) → Bool) (~ i) oddbinnat
in transport
(λ i → (n : ℕ≡binnat (~ i)) → eq i n ≡ not (eq i (NatImplℕ≡NatImplbinnat (~ i) .NatImpl.s n)))
oddSuc
| {
"alphanum_fraction": 0.6354281728,
"avg_line_length": 34.6794354839,
"ext": "agda",
"hexsha": "9552f02cb080dcd2257aed69927c871644572d51",
"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": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cj-xu/cubical",
"max_forks_repo_path": "Cubical/Data/BinNat/BinNat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"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": "cj-xu/cubical",
"max_issues_repo_path": "Cubical/Data/BinNat/BinNat.agda",
"max_line_length": 104,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cj-xu/cubical",
"max_stars_repo_path": "Cubical/Data/BinNat/BinNat.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6975,
"size": 17201
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.Limits.Pullback where
open import Cubical.Foundations.Prelude
open import Cubical.Categories.Limits.Base
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Data.Sigma
open import Cubical.Categories.Instances.Cospan public
private
variable
ℓ ℓ' : Level
module _ {C : Precategory ℓ ℓ'} where
open Precategory C
open Functor
record Cospan : Type (ℓ-max ℓ ℓ') where
constructor cospan
field
l m r : ob
s₁ : C [ l , m ]
s₂ : C [ r , m ]
record PullbackLegs (cspn : Cospan) (c : ob) : Type (ℓ-max ℓ ℓ') where
constructor pblegs
open Cospan cspn
field
p₁ : C [ c , l ]
p₂ : C [ c , r ]
record PullbackCone (cspn : Cospan) (c : ob) : Type (ℓ-max ℓ ℓ') where
constructor cone
open Cospan cspn
field
pl : PullbackLegs cspn c
open PullbackLegs pl public
field
sq : p₁ ⋆⟨ C ⟩ s₁ ≡ p₂ ⋆⟨ C ⟩ s₂
record isPullback (cspn : _) {c} (pb : PullbackLegs cspn c) : Type (ℓ-max ℓ ℓ') where
open Cospan cspn
open PullbackLegs
field
sq : pb .p₁ ⋆⟨ C ⟩ s₁ ≡ pb .p₂ ⋆⟨ C ⟩ s₂
open PullbackCone
field
up : ∀ {d}
→ (pb' : PullbackCone cspn d)
→ isContr (Σ[ f ∈ (C [ d , c ]) ] ((pb' .p₁ ≡ f ⋆⟨ C ⟩ pb .p₁)
× (pb' .p₂ ≡ f ⋆⟨ C ⟩ pb .p₂)))
Cospan→Func : Cospan → Functor CospanCat C
Cospan→Func (cospan l m r f g) .F-ob ⓪ = l
Cospan→Func (cospan l m r f g) .F-ob ① = m
Cospan→Func (cospan l m r f g) .F-ob ② = r
Cospan→Func (cospan l m r f g) .F-hom {⓪} {①} k = f
Cospan→Func (cospan l m r f g) .F-hom {②} {①} k = g
Cospan→Func (cospan l m r f g) .F-hom {⓪} {⓪} k = id l
Cospan→Func (cospan l m r f g) .F-hom {①} {①} k = id m
Cospan→Func (cospan l m r f g) .F-hom {②} {②} k = id r
Cospan→Func (cospan l m r f g) .F-id {⓪} = refl
Cospan→Func (cospan l m r f g) .F-id {①} = refl
Cospan→Func (cospan l m r f g) .F-id {②} = refl
Cospan→Func (cospan l m r f g) .F-seq {⓪} {⓪} {⓪} φ ψ = sym (⋆IdL _)
Cospan→Func (cospan l m r f g) .F-seq {⓪} {⓪} {①} φ ψ = sym (⋆IdL _)
Cospan→Func (cospan l m r f g) .F-seq {⓪} {①} {①} φ ψ = sym (⋆IdR _)
Cospan→Func (cospan l m r f g) .F-seq {①} {①} {①} φ ψ = sym (⋆IdL _)
Cospan→Func (cospan l m r f g) .F-seq {②} {②} {②} φ ψ = sym (⋆IdL _)
Cospan→Func (cospan l m r f g) .F-seq {②} {②} {①} φ ψ = sym (⋆IdL _)
Cospan→Func (cospan l m r f g) .F-seq {②} {①} {①} φ ψ = sym (⋆IdR _)
-- TODO: show that this definition of Pullback is equivalent to the Cospan limit
| {
"alphanum_fraction": 0.5812524011,
"avg_line_length": 32.1358024691,
"ext": "agda",
"hexsha": "be348ac5bb606ab90d43042457691f6fb31d245f",
"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/Categories/Limits/Pullback.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"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": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Categories/Limits/Pullback.agda",
"max_line_length": 87,
"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/Categories/Limits/Pullback.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1165,
"size": 2603
} |
open import Agda.Primitive
open import Agda.Builtin.Sigma
data Empty : Set where
_≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ')
A ≃ B = Σ (A → B) λ f → Empty
record Iso {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') : Set (ℓ ⊔ ℓ') where
field
inv : B → A
postulate
isoToEquiv : ∀{ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → Iso A B → A ≃ B
works : Iso (∀ {a : Set} → a) Empty
works = λ where
.Iso.inv n → {!n!}
-- something like (∀ {A : Set} → A) seems to be necessary to trigger
test : (∀ {A : Set} → A) ≃ Empty
test = isoToEquiv λ where
.Iso.inv n → {!n!}
| {
"alphanum_fraction": 0.5347593583,
"avg_line_length": 22.44,
"ext": "agda",
"hexsha": "c38e316820b277aef248f3ee89939a01b55b835b",
"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/interaction/Issue5252.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/interaction/Issue5252.agda",
"max_line_length": 70,
"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/interaction/Issue5252.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": 246,
"size": 561
} |
----------------------------------------------------------------------
-- Copyright: 2013, Jan Stolarek, Lodz University of Technology --
-- --
-- License: See LICENSE file in root of the repo --
-- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps --
-- --
-- Weight biased leftist heap that proves rank invariant: size of --
-- left subtree of a node is not smaller than size of right --
-- subtree. Uses a two-pass merging algorithm. --
----------------------------------------------------------------------
module TwoPassMerge.RankProof where
open import Basics
-- To prove the rank invariant we will index each Heap by its size,
-- (remember that size of a heap is its rank). Therefore index of
-- value n says that a Heap stores n elements. When merging two heaps
-- we will use the index to ensure that rank invariant is maintained.
--
-- Again, Heap has two constructor:
--
-- 1) empty constructs a heap containing no elements. Therefore the
-- index is 0.
--
-- 2) node takes two subtrees: one containing l elements, the other
-- containing r elements. The size of resulting heap is the sum of
-- l and r plus one for the element stored by the node itself. To
-- enforce the rank invariant node constructor expects a proof
-- that invariant holds: a value of type l ≥ r. If we can
-- construct value of this type then it proves the invariant.
data Heap : Rank → Set where
empty : Heap zero
node : {l r : Rank} → Priority → l ≥ r →
Heap l → Heap r → Heap (suc (l + r))
-- Since rank is now an index we no longer need rank function to
-- extract Rank from a node. We can pattern match on the index
-- instead.
-- Singleton heap stores only one element. Therefore it has size of
-- one. To prove the rank invariant we must show that 0 ≥ 0. We
-- construct a value of this type using ge0 constructor.
singleton : Priority → Heap one
singleton p = node p ge0 empty empty
-- Note [Proving rank invariant (merge using makeT)]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- Proving the rank invariant itself is surprisingly simple. We just
-- need to supply a proof that rank of left subtree is not smaller
-- than rank of right subtree. We can easily obtain evidence that it
-- is so by using order function which return result of comparing two
-- natural numbers (which will be tree ranks in this case) together
-- with a proof of the result.
--
-- But there is a different difficulty here. Since we index heaps by
-- their size we now require that makeT and merge construct trees of
-- correct size. Prooving this requires some substantial work on our
-- side.
--
-- We need to prove that the size of merged heap is equal to the sum
-- of sizes of heaps being merged. Recall that our merging algorithm
-- is two pass: we use merge to actually do the merging and makeT to
-- restore the rank invariant if necessary (see Note [Two-pass merging
-- algorithm]). This means our proof will be two-stage. We need to
-- prove that:
--
-- 1) makeT creates a node of required size, even if it swaps left
-- and right children.
--
-- 2) recursive calls to merge produce heaps of required size.
-- Note [Proving makeT]
-- ~~~~~~~~~~~~~~~~~~~~
--
-- makeT takes two subtrees of size l and r and produces a new tree of
-- size 1 + l + r. We must prove that each of two cases of makeT
-- returns tree of correct size:
--
-- 1) size of l is ≥ than size of r: no extra proof is necessary as
-- everything follows from the definition of +.
--
-- 2) size of r is ≥ than size of l: in this case we swap left and
-- right subtrees. This requires us to prove that:
--
-- suc (r + l) ≡ suc (l + r)
--
-- That proof is done using congruence on suc function and
-- commutativity of addition. We will define that proof as
-- makeT-lemma as we will be using in subsequent proofs.
makeT-lemma : (a b : Nat) → suc (a + b) ≡ suc (b + a)
makeT-lemma a b = cong suc (+comm a b)
makeT : {l r : Rank} → Priority → Heap l → Heap r → Heap (suc (l + r))
makeT {l-rank} {r-rank} p l r with order l-rank r-rank
makeT {l-rank} {r-rank} p l r | ge l≥r
= node p l≥r l r
makeT {l-rank} {r-rank} p l r | le r≥l
= subst Heap (makeT-lemma r-rank l-rank) (node p r≥l r l)
-- Note [Notation for proving heap merge]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- In the proofs of heap merge we will use following notation:
--
-- h1, h2 - rank of heaps being merged
-- p1, p2 - priority of root element
-- l1 - rank of left subtree in the first heap
-- r1 - rank of right subtree in the first heap
-- l2 - rank of left subtree in the second heap
-- r2 - rank of right subtree in the second heap
--
-- Note that:
--
-- h1 = suc (l1 + r1)
-- h2 = suc (l2 + r2)
--
-- h1 h2
--
-- p1 p2
-- / \ / \
-- / \ / \
-- l1 r1 l2 r2
-- Note [Proving merge]
-- ~~~~~~~~~~~~~~~~~~~~
--
-- We need to prove that all four cases of merge (see [Two-pass merging
-- algorithm]) produce heap of required size, which is h1 + h2. Since
-- in the proofs we will always operate on l1, r1, l2 and r2 we have:
--
-- h1 + h2 ̄≡ suc (l1 + r1) + suc (l2 + r2)
-- ≡ suc ((l1 + r1) + suc (l2 + r2))
--
-- (Second transformation comes from definition of +). This is the
-- expected size and therefore the final result we must prove in every
-- case that we analyze.
-- It is best to study the implementation of merge now and then read
-- the explanation of proofs.
-- Note [merge, proof 0a]
-- ~~~~~~~~~~~~~~~~~~~~~~
--
-- h1 ≡ 0, therefore: h1 + h2 ≡ 0 + h2 ≡ h2 ∎
--
-- This is definitional equality based on _+_
--
-- ∎
-- Note [merge, proof 0b]
-- ~~~~~~~~~~~~~~~~~~~~~~
--
-- h2 ≡ 0, therefore expected size is h1 + h2 ≡ h1 + 0. We need to
-- show that:
--
-- h1 ≡ h1 + 0
--
-- This is a simple statement that 0 is right identity of addition. We
-- proved that as one of basic properties of addition in
-- Basics.Reasoning module, except our proof had the sides of equality
-- reversed, ie. we proved a + 0 ≡ a, not a ≡ a + 0). We use symmetry
-- to construct a proof of latter from the former.
--
-- ∎
-- Note [merge, proof 1]
-- ~~~~~~~~~~~~~~~~~~~~~
--
-- We have p1 < p2. We keep p1 as the root and need to prove that
-- merging r1 with h2 gives correct size. Here's how the term that
-- performs the merge corresponds to its type (for the sake of
-- readability I elided implict parameters):
--
-- makeT p1 x1 l1 (merge r1 (node p2 l2≥r2 l2 r2))
-- | | | \__________________/
-- | +------+ | |
-- | | +----------+ |
-- | | | +---------+
-- | | | ________|__
-- | | | / \
-- suc (l1 + (r1 + suc (l2 + r2)))
--
-- Formally:
--
-- suc (l1 + (r1 + suc (l2 + r2))) ≡ suc ((l1 + r1) + suc (l2 + r2))
--
-- Recall that RHS of this equality comes from [Proving merge]. We
-- begin proof with congruence on suc:
--
-- cong suc X
--
-- where X proves
--
-- l1 + (r1 + suc (l2 + r2)) ≡ (l1 + r1) + suc (l2 + r2)
--
-- Substituting a = l1, b = r1 and c = suc (l2 + r2) we have
--
-- a + (b + c) ≡ (a + b) + c
--
-- Which is associativity of addition that we have already proved in
-- Basics.Reasoning.
--
-- ∎
proof-1 : (l1 r1 l2 r2 : Nat) → suc ( l1 + (r1 + suc (l2 + r2)))
≡ suc ((l1 + r1) + suc (l2 + r2))
proof-1 l1 r1 l2 r2 = cong suc (+assoc l1 r1 (suc (l2 + r2)))
-- Note [merge, proof 2]
-- ~~~~~~~~~~~~~~~~~~~~~
--
-- We have p2 < p1. We keep p2 as the root and need to prove that
-- merging r2 with h1 gives correct size. Again, here's the
-- corespondence between the term and its type:
--
-- makeT p2 x2 l2 (merge r2 (node p1 l1≥r1 l1 r1))
-- | | | \_________________/
-- | +------+ | |
-- | | +----------+ +---------+
-- | | | ________|__
-- | | | / \
-- suc (l2 + (r2 + suc (l1 + r1)))
--
-- Formally:
--
-- suc (l2 + (r2 + suc (l1 + r1))) ≡ suc ((l1 + r1) + suc (l2 + r2))
--
-- Again we use cong to deal with the outer calls to suc and
-- substitute a = l2, b = r2 and c = l1 + r1. This leaves us with a
-- proof of lemma A:
--
-- a + (b + suc c) ≡ c + suc (a + b)
--
-- From associativity we know that:
--
-- a + (b + suc c) ≡ (a + b) + suc c
--
-- If we prove lemma B:
--
-- (a + b) + suc c = c + suc (a + b)
--
-- we can combine it using transitivity to get the final proof. We can
-- rewrite lemma B as:
--
-- n + suc m ≡ m + suc n
--
-- where n = a + b and m = c. From symmetry of +suc we have:
---
-- n + (suc m) ≡ suc (n + m)
--
-- Using transitivity we combine it with congruence on commutativity
-- of addition to prove:
--
-- suc (n + m) ≡ suc (m + n)
--
-- Again, using transitivity we combine it with +suc:
--
-- suc (m + n) ≡ m + suc n
--
-- Which proves lemma B and therefore the whole proof is complete.
--
-- ∎
lemma-B : (n m : Nat) → n + suc m ≡ m + suc n
lemma-B n m = trans (sym (+suc n m)) (trans (cong suc (+comm n m)) (+suc m n))
lemma-A : (a b c : Nat) → a + (b + suc c) ≡ c + suc (a + b)
lemma-A a b c = trans (+assoc a b (suc c)) (lemma-B (a + b) c)
proof-2 : (l1 r1 l2 r2 : Nat) → suc (l2 + (r2 + suc (l1 + r1)))
≡ suc ((l1 + r1) + suc (l2 + r2))
proof-2 l1 r1 l2 r2 = cong suc (lemma-A l2 r2 (l1 + r1))
-- Note [Constructing equality proofs using transitivity]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- Now that constructed two specific proofs we can focus on a more
-- general technique used in both cases. Let's rewrite proof-2 in a
-- different fassion to see closely what is happening at each
-- step. Inlining lemmas A and B into proof-2 gives:
--
-- proof-2i : (l1 r1 l2 r2 : Nat) → suc (l2 + (r2 + suc (l1 + r1)))
-- ≡ suc ((l1 + r1) + suc (l2 + r2))
-- proof-2i l1 r1 l2 r2 =
-- cong suc (trans (+assoc l2 r2 (suc (l1 + r1)))
-- (trans (sym (+suc (l2 + r2) (l1 + r1)))
-- (trans (cong suc (+comm (l2 + r2) (l1 + r1)))
-- (+suc (l1 + r1) (l2 + r2))))
--
-- We see a lot of properties combined using transitivity. In general,
-- if we have to prove:
--
-- a ≡ e
--
-- and we can prove:
--
-- a ≡ b, b ≡ c, c ≡ d, d ≡ e
--
-- then we can combine these proofs using transitivity:
--
-- trans (a ≡ b) (trans (b ≡ c) (trans (c ≡ d) (d ≡ e)))
--
-- While simple to use, combining proofs with transitivity can be not
-- so obvious at first. Let's rewrite the proof we have conducted
-- using following notation:
--
-- a ≡[ proof 1 ]
-- b ≡[ proof 2 ]
-- c ≡[ proof 3 ]
-- d ≡[ proof 4 ]
-- e ∎
--
-- Where proof 1 proves a ≡ b, proof 2 proves b ≡ c and so on. In our
-- particular case this will be:
--
-- suc (l2 + (r2 + suc (l1 + r1))) ≡[ cong suc ]
-- [suc] l2 + (r2 + suc (l1 + r1)) ≡[+assoc l2 r2 (suc (l1 + r1))]
-- [suc] (l2 + r2) + suc (l1 + r1) ≡[ sym (+suc (l2 + r2) (l1 + r1))]
-- [suc] suc ((l2 + r2) + (l1 + r1)) ≡[ cong suc (+comm (l2 + r2) (l1 + r1)) ]
-- [suc] suc ((l1 + r1) + (l2 + r2)) ≡[+suc (l1 + r1) (l2 + r2) ]
-- [suc] (l1 + r1) + suc (l2 + r2) ∎
--
-- We use [suc] to denote that everything happens under a call to suc
-- (thanks to using congruence). Compare this notation with code of
-- proof-2i.
-- Note [Notation in merge]
-- ~~~~~~~~~~~~~~~~~~~~~~~~
--
-- merge uses different notation than the proofs. We use l1, r1, l2
-- and r2 to denote the respective subtrees and l1-rank, r1-rank,
-- l2-rank and r2-rank to denote their ranks. We use h1 and h2 to
-- denote heaps.
merge : {l r : Rank} → Heap l → Heap r → Heap (l + r)
merge empty h2 = h2 -- See [merge, proof 0a]
merge {suc l} {zero} h1 empty
= subst Heap (sym (+0 (suc l))) h1 -- See [merge, proof 0b]
merge {suc .(l1-rank + r1-rank)} {suc .(l2-rank + r2-rank)}
(node {l1-rank} {r1-rank} p1 l1≥r1 l1 r1)
(node {l2-rank} {r2-rank} p2 l2≥r2 l2 r2)
with p1 < p2
merge {suc .(l1-rank + r1-rank)} {suc .(l2-rank + r2-rank)}
(node {l1-rank} {r1-rank} p1 l1≥r1 l1 r1)
(node {l2-rank} {r2-rank} p2 l2≥r2 l2 r2)
| true
= subst Heap
(proof-1 l1-rank r1-rank l2-rank r2-rank) -- See [merge, proof 1]
(makeT p1 l1 (merge r1 (node p2 l2≥r2 l2 r2)))
merge {suc .(l1-rank + r1-rank)} {suc .(l2-rank + r2-rank)}
(node {l1-rank} {r1-rank} p1 l1≥r1 l1 r1)
(node {l2-rank} {r2-rank} p2 l2≥r2 l2 r2)
| false
= subst Heap
(proof-2 l1-rank r1-rank l2-rank r2-rank) -- See [merge, proof 2]
(makeT p2 l2 (merge r2 (node p1 l1≥r1 l1 r1)))
-- We require that inserting an element into the heap increases its
-- size by one. As previously we define insert as merge and a
-- singleton heap. Size of singleton heap is (suc zero), while already
-- existing heap has size n. According to definition of merge the
-- resulting heap will therefore have size:
--
-- (suc zero) + n
--
-- By definition of + this can be normalized to:
--
-- suc (zero + n)
--
-- and finally to
--
-- suc n
--
-- Which is size we require in the type signature. This means we don't
-- need any additional proof because expected result follows from
-- definitions.
insert : {n : Rank} → Priority → Heap n → Heap (suc n)
insert p h = merge (singleton p) h
-- By indexing heap with its size we can finally have means to ensure
-- that heap passed to findMin or deleteMin is not empty.
findMin : {n : Rank} → Heap (suc n) → Priority
findMin (node p _ _ _) = p
deleteMin : {n : Rank} → Heap (suc n) → Heap n
deleteMin (node _ _ l r) = merge l r
| {
"alphanum_fraction": 0.5716985246,
"avg_line_length": 35.189258312,
"ext": "agda",
"hexsha": "b2a56f9842005c87c9fad7bf833ddb46cc634d5b",
"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": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps",
"max_forks_repo_path": "src/TwoPassMerge/RankProof.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"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": "jstolarek/dep-typed-wbl-heaps",
"max_issues_repo_path": "src/TwoPassMerge/RankProof.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps",
"max_stars_repo_path": "src/TwoPassMerge/RankProof.agda",
"max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z",
"num_tokens": 4418,
"size": 13759
} |
------------------------------------------------------------------------
-- M-types
------------------------------------------------------------------------
{-# OPTIONS --without-K --sized-types #-}
open import Equality
module M
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Bijection eq as Bijection using (_↔_)
open Derived-definitions-and-properties eq
import Equivalence eq as Eq
open import Function-universe eq hiding (_∘_)
open import Function-universe.Size eq
open import H-level eq
open import H-level.Closure eq
open import Prelude
open import Prelude.Size
------------------------------------------------------------------------
-- M-types
mutual
data M {a b} (A : Type a) (B : A → Type b) (i : Size) :
Type (a ⊔ b) where
dns : (x : A) (f : B x → M′ A B i) → M A B i
record M′ {a b} (A : Type a) (B : A → Type b) (i : Size) :
Type (a ⊔ b) where
coinductive
field
force : {j : Size< i} → M A B j
open M′ public
-- Projections.
pɐǝɥ : ∀ {a b i} {A : Type a} {B : A → Type b} →
M A B i → A
pɐǝɥ (dns x f) = x
lıɐʇ : ∀ {a b i} {j : Size< i} {A : Type a} {B : A → Type b} →
(x : M A B i) → B (pɐǝɥ x) → M A B j
lıɐʇ (dns x f) y = force (f y)
------------------------------------------------------------------------
-- Equality
-- M-types are isomorphic to Σ-types containing M-types (almost).
M-unfolding : ∀ {a b} {i} {A : Type a} {B : A → Type b} →
M A B i ↔ ∃ λ (x : A) → B x → M′ A B i
M-unfolding = record
{ surjection = record
{ logical-equivalence = record
{ to = λ { (dns x f) → x , f }
; from = uncurry dns
}
; right-inverse-of = refl
}
; left-inverse-of = λ { (dns x f) → refl (dns x f) }
}
abstract
-- Equality between elements of an M-type can be proved using a pair
-- of equalities (assuming extensionality and a kind of η law).
--
-- Note that, because the equality type former is not sized, this
-- lemma is perhaps not very useful.
M-≡,≡↔≡ :
∀ {a b i} {A : Type a} {B : A → Type b} →
Extensionality b (a ⊔ b) →
(∀ {x} {f g : B x → M′ A B i} →
_≡_ {A = B x → {j : Size< i} → M A B j}
(force ∘ f) (force ∘ g) ↔
f ≡ g) →
∀ {x y} {f : B x → M′ A B i} {g : B y → M′ A B i} →
(∃ λ (p : x ≡ y) → ∀ b {j : Size< i} →
force (f b) {j = j} ≡ force (g (subst B p b))) ↔
_≡_ {A = M A B i} (dns x f) (dns y g)
M-≡,≡↔≡ {a} {i = i} {A} {B} ext η {x} {y} {f} {g} =
(∃ λ (p : x ≡ y) → ∀ b {j : Size< i} →
force (f b) {j = j} ≡ force (g (subst B p b))) ↝⟨ ∃-cong lemma ⟩
(∃ λ (p : x ≡ y) → subst (λ x → B x → M′ A B i) p f ≡ g) ↝⟨ Bijection.Σ-≡,≡↔≡ ⟩
(_≡_ {A = ∃ λ (x : A) → B x → M′ A B i} (x , f) (y , g)) ↔⟨ Eq.≃-≡ (Eq.↔⇒≃ M-unfolding) ⟩□
(dns x f ≡ dns y g) □
where
lemma : (p : x ≡ y) →
((b : B x) {j : Size< i} →
f b .force {j = j} ≡ g (subst B p b) .force) ↔
(subst (λ x → B x → M′ A B i) p f ≡ g)
lemma p = elim
(λ {x y} p → (f : B x → M′ A B i) (g : B y → M′ A B i) →
(∀ b {j : Size< i} → f b .force {j = j} ≡
g (subst B p b) .force) ↔
(subst (λ x → B x → M′ A B i) p f ≡ g))
(λ x f g →
(∀ b {j : Size< i} → f b .force {j = j} ≡
g (subst B (refl x) b) .force) ↝⟨ subst (λ h → (∀ b {j : Size< i} → f b .force ≡ g (h b) .force) ↔
(∀ b {j : Size< i} → f b .force ≡ g b .force))
(sym (apply-ext (lower-extensionality lzero a ext)
(subst-refl B)))
Bijection.id ⟩
(∀ b {j : Size< i} → f b .force {j = j} ≡ g b .force) ↔⟨ ∀-cong ext (λ _ → implicit-Π-size-≃-Π-size) ⟩
(∀ b (j : Size< i) → f b .force {j = j} ≡ g b .force) ↔⟨ ∀-cong ext (λ _ → Π-size-≃) ⟩
(∀ b (j : Size< i in-type) → f b .force {j = size j} ≡
g b .force {j = size j}) ↔⟨ ∀-cong ext (λ _ → Eq.extensionality-isomorphism
(lower-extensionality _ lzero ext)) ⟩
((b : B x) → _≡_ {A = (j : Size< i in-type) → M A B (size j)}
(λ j → f b .force {j = size j})
(λ j → g b .force {j = size j})) ↔⟨ ∀-cong ext (λ _ → Eq.≃-≡ $ Eq.↔⇒≃ Bijection.implicit-Π↔Π) ⟩
((b : B x) → _≡_ {A = {j : Size< i in-type} → M A B (size j)}
(λ {j} → f b .force {j = size j})
(λ {j} → g b .force {j = size j})) ↔⟨ ∀-cong ext (λ _ → Eq.≃-≡ implicit-Π-size-≃) ⟩
((b : B x) → _≡_ {A = {j : Size< i} → M A B j}
(λ { {j} → f b .force {j = j} })
(λ { {j} → g b .force {j = j} })) ↔⟨ Eq.extensionality-isomorphism ext ⟩
(force ∘ f ≡ force ∘ g) ↝⟨ η ⟩
(f ≡ g) ↝⟨ subst (λ h → (f ≡ g) ↔ (h ≡ g))
(sym $ subst-refl (λ x' → B x' → M′ A B i) f)
Bijection.id ⟩□
(subst (λ x → B x → M′ A B i) (refl x) f ≡ g) □)
p f g
------------------------------------------------------------------------
-- Bisimilarity and bisimilarity for bisimilarity
-- Bisimilarity.
mutual
infix 4 [_]_≡M_ [_]_≡M′_
data [_]_≡M_ {a b} {A : Type a} {B : A → Type b}
(i : Size) (x y : M A B ∞) : Type (a ⊔ b) where
dns : (p : pɐǝɥ x ≡ pɐǝɥ y) →
(∀ b → [ i ] lıɐʇ x b ≡M′ lıɐʇ y (subst B p b)) →
[ i ] x ≡M y
record [_]_≡M′_ {a b} {A : Type a} {B : A → Type b}
(i : Size) (x y : M A B ∞) : Type (a ⊔ b) where
coinductive
field
force : {j : Size< i} → [ j ] x ≡M y
open [_]_≡M′_ public
-- Projections.
pɐǝɥ≡ :
∀ {a b i} {A : Type a} {B : A → Type b} {x y : M A B ∞} →
[ i ] x ≡M y → pɐǝɥ x ≡ pɐǝɥ y
pɐǝɥ≡ (dns p q) = p
lıɐʇ≡ :
∀ {a b i} {A : Type a} {B : A → Type b} {x y : M A B ∞} →
(p : [ i ] x ≡M y) →
∀ b {j : Size< i} → [ j ] lıɐʇ x b ≡M lıɐʇ y (subst B (pɐǝɥ≡ p) b)
lıɐʇ≡ (dns p q) y = force (q y)
-- Equality implies bisimilarity.
≡⇒≡M : ∀ {a b i} {A : Type a} {B : A → Type b} {x y : M A B ∞} →
x ≡ y → [ i ] x ≡M y
≡⇒≡M {i = i} {B = B} {dns x f} {dns y g} p =
dns (proj₁ q) helper
where
q = elim (λ {m m′} m≡m′ →
∃ λ (x≡y : pɐǝɥ m ≡ pɐǝɥ m′) →
∀ b → lıɐʇ m b ≡ lıɐʇ m′ (subst B x≡y b))
(λ m → refl (pɐǝɥ m) , λ b →
lıɐʇ m b ≡⟨ cong (lıɐʇ m) (sym $ subst-refl B _) ⟩∎
lıɐʇ m (subst B (refl (pɐǝɥ m)) b) ∎)
p
helper :
∀ b →
[ i ] lıɐʇ (dns x f) b ≡M′ lıɐʇ (dns y g) (subst B (proj₁ q) b)
force (helper b) = ≡⇒≡M (proj₂ q b)
-- Bisimilarity for the bisimilarity type.
mutual
data [_]_≡≡M_ {a b} {A : Type a} {B : A → Type b} {x y : M A B ∞}
(i : Size) (p q : [ ∞ ] x ≡M y) : Type (a ⊔ b) where
dns : (r : pɐǝɥ≡ p ≡ pɐǝɥ≡ q) →
(∀ b → [ i ] lıɐʇ≡ p b ≡≡M′
subst (λ p → [ ∞ ] lıɐʇ x b ≡M
lıɐʇ y (subst B p b))
(sym r)
(lıɐʇ≡ q b)) →
[ i ] p ≡≡M q
record [_]_≡≡M′_ {a b} {A : Type a} {B : A → Type b} {x y : M A B ∞}
(i : Size) (p q : [ ∞ ] x ≡M y) : Type (a ⊔ b) where
coinductive
field
force : {j : Size< i} → [ j ] p ≡≡M q
open [_]_≡≡M′_ public
------------------------------------------------------------------------
-- Closure under various h-levels
abstract
-- If we assume a notion of extensionality (bisimilarity implies
-- equality) then Contractible is closed under M.
M-closure-contractible :
∀ {a b} {A : Type a} {B : A → Type b} →
({x y : M A B ∞} → [ ∞ ] x ≡M y → x ≡ y) →
Contractible A → Contractible (M A B ∞)
M-closure-contractible {A = A} {B} ext (z , irrA) = (x , ext ∘ irr)
where
x : ∀ {i} → M A B i
x = dns z λ _ → λ { .force → x }
irr : ∀ {i} y → [ i ] x ≡M y
irr {i} (dns x′ f) = dns (irrA x′) helper
where
helper : ∀ y → [ i ] x ≡M′ force (f (subst B (irrA x′) y))
force (helper _) = irr _
-- The same applies to Is-proposition.
M-closure-propositional :
∀ {a b} {A : Type a} {B : A → Type b} →
({x y : M A B ∞} → [ ∞ ] x ≡M y → x ≡ y) →
Is-proposition A → Is-proposition (M A B ∞)
M-closure-propositional {A = A} {B} ext p =
λ x y → ext $ irrelevant x y
where
irrelevant : ∀ {i} (x y : M A B ∞) → [ i ] x ≡M y
irrelevant {i} (dns x f) (dns y g) = dns (p x y) helper
where
helper :
(y′ : B x) →
[ i ] force (f y′) ≡M′ force (g (subst B (p x y) y′))
force (helper _) = irrelevant _ _
-- If we assume that we have another notion of extensionality, then
-- Is-set is closed under M.
M-closure-set :
∀ {a b} {A : Type a} {B : A → Type b} →
({x y : M A B ∞} {p q : x ≡ y} → [ ∞ ] ≡⇒≡M p ≡≡M ≡⇒≡M q → p ≡ q) →
Is-set A → Is-set (M A B ∞)
M-closure-set {A = A} {B} ext s =
λ p q → ext $ uip (≡⇒≡M p) (≡⇒≡M q)
where
uip : ∀ {i} {x y : M A B ∞} (p q : [ ∞ ] x ≡M y) → [ i ] p ≡≡M q
uip {i} {x} {y} (dns p f) (dns q g) = dns (s p q) helper
where
helper :
(b : B (pɐǝɥ x)) →
[ i ] force (f b) ≡≡M′
subst (λ eq → [ ∞ ] lıɐʇ x b ≡M lıɐʇ y (subst B eq b))
(sym (s p q))
(force (g b))
force (helper _) = uip _ _
| {
"alphanum_fraction": 0.3800157356,
"avg_line_length": 36.9745454545,
"ext": "agda",
"hexsha": "189b4fb2aeabf0ad7fcda56f7107fe1841b0f6a6",
"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/M.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/M.agda",
"max_line_length": 139,
"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/M.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": 3936,
"size": 10168
} |
module Sane where
import Data.Fin as F
--
-- open import Data.Empty
open import Data.Unit
-- open import Data.Unit.Core
open import Data.Nat using (ℕ ; zero ; suc ; _+_ ; _>_ )
open import Data.Sum using (inj₁ ; inj₂ )
-- open import Data.Product renaming (map to _×→_)
open import Data.Vec
open import Function using ( id ) renaming (_∘_ to _○_)
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; cong ; module ≡-Reasoning )
open ≡-Reasoning
-- start re-splitting things up, as this is getting out of hand
open import FT -- Finite Types
open import VecHelpers
open import NatSimple
open import Eval
-- not sure where else to put this [Z][A]
hetType : {A B : Set} → (a : A) → A ≡ B → B
hetType a refl = a
-- construct a combinator which represents the swapping of the i-th and
-- (i+1)-th 'bit' of a finite type.
-- Best to think of this as an 'elementary permutation', in the same way
-- we have 'elementary matrices' (which turn out to be permutations when they
-- are unitary).
swapi : {n : ℕ} → F.Fin n → (fromℕ (suc n)) ⇛ (fromℕ (suc n))
swapi {zero} ()
swapi {suc n} F.zero = assocl₊⇛ ◎ swap₊⇛ ⊕ id⇛ ◎ assocr₊⇛
swapi {suc n} (F.suc i) = id⇛ ⊕ swapi {n} i
-- swapUpTo i permutes the combinator left by one up to i
-- if possible values are X a b c Y d e, swapUpTo 3's possible outputs
-- are a b c X Y d e
swapUpTo : {n : ℕ} → F.Fin n → (fromℕ (suc n)) ⇛ (fromℕ (suc n))
swapUpTo F.zero = id⇛
swapUpTo (F.suc i) = (id⇛ ⊕ swapUpTo i) ◎ swapi F.zero
-- swapDownFrom i permutes the combinator right by one up to i (the reverse
-- of swapUpTo)
swapDownFrom : {n : ℕ} → F.Fin n → (fromℕ (suc n)) ⇛ (fromℕ (suc n))
swapDownFrom F.zero = id⇛
swapDownFrom (F.suc i) = swapi F.zero ◎ (id⇛ ⊕ swapDownFrom i)
-- TODO: verify that this is actually correct
-- Idea: To swap n < m with each other, swap n, n + 1, ... , m - 1, m, then
-- go back down, so that m and n are swapped and everything else is in the
-- same spot
-- makeSingleComb {combinator size} (arrayElement) (arrayIndex),
-- gives a combinator which 'does' that, assuming i<j, else id⇛
makeSingleComb : {n : ℕ} → F.Fin n → F.Fin n → (fromℕ n) ⇛ (fromℕ n)
makeSingleComb F.zero F.zero = id⇛
makeSingleComb F.zero (F.suc i) = id⇛
makeSingleComb (F.suc j) F.zero = swapDownFrom j ◎ swapi j ◎ swapUpTo j
makeSingleComb (F.suc j) (F.suc i) = id⇛ ⊕ makeSingleComb j i
-- swapm i returns a combinator that swaps 0 and i
swapm : {n : ℕ} → F.Fin n → (fromℕ n) ⇛ (fromℕ n)
swapm F.zero = id⇛
swapm (F.suc i) = swapUpTo i ◎ swapi i ◎ swapDownFrom i
-- Correctness: after putting together i indices, the partial combinator c' is
-- represented by the vector [1, 2, ... , n - (i +1)] ++ (last i v)
--
-- Might want to bake in the correctness proof here---have the output be a
-- combinator c, a vector v, and a proof that vecRep c v, then we just prove
-- that the vector at the end is just the vector from the beginning
--
-- Or just put them together and prove that they're related by vecRep with
-- foldrWorks and that the end vector is the input vector; this is probably simpler
-- (and is the approach currently reflected in the code below)
-- swapInd i j returns a vector v′ where v′[i] = j, v′[j] = i, and v′[k] = k
-- where k != j and k != i
zeroIfEq : {n n′ : ℕ} → F.Fin n → F.Fin n → F.Fin (suc n′) → F.Fin (suc n′)
zeroIfEq F.zero F.zero ret = F.zero
zeroIfEq F.zero (F.suc j) ret = ret
zeroIfEq (F.suc i) F.zero ret = ret
zeroIfEq (F.suc i) (F.suc j) ret = zeroIfEq i j ret
swapIndFn : {n : ℕ} → F.Fin n → F.Fin n → (F.Fin n → F.Fin n)
swapIndFn F.zero j F.zero = j
swapIndFn (F.suc i) F.zero F.zero = F.suc i
swapIndFn (F.suc i) (F.suc j) F.zero = F.zero
swapIndFn F.zero F.zero (F.suc x) = F.suc x
swapIndFn {suc zero} F.zero (F.suc ()) (F.suc x)
swapIndFn {suc (suc n)} F.zero (F.suc j) (F.suc x) = zeroIfEq j x (F.suc x)
swapIndFn (F.suc i) F.zero (F.suc x) = zeroIfEq i x (F.suc x)
swapIndFn (F.suc i) (F.suc j) (F.suc x) = F.suc (swapIndFn i j x)
swapInd : {n : ℕ} → F.Fin n → F.Fin n → Vec (F.Fin n) n
swapInd i j = tabulate (swapIndFn i j)
swapIndVec : {n : ℕ} → F.Fin n → F.Fin n → Vec (F.Fin n) n → Vec (F.Fin n) n
swapIndVec i j v = tabulate (λ k → v !! swapIndFn i j k)
-- useful abbreviations
2+ : ℕ → ℕ
2+ n = suc (suc n)
3+ : ℕ → ℕ
3+ n = suc (2+ n)
F2+ : {n : ℕ} → F.Fin n → F.Fin (2+ n)
F2+ i = F.suc (F.suc i)
F3+ : {n : ℕ} → F.Fin n → F.Fin (3+ n)
F3+ i = F.suc (F2+ i)
swap01 : {n : ℕ} → Vec (F.Fin (2+ n)) (2+ n)
swap01 = F.suc F.zero ∷ F.zero ∷ tabulate F2+
swapIndIdAfterOne : {n : ℕ} → (i : F.Fin n) →
(F2+ i) ≡ swapIndFn F.zero (F.suc F.zero) (F2+ i)
swapIndIdAfterOne i = refl -- yesss finally it just works!
swapIndSucDist : {n : ℕ} → (i j x : F.Fin n) →
(F.suc (swapIndFn i j x)) ≡
(swapIndFn (F.suc i) (F.suc j) (F.suc x))
swapIndSucDist i j x = refl
-- more useful abbreviations
F1+swap : {n : ℕ} → (i : F.Fin n) → Vec (F.Fin (2+ n)) (suc n)
F1+swap i = vmap F.suc (swapInd (F.inject₁ i) (F.suc i))
swapIndFn+ : {n : ℕ} → (i : F.Fin n) → F.Fin (suc n) → F.Fin (suc n)
swapIndFn+ i = swapIndFn (F.inject₁ i) (F.suc i)
swapInd++ : {n : ℕ} → (i : F.Fin n) → Vec (F.Fin (2+ n)) (2+ n)
swapInd++ i = swapInd (F.inject₁ (F.suc i)) (F2+ i)
swap≡ind₁ : {n : ℕ} → (i : F.Fin n) → F.zero ∷ F1+swap i ≡ swapInd++ i
swap≡ind₁ {n} i = begin
F.zero ∷ F1+swap i
≡⟨ cong (_∷_ F.zero)
(begin
F1+swap i
≡⟨ mapTab F.suc (swapIndFn+ i) ⟩
tabulate (F.suc ○ swapIndFn+ i)
≡⟨ tabf∼g _ _ (swapIndSucDist (F.inject₁ i) (F.suc i)) ⟩
(tabulate (swapIndFn+ (F.suc i) ○ F.suc)
∎)) ⟩
swapInd++ i ∎
-- vecRep c v relates a combinator c over normal types to the output
-- vector it results in. This works only over a subset of combinators
-- used in decompilation.
data vecRep : {n : ℕ} → (fromℕ n) ⇛ (fromℕ n) → Vec (F.Fin n) n → Set where
vr-id : {n : ℕ} → vecRep (id⇛ {fromℕ n}) (upTo n)
vr-swap : {n : ℕ} → vecRep {suc (suc n)} (swapi {suc n} F.zero) swap01
vr-comp : {n : ℕ} {c₁ c₂ : (fromℕ n) ⇛ (fromℕ n)} {v₁ v₂ : Vec (F.Fin n) n} →
vecRep c₁ v₁ → vecRep c₂ v₂ →
vecRep (c₁ ◎ c₂) (v₁ ∘̬ v₂)
vr-plus : {n : ℕ} → {c : (fromℕ n) ⇛ (fromℕ n)} → {v : Vec (F.Fin n) n} →
vecRep {n} c v →
vecRep {suc n} (id⇛ ⊕ c) (F.zero ∷ (vmap F.suc v))
-- Record for keeping a combinator, a vector, and a proof that they compute
-- the same function.
record Compiled (n : ℕ) : Set where
constructor
_►_⟨_⟩
field
comb : (fromℕ n) ⇛ (fromℕ n)
vec : Vec (F.Fin n) n
proof : vecRep comb vec
-- TODO: there might be a better vector to put in the vecRep here
-- we'll need to see what's most amenable to proving swapUpToWorks
swapiWorks : {n : ℕ} → (i : F.Fin n) → vecRep (swapi i) (swapInd (F.inject₁ i) (F.suc i))
swapiWorks {zero} ()
swapiWorks {suc n} F.zero = vr-swap
swapiWorks {suc n} (F.suc i) =
hetType (vr-plus (swapiWorks i)) (cong (vecRep (id⇛ ⊕ swapi i)) (swap≡ind₁ i))
-- permutations on vectors for specifying swapUpTo/DownFrom
data _<F_ : {n : ℕ} → F.Fin n → F.Fin n → Set where
zero-leq : {n : ℕ} → {i : F.Fin n} → F.zero <F (F.suc i)
suc-leq : {n : ℕ} → {i j : F.Fin n} → i <F j → (F.suc i) <F (F.suc j)
<suc : {n : ℕ} → (i j : F.Fin n) → (F.suc i) <F (F.suc j) → i <F j
<suc i j (suc-leq p) = p
dec<F : {n : ℕ} → (i j : F.Fin n) → Dec (i <F j)
dec<F F.zero F.zero = no (λ ())
dec<F F.zero (F.suc j) = yes zero-leq
dec<F (F.suc i) F.zero = no (λ ())
dec<F (F.suc i) (F.suc j) with dec<F i j
dec<F (F.suc i) (F.suc j) | yes x = yes (suc-leq x)
dec<F (F.suc i) (F.suc j) | no x = no (λ p → x (<suc i j p))
-- swap args of F.inject+
inj+ : {m n : ℕ} → F.Fin m → F.Fin (n + m)
inj+ {m} {n} i = hetType (F.inject+ n i) (cong F.Fin (+-comm m n))
-- the library definition of + on Fin isn't what we want here, ugh
_+F_ : {m n : ℕ} → F.Fin (suc m) → F.Fin n → F.Fin (m + n)
_+F_ {m} {zero} F.zero ()
_+F_ {m} {suc n} F.zero j = inj+ {suc n} {m} j
_+F_ {zero} {n} (F.suc ()) _
_+F_ {suc m} {n} (F.suc i) j = F.suc (i +F j)
data _h≡_ {A : Set} : {B : Set} → A → B → Set₁ where
hrefl : (x : A) → _h≡_ {A} {A} x x
hetTypeIsID : {A B : Set} → (x : A) → (p : A ≡ B) → (hetType x p) h≡ x
hetTypeIsID x refl = hrefl x
-- Permute the first i elements of v to the right one (and i^th down to 0)
-- Should correspond with swapDownFrom
-- permuteRight : {n : ℕ} → (i : F.Fin n) → Vec (F.Fin n) n → Vec (F.Fin n) n
-- permuteRight i v = tabulate (permRightFn v i)
permuteRight : {n : ℕ} → (i : F.Fin n) → Vec (F.Fin n) n
permuteRight {zero} ()
permuteRight {suc n} F.zero = upTo _
permuteRight {suc zero} (F.suc ())
permuteRight {suc (suc n)} (F.suc i) =
F.suc (head (permuteRight i)) ∷ F.zero ∷ vmap F.suc (tail (permuteRight i))
-- redundant helper
permRightID : {n : ℕ} → F.Fin n → Vec (F.Fin n) n
permRightID i = permuteRight i
-- The opposite of permuteRight; should correspond with swapUpTo
pl′ : {m : ℕ} {A : Set} → F.Fin m → Vec A m → A → Vec A (suc m)
pl′ {m = zero} () _ _
pl′ {m = suc m} F.zero (x ∷ xs) first = x ∷ first ∷ xs
pl′ (F.suc i) (x ∷ xs) first = x ∷ (pl′ i xs first)
permuteLeft : {n : ℕ} {A : Set} → (i : F.Fin n) → Vec A n → Vec A n
permuteLeft {zero} () _
permuteLeft {suc n} F.zero v = v
permuteLeft {suc zero} (F.suc ()) _
permuteLeft {suc (suc n)} (F.suc i) (a ∷ b ∷ rest) = pl′ i (b ∷ rest) a
permLeftID : {n : ℕ} → F.Fin n → Vec (F.Fin n) n
permLeftID i = permuteLeft i (upTo _)
permLeftId₀ : {n : ℕ} → (upTo (suc n)) ≡ permuteLeft F.zero (upTo (suc n))
permLeftId₀ {n} = refl
permLeftIdPasti : {n : ℕ} → (v : Vec (F.Fin (2+ n)) (2+ n)) →
(i : F.Fin n) →
permuteLeft (F.suc F.zero) v !! (F2+ i) ≡ v !! F2+ i
permLeftIdPasti (x ∷ x₁ ∷ x₂ ∷ v) F.zero = refl
permLeftIdPasti (x ∷ x₁ ∷ x₂ ∷ v) (F.suc i) = refl
-- it should actually be possible to recur on this!
-- and as an added bonus, it should actually be true! [Z]
plCorr : {m n : ℕ} (v : Vec (F.Fin m) n) (i : F.Fin n) →
vmap F.suc (pl′ i (vmap F.suc v) F.zero) ∘̬′ swap01 ≡
pl′ i (vmap F.suc (vmap F.suc v)) F.zero
plCorr [] ()
plCorr (x ∷ v) F.zero =
begin
vmap F.suc (pl′ F.zero (vmap F.suc (x ∷ v)) F.zero) ∘̬′ swap01
≡⟨ refl ⟩
(F.suc (F.suc x) ∷ F.suc F.zero ∷ vmap F.suc (vmap F.suc v)) ∘̬′ swap01
≡⟨ refl ⟩
((tabulate (F.suc ○ F.suc)) !! x) ∷ (F.suc F.zero ∷ vmap F.suc (vmap F.suc v)) ∘̬′ swap01
≡⟨ cong (λ x → x ∷ (F.suc F.zero ∷ vmap F.suc (vmap F.suc v)) ∘̬′ swap01)
(lookupTab x) ⟩
(F.suc (F.suc x)) ∷ ((F.suc F.zero ∷ vmap F.suc (vmap F.suc v)) ∘̬′ swap01)
≡⟨ refl ⟩
(F.suc (F.suc x)) ∷ F.zero ∷ ((vmap F.suc (vmap F.suc v)) ∘̬′ swap01)
≡⟨ cong (λ q → F.suc (F.suc x) ∷ F.zero ∷ q) (map2+id v) ⟩
F.suc (F.suc x) ∷ F.zero ∷ vmap F.suc (vmap F.suc v)
≡⟨ refl ⟩
pl′ F.zero (vmap F.suc (vmap F.suc (x ∷ v))) F.zero ∎
plCorr (x ∷ v) (F.suc i) =
begin
vmap F.suc (pl′ (F.suc i) (vmap F.suc (x ∷ v)) F.zero) ∘̬′ swap01
≡⟨ refl ⟩
(tabulate (F.suc ○ F.suc) !! x) ∷
((vmap F.suc (pl′ i (vmap F.suc v) F.zero)) ∘̬′ swap01)
≡⟨ cong (λ q → q ∷ ((vmap F.suc (pl′ i (vmap F.suc v) F.zero)) ∘̬′ swap01))
(lookupTab x) ⟩
F.suc (F.suc x) ∷
((vmap F.suc (pl′ i (vmap F.suc v) F.zero)) ∘̬′ swap01)
≡⟨ cong (_∷_ (F.suc (F.suc x))) (plCorr v i) ⟩
F.suc (F.suc x) ∷ pl′ i (vmap F.suc (vmap F.suc v)) F.zero
≡⟨ refl ⟩
pl′ (F.suc i) (vmap F.suc (vmap F.suc (x ∷ v))) F.zero ∎
fzero : F.Fin 7
fzero = F.zero
fone : F.Fin 7
fone = F.suc F.zero
ftwo : F.Fin 7
ftwo = F.suc (F.suc F.zero)
fthree : F.Fin 7
fthree = F.suc (F.suc (F.suc F.zero))
ffour : F.Fin 7
ffour = F.suc (F.suc (F.suc (F.suc F.zero)))
ffive : F.Fin 7
ffive = F.suc (F.suc (F.suc (F.suc (F.suc F.zero))))
fsix : F.Fin 7
fsix = F.suc (F.suc (F.suc (F.suc (F.suc (F.suc F.zero)))))
--
gzero : F.Fin 6
gzero = F.zero
gone : F.Fin 6
gone = F.suc F.zero
gtwo : F.Fin 6
gtwo = F.suc (F.suc F.zero)
gthree : F.Fin 6
gthree = F.suc (F.suc (F.suc F.zero))
gfour : F.Fin 6
gfour = F.suc (F.suc (F.suc (F.suc F.zero)))
gfive : F.Fin 6
gfive = F.suc (F.suc (F.suc (F.suc (F.suc F.zero))))
-- i=3
-- n=5
test1 : Vec (F.Fin 7) 7
test1 = permuteLeft
ffour
(fzero ∷ fone ∷ ftwo ∷ fthree ∷ ffour ∷ ffive ∷ fsix ∷ [])
{--
test1 = (0 1)
(1 2)
(2 3)
(3 4)
(4 0)
(5 5)
(6 6)
--}
test2 : Vec (F.Fin 6) 6
test2 = permuteLeft
gthree
(gzero ∷ gone ∷ gtwo ∷ gthree ∷ gfour ∷ gfive ∷ [])
{--
test2 = (0 1)
(1 2)
(2 3)
(3 0)
(4 4)
(5 5)
vmap F.suc test2 =
(0 2)
(1 3)
(2 4)
(3 1)
(4 5)
(5 6)
F.zero ∷ vmap F.suc test2 =
(0 0)
(1 2)
(2 3)
(3 4)
(4 1)
(5 5)
(6 6)
swap01 =
(0 1)
(1 0)
(2 2)
(3 3)
(4 4)
(5 5)
(6 6)
(F.zero ∷ vmap F.suc test2) ∘̬ swap01 =
(0 1)
(1 2)
(2 3)
(3 4)
(4 0)
(5 5)
(6 6)
test1 = (0 1)
(1 2)
(2 3)
(3 4)
(4 0)
(5 5)
(6 6)
--}
-- glue lemma between plCorr and swapUpToWorks to deal with the difference between
-- the result type of swapUpToWorks and the result type of the VecRep combinators
-- We need this glue here to get from swapUpToWorks (which has two calls to permuteLeft)
-- to plCorr (which has two calls to pl′), since permuteLeft is a wrapper around pl′.
-- Once we've removed the wrapper, we can eat the delicious candy^W^W^W^Wactually do
-- induction; hopefully the type of plCorr is general enough for this but not too general
-- to, er, be true. [Z]
sucWorks : {n : ℕ} → (i : F.Fin n) →
(F.zero ∷ vmap F.suc (permuteLeft (F.inject₁ i) (upTo (suc n))))
∘̬ swap01
≡ pl′ {suc n} (F.inject₁ i) (tail (upTo (suc (suc n)))) F.zero
sucWorks {suc n} F.zero =
begin
(F.zero ∷ vmap F.suc (permuteLeft F.zero (upTo (suc (suc n)))))
∘̬ swap01
≡⟨ cong (λ x → (F.zero ∷ vmap F.suc x) ∘̬ swap01)
(sym (permLeftId₀)) ⟩
(F.zero ∷ vmap F.suc (upTo (suc (suc n))))
∘̬ swap01
≡⟨ cong (λ x → (F.zero ∷ x) ∘̬ swap01) ((mapTab F.suc id)) ⟩
upTo (suc (suc (suc n))) ∘̬ swap01
≡⟨ ∘̬simpleid swap01 ⟩
swap01
≡⟨ refl ⟩
pl′ F.zero (tail (upTo (suc (suc (suc n))))) F.zero ∎
sucWorks {suc zero} (F.suc ())
sucWorks {suc (suc n)} (F.suc i) =
begin
(F.zero ∷ vmap F.suc (permuteLeft (F.inject₁ (F.suc i)) (upTo (suc (suc (suc n))))))
∘̬ swap01
≡⟨ ∘̬≡∘̬′
(F.zero ∷
vmap F.suc
(permuteLeft (F.inject₁ (F.suc i)) (upTo (suc (suc (suc n))))))
swap01 ⟩
(F.zero ∷ vmap F.suc (permuteLeft (F.inject₁ (F.suc i)) (upTo (suc (suc (suc n))))))
∘̬′ swap01
≡⟨ refl ⟩
(F.zero ∷ vmap F.suc (pl′ (F.inject₁ i) (tail (upTo (suc (suc (suc n))))) F.zero))
∘̬′ swap01
≡⟨ refl ⟩
(F.suc F.zero) ∷
((vmap F.suc (pl′ (F.inject₁ i) (tabulate F.suc) F.zero))
∘̬′ swap01)
≡⟨ cong
(λ q →
F.suc F.zero ∷ vmap F.suc (pl′ (F.inject₁ i) q F.zero) ∘̬′ swap01)
(sym (mapTab F.suc id)) ⟩
(F.suc F.zero) ∷
((vmap F.suc (pl′ (F.inject₁ i) (vmap F.suc (tabulate id)) F.zero))
∘̬′ swap01)
≡⟨ cong (_∷_ (F.suc F.zero)) (plCorr (tabulate id) (F.inject₁ i)) ⟩
(F.suc F.zero) ∷
(pl′ (F.inject₁ i) (vmap F.suc (vmap F.suc (tabulate id))) F.zero)
≡⟨ cong (λ q → F.suc F.zero ∷ pl′ (F.inject₁ i) (vmap F.suc q) F.zero)
(mapTab F.suc id) ⟩
(F.suc F.zero) ∷ pl′ (F.inject₁ i) (vmap F.suc (tail (upTo (suc (suc (suc n)))))) F.zero
≡⟨ cong (λ x → (F.suc F.zero) ∷ pl′ (F.inject₁ i) x F.zero)
(sym (upToTail (suc (suc n)))) ⟩
F.suc F.zero ∷ pl′ (F.inject₁ i) (tail (tail (upTo (suc (suc (suc (suc n))))))) F.zero
≡⟨ refl ⟩
pl′ (F.inject₁ (F.suc i)) (tail (upTo (suc (suc (suc (suc n)))))) F.zero ∎
-- NB: I added the F.inject₁ in calls to permuteLeft/Right to get it to work
-- with swapUpTo/DownFrom; I'm not sure that this is correct? It might
-- be a sign that the type of the swap functions is too specific, instead.
-- (though now it looks like it will at least make the type of shuffle a bit nicer) [Z]
swapUpToWorks : {n : ℕ} → (i : F.Fin n) →
vecRep (swapUpTo i) (permuteLeft (F.inject₁ i) (upTo (suc n)))
swapUpToWorks F.zero = vr-id
swapUpToWorks (F.suc i) = hetType (vr-comp (vr-plus (swapUpToWorks i)) vr-swap)
(cong (vecRep (swapUpTo (F.suc i))) (sucWorks i))
sdfWorks : {n : ℕ} → (i : F.Fin (suc n)) →
swap01 ∘̬ (F.zero ∷ vmap F.suc (permuteRight i)) ≡
permuteRight (F.suc i)
sdfWorks i =
begin
swap01 ∘̬ (F.zero ∷ vmap F.suc (permuteRight i))
≡⟨ ∘̬≡∘̬′ swap01 (F.zero ∷ vmap F.suc (permuteRight i)) ⟩
swap01 ∘̬′ (F.zero ∷ vmap F.suc (permuteRight i))
≡⟨ refl ⟩
(vmap F.suc (permuteRight i) !! F.zero) ∷ F.zero ∷
(tabulate (F.suc ○ F.suc) ∘̬′ (F.zero ∷ vmap F.suc (permuteRight i)))
≡⟨ cong
(λ q →
q ∷
F.zero ∷
tabulate (F.suc ○ F.suc) ∘̬′
(F.zero ∷ vmap F.suc (permuteRight i)))
(head!!0 (vmap F.suc (permuteRight i))) ⟩
(head (vmap F.suc (permuteRight i))) ∷ F.zero ∷
(tabulate (F.suc ○ F.suc) ∘̬′ (F.zero ∷ vmap F.suc (permuteRight i)))
≡⟨ cong
(λ q →
q ∷
F.zero ∷
tabulate (F.suc ○ F.suc) ∘̬′
(F.zero ∷ vmap F.suc (permuteRight i)))
(headmap (permuteRight i)) ⟩
(F.suc (head (permuteRight i))) ∷ F.zero ∷
(tabulate (F.suc ○ F.suc) ∘̬′ (F.zero ∷ vmap F.suc (permuteRight i)))
≡⟨ cong (λ q → F.suc (head (permuteRight i)) ∷ F.zero ∷ q)
(sym
(∘̬≡∘̬′ (tabulate (F.suc ○ F.suc))
(F.zero ∷ vmap F.suc (permuteRight i)))) ⟩
(F.suc (head (permuteRight i))) ∷ F.zero ∷
(tabulate (F.suc ○ F.suc) ∘̬ (F.zero ∷ vmap F.suc (permuteRight i)))
≡⟨ cong (λ q → F.suc (head (permuteRight i)) ∷ F.zero ∷ q)
(2suc∘̬2tail (F.zero ∷ vmap F.suc (permuteRight i))) ⟩
(F.suc (head (permuteRight i))) ∷ F.zero ∷
(tail (vmap F.suc (permuteRight i)))
≡⟨ cong (λ q → F.suc (head (permuteRight i)) ∷ F.zero ∷ q)
(tailmap (permuteRight i)) ⟩
(F.suc (head (permuteRight i))) ∷ F.zero ∷ (vmap F.suc (tail (permuteRight i)))
≡⟨ refl ⟩
permuteRight (F.suc i) ∎
swapDownFromWorks : {n : ℕ} → (i : F.Fin n) →
vecRep (swapDownFrom i) (permuteRight (F.inject₁ i))
swapDownFromWorks F.zero = vr-id
swapDownFromWorks (F.suc i) =
hetType (vr-comp vr-swap (vr-plus (swapDownFromWorks i)))
(cong (vecRep (swapDownFrom (F.suc i))) (sdfWorks (F.inject₁ i)))
_◎∘̬_ : {n : ℕ} → Compiled n → Compiled n → Compiled n
(c₁ ► v₁ ⟨ p₁ ⟩) ◎∘̬ (c₂ ► v₂ ⟨ p₂ ⟩) = ((c₁ ◎ c₂) ► v₁ ∘̬ v₂ ⟨ vr-comp p₁ p₂ ⟩ )
vecToComb : {n : ℕ} → Vec (F.Fin n) n → (fromℕ n) ⇛ (fromℕ n)
vecToComb {n} vec =
foldr (λ i → fromℕ n ⇛ fromℕ n) _◎_ id⇛ (map (λ i → makeSingleComb (vec !! i) i) (upTo n))
finToVal : {n : ℕ} → F.Fin n → ⟦ fromℕ n ⟧
finToVal F.zero = inj₁ tt
finToVal (F.suc n) = inj₂ (finToVal n)
valToFin : {n : ℕ} → ⟦ fromℕ n ⟧ → F.Fin n
valToFin {zero} ()
valToFin {suc n} (inj₁ tt) = F.zero
valToFin {suc n} (inj₂ v) = F.suc (valToFin v)
finToValToFin : {n : ℕ} → (v : ⟦ fromℕ n ⟧) → finToVal (valToFin v) ≡ v
finToValToFin {zero} ()
finToValToFin {suc n} (inj₁ tt) = refl -- (inj₁ tt)
finToValToFin {suc n} (inj₂ v) = cong inj₂ (finToValToFin v)
valToFinToVal : {n : ℕ} → (i : F.Fin n) → valToFin (finToVal i) ≡ i
valToFinToVal F.zero = refl -- F.zero
valToFinToVal (F.suc i) = cong F.suc (valToFinToVal i)
combToVec : {n : ℕ} → (fromℕ n) ⇛ (fromℕ n) → Vec (F.Fin n) n
combToVec c = tabulate (valToFin ○ (evalComb c) ○ finToVal)
twoF4 : F.Fin four
twoF4 = F.suc (F.suc F.zero)
fourF5 : F.Fin five
fourF5 = F.suc (F.suc F.zero)
swapUpToTest : Vec (F.Fin five) five
swapUpToTest = combToVec (swapUpTo twoF4)
pltest : (n : ℕ) → (i : F.Fin n) → Vec (F.Fin n) n
pltest n i = permuteLeft i (upTo n)
prtest : Vec (F.Fin five) five
prtest = permuteRight fourF5 -- (F.suc (F.suc (F.suc (F.suc F.zero))))
sdftest : Vec (F.Fin five) five
sdftest = combToVec (swapDownFrom twoF4)
sucomptest : {n : ℕ} → (i : F.Fin n) → Vec (F.Fin (suc (suc n))) (suc (suc n))
sucomptest {n} i = (F.zero ∷ vmap F.suc (permuteLeft (F.inject₁ i) (upTo (suc n))))
∘̬ (F.suc F.zero ∷ F.zero ∷ vmap (F.suc ○ F.suc) (upTo n))
sit : Vec (F.Fin five) five
sit = combToVec (swapi (F.suc (F.suc F.zero)))
mntest : Vec (F.Fin five) five
mntest = combToVec (makeSingleComb (F.suc (F.suc (F.suc F.zero))) F.zero)
evalVec : {n : ℕ} → Vec (F.Fin n) n → F.Fin n → ⟦ fromℕ n ⟧
evalVec vec i = finToVal (lookup i vec)
permLeftTest : F.Fin four
permLeftTest = valToFin (evalVec (permLeftID (F.suc (F.suc F.zero))) (F.zero))
lookupToEvalVec : {n : ℕ} → (i : F.Fin n) → (v : Vec (F.Fin n) n) → lookup i v ≡ valToFin (evalVec v i)
lookupToEvalVec i v = sym (valToFinToVal (lookup i v) )
-- Might want to take a ⟦ fromℕ n ⟧ instead of a Fin n as the second
-- argument here?
combToVecWorks : {n : ℕ} → (c : (fromℕ n) ⇛ (fromℕ n)) →
(i : F.Fin n) → (evalComb c (finToVal i)) ≡ evalVec (combToVec c) i
combToVecWorks c i = (sym (finToValToFin _)) ∘ (cong finToVal (sym (lookupTab i)))
-- This lemma is the hammer that will let us use vecRep to (hopefully) simply
-- prove some lemmas about the helper functions used in vecToComb, then apply
-- vecRepWorks at the end to make sure they all "do the right thing"
vecRepWorks : {n : ℕ} → {c : (fromℕ n) ⇛ (fromℕ n)} → {v : Vec (F.Fin n) n} →
vecRep c v → (i : F.Fin n) → (evalVec v i) ≡ (evalComb c (finToVal i))
vecRepWorks vr-id i = cong finToVal (lookupTab i)
vecRepWorks vr-swap F.zero = refl -- (inj₂ (inj₁ tt))
vecRepWorks vr-swap (F.suc F.zero) = refl -- (inj₁ tt)
vecRepWorks {suc (suc n)} vr-swap (F.suc (F.suc i)) = cong finToVal (lookupTab i)
vecRepWorks (vr-comp {n} {c₁} {c₂} {v₁} {v₂} vr vr₁) i = begin
finToVal (lookup i (tabulate (λ j → lookup (lookup j v₁) v₂)))
≡⟨ cong finToVal (lookup∘tabulate i (λ j → lookup (lookup j v₁) v₂)) ⟩
finToVal (lookup (lookup i v₁) v₂)
≡⟨ cong (λ x → finToVal (lookup x v₂)) (lookupToEvalVec i v₁) ⟩
finToVal (lookup (valToFin (evalVec v₁ i)) v₂)
≡⟨ cong (λ x → finToVal (lookup (valToFin x) v₂)) (vecRepWorks vr i) ⟩
finToVal (lookup (valToFin (evalComb c₁ (finToVal i))) v₂)
≡⟨ cong finToVal (lookupToEvalVec (valToFin (evalComb c₁ (finToVal i))) v₂) ⟩
finToVal (valToFin (evalVec v₂ (valToFin (evalComb c₁ (finToVal i)))))
≡⟨ finToValToFin (evalVec v₂ (valToFin (evalComb c₁ (finToVal i)))) ⟩
evalVec v₂ (valToFin (evalComb c₁ (finToVal i)))
≡⟨ vecRepWorks vr₁ (valToFin (evalComb c₁ (finToVal i))) ⟩
evalComb c₂ (finToVal (valToFin (evalComb c₁ (finToVal i))))
≡⟨ cong (evalComb c₂) (finToValToFin (evalComb c₁ (finToVal i))) ⟩
evalComb (c₁ ◎ c₂) (finToVal i) ∎
vecRepWorks {suc n} (vr-plus vr) F.zero = refl -- (inj₁ tt)
vecRepWorks (vr-plus {c = c} {v = v} vr) (F.suc i) = begin
evalVec (F.zero ∷ vmap F.suc v) (F.suc i) ≡⟨ cong finToVal (map!! F.suc v i) ⟩
inj₂ (finToVal (v !! i)) ≡⟨ cong inj₂ (vecRepWorks vr i) ⟩
(evalComb (id⇛ ⊕ c) (finToVal (F.suc i)) ∎)
record Permut (n : ℕ) : Set where
constructor per
field
vec : Vec (F.Fin n) n
uniq : ∀ {i j : F.Fin n} → (vec !! i) ≡ (vec !! j) → i ≡ j
-- this should also take a proof that i>0.
pred′ : {n : ℕ} (i : F.Fin (suc (suc n))) → F.Fin (suc n)
pred′ F.zero = F.zero
pred′ (F.suc i) = i
record NormComb (n : ℕ) : Set where
constructor ⟪_,_⟫
field
v : Vec (F.Fin n) n
-- We can't actually have it be the stronger condition and still be
-- able to properly recur on it as in vtc′.
p : ∀ (i : F.Fin n) (j : F.Fin′ i) → (v !! (F.inject j) ≡ i) → (v !! i ≡ (F.inject j))
predToSuc : {n : ℕ} (i : F.Fin (suc n)) (j : F.Fin′ i) (x : F.Fin (suc (suc n)))
(v : Vec (F.Fin (suc (suc n))) (suc n)) →
vmap pred′ v !! F.inject j ≡ i →
(∀ (i : F.Fin (suc (suc n))) (j : F.Fin′ i) →
((x ∷ v) !! (F.inject j) ≡ i) → ((x ∷ v) !! i ≡ (F.inject j))) →
(x ∷ v) !! F.inject (F.suc j) ≡ F.suc i
predToSuc i j x v p p₁ =
begin
(x ∷ v) !! F.inject (F.suc j)
≡⟨ refl ⟩
v !! F.inject j
≡⟨ {!refl!} ⟩
F.suc i ∎
nctail : {n : ℕ} → NormComb (suc n) → NormComb n
nctail {zero} ⟪ x ∷ [] , p ⟫ = ⟪ [] , (λ ()) ⟫
nctail {suc n} ⟪ x ∷ v , p ⟫ = ⟪ vmap pred′ v , {!!} ⟫
vtc′ : {n : ℕ} (v : Vec (F.Fin n) n) → (fromℕ n) ⇛ (fromℕ n)
vtc′ {zero} [] = id⇛
vtc′ {suc zero} (x ∷ []) = id⇛ -- can only swap with itself
vtc′ {suc (suc n)} (F.zero ∷ v) = id⇛ ⊕ (vtc′ (vmap pred′ v))
vtc′ {suc (suc n)} ((F.suc i) ∷ v) =
(id⇛ ⊕ (vtc′ (vmap pred′ v))) ◎ (swapm (F.suc i))
testvtc : {n : ℕ} → Vec (F.Fin n) n → Vec (F.Fin n) n
testvtc v = combToVec (vtc′ v)
testvtc0 : {n : ℕ} → Vec (F.Fin n) n → Vec (F.Fin n) n
testvtc0 v = combToVec (vecToComb v)
pl2 : Vec (F.Fin 5) 5
pl2 = permuteLeft (F.suc (F.suc F.zero)) (upTo 5)
pr2 : Vec (F.Fin 5) 5
pr2 = permuteRight (F.suc (F.suc F.zero))
pred∘suc : {n : ℕ} (x : F.Fin (suc (suc n))) → ((F.toℕ x) > zero) → F.suc (pred′ x) ≡ x
pred∘suc F.zero ()
pred∘suc (F.suc _) _ = refl
-- Assumptions we need so far:
-- - If the first element of a vec is zero, no other element is zero
-- (to prove that "vmap F.suc (vmap pred′ v) == v")
-- - Probably something for the last case, too
magic1 : {n : ℕ} (v : Vec (F.Fin n) n) → vecRep (vtc′ v) v
magic1 {zero} [] = vr-id
magic1 {suc zero} (F.zero ∷ []) = vr-id
magic1 {suc zero} (F.suc () ∷ [])
-- this will need something reminiscent of LeftCancellation?
magic1 {suc (suc n)} (F.zero ∷ v) = hetType
(vr-plus (magic1 {suc n} (vmap pred′ v)))
(cong (λ x → vecRep (id⇛ ⊕ vtc′ (vmap pred′ v)) (F.zero ∷ x))
((vmap∘vmap F.suc pred′ v) ∘ (vmap∘id {!!}) ))
-- swap and recurse?
magic1 {suc (suc n)} (F.suc x ∷ v) = {!!}
-- [JC] flip the conclusion around, as 'evalVec v i' is trivial. Makes
-- equational reasoning easier
vecToCombWorks : {n : ℕ} →
(v : Vec (F.Fin n) n) → (i : F.Fin n) →
(evalComb (vtc′ v) (finToVal i)) ≡ (evalVec v i)
vecToCombWorks v i = sym (vecRepWorks (magic1 v) i)
------------------------------------------------------------------
-- Goal:
lemma1 : {n : ℕ} (v : Vec (F.Fin n) n) → (i : F.Fin n) →
(evalVec v i) ≡ (evalComb (vtc′ v) (finToVal i))
lemma1 v i = sym (vecToCombWorks v i)
lemma2 : {n : ℕ} (c : (fromℕ n) ⇛ (fromℕ n)) → (i : F.Fin n) →
(evalComb c (finToVal i)) ≡ evalVec (combToVec c) i
lemma2 c i = combToVecWorks c i
----------------------------------------------------------------
| {
"alphanum_fraction": 0.5542609854,
"avg_line_length": 36.9849521204,
"ext": "agda",
"hexsha": "688e643af528de4f1662d2a39fac00e18a9a94f2",
"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/Sane.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/Sane.agda",
"max_line_length": 104,
"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/Sane.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": 11414,
"size": 27036
} |
module Data.Vec.Membership.Properties where
open import Data.Vec
open import Data.Vec.Membership
open import Data.Vec.Any.Membership.Propositional
| {
"alphanum_fraction": 0.8169934641,
"avg_line_length": 13.9090909091,
"ext": "agda",
"hexsha": "807b7246c02a7d6bdfecd6946e0cd24736807b04",
"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": "1a60f72b9ea1dd61845311ee97dc380aa542b874",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "tizmd/agda-vector-any",
"max_forks_repo_path": "src/Data/Vec/Membership/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874",
"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-vector-any",
"max_issues_repo_path": "src/Data/Vec/Membership/Properties.agda",
"max_line_length": 49,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tizmd/agda-vector-any",
"max_stars_repo_path": "src/Data/Vec/Membership/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 35,
"size": 153
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Susp where
open import Cubical.HITs.Susp.Base public
-- open import Cubical.HITs.Susp.Properties public
| {
"alphanum_fraction": 0.7547169811,
"avg_line_length": 22.7142857143,
"ext": "agda",
"hexsha": "deaf83c22b0af6862239bf44d1207ee236484865",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "limemloh/cubical",
"max_forks_repo_path": "Cubical/HITs/Susp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "limemloh/cubical",
"max_issues_repo_path": "Cubical/HITs/Susp.agda",
"max_line_length": 50,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "limemloh/cubical",
"max_stars_repo_path": "Cubical/HITs/Susp.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 44,
"size": 159
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some properties about integers
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Integer.Properties where
open import Algebra
import Algebra.Morphism as Morphism
import Algebra.Properties.AbelianGroup
open import Data.Integer.Base renaming (suc to sucℤ)
open import Data.Nat as ℕ
using (ℕ; suc; zero; _∸_; s≤s; z≤n)
hiding (module ℕ)
import Data.Nat.Properties as ℕₚ
open import Data.Nat.Solver
open import Data.Product using (proj₁; proj₂; _,_)
open import Data.Sum as Sum using (inj₁; inj₂)
open import Data.Sign as Sign using () renaming (_*_ to _𝕊*_)
import Data.Sign.Properties as 𝕊ₚ
open import Function using (_∘_; _$_)
open import Level using (0ℓ)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
import Relation.Binary.Reasoning.PartialOrder as POR
import Relation.Binary.Reasoning.Preorder as PreR
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Negation using (contradiction)
import Relation.Nullary.Decidable as Dec
open import Algebra.FunctionProperties {A = ℤ} _≡_
open import Algebra.FunctionProperties.Consequences.Propositional
open import Algebra.Structures {A = ℤ} _≡_
module ℤtoℕ = Morphism.Definitions ℤ ℕ _≡_
module ℕtoℤ = Morphism.Definitions ℕ ℤ _≡_
open +-*-Solver
------------------------------------------------------------------------
-- Equality
+-injective : ∀ {m n} → + m ≡ + n → m ≡ n
+-injective refl = refl
-[1+-injective : ∀ {m n} → -[1+ m ] ≡ -[1+ n ] → m ≡ n
-[1+-injective refl = refl
infix 4 _≟_
_≟_ : Decidable {A = ℤ} _≡_
+ m ≟ + n = Dec.map′ (cong (+_)) +-injective (m ℕ.≟ n)
+ m ≟ -[1+ n ] = no λ()
-[1+ m ] ≟ + n = no λ()
-[1+ m ] ≟ -[1+ n ] = Dec.map′ (cong -[1+_]) -[1+-injective (m ℕ.≟ n)
≡-decSetoid : DecSetoid _ _
≡-decSetoid = decSetoid _≟_
------------------------------------------------------------------------
-- Properties of -_
neg-involutive : ∀ n → - - n ≡ n
neg-involutive (+ zero) = refl
neg-involutive (+ suc n) = refl
neg-involutive (-[1+ n ]) = refl
neg-injective : ∀ {m n} → - m ≡ - n → m ≡ n
neg-injective {m} {n} -m≡-n = begin
m ≡⟨ sym (neg-involutive m) ⟩
- - m ≡⟨ cong -_ -m≡-n ⟩
- - n ≡⟨ neg-involutive n ⟩
n ∎ where open ≡-Reasoning
neg-suc : ∀ m → - + suc m ≡ pred (- + m)
neg-suc zero = refl
neg-suc (suc m) = refl
------------------------------------------------------------------------
-- Properties of ∣_∣
∣n∣≡0⇒n≡0 : ∀ {n} → ∣ n ∣ ≡ 0 → n ≡ + 0
∣n∣≡0⇒n≡0 {+ .zero} refl = refl
∣n∣≡0⇒n≡0 { -[1+ n ]} ()
∣-n∣≡∣n∣ : ∀ n → ∣ - n ∣ ≡ ∣ n ∣
∣-n∣≡∣n∣ (+ zero) = refl
∣-n∣≡∣n∣ (+ suc n) = refl
∣-n∣≡∣n∣ (-[1+ n ]) = refl
0≤n⇒+∣n∣≡n : ∀ {n} → + 0 ≤ n → + ∣ n ∣ ≡ n
0≤n⇒+∣n∣≡n (+≤+ 0≤n) = refl
+∣n∣≡n⇒0≤n : ∀ {n} → + ∣ n ∣ ≡ n → + 0 ≤ n
+∣n∣≡n⇒0≤n {+ n} _ = +≤+ z≤n
+∣n∣≡n⇒0≤n { -[1+ n ]} ()
------------------------------------------------------------------------
-- Properties of sign and _◃_
◃-inverse : ∀ i → sign i ◃ ∣ i ∣ ≡ i
◃-inverse -[1+ n ] = refl
◃-inverse (+ zero) = refl
◃-inverse (+ suc n) = refl
◃-cong : ∀ {i j} → sign i ≡ sign j → ∣ i ∣ ≡ ∣ j ∣ → i ≡ j
◃-cong {i} {j} sign-≡ abs-≡ = begin
i ≡⟨ sym $ ◃-inverse i ⟩
sign i ◃ ∣ i ∣ ≡⟨ cong₂ _◃_ sign-≡ abs-≡ ⟩
sign j ◃ ∣ j ∣ ≡⟨ ◃-inverse j ⟩
j ∎ where open ≡-Reasoning
+◃n≡+n : ∀ n → Sign.+ ◃ n ≡ + n
+◃n≡+n zero = refl
+◃n≡+n (suc _) = refl
-◃n≡-n : ∀ n → Sign.- ◃ n ≡ - + n
-◃n≡-n zero = refl
-◃n≡-n (suc _) = refl
sign-◃ : ∀ s n → sign (s ◃ suc n) ≡ s
sign-◃ Sign.- _ = refl
sign-◃ Sign.+ _ = refl
abs-◃ : ∀ s n → ∣ s ◃ n ∣ ≡ n
abs-◃ _ zero = refl
abs-◃ Sign.- (suc n) = refl
abs-◃ Sign.+ (suc n) = refl
signₙ◃∣n∣≡n : ∀ n → sign n ◃ ∣ n ∣ ≡ n
signₙ◃∣n∣≡n (+ n) = +◃n≡+n n
signₙ◃∣n∣≡n (-[1+ n ]) = refl
sign-cong : ∀ {s₁ s₂ n₁ n₂} →
s₁ ◃ suc n₁ ≡ s₂ ◃ suc n₂ → s₁ ≡ s₂
sign-cong {s₁} {s₂} {n₁} {n₂} eq = begin
s₁ ≡⟨ sym $ sign-◃ s₁ n₁ ⟩
sign (s₁ ◃ suc n₁) ≡⟨ cong sign eq ⟩
sign (s₂ ◃ suc n₂) ≡⟨ sign-◃ s₂ n₂ ⟩
s₂ ∎ where open ≡-Reasoning
abs-cong : ∀ {s₁ s₂ n₁ n₂} → s₁ ◃ n₁ ≡ s₂ ◃ n₂ → n₁ ≡ n₂
abs-cong {s₁} {s₂} {n₁} {n₂} eq = begin
n₁ ≡⟨ sym $ abs-◃ s₁ n₁ ⟩
∣ s₁ ◃ n₁ ∣ ≡⟨ cong ∣_∣ eq ⟩
∣ s₂ ◃ n₂ ∣ ≡⟨ abs-◃ s₂ n₂ ⟩
n₂ ∎ where open ≡-Reasoning
∣s◃m∣*∣t◃n∣≡m*n : ∀ s t m n → ∣ s ◃ m ∣ ℕ.* ∣ t ◃ n ∣ ≡ m ℕ.* n
∣s◃m∣*∣t◃n∣≡m*n s t m n = cong₂ ℕ._*_ (abs-◃ s m) (abs-◃ t n)
◃-≡ : ∀ {m n} → sign m ≡ sign n → ∣ m ∣ ≡ ∣ n ∣ → m ≡ n
◃-≡ {+ m} {+ n } ≡-sign ≡-abs = cong ℤ.pos ≡-abs
◃-≡ { -[1+ m ]} { -[1+ n ]} ≡-sign ≡-abs = cong -[1+_] (ℕₚ.suc-injective ≡-abs)
◃-≡ {+ m} { -[1+ n ]} () ≡-abs
◃-≡ { -[1+ m ]} {+ n } () ≡-abs
------------------------------------------------------------------------
-- Properties of _⊖_
n⊖n≡0 : ∀ n → n ⊖ n ≡ + 0
n⊖n≡0 zero = refl
n⊖n≡0 (suc n) = n⊖n≡0 n
⊖-swap : ∀ a b → a ⊖ b ≡ - (b ⊖ a)
⊖-swap zero zero = refl
⊖-swap (suc _) zero = refl
⊖-swap zero (suc _) = refl
⊖-swap (suc a) (suc b) = ⊖-swap a b
⊖-≥ : ∀ {m n} → m ℕ.≥ n → m ⊖ n ≡ + (m ∸ n)
⊖-≥ z≤n = refl
⊖-≥ (ℕ.s≤s n≤m) = ⊖-≥ n≤m
⊖-< : ∀ {m n} → m ℕ.< n → m ⊖ n ≡ - + (n ∸ m)
⊖-< {zero} (ℕ.s≤s z≤n) = refl
⊖-< {suc m} (ℕ.s≤s m<n) = ⊖-< m<n
⊖-≰ : ∀ {m n} → n ℕ.≰ m → m ⊖ n ≡ - + (n ∸ m)
⊖-≰ = ⊖-< ∘ ℕₚ.≰⇒>
∣⊖∣-< : ∀ {m n} → m ℕ.< n → ∣ m ⊖ n ∣ ≡ n ∸ m
∣⊖∣-< {zero} (ℕ.s≤s z≤n) = refl
∣⊖∣-< {suc n} (ℕ.s≤s m<n) = ∣⊖∣-< m<n
∣⊖∣-≰ : ∀ {m n} → n ℕ.≰ m → ∣ m ⊖ n ∣ ≡ n ∸ m
∣⊖∣-≰ = ∣⊖∣-< ∘ ℕₚ.≰⇒>
sign-⊖-< : ∀ {m n} → m ℕ.< n → sign (m ⊖ n) ≡ Sign.-
sign-⊖-< {zero} (ℕ.s≤s z≤n) = refl
sign-⊖-< {suc n} (ℕ.s≤s m<n) = sign-⊖-< m<n
sign-⊖-≰ : ∀ {m n} → n ℕ.≰ m → sign (m ⊖ n) ≡ Sign.-
sign-⊖-≰ = sign-⊖-< ∘ ℕₚ.≰⇒>
-[n⊖m]≡-m+n : ∀ m n → - (m ⊖ n) ≡ (- (+ m)) + (+ n)
-[n⊖m]≡-m+n zero zero = refl
-[n⊖m]≡-m+n zero (suc n) = refl
-[n⊖m]≡-m+n (suc m) zero = refl
-[n⊖m]≡-m+n (suc m) (suc n) = sym (⊖-swap n m)
∣m⊖n∣≡∣n⊖m∣ : ∀ x y → ∣ x ⊖ y ∣ ≡ ∣ y ⊖ x ∣
∣m⊖n∣≡∣n⊖m∣ zero zero = refl
∣m⊖n∣≡∣n⊖m∣ zero (suc _) = refl
∣m⊖n∣≡∣n⊖m∣ (suc _) zero = refl
∣m⊖n∣≡∣n⊖m∣ (suc x) (suc y) = ∣m⊖n∣≡∣n⊖m∣ x y
+-cancelˡ-⊖ : ∀ a b c → (a ℕ.+ b) ⊖ (a ℕ.+ c) ≡ b ⊖ c
+-cancelˡ-⊖ zero b c = refl
+-cancelˡ-⊖ (suc a) b c = +-cancelˡ-⊖ a b c
------------------------------------------------------------------------
-- Properties of _+_
+-comm : Commutative _+_
+-comm -[1+ a ] -[1+ b ] = cong (-[1+_] ∘ suc) (ℕₚ.+-comm a b)
+-comm (+ a ) (+ b ) = cong +_ (ℕₚ.+-comm a b)
+-comm -[1+ _ ] (+ _ ) = refl
+-comm (+ _ ) -[1+ _ ] = refl
+-identityˡ : LeftIdentity (+ 0) _+_
+-identityˡ -[1+ _ ] = refl
+-identityˡ (+ _ ) = refl
+-identityʳ : RightIdentity (+ 0) _+_
+-identityʳ = comm+idˡ⇒idʳ +-comm +-identityˡ
+-identity : Identity (+ 0) _+_
+-identity = +-identityˡ , +-identityʳ
distribˡ-⊖-+-pos : ∀ a b c → b ⊖ c + + a ≡ b ℕ.+ a ⊖ c
distribˡ-⊖-+-pos _ zero zero = refl
distribˡ-⊖-+-pos _ zero (suc _) = refl
distribˡ-⊖-+-pos _ (suc _) zero = refl
distribˡ-⊖-+-pos a (suc b) (suc c) = distribˡ-⊖-+-pos a b c
distribˡ-⊖-+-neg : ∀ a b c → b ⊖ c + -[1+ a ] ≡ b ⊖ (suc c ℕ.+ a)
distribˡ-⊖-+-neg _ zero zero = refl
distribˡ-⊖-+-neg _ zero (suc _) = refl
distribˡ-⊖-+-neg _ (suc _) zero = refl
distribˡ-⊖-+-neg a (suc b) (suc c) = distribˡ-⊖-+-neg a b c
distribʳ-⊖-+-pos : ∀ a b c → + a + (b ⊖ c) ≡ a ℕ.+ b ⊖ c
distribʳ-⊖-+-pos a b c = begin
+ a + (b ⊖ c) ≡⟨ +-comm (+ a) (b ⊖ c) ⟩
(b ⊖ c) + + a ≡⟨ distribˡ-⊖-+-pos a b c ⟩
b ℕ.+ a ⊖ c ≡⟨ cong (_⊖ c) (ℕₚ.+-comm b a) ⟩
a ℕ.+ b ⊖ c ∎ where open ≡-Reasoning
distribʳ-⊖-+-neg : ∀ a b c → -[1+ a ] + (b ⊖ c) ≡ b ⊖ (suc a ℕ.+ c)
distribʳ-⊖-+-neg a b c = begin
-[1+ a ] + (b ⊖ c) ≡⟨ +-comm -[1+ a ] (b ⊖ c) ⟩
(b ⊖ c) + -[1+ a ] ≡⟨ distribˡ-⊖-+-neg a b c ⟩
b ⊖ suc (c ℕ.+ a) ≡⟨ cong (λ x → b ⊖ suc x) (ℕₚ.+-comm c a) ⟩
b ⊖ suc (a ℕ.+ c) ∎ where open ≡-Reasoning
suc-+ : ∀ m n → + suc m + n ≡ sucℤ (+ m + n)
suc-+ m (+ n) = refl
suc-+ m (-[1+ n ]) = sym (distribʳ-⊖-+-pos 1 m (suc n))
pos-+-commute : ℕtoℤ.Homomorphic₂ +_ ℕ._+_ _+_
pos-+-commute zero n = refl
pos-+-commute (suc m) n = cong sucℤ (pos-+-commute m n)
+-assoc : Associative _+_
+-assoc (+ zero) y z rewrite +-identityˡ y | +-identityˡ (y + z) = refl
+-assoc x (+ zero) z rewrite +-identityʳ x | +-identityˡ z = refl
+-assoc x y (+ zero) rewrite +-identityʳ (x + y) | +-identityʳ y = refl
+-assoc -[1+ a ] -[1+ b ] (+ suc c) = sym (distribʳ-⊖-+-neg a c b)
+-assoc -[1+ a ] (+ suc b) (+ suc c) = distribˡ-⊖-+-pos (suc c) b a
+-assoc (+ suc a) -[1+ b ] -[1+ c ] = distribˡ-⊖-+-neg c a b
+-assoc (+ suc a) -[1+ b ] (+ suc c)
rewrite distribˡ-⊖-+-pos (suc c) a b
| distribʳ-⊖-+-pos (suc a) c b
| sym (ℕₚ.+-assoc a 1 c)
| ℕₚ.+-comm a 1
= refl
+-assoc (+ suc a) (+ suc b) -[1+ c ]
rewrite distribʳ-⊖-+-pos (suc a) b c
| sym (ℕₚ.+-assoc a 1 b)
| ℕₚ.+-comm a 1
= refl
+-assoc -[1+ a ] -[1+ b ] -[1+ c ]
rewrite sym (ℕₚ.+-assoc a 1 (b ℕ.+ c))
| ℕₚ.+-comm a 1
| ℕₚ.+-assoc a b c
= refl
+-assoc -[1+ a ] (+ suc b) -[1+ c ]
rewrite distribʳ-⊖-+-neg a b c
| distribˡ-⊖-+-neg c b a
= refl
+-assoc (+ suc a) (+ suc b) (+ suc c)
rewrite ℕₚ.+-assoc (suc a) (suc b) (suc c)
= refl
suc-pred : ∀ m → sucℤ (pred m) ≡ m
suc-pred m = begin
sucℤ (pred m) ≡⟨ sym (+-assoc (+ 1) (- + 1) m) ⟩
+ 0 + m ≡⟨ +-identityˡ m ⟩
m ∎ where open ≡-Reasoning
pred-suc : ∀ m → pred (sucℤ m) ≡ m
pred-suc m = begin
pred (sucℤ m) ≡⟨ sym (+-assoc (- + 1) (+ 1) m) ⟩
+ 0 + m ≡⟨ +-identityˡ m ⟩
m ∎ where open ≡-Reasoning
+-pred : ∀ m n → m + pred n ≡ pred (m + n)
+-pred m n = begin
m + (-[1+ 0 ] + n) ≡⟨ sym (+-assoc m -[1+ 0 ] n) ⟩
m + -[1+ 0 ] + n ≡⟨ cong (_+ n) (+-comm m -[1+ 0 ]) ⟩
-[1+ 0 ] + m + n ≡⟨ +-assoc -[1+ 0 ] m n ⟩
-[1+ 0 ] + (m + n) ∎ where open ≡-Reasoning
pred-+ : ∀ m n → pred m + n ≡ pred (m + n)
pred-+ m n = begin
pred m + n ≡⟨ +-comm (pred m) n ⟩
n + pred m ≡⟨ +-pred n m ⟩
pred (n + m) ≡⟨ cong pred (+-comm n m) ⟩
pred (m + n) ∎ where open ≡-Reasoning
+-inverseˡ : LeftInverse (+ 0) -_ _+_
+-inverseˡ -[1+ n ] = n⊖n≡0 n
+-inverseˡ (+ zero) = refl
+-inverseˡ (+ suc n) = n⊖n≡0 n
+-inverseʳ : RightInverse (+ 0) -_ _+_
+-inverseʳ = comm+invˡ⇒invʳ +-comm +-inverseˡ
+-inverse : Inverse (+ 0) -_ _+_
+-inverse = +-inverseˡ , +-inverseʳ
+-isMagma : IsMagma _+_
+-isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = cong₂ _+_
}
+-magma : Magma 0ℓ 0ℓ
+-magma = record
{ isMagma = +-isMagma
}
+-isSemigroup : IsSemigroup _+_
+-isSemigroup = record
{ isMagma = +-isMagma
; assoc = +-assoc
}
+-semigroup : Semigroup 0ℓ 0ℓ
+-semigroup = record
{ isSemigroup = +-isSemigroup
}
+-0-isMonoid : IsMonoid _+_ (+ 0)
+-0-isMonoid = record
{ isSemigroup = +-isSemigroup
; identity = +-identity
}
+-0-monoid : Monoid 0ℓ 0ℓ
+-0-monoid = record
{ isMonoid = +-0-isMonoid
}
+-0-isCommutativeMonoid : IsCommutativeMonoid _+_ (+ 0)
+-0-isCommutativeMonoid = record
{ isSemigroup = +-isSemigroup
; identityˡ = +-identityˡ
; comm = +-comm
}
+-0-commutativeMonoid : CommutativeMonoid _ _
+-0-commutativeMonoid = record
{ isCommutativeMonoid = +-0-isCommutativeMonoid
}
+-0-isGroup : IsGroup _+_ (+ 0) (-_)
+-0-isGroup = record
{ isMonoid = +-0-isMonoid
; inverse = +-inverse
; ⁻¹-cong = cong (-_)
}
+-isAbelianGroup : IsAbelianGroup _+_ (+ 0) (-_)
+-isAbelianGroup = record
{ isGroup = +-0-isGroup
; comm = +-comm
}
+-0-abelianGroup : AbelianGroup _ _
+-0-abelianGroup = record
{ isAbelianGroup = +-isAbelianGroup
}
-- Other properties of _+_
n≢1+n : ∀ {n} → n ≢ sucℤ n
n≢1+n {+ _} ()
n≢1+n { -[1+ 0 ]} ()
n≢1+n { -[1+ suc n ]} ()
1-[1+n]≡-n : ∀ n → sucℤ -[1+ n ] ≡ - (+ n)
1-[1+n]≡-n zero = refl
1-[1+n]≡-n (suc n) = refl
neg-distrib-+ : ∀ m n → - (m + n) ≡ (- m) + (- n)
neg-distrib-+ (+ zero) (+ zero) = refl
neg-distrib-+ (+ zero) (+ suc n) = refl
neg-distrib-+ (+ suc m) (+ zero) = cong -[1+_] (ℕₚ.+-identityʳ m)
neg-distrib-+ (+ suc m) (+ suc n) = cong -[1+_] (ℕₚ.+-suc m n)
neg-distrib-+ -[1+ m ] -[1+ n ] = cong (λ v → + suc v) (sym (ℕₚ.+-suc m n))
neg-distrib-+ (+ m) -[1+ n ] = -[n⊖m]≡-m+n m (suc n)
neg-distrib-+ -[1+ m ] (+ n) =
trans (-[n⊖m]≡-m+n n (suc m)) (+-comm (- + n) (+ suc m))
◃-distrib-+ : ∀ s m n → s ◃ (m ℕ.+ n) ≡ (s ◃ m) + (s ◃ n)
◃-distrib-+ Sign.- m n = begin
Sign.- ◃ (m ℕ.+ n) ≡⟨ -◃n≡-n (m ℕ.+ n) ⟩
- (+ (m ℕ.+ n)) ≡⟨⟩
- ((+ m) + (+ n)) ≡⟨ neg-distrib-+ (+ m) (+ n) ⟩
(- (+ m)) + (- (+ n)) ≡⟨ sym (cong₂ _+_ (-◃n≡-n m) (-◃n≡-n n)) ⟩
(Sign.- ◃ m) + (Sign.- ◃ n) ∎ where open ≡-Reasoning
◃-distrib-+ Sign.+ m n = begin
Sign.+ ◃ (m ℕ.+ n) ≡⟨ +◃n≡+n (m ℕ.+ n) ⟩
+ (m ℕ.+ n) ≡⟨⟩
(+ m) + (+ n) ≡⟨ sym (cong₂ _+_ (+◃n≡+n m) (+◃n≡+n n)) ⟩
(Sign.+ ◃ m) + (Sign.+ ◃ n) ∎ where open ≡-Reasoning
+-minus-telescope : ∀ x y z → (x - y) + (y - z) ≡ x - z
+-minus-telescope x y z = begin
(x - y) + (y - z) ≡⟨ +-assoc x (- y) (y - z) ⟩
x + (- y + (y - z)) ≡⟨ cong (λ v → x + v) (sym (+-assoc (- y) y _)) ⟩
x + ((- y + y) - z) ≡⟨ sym (+-assoc x (- y + y) (- z)) ⟩
x + (- y + y) - z ≡⟨ cong (λ a → x + a - z) (+-inverseˡ y) ⟩
x + (+ 0) - z ≡⟨ cong (_- z) (+-identityʳ x) ⟩
x - z ∎ where open ≡-Reasoning
------------------------------------------------------------------------
-- Properties of _-_
neg-minus-pos : ∀ x y → -[1+ x ] - (+ y) ≡ -[1+ (y ℕ.+ x) ]
neg-minus-pos x zero = refl
neg-minus-pos zero (suc y) = cong (-[1+_] ∘ suc) (sym (ℕₚ.+-identityʳ y))
neg-minus-pos (suc x) (suc y) = cong (-[1+_] ∘ suc) (ℕₚ.+-comm (suc x) y)
[+m]-[+n]≡m⊖n : ∀ x y → (+ x) - (+ y) ≡ x ⊖ y
[+m]-[+n]≡m⊖n zero zero = refl
[+m]-[+n]≡m⊖n zero (suc y) = refl
[+m]-[+n]≡m⊖n (suc x) zero = cong (+_ ∘ suc) (ℕₚ.+-identityʳ x)
[+m]-[+n]≡m⊖n (suc x) (suc y) = refl
∣m-n∣≡∣n-m∣ : (x y : ℤ) → ∣ x - y ∣ ≡ ∣ y - x ∣
∣m-n∣≡∣n-m∣ -[1+ x ] -[1+ y ] = ∣m⊖n∣≡∣n⊖m∣ y x
∣m-n∣≡∣n-m∣ -[1+ x ] (+ y) = begin
∣ -[1+ x ] - (+ y) ∣ ≡⟨ cong ∣_∣ (neg-minus-pos x y) ⟩
suc (y ℕ.+ x) ≡⟨ sym (ℕₚ.+-suc y x) ⟩
y ℕ.+ suc x ∎ where open ≡-Reasoning
∣m-n∣≡∣n-m∣ (+ x) -[1+ y ] = begin
x ℕ.+ suc y ≡⟨ ℕₚ.+-suc x y ⟩
suc (x ℕ.+ y) ≡⟨ cong ∣_∣ (sym (neg-minus-pos y x)) ⟩
∣ -[1+ y ] + - (+ x) ∣ ∎ where open ≡-Reasoning
∣m-n∣≡∣n-m∣ (+ x) (+ y) = begin
∣ (+ x) - (+ y) ∣ ≡⟨ cong ∣_∣ ([+m]-[+n]≡m⊖n x y) ⟩
∣ x ⊖ y ∣ ≡⟨ ∣m⊖n∣≡∣n⊖m∣ x y ⟩
∣ y ⊖ x ∣ ≡⟨ cong ∣_∣ (sym ([+m]-[+n]≡m⊖n y x)) ⟩
∣ (+ y) - (+ x) ∣ ∎ where open ≡-Reasoning
minus-suc : ∀ m n → m - + suc n ≡ pred (m - + n)
minus-suc m n = begin
m + - + suc n ≡⟨ cong (_+_ m) (neg-suc n) ⟩
m + pred (- (+ n)) ≡⟨ +-pred m (- + n) ⟩
pred (m - + n) ∎ where open ≡-Reasoning
m≡n⇒m-n≡0 : ∀ m n → m ≡ n → m - n ≡ + 0
m≡n⇒m-n≡0 m m refl = +-inverseʳ m
m-n≡0⇒m≡n : ∀ m n → m - n ≡ + 0 → m ≡ n
m-n≡0⇒m≡n m n m-n≡0 = begin
m ≡⟨ sym (+-identityʳ m) ⟩
m + + 0 ≡⟨ cong (_+_ m) (sym (+-inverseˡ n)) ⟩
m + (- n + n) ≡⟨ sym (+-assoc m (- n) n) ⟩
(m - n) + n ≡⟨ cong (_+ n) m-n≡0 ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎ where open ≡-Reasoning
------------------------------------------------------------------------
-- Properties of _*_
*-comm : Commutative _*_
*-comm -[1+ a ] -[1+ b ] rewrite ℕₚ.*-comm (suc a) (suc b) = refl
*-comm -[1+ a ] (+ b ) rewrite ℕₚ.*-comm (suc a) b = refl
*-comm (+ a ) -[1+ b ] rewrite ℕₚ.*-comm a (suc b) = refl
*-comm (+ a ) (+ b ) rewrite ℕₚ.*-comm a b = refl
*-identityˡ : LeftIdentity (+ 1) _*_
*-identityˡ (+ zero ) = refl
*-identityˡ -[1+ n ] rewrite ℕₚ.+-identityʳ n = refl
*-identityˡ (+ suc n) rewrite ℕₚ.+-identityʳ n = refl
*-identityʳ : RightIdentity (+ 1) _*_
*-identityʳ = comm+idˡ⇒idʳ *-comm *-identityˡ
*-identity : Identity (+ 1) _*_
*-identity = *-identityˡ , *-identityʳ
*-zeroˡ : LeftZero (+ 0) _*_
*-zeroˡ n = refl
*-zeroʳ : RightZero (+ 0) _*_
*-zeroʳ = comm+zeˡ⇒zeʳ *-comm *-zeroˡ
*-zero : Zero (+ 0) _*_
*-zero = *-zeroˡ , *-zeroʳ
private
lemma : ∀ a b c → c ℕ.+ (b ℕ.+ a ℕ.* suc b) ℕ.* suc c
≡ c ℕ.+ b ℕ.* suc c ℕ.+ a ℕ.* suc (c ℕ.+ b ℕ.* suc c)
lemma =
solve 3 (λ a b c → c :+ (b :+ a :* (con 1 :+ b)) :* (con 1 :+ c)
:= c :+ b :* (con 1 :+ c) :+
a :* (con 1 :+ (c :+ b :* (con 1 :+ c))))
refl
*-assoc : Associative _*_
*-assoc (+ zero) _ _ = refl
*-assoc x (+ zero) z rewrite ℕₚ.*-zeroʳ ∣ x ∣ = refl
*-assoc x y (+ zero) rewrite
ℕₚ.*-zeroʳ ∣ y ∣
| ℕₚ.*-zeroʳ ∣ x ∣
| ℕₚ.*-zeroʳ ∣ sign x 𝕊* sign y ◃ ∣ x ∣ ℕ.* ∣ y ∣ ∣
= refl
*-assoc -[1+ a ] -[1+ b ] (+ suc c) = cong (+_ ∘ suc) (lemma a b c)
*-assoc -[1+ a ] (+ suc b) -[1+ c ] = cong (+_ ∘ suc) (lemma a b c)
*-assoc (+ suc a) (+ suc b) (+ suc c) = cong (+_ ∘ suc) (lemma a b c)
*-assoc (+ suc a) -[1+ b ] -[1+ c ] = cong (+_ ∘ suc) (lemma a b c)
*-assoc -[1+ a ] -[1+ b ] -[1+ c ] = cong -[1+_] (lemma a b c)
*-assoc -[1+ a ] (+ suc b) (+ suc c) = cong -[1+_] (lemma a b c)
*-assoc (+ suc a) -[1+ b ] (+ suc c) = cong -[1+_] (lemma a b c)
*-assoc (+ suc a) (+ suc b) -[1+ c ] = cong -[1+_] (lemma a b c)
private
-- lemma used to prove distributivity.
distrib-lemma :
∀ a b c → (c ⊖ b) * -[1+ a ] ≡ a ℕ.+ b ℕ.* suc a ⊖ (a ℕ.+ c ℕ.* suc a)
distrib-lemma a b c
rewrite +-cancelˡ-⊖ a (b ℕ.* suc a) (c ℕ.* suc a)
| ⊖-swap (b ℕ.* suc a) (c ℕ.* suc a)
with b ℕ.≤? c
... | yes b≤c
rewrite ⊖-≥ b≤c
| ⊖-≥ (ℕₚ.*-mono-≤ b≤c (ℕₚ.≤-refl {x = suc a}))
| -◃n≡-n ((c ∸ b) ℕ.* suc a)
| ℕₚ.*-distribʳ-∸ (suc a) c b
= refl
... | no b≰c
rewrite sign-⊖-≰ b≰c
| ∣⊖∣-≰ b≰c
| +◃n≡+n ((b ∸ c) ℕ.* suc a)
| ⊖-≰ (b≰c ∘ ℕₚ.*-cancelʳ-≤ b c a)
| neg-involutive (+ (b ℕ.* suc a ∸ c ℕ.* suc a))
| ℕₚ.*-distribʳ-∸ (suc a) b c
= refl
*-distribʳ-+ : _*_ DistributesOverʳ _+_
*-distribʳ-+ (+ zero) y z
rewrite ℕₚ.*-zeroʳ ∣ y ∣
| ℕₚ.*-zeroʳ ∣ z ∣
| ℕₚ.*-zeroʳ ∣ y + z ∣
= refl
*-distribʳ-+ x (+ zero) z
rewrite +-identityˡ z
| +-identityˡ (sign z 𝕊* sign x ◃ ∣ z ∣ ℕ.* ∣ x ∣)
= refl
*-distribʳ-+ x y (+ zero)
rewrite +-identityʳ y
| +-identityʳ (sign y 𝕊* sign x ◃ ∣ y ∣ ℕ.* ∣ x ∣)
= refl
*-distribʳ-+ -[1+ a ] -[1+ b ] -[1+ c ] = cong (+_) $
solve 3 (λ a b c → (con 2 :+ b :+ c) :* (con 1 :+ a)
:= (con 1 :+ b) :* (con 1 :+ a) :+
(con 1 :+ c) :* (con 1 :+ a))
refl a b c
*-distribʳ-+ (+ suc a) (+ suc b) (+ suc c) = cong (+_) $
solve 3 (λ a b c → (con 1 :+ b :+ (con 1 :+ c)) :* (con 1 :+ a)
:= (con 1 :+ b) :* (con 1 :+ a) :+
(con 1 :+ c) :* (con 1 :+ a))
refl a b c
*-distribʳ-+ -[1+ a ] (+ suc b) (+ suc c) = cong -[1+_] $
solve 3 (λ a b c → a :+ (b :+ (con 1 :+ c)) :* (con 1 :+ a)
:= (con 1 :+ b) :* (con 1 :+ a) :+
(a :+ c :* (con 1 :+ a)))
refl a b c
*-distribʳ-+ (+ suc a) -[1+ b ] -[1+ c ] = cong -[1+_] $
solve 3 (λ a b c → a :+ (con 1 :+ a :+ (b :+ c) :* (con 1 :+ a))
:= (con 1 :+ b) :* (con 1 :+ a) :+
(a :+ c :* (con 1 :+ a)))
refl a b c
*-distribʳ-+ -[1+ a ] -[1+ b ] (+ suc c) = distrib-lemma a b c
*-distribʳ-+ -[1+ a ] (+ suc b) -[1+ c ] = distrib-lemma a c b
*-distribʳ-+ (+ suc a) -[1+ b ] (+ suc c) with b ℕ.≤? c
... | yes b≤c
rewrite +-cancelˡ-⊖ a (c ℕ.* suc a) (b ℕ.* suc a)
| ⊖-≥ b≤c
| +-comm (- (+ (a ℕ.+ b ℕ.* suc a))) (+ (a ℕ.+ c ℕ.* suc a))
| ⊖-≥ (ℕₚ.*-mono-≤ b≤c (ℕₚ.≤-refl {x = suc a}))
| ℕₚ.*-distribʳ-∸ (suc a) c b
| +◃n≡+n (c ℕ.* suc a ∸ b ℕ.* suc a)
= refl
... | no b≰c
rewrite +-cancelˡ-⊖ a (c ℕ.* suc a) (b ℕ.* suc a)
| sign-⊖-≰ b≰c
| ∣⊖∣-≰ b≰c
| -◃n≡-n ((b ∸ c) ℕ.* suc a)
| ⊖-≰ (b≰c ∘ ℕₚ.*-cancelʳ-≤ b c a)
| ℕₚ.*-distribʳ-∸ (suc a) b c
= refl
*-distribʳ-+ (+ suc c) (+ suc a) -[1+ b ] with b ℕ.≤? a
... | yes b≤a
rewrite +-cancelˡ-⊖ c (a ℕ.* suc c) (b ℕ.* suc c)
| ⊖-≥ b≤a
| ⊖-≥ (ℕₚ.*-mono-≤ b≤a (ℕₚ.≤-refl {x = suc c}))
| +◃n≡+n ((a ∸ b) ℕ.* suc c)
| ℕₚ.*-distribʳ-∸ (suc c) a b
= refl
... | no b≰a
rewrite +-cancelˡ-⊖ c (a ℕ.* suc c) (b ℕ.* suc c)
| sign-⊖-≰ b≰a
| ∣⊖∣-≰ b≰a
| ⊖-≰ (b≰a ∘ ℕₚ.*-cancelʳ-≤ b a c)
| -◃n≡-n ((b ∸ a) ℕ.* suc c)
| ℕₚ.*-distribʳ-∸ (suc c) b a
= refl
*-distribˡ-+ : _*_ DistributesOverˡ _+_
*-distribˡ-+ = comm+distrʳ⇒distrˡ *-comm *-distribʳ-+
[1+m]*n≡n+m*n : ∀ m n → sucℤ m * n ≡ n + m * n
[1+m]*n≡n+m*n m n = begin
sucℤ m * n ≡⟨ *-distribʳ-+ n (+ 1) m ⟩
+ 1 * n + m * n ≡⟨ cong (_+ m * n) (*-identityˡ n) ⟩
n + m * n ∎ where open ≡-Reasoning
*-isMagma : IsMagma _*_
*-isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = cong₂ _*_
}
*-magma : Magma 0ℓ 0ℓ
*-magma = record
{ isMagma = *-isMagma
}
*-isSemigroup : IsSemigroup _*_
*-isSemigroup = record
{ isMagma = *-isMagma
; assoc = *-assoc
}
*-semigroup : Semigroup 0ℓ 0ℓ
*-semigroup = record
{ isSemigroup = *-isSemigroup
}
*-1-isMonoid : IsMonoid _*_ (+ 1)
*-1-isMonoid = record
{ isSemigroup = *-isSemigroup
; identity = *-identity
}
*-1-monoid : Monoid 0ℓ 0ℓ
*-1-monoid = record
{ isMonoid = *-1-isMonoid
}
*-1-isCommutativeMonoid : IsCommutativeMonoid _*_ (+ 1)
*-1-isCommutativeMonoid = record
{ isSemigroup = *-isSemigroup
; identityˡ = *-identityˡ
; comm = *-comm
}
*-1-commutativeMonoid : CommutativeMonoid _ _
*-1-commutativeMonoid = record
{ isCommutativeMonoid = *-1-isCommutativeMonoid
}
+-*-isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ (+ 0) (+ 1)
+-*-isCommutativeSemiring = record
{ +-isCommutativeMonoid = +-0-isCommutativeMonoid
; *-isCommutativeMonoid = *-1-isCommutativeMonoid
; distribʳ = *-distribʳ-+
; zeroˡ = *-zeroˡ
}
+-*-isRing : IsRing _+_ _*_ -_ (+ 0) (+ 1)
+-*-isRing = record
{ +-isAbelianGroup = +-isAbelianGroup
; *-isMonoid = *-1-isMonoid
; distrib = IsCommutativeSemiring.distrib
+-*-isCommutativeSemiring
}
+-*-ring : Ring _ _
+-*-ring = record { isRing = +-*-isRing }
+-*-isCommutativeRing : IsCommutativeRing _+_ _*_ -_ (+ 0) (+ 1)
+-*-isCommutativeRing = record
{ isRing = +-*-isRing
; *-comm = *-comm
}
+-*-commutativeRing : CommutativeRing _ _
+-*-commutativeRing = record
{ Carrier = ℤ
; _≈_ = _≡_
; _+_ = _+_
; _*_ = _*_
; -_ = -_
; 0# = + 0
; 1# = + 1
; isCommutativeRing = +-*-isCommutativeRing
}
-- Other properties of _*_
abs-*-commute : ℤtoℕ.Homomorphic₂ ∣_∣ _*_ ℕ._*_
abs-*-commute i j = abs-◃ _ _
pos-distrib-* : ∀ x y → (+ x) * (+ y) ≡ + (x ℕ.* y)
pos-distrib-* zero y = refl
pos-distrib-* (suc x) zero = pos-distrib-* x zero
pos-distrib-* (suc x) (suc y) = refl
◃-distrib-* : ∀ s t m n → (s 𝕊* t) ◃ (m ℕ.* n) ≡ (s ◃ m) * (t ◃ n)
◃-distrib-* s t zero zero = refl
◃-distrib-* s t zero (suc n) = refl
◃-distrib-* s t (suc m) zero =
trans
(cong₂ _◃_ (𝕊ₚ.*-comm s t) (ℕₚ.*-comm m 0))
(*-comm (t ◃ zero) (s ◃ suc m))
◃-distrib-* s t (suc m) (suc n) =
sym (cong₂ _◃_
(cong₂ _𝕊*_ (sign-◃ s m) (sign-◃ t n))
(∣s◃m∣*∣t◃n∣≡m*n s t (suc m) (suc n)))
*-cancelʳ-≡ : ∀ i j k → k ≢ + 0 → i * k ≡ j * k → i ≡ j
*-cancelʳ-≡ i j k ≢0 eq with signAbs k
*-cancelʳ-≡ i j .(+ 0) ≢0 eq | s ◂ zero = contradiction refl ≢0
*-cancelʳ-≡ i j .(s ◃ suc n) ≢0 eq | s ◂ suc n
with ∣ s ◃ suc n ∣ | abs-◃ s (suc n) | sign (s ◃ suc n) | sign-◃ s n
... | .(suc n) | refl | .s | refl =
◃-cong (sign-i≡sign-j i j eq) $
ℕₚ.*-cancelʳ-≡ ∣ i ∣ ∣ j ∣ $ abs-cong eq
where
sign-i≡sign-j : ∀ i j →
(sign i 𝕊* s) ◃ (∣ i ∣ ℕ.* suc n) ≡
(sign j 𝕊* s) ◃ (∣ j ∣ ℕ.* suc n) →
sign i ≡ sign j
sign-i≡sign-j i j eq with signAbs i | signAbs j
sign-i≡sign-j .(+ 0) .(+ 0) eq | s₁ ◂ zero | s₂ ◂ zero = refl
sign-i≡sign-j .(+ 0) .(s₂ ◃ suc n₂) eq | s₁ ◂ zero | s₂ ◂ suc n₂
with ∣ s₂ ◃ suc n₂ ∣ | abs-◃ s₂ (suc n₂)
... | .(suc n₂) | refl
with abs-cong {s₁} {sign (s₂ ◃ suc n₂) 𝕊* s} {0} {suc n₂ ℕ.* suc n} eq
... | ()
sign-i≡sign-j .(s₁ ◃ suc n₁) .(+ 0) eq | s₁ ◂ suc n₁ | s₂ ◂ zero
with ∣ s₁ ◃ suc n₁ ∣ | abs-◃ s₁ (suc n₁)
... | .(suc n₁) | refl
with abs-cong {sign (s₁ ◃ suc n₁) 𝕊* s} {s₁} {suc n₁ ℕ.* suc n} {0} eq
... | ()
sign-i≡sign-j .(s₁ ◃ suc n₁) .(s₂ ◃ suc n₂) eq | s₁ ◂ suc n₁ | s₂ ◂ suc n₂
with ∣ s₁ ◃ suc n₁ ∣ | abs-◃ s₁ (suc n₁)
| sign (s₁ ◃ suc n₁) | sign-◃ s₁ n₁
| ∣ s₂ ◃ suc n₂ ∣ | abs-◃ s₂ (suc n₂)
| sign (s₂ ◃ suc n₂) | sign-◃ s₂ n₂
... | .(suc n₁) | refl | .s₁ | refl | .(suc n₂) | refl | .s₂ | refl =
𝕊ₚ.*-cancelʳ-≡ s₁ s₂ (sign-cong eq)
*-cancelˡ-≡ : ∀ i j k → i ≢ + 0 → i * j ≡ i * k → j ≡ k
*-cancelˡ-≡ i j k
rewrite *-comm i j
| *-comm i k
= *-cancelʳ-≡ j k i
*-cancelʳ-≤-pos : ∀ m n o → m * + suc o ≤ n * + suc o → m ≤ n
*-cancelʳ-≤-pos (-[1+ m ]) (-[1+ n ]) o (-≤- n≤m) =
-≤- (ℕₚ.≤-pred (ℕₚ.*-cancelʳ-≤ (suc n) (suc m) o (s≤s n≤m)))
*-cancelʳ-≤-pos -[1+ _ ] (+ _) _ _ = -≤+
*-cancelʳ-≤-pos (+ 0) -[1+ _ ] _ ()
*-cancelʳ-≤-pos (+ suc _) -[1+ _ ] _ ()
*-cancelʳ-≤-pos (+ 0) (+ 0) _ _ = +≤+ z≤n
*-cancelʳ-≤-pos (+ 0) (+ suc _) _ _ = +≤+ z≤n
*-cancelʳ-≤-pos (+ suc _) (+ 0) _ (+≤+ ())
*-cancelʳ-≤-pos (+ suc m) (+ suc n) o (+≤+ m≤n) =
+≤+ (ℕₚ.*-cancelʳ-≤ (suc m) (suc n) o m≤n)
*-cancelˡ-≤-pos : ∀ m n o → + suc m * n ≤ + suc m * o → n ≤ o
*-cancelˡ-≤-pos m n o
rewrite *-comm (+ suc m) n
| *-comm (+ suc m) o
= *-cancelʳ-≤-pos n o m
*-monoʳ-≤-pos : ∀ n → (_* + suc n) Preserves _≤_ ⟶ _≤_
*-monoʳ-≤-pos _ (-≤+ {n = 0}) = -≤+
*-monoʳ-≤-pos _ (-≤+ {n = suc _}) = -≤+
*-monoʳ-≤-pos x (-≤- n≤m) =
-≤- (ℕₚ.≤-pred (ℕₚ.*-mono-≤ (s≤s n≤m) (ℕₚ.≤-refl {x = suc x})))
*-monoʳ-≤-pos _ (+≤+ {m = 0} {n = 0} m≤n) = +≤+ m≤n
*-monoʳ-≤-pos _ (+≤+ {m = 0} {n = suc _} m≤n) = +≤+ z≤n
*-monoʳ-≤-pos _ (+≤+ {m = suc _} {n = 0} ())
*-monoʳ-≤-pos x (+≤+ {m = suc _} {n = suc _} m≤n) =
+≤+ ((ℕₚ.*-mono-≤ m≤n (ℕₚ.≤-refl {x = suc x})))
*-monoʳ-≤-non-neg : ∀ n → (_* + n) Preserves _≤_ ⟶ _≤_
*-monoʳ-≤-non-neg (suc n) = *-monoʳ-≤-pos n
*-monoʳ-≤-non-neg zero {i} {j} i≤j
rewrite *-zeroʳ i
| *-zeroʳ j
= +≤+ z≤n
*-monoˡ-≤-non-neg : ∀ n → (+ n *_) Preserves _≤_ ⟶ _≤_
*-monoˡ-≤-non-neg n {i} {j} i≤j
rewrite *-comm (+ n) i
| *-comm (+ n) j
= *-monoʳ-≤-non-neg n i≤j
*-monoˡ-≤-pos : ∀ n → (+ suc n *_) Preserves _≤_ ⟶ _≤_
*-monoˡ-≤-pos n = *-monoˡ-≤-non-neg (suc n)
-1*n≡-n : ∀ n → -[1+ 0 ] * n ≡ - n
-1*n≡-n (+ zero) = refl
-1*n≡-n (+ suc n) = cong -[1+_] (ℕₚ.+-identityʳ n)
-1*n≡-n -[1+ n ] = cong (λ v → + suc v) (ℕₚ.+-identityʳ n)
neg-distribˡ-* : ∀ x y → - (x * y) ≡ (- x) * y
neg-distribˡ-* x y = begin
- (x * y) ≡⟨ sym (-1*n≡-n (x * y)) ⟩
-[1+ 0 ] * (x * y) ≡⟨ sym (*-assoc -[1+ 0 ] x y) ⟩
-[1+ 0 ] * x * y ≡⟨ cong (_* y) (-1*n≡-n x) ⟩
- x * y ∎ where open ≡-Reasoning
neg-distribʳ-* : ∀ x y → - (x * y) ≡ x * (- y)
neg-distribʳ-* x y = begin
- (x * y) ≡⟨ cong -_ (*-comm x y) ⟩
- (y * x) ≡⟨ neg-distribˡ-* y x ⟩
- y * x ≡⟨ *-comm (- y) x ⟩
x * (- y) ∎ where open ≡-Reasoning
------------------------------------------------------------------------
-- Properties _⊓_
⊓-comm : Commutative _⊓_
⊓-comm -[1+ m ] -[1+ n ] = cong -[1+_] (ℕₚ.⊔-comm m n)
⊓-comm -[1+ m ] (+ n) = refl
⊓-comm (+ m) -[1+ n ] = refl
⊓-comm (+ m) (+ n) = cong +_ (ℕₚ.⊓-comm m n)
⊓-assoc : Associative _⊓_
⊓-assoc -[1+ m ] -[1+ n ] -[1+ p ] = cong -[1+_] (ℕₚ.⊔-assoc m n p)
⊓-assoc -[1+ m ] -[1+ n ] (+ p) = refl
⊓-assoc -[1+ m ] (+ n) -[1+ p ] = refl
⊓-assoc -[1+ m ] (+ n) (+ p) = refl
⊓-assoc (+ m) -[1+ n ] -[1+ p ] = refl
⊓-assoc (+ m) -[1+ n ] (+ p) = refl
⊓-assoc (+ m) (+ n) -[1+ p ] = refl
⊓-assoc (+ m) (+ n) (+ p) = cong +_ (ℕₚ.⊓-assoc m n p)
⊓-idem : Idempotent _⊓_
⊓-idem (+ m) = cong +_ (ℕₚ.⊓-idem m)
⊓-idem -[1+ m ] = cong -[1+_] (ℕₚ.⊔-idem m)
⊓-sel : Selective _⊓_
⊓-sel -[1+ m ] -[1+ n ] = Sum.map (cong -[1+_]) (cong -[1+_]) $ ℕₚ.⊔-sel m n
⊓-sel -[1+ m ] (+ n) = inj₁ refl
⊓-sel (+ m) -[1+ n ] = inj₂ refl
⊓-sel (+ m) (+ n) = Sum.map (cong ℤ.pos) (cong ℤ.pos) $ ℕₚ.⊓-sel m n
m≤n⇒m⊓n≡m : ∀ {m n} → m ≤ n → m ⊓ n ≡ m
m≤n⇒m⊓n≡m -≤+ = refl
m≤n⇒m⊓n≡m (-≤- n≤m) = cong -[1+_] (ℕₚ.m≤n⇒n⊔m≡n n≤m)
m≤n⇒m⊓n≡m (+≤+ m≤n) = cong +_ (ℕₚ.m≤n⇒m⊓n≡m m≤n)
m⊓n≡m⇒m≤n : ∀ {m n} → m ⊓ n ≡ m → m ≤ n
m⊓n≡m⇒m≤n { -[1+ m ]} { -[1+ n ]} eq = -≤- (ℕₚ.n⊔m≡n⇒m≤n (-[1+-injective eq))
m⊓n≡m⇒m≤n { -[1+ m ]} {+ n} eq = -≤+
m⊓n≡m⇒m≤n {+ m} { -[1+ n ]} ()
m⊓n≡m⇒m≤n {+ m} {+ n} eq = +≤+ (ℕₚ.m⊓n≡m⇒m≤n (+-injective eq))
m≥n⇒m⊓n≡n : ∀ {m n} → m ≥ n → m ⊓ n ≡ n
m≥n⇒m⊓n≡n {m} {n} pr rewrite ⊓-comm m n = m≤n⇒m⊓n≡m pr
m⊓n≡n⇒m≥n : ∀ {m n} → m ⊓ n ≡ n → m ≥ n
m⊓n≡n⇒m≥n {m} {n} eq rewrite ⊓-comm m n = m⊓n≡m⇒m≤n eq
m⊓n≤n : ∀ m n → m ⊓ n ≤ n
m⊓n≤n -[1+ m ] -[1+ n ] = -≤- (ℕₚ.n≤m⊔n m n)
m⊓n≤n -[1+ m ] (+ n) = -≤+
m⊓n≤n (+ m) -[1+ n ] = -≤- ℕₚ.≤-refl
m⊓n≤n (+ m) (+ n) = +≤+ (ℕₚ.m⊓n≤n m n)
m⊓n≤m : ∀ m n → m ⊓ n ≤ m
m⊓n≤m m n rewrite ⊓-comm m n = m⊓n≤n n m
------------------------------------------------------------------------
-- Properties _⊔_
⊔-comm : Commutative _⊔_
⊔-comm -[1+ m ] -[1+ n ] = cong -[1+_] (ℕₚ.⊓-comm m n)
⊔-comm -[1+ m ] (+ n) = refl
⊔-comm (+ m) -[1+ n ] = refl
⊔-comm (+ m) (+ n) = cong +_ (ℕₚ.⊔-comm m n)
⊔-assoc : Associative _⊔_
⊔-assoc -[1+ m ] -[1+ n ] -[1+ p ] = cong -[1+_] (ℕₚ.⊓-assoc m n p)
⊔-assoc -[1+ m ] -[1+ n ] (+ p) = refl
⊔-assoc -[1+ m ] (+ n) -[1+ p ] = refl
⊔-assoc -[1+ m ] (+ n) (+ p) = refl
⊔-assoc (+ m) -[1+ n ] -[1+ p ] = refl
⊔-assoc (+ m) -[1+ n ] (+ p) = refl
⊔-assoc (+ m) (+ n) -[1+ p ] = refl
⊔-assoc (+ m) (+ n) (+ p) = cong +_ (ℕₚ.⊔-assoc m n p)
⊔-idem : Idempotent _⊔_
⊔-idem (+ m) = cong +_ (ℕₚ.⊔-idem m)
⊔-idem -[1+ m ] = cong -[1+_] (ℕₚ.⊓-idem m)
⊔-sel : Selective _⊔_
⊔-sel -[1+ m ] -[1+ n ] = Sum.map (cong -[1+_]) (cong -[1+_]) $ ℕₚ.⊓-sel m n
⊔-sel -[1+ m ] (+ n) = inj₂ refl
⊔-sel (+ m) -[1+ n ] = inj₁ refl
⊔-sel (+ m) (+ n) = Sum.map (cong ℤ.pos) (cong ℤ.pos) $ ℕₚ.⊔-sel m n
m≤n⇒m⊔n≡n : ∀ {m n} → m ≤ n → m ⊔ n ≡ n
m≤n⇒m⊔n≡n -≤+ = refl
m≤n⇒m⊔n≡n (-≤- n≤m) = cong -[1+_] (ℕₚ.m≤n⇒n⊓m≡m n≤m)
m≤n⇒m⊔n≡n (+≤+ m≤n) = cong +_ (ℕₚ.m≤n⇒m⊔n≡n m≤n)
m⊔n≡n⇒m≤n : ∀ {m n} → m ⊔ n ≡ n → m ≤ n
m⊔n≡n⇒m≤n { -[1+ m ]} { -[1+ n ]} eq = -≤- (ℕₚ.m⊓n≡n⇒n≤m (-[1+-injective eq))
m⊔n≡n⇒m≤n { -[1+ m ]} {+ n} eq = -≤+
m⊔n≡n⇒m≤n {+ m} { -[1+ n ]} ()
m⊔n≡n⇒m≤n {+ m} {+ n} eq = +≤+ (ℕₚ.n⊔m≡m⇒n≤m (+-injective eq))
m≥n⇒m⊔n≡m : ∀ {m n} → m ≥ n → m ⊔ n ≡ m
m≥n⇒m⊔n≡m {m} {n} pr rewrite ⊔-comm m n = m≤n⇒m⊔n≡n pr
m⊔n≡m⇒m≥n : ∀ {m n} → m ⊔ n ≡ m → m ≥ n
m⊔n≡m⇒m≥n {m} {n} eq rewrite ⊔-comm m n = m⊔n≡n⇒m≤n eq
m≤m⊔n : ∀ m n → m ≤ m ⊔ n
m≤m⊔n -[1+ m ] -[1+ n ] = -≤- (ℕₚ.m⊓n≤m m n)
m≤m⊔n -[1+ m ] (+ n) = -≤+
m≤m⊔n (+ m) -[1+ n ] = +≤+ ℕₚ.≤-refl
m≤m⊔n (+ m) (+ n) = +≤+ (ℕₚ.m≤m⊔n m n)
n≤m⊔n : ∀ m n → n ≤ m ⊔ n
n≤m⊔n m n rewrite ⊔-comm m n = m≤m⊔n n m
neg-distrib-⊔-⊓ : ∀ m n → - (m ⊔ n) ≡ - m ⊓ - n
neg-distrib-⊔-⊓ -[1+ m ] -[1+ n ] = refl
neg-distrib-⊔-⊓ -[1+ m ] (+ zero) = refl
neg-distrib-⊔-⊓ -[1+ m ] (+ suc n) = refl
neg-distrib-⊔-⊓ (+ zero) -[1+ n ] = refl
neg-distrib-⊔-⊓ (+ suc m) -[1+ n ] = refl
neg-distrib-⊔-⊓ (+ zero) (+ zero) = refl
neg-distrib-⊔-⊓ (+ zero) (+ suc n) = refl
neg-distrib-⊔-⊓ (+ suc m) (+ zero) = refl
neg-distrib-⊔-⊓ (+ suc m) (+ suc n) = refl
neg-distrib-⊓-⊔ : ∀ m n → - (m ⊓ n) ≡ - m ⊔ - n
neg-distrib-⊓-⊔ -[1+ m ] -[1+ n ] = refl
neg-distrib-⊓-⊔ -[1+ m ] (+ zero) = refl
neg-distrib-⊓-⊔ -[1+ m ] (+ suc n) = refl
neg-distrib-⊓-⊔ (+ zero) -[1+ n ] = refl
neg-distrib-⊓-⊔ (+ suc m) -[1+ n ] = refl
neg-distrib-⊓-⊔ (+ zero) (+ zero) = refl
neg-distrib-⊓-⊔ (+ zero) (+ suc n) = refl
neg-distrib-⊓-⊔ (+ suc m) (+ zero) = refl
neg-distrib-⊓-⊔ (+ suc m) (+ suc n) = refl
------------------------------------------------------------------------
-- Properties _≤_
drop‿+≤+ : ∀ {m n} → + m ≤ + n → m ℕ.≤ n
drop‿+≤+ (+≤+ m≤n) = m≤n
drop‿-≤- : ∀ {m n} → -[1+ m ] ≤ -[1+ n ] → n ℕ.≤ m
drop‿-≤- (-≤- n≤m) = n≤m
≤-reflexive : _≡_ ⇒ _≤_
≤-reflexive { -[1+ n ]} refl = -≤- ℕₚ.≤-refl
≤-reflexive {+ n} refl = +≤+ ℕₚ.≤-refl
≤-refl : Reflexive _≤_
≤-refl = ≤-reflexive refl
≤-trans : Transitive _≤_
≤-trans -≤+ (+≤+ n≤m) = -≤+
≤-trans (-≤- n≤m) -≤+ = -≤+
≤-trans (-≤- n≤m) (-≤- k≤n) = -≤- (ℕₚ.≤-trans k≤n n≤m)
≤-trans (+≤+ m≤n) (+≤+ n≤k) = +≤+ (ℕₚ.≤-trans m≤n n≤k)
≤-antisym : Antisymmetric _≡_ _≤_
≤-antisym -≤+ ()
≤-antisym (-≤- n≤m) (-≤- m≤n) = cong -[1+_] $ ℕₚ.≤-antisym m≤n n≤m
≤-antisym (+≤+ m≤n) (+≤+ n≤m) = cong (+_) $ ℕₚ.≤-antisym m≤n n≤m
≤-total : Total _≤_
≤-total (-[1+ m ]) (-[1+ n ]) with ℕₚ.≤-total m n
... | inj₁ m≤n = inj₂ (-≤- m≤n)
... | inj₂ n≤m = inj₁ (-≤- n≤m)
≤-total (-[1+ m ]) (+ n ) = inj₁ -≤+
≤-total (+ m ) (-[1+ n ]) = inj₂ -≤+
≤-total (+ m ) (+ n ) with ℕₚ.≤-total m n
... | inj₁ m≤n = inj₁ (+≤+ m≤n)
... | inj₂ n≤m = inj₂ (+≤+ n≤m)
infix 4 _≤?_
_≤?_ : Decidable _≤_
-[1+ m ] ≤? -[1+ n ] = Dec.map′ -≤- drop‿-≤- (ℕ._≤?_ n m)
-[1+ m ] ≤? + n = yes -≤+
+ m ≤? -[1+ n ] = no λ ()
+ m ≤? + n = Dec.map′ +≤+ drop‿+≤+ (ℕ._≤?_ m n)
≤-isPreorder : IsPreorder _≡_ _≤_
≤-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ≤-reflexive
; trans = ≤-trans
}
≤-preorder : Preorder _ _ _
≤-preorder = record
{ isPreorder = ≤-isPreorder
}
≤-isPartialOrder : IsPartialOrder _≡_ _≤_
≤-isPartialOrder = record
{ isPreorder = ≤-isPreorder
; antisym = ≤-antisym
}
≤-poset : Poset _ _ _
≤-poset = record
{ Carrier = ℤ
; _≈_ = _≡_
; _≤_ = _≤_
; isPartialOrder = ≤-isPartialOrder
}
≤-isTotalOrder : IsTotalOrder _≡_ _≤_
≤-isTotalOrder = record
{ isPartialOrder = ≤-isPartialOrder
; total = ≤-total
}
≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_
≤-isDecTotalOrder = record
{ isTotalOrder = ≤-isTotalOrder
; _≟_ = _≟_
; _≤?_ = _≤?_
}
≤-decTotalOrder : DecTotalOrder _ _ _
≤-decTotalOrder = record
{ Carrier = ℤ
; _≈_ = _≡_
; _≤_ = _≤_
; isDecTotalOrder = ≤-isDecTotalOrder
}
-- Other properties of _≤_
0⊖m≤+ : ∀ m {n} → 0 ⊖ m ≤ + n
0⊖m≤+ zero = +≤+ z≤n
0⊖m≤+ (suc m) = -≤+
≤-step : ∀ {n m} → n ≤ m → n ≤ sucℤ m
≤-step -≤+ = -≤+
≤-step (+≤+ m≤n) = +≤+ (ℕₚ.≤-step m≤n)
≤-step (-≤- z≤n) = -≤+
≤-step (-≤- (ℕ.s≤s n≤m)) = -≤- (ℕₚ.≤-step n≤m)
≤-steps : ∀ {m n} p → m ≤ n → m ≤ + p + n
≤-steps {n = n} zero m≤n rewrite +-identityˡ n = m≤n
≤-steps {n = n} (suc p) m≤n rewrite suc-+ p n = ≤-step (≤-steps p m≤n)
≤-step-neg : ∀ {m n} → m ≤ n → pred m ≤ n
≤-step-neg -≤+ = -≤+
≤-step-neg (-≤- n≤m) = -≤- (ℕₚ.≤-step n≤m)
≤-step-neg (+≤+ z≤n) = -≤+
≤-step-neg (+≤+ (ℕ.s≤s m≤n)) = +≤+ (ℕₚ.≤-step m≤n)
≤-steps-neg : ∀ {m n} p → m ≤ n → m - + p ≤ n
≤-steps-neg {m} zero m≤n rewrite +-identityʳ m = m≤n
≤-steps-neg {m} (suc p) m≤n rewrite minus-suc m p = ≤-step-neg (≤-steps-neg p m≤n)
⊖-monoʳ-≥-≤ : ∀ p → (p ⊖_) Preserves ℕ._≥_ ⟶ _≤_
⊖-monoʳ-≥-≤ zero (z≤n {n}) = 0⊖m≤+ n
⊖-monoʳ-≥-≤ zero (ℕ.s≤s m≤n) = -≤- m≤n
⊖-monoʳ-≥-≤ (suc p) (z≤n {zero}) = ≤-refl
⊖-monoʳ-≥-≤ (suc p) (z≤n {suc n}) = ≤-step (⊖-monoʳ-≥-≤ p (z≤n {n}))
⊖-monoʳ-≥-≤ (suc p) (ℕ.s≤s m≤n) = ⊖-monoʳ-≥-≤ p m≤n
⊖-monoˡ-≤ : ∀ p → (_⊖ p) Preserves ℕ._≤_ ⟶ _≤_
⊖-monoˡ-≤ zero m≤n = +≤+ m≤n
⊖-monoˡ-≤ (suc p) (z≤n {0}) = ≤-refl
⊖-monoˡ-≤ (suc p) (z≤n {(suc m)}) = ≤-trans (⊖-monoʳ-≥-≤ 0 (ℕₚ.n≤1+n p)) (⊖-monoˡ-≤ p z≤n)
⊖-monoˡ-≤ (suc p) (ℕ.s≤s m≤n) = ⊖-monoˡ-≤ p m≤n
pred-mono : pred Preserves _≤_ ⟶ _≤_
pred-mono (-≤+ {n = 0}) = -≤- z≤n
pred-mono (-≤+ {n = suc n}) = -≤+
pred-mono (-≤- n≤m) = -≤- (ℕ.s≤s n≤m)
pred-mono (+≤+ m≤n) = ⊖-monoˡ-≤ 1 m≤n
suc-mono : sucℤ Preserves _≤_ ⟶ _≤_
suc-mono (-≤+ {m}) = 0⊖m≤+ m
suc-mono (-≤- n≤m) = ⊖-monoʳ-≥-≤ zero n≤m
suc-mono (+≤+ m≤n) = +≤+ (ℕ.s≤s m≤n)
+-pos-monoʳ-≤ : ∀ n → (_+_ (+ n)) Preserves _≤_ ⟶ _≤_
+-pos-monoʳ-≤ zero {i} {j} i≤j
rewrite +-identityˡ i
| +-identityˡ j
= i≤j
+-pos-monoʳ-≤ (suc n) {i} {j} i≤j
rewrite suc-+ n i
| suc-+ n j
= suc-mono (+-pos-monoʳ-≤ n i≤j)
+-neg-monoʳ-≤ : ∀ n → (_+_ -[1+ n ]) Preserves _≤_ ⟶ _≤_
+-neg-monoʳ-≤ zero i≤j = pred-mono i≤j
+-neg-monoʳ-≤ (suc n) {i} {j} i≤j
rewrite pred-+ -[1+ n ] i
| pred-+ -[1+ n ] j
= pred-mono (+-neg-monoʳ-≤ n i≤j)
+-monoʳ-≤ : ∀ n → (_+_ n) Preserves _≤_ ⟶ _≤_
+-monoʳ-≤ (+ n) = +-pos-monoʳ-≤ n
+-monoʳ-≤ -[1+ n ] = +-neg-monoʳ-≤ n
+-monoˡ-≤ : ∀ n → (_+ n) Preserves _≤_ ⟶ _≤_
+-monoˡ-≤ n {i} {j} i≤j
rewrite +-comm i n
| +-comm j n
= +-monoʳ-≤ n i≤j
+-mono-≤ : _+_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_
+-mono-≤ {m} {n} {i} {j} m≤n i≤j = begin
m + i ≤⟨ +-monoˡ-≤ i m≤n ⟩
n + i ≤⟨ +-monoʳ-≤ n i≤j ⟩
n + j ∎
where open POR ≤-poset
neg-≤-pos : ∀ {m n} → - (+ m) ≤ + n
neg-≤-pos {zero} = +≤+ z≤n
neg-≤-pos {suc m} = -≤+
neg-mono-≤-≥ : -_ Preserves _≤_ ⟶ _≥_
neg-mono-≤-≥ -≤+ = neg-≤-pos
neg-mono-≤-≥ (-≤- n≤m) = +≤+ (s≤s n≤m)
neg-mono-≤-≥ (+≤+ z≤n) = neg-≤-pos
neg-mono-≤-≥ (+≤+ (s≤s m≤n)) = -≤- m≤n
m≤m+n : ∀ {m} n → m ≤ m + + n
m≤m+n {m} n = begin
m ≡⟨ sym (+-identityʳ m) ⟩
m + + 0 ≤⟨ +-monoʳ-≤ m (+≤+ z≤n) ⟩
m + + n ∎
where open POR ≤-poset
m-n≤m : ∀ m n → m - + n ≤ m
m-n≤m m n = ≤-steps-neg n ≤-refl
n≤m+n : ∀ m {n} → n ≤ + m + n
n≤m+n m {n} rewrite +-comm (+ m) n = m≤m+n m
m≤n⇒m-n≤0 : ∀ {m n} → m ≤ n → m - n ≤ + 0
m≤n⇒m-n≤0 (-≤+ {n = n}) = ≤-steps-neg n -≤+
m≤n⇒m-n≤0 (-≤- {n = n} n≤m) = ≤-trans (⊖-monoʳ-≥-≤ n n≤m) (≤-reflexive (n⊖n≡0 n))
m≤n⇒m-n≤0 (+≤+ {n = 0} z≤n) = +≤+ z≤n
m≤n⇒m-n≤0 (+≤+ {n = suc n} z≤n) = -≤+
m≤n⇒m-n≤0 (+≤+ (ℕ.s≤s {m} m≤n)) = ≤-trans (⊖-monoʳ-≥-≤ m m≤n) (≤-reflexive (n⊖n≡0 m))
m-n≤0⇒m≤n : ∀ {m n} → m - n ≤ + 0 → m ≤ n
m-n≤0⇒m≤n {m} {n} m-n≤0 = begin
m ≡⟨ sym (+-identityʳ m) ⟩
m + + 0 ≡⟨ cong (_+_ m) (sym (+-inverseˡ n)) ⟩
m + (- n + n) ≡⟨ sym (+-assoc m (- n) n) ⟩
(m - n) + n ≤⟨ +-monoˡ-≤ n m-n≤0 ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎
where open POR ≤-poset
m≤n⇒0≤n-m : ∀ {m n} → m ≤ n → + 0 ≤ n - m
m≤n⇒0≤n-m {m} {n} m≤n = begin
+ 0 ≡⟨ sym (+-inverseʳ m) ⟩
m - m ≤⟨ +-monoˡ-≤ (- m) m≤n ⟩
n - m ∎
where open POR ≤-poset
0≤n-m⇒m≤n : ∀ {m n} → + 0 ≤ n - m → m ≤ n
0≤n-m⇒m≤n {m} {n} 0≤n-m = begin
m ≡⟨ sym (+-identityˡ m) ⟩
+ 0 + m ≤⟨ +-monoˡ-≤ m 0≤n-m ⟩
n - m + m ≡⟨ +-assoc n (- m) m ⟩
n + (- m + m) ≡⟨ cong (_+_ n) (+-inverseˡ m) ⟩
n + + 0 ≡⟨ +-identityʳ n ⟩
n ∎
where open POR ≤-poset
n≤1+n : ∀ n → n ≤ (+ 1) + n
n≤1+n n = ≤-step ≤-refl
≤-irrelevant : Irrelevant _≤_
≤-irrelevant -≤+ -≤+ = refl
≤-irrelevant (-≤- n≤m₁) (-≤- n≤m₂) = cong -≤- (ℕₚ.≤-irrelevant n≤m₁ n≤m₂)
≤-irrelevant (+≤+ n≤m₁) (+≤+ n≤m₂) = cong +≤+ (ℕₚ.≤-irrelevant n≤m₁ n≤m₂)
------------------------------------------------------------------------
-- Properties _<_
-<+ : ∀ {m n} → -[1+ m ] < + n
-<+ {0} = +≤+ z≤n
-<+ {suc _} = -≤+
<-irrefl : Irreflexive _≡_ _<_
<-irrefl { + n} refl (+≤+ 1+n≤n) = ℕₚ.<-irrefl refl 1+n≤n
<-irrefl { -[1+ zero ]} refl ()
<-irrefl { -[1+ suc n ]} refl (-≤- 1+n≤n) = ℕₚ.<-irrefl refl 1+n≤n
>-irrefl : Irreflexive _≡_ _>_
>-irrefl = <-irrefl ∘ sym
<-asym : Asymmetric _<_
<-asym {+ n} {+ m} (+≤+ n<m) (+≤+ m<n) =
ℕₚ.<-asym n<m m<n
<-asym {+ n} { -[1+ m ]} () _
<-asym { -[1+ n ]} {+_ n₁} _ ()
<-asym { -[1+ 0 ]} { -[1+_] _} () _
<-asym { -[1+ _ ]} { -[1+_] 0} _ ()
<-asym { -[1+ suc n ]} { -[1+ suc m ]} (-≤- n<m) (-≤- m<n) =
ℕₚ.<-asym n<m m<n
≤-<-trans : Trans _≤_ _<_ _<_
≤-<-trans { -[1+ m ]} {+ n} {+ p} -≤+ (+≤+ 1+n≤p) = -<+ {m} {p}
≤-<-trans {+ m} {+ n} {+ p} (+≤+ m≤n) (+≤+ 1+n≤p) = +≤+ (ℕₚ.≤-trans (ℕ.s≤s m≤n) 1+n≤p)
≤-<-trans { -[1+ m ]} { -[1+ n ]} (-≤- n≤m) n<p = ≤-trans (⊖-monoʳ-≥-≤ 0 n≤m) n<p
<-≤-trans : Trans _<_ _≤_ _<_
<-≤-trans = ≤-trans
<⇒≤ : ∀ {m n} → m < n → m ≤ n
<⇒≤ m<n = ≤-trans (n≤1+n _) m<n
<-trans : Transitive _<_
<-trans {m} {n} {p} m<n n<p = ≤-<-trans {m} {n} {p} (<⇒≤ m<n) n<p
<-cmp : Trichotomous _≡_ _<_
<-cmp (+ m) (+ n) with ℕₚ.<-cmp m n
... | tri< m<n m≢n m≯n =
tri< (+≤+ m<n) (m≢n ∘ +-injective) (m≯n ∘ drop‿+≤+)
... | tri≈ m≮n m≡n m≯n =
tri≈ (m≮n ∘ drop‿+≤+) (cong (+_) m≡n) (m≯n ∘ drop‿+≤+)
... | tri> m≮n m≢n m>n =
tri> (m≮n ∘ drop‿+≤+) (m≢n ∘ +-injective) (+≤+ m>n)
<-cmp (+_ m) -[1+ 0 ] = tri> (λ()) (λ()) (+≤+ z≤n)
<-cmp (+_ m) -[1+ suc n ] = tri> (λ()) (λ()) -≤+
<-cmp -[1+ 0 ] (+ n) = tri< (+≤+ z≤n) (λ()) (λ())
<-cmp -[1+ suc m ] (+ n) = tri< -≤+ (λ()) (λ())
<-cmp -[1+ 0 ] -[1+ 0 ] = tri≈ (λ()) refl (λ())
<-cmp -[1+ 0 ] -[1+ suc n ] = tri> (λ()) (λ()) (-≤- z≤n)
<-cmp -[1+ suc m ] -[1+ 0 ] = tri< (-≤- z≤n) (λ()) (λ())
<-cmp -[1+ suc m ] -[1+ suc n ] with ℕₚ.<-cmp (suc m) (suc n)
... | tri< m<n m≢n m≯n =
tri> (m≯n ∘ s≤s ∘ drop‿-≤-) (m≢n ∘ -[1+-injective) (-≤- (ℕₚ.≤-pred m<n))
... | tri≈ m≮n m≡n m≯n =
tri≈ (m≯n ∘ ℕ.s≤s ∘ drop‿-≤-) (cong -[1+_] m≡n) (m≮n ∘ ℕ.s≤s ∘ drop‿-≤-)
... | tri> m≮n m≢n m>n =
tri< (-≤- (ℕₚ.≤-pred m>n)) (m≢n ∘ -[1+-injective) (m≮n ∘ s≤s ∘ drop‿-≤-)
<-isStrictPartialOrder : IsStrictPartialOrder _≡_ _<_
<-isStrictPartialOrder = record
{ isEquivalence = isEquivalence
; irrefl = <-irrefl
; trans = λ {i} → <-trans {i}
; <-resp-≈ = (λ {x} → subst (x <_)) , subst (_< _)
}
<-strictPartialOrder : StrictPartialOrder _ _ _
<-strictPartialOrder = record
{ isStrictPartialOrder = <-isStrictPartialOrder
}
<-isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_
<-isStrictTotalOrder = record
{ isEquivalence = isEquivalence
; trans = λ {i} → <-trans {i}
; compare = <-cmp
}
<-strictTotalOrder : StrictTotalOrder _ _ _
<-strictTotalOrder = record
{ isStrictTotalOrder = <-isStrictTotalOrder
}
-- Other properties of _<_
n≮n : ∀ {n} → n ≮ n
n≮n {+ n} (+≤+ n<n) = contradiction n<n ℕₚ.1+n≰n
n≮n { -[1+ 0 ]} ()
n≮n { -[1+ suc n ]} (-≤- n<n) = contradiction n<n ℕₚ.1+n≰n
>⇒≰ : ∀ {x y} → x > y → x ≰ y
>⇒≰ {y = y} x>y x≤y = contradiction (<-≤-trans {i = y} x>y x≤y) n≮n
≰⇒> : ∀ {x y} → x ≰ y → x > y
≰⇒> {+ m} {+ n} m≰n = +≤+ (ℕₚ.≰⇒> (m≰n ∘ +≤+))
≰⇒> {+ m} { -[1+ n ]} _ = -<+ {n} {m}
≰⇒> { -[1+ m ]} {+ _} m≰n = contradiction -≤+ m≰n
≰⇒> { -[1+ 0 ]} { -[1+ 0 ]} m≰n = contradiction ≤-refl m≰n
≰⇒> { -[1+ suc _ ]} { -[1+ 0 ]} m≰n = contradiction (-≤- z≤n) m≰n
≰⇒> { -[1+ m ]} { -[1+ suc n ]} m≰n with m ℕ.≤? n
... | yes m≤n = -≤- m≤n
... | no m≰n' = contradiction (-≤- (ℕₚ.≰⇒> m≰n')) m≰n
<-irrelevant : Irrelevant _<_
<-irrelevant = ≤-irrelevant
+-monoˡ-< : ∀ n → (_+ n) Preserves _<_ ⟶ _<_
+-monoˡ-< n {i} {j} i<j
rewrite sym (+-assoc (+ 1) i n)
= +-monoˡ-≤ n i<j
+-monoʳ-< : ∀ n → (_+_ n) Preserves _<_ ⟶ _<_
+-monoʳ-< n {i} {j} i<j
rewrite +-comm n i
| +-comm n j
= +-monoˡ-< n {i} {j} i<j
+-mono-< : _+_ Preserves₂ _<_ ⟶ _<_ ⟶ _<_
+-mono-< {m} {n} {i} {j} m<n i<j = begin
sucℤ (m + i) ≤⟨ suc-mono {m + i} (<⇒≤ (+-monoˡ-< i {m} {n} m<n)) ⟩
sucℤ (n + i) ≤⟨ +-monoʳ-< n i<j ⟩
n + j ∎
where open POR ≤-poset
+-mono-≤-< : _+_ Preserves₂ _≤_ ⟶ _<_ ⟶ _<_
+-mono-≤-< {m} {n} {i} {j} m≤n i<j = ≤-<-trans (+-monoˡ-≤ i m≤n) (+-monoʳ-< n i<j)
+-mono-<-≤ : _+_ Preserves₂ _<_ ⟶ _≤_ ⟶ _<_
+-mono-<-≤ {m} {n} {i} {j} m<n i≤j =
<-≤-trans {m + i} {n + i} {n + j} (+-monoˡ-< i {m} {n} m<n) (+-monoʳ-≤ n i≤j)
------------------------------------------------------------------------
-- Extra properties
m≤pred[n]⇒m<n : ∀ {m n} → m ≤ pred n → m < n
m≤pred[n]⇒m<n {m} {n} m≤predn = begin
sucℤ m ≤⟨ +-monoʳ-≤ (+ 1) m≤predn ⟩
+ 1 + pred n ≡⟨ sym (+-assoc (+ 1) -[1+ 0 ] n) ⟩
(+ 1 + -[1+ 0 ]) + n ≡⟨ cong (_+ n) (+-inverseʳ (+ 1)) ⟩
+ 0 + n ≡⟨ +-identityˡ n ⟩
n ∎
where open POR ≤-poset
m<n⇒m≤pred[n] : ∀ {m n} → m < n → m ≤ pred n
m<n⇒m≤pred[n] {m} {n} m<n = begin
m ≡⟨ sym (pred-suc m) ⟩
pred (sucℤ m) ≤⟨ pred-mono m<n ⟩
pred n ∎
where open POR ≤-poset
neg-mono-<-> : -_ Preserves _<_ ⟶ _>_
neg-mono-<-> {i} {j} i<j = begin
+ 1 - j ≡⟨ cong (_- j) (neg-involutive (+ 1)) ⟩
- - + 1 - j ≡⟨ sym (neg-distrib-+ (- + 1) j) ⟩
- (- + 1 + j) ≤⟨ neg-mono-≤-≥ (m<n⇒m≤pred[n] i<j) ⟩
- i ∎
where open POR ≤-poset
------------------------------------------------------------------------
-- A specialised module for reasoning about the _≤_ and _<_ relations
module ≤-Reasoning where
open import Relation.Binary.Reasoning.Base.Triple
≤-isPreorder
(λ {i} → <-trans {i})
(resp₂ _<_)
<⇒≤
(λ {i} → <-≤-trans {i})
≤-<-trans
public hiding (_≈⟨_⟩_)
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.15
inverseˡ = +-inverseˡ
{-# WARNING_ON_USAGE inverseˡ
"Warning: inverseˡ was deprecated in v0.15.
Please use +-inverseˡ instead."
#-}
inverseʳ = +-inverseʳ
{-# WARNING_ON_USAGE inverseʳ
"Warning: inverseʳ was deprecated in v0.15.
Please use +-inverseʳ instead."
#-}
distribʳ = *-distribʳ-+
{-# WARNING_ON_USAGE distribʳ
"Warning: distribʳ was deprecated in v0.15.
Please use *-distribʳ-+ instead."
#-}
isCommutativeSemiring = +-*-isCommutativeSemiring
{-# WARNING_ON_USAGE isCommutativeSemiring
"Warning: isCommutativeSemiring was deprecated in v0.15.
Please use +-*-isCommutativeSemiring instead."
#-}
commutativeRing = +-*-commutativeRing
{-# WARNING_ON_USAGE commutativeRing
"Warning: commutativeRing was deprecated in v0.15.
Please use +-*-commutativeRing instead."
#-}
*-+-right-mono = *-monoʳ-≤-pos
{-# WARNING_ON_USAGE *-+-right-mono
"Warning: *-+-right-mono was deprecated in v0.15.
Please use *-monoʳ-≤-pos instead."
#-}
cancel-*-+-right-≤ = *-cancelʳ-≤-pos
{-# WARNING_ON_USAGE cancel-*-+-right-≤
"Warning: cancel-*-+-right-≤ was deprecated in v0.15.
Please use *-cancelʳ-≤-pos instead."
#-}
cancel-*-right = *-cancelʳ-≡
{-# WARNING_ON_USAGE cancel-*-right
"Warning: cancel-*-right was deprecated in v0.15.
Please use *-cancelʳ-≡ instead."
#-}
doubleNeg = neg-involutive
{-# WARNING_ON_USAGE doubleNeg
"Warning: doubleNeg was deprecated in v0.15.
Please use neg-involutive instead."
#-}
-‿involutive = neg-involutive
{-# WARNING_ON_USAGE -‿involutive
"Warning: -‿involutive was deprecated in v0.15.
Please use neg-involutive instead."
#-}
+-⊖-left-cancel = +-cancelˡ-⊖
{-# WARNING_ON_USAGE +-⊖-left-cancel
"Warning: +-⊖-left-cancel was deprecated in v0.15.
Please use +-cancelˡ-⊖ instead."
#-}
-- Version 1.0
≰→> = ≰⇒>
{-# WARNING_ON_USAGE ≰→>
"Warning: ≰→> was deprecated in v1.0.
Please use ≰⇒> instead."
#-}
≤-irrelevance = ≤-irrelevant
{-# WARNING_ON_USAGE ≤-irrelevance
"Warning: ≤-irrelevance was deprecated in v1.0.
Please use ≤-irrelevant instead."
#-}
<-irrelevance = <-irrelevant
{-# WARNING_ON_USAGE <-irrelevance
"Warning: <-irrelevance was deprecated in v1.0.
Please use <-irrelevant instead."
#-}
| {
"alphanum_fraction": 0.43863104,
"avg_line_length": 32.5512820513,
"ext": "agda",
"hexsha": "b910d836e65564d064b0790e069e97aea3e8a377",
"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/Integer/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/Integer/Properties.agda",
"max_line_length": 90,
"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/Integer/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 25141,
"size": 48241
} |
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LogicalFramework.AdequacyTheorems where
module Example5 where
-- First-order logic with equality.
open import Common.FOL.FOL-Eq public
postulate
A B C : Set
f₁ : A → C
f₂ : B → C
g : (A → C) → (B → C) → A ∨ B → C
g f₁ f₂ (inj₁ a) = f₁ a
g f₁ f₂ (inj₂ b) = f₂ b
g' : (A → C) → (B → C) → A ∨ B → C
g' f₁ f₂ x = case f₁ f₂ x
module Example7 where
-- First-order logic with equality.
open import Common.FOL.FOL-Eq public
postulate
C : D → D → Set
d : ∀ {a} → C a a
g : ∀ {a b} → a ≡ b → C a b
g refl = d
g' : ∀ {a b} → a ≡ b → C a b
g' {a} h = subst (C a) h d
module Example10 where
-- First-order logic with equality.
open import Common.FOL.FOL-Eq public
postulate
A B C : Set
f₁ : A → C
f₂ : B → C
f : A ∨ B → C
f (inj₁ a) = f₁ a
f (inj₂ b) = f₂ b
f' : A ∨ B → C
f' = case f₁ f₂
module Example20 where
-- First-order logic with equality.
open import Common.FOL.FOL-Eq public
f : {A : D → Set}{t t' : D} → t ≡ t' → A t → A t'
f {A} {t} {.t} refl At = d At
where
postulate d : A t → A t
f' : {A : D → Set}{t t' : D} → t ≡ t' → A t → A t'
f' {A} h At = subst A h At
module Example30 where
-- First-order logic with equality.
open import Common.FOL.FOL-Eq public
postulate
A B C E : Set
f₁ : A → E
f₂ : B → E
f₃ : C → E
g : (A ∨ B) ∨ C → E
g (inj₁ (inj₁ a)) = f₁ a
g (inj₁ (inj₂ b)) = f₂ b
g (inj₂ c) = f₃ c
g' : (A ∨ B) ∨ C → E
g' = case (case f₁ f₂) f₃
module Example40 where
infixl 9 _+_ _+'_
infix 7 _≡_
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
ℕ-ind : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n
ℕ-ind A A0 h zero = A0
ℕ-ind A A0 h (succ n) = h n (ℕ-ind A A0 h n)
data _≡_ (x : ℕ) : ℕ → Set where
refl : x ≡ x
subst : (A : ℕ → Set) → ∀ {x y} → x ≡ y → A x → A y
subst A refl Ax = Ax
_+_ : ℕ → ℕ → ℕ
zero + n = n
succ m + n = succ (m + n)
_+'_ : ℕ → ℕ → ℕ
m +' n = ℕ-ind (λ _ → ℕ) n (λ x y → succ y) m
-- Properties using pattern matching.
succCong : ∀ {m n} → m ≡ n → succ m ≡ succ n
succCong refl = refl
+-rightIdentity : ∀ n → n + zero ≡ n
+-rightIdentity zero = refl
+-rightIdentity (succ n) = succCong (+-rightIdentity n)
-- Properties using the basic inductive constants.
succCong' : ∀ {m n} → m ≡ n → succ m ≡ succ n
succCong' {m} h = subst (λ x → succ m ≡ succ x) h refl
+'-leftIdentity : ∀ n → zero +' n ≡ n
+'-leftIdentity n = refl
+'-rightIdentity : ∀ n → n +' zero ≡ n
+'-rightIdentity = ℕ-ind A A0 is
where
A : ℕ → Set
A n = n +' zero ≡ n
A0 : A zero
A0 = refl
is : ∀ n → A n → A (succ n)
is n ih = succCong' ih
module Example50 where
infixl 10 _*_
infixl 9 _+_
infix 7 _≡_
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
ℕ-ind : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n
ℕ-ind A A0 h zero = A0
ℕ-ind A A0 h (succ n) = h n (ℕ-ind A A0 h n)
data _≡_ (x : ℕ) : ℕ → Set where
refl : x ≡ x
ℕ-rec : {A : Set} → A → (ℕ → A → A) → ℕ → A
ℕ-rec {A} = ℕ-ind (λ _ → A)
_+_ : ℕ → ℕ → ℕ
m + n = ℕ-rec n (λ _ x → succ x) m
+-0x : ∀ n → zero + n ≡ n
+-0x n = refl
+-Sx : ∀ m n → succ m + n ≡ succ (m + n)
+-Sx m n = refl
_*_ : ℕ → ℕ → ℕ
m * n = ℕ-rec zero (λ _ x → n + x) m
*-0x : ∀ n → zero * n ≡ zero
*-0x n = refl
*-Sx : ∀ m n → succ m * n ≡ n + m * n
*-Sx m n = refl
| {
"alphanum_fraction": 0.4860426929,
"avg_line_length": 20.4134078212,
"ext": "agda",
"hexsha": "97a4aac62bdeba15ab685a91c1610590ab2f370c",
"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/AdequacyTheorems.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/AdequacyTheorems.agda",
"max_line_length": 71,
"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/AdequacyTheorems.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": 1543,
"size": 3654
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of right-scaling
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
-- The properties are parameterised by the two carriers and
-- the result equality.
module Algebra.Module.Definitions.Right
{a b ℓb} (A : Set a) {B : Set b} (_≈_ : Rel B ℓb)
where
open import Data.Product
open import Data.Sum
------------------------------------------------------------------------
-- Binary operations
open import Algebra.Core
------------------------------------------------------------------------
-- Properties of operations
RightIdentity : A → Opᵣ A B → Set _
RightIdentity a _∙ᴮ_ = ∀ m → (m ∙ᴮ a) ≈ m
Associative : Op₂ A → Opᵣ A B → Set _
Associative _∙ᴬ_ _∙ᴮ_ = ∀ m x y → ((m ∙ᴮ x) ∙ᴮ y) ≈ (m ∙ᴮ (x ∙ᴬ y))
_DistributesOverˡ_⟶_ : Opᵣ A B → Op₂ A → Op₂ B → Set _
_*_ DistributesOverˡ _+ᴬ_ ⟶ _+ᴮ_ =
∀ m x y → (m * (x +ᴬ y)) ≈ ((m * x) +ᴮ (m * y))
_DistributesOverʳ_ : Opᵣ A B → Op₂ B → Set _
_*_ DistributesOverʳ _+_ =
∀ x m n → ((m + n) * x) ≈ ((m * x) + (n * x))
LeftZero : B → Opᵣ A B → Set _
LeftZero z _∙_ = ∀ x → (z ∙ x) ≈ z
RightZero : A → B → Opᵣ A B → Set _
RightZero zᴬ zᴮ _∙_ = ∀ x → (x ∙ zᴬ) ≈ zᴮ
Commutative : Opᵣ A B → Set _
Commutative _∙_ = ∀ m x y → ((m ∙ x) ∙ y) ≈ ((m ∙ y) ∙ x)
LeftCongruent : ∀ {ℓa} → Rel A ℓa → Opᵣ A B → Set _
LeftCongruent ≈ᴬ _∙_ = ∀ {m} → (m ∙_) Preserves ≈ᴬ ⟶ _≈_
RightCongruent : Opᵣ A B → Set _
RightCongruent _∙_ = ∀ {x} → (_∙ x) Preserves _≈_ ⟶ _≈_
Congruent : ∀ {ℓa} → Rel A ℓa → Opᵣ A B → Set _
Congruent ≈ᴬ ∙ = ∙ Preserves₂ _≈_ ⟶ ≈ᴬ ⟶ _≈_
| {
"alphanum_fraction": 0.4850615114,
"avg_line_length": 28.45,
"ext": "agda",
"hexsha": "1612c47c4cafde51261088a74b465c16eca1392a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Algebra/Module/Definitions/Right.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Algebra/Module/Definitions/Right.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Algebra/Module/Definitions/Right.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": 674,
"size": 1707
} |
module Lec1Done where
-- the -- mark introduces a "comment to end of line"
------------------------------------------------------------------------------
-- some basic "logical" types
------------------------------------------------------------------------------
data Zero : Set where
-- to give a value in a data, choose one constructor
-- there are no constructors
-- so that's impossible
record One : Set where
-- to give a value in a record type, fill all its fields
-- there are no fields
-- so that's trivial
-- (can we have a constructor, for convenience?)
constructor <>
{-# COMPILE GHC One = data () (()) #-}
data _+_ (S : Set)(T : Set) : Set where -- "where" wants an indented block
-- to offer a choice of constructors, list them with their types
inl : S -> S + T -- constructors can pack up stuff
inr : T -> S + T
-- in Haskell, this was called "Either S T"
{-
record _*_ (S : Set)(T : Set) : Set where
field -- introduces a bunch of fields, listed with their types
fst : S
snd : T
-- in Haskell, this was called "(S, T)"
-}
-- _*_ IS GENERALIZED BY SIGMA
record Sg (S : Set)(T : S -> Set) : Set where -- Sg is short for "Sigma"
constructor _,_
field -- introduces a bunch of fields, listed with their types
fst : S
snd : T fst
open Sg public -- brings fst and snd into scope hereafter unto all inheritors
-- make _*_ from Sg ?
_*_ : Set -> Set -> Set
S * T = Sg S \ _ -> T
infixr 4 _*_ _,_
------------------------------------------------------------------------------
-- some simple proofs
------------------------------------------------------------------------------
comm-* : {A : Set}{B : Set} -> A * B -> B * A
comm-* record { fst = a ; snd = b } = record { fst = b ; snd = a }
assocLR-+ : {A B C : Set} -> (A + B) + C -> A + (B + C)
assocLR-+ (inl (inl a)) = inl a
assocLR-+ (inl (inr b)) = inr (inl b)
assocLR-+ (inr c) = inr (inr c)
_$*_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A * B -> A' * B'
(f $* g) record { fst = a ; snd = b } = record { fst = f a ; snd = g b }
-- record syntax is rather ugly for small stuff; can we have constructors?
_$+_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A + B -> A' + B'
(f $+ g) (inl a) = inl (f a)
(f $+ g) (inr b) = inr (g b)
combinatorK : {A E : Set} -> A -> E -> A
combinatorK = \ a _ -> a
combinatorS : {S T E : Set} -> (E -> S -> T) -> (E -> S) -> E -> T
combinatorS = \ f s e -> (f e) (s e)
id : {X : Set} -> X -> X
-- id x = x -- is the easy way; let's do it a funny way to make a point
id = combinatorS combinatorK (combinatorK {_} {Zero})
-- no choice for -^ ^^^^- could be anything
naughtE : {X : Set} -> Zero -> X
naughtE ()
-- standard composition: f << g is "f after g"
_<<_ : {X Y Z : Set} -> (Y -> Z) -> (X -> Y) -> (X -> Z)
(f << g) x = f (g x)
-- diagrammatic composition: f >> g is "f then g"
_>>_ : {X Y Z : Set} -> (X -> Y) -> (Y -> Z) -> (X -> Z)
-- ^^^^^^^^ dominoes!
(f >> g) x = g (f x)
-- infix application
_$_ : {S : Set}{T : S -> Set}(f : (x : S) -> T x)(s : S) -> T s
f $ s = f s
infixl 2 _$_
------------------------------------------------------------------------------
-- from logic to data
------------------------------------------------------------------------------
data Nat : Set where
zero : Nat
suc : Nat -> Nat -- recursive data type
{-# BUILTIN NATURAL Nat #-}
-- ^^^^^^^^^^^^^^^^^^^ this pragma lets us use decimal notation
_+N_ : Nat -> Nat -> Nat
zero +N y = y
suc x +N y = suc (x +N y) -- there are other choices
four : Nat
four = 2 +N 2
------------------------------------------------------------------------------
-- and back to logic
------------------------------------------------------------------------------
data _==_ {X : Set} : X -> X -> Set where
refl : (x : X) -> x == x -- the relation that's "only reflexive"
{-# BUILTIN EQUALITY _==_ #-} -- we'll see what that's for, later
_=$=_ : {X Y : Set}{f f' : X -> Y}{x x' : X} ->
f == f' -> x == x' -> f x == f' x'
refl f =$= refl x = refl (f x)
infixl 2 _=$=_
zero-+N : (n : Nat) -> (zero +N n) == n
zero-+N n = refl n
+N-zero : (n : Nat) -> (n +N zero) == n
+N-zero zero = refl zero
+N-zero (suc n) = refl suc =$= +N-zero n
assocLR-+N : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z))
assocLR-+N zero y z = refl (y +N z)
assocLR-+N (suc x) y z = refl suc =$= assocLR-+N x y z
------------------------------------------------------------------------------
-- computing types
------------------------------------------------------------------------------
_>=_ : Nat -> Nat -> Set
x >= zero = One
zero >= suc y = Zero
suc x >= suc y = x >= y
refl->= : (n : Nat) -> n >= n
refl->= zero = record {}
refl->= (suc n) = refl->= n
trans->= : (x y z : Nat) -> x >= y -> y >= z -> x >= z
trans->= x y zero x>=y y>=z = record {}
trans->= x zero (suc z) x>=y ()
trans->= zero (suc y) (suc z) () y>=z
trans->= (suc x) (suc y) (suc z) x>=y y>=z = trans->= x y z x>=y y>=z
------------------------------------------------------------------------------
-- construction by proof
------------------------------------------------------------------------------
{- -- MOVED UP TO REPLACE _*_
record Sg (S : Set)(T : S -> Set) : Set where -- Sg is short for "Sigma"
constructor _,_
field -- introduces a bunch of fields, listed with their types
fst : S
snd : T fst
-- make _*_ from Sg ?
_*_ : Set -> Set -> Set
S * T = Sg S \ _ -> T
-}
difference : (m n : Nat) -> m >= n -> Sg Nat \ d -> m == (n +N d)
-- ( )
difference m zero m>=n = m , refl m
difference zero (suc n) ()
difference (suc m) (suc n) m>=n with difference m n m>=n
difference (suc m) (suc n) m>=n | d , q = d , (refl suc =$= q)
tryMe = difference 42 37 _
-- don'tTryMe = difference 37 42 {!!}
------------------------------------------------------------------------------
-- things to remember to say
------------------------------------------------------------------------------
-- why the single colon?
-- what's with all the spaces?
-- what's with identifiers mixing letters and symbols?
-- what's with all the braces?
-- what is Set?
-- are there any lowercase/uppercase conventions?
-- what's with all the underscores?
-- (i) placeholders in mixfix operators
-- (ii) don't care (on the left)
-- (iii) go figure (on the right)
-- why use arithmetic operators for types?
-- what's the difference between = and == ?
-- can't we leave out cases?
-- can't we loop?
-- the function type is both implication and universal quantification,
-- but why is it called Pi?
-- why is Sigma called Sigma?
-- B or nor B?
| {
"alphanum_fraction": 0.4416593374,
"avg_line_length": 29.6608695652,
"ext": "agda",
"hexsha": "4a272dbc778cc9e3c653f61a65c2f5d23205e02b",
"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/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec1Done.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/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec1Done.agda",
"max_line_length": 78,
"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/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec1Done.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": 2016,
"size": 6822
} |
open import Level hiding ( suc ; zero )
open import Algebra
module sym3 where
open import Symmetric
open import Data.Unit
open import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_)
open import Function
open import Data.Nat hiding (_⊔_) -- using (ℕ; suc; zero)
open import Relation.Nullary
open import Data.Empty
open import Data.Product
open import Gutil
open import Putil
open import FLutil
open import Solvable using (solvable)
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import Data.Fin
open import Data.Fin.Permutation hiding (_∘ₚ_)
infixr 200 _∘ₚ_
_∘ₚ_ = Data.Fin.Permutation._∘ₚ_
sym3solvable : solvable (Symmetric 3)
solvable.dervied-length sym3solvable = 2
solvable.end sym3solvable x d = solved1 x d where
open import Data.List using ( List ; [] ; _∷_ )
open Solvable (Symmetric 3)
p0id : FL→perm ((# 0) :: ((# 0) :: ((# 0 ) :: f0))) =p= pid
p0id = pleq _ _ refl
p0 = FL→perm ((# 0) :: ((# 0) :: ((# 0 ) :: f0)))
p1 = FL→perm ((# 0) :: ((# 1) :: ((# 0 ) :: f0)))
p2 = FL→perm ((# 1) :: ((# 0) :: ((# 0 ) :: f0)))
p3 = FL→perm ((# 1) :: ((# 1) :: ((# 0 ) :: f0)))
p4 = FL→perm ((# 2) :: ((# 0) :: ((# 0 ) :: f0)))
p5 = FL→perm ((# 2) :: ((# 1) :: ((# 0 ) :: f0)))
t0 = plist p0 ∷ plist p1 ∷ plist p2 ∷ plist p3 ∷ plist p4 ∷ plist p5 ∷ []
t1 = plist [ p0 , p0 ] ∷ plist [ p1 , p0 ] ∷ plist [ p2 , p0 ] ∷ plist [ p3 , p0 ] ∷ plist [ p4 , p0 ] ∷ plist [ p5 , p1 ] ∷
plist [ p0 , p1 ] ∷ plist [ p1 , p1 ] ∷ plist [ p2 , p1 ] ∷ plist [ p3 , p1 ] ∷ plist [ p4 , p1 ] ∷ plist [ p5 , p1 ] ∷
plist [ p0 , p2 ] ∷ plist [ p1 , p2 ] ∷ plist [ p2 , p2 ] ∷ plist [ p3 , p2 ] ∷ plist [ p4 , p2 ] ∷ plist [ p5 , p2 ] ∷
plist [ p0 , p3 ] ∷ plist [ p1 , p3 ] ∷ plist [ p3 , p3 ] ∷ plist [ p3 , p3 ] ∷ plist [ p4 , p3 ] ∷ plist [ p5 , p3 ] ∷
plist [ p0 , p4 ] ∷ plist [ p1 , p4 ] ∷ plist [ p3 , p4 ] ∷ plist [ p3 , p4 ] ∷ plist [ p4 , p4 ] ∷ plist [ p5 , p4 ] ∷
plist [ p0 , p5 ] ∷ plist [ p1 , p5 ] ∷ plist [ p3 , p5 ] ∷ plist [ p3 , p5 ] ∷ plist [ p4 , p4 ] ∷ plist [ p5 , p5 ] ∷
[]
open _=p=_
stage1 : (x : Permutation 3 3) → Set (Level.suc Level.zero)
stage1 x = Commutator (λ x₂ → Lift (Level.suc Level.zero) ⊤) x
open import logic
p33=4 : ( p3 ∘ₚ p3 ) =p= p4
p33=4 = pleq _ _ refl
p44=3 : ( p4 ∘ₚ p4 ) =p= p3
p44=3 = pleq _ _ refl
p34=0 : ( p3 ∘ₚ p4 ) =p= pid
p34=0 = pleq _ _ refl
p43=0 : ( p4 ∘ₚ p3 ) =p= pid
p43=0 = pleq _ _ refl
com33 : [ p3 , p3 ] =p= pid
com33 = pleq _ _ refl
com44 : [ p4 , p4 ] =p= pid
com44 = pleq _ _ refl
com34 : [ p3 , p4 ] =p= pid
com34 = pleq _ _ refl
com43 : [ p4 , p3 ] =p= pid
com43 = pleq _ _ refl
pFL : ( g : Permutation 3 3) → { x : FL 3 } → perm→FL g ≡ x → g =p= FL→perm x
pFL g {x} refl = ptrans (psym (FL←iso g)) ( FL-inject refl )
open ≡-Reasoning
-- st01 : ( x y : Permutation 3 3) → x =p= p3 → y =p= p3 → x ∘ₚ y =p= p4
-- st01 x y s t = record { peq = λ q → ( begin
-- (x ∘ₚ y) ⟨$⟩ʳ q
-- ≡⟨ peq ( presp s t ) q ⟩
-- ( p3 ∘ₚ p3 ) ⟨$⟩ʳ q
-- ≡⟨ peq p33=4 q ⟩
-- p4 ⟨$⟩ʳ q
-- ∎ ) }
st00 = perm→FL [ FL→perm ((suc zero) :: (suc zero :: (zero :: f0 ))) , FL→perm ((suc (suc zero)) :: (suc zero) :: (zero :: f0)) ]
st02 : ( g h : Permutation 3 3) → ([ g , h ] =p= pid) ∨ ([ g , h ] =p= p3) ∨ ([ g , h ] =p= p4)
st02 g h with perm→FL g | perm→FL h | inspect perm→FL g | inspect perm→FL h
... | (zero :: (zero :: (zero :: f0))) | t | record { eq = ge } | te = case1 (ptrans (comm-resp {g} {h} {pid} (FL-inject ge ) prefl ) (idcomtl h) )
... | s | (zero :: (zero :: (zero :: f0))) | se | record { eq = he } = case1 (ptrans (comm-resp {g} {h} {_} {pid} prefl (FL-inject he ))(idcomtr g) )
... | (zero :: (suc zero) :: (zero :: f0 )) | (zero :: (suc zero) :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) )
... | (suc zero) :: (zero :: (zero :: f0 )) | (suc zero) :: (zero :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) )
... | (suc zero) :: (suc zero :: (zero :: f0 )) | (suc zero) :: (suc zero :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) )
... | (suc (suc zero)) :: (zero :: (zero :: f0 )) | (suc (suc zero)) :: (zero :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) )
... | (suc (suc zero)) :: (suc zero) :: (zero :: f0) | (suc (suc zero)) :: (suc zero) :: (zero :: f0) | record { eq = ge } | record { eq = he } =
case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) )
... | (zero :: (suc zero) :: (zero :: f0 )) | ((suc zero) :: (zero :: (zero :: f0 ))) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (zero :: (suc zero) :: (zero :: f0 )) | (suc zero) :: (suc zero :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (zero :: (suc zero) :: (zero :: f0 )) | (suc (suc zero)) :: (zero :: (zero :: f0 ))| record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (zero :: (suc zero) :: (zero :: f0 )) | ((suc (suc zero)) :: (suc zero) :: (zero :: f0))| record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc zero) :: (zero :: (zero :: f0 ))) | (zero :: (suc zero) :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc zero) :: (zero :: (zero :: f0 ))) | (suc zero) :: (suc zero :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc zero) :: (zero :: (zero :: f0 ))) | ((suc (suc zero)) :: (zero :: (zero :: f0 )))| record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc zero) :: (zero :: (zero :: f0 ))) | (suc (suc zero)) :: (suc zero) :: (zero :: f0) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (suc zero) :: (suc zero :: (zero :: f0 )) | (zero :: (suc zero) :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (suc zero) :: (suc zero :: (zero :: f0 )) | ((suc zero) :: (zero :: (zero :: f0 ))) | record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (suc zero) :: (suc zero :: (zero :: f0 )) | ((suc (suc zero)) :: (zero :: (zero :: f0 ))) | record { eq = ge } | record { eq = he } =
case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) )
... | (suc zero) :: (suc zero :: (zero :: f0 )) | ((suc (suc zero)) :: (suc zero) :: (zero :: f0)) | record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (suc (suc zero)) :: (zero :: (zero :: f0 )) | ((zero :: (suc zero) :: (zero :: f0 )) ) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (suc (suc zero)) :: (zero :: (zero :: f0 )) | ((suc zero) :: (zero :: (zero :: f0 ))) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | (suc (suc zero)) :: (zero :: (zero :: f0 )) | ((suc zero) :: (suc zero :: (zero :: f0 ))) | record { eq = ge } | record { eq = he } =
case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) )
... | (suc (suc zero)) :: (zero :: (zero :: f0 )) | ((suc (suc zero)) :: (suc zero) :: (zero :: f0)) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc (suc zero)) :: (suc zero) :: (zero :: f0)) | ((zero :: (suc zero) :: (zero :: f0 )) ) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc (suc zero)) :: (suc zero) :: (zero :: f0)) | ((suc zero) :: (zero :: (zero :: f0 ))) | record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc (suc zero)) :: (suc zero) :: (zero :: f0)) | ((suc zero) :: (suc zero :: (zero :: f0 ))) | record { eq = ge } | record { eq = he } =
case2 (case2 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
... | ((suc (suc zero)) :: (suc zero) :: (zero :: f0)) | (suc (suc zero)) :: (zero :: (zero :: f0 )) | record { eq = ge } | record { eq = he } =
case2 (case1 (ptrans (comm-resp (pFL g ge) (pFL h he)) (FL-inject refl) ))
stage12 : (x : Permutation 3 3) → stage1 x → ( x =p= pid ) ∨ ( x =p= p3 ) ∨ ( x =p= p4 )
stage12 x (comm {g} {h} x1 y1 ) = st02 g h
stage12 _ (ccong {y} x=y sx) with stage12 y sx
... | case1 id = case1 ( ptrans (psym x=y ) id )
... | case2 (case1 x₁) = case2 (case1 ( ptrans (psym x=y ) x₁ ))
... | case2 (case2 x₁) = case2 (case2 ( ptrans (psym x=y ) x₁ ))
solved1 : (x : Permutation 3 3) → Commutator (λ x₁ → Commutator (λ x₂ → Lift (Level.suc Level.zero) ⊤) x₁) x → x =p= pid
solved1 x (ccong {f} {g} (record {peq = f=g}) d) with solved1 f d
... | record { peq = f=e } = record { peq = λ q → cc q } where
cc : ( q : Fin 3 ) → x ⟨$⟩ʳ q ≡ q
cc q = begin
x ⟨$⟩ʳ q
≡⟨ sym (f=g q) ⟩
f ⟨$⟩ʳ q
≡⟨ f=e q ⟩
q
∎
solved1 _ (comm {g} {h} x y) with stage12 g x | stage12 h y
... | case1 t | case1 s = ptrans (comm-resp t s) (comm-refl {pid} prefl)
... | case1 t | case2 s = ptrans (comm-resp {g} {h} {pid} t prefl) (idcomtl h)
... | case2 t | case1 s = ptrans (comm-resp {g} {h} {_} {pid} prefl s) (idcomtr g)
... | case2 (case1 t) | case2 (case1 s) = record { peq = λ q → trans ( peq ( comm-resp {g} {h} t s ) q ) (peq com33 q) }
... | case2 (case2 t) | case2 (case2 s) = record { peq = λ q → trans ( peq ( comm-resp {g} {h} t s ) q ) (peq com44 q) }
... | case2 (case1 t) | case2 (case2 s) = record { peq = λ q → trans ( peq ( comm-resp {g} {h} t s ) q ) (peq com34 q) }
... | case2 (case2 t) | case2 (case1 s) = record { peq = λ q → trans ( peq ( comm-resp {g} {h} t s ) q ) (peq com43 q) }
| {
"alphanum_fraction": 0.4808811677,
"avg_line_length": 60.0376344086,
"ext": "agda",
"hexsha": "6b7b4e205f56306bde378151d13a6f87b1effd22",
"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/sym3.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/sym3.agda",
"max_line_length": 153,
"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/sym3.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": 4591,
"size": 11167
} |
{-# OPTIONS --allow-unsolved-metas #-} -- FIXME
open import Everything
module Test.Test2 where
failed-test test-functor-transextensionality test-the-test : ∀
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} {_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁}
{ℓ₁} {_∼̇₁_ : ∀ {x y} → x ∼₁ y → x ∼₁ y → Ø ℓ₁}
{ε₁ : Reflexivity.type _∼₁_}
{_↦₁_ : Transitivity.type _∼₁_}
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} {_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂}
{ℓ₂} {_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂}
{ε₂ : Reflexivity.type _∼₂_}
{_↦₂_ : Transitivity.type _∼₂_}
{surjection : Surjection.type 𝔒₁ 𝔒₂}
{smap : Smap.type _∼₁_ _∼₂_ surjection surjection}
⦃ I : IsFunctor _∼₁_ _∼̇₁_ ε₁ _↦₁_ _∼₂_ _∼̇₂_ ε₂ _↦₂_ smap ⦄
⦃ J : IsFunctor _∼₁_ _∼̇₁_ ε₁ _↦₁_ _∼₂_ _∼̇₂_ ε₂ _↦₂_ smap ⦄
→ Transextensionality.type _∼₁_ _∼̇₁_ _↦₁_
failed-test = transextensionality
test-functor-transextensionality {_∼₁_ = _∼₁_} {_∼̇₁_ = _∼̇₁_} {_↦₁_ = _↦₁_} {{I}} = transextensionality {_∼_ = λ z z₁ → z ∼₁ z₁} {_∼̇_ = λ {x} {y} → _∼̇₁_ {x} {y}} {transitivity = λ {x y z} → _↦₁_ {x} {y} {z}} {{I .IsFunctor.`IsCategory₁ .IsCategory.`IsPrecategory .IsPrecategory.`𝓣ransextensionality}} -- FIXME can this be simplified?
test-the-test {_∼₁_ = _∼₁_} {_∼̇₁_ = _∼̇₁_} {_↦₁_ = _↦₁_} = test-functor-transextensionality {_∼₁_ = _∼₁_} {_∼̇₁_ = _∼̇₁_} {_↦₁_ = _↦₁_}
| {
"alphanum_fraction": 0.5840368381,
"avg_line_length": 44.9310344828,
"ext": "agda",
"hexsha": "665ac68af57621011e9aa91362e2618349c606b1",
"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-3/src/Test/Test2.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-3/src/Test/Test2.agda",
"max_line_length": 338,
"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-3/src/Test/Test2.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 714,
"size": 1303
} |
----------------------------------------------------------------------
-- Copyright: 2013, Jan Stolarek, Lodz University of Technology --
-- --
-- License: See LICENSE file in root of the repo --
-- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps --
-- --
-- Definition of natural numbers and operations on them. --
----------------------------------------------------------------------
module Basics.Nat where
open import Basics.Bool
-- Nat represents natural numbers (starting with 0)
data Nat : Set where
zero : Nat
suc : Nat → Nat
-- We define a constant 1 as it will be useful later on
one : Nat
one = suc zero
-- Addition
_+_ : Nat → Nat → Nat
zero + m = m
suc n + m = suc (n + m)
infixl 6 _+_
-- Comparisons needed in our code
_<_ : Nat → Nat → Bool
n < zero = false
zero < suc n = true
suc n < suc m = n < m
_≥_ : Nat → Nat → Bool
m ≥ zero = true
zero ≥ suc n = false
suc m ≥ suc n = m ≥ n
infixl 4 _<_ _≥_
| {
"alphanum_fraction": 0.4612644702,
"avg_line_length": 26.7380952381,
"ext": "agda",
"hexsha": "271fdbf0fe30a1fac74c048a355a223725111fa1",
"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": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps",
"max_forks_repo_path": "src/Basics/Nat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"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": "jstolarek/dep-typed-wbl-heaps",
"max_issues_repo_path": "src/Basics/Nat.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps",
"max_stars_repo_path": "src/Basics/Nat.agda",
"max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z",
"num_tokens": 272,
"size": 1123
} |
open import Common.Reflect
open import Common.Prelude
open import Common.Equality
data Maybe A : Set where
nothing : Maybe A
just : A → Maybe A
_<$>_ : ∀ {A B} → (A → B) → Maybe A → Maybe B
f <$> just x = just (f x)
f <$> nothing = nothing
_==_ = primQNameEquality
-- This is awkward!
awkwardUnquoteNat : Term → Maybe Nat
awkwardUnquoteNat (con z []) =
if z == quote Nat.zero
then just 0
else nothing
awkwardUnquoteNat (con s (arg _ n ∷ [])) =
if s == quote Nat.suc
then suc <$> awkwardUnquoteNat n
else nothing
awkwardUnquoteNat v = nothing
testAwkward : just 10 ≡ awkwardUnquoteNat (quoteTerm 10)
testAwkward = refl
-- This is nicer!
pattern `zero = con (quote Nat.zero) []
pattern `suc n = con (quote Nat.suc) (arg _ n ∷ [])
unquoteNat : Term → Maybe Nat
unquoteNat `zero = just zero
unquoteNat (`suc n) = suc <$> unquoteNat n
unquoteNat _ = nothing
test : just 10 ≡ unquoteNat (quoteTerm 10)
test = refl
| {
"alphanum_fraction": 0.6677248677,
"avg_line_length": 22.5,
"ext": "agda",
"hexsha": "e7f8d09b769c3c0eec083d51f5c4b43239fe4cfd",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "test/succeed/Issue619.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "test/succeed/Issue619.agda",
"max_line_length": 56,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/Issue619.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 308,
"size": 945
} |
module Testing where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
plus : Nat -> Nat -> Nat
plus zero n = n
plus (suc m) n = suc (plus m n)
times : Nat -> Nat -> Nat
times zero n = zero
times (suc m) n = plus n (times m n)
data List (A : Set) : Nat -> Set where
nil : List A 0
cons : {n : Nat} -> A -> List A n -> List A (suc n)
f : Nat -> (b : Nat) -> (a : Nat) -> Nat
f x = plus
-- Push argument doesn't work with implicit
-- Toggle implicit generates code that the tool can't handle
-- also, want to include {something = x} in language
map : {n : Nat} -> {A : Set} -> {B : Set} -> {renameMe0 : A -> B} -> List A n ->
List B n
map {renameMe0 = f} nil = nil
map {renameMe0 = f} (cons x xs) = cons (f x) (map {_} {_} {_} {f} xs)
map2 : {n : Nat} -> {A : Set} -> {B : Set} -> (A -> B) -> List A n ->
List B n
map2 f nil = nil
map2 f (cons x xs) = cons (f x) (map2 f xs)
{-
data Eq {A : Set} (x : A) : A -> Set where
refl : Eq x x
subst : {A : Set} -> (P : A -> Set) ->
{x : A} -> {y : A} -> Eq x y -> P x -> P y
subst P refl px = px
data Foo : Set where
foo : Foo
bar : Foo
-- Refactoring to introduce these!
{-# FOREIGN GHC data Foo = Foo | Bar #-}
{-# COMPILE GHC Foo = data Foo (Foo | Bar) #-}
-}
| {
"alphanum_fraction": 0.53359375,
"avg_line_length": 24.1509433962,
"ext": "agda",
"hexsha": "666f35fcff9d7dc955725ea9da8a28f7185e6e02",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "omega12345/RefactorAgda",
"max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/ManualTestFiles/Testing.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "omega12345/RefactorAgda",
"max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/ManualTestFiles/Testing.agda",
"max_line_length": 80,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "omega12345/RefactorAgda",
"max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/ManualTestFiles/Testing.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z",
"num_tokens": 455,
"size": 1280
} |
-- Andreas, 2020-03-26, issue #4481, reported by gallais
-- #952 unintentionally added named lambdas, but without updating the type-checker.
-- {-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.term.expr.top:15 #-}
-- {-# OPTIONS -v tc.term.lambda:30 #-}
open import Agda.Primitive
-- In Agda 2.6.0 and 2.6.1, this is a fake inconsistency proof:
data ⊥ : Set where
record ⊤ : Set where
proj2 : ∀ a {A B : Set a} → Set a
proj2 = λ _ {B = B} → B
agdaIsInconsistent : proj2 lzero {⊤} {⊥}
agdaIsInconsistent = _ -- should be yellow in > 2.6.1
-- The following should complain about unexpected implicit argument:
_ : Set → {A B : Set} → Set
_ = λ _ {C = B} {A} → A -- should fail
| {
"alphanum_fraction": 0.6429608128,
"avg_line_length": 26.5,
"ext": "agda",
"hexsha": "a22382b36f4b738cef44ac6bd34b5b3fda1a4130",
"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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue4481.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue4481.agda",
"max_line_length": 83,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue4481.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": 231,
"size": 689
} |
-- Andreas, 2014-03-02, issue and test case by Nisse
-- {-# OPTIONS --show-implicit -v tc.meta.assign:25 -v tc.meta.occurs:70 -v tc.meta.kill:30 #-}
-- {-# OPTIONS -v tc:10 #-}
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ public
postulate
A : Set
D : A → Set
data P : ∀ {xP} → D xP → Set where
c : ∀ {xc} (dc : D xc) → P dc
module M (f : ∀ {x} → D x → Σ A D)
(_ : ∀ {xM} (dM : D xM) → P (proj₂ (f dM)))
where
postulate
p : ∀ {x} → D x → A
q : ∀ {x} {d : D x} → D (p d)
p : ∀ {x} → D x → A
p = M.p (λ x → _ , x) c
q : ∀ {xq} {dq : D xq} → D (p dq)
q = M.q _ c
-- WAS: Unsound pruning of metas under projections
--
-- Cannot instantiate the metavariable _49 to solution d since it
-- contains the variable d which is not in scope of the metavariable
-- or irrelevant in the metavariable but relevant in the solution
-- when checking that the expression c has type ((d : D .x₁) → P _49)
-- NOW: type-checks fine
| {
"alphanum_fraction": 0.5710059172,
"avg_line_length": 23.5813953488,
"ext": "agda",
"hexsha": "0700623814fb24550c901aac293c94130f6ceb5a",
"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/Issue1070.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/Issue1070.agda",
"max_line_length": 95,
"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/Issue1070.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": 375,
"size": 1014
} |
{-# OPTIONS --cubical --safe #-}
module NormalForm where
open import Cubical.Core.Everything using (_≡_; Level; Type; Σ; _,_; fst; snd; _≃_; ~_)
open import Cubical.Foundations.Prelude using (refl; sym; _∙_; cong; transport; subst; funExt; transp; i0; i1)
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.Univalence using (ua)
open import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract; isoToEquiv)
open import Data.Bool using (Bool; false; true; if_then_else_)
open import Data.Integer using (ℤ; +_; -[1+_])
open import Data.Fin using (Fin; toℕ; #_; _≟_) renaming (zero to fz; suc to fs)
open import Data.List using (List; []; _∷_; foldr; length; map)
open import Data.Maybe using (Maybe; just; nothing) renaming (map to mmap)
open import Data.Nat using (ℕ; zero; suc; pred; _+_; _*_; _∸_; _≡ᵇ_; _>_; _<ᵇ_)
open import Data.Nat.DivMod using (_mod_; _div_)
open import Data.Product using (_×_; _,_; proj₁)
open import Data.Vec using (Vec; []; _∷_; lookup; replicate; _[_]%=_; toList) renaming (map to vmap)
open import Relation.Nullary using (yes; no)
open import BitVec using (BitVec; insert; empty; show)
open import Util
open import Pitch
open import Interval
_≤[]_ : List ℕ → List ℕ → Bool
[] ≤[] ys = true
(x ∷ xs) ≤[] [] = false
(x ∷ xs) ≤[] (y ∷ ys) =
if x ≡ᵇ y
then xs ≤[] ys
else (if x <ᵇ y then true else false)
_≤[opci]_ : List PitchClass → List PitchClass → Bool
_≤[opci]_ xs ys =
(map (toℕ ∘ unOrderedIntervalClass) (pcIntervals xs)) ≤[]
(map (toℕ ∘ unOrderedIntervalClass) (pcIntervals ys))
bestPitchClassList : List PitchClass → List (List PitchClass) → List PitchClass
bestPitchClassList xs [] = xs
bestPitchClassList [] (ys ∷ yss) = bestPitchClassList ys yss
bestPitchClassList xs@(_ ∷ _) (ys ∷ yss) =
if xs ≤[opci] ys
then bestPitchClassList xs yss
else bestPitchClassList ys yss
normalForm : PitchClassSet → List PitchClass
normalForm pcs =
let xs = fromPitchClassSet pcs
in bestPitchClassList [] (iter rotateLeft (pred (length xs)) xs)
bestNormalForm : PitchClassSet → List PitchClass
bestNormalForm pcs =
let xs = normalForm pcs
ys = normalForm (I pcs)
in if xs ≤[opci] ys then xs else ys
primeForm : PitchClassSet → List PitchClass
primeForm pcs with bestNormalForm pcs
... | [] = []
... | xs@(pitchClass p ∷ _) = map (Tp (toℕ (opposite p))) xs
-- Test
--ss = vmap pitchClass (# 4 ∷ # 7 ∷ # 9 ∷ [])
ss = vmap pitchClass (# 2 ∷ # 0 ∷ # 5 ∷ # 6 ∷ [])
--ss = vmap pitchClass (# 8 ∷ # 9 ∷ # 11 ∷ # 0 ∷ # 4 ∷ [])
--ss = vmap pitchClass (# 8 ∷ # 7 ∷ # 4 ∷ # 3 ∷ # 11 ∷ # 0 ∷ [])
aa = show (toPitchClassSet (toList ss))
bb = fromPitchClassSet (toPitchClassSet (toList ss))
cc = map (toℕ ∘ unPitchClass) (normalForm (toPitchClassSet (toList ss)))
dd = map (toℕ ∘ unPitchClass) (bestNormalForm (toPitchClassSet (toList ss)))
ee = map (toℕ ∘ unPitchClass) (primeForm (toPitchClassSet (toList ss)))
ff = icVector (primeForm (toPitchClassSet (toList ss)))
gg = map (toℕ ∘ unPitchClass) (fromPitchClassSet (T 8 (toPitchClassSet (toList ss))))
| {
"alphanum_fraction": 0.6588976378,
"avg_line_length": 39.1975308642,
"ext": "agda",
"hexsha": "959fa7c21159ca17ac8becf3faab388642160c7b",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z",
"max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/MusicTools",
"max_forks_repo_path": "agda/NormalForm.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "halfaya/MusicTools",
"max_issues_repo_path": "agda/NormalForm.agda",
"max_line_length": 114,
"max_stars_count": 28,
"max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/MusicTools",
"max_stars_repo_path": "agda/NormalForm.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z",
"num_tokens": 1062,
"size": 3175
} |
open import Data.Bool using ( Bool )
open import Data.String using ( String )
open import Data.Word using ( Byte )
open import Data.Natural using ( Natural )
module Data.ByteString.Primitive where
postulate
ByteStringLazy : Set
ByteStringLazy² : Set
emptyLazy : ByteStringLazy
consLazy : Byte → ByteStringLazy → ByteStringLazy
snocLazy : ByteStringLazy → Byte → ByteStringLazy
appendLazy : ByteStringLazy → ByteStringLazy → ByteStringLazy
lengthLazy : ByteStringLazy → Natural
nullLazy : ByteStringLazy → Bool
spanLazy : (Byte → Bool) → ByteStringLazy → ByteStringLazy²
breakLazy : (Byte → Bool) → ByteStringLazy → ByteStringLazy²
lazy₁ : ByteStringLazy² → ByteStringLazy
lazy₂ : ByteStringLazy² → ByteStringLazy
{-# IMPORT Data.ByteString.Lazy #-}
{-# COMPILED_TYPE ByteStringLazy Data.ByteString.Lazy.ByteString #-}
{-# COMPILED_TYPE ByteStringLazy² (Data.ByteString.Lazy.ByteString,Data.ByteString.Lazy.ByteString) #-}
{-# COMPILED emptyLazy Data.ByteString.Lazy.empty #-}
{-# COMPILED consLazy Data.ByteString.Lazy.cons #-}
{-# COMPILED snocLazy Data.ByteString.Lazy.snoc #-}
{-# COMPILED appendLazy Data.ByteString.Lazy.append #-}
{-# COMPILED lengthLazy fromIntegral . Data.ByteString.Lazy.length #-}
{-# COMPILED nullLazy Data.ByteString.Lazy.null #-}
{-# COMPILED spanLazy Data.ByteString.Lazy.span #-}
{-# COMPILED breakLazy Data.ByteString.Lazy.break #-}
{-# COMPILED lazy₁ \ ( x , y ) -> x #-}
{-# COMPILED lazy₂ \ ( x , y ) -> y #-}
postulate
ByteStringStrict : Set
ByteStringStrict² : Set
emptyStrict : ByteStringStrict
consStrict : Byte → ByteStringStrict → ByteStringStrict
snocStrict : ByteStringStrict → Byte → ByteStringStrict
appendStrict : ByteStringStrict → ByteStringStrict → ByteStringStrict
lengthStrict : ByteStringStrict → Natural
nullStrict : ByteStringStrict → Bool
spanStrict : (Byte → Bool) → ByteStringStrict → ByteStringStrict²
breakStrict : (Byte → Bool) → ByteStringStrict → ByteStringStrict²
strict₁ : ByteStringStrict² → ByteStringStrict
strict₂ : ByteStringStrict² → ByteStringStrict
{-# IMPORT Data.ByteString #-}
{-# COMPILED_TYPE ByteStringStrict Data.ByteString.ByteString #-}
{-# COMPILED_TYPE ByteStringStrict² (Data.ByteString.ByteString,Data.ByteString.ByteString) #-}
{-# COMPILED emptyStrict Data.ByteString.empty #-}
{-# COMPILED consStrict Data.ByteString.cons #-}
{-# COMPILED snocStrict Data.ByteString.snoc #-}
{-# COMPILED appendStrict Data.ByteString.append #-}
{-# COMPILED lengthStrict fromIntegral . Data.ByteString.length #-}
{-# COMPILED nullStrict Data.ByteString.null #-}
{-# COMPILED spanStrict Data.ByteString.span #-}
{-# COMPILED breakStrict Data.ByteString.break #-}
{-# COMPILED strict₁ \ ( x , y ) -> x #-}
{-# COMPILED strict₂ \ ( x , y ) -> y #-}
postulate
mkLazy : ByteStringStrict → ByteStringLazy
mkStrict : ByteStringLazy → ByteStringStrict
{-# COMPILED mkStrict (Data.ByteString.concat . Data.ByteString.Lazy.toChunks) #-}
{-# COMPILED mkLazy (\ bs -> Data.ByteString.Lazy.fromChunks [ bs ]) #-}
| {
"alphanum_fraction": 0.7432432432,
"avg_line_length": 43.3428571429,
"ext": "agda",
"hexsha": "e2e5becb6230fc5671e5a754e115b11926cb19cd",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z",
"max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ilya-fiveisky/agda-system-io",
"max_forks_repo_path": "src/Data/ByteString/Primitive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"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": "ilya-fiveisky/agda-system-io",
"max_issues_repo_path": "src/Data/ByteString/Primitive.agda",
"max_line_length": 103,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ilya-fiveisky/agda-system-io",
"max_stars_repo_path": "src/Data/ByteString/Primitive.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z",
"num_tokens": 697,
"size": 3034
} |
open import Data.Empty
open import Data.Maybe
open import Data.Product
open import Data.Sum
open import Data.Unit
open import AEff
open import AwaitingComputations
open import EffectAnnotations
open import Preservation
open import Renamings
open import Substitutions
open import Types
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary
open import Relation.Nullary.Negation
module Progress where
-- WRAPPING PROMISES AROUND A CONTEXT
⟨⟨_⟩⟩ : Ctx → Ctx
⟨⟨ [] ⟩⟩ = []
⟨⟨ Γ ∷ X ⟩⟩ = ⟨⟨ Γ ⟩⟩ ∷ ⟨ X ⟩
-- RESULTS
data RunResult⟨_∣_⟩ (Γ : Ctx) : {C : CType} → ⟨⟨ Γ ⟩⟩ ⊢M⦂ C → Set where
return : {X : VType}
{o : O}
{i : I}
(V : ⟨⟨ Γ ⟩⟩ ⊢V⦂ X) →
------------------------------------------
RunResult⟨ Γ ∣ return {o = o} {i = i} V ⟩
promise : {X Y : VType}
{o o' : O}
{i i' : I}
{op : Σₛ}
{p : lkpᵢ op i ≡ just (o' , i')}
{M : ⟨⟨ Γ ⟩⟩ ∷ ``(payload op) ⊢M⦂ ⟨ X ⟩ ! (o' , i')}
{N : ⟨⟨ Γ ⟩⟩ ∷ ⟨ X ⟩ ⊢M⦂ Y ! (o , i)} →
RunResult⟨ Γ ∷ X ∣ N ⟩ →
----------------------------------------------------
RunResult⟨ Γ ∣ promise op ∣ p ↦ M `in N ⟩
awaiting : {C : CType}
{Y : VType}
{y : ⟨ Y ⟩ ∈ ⟨⟨ Γ ⟩⟩}
{M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ C} →
y ⧗ M →
---------------------
RunResult⟨ Γ ∣ M ⟩
data CompResult⟨_∣_⟩ (Γ : Ctx) : {C : CType} → ⟨⟨ Γ ⟩⟩ ⊢M⦂ C → Set where
comp : {C : CType}
{M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ C} →
RunResult⟨ Γ ∣ M ⟩ →
---------------------
CompResult⟨ Γ ∣ M ⟩
signal : {X : VType}
{o : O}
{i : I}
{op : Σₛ}
{p : op ∈ₒ o}
{V : ⟨⟨ Γ ⟩⟩ ⊢V⦂ ``(payload op)}
{M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ X ! (o , i)} →
CompResult⟨ Γ ∣ M ⟩ →
--------------------------------
CompResult⟨ Γ ∣ ↑ op p V M ⟩
-- PROGRESS THEOREM FOR PROMISE-OPEN COMPUTATIONS
⇒-not-in-ctx : {Γ : Ctx} {X : VType} {C : CType} → X ⇒ C ∈ ⟨⟨ Γ ⟩⟩ → ⊥
⇒-not-in-ctx {Γ ∷ y} (Tl x) =
⇒-not-in-ctx x
{- THEOREM 3.3 -}
progress : {Γ : Ctx}
{C : CType} →
(M : ⟨⟨ Γ ⟩⟩ ⊢M⦂ C) →
-------------------------------
(Σ[ N ∈ ⟨⟨ Γ ⟩⟩ ⊢M⦂ C ] (M ↝ N)
⊎
CompResult⟨ Γ ∣ M ⟩)
progress (return V) =
inj₂ (comp (return V))
progress (let= M `in N) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (let= [-] `in N) r)
... | inj₂ (comp (return V)) =
inj₁ (_ , let-return V N)
... | inj₂ (comp (promise {_} {_} {_} {_} {_} {_} {_} {p} {M'} {M''} R)) =
inj₁ (_ , let-promise p M' M'' N)
... | inj₂ (comp (awaiting R)) =
inj₂ (comp (awaiting (let-in R)))
... | inj₂ (signal {_} {_} {_} {_} {p} {V} {M'} R) =
inj₁ (_ , let-↑ p V M' N)
progress (letrec M `in N) =
inj₁ (_ , letrec-unfold M N)
progress ((` x) · W) with ⇒-not-in-ctx x
... | ()
progress (ƛ M · W) =
inj₁ (_ , apply M W)
progress (↑ op p V M) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (↑ op p V [-]) r)
... | inj₂ R =
inj₂ (signal R)
progress (↓ op V M) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (↓ op V [-]) r)
... | inj₂ (comp (return W)) =
inj₁ (_ , (↓-return V W))
... | inj₂ (comp (awaiting R)) =
inj₂ (comp (awaiting (interrupt R)))
... | inj₂ (signal {X} {o} {i} {op'} {p} {W} {M'} R) =
inj₁ (_ , (↓-↑ p V W M'))
... | inj₂ (comp (promise {_} {_} {_} {_} {_} {_} {op'} {p} {M'} {M''} R)) with decₛ op op'
... | yes refl =
inj₁ (_ , ↓-promise-op p V M' M'')
... | no ¬q =
inj₁ (_ , ↓-promise-op' ¬q p V M' M'')
progress (promise op ∣ p ↦ M `in N) with progress N
... | inj₁ (M' , r) =
inj₁ (_ , context (promise op ∣ p ↦ M `in [-]) r)
... | inj₂ (comp R) =
inj₂ (comp (promise R))
... | inj₂ (signal {_} {_} {_} {_} {q} {V} {M'} R) =
inj₁ (_ , promise-↑ p q V M M')
progress (await ` x until M) =
inj₂ (comp (awaiting await))
progress (await ⟨ V ⟩ until M) =
inj₁ (_ , await-promise V M)
progress (coerce p q M) with progress M
... | inj₁ (M' , r) =
inj₁ (_ , context (coerce p q [-]) r)
... | inj₂ (comp (return V)) =
inj₁ (_ , coerce-return V)
... | inj₂ (comp (promise {_} {_} {_} {_} {_} {_} {op'} {r} {M'} {M''} R)) =
inj₁ (_ , coerce-promise r M' M'')
... | inj₂ (comp (awaiting R)) =
inj₂ (comp (awaiting (coerce R)))
... | inj₂ (signal {_} {_} {_} {_} {r} {V} {M'} R) =
inj₁ (_ , coerce-↑ r V M')
-- PROGRESS THEOREM FOR CLOSED COMPUTATIONS
{- COROLLARY 3.4 -}
closed-progress : {C : CType} →
(M : [] ⊢M⦂ C) →
--------------------------
(Σ[ N ∈ [] ⊢M⦂ C ] (M ↝ N)
⊎
CompResult⟨ [] ∣ M ⟩)
closed-progress M =
progress M
| {
"alphanum_fraction": 0.4265255293,
"avg_line_length": 28.3411764706,
"ext": "agda",
"hexsha": "41f98f7479021c31d240cdeab19eea2472e5687d",
"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": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "danelahman/aeff-agda",
"max_forks_repo_path": "Progress.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"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": "danelahman/aeff-agda",
"max_issues_repo_path": "Progress.agda",
"max_line_length": 91,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "danelahman/aeff-agda",
"max_stars_repo_path": "Progress.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-22T22:48:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-17T00:15:00.000Z",
"num_tokens": 1828,
"size": 4818
} |
{-# OPTIONS --without-K --exact-split #-}
module categories where
import 21-image
open 21-image public
{- We introduce precategories and categories. -}
Precat :
(l1 l2 : Level) → UU (lsuc l1 ⊔ lsuc l2)
Precat l1 l2 =
Σ (UU l1) (λ Obj → Σ (Obj → Obj → hSet l2) (λ Hom →
Σ ({X : Obj} → type-Set (Hom X X)) (λ i →
Σ ( {X Y Z : Obj} →
type-Set (Hom Y Z) → type-Set (Hom X Y) → type-Set (Hom X Z))
( λ comp →
( {X Y Z W : Obj} (f : type-Set (Hom X Y)) (g : type-Set (Hom Y Z))
(h : type-Set (Hom Z W)) →
Id (comp (comp h g) f) (comp h (comp g f))) ×
( ( {X Y : Obj} (f : type-Set (Hom X Y)) → Id (comp i f) f) ×
( {X Y : Obj} (f : type-Set (Hom X Y)) → Id (comp f i) f))))))
obj-Precat :
{l1 l2 : Level} (C : Precat l1 l2) → UU l1
obj-Precat C = pr1 C
hom-Precat :
{l1 l2 : Level} (C : Precat l1 l2) → obj-Precat C → obj-Precat C → hSet l2
hom-Precat C = pr1 (pr2 C)
id-Precat :
{l1 l2 : Level} (C : Precat l1 l2)
{X : obj-Precat C} → type-Set (hom-Precat C X X)
id-Precat C = pr1 (pr2 (pr2 C))
comp-Precat :
{l1 l2 : Level} (C : Precat l1 l2)
{X Y Z : obj-Precat C} → type-Set (hom-Precat C Y Z) →
type-Set (hom-Precat C X Y) → type-Set (hom-Precat C X Z)
comp-Precat C = pr1 (pr2 (pr2 (pr2 C)))
assoc-Precat :
{l1 l2 : Level} (C : Precat l1 l2)
{X Y Z W : obj-Precat C} (f : type-Set (hom-Precat C X Y)) →
( g : type-Set (hom-Precat C Y Z)) ( h : type-Set (hom-Precat C Z W)) →
Id (comp-Precat C (comp-Precat C h g) f) (comp-Precat C h (comp-Precat C g f))
assoc-Precat C = pr1 (pr2 (pr2 (pr2 (pr2 C))))
left-unit-Precat :
{l1 l2 : Level} (C : Precat l1 l2)
{X Y : obj-Precat C} (f : type-Set (hom-Precat C X Y)) →
Id (comp-Precat C (id-Precat C) f) f
left-unit-Precat C = pr1 (pr2 (pr2 (pr2 (pr2 (pr2 C)))))
right-unit-Precat :
{l1 l2 : Level} (C : Precat l1 l2)
{X Y : obj-Precat C} (f : type-Set (hom-Precat C X Y)) →
Id (comp-Precat C f (id-Precat C)) f
right-unit-Precat C = pr2 (pr2 (pr2 (pr2 (pr2 (pr2 C)))))
{- We define the notion of isomorphism in a precategory. -}
is-iso-Precat :
{l1 l2 : Level} (C : Precat l1 l2) {X Y : obj-Precat C} →
(type-Set (hom-Precat C X Y)) → UU l2
is-iso-Precat C {X} {Y} f =
Σ ( type-Set (hom-Precat C Y X)) (λ g →
Id (comp-Precat C f g) (id-Precat C) ×
Id (comp-Precat C g f) (id-Precat C))
iso-Precat :
{l1 l2 : Level} (C : Precat l1 l2) →
obj-Precat C → obj-Precat C → hSet l2
iso-Precat C X Y =
{!!}
| {
"alphanum_fraction": 0.5519713262,
"avg_line_length": 32.1923076923,
"ext": "agda",
"hexsha": "d2ba27ade137ef617cd2154d69e5649b8270baf8",
"lang": "Agda",
"max_forks_count": 30,
"max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z",
"max_forks_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "tadejpetric/HoTT-Intro",
"max_forks_repo_path": "Agda/categories.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "tadejpetric/HoTT-Intro",
"max_issues_repo_path": "Agda/categories.agda",
"max_line_length": 80,
"max_stars_count": 333,
"max_stars_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "tadejpetric/HoTT-Intro",
"max_stars_repo_path": "Agda/categories.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z",
"num_tokens": 1090,
"size": 2511
} |
{-# OPTIONS --allow-unsolved-metas #-}
module Formula where
module _ where
open import VariableName
open import PredicateName
open import Term
data Formula : Set
where
atomic : PredicateName → Terms → Formula
logical : Formula →
Formula →
Formula
quantified : VariableName → Formula → Formula
module _ where
open import OscarPrelude
formulaAtomic-inj₁ : ∀ {𝑃₁ τs₁ 𝑃₂ τs₂} → atomic 𝑃₁ τs₁ ≡ atomic 𝑃₂ τs₂ → 𝑃₁ ≡ 𝑃₂
formulaAtomic-inj₁ refl = refl
formulaAtomic-inj₂ : ∀ {𝑃₁ τs₁ 𝑃₂ τs₂} → atomic 𝑃₁ τs₁ ≡ atomic 𝑃₂ τs₂ → τs₁ ≡ τs₂
formulaAtomic-inj₂ refl = refl
formulaLogical-inj₁ : ∀ {φ₁₁ φ₁₂ φ₂₁ φ₂₂} → logical φ₁₁ φ₁₂ ≡ logical φ₂₁ φ₂₂ → φ₁₁ ≡ φ₂₁
formulaLogical-inj₁ refl = refl
formulaLogical-inj₂ : ∀ {φ₁₁ φ₁₂ φ₂₁ φ₂₂} → logical φ₁₁ φ₁₂ ≡ logical φ₂₁ φ₂₂ → φ₁₂ ≡ φ₂₂
formulaLogical-inj₂ refl = refl
formulaQuantified-inj₁ : ∀ {𝑥₁ φ₁ 𝑥₂ φ₂} → quantified 𝑥₁ φ₁ ≡ quantified 𝑥₂ φ₂ → 𝑥₁ ≡ 𝑥₂
formulaQuantified-inj₁ refl = refl
formulaQuantified-inj₂ : ∀ {𝑥₁ φ₁ 𝑥₂ φ₂} → quantified 𝑥₁ φ₁ ≡ quantified 𝑥₂ φ₂ → φ₁ ≡ φ₂
formulaQuantified-inj₂ refl = refl
instance EqFormula : Eq Formula
Eq._==_ EqFormula (atomic 𝑃₁ τs₁)
(atomic 𝑃₂ τs₂)
= decEq₂ formulaAtomic-inj₁
formulaAtomic-inj₂
(𝑃₁ ≟ 𝑃₂)
(τs₁ ≟ τs₂)
Eq._==_ EqFormula (logical φ₁₁ φ₁₂)
(logical φ₂₁ φ₂₂)
= decEq₂ formulaLogical-inj₁ formulaLogical-inj₂ (φ₁₁ ≟ φ₂₁) (φ₁₂ ≟ φ₂₂)
Eq._==_ EqFormula (quantified 𝑥₁ φ₁) (quantified 𝑥₂ φ₂) = decEq₂ formulaQuantified-inj₁ formulaQuantified-inj₂ (𝑥₁ ≟ 𝑥₂) (φ₁ ≟ φ₂)
Eq._==_ EqFormula (atomic _ _) (logical _ _) = no λ ()
Eq._==_ EqFormula (atomic _ _) (quantified _ _) = no λ ()
Eq._==_ EqFormula (logical _ _) (atomic _ _) = no λ ()
Eq._==_ EqFormula (logical _ _) (quantified _ _) = no λ ()
Eq._==_ EqFormula (quantified _ _) (atomic _ _) = no λ ()
Eq._==_ EqFormula (quantified _ _) (logical _ _) = no λ ()
module _ where
open import PredicateName
open import Term
𝑃[_♭_] : PredicateName → Terms → Formula
𝑃[_♭_] = atomic
{-# DISPLAY atomic = 𝑃[_♭_] #-}
module _ where
open import HasNeitherNor
instance HasNeitherNorFormula : HasNeitherNor Formula
HasNeitherNor._⊗_ HasNeitherNorFormula = logical
{-# DISPLAY logical = _⊗_ #-}
module _ where
open import HasNeitherNor
open import HasNegation
instance HasNegationFormula : HasNegation Formula
HasNegation.~ HasNegationFormula φ = φ ⊗ φ
module _ where
open import OscarPrelude
open import Term
open import HasSatisfaction
open import Interpretation
open import Vector
open import InterpretationEqualityExceptAtVariableName
open import Elements
open import TruthValue
instance HasSatisfactionFormula : HasSatisfaction Formula
HasSatisfaction._⊨_ HasSatisfactionFormula I (atomic 𝑃 τs) = 𝑃⟦ I ⟧ 𝑃 ⟨ ⟨ τ⟦ I ⟧ <$> vector (terms τs) ⟩ ⟩ ≡ ⟨ true ⟩
HasSatisfaction._⊨_ HasSatisfactionFormula I (logical φ₁ φ₂) = ¬ I ⊨ φ₁ × ¬ I ⊨ φ₂
HasSatisfaction._⊨_ HasSatisfactionFormula I (quantified 𝑥 φ) = (𝓘 : Interpretation) → 𝓘 ≞ I / 𝑥 → 𝓘 ⊨ φ
instance HasDecidableSatisfactionFormula : HasDecidableSatisfaction Formula
HasDecidableSatisfaction._⊨?_ HasDecidableSatisfactionFormula I (atomic 𝑃 τs) = {!!}
HasDecidableSatisfaction._⊨?_ HasDecidableSatisfactionFormula I (logical φ₁ φ₂) = {!!}
HasDecidableSatisfaction._⊨?_ HasDecidableSatisfactionFormula I (quantified 𝑥 φ) = {!!}
instance HasDecidableValidationFormula : HasDecidableValidation Formula
HasDecidableValidation.⊨?_ HasDecidableValidationFormula (atomic 𝑃 τs) = {!!}
HasDecidableValidation.⊨?_ HasDecidableValidationFormula (logical φ₁ φ₂) = {!!}
HasDecidableValidation.⊨?_ HasDecidableValidationFormula (quantified 𝑥 φ) = {!!}
module _ where
open import OscarPrelude
open import Relation.Binary.Core
--open import PredicateName
open import VariableName
open import Arity
open import Term
open import Vector
mutual
notationalVariantTerm* : (VariableName → Maybe VariableName) → Term → Term → Set
notationalVariantTerm* v (variable 𝑥₁) (variable 𝑥₂) = maybe 𝑥₁ id (v 𝑥₁) ≡ 𝑥₂
notationalVariantTerm* v (function 𝑓₁ τs₁) (function 𝑓₂ τs₂) = 𝑓₁ ≡ 𝑓₂ × notationalVariantTerms* v τs₁ τs₂
notationalVariantTerm* v (variable x) (function x₁ x₂) = ⊥
notationalVariantTerm* v (function x x₁) (variable x₂) = ⊥
notationalVariantTerms* : (VariableName → Maybe VariableName) → Terms → Terms → Set
notationalVariantTerms* v (⟨_⟩ {a₁} terms₁) (⟨_⟩ {a₂} terms₂) with a₁ ≟ a₂
notationalVariantTerms* v (⟨_⟩ {⟨ .0 ⟩} ⟨ [] ⟩) (⟨_⟩ {.(⟨ 0 ⟩)} ⟨ [] ⟩) | yes refl = ⊤
notationalVariantTerms* v (⟨_⟩ {⟨ .(suc _) ⟩} ⟨ x ∷ vector₁ ⟩) (⟨_⟩ {.(⟨ suc _ ⟩)} ⟨ x₁ ∷ vector₂ ⟩) | yes refl = notationalVariantTerm* v x x₁ × notationalVariantTerms* v ⟨ ⟨ vector₁ ⟩ ⟩ ⟨ ⟨ vector₂ ⟩ ⟩
… | no neq = ⊥
mutual
data Term⟦_/_≈_⟧ (v : VariableName → Maybe VariableName) : Term → Term → Set where
variable : ∀ 𝑥₁ 𝑥₂ → maybe 𝑥₁ id (v 𝑥₁) ≡ 𝑥₂ → Term⟦ v / variable 𝑥₁ ≈ variable 𝑥₂ ⟧
function : ∀ 𝑓 τs₁ τs₂ → Terms⟦ v / τs₁ ≈ τs₂ ⟧ → Term⟦ v / function 𝑓 τs₁ ≈ function 𝑓 τs₂ ⟧
data Terms⟦_/_≈_⟧ (v : VariableName → Maybe VariableName) : Terms → Terms → Set where
[] : Terms⟦ v / ⟨ ⟨ [] ⟩ ⟩ ≈ ⟨ ⟨ [] ⟩ ⟩ ⟧
_∷_ : ∀ τ₁ τ₂ → Term⟦ v / τ₁ ≈ τ₂ ⟧ → ∀ τs₁ τs₂ → Terms⟦ v / τs₁ ≈ τs₂ ⟧ → Terms⟦ v / ⟨ ⟨ τ₁ ∷ vector (terms τs₁) ⟩ ⟩ ≈ ⟨ ⟨ τ₂ ∷ vector (terms τs₂) ⟩ ⟩ ⟧
notationalVariantFormula* : (VariableName → Maybe VariableName) → Formula → Formula → Set
notationalVariantFormula* v (atomic x x₁) (atomic x₂ x₃) = x ≡ x₂ × notationalVariantTerms* v x₁ x₃
notationalVariantFormula* v (logical φ₁ φ₂) (logical φ₃ φ₄) = notationalVariantFormula* v φ₁ φ₃ × notationalVariantFormula* v φ₂ φ₄
notationalVariantFormula* v (quantified x φ₁) (quantified x₁ φ₂) = notationalVariantFormula* (λ {v' → ifYes v' ≟ x then just x₁ else v v'}) φ₁ φ₂
notationalVariantFormula* v (logical φ₁ φ₂) (atomic x x₁) = ⊥
notationalVariantFormula* v (atomic x x₁) (logical φ₂ φ₃) = ⊥
notationalVariantFormula* v (atomic x x₁) (quantified x₂ φ₂) = ⊥
notationalVariantFormula* v (logical φ₁ φ₂) (quantified x φ₃) = ⊥
notationalVariantFormula* v (quantified x φ₁) (atomic x₁ x₂) = ⊥
notationalVariantFormula* v (quantified x φ₁) (logical φ₂ φ₃) = ⊥
notationalVariantFormula : Formula → Formula → Set
notationalVariantFormula φ₁ φ₂ = notationalVariantFormula* (const nothing) φ₁ φ₂
private
refl-notationalVariantTerms* : ∀ x₁ → notationalVariantTerms* (λ x₂ → nothing) ⟨ terms x₁ ⟩ ⟨ terms x₁ ⟩
refl-notationalVariantTerms* (⟨_⟩ {arity = ⟨ .0 ⟩} ⟨ [] ⟩) = {!!}
refl-notationalVariantTerms* (⟨_⟩ {arity = ⟨ .(suc _) ⟩} ⟨ _∷_ {n = n} x vector₁ ⟩) = {!!}
{-
refl-notationalVariantTerms* ⟨ ⟨ [] ⟩ ⟩ = tt
refl-notationalVariantTerms* (⟨_⟩ {nx} ⟨ x ∷ vector₁ ⟩) = {!!}
-}
refl-notationalVariantFormula : (φ : Formula) → notationalVariantFormula φ φ
refl-notationalVariantFormula (atomic x x₁) = {!!}
refl-notationalVariantFormula (logical φ φ₁) = {!!}
refl-notationalVariantFormula (quantified x φ) = {!!}
isEquivalenceNotationalVariantFormula : IsEquivalence notationalVariantFormula
isEquivalenceNotationalVariantFormula =
record
{ refl = {!!} -- λ { {atomic _ _} → refl , {!!} ; {logical x x₁} → {!!} ; {quantified x x₁} → {!!} }
; sym = {!!}
; trans = {!!} }
data Formula⟦_/_≈_⟧ (v : VariableName → Maybe VariableName) : Formula → Formula → Set where
atomic : ∀ 𝑃 τs₁ τs₂ → Terms⟦ v / τs₁ ≈ τs₂ ⟧ → Formula⟦ v / atomic 𝑃 τs₁ ≈ atomic 𝑃 τs₂ ⟧
logical : ∀ φ₁₁ φ₁₂ φ₂₁ φ₂₂ → Formula⟦ v / φ₁₁ ≈ φ₂₁ ⟧ → Formula⟦ v / φ₁₂ ≈ φ₂₂ ⟧ → Formula⟦ v / logical φ₁₁ φ₁₂ ≈ logical φ₂₁ φ₂₂ ⟧
quantified : ∀ 𝑥₁ 𝑥₂ φ₁ φ₂ → Formula⟦ (λ {v' → ifYes v' ≟ 𝑥₁ then just 𝑥₂ else v v'}) / φ₁ ≈ φ₂ ⟧ → Formula⟦ v / quantified 𝑥₁ φ₁ ≈ quantified 𝑥₂ φ₂ ⟧
data F⟦_NotationalVariant_⟧ : Formula → Formula → Set where
basic : ∀ φ₁ φ₂ → Formula⟦ const nothing / φ₁ ≈ φ₂ ⟧ → F⟦ φ₁ NotationalVariant φ₂ ⟧
private
mutual
refl-notVarTerms : ∀ x₁ → Terms⟦ const nothing / x₁ ≈ x₁ ⟧
refl-notVarTerms ⟨ ⟨ [] ⟩ ⟩ = []
refl-notVarTerms ⟨ ⟨ x ∷ vector₁ ⟩ ⟩ = (x ∷ x) (refl-notVarTerm x) ⟨ ⟨ vector₁ ⟩ ⟩ ⟨ ⟨ vector₁ ⟩ ⟩ (refl-notVarTerms ⟨ ⟨ vector₁ ⟩ ⟩)
refl-notVarTerm : ∀ x₁ → Term⟦ const nothing / x₁ ≈ x₁ ⟧
refl-notVarTerm (variable x) = variable x x refl
refl-notVarTerm (function x x₁) = function x x₁ x₁ (refl-notVarTerms x₁)
refl-notationalVariant' : (φ : Formula) → F⟦ φ NotationalVariant φ ⟧
refl-notationalVariant' (atomic x x₁) = basic 𝑃[ x ♭ x₁ ] 𝑃[ x ♭ x₁ ] (atomic x x₁ x₁ (refl-notVarTerms x₁))
refl-notationalVariant' (logical φ φ₁) = basic (logical φ φ₁) (logical φ φ₁) (logical φ φ₁ φ φ₁ {!!} {!!})
refl-notationalVariant' (quantified x φ) = basic (quantified x φ) (quantified x φ) (quantified x x φ φ {!!})
isEquivalenceNotationalVariant' : IsEquivalence F⟦_NotationalVariant_⟧
isEquivalenceNotationalVariant' =
record
{ refl = {!!} -- λ { {atomic _ _} → refl , {!!} ; {logical x x₁} → {!!} ; {quantified x x₁} → {!!} }
; sym = {!!}
; trans = {!!} }
module _ where
open import HasSubstantiveDischarge
{-
postulate
instance cs : CanonicalSubstitution Formula
instance hpu : HasPairUnification Formula (CanonicalSubstitution.S cs)
-}
instance HasSubstantiveDischargeFormulaFormula : HasSubstantiveDischarge Formula
HasSubstantiveDischarge.hasNegation HasSubstantiveDischargeFormulaFormula = {!!}
--HasSubstantiveDischarge._o≽o_ HasSubstantiveDischargeFormulaFormula φ₁ φ₂ = {!!} -- ∃ λ υ → υ Unifies φ₁ and φ₂
HasSubstantiveDischarge.≽-reflexive HasSubstantiveDischargeFormulaFormula = {!!}
HasSubstantiveDischarge.≽-consistent HasSubstantiveDischargeFormulaFormula = {!!}
HasSubstantiveDischarge.≽-contrapositive HasSubstantiveDischargeFormulaFormula = {!!}
instance HasDecidableSubstantiveDischargeFormulaFormula : HasDecidableSubstantiveDischarge Formula
HasDecidableSubstantiveDischarge.hasSubstantiveDischarge HasDecidableSubstantiveDischargeFormulaFormula = {!!}
HasDecidableSubstantiveDischarge._≽?_ HasDecidableSubstantiveDischargeFormulaFormula = {!!}
module _ where
open import VariableName
∀[_♭_] : VariableName → Formula → Formula
∀[_♭_] = quantified
{-# DISPLAY Formula.quantified = ∀[_♭_] #-}
module _ where
open import HasNegation
open import HasNeitherNor
_∧_ : Formula → Formula → Formula
φ₁ ∧ φ₂ = ~ φ₁ ⊗ ~ φ₂
_∨_ : Formula → Formula → Formula
φ₁ ∨ φ₂ = ~ (φ₁ ⊗ φ₂)
_⊃_ : Formula → Formula → Formula
φ₁ ⊃ φ₂ = ~ φ₁ ∨ φ₂
_⟷_ : Formula → Formula → Formula
φ₁ ⟷ φ₂ = (φ₁ ⊗ (φ₂ ⊗ φ₂)) ⊗ ((φ₁ ⊗ φ₁) ⊗ φ₂) -- TODO check that this is logically equivalent to the more verbose, (φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁)
| {
"alphanum_fraction": 0.6661175178,
"avg_line_length": 42.6796875,
"ext": "agda",
"hexsha": "2ce31f34d3174c90161a306d92c91a32d8b8fbc8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/Formula.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/Formula.agda",
"max_line_length": 207,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/Formula.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3944,
"size": 10926
} |
-- Andreas, 2018-03-19, issue #2971, reported by Ulf
-- Splitting on result should give proper error
-- when record type is weak, i.e. lacks projections.
{-# OPTIONS --no-irrelevant-projections #-}
-- {-# OPTIONS -v tc.cover:20 #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
record Five : Set where
field
five : Nat
.prf : five ≡ 5 -- No corresponding projection!
best-number : Five
best-number = {!!} -- C-c C-c (on result)
-- Error WAS:
-- Panic: Unbound name: NoIrrProj.Five.prf
-- [0,2,10]@5465979233139828506
-- when checking that the expression ? has type Five
-- Should give proper error message.
-- Cannot split on result here, because record has irrelevant fields,
-- but no corresponding projections
-- when checking that the expression ? has type Five
-- Testing similar errors:
not-record : Set
not-record = {!!}
-- Cannot split on result here, because target type Set is not a record type
-- when checking that the expression ? has type Set
| {
"alphanum_fraction": 0.7074148297,
"avg_line_length": 26.2631578947,
"ext": "agda",
"hexsha": "65ce6a4231cd0632fc8ce72c5e27cef81c3e90b4",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "asr/eagda",
"max_forks_repo_path": "test/interaction/Issue2971.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "asr/eagda",
"max_issues_repo_path": "test/interaction/Issue2971.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "asr/eagda",
"max_stars_repo_path": "test/interaction/Issue2971.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 262,
"size": 998
} |
{-# OPTIONS --without-K #-}
module container.m where
open import container.m.coalgebra public
open import container.m.from-nat public
open import container.m.core public
open import container.m.extensionality public
open import container.m.level public
| {
"alphanum_fraction": 0.8039215686,
"avg_line_length": 25.5,
"ext": "agda",
"hexsha": "b2865073530954cfdf4bc32b448d07255f54cb8b",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "container/m.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "HoTT/M-types",
"max_issues_repo_path": "container/m.agda",
"max_line_length": 45,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "container/m.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 51,
"size": 255
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import Haskell.Modules.RWS
open import Haskell.Modules.RWS.Lens
open import Haskell.Modules.RWS.RustAnyHow
open import LibraBFT.Base.Types
import LibraBFT.Impl.Consensus.TestUtils.MockStorage as MockStorage
open import LibraBFT.Impl.OBM.Logging.Logging
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.LBFT
open import Optics.All
open import Util.Prelude
------------------------------------------------------------------------------
open import Data.String using (String)
module LibraBFT.Impl.Consensus.PersistentLivenessStorage where
------------------------------------------------------------------------------
obmUpdateM
: ( PersistentLivenessStorage → LBFT (Either ErrLog PersistentLivenessStorage) )
→ LBFT (Either ErrLog Unit)
obmUpdateE
: BlockStore
→ ( PersistentLivenessStorage
→ Either ErrLog PersistentLivenessStorage )
-> Either ErrLog BlockStore
------------------------------------------------------------------------------
saveTreeM : List Block → List QuorumCert → LBFT (Either ErrLog Unit)
saveTreeM blocks qcs =
obmUpdateM (MockStorage.saveTreeM blocks qcs)
saveTreeE : BlockStore → List Block → List QuorumCert → Either ErrLog BlockStore
saveTreeE bs blocks qcs =
obmUpdateE bs (MockStorage.saveTreeE blocks qcs)
pruneTreeM : List HashValue → LBFT (Either ErrLog Unit)
pruneTreeM =
obmUpdateM ∘ MockStorage.pruneTreeM
saveVoteM : Vote → LBFT (Either ErrLog Unit)
saveVoteM =
obmUpdateM ∘ MockStorage.saveStateM
startM : LBFT (Either ErrLog RecoveryData)
startM =
use (lBlockStore ∙ bsStorage) >>= λ s → pure (MockStorage.start s) ∙^∙ withErrCtx (here' [])
where
here' : List String → List String
here' t = "PersistentLivenessStorage" ∷ "startM" ∷ t
saveHighestTimeoutCertM : TimeoutCertificate → LBFT (Either ErrLog Unit)
saveHighestTimeoutCertM =
obmUpdateM ∘ MockStorage.saveHighestTimeoutCertificateM
------------------------------------------------------------------------------
obmUpdateM f = do
s <- use (lBlockStore ∙ bsStorage)
f s ∙?∙ λ s' → do lBlockStore ∙ bsStorage ∙= s'; ok unit
obmUpdateE bs f = do
let s = bs ^∙ bsStorage
s' ← f s
pure (bs & bsStorage ∙~ s')
| {
"alphanum_fraction": 0.6576648133,
"avg_line_length": 34.027027027,
"ext": "agda",
"hexsha": "58c7745717212a82e12b4aab8b879344b941648b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Consensus/PersistentLivenessStorage.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Consensus/PersistentLivenessStorage.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Consensus/PersistentLivenessStorage.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 645,
"size": 2518
} |
open import Agda.Builtin.Equality
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.String
open import Agda.Builtin.List
open import Agda.Builtin.Unit
impNames : Term → List String
impNames (pi (arg (arg-info hidden _) _) (abs x b)) = x ∷ impNames b
impNames _ = []
macro
implicits : Name → Term → TC ⊤
implicits x hole = do
t ← getType x
i ← quoteTC (impNames t)
unify hole i
variable
A : Set₁
x : A
postulate
f : (B : Set) → B ≡ B → Set
g : f _ x ≡ f _ x
g = refl
_ : implicits g ≡ "x.A.1" ∷ "x" ∷ []
_ = refl
postulate
F : Set → Set₁
P : {x : Set} → F x → Set
Q : {x : Set₁} → x → Set
p : P x
q : Q x
_ : implicits p ≡ "x.A.1" ∷ "x" ∷ []
_ = refl
_ : implicits q ≡ "x.A" ∷ "x" ∷ []
_ = refl
fails : (A : Set) (f : F A) → P f
fails A f = p {x = f}
| {
"alphanum_fraction": 0.5740072202,
"avg_line_length": 17.6808510638,
"ext": "agda",
"hexsha": "724fc728a30e971bae5a36af446e6bf4467b06a5",
"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/Issue4291.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/Issue4291.agda",
"max_line_length": 68,
"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/Issue4291.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": 329,
"size": 831
} |
module BasicIPC.Metatheory.GentzenSpinalNormalForm-HereditarySubstitution where
open import BasicIPC.Syntax.GentzenSpinalNormalForm public
-- Hereditary substitution and reduction.
mutual
[_≔_]ⁿᶠ_ : ∀ {A B Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B → Γ ∖ i ⊢ⁿᶠ B
[ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ j xs) with i ≟∈ j
[ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ .i xs) | same = reduce s ([ i ≔ s ]ˢᵖ xs)
[ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ ._ xs) | diff j = neⁿᶠ (spⁿᵉ j ([ i ≔ s ]ˢᵖ xs))
[ i ≔ s ]ⁿᶠ lamⁿᶠ t = lamⁿᶠ ([ pop i ≔ mono⊢ⁿᶠ weak⊆ s ]ⁿᶠ t)
[ i ≔ s ]ⁿᶠ pairⁿᶠ t u = pairⁿᶠ ([ i ≔ s ]ⁿᶠ t) ([ i ≔ s ]ⁿᶠ u)
[ i ≔ s ]ⁿᶠ unitⁿᶠ = unitⁿᶠ
[_≔_]ˢᵖ_ : ∀ {A B C Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ⁿᶠ A → Γ ⊢ˢᵖ B ⦙ C → Γ ∖ i ⊢ˢᵖ B ⦙ C
[ i ≔ s ]ˢᵖ nilˢᵖ = nilˢᵖ
[ i ≔ s ]ˢᵖ appˢᵖ xs u = appˢᵖ ([ i ≔ s ]ˢᵖ xs) ([ i ≔ s ]ⁿᶠ u)
[ i ≔ s ]ˢᵖ fstˢᵖ xs = fstˢᵖ ([ i ≔ s ]ˢᵖ xs)
[ i ≔ s ]ˢᵖ sndˢᵖ xs = sndˢᵖ ([ i ≔ s ]ˢᵖ xs)
reduce : ∀ {A C Γ} → Γ ⊢ⁿᶠ A → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ⁿᶠ C
reduce t nilˢᵖ = t
reduce (lamⁿᶠ t) (appˢᵖ xs u) = reduce ([ top ≔ u ]ⁿᶠ t) xs
reduce (pairⁿᶠ t u) (fstˢᵖ xs) = reduce t xs
reduce (pairⁿᶠ t u) (sndˢᵖ xs) = reduce u xs
-- Reduction-based normal forms.
appⁿᶠ : ∀ {A B Γ} → Γ ⊢ⁿᶠ A ▻ B → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B
appⁿᶠ t u = reduce t (appˢᵖ nilˢᵖ u)
fstⁿᶠ : ∀ {A B Γ} → Γ ⊢ⁿᶠ A ∧ B → Γ ⊢ⁿᶠ A
fstⁿᶠ t = reduce t (fstˢᵖ nilˢᵖ)
sndⁿᶠ : ∀ {A B Γ} → Γ ⊢ⁿᶠ A ∧ B → Γ ⊢ⁿᶠ B
sndⁿᶠ t = reduce t (sndˢᵖ nilˢᵖ)
-- Useful equipment for deriving neutrals.
≪appˢᵖ : ∀ {A B C Γ} → Γ ⊢ˢᵖ C ⦙ A ▻ B → Γ ⊢ⁿᶠ A → Γ ⊢ˢᵖ C ⦙ B
≪appˢᵖ nilˢᵖ t = appˢᵖ nilˢᵖ t
≪appˢᵖ (appˢᵖ xs u) t = appˢᵖ (≪appˢᵖ xs t) u
≪appˢᵖ (fstˢᵖ xs) t = fstˢᵖ (≪appˢᵖ xs t)
≪appˢᵖ (sndˢᵖ xs) t = sndˢᵖ (≪appˢᵖ xs t)
≪fstˢᵖ : ∀ {A B C Γ} → Γ ⊢ˢᵖ C ⦙ A ∧ B → Γ ⊢ˢᵖ C ⦙ A
≪fstˢᵖ nilˢᵖ = fstˢᵖ nilˢᵖ
≪fstˢᵖ (appˢᵖ xs u) = appˢᵖ (≪fstˢᵖ xs) u
≪fstˢᵖ (fstˢᵖ xs) = fstˢᵖ (≪fstˢᵖ xs)
≪fstˢᵖ (sndˢᵖ xs) = sndˢᵖ (≪fstˢᵖ xs)
≪sndˢᵖ : ∀ {A B C Γ} → Γ ⊢ˢᵖ C ⦙ A ∧ B → Γ ⊢ˢᵖ C ⦙ B
≪sndˢᵖ nilˢᵖ = sndˢᵖ nilˢᵖ
≪sndˢᵖ (appˢᵖ xs u) = appˢᵖ (≪sndˢᵖ xs) u
≪sndˢᵖ (fstˢᵖ xs) = fstˢᵖ (≪sndˢᵖ xs)
≪sndˢᵖ (sndˢᵖ xs) = sndˢᵖ (≪sndˢᵖ xs)
-- Derived neutrals.
varⁿᵉ : ∀ {A Γ} → A ∈ Γ → Γ ⊢ⁿᵉ A
varⁿᵉ i = spⁿᵉ i nilˢᵖ
appⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ▻ B → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᵉ B
appⁿᵉ (spⁿᵉ i xs) t = spⁿᵉ i (≪appˢᵖ xs t)
fstⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ∧ B → Γ ⊢ⁿᵉ A
fstⁿᵉ (spⁿᵉ i xs) = spⁿᵉ i (≪fstˢᵖ xs)
sndⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ∧ B → Γ ⊢ⁿᵉ B
sndⁿᵉ (spⁿᵉ i xs) = spⁿᵉ i (≪sndˢᵖ xs)
-- Iterated expansion.
expand : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊢ⁿᶠ A
expand {α P} t = neⁿᶠ t
expand {A ▻ B} t = lamⁿᶠ (expand (appⁿᵉ (mono⊢ⁿᵉ weak⊆ t) (expand (varⁿᵉ top))))
expand {A ∧ B} t = pairⁿᶠ (expand (fstⁿᵉ t)) (expand (sndⁿᵉ t))
expand {⊤} t = unitⁿᶠ
-- Expansion-based normal forms.
varⁿᶠ : ∀ {A Γ} → A ∈ Γ → Γ ⊢ⁿᶠ A
varⁿᶠ i = expand (varⁿᵉ i)
-- Translation from simple terms to normal forms.
tm→nf : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ⁿᶠ A
tm→nf (var i) = varⁿᶠ i
tm→nf (lam t) = lamⁿᶠ (tm→nf t)
tm→nf (app t u) = appⁿᶠ (tm→nf t) (tm→nf u)
tm→nf (pair t u) = pairⁿᶠ (tm→nf t) (tm→nf u)
tm→nf (fst t) = fstⁿᶠ (tm→nf t)
tm→nf (snd t) = sndⁿᶠ (tm→nf t)
tm→nf unit = unitⁿᶠ
-- Normalisation by hereditary substitution.
norm : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ A
norm = nf→tm ∘ tm→nf
| {
"alphanum_fraction": 0.5339805825,
"avg_line_length": 30.2385321101,
"ext": "agda",
"hexsha": "13d1226578752a1674d1d6656fe24b87ea485fa1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIPC/Metatheory/GentzenSpinalNormalForm-HereditarySubstitution.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIPC/Metatheory/GentzenSpinalNormalForm-HereditarySubstitution.agda",
"max_line_length": 84,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIPC/Metatheory/GentzenSpinalNormalForm-HereditarySubstitution.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 2256,
"size": 3296
} |
{-# OPTIONS --cubical --no-positivity-check --no-termination-check #-}
open import Prelude
open import Algebra
open import Algebra.Monus
open import Relation.Binary
open import Data.Maybe
open import Data.List using (List; _∷_; []; foldr)
module Control.Monad.HeapT
{ℓ}
(monoid : Monoid ℓ)
(gmon : GradedMonad monoid ℓ ℓ)
where
open Monoid monoid
open GradedMonad gmon
private
variable
w : 𝑆
infixr 5 _∷_
infixr 6 _⋊_
mutual
record Root (A : Type ℓ) : Type ℓ where
coinductive
constructor _⋊_
field
weight : 𝑆
step : 𝐹 weight (Branch A)
data Node (A : Type ℓ) : Type ℓ where
⌊_⌋ : A → Node A
⌈_⌉ : Root A → Node A
data Branch (A : Type ℓ) : Type ℓ where
[] : Branch A
_∷_ : Node A → 𝐹 ε (Branch A) → Branch A
open Root public
Heap : Type ℓ → Type ℓ
Heap A = 𝐹 ε (Branch A)
infixr 5 _++_
_++_ : 𝐹 w (Branch A) → 𝐹 ε (Branch A) → 𝐹 w (Branch A)
xs ++ ys =
xs >>=ε λ { [] → ys
; (x ∷ xs) → pure (x ∷ xs ++ ys) }
infixr 1 _>>=ᴺ_ _>>=ᴴ_
mutual
_>>=ᴺ_ : Node A → (A → Heap B) → Heap B
⌊ x ⌋ >>=ᴺ f = f x
⌈ x ⌉ >>=ᴺ f = pure (⌈ weight x ⋊ (step x >>=ᴴ f) ⌉ ∷ pure [])
_>>=ᴴ_ : 𝐹 w (Branch A) → (A → Heap B) → 𝐹 w (Branch B)
xs >>=ᴴ f =
xs >>=ε λ { [] → pure []
; (x ∷ xs) → (x >>=ᴺ f) ++ (xs >>=ᴴ f) }
pureᴴ : A → Heap A
pureᴴ x = pure (⌊ x ⌋ ∷ pure [])
liftᴴ : 𝐹 w A → Heap A
liftᴴ xs = pure (⌈ _ ⋊ map (λ x → ⌊ x ⌋ ∷ pure []) xs ⌉ ∷ pure [])
flatten : 𝐹 w (Branch A) → 𝐹 w (List A × List (Root A))
flatten xs =
xs >>=ε λ { [] → pure ([] , [])
; (⌊ x ⌋ ∷ xs) → map (map₁ (x ∷_)) (flatten xs)
; (⌈ x ⌉ ∷ xs) → map (map₂ (x ∷_)) (flatten xs) }
module PopMin
(_≤|≥_ : Total (λ x y → ∃ z × (y ≡ x ∙ z)))
(decomp : ∀ {A B w₁ w₂ w₃} → 𝐹 (w₁ ∙ w₂) A → 𝐹 (w₁ ∙ w₃) B → 𝐹 w₁ (𝐹 w₂ A × 𝐹 w₃ B)) where
_∪_ : Root A → Root A → Root A
xs ∪ ys with weight xs ≤|≥ weight ys
... | inl (k , wʸ≡wˣ∙k) = weight xs ⋊ map (λ { (xs , ys) → ⌈ k ⋊ ys ⌉ ∷ xs }) (decomp (subst (flip 𝐹 _) (sym (∙ε _)) (step xs)) (subst (flip 𝐹 _) wʸ≡wˣ∙k (step ys)))
... | inr (k , wˣ≡wʸ∙k) = weight ys ⋊ map (λ { (ys , xs) → ⌈ k ⋊ xs ⌉ ∷ ys }) (decomp (subst (flip 𝐹 _) (sym (∙ε _)) (step ys)) (subst (flip 𝐹 _) wˣ≡wʸ∙k (step xs)))
⋃⁺ : Root A → List (Root A) → Root A
⋃⁺ x₁ [] = x₁
⋃⁺ x₁ (x₂ ∷ []) = x₁ ∪ x₂
⋃⁺ x₁ (x₂ ∷ x₃ ∷ xs) = (x₁ ∪ x₂) ∪ ⋃⁺ x₃ xs
⋃ : List (Root A) → Maybe (Root A)
⋃ [] = nothing
⋃ (x ∷ xs) = just (⋃⁺ x xs)
popMin : 𝐹 w (Branch A) → 𝐹 w (List A × Maybe (Root A))
popMin = map (map₂ ⋃) ∘ flatten
| {
"alphanum_fraction": 0.4898739014,
"avg_line_length": 27.5473684211,
"ext": "agda",
"hexsha": "b075fb8e8d207f6404bc4db9060fc31401302488",
"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/Monad/HeapT.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/Monad/HeapT.agda",
"max_line_length": 167,
"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/Monad/HeapT.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": 1263,
"size": 2617
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The min operator derived from an arbitrary total order
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Algebra.Construct.NaturalChoice.Min
{a ℓ₁ ℓ₂} (totalOrder : TotalOrder a ℓ₁ ℓ₂)
where
open import Algebra
open import Data.Sum using (inj₁; inj₂; [_,_])
open import Data.Product using (_,_)
open import Function using (id)
open TotalOrder totalOrder renaming (Carrier to A)
open import Algebra.FunctionProperties _≈_
open import Algebra.Structures _≈_
----------------------------------------------------------------------------
-- Definition
infixl 7 _⊓_
_⊓_ : Op₂ A
x ⊓ y with total x y
... | inj₁ x≤y = x
... | inj₂ y≤x = y
----------------------------------------------------------------------------
-- Algebraic properties
⊓-sel : Selective _⊓_
⊓-sel x y with total x y
... | inj₁ x≤y = inj₁ Eq.refl
... | inj₂ y≤x = inj₂ Eq.refl
⊓-idem : Idempotent _⊓_
⊓-idem x with ⊓-sel x x
... | inj₁ x⊓x=x = x⊓x=x
... | inj₂ x⊓x=x = x⊓x=x
⊓-cong : Congruent₂ _⊓_
⊓-cong {w} {x} {y} {z} w≈x y≈z with total w y | total x z
... | inj₁ w≤y | inj₁ x≤z = w≈x
... | inj₁ w≤y | inj₂ z≤x = antisym (≤-respʳ-≈ y≈z w≤y) (≤-respʳ-≈ (Eq.sym w≈x) z≤x)
... | inj₂ y≤w | inj₁ x≤z = antisym (≤-respʳ-≈ w≈x y≤w) (≤-respʳ-≈ (Eq.sym y≈z) x≤z)
... | inj₂ y≤w | inj₂ z≤x = y≈z
⊓-comm : Commutative _⊓_
⊓-comm x y with total x y | total y x
... | inj₁ x≤y | inj₁ y≤x = antisym x≤y y≤x
... | inj₁ _ | inj₂ _ = Eq.refl
... | inj₂ _ | inj₁ _ = Eq.refl
... | inj₂ y≤x | inj₂ x≤y = antisym y≤x x≤y
⊓-assoc : Associative _⊓_
⊓-assoc x y z with total x y | total x z | total y z
⊓-assoc x y z | inj₁ x≤y | inj₁ x≤z | inj₁ y≤z with total x z | total x y
... | inj₁ x≤z₂ | inj₁ _ = Eq.refl
... | inj₁ x≤z₂ | inj₂ y≤x = antisym x≤y y≤x
... | inj₂ z≤x | inj₁ _ = antisym z≤x (trans x≤y y≤z)
... | inj₂ z≤x | inj₂ y≤x = antisym (trans z≤x x≤y) (trans y≤x x≤z)
⊓-assoc x y z | inj₁ x≤y | inj₁ x≤z | inj₂ z≤y with total x z
... | inj₁ _ = Eq.refl
... | inj₂ _ = Eq.refl
⊓-assoc x y z | inj₁ x≤y | inj₂ z≤x | inj₁ y≤z with total x z | total x y
... | inj₁ x≤z | inj₁ _ = Eq.refl
... | inj₁ x≤z | inj₂ y≤x = antisym x≤y (trans y≤z z≤x)
... | inj₂ _ | inj₁ _ = antisym z≤x (trans x≤y y≤z)
... | inj₂ _ | inj₂ y≤x = antisym (trans z≤x x≤y) y≤z
⊓-assoc x y z | inj₁ x≤y | inj₂ z≤x | inj₂ z≤y with total x z
... | inj₁ _ = Eq.refl
... | inj₂ _ = Eq.refl
⊓-assoc x y z | inj₂ y≤x | inj₁ x≤z | inj₁ y≤z with total y z | total x y
... | inj₁ _ | inj₁ x≤y = antisym y≤x x≤y
... | inj₁ _ | inj₂ _ = Eq.refl
... | inj₂ z≤y | inj₁ x≤y = antisym (trans z≤y y≤x) (trans x≤y y≤z)
... | inj₂ z≤y | inj₂ _ = antisym z≤y (trans y≤x x≤z)
⊓-assoc x y z | inj₂ y≤x | inj₁ x≤z | inj₂ z≤y with total y z | total x z
... | inj₁ y≤z | inj₁ _ = antisym y≤x (trans x≤z z≤y)
... | inj₁ y≤z | inj₂ z≤x = antisym (trans y≤x x≤z) z≤y
... | inj₂ _ | inj₁ _ = antisym (trans z≤y y≤x) x≤z
... | inj₂ _ | inj₂ z≤x = Eq.refl
⊓-assoc x y z | inj₂ y≤x | inj₂ z≤x | inj₁ y≤z with total y z | total x y
... | inj₁ _ | inj₁ x≤y = antisym (trans y≤z z≤x) x≤y
... | inj₁ _ | inj₂ _ = Eq.refl
... | inj₂ z≤y | inj₁ x≤y = antisym (trans z≤y y≤x) (trans x≤y y≤z)
... | inj₂ z≤y | inj₂ _ = antisym z≤y y≤z
⊓-assoc x y z | inj₂ y≤x | inj₂ z≤x | inj₂ z≤y with total y z | total x z
... | inj₁ y≤z | inj₁ x≤z = antisym (trans y≤z z≤x) (trans x≤z z≤y)
... | inj₁ y≤z | inj₂ _ = antisym y≤z z≤y
... | inj₂ _ | inj₁ x≤z = antisym (trans z≤y y≤x) x≤z
... | inj₂ _ | inj₂ _ = Eq.refl
⊓-identityˡ : ∀ {⊥} → Maximum _≤_ ⊥ → LeftIdentity ⊥ _⊓_
⊓-identityˡ {⊥} top x with total ⊥ x
... | inj₁ ⊥≤x = antisym ⊥≤x (top x)
... | inj₂ x≤⊥ = Eq.refl
⊓-identityʳ : ∀ {⊥} → Maximum _≤_ ⊥ → RightIdentity ⊥ _⊓_
⊓-identityʳ {⊥} top x with total x ⊥
... | inj₁ x≤⊥ = Eq.refl
... | inj₂ ⊥≤x = antisym ⊥≤x (top x)
⊓-identity : ∀ {⊥} → Maximum _≤_ ⊥ → Identity ⊥ _⊓_
⊓-identity top = (⊓-identityˡ top , ⊓-identityʳ top)
⊓-zeroˡ : ∀ {⊥} → Minimum _≤_ ⊥ → LeftZero ⊥ _⊓_
⊓-zeroˡ {⊥} bot x with total ⊥ x
... | inj₁ ⊥≤x = Eq.refl
... | inj₂ x≤⊥ = antisym x≤⊥ (bot x)
⊓-zeroʳ : ∀ {⊥} → Minimum _≤_ ⊥ → RightZero ⊥ _⊓_
⊓-zeroʳ {⊥} bot x with total x ⊥
... | inj₁ x≤⊥ = antisym x≤⊥ (bot x)
... | inj₂ ⊥≤x = Eq.refl
⊓-zero : ∀ {⊥} → Minimum _≤_ ⊥ → Zero ⊥ _⊓_
⊓-zero bot = (⊓-zeroˡ bot , ⊓-zeroʳ bot)
----------------------------------------------------------------------------
-- Algebraic structures
⊓-isMagma : IsMagma _⊓_
⊓-isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = ⊓-cong
}
⊓-isSemigroup : IsSemigroup _⊓_
⊓-isSemigroup = record
{ isMagma = ⊓-isMagma
; assoc = ⊓-assoc
}
⊓-isBand : IsBand _⊓_
⊓-isBand = record
{ isSemigroup = ⊓-isSemigroup
; idem = ⊓-idem
}
⊓-isSemilattice : IsSemilattice _⊓_
⊓-isSemilattice = record
{ isBand = ⊓-isBand
; comm = ⊓-comm
}
⊓-isMonoid : ∀ {⊥} → Maximum _≤_ ⊥ → IsMonoid _⊓_ ⊥
⊓-isMonoid top = record
{ isSemigroup = ⊓-isSemigroup
; identity = ⊓-identity top
}
----------------------------------------------------------------------------
-- Algebraic packages
⊓-magma : Magma a ℓ₁
⊓-magma = record
{ isMagma = ⊓-isMagma
}
⊓-semigroup : Semigroup a ℓ₁
⊓-semigroup = record
{ isSemigroup = ⊓-isSemigroup
}
⊓-band : Band a ℓ₁
⊓-band = record
{ isBand = ⊓-isBand
}
⊓-semilattice : Semilattice a ℓ₁
⊓-semilattice = record
{ isSemilattice = ⊓-isSemilattice
}
⊓-monoid : ∀ {⊥} → Maximum _≤_ ⊥ → Monoid a ℓ₁
⊓-monoid top = record
{ isMonoid = ⊓-isMonoid top
}
----------------------------------------------------------------------------
-- Other properties
x⊓y≈y⇒y≤x : ∀ {x y} → x ⊓ y ≈ y → y ≤ x
x⊓y≈y⇒y≤x {x} {y} x⊓y≈y with total x y
... | inj₁ _ = reflexive (Eq.sym x⊓y≈y)
... | inj₂ y≤x = y≤x
x⊓y≈x⇒x≤y : ∀ {x y} → x ⊓ y ≈ x → x ≤ y
x⊓y≈x⇒x≤y {x} {y} x⊓y≈x with total x y
... | inj₁ x≤y = x≤y
... | inj₂ _ = reflexive (Eq.sym x⊓y≈x)
| {
"alphanum_fraction": 0.5045617465,
"avg_line_length": 30.8442211055,
"ext": "agda",
"hexsha": "626d0dc68187e3c4e1c9d375baa092bf8914a071",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Construct/NaturalChoice/Min.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Construct/NaturalChoice/Min.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Construct/NaturalChoice/Min.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2901,
"size": 6138
} |
{-# OPTIONS --without-K --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Reflexivity {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Substitution
open import Definition.Untyped using (Con ; Term)
open import Tools.Nat
open import Tools.Product
private
variable
n : Nat
Γ : Con Term n
-- Reflexivity of valid types.
reflᵛ : ∀ {A l}
([Γ] : ⊩ᵛ Γ)
([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ])
→ Γ ⊩ᵛ⟨ l ⟩ A ≡ A / [Γ] / [A]
reflᵛ [Γ] [A] ⊢Δ [σ] =
reflEq (proj₁ ([A] ⊢Δ [σ]))
-- Reflexivity of valid terms.
reflᵗᵛ : ∀ {A t l}
([Γ] : ⊩ᵛ Γ)
([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ])
([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ A / [Γ] / [A])
→ Γ ⊩ᵛ⟨ l ⟩ t ≡ t ∷ A / [Γ] / [A]
reflᵗᵛ [Γ] [A] [t] ⊢Δ [σ] =
reflEqTerm (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ]))
| {
"alphanum_fraction": 0.5542168675,
"avg_line_length": 25.3611111111,
"ext": "agda",
"hexsha": "76ff21e6ebe588b13e8b684e5785b039329118ee",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z",
"max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "fhlkfy/logrel-mltt",
"max_forks_repo_path": "Definition/LogicalRelation/Substitution/Reflexivity.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "fhlkfy/logrel-mltt",
"max_issues_repo_path": "Definition/LogicalRelation/Substitution/Reflexivity.agda",
"max_line_length": 85,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "fhlkfy/logrel-mltt",
"max_stars_repo_path": "Definition/LogicalRelation/Substitution/Reflexivity.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z",
"num_tokens": 386,
"size": 913
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- A universe of proposition functors, along with some properties
------------------------------------------------------------------------
module Relation.Nullary.Universe where
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Relation.Binary hiding (_⇒_)
open import Relation.Binary.Simple
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; refl)
open import Relation.Binary.Sum
open import Relation.Binary.Product.Pointwise
open import Data.Sum as Sum hiding (map)
open import Data.Product as Prod hiding (map)
open import Function
import Function.Equality as FunS
open import Data.Empty
open import Category.Applicative
open import Category.Monad
open import Level
infix 5 ¬¬_
infixr 4 _⇒_
infixr 3 _∧_
infixr 2 _∨_
infix 1 ⟨_⟩_≈_
-- The universe.
data PropF p : Set (suc p) where
Id : PropF p
K : (P : Set p) → PropF p
_∨_ : (F₁ F₂ : PropF p) → PropF p
_∧_ : (F₁ F₂ : PropF p) → PropF p
_⇒_ : (P₁ : Set p) (F₂ : PropF p) → PropF p
¬¬_ : (F : PropF p) → PropF p
-- Equalities for universe inhabitants.
mutual
setoid : ∀ {p} → PropF p → Set p → Setoid p p
setoid Id P = PropEq.setoid P
setoid (K P) _ = PropEq.setoid P
setoid (F₁ ∨ F₂) P = (setoid F₁ P) ⊎-setoid (setoid F₂ P)
setoid (F₁ ∧ F₂) P = (setoid F₁ P) ×-setoid (setoid F₂ P)
setoid (P₁ ⇒ F₂) P = FunS.≡-setoid P₁
(Setoid.indexedSetoid (setoid F₂ P))
setoid (¬¬ F) P = Always-setoid (¬ ¬ ⟦ F ⟧ P)
⟦_⟧ : ∀ {p} → PropF p → (Set p → Set p)
⟦ F ⟧ P = Setoid.Carrier (setoid F P)
⟨_⟩_≈_ : ∀ {p} (F : PropF p) {P : Set p} → Rel (⟦ F ⟧ P) p
⟨_⟩_≈_ F = Setoid._≈_ (setoid F _)
-- ⟦ F ⟧ is functorial.
map : ∀ {p} (F : PropF p) {P Q} → (P → Q) → ⟦ F ⟧ P → ⟦ F ⟧ Q
map Id f p = f p
map (K P) f p = p
map (F₁ ∨ F₂) f FP = Sum.map (map F₁ f) (map F₂ f) FP
map (F₁ ∧ F₂) f FP = Prod.map (map F₁ f) (map F₂ f) FP
map (P₁ ⇒ F₂) f FP = map F₂ f ∘ FP
map (¬¬ F) f FP = ¬¬-map (map F f) FP
map-id : ∀ {p} (F : PropF p) {P} → ⟨ ⟦ F ⟧ P ⇒ F ⟩ map F id ≈ id
map-id Id x = refl
map-id (K P) x = refl
map-id (F₁ ∨ F₂) (inj₁ x) = ₁∼₁ (map-id F₁ x)
map-id (F₁ ∨ F₂) (inj₂ y) = ₂∼₂ (map-id F₂ y)
map-id (F₁ ∧ F₂) (x , y) = (map-id F₁ x , map-id F₂ y)
map-id (P₁ ⇒ F₂) f = λ x → map-id F₂ (f x)
map-id (¬¬ F) ¬¬x = _
map-∘ : ∀ {p} (F : PropF p) {P Q R} (f : Q → R) (g : P → Q) →
⟨ ⟦ F ⟧ P ⇒ F ⟩ map F f ∘ map F g ≈ map F (f ∘ g)
map-∘ Id f g x = refl
map-∘ (K P) f g x = refl
map-∘ (F₁ ∨ F₂) f g (inj₁ x) = ₁∼₁ (map-∘ F₁ f g x)
map-∘ (F₁ ∨ F₂) f g (inj₂ y) = ₂∼₂ (map-∘ F₂ f g y)
map-∘ (F₁ ∧ F₂) f g x = (map-∘ F₁ f g (proj₁ x) ,
map-∘ F₂ f g (proj₂ x))
map-∘ (P₁ ⇒ F₂) f g h = λ x → map-∘ F₂ f g (h x)
map-∘ (¬¬ F) f g x = _
-- A variant of sequence can be implemented for ⟦ F ⟧.
sequence : ∀ {p AF} → RawApplicative AF →
(AF (Lift ⊥) → ⊥) →
({A B : Set p} → (A → AF B) → AF (A → B)) →
∀ F {P} → ⟦ F ⟧ (AF P) → AF (⟦ F ⟧ P)
sequence {AF = AF} A extract-⊥ sequence-⇒ = helper
where
open RawApplicative A
helper : ∀ F {P} → ⟦ F ⟧ (AF P) → AF (⟦ F ⟧ P)
helper Id x = x
helper (K P) x = pure x
helper (F₁ ∨ F₂) (inj₁ x) = inj₁ <$> helper F₁ x
helper (F₁ ∨ F₂) (inj₂ y) = inj₂ <$> helper F₂ y
helper (F₁ ∧ F₂) (x , y) = _,_ <$> helper F₁ x ⊛ helper F₂ y
helper (P₁ ⇒ F₂) f = sequence-⇒ (helper F₂ ∘ f)
helper (¬¬ F) x =
pure (λ ¬FP → x (λ fp → extract-⊥ (lift ∘ ¬FP <$> helper F fp)))
-- Some lemmas about double negation.
private
open module M {p} = RawMonad (¬¬-Monad {p = p})
¬¬-pull : ∀ {p} (F : PropF p) {P} →
⟦ F ⟧ (¬ ¬ P) → ¬ ¬ ⟦ F ⟧ P
¬¬-pull = sequence rawIApplicative
(λ f → f lower)
(λ f g → g (λ x → ⊥-elim (f x (λ y → g (λ _ → y)))))
¬¬-remove : ∀ {p} (F : PropF p) {P} →
¬ ¬ ⟦ F ⟧ (¬ ¬ P) → ¬ ¬ ⟦ F ⟧ P
¬¬-remove F = negated-stable ∘ ¬¬-pull (¬¬ F)
| {
"alphanum_fraction": 0.4941204704,
"avg_line_length": 33.336,
"ext": "agda",
"hexsha": "c85f85821bc8b712dd1ed498ecd6355eb03e29ce",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Universe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Universe.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Relation/Nullary/Universe.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 1730,
"size": 4167
} |
module BFF where
open import Data.Nat using (ℕ)
open import Data.Fin using (Fin)
open import Level using () renaming (zero to ℓ₀)
import Category.Monad
import Category.Functor
open import Data.Maybe using (Maybe ; just ; nothing ; maybe′)
open Category.Monad.RawMonad {Level.zero} Data.Maybe.monad using (_>>=_)
open Category.Functor.RawFunctor {Level.zero} Data.Maybe.functor using (_<$>_)
open import Data.List using (List ; [] ; _∷_ ; map ; length)
open import Data.Vec using (Vec ; toList ; fromList ; allFin) renaming (lookup to lookupV ; map to mapV ; [] to []V ; _∷_ to _∷V_)
open import Function using (_∘_ ; flip)
open import Relation.Binary using (Setoid ; DecSetoid ; module DecSetoid)
open import FinMap
open import Generic using (sequenceV ; ≡-to-Π)
open import Structures using (Shaped ; module Shaped)
open import Instances using (VecShaped)
import CheckInsert
open import GetTypes using (VecVec-to-PartialVecVec ; PartialVecVec-to-PartialShapeShape)
module PartialShapeBFF (A : DecSetoid ℓ₀ ℓ₀) where
open GetTypes.PartialShapeShape public using (Get ; module Get)
open module A = DecSetoid A using (Carrier) renaming (_≟_ to deq)
open CheckInsert A
assoc : {n m : ℕ} → Vec (Fin n) m → Vec Carrier m → Maybe (FinMapMaybe n Carrier)
assoc []V []V = just empty
assoc (i ∷V is) (b ∷V bs) = (assoc is bs) >>= (checkInsert i b)
enumerate : {S : Set} {C : Set → S → Set} → (ShapeT : Shaped S C) → (s : S) → C (Fin (Shaped.arity ShapeT s)) s
enumerate ShapeT s = fill s (allFin (arity s))
where open Shaped ShapeT
denumerate : {S : Set} {C : Set → S → Set} → (ShapeT : Shaped S C) → {α : Set} {s : S} → (c : C α s) → Fin (Shaped.arity ShapeT s) → α
denumerate ShapeT c = flip lookupV (Shaped.content ShapeT c)
bff : (G : Get) → {i : Get.I G} → (j : Get.I G) → Get.SourceContainer G Carrier (Get.gl₁ G i) → Get.ViewContainer G Carrier (Get.gl₂ G j) → Maybe (Get.SourceContainer G (Maybe Carrier) (Get.gl₁ G j))
bff G {i} j s v = let s′ = enumerate SourceShapeT (gl₁ i)
t′ = get s′
g = fromFunc (denumerate SourceShapeT s)
g′ = delete-many (Shaped.content ViewShapeT t′) g
t = enumerate SourceShapeT (gl₁ j)
h = assoc (Shaped.content ViewShapeT (get t)) (Shaped.content ViewShapeT v)
h′ = (flip union (reshape g′ (Shaped.arity SourceShapeT (gl₁ j)))) <$> h
in ((λ f → fmapS f t) ∘ flip lookupM) <$> h′
where open Get G
sbff : (G : Get) → {i : Get.I G} → (j : Get.I G) → Get.SourceContainer G Carrier (Get.gl₁ G i) → Get.ViewContainer G Carrier (Get.gl₂ G j) → Maybe (Get.SourceContainer G Carrier (Get.gl₁ G j))
sbff G j s v = bff G j s v >>= Shaped.sequence (Get.SourceShapeT G)
module PartialVecBFF (A : DecSetoid ℓ₀ ℓ₀) where
open GetTypes.PartialVecVec public using (Get)
open module A = DecSetoid A using (Carrier) renaming (_≟_ to deq)
open CheckInsert A
open PartialShapeBFF A public using (assoc)
enumerate : {n : ℕ} → Vec Carrier n → Vec (Fin n) n
enumerate {n} _ = PartialShapeBFF.enumerate A VecShaped n
enumeratel : (n : ℕ) → Vec (Fin n) n
enumeratel = PartialShapeBFF.enumerate A VecShaped
denumerate : {n : ℕ} → Vec Carrier n → Fin n → Carrier
denumerate = PartialShapeBFF.denumerate A VecShaped
bff : (G : Get) → {i : Get.I G} → (j : Get.I G) → Vec Carrier (Get.gl₁ G i) → Vec Carrier (Get.gl₂ G j) → Maybe (Vec (Maybe Carrier) (Get.gl₁ G j))
bff G j s v = PartialShapeBFF.bff A (PartialVecVec-to-PartialShapeShape G) j s v
sbff : (G : Get) → {i : Get.I G} → (j : Get.I G) → Vec Carrier (Get.gl₁ G i) → Vec Carrier (Get.gl₂ G j) → Maybe (Vec Carrier (Get.gl₁ G j))
sbff G j s v = PartialShapeBFF.sbff A (PartialVecVec-to-PartialShapeShape G) j s v
module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where
open GetTypes.VecVec public using (Get)
open module A = DecSetoid A using (Carrier) renaming (_≟_ to deq)
open CheckInsert A
open PartialVecBFF A public using (assoc ; enumerate ; denumerate)
bff : (G : Get) → {n : ℕ} → (m : ℕ) → Vec Carrier n → Vec Carrier (Get.getlen G m) → Maybe (Vec (Maybe Carrier) m)
bff G = PartialVecBFF.bff A (VecVec-to-PartialVecVec G)
sbff : (G : Get) → {n : ℕ} → (m : ℕ) → Vec Carrier n → Vec Carrier (Get.getlen G m) → Maybe (Vec Carrier m)
sbff G = PartialVecBFF.sbff A (VecVec-to-PartialVecVec G)
| {
"alphanum_fraction": 0.6490950226,
"avg_line_length": 50.8045977011,
"ext": "agda",
"hexsha": "e9b459a7a91c0adef89006364f94cc25770c4ff6",
"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": "BFF.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": "BFF.agda",
"max_line_length": 201,
"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": "BFF.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1432,
"size": 4420
} |
module MLib.Prelude.FromStdlib where
--------------------------------------------------------------------------------
-- Misc
--------------------------------------------------------------------------------
open import Level public
using (Level)
renaming ( zero to zeroˡ; suc to sucˡ; _⊔_ to _⊔ˡ_
; Lift to Liftˡ; lift to liftˡ; lower to lowerˡ)
--------------------------------------------------------------------------------
-- Data
--------------------------------------------------------------------------------
module Σ where
open import Data.Product public
hiding (module Σ)
open import Data.Product.Relation.Pointwise.Dependent public
using (_,_; Pointwise-≡⇒≡; ≡⇒Pointwise-≡)
open import Data.Product.Relation.Pointwise.NonDependent public
using (≡×≡⇒≡; ≡⇒≡×≡)
open Σ using (Σ; _×_; _,_; proj₁; proj₂; ∃; ∃₂; curry; uncurry) public
open import Data.Sum public
using (_⊎_; inj₁; inj₂)
open import Data.Unit public
using (⊤; tt)
open import Data.Empty public
using (⊥; ⊥-elim)
module Bool where
open import Data.Bool public
open import Data.Bool.Properties public
open Bool using (Bool; true; false; if_then_else_) hiding (module Bool) public
module Nat where
open import Data.Nat public
open import Data.Nat.Properties public
open Nat using (ℕ; zero; suc) hiding (module ℕ) public
module Maybe where
open import Data.Maybe public
open Maybe using (Maybe; just; nothing; maybe) hiding (module Maybe) public
module List where
open import Data.List public
open import Data.List.Properties public
module All where
open import Data.List.All public hiding (module All)
open import Data.List.All.Properties public
traverse : ∀ {a p p′} {A : Set a} {P : A → Set p} {P′ : A → Set p′} → (∀ {x} → P x → Maybe (P′ x)) → {xs : List A} → All P xs → Maybe (All P′ xs)
traverse f [] = just []
traverse f (px ∷ ap) with f px | traverse f ap
traverse f (px ∷ ap) | just px′ | just ap′ = just (px′ ∷ ap′)
traverse f (px ∷ ap) | _ | _ = nothing
open All using (All) public
open List using (List; _∷_; []) hiding (module List) public
module Table where
open import Data.Table public
open import Data.Table.Properties public
open import Data.Table.Relation.Equality public
open Table using (Table; tabulate; lookup) hiding (module Table) public
module Vec where
open import Data.Vec public
hiding (module Vec)
open import Data.Vec.Properties public
module Pointwise where
open import Data.Vec.Relation.Pointwise.Inductive public
open Pointwise public
using (Pointwise; []; _∷_) hiding (module Pointwise)
open Vec public
using (Vec; []; _∷_)
module FE where
open import Function.Equality hiding (module Π) public
open FE using (_⟶_; _⟨$⟩_) public
module Inverse where
open import Function.Inverse public
open Inverse public
open Inverse using (Inverse; _↔_) hiding (module Inverse) public
module LeftInverse where
open import Function.LeftInverse public
open LeftInverse public
open LeftInverse using (LeftInverse; _↞_) hiding (module LeftInverse) public
--------------------------------------------------------------------------------
-- Combinators
--------------------------------------------------------------------------------
module Function where
open import Function public
open Function using (id; _∘_; case_of_) public
--------------------------------------------------------------------------------
-- Relations
--------------------------------------------------------------------------------
open import Relation.Nullary public
using (Dec; yes; no; ¬_)
open import Relation.Nullary.Decidable public
using (⌊_⌋)
-- Export names that can only apply to binary relations; things like 'Decidable'
-- can apply to nullary or unary relations too!
open import Relation.Binary.Core public
using (Reflexive; Symmetric; Transitive; Irreflexive; Antisymmetric; Asymmetric; Trichotomous)
open import Relation.Binary public
using (Rel; Setoid; IsEquivalence; Poset; IsPartialOrder)
module EqReasoning {c ℓ} (setoid : Setoid c ℓ) where
open import Relation.Binary.EqReasoning setoid public
module ≡ where
open import Relation.Binary.PropositionalEquality public
renaming (module ≡-Reasoning to Reasoning)
open ≡ using (_≡_) public
module ≅ where
open import Relation.Binary.HeterogeneousEquality public
renaming (module ≅-Reasoning to Reasoning)
open ≅ using (_≅_) public
--------------------------------------------------------------------------------
-- Algebra
--------------------------------------------------------------------------------
module Algebra where
open import Algebra public
open import Algebra.Structures public
module FunctionProperties {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where
open import Algebra.FunctionProperties _≈_ public
--------------------------------------------------------------------------------
-- From Holes.Prelude
--------------------------------------------------------------------------------
open import Holes.Prelude public using
( RawMonad
; _>>=_
; return
; _<$>_
; join
; RawTraversable
; traverse
; sequence
; Choice
; _<|>_
)
infixl 1 _>>=ₘ_ _>>=ₗ_
_>>=ₘ_ : ∀ {a b} {A : Set a} {B : Set b} → Maybe A → (A → Maybe B) → Maybe B
nothing >>=ₘ _ = nothing
just x >>=ₘ f = f x
_>>=ₗ_ : ∀ {a b} {A : Set a} {B : Set b} → List A → (A → List B) → List B
[] >>=ₗ _ = []
(x ∷ xs) >>=ₗ f = f x List.++ (xs >>=ₗ f)
instance
Maybe-Monad : ∀ {a} → RawMonad {a} Maybe
_>>=_ {{Maybe-Monad}} = _>>=ₘ_
return {{Maybe-Monad}} = just
List-Monad : ∀ {a} → RawMonad {a} List
_>>=_ {{List-Monad}} = _>>=ₗ_
return {{List-Monad}} x = x ∷ []
instance
Maybe-Traversable : ∀ {a} → RawTraversable {a} Maybe
traverse {{Maybe-Traversable}} f (just x) = just <$> f x
traverse {{Maybe-Traversable}} f nothing = return nothing
List-Traversable : ∀ {a} → RawTraversable {a} List
traverse {{List-Traversable}} f [] = return []
traverse {{List-Traversable}} f (x ∷ xs) =
f x >>= λ x′ →
traverse {{List-Traversable}} f xs >>= λ xs′ →
return (x′ ∷ xs′)
instance
Maybe-Choice : ∀ {a} → Choice {a} Maybe
Choice._<|>_ Maybe-Choice (just x) _ = just x
Choice._<|>_ Maybe-Choice nothing y = y
module List-All where
open List
open All using ([]; _∷_)
traverse-map :
∀ {a p q r} {A : Set a} {P : A → Set p} {Q : A → Set q} {R : A → Set r}
(g : ∀ {x} → Q x → Maybe (R x)) (f : ∀ {x} → P x → Q x)
{xs : List A} (ap : All P xs) → All.traverse g (All.map f ap) ≡ All.traverse (g ∘ f) ap
traverse-map g f [] = ≡.refl
traverse-map g f (px ∷ ap) with g (f px)
traverse-map g f (px ∷ ap) | just _ rewrite traverse-map g f ap = ≡.refl
traverse-map g f (px ∷ ap) | nothing = ≡.refl
traverse-just : ∀ {a p} {A : Set a} {P : A → Set p} {xs : List A} (ap : All P xs) → All.traverse just ap ≡ just ap
traverse-just [] = ≡.refl
traverse-just (px ∷ ap) rewrite traverse-just ap = ≡.refl
traverse-cong :
∀ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q}
(f g : ∀ {x} → P x → Maybe (Q x)) →
(∀ {x} (p : P x) → f p ≡ g p) →
∀ {xs : List A} (ap : All P xs) →
All.traverse f ap ≡ All.traverse g ap
traverse-cong f g eq [] = ≡.refl
traverse-cong f g eq (px ∷ ap) rewrite eq px | traverse-cong f g eq ap = ≡.refl
| {
"alphanum_fraction": 0.569258144,
"avg_line_length": 32.6160714286,
"ext": "agda",
"hexsha": "69df62602be23a5397a6b36e92e463ee8eeb86c8",
"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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib/Prelude/FromStdlib.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"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": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib/Prelude/FromStdlib.agda",
"max_line_length": 149,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib/Prelude/FromStdlib.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2115,
"size": 7306
} |
module Categories.Agda.ISetoids.Complete where
open import Level
open import Relation.Binary using (Setoid; module Setoid; Preorder; module Preorder; Rel; _=[_]⇒_)
open import Data.Product using (Σ; _,_; proj₁; proj₂)
open import Categories.Support.IProduct
-- import Relation.Binary.EqReasoning as EqReasoning
open import Categories.Support.Equivalence using (module I→R-Wrapper; setoid-i→r; Fam-setoid; ∀[_]-setoid_)
renaming (Setoid to ISetoid; module Setoid to ISetoid)
open import Categories.Support.SetoidFunctions using (module _⟶_)
open import Categories.Support.PropositionalEquality
import Categories.Support.ZigZag as ZigZag
open import Categories.Category
open import Categories.Functor
import Categories.NaturalTransformation as NT
open import Categories.Agda
open import Categories.Colimit
open import Categories.Object.Initial
open import Categories.Cocones
open import Categories.Cocone
ISetoidsComplete : ∀ {o ℓ e c ℓ′} → Cocomplete o ℓ e (Category.op (ISetoids (c ⊔ ℓ′ ⊔ (o ⊔ ℓ ⊔ e)) (c ⊔ (o ⊔ ℓ ⊔ e))))
ISetoidsComplete {o} {ℓ} {e} {c} {cℓ} = record { colimit = colimit }
where
c′ = c ⊔ cℓ ⊔ (o ⊔ ℓ ⊔ e)
ℓ′ = c ⊔ (o ⊔ ℓ ⊔ e)
C = Category.op (ISetoids c′ ℓ′)
colimit : ∀ {J : Category o ℓ e} (F : Functor J C) → Colimit F
colimit {J} F = record { initial = record
{ ⊥ = record
{ N = Fam-setoid (Σ′ (∀ j → Carrier (F₀ j)) (λ f → ∀ {a b} (h : a J.⇒ b) → (F₀ a ≈ F₁ h ⟨$⟩ f b) (f a)))
(∀[ J.Obj ]-setoid F₀) proj₁′
; ψ = λ X → record
{ _⟨$⟩_ = λ f → proj₁′ f X
; cong = λ eq → eq X
}
; commute = λ {X} {Y} h {f} {g} f≈g → trans (F₀ X) (f≈g X) (sym (F₀ X) (proj₂′ g h))
}
; ! = λ {A} → record
{ f = record
{ _⟨$⟩_ = λ X → (λ j → Cocone.ψ A j ⟨$⟩ X) , (λ {a} {b} h → sym (F₀ a) (Cocone.commute A h (refl (Cocone.N A))))
; cong = λ i≈j a → cong (Cocone.ψ A a) i≈j
}
; commute = λ {X} x≈y → cong (Cocone.ψ A X) x≈y
}
; !-unique = λ {A} f x≈y a → sym (F₀ a) (CoconeMorphism.commute f (sym (Cocone.N A) x≈y))
} }
where
module J = Category J
open Functor F
open ISetoid
open _⟶_
| {
"alphanum_fraction": 0.5737489025,
"avg_line_length": 41.4181818182,
"ext": "agda",
"hexsha": "bfe6d6590bc2900aebd91310b1aee88d706abef3",
"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/Agda/ISetoids/Complete.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/Agda/ISetoids/Complete.agda",
"max_line_length": 126,
"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/Agda/ISetoids/Complete.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": 799,
"size": 2278
} |
module Tactic.Nat.NF where
open import Prelude
open import Tactic.Nat.Exp
open import Container.Bag
Tm : Set → Set
Tm Atom = List Atom
NF : Set → Set
NF Atom = Bag (Tm Atom)
product1 : List Nat → Nat
product1 [] = 1
product1 (x ∷ xs) = foldl (λ n x → n * x) x xs
module _ {Atom : Set} {{_ : Ord Atom}} where
infixl 6 _+nf_
infixl 7 _*nf_
_+nf_ : NF Atom → NF Atom → NF Atom
_+nf_ a b = union a b
merge : Tm Atom → Tm Atom → Tm Atom
merge x [] = x
merge [] y = y
merge (i ∷ x) (j ∷ y) =
if i <? j then i ∷ merge x (j ∷ y)
else j ∷ merge (i ∷ x) y
nf-sort : NF Atom → NF Atom
nf-sort [] = []
nf-sort (x ∷ nf) = union [ x ] (nf-sort nf)
mulTm : Nat × Tm Atom → Nat × Tm Atom → Nat × Tm Atom
mulTm (a , x) (b , y) = a * b , merge x y
_*nf_ : NF Atom → NF Atom → NF Atom
[] *nf b = []
(t ∷ a) *nf b = nf-sort (map (mulTm t) b) +nf (a *nf b)
-- Normalising expressions --
norm : Exp Atom → NF Atom
norm (var x) = [ 1 , [ x ] ]
norm (lit 0) = []
norm (lit n) = [ n , [] ]
norm (e ⟨+⟩ e₁) = norm e +nf norm e₁
norm (e ⟨*⟩ e₁) = norm e *nf norm e₁
⟦_⟧t : Nat × Tm Atom → Env Atom → Nat
⟦ k , v ⟧t ρ = k * productR (map ρ v)
⟦_⟧n : NF Atom → Env Atom → Nat
⟦ nf ⟧n ρ = sumR (map (flip ⟦_⟧t ρ) nf)
⟦_⟧ts : Nat × Tm Atom → Env Atom → Nat
⟦ 1 , v ⟧ts ρ = product1 (map ρ v)
⟦ k , v ⟧ts ρ = product1 (map ρ v) * k
⟦_⟧ns : NF Atom → Env Atom → Nat
⟦ [] ⟧ns ρ = 0
⟦ t ∷ nf ⟧ns ρ = foldl (λ n t → n + ⟦ t ⟧ts ρ) (⟦ t ⟧ts ρ) nf
cancel : NF Atom → NF Atom → NF Atom × NF Atom
cancel nf₁ [] = nf₁ , []
cancel [] nf₂ = [] , nf₂
cancel ((i , x) ∷ nf₁) ((j , y) ∷ nf₂) with compare x y
... | less _ = first (_∷_ (i , x)) (cancel nf₁ ((j , y) ∷ nf₂))
... | greater _ = second (_∷_ (j , y)) (cancel ((i , x) ∷ nf₁) nf₂)
... | equal _ with compare i j
... | less (diff k _) = second (_∷_ (suc k , y)) (cancel nf₁ nf₂)
... | greater (diff k _) = first (_∷_ (suc k , x)) (cancel nf₁ nf₂)
... | equal _ = cancel nf₁ nf₂
| {
"alphanum_fraction": 0.4932950192,
"avg_line_length": 27.4736842105,
"ext": "agda",
"hexsha": "dd5cc3743f833a340a5520493f28b988d925e056",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "lclem/agda-prelude",
"max_forks_repo_path": "src/Tactic/Nat/NF.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "lclem/agda-prelude",
"max_issues_repo_path": "src/Tactic/Nat/NF.agda",
"max_line_length": 85,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "lclem/agda-prelude",
"max_stars_repo_path": "src/Tactic/Nat/NF.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 886,
"size": 2088
} |
{-# OPTIONS --no-positivity-check #-}
module IIRDr where
import LF
import IIRD
open LF
open IIRD
-- Agda2 has restricted IIRDs so we can define Ur/Tr directly
mutual
data Ur {I : Set}{D : I -> Set1}(γ : OPr I D)(i : I) : Set where
intror : Hu γ (Ur γ) (Tr γ) i -> Ur {I}{D} γ i
Tr : {I : Set}{D : I -> Set1}(γ : OPr I D)(i : I) -> Ur γ i -> D i
Tr γ i (intror a) = Ht γ (Ur γ) (Tr γ) i a
-- Elimination rule
Rr : {I : Set}{D : I -> Set1}(γ : OPr I D)(F : (i : I) -> Ur γ i -> Set1)
(h : (i : I)(a : Hu γ (Ur γ) (Tr γ) i) -> KIH (γ i) (Ur γ) (Tr γ) F a -> F i (intror a))
(i : I)(u : Ur γ i) -> F i u
Rr γ F h i (intror a) = h i a (Kmap (γ i) (Ur γ) (Tr γ) F (Rr γ F h) a)
-- Helpers
ι★r : {I : Set}{D : I -> Set1} -> OP I D One'
ι★r = ι ★'
| {
"alphanum_fraction": 0.4967490247,
"avg_line_length": 25.6333333333,
"ext": "agda",
"hexsha": "f3dcf992da7e4f6b415a68a2ab5caa42e69a78ad",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/iird/IIRDr.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/iird/IIRDr.agda",
"max_line_length": 93,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/iird/IIRDr.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": 343,
"size": 769
} |
{-# OPTIONS --warning=error --safe --guardedness --without-K #-}
open import Setoids.Orders.Partial.Definition
open import Setoids.Setoids
open import LogicalFormulae
open import Rings.Definition
open import Numbers.Rationals.Definition
open import Functions.Definition
module Numbers.Reals.Definition where
open import Fields.CauchyCompletion.Definition ℚOrdered ℚField
open import Fields.CauchyCompletion.Setoid ℚOrdered ℚField
open import Fields.CauchyCompletion.Addition ℚOrdered ℚField
open import Fields.CauchyCompletion.Multiplication ℚOrdered ℚField
open import Fields.CauchyCompletion.Ring ℚOrdered ℚField
open import Fields.CauchyCompletion.Comparison ℚOrdered ℚField
ℝ : Set
ℝ = CauchyCompletion
_+R_ : ℝ → ℝ → ℝ
_+R_ = _+C_
_*R_ : ℝ → ℝ → ℝ
_*R_ = _*C_
ℝSetoid = cauchyCompletionSetoid
_=R_ : ℝ → ℝ → Set
a =R b = Setoid._∼_ cauchyCompletionSetoid a b
ℝRing : Ring cauchyCompletionSetoid _+R_ _*R_
ℝRing = CRing
injectionR : ℚ → ℝ
injectionR = injection
injectionRInjective : Injection injectionR
injectionRInjective = CInjection'
0R : ℝ
0R = injection 0Q
_<R_ : ℝ → ℝ → Set
_<R_ = _<C_
ℝPartialOrder : SetoidPartialOrder cauchyCompletionSetoid _<C_
ℝPartialOrder = <COrder
| {
"alphanum_fraction": 0.7908333333,
"avg_line_length": 24,
"ext": "agda",
"hexsha": "1f9b8cb6d8a48ac9d4f2bb942f522d5486605052",
"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/Reals/Definition.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/Reals/Definition.agda",
"max_line_length": 66,
"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/Reals/Definition.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": 382,
"size": 1200
} |
-- Andreas, 2016-07-28, issue #779
data D : Set where c : D
record R : Set1 where
bla : D → D
bla c = c
field F : Set
-- Current:
-- Not a valid let-definition
-- Expected:
-- Success, or error outlawing pattern matching definition before last field.
| {
"alphanum_fraction": 0.662835249,
"avg_line_length": 17.4,
"ext": "agda",
"hexsha": "4f67203ccd97d3f2eb19ed770bf229ef1c628f9e",
"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/Issue779pattern.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/Issue779pattern.agda",
"max_line_length": 77,
"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/Issue779pattern.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 77,
"size": 261
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- this module characterizes a category of all products indexed by I.
-- this notion formalizes a category with all products up to certain cardinal.
module Categories.Object.Product.Indexed {o ℓ e} (C : Category o ℓ e) where
open import Level
open import Categories.Morphism.Reasoning C
open Category C
open Equiv
open HomReasoning
record IndexedProductOf {i} {I : Set i} (P : I → Obj) : Set (i ⊔ o ⊔ e ⊔ ℓ) where
field
-- the product
X : Obj
π : ∀ i → X ⇒ P i
⟨_⟩ : ∀ {Y} → (∀ i → Y ⇒ P i) → Y ⇒ X
commute : ∀ {Y} (f : ∀ i → Y ⇒ P i) → ∀ i → π i ∘ ⟨ f ⟩ ≈ f i
unique : ∀ {Y} (h : Y ⇒ X) (f : ∀ i → Y ⇒ P i) → (∀ i → π i ∘ h ≈ f i) → ⟨ f ⟩ ≈ h
η : ∀ {Y} (h : Y ⇒ X) → ⟨ (λ i → π i ∘ h) ⟩ ≈ h
η h = unique _ _ λ _ → refl
⟨⟩∘ : ∀ {Y Z} (f : ∀ i → Y ⇒ P i) (g : Z ⇒ Y) → ⟨ f ⟩ ∘ g ≈ ⟨ (λ i → f i ∘ g) ⟩
⟨⟩∘ f g = ⟺ (unique _ _ λ i → pullˡ (commute _ _))
⟨⟩-cong : ∀ {Y} (f g : ∀ i → Y ⇒ P i) → (eq : ∀ i → f i ≈ g i) → ⟨ f ⟩ ≈ ⟨ g ⟩
⟨⟩-cong f g eq = unique _ _ λ i → trans (commute _ _) (⟺ (eq i))
unique′ : ∀ {Y} (h h′ : Y ⇒ X) → (∀ i → π i ∘ h′ ≈ π i ∘ h) → h′ ≈ h
unique′ h h′ f = trans (⟺ (unique _ _ f)) (η _)
record IndexedProduct {i} (I : Set i) : Set (i ⊔ o ⊔ e ⊔ ℓ) where
field
P : I → Obj
productOf : IndexedProductOf P
open IndexedProductOf productOf public
AllProducts : ∀ i → Set (o ⊔ ℓ ⊔ e ⊔ suc i)
AllProducts i = (I : Set i) → IndexedProduct I
AllProductsOf : ∀ i → Set (o ⊔ ℓ ⊔ e ⊔ suc i)
AllProductsOf i = ∀ {I : Set i} (P : I → Obj) → IndexedProductOf P
| {
"alphanum_fraction": 0.5120444719,
"avg_line_length": 30.5471698113,
"ext": "agda",
"hexsha": "e90dfe2cca5cb899a92678ba6139ba612c8d755a",
"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/Object/Product/Indexed.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/Object/Product/Indexed.agda",
"max_line_length": 87,
"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/Object/Product/Indexed.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": 672,
"size": 1619
} |
{-# OPTIONS --without-K #-}
open import level
open import algebra.group.core
open import algebra.monoid.mset
open import algebra.monoid.morphism
open import function.extensionality
open import function.isomorphism
open import equality.calculus
open import equality.core
open import sum
open import hott.level
open import hott.equivalence
open import hott.univalence
module algebra.group.gset {i}(G : Set i) ⦃ gG : IsGroup G ⦄ where
open IsGroup ⦃ ... ⦄
IsGSet : ∀ {j}(X : Set j) → Set (i ⊔ j)
IsGSet X = IsMSet G X
GSet : ∀ j → Set (i ⊔ lsuc j)
GSet j = Σ (Set j) IsGSet
GSet₀ : ∀ j → Set (i ⊔ lsuc j)
GSet₀ j = Σ (Type j 2) λ { (X , hX) → G → X → X }
GSet₁ : ∀ {j} → GSet₀ j → Set (i ⊔ j)
GSet₁ ((X , _) , _◂_) =
((g₁ g₂ : G)(x : X) → (g₁ * g₂) ◂ x ≡ g₁ ◂ (g₂ ◂ x))
× ((x : X) → e ◂ x ≡ x)
gset₁-level : ∀ {j}(X : GSet₀ j)
→ h 1 (GSet₁ X)
gset₁-level ((X , hX) , act) = ×-level
(Π-level λ g₁ → Π-level λ g₂ → Π-level λ x → hX _ _)
(Π-level λ x → hX _ _)
gset-struct-iso : ∀ {j} → GSet j ≅ Σ (GSet₀ j) GSet₁
gset-struct-iso = record
{ to = λ { (X , xG) → (((X , IsMSet.mset-level xG) , IsMSet._◂_ xG) ,
(IsMSet.◂-hom xG , IsMSet.◂-id xG)) }
; from = λ { (((X , hX) , _◂_) , (◂-hom , ◂-id))
→ (X , mk-is-mset _◂_ ◂-hom ◂-id hX) }
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
open IsMSet ⦃ ... ⦄
module _ {j k}
{X : Set j} ⦃ xG : IsGSet X ⦄
{Y : Set k} ⦃ yG : IsGSet Y ⦄ where
IsGSetMorphism : (X → Y) → Set (i ⊔ j ⊔ k)
IsGSetMorphism = IsMSetMorphism G
module _ {j k}
(X : Set j) ⦃ xG : IsGSet X ⦄
(Y : Set k) ⦃ yG : IsGSet Y ⦄ where
GSetMorphism : Set (i ⊔ j ⊔ k)
GSetMorphism = Σ (X → Y) IsGSetMorphism
gsetmorphism-equality : h 2 Y → {f g : X → Y}
(f-mor : IsGSetMorphism f) (g-mor : IsGSetMorphism g)
→ f ≡ g
→ _≡_ {A = GSetMorphism}
(f , f-mor)
(g , g-mor)
gsetmorphism-equality hY {f} f-mor g-mor refl =
ap (λ m → (f , m)) (h1⇒prop (is-mset-morphism-level G hY f) _ _)
module _ {j} (X : Set j) ⦃ xG : IsGSet X ⦄
(Y : Set j) ⦃ yG : IsGSet Y ⦄ where
𝑋 𝑌 : GSet j
𝑋 = (X , xG)
𝑌 = (Y , yG)
X₀ Y₀ : GSet₀ j
X₀ = ((X , IsMSet.mset-level xG) , _◂_)
Y₀ = ((Y , IsMSet.mset-level yG) , _◂_)
GSet-univalence : (𝑋 ≡ 𝑌)
≅ (Σ (GSetMorphism X Y) λ { (f , _) → weak-equiv f })
GSet-univalence = begin
(𝑋 ≡ 𝑌)
≅⟨ iso≡ gset-struct-iso ·≅ sym≅ (subtype-equality gset₁-level) ⟩
(X₀ ≡ Y₀)
≅⟨ sym≅ Σ-split-iso ⟩
( Σ (proj₁ X₀ ≡ proj₁ Y₀) λ p →
subst (λ { (X , _) → G → X → X }) p (proj₂ X₀) ≡ proj₂ Y₀ )
≅⟨ ( Σ-ap-iso (sym≅ (subtype-equality λ X → hn-h1 2 X)) λ p
→ trans≡-iso (sym (subst-naturality (λ X → G → X → X)
proj₁ p (proj₂ X₀)))) ⟩
( Σ (X ≡ Y) λ p → subst (λ X → G → X → X) p (proj₂ X₀) ≡ proj₂ Y₀ )
≅⟨ Σ-ap-iso refl≅ (λ p → sym≅ (lem₁ p _ _)) ⟩
( Σ (X ≡ Y) λ p → ∀ g w → coerce p (proj₂ X₀ g w)
≡ proj₂ Y₀ g (coerce p w) )
≅⟨ ( Σ-ap-iso uni-iso λ p → refl≅ ) ⟩
( Σ (X ≈ Y) λ f → ∀ g w → apply≈ f (proj₂ X₀ g w)
≡ proj₂ Y₀ g (apply≈ f w))
≅⟨ record
{ to = λ { ((f , we), mor) → ((f , mor) , we) }
; from = λ { ((f , mor) , we) → ((f , we) , mor) }
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl } ⟩
(Σ (GSetMorphism X Y) λ { (f , _) → weak-equiv f })
∎
where
open ≅-Reasoning
lem₁ : {U V : Set j}(p : U ≡ V)
→ (act : G → U → U)
→ (act' : G → V → V)
→ (∀ g u → coerce p (act g u) ≡ act' g (coerce p u))
≅ (subst (λ { X → G → X → X }) p act ≡ act')
lem₁ refl act act' = (Π-ap-iso refl≅ λ g → strong-funext-iso)
·≅ strong-funext-iso
instance
GisGSet : IsGSet G
GisGSet = record
{ _◂_ = _*_
; ◂-hom = assoc
; ◂-id = lunit
; mset-level = is-set }
module _ {j} {X : Set j} (hX : h 2 X) ⦃ xG : IsGSet X ⦄ where
GSet-repr : (ϕ : G → X) → IsGSetMorphism ϕ
→ (g : G) → ϕ g ≡ g ◂ ϕ e
GSet-repr ϕ ϕ-mor g = ap ϕ (sym (runit g)) · ϕ-mor g e
GSet-repr-iso : GSetMorphism G X ≅ X
GSet-repr-iso = iso f g α β
where
f : GSetMorphism G X → X
f (ϕ , _) = ϕ e
g : X → GSetMorphism G X
g x = (ϕ , ϕ-mor)
where
ϕ : G → X
ϕ g = g ◂ x
ϕ-mor : IsGSetMorphism ϕ
ϕ-mor g₁ g₂ = ◂-hom g₁ g₂ x
α : (ϕ : GSetMorphism G X) → g (f ϕ) ≡ ϕ
α (ϕ , ϕ-mor) = gsetmorphism-equality G X hX _ _
(funext λ g → sym (GSet-repr ϕ ϕ-mor g))
β : (x : X) → f (g x) ≡ x
β x = (IsMSet.◂-id xG) x
| {
"alphanum_fraction": 0.4562691131,
"avg_line_length": 32.4834437086,
"ext": "agda",
"hexsha": "91bd45b290524f970ee63d367292ad9ae2770af3",
"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/algebra/group/gset.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/algebra/group/gset.agda",
"max_line_length": 75,
"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/algebra/group/gset.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": 2108,
"size": 4905
} |
{-
Definition of finite sets
There are may different formulations of finite sets in constructive mathematics,
and we will use Bishop finiteness as is usually called in the literature.
-}
{-# OPTIONS --safe #-}
module Cubical.Data.FinSet.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Equiv renaming (_∙ₑ_ to _⋆_)
open import Cubical.Foundations.Univalence
open import Cubical.HITs.PropositionalTruncation as Prop
open import Cubical.Data.Nat
open import Cubical.Data.Fin renaming (Fin to Finℕ) hiding (isSetFin)
open import Cubical.Data.SumFin
open import Cubical.Data.Sigma
private
variable
ℓ ℓ' ℓ'' : Level
A : Type ℓ
-- definition of (Bishop) finite sets
-- this definition makes cardinality computation more efficient
isFinSet : Type ℓ → Type ℓ
isFinSet A = Σ[ n ∈ ℕ ] ∥ A ≃ Fin n ∥
isFinOrd : Type ℓ → Type ℓ
isFinOrd A = Σ[ n ∈ ℕ ] A ≃ Fin n
isFinOrd→isFinSet : isFinOrd A → isFinSet A
isFinOrd→isFinSet (_ , p) = _ , ∣ p ∣
-- finite sets are sets
isFinSet→isSet : isFinSet A → isSet A
isFinSet→isSet p = rec isPropIsSet (λ e → isOfHLevelRespectEquiv 2 (invEquiv e) isSetFin) (p .snd)
-- isFinSet is proposition
isPropIsFinSet : isProp (isFinSet A)
isPropIsFinSet p q = Σ≡PropEquiv (λ _ → isPropPropTrunc) .fst (
Prop.elim2
(λ _ _ → isSetℕ _ _)
(λ p q → Fin-inj _ _ (ua (invEquiv (SumFin≃Fin _) ⋆ (invEquiv p) ⋆ q ⋆ SumFin≃Fin _)))
(p .snd) (q .snd))
-- isFinOrd is Set
-- ordering can be seen as extra structures over finite sets
isSetIsFinOrd : isSet (isFinOrd A)
isSetIsFinOrd = isOfHLevelΣ 2 isSetℕ (λ _ → isOfHLevel⁺≃ᵣ 1 isSetFin)
-- alternative definition of isFinSet
isFinSet' : Type ℓ → Type ℓ
isFinSet' A = ∥ Σ[ n ∈ ℕ ] A ≃ Fin n ∥
isFinSet→isFinSet' : isFinSet A → isFinSet' A
isFinSet→isFinSet' (_ , p) = Prop.rec isPropPropTrunc (λ p → ∣ _ , p ∣) p
isFinSet'→isFinSet : isFinSet' A → isFinSet A
isFinSet'→isFinSet = Prop.rec isPropIsFinSet (λ (n , p) → _ , ∣ p ∣ )
isFinSet≡isFinSet' : isFinSet A ≡ isFinSet' A
isFinSet≡isFinSet' = hPropExt isPropIsFinSet isPropPropTrunc isFinSet→isFinSet' isFinSet'→isFinSet
-- the type of finite sets/propositions
FinSet : (ℓ : Level) → Type (ℓ-suc ℓ)
FinSet ℓ = TypeWithStr _ isFinSet
FinProp : (ℓ : Level) → Type (ℓ-suc ℓ)
FinProp ℓ = Σ[ P ∈ FinSet ℓ ] isProp (P .fst)
-- cardinality of finite sets
card : FinSet ℓ → ℕ
card X = X .snd .fst
-- equality between finite sets/propositions
FinSet≡ : (X Y : FinSet ℓ) → (X .fst ≡ Y .fst) ≃ (X ≡ Y)
FinSet≡ _ _ = Σ≡PropEquiv (λ _ → isPropIsFinSet)
FinProp≡ : (X Y : FinProp ℓ) → (X .fst .fst ≡ Y .fst .fst) ≃ (X ≡ Y)
FinProp≡ X Y = compEquiv (FinSet≡ (X .fst) (Y .fst)) (Σ≡PropEquiv (λ _ → isPropIsProp))
-- hlevels of FinSet and FinProp
isGroupoidFinSet : isGroupoid (FinSet ℓ)
isGroupoidFinSet X Y =
isOfHLevelRespectEquiv 2 (FinSet≡ X Y)
(isOfHLevel≡ 2 (isFinSet→isSet (X .snd)) (isFinSet→isSet (Y .snd)))
isSetFinProp : isSet (FinProp ℓ)
isSetFinProp X Y =
isOfHLevelRespectEquiv 1 (FinProp≡ X Y) (isOfHLevel≡ 1 (X .snd) (Y .snd))
| {
"alphanum_fraction": 0.6994868505,
"avg_line_length": 28.8703703704,
"ext": "agda",
"hexsha": "40dce365801e2e49423b345687176cc5516096d1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Data/FinSet/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Data/FinSet/Base.agda",
"max_line_length": 98,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Data/FinSet/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1190,
"size": 3118
} |
module Luau.RuntimeError where
open import Agda.Builtin.Equality using (_≡_)
open import Luau.Heap using (Heap; lookup)
open import FFI.Data.Maybe using (just; nothing)
open import Luau.Syntax using (Block; Expr; nil; var; addr; function⟨_⟩_end; block_is_end; _$_; local_←_; function_⟨_⟩_end; return; done; _∙_)
data RuntimeErrorᴮ (H : Heap) : Block → Set
data RuntimeErrorᴱ (H : Heap) : Expr → Set
data RuntimeErrorᴱ H where
NilIsNotAFunction : ∀ {M} → RuntimeErrorᴱ H (nil $ M)
UnboundVariable : ∀ x → RuntimeErrorᴱ H (var x)
SEGV : ∀ a → (lookup H a ≡ nothing) → RuntimeErrorᴱ H (addr a)
app : ∀ {M N} → RuntimeErrorᴱ H M → RuntimeErrorᴱ H (M $ N)
block : ∀ b {B} → RuntimeErrorᴮ H B → RuntimeErrorᴱ H (block b is B end)
data RuntimeErrorᴮ H where
local : ∀ x {M B} → RuntimeErrorᴱ H M → RuntimeErrorᴮ H (local x ← M ∙ B)
return : ∀ {M B} → RuntimeErrorᴱ H M → RuntimeErrorᴮ H (return M ∙ B)
| {
"alphanum_fraction": 0.6849015317,
"avg_line_length": 41.5454545455,
"ext": "agda",
"hexsha": "86e7cf2114d3a1c25c4ae4f1ef84a5ef14a53af2",
"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/Luau/RuntimeError.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/Luau/RuntimeError.agda",
"max_line_length": 142,
"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/Luau/RuntimeError.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": 321,
"size": 914
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Addition
open import Numbers.Naturals.Order
open import Numbers.Naturals.Multiplication
open import Semirings.Definition
open import Orders.Total.Definition
module Numbers.Naturals.Naturals where
record subtractionNResult (a b : ℕ) .(p : a ≤N b) : Set where
field
result : ℕ
pr : a +N result ≡ b
subtractionNWellDefined : {a b : ℕ} → {p1 p2 : a ≤N b} → (s : subtractionNResult a b p1) → (t : subtractionNResult a b p2) → (subtractionNResult.result s ≡ subtractionNResult.result t)
subtractionNWellDefined {a} {b} {inl x} {pr2} record { result = result1 ; pr = pr1 } record { result = result ; pr = pr } = canSubtractFromEqualityLeft {a} (transitivity pr1 (equalityCommutative pr))
subtractionNWellDefined {a} {.a} {inr refl} {pr2} record { result = result1 ; pr = pr1 } record { result = result2 ; pr = pr } = transitivity g' (equalityCommutative g)
where
g : result2 ≡ 0
g = canSubtractFromEqualityLeft {a} {_} {0} (transitivity pr (equalityCommutative (addZeroRight a)))
g' : result1 ≡ 0
g' = canSubtractFromEqualityLeft {a} {_} {0} (transitivity pr1 (equalityCommutative (addZeroRight a)))
-N : {a : ℕ} → {b : ℕ} → (pr : a ≤N b) → subtractionNResult a b pr
-N {zero} {b} prAB = record { result = b ; pr = refl }
-N {succ a} {zero} (inl ())
-N {succ a} {zero} (inr ())
-N {succ a} {succ b} (inl x) with -N {a} {b} (inl (canRemoveSuccFrom<N x))
-N {succ a} {succ b} (inl x) | record { result = result ; pr = pr } = record { result = result ; pr = applyEquality succ pr }
-N {succ a} {succ b} (inr pr) = record { result = 0 ; pr = transitivity (applyEquality succ (addZeroRight a)) pr }
addOneToWeakInequality : {a b : ℕ} → (a ≤N b) → (succ a ≤N succ b)
addOneToWeakInequality {a} {b} (inl ineq) = inl (succPreservesInequality ineq)
addOneToWeakInequality {a} {.a} (inr refl) = inr refl
bumpUpSubtraction : {a b : ℕ} → (p1 : a ≤N b) → (s : subtractionNResult a b p1) → Sg (subtractionNResult (succ a) (succ b) (addOneToWeakInequality p1)) (λ n → subtractionNResult.result n ≡ subtractionNResult.result s)
bumpUpSubtraction {a} {b} a<=b record { result = result ; pr = pr } = record { result = result ; pr = applyEquality succ pr } , refl
addMinus : {a : ℕ} → {b : ℕ} → (pr : a ≤N b) → subtractionNResult.result (-N {a} {b} pr) +N a ≡ b
addMinus {zero} {zero} p = refl
addMinus {zero} {succ b} pr = applyEquality succ (addZeroRight b)
addMinus {succ a} {zero} (inl (le x ()))
addMinus {succ a} {zero} (inr ())
addMinus {succ a} {succ b} (inl x) with (-N {succ a} {succ b} (inl x))
addMinus {succ a} {succ b} (inl x) | record { result = result ; pr = pr } = transitivity (transitivity (applyEquality (_+N succ a) (transitivity (subtractionNWellDefined {p1 = inl (canRemoveSuccFrom<N x)} {p2 = inl (canRemoveSuccFrom<N x)} (record { result = subtractionNResult.result (-N (inl (canRemoveSuccFrom<N x))) ; pr = transitivity (additionNIsCommutative a _) (addMinus (inl (canRemoveSuccFrom<N x)))}) previous) (equalityCommutative t))) (additionNIsCommutative result (succ a))) pr
where
pr'' : (a <N b) || (a ≡ b)
pr'' = (inl (le (_<N_.x x) (transitivity (equalityCommutative (succExtracts (_<N_.x x) a)) (succInjective (_<N_.proof x)))))
previous : subtractionNResult a b pr''
previous = -N pr''
next : Sg (subtractionNResult (succ a) (succ b) (addOneToWeakInequality pr'')) λ n → subtractionNResult.result n ≡ subtractionNResult.result previous
next = bumpUpSubtraction pr'' previous
t : result ≡ subtractionNResult.result (underlying next)
t = subtractionNWellDefined {succ a} {succ b} {inl x} {addOneToWeakInequality pr''} (record { result = result ; pr = pr }) (underlying next)
addMinus {succ a} {succ .a} (inr refl) = refl
addMinus' : {a b : ℕ} → (pr : a ≤N b) → a +N subtractionNResult.result (-N {a} {b} pr) ≡ b
addMinus' {a} {b} pr rewrite additionNIsCommutative a (subtractionNResult.result (-N {a} {b} pr)) = addMinus {a} {b} pr
additionPreservesInequality : {a b : ℕ} → (c : ℕ) → a <N b → a +N c <N b +N c
additionPreservesInequality {a} {b} zero prAB rewrite additionNIsCommutative a 0 | additionNIsCommutative b 0 = prAB
additionPreservesInequality {a} {b} (succ c) (le x proof) = le x (transitivity (equalityCommutative (additionNIsAssociative (succ x) a (succ c))) (applyEquality (_+N succ c) proof))
additionPreservesInequalityOnLeft : {a b : ℕ} → (c : ℕ) → a <N b → c +N a <N c +N b
additionPreservesInequalityOnLeft {a} {b} c prAB = identityOfIndiscernablesRight (λ a b → a <N b) (identityOfIndiscernablesLeft (λ a b → a <N b) (additionPreservesInequality {a} {b} c prAB) (additionNIsCommutative a c)) (additionNIsCommutative b c)
multiplyIncreases : (a : ℕ) → (b : ℕ) → succ zero <N a → zero <N b → b <N a *N b
multiplyIncreases zero b (le x ()) prB
multiplyIncreases (succ zero) b (le zero ()) prb
multiplyIncreases (succ zero) b (le (succ x) ()) prb
multiplyIncreases (succ (succ a)) (succ b) prA prb = le (b +N a *N succ b) (applyEquality succ (transitivity (Semiring.commutative ℕSemiring _ (succ b)) (transitivity (applyEquality succ (Semiring.commutative ℕSemiring b _)) (Semiring.commutative ℕSemiring _ b))))
canTimesOneOnLeft : {a b : ℕ} → (a <N b) → (a *N (succ zero)) <N b
canTimesOneOnLeft {a} {b} prAB = identityOfIndiscernablesLeft _<N_ prAB (equalityCommutative (productWithOneRight a))
canTimesOneOnRight : {a b : ℕ} → (a <N b) → a <N (b *N (succ zero))
canTimesOneOnRight {a} {b} prAB = identityOfIndiscernablesRight _<N_ prAB (equalityCommutative (productWithOneRight b))
canSwapAddOnLeftOfInequality : {a b c : ℕ} → (a +N b <N c) → (b +N a <N c)
canSwapAddOnLeftOfInequality {a} {b} {c} pr = identityOfIndiscernablesLeft _<N_ pr (additionNIsCommutative a b)
canSwapAddOnRightOfInequality : {a b c : ℕ} → (a <N b +N c) → (a <N c +N b)
canSwapAddOnRightOfInequality {a} {b} {c} pr = identityOfIndiscernablesRight _<N_ pr (additionNIsCommutative b c)
bumpDownOnRight : (a c : ℕ) → c *N succ a ≡ c *N a +N c
bumpDownOnRight a c = transitivity (multiplicationNIsCommutative c (succ a)) (transitivity refl (transitivity (additionNIsCommutative c (a *N c)) ((addingPreservesEqualityRight c (multiplicationNIsCommutative a c) ))))
succIsNonzero : {a : ℕ} → (succ a ≡ zero) → False
succIsNonzero {a} ()
lessImpliesNotEqual : {a b : ℕ} → (a <N b) → a ≡ b → False
lessImpliesNotEqual {a} {.a} prAB refl = TotalOrder.irreflexive ℕTotalOrder prAB
-NIsDecreasing : {a b : ℕ} → (prAB : succ a <N b) → subtractionNResult.result (-N (inl prAB)) <N b
-NIsDecreasing {a} {b} prAB with (-N (inl prAB))
-NIsDecreasing {a} {b} (le x proof) | record { result = result ; pr = pr } = record { x = a ; proof = pr }
sumZeroImpliesSummandsZero : {a b : ℕ} → (a +N b ≡ zero) → ((a ≡ zero) && (b ≡ zero))
sumZeroImpliesSummandsZero {zero} {zero} pr = record { fst = refl ; snd = refl }
sumZeroImpliesSummandsZero {zero} {(succ b)} pr = record { fst = refl ; snd = pr }
sumZeroImpliesSummandsZero {(succ a)} {zero} ()
sumZeroImpliesSummandsZero {(succ a)} {(succ b)} ()
productWithNonzeroZero : (a b : ℕ) → (a *N succ b ≡ zero) → a ≡ zero
productWithNonzeroZero zero b pr = refl
productWithNonzeroZero (succ a) b ()
productOneImpliesOperandsOne : {a b : ℕ} → (a *N b ≡ 1) → (a ≡ 1) && (b ≡ 1)
productOneImpliesOperandsOne {zero} {b} ()
productOneImpliesOperandsOne {succ a} {zero} pr = exFalso absurd''
where
absurd : zero *N (succ a) ≡ 1
absurd' : 0 ≡ 1
absurd'' : False
absurd'' = succIsNonzero (equalityCommutative absurd')
absurd = identityOfIndiscernablesLeft _≡_ pr (productZeroIsZeroRight a)
absurd' = absurd
productOneImpliesOperandsOne {succ a} {succ b} pr = record { fst = r' ; snd = (applyEquality succ (_&&_.fst q)) }
where
p : b +N a *N succ b ≡ zero
p = succInjective pr
q : (b ≡ zero) && (a *N succ b ≡ zero)
q = sumZeroImpliesSummandsZero p
r : a ≡ zero
r = productWithNonzeroZero a b (_&&_.snd q)
r' : succ a ≡ 1
r' = applyEquality succ r
oneTimesPlusZero : (a : ℕ) → a ≡ a *N succ zero +N zero
oneTimesPlusZero a = identityOfIndiscernablesRight _≡_ (equalityCommutative (productWithOneRight a)) (equalityCommutative (addZeroRight (a *N succ zero)))
equivalentSubtraction' : (a b c d : ℕ) → (a<c : a <N c) → (d<b : d <N b) → (subtractionNResult.result (-N {a} {c} (inl a<c))) ≡ (subtractionNResult.result (-N {d} {b} (inl d<b))) → a +N b ≡ c +N d
equivalentSubtraction' a b c d prac prdb eq with -N (inl prac)
equivalentSubtraction' a b c d prac prdb eq | record { result = result ; pr = pr } with -N (inl prdb)
equivalentSubtraction' a b c d prac prdb refl | record { result = .result ; pr = pr1 } | record { result = result ; pr = pr } rewrite (equalityCommutative pr) = go
where
go : a +N (d +N result) ≡ c +N d
go rewrite (equalityCommutative pr1) = t
where
t : a +N (d +N result) ≡ (a +N result) +N d
t rewrite (additionNIsAssociative a result d) = applyEquality (λ n → a +N n) (additionNIsCommutative d result)
lessThanMeansPositiveSubtr : {a b : ℕ} → (a<b : a <N b) → (subtractionNResult.result (-N (inl a<b)) ≡ 0) → False
lessThanMeansPositiveSubtr {a} {b} a<b pr with -N (inl a<b)
lessThanMeansPositiveSubtr {a} {b} a<b pr | record { result = result ; pr = sub } rewrite pr | addZeroRight a = lessImpliesNotEqual a<b sub
moveOneSubtraction : {a b c : ℕ} → {a<=b : a ≤N b} → (subtractionNResult.result (-N {a} {b} a<=b)) ≡ c → b ≡ a +N c
moveOneSubtraction {a} {b} {zero} {inl a<b} pr rewrite addZeroRight a = exFalso (lessThanMeansPositiveSubtr {a} {b} a<b pr)
moveOneSubtraction {a} {b} {succ c} {inl a<b} pr with -N (inl a<b)
moveOneSubtraction {a} {b} {succ c} {inl a<b} pr | record { result = result ; pr = sub } rewrite pr | sub = refl
moveOneSubtraction {a} {.a} {zero} {inr refl} pr = equalityCommutative (addZeroRight a)
moveOneSubtraction {a} {.a} {succ c} {inr refl} pr = identityOfIndiscernablesRight _≡_ (equalityCommutative (addZeroRight a)) (applyEquality (λ t → a +N t) pr')
where
selfSub : (r : ℕ) → subtractionNResult.result (-N {r} {r} (inr refl)) ≡ zero
selfSub zero = refl
selfSub (succ r) = refl
pr' : 0 ≡ succ c
pr' = transitivity (equalityCommutative (selfSub a)) pr
moveOneSubtraction' : {a b c : ℕ} → {a<=b : a ≤N b} → (b ≡ a +N c) → subtractionNResult.result (-N {a} {b} a<=b) ≡ c
moveOneSubtraction' {a} {b} {c} {inl x} pr with -N (inl x)
moveOneSubtraction' {a} {b} {c} {inl x} pr | record { result = result ; pr = pr1 } rewrite pr = canSubtractFromEqualityLeft pr1
moveOneSubtraction' {a} {b} {c} {inr x} pr with -N (inr x)
moveOneSubtraction' {a} {b} {c} {inr x} pr | record { result = result ; pr = pr1 } rewrite pr = canSubtractFromEqualityLeft pr1
equivalentSubtraction : (a b c d : ℕ) → (a<c : a <N c) → (d<b : d <N b) → a +N b ≡ c +N d → (subtractionNResult.result (-N {a} {c} (inl a<c))) ≡ (subtractionNResult.result (-N {d} {b} (inl d<b)))
equivalentSubtraction zero b c d prac (le x proof) eq with (-N (inl (le x proof)))
equivalentSubtraction zero b c d prac (le x proof) eq | record { result = result ; pr = pr } = equalityCommutative p''
where
p : d +N result ≡ c +N d
p = transitivity pr eq
p' : d +N result ≡ d +N c
p' = transitivity p (additionNIsCommutative c d)
p'' : result ≡ c
p'' = canSubtractFromEqualityLeft {d} {result} {c} p'
equivalentSubtraction (succ a) b zero d (le x ()) prdb eq
equivalentSubtraction (succ a) b (succ c) d prac prdb eq with (-N (inl (canRemoveSuccFrom<N prac)))
equivalentSubtraction (succ a) b (succ c) d prac prdb eq | record { result = c-a ; pr = prc-a } with -N (inl prdb)
equivalentSubtraction (succ a) b (succ c) d prac prdb eq | record { result = c-a ; pr = prc-a } | record { result = result ; pr = pr } rewrite equalityCommutative prc-a | equalityCommutative pr | equalityCommutative (additionNIsAssociative a d result) | additionNIsCommutative (a +N c-a) d | equalityCommutative (additionNIsAssociative d a c-a) | additionNIsCommutative a d = equalityCommutative (canSubtractFromEqualityLeft eq)
leLemma : (b c : ℕ) → (b ≤N c) ≡ (b +N zero ≤N c +N zero)
leLemma b c rewrite addZeroRight c = q
where
q : (b ≤N c) ≡ (b +N zero ≤N c)
q rewrite addZeroRight b = refl
lessCast : {a b c : ℕ} → (pr : a ≤N b) → (eq : a ≡ c) → c ≤N b
lessCast {a} {b} pr eq rewrite eq = pr
lessCast' : {a b c : ℕ} → (pr : a ≤N b) → (eq : b ≡ c) → a ≤N c
lessCast' {a} {b} pr eq rewrite eq = pr
subtractionCast : {a b c : ℕ} → {pr : a ≤N b} → (eq : a ≡ c) → (p : subtractionNResult a b pr) → Sg (subtractionNResult c b (lessCast pr eq)) (λ res → subtractionNResult.result p ≡ subtractionNResult.result res)
subtractionCast {a} {b} {c} {a<b} eq subt rewrite eq = (subt , refl)
subtractionCast' : {a b c : ℕ} → {pr : a ≤N b} → (eq : b ≡ c) → (p : subtractionNResult a b pr) → Sg (subtractionNResult a c (lessCast' pr eq)) (λ res → subtractionNResult.result p ≡ subtractionNResult.result res)
subtractionCast' {a} {b} {c} {a<b} eq subt rewrite eq = (subt , refl)
addToRightWeakInequality : (a : ℕ) → {b c : ℕ} → (pr : b ≤N c) → (b ≤N c +N a)
addToRightWeakInequality zero {b} {c} (inl x) rewrite (addZeroRight c) = inl x
addToRightWeakInequality (succ a) {b} {c} (inl x) = inl (TotalOrder.<Transitive ℕTotalOrder x (addingIncreases c a))
addToRightWeakInequality zero {b} {.b} (inr refl) = inr (equalityCommutative (addZeroRight b))
addToRightWeakInequality (succ a) {b} {.b} (inr refl) = inl (addingIncreases b a)
addAssocLemma : (a b c : ℕ) → (a +N b) +N c ≡ (a +N c) +N b
addAssocLemma a b c rewrite (additionNIsAssociative a b c) = g
where
g : a +N (b +N c) ≡ (a +N c) +N b
g rewrite (additionNIsAssociative a c b) = applyEquality (λ t → a +N t) (additionNIsCommutative b c)
addIntoSubtraction : (a : ℕ) → {b c : ℕ} → (pr : b ≤N c) → a +N (subtractionNResult.result (-N {b} {c} pr)) ≡ subtractionNResult.result (-N {b} {c +N a} (addToRightWeakInequality a pr))
addIntoSubtraction a {b} {c} pr with (-N {b} {c} pr)
addIntoSubtraction a {b} {c} pr | record { result = c-b ; pr = prc-b } with (-N {b} {c +N a} (addToRightWeakInequality a pr))
addIntoSubtraction a {b} {c} pr | record { result = c-b ; pr = prc-b } | record { result = c+a-b ; pr = prcab } = equalityCommutative g'''
where
g : (b +N c+a-b) +N c-b ≡ c +N (a +N c-b)
g rewrite (equalityCommutative (additionNIsAssociative c a c-b)) = applyEquality (λ t → t +N c-b) prcab
g' : (b +N c-b) +N c+a-b ≡ c +N (a +N c-b)
g' = identityOfIndiscernablesLeft _≡_ g (addAssocLemma b c+a-b c-b)
g'' : c +N c+a-b ≡ c +N (a +N c-b)
g'' = identityOfIndiscernablesLeft _≡_ g' (applyEquality (λ i → i +N c+a-b) prc-b)
g''' : c+a-b ≡ a +N c-b
g''' = canSubtractFromEqualityLeft {c} {c+a-b} {a +N c-b} g''
addStrongInequalities : {a b c d : ℕ} → (a<b : a <N b) → (c<d : c <N d) → (a +N c <N b +N d)
addStrongInequalities {zero} {zero} {c} {d} prab prcd = prcd
addStrongInequalities {zero} {succ b} {c} {d} prab prcd rewrite (additionNIsCommutative b d) = TotalOrder.<Transitive ℕTotalOrder prcd (cannotAddAndEnlarge d b)
addStrongInequalities {succ a} {zero} {c} {d} (le x ()) prcd
addStrongInequalities {succ a} {succ b} {c} {d} prab prcd = succPreservesInequality (addStrongInequalities (canRemoveSuccFrom<N prab) prcd)
addWeakInequalities : {a b c d : ℕ} → (a<=b : a ≤N b) → (c<=d : c ≤N d) → (a +N c) ≤N (b +N d)
addWeakInequalities {a} {b} {c} {d} (inl x) (inl y) = inl (addStrongInequalities x y)
addWeakInequalities {a} {b} {c} {.c} (inl x) (inr refl) = inl (additionPreservesInequality c x)
addWeakInequalities {a} {.a} {c} {d} (inr refl) (inl x) = inl (additionPreservesInequalityOnLeft a x)
addWeakInequalities {a} {.a} {c} {.c} (inr refl) (inr refl) = inr refl
addSubIntoSub : {a b c d : ℕ} → (a<b : a ≤N b) → (c<d : c ≤N d) → (subtractionNResult.result (-N {a} {b} a<b)) +N (subtractionNResult.result (-N {c} {d} c<d)) ≡ subtractionNResult.result (-N {a +N c} {b +N d} (addWeakInequalities a<b c<d))
addSubIntoSub {a}{b}{c}{d} a<b c<d with (-N {a} {b} a<b)
addSubIntoSub {a} {b} {c} {d} a<b c<d | record { result = b-a ; pr = prb-a } with (-N {c} {d} c<d)
addSubIntoSub {a} {b} {c} {d} a<b c<d | record { result = b-a ; pr = prb-a } | record { result = d-c ; pr = prd-c } with (-N {a +N c} {b +N d} (addWeakInequalities a<b c<d))
addSubIntoSub {a} {b} {c} {d} a<b c<d | record { result = b-a ; pr = prb-a } | record { result = d-c ; pr = prd-c } | record { result = b+d-a-c ; pr = pr } = equalityCommutative r
where
pr' : (a +N c) +N b+d-a-c ≡ (a +N b-a) +N d
pr' rewrite prb-a = pr
pr'' : a +N (c +N b+d-a-c) ≡ (a +N b-a) +N d
pr'' rewrite (equalityCommutative (additionNIsAssociative a c b+d-a-c)) = pr'
pr''' : a +N (c +N b+d-a-c) ≡ a +N (b-a +N d)
pr''' rewrite (equalityCommutative (additionNIsAssociative a b-a d)) = pr''
q : c +N b+d-a-c ≡ b-a +N d
q = canSubtractFromEqualityLeft {a} pr'''
q' : c +N b+d-a-c ≡ b-a +N (c +N d-c)
q' rewrite prd-c = q
q'' : c +N b+d-a-c ≡ (b-a +N c) +N d-c
q'' rewrite additionNIsAssociative b-a c d-c = q'
q''' : c +N b+d-a-c ≡ (c +N b-a) +N d-c
q''' rewrite additionNIsCommutative c b-a = q''
q'''' : c +N b+d-a-c ≡ c +N (b-a +N d-c)
q'''' rewrite equalityCommutative (additionNIsAssociative c b-a d-c) = q'''
r : b+d-a-c ≡ b-a +N d-c
r = canSubtractFromEqualityLeft {c} q''''
subtractProduct : {a b c : ℕ} → (aPos : 0 <N a) → (b<c : b <N c) →
(a *N (subtractionNResult.result (-N (inl b<c)))) ≡ subtractionNResult.result (-N {a *N b} {a *N c} (inl (lessRespectsMultiplicationLeft b c a b<c aPos)))
subtractProduct {zero} {b} {c} aPos b<c = refl
subtractProduct {succ zero} {b} {c} aPos b<c = s'
where
resbc = -N {b} {c} (inl b<c)
resbc' : Sg (subtractionNResult (b +N 0 *N b) c (lessCast (inl b<c) (equalityCommutative (addZeroRight b)))) ((λ res → subtractionNResult.result resbc ≡ subtractionNResult.result res))
resbc'' : Sg (subtractionNResult (b +N 0 *N b) (c +N 0 *N c) (lessCast' (lessCast (inl b<c) (equalityCommutative (addZeroRight b))) (equalityCommutative (addZeroRight c)))) (λ res → subtractionNResult.result (underlying resbc') ≡ subtractionNResult.result res)
g : (rsbc' : Sg (subtractionNResult (b +N 0 *N b) c (lessCast (inl b<c) (equalityCommutative (addZeroRight b)))) (λ res → subtractionNResult.result resbc ≡ subtractionNResult.result res)) → subtractionNResult.result resbc ≡ subtractionNResult.result (underlying rsbc')
g' : (rsbc'' : Sg (subtractionNResult (b +N 0 *N b) (c +N 0 *N c) (lessCast' (lessCast (inl b<c) (equalityCommutative (addZeroRight b))) (equalityCommutative (addZeroRight c)))) (λ res → subtractionNResult.result (underlying resbc') ≡ subtractionNResult.result res)) → subtractionNResult.result (underlying resbc') ≡ subtractionNResult.result (underlying rsbc'')
q : subtractionNResult.result resbc ≡ subtractionNResult.result (underlying resbc'')
r : subtractionNResult.result (underlying resbc'') ≡ subtractionNResult.result (-N {b +N 0 *N b} {c +N 0 *N c} (inl (lessRespectsMultiplicationLeft b c 1 b<c aPos)))
s : subtractionNResult.result resbc ≡ subtractionNResult.result (-N {b +N 0 *N b} {c +N 0 *N c} (inl (lessRespectsMultiplicationLeft b c 1 b<c aPos)))
s = transitivity q r
s' : subtractionNResult.result resbc +N 0 ≡ subtractionNResult.result (-N {b +N 0 *N b} {c +N 0 *N c} (inl (lessRespectsMultiplicationLeft b c 1 b<c aPos)))
s' = identityOfIndiscernablesLeft _≡_ s (equalityCommutative (addZeroRight _))
r = subtractionNWellDefined {b +N 0 *N b} {c +N 0 *N c} {(lessCast' (lessCast (inl b<c) (equalityCommutative (addZeroRight b))) (equalityCommutative (addZeroRight c)))} {inl (lessRespectsMultiplicationLeft b c 1 b<c aPos)} (underlying resbc'') (-N {b +N 0 *N b} {c +N 0 *N c} (inl (lessRespectsMultiplicationLeft b c 1 b<c aPos)))
g (a , b) = b
g' (a , b) = b
resbc'' = subtractionCast' {pr = inl (identityOfIndiscernablesLeft _<N_ b<c (equalityCommutative (addZeroRight b)))} (equalityCommutative (addZeroRight c)) (underlying resbc')
q = transitivity {_} {_} {subtractionNResult.result resbc} {subtractionNResult.result (underlying resbc')} {subtractionNResult.result (underlying resbc'')} (g resbc') (g' resbc'')
resbc' = subtractionCast {b} {c} {b +N 0 *N b} {inl b<c} (equalityCommutative (addZeroRight b)) resbc
subtractProduct {succ (succ a)} {b} {c} aPos b<c =
let
t : (succ a) *N subtractionNResult.result (-N {b} {c} (inl b<c)) ≡ subtractionNResult.result (-N {(succ a) *N b} {(succ a) *N c} (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a))))
t = subtractProduct {succ a} {b} {c} (succIsPositive a) b<c
in
go t --go t
where
go : (succ a) *N subtractionNResult.result (-N {b} {c} (inl b<c)) ≡ subtractionNResult.result (-N {(succ a) *N b} {(succ a) *N c} (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a)))) → (subtractionNResult.result (-N (inl b<c)) +N (subtractionNResult.result (-N (inl b<c)) +N a *N subtractionNResult.result (-N (inl b<c))) ≡ subtractionNResult.result (-N (inl (lessRespectsMultiplicationLeft b c (succ (succ a)) b<c aPos))))
go t = transitivity {_} {_} {lhs} {middle2} {rhs} u' v
where
c-b = subtractionNResult.result (-N {b} {c} (inl b<c))
lhs = c-b +N (succ a) *N c-b
middle = subtractionNResult.result (-N {(succ a) *N b} {(succ a) *N c} (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a))))
middle2 = subtractionNResult.result (-N {b +N (succ a *N b)} {c +N (succ a *N c)} (addWeakInequalities (inl b<c) (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a)))))
rhs = subtractionNResult.result (-N {succ (succ a) *N b} {(succ (succ a)) *N c} (inl (lessRespectsMultiplicationLeft b c (succ (succ a)) b<c aPos)))
lhs' : lhs ≡ c-b +N middle
u : c-b +N middle ≡ middle2
u' : lhs ≡ middle2
v : middle2 ≡ rhs
u'' : c-b +N subtractionNResult.result (-N {(succ a) *N b} {(succ a) *N c} (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a)))) ≡ rhs
u'' rewrite equalityCommutative v = u
u' rewrite equalityCommutative u = lhs'
lhs' rewrite t = refl
u = addSubIntoSub (inl b<c) (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a)))
v = subtractionNWellDefined {succ (succ a) *N b} {succ (succ a) *N c} {addWeakInequalities (inl b<c) (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a)))} {inl (lessRespectsMultiplicationLeft b c (succ (succ a)) b<c aPos)} (-N {b +N (succ a *N b)} {c +N (succ a *N c)} (addWeakInequalities (inl b<c) (inl (lessRespectsMultiplicationLeft b c (succ a) b<c (succIsPositive a))))) (-N {(succ (succ a)) *N b} {(succ (succ a)) *N c} (inl (lessRespectsMultiplicationLeft b c (succ (succ a)) b<c aPos)))
subtractProduct' : {a b c : ℕ} → (aPos : 0 <N a) → (b<c : b <N c) →
(subtractionNResult.result (-N (inl b<c))) *N a ≡ subtractionNResult.result (-N {a *N b} {a *N c} (inl (lessRespectsMultiplicationLeft b c a b<c aPos)))
subtractProduct' {a} aPos b<c = identityOfIndiscernablesLeft _≡_ (subtractProduct aPos b<c) (multiplicationNIsCommutative a _)
equalityDecidable : (a b : ℕ) → (a ≡ b) || ((a ≡ b) → False)
equalityDecidable zero zero = inl refl
equalityDecidable zero (succ b) = inr naughtE
equalityDecidable (succ a) zero = inr λ t → naughtE (equalityCommutative t)
equalityDecidable (succ a) (succ b) with equalityDecidable a b
equalityDecidable (succ a) (succ b) | inl x = inl (applyEquality succ x)
equalityDecidable (succ a) (succ b) | inr x = inr (λ t → x (succInjective t))
cannotAddKeepingEquality : (a b : ℕ) → (a ≡ a +N succ b) → False
cannotAddKeepingEquality zero zero pr = naughtE pr
cannotAddKeepingEquality (succ a) zero pr = cannotAddKeepingEquality a zero (succInjective pr)
cannotAddKeepingEquality zero (succ b) pr = naughtE pr
cannotAddKeepingEquality (succ a) (succ b) pr = cannotAddKeepingEquality a (succ b) (succInjective pr)
<NWellDefined' : {a b c d : ℕ} → a ≡ c → b ≡ d → a <N b → c <N d
<NWellDefined' {a} {b} {c} {d} a=c b=d a<b rewrite a=c | b=d = a<b
| {
"alphanum_fraction": 0.6527175932,
"avg_line_length": 72.1160714286,
"ext": "agda",
"hexsha": "a33cf93e49a977bd642a4849739da81e62bd3684",
"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/Naturals/Naturals.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/Naturals/Naturals.agda",
"max_line_length": 527,
"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/Naturals/Naturals.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": 8853,
"size": 24231
} |
module Prelude.Decidable where
open import Prelude.Empty
data Dec {a} (P : Set a) : Set a where
yes : P → Dec P
no : ¬ P → Dec P
infix 0 ifYes_then_else_ ifNo_then_else_
ifYes_then_else_ : ∀ {a b} {A : Set a} {B : Set b} → Dec A → B → B → B
ifYes yes _ then x else _ = x
ifYes no _ then _ else y = y
ifNo_then_else_ : ∀ {a b} {A : Set a} {B : Set b} → Dec A → B → B → B
ifNo d then x else y = ifYes d then y else x
FromDec : ∀ {a} {P : Set a} → Dec P → Set a
FromDec {P = P} (yes _) = P
FromDec {P = P} (no _) = ¬ P
fromDec : ∀ {a} {P : Set a} (d : Dec P) → FromDec d
fromDec (yes x) = x
fromDec (no x) = x
| {
"alphanum_fraction": 0.577170418,
"avg_line_length": 24.88,
"ext": "agda",
"hexsha": "43edde66b34467fc61856e6a7b1ef060e0b5bb79",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Prelude/Decidable.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Prelude/Decidable.agda",
"max_line_length": 70,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Prelude/Decidable.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": 256,
"size": 622
} |
{-# OPTIONS --without-K #-}
open import Type
open import Function
open import Function.Extensionality
open import Data.Fin using (Fin)
open import Level.NP
open import Algebra
open import Algebra.FunctionProperties.NP
open import Data.Fin using (Fin; zero; suc)
open import Data.Nat
open import Data.Product
open import Relation.Binary.NP
open import Explore.Core
open import Explore.Properties
open import Explore.Explorable
import Explore.Fin
open Explore.Fin.Regular
open import HoTT
module Explore.Function.Fin where
postulate
Postulate-FinFunˢ-ok : ★
-- open ExplorableRecord
module _ {A : ★}(μA : Explorable A) where
eᴬ = explore μA
extend : ∀ {n} → A → (Fin n → A) → Fin (suc n) → A
extend x g zero = x
extend x g (suc i) = g i
¬Fin0 : Fin 0 → A
¬Fin0 ()
-- There is one function Fin 0 → A (called abs) so this should be fine
-- if not there is a version below that forces the domain to be non-empty
FinFunᵉ : ∀ n → Explore _ (Fin n → A)
FinFunᵉ zero z op f = f ¬Fin0
FinFunᵉ (suc n) z op f = eᴬ z op (λ x → FinFunᵉ n z op (f ∘ extend x))
FinFunⁱ : ∀ n → ExploreInd _ (FinFunᵉ n)
FinFunⁱ zero P Pz P∙ Pf = Pf _
FinFunⁱ (suc n) P Pz P∙ Pf =
explore-ind μA (λ sa → P (λ z op f → sa z op (λ x → FinFunᵉ n z op (f ∘ extend x))))
Pz P∙
(λ x → FinFunⁱ n (λ sf → P (λ z op f → sf z op (f ∘ extend x)))
Pz P∙ (Pf ∘ extend x))
FinFunˢ : ∀ n → Sum (Fin n → A)
FinFunˢ n = FinFunᵉ n 0 _+_
postulate
FinFunˢ-ok : ∀ {{_ : Postulate-FinFunˢ-ok}} n → Adequate-sum (FinFunˢ n)
μFinFun : ∀ {{_ : Postulate-FinFunˢ-ok}} {n} → Explorable (Fin n → A)
μFinFun = mk _ (FinFunⁱ _) (FinFunˢ-ok _)
module BigDistr
{{_ : Postulate-FinFunˢ-ok}} {{_ : FunExt}} {{_ : UA}}
{A : ★}(μA : Explorable A)
(cm : CommutativeMonoid ₀ ₀)
-- we want (open CMon cm) !!!
(_◎_ : let open CMon cm in C → C → C)
(ε-◎ : let open CMon cm in Zero _≈_ ε _◎_)
(distrib : let open CMon cm in _DistributesOver_ _≈_ _◎_ _∙_)
(_◎-cong_ : let open CMon cm in _◎_ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_) where
open CMon cm renaming (sym to ≈-sym)
μF→A = μFinFun μA
-- Sum over A
Σᴬ = explore μA ε _∙_
-- Sum over (Fin(1+I)→A) functions
Σ' : ∀ {I} → ((Fin I → A) → C) → C
Σ' = explore μF→A ε _∙_
-- Product over Fin(1+I) values
Π' = λ I → explore (μFin I) ε _◎_
bigDistr : ∀ I F → Π' I (Σᴬ ∘ F) ≈ Σ' (Π' I ∘ _ˢ_ F)
bigDistr zero _ = refl
bigDistr (suc I) F
= Σᴬ (F zero) ◎ Π' I (Σᴬ ∘ F ∘ suc)
≈⟨ refl ◎-cong bigDistr I (F ∘ suc) ⟩
Σᴬ (F zero) ◎ Σ' (Π' I ∘ _ˢ_ (F ∘ suc))
≈⟨ ≈-sym (explore-linʳ μA monoid _◎_ (F zero) (Σ' (Π' I ∘ _ˢ_ (F ∘ suc))) (proj₁ ε-◎ _) (proj₂ distrib)) ⟩
Σᴬ (λ j → F zero j ◎ Σ' (Π' I ∘ _ˢ_ (F ∘ suc)))
≈⟨ explore-mon-ext μA monoid (λ j → ≈-sym (explore-linˡ μF→A monoid _◎_ (Π' I ∘ _ˢ_ (F ∘ suc)) (F zero j) (proj₂ ε-◎ _) (proj₁ distrib))) ⟩
(Σᴬ λ j → Σ' λ f → F zero j ◎ Π' I ((F ∘ suc) ˢ f))
∎
module _
{{_ : Postulate-FinFunˢ-ok}}{{_ : UA}}{{_ : FunExt}} where
FinDist : ∀ {n} → DistFun (μFin n) (λ μX → μFinFun μX)
FinDist μB c ◎ distrib ◎-cong f = BigDistr.bigDistr μB c ◎ distrib ◎-cong f _
| {
"alphanum_fraction": 0.5861093652,
"avg_line_length": 31.1960784314,
"ext": "agda",
"hexsha": "1463e86585e6d09009aa36fee39ed8231fe513b5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crypto-agda/explore",
"max_forks_repo_path": "lib/Explore/Function/Fin.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "crypto-agda/explore",
"max_issues_repo_path": "lib/Explore/Function/Fin.agda",
"max_line_length": 143,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crypto-agda/explore",
"max_stars_repo_path": "lib/Explore/Function/Fin.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
"num_tokens": 1374,
"size": 3182
} |
{-# OPTIONS --without-K -v 2 #-}
module Leftovers.Equality where
open import Leftovers.Utils
-- open import Leftovers.Leftovers
import Level as Level
-- open import Reflection
open import Reflection.Term
open import Reflection.Pattern as P
open import Reflection.TypeChecking.Monad.Instances
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary
open import Data.Unit
open import Data.Nat as Nat hiding (_⊓_)
open import Data.Bool
open import Data.Product
open import Data.List as List
open import Data.Char as Char
open import Data.String as String
open import Leftovers.Monad
import Data.List.Categorical
open Data.List.Categorical.TraversableM {m = Level.zero} leftoversMonad
--This file was adapted from https://github.com/alhassy/gentle-intro-to-reflection
open import Reflection.Show
import Data.Nat.Show as NShow
--Unify the goal with a function that does a case-split on an argument of the type with the given name
-- Return the metavariables, along with telescopes, for each branch
cases : Name → Term → Leftovers ⊤
cases typeName hole -- thm-you-hope-is-provable-by-refls
= do
-- let η = nom
δ ← getDefinition typeName
holeType ← inferType hole
debugPrint "refl-cases" 2 (strErr " hole type to start " ∷ termErr holeType ∷ [])
clauses ← forM (constructors δ) (mk-cls holeType)
-- declareDef (vArg η) holeType
let retFun = (pat-lam clauses [])
normFun ← reduce retFun
debugPrint "refl-cases" 2 (strErr "reflcases ret non-norm " ∷ termErr retFun ∷ [])
unify hole normFun
normHole ← reduce hole
debugPrint "refl-cases" 2 (strErr "reflCases final " ∷ termErr normHole ∷ [])
where
-- For each constructor, generate the clause,
-- along with the metavariable term for its right-hand side
mk-cls : Type → Name → Leftovers (Clause )
mk-cls holeType ctor =
do
debugPrint "mk-cls" 2 (strErr "mk-cls with ctor " ∷ nameErr ctor ∷ [])
fullyApplied <- fully-applied-pattern ctor
let
patArgs = List.map CtorArg.pat fullyApplied
patTerm = List.map CtorArg.term fullyApplied
patTypes = List.map CtorArg.type fullyApplied
extendContexts patTypes do
debugPrint "" 2 (strErr "before retType " ∷ termErr holeType ∷ strErr " and " ∷ termErr (con ctor patTerm) ∷ [])
retType ← returnTypeFor holeType (con ctor patTerm)
debugPrint "mk-cls" 2 (strErr "retType is " ∷ termErr retType ∷ [])
-- Make the right-hand side in an extended context
-- with new pattern-match variables
rhs ← freshMeta retType
let
teles =
List.map
(λ (x , n) → ( "arg" String.++ NShow.show n , x ))
(List.zip patTypes (List.upTo (List.length patTypes)))
debugPrint "mk-cls" 2 (strErr "Pat" ∷ strErr (showPatterns patArgs) ∷ [] )
let
ret =
(clause
teles
[ vArg (con ctor patArgs) ]
(rhs ⦂ retType))
debugPrint "mk-cls" 2 (strErr "retClause" ∷ strErr (showClause ret) ∷ [])
-- tryUnify rhs (con (quote refl) [])
pure ret
-- ≡-type-info : Term → Leftovers (Arg Term × Arg Term × Term × Term)
-- ≡-type-info (def (quote _≡_) (𝓁 ∷ 𝒯 ∷ arg _ l ∷ arg _ r ∷ [])) = return (𝓁 , 𝒯 , l , r)
-- ≡-type-info _ = typeError [ strErr "Term is not a ≡-type." ]
-- {- If we have “f $ args” return “f”. -}
-- $-head : Term → Term
-- $-head (var v args) = var v []
-- $-head (con c args) = con c []
-- $-head (def f args) = def f []
-- $-head (pat-lam cs args) = pat-lam cs []
-- $-head t = t
-- import Agda.Builtin.Reflection as Builtin
-- _$-≟_ : Term → Term → Bool
-- con c args $-≟ con c′ args′ = Builtin.primQNameEquality c c′
-- def f args $-≟ def f′ args′ = Builtin.primQNameEquality f f′
-- var x args $-≟ var x′ args′ = does (x Nat.≟ x′)
-- _ $-≟ _ = false
-- {- Only gets heads and as much common args, not anywhere deep. :'( -}
-- infix 5 _⊓_
-- {-# TERMINATING #-} {- Fix this by adding fuel (con c args) ≔ 1 + length args -}
-- _⊓_ : Term → Term → Term
-- l ⊓ r with l $-≟ r | l | r
-- ...| false | x | y = unknown
-- ...| true | var f args | var f′ args′ = var f (List.zipWith (λ{ (arg i!! t) (arg j!! s) → arg i!! (t ⊓ s) }) args args′)
-- ...| true | con f args | con f′ args′ = con f (List.zipWith (λ{ (arg i!! t) (arg j!! s) → arg i!! (t ⊓ s) }) args args′)
-- ...| true | def f args | def f′ args′ = def f (List.zipWith (λ{ (arg i!! t) (arg j!! s) → arg i!! (t ⊓ s) }) args args′)
-- ...| true | ll | _ = ll {- Left biased; using ‘unknown’ does not ensure idempotence. -}
-- {- ‘unknown’ goes to a variable, a De Bruijn index -}
-- unknown-elim : ℕ → List (Arg Term) → List (Arg Term)
-- unknown-elim n [] = []
-- unknown-elim n (arg i unknown ∷ xs) = arg i (var n []) ∷ unknown-elim (n + 1) xs
-- unknown-elim n (arg i (var x args) ∷ xs) = arg i (var (n + suc x) args) ∷ unknown-elim n xs
-- unknown-elim n (arg i x ∷ xs) = arg i x ∷ unknown-elim n xs
-- {- Essentially we want: body(unknownᵢ) ⇒ λ _ → body(var 0)
-- However, now all “var 0” references in “body” refer to the wrong argument;
-- they now refer to “one more lambda away than before”. -}
-- unknown-count : List (Arg Term) → ℕ
-- unknown-count [] = 0
-- unknown-count (arg i unknown ∷ xs) = 1 + unknown-count xs
-- unknown-count (arg i _ ∷ xs) = unknown-count xs
-- unknown-λ : ℕ → Term → Term
-- unknown-λ zero body = body
-- unknown-λ (suc n) body = unknown-λ n (λv "section" ↦ body)
-- {- Replace ‘unknown’ with sections -}
-- patch : Term → Term
-- patch it@(def f args) = unknown-λ (unknown-count args) (def f (unknown-elim 0 args))
-- patch it@(var f args) = unknown-λ (unknown-count args) (var f (unknown-elim 0 args))
-- patch it@(con f args) = unknown-λ (unknown-count args) (con f (unknown-elim 0 args))
-- patch t = t
-- macro
-- spine : Term → Term → Leftovers ⊤
-- spine p goal =
-- do τ ← inferType p
-- _ , _ , l , r ← ≡-type-info τ
-- unify goal (patch (l ⊓ r))
-- macro
-- applyEq : Term → Term → Leftovers ⊤
-- applyEq p hole =
-- do
-- τ ← inferType hole
-- _ , _ , l , r ← ≡-type-info τ
-- unify hole ((def (quote cong) (vArg (patch (l ⊓ r)) ∷ vArg p ∷ [])))
| {
"alphanum_fraction": 0.5905172414,
"avg_line_length": 38.4378698225,
"ext": "agda",
"hexsha": "7e9f3fca27584898e762d7cfd413e1fa81a90b30",
"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": "01b60b405009feaada181af175f019ceb89e42b2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "JoeyEremondi/AgdaLeftovers",
"max_forks_repo_path": "src/Leftovers/Equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "01b60b405009feaada181af175f019ceb89e42b2",
"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": "JoeyEremondi/AgdaLeftovers",
"max_issues_repo_path": "src/Leftovers/Equality.agda",
"max_line_length": 132,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "01b60b405009feaada181af175f019ceb89e42b2",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "JoeyEremondi/AgdaLeftovers",
"max_stars_repo_path": "src/Leftovers/Equality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1979,
"size": 6496
} |
-- Adapted from Wadler: https://plfa.github.io/Lambda/
module Context (A : Set) where
open import Prelude
open import Data.Nat
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym)
open import Data.Maybe
open import Data.Product using (_×_; proj₁; proj₂; ∃-syntax) renaming (_,_ to ⟨_,_⟩)
open import Relation.Nullary.Decidable
open import Relation.Nullary using (Dec; yes; no)
open import Data.Empty
import Data.Nat.Properties
infixl 5 _,_⦂_
-- Internal type of contexts
data ctx : Set where
∅ : ctx
_,_⦂_ : ctx → ℕ → A → ctx
infix 4 _∋_⦂_
data _∋_⦂_ : ctx → ℕ → A → Set where
Z : ∀ {Γ : ctx}
→ ∀ {x : ℕ}
→ ∀ {a : A}
------------------
→ Γ , x ⦂ a ∋ x ⦂ a
S : ∀ {Γ x y a b}
→ x ≢ y
→ Γ ∋ x ⦂ a
------------------
→ Γ , y ⦂ b ∋ x ⦂ a
lookup : ctx → ℕ → Maybe A
lookup ∅ _ = nothing
lookup (Γ , x ⦂ t) y with compare x y
... | equal _ = just t
... | _ = lookup Γ x
data _∈dom_ : ℕ → ctx → Set where
inDom : ∀ {x Γ a}
→ Γ ∋ x ⦂ a
-------------
→ x ∈dom Γ
data _∉dom_ : ℕ → ctx → Set where
notInEmpty : ∀ {x}
----------
→ x ∉dom ∅
notInNonempty : ∀ {x x' Γ T}
→ x ≢ x'
→ x ∉dom Γ
--------------------
→ x ∉dom (Γ , x' ⦂ T)
irrelevantExtensionsOK : ∀ {Γ : ctx}
→ ∀ {x y t t'}
→ Γ ∋ x ⦂ t
→ x ≢ y
→ Γ , y ⦂ t' ∋ x ⦂ t
irrelevantExtensionsOK {Γ} {x} {y} {t} cont@(Z {Γ₀} {x} {t}) neq = S neq cont
irrelevantExtensionsOK (S neq' rest) neq = S neq (irrelevantExtensionsOK rest neq')
irrelevantReductionsOK : ∀ {Γ : ctx}
→ ∀ {x y t t'}
→ Γ , x ⦂ t ∋ y ⦂ t'
→ y ≢ x
→ Γ ∋ y ⦂ t'
-- ⊥-elim (!neq (Relation.Binary.PropositionalEquality.sym x x))
irrelevantReductionsOK {Γ} {x} {y} {t} {t'} z@(Z {Γ} {x} {t}) neq =
let
s : x ≡ x
s = refl
bot = neq s
in
Data.Empty.⊥-elim bot
irrelevantReductionsOK {Γ} {x} {y} {t} {t'} (S x₁ qq) neq = qq
irrelevantReductionsInValuesOK : ∀ {Γ : ctx}
→ ∀ {x y t t'}
→ Γ , x ⦂ t ∋ y ⦂ t'
→ t ≢ t'
→ Γ ∋ y ⦂ t'
irrelevantReductionsInValuesOK {Γ} {x} {.x} {t} {.t} Z tNeqt' = ⊥-elim (tNeqt' refl)
irrelevantReductionsInValuesOK {Γ} {x} {y} {t} {t'} (S yNeqx yt'InΓ') tNeqt' = yt'InΓ'
∈domExcludedMiddle : ∀ {Γ x}
→ x ∉dom Γ
→ Relation.Nullary.¬ (x ∈dom Γ)
∈domExcludedMiddle {.∅} {x} notInEmpty (inDom ())
∈domExcludedMiddle {.(_ , _ ⦂ _)} {x} (notInNonempty xNeqx' xNotInΓ) (inDom n) =
let
rest = ∈domExcludedMiddle xNotInΓ
xInΓ = irrelevantReductionsOK n xNeqx'
in
rest (inDom xInΓ)
∉domPreservation : ∀ {x x' Γ T T'}
→ x ∉dom (Γ , x' ⦂ T)
---------------------
→ x ∉dom (Γ , x' ⦂ T')
∉domPreservation {x} {x'} {Γ} {T} {T'} (notInNonempty xNeqX' xNotInDom) = notInNonempty xNeqX' xNotInDom
∉domGreaterThan : ∀ {Γ x}
→ (∀ x' → x' ∈dom Γ → x' < x)
→ x ∉dom Γ
∉domGreaterThan {∅} {x} xBigger = notInEmpty
∉domGreaterThan {Γ , x' ⦂ t} {x} xBigger =
notInNonempty x≢x' (∉domGreaterThan rest) -- (∉domGreaterThan (λ x'' → λ x''InΓ → xBigger x'' (inDom {!!})))
where
x'<x = xBigger x' (inDom Z)
x≢x' : x ≢ x'
x≢x' = ≢-sym (Data.Nat.Properties.<⇒≢ x'<x)
rest : (x'' : ℕ)
→ x'' ∈dom Γ
→ x'' < x
rest x'' (inDom x''InΓ) with x' ≟ x''
... | yes x'≡x'' rewrite x'≡x'' = xBigger x'' (inDom Z)
... | no x'≢x'' = xBigger x'' (inDom (S (≢-sym x'≢x'') x''InΓ))
fresh : (Γ : ctx)
→ ∃[ x ] (x ∉dom Γ × (∀ x' → x' ∈dom Γ → x' < x))
fresh ∅ =
⟨ zero , ⟨ notInEmpty , xBigger ⟩ ⟩
where
xBigger : (∀ x' → x' ∈dom ∅ → x' < zero)
xBigger x' (inDom ())
fresh (Γ , x ⦂ t) =
⟨ x' , ⟨ x'IsFresh , x'Bigger ⟩ ⟩
where
freshInRest = fresh Γ
biggerThanRest = suc (proj₁ freshInRest)
x' = biggerThanRest ⊔ (suc x) -- bigger than both everything in Γ and x.
freshInRestBigger = proj₂ (proj₂ freshInRest)
x'Bigger : (x'' : ℕ) → (x'' ∈dom (Γ , x ⦂ t)) → x'' < x'
x'Bigger x'' (inDom x''InΓ') with x ≟ x''
... | yes x≡x'' rewrite x≡x'' =
s≤s (Data.Nat.Properties.n≤m⊔n (proj₁ (fresh Γ)) x'') -- s≤s (Data.Nat.Properties.<⇒≤ x''<oldFresh)
... | no x≢x'' =
let
x''<oldFresh = freshInRestBigger x'' (inDom (irrelevantReductionsOK x''InΓ' (≢-sym x≢x'')) )
x''≤oldFresh = (Data.Nat.Properties.<⇒≤ x''<oldFresh)
in
s≤s ( Data.Nat.Properties.m≤n⇒m≤n⊔o x x''≤oldFresh) -- s≤s (Data.Nat.Properties.<⇒≤ x''<oldFresh)
x'IsFresh : x' ∉dom (Γ , x ⦂ t)
x'IsFresh = ∉domGreaterThan x'Bigger
-- Removing elements from a context
_#_ : ctx → ℕ → ctx
∅ # x = ∅
(Γ , x' ⦂ T) # x with compare x x'
... | equal _ = Γ
... | _ = (Γ # x) , x' ⦂ T
contextLookupUnique : ∀ {Γ : ctx}
→ ∀ {x t t'}
→ Γ ∋ x ⦂ t
→ Γ ∋ x ⦂ t'
→ t ≡ t'
contextLookupUnique z1@Z z2@Z = refl
contextLookupUnique z1@Z s2@(S {Γ} {x} {y} {a} {b} neq xHasTypeT') = Data.Empty.⊥-elim (neq refl)
contextLookupUnique (S neq xHasTypeT) Z = Data.Empty.⊥-elim (neq refl)
contextLookupUnique (S x₁ xHasTypeT) (S x₂ xHasTypeT') = contextLookupUnique xHasTypeT xHasTypeT'
contextLookupNeq : ∀ {Γ : ctx}
→ ∀ {x x' t t'}
→ Γ , x ⦂ t ∋ x' ⦂ t'
→ t ≢ t'
→ x ≢ x'
contextLookupNeq Z tNeq = Data.Empty.⊥-elim (tNeq refl)
contextLookupNeq (S xNeq x'InΓ) tNeq = λ xEq → xNeq (sym xEq)
lookupWeakening : ∀ {Γ : ctx}
→ ∀ {x x' t t'}
→ Γ ∋ x ⦂ t
→ ∃[ T ] ((Γ , x' ⦂ t') ∋ x ⦂ T)
lookupWeakening {Γ} {x} {x'} {t} {t'} Γcontainment with x ≟ x'
... | yes refl = ⟨ t' , Z {Γ = Γ} {x = x'} {a = t'} ⟩
... | no neq = ⟨ t , S neq Γcontainment ⟩
∉dom-≢ : {Γ : ctx}
→ ∀ {x x' t}
→ x ∉dom (Γ , x' ⦂ t)
→ x ≢ x'
∉dom-≢ {Γ} {x} {x'} {t} (notInNonempty xNeqx' xNotInΓ') xEqx' = xNeqx' xEqx'
| {
"alphanum_fraction": 0.4253171857,
"avg_line_length": 33.6699029126,
"ext": "agda",
"hexsha": "fb0762af21cf302ffe9d3c4e833231eaaa6d45fc",
"lang": "Agda",
"max_forks_count": 11,
"max_forks_repo_forks_event_max_datetime": "2021-06-09T18:40:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-05-24T08:20:52.000Z",
"max_forks_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "ivoysey/Obsidian",
"max_forks_repo_path": "formalization/Context.agda",
"max_issues_count": 259,
"max_issues_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_issues_repo_issues_event_max_datetime": "2022-03-29T18:20:05.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-08-18T19:50:41.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "ivoysey/Obsidian",
"max_issues_repo_path": "formalization/Context.agda",
"max_line_length": 115,
"max_stars_count": 79,
"max_stars_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "ivoysey/Obsidian",
"max_stars_repo_path": "formalization/Context.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T10:34:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-08-19T16:24:10.000Z",
"num_tokens": 2542,
"size": 6936
} |
open import Proc
module Hear (param : Param) where
open import Basics
private open module P = Process param
open Tran
hear : {a : U}{p : Proc a} -> Guard p -> LT a -> Proc a
hear {p = p} g bot = p
hear og (lift v) = o
hear (w !g p) (lift v) = w ! p
hear (>g f) (lift v) = f v
hear (_ ! _ +g f) (lift v) = f v
hear (g1 ||g g2) (lift v) = hear g1 (lift v) || hear g2 (lift v)
hear (φ /|g g) (lift v) = φ /| hear g (downV φ v)
hear (defg x g) (lift v) = hear g (lift v)
sound : {a : U}{p : Proc a}(g : Guard p){w : LT a} ->
p -[ w ]-> hear g w
sound g {bot} = qtau
sound og {lift v} = rx-o
sound (>g _) {lift v} = rx->
sound (w !g p) {lift v} = rx-!
sound (w ! p +g f) {lift v} = rx-+
sound (g1 ||g g2) {lift v} = rx-|| (sound g1) (sound g2)
sound (φ /|g g) {lift v} = rx-/| (sound g)
sound (defg x g) {lift v} = rx-def (sound g)
uniq : {a : U}{p : Proc a}{w : LT a}{px py : Proc a} ->
p -[ w ]-> px -> p -[ w ]-> py -> px == py
uniq qtau qtau = refl
uniq rx-o rx-o = refl
uniq rx-> rx-> = refl
uniq rx-! rx-! = refl
uniq rx-+ rx-+ = refl
uniq (rx-|| l1 r1) (rx-|| l2 r2) with uniq l1 l2 | uniq r1 r2
... | refl | refl = refl
uniq (rx-/| r1) (rx-/| r2) with uniq r1 r2
... | refl = refl
uniq (rx-def r1) (rx-def r2) with uniq r1 r2
... | refl = refl
complete : {a : U}{p : Proc a}(g : Guard p){w : LT a}{p' : Proc a} ->
p -[ w ]-> p' -> p' == hear g w
complete g r = uniq r (sound g)
| {
"alphanum_fraction": 0.4959731544,
"avg_line_length": 30.4081632653,
"ext": "agda",
"hexsha": "e70df5eb167deae23d24f386b3d5afb4001c6e48",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/cbs/Hear.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/cbs/Hear.agda",
"max_line_length": 69,
"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": "examples/outdated-and-incorrect/cbs/Hear.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 604,
"size": 1490
} |
module NatProps where
open import Data.Nat using (ℕ ; _≟_ ; _<_ ; zero ; suc ; s≤s)
open import Relation.Nullary using (Dec ; yes ; no ; ¬_)
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym)
<-¬≡ : ∀ {n m} → n < m → ¬ n ≡ m
<-¬≡ {zero} {zero} ()
<-¬≡ {zero} {suc m} p = λ ()
<-¬≡ {suc n} {zero} p = λ ()
<-¬≡ {suc n} {suc m} (Data.Nat.s≤s p) with (<-¬≡ p)
... | q = λ { refl → q refl }
| {
"alphanum_fraction": 0.5224586288,
"avg_line_length": 35.25,
"ext": "agda",
"hexsha": "dbadc11fae6741f8bad5a4a7211310958fa256df",
"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": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Zalastax/singly-typed-actors",
"max_forks_repo_path": "src/NatProps.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"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": "Zalastax/singly-typed-actors",
"max_issues_repo_path": "src/NatProps.agda",
"max_line_length": 75,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Zalastax/thesis",
"max_stars_repo_path": "src/NatProps.agda",
"max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z",
"num_tokens": 172,
"size": 423
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of permutations using setoid equality
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary hiding (Decidable)
module Data.List.Relation.Binary.Permutation.Setoid.Properties
{a ℓ} (S : Setoid a ℓ)
where
open import Algebra
open import Data.Fin.Base using (Fin)
open import Data.List.Base as List hiding (head; tail)
open import Data.List.Relation.Binary.Pointwise as Pointwise
using (Pointwise; head; tail)
import Data.List.Relation.Binary.Equality.Setoid as Equality
import Data.List.Relation.Binary.Permutation.Setoid as Permutation
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
open import Data.List.Relation.Unary.AllPairs using (AllPairs; []; _∷_)
import Data.List.Relation.Unary.Unique.Setoid as Unique
import Data.List.Membership.Setoid as Membership
open import Data.List.Membership.Setoid.Properties using (∈-∃++; ∈-insert)
open import Data.List.Relation.Binary.BagAndSetEquality
using (bag; _∼[_]_; empty-unique; drop-cons; commutativeMonoid)
import Data.List.Properties as Lₚ
open import Data.Nat hiding (_⊔_)
open import Data.Nat.Induction
open import Data.Nat.Properties
open import Data.Product using (_,_; _×_; ∃; ∃₂; proj₁; proj₂)
open import Function using (_∘_; _⟨_⟩_; flip)
open import Function.Equality using (_⟨$⟩_)
open import Function.Inverse as Inv using (inverse)
open import Level using (Level; _⊔_)
open import Relation.Unary using (Pred; Decidable)
open import Relation.Binary.Properties.Setoid S using (≉-resp₂)
open import Relation.Binary.PropositionalEquality as ≡
using (_≡_ ; refl; sym; cong; cong₂; subst; _≢_; inspect)
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Negation using (contradiction)
private
variable
b p r : Level
open Setoid S using (_≈_) renaming (Carrier to A; refl to ≈-refl; sym to ≈-sym; trans to ≈-trans)
open Permutation S
open Membership S
open Unique S using (Unique)
open module ≋ = Equality S
using (_≋_; []; _∷_; ≋-refl; ≋-sym; ≋-trans; All-resp-≋; Any-resp-≋; AllPairs-resp-≋)
open PermutationReasoning
------------------------------------------------------------------------
-- Relationships to other predicates
------------------------------------------------------------------------
All-resp-↭ : ∀ {P : Pred A p} → P Respects _≈_ → (All P) Respects _↭_
All-resp-↭ resp (refl xs≋ys) pxs = All-resp-≋ resp xs≋ys pxs
All-resp-↭ resp (prep x≈y p) (px ∷ pxs) = resp x≈y px ∷ All-resp-↭ resp p pxs
All-resp-↭ resp (swap ≈₁ ≈₂ p) (px ∷ py ∷ pxs) = resp ≈₂ py ∷ resp ≈₁ px ∷ All-resp-↭ resp p pxs
All-resp-↭ resp (trans p₁ p₂) pxs = All-resp-↭ resp p₂ (All-resp-↭ resp p₁ pxs)
Any-resp-↭ : ∀ {P : Pred A p} → P Respects _≈_ → (Any P) Respects _↭_
Any-resp-↭ resp (refl xs≋ys) pxs = Any-resp-≋ resp xs≋ys pxs
Any-resp-↭ resp (prep x≈y p) (here px) = here (resp x≈y px)
Any-resp-↭ resp (prep x≈y p) (there pxs) = there (Any-resp-↭ resp p pxs)
Any-resp-↭ resp (swap x y p) (here px) = there (here (resp x px))
Any-resp-↭ resp (swap x y p) (there (here px)) = here (resp y px)
Any-resp-↭ resp (swap x y p) (there (there pxs)) = there (there (Any-resp-↭ resp p pxs))
Any-resp-↭ resp (trans p₁ p₂) pxs = Any-resp-↭ resp p₂ (Any-resp-↭ resp p₁ pxs)
AllPairs-resp-↭ : ∀ {R : Rel A r} → Symmetric R → R Respects₂ _≈_ → (AllPairs R) Respects _↭_
AllPairs-resp-↭ sym resp (refl xs≋ys) pxs = AllPairs-resp-≋ resp xs≋ys pxs
AllPairs-resp-↭ sym resp (prep x≈y p) (∼ ∷ pxs) =
All-resp-↭ (proj₁ resp) p (All.map (proj₂ resp x≈y) ∼) ∷
AllPairs-resp-↭ sym resp p pxs
AllPairs-resp-↭ sym resp@(rʳ , rˡ) (swap eq₁ eq₂ p) ((∼₁ ∷ ∼₂) ∷ ∼₃ ∷ pxs) =
(sym (rʳ eq₂ (rˡ eq₁ ∼₁)) ∷ All-resp-↭ rʳ p (All.map (rˡ eq₂) ∼₃)) ∷
All-resp-↭ rʳ p (All.map (rˡ eq₁) ∼₂) ∷
AllPairs-resp-↭ sym resp p pxs
AllPairs-resp-↭ sym resp (trans p₁ p₂) pxs =
AllPairs-resp-↭ sym resp p₂ (AllPairs-resp-↭ sym resp p₁ pxs)
∈-resp-↭ : ∀ {x} → (x ∈_) Respects _↭_
∈-resp-↭ = Any-resp-↭ (flip ≈-trans)
Unique-resp-↭ : Unique Respects _↭_
Unique-resp-↭ = AllPairs-resp-↭ (_∘ ≈-sym) ≉-resp₂
------------------------------------------------------------------------
-- Relationships to other relations
------------------------------------------------------------------------
≋⇒↭ : _≋_ ⇒ _↭_
≋⇒↭ = refl
↭-respʳ-≋ : _↭_ Respectsʳ _≋_
↭-respʳ-≋ xs≋ys (refl zs≋xs) = refl (≋-trans zs≋xs xs≋ys)
↭-respʳ-≋ (x≈y ∷ xs≋ys) (prep eq zs↭xs) = prep (≈-trans eq x≈y) (↭-respʳ-≋ xs≋ys zs↭xs)
↭-respʳ-≋ (x≈y ∷ w≈z ∷ xs≋ys) (swap eq₁ eq₂ zs↭xs) = swap (≈-trans eq₁ w≈z) (≈-trans eq₂ x≈y) (↭-respʳ-≋ xs≋ys zs↭xs)
↭-respʳ-≋ xs≋ys (trans ws↭zs zs↭xs) = trans ws↭zs (↭-respʳ-≋ xs≋ys zs↭xs)
↭-respˡ-≋ : _↭_ Respectsˡ _≋_
↭-respˡ-≋ xs≋ys (refl ys≋zs) = refl (≋-trans (≋-sym xs≋ys) ys≋zs)
↭-respˡ-≋ (x≈y ∷ xs≋ys) (prep eq zs↭xs) = prep (≈-trans (≈-sym x≈y) eq) (↭-respˡ-≋ xs≋ys zs↭xs)
↭-respˡ-≋ (x≈y ∷ w≈z ∷ xs≋ys) (swap eq₁ eq₂ zs↭xs) = swap (≈-trans (≈-sym x≈y) eq₁) (≈-trans (≈-sym w≈z) eq₂) (↭-respˡ-≋ xs≋ys zs↭xs)
↭-respˡ-≋ xs≋ys (trans ws↭zs zs↭xs) = trans (↭-respˡ-≋ xs≋ys ws↭zs) zs↭xs
------------------------------------------------------------------------
-- Properties of steps
------------------------------------------------------------------------
0<steps : ∀ {xs ys} (xs↭ys : xs ↭ ys) → 0 < steps xs↭ys
0<steps (refl _) = s≤s z≤n
0<steps (prep eq xs↭ys) = ≤-step (0<steps xs↭ys)
0<steps (swap eq₁ eq₂ xs↭ys) = ≤-step (0<steps xs↭ys)
0<steps (trans xs↭ys xs↭ys₁) =
<-transˡ (0<steps xs↭ys) (m≤m+n (steps xs↭ys) (steps xs↭ys₁))
steps-respˡ : ∀ {xs ys zs} (ys≋xs : ys ≋ xs) (ys↭zs : ys ↭ zs) →
steps (↭-respˡ-≋ ys≋xs ys↭zs) ≡ steps ys↭zs
steps-respˡ _ (refl _) = refl
steps-respˡ (_ ∷ ys≋xs) (prep _ ys↭zs) = cong suc (steps-respˡ ys≋xs ys↭zs)
steps-respˡ (_ ∷ _ ∷ ys≋xs) (swap _ _ ys↭zs) = cong suc (steps-respˡ ys≋xs ys↭zs)
steps-respˡ ys≋xs (trans ys↭ws ws↭zs) = cong (_+ steps ws↭zs) (steps-respˡ ys≋xs ys↭ws)
steps-respʳ : ∀ {xs ys zs} (xs≋ys : xs ≋ ys) (zs↭xs : zs ↭ xs) →
steps (↭-respʳ-≋ xs≋ys zs↭xs) ≡ steps zs↭xs
steps-respʳ _ (refl _) = refl
steps-respʳ (_ ∷ ys≋xs) (prep _ ys↭zs) = cong suc (steps-respʳ ys≋xs ys↭zs)
steps-respʳ (_ ∷ _ ∷ ys≋xs) (swap _ _ ys↭zs) = cong suc (steps-respʳ ys≋xs ys↭zs)
steps-respʳ ys≋xs (trans ys↭ws ws↭zs) = cong (steps ys↭ws +_) (steps-respʳ ys≋xs ws↭zs)
------------------------------------------------------------------------
-- Properties of list functions
------------------------------------------------------------------------
------------------------------------------------------------------------
-- map
module _ (T : Setoid b ℓ) where
open Setoid T using () renaming (_≈_ to _≈′_)
open Permutation T using () renaming (_↭_ to _↭′_)
map⁺ : ∀ {f} → f Preserves _≈_ ⟶ _≈′_ →
∀ {xs ys} → xs ↭ ys → map f xs ↭′ map f ys
map⁺ pres (refl xs≋ys) = refl (Pointwise.map⁺ _ _ (Pointwise.map pres xs≋ys))
map⁺ pres (prep x p) = prep (pres x) (map⁺ pres p)
map⁺ pres (swap x y p) = swap (pres x) (pres y) (map⁺ pres p)
map⁺ pres (trans p₁ p₂) = trans (map⁺ pres p₁) (map⁺ pres p₂)
------------------------------------------------------------------------
-- _++_
shift : ∀ {v w} → v ≈ w → (xs ys : List A) → xs ++ [ v ] ++ ys ↭ w ∷ xs ++ ys
shift {v} {w} v≈w [] ys = prep v≈w ↭-refl
shift {v} {w} v≈w (x ∷ xs) ys = begin
x ∷ (xs ++ [ v ] ++ ys) <⟨ shift v≈w xs ys ⟩
x ∷ w ∷ xs ++ ys <<⟨ ↭-refl ⟩
w ∷ x ∷ xs ++ ys ∎
++⁺ˡ : ∀ xs {ys zs : List A} → ys ↭ zs → xs ++ ys ↭ xs ++ zs
++⁺ˡ [] ys↭zs = ys↭zs
++⁺ˡ (x ∷ xs) ys↭zs = ↭-prep _ (++⁺ˡ xs ys↭zs)
++⁺ʳ : ∀ {xs ys : List A} zs → xs ↭ ys → xs ++ zs ↭ ys ++ zs
++⁺ʳ zs (refl xs≋ys) = refl (Pointwise.++⁺ xs≋ys ≋-refl)
++⁺ʳ zs (prep x ↭) = prep x (++⁺ʳ zs ↭)
++⁺ʳ zs (swap x y ↭) = swap x y (++⁺ʳ zs ↭)
++⁺ʳ zs (trans ↭₁ ↭₂) = trans (++⁺ʳ zs ↭₁) (++⁺ʳ zs ↭₂)
++⁺ : _++_ Preserves₂ _↭_ ⟶ _↭_ ⟶ _↭_
++⁺ ws↭xs ys↭zs = trans (++⁺ʳ _ ws↭xs) (++⁺ˡ _ ys↭zs)
-- Algebraic properties
++-identityˡ : LeftIdentity _↭_ [] _++_
++-identityˡ xs = ↭-refl
++-identityʳ : RightIdentity _↭_ [] _++_
++-identityʳ xs = ↭-reflexive (Lₚ.++-identityʳ xs)
++-identity : Identity _↭_ [] _++_
++-identity = ++-identityˡ , ++-identityʳ
++-assoc : Associative _↭_ _++_
++-assoc xs ys zs = ↭-reflexive (Lₚ.++-assoc xs ys zs)
++-comm : Commutative _↭_ _++_
++-comm [] ys = ↭-sym (++-identityʳ ys)
++-comm (x ∷ xs) ys = begin
x ∷ xs ++ ys <⟨ ++-comm xs ys ⟩
x ∷ ys ++ xs ≡⟨ cong (λ v → x ∷ v ++ xs) (≡.sym (Lₚ.++-identityʳ _)) ⟩
(x ∷ ys ++ []) ++ xs ↭⟨ ++⁺ʳ xs (↭-sym (shift ≈-refl ys [])) ⟩
(ys ++ [ x ]) ++ xs ↭⟨ ++-assoc ys [ x ] xs ⟩
ys ++ ([ x ] ++ xs) ≡⟨⟩
ys ++ (x ∷ xs) ∎
-- Structures
++-isMagma : IsMagma _↭_ _++_
++-isMagma = record
{ isEquivalence = ↭-isEquivalence
; ∙-cong = ++⁺
}
++-isSemigroup : IsSemigroup _↭_ _++_
++-isSemigroup = record
{ isMagma = ++-isMagma
; assoc = ++-assoc
}
++-isMonoid : IsMonoid _↭_ _++_ []
++-isMonoid = record
{ isSemigroup = ++-isSemigroup
; identity = ++-identity
}
++-isCommutativeMonoid : IsCommutativeMonoid _↭_ _++_ []
++-isCommutativeMonoid = record
{ isMonoid = ++-isMonoid
; comm = ++-comm
}
-- Bundles
++-magma : Magma a (a ⊔ ℓ)
++-magma = record
{ isMagma = ++-isMagma
}
++-semigroup : Semigroup a (a ⊔ ℓ)
++-semigroup = record
{ isSemigroup = ++-isSemigroup
}
++-monoid : Monoid a (a ⊔ ℓ)
++-monoid = record
{ isMonoid = ++-isMonoid
}
++-commutativeMonoid : CommutativeMonoid a (a ⊔ ℓ)
++-commutativeMonoid = record
{ isCommutativeMonoid = ++-isCommutativeMonoid
}
-- Some other useful lemmas
zoom : ∀ h {t xs ys : List A} → xs ↭ ys → h ++ xs ++ t ↭ h ++ ys ++ t
zoom h {t} = ++⁺ˡ h ∘ ++⁺ʳ t
inject : ∀ (v : A) {ws xs ys zs} → ws ↭ ys → xs ↭ zs →
ws ++ [ v ] ++ xs ↭ ys ++ [ v ] ++ zs
inject v ws↭ys xs↭zs = trans (++⁺ˡ _ (↭-prep _ xs↭zs)) (++⁺ʳ _ ws↭ys)
shifts : ∀ xs ys {zs : List A} → xs ++ ys ++ zs ↭ ys ++ xs ++ zs
shifts xs ys {zs} = begin
xs ++ ys ++ zs ↭˘⟨ ++-assoc xs ys zs ⟩
(xs ++ ys) ++ zs ↭⟨ ++⁺ʳ zs (++-comm xs ys) ⟩
(ys ++ xs) ++ zs ↭⟨ ++-assoc ys xs zs ⟩
ys ++ xs ++ zs ∎
dropMiddleElement-≋ : ∀ {x} ws xs {ys} {zs} →
ws ++ [ x ] ++ ys ≋ xs ++ [ x ] ++ zs →
ws ++ ys ↭ xs ++ zs
dropMiddleElement-≋ [] [] (_ ∷ eq) = ≋⇒↭ eq
dropMiddleElement-≋ [] (x ∷ xs) (w≈v ∷ eq) = ↭-respˡ-≋ (≋-sym eq) (shift w≈v xs _)
dropMiddleElement-≋ (w ∷ ws) [] (w≈x ∷ eq) = ↭-respʳ-≋ eq (↭-sym (shift (≈-sym w≈x) ws _))
dropMiddleElement-≋ (w ∷ ws) (x ∷ xs) (w≈x ∷ eq) = prep w≈x (dropMiddleElement-≋ ws xs eq)
dropMiddleElement : ∀ {v} ws xs {ys zs} →
ws ++ [ v ] ++ ys ↭ xs ++ [ v ] ++ zs →
ws ++ ys ↭ xs ++ zs
dropMiddleElement {v} ws xs {ys} {zs} p = helper p ws xs ≋-refl ≋-refl
where
lemma : ∀ {w x y z} → w ≈ x → x ≈ y → z ≈ y → w ≈ z
lemma w≈x x≈y z≈y = ≈-trans (≈-trans w≈x x≈y) (≈-sym z≈y)
open PermutationReasoning
-- The l′ & l″ could be eliminated at the cost of making the `trans` case
-- much more difficult to prove. At the very least would require using `Acc`.
helper : ∀ {l′ l″ : List A} → l′ ↭ l″ →
∀ ws xs {ys zs : List A} →
ws ++ [ v ] ++ ys ≋ l′ →
xs ++ [ v ] ++ zs ≋ l″ →
ws ++ ys ↭ xs ++ zs
helper {as} {bs} (refl eq3) ws xs {ys} {zs} eq1 eq2 =
dropMiddleElement-≋ ws xs (≋-trans (≋-trans eq1 eq3) (≋-sym eq2))
helper {_ ∷ as} {_ ∷ bs} (prep _ as↭bs) [] [] {ys} {zs} (_ ∷ ys≋as) (_ ∷ zs≋bs) = begin
ys ≋⟨ ys≋as ⟩
as ↭⟨ as↭bs ⟩
bs ≋˘⟨ zs≋bs ⟩
zs ∎
helper {_ ∷ as} {_ ∷ bs} (prep a≈b as↭bs) [] (x ∷ xs) {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
ys ≋⟨ ≋₁ ⟩
as ↭⟨ as↭bs ⟩
bs ≋˘⟨ ≋₂ ⟩
xs ++ v ∷ zs ↭⟨ shift (lemma ≈₁ a≈b ≈₂) xs zs ⟩
x ∷ xs ++ zs ∎
helper {_ ∷ as} {_ ∷ bs} (prep v≈w p) (w ∷ ws) [] {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
w ∷ ws ++ ys ↭⟨ ↭-sym (shift (lemma ≈₂ (≈-sym v≈w) ≈₁) ws ys) ⟩
ws ++ v ∷ ys ≋⟨ ≋₁ ⟩
as ↭⟨ p ⟩
bs ≋˘⟨ ≋₂ ⟩
zs ∎
helper {_ ∷ as} {_ ∷ bs} (prep w≈x p) (w ∷ ws) (x ∷ xs) {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
w ∷ ws ++ ys ↭⟨ prep (lemma ≈₁ w≈x ≈₂) (helper p ws xs ≋₁ ≋₂) ⟩
x ∷ xs ++ zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap v≈x y≈v p) [] [] {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
ys ≋⟨ ≋₁ ⟩
a ∷ as ↭⟨ prep (≈-trans (≈-trans (≈-trans y≈v (≈-sym ≈₂)) ≈₁) v≈x) p ⟩
b ∷ bs ≋˘⟨ ≋₂ ⟩
zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap v≈w y≈w p) [] (x ∷ []) {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
ys ≋⟨ ≋₁ ⟩
a ∷ as ↭⟨ prep y≈w p ⟩
_ ∷ bs ≋˘⟨ ≈₂ ∷ tail ≋₂ ⟩
x ∷ zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap v≈w y≈x p) [] (x ∷ w ∷ xs) {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
ys ≋⟨ ≋₁ ⟩
a ∷ as ↭⟨ prep y≈x p ⟩
_ ∷ bs ≋⟨ ≋-sym (≈₂ ∷ tail ≋₂) ⟩
x ∷ xs ++ v ∷ zs ↭⟨ prep ≈-refl (shift (lemma ≈₁ v≈w (head ≋₂)) xs zs) ⟩
x ∷ w ∷ xs ++ zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap w≈x _ p) (w ∷ []) [] {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
w ∷ ys ≋⟨ ≈₁ ∷ tail (≋₁) ⟩
_ ∷ as ↭⟨ prep w≈x p ⟩
b ∷ bs ≋⟨ ≋-sym ≋₂ ⟩
zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap w≈y x≈v p) (w ∷ x ∷ ws) [] {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
w ∷ x ∷ ws ++ ys ↭⟨ prep ≈-refl (↭-sym (shift (lemma ≈₂ (≈-sym x≈v) (head ≋₁)) ws ys)) ⟩
w ∷ ws ++ v ∷ ys ≋⟨ ≈₁ ∷ tail ≋₁ ⟩
_ ∷ as ↭⟨ prep w≈y p ⟩
b ∷ bs ≋⟨ ≋-sym ≋₂ ⟩
zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap x≈v v≈y p) (x ∷ []) (y ∷ []) {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
x ∷ ys ≋⟨ ≈₁ ∷ tail ≋₁ ⟩
_ ∷ as ↭⟨ prep (≈-trans x≈v (≈-trans (≈-sym (head ≋₂)) (≈-trans (head ≋₁) v≈y))) p ⟩
_ ∷ bs ≋⟨ ≋-sym (≈₂ ∷ tail ≋₂) ⟩
y ∷ zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap y≈w v≈z p) (y ∷ []) (z ∷ w ∷ xs) {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
y ∷ ys ≋⟨ ≈₁ ∷ tail ≋₁ ⟩
_ ∷ as ↭⟨ prep y≈w p ⟩
_ ∷ bs ≋⟨ ≋-sym ≋₂ ⟩
w ∷ xs ++ v ∷ zs ↭⟨ ↭-prep w (shift ≈-refl xs zs) ⟩
w ∷ v ∷ xs ++ zs ↭⟨ swap ≈-refl (lemma (head ≋₁) v≈z ≈₂) ↭-refl ⟩
z ∷ w ∷ xs ++ zs ∎
helper {_ ∷ a ∷ as} {_ ∷ b ∷ bs} (swap y≈v w≈z p) (y ∷ w ∷ ws) (z ∷ []) {ys} {zs} (≈₁ ∷ ≋₁) (≈₂ ∷ ≋₂) = begin
y ∷ w ∷ ws ++ ys ↭⟨ swap (lemma ≈₁ y≈v (head ≋₂)) ≈-refl ↭-refl ⟩
w ∷ v ∷ ws ++ ys ↭⟨ ↭-prep w (↭-sym (shift ≈-refl ws ys)) ⟩
w ∷ ws ++ v ∷ ys ≋⟨ ≋₁ ⟩
_ ∷ as ↭⟨ prep w≈z p ⟩
_ ∷ bs ≋⟨ ≋-sym (≈₂ ∷ tail ≋₂) ⟩
z ∷ zs ∎
helper (swap x≈z y≈w p) (x ∷ y ∷ ws) (w ∷ z ∷ xs) {ys} {zs} (≈₁ ∷ ≈₃ ∷ ≋₁) (≈₂ ∷ ≈₄ ∷ ≋₂) = begin
x ∷ y ∷ ws ++ ys ↭⟨ swap (lemma ≈₁ x≈z ≈₄) (lemma ≈₃ y≈w ≈₂) (helper p ws xs ≋₁ ≋₂) ⟩
w ∷ z ∷ xs ++ zs ∎
helper {as} {bs} (trans p₁ p₂) ws xs eq1 eq2
with ∈-∃++ S (∈-resp-↭ (↭-respˡ-≋ (≋-sym eq1) p₁) (∈-insert S ws ≈-refl))
... | (h , t , w , v≈w , eq) = trans
(helper p₁ ws h eq1 (≋-trans (≋.++⁺ ≋-refl (v≈w ∷ ≋-refl)) (≋-sym eq)))
(helper p₂ h xs (≋-trans (≋.++⁺ ≋-refl (v≈w ∷ ≋-refl)) (≋-sym eq)) eq2)
dropMiddle : ∀ {vs} ws xs {ys zs} →
ws ++ vs ++ ys ↭ xs ++ vs ++ zs →
ws ++ ys ↭ xs ++ zs
dropMiddle {[]} ws xs p = p
dropMiddle {v ∷ vs} ws xs p = dropMiddle ws xs (dropMiddleElement ws xs p)
split : ∀ (v : A) as bs {xs} → xs ↭ as ++ [ v ] ++ bs → ∃₂ λ ps qs → xs ≋ ps ++ [ v ] ++ qs
split v as bs p = helper as bs p (<-wellFounded (steps p))
where
helper : ∀ as bs {xs} (p : xs ↭ as ++ [ v ] ++ bs) → Acc _<_ (steps p) →
∃₂ λ ps qs → xs ≋ ps ++ [ v ] ++ qs
helper [] bs (refl eq) _ = [] , bs , eq
helper (a ∷ []) bs (refl eq) _ = [ a ] , bs , eq
helper (a ∷ b ∷ as) bs (refl eq) _ = a ∷ b ∷ as , bs , eq
helper [] bs (prep v≈x _) _ = [] , _ , v≈x ∷ ≋-refl
helper (a ∷ as) bs (prep eq as↭xs) (acc rec) with helper as bs as↭xs (rec _ ≤-refl)
... | (ps , qs , eq₂) = a ∷ ps , qs , eq ∷ eq₂
helper [] (b ∷ bs) (swap x≈b y≈v _) _ = [ b ] , _ , x≈b ∷ y≈v ∷ ≋-refl
helper (a ∷ []) bs (swap x≈v y≈a ↭) _ = [] , a ∷ _ , x≈v ∷ y≈a ∷ ≋-refl
helper (a ∷ b ∷ as) bs (swap x≈b y≈a as↭xs) (acc rec) with helper as bs as↭xs (rec _ ≤-refl)
... | (ps , qs , eq) = b ∷ a ∷ ps , qs , x≈b ∷ y≈a ∷ eq
helper as bs (trans ↭₁ ↭₂) (acc rec) with helper as bs ↭₂ (rec _ (m<n+m (steps ↭₂) (0<steps ↭₁)))
... | (ps , qs , eq) = helper ps qs (↭-respʳ-≋ eq ↭₁)
(rec _ (subst (_< _) (sym (steps-respʳ eq ↭₁)) (m<m+n (steps ↭₁) (0<steps ↭₂))))
------------------------------------------------------------------------
-- filter
module _ {p} {P : Pred A p} (P? : Decidable P) (P≈ : P Respects _≈_) where
filter⁺ : ∀ {xs ys : List A} → xs ↭ ys → filter P? xs ↭ filter P? ys
filter⁺ (refl xs≋ys) = refl (≋.filter⁺ P? P≈ xs≋ys)
filter⁺ (trans xs↭zs zs↭ys) = trans (filter⁺ xs↭zs) (filter⁺ zs↭ys)
filter⁺ {x ∷ xs} {y ∷ ys} (prep x≈y xs↭ys) with P? x | P? y
... | yes _ | yes _ = prep x≈y (filter⁺ xs↭ys)
... | yes Px | no ¬Py = contradiction (P≈ x≈y Px) ¬Py
... | no ¬Px | yes Py = contradiction (P≈ (≈-sym x≈y) Py) ¬Px
... | no _ | no _ = filter⁺ xs↭ys
filter⁺ {x ∷ w ∷ xs} {y ∷ z ∷ ys} (swap x≈z w≈y xs↭ys) with P? x | P? y
filter⁺ {x ∷ w ∷ xs} {y ∷ z ∷ ys} (swap x≈z w≈y xs↭ys) | no ¬Px | no ¬Py
with P? z | P? w
... | _ | yes Pw = contradiction (P≈ w≈y Pw) ¬Py
... | yes Pz | _ = contradiction (P≈ (≈-sym x≈z) Pz) ¬Px
... | no _ | no _ = filter⁺ xs↭ys
filter⁺ {x ∷ w ∷ xs} {y ∷ z ∷ ys} (swap x≈z w≈y xs↭ys) | no ¬Px | yes Py
with P? z | P? w
... | _ | no ¬Pw = contradiction (P≈ (≈-sym w≈y) Py) ¬Pw
... | yes Pz | _ = contradiction (P≈ (≈-sym x≈z) Pz) ¬Px
... | no _ | yes _ = prep w≈y (filter⁺ xs↭ys)
filter⁺ {x ∷ w ∷ xs} {y ∷ z ∷ ys} (swap x≈z w≈y xs↭ys) | yes Px | no ¬Py
with P? z | P? w
... | no ¬Pz | _ = contradiction (P≈ x≈z Px) ¬Pz
... | _ | yes Pw = contradiction (P≈ w≈y Pw) ¬Py
... | yes _ | no _ = prep x≈z (filter⁺ xs↭ys)
filter⁺ {x ∷ w ∷ xs} {y ∷ z ∷ ys} (swap x≈z w≈y xs↭ys) | yes Px | yes Py
with P? z | P? w
... | no ¬Pz | _ = contradiction (P≈ x≈z Px) ¬Pz
... | _ | no ¬Pw = contradiction (P≈ (≈-sym w≈y) Py) ¬Pw
... | yes _ | yes _ = swap x≈z w≈y (filter⁺ xs↭ys)
------------------------------------------------------------------------
-- _∷ʳ_
∷↭∷ʳ : ∀ (x : A) xs → x ∷ xs ↭ xs ∷ʳ x
∷↭∷ʳ x xs = ↭-sym (begin
xs ++ [ x ] ↭⟨ shift ≈-refl xs [] ⟩
x ∷ xs ++ [] ≡⟨ Lₚ.++-identityʳ _ ⟩
x ∷ xs ∎)
where open PermutationReasoning
| {
"alphanum_fraction": 0.4673985877,
"avg_line_length": 44.0931818182,
"ext": "agda",
"hexsha": "49d502b1c3c27a2064787cecb78c97b1c7589740",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Setoid/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Setoid/Properties.agda",
"max_line_length": 133,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Permutation/Setoid/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 8790,
"size": 19401
} |
module L.Base.Nat.Properties where
open import L.Base.Nat
open import L.Base.Id.Core
open import L.Base.Id.Properties using (ap;sym;transport)
-- Properties of +
+-idl : ∀{x} → zero + x ≡ x
+-idl = refl
+-idr : ∀{x} → x + zero ≡ x
+-idr {x} = ind (λ n → n + zero ≡ n) refl (λ _ p → ap succ p) x
+-assoc : {x y z : Nat} → (x + y) + z ≡ x + (y + z)
+-assoc {x}{y}{z} = ind (λ n → (n + y) + z ≡ n + (y + z))
refl (λ _ p → ap succ p) x
+-succ : {x y : Nat} → x + succ y ≡ succ (x + y)
+-succ {x}{y} = ind (λ n → n + succ y ≡ succ (n + y)) refl (λ _ p → ap succ p) x
+-comm : {x y : Nat} → x + y ≡ y + x
+-comm {x}{y} = ind (λ n → n + y ≡ y + n) (sym +-idr) (λ n p → sym
(transport (λ q → y + succ n ≡ succ q) (sym p) +-succ)) x
-- Properties of *
*-zl : ∀{x} → zero * x ≡ zero
*-zl = refl
*-zr : ∀{x} → x * zero ≡ zero
*-zr {x} = ind (λ n → n * zero ≡ zero) refl (λ _ p → p) x
*-idl : ∀{x} → 1 * x ≡ x
*-idl = +-idr
*-idr : ∀{x} → x * 1 ≡ x
*-idr {x} = ind (λ n → n * 1 ≡ n) refl (λ _ p → ap succ p) x
*-distrib-+ : {x y z : Nat} → (x + y) * z ≡ x * z + y * z
*-distrib-+ {x}{y}{z} = ind (λ n → (n + y) * z ≡ n * z + y * z) refl
(λ m p → transport (λ s → z + (m + y) * z ≡ s)
(sym (+-assoc {z} {m * z} {y * z}))
(ap (λ k → z + k) p)) x
*-assoc : {x y z : Nat} → (x * y) * z ≡ x * (y * z)
*-assoc {x}{y}{z} = ind (λ n → (n * y) * z ≡ n * (y * z)) refl (λ n p
→ transport (λ q → (y + n * y) * z ≡ y * z + q) p
(*-distrib-+ {y}{n * y})) x
| {
"alphanum_fraction": 0.4032869785,
"avg_line_length": 32.9583333333,
"ext": "agda",
"hexsha": "f63c90931e2caaead9c9381f9393af09cd01f4ea",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "borszag/smallib",
"max_forks_repo_path": "src/L/Base/Nat/Properties.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "borszag/smallib",
"max_issues_repo_path": "src/L/Base/Nat/Properties.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "borszag/smallib",
"max_stars_repo_path": "src/L/Base/Nat/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 689,
"size": 1582
} |
-- Andreas, 2017-01-12, issue #2386
open import Agda.Primitive
data _≡_ {a b} {A : Set (a ⊔ b)} : (x y : A) → Set where
refl : (x : A) → x ≡ x
{-# BUILTIN EQUALITY _≡_ #-}
-- Should be accepted
-- The type of primErase has to match the flavor of EQUALITY
primitive primEraseEquality : ∀ {a b}{A : Set (a ⊔ b)} {x y : A} → _≡_ x y → _≡_ x y
testTM : ∀ {a b} {A : Set (a ⊔ b)} {x : A} (eq : _≡_ {a} {b} x x) → primEraseEquality {x = x} {y = x} eq ≡ refl _
testTM _ = refl _
-- Testing rewrite
subst : ∀{ℓ}{A : Set ℓ} {P : A → Set}{a b : A} → _≡_ {a = ℓ} {b = ℓ} a b → P a → P b
subst eq p rewrite eq = p
| {
"alphanum_fraction": 0.5415986949,
"avg_line_length": 26.652173913,
"ext": "agda",
"hexsha": "8dee4c7fd1fe96e9abfbbdabd48c21316ca188a7",
"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/Issue2386BuiltinEqualityUniverseLub.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/Issue2386BuiltinEqualityUniverseLub.agda",
"max_line_length": 113,
"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/Issue2386BuiltinEqualityUniverseLub.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": 267,
"size": 613
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.AbGroup.Instances.DirectSumHIT where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.DirectSum.DirectSumHIT.Base
open import Cubical.Algebra.DirectSum.DirectSumHIT.Properties
private variable
ℓ ℓ' : Level
module _ (Idx : Type ℓ) (P : Idx → Type ℓ') (AGP : (r : Idx) → AbGroupStr (P r)) where
open AbGroupStr
open AbGroupProperties Idx P AGP
⊕HIT-AbGr : AbGroup (ℓ-max ℓ ℓ')
fst ⊕HIT-AbGr = ⊕HIT Idx P AGP
0g (snd ⊕HIT-AbGr) = neutral
_+_ (snd ⊕HIT-AbGr) = _add_
- snd ⊕HIT-AbGr = inv
isAbGroup (snd ⊕HIT-AbGr) = makeIsAbGroup trunc addAssoc addRid rinv addComm
| {
"alphanum_fraction": 0.7223837209,
"avg_line_length": 27.52,
"ext": "agda",
"hexsha": "63699f140db011612b30a8a11fd839628f181775",
"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/AbGroup/Instances/DirectSumHIT.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/AbGroup/Instances/DirectSumHIT.agda",
"max_line_length": 86,
"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/AbGroup/Instances/DirectSumHIT.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 252,
"size": 688
} |
open import Agda.Primitive
open import Agda.Builtin.Equality
variable
ℓ : Level
A : Set ℓ
P : A → Set ℓ
x y : A
f : (x : A) → P x
cong : x ≡ y → f x ≡ f y
cong refl = refl
| {
"alphanum_fraction": 0.5783783784,
"avg_line_length": 13.2142857143,
"ext": "agda",
"hexsha": "5de7b258c451deccab10c0212a64fd4c553a2b55",
"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/Issue3340.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/Issue3340.agda",
"max_line_length": 33,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue3340.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": 80,
"size": 185
} |
------------------------------------------------------------------------
-- Descending lists
------------------------------------------------------------------------
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Foundations.Everything
module Cubical.Data.DescendingList.Base
(A : Type₀)
(_≥_ : A → A → Type₀)
where
------------------------------------------------------------------------
-- Descending lists
--
-- Defined simultaneously with the relation "x ≥ the HEAD of u"
data DL : Type₀
data _≥ᴴ_ (x : A) : DL → Type₀
data DL where
[] : DL
cons : (x : A) (u : DL) → x ≥ᴴ u → DL
data _≥ᴴ_ x where
≥ᴴ[] : x ≥ᴴ []
≥ᴴcons : {y : A} {u : DL} {r : y ≥ᴴ u}
→ x ≥ y → x ≥ᴴ (cons y u r)
[_] : A → DL
[ x ] = cons x [] ≥ᴴ[]
| {
"alphanum_fraction": 0.3976683938,
"avg_line_length": 22.7058823529,
"ext": "agda",
"hexsha": "a47285f7124dce0afa11ae5fb3db9fb2b5cf1db2",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/DescendingList/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/DescendingList/Base.agda",
"max_line_length": 72,
"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/DescendingList/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 227,
"size": 772
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- A categorical view of Covec
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Covec.Categorical where
open import Codata.Conat
open import Codata.Covec
open import Category.Functor
open import Category.Applicative
functor : ∀ {ℓ i n} → RawFunctor {ℓ} (λ A → Covec A n i)
functor = record { _<$>_ = map }
applicative : ∀ {ℓ i n} → RawApplicative {ℓ} (λ A → Covec A n i)
applicative = record
{ pure = replicate _
; _⊛_ = ap
}
| {
"alphanum_fraction": 0.5166402536,
"avg_line_length": 25.24,
"ext": "agda",
"hexsha": "1ec6629994098539eaf7ba3dc8109cfba7366fa3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/Covec/Categorical.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/Covec/Categorical.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/Covec/Categorical.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": 161,
"size": 631
} |
{-# OPTIONS --without-K --exact-split --safe #-}
open import Fragment.Equational.Theory.Base
module Fragment.Equational.Theory.Combinators (Θ : Theory) where
open import Fragment.Algebra.Signature
open import Fragment.Algebra.Properties
open import Fragment.Equational.Model
using (Model; IsModel; Models)
open import Fragment.Equational.Model.Satisfaction
open import Level using (Level)
open import Function using (_∘_)
open import Data.Nat using (ℕ)
private
variable
a ℓ : Level
{-
forgetₒ' : ∀ {O} → Model (Θ ⦅ O ⦆ₒ) {a} {ℓ} → Model Θ {a} {ℓ}
forgetₒ' {O = O} A =
record { ∥_∥/≈ = ∥ A ∥/≈
; isModel = forget-isModel
}
where open import Fragment.Equational.Model (Θ ⦅ O ⦆ₒ)
using (∥_∥/≈; ∥_∥ₐ; ∥_∥ₐ-models)
open import Fragment.Algebra.Algebra (Σ Θ)
using (∥_∥/≈-isAlgebra)
forget-⊨ : ∀ {θ eq} → ∥ A ∥ₐ ⊨⟨ θ ⟩ ((Θ ⦅ O ⦆ₒ) ⟦ {!oldₑ!} ⟧ₑ)
→ forgetₒ ∥ A ∥ₐ ⊨⟨ θ ⟩ (Θ ⟦ eq ⟧ₑ)
forget-⊨ = {!!}
forget-models : Models Θ (forgetₒ ∥ A ∥ₐ)
forget-models eq θ = {!!}
forget-isModel : IsModel Θ ∥ A ∥/≈
forget-isModel =
record { isAlgebra = ∥ (forgetₒ ∥ A ∥ₐ) ∥/≈-isAlgebra
; models = forget-models
}
forgetₑ : ∀ {O E}
→ {X : ∀ {n} → E n → Eq ((Σ Θ) ⦅ O ⦆) n}
→ Model (Θ ⦅ O ∣ E / X ⦆) {a} {ℓ}
→ Model Θ {a} {ℓ}
forgetₑ {O = O} {E} {X} A =
record { ∥_∥/≈ = {!!}
; isModel = {!!}
}
-}
data HomOp : ℕ → Set where
h : HomOp 1
data HomEq : ℕ → Set where
hom : ∀ {n} → ops (Σ Θ) n → HomEq n
AddHom : Theory
AddHom = Θ ⦅ HomOp ∣ HomEq / hom' ⦆
where import Fragment.Equational.Theory.Laws ((Σ Θ) ⦅ HomOp ⦆) as L
hom' : ∀ {arity} → HomEq arity → Eq ((Σ Θ) ⦅ HomOp ⦆) arity
hom' (hom f) = L.hom (newₒ h) (oldₒ f)
data IdOp : ℕ → Set where
α : IdOp 0
data IdEq : ℕ → Set where
idₗ : IdEq 1
idᵣ : IdEq 1
AddId : ops (Σ Θ) 2 → Theory
AddId • = Θ ⦅ IdOp ∣ IdEq / id ⦆
where import Fragment.Equational.Theory.Laws ((Σ Θ) ⦅ IdOp ⦆) as L
id : ∀ {arity} → IdEq arity → Eq ((Σ Θ) ⦅ IdOp ⦆) arity
id idₗ = L.idₗ (newₒ α) (oldₒ •)
id idᵣ = L.idᵣ (newₒ α) (oldₒ •)
data AnOp : ℕ → Set where
ω : AnOp 0
data AnEq : ℕ → Set where
anₗ : AnEq 1
anᵣ : AnEq 1
AddAn : ops (Σ Θ) 2 → Theory
AddAn • = Θ ⦅ AnOp ∣ AnEq / an ⦆
where import Fragment.Equational.Theory.Laws ((Σ Θ) ⦅ AnOp ⦆) as L
an : ∀ {arity} → AnEq arity → Eq ((Σ Θ) ⦅ AnOp ⦆) arity
an anₗ = L.anₗ (newₒ ω) (oldₒ •)
an anᵣ = L.anᵣ (newₒ ω) (oldₒ •)
| {
"alphanum_fraction": 0.5284242655,
"avg_line_length": 26.7448979592,
"ext": "agda",
"hexsha": "d2c7a13898c6de8e97538bbb5002dfea729d038a",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z",
"max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "yallop/agda-fragment",
"max_forks_repo_path": "src/Fragment/Equational/Theory/Combinators.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "yallop/agda-fragment",
"max_issues_repo_path": "src/Fragment/Equational/Theory/Combinators.agda",
"max_line_length": 70,
"max_stars_count": 18,
"max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yallop/agda-fragment",
"max_stars_repo_path": "src/Fragment/Equational/Theory/Combinators.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z",
"num_tokens": 1131,
"size": 2621
} |
{-# OPTIONS --type-in-type #-}
Ty : Set
Ty =
(Ty : Set)
(nat top bot : Ty)
(arr prod sum : Ty → Ty → Ty)
→ Ty
nat : Ty; nat = λ _ nat _ _ _ _ _ → nat
top : Ty; top = λ _ _ top _ _ _ _ → top
bot : Ty; bot = λ _ _ _ bot _ _ _ → bot
arr : Ty → Ty → Ty; arr
= λ A B Ty nat top bot arr prod sum →
arr (A Ty nat top bot arr prod sum) (B Ty nat top bot arr prod sum)
prod : Ty → Ty → Ty; prod
= λ A B Ty nat top bot arr prod sum →
prod (A Ty nat top bot arr prod sum) (B Ty nat top bot arr prod sum)
sum : Ty → Ty → Ty; sum
= λ A B Ty nat top bot arr prod sum →
sum (A Ty nat top bot arr prod sum) (B Ty nat top bot arr prod sum)
Con : Set; Con
= (Con : Set)
(nil : Con)
(snoc : Con → Ty → Con)
→ Con
nil : Con; nil
= λ Con nil snoc → nil
snoc : Con → Ty → Con; snoc
= λ Γ A Con nil snoc → snoc (Γ Con nil snoc) A
Var : Con → Ty → Set; Var
= λ Γ A →
(Var : Con → Ty → Set)
(vz : ∀{Γ A} → Var (snoc Γ A) A)
(vs : ∀{Γ B A} → Var Γ A → Var (snoc Γ B) A)
→ Var Γ A
vz : ∀{Γ A} → Var (snoc Γ A) A; vz
= λ Var vz vs → vz
vs : ∀{Γ B A} → Var Γ A → Var (snoc Γ B) A; vs
= λ x Var vz vs → vs (x Var vz vs)
Tm : Con → Ty → Set; Tm
= λ Γ A →
(Tm : Con → Ty → Set)
(var : ∀{Γ A} → Var Γ A → Tm Γ A)
(lam : ∀{Γ A B} → Tm (snoc Γ A) B → Tm Γ (arr A B))
(app : ∀{Γ A B} → Tm Γ (arr A B) → Tm Γ A → Tm Γ B)
(tt : ∀{Γ} → Tm Γ top)
(pair : ∀{Γ A B} → Tm Γ A → Tm Γ B → Tm Γ (prod A B))
(fst : ∀{Γ A B} → Tm Γ (prod A B) → Tm Γ A)
(snd : ∀{Γ A B} → Tm Γ (prod A B) → Tm Γ B)
(left : ∀{Γ A B} → Tm Γ A → Tm Γ (sum A B))
(right : ∀{Γ A B} → Tm Γ B → Tm Γ (sum A B))
(case : ∀{Γ A B C} → Tm Γ (sum A B) → Tm Γ (arr A C) → Tm Γ (arr B C) → Tm Γ C)
(zero : ∀{Γ} → Tm Γ nat)
(suc : ∀{Γ} → Tm Γ nat → Tm Γ nat)
(rec : ∀{Γ A} → Tm Γ nat → Tm Γ (arr nat (arr A A)) → Tm Γ A → Tm Γ A)
→ Tm Γ A
var : ∀{Γ A} → Var Γ A → Tm Γ A; var
= λ x Tm var lam app tt pair fst snd left right case zero suc rec →
var x
lam : ∀{Γ A B} → Tm (snoc Γ A) B → Tm Γ (arr A B); lam
= λ t Tm var lam app tt pair fst snd left right case zero suc rec →
lam (t Tm var lam app tt pair fst snd left right case zero suc rec)
app : ∀{Γ A B} → Tm Γ (arr A B) → Tm Γ A → Tm Γ B; app
= λ t u Tm var lam app tt pair fst snd left right case zero suc rec →
app (t Tm var lam app tt pair fst snd left right case zero suc rec)
(u Tm var lam app tt pair fst snd left right case zero suc rec)
tt : ∀{Γ} → Tm Γ top; tt
= λ Tm var lam app tt pair fst snd left right case zero suc rec → tt
pair : ∀{Γ A B} → Tm Γ A → Tm Γ B → Tm Γ (prod A B); pair
= λ t u Tm var lam app tt pair fst snd left right case zero suc rec →
pair (t Tm var lam app tt pair fst snd left right case zero suc rec)
(u Tm var lam app tt pair fst snd left right case zero suc rec)
fst : ∀{Γ A B} → Tm Γ (prod A B) → Tm Γ A; fst
= λ t Tm var lam app tt pair fst snd left right case zero suc rec →
fst (t Tm var lam app tt pair fst snd left right case zero suc rec)
snd : ∀{Γ A B} → Tm Γ (prod A B) → Tm Γ B; snd
= λ t Tm var lam app tt pair fst snd left right case zero suc rec →
snd (t Tm var lam app tt pair fst snd left right case zero suc rec)
left : ∀{Γ A B} → Tm Γ A → Tm Γ (sum A B); left
= λ t Tm var lam app tt pair fst snd left right case zero suc rec →
left (t Tm var lam app tt pair fst snd left right case zero suc rec)
right : ∀{Γ A B} → Tm Γ B → Tm Γ (sum A B); right
= λ t Tm var lam app tt pair fst snd left right case zero suc rec →
right (t Tm var lam app tt pair fst snd left right case zero suc rec)
case : ∀{Γ A B C} → Tm Γ (sum A B) → Tm Γ (arr A C) → Tm Γ (arr B C) → Tm Γ C; case
= λ t u v Tm var lam app tt pair fst snd left right case zero suc rec →
case (t Tm var lam app tt pair fst snd left right case zero suc rec)
(u Tm var lam app tt pair fst snd left right case zero suc rec)
(v Tm var lam app tt pair fst snd left right case zero suc rec)
zero : ∀{Γ} → Tm Γ nat; zero
= λ Tm var lam app tt pair fst snd left right case zero suc rec → zero
suc : ∀{Γ} → Tm Γ nat → Tm Γ nat; suc
= λ t Tm var lam app tt pair fst snd left right case zero suc rec →
suc (t Tm var lam app tt pair fst snd left right case zero suc rec)
rec : ∀{Γ A} → Tm Γ nat → Tm Γ (arr nat (arr A A)) → Tm Γ A → Tm Γ A; rec
= λ t u v Tm var lam app tt pair fst snd left right case zero suc rec →
rec (t Tm var lam app tt pair fst snd left right case zero suc rec)
(u Tm var lam app tt pair fst snd left right case zero suc rec)
(v Tm var lam app tt pair fst snd left right case zero suc rec)
v0 : ∀{Γ A} → Tm (snoc Γ A) A; v0
= var vz
v1 : ∀{Γ A B} → Tm (snoc (snoc Γ A) B) A; v1
= var (vs vz)
v2 : ∀{Γ A B C} → Tm (snoc (snoc (snoc Γ A) B) C) A; v2
= var (vs (vs vz))
v3 : ∀{Γ A B C D} → Tm (snoc (snoc (snoc (snoc Γ A) B) C) D) A; v3
= var (vs (vs (vs vz)))
tbool : Ty; tbool
= sum top top
true : ∀{Γ} → Tm Γ tbool; true
= left tt
tfalse : ∀{Γ} → Tm Γ tbool; tfalse
= right tt
ifthenelse : ∀{Γ A} → Tm Γ (arr tbool (arr A (arr A A))); ifthenelse
= lam (lam (lam (case v2 (lam v2) (lam v1))))
times4 : ∀{Γ A} → Tm Γ (arr (arr A A) (arr A A)); times4
= lam (lam (app v1 (app v1 (app v1 (app v1 v0)))))
add : ∀{Γ} → Tm Γ (arr nat (arr nat nat)); add
= lam (rec v0
(lam (lam (lam (suc (app v1 v0)))))
(lam v0))
mul : ∀{Γ} → Tm Γ (arr nat (arr nat nat)); mul
= lam (rec v0
(lam (lam (lam (app (app add (app v1 v0)) v0))))
(lam zero))
fact : ∀{Γ} → Tm Γ (arr nat nat); fact
= lam (rec v0 (lam (lam (app (app mul (suc v1)) v0)))
(suc zero))
{-# OPTIONS --type-in-type #-}
Ty1 : Set
Ty1 =
(Ty1 : Set)
(nat top bot : Ty1)
(arr prod sum : Ty1 → Ty1 → Ty1)
→ Ty1
nat1 : Ty1; nat1 = λ _ nat1 _ _ _ _ _ → nat1
top1 : Ty1; top1 = λ _ _ top1 _ _ _ _ → top1
bot1 : Ty1; bot1 = λ _ _ _ bot1 _ _ _ → bot1
arr1 : Ty1 → Ty1 → Ty1; arr1
= λ A B Ty1 nat1 top1 bot1 arr1 prod sum →
arr1 (A Ty1 nat1 top1 bot1 arr1 prod sum) (B Ty1 nat1 top1 bot1 arr1 prod sum)
prod1 : Ty1 → Ty1 → Ty1; prod1
= λ A B Ty1 nat1 top1 bot1 arr1 prod1 sum →
prod1 (A Ty1 nat1 top1 bot1 arr1 prod1 sum) (B Ty1 nat1 top1 bot1 arr1 prod1 sum)
sum1 : Ty1 → Ty1 → Ty1; sum1
= λ A B Ty1 nat1 top1 bot1 arr1 prod1 sum1 →
sum1 (A Ty1 nat1 top1 bot1 arr1 prod1 sum1) (B Ty1 nat1 top1 bot1 arr1 prod1 sum1)
Con1 : Set; Con1
= (Con1 : Set)
(nil : Con1)
(snoc : Con1 → Ty1 → Con1)
→ Con1
nil1 : Con1; nil1
= λ Con1 nil1 snoc → nil1
snoc1 : Con1 → Ty1 → Con1; snoc1
= λ Γ A Con1 nil1 snoc1 → snoc1 (Γ Con1 nil1 snoc1) A
Var1 : Con1 → Ty1 → Set; Var1
= λ Γ A →
(Var1 : Con1 → Ty1 → Set)
(vz : ∀{Γ A} → Var1 (snoc1 Γ A) A)
(vs : ∀{Γ B A} → Var1 Γ A → Var1 (snoc1 Γ B) A)
→ Var1 Γ A
vz1 : ∀{Γ A} → Var1 (snoc1 Γ A) A; vz1
= λ Var1 vz1 vs → vz1
vs1 : ∀{Γ B A} → Var1 Γ A → Var1 (snoc1 Γ B) A; vs1
= λ x Var1 vz1 vs1 → vs1 (x Var1 vz1 vs1)
Tm1 : Con1 → Ty1 → Set; Tm1
= λ Γ A →
(Tm1 : Con1 → Ty1 → Set)
(var : ∀{Γ A} → Var1 Γ A → Tm1 Γ A)
(lam : ∀{Γ A B} → Tm1 (snoc1 Γ A) B → Tm1 Γ (arr1 A B))
(app : ∀{Γ A B} → Tm1 Γ (arr1 A B) → Tm1 Γ A → Tm1 Γ B)
(tt : ∀{Γ} → Tm1 Γ top1)
(pair : ∀{Γ A B} → Tm1 Γ A → Tm1 Γ B → Tm1 Γ (prod1 A B))
(fst : ∀{Γ A B} → Tm1 Γ (prod1 A B) → Tm1 Γ A)
(snd : ∀{Γ A B} → Tm1 Γ (prod1 A B) → Tm1 Γ B)
(left : ∀{Γ A B} → Tm1 Γ A → Tm1 Γ (sum1 A B))
(right : ∀{Γ A B} → Tm1 Γ B → Tm1 Γ (sum1 A B))
(case : ∀{Γ A B C} → Tm1 Γ (sum1 A B) → Tm1 Γ (arr1 A C) → Tm1 Γ (arr1 B C) → Tm1 Γ C)
(zero : ∀{Γ} → Tm1 Γ nat1)
(suc : ∀{Γ} → Tm1 Γ nat1 → Tm1 Γ nat1)
(rec : ∀{Γ A} → Tm1 Γ nat1 → Tm1 Γ (arr1 nat1 (arr1 A A)) → Tm1 Γ A → Tm1 Γ A)
→ Tm1 Γ A
var1 : ∀{Γ A} → Var1 Γ A → Tm1 Γ A; var1
= λ x Tm1 var1 lam app tt pair fst snd left right case zero suc rec →
var1 x
lam1 : ∀{Γ A B} → Tm1 (snoc1 Γ A) B → Tm1 Γ (arr1 A B); lam1
= λ t Tm1 var1 lam1 app tt pair fst snd left right case zero suc rec →
lam1 (t Tm1 var1 lam1 app tt pair fst snd left right case zero suc rec)
app1 : ∀{Γ A B} → Tm1 Γ (arr1 A B) → Tm1 Γ A → Tm1 Γ B; app1
= λ t u Tm1 var1 lam1 app1 tt pair fst snd left right case zero suc rec →
app1 (t Tm1 var1 lam1 app1 tt pair fst snd left right case zero suc rec)
(u Tm1 var1 lam1 app1 tt pair fst snd left right case zero suc rec)
tt1 : ∀{Γ} → Tm1 Γ top1; tt1
= λ Tm1 var1 lam1 app1 tt1 pair fst snd left right case zero suc rec → tt1
pair1 : ∀{Γ A B} → Tm1 Γ A → Tm1 Γ B → Tm1 Γ (prod1 A B); pair1
= λ t u Tm1 var1 lam1 app1 tt1 pair1 fst snd left right case zero suc rec →
pair1 (t Tm1 var1 lam1 app1 tt1 pair1 fst snd left right case zero suc rec)
(u Tm1 var1 lam1 app1 tt1 pair1 fst snd left right case zero suc rec)
fst1 : ∀{Γ A B} → Tm1 Γ (prod1 A B) → Tm1 Γ A; fst1
= λ t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd left right case zero suc rec →
fst1 (t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd left right case zero suc rec)
snd1 : ∀{Γ A B} → Tm1 Γ (prod1 A B) → Tm1 Γ B; snd1
= λ t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left right case zero suc rec →
snd1 (t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left right case zero suc rec)
left1 : ∀{Γ A B} → Tm1 Γ A → Tm1 Γ (sum1 A B); left1
= λ t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right case zero suc rec →
left1 (t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right case zero suc rec)
right1 : ∀{Γ A B} → Tm1 Γ B → Tm1 Γ (sum1 A B); right1
= λ t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case zero suc rec →
right1 (t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case zero suc rec)
case1 : ∀{Γ A B C} → Tm1 Γ (sum1 A B) → Tm1 Γ (arr1 A C) → Tm1 Γ (arr1 B C) → Tm1 Γ C; case1
= λ t u v Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero suc rec →
case1 (t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero suc rec)
(u Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero suc rec)
(v Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero suc rec)
zero1 : ∀{Γ} → Tm1 Γ nat1; zero1
= λ Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero1 suc rec → zero1
suc1 : ∀{Γ} → Tm1 Γ nat1 → Tm1 Γ nat1; suc1
= λ t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero1 suc1 rec →
suc1 (t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero1 suc1 rec)
rec1 : ∀{Γ A} → Tm1 Γ nat1 → Tm1 Γ (arr1 nat1 (arr1 A A)) → Tm1 Γ A → Tm1 Γ A; rec1
= λ t u v Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero1 suc1 rec1 →
rec1 (t Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero1 suc1 rec1)
(u Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero1 suc1 rec1)
(v Tm1 var1 lam1 app1 tt1 pair1 fst1 snd1 left1 right1 case1 zero1 suc1 rec1)
v01 : ∀{Γ A} → Tm1 (snoc1 Γ A) A; v01
= var1 vz1
v11 : ∀{Γ A B} → Tm1 (snoc1 (snoc1 Γ A) B) A; v11
= var1 (vs1 vz1)
v21 : ∀{Γ A B C} → Tm1 (snoc1 (snoc1 (snoc1 Γ A) B) C) A; v21
= var1 (vs1 (vs1 vz1))
v31 : ∀{Γ A B C D} → Tm1 (snoc1 (snoc1 (snoc1 (snoc1 Γ A) B) C) D) A; v31
= var1 (vs1 (vs1 (vs1 vz1)))
tbool1 : Ty1; tbool1
= sum1 top1 top1
true1 : ∀{Γ} → Tm1 Γ tbool1; true1
= left1 tt1
tfalse1 : ∀{Γ} → Tm1 Γ tbool1; tfalse1
= right1 tt1
ifthenelse1 : ∀{Γ A} → Tm1 Γ (arr1 tbool1 (arr1 A (arr1 A A))); ifthenelse1
= lam1 (lam1 (lam1 (case1 v21 (lam1 v21) (lam1 v11))))
times41 : ∀{Γ A} → Tm1 Γ (arr1 (arr1 A A) (arr1 A A)); times41
= lam1 (lam1 (app1 v11 (app1 v11 (app1 v11 (app1 v11 v01)))))
add1 : ∀{Γ} → Tm1 Γ (arr1 nat1 (arr1 nat1 nat1)); add1
= lam1 (rec1 v01
(lam1 (lam1 (lam1 (suc1 (app1 v11 v01)))))
(lam1 v01))
mul1 : ∀{Γ} → Tm1 Γ (arr1 nat1 (arr1 nat1 nat1)); mul1
= lam1 (rec1 v01
(lam1 (lam1 (lam1 (app1 (app1 add1 (app1 v11 v01)) v01))))
(lam1 zero1))
fact1 : ∀{Γ} → Tm1 Γ (arr1 nat1 nat1); fact1
= lam1 (rec1 v01 (lam1 (lam1 (app1 (app1 mul1 (suc1 v11)) v01)))
(suc1 zero1))
{-# OPTIONS --type-in-type #-}
Ty2 : Set
Ty2 =
(Ty2 : Set)
(nat top bot : Ty2)
(arr prod sum : Ty2 → Ty2 → Ty2)
→ Ty2
nat2 : Ty2; nat2 = λ _ nat2 _ _ _ _ _ → nat2
top2 : Ty2; top2 = λ _ _ top2 _ _ _ _ → top2
bot2 : Ty2; bot2 = λ _ _ _ bot2 _ _ _ → bot2
arr2 : Ty2 → Ty2 → Ty2; arr2
= λ A B Ty2 nat2 top2 bot2 arr2 prod sum →
arr2 (A Ty2 nat2 top2 bot2 arr2 prod sum) (B Ty2 nat2 top2 bot2 arr2 prod sum)
prod2 : Ty2 → Ty2 → Ty2; prod2
= λ A B Ty2 nat2 top2 bot2 arr2 prod2 sum →
prod2 (A Ty2 nat2 top2 bot2 arr2 prod2 sum) (B Ty2 nat2 top2 bot2 arr2 prod2 sum)
sum2 : Ty2 → Ty2 → Ty2; sum2
= λ A B Ty2 nat2 top2 bot2 arr2 prod2 sum2 →
sum2 (A Ty2 nat2 top2 bot2 arr2 prod2 sum2) (B Ty2 nat2 top2 bot2 arr2 prod2 sum2)
Con2 : Set; Con2
= (Con2 : Set)
(nil : Con2)
(snoc : Con2 → Ty2 → Con2)
→ Con2
nil2 : Con2; nil2
= λ Con2 nil2 snoc → nil2
snoc2 : Con2 → Ty2 → Con2; snoc2
= λ Γ A Con2 nil2 snoc2 → snoc2 (Γ Con2 nil2 snoc2) A
Var2 : Con2 → Ty2 → Set; Var2
= λ Γ A →
(Var2 : Con2 → Ty2 → Set)
(vz : ∀{Γ A} → Var2 (snoc2 Γ A) A)
(vs : ∀{Γ B A} → Var2 Γ A → Var2 (snoc2 Γ B) A)
→ Var2 Γ A
vz2 : ∀{Γ A} → Var2 (snoc2 Γ A) A; vz2
= λ Var2 vz2 vs → vz2
vs2 : ∀{Γ B A} → Var2 Γ A → Var2 (snoc2 Γ B) A; vs2
= λ x Var2 vz2 vs2 → vs2 (x Var2 vz2 vs2)
Tm2 : Con2 → Ty2 → Set; Tm2
= λ Γ A →
(Tm2 : Con2 → Ty2 → Set)
(var : ∀{Γ A} → Var2 Γ A → Tm2 Γ A)
(lam : ∀{Γ A B} → Tm2 (snoc2 Γ A) B → Tm2 Γ (arr2 A B))
(app : ∀{Γ A B} → Tm2 Γ (arr2 A B) → Tm2 Γ A → Tm2 Γ B)
(tt : ∀{Γ} → Tm2 Γ top2)
(pair : ∀{Γ A B} → Tm2 Γ A → Tm2 Γ B → Tm2 Γ (prod2 A B))
(fst : ∀{Γ A B} → Tm2 Γ (prod2 A B) → Tm2 Γ A)
(snd : ∀{Γ A B} → Tm2 Γ (prod2 A B) → Tm2 Γ B)
(left : ∀{Γ A B} → Tm2 Γ A → Tm2 Γ (sum2 A B))
(right : ∀{Γ A B} → Tm2 Γ B → Tm2 Γ (sum2 A B))
(case : ∀{Γ A B C} → Tm2 Γ (sum2 A B) → Tm2 Γ (arr2 A C) → Tm2 Γ (arr2 B C) → Tm2 Γ C)
(zero : ∀{Γ} → Tm2 Γ nat2)
(suc : ∀{Γ} → Tm2 Γ nat2 → Tm2 Γ nat2)
(rec : ∀{Γ A} → Tm2 Γ nat2 → Tm2 Γ (arr2 nat2 (arr2 A A)) → Tm2 Γ A → Tm2 Γ A)
→ Tm2 Γ A
var2 : ∀{Γ A} → Var2 Γ A → Tm2 Γ A; var2
= λ x Tm2 var2 lam app tt pair fst snd left right case zero suc rec →
var2 x
lam2 : ∀{Γ A B} → Tm2 (snoc2 Γ A) B → Tm2 Γ (arr2 A B); lam2
= λ t Tm2 var2 lam2 app tt pair fst snd left right case zero suc rec →
lam2 (t Tm2 var2 lam2 app tt pair fst snd left right case zero suc rec)
app2 : ∀{Γ A B} → Tm2 Γ (arr2 A B) → Tm2 Γ A → Tm2 Γ B; app2
= λ t u Tm2 var2 lam2 app2 tt pair fst snd left right case zero suc rec →
app2 (t Tm2 var2 lam2 app2 tt pair fst snd left right case zero suc rec)
(u Tm2 var2 lam2 app2 tt pair fst snd left right case zero suc rec)
tt2 : ∀{Γ} → Tm2 Γ top2; tt2
= λ Tm2 var2 lam2 app2 tt2 pair fst snd left right case zero suc rec → tt2
pair2 : ∀{Γ A B} → Tm2 Γ A → Tm2 Γ B → Tm2 Γ (prod2 A B); pair2
= λ t u Tm2 var2 lam2 app2 tt2 pair2 fst snd left right case zero suc rec →
pair2 (t Tm2 var2 lam2 app2 tt2 pair2 fst snd left right case zero suc rec)
(u Tm2 var2 lam2 app2 tt2 pair2 fst snd left right case zero suc rec)
fst2 : ∀{Γ A B} → Tm2 Γ (prod2 A B) → Tm2 Γ A; fst2
= λ t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd left right case zero suc rec →
fst2 (t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd left right case zero suc rec)
snd2 : ∀{Γ A B} → Tm2 Γ (prod2 A B) → Tm2 Γ B; snd2
= λ t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left right case zero suc rec →
snd2 (t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left right case zero suc rec)
left2 : ∀{Γ A B} → Tm2 Γ A → Tm2 Γ (sum2 A B); left2
= λ t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right case zero suc rec →
left2 (t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right case zero suc rec)
right2 : ∀{Γ A B} → Tm2 Γ B → Tm2 Γ (sum2 A B); right2
= λ t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case zero suc rec →
right2 (t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case zero suc rec)
case2 : ∀{Γ A B C} → Tm2 Γ (sum2 A B) → Tm2 Γ (arr2 A C) → Tm2 Γ (arr2 B C) → Tm2 Γ C; case2
= λ t u v Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero suc rec →
case2 (t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero suc rec)
(u Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero suc rec)
(v Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero suc rec)
zero2 : ∀{Γ} → Tm2 Γ nat2; zero2
= λ Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero2 suc rec → zero2
suc2 : ∀{Γ} → Tm2 Γ nat2 → Tm2 Γ nat2; suc2
= λ t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero2 suc2 rec →
suc2 (t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero2 suc2 rec)
rec2 : ∀{Γ A} → Tm2 Γ nat2 → Tm2 Γ (arr2 nat2 (arr2 A A)) → Tm2 Γ A → Tm2 Γ A; rec2
= λ t u v Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero2 suc2 rec2 →
rec2 (t Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero2 suc2 rec2)
(u Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero2 suc2 rec2)
(v Tm2 var2 lam2 app2 tt2 pair2 fst2 snd2 left2 right2 case2 zero2 suc2 rec2)
v02 : ∀{Γ A} → Tm2 (snoc2 Γ A) A; v02
= var2 vz2
v12 : ∀{Γ A B} → Tm2 (snoc2 (snoc2 Γ A) B) A; v12
= var2 (vs2 vz2)
v22 : ∀{Γ A B C} → Tm2 (snoc2 (snoc2 (snoc2 Γ A) B) C) A; v22
= var2 (vs2 (vs2 vz2))
v32 : ∀{Γ A B C D} → Tm2 (snoc2 (snoc2 (snoc2 (snoc2 Γ A) B) C) D) A; v32
= var2 (vs2 (vs2 (vs2 vz2)))
tbool2 : Ty2; tbool2
= sum2 top2 top2
true2 : ∀{Γ} → Tm2 Γ tbool2; true2
= left2 tt2
tfalse2 : ∀{Γ} → Tm2 Γ tbool2; tfalse2
= right2 tt2
ifthenelse2 : ∀{Γ A} → Tm2 Γ (arr2 tbool2 (arr2 A (arr2 A A))); ifthenelse2
= lam2 (lam2 (lam2 (case2 v22 (lam2 v22) (lam2 v12))))
times42 : ∀{Γ A} → Tm2 Γ (arr2 (arr2 A A) (arr2 A A)); times42
= lam2 (lam2 (app2 v12 (app2 v12 (app2 v12 (app2 v12 v02)))))
add2 : ∀{Γ} → Tm2 Γ (arr2 nat2 (arr2 nat2 nat2)); add2
= lam2 (rec2 v02
(lam2 (lam2 (lam2 (suc2 (app2 v12 v02)))))
(lam2 v02))
mul2 : ∀{Γ} → Tm2 Γ (arr2 nat2 (arr2 nat2 nat2)); mul2
= lam2 (rec2 v02
(lam2 (lam2 (lam2 (app2 (app2 add2 (app2 v12 v02)) v02))))
(lam2 zero2))
fact2 : ∀{Γ} → Tm2 Γ (arr2 nat2 nat2); fact2
= lam2 (rec2 v02 (lam2 (lam2 (app2 (app2 mul2 (suc2 v12)) v02)))
(suc2 zero2))
{-# OPTIONS --type-in-type #-}
Ty3 : Set
Ty3 =
(Ty3 : Set)
(nat top bot : Ty3)
(arr prod sum : Ty3 → Ty3 → Ty3)
→ Ty3
nat3 : Ty3; nat3 = λ _ nat3 _ _ _ _ _ → nat3
top3 : Ty3; top3 = λ _ _ top3 _ _ _ _ → top3
bot3 : Ty3; bot3 = λ _ _ _ bot3 _ _ _ → bot3
arr3 : Ty3 → Ty3 → Ty3; arr3
= λ A B Ty3 nat3 top3 bot3 arr3 prod sum →
arr3 (A Ty3 nat3 top3 bot3 arr3 prod sum) (B Ty3 nat3 top3 bot3 arr3 prod sum)
prod3 : Ty3 → Ty3 → Ty3; prod3
= λ A B Ty3 nat3 top3 bot3 arr3 prod3 sum →
prod3 (A Ty3 nat3 top3 bot3 arr3 prod3 sum) (B Ty3 nat3 top3 bot3 arr3 prod3 sum)
sum3 : Ty3 → Ty3 → Ty3; sum3
= λ A B Ty3 nat3 top3 bot3 arr3 prod3 sum3 →
sum3 (A Ty3 nat3 top3 bot3 arr3 prod3 sum3) (B Ty3 nat3 top3 bot3 arr3 prod3 sum3)
Con3 : Set; Con3
= (Con3 : Set)
(nil : Con3)
(snoc : Con3 → Ty3 → Con3)
→ Con3
nil3 : Con3; nil3
= λ Con3 nil3 snoc → nil3
snoc3 : Con3 → Ty3 → Con3; snoc3
= λ Γ A Con3 nil3 snoc3 → snoc3 (Γ Con3 nil3 snoc3) A
Var3 : Con3 → Ty3 → Set; Var3
= λ Γ A →
(Var3 : Con3 → Ty3 → Set)
(vz : ∀{Γ A} → Var3 (snoc3 Γ A) A)
(vs : ∀{Γ B A} → Var3 Γ A → Var3 (snoc3 Γ B) A)
→ Var3 Γ A
vz3 : ∀{Γ A} → Var3 (snoc3 Γ A) A; vz3
= λ Var3 vz3 vs → vz3
vs3 : ∀{Γ B A} → Var3 Γ A → Var3 (snoc3 Γ B) A; vs3
= λ x Var3 vz3 vs3 → vs3 (x Var3 vz3 vs3)
Tm3 : Con3 → Ty3 → Set; Tm3
= λ Γ A →
(Tm3 : Con3 → Ty3 → Set)
(var : ∀{Γ A} → Var3 Γ A → Tm3 Γ A)
(lam : ∀{Γ A B} → Tm3 (snoc3 Γ A) B → Tm3 Γ (arr3 A B))
(app : ∀{Γ A B} → Tm3 Γ (arr3 A B) → Tm3 Γ A → Tm3 Γ B)
(tt : ∀{Γ} → Tm3 Γ top3)
(pair : ∀{Γ A B} → Tm3 Γ A → Tm3 Γ B → Tm3 Γ (prod3 A B))
(fst : ∀{Γ A B} → Tm3 Γ (prod3 A B) → Tm3 Γ A)
(snd : ∀{Γ A B} → Tm3 Γ (prod3 A B) → Tm3 Γ B)
(left : ∀{Γ A B} → Tm3 Γ A → Tm3 Γ (sum3 A B))
(right : ∀{Γ A B} → Tm3 Γ B → Tm3 Γ (sum3 A B))
(case : ∀{Γ A B C} → Tm3 Γ (sum3 A B) → Tm3 Γ (arr3 A C) → Tm3 Γ (arr3 B C) → Tm3 Γ C)
(zero : ∀{Γ} → Tm3 Γ nat3)
(suc : ∀{Γ} → Tm3 Γ nat3 → Tm3 Γ nat3)
(rec : ∀{Γ A} → Tm3 Γ nat3 → Tm3 Γ (arr3 nat3 (arr3 A A)) → Tm3 Γ A → Tm3 Γ A)
→ Tm3 Γ A
var3 : ∀{Γ A} → Var3 Γ A → Tm3 Γ A; var3
= λ x Tm3 var3 lam app tt pair fst snd left right case zero suc rec →
var3 x
lam3 : ∀{Γ A B} → Tm3 (snoc3 Γ A) B → Tm3 Γ (arr3 A B); lam3
= λ t Tm3 var3 lam3 app tt pair fst snd left right case zero suc rec →
lam3 (t Tm3 var3 lam3 app tt pair fst snd left right case zero suc rec)
app3 : ∀{Γ A B} → Tm3 Γ (arr3 A B) → Tm3 Γ A → Tm3 Γ B; app3
= λ t u Tm3 var3 lam3 app3 tt pair fst snd left right case zero suc rec →
app3 (t Tm3 var3 lam3 app3 tt pair fst snd left right case zero suc rec)
(u Tm3 var3 lam3 app3 tt pair fst snd left right case zero suc rec)
tt3 : ∀{Γ} → Tm3 Γ top3; tt3
= λ Tm3 var3 lam3 app3 tt3 pair fst snd left right case zero suc rec → tt3
pair3 : ∀{Γ A B} → Tm3 Γ A → Tm3 Γ B → Tm3 Γ (prod3 A B); pair3
= λ t u Tm3 var3 lam3 app3 tt3 pair3 fst snd left right case zero suc rec →
pair3 (t Tm3 var3 lam3 app3 tt3 pair3 fst snd left right case zero suc rec)
(u Tm3 var3 lam3 app3 tt3 pair3 fst snd left right case zero suc rec)
fst3 : ∀{Γ A B} → Tm3 Γ (prod3 A B) → Tm3 Γ A; fst3
= λ t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd left right case zero suc rec →
fst3 (t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd left right case zero suc rec)
snd3 : ∀{Γ A B} → Tm3 Γ (prod3 A B) → Tm3 Γ B; snd3
= λ t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left right case zero suc rec →
snd3 (t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left right case zero suc rec)
left3 : ∀{Γ A B} → Tm3 Γ A → Tm3 Γ (sum3 A B); left3
= λ t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right case zero suc rec →
left3 (t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right case zero suc rec)
right3 : ∀{Γ A B} → Tm3 Γ B → Tm3 Γ (sum3 A B); right3
= λ t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case zero suc rec →
right3 (t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case zero suc rec)
case3 : ∀{Γ A B C} → Tm3 Γ (sum3 A B) → Tm3 Γ (arr3 A C) → Tm3 Γ (arr3 B C) → Tm3 Γ C; case3
= λ t u v Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero suc rec →
case3 (t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero suc rec)
(u Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero suc rec)
(v Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero suc rec)
zero3 : ∀{Γ} → Tm3 Γ nat3; zero3
= λ Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero3 suc rec → zero3
suc3 : ∀{Γ} → Tm3 Γ nat3 → Tm3 Γ nat3; suc3
= λ t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero3 suc3 rec →
suc3 (t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero3 suc3 rec)
rec3 : ∀{Γ A} → Tm3 Γ nat3 → Tm3 Γ (arr3 nat3 (arr3 A A)) → Tm3 Γ A → Tm3 Γ A; rec3
= λ t u v Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero3 suc3 rec3 →
rec3 (t Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero3 suc3 rec3)
(u Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero3 suc3 rec3)
(v Tm3 var3 lam3 app3 tt3 pair3 fst3 snd3 left3 right3 case3 zero3 suc3 rec3)
v03 : ∀{Γ A} → Tm3 (snoc3 Γ A) A; v03
= var3 vz3
v13 : ∀{Γ A B} → Tm3 (snoc3 (snoc3 Γ A) B) A; v13
= var3 (vs3 vz3)
v23 : ∀{Γ A B C} → Tm3 (snoc3 (snoc3 (snoc3 Γ A) B) C) A; v23
= var3 (vs3 (vs3 vz3))
v33 : ∀{Γ A B C D} → Tm3 (snoc3 (snoc3 (snoc3 (snoc3 Γ A) B) C) D) A; v33
= var3 (vs3 (vs3 (vs3 vz3)))
tbool3 : Ty3; tbool3
= sum3 top3 top3
true3 : ∀{Γ} → Tm3 Γ tbool3; true3
= left3 tt3
tfalse3 : ∀{Γ} → Tm3 Γ tbool3; tfalse3
= right3 tt3
ifthenelse3 : ∀{Γ A} → Tm3 Γ (arr3 tbool3 (arr3 A (arr3 A A))); ifthenelse3
= lam3 (lam3 (lam3 (case3 v23 (lam3 v23) (lam3 v13))))
times43 : ∀{Γ A} → Tm3 Γ (arr3 (arr3 A A) (arr3 A A)); times43
= lam3 (lam3 (app3 v13 (app3 v13 (app3 v13 (app3 v13 v03)))))
add3 : ∀{Γ} → Tm3 Γ (arr3 nat3 (arr3 nat3 nat3)); add3
= lam3 (rec3 v03
(lam3 (lam3 (lam3 (suc3 (app3 v13 v03)))))
(lam3 v03))
mul3 : ∀{Γ} → Tm3 Γ (arr3 nat3 (arr3 nat3 nat3)); mul3
= lam3 (rec3 v03
(lam3 (lam3 (lam3 (app3 (app3 add3 (app3 v13 v03)) v03))))
(lam3 zero3))
fact3 : ∀{Γ} → Tm3 Γ (arr3 nat3 nat3); fact3
= lam3 (rec3 v03 (lam3 (lam3 (app3 (app3 mul3 (suc3 v13)) v03)))
(suc3 zero3))
{-# OPTIONS --type-in-type #-}
Ty4 : Set
Ty4 =
(Ty4 : Set)
(nat top bot : Ty4)
(arr prod sum : Ty4 → Ty4 → Ty4)
→ Ty4
nat4 : Ty4; nat4 = λ _ nat4 _ _ _ _ _ → nat4
top4 : Ty4; top4 = λ _ _ top4 _ _ _ _ → top4
bot4 : Ty4; bot4 = λ _ _ _ bot4 _ _ _ → bot4
arr4 : Ty4 → Ty4 → Ty4; arr4
= λ A B Ty4 nat4 top4 bot4 arr4 prod sum →
arr4 (A Ty4 nat4 top4 bot4 arr4 prod sum) (B Ty4 nat4 top4 bot4 arr4 prod sum)
prod4 : Ty4 → Ty4 → Ty4; prod4
= λ A B Ty4 nat4 top4 bot4 arr4 prod4 sum →
prod4 (A Ty4 nat4 top4 bot4 arr4 prod4 sum) (B Ty4 nat4 top4 bot4 arr4 prod4 sum)
sum4 : Ty4 → Ty4 → Ty4; sum4
= λ A B Ty4 nat4 top4 bot4 arr4 prod4 sum4 →
sum4 (A Ty4 nat4 top4 bot4 arr4 prod4 sum4) (B Ty4 nat4 top4 bot4 arr4 prod4 sum4)
Con4 : Set; Con4
= (Con4 : Set)
(nil : Con4)
(snoc : Con4 → Ty4 → Con4)
→ Con4
nil4 : Con4; nil4
= λ Con4 nil4 snoc → nil4
snoc4 : Con4 → Ty4 → Con4; snoc4
= λ Γ A Con4 nil4 snoc4 → snoc4 (Γ Con4 nil4 snoc4) A
Var4 : Con4 → Ty4 → Set; Var4
= λ Γ A →
(Var4 : Con4 → Ty4 → Set)
(vz : ∀{Γ A} → Var4 (snoc4 Γ A) A)
(vs : ∀{Γ B A} → Var4 Γ A → Var4 (snoc4 Γ B) A)
→ Var4 Γ A
vz4 : ∀{Γ A} → Var4 (snoc4 Γ A) A; vz4
= λ Var4 vz4 vs → vz4
vs4 : ∀{Γ B A} → Var4 Γ A → Var4 (snoc4 Γ B) A; vs4
= λ x Var4 vz4 vs4 → vs4 (x Var4 vz4 vs4)
Tm4 : Con4 → Ty4 → Set; Tm4
= λ Γ A →
(Tm4 : Con4 → Ty4 → Set)
(var : ∀{Γ A} → Var4 Γ A → Tm4 Γ A)
(lam : ∀{Γ A B} → Tm4 (snoc4 Γ A) B → Tm4 Γ (arr4 A B))
(app : ∀{Γ A B} → Tm4 Γ (arr4 A B) → Tm4 Γ A → Tm4 Γ B)
(tt : ∀{Γ} → Tm4 Γ top4)
(pair : ∀{Γ A B} → Tm4 Γ A → Tm4 Γ B → Tm4 Γ (prod4 A B))
(fst : ∀{Γ A B} → Tm4 Γ (prod4 A B) → Tm4 Γ A)
(snd : ∀{Γ A B} → Tm4 Γ (prod4 A B) → Tm4 Γ B)
(left : ∀{Γ A B} → Tm4 Γ A → Tm4 Γ (sum4 A B))
(right : ∀{Γ A B} → Tm4 Γ B → Tm4 Γ (sum4 A B))
(case : ∀{Γ A B C} → Tm4 Γ (sum4 A B) → Tm4 Γ (arr4 A C) → Tm4 Γ (arr4 B C) → Tm4 Γ C)
(zero : ∀{Γ} → Tm4 Γ nat4)
(suc : ∀{Γ} → Tm4 Γ nat4 → Tm4 Γ nat4)
(rec : ∀{Γ A} → Tm4 Γ nat4 → Tm4 Γ (arr4 nat4 (arr4 A A)) → Tm4 Γ A → Tm4 Γ A)
→ Tm4 Γ A
var4 : ∀{Γ A} → Var4 Γ A → Tm4 Γ A; var4
= λ x Tm4 var4 lam app tt pair fst snd left right case zero suc rec →
var4 x
lam4 : ∀{Γ A B} → Tm4 (snoc4 Γ A) B → Tm4 Γ (arr4 A B); lam4
= λ t Tm4 var4 lam4 app tt pair fst snd left right case zero suc rec →
lam4 (t Tm4 var4 lam4 app tt pair fst snd left right case zero suc rec)
app4 : ∀{Γ A B} → Tm4 Γ (arr4 A B) → Tm4 Γ A → Tm4 Γ B; app4
= λ t u Tm4 var4 lam4 app4 tt pair fst snd left right case zero suc rec →
app4 (t Tm4 var4 lam4 app4 tt pair fst snd left right case zero suc rec)
(u Tm4 var4 lam4 app4 tt pair fst snd left right case zero suc rec)
tt4 : ∀{Γ} → Tm4 Γ top4; tt4
= λ Tm4 var4 lam4 app4 tt4 pair fst snd left right case zero suc rec → tt4
pair4 : ∀{Γ A B} → Tm4 Γ A → Tm4 Γ B → Tm4 Γ (prod4 A B); pair4
= λ t u Tm4 var4 lam4 app4 tt4 pair4 fst snd left right case zero suc rec →
pair4 (t Tm4 var4 lam4 app4 tt4 pair4 fst snd left right case zero suc rec)
(u Tm4 var4 lam4 app4 tt4 pair4 fst snd left right case zero suc rec)
fst4 : ∀{Γ A B} → Tm4 Γ (prod4 A B) → Tm4 Γ A; fst4
= λ t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd left right case zero suc rec →
fst4 (t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd left right case zero suc rec)
snd4 : ∀{Γ A B} → Tm4 Γ (prod4 A B) → Tm4 Γ B; snd4
= λ t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left right case zero suc rec →
snd4 (t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left right case zero suc rec)
left4 : ∀{Γ A B} → Tm4 Γ A → Tm4 Γ (sum4 A B); left4
= λ t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right case zero suc rec →
left4 (t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right case zero suc rec)
right4 : ∀{Γ A B} → Tm4 Γ B → Tm4 Γ (sum4 A B); right4
= λ t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case zero suc rec →
right4 (t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case zero suc rec)
case4 : ∀{Γ A B C} → Tm4 Γ (sum4 A B) → Tm4 Γ (arr4 A C) → Tm4 Γ (arr4 B C) → Tm4 Γ C; case4
= λ t u v Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero suc rec →
case4 (t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero suc rec)
(u Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero suc rec)
(v Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero suc rec)
zero4 : ∀{Γ} → Tm4 Γ nat4; zero4
= λ Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero4 suc rec → zero4
suc4 : ∀{Γ} → Tm4 Γ nat4 → Tm4 Γ nat4; suc4
= λ t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero4 suc4 rec →
suc4 (t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero4 suc4 rec)
rec4 : ∀{Γ A} → Tm4 Γ nat4 → Tm4 Γ (arr4 nat4 (arr4 A A)) → Tm4 Γ A → Tm4 Γ A; rec4
= λ t u v Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero4 suc4 rec4 →
rec4 (t Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero4 suc4 rec4)
(u Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero4 suc4 rec4)
(v Tm4 var4 lam4 app4 tt4 pair4 fst4 snd4 left4 right4 case4 zero4 suc4 rec4)
v04 : ∀{Γ A} → Tm4 (snoc4 Γ A) A; v04
= var4 vz4
v14 : ∀{Γ A B} → Tm4 (snoc4 (snoc4 Γ A) B) A; v14
= var4 (vs4 vz4)
v24 : ∀{Γ A B C} → Tm4 (snoc4 (snoc4 (snoc4 Γ A) B) C) A; v24
= var4 (vs4 (vs4 vz4))
v34 : ∀{Γ A B C D} → Tm4 (snoc4 (snoc4 (snoc4 (snoc4 Γ A) B) C) D) A; v34
= var4 (vs4 (vs4 (vs4 vz4)))
tbool4 : Ty4; tbool4
= sum4 top4 top4
true4 : ∀{Γ} → Tm4 Γ tbool4; true4
= left4 tt4
tfalse4 : ∀{Γ} → Tm4 Γ tbool4; tfalse4
= right4 tt4
ifthenelse4 : ∀{Γ A} → Tm4 Γ (arr4 tbool4 (arr4 A (arr4 A A))); ifthenelse4
= lam4 (lam4 (lam4 (case4 v24 (lam4 v24) (lam4 v14))))
times44 : ∀{Γ A} → Tm4 Γ (arr4 (arr4 A A) (arr4 A A)); times44
= lam4 (lam4 (app4 v14 (app4 v14 (app4 v14 (app4 v14 v04)))))
add4 : ∀{Γ} → Tm4 Γ (arr4 nat4 (arr4 nat4 nat4)); add4
= lam4 (rec4 v04
(lam4 (lam4 (lam4 (suc4 (app4 v14 v04)))))
(lam4 v04))
mul4 : ∀{Γ} → Tm4 Γ (arr4 nat4 (arr4 nat4 nat4)); mul4
= lam4 (rec4 v04
(lam4 (lam4 (lam4 (app4 (app4 add4 (app4 v14 v04)) v04))))
(lam4 zero4))
fact4 : ∀{Γ} → Tm4 Γ (arr4 nat4 nat4); fact4
= lam4 (rec4 v04 (lam4 (lam4 (app4 (app4 mul4 (suc4 v14)) v04)))
(suc4 zero4))
{-# OPTIONS --type-in-type #-}
Ty5 : Set
Ty5 =
(Ty5 : Set)
(nat top bot : Ty5)
(arr prod sum : Ty5 → Ty5 → Ty5)
→ Ty5
nat5 : Ty5; nat5 = λ _ nat5 _ _ _ _ _ → nat5
top5 : Ty5; top5 = λ _ _ top5 _ _ _ _ → top5
bot5 : Ty5; bot5 = λ _ _ _ bot5 _ _ _ → bot5
arr5 : Ty5 → Ty5 → Ty5; arr5
= λ A B Ty5 nat5 top5 bot5 arr5 prod sum →
arr5 (A Ty5 nat5 top5 bot5 arr5 prod sum) (B Ty5 nat5 top5 bot5 arr5 prod sum)
prod5 : Ty5 → Ty5 → Ty5; prod5
= λ A B Ty5 nat5 top5 bot5 arr5 prod5 sum →
prod5 (A Ty5 nat5 top5 bot5 arr5 prod5 sum) (B Ty5 nat5 top5 bot5 arr5 prod5 sum)
sum5 : Ty5 → Ty5 → Ty5; sum5
= λ A B Ty5 nat5 top5 bot5 arr5 prod5 sum5 →
sum5 (A Ty5 nat5 top5 bot5 arr5 prod5 sum5) (B Ty5 nat5 top5 bot5 arr5 prod5 sum5)
Con5 : Set; Con5
= (Con5 : Set)
(nil : Con5)
(snoc : Con5 → Ty5 → Con5)
→ Con5
nil5 : Con5; nil5
= λ Con5 nil5 snoc → nil5
snoc5 : Con5 → Ty5 → Con5; snoc5
= λ Γ A Con5 nil5 snoc5 → snoc5 (Γ Con5 nil5 snoc5) A
Var5 : Con5 → Ty5 → Set; Var5
= λ Γ A →
(Var5 : Con5 → Ty5 → Set)
(vz : ∀{Γ A} → Var5 (snoc5 Γ A) A)
(vs : ∀{Γ B A} → Var5 Γ A → Var5 (snoc5 Γ B) A)
→ Var5 Γ A
vz5 : ∀{Γ A} → Var5 (snoc5 Γ A) A; vz5
= λ Var5 vz5 vs → vz5
vs5 : ∀{Γ B A} → Var5 Γ A → Var5 (snoc5 Γ B) A; vs5
= λ x Var5 vz5 vs5 → vs5 (x Var5 vz5 vs5)
Tm5 : Con5 → Ty5 → Set; Tm5
= λ Γ A →
(Tm5 : Con5 → Ty5 → Set)
(var : ∀{Γ A} → Var5 Γ A → Tm5 Γ A)
(lam : ∀{Γ A B} → Tm5 (snoc5 Γ A) B → Tm5 Γ (arr5 A B))
(app : ∀{Γ A B} → Tm5 Γ (arr5 A B) → Tm5 Γ A → Tm5 Γ B)
(tt : ∀{Γ} → Tm5 Γ top5)
(pair : ∀{Γ A B} → Tm5 Γ A → Tm5 Γ B → Tm5 Γ (prod5 A B))
(fst : ∀{Γ A B} → Tm5 Γ (prod5 A B) → Tm5 Γ A)
(snd : ∀{Γ A B} → Tm5 Γ (prod5 A B) → Tm5 Γ B)
(left : ∀{Γ A B} → Tm5 Γ A → Tm5 Γ (sum5 A B))
(right : ∀{Γ A B} → Tm5 Γ B → Tm5 Γ (sum5 A B))
(case : ∀{Γ A B C} → Tm5 Γ (sum5 A B) → Tm5 Γ (arr5 A C) → Tm5 Γ (arr5 B C) → Tm5 Γ C)
(zero : ∀{Γ} → Tm5 Γ nat5)
(suc : ∀{Γ} → Tm5 Γ nat5 → Tm5 Γ nat5)
(rec : ∀{Γ A} → Tm5 Γ nat5 → Tm5 Γ (arr5 nat5 (arr5 A A)) → Tm5 Γ A → Tm5 Γ A)
→ Tm5 Γ A
var5 : ∀{Γ A} → Var5 Γ A → Tm5 Γ A; var5
= λ x Tm5 var5 lam app tt pair fst snd left right case zero suc rec →
var5 x
lam5 : ∀{Γ A B} → Tm5 (snoc5 Γ A) B → Tm5 Γ (arr5 A B); lam5
= λ t Tm5 var5 lam5 app tt pair fst snd left right case zero suc rec →
lam5 (t Tm5 var5 lam5 app tt pair fst snd left right case zero suc rec)
app5 : ∀{Γ A B} → Tm5 Γ (arr5 A B) → Tm5 Γ A → Tm5 Γ B; app5
= λ t u Tm5 var5 lam5 app5 tt pair fst snd left right case zero suc rec →
app5 (t Tm5 var5 lam5 app5 tt pair fst snd left right case zero suc rec)
(u Tm5 var5 lam5 app5 tt pair fst snd left right case zero suc rec)
tt5 : ∀{Γ} → Tm5 Γ top5; tt5
= λ Tm5 var5 lam5 app5 tt5 pair fst snd left right case zero suc rec → tt5
pair5 : ∀{Γ A B} → Tm5 Γ A → Tm5 Γ B → Tm5 Γ (prod5 A B); pair5
= λ t u Tm5 var5 lam5 app5 tt5 pair5 fst snd left right case zero suc rec →
pair5 (t Tm5 var5 lam5 app5 tt5 pair5 fst snd left right case zero suc rec)
(u Tm5 var5 lam5 app5 tt5 pair5 fst snd left right case zero suc rec)
fst5 : ∀{Γ A B} → Tm5 Γ (prod5 A B) → Tm5 Γ A; fst5
= λ t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd left right case zero suc rec →
fst5 (t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd left right case zero suc rec)
snd5 : ∀{Γ A B} → Tm5 Γ (prod5 A B) → Tm5 Γ B; snd5
= λ t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left right case zero suc rec →
snd5 (t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left right case zero suc rec)
left5 : ∀{Γ A B} → Tm5 Γ A → Tm5 Γ (sum5 A B); left5
= λ t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right case zero suc rec →
left5 (t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right case zero suc rec)
right5 : ∀{Γ A B} → Tm5 Γ B → Tm5 Γ (sum5 A B); right5
= λ t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case zero suc rec →
right5 (t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case zero suc rec)
case5 : ∀{Γ A B C} → Tm5 Γ (sum5 A B) → Tm5 Γ (arr5 A C) → Tm5 Γ (arr5 B C) → Tm5 Γ C; case5
= λ t u v Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero suc rec →
case5 (t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero suc rec)
(u Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero suc rec)
(v Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero suc rec)
zero5 : ∀{Γ} → Tm5 Γ nat5; zero5
= λ Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero5 suc rec → zero5
suc5 : ∀{Γ} → Tm5 Γ nat5 → Tm5 Γ nat5; suc5
= λ t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero5 suc5 rec →
suc5 (t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero5 suc5 rec)
rec5 : ∀{Γ A} → Tm5 Γ nat5 → Tm5 Γ (arr5 nat5 (arr5 A A)) → Tm5 Γ A → Tm5 Γ A; rec5
= λ t u v Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero5 suc5 rec5 →
rec5 (t Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero5 suc5 rec5)
(u Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero5 suc5 rec5)
(v Tm5 var5 lam5 app5 tt5 pair5 fst5 snd5 left5 right5 case5 zero5 suc5 rec5)
v05 : ∀{Γ A} → Tm5 (snoc5 Γ A) A; v05
= var5 vz5
v15 : ∀{Γ A B} → Tm5 (snoc5 (snoc5 Γ A) B) A; v15
= var5 (vs5 vz5)
v25 : ∀{Γ A B C} → Tm5 (snoc5 (snoc5 (snoc5 Γ A) B) C) A; v25
= var5 (vs5 (vs5 vz5))
v35 : ∀{Γ A B C D} → Tm5 (snoc5 (snoc5 (snoc5 (snoc5 Γ A) B) C) D) A; v35
= var5 (vs5 (vs5 (vs5 vz5)))
tbool5 : Ty5; tbool5
= sum5 top5 top5
true5 : ∀{Γ} → Tm5 Γ tbool5; true5
= left5 tt5
tfalse5 : ∀{Γ} → Tm5 Γ tbool5; tfalse5
= right5 tt5
ifthenelse5 : ∀{Γ A} → Tm5 Γ (arr5 tbool5 (arr5 A (arr5 A A))); ifthenelse5
= lam5 (lam5 (lam5 (case5 v25 (lam5 v25) (lam5 v15))))
times45 : ∀{Γ A} → Tm5 Γ (arr5 (arr5 A A) (arr5 A A)); times45
= lam5 (lam5 (app5 v15 (app5 v15 (app5 v15 (app5 v15 v05)))))
add5 : ∀{Γ} → Tm5 Γ (arr5 nat5 (arr5 nat5 nat5)); add5
= lam5 (rec5 v05
(lam5 (lam5 (lam5 (suc5 (app5 v15 v05)))))
(lam5 v05))
mul5 : ∀{Γ} → Tm5 Γ (arr5 nat5 (arr5 nat5 nat5)); mul5
= lam5 (rec5 v05
(lam5 (lam5 (lam5 (app5 (app5 add5 (app5 v15 v05)) v05))))
(lam5 zero5))
fact5 : ∀{Γ} → Tm5 Γ (arr5 nat5 nat5); fact5
= lam5 (rec5 v05 (lam5 (lam5 (app5 (app5 mul5 (suc5 v15)) v05)))
(suc5 zero5))
{-# OPTIONS --type-in-type #-}
Ty6 : Set
Ty6 =
(Ty6 : Set)
(nat top bot : Ty6)
(arr prod sum : Ty6 → Ty6 → Ty6)
→ Ty6
nat6 : Ty6; nat6 = λ _ nat6 _ _ _ _ _ → nat6
top6 : Ty6; top6 = λ _ _ top6 _ _ _ _ → top6
bot6 : Ty6; bot6 = λ _ _ _ bot6 _ _ _ → bot6
arr6 : Ty6 → Ty6 → Ty6; arr6
= λ A B Ty6 nat6 top6 bot6 arr6 prod sum →
arr6 (A Ty6 nat6 top6 bot6 arr6 prod sum) (B Ty6 nat6 top6 bot6 arr6 prod sum)
prod6 : Ty6 → Ty6 → Ty6; prod6
= λ A B Ty6 nat6 top6 bot6 arr6 prod6 sum →
prod6 (A Ty6 nat6 top6 bot6 arr6 prod6 sum) (B Ty6 nat6 top6 bot6 arr6 prod6 sum)
sum6 : Ty6 → Ty6 → Ty6; sum6
= λ A B Ty6 nat6 top6 bot6 arr6 prod6 sum6 →
sum6 (A Ty6 nat6 top6 bot6 arr6 prod6 sum6) (B Ty6 nat6 top6 bot6 arr6 prod6 sum6)
Con6 : Set; Con6
= (Con6 : Set)
(nil : Con6)
(snoc : Con6 → Ty6 → Con6)
→ Con6
nil6 : Con6; nil6
= λ Con6 nil6 snoc → nil6
snoc6 : Con6 → Ty6 → Con6; snoc6
= λ Γ A Con6 nil6 snoc6 → snoc6 (Γ Con6 nil6 snoc6) A
Var6 : Con6 → Ty6 → Set; Var6
= λ Γ A →
(Var6 : Con6 → Ty6 → Set)
(vz : ∀{Γ A} → Var6 (snoc6 Γ A) A)
(vs : ∀{Γ B A} → Var6 Γ A → Var6 (snoc6 Γ B) A)
→ Var6 Γ A
vz6 : ∀{Γ A} → Var6 (snoc6 Γ A) A; vz6
= λ Var6 vz6 vs → vz6
vs6 : ∀{Γ B A} → Var6 Γ A → Var6 (snoc6 Γ B) A; vs6
= λ x Var6 vz6 vs6 → vs6 (x Var6 vz6 vs6)
Tm6 : Con6 → Ty6 → Set; Tm6
= λ Γ A →
(Tm6 : Con6 → Ty6 → Set)
(var : ∀{Γ A} → Var6 Γ A → Tm6 Γ A)
(lam : ∀{Γ A B} → Tm6 (snoc6 Γ A) B → Tm6 Γ (arr6 A B))
(app : ∀{Γ A B} → Tm6 Γ (arr6 A B) → Tm6 Γ A → Tm6 Γ B)
(tt : ∀{Γ} → Tm6 Γ top6)
(pair : ∀{Γ A B} → Tm6 Γ A → Tm6 Γ B → Tm6 Γ (prod6 A B))
(fst : ∀{Γ A B} → Tm6 Γ (prod6 A B) → Tm6 Γ A)
(snd : ∀{Γ A B} → Tm6 Γ (prod6 A B) → Tm6 Γ B)
(left : ∀{Γ A B} → Tm6 Γ A → Tm6 Γ (sum6 A B))
(right : ∀{Γ A B} → Tm6 Γ B → Tm6 Γ (sum6 A B))
(case : ∀{Γ A B C} → Tm6 Γ (sum6 A B) → Tm6 Γ (arr6 A C) → Tm6 Γ (arr6 B C) → Tm6 Γ C)
(zero : ∀{Γ} → Tm6 Γ nat6)
(suc : ∀{Γ} → Tm6 Γ nat6 → Tm6 Γ nat6)
(rec : ∀{Γ A} → Tm6 Γ nat6 → Tm6 Γ (arr6 nat6 (arr6 A A)) → Tm6 Γ A → Tm6 Γ A)
→ Tm6 Γ A
var6 : ∀{Γ A} → Var6 Γ A → Tm6 Γ A; var6
= λ x Tm6 var6 lam app tt pair fst snd left right case zero suc rec →
var6 x
lam6 : ∀{Γ A B} → Tm6 (snoc6 Γ A) B → Tm6 Γ (arr6 A B); lam6
= λ t Tm6 var6 lam6 app tt pair fst snd left right case zero suc rec →
lam6 (t Tm6 var6 lam6 app tt pair fst snd left right case zero suc rec)
app6 : ∀{Γ A B} → Tm6 Γ (arr6 A B) → Tm6 Γ A → Tm6 Γ B; app6
= λ t u Tm6 var6 lam6 app6 tt pair fst snd left right case zero suc rec →
app6 (t Tm6 var6 lam6 app6 tt pair fst snd left right case zero suc rec)
(u Tm6 var6 lam6 app6 tt pair fst snd left right case zero suc rec)
tt6 : ∀{Γ} → Tm6 Γ top6; tt6
= λ Tm6 var6 lam6 app6 tt6 pair fst snd left right case zero suc rec → tt6
pair6 : ∀{Γ A B} → Tm6 Γ A → Tm6 Γ B → Tm6 Γ (prod6 A B); pair6
= λ t u Tm6 var6 lam6 app6 tt6 pair6 fst snd left right case zero suc rec →
pair6 (t Tm6 var6 lam6 app6 tt6 pair6 fst snd left right case zero suc rec)
(u Tm6 var6 lam6 app6 tt6 pair6 fst snd left right case zero suc rec)
fst6 : ∀{Γ A B} → Tm6 Γ (prod6 A B) → Tm6 Γ A; fst6
= λ t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd left right case zero suc rec →
fst6 (t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd left right case zero suc rec)
snd6 : ∀{Γ A B} → Tm6 Γ (prod6 A B) → Tm6 Γ B; snd6
= λ t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left right case zero suc rec →
snd6 (t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left right case zero suc rec)
left6 : ∀{Γ A B} → Tm6 Γ A → Tm6 Γ (sum6 A B); left6
= λ t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right case zero suc rec →
left6 (t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right case zero suc rec)
right6 : ∀{Γ A B} → Tm6 Γ B → Tm6 Γ (sum6 A B); right6
= λ t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case zero suc rec →
right6 (t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case zero suc rec)
case6 : ∀{Γ A B C} → Tm6 Γ (sum6 A B) → Tm6 Γ (arr6 A C) → Tm6 Γ (arr6 B C) → Tm6 Γ C; case6
= λ t u v Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero suc rec →
case6 (t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero suc rec)
(u Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero suc rec)
(v Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero suc rec)
zero6 : ∀{Γ} → Tm6 Γ nat6; zero6
= λ Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero6 suc rec → zero6
suc6 : ∀{Γ} → Tm6 Γ nat6 → Tm6 Γ nat6; suc6
= λ t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero6 suc6 rec →
suc6 (t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero6 suc6 rec)
rec6 : ∀{Γ A} → Tm6 Γ nat6 → Tm6 Γ (arr6 nat6 (arr6 A A)) → Tm6 Γ A → Tm6 Γ A; rec6
= λ t u v Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero6 suc6 rec6 →
rec6 (t Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero6 suc6 rec6)
(u Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero6 suc6 rec6)
(v Tm6 var6 lam6 app6 tt6 pair6 fst6 snd6 left6 right6 case6 zero6 suc6 rec6)
v06 : ∀{Γ A} → Tm6 (snoc6 Γ A) A; v06
= var6 vz6
v16 : ∀{Γ A B} → Tm6 (snoc6 (snoc6 Γ A) B) A; v16
= var6 (vs6 vz6)
v26 : ∀{Γ A B C} → Tm6 (snoc6 (snoc6 (snoc6 Γ A) B) C) A; v26
= var6 (vs6 (vs6 vz6))
v36 : ∀{Γ A B C D} → Tm6 (snoc6 (snoc6 (snoc6 (snoc6 Γ A) B) C) D) A; v36
= var6 (vs6 (vs6 (vs6 vz6)))
tbool6 : Ty6; tbool6
= sum6 top6 top6
true6 : ∀{Γ} → Tm6 Γ tbool6; true6
= left6 tt6
tfalse6 : ∀{Γ} → Tm6 Γ tbool6; tfalse6
= right6 tt6
ifthenelse6 : ∀{Γ A} → Tm6 Γ (arr6 tbool6 (arr6 A (arr6 A A))); ifthenelse6
= lam6 (lam6 (lam6 (case6 v26 (lam6 v26) (lam6 v16))))
times46 : ∀{Γ A} → Tm6 Γ (arr6 (arr6 A A) (arr6 A A)); times46
= lam6 (lam6 (app6 v16 (app6 v16 (app6 v16 (app6 v16 v06)))))
add6 : ∀{Γ} → Tm6 Γ (arr6 nat6 (arr6 nat6 nat6)); add6
= lam6 (rec6 v06
(lam6 (lam6 (lam6 (suc6 (app6 v16 v06)))))
(lam6 v06))
mul6 : ∀{Γ} → Tm6 Γ (arr6 nat6 (arr6 nat6 nat6)); mul6
= lam6 (rec6 v06
(lam6 (lam6 (lam6 (app6 (app6 add6 (app6 v16 v06)) v06))))
(lam6 zero6))
fact6 : ∀{Γ} → Tm6 Γ (arr6 nat6 nat6); fact6
= lam6 (rec6 v06 (lam6 (lam6 (app6 (app6 mul6 (suc6 v16)) v06)))
(suc6 zero6))
{-# OPTIONS --type-in-type #-}
Ty7 : Set
Ty7 =
(Ty7 : Set)
(nat top bot : Ty7)
(arr prod sum : Ty7 → Ty7 → Ty7)
→ Ty7
nat7 : Ty7; nat7 = λ _ nat7 _ _ _ _ _ → nat7
top7 : Ty7; top7 = λ _ _ top7 _ _ _ _ → top7
bot7 : Ty7; bot7 = λ _ _ _ bot7 _ _ _ → bot7
arr7 : Ty7 → Ty7 → Ty7; arr7
= λ A B Ty7 nat7 top7 bot7 arr7 prod sum →
arr7 (A Ty7 nat7 top7 bot7 arr7 prod sum) (B Ty7 nat7 top7 bot7 arr7 prod sum)
prod7 : Ty7 → Ty7 → Ty7; prod7
= λ A B Ty7 nat7 top7 bot7 arr7 prod7 sum →
prod7 (A Ty7 nat7 top7 bot7 arr7 prod7 sum) (B Ty7 nat7 top7 bot7 arr7 prod7 sum)
sum7 : Ty7 → Ty7 → Ty7; sum7
= λ A B Ty7 nat7 top7 bot7 arr7 prod7 sum7 →
sum7 (A Ty7 nat7 top7 bot7 arr7 prod7 sum7) (B Ty7 nat7 top7 bot7 arr7 prod7 sum7)
Con7 : Set; Con7
= (Con7 : Set)
(nil : Con7)
(snoc : Con7 → Ty7 → Con7)
→ Con7
nil7 : Con7; nil7
= λ Con7 nil7 snoc → nil7
snoc7 : Con7 → Ty7 → Con7; snoc7
= λ Γ A Con7 nil7 snoc7 → snoc7 (Γ Con7 nil7 snoc7) A
Var7 : Con7 → Ty7 → Set; Var7
= λ Γ A →
(Var7 : Con7 → Ty7 → Set)
(vz : ∀{Γ A} → Var7 (snoc7 Γ A) A)
(vs : ∀{Γ B A} → Var7 Γ A → Var7 (snoc7 Γ B) A)
→ Var7 Γ A
vz7 : ∀{Γ A} → Var7 (snoc7 Γ A) A; vz7
= λ Var7 vz7 vs → vz7
vs7 : ∀{Γ B A} → Var7 Γ A → Var7 (snoc7 Γ B) A; vs7
= λ x Var7 vz7 vs7 → vs7 (x Var7 vz7 vs7)
Tm7 : Con7 → Ty7 → Set; Tm7
= λ Γ A →
(Tm7 : Con7 → Ty7 → Set)
(var : ∀{Γ A} → Var7 Γ A → Tm7 Γ A)
(lam : ∀{Γ A B} → Tm7 (snoc7 Γ A) B → Tm7 Γ (arr7 A B))
(app : ∀{Γ A B} → Tm7 Γ (arr7 A B) → Tm7 Γ A → Tm7 Γ B)
(tt : ∀{Γ} → Tm7 Γ top7)
(pair : ∀{Γ A B} → Tm7 Γ A → Tm7 Γ B → Tm7 Γ (prod7 A B))
(fst : ∀{Γ A B} → Tm7 Γ (prod7 A B) → Tm7 Γ A)
(snd : ∀{Γ A B} → Tm7 Γ (prod7 A B) → Tm7 Γ B)
(left : ∀{Γ A B} → Tm7 Γ A → Tm7 Γ (sum7 A B))
(right : ∀{Γ A B} → Tm7 Γ B → Tm7 Γ (sum7 A B))
(case : ∀{Γ A B C} → Tm7 Γ (sum7 A B) → Tm7 Γ (arr7 A C) → Tm7 Γ (arr7 B C) → Tm7 Γ C)
(zero : ∀{Γ} → Tm7 Γ nat7)
(suc : ∀{Γ} → Tm7 Γ nat7 → Tm7 Γ nat7)
(rec : ∀{Γ A} → Tm7 Γ nat7 → Tm7 Γ (arr7 nat7 (arr7 A A)) → Tm7 Γ A → Tm7 Γ A)
→ Tm7 Γ A
var7 : ∀{Γ A} → Var7 Γ A → Tm7 Γ A; var7
= λ x Tm7 var7 lam app tt pair fst snd left right case zero suc rec →
var7 x
lam7 : ∀{Γ A B} → Tm7 (snoc7 Γ A) B → Tm7 Γ (arr7 A B); lam7
= λ t Tm7 var7 lam7 app tt pair fst snd left right case zero suc rec →
lam7 (t Tm7 var7 lam7 app tt pair fst snd left right case zero suc rec)
app7 : ∀{Γ A B} → Tm7 Γ (arr7 A B) → Tm7 Γ A → Tm7 Γ B; app7
= λ t u Tm7 var7 lam7 app7 tt pair fst snd left right case zero suc rec →
app7 (t Tm7 var7 lam7 app7 tt pair fst snd left right case zero suc rec)
(u Tm7 var7 lam7 app7 tt pair fst snd left right case zero suc rec)
tt7 : ∀{Γ} → Tm7 Γ top7; tt7
= λ Tm7 var7 lam7 app7 tt7 pair fst snd left right case zero suc rec → tt7
pair7 : ∀{Γ A B} → Tm7 Γ A → Tm7 Γ B → Tm7 Γ (prod7 A B); pair7
= λ t u Tm7 var7 lam7 app7 tt7 pair7 fst snd left right case zero suc rec →
pair7 (t Tm7 var7 lam7 app7 tt7 pair7 fst snd left right case zero suc rec)
(u Tm7 var7 lam7 app7 tt7 pair7 fst snd left right case zero suc rec)
fst7 : ∀{Γ A B} → Tm7 Γ (prod7 A B) → Tm7 Γ A; fst7
= λ t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd left right case zero suc rec →
fst7 (t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd left right case zero suc rec)
snd7 : ∀{Γ A B} → Tm7 Γ (prod7 A B) → Tm7 Γ B; snd7
= λ t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left right case zero suc rec →
snd7 (t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left right case zero suc rec)
left7 : ∀{Γ A B} → Tm7 Γ A → Tm7 Γ (sum7 A B); left7
= λ t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right case zero suc rec →
left7 (t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right case zero suc rec)
right7 : ∀{Γ A B} → Tm7 Γ B → Tm7 Γ (sum7 A B); right7
= λ t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case zero suc rec →
right7 (t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case zero suc rec)
case7 : ∀{Γ A B C} → Tm7 Γ (sum7 A B) → Tm7 Γ (arr7 A C) → Tm7 Γ (arr7 B C) → Tm7 Γ C; case7
= λ t u v Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero suc rec →
case7 (t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero suc rec)
(u Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero suc rec)
(v Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero suc rec)
zero7 : ∀{Γ} → Tm7 Γ nat7; zero7
= λ Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero7 suc rec → zero7
suc7 : ∀{Γ} → Tm7 Γ nat7 → Tm7 Γ nat7; suc7
= λ t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero7 suc7 rec →
suc7 (t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero7 suc7 rec)
rec7 : ∀{Γ A} → Tm7 Γ nat7 → Tm7 Γ (arr7 nat7 (arr7 A A)) → Tm7 Γ A → Tm7 Γ A; rec7
= λ t u v Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero7 suc7 rec7 →
rec7 (t Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero7 suc7 rec7)
(u Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero7 suc7 rec7)
(v Tm7 var7 lam7 app7 tt7 pair7 fst7 snd7 left7 right7 case7 zero7 suc7 rec7)
v07 : ∀{Γ A} → Tm7 (snoc7 Γ A) A; v07
= var7 vz7
v17 : ∀{Γ A B} → Tm7 (snoc7 (snoc7 Γ A) B) A; v17
= var7 (vs7 vz7)
v27 : ∀{Γ A B C} → Tm7 (snoc7 (snoc7 (snoc7 Γ A) B) C) A; v27
= var7 (vs7 (vs7 vz7))
v37 : ∀{Γ A B C D} → Tm7 (snoc7 (snoc7 (snoc7 (snoc7 Γ A) B) C) D) A; v37
= var7 (vs7 (vs7 (vs7 vz7)))
tbool7 : Ty7; tbool7
= sum7 top7 top7
true7 : ∀{Γ} → Tm7 Γ tbool7; true7
= left7 tt7
tfalse7 : ∀{Γ} → Tm7 Γ tbool7; tfalse7
= right7 tt7
ifthenelse7 : ∀{Γ A} → Tm7 Γ (arr7 tbool7 (arr7 A (arr7 A A))); ifthenelse7
= lam7 (lam7 (lam7 (case7 v27 (lam7 v27) (lam7 v17))))
times47 : ∀{Γ A} → Tm7 Γ (arr7 (arr7 A A) (arr7 A A)); times47
= lam7 (lam7 (app7 v17 (app7 v17 (app7 v17 (app7 v17 v07)))))
add7 : ∀{Γ} → Tm7 Γ (arr7 nat7 (arr7 nat7 nat7)); add7
= lam7 (rec7 v07
(lam7 (lam7 (lam7 (suc7 (app7 v17 v07)))))
(lam7 v07))
mul7 : ∀{Γ} → Tm7 Γ (arr7 nat7 (arr7 nat7 nat7)); mul7
= lam7 (rec7 v07
(lam7 (lam7 (lam7 (app7 (app7 add7 (app7 v17 v07)) v07))))
(lam7 zero7))
fact7 : ∀{Γ} → Tm7 Γ (arr7 nat7 nat7); fact7
= lam7 (rec7 v07 (lam7 (lam7 (app7 (app7 mul7 (suc7 v17)) v07)))
(suc7 zero7))
| {
"alphanum_fraction": 0.5985017533,
"avg_line_length": 38.2269611577,
"ext": "agda",
"hexsha": "8124386c40e1096a02cf0e713f5173dbc253d18a",
"lang": "Agda",
"max_forks_count": 19,
"max_forks_repo_forks_event_max_datetime": "2022-03-03T19:46:54.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-05T21:11:34.000Z",
"max_forks_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "int-index/smalltt",
"max_forks_repo_path": "bench/stlc1k.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff",
"max_issues_repo_issues_event_max_datetime": "2022-02-28T21:51:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-16T09:14:57.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "int-index/smalltt",
"max_issues_repo_path": "bench/stlc1k.agda",
"max_line_length": 92,
"max_stars_count": 377,
"max_stars_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "int-index/smalltt",
"max_stars_repo_path": "bench/stlc1k.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T21:31:01.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-26T16:57:16.000Z",
"num_tokens": 22693,
"size": 50192
} |
module IdemInvo where
open import Relation.Binary.PropositionalEquality
module MainResult
(A : Set)
(f : A → A)
(idem : ∀ x → f (f x) ≡ f x)
(invo : ∀ x → f (f x) ≡ x)
where
-- an idempotent and involutive function is an identity function
iden : ∀ x → f x ≡ x
iden x = trans (sym (idem x)) (invo x)
| {
"alphanum_fraction": 0.6132075472,
"avg_line_length": 21.2,
"ext": "agda",
"hexsha": "f615f5affe8428621df82b16cb8316583e03c572",
"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": "44f16597c9ef9596f6dc1b628848a3a74fa9a19b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "zaklogician/IdemInvo",
"max_forks_repo_path": "IdemInvo.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "44f16597c9ef9596f6dc1b628848a3a74fa9a19b",
"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": "zaklogician/IdemInvo",
"max_issues_repo_path": "IdemInvo.agda",
"max_line_length": 66,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "44f16597c9ef9596f6dc1b628848a3a74fa9a19b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "zaklogician/IdemInvo",
"max_stars_repo_path": "IdemInvo.agda",
"max_stars_repo_stars_event_max_datetime": "2015-11-19T01:54:50.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-11-19T01:54:50.000Z",
"num_tokens": 118,
"size": 318
} |
postulate
I : Set
data Box (A : Set) : Set where
[_] : A → Box A
variable
@0 i : I
@0 b : Box I
data D : @0 Box I → Set where
d : D [ i ] → D [ i ]
variable
@0 x : D b
data P : @0 D b → Set where
p : P (d x)
works : ∀ {i} {@0 x : D [ i ]} → P (d x)
works = p
fails : ∀ {@0 i} {@0 x : D [ i ]} → P (d x)
fails = p
| {
"alphanum_fraction": 0.4447761194,
"avg_line_length": 12.8846153846,
"ext": "agda",
"hexsha": "7c07456542a4fb9b978319c3418ec525794ca884",
"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/Issue5058.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/Issue5058.agda",
"max_line_length": 43,
"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/Issue5058.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": 149,
"size": 335
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.FunExtEquiv where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
private
variable
ℓ ℓ₁ ℓ₂ ℓ₃ : Level
-- Function extensionality is an equivalence
module _ {A : Type ℓ} {B : A → Type ℓ₁} {f g : (x : A) → B x} where
private
fib : (p : f ≡ g) → fiber funExt p
fib p = (funExt⁻ p , refl)
funExt-fiber-isContr : (p : f ≡ g) → (fi : fiber funExt p) → fib p ≡ fi
funExt-fiber-isContr p (h , eq) i = (funExt⁻ (eq (~ i)) , λ j → eq (~ i ∨ j))
funExt-isEquiv : isEquiv funExt
equiv-proof funExt-isEquiv p = (fib p , funExt-fiber-isContr p)
funExtEquiv : (∀ x → f x ≡ g x) ≃ (f ≡ g)
funExtEquiv = (funExt {B = B} , funExt-isEquiv)
funExtPath : (∀ x → f x ≡ g x) ≡ (f ≡ g)
funExtPath = ua funExtEquiv
-- Function extensionality for binary functions
funExt₂ : {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}
{f g : (x : A) → (y : B x) → C x y}
→ ((x : A) (y : B x) → f x y ≡ g x y) → f ≡ g
funExt₂ p i x y = p x y i
-- Function extensionality for binary functions is an equivalence
module _ {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}
{f g : (x : A) → (y : B x) → C x y} where
private
appl₂ : f ≡ g → ∀ x y → f x y ≡ g x y
appl₂ eq x y i = eq i x y
fib : (p : f ≡ g) → fiber funExt₂ p
fib p = (appl₂ p , refl)
funExt₂-fiber-isContr : (p : f ≡ g) → (fi : fiber funExt₂ p) → fib p ≡ fi
funExt₂-fiber-isContr p (h , eq) i = (appl₂ (eq (~ i)) , λ j → eq (~ i ∨ j))
funExt₂-isEquiv : isEquiv funExt₂
equiv-proof funExt₂-isEquiv p = (fib p , funExt₂-fiber-isContr p)
funExt₂Equiv : (∀ x y → f x y ≡ g x y) ≃ (f ≡ g)
funExt₂Equiv = (funExt₂ , funExt₂-isEquiv)
funExt₂Path : (∀ x y → f x y ≡ g x y) ≡ (f ≡ g)
funExt₂Path = ua funExt₂Equiv
-- Function extensionality for ternary functions
funExt₃ : {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}
{D : (x : A) → (y : B x) → C x y → Type ℓ₃}
{f g : (x : A) → (y : B x) → (z : C x y) → D x y z}
→ ((x : A) (y : B x) (z : C x y) → f x y z ≡ g x y z) → f ≡ g
funExt₃ p i x y z = p x y z i
-- Function extensionality for ternary functions is an equivalence
module _ {A : Type ℓ} {B : A → Type ℓ₁} {C : (x : A) → B x → Type ℓ₂}
{D : (x : A) → (y : B x) → C x y → Type ℓ₃}
{f g : (x : A) → (y : B x) → (z : C x y) → D x y z} where
private
appl₃ : f ≡ g → ∀ x y z → f x y z ≡ g x y z
appl₃ eq x y z i = eq i x y z
fib : (p : f ≡ g) → fiber funExt₃ p
fib p = (appl₃ p , refl)
funExt₃-fiber-isContr : (p : f ≡ g) → (fi : fiber funExt₃ p) → fib p ≡ fi
funExt₃-fiber-isContr p (h , eq) i = (appl₃ (eq (~ i)) , λ j → eq (~ i ∨ j))
funExt₃-isEquiv : isEquiv funExt₃
equiv-proof funExt₃-isEquiv p = (fib p , funExt₃-fiber-isContr p)
funExt₃Equiv : (∀ x y z → f x y z ≡ g x y z) ≃ (f ≡ g)
funExt₃Equiv = (funExt₃ , funExt₃-isEquiv)
funExt₃Path : (∀ x y z → f x y z ≡ g x y z) ≡ (f ≡ g)
funExt₃Path = ua funExt₃Equiv
-- Puzzle: Can one generalize this to n-ary functions?
| {
"alphanum_fraction": 0.5437933207,
"avg_line_length": 34.5,
"ext": "agda",
"hexsha": "4a61b856ef684ab111337fb8759f321e001e06aa",
"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/Foundations/FunExtEquiv.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/Foundations/FunExtEquiv.agda",
"max_line_length": 81,
"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/Foundations/FunExtEquiv.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1352,
"size": 3174
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Object.Coproduct {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Function using (_$_)
open Category 𝒞
open import Categories.Morphism.Reasoning 𝒞
open import Categories.Morphism 𝒞
open HomReasoning
private
variable
A B C D : Obj
f g h : A ⇒ B
record Coproduct (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where
infix 10 [_,_]
field
A+B : Obj
i₁ : A ⇒ A+B
i₂ : B ⇒ A+B
[_,_] : A ⇒ C → B ⇒ C → A+B ⇒ C
inject₁ : [ f , g ] ∘ i₁ ≈ f
inject₂ : [ f , g ] ∘ i₂ ≈ g
unique : h ∘ i₁ ≈ f → h ∘ i₂ ≈ g → [ f , g ] ≈ h
g-η : [ f ∘ i₁ , f ∘ i₂ ] ≈ f
g-η = unique Equiv.refl Equiv.refl
η : [ i₁ , i₂ ] ≈ id
η = unique identityˡ identityˡ
[]-cong₂ : ∀ {C} → {f f′ : A ⇒ C} {g g′ : B ⇒ C} → f ≈ f′ → g ≈ g′ → [ f , g ] ≈ [ f′ , g′ ]
[]-cong₂ f≈f′ g≈g′ = unique (inject₁ ○ ⟺ f≈f′) (inject₂ ○ ⟺ g≈g′)
∘-distribˡ-[] : ∀ {f : A ⇒ C} {g : B ⇒ C} {q : C ⇒ D} → q ∘ [ f , g ] ≈ [ q ∘ f , q ∘ g ]
∘-distribˡ-[] = ⟺ $ unique (pullʳ inject₁) (pullʳ inject₂)
| {
"alphanum_fraction": 0.5031731641,
"avg_line_length": 23.9782608696,
"ext": "agda",
"hexsha": "5fa72725350290829ecc7e27976135172005ba30",
"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": "3ef03f73bce18f1efba2890df9ddf3d76ed2de32",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FintanH/agda-categories",
"max_forks_repo_path": "src/Categories/Object/Coproduct.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3ef03f73bce18f1efba2890df9ddf3d76ed2de32",
"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": "FintanH/agda-categories",
"max_issues_repo_path": "src/Categories/Object/Coproduct.agda",
"max_line_length": 94,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3ef03f73bce18f1efba2890df9ddf3d76ed2de32",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FintanH/agda-categories",
"max_stars_repo_path": "src/Categories/Object/Coproduct.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 498,
"size": 1103
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.