Search is not available for this dataset
text
string | meta
dict |
---|---|
module Numeral.Finite.Sequence where
import Lvl
open import Data.Either as Either using (_โ_)
open import Data.Either.Equiv as Either
open import Data.Either.Equiv.Id
open import Data.Either.Proofs as Either
open import Data.Tuple as Tuple using (_โจฏ_ ; _,_)
open import Data.Tuple.Equiv as Tuple
open import Data.Tuple.Equiv.Id
open import Data.Tuple.Proofs as Tuple
open import Functional
open import Function.Equals
open import Function.Proofs
open import Logic
open import Logic.Predicate
open import Logic.Propositional
open import Numeral.Finite
open import Numeral.Finite.Bound
-- open import Numeral.Finite.Equiv
import Numeral.Finite.Oper as ๐
open import Numeral.Natural
import Numeral.Natural.Oper as โ
open import Numeral.Natural.Oper.Proofs.Order
open import Relator.Equals
open import Relator.Equals.Proofs.Equiv using () renaming ([โก]-equiv to Id-equiv ; [โก]-function to Id-function)
open import Structure.Function
open import Structure.Function.Domain
open import Structure.Function.Domain.Proofs
import Structure.Function.Names as Names
open import Structure.Operator
open import Structure.Relator
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
open import Type.Size
private variable โ โโ โโ โโ โโโ โโโ โโโ โโโ โโโ
โโโ : Lvl.Level
private variable A : Type{โโ}
private variable B : Type{โโ}
private variable a b : โ
module Interleaving where
join : (๐(a) โ ๐(b)) โ ๐(a โ.+ b)
join {๐} {๐ b} (Either.Right n) = n
join {๐ a}{๐} (Either.Left n) = n
join {๐ a}{๐ b} (Either.Left ๐) = ๐
join {๐ a}{๐ b} (Either.Right ๐) = ๐(๐)
join {๐ a}{๐ b} (Either.Left (๐ n)) = ๐(๐(join {a}{b} (Either.Left n)))
join {๐ a}{๐ b} (Either.Right (๐ n)) = ๐(๐(join {a}{b} (Either.Right n)))
split : ๐(a โ.+ b) โ (๐(a) โ ๐(b))
split {๐} {๐ b} n = Either.Right n
split {๐ a} {๐} n = Either.Left n
split {๐ a} {๐ b} ๐ = Either.Left ๐
split {๐ a} {๐ b} (๐(๐)) = Either.Right ๐
split {๐ a} {๐ b} (๐(๐(n))) = Either.map ๐ ๐ (split {a} {b} n)
instance
join-split-inverses : Inverseแตฃ(join{a}{b})(split{a}{b})
join-split-inverses {a}{b} = intro(proof{a}{b}) where
proof : โ{a b} โ Names.Inverses(join{a}{b})(split{a}{b})
proof {๐} {๐ b}{๐} = [โก]-intro
proof {๐} {๐ b}{๐ n} = [โก]-intro
proof {๐ a}{๐} {๐} = [โก]-intro
proof {๐ a}{๐} {๐ n} = [โก]-intro
proof {๐ a}{๐ b}{๐} = [โก]-intro
proof {๐ a}{๐ b}{๐ ๐} = [โก]-intro
proof {๐ a}{๐ b}{๐(๐ n)} with split{a}{b} n | proof {a}{b}{n}
... | Either.Left m | p = congruenceโ(๐) (congruenceโ(๐) p)
... | Either.Right m | p = congruenceโ(๐) (congruenceโ(๐) p)
instance
split-join-inverses : Inverseโ(join{a}{b})(split{a}{b})
split-join-inverses {a}{b} = intro(proof{a}{b}) where
proof : โ{a b} โ Names.Inverses(split{a}{b})(join{a}{b})
proof {๐} {๐} {Either.Left ()}
proof {๐} {๐} {Either.Right ()}
proof {๐} {๐ b} {Either.Right n} = [โก]-intro
proof {๐ a} {๐} {Either.Left n} = [โก]-intro
proof {๐ a} {๐ b} {Either.Left ๐} = [โก]-intro
proof {๐ a} {๐ b} {Either.Right ๐} = [โก]-intro
proof {๐(๐ a)} {๐ ๐} {Either.Left (๐ n)} = [โก]-intro
proof {๐ ๐} {๐(๐ b)} {Either.Right (๐ n)} = [โก]-intro
proof {๐(๐ a)} {๐(๐ b)} {Either.Left (๐ n)} with join{๐ a}{๐ b} (Either.Left n) | proof {๐ a}{๐ b}{Either.Left n}
... | ๐ | p = congruenceโ(Either.map ๐ ๐) p
... | ๐(๐ m) | p = congruenceโ(Either.map ๐ ๐) p
proof {๐(๐ a)} {๐(๐ b)} {Either.Right (๐ n)} with join{๐ a}{๐ b} (Either.Right n) | proof {๐ a}{๐ b}{Either.Right n}
... | ๐(๐) | p = congruenceโ(Either.map ๐ ๐) p
... | ๐(๐ m) | p = congruenceโ(Either.map ๐ ๐) p
instance
split-join-inverse : Inverse(split{a}{b})(join{a}{b})
split-join-inverse = [โง]-intro join-split-inverses split-join-inverses
instance
split-bijective : Bijective(split{a}{b})
split-bijective = invertible-to-bijective โฆ inver = [โ]-intro join โฆ [โง]-intro Id-function split-join-inverse โฆ โฆ
-- Interleaves two sequences into one, alternating between the elements and then putting the leftovers at the end.
interleave : (๐(a) โ A) โ (๐(b) โ B) โ (๐(a โ.+ b) โ (A โ B))
interleave af bf = Either.map af bf โ Interleaving.split
module _
โฆ equiv-A : Equiv{โโโ}(A) โฆ
โฆ equiv-B : Equiv{โโโ}(B) โฆ
โฆ equiv-AB : Equiv{โโ}(A โ B) โฆ โฆ ext-AB : Either.Extensionality โฆ equiv-A โฆ โฆ equiv-B โฆ (equiv-AB) โฆ
{af : ๐(a) โ A} โฆ bij-af : Bijective โฆ Id-equiv โฆ โฆ equiv-A โฆ (af) โฆ
{bf : ๐(b) โ B} โฆ bij-bf : Bijective โฆ Id-equiv โฆ โฆ equiv-B โฆ (bf) โฆ
where
instance
interleave-bijective : Bijective(interleave af bf)
interleave-bijective = [โ]-bijective โฆ bij-f = Either.map-bijective โฆ โฆ bij-g = Interleaving.split-bijective โฆ
module Concatenation where
join : (๐(a) โ ๐(b)) โ ๐(a โ.+ b)
join {a} {b} (Either.Left n) = bound-[โค] [โค]-of-[+]โ n
join {a} {b} (Either.Right n) = a ๐.Unclosed.+โโ n
split : ๐(a โ.+ b) โ (๐(a) โ ๐(b))
split {๐} {๐ b} n = Either.Right n
split {๐ a}{๐} n = Either.Left n
split {๐ a}{๐ b} ๐ = Either.Left ๐
split {๐ a}{๐ b} (๐ n) = Either.mapLeft ๐ (split {a}{๐ b} n)
open import Numeral.Finite.Category
open import Structure.Category.Functor
instance
join-split-inverses : Inverseแตฃ(join{a}{b})(split{a}{b})
join-split-inverses {a}{b} = intro(proof{a}{b}) where
proof : โ{a b} โ Names.Inverses(join{a}{b})(split{a}{b})
proof {๐} {๐ b} {n} = [โก]-intro
proof {๐ a} {๐} {n} = _โ_.proof (Functor.id-preserving bound-functor)
proof {๐ a} {๐ b} {๐} = [โก]-intro
proof {๐ a} {๐ b} {๐ n} with split {a}{๐ b} n | proof {a} {๐ b} {n}
... | Either.Left _ | [โก]-intro = [โก]-intro
... | Either.Right _ | [โก]-intro = [โก]-intro
instance
split-join-inverses : Inverseโ(join{a}{b})(split{a}{b})
split-join-inverses {a}{b} = intro(proof{a}{b}) where
proof : โ{a b} โ Names.Inverses(split{a}{b})(join{a}{b})
proof {๐} {๐ b} {Either.Right n} = [โก]-intro
proof {๐ a} {๐} {Either.Left n} = congruenceโ(Either.Left) (_โ_.proof (Functor.id-preserving bound-functor))
proof {๐ a} {๐ b} {Either.Left ๐} = [โก]-intro
proof {๐ a} {๐ b} {Either.Left (๐ n)} = congruenceโ(Either.mapLeft ๐) (proof{a}{๐ b} {Either.Left n})
proof {๐ a} {๐ b} {Either.Right n} = congruenceโ(Either.mapLeft ๐) (proof{a}{๐ b} {Either.Right n})
instance
split-join-inverse : Inverse(split{a}{b})(join{a}{b})
split-join-inverse = [โง]-intro join-split-inverses split-join-inverses
instance
split-bijective : Bijective(split{a}{b})
split-bijective = invertible-to-bijective โฆ inver = [โ]-intro join โฆ [โง]-intro Id-function split-join-inverse โฆ โฆ
-- Concatenates two sequences into one, putting the elements of the first sequence first followed by the elements of the second sequence.
concat : (๐(a) โ A) โ (๐(b) โ B) โ (๐(a โ.+ b) โ (A โ B))
concat af bf = Either.map af bf โ Concatenation.split
module _
โฆ equiv-A : Equiv{โโโ}(A) โฆ
โฆ equiv-B : Equiv{โโโ}(B) โฆ
โฆ equiv-AB : Equiv{โโ}(A โ B) โฆ โฆ ext-AB : Either.Extensionality โฆ equiv-A โฆ โฆ equiv-B โฆ (equiv-AB) โฆ
{af : ๐(a) โ A} โฆ bij-af : Bijective โฆ Id-equiv โฆ โฆ equiv-A โฆ (af) โฆ
{bf : ๐(b) โ B} โฆ bij-bf : Bijective โฆ Id-equiv โฆ โฆ equiv-B โฆ (bf) โฆ
where
instance
concat-bijective : Bijective(concat af bf)
concat-bijective = [โ]-bijective โฆ bij-f = Either.map-bijective โฆ โฆ bij-g = Concatenation.split-bijective โฆ
module LinearSpaceFilling where
join : (๐(a) โจฏ ๐(b)) โ ๐(a โ.โ
b)
join = Tuple.uncurry(๐.Exact._โ
_)
-- split : ๐(a โ.โ
b) โ (๐(a) โจฏ ๐(b))
-- split {a}{b} n = ({!n mod a!} , {!n / a!})
module BaseNumerals where -- TODO: Maybe try to use Numeral.FixedPositional
-- When interpreting the function as a numeral in a certain base, the parameters mean the following:
-- โข `a` is the base.
-- โข `b` is the length of the numerals (the maximum number of digits).
-- โข The argument of the specified function is the position of the numeral.
-- โข The value of the specified function is the digit on the argument's position.
{-join : (๐(a) โ ๐(b)) โ ๐(a โ.^ b)
join {a}{๐} f = ๐
join {a}{๐ b} f = {!f(๐) ๐.Exact.+ ((join {a}{b} (f โ ๐)) ๐.Unclosed.โ
โแตฃ a)!}-}
-- f(๐) ๐.Exact.โ
join {a}{b} (f โ ๐)
-- 4321
-- 1โ
10โฐ + 2โ
10ยน + 3โ
10ยฒ + 4โ
10ยณ
-- 1 + 10โ
(2 + 10โ
(3 + 10โ
(4 + 10โ
0)))
-- TODO: Something is incorrect here. This is the type of the induction step:
-- a + ๐(aโ
(a ^ b))
-- ๐(a + aโ
(a ^ b))
-- ๐(a + (a ^ ๐(b)))
-- ๐(a) + (a ^ ๐(b))
{-
open import Data.Boolean
join : (๐(a) โ Bool) โ ๐(2 โ.^ a)
join {๐} f = ๐
join {๐ a} f = {!(if f(๐) then ๐.๐(๐.๐) else ๐.๐) ๐.Exact.+ join {a} (f โ ๐.๐)!}
-}
{- TODO: Old stuff below. Could be useful to have some properties of the interleave and concat functions
-- Interleaves two sequences into one, alternating between the elements and then putting the leftovers at the end.
interleave : (๐(a) โ A) โ (๐(b) โ B) โ (๐(a โ.+ b) โ (A โ B))
interleave {a = ๐} {b = ๐ b} af bf n = Either.Right(bf(n))
interleave {a = ๐ a} {b = ๐} af bf n = Either.Left(af(n))
interleave {a = ๐ a} {b = ๐ b} af bf ๐ = Either.Left(af(๐))
interleave {a = ๐ a} {b = ๐ b} af bf (๐ ๐) = Either.Right(bf(๐))
interleave {a = ๐ a} {b = ๐ b} af bf (๐(๐ n)) = interleave {a = a}{b = b} (af โ ๐) (bf โ ๐) n
-- Concatenates two sequences into one, putting the elements of the first sequence first followed by the elements of the second sequence.
concat : (๐(a) โ A) โ (๐(b) โ B) โ (๐(a โ.+ b) โ (A โ B))
concat {a = ๐} {b = ๐ b} af bf n = Either.Right(bf(n))
concat {a = ๐ a} {b = b} af bf ๐ = Either.Left(af(๐))
concat {a = ๐ a} {b = b} af bf (๐ n) = concat {a = a} {b = b} (af โ ๐) bf n
concat-is-left : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n : ๐(a)} โ (concat af bf (bound-[โค] [โค]-of-[+]โ n) โก Either.Left(af(n)))
concat-is-left {a = ๐ a} {b} {af}{bf} {n = ๐} = [โก]-intro
concat-is-left {a = ๐ a} {๐} {af}{bf} {n = ๐ n} = ([โก]-with(concat af bf) (p{n = n})) ๐ concat-is-left {a = a} {b = ๐} {af = af โ ๐}{bf = bf} {n = n} where
p : โ{A}{n : ๐(A)} โ (bound-[โค] ([โค]-of-[+]โ {๐ A}{๐}) (๐(n)) โก ๐(bound-[โค] [โค]-of-[+]โ n))
p {.(๐ _)} {๐} = [โก]-intro
p {.(๐ _)} {๐ n} = [โก]-intro
concat-is-left {a = ๐ a} {๐ b} {af}{bf} {n = ๐ n} = concat-is-left {a = a} {b = ๐ b} {af = af โ ๐}{bf = bf} {n = n}
concat-is-left-on-0 : โ{a}{af : ๐(a) โ A}{bf : ๐(๐) โ B}{n : ๐(a)} โ (concat af bf n โก Either.Left(af(n)))
concat-is-left-on-0 {a = ๐ a} {n = ๐} = [โก]-intro
concat-is-left-on-0 {a = ๐ a} {n = ๐ n} = concat-is-left-on-0 {a = a} {n = n}
-- concat-is-right : โ{a b}{af : ๐(a) โ A}{bf : ๐(๐ b) โ B}{n : ๐(b)} โ (concat af bf (maximum{n = a} ๐.+ n) โก Either.Right(bf(bound-๐ n)))
concat-left-pattern : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n : ๐(a โ.+ b)}{aa} โ (concat af bf n โก Either.Left(aa)) โ โ(k โฆ (af(k) โก aa))
concat-left-pattern {a = ๐} {๐} {af} {bf} {}
concat-left-pattern {a = ๐ a} {b} {af} {bf} {๐} {aa} p = [โ]-intro ๐ โฆ injective(Either.Left) p โฆ
concat-left-pattern {a = ๐ a} {๐} {af} {bf} {๐ n} {aa} p rewrite concat-is-left-on-0 {af = af}{bf = bf}{n = ๐ n} = [โ]-intro (๐(n)) โฆ injective(Either.Left) p โฆ
concat-left-pattern {a = ๐ a} {๐ b} {af} {bf} {๐ n} {aa} p with concat-left-pattern {a = a}{๐ b}{af โ ๐}{bf}{n}
... | q with q p
... | [โ]-intro witness โฆ proof โฆ = [โ]-intro (๐ witness) โฆ proof โฆ
concat-right-pattern : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n : ๐(a โ.+ b)}{bb} โ (concat af bf n โก Either.Right(bb)) โ โ(k โฆ (bf(k) โก bb))
concat-right-pattern {a = ๐} {๐} {af} {bf} {}
concat-right-pattern {a = ๐} {๐ b} {af} {bf} {๐} {bb} p = [โ]-intro ๐ โฆ injective(Either.Right) p โฆ
concat-right-pattern {a = ๐} {๐ b} {af} {bf} {๐ n} {bb} p = [โ]-intro (๐(n)) โฆ injective(Either.Right) p โฆ
concat-right-pattern {a = ๐ a} {๐} {af} {bf} {๐ n} {bb} p = concat-right-pattern {a = a}{๐} {af โ ๐}{bf} {n} {bb} p
concat-right-pattern {a = ๐ a} {๐ b} {af} {bf} {๐ n} {bb} p = concat-right-pattern {a = a}{๐ b}{af โ ๐}{bf}{n} p
concat-left-or-right : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n : ๐(a โ.+ b)} โ โ(aa โฆ concat af bf n โก Either.Left(af(aa))) โจ โ(bb โฆ concat af bf n โก Either.Right(bf(bb)))
concat-left-or-right {a = a} {b} {af} {bf} {n} with concat af bf n | inspect (concat af bf) n
... | [โจ]-introโ aa | intro q with [โ]-intro r โฆ rp โฆ โ concat-left-pattern{a = a}{b}{af}{bf}{n}{aa} q = [โจ]-introโ ([โ]-intro r โฆ [โก]-with(Either.Left) (symmetry(_โก_) rp) โฆ)
... | [โจ]-introแตฃ bb | intro q with [โ]-intro r โฆ rp โฆ โ concat-right-pattern{a = a}{b}{af}{bf}{n}{bb} q = [โจ]-introแตฃ ([โ]-intro r โฆ [โก]-with(Either.Right) (symmetry(_โก_) rp) โฆ)
instance
concat-injective : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B} โ โฆ Injective(af) โฆ โ โฆ Injective(bf) โฆ โ Injective(concat af bf)
Injective.proof (concat-injective {a = ๐} {๐ b} {af} {bf}) {x} {y} p = injective(bf) (injective(Either.Right) p)
Injective.proof (concat-injective {a = ๐ a} {b} {af} {bf}) {๐} {๐} p = [โก]-intro
Injective.proof (concat-injective {a = ๐ a} {๐} {af} {bf}) {๐} {๐ y} p rewrite concat-is-left-on-0 {af = af}{bf = bf}{n = ๐ y} with () โ injective(af) (injective(Either.Left) p)
Injective.proof (concat-injective {a = ๐ a} {๐} {af} {bf}) {๐ x} {๐} p rewrite concat-is-left-on-0 {af = af}{bf = bf}{n = ๐ x} with () โ injective(af) (injective(Either.Left) p)
Injective.proof (concat-injective {a = ๐ a} {๐ b} {af} {bf}) {๐} {๐ y} p with concat-left-or-right{af = af โ ๐}{bf = bf}{n = y}
... | [โจ]-introโ ([โ]-intro _ โฆ proof โฆ) with () โ injective(af) (injective(Either.Left) (p ๐ proof))
... | [โจ]-introแตฃ ([โ]-intro _ โฆ proof โฆ) with () โ p ๐ proof
Injective.proof (concat-injective {a = ๐ a} {๐ b} {af} {bf}) {๐ x} {๐} p with concat-left-or-right{af = af โ ๐}{bf = bf}{n = x}
... | [โจ]-introโ ([โ]-intro _ โฆ proof โฆ) with () โ injective(af) (injective(Either.Left) (symmetry(_โก_) p ๐ proof))
... | [โจ]-introแตฃ ([โ]-intro _ โฆ proof โฆ) with () โ symmetry(_โก_) p ๐ proof
{-# CATCHALL #-}
Injective.proof (concat-injective {a = ๐ a} {b} {af} {bf}) {๐ x} {๐ y} p = congruenceโ(๐) (Injective.proof (concat-injective {a = a} {b} {af โ ๐} {bf} โฆ [โ]-injective {f = af}{g = ๐} โฆ) {x} {y} p)
concat-when-left : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n} โ โ(aa โฆ concat af bf n โก Either.Left(aa)) โ (๐-to-โ(n) < a)
concat-when-left {a = a} {b} {af} {bf} {n} = [โ]-intro l r where
l : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n} โ โ(aa โฆ concat af bf n โก Either.Left(aa)) โ (๐-to-โ(n) < a)
l {a = .(๐ _)} {b} {af} {bf} {๐} [โค]-with-[๐] = [โ]-intro (af(๐)) โฆ reflexivity(_โก_) โฆ
l {a = .(๐ _)} {b} {af} {bf} {๐ n} ([โค]-with-[๐] {y = a} โฆ p โฆ) = l {a = a}{b}{af โ ๐}{bf}{n} p
r : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n} โ โ(aa โฆ concat af bf n โก Either.Left(aa)) โ (๐-to-โ(n) < a)
r {a = ๐} {b} {af} {bf} {๐} ([โ]-intro aa โฆ โฆ)
r {a = ๐ a} {b} {af} {bf} {๐} ([โ]-intro aa โฆ p โฆ) = [<]-minimum
r {a = ๐ a} {b} {af} {bf} {๐ n} ([โ]-intro aa โฆ p โฆ) = [โค]-with-[๐] โฆ r {a = a}{b}{af โ ๐}{bf}{n} ([โ]-intro aa โฆ p โฆ) โฆ
concat-when-right : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n} โ โ(bb โฆ concat af bf n โก Either.Right(bb)) โ (a โค ๐-to-โ(n))
concat-when-right {a = a} {b} {af} {bf} {n} = [โ]-intro l r where
l : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n} โ โ(bb โฆ concat af bf n โก Either.Right(bb)) โ (a โค ๐-to-โ(n))
l {a = ๐} {๐ b} {af} {bf} {n} [โค]-minimum = [โ]-intro (bf(n)) โฆ reflexivity(_โก_) โฆ
l {a = ๐ a} {b} {af} {bf} {๐ n} ([โค]-with-[๐] โฆ p โฆ) = l {a = a}{b}{af โ ๐}{bf}{n} p
r : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n} โ โ(bb โฆ concat af bf n โก Either.Right(bb)) โ (a โค ๐-to-โ(n))
r {a = ๐} {b} {af} {bf} {_} ([โ]-intro bb โฆ p โฆ) = [โค]-minimum
r {a = ๐ a} {b} {af} {bf} {๐} ([โ]-intro bb โฆ โฆ)
r {a = ๐ a} {b} {af} {bf} {๐ n} ([โ]-intro bb โฆ p โฆ) = [โค]-with-[๐] โฆ r {a = a}{b}{af โ ๐}{bf}{n} ([โ]-intro bb โฆ p โฆ) โฆ
๐-shrink : โ{A B} โ (b : ๐(B)) โ (๐-to-โ(b) < A) โ ๐(A)
๐-shrink {๐ A}{๐ B} ๐ [โค]-with-[๐] = ๐
๐-shrink {๐ A}{๐ B} (๐ b) ([โค]-with-[๐] โฆ p โฆ) = ๐(๐-shrink {A}{B} b p)
๐-subtract : โ{A B} โ (b : ๐(B)) โ (A < ๐-to-โ(b)) โ ๐(๐(A))
๐-subtract {๐} {๐ B} (๐ b) [โค]-with-[๐] = ๐
๐-subtract {๐ A}{๐ B} (๐ b) ([โค]-with-[๐] โฆ p โฆ) = ๐(๐-subtract {A}{B} b p)
concat-when-lesser : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{n} โ (na : ๐-to-โ(n) < a) โ (concat af bf n โก Either.Left(af(๐-shrink n na)))
concat-when-lesser {a = ๐ a} {b} {af} {bf} {๐} [โค]-with-[๐] = [โก]-intro
concat-when-lesser {a = ๐ a} {b} {af} {bf} {๐ n} ([โค]-with-[๐] โฆ p โฆ) = concat-when-lesser {a = a} {b} {af โ ๐} {bf} {n} p
{-
open import Numeral.Natural.Relation.Order.Proofs
concat-when-greater : โ{a b}{af : ๐(a) โ A}{bf : ๐(๐(b)) โ B}{n} โ (bn : ๐(b) < ๐-to-โ(n)) โ (concat af bf n โก Either.Right(bf(๐-subtract n ([โค]-predecessor bn))))
concat-when-greater {a = ๐} {๐ b} {af} {bf} {๐ n} [โค]-with-[๐] = {!!}
concat-when-greater {a = ๐ a} {๐} {af} {bf} {๐ n} ([โค]-with-[๐] {y = y} โฆ p โฆ) with n | ๐-to-โ n
... | ๐ | ๐ = {!concat-when-greater {a = a} {?} {af โ ๐} {bf} {๐}!}
... | ๐ | ๐ bb = {!!}
... | ๐ aa | ๐ = {!!}
... | ๐ aa | ๐ bb = {!!}
concat-when-greater {a = ๐ a} {๐ b} {af} {bf} {๐ n} ([โค]-with-[๐] {y = _} โฆ p โฆ) = {!concat-when-greater {a = a} {๐ b} {af โ ๐} {bf} {n}!}
open import Numeral.Natural.Relation.Order.Proofs
bound-[โค]-of-refl : โ{n}{x} โ (bound-[โค] (reflexivity(_โค_) {n}) x โก x)
bound-[โค]-of-refl {๐ n} {๐} = [โก]-intro
bound-[โค]-of-refl {๐ n} {๐ x} = [โก]-with(๐) (bound-[โค]-of-refl {n}{x})
concat-surjective-left : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B}{x} โ โฆ Surjective(af) โฆ โ โ(n โฆ concat af bf n โก Either.Left(x))
concat-surjective-left {a = ๐} {b} {af} {bf} {x} with () โ [โ]-witness(surjective(af) {x})
concat-surjective-left {a = ๐ a} {b} {af} {bf} {x} with [โ]-intro x โฆ q โฆ โ [โ]-to-[โ] (concat-when-left {a = ๐ a}{b}{af}{bf}{{!!}}) {!!} = {!!}
{-โ.witness (concat-surjective-left {a = a} {b} {af} {bf} {x}) = bound-[โค] ([โค]-of-[+]โ {y = b}) ([โ]-witness(surjective(af) {x}))
โ.proof (concat-surjective-left {a = ๐} {_} {af} {bf} {x}) with () โ [โ]-witness(surjective(af) {x})
โ.proof (concat-surjective-left {a = ๐ a} {๐} {af} {bf} {x}) rewrite bound-[โค]-of-refl {๐ a}{[โ]-witness(surjective(af) {x})} with surjective(af) {x}
... | [โ]-intro ๐ โฆ p โฆ = congruenceโ(Either.Left) p
... | [โ]-intro (๐ c) โฆ p โฆ with [โ]-intro x โฆ q โฆ โ [โ]-to-[โ] (concat-when-left {a = ๐ a}{๐}{af}{bf}{๐ c}) {!!} = {!!}
โ.proof (concat-surjective-left {a = ๐ a} {๐ b} {af} {bf} {x}) = {!!}-}
-}
interleave-join-equality : โ{af : ๐(a) โ A}{bf : ๐(b) โ B} โ (interleave af bf โ Interleaving.join โ Either.map af bf)
interleave-join-equality {a = a}{b = b} = intro(p{a = a}{b = b}) where
p : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B} โ (interleave af bf โ Interleaving.join Names.โ Either.map af bf)
p {a = ๐} {b = ๐ b} {af}{bf} {Either.Right n} = [โก]-intro
p {a = ๐ a}{b = ๐} {af}{bf} {Either.Left n} = [โก]-intro
p {a = ๐ a}{b = ๐ b} {af}{bf} {Either.Left ๐} = [โก]-intro
p {a = ๐ a}{b = ๐ b} {af}{bf} {Either.Right ๐} = [โก]-intro
p {a = ๐ a}{b = ๐ b} {af}{bf} {Either.Left (๐ n)} = p {a = a}{b = b} {af โ ๐}{bf โ ๐} {Either.Left n}
p {a = ๐ a}{b = ๐ b} {af}{bf} {Either.Right (๐ n)} = p {a = a}{b = b} {af โ ๐}{bf โ ๐} {Either.Right n}
interleave-split-equality : โ{af : ๐(a) โ A}{bf : ๐(b) โ B} โ (interleave af bf โ Either.map af bf โ Interleaving.split)
interleave-split-equality {a = a}{b = b}{af = af}{bf = bf} =
interleave af bf ๐[ _โ_ ]-[]
interleave af bf โ id ๐[ _โ_ ]-[ congruenceโแตฃ(_โ_)(interleave af bf) (intro(inverseแตฃ(Interleaving.join{a}{b})(Interleaving.split{a}{b}))) ]-sym
interleave af bf โ Interleaving.join{a}{b} โ Interleaving.split ๐[ _โ_ ]-[ congruenceโโ(_โ_)(Interleaving.split) (interleave-join-equality{a = a}{b = b}{af = af}{bf = bf}) ]
Either.map af bf โ Interleaving.split ๐-end
instance
interleave-injective : โ{af : ๐(a) โ A}{bf : ๐(b) โ B} โ โฆ Injective(af) โฆ โ โฆ Injective(bf) โฆ โ Injective(interleave af bf)
interleave-injective {a = a}{b = b}{af = af}{bf = bf} = substituteโโ(Injective) (interleave-split-equality {af = af}{bf = bf}) ([โ]-injective {f = Either.map af bf}{g = Interleaving.split} โฆ inj-g = inverse-to-injective โฆ inver = [โง]-intro Interleaving.join-split-inverse Interleaving.split-join-inverse โฆ โฆ)
instance
interleave-surjective : โ{af : ๐(a) โ A}{bf : ๐(b) โ B} โ โฆ Surjective(af) โฆ โ โฆ Surjective(bf) โฆ โ Surjective(interleave af bf)
interleave-surjective {a = a}{b = b}{af = af}{bf = bf} = substituteโโ(Surjective) (interleave-split-equality {af = af}{bf = bf}) ([โ]-surjective {f = Either.map af bf}{g = Interleaving.split} โฆ surj-g = inverse-to-surjective โฆ inver = [โง]-intro Interleaving.join-split-inverse Interleaving.split-join-inverse โฆ โฆ)
instance
interleave-bijective : โ{af : ๐(a) โ A}{bf : ๐(b) โ B} โ โฆ Bijective(af) โฆ โ โฆ Bijective(bf) โฆ โ Bijective(interleave af bf)
interleave-bijective {a = a}{b = b}{af = af}{bf = bf} = substituteโโ(Bijective) (interleave-split-equality {af = af}{bf = bf}) ([โ]-bijective {f = Either.map af bf}{g = Interleaving.split} โฆ bij-g = inverse-to-bijective โฆ inver = [โง]-intro Interleaving.join-split-inverse Interleaving.split-join-inverse โฆ โฆ)
concat-split-equality : โ{af : ๐(a) โ A}{bf : ๐(b) โ B} โ (concat af bf โ Either.map af bf โ Concatenation.split)
concat-split-equality {a = a}{b = b} = intro(p{a = a}{b = b}) where
p : โ{a b}{af : ๐(a) โ A}{bf : ๐(b) โ B} โ (concat af bf Names.โ Either.map af bf โ Concatenation.split)
p {a = ๐} {b = ๐ b} {af = af}{bf = bf} {n} = [โก]-intro
p {a = ๐ a} {b = ๐} {af = af}{bf = bf} {๐} = [โก]-intro
p {a = ๐(๐ a)}{b = ๐} {af = af}{bf = bf} {๐ n} = p{a = ๐ a}{b = ๐}{af = af โ ๐}{bf = bf}{n}
p {a = ๐ a} {b = ๐ b} {af = af}{bf = bf} {๐} = [โก]-intro
p {a = ๐ a} {b = ๐ b} {af = af}{bf = bf} {๐ n} with Concatenation.split {a}{๐ b} n | p {a = a} {b = ๐ b} {af = af โ ๐} {bf = bf} {n}
... | Either.Left _ | prev = prev
... | Either.Right _ | prev = prev
-- TODO: It is possible to copy-paste the proofs of inj/surj/bijectivity with a few modifications from Interleaving and apply it to Concatenation
-}
| {
"alphanum_fraction": 0.545458603,
"avg_line_length": 59.1160949868,
"ext": "agda",
"hexsha": "5f63700642e96422e84ef1ccc91a8926fcf86c58",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Finite/Sequence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Finite/Sequence.agda",
"max_line_length": 315,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Finite/Sequence.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 10753,
"size": 22405
} |
open import Agda.Primitive
open import Data.Nat using (โ)
data โ {nโ : Level} {nโ : Level} (A : Set nโ) (P : A โ Set nโ) : Set (nโ โ nโ) where
sum : (a : A) โ (pa : P a) โ โ A P
data List {n : Level} (t : Set n) : Set n where
_::_ : t โ List t โ List t
[] : List t
data Unit {n : Level} : Set n where
## : Unit
heterohomo : List (โ Set ฮป x โ x)
heterohomo = (sum โ 0) :: ((sum (List Unit) (## :: [])) :: ((sum Unit ##) :: []))
| {
"alphanum_fraction": 0.509009009,
"avg_line_length": 26.1176470588,
"ext": "agda",
"hexsha": "3b89cf673749db0105effb12bec508d4201f8fbb",
"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": "ad7278cc2a5152fde242e9be5961ce907ab482a5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Mikotochan/csders",
"max_forks_repo_path": "agda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ad7278cc2a5152fde242e9be5961ce907ab482a5",
"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": "Mikotochan/csders",
"max_issues_repo_path": "agda.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ad7278cc2a5152fde242e9be5961ce907ab482a5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Mikotochan/csders",
"max_stars_repo_path": "agda.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 182,
"size": 444
} |
module AbsurdLam where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Fin : Nat -> Set where
fzero : forall {n} -> Fin (suc n)
fsuc : forall {n} -> Fin n -> Fin (suc n)
data False : Set where
elimFalse : (A : Set) -> False -> A
elimFalse A = \()
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
magic : forall {n} -> suc n == zero -> False
magic = \()
hidden : Nat -> {x : Fin zero} -> False
hidden = \n {}
| {
"alphanum_fraction": 0.546275395,
"avg_line_length": 17.72,
"ext": "agda",
"hexsha": "929a6700aba010b175b48cec37955443fbe775f8",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/AbsurdLam.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/AbsurdLam.agda",
"max_line_length": 44,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/AbsurdLam.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": 156,
"size": 443
} |
module UnequalRelevance where
postulate
A : Set
f : .A -> A
g : (A -> A) -> A -> A
-- this should fail because
-- cannot use irrelevant function where relevant is needed
h : A -> A
h = g f -- error: function types are not equal because one is relevant and the other not | {
"alphanum_fraction": 0.6690647482,
"avg_line_length": 25.2727272727,
"ext": "agda",
"hexsha": "889aa2ac638c0cbd9c371fdd99031cead9558260",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/agda-kanso",
"max_forks_repo_path": "test/fail/UnequalRelevance.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/agda-kanso",
"max_issues_repo_path": "test/fail/UnequalRelevance.agda",
"max_line_length": 89,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/UnequalRelevance.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 79,
"size": 278
} |
{-# OPTIONS --rewriting #-}
module Properties.TypeSaturation where
open import Agda.Builtin.Equality using (_โก_; refl)
open import FFI.Data.Either using (Either; Left; Right)
open import Luau.Subtyping using (Tree; Language; ยฌLanguage; _<:_; _โฎ:_; witness; scalar; function; function-err; function-ok; function-okโ; function-okโ; scalar-function; _,_; never)
open import Luau.Type using (Type; _โ_; _โฉ_; _โช_; never; unknown)
open import Luau.TypeNormalization using (_โฉโฟ_; _โชโฟ_)
open import Luau.TypeSaturation using (_โ_; _โ_; _โฉแต_; _โฉโฑ_; โช-saturate; โฉ-saturate; saturate)
open import Properties.Subtyping using (dec-language; language-comp; <:-impl-โ; <:-refl; <:-trans; <:-trans-โฎ:; <:-impl-ยฌโฎ: ; <:-never; <:-unknown; <:-function; <:-union; <:-โช-symm; <:-โช-left; <:-โช-right; <:-โช-lub; <:-โช-assocl; <:-โช-assocr; <:-intersect; <:-โฉ-symm; <:-โฉ-left; <:-โฉ-right; <:-โฉ-glb; โฎ:-function-left; โฎ:-function-right; <:-function-โฉ-โช; <:-function-โฉ-โฉ; <:-โฉ-assocl; <:-โฉ-assocr; โฉ-<:-โช; <:-โฉ-distl-โช; โฉ-distl-โช-<:; <:-โฉ-distr-โช; โฉ-distr-โช-<:)
open import Properties.TypeNormalization using (Normal; FunType; _โ_; _โฉ_; _โช_; never; unknown; normal-โชโฟ; normal-โฉโฟ; โชโฟ-<:-โช; โช-<:-โชโฟ; โฉโฟ-<:-โฉ; โฉ-<:-โฉโฟ)
open import Properties.Contradiction using (CONTRADICTION)
open import Properties.Functions using (_โ_)
-- Saturation preserves normalization
normal-โ : โ {F G} โ FunType F โ FunType G โ FunType (F โ G)
normal-โ (R โ S) (T โ U) = (normal-โฉโฟ R T) โ (normal-โฉโฟ S U)
normal-โ (R โ S) (G โฉ H) = normal-โ (R โ S) G โฉ normal-โ (R โ S) H
normal-โ (E โฉ F) G = normal-โ E G โฉ normal-โ F G
normal-โ : โ {F G} โ FunType F โ FunType G โ FunType (F โ G)
normal-โ (R โ S) (T โ U) = (normal-โชโฟ R T) โ (normal-โชโฟ S U)
normal-โ (R โ S) (G โฉ H) = normal-โ (R โ S) G โฉ normal-โ (R โ S) H
normal-โ (E โฉ F) G = normal-โ E G โฉ normal-โ F G
normal-โฉ-saturate : โ {F} โ FunType F โ FunType (โฉ-saturate F)
normal-โฉ-saturate (S โ T) = S โ T
normal-โฉ-saturate (F โฉ G) = (normal-โฉ-saturate F โฉ normal-โฉ-saturate G) โฉ normal-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G)
normal-โช-saturate : โ {F} โ FunType F โ FunType (โช-saturate F)
normal-โช-saturate (S โ T) = S โ T
normal-โช-saturate (F โฉ G) = (normal-โช-saturate F โฉ normal-โช-saturate G) โฉ normal-โ (normal-โช-saturate F) (normal-โช-saturate G)
normal-saturate : โ {F} โ FunType F โ FunType (saturate F)
normal-saturate F = normal-โช-saturate (normal-โฉ-saturate F)
-- Saturation resects subtyping
โช-saturate-<: : โ {F} โ FunType F โ โช-saturate F <: F
โช-saturate-<: (S โ T) = <:-refl
โช-saturate-<: (F โฉ G) = <:-trans <:-โฉ-left (<:-intersect (โช-saturate-<: F) (โช-saturate-<: G))
โฉ-saturate-<: : โ {F} โ FunType F โ โฉ-saturate F <: F
โฉ-saturate-<: (S โ T) = <:-refl
โฉ-saturate-<: (F โฉ G) = <:-trans <:-โฉ-left (<:-intersect (โฉ-saturate-<: F) (โฉ-saturate-<: G))
saturate-<: : โ {F} โ FunType F โ saturate F <: F
saturate-<: F = <:-trans (โช-saturate-<: (normal-โฉ-saturate F)) (โฉ-saturate-<: F)
โฉ-<:-โ : โ {F G} โ FunType F โ FunType G โ (F โฉ G) <: (F โ G)
โฉ-<:-โ (R โ S) (T โ U) = <:-trans <:-function-โฉ-โช (<:-function (โชโฟ-<:-โช R T) (โช-<:-โชโฟ S U))
โฉ-<:-โ (R โ S) (G โฉ H) = <:-trans (<:-โฉ-glb (<:-intersect <:-refl <:-โฉ-left) (<:-intersect <:-refl <:-โฉ-right)) (<:-intersect (โฉ-<:-โ (R โ S) G) (โฉ-<:-โ (R โ S) H))
โฉ-<:-โ (E โฉ F) G = <:-trans (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-refl) (<:-intersect <:-โฉ-right <:-refl)) (<:-intersect (โฉ-<:-โ E G) (โฉ-<:-โ F G))
โฉ-<:-โ : โ {F G} โ FunType F โ FunType G โ (F โฉ G) <: (F โ G)
โฉ-<:-โ (R โ S) (T โ U) = <:-trans <:-function-โฉ-โฉ (<:-function (โฉโฟ-<:-โฉ R T) (โฉ-<:-โฉโฟ S U))
โฉ-<:-โ (R โ S) (G โฉ H) = <:-trans (<:-โฉ-glb (<:-intersect <:-refl <:-โฉ-left) (<:-intersect <:-refl <:-โฉ-right)) (<:-intersect (โฉ-<:-โ (R โ S) G) (โฉ-<:-โ (R โ S) H))
โฉ-<:-โ (E โฉ F) G = <:-trans (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-refl) (<:-intersect <:-โฉ-right <:-refl)) (<:-intersect (โฉ-<:-โ E G) (โฉ-<:-โ F G))
<:-โช-saturate : โ {F} โ FunType F โ F <: โช-saturate F
<:-โช-saturate (S โ T) = <:-refl
<:-โช-saturate (F โฉ G) = <:-โฉ-glb (<:-intersect (<:-โช-saturate F) (<:-โช-saturate G)) (<:-trans (<:-intersect (<:-โช-saturate F) (<:-โช-saturate G)) (โฉ-<:-โ (normal-โช-saturate F) (normal-โช-saturate G)))
<:-โฉ-saturate : โ {F} โ FunType F โ F <: โฉ-saturate F
<:-โฉ-saturate (S โ T) = <:-refl
<:-โฉ-saturate (F โฉ G) = <:-โฉ-glb (<:-intersect (<:-โฉ-saturate F) (<:-โฉ-saturate G)) (<:-trans (<:-intersect (<:-โฉ-saturate F) (<:-โฉ-saturate G)) (โฉ-<:-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G)))
<:-saturate : โ {F} โ FunType F โ F <: saturate F
<:-saturate F = <:-trans (<:-โฉ-saturate F) (<:-โช-saturate (normal-โฉ-saturate F))
-- Overloads F is the set of overloads of F
data Overloads : Type โ Type โ Set where
here : โ {S T} โ Overloads (S โ T) (S โ T)
left : โ {S T F G} โ Overloads F (S โ T) โ Overloads (F โฉ G) (S โ T)
right : โ {S T F G} โ Overloads G (S โ T) โ Overloads (F โฉ G) (S โ T)
normal-overload-src : โ {F S T} โ FunType F โ Overloads F (S โ T) โ Normal S
normal-overload-src (S โ T) here = S
normal-overload-src (F โฉ G) (left o) = normal-overload-src F o
normal-overload-src (F โฉ G) (right o) = normal-overload-src G o
normal-overload-tgt : โ {F S T} โ FunType F โ Overloads F (S โ T) โ Normal T
normal-overload-tgt (S โ T) here = T
normal-overload-tgt (F โฉ G) (left o) = normal-overload-tgt F o
normal-overload-tgt (F โฉ G) (right o) = normal-overload-tgt G o
-- An inductive presentation of the overloads of F โ G
data โช-Lift (P Q : Type โ Set) : Type โ Set where
union : โ {R S T U} โ
P (R โ S) โ
Q (T โ U) โ
--------------------
โช-Lift P Q ((R โช T) โ (S โช U))
-- An inductive presentation of the overloads of F โ G
data โฉ-Lift (P Q : Type โ Set) : Type โ Set where
intersect : โ {R S T U} โ
P (R โ S) โ
Q (T โ U) โ
--------------------
โฉ-Lift P Q ((R โฉ T) โ (S โฉ U))
-- An inductive presentation of the overloads of โช-saturate F
data โช-Saturate (P : Type โ Set) : Type โ Set where
base : โ {S T} โ
P (S โ T) โ
--------------------
โช-Saturate P (S โ T)
union : โ {R S T U} โ
โช-Saturate P (R โ S) โ
โช-Saturate P (T โ U) โ
--------------------
โช-Saturate P ((R โช T) โ (S โช U))
-- An inductive presentation of the overloads of โฉ-saturate F
data โฉ-Saturate (P : Type โ Set) : Type โ Set where
base : โ {S T} โ
P (S โ T) โ
--------------------
โฉ-Saturate P (S โ T)
intersect : โ {R S T U} โ
โฉ-Saturate P (R โ S) โ
โฉ-Saturate P (T โ U) โ
--------------------
โฉ-Saturate P ((R โฉ T) โ (S โฉ U))
-- The <:-up-closure of a set of function types
data <:-Close (P : Type โ Set) : Type โ Set where
defn : โ {R S T U} โ
P (S โ T) โ
R <: S โ
T <: U โ
------------------
<:-Close P (R โ U)
-- F โแต G whenever every overload of F is an overload of G
_โแต_ : Type โ Type โ Set
F โแต G = โ {S T} โ Overloads F (S โ T) โ Overloads G (S โ T)
-- F <:แต G when every overload of G is a supertype of an overload of F
_<:แต_ : Type โ Type โ Set
_<:แต_ F G = โ {S T} โ Overloads G (S โ T) โ <:-Close (Overloads F) (S โ T)
-- P โ: Q when any type in P is a subtype of some type in Q
_โ:_ : (Type โ Set) โ (Type โ Set) โ Set
P โ: Q = โ {S T} โ P (S โ T) โ <:-Close Q (S โ T)
-- <:-Close is a monad
just : โ {P S T} โ P (S โ T) โ <:-Close P (S โ T)
just p = defn p <:-refl <:-refl
infixl 5 _>>=_ _>>=หก_ _>>=สณ_
_>>=_ : โ {P Q S T} โ <:-Close P (S โ T) โ (P โ: Q) โ <:-Close Q (S โ T)
(defn p pโ pโ) >>= PโQ with PโQ p
(defn p pโ pโ) >>= PโQ | defn q qโ qโ = defn q (<:-trans pโ qโ) (<:-trans qโ pโ)
_>>=หก_ : โ {P R S T} โ <:-Close P (S โ T) โ (R <: S) โ <:-Close P (R โ T)
(defn p pโ pโ) >>=หก q = defn p (<:-trans q pโ) pโ
_>>=สณ_ : โ {P S T U} โ <:-Close P (S โ T) โ (T <: U) โ <:-Close P (S โ U)
(defn p pโ pโ) >>=สณ q = defn p pโ (<:-trans pโ q)
-- Properties of โ:
โ:-refl : โ {P} โ P โ: P
โ:-refl p = just p
_[โช]_ : โ {P Q R S T U} โ <:-Close P (R โ S) โ <:-Close Q (T โ U) โ <:-Close (โช-Lift P Q) ((R โช T) โ (S โช U))
(defn p pโ pโ) [โช] (defn q qโ qโ) = defn (union p q) (<:-union pโ qโ) (<:-union pโ qโ)
_[โฉ]_ : โ {P Q R S T U} โ <:-Close P (R โ S) โ <:-Close Q (T โ U) โ <:-Close (โฉ-Lift P Q) ((R โฉ T) โ (S โฉ U))
(defn p pโ pโ) [โฉ] (defn q qโ qโ) = defn (intersect p q) (<:-intersect pโ qโ) (<:-intersect pโ qโ)
โ:-โฉ-saturate-inj : โ {P} โ P โ: โฉ-Saturate P
โ:-โฉ-saturate-inj p = defn (base p) <:-refl <:-refl
โ:-โช-saturate-inj : โ {P} โ P โ: โช-Saturate P
โ:-โช-saturate-inj p = just (base p)
โ:-โฉ-lift-saturate : โ {P} โ โฉ-Lift (โฉ-Saturate P) (โฉ-Saturate P) โ: โฉ-Saturate P
โ:-โฉ-lift-saturate (intersect p q) = just (intersect p q)
โ:-โช-lift-saturate : โ {P} โ โช-Lift (โช-Saturate P) (โช-Saturate P) โ: โช-Saturate P
โ:-โช-lift-saturate (union p q) = just (union p q)
โ:-โฉ-lift : โ {P Q R S} โ (P โ: Q) โ (R โ: S) โ (โฉ-Lift P R โ: โฉ-Lift Q S)
โ:-โฉ-lift PโQ RโS (intersect n o) = PโQ n [โฉ] RโS o
โ:-โช-lift : โ {P Q R S} โ (P โ: Q) โ (R โ: S) โ (โช-Lift P R โ: โช-Lift Q S)
โ:-โช-lift PโQ RโS (union n o) = PโQ n [โช] RโS o
โ:-โฉ-saturate : โ {P Q} โ (P โ: Q) โ (โฉ-Saturate P โ: โฉ-Saturate Q)
โ:-โฉ-saturate PโQ (base p) = PโQ p >>= โ:-โฉ-saturate-inj
โ:-โฉ-saturate PโQ (intersect p q) = (โ:-โฉ-saturate PโQ p [โฉ] โ:-โฉ-saturate PโQ q) >>= โ:-โฉ-lift-saturate
โ:-โช-saturate : โ {P Q} โ (P โ: Q) โ (โช-Saturate P โ: โช-Saturate Q)
โ:-โช-saturate PโQ (base p) = PโQ p >>= โ:-โช-saturate-inj
โ:-โช-saturate PโQ (union p q) = (โ:-โช-saturate PโQ p [โช] โ:-โช-saturate PโQ q) >>= โ:-โช-lift-saturate
โ:-โฉ-saturate-indn : โ {P Q} โ (P โ: Q) โ (โฉ-Lift Q Q โ: Q) โ (โฉ-Saturate P โ: Q)
โ:-โฉ-saturate-indn PโQ QQโQ (base p) = PโQ p
โ:-โฉ-saturate-indn PโQ QQโQ (intersect p q) = (โ:-โฉ-saturate-indn PโQ QQโQ p [โฉ] โ:-โฉ-saturate-indn PโQ QQโQ q) >>= QQโQ
โ:-โช-saturate-indn : โ {P Q} โ (P โ: Q) โ (โช-Lift Q Q โ: Q) โ (โช-Saturate P โ: Q)
โ:-โช-saturate-indn PโQ QQโQ (base p) = PโQ p
โ:-โช-saturate-indn PโQ QQโQ (union p q) = (โ:-โช-saturate-indn PโQ QQโQ p [โช] โ:-โช-saturate-indn PโQ QQโQ q) >>= QQโQ
โช-saturate-resp-โฉ-saturation : โ {P} โ (โฉ-Lift P P โ: P) โ (โฉ-Lift (โช-Saturate P) (โช-Saturate P) โ: โช-Saturate P)
โช-saturate-resp-โฉ-saturation โฉPโP (intersect (base p) (base q)) = โฉPโP (intersect p q) >>= โ:-โช-saturate-inj
โช-saturate-resp-โฉ-saturation โฉPโP (intersect p (union q qโ)) = (โช-saturate-resp-โฉ-saturation โฉPโP (intersect p q) [โช] โช-saturate-resp-โฉ-saturation โฉPโP (intersect p qโ)) >>= โ:-โช-lift-saturate >>=หก <:-โฉ-distl-โช >>=สณ โฉ-distl-โช-<:
โช-saturate-resp-โฉ-saturation โฉPโP (intersect (union p pโ) q) = (โช-saturate-resp-โฉ-saturation โฉPโP (intersect p q) [โช] โช-saturate-resp-โฉ-saturation โฉPโP (intersect pโ q)) >>= โ:-โช-lift-saturate >>=หก <:-โฉ-distr-โช >>=สณ โฉ-distr-โช-<:
ov-language : โ {F t} โ FunType F โ (โ {S T} โ Overloads F (S โ T) โ Language (S โ T) t) โ Language F t
ov-language (S โ T) p = p here
ov-language (F โฉ G) p = (ov-language F (p โ left) , ov-language G (p โ right))
ov-<: : โ {F R S T U} โ FunType F โ Overloads F (R โ S) โ ((R โ S) <: (T โ U)) โ F <: (T โ U)
ov-<: F here p = p
ov-<: (F โฉ G) (left o) p = <:-trans <:-โฉ-left (ov-<: F o p)
ov-<: (F โฉ G) (right o) p = <:-trans <:-โฉ-right (ov-<: G o p)
<:แต-impl-<: : โ {F G} โ FunType F โ FunType G โ (F <:แต G) โ (F <: G)
<:แต-impl-<: F (T โ U) F<G with F<G here
<:แต-impl-<: F (T โ U) F<G | defn o oโ oโ = ov-<: F o (<:-function oโ oโ)
<:แต-impl-<: F (G โฉ H) F<G = <:-โฉ-glb (<:แต-impl-<: F G (F<G โ left)) (<:แต-impl-<: F H (F<G โ right))
โ:-overloads-left : โ {F G} โ Overloads F โ: Overloads (F โฉ G)
โ:-overloads-left p = just (left p)
โ:-overloads-right : โ {F G} โ Overloads G โ: Overloads (F โฉ G)
โ:-overloads-right p = just (right p)
โ:-overloads-โ : โ {F G} โ FunType F โ FunType G โ โฉ-Lift (Overloads F) (Overloads G) โ: Overloads (F โ G)
โ:-overloads-โ (R โ S) (T โ U) (intersect here here) = defn here (โฉ-<:-โฉโฟ R T) (โฉโฟ-<:-โฉ S U)
โ:-overloads-โ (R โ S) (G โฉ H) (intersect here (left o)) = โ:-overloads-โ (R โ S) G (intersect here o) >>= โ:-overloads-left
โ:-overloads-โ (R โ S) (G โฉ H) (intersect here (right o)) = โ:-overloads-โ (R โ S) H (intersect here o) >>= โ:-overloads-right
โ:-overloads-โ (E โฉ F) G (intersect (left n) o) = โ:-overloads-โ E G (intersect n o) >>= โ:-overloads-left
โ:-overloads-โ (E โฉ F) G (intersect (right n) o) = โ:-overloads-โ F G (intersect n o) >>= โ:-overloads-right
โ:-โ-overloads : โ {F G} โ FunType F โ FunType G โ Overloads (F โ G) โ: โฉ-Lift (Overloads F) (Overloads G)
โ:-โ-overloads (R โ S) (T โ U) here = defn (intersect here here) (โฉโฟ-<:-โฉ R T) (โฉ-<:-โฉโฟ S U)
โ:-โ-overloads (R โ S) (G โฉ H) (left o) = โ:-โ-overloads (R โ S) G o >>= โ:-โฉ-lift โ:-refl โ:-overloads-left
โ:-โ-overloads (R โ S) (G โฉ H) (right o) = โ:-โ-overloads (R โ S) H o >>= โ:-โฉ-lift โ:-refl โ:-overloads-right
โ:-โ-overloads (E โฉ F) G (left o) = โ:-โ-overloads E G o >>= โ:-โฉ-lift โ:-overloads-left โ:-refl
โ:-โ-overloads (E โฉ F) G (right o) = โ:-โ-overloads F G o >>= โ:-โฉ-lift โ:-overloads-right โ:-refl
โ:-overloads-โ : โ {F G} โ FunType F โ FunType G โ โช-Lift (Overloads F) (Overloads G) โ: Overloads (F โ G)
โ:-overloads-โ (R โ S) (T โ U) (union here here) = defn here (โช-<:-โชโฟ R T) (โชโฟ-<:-โช S U)
โ:-overloads-โ (R โ S) (G โฉ H) (union here (left o)) = โ:-overloads-โ (R โ S) G (union here o) >>= โ:-overloads-left
โ:-overloads-โ (R โ S) (G โฉ H) (union here (right o)) = โ:-overloads-โ (R โ S) H (union here o) >>= โ:-overloads-right
โ:-overloads-โ (E โฉ F) G (union (left n) o) = โ:-overloads-โ E G (union n o) >>= โ:-overloads-left
โ:-overloads-โ (E โฉ F) G (union (right n) o) = โ:-overloads-โ F G (union n o) >>= โ:-overloads-right
โ:-โ-overloads : โ {F G} โ FunType F โ FunType G โ Overloads (F โ G) โ: โช-Lift (Overloads F) (Overloads G)
โ:-โ-overloads (R โ S) (T โ U) here = defn (union here here) (โชโฟ-<:-โช R T) (โช-<:-โชโฟ S U)
โ:-โ-overloads (R โ S) (G โฉ H) (left o) = โ:-โ-overloads (R โ S) G o >>= โ:-โช-lift โ:-refl โ:-overloads-left
โ:-โ-overloads (R โ S) (G โฉ H) (right o) = โ:-โ-overloads (R โ S) H o >>= โ:-โช-lift โ:-refl โ:-overloads-right
โ:-โ-overloads (E โฉ F) G (left o) = โ:-โ-overloads E G o >>= โ:-โช-lift โ:-overloads-left โ:-refl
โ:-โ-overloads (E โฉ F) G (right o) = โ:-โ-overloads F G o >>= โ:-โช-lift โ:-overloads-right โ:-refl
โช-saturate-overloads : โ {F} โ FunType F โ Overloads (โช-saturate F) โ: โช-Saturate (Overloads F)
โช-saturate-overloads (S โ T) here = just (base here)
โช-saturate-overloads (F โฉ G) (left (left o)) = โช-saturate-overloads F o >>= โ:-โช-saturate โ:-overloads-left
โช-saturate-overloads (F โฉ G) (left (right o)) = โช-saturate-overloads G o >>= โ:-โช-saturate โ:-overloads-right
โช-saturate-overloads (F โฉ G) (right o) =
โ:-โ-overloads (normal-โช-saturate F) (normal-โช-saturate G) o >>=
โ:-โช-lift (โช-saturate-overloads F) (โช-saturate-overloads G) >>=
โ:-โช-lift (โ:-โช-saturate โ:-overloads-left) (โ:-โช-saturate โ:-overloads-right) >>=
โ:-โช-lift-saturate
overloads-โช-saturate : โ {F} โ FunType F โ โช-Saturate (Overloads F) โ: Overloads (โช-saturate F)
overloads-โช-saturate F = โ:-โช-saturate-indn (inj F) (step F) where
inj : โ {F} โ FunType F โ Overloads F โ: Overloads (โช-saturate F)
inj (S โ T) here = just here
inj (F โฉ G) (left p) = inj F p >>= โ:-overloads-left >>= โ:-overloads-left
inj (F โฉ G) (right p) = inj G p >>= โ:-overloads-right >>= โ:-overloads-left
step : โ {F} โ FunType F โ โช-Lift (Overloads (โช-saturate F)) (Overloads (โช-saturate F)) โ: Overloads (โช-saturate F)
step (S โ T) (union here here) = defn here (<:-โช-lub <:-refl <:-refl) <:-โช-left
step (F โฉ G) (union (left (left p)) (left (left q))) = step F (union p q) >>= โ:-overloads-left >>= โ:-overloads-left
step (F โฉ G) (union (left (left p)) (left (right q))) = โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) (union p q) >>= โ:-overloads-right
step (F โฉ G) (union (left (right p)) (left (left q))) = โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) (union q p) >>= โ:-overloads-right >>=หก <:-โช-symm >>=สณ <:-โช-symm
step (F โฉ G) (union (left (right p)) (left (right q))) = step G (union p q) >>= โ:-overloads-right >>= โ:-overloads-left
step (F โฉ G) (union p (right q)) with โ:-โ-overloads (normal-โช-saturate F) (normal-โช-saturate G) q
step (F โฉ G) (union (left (left p)) (right q)) | defn (union qโ qโ) qโ qโ =
(step F (union p qโ) [โช] just qโ) >>=
โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-union <:-refl qโ) <:-โช-assocl >>=สณ
<:-trans <:-โช-assocr (<:-union <:-refl qโ)
step (F โฉ G) (union (left (right p)) (right q)) | defn (union qโ qโ) qโ qโ =
(just qโ [โช] step G (union p qโ)) >>=
โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-union <:-refl qโ) (<:-โช-lub (<:-trans <:-โช-left <:-โช-right) (<:-โช-lub <:-โช-left (<:-trans <:-โช-right <:-โช-right))) >>=สณ
<:-trans (<:-โช-lub (<:-trans <:-โช-left <:-โช-right) (<:-โช-lub <:-โช-left (<:-trans <:-โช-right <:-โช-right))) (<:-union <:-refl qโ)
step (F โฉ G) (union (right p) (right q)) | defn (union qโ qโ) qโ qโ with โ:-โ-overloads (normal-โช-saturate F) (normal-โช-saturate G) p
step (F โฉ G) (union (right p) (right q)) | defn (union qโ qโ) qโ qโ | defn (union pโ pโ) pโ pโ =
(step F (union pโ qโ) [โช] step G (union pโ qโ)) >>=
โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-union pโ qโ) (<:-โช-lub (<:-union <:-โช-left <:-โช-left) (<:-union <:-โช-right <:-โช-right)) >>=สณ
<:-trans (<:-โช-lub (<:-union <:-โช-left <:-โช-left) (<:-union <:-โช-right <:-โช-right)) (<:-union pโ qโ)
step (F โฉ G) (union (right p) q) with โ:-โ-overloads (normal-โช-saturate F) (normal-โช-saturate G) p
step (F โฉ G) (union (right p) (left (left q))) | defn (union pโ pโ) pโ pโ =
(step F (union pโ q) [โช] just pโ) >>=
โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-union pโ <:-refl) (<:-โช-lub (<:-union <:-โช-left <:-refl) (<:-trans <:-โช-right <:-โช-left)) >>=สณ
<:-trans (<:-โช-lub (<:-union <:-โช-left <:-refl) (<:-trans <:-โช-right <:-โช-left)) (<:-union pโ <:-refl)
step (F โฉ G) (union (right p) (left (right q))) | defn (union pโ pโ) pโ pโ =
(just pโ [โช] step G (union pโ q)) >>=
โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-union pโ <:-refl) <:-โช-assocr >>=สณ
<:-trans <:-โช-assocl (<:-union pโ <:-refl)
step (F โฉ G) (union (right p) (right q)) | defn (union pโ pโ) pโ pโ with โ:-โ-overloads (normal-โช-saturate F) (normal-โช-saturate G) q
step (F โฉ G) (union (right p) (right q)) | defn (union pโ pโ) pโ pโ | defn (union qโ qโ) qโ qโ =
(step F (union pโ qโ) [โช] step G (union pโ qโ)) >>=
โ:-overloads-โ (normal-โช-saturate F) (normal-โช-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-union pโ qโ) (<:-โช-lub (<:-union <:-โช-left <:-โช-left) (<:-union <:-โช-right <:-โช-right)) >>=สณ
<:-trans (<:-โช-lub (<:-union <:-โช-left <:-โช-left) (<:-union <:-โช-right <:-โช-right)) (<:-union pโ qโ)
โช-saturated : โ {F} โ FunType F โ โช-Lift (Overloads (โช-saturate F)) (Overloads (โช-saturate F)) โ: Overloads (โช-saturate F)
โช-saturated F o =
โ:-โช-lift (โช-saturate-overloads F) (โช-saturate-overloads F) o >>=
โ:-โช-lift-saturate >>=
overloads-โช-saturate F
โฉ-saturate-overloads : โ {F} โ FunType F โ Overloads (โฉ-saturate F) โ: โฉ-Saturate (Overloads F)
โฉ-saturate-overloads (S โ T) here = just (base here)
โฉ-saturate-overloads (F โฉ G) (left (left o)) = โฉ-saturate-overloads F o >>= โ:-โฉ-saturate โ:-overloads-left
โฉ-saturate-overloads (F โฉ G) (left (right o)) = โฉ-saturate-overloads G o >>= โ:-โฉ-saturate โ:-overloads-right
โฉ-saturate-overloads (F โฉ G) (right o) =
โ:-โ-overloads (normal-โฉ-saturate F) (normal-โฉ-saturate G) o >>=
โ:-โฉ-lift (โฉ-saturate-overloads F) (โฉ-saturate-overloads G) >>=
โ:-โฉ-lift (โ:-โฉ-saturate โ:-overloads-left) (โ:-โฉ-saturate โ:-overloads-right) >>=
โ:-โฉ-lift-saturate
overloads-โฉ-saturate : โ {F} โ FunType F โ โฉ-Saturate (Overloads F) โ: Overloads (โฉ-saturate F)
overloads-โฉ-saturate F = โ:-โฉ-saturate-indn (inj F) (step F) where
inj : โ {F} โ FunType F โ Overloads F โ: Overloads (โฉ-saturate F)
inj (S โ T) here = just here
inj (F โฉ G) (left p) = inj F p >>= โ:-overloads-left >>= โ:-overloads-left
inj (F โฉ G) (right p) = inj G p >>= โ:-overloads-right >>= โ:-overloads-left
step : โ {F} โ FunType F โ โฉ-Lift (Overloads (โฉ-saturate F)) (Overloads (โฉ-saturate F)) โ: Overloads (โฉ-saturate F)
step (S โ T) (intersect here here) = defn here <:-โฉ-left (<:-โฉ-glb <:-refl <:-refl)
step (F โฉ G) (intersect (left (left p)) (left (left q))) = step F (intersect p q) >>= โ:-overloads-left >>= โ:-overloads-left
step (F โฉ G) (intersect (left (left p)) (left (right q))) = โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) (intersect p q) >>= โ:-overloads-right
step (F โฉ G) (intersect (left (right p)) (left (left q))) = โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) (intersect q p) >>= โ:-overloads-right >>=หก <:-โฉ-symm >>=สณ <:-โฉ-symm
step (F โฉ G) (intersect (left (right p)) (left (right q))) = step G (intersect p q) >>= โ:-overloads-right >>= โ:-overloads-left
step (F โฉ G) (intersect (right p) q) with โ:-โ-overloads (normal-โฉ-saturate F) (normal-โฉ-saturate G) p
step (F โฉ G) (intersect (right p) (left (left q))) | defn (intersect pโ pโ) pโ pโ =
(step F (intersect pโ q) [โฉ] just pโ) >>=
โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-intersect pโ <:-refl) (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-refl) (<:-trans <:-โฉ-left <:-โฉ-right)) >>=สณ
<:-trans (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-refl) (<:-trans <:-โฉ-left <:-โฉ-right)) (<:-intersect pโ <:-refl)
step (F โฉ G) (intersect (right p) (left (right q))) | defn (intersect pโ pโ) pโ pโ =
(just pโ [โฉ] step G (intersect pโ q)) >>=
โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-intersect pโ <:-refl) <:-โฉ-assocr >>=สณ
<:-trans <:-โฉ-assocl (<:-intersect pโ <:-refl)
step (F โฉ G) (intersect (right p) (right q)) | defn (intersect pโ pโ) pโ pโ with โ:-โ-overloads (normal-โฉ-saturate F) (normal-โฉ-saturate G) q
step (F โฉ G) (intersect (right p) (right q)) | defn (intersect pโ pโ) pโ pโ | defn (intersect qโ qโ) qโ qโ =
(step F (intersect pโ qโ) [โฉ] step G (intersect pโ qโ)) >>=
โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-intersect pโ qโ) (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-โฉ-left) (<:-intersect <:-โฉ-right <:-โฉ-right)) >>=สณ
<:-trans (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-โฉ-left) (<:-intersect <:-โฉ-right <:-โฉ-right)) (<:-intersect pโ qโ)
step (F โฉ G) (intersect p (right q)) with โ:-โ-overloads (normal-โฉ-saturate F) (normal-โฉ-saturate G) q
step (F โฉ G) (intersect (left (left p)) (right q)) | defn (intersect qโ qโ) qโ qโ =
(step F (intersect p qโ) [โฉ] just qโ) >>=
โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-intersect <:-refl qโ) <:-โฉ-assocl >>=สณ
<:-trans <:-โฉ-assocr (<:-intersect <:-refl qโ)
step (F โฉ G) (intersect (left (right p)) (right q)) | defn (intersect qโ qโ) qโ qโ =
(just qโ [โฉ] step G (intersect p qโ) ) >>=
โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-intersect <:-refl qโ) (<:-โฉ-glb (<:-trans <:-โฉ-right <:-โฉ-left) (<:-โฉ-glb <:-โฉ-left (<:-trans <:-โฉ-right <:-โฉ-right))) >>=สณ
<:-โฉ-glb (<:-trans <:-โฉ-right <:-โฉ-left) (<:-trans (<:-โฉ-glb <:-โฉ-left (<:-trans <:-โฉ-right <:-โฉ-right)) qโ)
step (F โฉ G) (intersect (right p) (right q)) | defn (intersect qโ qโ) qโ qโ with โ:-โ-overloads (normal-โฉ-saturate F) (normal-โฉ-saturate G) p
step (F โฉ G) (intersect (right p) (right q)) | defn (intersect qโ qโ) qโ qโ | defn (intersect pโ pโ) pโ pโ =
(step F (intersect pโ qโ) [โฉ] step G (intersect pโ qโ)) >>=
โ:-overloads-โ (normal-โฉ-saturate F) (normal-โฉ-saturate G) >>=
โ:-overloads-right >>=หก
<:-trans (<:-intersect pโ qโ) (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-โฉ-left) (<:-intersect <:-โฉ-right <:-โฉ-right)) >>=สณ
<:-trans (<:-โฉ-glb (<:-intersect <:-โฉ-left <:-โฉ-left) (<:-intersect <:-โฉ-right <:-โฉ-right)) (<:-intersect pโ qโ)
saturate-overloads : โ {F} โ FunType F โ Overloads (saturate F) โ: โช-Saturate (โฉ-Saturate (Overloads F))
saturate-overloads F o = โช-saturate-overloads (normal-โฉ-saturate F) o >>= (โ:-โช-saturate (โฉ-saturate-overloads F))
overloads-saturate : โ {F} โ FunType F โ โช-Saturate (โฉ-Saturate (Overloads F)) โ: Overloads (saturate F)
overloads-saturate F o = โ:-โช-saturate (overloads-โฉ-saturate F) o >>= overloads-โช-saturate (normal-โฉ-saturate F)
-- Saturated F whenever
-- * if F has overloads (R โ S) and (T โ U) then F has an overload which is a subtype of ((R โฉ T) โ (S โฉ U))
-- * ditto union
data Saturated (F : Type) : Set where
defn :
(โ {R S T U} โ Overloads F (R โ S) โ Overloads F (T โ U) โ <:-Close (Overloads F) ((R โฉ T) โ (S โฉ U))) โ
(โ {R S T U} โ Overloads F (R โ S) โ Overloads F (T โ U) โ <:-Close (Overloads F) ((R โช T) โ (S โช U))) โ
-----------
Saturated F
-- saturated F is saturated!
saturated : โ {F} โ FunType F โ Saturated (saturate F)
saturated F = defn
(ฮป n o โ (saturate-overloads F n [โฉ] saturate-overloads F o) >>= โช-saturate-resp-โฉ-saturation โ:-โฉ-lift-saturate >>= overloads-saturate F)
(ฮป n o โ โช-saturated (normal-โฉ-saturate F) (union n o))
| {
"alphanum_fraction": 0.534125099,
"avg_line_length": 58.202764977,
"ext": "agda",
"hexsha": "13f7d171ffe571ab31261d45297a5b85c08369d1",
"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": "39fbd2146a379fb0878369b48764cd7e8772c0fb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sthagen/Roblox-luau",
"max_forks_repo_path": "prototyping/Properties/TypeSaturation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb",
"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": "sthagen/Roblox-luau",
"max_issues_repo_path": "prototyping/Properties/TypeSaturation.agda",
"max_line_length": 459,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f1b46f4b967f11fabe666da1de0e71b225368260",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Libertus-Lab/luau",
"max_stars_repo_path": "prototyping/Properties/TypeSaturation.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-06T08:03:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-06T08:03:00.000Z",
"num_tokens": 12167,
"size": 25260
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Patterns used in the reflection machinery
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Reflection.Pattern where
open import Data.List.Base hiding (_++_)
open import Data.List.Properties
open import Data.Product
open import Data.String as String using (String; braces; parens; _++_; _<+>_)
import Reflection.Literal as Literal
import Reflection.Name as Name
open import Relation.Nullary
open import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Product using (_ร-dec_)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Reflection.Argument
open import Reflection.Argument.Visibility using (Visibility); open Visibility
open import Reflection.Argument.Relevance using (Relevance); open Relevance
open import Reflection.Argument.Information using (ArgInfo); open ArgInfo
------------------------------------------------------------------------
-- Re-exporting the builtin type and constructors
open import Agda.Builtin.Reflection public using (Pattern)
open Pattern public
------------------------------------------------------------------------
-- Decidable equality
con-injectiveโ : โ {c cโฒ args argsโฒ} โ con c args โก con cโฒ argsโฒ โ c โก cโฒ
con-injectiveโ refl = refl
con-injectiveโ : โ {c cโฒ args argsโฒ} โ con c args โก con cโฒ argsโฒ โ args โก argsโฒ
con-injectiveโ refl = refl
con-injective : โ {c cโฒ args argsโฒ} โ con c args โก con cโฒ argsโฒ โ c โก cโฒ ร args โก argsโฒ
con-injective = < con-injectiveโ , con-injectiveโ >
var-injective : โ {x y} โ var x โก var y โ x โก y
var-injective refl = refl
lit-injective : โ {x y} โ Pattern.lit x โก lit y โ x โก y
lit-injective refl = refl
proj-injective : โ {x y} โ proj x โก proj y โ x โก y
proj-injective refl = refl
_โs_ : Decidable (_โก_ {A = Args Pattern})
_โ_ : Decidable (_โก_ {A = Pattern})
con c ps โ con cโฒ psโฒ = Dec.mapโฒ (uncurry (congโ con)) con-injective (c Name.โ cโฒ ร-dec ps โs psโฒ)
var s โ var sโฒ = Dec.mapโฒ (cong var) var-injective (s String.โ sโฒ)
lit l โ lit lโฒ = Dec.mapโฒ (cong lit) lit-injective (l Literal.โ lโฒ)
proj a โ proj aโฒ = Dec.mapโฒ (cong proj) proj-injective (a Name.โ aโฒ)
con x xโ โ dot = no (ฮป ())
con x xโ โ var xโ = no (ฮป ())
con x xโ โ lit xโ = no (ฮป ())
con x xโ โ proj xโ = no (ฮป ())
con x xโ โ absurd = no (ฮป ())
dot โ con x xโ = no (ฮป ())
dot โ dot = yes refl
dot โ var x = no (ฮป ())
dot โ lit x = no (ฮป ())
dot โ proj x = no (ฮป ())
dot โ absurd = no (ฮป ())
var s โ con x xโ = no (ฮป ())
var s โ dot = no (ฮป ())
var s โ lit x = no (ฮป ())
var s โ proj x = no (ฮป ())
var s โ absurd = no (ฮป ())
lit x โ con xโ xโ = no (ฮป ())
lit x โ dot = no (ฮป ())
lit x โ var _ = no (ฮป ())
lit x โ proj xโ = no (ฮป ())
lit x โ absurd = no (ฮป ())
proj x โ con xโ xโ = no (ฮป ())
proj x โ dot = no (ฮป ())
proj x โ var _ = no (ฮป ())
proj x โ lit xโ = no (ฮป ())
proj x โ absurd = no (ฮป ())
absurd โ con x xโ = no (ฮป ())
absurd โ dot = no (ฮป ())
absurd โ var _ = no (ฮป ())
absurd โ lit x = no (ฮป ())
absurd โ proj x = no (ฮป ())
absurd โ absurd = yes refl
[] โs [] = yes refl
(arg i p โท xs) โs (arg j q โท ys) = โท-dec (unArg-dec (p โ q)) (xs โs ys)
[] โs (_ โท _) = no ฮป()
(_ โท _) โs [] = no ฮป()
| {
"alphanum_fraction": 0.5600839077,
"avg_line_length": 33.0396039604,
"ext": "agda",
"hexsha": "1ddc31778804f4e778e6acad4d2a02f3fbfb603f",
"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/Reflection/Pattern.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/Reflection/Pattern.agda",
"max_line_length": 98,
"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/Reflection/Pattern.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": 1039,
"size": 3337
} |
module sum-thms where
open import eq
open import sum
open import list
open import product
open import empty
open import negation
injโ-inj : โ{โ โ'}{A : Set โ}{B : Set โ'}{x : A}{x'} โ injโ{โ}{โ'}{A}{B} x โก injโ x' โ x โก x'
injโ-inj refl = refl
โ-assoc-isoโ : โ{โ}{U V W : Set โ}{x : U โ V โ W} โ โ-assoc-inv (โ-assoc x) โก x
โ-assoc-isoโ {x = injโ x} = refl
โ-assoc-isoโ {x = injโ (injโ x)} = refl
โ-assoc-isoโ {x = injโ (injโ y)} = refl
โ-assoc-isoโ : โ{โ}{U V W : Set โ}{x : (U โ V) โ W} โ โ-assoc (โ-assoc-inv x) โก x
โ-assoc-isoโ {x = injโ (injโ x)} = refl
โ-assoc-isoโ {x = injโ (injโ y)} = refl
โ-assoc-isoโ {x = injโ y} = refl
โ-left-ident-isoโ : โ{โ}{X : Set โ}{x} โ โ-left-ident-inv {_}{X} (โ-left-ident x) โก x
โ-left-ident-isoโ {x = injโ x} = โฅ-elim x
โ-left-ident-isoโ {x = injโ y} = refl
โ-left-ident-isoโ : โ{โ}{X : Set โ}{x} โ โ-left-ident {_}{X} (โ-left-ident-inv x) โก x
โ-left-ident-isoโ = refl
โ-right-ident-isoโ : โ{โ}{X : Set โ}{x} โ โ-right-ident-inv {_}{X} (โ-right-ident x) โก x
โ-right-ident-isoโ {x = injโ x} = refl
โ-right-ident-isoโ {x = injโ y} = โฅ-elim y
โ-right-ident-isoโ : โ{โ}{X : Set โ}{x} โ โ-right-ident {_}{X} (โ-right-ident-inv x) โก x
โ-right-ident-isoโ = refl
ยฌโโร : โ{โ}{A B : Set โ} โ ยฌ (_โ_ {โ} A B) โ ยฌ A ร ยฌ B
ยฌโโร {โ}{A}{B} p = (ฮป x โ p (injโ x)) , ฮป x โ p (injโ x)
| {
"alphanum_fraction": 0.5417933131,
"avg_line_length": 33.7435897436,
"ext": "agda",
"hexsha": "b26bc9e4b29b19012c1b67bf9b31d2fd433f03ec",
"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": "sum-thms.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "sum-thms.agda",
"max_line_length": 93,
"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": "sum-thms.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 719,
"size": 1316
} |
module Imports.Unsolved where
X : Set
X = ?
| {
"alphanum_fraction": 0.6595744681,
"avg_line_length": 6.7142857143,
"ext": "agda",
"hexsha": "beb0226c3b2d87b943d3c191671c8c80771e822e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Imports/Unsolved.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/Imports/Unsolved.agda",
"max_line_length": 29,
"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/Imports/Unsolved.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": 15,
"size": 47
} |
open import Agda.Primitive
postulate
F : (a : Level) โ Set a โ Set a
P : (a : Level) (A : Set a) โ F a A โ Set a
p : (a : Level) (A : Set a) (x : F a A) โ P a A x
Q : (a : Level) (A : Set a) โ A โ Set a
variable
a : Level
A : Set a
postulate
q : (x : F _ A) โ Q a _ (p a A x)
q' : {a : Level} {A : Set a} (x : F a A) โ Q a (P a A x) (p a A x)
q' {a} {A} = q {a} {A}
| {
"alphanum_fraction": 0.4545454545,
"avg_line_length": 20.2631578947,
"ext": "agda",
"hexsha": "146240fac0a8bec2b7d990182aaec3d8599ae5f5",
"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/Issue3655.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/Issue3655.agda",
"max_line_length": 66,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3655.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": 183,
"size": 385
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.Vec.Relation.Unary.All directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Vec.All where
open import Data.Vec.Relation.Unary.All public
| {
"alphanum_fraction": 0.4393530997,
"avg_line_length": 28.5384615385,
"ext": "agda",
"hexsha": "c04627bda24005e079a4dfd599ceef824f7ddcbf",
"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/Vec/All.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/Vec/All.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/All.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 60,
"size": 371
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor
open import Categories.Adjoint
-- Right Adjoint Preserves Limits.
module Categories.Adjoint.RAPL {o oโฒ โ โโฒ e eโฒ} {C : Category o โ e} {D : Category oโฒ โโฒ eโฒ}
{L : Functor C D} {R : Functor D C} (LโฃR : L โฃ R) where
open import Categories.Functor.Properties
import Categories.Morphism.Reasoning as MR
import Categories.Diagram.Limit as Lim
import Categories.Category.Construction.Cones as Con
private
module C = Category C
module D = Category D
module L = Functor L
module R = Functor R
open Adjoint LโฃR
module _ {oโณ โโณ eโณ} {J : Category oโณ โโณ eโณ} (F : Functor J D) where
private
module F = Functor F
module LF = Lim F
module CF = Con F
RF = R โF F
module LRF = Lim RF
module CRF = Con RF
rapl : LF.Limit โ LRF.Limit
rapl lim = record
{ terminal = record
{ โค = โค
; ! = !
; !-unique = !-unique
}
}
where module lim = LF.Limit lim
open lim
โค : CRF.Cone
โค = record
{ N = R.Fโ apex
; apex = record
{ ฯ = ฮป X โ R.Fโ (proj X)
; commute = ฮป f โ [ R ]-resp-โ (limit-commute f)
}
}
Kโฒ : CRF.Cone โ CF.Cone
Kโฒ K = record
{ N = L.Fโ K.N
; apex = record
{ ฯ = ฮป X โ counit.ฮท (F.Fโ X) D.โ L.Fโ (K.ฯ X)
; commute = ฮป {X Y} f โ begin
F.Fโ f D.โ counit.ฮท (F.Fโ X) D.โ L.Fโ (K.ฯ X)
โหโจ pushหก (counit.commute (F.Fโ f)) โฉ
(counit.ฮท (F.Fโ Y) D.โ L.Fโ (R.Fโ (F.Fโ f))) D.โ L.Fโ (K.ฯ X)
โโจ pullสณ ([ L ]-resp-โ (K.commute f)) โฉ
counit.ฮท (F.Fโ Y) D.โ L.Fโ (K.ฯ Y)
โ
}
}
where module K = CRF.Cone K
open D.HomReasoning
open MR D
module Kโฒ K = CF.Cone (Kโฒ K)
! : โ {K : CRF.Cone} โ CRF.Cones [ K , โค ]
! {K} = record
{ arr = R.Fโ (rep (Kโฒ K)) C.โ unit.ฮท K.N
; commute = commuteโฒ
}
where module K = CRF.Cone K
commuteโฒ : โ {X} โ R.Fโ (proj X) C.โ R.Fโ (rep (Kโฒ K)) C.โ unit.ฮท K.N C.โ K.ฯ X
commuteโฒ {X} = begin
R.Fโ (proj X) C.โ R.Fโ (rep (Kโฒ K)) C.โ unit.ฮท K.N
โโจ pullหก ([ R ]-resp-โ commute) โฉ
R.Fโ (Kโฒ.ฯ K X) C.โ unit.ฮท K.N
โโจ LRadjunctโid โฉ
K.ฯ X
โ
where open C.HomReasoning
open MR C
module ! {K} = CRF.Coneโ (! {K})
!-unique : โ {K : CRF.Cone} (f : CRF.Cones [ K , โค ]) โ CRF.Cones [ ! โ f ]
!-unique {K} f =
let open C.HomReasoning
open MR C
in begin
R.Fโ (rep (Kโฒ K)) C.โ unit.ฮท K.N โโจ R.F-resp-โ (terminal.!-unique fโฒ) โฉโโจrefl โฉ
Ladjunct (Radjunct f.arr) โโจ LRadjunctโid โฉ
f.arr โ
where module K = CRF.Cone K
module f = CRF.Coneโ f
fโฒ : CF.Cones [ Kโฒ K , limit ]
fโฒ = record
{ arr = Radjunct f.arr
; commute = ฮป {X} โ begin
proj X D.โ Radjunct f.arr โหโจ pushหก (counit.commute (proj X)) โฉ
(counit.ฮท (F.Fโ X) D.โ L.Fโ (R.Fโ (proj X))) D.โ L.Fโ f.arr โหโจ pushสณ L.homomorphism โฉ
Radjunct (R.Fโ (proj X) C.โ f.arr) โโจ Radjunct-resp-โ f.commute โฉ
Radjunct (K.ฯ X) โ
}
where open D.HomReasoning
open MR D
| {
"alphanum_fraction": 0.400544285,
"avg_line_length": 34.547008547,
"ext": "agda",
"hexsha": "b701bf681849447fa3e4e1aad73faef160263503",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Adjoint/RAPL.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Adjoint/RAPL.agda",
"max_line_length": 119,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Adjoint/RAPL.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1326,
"size": 4042
} |
module Convertibility where
open import Syntax public
-- ฮฒ-ฮท-equivalence.
infix 4 _โกแตแต_
data _โกแตแต_ : โ {A ฮ} โ ฮ โข A โ ฮ โข A โ Set where
reflโกแตแต : โ {A ฮ} {d : ฮ โข A} โ d โกแตแต d
transโกแตแต : โ {A ฮ} {d dโฒ dโณ : ฮ โข A} โ d โกแตแต dโฒ โ dโฒ โกแตแต dโณ โ d โกแตแต dโณ
symโกแตแต : โ {A ฮ} {d dโฒ : ฮ โข A} โ d โกแตแต dโฒ โ dโฒ โกแตแต d
-- Congruences.
congโกแตแตlam : โ {A B ฮ} {d dโฒ : ฮ , A โข B} โ
d โกแตแต dโฒ โ lam d โกแตแต lam dโฒ
congโกแตแตapp : โ {A B ฮ} {d dโฒ : ฮ โข A โ B} {e eโฒ : ฮ โข A} โ
d โกแตแต dโฒ โ e โกแตแต eโฒ โ app d e โกแตแต app dโฒ eโฒ
congโกแตแตpair : โ {A B ฮ} {d dโฒ : ฮ โข A} {e eโฒ : ฮ โข B} โ
d โกแตแต dโฒ โ e โกแตแต eโฒ โ pair d e โกแตแต pair dโฒ eโฒ
congโกแตแตfst : โ {A B ฮ} {d dโฒ : ฮ โข A โฉ B} โ
d โกแตแต dโฒ โ fst d โกแตแต fst dโฒ
congโกแตแตsnd : โ {A B ฮ} {d dโฒ : ฮ โข A โฉ B} โ
d โกแตแต dโฒ โ snd d โกแตแต snd dโฒ
-- Reductions, or ฮฒ-conversions.
reduceโ : โ {A B ฮ} โ (d : ฮ , A โข B) (e : ฮ โข A) โ
app (lam d) e โกแตแต [ top โ e ] d
reduceโฉโ : โ {A B ฮ} โ (d : ฮ โข A) (e : ฮ โข B) โ
fst (pair d e) โกแตแต d
reduceโฉโ : โ {A B ฮ} โ (d : ฮ โข A) (e : ฮ โข B) โ
snd (pair d e) โกแตแต e
-- Expansions, or ฮท-conversions.
expandโ : โ {A B ฮ} โ (d : ฮ โข A โ B) โ
d โกแตแต lam (app (monoโข weakโ d) vโ)
expandโฉ : โ {A B ฮ} โ (d : ฮ โข A โฉ B) โ
d โกแตแต pair (fst d) (snd d)
expandโซช : โ {ฮ} โ (d : ฮ โข โซช) โ
d โกแตแต unit
โกโโกแตแต : โ {A ฮ} {d dโฒ : ฮ โข A} โ d โก dโฒ โ d โกแตแต dโฒ
โกโโกแตแต refl = reflโกแตแต
-- Syntax for equational reasoning with ฮฒ-ฮท-equivalence.
module โกแตแต-Reasoning where
infix 1 beginโกแตแต_
beginโกแตแต_ : โ {A ฮ} {d dโฒ : ฮ โข A} โ d โกแตแต dโฒ โ d โกแตแต dโฒ
beginโกแตแต_ p = p
infixr 2 _โกโโกแตแตโจโฉ_
_โกโโกแตแตโจโฉ_ : โ {A ฮ} (d {dโฒ} : ฮ โข A) โ d โก dโฒ โ d โกแตแต dโฒ
d โกโโกแตแตโจโฉ p = โกโโกแตแต p
infixr 2 _โกแตแตโจโฉ_
_โกแตแตโจโฉ_ : โ {A ฮ} (d {dโฒ} : ฮ โข A) โ d โกแตแต dโฒ โ d โกแตแต dโฒ
d โกแตแตโจโฉ p = p
infixr 2 _โกแตแตโจ_โฉ_
_โกแตแตโจ_โฉ_ : โ {A ฮ} (d {dโฒ dโณ} : ฮ โข A) โ d โกแตแต dโฒ โ dโฒ โกแตแต dโณ โ d โกแตแต dโณ
d โกแตแตโจ p โฉ q = transโกแตแต p q
infix 3 _โโกแตแต
_โโกแตแต : โ {A ฮ} (d : ฮ โข A) โ d โกแตแต d
_โโกแตแต _ = reflโกแตแต
open โกแตแต-Reasoning public
| {
"alphanum_fraction": 0.4051764706,
"avg_line_length": 24.4252873563,
"ext": "agda",
"hexsha": "44ca6afa7623ae08fc156252b746f39933afc215",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/nbe-correctness",
"max_forks_repo_path": "src/Convertibility.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/nbe-correctness",
"max_issues_repo_path": "src/Convertibility.agda",
"max_line_length": 74,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/nbe-correctness",
"max_stars_repo_path": "src/Convertibility.agda",
"max_stars_repo_stars_event_max_datetime": "2017-03-23T18:51:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-23T06:25:23.000Z",
"num_tokens": 1473,
"size": 2125
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties related to propositional list membership, that rely on
-- the K rule
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.List.Membership.Propositional.Properties.WithK where
open import Data.List.Base
open import Data.List.Relation.Unary.Unique.Propositional
open import Data.List.Membership.Propositional
import Data.List.Membership.Setoid.Properties as Membershipโ
open import Relation.Unary using (Irrelevant)
open import Relation.Binary.PropositionalEquality as P using (_โก_)
open import Relation.Binary.PropositionalEquality.WithK
------------------------------------------------------------------------
-- Irrelevance
uniqueโirrelevant : โ {a} {A : Set a} {xs : List A} โ
Unique xs โ Irrelevant (_โ xs)
uniqueโirrelevant = Membershipโ.uniqueโirrelevant (P.setoid _) โก-irrelevant
| {
"alphanum_fraction": 0.5935613682,
"avg_line_length": 38.2307692308,
"ext": "agda",
"hexsha": "5909ec3e723ad7c5287c22ffe2ff9bda01100461",
"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/Membership/Propositional/Properties/WithK.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/Membership/Propositional/Properties/WithK.agda",
"max_line_length": 75,
"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/Membership/Propositional/Properties/WithK.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": 199,
"size": 994
} |
{-# OPTIONS --without-K --rewriting #-}
module Bool where
open import Basics
open import lib.Basics
open import lib.types.Bool public
_โคb_ : Bool โ Bool โ PropTโ
true โคb true = True
true โคb false = False
false โคb true = True
false โคb false = True
โคb-refl : (b : Bool) โ (b โคb b) holds
โคb-refl true = unit
โคb-refl false = unit
โคb-trans : {a b c : Bool} โ (a โคb b) holds โ (b โคb c) holds โ (a โคb c) holds
โคb-trans {a} {b} {c} = โคb-trans' a b c
where
โคb-trans' : (a b c : Bool) โ (a โคb b) holds โ (b โคb c) holds โ (a โคb c) holds
โคb-trans' true true true = ฮป _ _ โ unit
โคb-trans' true true false = ฮป _ z โ z
โคb-trans' true false true = ฮป _ _ โ unit
โคb-trans' true false false = ฮป z _ โ z
โคb-trans' false true true = ฮป _ _ โ unit
โคb-trans' false true false = ฮป _ _ โ unit
โคb-trans' false false true = ฮป _ _ โ unit
โคb-trans' false false false = ฮป _ _ โ unit
Bool-to-PropTโ : Bool โ PropTโ
Bool-to-PropTโ true = True
Bool-to-PropTโ false = False
Dec-Prop-to-Bool : {i : ULevel} (P : PropT i) โ Dec (P holds) โ Bool
Dec-Prop-to-Bool _ (inl _) = true
Dec-Prop-to-Bool _ (inr _) = false
Dec-Prop-to-Bool-true-id : {i : ULevel} (P : PropT i) (d : Dec (P holds))
โ P holds โ (Dec-Prop-to-Bool P d) == true
Dec-Prop-to-Bool-true-id P (inl _) p = refl
Dec-Prop-to-Bool-true-id P (inr d) p = quodlibet (d p)
Dec-Prop-to-Bool-false-id : {i : ULevel} (P : PropT i) (d : Dec (P holds))
โ ยฌ (P holds) โ (Dec-Prop-to-Bool P d) == false
Dec-Prop-to-Bool-false-id P (inl x) np = quodlibet (np x)
Dec-Prop-to-Bool-false-id P (inr _) np = refl
_holds-b : Bool โ Typeโ
b holds-b = (Bool-to-PropTโ b) holds
| {
"alphanum_fraction": 0.5598411798,
"avg_line_length": 34.568627451,
"ext": "agda",
"hexsha": "5f01fc864b8a1fcbf43875934c6c53bde28d95c0",
"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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "glangmead/formalization",
"max_forks_repo_path": "cohesion/david_jaz_261/Bool.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "glangmead/formalization",
"max_issues_repo_path": "cohesion/david_jaz_261/Bool.agda",
"max_line_length": 83,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "glangmead/formalization",
"max_stars_repo_path": "cohesion/david_jaz_261/Bool.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z",
"num_tokens": 655,
"size": 1763
} |
{-# OPTIONS --without-K #-}
module sets.int.properties where
open import equality
open import function.core
import sets.nat as N
open N using (โ; suc)
open import sets.int.definition
open import sets.int.utils
import sets.int.core as Z
private
module _ where
open N
add-right-unit : โ n n' โ (n + 0) [-] (n' + 0) โก n [-] n'
add-right-unit n n' = apโ _[-]_ (+-right-unit n) (+-right-unit n')
add-left-inverse : โ n n' โ (n' + n) [-] (n + n') โก 0 [-] 0
add-left-inverse n n' = sym
$ eq-โค 0 0 (n' + n)
ยท apโ _[-]_ (+-right-unit (n' + n))
(+-right-unit (n' + n) ยท +-commutativity n' n)
module _ where
open Z
+-left-unit : โ n โ zero + n โก n
+-left-unit = elim-prop-โค (ฮป n โ hโค (zero + n) n)
(ฮป n n' โ refl)
+-right-unit : โ n โ n + zero โก n
+-right-unit = elim-prop-โค (ฮป n โ hโค (n + zero) n)
add-right-unit
+-left-inverse : โ n โ negate n + n โก zero
+-left-inverse = elim-prop-โค (ฮป n โ hโค (negate n + n) zero)
add-left-inverse
+-right-inverse : โ n โ n + negate n โก zero
+-right-inverse = elim-prop-โค (ฮป n โ hโค (n + negate n) zero)
(ฮป n n' โ add-left-inverse n' n)
inc-dec : โ n โ inc (dec n) โก n
inc-dec = elim-prop-โค (ฮป n โ hโค (inc (dec n)) n)
(ฮป n n' โ sym (eq-โค n n' 1))
dec-inc : โ n โ dec (inc n) โก n
dec-inc = elim-prop-โค (ฮป n โ hโค (dec (inc n)) n)
(ฮป n n' โ sym (eq-โค n n' 1))
+-associativity : โ n m p โ n + m + p โก n + (m + p)
+-associativity = elimโ-prop-โค
(ฮป n m p โ hโค (n + m + p) (n + (m + p)))
(ฮป n n' m m' p p' โ apโ _[-]_ (N.+-associativity n m p)
(N.+-associativity n' m' p'))
| {
"alphanum_fraction": 0.469376392,
"avg_line_length": 30.9655172414,
"ext": "agda",
"hexsha": "8ab09c6e70ae74fdb8e5c8c7a6faee64303ccc1f",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/sets/int/properties.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/sets/int/properties.agda",
"max_line_length": 70,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/sets/int/properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 647,
"size": 1796
} |
{-# OPTIONS --safe #-}
module Issue2487.B where
import Issue2487.A
| {
"alphanum_fraction": 0.7058823529,
"avg_line_length": 13.6,
"ext": "agda",
"hexsha": "0dad358e65940419816582c921116983ab3e618e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/interaction/Issue2487/B.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/interaction/Issue2487/B.agda",
"max_line_length": 24,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue2487/B.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": 18,
"size": 68
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Rings.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Setoids.Setoids
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Functions.Definition
open import Fields.Fields
open import Fields.Orders.Total.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Sets.EquivalenceRelations
open import LogicalFormulae
open import Groups.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _โ_)
module Fields.Orders.Total.Lemmas {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A โ A โ A} {_*_ : A โ A โ A} {R : Ring S _+_ _*_} {F : Field R} {p : _} {_<_ : Rel {_} {p} A} {pOrder : SetoidPartialOrder S _<_} {oR : PartiallyOrderedRing R pOrder} (oF : TotallyOrderedField F oR) where
open Ring R
open Group additiveGroup
open Setoid S
open Equivalence eq
open Field F
open TotallyOrderedField oF
open TotallyOrderedRing oRing
open PartiallyOrderedRing oR
open SetoidTotalOrder total
open SetoidPartialOrder pOrder
open import Rings.InitialRing R
open import Rings.Orders.Total.Lemmas oRing
open import Rings.Orders.Partial.Lemmas oR
open import Rings.Lemmas R
open import Groups.Lemmas additiveGroup
charNotN : (n : โ) โ fromN (succ n) โผ 0R โ False
charNotN n pr = irreflexive (<WellDefined reflexive pr t)
where
t : 0R < fromN (succ n)
t = fromNPreservesOrder (0<1 (Field.nontrivial F)) (succIsPositive n)
charNot2 : Setoid._โผ_ S ((Ring.1R R) + (Ring.1R R)) (Ring.0R R) โ False
charNot2 pr = charNotN 1 (transitive (transitive +Associative identRight) pr)
| {
"alphanum_fraction": 0.759149941,
"avg_line_length": 36.8260869565,
"ext": "agda",
"hexsha": "1d04ed093bcafae099408ffeb6c0dee3a873086e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Fields/Orders/Total/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Fields/Orders/Total/Lemmas.agda",
"max_line_length": 290,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Fields/Orders/Total/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 510,
"size": 1694
} |
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
module Light.Package where
open import Light.Level using (Setฯ)
record Meta : Setฯ where
field Dependencies : Setฯ
field Library : Dependencies โ Setฯ
record Package (meta : Meta) : Setฯ where
instance constructor package
open Meta meta
field โฆ dependencies โฆ : Dependencies
field โฆ library โฆ : Library dependencies
open Package โฆ ... โฆ public
| {
"alphanum_fraction": 0.6939655172,
"avg_line_length": 27.2941176471,
"ext": "agda",
"hexsha": "b34946cfd2a2c59c1380ec1e8416f483681102e3",
"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": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "Zambonifofex/lightlib",
"max_forks_repo_path": "Light/Package.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "Zambonifofex/lightlib",
"max_issues_repo_path": "Light/Package.agda",
"max_line_length": 79,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "zamfofex/lightlib",
"max_stars_repo_path": "Light/Package.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z",
"num_tokens": 113,
"size": 464
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.SuspSectionDecomp
open import homotopy.CofiberComp
open import homotopy.SmashIsCofiber
module homotopy.SuspProduct where
module SuspProduct {i} {j} (X : Ptd i) (Y : Ptd j) where
private
iโ : X โโ X โร Y
iโ = ((ฮป x โ (x , pt Y)) , idp)
iโ : Y โโ X โร Y
iโ = ((ฮป y โ (pt X , y)) , idp)
jโ : deโ (โCofiber iโ) โ deโ Y
jโ = CofiberRec.f (pt Y) snd (ฮป x โ idp)
โeq : โSusp (X โร Y) โโ โSusp X โโจ (โSusp Y โโจ โSusp (X โโง Y))
โeq =
โโจ-emap (โide (โSusp X))
(โโจ-emap (โide (โSusp Y))
(โSusp-emap (Smash-โequiv-Cof X Y โโปยน โโe CofiberComp.โeq iโ iโ)))
โโe โโจ-emap (โide (โSusp X))
(โ-to-โโ (SuspSectionDecomp.eq (โcfcod' iโ โโ iโ) jโ (ฮป y โ idp))
(! $ ap winl $ merid (pt Y)))
โโe โ-to-โโ (SuspSectionDecomp.eq iโ fst (ฮป x โ idp))
(! $ ap winl $ merid (pt X))
| {
"alphanum_fraction": 0.5112059765,
"avg_line_length": 29.28125,
"ext": "agda",
"hexsha": "d83a98e580c4cf7ffff494486080dcaf1149ee2c",
"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/homotopy/SuspProduct.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/homotopy/SuspProduct.agda",
"max_line_length": 75,
"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/homotopy/SuspProduct.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 457,
"size": 937
} |
module Structure.Operator.Monoid.Invertible.Proofs where
import Data.Tuple as Tuple
import Lvl
open import Logic.Propositional
open import Logic.Predicate
open import Structure.Operator
open import Structure.Operator.Monoid
open import Structure.Operator.Monoid.Invertible
open import Structure.Operator.Properties hiding (InverseOperatorโ ; InverseOperatorแตฃ)
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
private variable โ โโ โโ : Lvl.Level
private variable T : Type{โ}
private variable _โซ_ : T โ T โ T
private variable _โจ_ : T โ T โ Type{โโ}
module _ โฆ equiv : Equiv{โโ}(T) โฆ โฆ monoid : Monoid{T = T}(_โซ_) โฆ โฆ invRel : InverseRelationแตฃ(_โซ_){โโ}(_โจ_) โฆ where
open Monoid(monoid) using (id)
instance
inverseRelationแตฃ-reflexivity : Reflexivity(_โจ_)
Reflexivity.proof inverseRelationแตฃ-reflexivity = [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) ([โ]-intro id โฆ identityแตฃ(_โซ_)(id) โฆ)
instance
inverseRelationแตฃ-transitivity : Transitivity(_โจ_)
Transitivity.proof inverseRelationแตฃ-transitivity xy yz
with [โ]-intro a โฆ pa โฆ โ [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) xy
with [โ]-intro b โฆ pb โฆ โ [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) yz
= [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) ([โ]-intro (a โซ b) โฆ symmetry(_โก_) (associativity(_โซ_)) ๐ congruenceโโ(_โซ_)(b) pa ๐ pb โฆ)
inverseRelationแตฃ-with-opแตฃ : โ{a x y} โ (x โจ y) โ ((a โซ x) โจ (a โซ y))
inverseRelationแตฃ-with-opแตฃ {a}{x}{y} xy
with [โ]-intro z โฆ xzy โฆ โ [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) xy
= [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) ([โ]-intro z โฆ associativity(_โซ_) ๐ congruenceโแตฃ(_โซ_)(a) xzy โฆ)
inverseRelationแตฃ-without-opแตฃ : โฆ cancโ : Cancellationโ(_โซ_) โฆ โ โ{a x y} โ ((a โซ x) โจ (a โซ y)) โ (x โจ y)
inverseRelationแตฃ-without-opแตฃ {a}{x}{y} xy
with [โ]-intro z โฆ xzy โฆ โ [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) xy
= [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) ([โ]-intro z โฆ cancellationโ(_โซ_) (symmetry(_โก_) (associativity(_โซ_)) ๐ xzy) โฆ)
inverseRelationแตฃ-of-idโ : โ{x} โ (id โจ x)
inverseRelationแตฃ-of-idโ {x} = [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) ([โ]-intro x โฆ identityโ(_โซ_)(id) โฆ)
module _ {_โ_ : (x : T) โ (y : T) โ . โฆ inv : (y โจ x) โฆ โ T} โฆ invOper : InverseOperatorแตฃ(_โซ_)(_โ_) โฆ where
{-op-cancellationแตฃ : โ{a x y} โ (a โจ x) โ (a โจ y) โ (a โซ x โก a โซ y) โ (x โก y)
op-cancellationแตฃ {a}{x}{y} ax ay axay
with [โ]-intro r โฆ pr โฆ โ [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) ax
with [โ]-intro s โฆ ps โฆ โ [โ]-to-[โ] (InverseRelationแตฃ.proof invRel) ay
=
x ๐[ _โก_ ]-[ {!!} ]
y ๐-end-}
inverseRelationแตฃ-to-invertibleแตฃ : โ{x} โ โฆ x โจ id โฆ โ InvertibleElementแตฃ(_โซ_) โฆ Monoid.identity-existenceแตฃ(monoid) โฆ (x)
inverseRelationแตฃ-to-invertibleแตฃ {x} โฆ xid โฆ = [โ]-intro (id โ x) โฆ intro p โฆ where
p =
(x โซ (id โ x)) ๐[ _โก_ ]-[ congruenceโแตฃ(_โซ_)(x) (InverseOperatorแตฃ.proof invOper {id}{x}) ]
(x โซ [โ]-witness([โ]-to-[โ] (InverseRelationแตฃ.proof invRel) xid)) ๐[ _โก_ ]-[ [โ]-proof([โ]-to-[โ] (InverseRelationแตฃ.proof invRel) xid) ]
id ๐-end
{- TODO: Should this not be possible without cancellation?
inverseOperator-self : โ{x} โ let instance _ = reflexivity(_โจ_) in (x โ x โก id)
inverseOperator-self {x} = let instance _ = reflexivity(_โจ_) {x} in
(x โ x) ๐[ _โก_ ]-[ InverseOperatorแตฃ.proof invOper {x}{x} ]
[โ]-witness([โ]-to-[โ] (InverseRelationแตฃ.proof invRel) (reflexivity(_โจ_) {x})) ๐[ _โก_ ]-[]
โ.witness(Tuple.right(InverseRelationแตฃ.proof invRel) (reflexivity(_โจ_))) ๐[ _โก_ ]-[ {!!} ]
id ๐-end
-}
| {
"alphanum_fraction": 0.5738375064,
"avg_line_length": 54.3611111111,
"ext": "agda",
"hexsha": "3d7f7d61026b6666e15eb94fa57f7a988a00d2b9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Operator/Monoid/Invertible/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Operator/Monoid/Invertible/Proofs.agda",
"max_line_length": 148,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Operator/Monoid/Invertible/Proofs.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 1609,
"size": 3914
} |
module PiQ.SAT where
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Data.Nat
open import Data.Nat.Properties
open import Data.List as L
open import Data.Maybe
open import Relation.Binary.PropositionalEquality
open import PiQ.Syntax
open import PiQ.Eval
open import PiQ.Examples
-- Given reversible F : ๐น^n โ ๐น^n, generate a circuit to find xฬ
such that F(xฬ
) = (๐ฝ,โฆ)
-- via running (LOOP F)(๐ฝ,๐ฝฬ
).
-- (idโ โ F)((LOOP F)(๐ฝ,๐ฝฬ
)) = (๐ฝ,๐ฝ,โฆ)
LOOP : โ {n} โ ๐น^ n โ ๐น^ n โ ๐น รแตค ๐น^ n โ ๐น รแตค ๐น^ n
LOOP {0} F = idโ
LOOP {1} F = idโ โ F
LOOP {suc (suc n)} F = traceโ ((dist โ idโ) โจพ [A+B]+C=[A+C]+B โจพ (factor โ idโ) โจพ
((RESET โจพ (idโ โ F) โจพ COPY โจพ (idโ โ ! F)) โ idโ) โจพ
(dist โ idโ) โจพ [A+B]+C=[A+C]+B โจพ (factor โ (idโ โ INCR)))
MERGE : (n m : โ) โ ๐น^ n รแตค ๐น^ m โ ๐น^ (n + m)
MERGE 0 m = uniteโl
MERGE 1 0 = uniteโr
MERGE 1 (suc m) = idโ
MERGE (suc (suc n)) m = assocrโ โจพ (idโ โ MERGE (suc n) m)
SPLIT : (n m : โ) โ ๐น^ (n + m) โ ๐น^ n รแตค ๐น^ m
SPLIT n m = ! MERGE n m
~_ : โ {n} โ ๐น^ (1 + n) โ ๐น^ (1 + n) โ ๐น^ (1 + n) โ ๐น^ (1 + n)
~_ {zero} F = F
~_ {suc n} F = F โจพ NOT โ idโ
-- Given a function G : ๐น^n โ ๐น there exists a reversible Gสณ : ๐น^(1+n) โ ๐น^(1+n) such that Gสณ(๐ฝ,xโฟ) = (F(xโฟ),โฆ)
-- SAT(Gสณ) = tt iff โ xโฟ . G(xโฟ) = ๐
SAT : โ {n} โ ๐น^ (1 + n) โ ๐น^ (1 + n) โ ๐ โ ๐
SAT {n} Gสณ = traceโ (๐ฝ^ (3 + n)) (idโ โ ((idโ โ (LOOP (~ Gสณ) โจพ (idโ โ SPLIT 1 n))) โจพ
(idโ โ (assoclโ โจพ (COPY โ idโ) โจพ assocrโ)) โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
(idโ โ ((idโ โ MERGE 1 n) โจพ LOOPโปยน (~ Gสณ)))))
where
LOOPโปยน : โ {n} โ ๐น^ n โ ๐น^ n โ ๐น รแตค ๐น^ n โ ๐น รแตค ๐น^ n
LOOPโปยน F = ! (LOOP F)
module SAT_test where
-- Examples
-- AND(๐ฝ,a,b) = AND(aโงb,a,b)
AND : ๐น^ 3 โ ๐น^ 3
AND = FST2LAST โจพ (dist โจพ (idโ โ (idโ โ (dist โจพ (idโ โ (idโ โ swapโ)) โจพ factor))) โจพ factor) โจพ FST2LASTโปยน
NAND : ๐น^ 3 โ ๐น^ 3
NAND = AND โจพ (NOT โ idโ)
-- OR(๐ฝ,a,b) = OR(aโจb,a,b)
OR : ๐น^ 3 โ ๐น^ 3
OR = FST2LAST โจพ (dist โจพ ((idโ โ (dist โจพ (idโ โ (idโ โ swapโ)) โจพ factor)) โ (idโ โ (idโ โ swapโ))) โจพ factor) โจพ FST2LASTโปยน
NOR : ๐น^ 3 โ ๐น^ 3
NOR = OR โจพ (NOT โ idโ)
-- XOR(a,b) = XOR(a xor b,b)
XOR : ๐น^ 2 โ ๐น^ 2
XOR = distl โจพ (idโ โ (swapโ โ idโ)) โจพ factorl
tests : List โฆ ๐น^ 3 โง
tests = (๐ฝ , ๐ฝ , ๐ฝ) โท (๐ฝ , ๐ฝ , ๐) โท (๐ฝ , ๐ , ๐ฝ) โท (๐ฝ , ๐ , ๐) โท (๐ , ๐ฝ , ๐ฝ) โท (๐ , ๐ฝ , ๐) โท (๐ , ๐ , ๐ฝ) โท (๐ , ๐ , ๐) โท []
-- Exโ(๐ฝ,a,b) = ((aโงb) xor (aโงb),_,_)
-- ยฌโa,b . Exโ(๐ฝ,a,b) = (๐,โฆ)
Exโ : ๐น^ 3 โ ๐น^ 3
Exโ = traceโ (๐ฝ^ 1) (swapโ โจพ
(idโ โ AND) โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
(idโ โ AND) โจพ
assoclโ โจพ (XOR โ idโ) โจพ assocrโ โจพ
(idโ โ ! AND) โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
swapโ )
testsโ = L.map (eval' Exโ) tests
-- Exโ(๐ฝ,a,b) = ((aโงb) xor (aโจb),_,_)
-- โa,b . Exโ(๐ฝ,a,b) = (๐,โฆ)
Exโ : ๐น^ 3 โ ๐น^ 3
Exโ = traceโ (๐ฝ^ 1) (swapโ โจพ
(idโ โ AND) โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
(idโ โ OR) โจพ
assoclโ โจพ (XOR โ idโ) โจพ assocrโ โจพ
(idโ โ ! OR) โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
swapโ )
testsโ = L.map (eval' Exโ) tests
-- Exโ(๐ฝ,a,b) = (((aโงb) โง (a xor b)),_,_)
-- ยฌโa,b . Exโ(๐ฝ,a,b) = (๐,โฆ)
Exโ : ๐น^ 3 โ ๐น^ 3
Exโ = traceโ (๐ฝ^ 1) (swapโ โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
idโ โ F โจพ
(idโ โ assoclโ) โจพ assoclโ โจพ
(AND โ idโ) โจพ
assocrโ โจพ (idโ โ assocrโ) โจพ
idโ โ ! F โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
swapโ)
where
F : ๐น^ 3 โ ๐น^ 3
F = AND โจพ (idโ โ XOR)
testsโ = L.map (eval' Exโ) tests
-- Exโ(๐ฝ,a,b) = (((aโจb) โง (a xor b)),_,_)
-- โa,b . Exโ(๐ฝ,a,b) = (๐,โฆ)
Exโ : ๐น^ 3 โ ๐น^ 3
Exโ = traceโ (๐ฝ^ 1) (swapโ โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
idโ โ F โจพ
(idโ โ assoclโ) โจพ assoclโ โจพ
(AND โ idโ) โจพ
assocrโ โจพ (idโ โ assocrโ) โจพ
idโ โ ! F โจพ
assoclโ โจพ (swapโ โ idโ) โจพ assocrโ โจพ
swapโ)
where
F : ๐น^ 3 โ ๐น^ 3
F = OR โจพ (idโ โ XOR)
testsโ = L.map (eval' Exโ) tests
SAT-tests : List (๐ โ ๐)
SAT-tests = (SAT AND) โท (SAT OR) โท (SAT XOR) โท (SAT Exโ) โท (SAT Exโ) โท (SAT Exโ) โท (SAT Exโ) โท []
results : List (Maybe (ฮฃ[ t โ ๐ ] โฆ t โง) ร โ)
results = L.map (ฮป c โ eval' c tt) SAT-tests
-- (just (๐ , tt) , 3923) โท
-- (just (๐ , tt) , 2035) โท
-- (just (๐ , tt) , 1347) โท
-- (nothing , 10386) โท
-- (just (๐ , tt) , 4307) โท
-- (nothing , 11442) โท
-- (just (๐ , tt) , 4827) โท []
| {
"alphanum_fraction": 0.3792006363,
"avg_line_length": 35.1678321678,
"ext": "agda",
"hexsha": "4f686a8bd439e6d7a192b27a181f0ccacf11b739",
"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": "PiQ/SAT.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": "PiQ/SAT.agda",
"max_line_length": 124,
"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": "PiQ/SAT.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": 2759,
"size": 5029
} |
-- Andreas, 2019-03-25, issue #3640, reported by gallais
{-# OPTIONS --sized-types #-}
-- {-# OPTIONS -v tc.polarity:40 #-}
module _ where
open import Agda.Builtin.Size
module M (_ : Set) where
data U : Size โ Set where
node : โ {i} โ U (โ i)
module L (A B : Set) where
open M A
-- WAS: crash because of number of parameters in size-index checki
-- of L.U was wrongly calculated.
-- Should succeed.
| {
"alphanum_fraction": 0.643373494,
"avg_line_length": 18.8636363636,
"ext": "agda",
"hexsha": "2062ea9432d568e12b3e55ba10995a1d3e529eee",
"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/Issue3640.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/Issue3640.agda",
"max_line_length": 66,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3640.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": 124,
"size": 415
} |
open import FRP.JS.Delay using ( Delay )
module FRP.JS.Time.Core where
record Time : Set where
constructor epoch
field toDelay : Delay
{-# COMPILED_JS Time function(x,v) { return v.epoch(x); } #-}
{-# COMPILED_JS epoch function(d) { return d; } #-}
| {
"alphanum_fraction": 0.68359375,
"avg_line_length": 23.2727272727,
"ext": "agda",
"hexsha": "a6583887ea6e1a5ee36239c9847f5fa563fd6e45",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "src/agda/FRP/JS/Time/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "src/agda/FRP/JS/Time/Core.agda",
"max_line_length": 61,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "src/agda/FRP/JS/Time/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 70,
"size": 256
} |
module Shallow where
open import Level using (_โ_) renaming (suc to lsuc)
open import Function
open import Data.Unit
open import Data.Empty
open import Data.Product
open import Data.Sum
open import Data.Nat hiding (_โ_)
open import Data.Fin
open import Relation.Binary.PropositionalEquality as PE hiding ([_]; subst)
ฮ : โ {a b} (A : Set a) (B : A โ Set b) โ Set (a โ b)
ฮ A B = (a : A) โ B a
Fam : โ {a} โ Set a โ Set (lsuc a)
Fam {a} I = I โ Set a
data ฮฃ' {A B : Set} (f : A โ B) (P : Fam A) : B โ Set where
ins : (a : A) โ P a โ ฮฃ' f P (f a)
ฮ ' : {I J : Set} (u : I โ J) (P : Fam I) โ Fam J
ฮ ' {I} u P j = ฮ (โ ฮป i โ u i โก j) (ฮป { (i , _) โ P i})
_* : {I J : Set} โ (I โ J) โ Fam J โ Fam I
(u *) A i = A (u i)
Finโบ : โ โ Set
Finโบ = Fin โ suc
Vecโบ : โ {a} โ Set a โ โ โ Set a
Vecโบ A n = Finโบ n โ A
[_] : โ {a} {A : Set a} โ A โ Vecโบ A 0
[ x ] _ = x
_โท_ : โ {a} {A : Set a} {n : โ} โ A โ Vecโบ A n โ Vecโบ A (suc n)
(x โท v) zero = x
(x โท v) (suc k) = v k
module Simple where
module _ where
mutual
data U : Set where
zero : U
one : U
sigma : (A : U) โ (Elem A โ U) โ U
pi : (A : U) โ (Elem A โ U) โ U
Elem : U โ Set
Elem zero = โฅ
Elem one = โค
Elem (sigma A B) = ฮฃ (Elem A) (ฮป x โ Elem (B x))
Elem (pi A B) = ฮ (Elem A) (ฮป x โ Elem (B x))
module Recursive where
module _ where
โ : {n : โ} {I : Set} โ (Finโบ n โ Fam I) โ Fam I
โ {zero} f = f zero
โ {suc n} f i = f zero i โ โ (ฮป k โ f (suc k)) i
โ : {n : โ} {I : Set} โ (Finโบ n โ Fam I) โ Fam I
โ {zero} f = f zero
โ {suc n} f i = f zero i ร โ (ฮป k โ f (suc k)) i
data FP : Set where
ฮผ : FP
ฮฝ : FP
mutual
data U : Set where
fp : {n : โ} (A : U) (o : Vecโบ U n) โ
FP โ Functor [ A ] o โ Subst o A โ U
-- | Substitutions
Subst : {n : โ} โ Vecโบ U n โ U โ Set
Subst {n} o A = (k : Finโบ n) โ Elem (o k) โ Elem A
data Functor : {m n : โ} โ Vecโบ U m โ Vecโบ U n โ Set where
K : {m : โ} (v : Vecโบ U m) (A : U) โ Functor v [ A ]
ฯ : {m : โ} (v : Vecโบ U m) (i : Finโบ m) โ Functor v [ v i ]
fpF : {m n : โ} {v : Vecโบ U m} {o : Vecโบ U n} {A : U} โ
FP โ Functor (A โท v) o โ Subst o A โ Functor v [ A ]
Elem : U โ Set
Elem (fp A o ฮผ F u) = {!!} -- LFP F u {!!}
where
G : Fam (Elem A) โ Fam (Elem A)
G = IndFun F u
Elem (fp A o ฮฝ F u) = {!!}
IdxFam : {m : โ} โ Vecโบ U m โ Setโ
IdxFam {m} v = (k : Finโบ m) โ Fam (Elem (v k))
โฆ_โง : {m n : โ} {i : Vecโบ U m} {o : Vecโบ U n} โ
Functor i o โ (IdxFam i โ IdxFam o)
โฆ K v A โง x k i = Elem A
โฆ ฯ v k โง x zero i = x k i
โฆ ฯ v k โง x (suc ()) i
โฆ fpF ฮผ F u โง x = {!!}
โฆ fpF ฮฝ F u โง x = {!!}
IndFun : {n : โ} {A : U} {o : Vecโบ U n} โ
(F : Functor [ A ] o) โ
-- (F : Fam (Elem A) โ IdxFam o) โ
(u : Subst o A) โ
(Fam (Elem A) โ Fam (Elem A))
IndFun {n} {A} F u X = โ f
where
f : Finโบ n โ Fam (Elem A)
f k = ฮฃ' (u k) (โฆ F โง (ฮป _ โ X) k)
CoindFun : {n : โ} {A : U} {o : Vecโบ U n} โ
(F : Functor [ A ] o) โ
-- (F : Fam (Elem A) โ IdxFam o) โ
(u : Subst o A) โ
(Fam (Elem A) โ Fam (Elem A))
CoindFun {n} {A} F u X = โ f
where
f : Finโบ n โ Fam (Elem A)
f k = ฮ ' (u k) (โฆ F โง (ฮป _ โ X) k)
data LFP {n : โ} {A : U} {o : Vecโบ U n}
(F : Functor [ A ] o) (u : Subst o A) : Elem A โ Set where
-- ฮฑ : (a : Elem A) โ IndFun F u (LFP F u) a โ LFP F u a
{-
data U : Set where
fp : {n : โ} (C : Cat) (o : Vec Cat n) โ
FP โ Functor [ C ] o โ Subst o C โ U
-- | Index of a fibre
Cat : Set
Cat = ฮฃ U Elem
Mor : Cat โ Set
Mor C = ? -- (A , x) = -- ฮฃ U (ฮป B โ {!Elem B โ x!})
-- | Substitutions
Subst : {n : โ} โ Vec Cat n โ Cat โ Set
Subst {n} o C = Vec {!!} n
data Functor : {m n : โ} โ Vec Cat m โ Vec Cat n โ Set where
K : {m : โ} (v : Vec Cat m) โ {A : U} โ (x : Elem A) โ Functor v [ , x ]
ฯ : {m : โ} (v : Vec Cat m) โ (i : Fin m) โ Functor v [ lookup i v ]
fpF : {m n : โ} {v : Vec Cat m} {o : Vec Cat n} {C : Cat} โ
FP โ Functor (C โท v) o โ Subst o C โ Functor v [ C ]
Elem : U โ Set
Elem x = {!!}
-}
module DepPoly where
module _ where
record DPoly (J I : Set) : Setโ where
constructor dpoly
field
-- J <- Shapes -> Pos -> I
Pos : Set
Shapes : Set
s : Shapes โ J
f : Shapes โ Pos
t : Pos โ I
open DPoly
โฆ_โง : {J I : Set} โ DPoly J I โ Fam J โ Fam I
โฆ dpoly A B s f t โง X = ฮฃ' t (ฮ ' f ((s *) X))
data W {I : Set} (P : DPoly I I) : I โ Set where
ฮฑ : (i : I) โ โฆ P โง (W P) i โ W P i
record M {I : Set} (P : DPoly I I) (i : I) : Set where
coinductive
field
ฮพ : โฆ P โง (M P) i
data FP : Set where
ฮผ : FP
ฮฝ : FP
mutual
data U : Set where
fp : {n : โ} (A : U) (o : Vecโบ U n) โ
FP โ Functor [ A ] o โ Subst o A โ U
-- | Substitutions
Subst : {n : โ} โ Vecโบ U n โ U โ Set
Subst {n} o A = (k : Finโบ n) โ Elem (o k) โ Elem A
data Functor : {m n : โ} โ Vecโบ U m โ Vecโบ U n โ Set where
K : {m : โ} (v : Vecโบ U m) {I A : U} โ (Elem A โ Elem I) โ Functor v [ I ]
ฯ : {m : โ} (v : Vecโบ U m) (i : Finโบ m) โ Functor v [ v i ]
fpF : {m n : โ} {v : Vecโบ U m} {o : Vecโบ U n} {A : U} โ
FP โ Functor (A โท v) o โ Subst o A โ Functor v [ A ]
Elem : U โ Set
Elem (fp A o ฮผ F u) = ฮฃ (Elem A) (W (Poly F u))
Elem (fp A o ฮฝ F u) = {!!}
Poly : {n : โ} {I : U} {o : Vecโบ U n} (F : Functor [ I ] o) โ
(u : Subst o I) โ DPoly (Elem I) (Elem I)
Poly (K ._ {J} {A} B) u =
dpoly (Elem A) โฅ (ฮป ()) (ฮป ()) (u zero โ B)
Poly {I = I} (ฯ ._ i) u =
dpoly (Elem I) (Elem I) id id id
Poly (fpF ฮผ F v) u =
{!!}
Poly (fpF ฮฝ F v) u =
{!!}
| {
"alphanum_fraction": 0.3990092681,
"avg_line_length": 29.6587677725,
"ext": "agda",
"hexsha": "68d967d90023a894a377230744ec6ba8085954e1",
"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/FibDataTypes/Shallow.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/FibDataTypes/Shallow.agda",
"max_line_length": 82,
"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/FibDataTypes/Shallow.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2560,
"size": 6258
} |
-- ฮฃ type (also used as existential) and
-- cartesian product (also used as conjunction).
{-# OPTIONS --without-K --safe #-}
module Tools.Product where
open import Agda.Primitive
infixr 4 _,_
infixr 2 _ร_
-- Dependent pair type (aka dependent sum, ฮฃ type).
record ฮฃ {โ โโฒ : Level} (A : Set โ) (B : A โ Set โโฒ) : Set (โ โ โโฒ) where
constructor _,_
field
projโ : A
projโ : B projโ
open ฮฃ public
record ฮฃฯโ {โ} (A : Set โ) (B : A โ Setฯ) : Setฯ where
constructor _,_
field
projโ : A
projโ : B projโ
open ฮฃฯโ public
record ฮฃฯโ {โ} (A : Setฯ) (B : A โ Set โ) : Setฯ where
constructor _,_
field
projโ : A
projโ : B projโ
open ฮฃฯโ public
record ฮฃฯโ (A : Setฯ) (B : A โ Setฯ) : Setฯ where
constructor _,_
field
projโ : A
projโ : B projโ
open ฮฃฯโ public
record ฮฃฯโ (A : Setฯโ) (B : A โ Setฯ) : Setฯโ where
constructor _,_
field
projโ : A
projโ : B projโ
open ฮฃฯโ public
-- Existential quantification.
โ : {โ โโฒ : Level} โ {A : Set โ} โ (A โ Set โโฒ) โ Set (โ โ โโฒ)
โ = ฮฃ _
โโ : {โ โโฒ โโณ : Level} โ {A : Set โ} {B : A โ Set โโฒ}
(C : (x : A) โ B x โ Set โโณ) โ Set (โ โ โโฒ โ โโณ)
โโ C = โ ฮป a โ โ ฮป b โ C a b
โฯโ : {A : Setฯ} โ (A โ Setฯ) โ Setฯ
โฯโ = ฮฃฯโ _
โฯโยฒ : {A : Setฯ} {B : A โ Setฯ}
(C : (x : A) โ B x โ Setฯ) โ Setฯ
โฯโยฒ C = โฯโ ฮป a โ โฯโ ฮป b โ C a b
โฯโ : {A : Setฯโ} โ (A โ Setฯ) โ Setฯโ
โฯโ = ฮฃฯโ _
-- Cartesian product.
_ร_ : {โ โโฒ : Level} โ (A : Set โ) โ (B : Set โโฒ) โ Set (โ โ โโฒ)
A ร B = ฮฃ A (ฮป x โ B)
_รฯโ_ : {โ : Level} โ (A : Setฯ) โ (B : Set โ) โ Setฯ
A รฯโ B = ฮฃฯโ A (ฮป x โ B)
_รฯโ_ : (A : Setฯ) โ (B : Setฯ) โ Setฯ
A รฯโ B = ฮฃฯโ A (ฮป x โ B)
| {
"alphanum_fraction": 0.5291616039,
"avg_line_length": 19.5952380952,
"ext": "agda",
"hexsha": "7a4461e06f9c0d669b490ba93ed400badd77df53",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "loic-p/logrel-mltt",
"max_forks_repo_path": "Tools/Product.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "loic-p/logrel-mltt",
"max_issues_repo_path": "Tools/Product.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "loic-p/logrel-mltt",
"max_stars_repo_path": "Tools/Product.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 791,
"size": 1646
} |
-- Andreas, 2012-11-22 issue #729, abstract aliases
-- Andreas, 2016-07-19 issue #2102, better fix of #418 helps!
module Issue729 where
abstract
B = Set
Bโ = B
Bโ = Set
abstract
foo : Setโ
foo = x
where x = B
mutual
abstract
D = C
C = B
abstract
mutual
F = E
E = D
-- other stuff
private
A = Set
Y = let X = Set in Set
| {
"alphanum_fraction": 0.5950413223,
"avg_line_length": 11.34375,
"ext": "agda",
"hexsha": "cf53adae8fd8a81efeed65c9673b64cec464ea5d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue729.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue729.agda",
"max_line_length": 61,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue729.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": 133,
"size": 363
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Category.Site {o โ e} (C : Category o โ e) where
open import Level
open import Data.Product using (ฮฃ; _,_; โโ)
open Category C
private
variable
X Y Z : Obj
record Coverage {i} j {I : Obj โ Set i}
(coveringโ : โ {X} โ I X โ Obj)
(coveringโ : โ {X} (i : I X) โ coveringโ i โ X) : Set (i โ suc j โ o โ โ โ e) where
field
J : โ (g : Y โ Z) โ Set j
universalโ : โ {g : Y โ Z} โ J g โ Obj
universalโ : โ {g : Y โ Z} (j : J g) โ universalโ j โ Y
commute : โ {g : Y โ Z} (j : J g) โ โโ (ฮป i k โ g โ universalโ j โ coveringโ i โ k)
record Site i j : Set (suc i โ suc j โ o โ โ โ e) where
field
I : Obj โ Set i
coveringโ : โ {X} โ I X โ Obj
coveringโ : โ {X} (i : I X) โ coveringโ i โ X
coverage : Coverage j coveringโ coveringโ
module coverage = Coverage coverage
open coverage public
| {
"alphanum_fraction": 0.5351239669,
"avg_line_length": 28.4705882353,
"ext": "agda",
"hexsha": "51198a829f2d873672022d174c509fe2809da5e1",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Site.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Site.agda",
"max_line_length": 99,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Site.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": 342,
"size": 968
} |
module JVM.Model.Properties where
open import Data.List
open import Data.List.Properties
open import Data.List.Relation.Binary.Permutation.Propositional
open import Data.List.Relation.Binary.Permutation.Propositional.Properties
open import Data.Product hiding (map)
open import Relation.Unary using (Pred)
open import Relation.Binary.PropositionalEquality
open import Relation.Ternary.Core
open import Relation.Ternary.Structures
open import Relation.Ternary.Structures.Syntax
open import Relation.Ternary.Construct.Bag.Properties
open import Function
module _ {p t} {T : Set t} {P : Pred _ p} where
open import JVM.Model (List T)
open import Data.List.Relation.Unary.All
-- If you know the split and what is bubbling up from the left and right parts,
-- then you know what bubbles up from the composite.
source : โ {ฮฆโ : Intf} โ ฮฆโ โ ฮฆโ โฃ ฮฆ โ All P (up ฮฆโ) โ All P (up ฮฆโ) โ All P (up ฮฆ)
source (ex {uโ} {uโ} (sub xโ xโ) (sub xโ xโ) xโ
xโ) puโ puโ = joinAll (ฮป ()) xโ
puโ' puโ'
where
puโ' = projโ (splitAll (ฮป where dup p โ p , p) xโ puโ)
puโ' = projโ (splitAll (ฮป where dup p โ p , p) xโ puโ)
-- If you know the split and what is bubbling up from the left and flowing down the composite,
-- then you know what flows down the right part.
sinkแตฃ : โ {ฮฆโ : Intf} โ ฮฆโ โ ฮฆโ โฃ ฮฆ โ All P (up ฮฆโ) โ All P (down ฮฆ) โ All P (down ฮฆโ)
sinkแตฃ (ex (sub xโ xโ) (sub xโ xโ) xโ
xโ) puโ puโ = joinAll (ฮป ()) xโ pdโ' peโ
where
pdโ' = projโ (splitAll (ฮป where dup p โ p , p) xโ puโ)
peโ = projโ (splitAll (ฮป where dup p โ p , p) xโ puโ)
-- The same, but different.
sinkโ : โ {ฮฆโ ฮฆโ ฮฆ : Intf} โ ฮฆโ โ ฮฆโ โฃ ฮฆ โ All P (up ฮฆโ) โ All P (down ฮฆ) โ All P (down ฮฆโ)
sinkโ ฯ ups downs = sinkแตฃ (โ-comm ฯ) ups downs
-- {- Mapping along any injection yields a model morphism -}
-- module _ {a b} {A : Set a} {B : Set b} (๐ : A โฃ B) where
-- open Injection ๐
-- private
-- โฆ_โง = ฮป a โ f a
-- j = map โฆ_โง
-- open import JVM.Model A as L
-- open import JVM.Model B as R
-- import Relation.Ternary.Construct.Duplicate.Properties as D
-- import Relation.Ternary.Construct.Empty.Properties as E
-- module OMM = MonoidMorphism (bagMap (D.f-morphism ๐))
-- module DMM = MonoidMorphism (bagMap (E.โฅ-morphism โฆ_โง))
-- import Relation.Ternary.Construct.Bag.Overlapping as O
-- import Relation.Ternary.Construct.Bag.Disjoint as D
-- private
-- sub-lemmaโบ : โ {xs ys u d} โ xs L.- ys โฃ (u L.โ
d) โ j xs R.- j ys โฃ (j u R.โ
j d)
-- sub-lemmaโบ (sub x xโ) = R.sub (DMM.j-โ x) (OMM.j-โ xโ)
-- sub-lemmaโป : โ {xs ys u d} โ j xs R.- j ys โฃ (u R.โ
d) โ
-- โโ ฮป u' d' โ xs L.- ys โฃ (u' L.โ
d') ร u โก j u' ร d โก j d'
-- sub-lemmaโป (sub x y)
-- with _ , x' , refl , refl โ D.map-inv _ โฆ_โง x
-- | _ , y' , refl , eq โ O.map-inv _ โฆ_โง y
-- with refl โ map-injective ๐ eq
-- = -, -, (L.sub x' y' , refl , refl)
-- โฆโง-morphism : SemigroupMorphism L.intf-isSemigroup R.intf-isSemigroup
-- SemigroupMorphism.j โฆโง-morphism (e โ
d) = (j e) R.โ
(j d)
-- SemigroupMorphism.jcong โฆโง-morphism (ฯโ , ฯโ) = mapโบ โฆ_โง ฯโ , mapโบ โฆ_โง ฯโ
-- SemigroupMorphism.j-โ โฆโง-morphism (ex x xโ ฯโ ฯโ) =
-- R.ex (sub-lemmaโบ x) (sub-lemmaโบ xโ) (DMM.j-โ ฯโ) (OMM.j-โ ฯโ)
-- SemigroupMorphism.j-โโป โฆโง-morphism (ex x xโ ฯโ ฯโ) with sub-lemmaโป x
-- ... | _ , _ , y , refl , refl with sub-lemmaโป xโ
-- ... | _ , _ , yโ , refl , refl with _ , ฯโ , refl โ DMM.j-โโป ฯโ | _ , ฯโ , refl โ OMM.j-โโป ฯโ
-- = -, L.ex y yโ ฯโ ฯโ , refl
| {
"alphanum_fraction": 0.6044607566,
"avg_line_length": 42.6746987952,
"ext": "agda",
"hexsha": "1d7ff4d259c0e12cbd3d69934945a553b1724a95",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z",
"max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ajrouvoet/jvm.agda",
"max_forks_repo_path": "src/JVM/Model/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"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": "ajrouvoet/jvm.agda",
"max_issues_repo_path": "src/JVM/Model/Properties.agda",
"max_line_length": 98,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ajrouvoet/jvm.agda",
"max_stars_repo_path": "src/JVM/Model/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z",
"num_tokens": 1404,
"size": 3542
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Functors
------------------------------------------------------------------------
-- Note that currently the functor laws are not included here.
{-# OPTIONS --without-K --safe #-}
module Category.Functor where
open import Function
open import Level
open import Relation.Binary.PropositionalEquality
record RawFunctor {โ} (F : Set โ โ Set โ) : Set (suc โ) where
infixl 4 _<$>_ _<$_
infixl 1 _<&>_
field
_<$>_ : โ {A B} โ (A โ B) โ F A โ F B
_<$_ : โ {A B} โ A โ F B โ F A
x <$ y = const x <$> y
_<&>_ : โ {A B} โ F A โ (A โ B) โ F B
_<&>_ = flip _<$>_
-- A functor morphism from Fโ to Fโ is an operation op such that
-- op (Fโ f x) โก Fโ f (op x)
record Morphism {โ} {Fโ Fโ : Set โ โ Set โ}
(funโ : RawFunctor Fโ)
(funโ : RawFunctor Fโ) : Set (suc โ) where
open RawFunctor
field
op : โ{X} โ Fโ X โ Fโ X
op-<$> : โ{X Y} (f : X โ Y) (x : Fโ X) โ
op (funโ ._<$>_ f x) โก funโ ._<$>_ f (op x)
| {
"alphanum_fraction": 0.463099631,
"avg_line_length": 25.8095238095,
"ext": "agda",
"hexsha": "fd7f607f7a52df9fc9e51ee6a2c647aa92996428",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Category/Functor.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Category/Functor.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Category/Functor.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 362,
"size": 1084
} |
module Naturals where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
infixl 60 _+_
infixl 80 _*_
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
_*_ : Nat -> Nat -> Nat
zero * m = zero
suc n * m = m + n * m
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
{-# BUILTIN NATPLUS _+_ #-}
{-# BUILTIN NATTIMES _*_ #-}
| {
"alphanum_fraction": 0.5272727273,
"avg_line_length": 16.0416666667,
"ext": "agda",
"hexsha": "8f4174eb590c0e79741d3b7a20625a278e88d9e5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "examples/AIM6/HelloAgda/Naturals.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "examples/AIM6/HelloAgda/Naturals.agda",
"max_line_length": 29,
"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/AIM6/HelloAgda/Naturals.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": 142,
"size": 385
} |
-- Two fun examples of generic programming using univalence
{-# OPTIONS --cubical --safe #-}
module Cubical.Experiments.Generic where
open import Agda.Builtin.String
open import Agda.Builtin.List
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.Data.Prod
----------------------------------------------------------------------------
--
-- Dan Licata's example from slide 47 of:
-- http://dlicata.web.wesleyan.edu/pubs/l13jobtalk/l13jobtalk.pdf
There : Typeโ โ Typeโ
There X = List (โ ร String ร (X ร โ))
Database : Typeโ
Database = There (โ ร โ)
us : Database
us = (4 , "John" , (30 , 5) , 1956)
โท (8 , "Hugo" , (29 , 12) , 1978)
โท (15 , "James" , (1 , 7) , 1968)
โท (16 , "Sayid" , (2 , 10) , 1967)
โท (23 , "Jack" , (3 , 12) , 1969)
โท (42 , "Sun" , (20 , 3) , 1980)
โท []
convert : Database โ Database
convert d = transport (ฮป i โ There (swapEq โ โ i)) d
-- Swap the dates of the American database to get the European format
eu : Database
eu = convert us
-- A sanity check
_ : us โก convert eu
_ = refl
----------------------------------------------------------------------------
--
-- Example inspired by:
--
-- Scrap Your Boilerplate: A Practical Design Pattern for Generic Programming
-- Ralf Lรคmmel & Simon Peyton Jones, TLDI'03
Address : Typeโ
Address = String
Name : Typeโ
Name = String
data Person : Typeโ where
P : Name โ Address โ Person
data Salary (A : Typeโ) : Typeโ where
S : A โ Salary A
data Employee (A : Typeโ) : Typeโ where
E : Person โ Salary A โ Employee A
Manager : Typeโ โ Typeโ
Manager A = Employee A
-- First test of "mutual"
mutual
data Dept (A : Typeโ) : Typeโ where
D : Name โ Manager A โ List (SubUnit A) โ Dept A
data SubUnit (A : Typeโ) : Typeโ where
PU : Employee A โ SubUnit A
DU : Dept A โ SubUnit A
data Company (A : Typeโ) : Typeโ where
C : List (Dept A) โ Company A
-- A small example
anders : Employee Int
anders = E (P "Anders" "Pittsburgh") (S (pos 2500))
andrea : Employee Int
andrea = E (P "Andrea" "Copenhagen") (S (pos 2000))
andreas : Employee Int
andreas = E (P "Andreas" "Gothenburg") (S (pos 3000))
-- For now we have a small company
genCom : Company Int
genCom =
C ( D "Research" andreas (PU anders โท PU andrea โท [])
โท [])
-- Increase the salary for everyone by 1
incSalary : Company Int โ Company Int
incSalary c = transport (ฮป i โ Company (sucPathInt i)) c
genCom1 : Company Int
genCom1 = incSalary genCom
-- Increase the salary more
incSalaryโ : โ โ Company Int โ Company Int
incSalaryโ n c = transport (ฮป i โ Company (addEq n i)) c
genCom2 : Company Int
genCom2 = incSalaryโ 2 genCom
genCom10 : Company Int
genCom10 = incSalaryโ 10 genCom
| {
"alphanum_fraction": 0.6354883081,
"avg_line_length": 23.4516129032,
"ext": "agda",
"hexsha": "7996f92c64ceb66f27d2b771fc1701f02b3ed861",
"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/Experiments/Generic.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/Experiments/Generic.agda",
"max_line_length": 77,
"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/Experiments/Generic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 905,
"size": 2908
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
import LibraBFT.Impl.OBM.ConfigHardCoded as ConfigHardCoded
open import LibraBFT.Impl.OBM.Logging.Logging
import LibraBFT.Impl.Storage.DiemDB.DiemDB as DiemDB
import LibraBFT.Impl.Types.OnChainConfig.ValidatorSet as ValidatorSet
open import LibraBFT.ImplShared.Consensus.Types
open import Optics.All
open import Util.ByteString as BS
import Util.Encode as S
open import Util.Hash
open import Util.Prelude
------------------------------------------------------------------------------
open import Data.String using (String)
module LibraBFT.Impl.Consensus.StateComputerByteString where
-- LBFT-OBM-DIFF: In Rust, the following might throw BlockNotFound
-- in execution_correctness_client.execute_block (not needed/implemented).
-- In OBM we call this error ErrECCBlockNotFound so it is easy to see it is
-- defined, caught, but never thrown.
compute : StateComputerComputeType
compute _self block _parentBlockId =
StateComputeResultโnew
(Versionโnew (block ^โ bEpoch {-โ eEpoch-}) (block ^โ bRound {-โ rRound-}))
<$> maybeEC
where
getES : ByteString โ Either (List String) EpochState
maybeEC : Either (List String) (Maybe EpochState)
maybeEC = case block ^โ bBlockData โ bdBlockType of ฮป where
(Proposal {-Payload [-}a{-])-} _author) โ
if BSโisPrefixOf ConfigHardCoded.ePOCHCHANGE a then just <$> getES a else pure nothing
NilBlock โ pure nothing
Genesis โ pure nothing
getES bs = do
let bs' = BSโdrop (BSโlength ConfigHardCoded.ePOCHCHANGE) bs
case S.decode bs' of ฮป where
(Left e) โ Left ("StateComputerByteString" โท "compute" โท "decode" โท {-T.pack-} e โท [])
(Right vv) โ Right (EpochStateโnew (block ^โ bEpoch + 1) vv)
-- LBFT-OBM-DIFF : gets block instead of vector of hashes
-- TODO-2: consider converting to EitherD before proving anything about this
commit : StateComputerCommitType
commit self db (ExecutedBlockโnew _b (StateComputeResultโnew version _)) liws =
case (DiemDB.saveTransactions.E db (just liws)) of ฮป where
(Left e) โ Left (errText e)
(Right db') โ pure
( (self & scObmVersion โ~ version)
, db'
, (maybeS (liws ^โ liwsLedgerInfo โ liNextEpochState) nothing $ ฮป (EpochStateโnew e vv) โ
just (ReconfigEventEpochChangeโnew
(OnChainConfigPayloadโnew e (ValidatorSet.obmFromVV vv))))
)
-- LBFT-OBM-DIFF : completely different
syncTo : StateComputerSyncToType
syncTo liws =
maybeS (liws ^โ liwsNextEpochState) (Left ("StateComputerByteString" โท "syncTo" โท "Nothing" โท [])) $
ฮป (EpochStateโnew e vv) โ
Right (ReconfigEventEpochChangeโnew
(OnChainConfigPayloadโnew e (ValidatorSet.obmFromVV vv)))
| {
"alphanum_fraction": 0.6632555165,
"avg_line_length": 44.6714285714,
"ext": "agda",
"hexsha": "e8944758aac218a46c69578f7468773258cd5b2d",
"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/StateComputerByteString.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/StateComputerByteString.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/StateComputerByteString.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 858,
"size": 3127
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Data.Vec.OperationsNat where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty as โฅ
open import Cubical.Data.Nat renaming (_+_ to _+n_; _ยท_ to _ยทn_)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Vec.Base
open import Cubical.Data.Vec.Properties
open import Cubical.Data.Sigma
open import Cubical.Data.Sum
open import Cubical.Relation.Nullary
private variable
โ : Level
-----------------------------------------------------------------------------
-- Generating Vector
genฮดโ-Vec : {A : Type โ} โ (m k : โ) โ (a b : A) โ Vec A m
genฮดโ-Vec zero k a b = []
genฮดโ-Vec (suc m) k a b with (discreteโ k m)
... | yes p = a โท replicate b
... | no ยฌp = b โท (genฮดโ-Vec m k a b)
-- some results are easier / false without general a and b
ฮดโ-Vec : (m : โ) โ (k : โ) โ Vec โ m
ฮดโ-Vec m k = genฮดโ-Vec m k 1 0
ฮดโ-Vec-nโคkโโก : (m k : โ) โ (m โค k) โ ฮดโ-Vec m k โก replicate 0
ฮดโ-Vec-nโคkโโก zero k r = refl
ฮดโ-Vec-nโคkโโก (suc m) k r with (discreteโ k m)
... | yes p = โฅ.rec (<โโข r (sym p))
... | no ยฌp = cong (ฮป X โ 0 โท X) (ฮดโ-Vec-nโคkโโก m k (โค-trans โค-sucโ r))
ฮดโ-Vec-k<nโโข : (m k : โ) โ (k < m) โ (ฮดโ-Vec m k โก replicate 0 โ โฅ)
ฮดโ-Vec-k<nโโข zero k r = โฅ.rec (ยฌ-<-zero r)
ฮดโ-Vec-k<nโโข (suc m) k r q with (discreteโ k m) | (โค-split r)
... | yes p | z = compute-eqโ 1 0 (fst (VecPath.encode _ _ q))
... | no ยฌp | inl x = ฮดโ-Vec-k<nโโข m k (pred-โค-pred x) (snd (VecPath.encode _ _ q))
... | no ยฌp | inr x = ยฌp (injSuc x)
-----------------------------------------------------------------------------
-- Point wise add
_+n-vec_ : {m : โ} โ Vec โ m โ Vec โ m โ Vec โ m
_+n-vec_ {.zero} [] [] = []
_+n-vec_ {.(suc _)} (k โท v) (l โท v') = (k +n l) โท (v +n-vec v')
+n-vec-lid : {m : โ} โ (v : Vec โ m) โ replicate 0 +n-vec v โก v
+n-vec-lid {.zero} [] = refl
+n-vec-lid {.(suc _)} (k โท v) = cong (_โท_ k) (+n-vec-lid v)
+n-vec-rid : {m : โ} โ (v : Vec โ m) โ v +n-vec replicate 0 โก v
+n-vec-rid {.zero} [] = refl
+n-vec-rid {.(suc _)} (k โท v) = congโ _โท_ (+-zero k) (+n-vec-rid v)
+n-vec-assoc : {m : โ} โ (v v' v'' : Vec โ m) โ v +n-vec (v' +n-vec v'') โก (v +n-vec v') +n-vec v''
+n-vec-assoc [] [] [] = refl
+n-vec-assoc (k โท v) (l โท v') (p โท v'') = congโ _โท_ (+-assoc k l p) (+n-vec-assoc v v' v'')
+n-vec-comm : {m : โ} โ (v v' : Vec โ m) โ v +n-vec v' โก v' +n-vec v
+n-vec-comm {.zero} [] [] = refl
+n-vec-comm {.(suc _)} (k โท v) (l โท v') = congโ _โท_ (+-comm k l) (+n-vec-comm v v')
-----------------------------------------------------------------------------
-- Equlity on Vec โ
+n-vecSplitReplicate0 : {m : โ} โ (v v' : Vec โ m) โ (v +n-vec v') โก replicate 0
โ (v โก replicate 0) ร (v' โก replicate 0)
+n-vecSplitReplicate0 [] [] p = refl , refl
+n-vecSplitReplicate0 (k โท v) (l โท v') p with VecPath.encode ((k +n l) โท (v +n-vec v')) (replicate 0) p
... | pkl , pvv' = (congโ _โท_ (fst (m+nโก0โmโก0รnโก0 pkl)) (fst (+n-vecSplitReplicate0 v v' pvv'))) ,
(congโ _โท_ (snd (m+nโก0โmโก0รnโก0 pkl)) (snd (+n-vecSplitReplicate0 v v' pvv')))
pred-vec-โข0 : {m : โ} โ (v : Vec โ m) โ (v โก replicate 0 โ โฅ)
โ ฮฃ[ k โ โ ] (ฮฃ[ v' โ Vec โ m ] ( ฮฃ[ r โ (k < m) ] v โก v' +n-vec (ฮดโ-Vec m k)))
pred-vec-โข0 {zero} [] ยฌq = โฅ.rec (ยฌq refl)
pred-vec-โข0 {(suc m)} (l โท v) ยฌq with (discreteโ l 0)
-- case l โก 0
pred-vec-โข0 {(suc m)} (l โท v) ยฌq | yes p with pred-vec-โข0 v (ฮป r โ ยฌq (congโ _โท_ p r))
... | k , v' , infkm , eqvv' = k , ((0 โท v') , ((โค-trans infkm โค-sucโ) , helper))
where
helper : _
helper with (discreteโ k m)
... | yes pp = โฅ.rec (<โโข (fst infkm , +-suc _ _ โ cong suc (snd infkm)) (cong suc pp))
... | no ยฌpp = congโ _โท_ p eqvv'
-- case l โข 0
pred-vec-โข0 {(suc m)} (l โท v) ยฌq | no ยฌp = m , ((predโ l โท v) , (โค-refl , helper))
where
helper : _
helper with (discreteโ m m)
... | yes pp = congโ _โท_ (sym (+-suc _ _ โ +-zero _ โ sym (suc-predโ l ยฌp)))
(sym (+n-vec-rid v))
... | no ยฌpp = โฅ.rec (ยฌpp refl)
-- split + concat vec results
sep-vec : (k l : โ) โ Vec โ (k +n l) โ (Vec โ k) ร (Vec โ l )
sep-vec zero l v = [] , v
sep-vec (suc k) l (x โท v) = (x โท fst (sep-vec k l v)) , (snd (sep-vec k l v))
sep-vec-fst : (k l : โ) โ (v : Vec โ k) โ (v' : Vec โ l) โ fst (sep-vec k l (v ++ v')) โก v
sep-vec-fst zero l [] v' = refl
sep-vec-fst (suc k) l (x โท v) v' = cong (ฮป X โ x โท X) (sep-vec-fst k l v v')
sep-vec-snd : (k l : โ) โ (v : Vec โ k) โ (v' : Vec โ l) โ snd (sep-vec k l (v ++ v')) โก v'
sep-vec-snd zero l [] v' = refl
sep-vec-snd (suc k) l (x โท v) v' = sep-vec-snd k l v v'
sep-vec-id : (k l : โ) โ (v : Vec โ (k +n l)) โ fst (sep-vec k l v) ++ snd (sep-vec k l v) โก v
sep-vec-id zero l v = refl
sep-vec-id (suc k) l (x โท v) = cong (ฮป X โ x โท X) (sep-vec-id k l v)
rep-concat : (k l : โ) โ {B : Type โ} โ (b : B) โ
replicate {_} {k} {B} b ++ replicate {_} {l} {B} b โก replicate {_} {k +n l} {B} b
rep-concat zero l b = refl
rep-concat (suc k) l b = cong (ฮป X โ b โท X) (rep-concat k l b)
+n-vec-concat : (k l : โ) โ (v w : Vec โ k) โ (v' w' : Vec โ l)
โ (v +n-vec w) ++ (v' +n-vec w') โก (v ++ v') +n-vec (w ++ w')
+n-vec-concat zero l [] [] v' w' = refl
+n-vec-concat (suc k) l (x โท v) (y โท w) v' w' = cong (ฮป X โ x +n y โท X) (+n-vec-concat k l v w v' w')
| {
"alphanum_fraction": 0.4859795377,
"avg_line_length": 40.9147286822,
"ext": "agda",
"hexsha": "9c1d6940b2f8fa9ccd4fca7d7fe55d828b66ea26",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Data/Vec/OperationsNat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Data/Vec/OperationsNat.agda",
"max_line_length": 103,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Data/Vec/OperationsNat.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 2366,
"size": 5278
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cohomology.Theory
module cohomology.Coproduct {i} (CT : CohomologyTheory i)
(n : โค) (X Y : Ptd i) where
open CohomologyTheory CT
open import cohomology.Sigma CT
private
P : Bool โ Ptd i
P true = X
P false = Y
C-โ : C n (X โโ Y) โแดณ C n (X โโจ Y) รแดณ C2 n
C-โ = (รแดณ-emap
(C-emap n (โ-to-โโ ( BigWedge-Bool-equiv-Wedge P
โe BigWedge-emap-l P lower-equiv) idp))
(idiso _)) โปยนแดณ
โeแดณ C-ฮฃ n (โLift {j = i} โBool) (P โ lower)
โeแดณ C-emap n (โ-to-โโ ( ฮฃBool-equiv-โ (deโ โ P)
โe ฮฃ-emap-l (deโ โ P) lower-equiv) idp)
| {
"alphanum_fraction": 0.5412844037,
"avg_line_length": 26.16,
"ext": "agda",
"hexsha": "99d873053dd558f83093f751fe090b9a4ace19e6",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/cohomology/Coproduct.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/cohomology/Coproduct.agda",
"max_line_length": 65,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/cohomology/Coproduct.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 306,
"size": 654
} |
open import Agda.Builtin.Unit
open import Agda.Builtin.Bool
open import Agda.Builtin.Sigma
data โฅ : Set where
type : Bool โ Set
type true = โค
type false = โฅ
record Bad : Set where
constructor b
field
.f : ฮฃ Bool type
test : Bad โ Bool
test (b (x , y)) = x
| {
"alphanum_fraction": 0.6654275093,
"avg_line_length": 14.1578947368,
"ext": "agda",
"hexsha": "b44d58b101f4997901e8e53a51a374e9e571ccf1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue3056.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/Issue3056.agda",
"max_line_length": 30,
"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/Issue3056.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": 90,
"size": 269
} |
module Negative3 where
data Mu (F : Set -> Set) : Set where
inn : F (Mu F) -> Mu F
| {
"alphanum_fraction": 0.5666666667,
"avg_line_length": 12.8571428571,
"ext": "agda",
"hexsha": "117337f24827294f582c8be9cf555968abf3ad9f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Negative3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Negative3.agda",
"max_line_length": 36,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Negative3.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 30,
"size": 90
} |
module Ethambda.Position
import Eth.Prelude -- using (bool)
import Prelude.Bool -- using (bool)
import Data.List -- using (intercalate)
import Prelude.Monad -- using ((>=>))
import Control.Monad.Identity
import Control.Monad.Writer -- using
-- (MonadWriter, WriterT, Writer, execWriterT, execWriter, tell)
import Control.Monad.Reader -- using
-- (MonadReader, ReaderT, Reader, runReaderT, runReader, ask, local)
import Ethambda.Common -- using ((<.>), (<.))
import Ethambda.System -- using (Type(Var, Fun))
-- * The 'PosNeg' type.
record PosNeg a where
constructor PN
negatives : List a
positives : List a
stuff : Show a => String -> List a -> String
stuff ttl l = case l of
[] => neutral
_ => ttl <> ": " <> unwords (intercalate (pure ",") (map (pure . show) l))
Show a => Show (PosNeg a) where
show (PN neg pos)
= "PN"
<.> "neg"
<.> "pos"
Semigroup (PosNeg a) where
(PN p n) <+> (PN p' n') = PN (p <> p') (n <> n')
Monoid (PosNeg a) where
neutral = PN neutral neutral
pos : a -> PosNeg a
pos a = PN neutral (pure a)
neg : a -> PosNeg a
neg a = PN (pure a) neutral
-- * Core algorithm.
AppM : Type -> (Type -> Type) -> Type
AppM a m =
( MonadWriter (PosNeg a) m
, MonadReader Bool m
)
App : Type -> Type -> Type
App a x = WriterT (PosNeg a) (Reader Bool) x
-- implementation Functor (ReaderT ?a ?m) where
-- execApp : App a x -> PosNeg a
execApp : WriterT (PosNeg a) (ReaderT Bool Identity) x -> PosNeg a
execApp = (`runReader` True) . execWriterT
-- tellPos : AppM a m => a -> m ()
tellPos : MonadWriter (PosNeg a) m => a -> m ()
-- tellPos = tell . pos
tellPos = tell . pos
-- tellNeg : AppM a m => a -> m ()
-- tellNeg = tell . neg
tellNeg : MonadWriter (PosNeg a) m => a -> m ()
tellNeg = tell . neg
-- tellIt : AppM a m => a -> m ()
-- tellIt a = ask >>= bool (tellNeg a) (tellPos a)
tellIt
: MonadWriter (PosNeg a) m
=> MonadReader Bool m
=> a -> m ()
tellIt a = ask >>= bool (tellNeg a) (tellPos a)
-- positionM : AppM a m => Type a -> m ()
positionM
: MonadWriter (PosNeg a) n
=> MonadReader Bool m
=> Tp a -> m ()
positionM tp = case tp of
Var a => tellIt a
Fun t u => do
positionM u
local not $ positionM t
-- export
-- position : Type a -> PosNeg a
-- position = execApp . positionM
| {
"alphanum_fraction": 0.6134969325,
"avg_line_length": 23.5257731959,
"ext": "agda",
"hexsha": "9a3ddd0f6137e23a701d09a72dcba5a45dca3ce2",
"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": "18e1f9271a3ce76319cdfbcffe027c2088a418aa",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "fredefox/ethambda-agda",
"max_forks_repo_path": "src/Ethambda/Position.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa",
"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": "fredefox/ethambda-agda",
"max_issues_repo_path": "src/Ethambda/Position.agda",
"max_line_length": 77,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "fredefox/ethambda-agda",
"max_stars_repo_path": "src/Ethambda/Position.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 732,
"size": 2282
} |
{-# OPTIONS --erased-cubical --safe #-}
module Pitch where
open import Cubical.Core.Everything using (_โก_; Level; Type; ฮฃ; _,_; fst; snd; _โ_; ~_)
open import Cubical.Foundations.Prelude using (refl; sym; _โ_; cong; transport; subst; funExt; transp)
--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)
open import Data.Integer using (โค; +_; -[1+_])
open import Data.Fin using (Fin; toโ; #_; _โ_; fromโ<) renaming (zero to fz; suc to fs)
open import Data.List using (List; []; _โท_; foldr; map)
open import Data.Maybe using (Maybe; just; nothing) renaming (map to mmap)
open import Data.Nat using (โ; zero; suc; _+_; _*_; _โธ_; _โกแต_; _>_)
open import Data.Nat.DivMod using (_mod_; _div_)
open import Data.Product using (_ร_; _,_; projโ)
open import Data.String using (String; intersperse) renaming (_++_ to _++s_)
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 using (nโธk<n; _+N_; opposite; _โ_)
-- Position of a pitch on an absolute scale
-- 0 is C(-1) on the international scale (where C4 is middle C)
-- or C0 on the Midi scale (where C5 is middle C)
-- Pitch is intentially set to match Midi pitch.
-- However it is fine to let 0 represent some other note and
-- translate appropriately at the end.
Pitch : Type
Pitch = โ
-- Number of notes in the chromatic scale.
s12 : โ
s12 = 12
-- Number of notes in the diatonic scale.
s7 : โ
s7 = 7
-- Pitch Class: position of a pitch within an octave, in the range [0..s12-1].
-- Pitch class 0 corresponds to C (assuming pitch 0 is Midi C0), which is standard.
PC : Type
PC = Fin s12
showPC : PC โ String
showPC fz = "0"
showPC (fs fz) = "1"
showPC (fs (fs fz)) = "2"
showPC (fs (fs (fs fz))) = "3"
showPC (fs (fs (fs (fs fz)))) = "4"
showPC (fs (fs (fs (fs (fs fz))))) = "5"
showPC (fs (fs (fs (fs (fs (fs fz)))))) = "6"
showPC (fs (fs (fs (fs (fs (fs (fs fz))))))) = "7"
showPC (fs (fs (fs (fs (fs (fs (fs (fs fz)))))))) = "8"
showPC (fs (fs (fs (fs (fs (fs (fs (fs (fs fz))))))))) = "9"
showPC (fs (fs (fs (fs (fs (fs (fs (fs (fs (fs fz)))))))))) = "a"
showPC (fs (fs (fs (fs (fs (fs (fs (fs (fs (fs (fs fz))))))))))) = "b"
showPCs : List PC โ String
showPCs pcs = intersperse " " (map showPC pcs)
toPC : Pitch โ PC
toPC = _mod s12
Scale : โ โ Type
Scale = Vec PC
-- Which octave one is in.
Octave : Type
Octave = โ
PitchOctave : Type
PitchOctave = PC ร Octave
relativeToAbsolute : PitchOctave โ Pitch
relativeToAbsolute (n , o) = (o * s12 + (toโ n))
absoluteToRelative : Pitch โ PitchOctave
absoluteToRelative n = (toPC n , n div s12)
pitchToClass : Pitch โ PC
pitchToClass = projโ โ absoluteToRelative
majorScale harmonicMinorScale : Scale s7
majorScale = # 0 โท # 2 โท # 4 โท # 5 โท # 7 โท # 9 โท # 11 โท []
harmonicMinorScale = # 0 โท # 2 โท # 3 โท # 5 โท # 7 โท # 8 โท # 11 โท []
wholeTone0Scale wholeTone1Scale : Scale 6
wholeTone0Scale = # 0 โท # 2 โท # 4 โท # 6 โท # 8 โท # 10 โท []
wholeTone1Scale = # 1 โท # 3 โท # 5 โท # 7 โท # 9 โท # 11 โท []
octatonic01Scale octatonic02Scale octatonic12Scale : Scale 8
octatonic01Scale = # 0 โท # 1 โท # 3 โท # 4 โท # 6 โท # 7 โท # 9 โท # 10 โท []
octatonic02Scale = # 0 โท # 2 โท # 3 โท # 5 โท # 6 โท # 8 โท # 9 โท # 11 โท []
octatonic12Scale = # 1 โท # 2 โท # 4 โท # 5 โท # 7 โท # 8 โท # 10 โท # 11 โท []
majorPentatonicScale minorPentatonicScale ryukyuScale : Scale 5
majorPentatonicScale = # 0 โท # 2 โท # 4 โท # 7 โท # 9 โท []
minorPentatonicScale = # 0 โท # 2 โท # 4 โท # 7 โท # 9 โท []
ryukyuScale = # 0 โท # 4 โท # 5 โท # 7 โท # 11 โท []
indexInScale : {n : โ} โ Vec PC n โ Fin s12 โ Maybe (Fin n)
indexInScale [] p = nothing
indexInScale (pc โท pcs) p with pc โ p
... | yes _ = just fz
... | no _ = mmap fs (indexInScale pcs p)
scaleSize : {n : โ} โ Scale n โ โ
scaleSize {n} _ = n
transposePitch : โค โ Pitch โ Pitch
transposePitch (+_ k) n = n + k
transposePitch (-[1+_] k) n = n โธ suc k
-- transpose pitch class
Tp : โ โ PC โ PC
Tp n pc = pc +N n
-- invert pitch class
Ip : PC โ PC
Ip = opposite
-- Set of pitch classes represented as a bit vector.
PCSet : Type
PCSet = BitVec s12
toPCSet : List PC โ PCSet
toPCSet = foldr insert empty
fromPCSet : PCSet โ List PC
fromPCSet pcs = fromPCS s12 pcs
where fromPCS : (n : โ) โ BitVec n โ List PC
fromPCS zero [] = []
fromPCS (suc n) (false โท xs) = fromPCS n xs
fromPCS (suc n) (true โท xs) = fromโ< (nโธk<n 11 n) โท fromPCS n xs
-- transpose pitch class set
T : โ โ PCSet โ PCSet
T n = toPCSet โ map (Tp n) โ fromPCSet
-- invert pitch class set
I : PCSet โ PCSet
I = toPCSet โ map Ip โ fromPCSet
-- Standard Midi pitches
-- first argument is relative pitch within octave
-- second argument is octave (C5 = middle C for Midi)
standardMidiPitch : Fin s12 โ โ โ Pitch
standardMidiPitch p o = relativeToAbsolute (p , o)
c cโฏ d dโฏ e f fโฏ g gโฏ a bโญ b : โ โ Pitch
c = standardMidiPitch (# 0)
cโฏ = standardMidiPitch (# 1)
d = standardMidiPitch (# 2)
dโฏ = standardMidiPitch (# 3)
e = standardMidiPitch (# 4)
f = standardMidiPitch (# 5)
fโฏ = standardMidiPitch (# 6)
g = standardMidiPitch (# 7)
gโฏ = standardMidiPitch (# 8)
a = standardMidiPitch (# 9)
bโญ = standardMidiPitch (# 10)
b = standardMidiPitch (# 11)
-- Equivalences
relโabs : PitchOctave โ Pitch
relโabs = relativeToAbsolute
absโrel : Pitch โ PitchOctave
absโrel = absoluteToRelative
{-
relโabsโrel : (p : PitchOctave) โ (absโrel โ relโabs) p โก p
relโabsโrel (pitchClass p , octave o) i =
let a = cong pitchClass (modUnique s12 o p)
b = cong octave (divUnique s12 o p)
in a i , b i
absโrelโabs : (p : Pitch) โ (relโabs โ absโrel) p โก p
absโrelโabs (pitch p) = cong pitch (sym (nโกdivmod p s12))
absโrel : Iso Pitch PitchOctave
absโrel = iso absโrel relโabs relโabsโrel absโrelโabs
absโกrel : Pitch โก PitchOctave
absโกrel = isoToPath absโrel
-}
| {
"alphanum_fraction": 0.6218800648,
"avg_line_length": 31.641025641,
"ext": "agda",
"hexsha": "329bb7d55e7cd5e5d6293828ff11b7e48c306d77",
"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/Pitch.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/Pitch.agda",
"max_line_length": 107,
"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/Pitch.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": 2301,
"size": 6170
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Strings
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.String where
open import Data.Vec as Vec using (Vec)
open import Data.Char as Char using (Char)
------------------------------------------------------------------------
-- Re-export contents of base, and decidability of equality
open import Data.String.Base public
open import Data.String.Properties using (_โ_; _==_) public
------------------------------------------------------------------------
-- Operations
toVec : (s : String) โ Vec Char (length s)
toVec s = Vec.fromList (toList s)
| {
"alphanum_fraction": 0.4289617486,
"avg_line_length": 29.28,
"ext": "agda",
"hexsha": "7959353b7935168531baa9b3f37f0e0fa60d321c",
"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/String.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/String.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/String.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 117,
"size": 732
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.Groups.Torus where
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.Groups.Connected
open import Cubical.ZCohomology.MayerVietorisUnreduced
open import Cubical.ZCohomology.Groups.Unit
open import Cubical.ZCohomology.Groups.Sn
open import Cubical.ZCohomology.Groups.Prelims
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Data.Sigma
open import Cubical.Data.Int renaming (_+_ to _+โค_; +Comm to +โค-comm ; +Assoc to +โค-assoc)
open import Cubical.Data.Nat
open import Cubical.Data.Unit
open import Cubical.Algebra.Group renaming (โค to โคGroup ; Bool to BoolGroup ; Unit to UnitGroup)
open import Cubical.HITs.Pushout
open import Cubical.HITs.S1
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2) hiding (map)
open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim2 to pElim2 ; โฃ_โฃ to โฃ_โฃโ) hiding (map)
open import Cubical.HITs.Nullification
open import Cubical.HITs.Truncation renaming (elim to trElim ; elim2 to trElim2 ; map to trMap ; rec to trRec)
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Loopspace
open IsGroupHom
open Iso
-- The following section contains stengthened induction principles for cohomology groups of Tยฒ. They are particularly useful for showing that
-- that some Isos are morphisms. They make things type-check faster, but should probably not be used for computations.
-- We first need some functions
elimFunTยฒ : (n : โ) (p q : typ (ฮฉ (coHomK-ptd (suc n))))
โ Square q q p p
โ Sยน ร Sยน โ coHomK (suc n)
elimFunTยฒ n p q P (base , base) = โฃ ptSn (suc n) โฃ
elimFunTยฒ n p q P (base , loop i) = q i
elimFunTยฒ n p q P (loop i , base) = p i
elimFunTยฒ n p q P (loop i , loop j) = P i j
elimFunTยฒ' : (n : โ) โ Square (refl {โ-zero} {coHomK (suc n)} {โฃ ptSn (suc n) โฃ}) refl refl refl
โ Sยน ร Sยน โ coHomK (suc n)
elimFunTยฒ' n P (x , base) = โฃ ptSn (suc n) โฃ
elimFunTยฒ' n P (base , loop j) = โฃ ptSn (suc n) โฃ
elimFunTยฒ' n P (loop i , loop j) = P i j
elimFunTยฒ'โกelimFunTยฒ : (n : โ) โ (P : _) โ elimFunTยฒ' n P โก elimFunTยฒ n refl refl P
elimFunTยฒ'โกelimFunTยฒ n P i (base , base) = โฃ ptSn (suc n) โฃ
elimFunTยฒ'โกelimFunTยฒ n P i (base , loop k) = โฃ ptSn (suc n) โฃ
elimFunTยฒ'โกelimFunTยฒ n P i (loop j , base) = โฃ ptSn (suc n) โฃ
elimFunTยฒ'โกelimFunTยฒ n P i (loop j , loop k) = P j k
{-
The first induction principle says that when proving a proposition for some x : Hโฟ(Tยฒ), n โฅ 1, it suffices to show that it holds for
(elimFunTยฒ p q P) for any paths p q : ฮฉKโ, and square P : Square q q p p. This is useful because elimFunTยฒ p q P (base , base) recudes to 0
-}
coHomPointedElimTยฒ : โ {โ} (n : โ) {B : coHom (suc n) (Sยน ร Sยน) โ Type โ}
โ ((x : coHom (suc n) (Sยน ร Sยน)) โ isProp (B x))
โ ((p q : _) (P : _) โ B โฃ elimFunTยฒ n p q P โฃโ)
โ (x : coHom (suc n) (Sยน ร Sยน)) โ B x
coHomPointedElimTยฒ n {B = B} isprop indp =
coHomPointedElim _ (base , base) isprop
ฮป f fId โ subst B (cong โฃ_โฃโ (funExt (ฮป { (base , base) โ sym fId
; (base , loop i) j โ helper f fId i1 i (~ j)
; (loop i , base) j โ helper f fId i i1 (~ j)
; (loop i , loop j) k โ helper f fId i j (~ k)})))
(indp (ฮป i โ helper f fId i i1 i1)
(ฮป i โ helper f fId i1 i i1)
ฮป i j โ helper f fId i j i1)
where
helper : (f : Sยน ร Sยน โ coHomK (suc n)) โ f (base , base) โก โฃ ptSn (suc n) โฃ
โ I โ I โ I โ coHomK (suc n)
helper f fId i j k =
hfill (ฮป k โ ฮป {(i = i0) โ doubleCompPath-filler (sym fId) (cong f (ฮป i โ (base , loop i))) fId k j
; (i = i1) โ doubleCompPath-filler (sym fId) (cong f (ฮป i โ (base , loop i))) fId k j
; (j = i0) โ doubleCompPath-filler (sym fId) (cong f (ฮป i โ (loop i , base))) fId k i
; (j = i1) โ doubleCompPath-filler (sym fId) (cong f (ฮป i โ (loop i , base))) fId k i})
(inS (f ((loop i) , (loop j))))
k
private
lem : โ {โ} (n : โ) {B : coHom (2 + n) (Sยน ร Sยน) โ Type โ}
โ ((P : _) โ B โฃ elimFunTยฒ (suc n) refl refl P โฃโ)
โ (p : _) โ (refl โก p)
โ (q : _) โ (refl โก q)
โ (P : _)
โ B โฃ elimFunTยฒ (suc n) p q P โฃโ
lem n {B = B} elimP p =
J (ฮป p _ โ (q : _) โ (refl โก q)
โ (P : _)
โ B โฃ elimFunTยฒ (suc n) p q P โฃโ)
ฮป q โ
J (ฮป q _ โ (P : _) โ B โฃ elimFunTยฒ (suc n) refl q P โฃโ)
elimP
{- When working with Hโฟ(Tยฒ) , n โฅ 2, we are, in the case described above, allowed to assume that any f : Hโฟ(Tยฒ) is
elimFunTยฒ n refl refl P -}
coHomPointedElimTยฒ' : โ {โ} (n : โ) {B : coHom (2 + n) (Sยน ร Sยน) โ Type โ}
โ ((x : coHom (2 + n) (Sยน ร Sยน)) โ isProp (B x))
โ ((P : _) โ B โฃ elimFunTยฒ (suc n) refl refl P โฃโ)
โ (x : coHom (2 + n) (Sยน ร Sยน)) โ B x
coHomPointedElimTยฒ' n {B = B} prop ind =
coHomPointedElimTยฒ (suc n) prop
ฮป p q P โ trRec (isPropโisOfHLevelSuc n (prop _))
(ฮป p-refl โ trRec (isPropโisOfHLevelSuc n (prop _))
(ฮป q-refl โ lem n {B = B} ind p (sym p-refl) q (sym q-refl) P)
(isConnectedPath _ (isConnectedPathKn (suc n) _ _) q refl .fst))
(isConnectedPath _ (isConnectedPathKn (suc n) _ _) p refl .fst)
{- A slight variation of the above which gives definitional equalities for all points (x , base) -}
private
coHomPointedElimTยฒ'' : โ {โ} (n : โ) {B : coHom (2 + n) (Sยน ร Sยน) โ Type โ}
โ ((x : coHom (2 + n) (Sยน ร Sยน)) โ isProp (B x))
โ ((P : _) โ B โฃ elimFunTยฒ' (suc n) P โฃโ)
โ (x : coHom (2 + n) (Sยน ร Sยน)) โ B x
coHomPointedElimTยฒ'' n {B = B} prop ind =
coHomPointedElimTยฒ' n prop ฮป P โ subst (ฮป x โ B โฃ x โฃโ)
(elimFunTยฒ'โกelimFunTยฒ (suc n) P) (ind P)
--------- Hโฐ(Tยฒ) ------------
Hโฐ-Tยฒโ
โค : GroupIso (coHomGr 0 (Sโ 1 ร Sโ 1)) โคGroup
Hโฐ-Tยฒโ
โค =
Hโฐ-connected (base , base)
ฮป (a , b) โ pRec isPropPropTrunc
(ฮป id1 โ pRec isPropPropTrunc
(ฮป id2 โ โฃ ฮฃPathP (id1 , id2) โฃโ)
(Sn-connected 0 b) )
(Sn-connected 0 a)
--------- Hยน(Tยฒ) -------------------------------
Hยน-Tยฒโ
โครโค : GroupIso (coHomGr 1 ((Sโ 1) ร (Sโ 1))) (DirProd โคGroup โคGroup)
Hยน-Tยฒโ
โครโค = theIso โก GroupIsoDirProd (Hโฟ-Sโฟโ
โค 0) (Hโฐ-Sโฟโ
โค 0)
where
typIso : Iso _ _
typIso = setTruncIso (curryIso โ codomainIso S1โKโโกS1รโค โ toProdIso)
โ setTruncOfProdIso
theIso : GroupIso _ _
fst theIso = typIso
snd theIso =
makeIsGroupHom
(coHomPointedElimTยฒ _ (ฮป _ โ isPropฮ ฮป _ โ isSetร isSetSetTrunc isSetSetTrunc _ _)
ฮป pf qf Pf โ
coHomPointedElimTยฒ _ (ฮป _ โ isSetร isSetSetTrunc isSetSetTrunc _ _)
ฮป pg qg Pg i โ โฃ funExt (helperFst pf qf pg qg Pg Pf) i โฃโ
, โฃ funExt (helperSnd pf qf pg qg Pg Pf) i โฃโ)
where
module _ (pf qf pg qg : 0โ 1 โก 0โ 1) (Pg : Square qg qg pg pg) (Pf : Square qf qf pf pf) where
helperFst : (x : Sยน)
โ fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pf qf Pf (x , y) +โ elimFunTยฒ 0 pg qg Pg (x , y)) .fst
โก fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pf qf Pf (x , y)) .fst
+โ fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pg qg Pg (x , y)) .fst
helperFst base = refl
helperFst (loop i) j = loopLem j i
where
loopLem : cong (ฮป x โ fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pf qf Pf (x , y) +โ elimFunTยฒ 0 pg qg Pg (x , y)) .fst) loop
โก cong (ฮป x โ fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pf qf Pf (x , y)) .fst
+โ fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pg qg Pg (x , y)) .fst) loop
loopLem = (ฮป i j โ Sยนmap-id (pf j +โ pg j) i)
โ (ฮป i j โ Sยนmap-id (pf j) (~ i) +โ Sยนmap-id (pg j) (~ i))
helperSnd : (x : Sยน)
โ fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pf qf Pf (x , y) +โ elimFunTยฒ 0 pg qg Pg (x , y)) .snd
โก fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pf qf Pf (x , y)) .snd +โค fun S1โKโโกS1รโค (ฮป y โ elimFunTยฒ 0 pg qg Pg (x , y)) .snd
helperSnd =
toPropElim (ฮป _ โ isSetโค _ _)
((ฮป i โ winding (basechange2โป base ฮป j โ Sยนmap (โโก+โ qf qg (~ i) j)))
โโ cong (winding โ basechange2โป base) (congFunct Sยนmap qf qg)
โโ (cong winding (basechange2โป-morph base (cong Sยนmap qf) (cong Sยนmap qg))
โ winding-hom (basechange2โป base (cong Sยนmap qf)) (basechange2โป base (cong Sยนmap qg))))
----------------------- Hยฒ(Tยฒ) ------------------------------
Hยฒ-Tยฒโ
โค : GroupIso (coHomGr 2 (Sโ 1 ร Sโ 1)) โคGroup
Hยฒ-Tยฒโ
โค = compGroupIso helper2 (Hโฟ-Sโฟโ
โค 0)
where
helper : Iso (โฅ ((a : Sยน) โ coHomK 2) โฅโ ร โฅ ((a : Sยน) โ coHomK 1) โฅโ) (coHom 1 Sยน)
inv helper s = 0โ _ , s
fun helper = snd
leftInv helper _ =
ฮฃPathP (isOfHLevelSuc 0 (isOfHLevelRetractFromIso 0 (fst (Hโฟ-Sยนโ
0 0)) (isContrUnit)) _ _
, refl)
rightInv helper _ = refl
theIso : Iso (coHom 2 (Sยน ร Sยน)) (coHom 1 Sยน)
theIso = setTruncIso (curryIso โ codomainIso S1โK2โกK2รK1 โ toProdIso)
โ setTruncOfProdIso
โ helper
helper2 : GroupIso (coHomGr 2 (Sยน ร Sยน)) (coHomGr 1 Sยน)
helper2 .fst = theIso
helper2 .snd = makeIsGroupHom (
coHomPointedElimTยฒ'' 0 (ฮป _ โ isPropฮ ฮป _ โ isSetSetTrunc _ _)
ฮป P โ coHomPointedElimTยฒ'' 0 (ฮป _ โ isSetSetTrunc _ _)
ฮป Q โ ((ฮป i โ โฃ (ฮป a โ ฮฉKn+1โKn 1 (sym (rCancelโกrefl 0 i)
โโ cong (ฮป x โ (elimFunTยฒ' 1 P (a , x) +โ elimFunTยฒ' 1 Q (a , x)) -โ โฃ north โฃ) loop
โโ rCancelโกrefl 0 i)) โฃโ))
โโ (ฮป i โ โฃ (ฮป a โ ฮฉKn+1โKn 1 (rUnit (cong (ฮป x โ rUnitโ 2 (elimFunTยฒ' 1 P (a , x) +โ elimFunTยฒ' 1 Q (a , x)) i) loop) (~ i))) โฃโ)
โโ (ฮป i โ โฃ (ฮป a โ ฮฉKn+1โKn 1 (โโก+โ 0 (cong (ฮป x โ elimFunTยฒ' 1 P (a , x)) loop) (cong (ฮป x โ elimFunTยฒ' 1 Q (a , x)) loop) (~ i))) โฃโ)
โโ (ฮป i โ โฃ (ฮป a โ ฮฉKn+1โKn-hom 1 (cong (ฮป x โ elimFunTยฒ' 1 P (a , x)) loop) (cong (ฮป x โ elimFunTยฒ' 1 Q (a , x)) loop) i) โฃโ)
โโ (ฮป i โ โฃ ((ฮป a โ ฮฉKn+1โKn 1 (rUnit (cong (ฮป x โ rUnitโ 2 (elimFunTยฒ' 1 P (a , x)) (~ i)) loop) i)
+โ ฮฉKn+1โKn 1 (rUnit (cong (ฮป x โ rUnitโ 2 (elimFunTยฒ' 1 Q (a , x)) (~ i)) loop) i))) โฃโ)
โ (ฮป i โ โฃ ((ฮป a โ ฮฉKn+1โKn 1 (sym (rCancelโกrefl 0 (~ i))
โโ cong (ฮป x โ elimFunTยฒ' 1 P (a , x) +โ โฃ north โฃ) loop
โโ rCancelโกrefl 0 (~ i))
+โ ฮฉKn+1โKn 1 (sym (rCancelโกrefl 0 (~ i))
โโ cong (ฮป x โ elimFunTยฒ' 1 Q (a , x) +โ โฃ north โฃ) loop
โโ rCancelโกrefl 0 (~ i)))) โฃโ))
-- >>>>>>> master
private
toโ : coHom 2 (Sโ 1 ร Sโ 1) โ โค
toโ = fun (fst Hยฒ-Tยฒโ
โค)
fromโ : โค โ coHom 2 (Sโ 1 ร Sโ 1)
fromโ = inv (fst Hยฒ-Tยฒโ
โค)
toโ : coHom 1 (Sโ 1 ร Sโ 1) โ โค ร โค
toโ = fun (fst Hยน-Tยฒโ
โครโค)
fromโ : โค ร โค โ coHom 1 (Sโ 1 ร Sโ 1)
fromโ = inv (fst Hยน-Tยฒโ
โครโค)
toโ : coHom 0 (Sโ 1 ร Sโ 1) โ โค
toโ = fun (fst Hโฐ-Tยฒโ
โค)
fromโ : โค โ coHom 0 (Sโ 1 ร Sโ 1)
fromโ = inv (fst Hโฐ-Tยฒโ
โค)
{-
-- Compute fast:
test : toโ (fromโ (0 , 1) +โ fromโ (1 , 0)) โก (1 , 1)
test = refl
test2 : toโ (fromโ (5 , 1) +โ fromโ (-2 , 3)) โก (3 , 4)
test2 = refl
-- Compute pretty fast
test3 : toโ (fromโ 1) โก 1
test3 = refl
test4 : toโ (fromโ 2) โก 2
test4 = refl
test5 : toโ (fromโ 3) โก 3
test5 = refl
-- Compute, but slower
test6 : toโ (fromโ 0 +โ fromโ 0) โก 0
test6 = refl
test6 : toโ (fromโ 0 +โ fromโ 1) โก 1
test6 = refl
-- Does not compute
test7 : toโ (fromโ 1 +โ fromโ 0) โก 1
test7 = refl
-}
| {
"alphanum_fraction": 0.5286088406,
"avg_line_length": 45.8218181818,
"ext": "agda",
"hexsha": "918ea48af5f0ec1d75cb4bcf54131d79835efc7e",
"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": "f2d74ae8e2e176963029a35bd886364480948214",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "kl-i/cubical-0.3",
"max_forks_repo_path": "Cubical/ZCohomology/Groups/Torus.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214",
"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": "kl-i/cubical-0.3",
"max_issues_repo_path": "Cubical/ZCohomology/Groups/Torus.agda",
"max_line_length": 145,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "kl-i/cubical-0.3",
"max_stars_repo_path": "Cubical/ZCohomology/Groups/Torus.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5064,
"size": 12601
} |
{-# OPTIONS --without-K --safe #-}
-- In this module, we define the subtyping relation of D<: according to Lemma 2.
module Dsub where
open import Data.List as List
open import Data.List.All as All
open import Data.Nat as โ
open import Data.Maybe as Maybe
open import Data.Product as ฮฃ
open import Data.Sum
open import Data.Empty renaming (โฅ to False)
open import Data.Vec as Vec renaming (_โท_ to _โผ_ ; [] to nil) hiding (_++_)
open import Function
open import Data.Maybe.Properties as Maybeโ
open import Data.Nat.Properties as โโ
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import DsubDef
open import Utils
module Dsub where
infix 4 _โข_<:_
data _โข_<:_ : Env โ Typ โ Typ โ Set where
dtop : โ {ฮ T} โ
ฮ โข T <: โค
dbot : โ {ฮ T} โ
ฮ โข โฅ <: T
drefl : โ {ฮ T} โ
ฮ โข T <: T
dtrans : โ {ฮ S U} T โ
(S<:T : ฮ โข S <: T) โ
(T<:U : ฮ โข T <: U) โ
ฮ โข S <: U
dbnd : โ {ฮ S U Sโฒ Uโฒ} โ
(Sโฒ<:S : ฮ โข Sโฒ <: S) โ
(U<:Uโฒ : ฮ โข U <: Uโฒ) โ
ฮ โข โจA: S โฏ U โฉ <: โจA: Sโฒ โฏ Uโฒ โฉ
dall : โ {ฮ S U Sโฒ Uโฒ} โ
(Sโฒ<:S : ฮ โข Sโฒ <: S) โ
(U<:Uโฒ : (Sโฒ โท ฮ) โข U <: Uโฒ) โ
ฮ โข ฮ S โ U <: ฮ Sโฒ โ Uโฒ
dselโ : โ {ฮ n T S} โ
(Tโฮ : env-lookup ฮ n โก just T) โ
(D : ฮ โข T <: โจA: S โฏ โค โฉ) โ
ฮ โข S <: n โA
dselโ : โ {ฮ n T U} โ
(Tโฮ : env-lookup ฮ n โก just T) โ
(D : ฮ โข T <: โจA: โฅ โฏ U โฉ) โ
ฮ โข n โA <: U
D-measure : โ {ฮ S U} (D : ฮ โข S <: U) โ โ
D-measure dtop = 1
D-measure dbot = 1
D-measure drefl = 1
D-measure (dtrans _ S<:T T<:U) = 1 + D-measure S<:T + D-measure T<:U
D-measure (dbnd Dโ Dโ) = 1 + D-measure Dโ + D-measure Dโ
D-measure (dall Dp Db) = 1 + D-measure Dp + D-measure Db
D-measure (dselโ Tโฮ D) = 1 + D-measure D
D-measure (dselโ Tโฮ D) = 1 + D-measure D
D-measureโฅ1 : โ {ฮ S U} (D : ฮ โข S <: U) โ D-measure D โฅ 1
D-measureโฅ1 dtop = sโคs zโคn
D-measureโฅ1 dbot = sโคs zโคn
D-measureโฅ1 drefl = sโคs zโคn
D-measureโฅ1 (dtrans _ _ _) = sโคs zโคn
D-measureโฅ1 (dbnd _ _) = sโคs zโคn
D-measureโฅ1 (dall _ _) = sโคs zโคn
D-measureโฅ1 (dselโ _ _) = sโคs zโคn
D-measureโฅ1 (dselโ _ _) = sโคs zโคn
D-deriv : Set
D-deriv = ฮฃ (Env ร Typ ร Typ) ฮป { (ฮ , S , U) โ ฮ โข S <: U }
env : D-deriv โ Env
env ((ฮ , _) , _) = ฮ
typโ : D-deriv โ Typ
typโ ((_ , S , U) , _) = S
typโ : D-deriv โ Typ
typโ ((_ , S , U) , _) = U
drefl-dec : โ (D : D-deriv) โ Dec (D โก ((env D , typโ D , _) , drefl))
drefl-dec (_ , dtop) = no (ฮป ())
drefl-dec (_ , dbot) = no (ฮป ())
drefl-dec (_ , drefl) = yes refl
drefl-dec (_ , dtrans _ _ _) = no (ฮป ())
drefl-dec (_ , dbnd _ _) = no (ฮป ())
drefl-dec (_ , dall _ _) = no (ฮป ())
drefl-dec (_ , dselโ _ _) = no (ฮป ())
drefl-dec (_ , dselโ _ _) = no (ฮป ())
-- weakening
infixl 7 _โ
_โ : Env โ Env
[] โ = []
(T โท ฮ) โ = T โ length ฮ โท ฮ โ
โฆโ-weaken-โค : โ {n T ฮ} โ
n โฆ T โ ฮ โ
โ ฮโ ฮโ Tโฒ โ
ฮ โก ฮโ โฃ ฮโ โ
length ฮโ โค n โ
suc n โฆ T โ length ฮโ โ ฮโ โฃ Tโฒ ! โฃ ฮโ โ
โฆโ-weaken-โค hd .(_ โท _) [] Tโฒ refl zโคn = tl hd
โฆโ-weaken-โค hd ฮโ (_ โท ฮโ) Tโฒ eqฮ ()
โฆโ-weaken-โค (tl Tโฮ) .(_ โท _) [] Tโฒ refl zโคn = tl (tl Tโฮ)
โฆโ-weaken-โค (tl {_} {T} Tโฮ) ฮโ (_ โท ฮโ) Tโฒ refl (sโคs lโคn)
rewrite โ-โ-comm T 0 (length ฮโ) zโคn = tl (โฆโ-weaken-โค Tโฮ ฮโ ฮโ Tโฒ refl lโคn)
โฆโ-weaken-> : โ {n T ฮ} โ
n โฆ T โ ฮ โ
โ ฮโ ฮโ Tโฒ โ
ฮ โก ฮโ โฃ ฮโ โ
length ฮโ > n โ
n โฆ T โ length ฮโ โ ฮโ โฃ Tโฒ ! โฃ ฮโ โ
โฆโ-weaken-> Tโฮ ฮโ [] Tโฒ eqฮ ()
โฆโ-weaken-> (hd {T}) ฮโ (_ โท ฮโ) Tโฒ refl (sโคs l>n)
rewrite โ-โ-comm T 0 (length ฮโ) l>n = hd
โฆโ-weaken-> (tl {_} {T} Tโฮ) ฮโ (_ โท ฮโ) Tโฒ refl (sโคs l>n)
rewrite โ-โ-comm T 0 (length ฮโ) zโคn = tl (โฆโ-weaken-> Tโฮ ฮโ ฮโ Tโฒ refl l>n)
โฆโ-weaken : โ {n T ฮ} โ
n โฆ T โ ฮ โ
โ ฮโ ฮโ Tโฒ โ
ฮ โก ฮโ โฃ ฮโ โ
โ-idx n (length ฮโ) โฆ T โ length ฮโ โ ฮโ โฃ Tโฒ ! โฃ ฮโ โ
โฆโ-weaken {n} Tโฮ _ ฮโ _ eqฮ with length ฮโ โค? n
... | yes lโคn = โฆโ-weaken-โค Tโฮ _ ฮโ _ eqฮ lโคn
... | no l>n = โฆโ-weaken-> Tโฮ _ ฮโ _ eqฮ (โฐโ> l>n)
โฆโ-weakenโฒ : โ {n T ฮ} โ
env-lookup ฮ n โก just T โ
โ ฮโ ฮโ Tโฒ โ
ฮ โก ฮโ โฃ ฮโ โ
env-lookup (ฮโ โฃ Tโฒ ! โฃ ฮโ โ) (โ-idx n (length ฮโ)) โก just (T โ length ฮโ)
โฆโ-weakenโฒ Tโฮ ฮโ ฮโ Tโฒ eqฮ = โฆโโlookup (โฆโ-weaken (lookupโโฆโ Tโฮ) ฮโ ฮโ Tโฒ eqฮ)
<:-weakening-gen : โ {ฮ S U} โ
ฮ โข S <: U โ
โ ฮโ ฮโ T โ
ฮ โก ฮโ โฃ ฮโ โ
ฮโ โฃ T ! โฃ ฮโ โ โข S โ length ฮโ <: U โ length ฮโ
<:-weakening-gen dtop ฮโ ฮโ T eqฮ = dtop
<:-weakening-gen dbot ฮโ ฮโ T eqฮ = dbot
<:-weakening-gen drefl ฮโ ฮโ T eqฮ = drefl
<:-weakening-gen (dtrans Tโฒ S<:Tโฒ Tโฒ<:U) ฮโ ฮโ T eqฮ = dtrans _
(<:-weakening-gen S<:Tโฒ ฮโ ฮโ T eqฮ)
(<:-weakening-gen Tโฒ<:U ฮโ ฮโ T eqฮ)
<:-weakening-gen (dbnd Sโฒ<:S U<:Uโฒ) ฮโ ฮโ T eqฮ = dbnd (<:-weakening-gen Sโฒ<:S ฮโ ฮโ T eqฮ)
(<:-weakening-gen U<:Uโฒ ฮโ ฮโ T eqฮ)
<:-weakening-gen (dall Sโฒ<:S U<:Uโฒ) ฮโ ฮโ T eqฮ = dall (<:-weakening-gen Sโฒ<:S ฮโ ฮโ T eqฮ)
(<:-weakening-gen U<:Uโฒ ฮโ (_ โท ฮโ) T (cong (_ โท_) eqฮ))
<:-weakening-gen (dselโ {_} {n} Tโฮ T<:B) ฮโ ฮโ T eqฮ
rewrite โ-var n (length ฮโ) = dselโ (โฆโ-weakenโฒ Tโฮ ฮโ ฮโ T eqฮ)
(<:-weakening-gen T<:B ฮโ ฮโ T eqฮ)
<:-weakening-gen (dselโ {_} {n} Tโฮ T<:B) ฮโ ฮโ T eqฮ
rewrite โ-var n (length ฮโ) = dselโ (โฆโ-weakenโฒ Tโฮ ฮโ ฮโ T eqฮ)
(<:-weakening-gen T<:B ฮโ ฮโ T eqฮ)
<:-weakening : โ {ฮโ ฮโ S U} T โ
ฮโ โฃ ฮโ โข S <: U โ
ฮโ โฃ T ! โฃ ฮโ โ โข S โ length ฮโ <: U โ length ฮโ
<:-weakening T S<:U = <:-weakening-gen S<:U _ _ T refl
<:-weakening-hd : โ {ฮ S U} T โ
ฮ โข S <: U โ
ฮ โฃ T ! โข S โ 0 <: U โ 0
<:-weakening-hd T = <:-weakening {ฮโ = []} T
-- narrowing
infix 4 _โบ:[_]_
data _โบ:[_]_ : Env โ โ โ Env โ Set where
โบ[_,_] : โ {ฮ U} S โ ฮ โข S <: U โ ฮ โฃ S ! โบ:[ 0 ] ฮ โฃ U !
_โท_ : โ {ฮโ n ฮโ} T โ ฮโ โบ:[ n ] ฮโ โ ฮโ โฃ T ! โบ:[ suc n ] ฮโ โฃ T !
<:โ-find : โ {x T ฮ ฮโฒ n} โ
x โฆ T โ ฮ โ
ฮโฒ โบ:[ n ] ฮ โ
x โก n ร (โ ฮป Tโฒ โ n โฆ Tโฒ โ ฮโฒ ร ฮโฒ โข Tโฒ <: T) โ x โข n ร x โฆ T โ ฮโฒ
<:โ-find hd โบ[ Tโฒ , Tโฒ<:T ] = injโ (refl , Tโฒ โ 0 , hd , <:-weakening-hd Tโฒ Tโฒ<:T)
<:โ-find hd (T โท ฮโฒโบ:ฮ) = injโ ((ฮป ()) , hd)
<:โ-find (tl Tโฮ) โบ[ Tโฒ , Tโฒ<:T ] = injโ ((ฮป ()) , tl Tโฮ)
<:โ-find (tl Tโฮ) (S โท ฮโฒโบ:ฮ) with <:โ-find Tโฮ ฮโฒโบ:ฮ
... | injโ (xโกn , Tโฒ , Tโฒโฮโฒ , Tโฒ<:T) = injโ (cong suc xโกn , Tโฒ โ 0 , tl Tโฒโฮโฒ , <:-weakening-hd S Tโฒ<:T)
... | injโ (xโขn , Tโฮโฒ) = injโ (xโขn โ suc-injective , tl Tโฮโฒ)
<:โ-findโฒ : โ {x T ฮ ฮโฒ n} โ
env-lookup ฮ x โก just T โ
ฮโฒ โบ:[ n ] ฮ โ
x โก n ร (โ ฮป Tโฒ โ env-lookup ฮโฒ n โก just Tโฒ ร ฮโฒ โข Tโฒ <: T) โ x โข n ร env-lookup ฮโฒ x โก just T
<:โ-findโฒ Tโฮ ฮโฒโบฮ with <:โ-find (lookupโโฆโ Tโฮ) ฮโฒโบฮ
... | injโ (xโกn , Tโฒ , Tโฒโฮโฒ , Tโฒ<:T) = injโ (xโกn , Tโฒ , โฆโโlookup Tโฒโฮโฒ , Tโฒ<:T)
... | injโ (xโขn , Tโฮโฒ) = injโ (xโขn , โฆโโlookup Tโฮโฒ)
<:-narrow : โ {ฮ ฮโฒ n S U T} โ
ฮ โข S <: U โ
ฮโฒ โบ:[ n ] ฮ โ
env-lookup ฮ n โก just T โ
ฮโฒ โข S <: U
<:-narrow dtop ฮโฒโบฮ Tโฮ = dtop
<:-narrow dbot ฮโฒโบฮ Tโฮ = dbot
<:-narrow drefl ฮโฒโบฮ Tโฮ = drefl
<:-narrow (dtrans T S<:T T<:U) ฮโฒโบฮ Tโฮ = dtrans T (<:-narrow S<:T ฮโฒโบฮ Tโฮ) (<:-narrow T<:U ฮโฒโบฮ Tโฮ)
<:-narrow (dbnd Sโฒ<:S U<:Uโฒ) ฮโฒโบฮ Tโฮ = dbnd (<:-narrow Sโฒ<:S ฮโฒโบฮ Tโฮ) (<:-narrow U<:Uโฒ ฮโฒโบฮ Tโฮ)
<:-narrow {ฮ} {ฮโฒ} {n} (dall {Sโฒ = Sโฒ} Sโฒ<:S U<:Uโฒ) ฮโฒโบฮ Tโฮ
= dall (<:-narrow Sโฒ<:S ฮโฒโบฮ Tโฮ)
(<:-narrow U<:Uโฒ (_ โท ฮโฒโบฮ) (โฆโโlookup (tl {n} {Tโฒ = Sโฒ} {ฮ} (lookupโโฆโ Tโฮ))))
<:-narrow (dselโ Tโฒโฮ Tโฒ<:B) ฮโฒโบฮ Tโฮ
with <:โ-findโฒ Tโฒโฮ ฮโฒโบฮ
... | injโ (refl , Tโณ , Tโณโฮโฒ , Tโณ<:T)
rewrite just-injective (trans (sym Tโฒโฮ) Tโฮ) = dselโ Tโณโฮโฒ (dtrans _ Tโณ<:T (<:-narrow Tโฒ<:B ฮโฒโบฮ Tโฮ))
... | injโ (xโขn , Tโฒโฮโฒ) = dselโ Tโฒโฮโฒ (<:-narrow Tโฒ<:B ฮโฒโบฮ Tโฮ)
<:-narrow (dselโ Tโฒโฮ Tโฒ<:B) ฮโฒโบฮ Tโฮ
with <:โ-findโฒ Tโฒโฮ ฮโฒโบฮ
... | injโ (refl , Tโณ , Tโณโฮโฒ , Tโณ<:T)
rewrite just-injective (trans (sym Tโฒโฮ) Tโฮ) = dselโ Tโณโฮโฒ (dtrans _ Tโณ<:T (<:-narrow Tโฒ<:B ฮโฒโบฮ Tโฮ))
... | injโ (xโขn , Tโฒโฮโฒ) = dselโ Tโฒโฮโฒ (<:-narrow Tโฒ<:B ฮโฒโบฮ Tโฮ)
open Dsub hiding (<:-weakening-gen; <:-weakening; <:-weakening-hd
; _โบ:[_]_; โบ[_,_]; _โท_; <:โ-find; <:โ-findโฒ; <:-narrow) public
-- materialization of inversion properties in invertible contexts
module DsubInvProperties {P : Env โ Set}
(invertible : InvertibleEnv P) where
module ContraEnvProperties = InvertibleProperties invertible _โข_<:_
open ContraEnvProperties public
mutual
<:โ<:แตข : โ {ฮ S U} โ ฮ โข S <: U โ P ฮ โ ฮ โขแตข S <: U
<:โ<:แตข dtop pฮ = ditop
<:โ<:แตข dbot pฮ = dibot
<:โ<:แตข drefl pฮ = direfl
<:โ<:แตข (dtrans T S<:T T<:U) pฮ = ditrans T (<:โ<:แตข S<:T pฮ) (<:โ<:แตข T<:U pฮ)
<:โ<:แตข (dbnd Sโฒ<:S U<:Uโฒ) pฮ = dibnd (<:โ<:แตข Sโฒ<:S pฮ) (<:โ<:แตข U<:Uโฒ pฮ)
<:โ<:แตข (dall Sโฒ<:S U<:Uโฒ) pฮ = diall (<:โ<:แตข Sโฒ<:S pฮ) U<:Uโฒ
<:โ<:แตข (dselโ Tโฮ T<:B) pฮ with sel-case Tโฮ T<:B pฮ
... | refl , _ = dibot
<:โ<:แตข (dselโ Tโฮ T<:B) pฮ with sel-case Tโฮ T<:B pฮ
... | refl , Uโฒ , refl
with โจA:โฉ<:โจA:โฉ (<:โ<:แตข T<:B pฮ) pฮ
... | _ , Uโฒ<:U = ditrans Uโฒ (disel Tโฮ) Uโฒ<:U
sel-case : โ {T ฮ n S U} โ
env-lookup ฮ n โก just T โ
ฮ โข T <: โจA: S โฏ U โฉ โ
P ฮ โ
S โก โฅ ร โ ฮป Uโฒ โ T โก โจA: โฅ โฏ Uโฒ โฉ
sel-case {โค} Tโฮ T<:B pฮ = case โค<: (<:โ<:แตข T<:B pฮ) of ฮป ()
sel-case {โฅ} Tโฮ T<:B pฮ = โฅ-elim (no-โฅ pฮ Tโฮ)
sel-case {n โA} Tโฮ T<:B pฮ
with <:โจA:โฉ (<:โ<:แตข T<:B pฮ) pฮ
... | injโ ()
... | injโ (_ , _ , ())
sel-case {ฮ S โ U} Tโฮ T<:B pฮ
with <:โจA:โฉ (<:โ<:แตข T<:B pฮ) pฮ
... | injโ ()
... | injโ (_ , _ , ())
sel-case {โจA: S โฏ U โฉ} Tโฮ T<:B pฮ
rewrite โฅ-lb pฮ Tโฮ with โจA:โฉ<:โจA:โฉ (<:โ<:แตข T<:B pฮ) pฮ
... | S<:โฅ , _ with <:โฅ S<:โฅ pฮ
... | refl = refl , U , refl
<:แตขโ<: : โ {ฮ S U} โ ฮ โขแตข S <: U โ ฮ โข S <: U
<:แตขโ<: ditop = dtop
<:แตขโ<: dibot = dbot
<:แตขโ<: direfl = drefl
<:แตขโ<: (ditrans T S<:T T<:U) = dtrans T (<:แตขโ<: S<:T) (<:แตขโ<: T<:U)
<:แตขโ<: (dibnd Sโฒ<:S U<:Uโฒ) = dbnd (<:แตขโ<: Sโฒ<:S) (<:แตขโ<: U<:Uโฒ)
<:แตขโ<: (diall Sโฒ<:S U<:Uโฒ) = dall (<:แตขโ<: Sโฒ<:S) U<:Uโฒ
<:แตขโ<: (disel Tโฮ) = dselโ Tโฮ drefl
โค<:โฒ : โ {ฮ T} โ ฮ โข โค <: T โ P ฮ โ T โก โค
โค<:โฒ โค<:T = โค<: โ <:โ<:แตข โค<:T
<:โฅโฒ : โ {ฮ T} โ ฮ โข T <: โฅ โ P ฮ โ T โก โฅ
<:โฅโฒ T<:โฅ pฮ = <:โฅ (<:โ<:แตข T<:โฅ pฮ) pฮ
โจA:โฉ<:โจA:โฉโฒ : โ {ฮ Sโฒ U Uโฒ} โ ฮ โข โจA: โฅ โฏ U โฉ <: โจA: Sโฒ โฏ Uโฒ โฉ โ P ฮ โ
Sโฒ โก โฅ
โจA:โฉ<:โจA:โฉโฒ B<:Bโฒ pฮ with โจA:โฉ<:โจA:โฉ (<:โ<:แตข B<:Bโฒ pฮ) pฮ
... | S<:โฅ , _ = <:โฅ S<:โฅ pฮ
ฮ <:โจA:โฉโโฅ : โ {ฮ S U Sโฒ Uโฒ} โ ฮ โขแตข ฮ S โ U <: โจA: Sโฒ โฏ Uโฒ โฉ โ P ฮ โ False
ฮ <:โจA:โฉโโฅ ฮ <:โจA:โฉ eฮ with <:โจA:โฉ ฮ <:โจA:โฉ eฮ
... | injโ ()
... | injโ (_ , _ , ())
โA<:โจA:โฉโโฅ : โ {ฮ x S U} โ ฮ โขแตข x โA <: โจA: S โฏ U โฉ โ P ฮ โ False
โA<:โจA:โฉโโฅ xโA<:โจA:โฉ eฮ with <:โจA:โฉ xโA<:โจA:โฉ eฮ
... | injโ ()
... | injโ (_ , _ , ())
ฮ <:ฮ : โ {ฮ S U Sโฒ Uโฒ} โ
ฮ โข ฮ S โ U <: ฮ Sโฒ โ Uโฒ โ
P ฮ โ
ฮ โข Sโฒ <: S ร (Sโฒ โท ฮ) โข U <: Uโฒ
ฮ <:ฮ <: pฮ = ฮฃ.mapโ <:แตขโ<: $ helper (<:โ<:แตข <: pฮ) pฮ
where helper : โ {ฮ S U Sโฒ Uโฒ} โ
ฮ โขแตข ฮ S โ U <: ฮ Sโฒ โ Uโฒ โ
P ฮ โ
ฮ โขแตข Sโฒ <: S ร (Sโฒ โท ฮ) โข U <: Uโฒ
helper direfl pฮ = direfl , drefl
helper (ditrans T <: <:โฒ) pฮ with ฮ <: <:
... | injโ refl = case โค<: <:โฒ of ฮป ()
... | injโ (_ , _ , refl)
with helper <: pฮ | helper <:โฒ pฮ
... | Sโณ<:Sโฒ , Uโฒ<:Uโณ | Sโด<:Sโณ , Uโณ<:Uโด = ditrans _ Sโด<:Sโณ Sโณ<:Sโฒ
, dtrans _ (Dsub.<:-narrow Uโฒ<:Uโณ Dsub.โบ[ _ , <:แตขโ<: Sโด<:Sโณ ] refl) Uโณ<:Uโด
helper (diall <: U<:Uโฒ) pฮ = <: , U<:Uโฒ
| {
"alphanum_fraction": 0.3749241505,
"avg_line_length": 41.5899053628,
"ext": "agda",
"hexsha": "b3bdb7f9ae3f9ad25a5b08f94fd88447ebf9a414",
"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": "48214a55ebb484fd06307df4320813d4a002535b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "HuStmpHrrr/popl20-artifact",
"max_forks_repo_path": "agda/Dsub.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b",
"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": "HuStmpHrrr/popl20-artifact",
"max_issues_repo_path": "agda/Dsub.agda",
"max_line_length": 127,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "HuStmpHrrr/popl20-artifact",
"max_stars_repo_path": "agda/Dsub.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-23T08:40:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-09-23T08:40:28.000Z",
"num_tokens": 6700,
"size": 13184
} |
{-
This second-order equational theory was created from the following second-order syntax description:
syntax Sum | S
type
_โ_ : 2-ary | l30
term
inl : ฮฑ -> ฮฑ โ ฮฒ
inr : ฮฒ -> ฮฑ โ ฮฒ
case : ฮฑ โ ฮฒ ฮฑ.ฮณ ฮฒ.ฮณ -> ฮณ
theory
(lฮฒ) a : ฮฑ f : ฮฑ.ฮณ g : ฮฒ.ฮณ |> case (inl(a), x.f[x], y.g[y]) = f[a]
(rฮฒ) b : ฮฒ f : ฮฑ.ฮณ g : ฮฒ.ฮณ |> case (inr(b), x.f[x], y.g[y]) = g[b]
(cฮท) s : ฮฑ โ ฮฒ c : (ฮฑ โ ฮฒ).ฮณ |> case (s, x.c[inl(x)], y.c[inr(y)]) = c[s]
-}
module Sum.Equality where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Families.Build
open import SOAS.ContextMaps.Inductive
open import Sum.Signature
open import Sum.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution S:Syn
open import SOAS.Metatheory.SecondOrder.Equality S:Syn
private
variable
ฮฑ ฮฒ ฮณ ฯ : ST
ฮ ฮ ฮ : Ctx
infix 1 _โน_โข_โโ_
-- Axioms of equality
data _โน_โข_โโ_ : โ ๐ ฮ {ฮฑ} โ (๐ โท S) ฮฑ ฮ โ (๐ โท S) ฮฑ ฮ โ Set where
lฮฒ : โ
ฮฑ โ โ
ฮฑ โฉ ฮณ โ โ
ฮฒ โฉ ฮณ โฬฃ โน โ
โข case (inl ๐) (๐โจ xโ โฉ) (๐ โจ xโ โฉ) โโ ๐โจ ๐ โฉ
rฮฒ : โ
ฮฒ โ โ
ฮฑ โฉ ฮณ โ โ
ฮฒ โฉ ฮณ โฬฃ โน โ
โข case (inr ๐) (๐โจ xโ โฉ) (๐ โจ xโ โฉ) โโ ๐ โจ ๐ โฉ
cฮท : โ
ฮฑ โ ฮฒ โ โ
(ฮฑ โ ฮฒ) โฉ ฮณ โฬฃ โน โ
โข case ๐ (๐โจ inl xโ โฉ) (๐โจ inr xโ โฉ) โโ ๐โจ ๐ โฉ
open EqLogic _โน_โข_โโ_
open โ-Reasoning
| {
"alphanum_fraction": 0.5562403698,
"avg_line_length": 25.96,
"ext": "agda",
"hexsha": "860df4c5d98e9c0893989137438cdfa86c432c67",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/Sum/Equality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/Sum/Equality.agda",
"max_line_length": 99,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/Sum/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 665,
"size": 1298
} |
open import Relation.Binary.Core
module BBHeap.Subtyping {A : Set}
(_โค_ : A โ A โ Set)
(transโค : Transitive _โค_) where
open import BBHeap _โค_
open import Bound.Lower A
open import Bound.Lower.Order _โค_
open import Bound.Lower.Order.Properties _โค_ transโค
subtyping : {b b' : Bound} โ LeB b' b โ BBHeap b โ BBHeap b'
subtyping _ leaf = leaf
subtyping b'โคb (left bโคx lโr) = left (transLeB b'โคb bโคx) lโr
subtyping b'โคb (right bโคx lโr) = right (transLeB b'โคb bโคx) lโr
| {
"alphanum_fraction": 0.6316831683,
"avg_line_length": 31.5625,
"ext": "agda",
"hexsha": "ed2a0959a153a61fbbc223f166af6963c92f0905",
"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/BBHeap/Subtyping.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/BBHeap/Subtyping.agda",
"max_line_length": 62,
"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/BBHeap/Subtyping.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": 197,
"size": 505
} |
-- Andreas, 2016-12-22, issue #2354
-- Interaction between size solver, constraint solver, and instance search.
-- The instance search fails initially because of a non rigid meta.
-- Before freezing, there is another attempt.
-- The instance search succeeds and instantiates the meta for M.
-- Then, a size constraint is solved which had blocked a term.
-- Finally the blocking constraint can be resolved.
-- Thus, we need to
-- * wake constraints
-- * solve size constraints
-- * wake constraints again.
-- In principle, there could be many alternations needed!?
-- {-# OPTIONS -v tc.meta:30 -v tc.instance:30 -v tc.constr:50 -v tc.size:30 -v tc.decl:10 #-}
-- {-# OPTIONS -v tc.instance:30 -v tc.decl:20 #-}
-- {-# OPTIONS -v tc.instance.rigid:100 -v tc.instance:70 -v tc.size:30 #-}
-- {-# OPTIONS -v tc.term.con:50 #-}
{-# BUILTIN SIZEUNIV SizeU #-}
{-# BUILTIN SIZE Size #-}
{-# BUILTIN SIZELT Size<_ #-}
{-# BUILTIN SIZESUC โ_ #-}
{-# BUILTIN SIZEINF ฯ #-}
record โค : Set where
constructor tt
record RawMonad (M : Set โ Set) : Setโ where
field return : โ{A} โ A โ M A
mutual
data Delay (i : Size) (A : Set) : Set where
now : A โ Delay i A
later : Delayโ i A โ Delay i A
record Delayโ (i : Size) (A : Set) : Set where
coinductive
field force : โ {j : Size< i} โ Delay j A
instance
RawMonad-Delay : โ {i} โ RawMonad (Delay i)
RawMonad-Delay = record
{ return = Delay.now
}
open RawMonad {{...}}
test : โ {i} โ Delay i โค
test {i} = return tt -- Solution: return {{RawMonad-Delay {i}}} tt
-- Should find solution!
| {
"alphanum_fraction": 0.6376262626,
"avg_line_length": 29.3333333333,
"ext": "agda",
"hexsha": "905a6ff16bbf743c8b9a2356efc366f913d98474",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/Succeed/Issue2354.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pthariensflame/agda",
"max_issues_repo_path": "test/Succeed/Issue2354.agda",
"max_line_length": 94,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/Succeed/Issue2354.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": 469,
"size": 1584
} |
{-# OPTIONS --allow-unsolved-metas #-}
module TermByFunctionNames where
open import OscarPrelude
open import VariableName
open import FunctionName
data TermByFunctionNames : Nat โ Set
where
variable : VariableName โ TermByFunctionNames zero
function : FunctionName โ {arity : Nat} โ (ฯs : Vec (ฮฃ Nat TermByFunctionNames) arity) โ {n : Nat} โ n โก sum (vecToList $ (fst <$> ฯs)) โ TermByFunctionNames (suc n)
mutual
eqTermByFunctionNames : โ {n} โ (x y : TermByFunctionNames n) โ Dec (x โก y)
eqTermByFunctionNames = {!!}
{-
eqTermByFunctionNames : โ {n} โ (x y : TermByFunctionNames n) โ Dec (x โก y)
eqTermByFunctionNames {.0} (variable x) (variable xโ) = {!!}
eqTermByFunctionNames {.(suc n)} (function x {arity = arityโ} ฯs {n = n} xโ) (function xโ {arity = arityโ} ฯsโ {n = .n} xโ) with x โ xโ | arityโ โ arityโ
eqTermByFunctionNames {.(suc n)} (function x {arityโ} ฯs {n} xโ) (function .x {.arityโ} ฯsโ {.n} xโ
) | yes refl | (yes refl) with eqTermByFunctionNamess ฯs ฯsโ
eqTermByFunctionNames {.(suc n)} (function xโ {arityโ} ฯs {n} xโ) (function .xโ {.arityโ} .ฯs {.n} xโ
) | yes refl | (yes refl) | (yes refl) rewrite xโ | xโ
= yes refl
eqTermByFunctionNames {.(suc n)} (function xโ {arityโ} ฯs {n} xโ) (function .xโ {.arityโ} ฯsโ {.n} xโ
) | yes refl | (yes refl) | (no x) = {!!}
eqTermByFunctionNames {.(suc n)} (function x {arityโ} ฯs {n} xโ) (function xโ {arityโ} ฯsโ {.n} xโ
) | yes xโ | (no xโ) = {!!}
eqTermByFunctionNames {.(suc n)} (function x {arityโ} ฯs {n} xโ) (function xโ {arityโ} ฯsโ {.n} xโ
) | no xโ | (yes xโ) = {!!}
eqTermByFunctionNames {.(suc n)} (function x {arityโ} ฯs {n} xโ) (function xโ {arityโ} ฯsโ {.n} xโ
) | no xโ | (no xโ) = {!!}
-}
eqTermByFunctionNamess : โ {n} โ (x y : Vec (ฮฃ Nat TermByFunctionNames) n) โ Dec (x โก y)
eqTermByFunctionNamess {.0} [] [] = {!!}
eqTermByFunctionNamess (_โท_ {n = n} (fstโ , sndโ) xโ) (_โท_ {n = .n} (fstโ , sndโ) y) with fstโ โ fstโ
eqTermByFunctionNamess (_โท_ {n = n} (fstโ , sndโ) xโ) (_โท_ {n = .n} (fstโ , sndโ) y) | yes refl with eqTermByFunctionNames sndโ sndโ
eqTermByFunctionNamess (_โท_ {n = n} (fstโ , sndโ) xโ) (_โท_ {n = .n} (fstโ , sndโ) y) | yes refl | yes refl with eqTermByFunctionNamess xโ y
eqTermByFunctionNamess (_โท_ {n = n} (fstโ , sndโ) xโ) (_โท_ {n = .n} (fstโ , sndโ) y) | yes refl | yes refl | yes refl = yes refl
eqTermByFunctionNamess (_โท_ {n = n} (fstโ , sndโ) xโ) (_โท_ {n = .n} (fstโ , sndโ) y) | yes refl | yes refl | no ref = {!!}
eqTermByFunctionNamess (_โท_ {n = n} (fstโ , sndโ) xโ) (_โท_ {n = .n} (fstโ , sndโ) y) | yes refl | no ref = {!!}
eqTermByFunctionNamess (_โท_ {n = n} (fstโ , sndโ) xโ) (_โท_ {n = .n} (fstโ , sndโ) y) | no ref = {!!}
instance EqTermByFunctionNames : โ {n} โ Eq (TermByFunctionNames n)
Eq._==_ EqTermByFunctionNames = eqTermByFunctionNames
{-
instance EqTermByFunctionNames : โ {n} โ Eq (TermByFunctionNames n)
Eq._==_ EqTermByFunctionNames (variable x) (variable xโ) = {!!}
Eq._==_ EqTermByFunctionNames (function x {arity = arityโ} ฯs {n = n} xโ) (function xโ {arity = arityโ} ฯsโ {n = .n} xโ) with x โ xโ | arityโ โ arityโ
Eq._==_ EqTermByFunctionNames (function x {arityโ} ฯs {n} xโ) (function .x {.arityโ} ฯsโ {.n} xโ
) | yes refl | (yes refl) with ฯs โ ฯsโ
Eq._==_ EqTermByFunctionNames (function x {arityโ} ฯs {n} xโ) (function .x {.arityโ} ฯsโ {.n} xโ
) | yes refl | (yes refl) | ฯsโกฯsโ = {!!}
Eq._==_ EqTermByFunctionNames (function x {arityโ} ฯs {n} xโ) (function xโ {arityโ} ฯsโ {.n} xโ
) | yes xโ | (no xโ) = {!!}
Eq._==_ EqTermByFunctionNames (function x {arityโ} ฯs {n} xโ) (function xโ {arityโ} ฯsโ {.n} xโ
) | no xโ | (yes xโ) = {!!}
Eq._==_ EqTermByFunctionNames (function x {arityโ} ฯs {n} xโ) (function xโ {arityโ} ฯsโ {.n} xโ
) | no xโ | (no xโ) = {!!}
-}
| {
"alphanum_fraction": 0.6349036403,
"avg_line_length": 74.72,
"ext": "agda",
"hexsha": "d8c29ccd65a2442424f77b353b9d47a3536ba783",
"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/TermByFunctionNames.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/TermByFunctionNames.agda",
"max_line_length": 168,
"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/TermByFunctionNames.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1550,
"size": 3736
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.RingStructure.CohomologyRing where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Transport
open import Cubical.Data.Nat renaming (_+_ to _+n_ ; _ยท_ to _ยทn_)
open import Cubical.Data.Sum
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Ring
open import Cubical.Algebra.DirectSum.Base
open import Cubical.Algebra.AbGroup.Instances.DirectSum
open import Cubical.HITs.SetTruncation as ST
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.RingStructure.CupProduct
open import Cubical.ZCohomology.RingStructure.RingLaws
open import Cubical.ZCohomology.RingStructure.GradedCommutativity
private variable
โ โ' : Level
open Iso
-----------------------------------------------------------------------------
-- Definition Cohomology Ring
module intermediate-def where
H*AbGr : (A : Type โ) โ AbGroup โ
H*AbGr A = โ-AbGr โ (ฮป n โ coHom n A) (ฮป n โ snd (coHomGroup n A))
H* : (A : Type โ) โ Type โ
H* A = fst (H*AbGr A)
module CupRingProperties (A : Type โ) where
open intermediate-def
open AbGroupStr (snd (H*AbGr A))
open AbGroupTheory (H*AbGr A)
_cup_ : H* A โ H* A โ H* A
_cup_ = DS-Rec-Set.f โ (ฮป n โ coHom n A) (ฮป n โ snd (coHomGroup n A))
(H* A โ H* A)
(ฮป f g p q i j x โ is-set (f x) (g x) (ฮป X โ p X x) (ฮป X โ q X x) i j)
-- elements
(ฮป x โ 0g)
(ฮป n a โ DS-Rec-Set.f โ _ _ (H* A) is-set
-- elements
0g
(ฮป m b โ base (n +' m) (a โฃ b))
_+_
-- equations
assoc
rid
comm
(ฮป m โ (cong (base (n +' m)) (โฃ-0โ n m a)) โ (base-neutral (n +' m)))
ฮป m b c โ base-add (n +' m) (a โฃ b) (a โฃ c) โ cong (base (n +' m)) (sym (leftDistr-โฃ n m a b c)))
(ฮป U V y โ (U y) + (V y))
-- equations
(ฮป xs ys zs i y โ assoc (xs y) (ys y) (zs y) i)
(ฮป xs i y โ rid (xs y) i)
(ฮป xs ys i y โ comm (xs y) (ys y) i)
(ฮป n โ funExt(
DS-Ind-Prop.f โ _ _ _ (ฮป _ โ is-set _ _)
refl
(ฮป m b โ cong (base (n +' m)) (0โ-โฃ n m b) โ base-neutral (n +' m))
ฮป {U V} ind-U ind-V โ (congโ _+_ ind-U ind-V) โ (rid 0g)))
ฮป n a b โ funExt (
DS-Ind-Prop.f โ _ _ _ (ฮป _ โ is-set _ _)
(rid 0g)
(ฮป m c โ (base-add (n +' m) (a โฃ c) (b โฃ c)) โ (cong (base (n +' m)) (sym (rightDistr-โฃ n m a b c))))
ฮป {U V} ind-U ind-V โ comm-4 _ _ _ _ โ congโ _+_ ind-U ind-V)
1H* : H* A
1H* = base 0 1โฃ
cupAssoc : (x y z : H* A) โ x cup (y cup z) โก (x cup y) cup z
cupAssoc = DS-Ind-Prop.f โ _ _ _
(ฮป x p q i y z j โ is-set _ _ (p y z) (q y z) i j)
(ฮป y z โ refl)
(ฮป n a โ DS-Ind-Prop.f โ _ _ _
(ฮป y p q i z j โ is-set _ _ (p z) (q z) i j)
(ฮป z โ refl)
(ฮป m b โ DS-Ind-Prop.f โ _ _ _ (ฮป _ โ is-set _ _)
refl
(ฮป k c โ (cong (base (n +' (m +' k))) (assoc-โฃ n m k a b c))
โ sym (constSubstCommSlice (ฮป n โ coHom n A) (H* A) base (sym (+'-assoc n m k)) ((a โฃ b) โฃ c)))
ฮป {U V} ind-U ind-V โ congโ _+_ ind-U ind-V)
ฮป {U V} ind-U ind-V z โ congโ _+_ (ind-U z) (ind-V z))
ฮป {U V} ind-U ind-V y z โ congโ _+_ (ind-U y z) (ind-V y z)
cupIdR : (x : H* A) โ x cup 1H* โก x
cupIdR = DS-Ind-Prop.f โ _ _ _ (ฮป _ โ is-set _ _)
refl
(ฮป n a โ (cong (base (n +' 0)) (lUnitโฃ n a)) โ sym (constSubstCommSlice (ฮป n โ coHom n A) (H* A) base (sym (n+'0 n)) a))
ฮป {U V} ind-U ind-V โ (congโ _+_ ind-U ind-V)
cupIdL : (x : H* A) โ 1H* cup x โก x
cupIdL = DS-Ind-Prop.f โ _ _ _ (ฮป _ โ is-set _ _)
refl
(ฮป n a โ cong (base n) (rUnitโฃ n a))
(ฮป {U V} ind-U ind-V โ congโ _+_ ind-U ind-V)
cupDistR : (x y z : H* A) โ x cup (y + z) โก (x cup y) + (x cup z)
cupDistR = DS-Ind-Prop.f โ _ _ _
(ฮป x p q i y z j โ is-set _ _ (p y z) (q y z) i j)
(ฮป y z โ sym (rid 0g))
(ฮป n a y z โ refl)
ฮป {U V} ind-U ind-V y z โ congโ _+_ (ind-U y z) (ind-V y z) โ comm-4 (U cup y) (U cup z) (V cup y) (V cup z)
cupDistL : (x y z : H* A) โ (x + y) cup z โก (x cup z) + (y cup z)
cupDistL = ฮป x y z โ refl
-----------------------------------------------------------------------------
-- Graded Comutative Ring
-- def + commutation with base
-^-gen : (n m : โ) โ (p : isEvenT n โ isOddT n) โ (q : isEvenT m โ isOddT m)
โ H* A โ H* A
-^-gen n m (inl p) q x = x
-^-gen n m (inr p) (inl q) x = x
-^-gen n m (inr p) (inr q) x = - x
-^_ยท_ : (n m : โ) โ H* A โ H* A
-^_ยท_ n m x = -^-gen n m (evenOrOdd n) (evenOrOdd m) x
-^-gen-base : {k : โ} โ (n m : โ) โ (p : isEvenT n โ isOddT n) โ (q : isEvenT m โ isOddT m)
(a : coHom k A) โ -^-gen n m p q (base k a) โก base k (-โ^-gen n m p q a)
-^-gen-base n m (inl p) q a = refl
-^-gen-base n m (inr p) (inl q) a = refl
-^-gen-base n m (inr p) (inr q) a = refl
-^-base : {k : โ} โ (n m : โ) โ (a : coHom k A) โ (-^ n ยท m) (base k a) โก base k ((-โ^ n ยท m) a)
-^-base n m a = -^-gen-base n m (evenOrOdd n) (evenOrOdd m) a
module _ (A : Type โ) where
open intermediate-def renaming (H* to H*')
open CupRingProperties A
open AbGroupStr (snd (H*AbGr A))
open AbGroupTheory (H*AbGr A)
H*R : Ring โ
fst H*R = H*' A
RingStr.0r (snd H*R) = 0g
RingStr.1r (snd H*R) = 1H*
RingStr._+_ (snd H*R) = _+_
RingStr._ยท_ (snd H*R) = _cup_
RingStr.- snd H*R = -_
RingStr.isRing (snd H*R) = makeIsRing is-set
assoc rid (ฮป x โ fst (inverse x)) comm
cupAssoc cupIdR cupIdL cupDistR cupDistL
H* : Type โ
H* = fst H*R
gradCommRing : (n m : โ) โ (a : coHom n A) โ (b : coHom m A) โ
(base n a) cup (base m b) โก (-^ n ยท m) ((base m b) cup (base n a))
gradCommRing n m a b = base (n +' m) (a โฃ b)
โกโจ cong (base (n +' m)) (gradedComm-โฃ n m a b) โฉ
base (n +' m) ((-โ^ n ยท m) (subst (ฮป nโ โ coHom nโ A) (+'-comm m n) (b โฃ a)))
โกโจ sym (-^-base n m (subst (ฮป k โ coHom k A) (+'-comm m n) (b โฃ a))) โฉ
(-^ n ยท m) (base (n +' m) (subst (ฮป k โ coHom k A) (+'-comm m n) (b โฃ a)))
โกโจ cong (-^ n ยท m) (sym (constSubstCommSlice (ฮป k โ coHom k A) H* base (+'-comm m n) (b โฃ a))) โฉ
(-^ n ยท m) (base (m +' n) (b โฃ a)) โ
-----------------------------------------------------------------------------
-- Equivalence of Type implies equivalence of Cohomology Ring
module CohomologyRing-Equiv
{X : Type โ}
{Y : Type โ'}
(e : Iso X Y)
where
open IsGroupHom
open RingStr (snd (H*R X)) using ()
renaming
( 0r to 0H*X
; 1r to 1H*X
; _+_ to _+H*X_
; -_ to -H*X_
; _ยท_ to _cupX_
; +Assoc to +H*XAssoc
; +Identity to +H*XIdentity
; +Lid to +H*XLid
; +Rid to +H*XRid
; +Inv to +H*XInv
; +Linv to +H*XLinv
; +Rinv to +H*XRinv
; +Comm to +H*XComm
; ยทAssoc to ยทH*XAssoc
; ยทIdentity to ยทH*XIdentity
; ยทLid to ยทH*XLid
; ยทRid to ยทH*XRid
; ยทRdist+ to ยทH*XRdist+
; ยทLdist+ to ยทH*XLdist+
; is-set to isSetH*X )
open RingStr (snd (H*R Y)) using ()
renaming
( 0r to 0H*Y
; 1r to 1H*Y
; _+_ to _+H*Y_
; -_ to -H*Y_
; _ยท_ to _cupY_
; +Assoc to +H*YAssoc
; +Identity to +H*YIdentity
; +Lid to +H*YLid
; +Rid to +H*YRid
; +Inv to +H*YInv
; +Linv to +H*YLinv
; +Rinv to +H*YRinv
; +Comm to +H*YComm
; ยทAssoc to ยทH*YAssoc
; ยทIdentity to ยทH*YIdentity
; ยทLid to ยทH*YLid
; ยทRid to ยทH*YRid
; ยทRdist+ to ยทH*YRdist+
; ยทLdist+ to ยทH*YLdist+
; is-set to isSetH*Y )
coHomGr-Iso : {n : โ} โ GroupIso (coHomGr n X) (coHomGr n Y)
fst (coHomGr-Iso {n}) = is
where
is : Iso (coHom n X) (coHom n Y)
fun is = ST.rec squashโ (ฮป f โ โฃ (ฮป y โ f (inv e y)) โฃโ)
inv is = ST.rec squashโ (ฮป g โ โฃ (ฮป x โ g (fun e x)) โฃโ)
rightInv is = ST.elim (ฮป _ โ isPropโisSet (squashโ _ _)) (ฮป f โ cong โฃ_โฃโ (funExt (ฮป y โ cong f (rightInv e y))))
leftInv is = ST.elim (ฮป _ โ isPropโisSet (squashโ _ _)) (ฮป g โ cong โฃ_โฃโ (funExt (ฮป x โ cong g (leftInv e x))))
snd (coHomGr-Iso {n}) = makeIsGroupHom
(ST.elim (ฮป _ โ isPropโisSet ฮป u v i y โ squashโ _ _ (u y) (v y) i)
(ฮป f โ ST.elim (ฮป _ โ isPropโisSet (squashโ _ _))
(ฮป f' โ refl)))
H*-XโH*-Y : H* X โ H* Y
H*-XโH*-Y = DS-Rec-Set.f _ _ _ _ isSetH*Y
0H*Y
(ฮป n a โ base n (fun (fst coHomGr-Iso) a))
_+H*Y_
+H*YAssoc
+H*YRid
+H*YComm
(ฮป n โ cong (base n) (pres1 (snd coHomGr-Iso)) โ base-neutral n)
ฮป n a b โ base-add _ _ _ โ cong (base n) (sym (presยท (snd coHomGr-Iso) a b))
H*-YโH*-X : H* Y โ H* X
H*-YโH*-X = DS-Rec-Set.f _ _ _ _ isSetH*X
0H*X
(ฮป m a โ base m (inv (fst coHomGr-Iso) a))
_+H*X_
+H*XAssoc
+H*XRid
+H*XComm
(ฮป m โ cong (base m) (pres1 (snd (invGroupIso coHomGr-Iso))) โ base-neutral m)
ฮป m a b โ base-add _ _ _ โ cong (base m) (sym (presยท (snd (invGroupIso coHomGr-Iso)) a b))
e-sect : (y : H* Y) โ H*-XโH*-Y (H*-YโH*-X y) โก y
e-sect = DS-Ind-Prop.f _ _ _ _ (ฮป _ โ isSetH*Y _ _)
refl
(ฮป m a โ cong (base m) (rightInv (fst coHomGr-Iso) a))
(ฮป {U V} ind-U ind-V โ congโ _+H*Y_ ind-U ind-V)
e-retr : (x : H* X) โ H*-YโH*-X (H*-XโH*-Y x) โก x
e-retr = DS-Ind-Prop.f _ _ _ _ (ฮป _ โ isSetH*X _ _)
refl
(ฮป n a โ cong (base n) (leftInv (fst coHomGr-Iso) a))
(ฮป {U V} ind-U ind-V โ congโ _+H*X_ ind-U ind-V)
H*-XโH*-Y-pres1 : H*-XโH*-Y 1H*X โก 1H*Y
H*-XโH*-Y-pres1 = refl
H*-XโH*-Y-pres+ : (x x' : H* X) โ H*-XโH*-Y (x +H*X x') โก H*-XโH*-Y x +H*Y H*-XโH*-Y x'
H*-XโH*-Y-pres+ x x' = refl
H*-XโH*-Y-presยท : (x x' : H* X) โ H*-XโH*-Y (x cupX x') โก H*-XโH*-Y x cupY H*-XโH*-Y x'
H*-XโH*-Y-presยท = DS-Ind-Prop.f _ _ _ _ (ฮป x u v i y โ isSetH*Y _ _ (u y) (v y) i)
(ฮป _ โ refl)
(ฮป n โ ST.elim (ฮป x โ isPropโisSet ฮป u v i y โ isSetH*Y _ _ (u y) (v y) i)
(ฮป f โ DS-Ind-Prop.f _ _ _ _ (ฮป _ โ isSetH*Y _ _)
refl
(ฮป m โ ST.elim (ฮป _ โ isPropโisSet (isSetH*Y _ _))
(ฮป g โ refl))
ฮป {U V} ind-U ind-V โ congโ _+H*Y_ ind-U ind-V) )
(ฮป {U V} ind-U ind-V y โ congโ _+H*Y_ (ind-U y) (ind-V y))
module _
{X : Type โ}
{Y : Type โ'}
(e : Iso X Y)
where
open CohomologyRing-Equiv e
CohomologyRing-Equiv : RingEquiv (H*R X) (H*R Y)
fst CohomologyRing-Equiv = isoToEquiv is
where
is : Iso (H* X) (H* Y)
fun is = H*-XโH*-Y
inv is = H*-YโH*-X
rightInv is = e-sect
leftInv is = e-retr
snd CohomologyRing-Equiv = makeIsRingHom H*-XโH*-Y-pres1 H*-XโH*-Y-pres+ H*-XโH*-Y-presยท
| {
"alphanum_fraction": 0.4543267236,
"avg_line_length": 37.9025157233,
"ext": "agda",
"hexsha": "6970c1dd2f44d69c31104af472a8b8181f049e4a",
"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": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guilhermehas/cubical",
"max_forks_repo_path": "Cubical/ZCohomology/RingStructure/CohomologyRing.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"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": "guilhermehas/cubical",
"max_issues_repo_path": "Cubical/ZCohomology/RingStructure/CohomologyRing.agda",
"max_line_length": 140,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guilhermehas/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/RingStructure/CohomologyRing.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 4635,
"size": 12053
} |
module Setoid where
module Logic where
infix 4 _/\_
-- infix 2 _\/_
data True : Set where
tt : True
data False : Set where
data _/\_ (P Q : Set) : Set where
andI : P -> Q -> P /\ Q
-- Not allowed if we have proof irrelevance
-- data _\/_ (P Q : Set) : Set where
-- orIL : P -> P \/ Q
-- orIR : Q -> P \/ Q
module Setoid where
data Setoid : Set1 where
setoid : (A : Set)
-> (_==_ : A -> A -> Set)
-> (refl : (x : A) -> x == x)
-> (sym : (x y : A) -> x == y -> y == x)
-> (trans : (x y z : A) -> x == y -> y == z -> x == z)
-> Setoid
El : Setoid -> Set
El (setoid A _ _ _ _) = A
module Projections where
eq : (A : Setoid) -> El A -> El A -> Set
eq (setoid _ e _ _ _) = e
refl : (A : Setoid) -> {x : El A} -> eq A x x
refl (setoid _ _ r _ _) = r _
sym : (A : Setoid) -> {x y : El A} -> (h : eq A x y) -> eq A y x
sym (setoid _ _ _ s _) = s _ _
trans : (A : Setoid) -> {x y z : El A} -> eq A x y -> eq A y z -> eq A x z
trans (setoid _ _ _ _ t) = t _ _ _
module Equality (A : Setoid) where
infix 6 _==_
_==_ : El A -> El A -> Set
_==_ = Projections.eq A
refl : {x : El A} -> x == x
refl = Projections.refl A
sym : {x y : El A} -> x == y -> y == x
sym = Projections.sym A
trans : {x y z : El A} -> x == y -> y == z -> x == z
trans = Projections.trans A
module EqChain (A : Setoid.Setoid) where
infixl 5 _===_ _=-=_
infix 8 _since_
open Setoid
private open module EqA = Equality A
eqProof>_ : (x : El A) -> x == x
eqProof> x = refl
_=-=_ : (x : El A) -> {y : El A} -> x == y -> x == y
x =-= eq = eq
_===_ : {x y z : El A} -> x == y -> y == z -> x == z
_===_ = trans
_since_ : {x : El A} -> (y : El A) -> x == y -> x == y
_ since eq = eq
module Fun where
open Logic
open Setoid
infixr 10 _=>_ _==>_
open Setoid.Projections using (eq)
data _=>_ (A B : Setoid) : Set where
lam : (f : El A -> El B)
-> ({x y : El A} -> eq A x y
-> eq B (f x) (f y)
)
-> A => B
app : {A B : Setoid} -> (A => B) -> El A -> El B
app (lam f _) = f
cong : {A B : Setoid} -> (f : A => B) -> {x y : El A} ->
eq A x y -> eq B (app f x) (app f y)
cong (lam _ resp) = resp
data EqFun {A B : Setoid}(f g : A => B) : Set where
eqFunI : ({x y : El A} -> eq A x y -> eq B (app f x) (app g y)) ->
EqFun f g
eqFunE : {A B : Setoid} -> {f g : A => B} -> {x y : El A} ->
EqFun f g -> eq A x y -> eq B (app f x) (app g y)
eqFunE (eqFunI h) = h
_==>_ : Setoid -> Setoid -> Setoid
A ==> B = setoid (A => B) EqFun r s t
where
module Proof where
open module EqChainB = EqChain B
module EqA = Equality A
open module EqB = Equality B
-- either abstract or --proof-irrelevance needed
-- (we don't want to compare the proofs for equality)
-- abstract
r : (f : A => B) -> EqFun f f
r f = eqFunI (\xy -> cong f xy)
s : (f g : A => B) -> EqFun f g -> EqFun g f
s f g fg =
eqFunI (\{x}{y} xy ->
app g x =-= app g y since cong g xy
=== app f x since sym (eqFunE fg xy)
=== app f y since cong f xy
)
t : (f g h : A => B) -> EqFun f g -> EqFun g h -> EqFun f h
t f g h fg gh =
eqFunI (\{x}{y} xy ->
app f x =-= app g y since eqFunE fg xy
=== app g x since cong g (EqA.sym xy)
=== app h y since eqFunE gh xy
)
open Proof
infixl 100 _$_
_$_ : {A B : Setoid} -> El (A ==> B) -> El A -> El B
_$_ = app
lam2 : {A B C : Setoid} ->
(f : El A -> El B -> El C) ->
({x x' : El A} -> eq A x x' ->
{y y' : El B} -> eq B y y' -> eq C (f x y) (f x' y')
) -> El (A ==> B ==> C)
lam2 {A} f h = lam (\x -> lam (\y -> f x y)
(\y -> h EqA.refl y))
(\x -> eqFunI (\y -> h x y))
where
module EqA = Equality A
lam3 : {A B C D : Setoid} ->
(f : El A -> El B -> El C -> El D) ->
({x x' : El A} -> eq A x x' ->
{y y' : El B} -> eq B y y' ->
{z z' : El C} -> eq C z z' -> eq D (f x y z) (f x' y' z')
) -> El (A ==> B ==> C ==> D)
lam3 {A} f h =
lam (\x -> lam2 (\y z -> f x y z)
(\y z -> h EqA.refl y z))
(\x -> eqFunI (\y -> eqFunI (\z -> h x y z)))
where
module EqA = Equality A
eta : {A B : Setoid} -> (f : El (A ==> B)) ->
eq (A ==> B) f (lam (\x -> f $ x) (\xy -> cong f xy))
eta f = eqFunI (\xy -> cong f xy)
id : {A : Setoid} -> El (A ==> A)
id = lam (\x -> x) (\x -> x)
{- Now it looks okay. But it's incredibly slow! Proof irrelevance makes it
go fast again... The problem is equality checking of (function type)
setoids which without proof irrelevance checks equality of the proof that
EqFun is an equivalence relation. It's not clear why using lam3 involves
so many more equality checks than using lam. Making the proofs abstract
makes the problem go away.
-}
compose : {A B C : Setoid} -> El ((B ==> C) ==> (A ==> B) ==> (A ==> C))
compose =
lam3 (\f g x -> f $ (g $ x))
(\f g x -> eqFunE f (eqFunE g x))
_โ_ : {A B C : Setoid} -> El (B ==> C) -> El (A ==> B) -> El (A ==> C)
f โ g = compose $ f $ g
const : {A B : Setoid} -> El (A ==> B ==> A)
const = lam2 (\x y -> x) (\x y -> x)
module Nat where
open Logic
open Setoid
open Fun
infixl 10 _+_
data Nat : Set where
zero : Nat
suc : Nat -> Nat
module NatSetoid where
eqNat : Nat -> Nat -> Set
eqNat zero zero = True
eqNat zero (suc _) = False
eqNat (suc _) zero = False
eqNat (suc n) (suc m) = eqNat n m
data EqNat (n m : Nat) : Set where
eqnat : eqNat n m -> EqNat n m
uneqnat : {n m : Nat} -> EqNat n m -> eqNat n m
uneqnat (eqnat x) = x
r : (x : Nat) -> eqNat x x
r zero = tt
r (suc n) = r n
-- reflexivity of EqNat
rf : (n : Nat) -> EqNat n n
rf = \ x -> eqnat (r x)
s : (x y : Nat) -> eqNat x y -> eqNat y x
s zero zero _ = tt
s (suc n) (suc m) h = s n m h
s zero (suc _) ()
s (suc _) zero ()
-- symmetry of EqNat
sy : (x y : Nat) -> EqNat x y -> EqNat y x
sy = \x y h -> eqnat (s x y (uneqnat h))
t : (x y z : Nat) -> eqNat x y -> eqNat y z -> eqNat x z
t zero zero z xy yz = yz
t (suc x) (suc y) (suc z) xy yz = t x y z xy yz
t zero (suc _) _ () _
t (suc _) zero _ () _
t (suc _) (suc _) zero _ ()
-- transitivity of EqNat
tr : (x y z : Nat) -> EqNat x y -> EqNat y z -> EqNat x z
tr = \x y z xy yz -> eqnat (t x y z (uneqnat xy) (uneqnat yz))
NAT : Setoid
NAT = setoid Nat NatSetoid.EqNat NatSetoid.rf NatSetoid.sy NatSetoid.tr
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
plus : El (NAT ==> NAT ==> NAT)
plus = lam2 (\n m -> n + m) eqPlus
where
module EqNat = Equality NAT
open EqNat
open NatSetoid
eqPlus : {n n' : Nat} -> n == n' -> {m m' : Nat} -> m == m' -> n + m == n' + m'
eqPlus {zero} {zero} _ mm = mm
eqPlus {suc n} {suc n'} (eqnat nn) {m}{m'} (eqnat mm) =
eqnat (uneqnat (eqPlus{n}{n'} (eqnat nn)
{m}{m'} (eqnat mm)
) )
eqPlus {zero} {suc _} (eqnat ()) _
eqPlus {suc _} {zero} (eqnat ()) _
module List where
open Logic
open Setoid
data List (A : Set) : Set where
nil : List A
_::_ : A -> List A -> List A
LIST : Setoid -> Setoid
LIST A = setoid (List (El A)) eqList r s t
where
module EqA = Equality A
open EqA
eqList : List (El A) -> List (El A) -> Set
eqList nil nil = True
eqList nil (_ :: _) = False
eqList (_ :: _) nil = False
eqList (x :: xs) (y :: ys) = x == y /\ eqList xs ys
r : (x : List (El A)) -> eqList x x
r nil = tt
r (x :: xs) = andI refl (r xs)
s : (x y : List (El A)) -> eqList x y -> eqList y x
s nil nil h = h
s (x :: xs) (y :: ys) (andI xy xys) = andI (sym xy) (s xs ys xys)
s nil (_ :: _) ()
s (_ :: _) nil ()
t : (x y z : List (El A)) -> eqList x y -> eqList y z -> eqList x z
t nil nil zs _ h = h
t (x :: xs) (y :: ys) (z :: zs) (andI xy xys) (andI yz yzs) =
andI (trans xy yz) (t xs ys zs xys yzs)
t nil (_ :: _) _ () _
t (_ :: _) nil _ () _
t (_ :: _) (_ :: _) nil _ ()
open Fun
| {
"alphanum_fraction": 0.4386713051,
"avg_line_length": 28.0220125786,
"ext": "agda",
"hexsha": "3ad5d991e4a3a09a9656aff3de2fed46e8fead5f",
"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/Setoid.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/Setoid.agda",
"max_line_length": 85,
"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/Setoid.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": 3259,
"size": 8911
} |
{-# OPTIONS --rewriting --confluence-check -v rewriting:80 #-}
open import Agda.Builtin.Equality
postulate
decorate : โ{a} (A : Set a) โ Set a
rewriteMe : โ{a b} {A : Set a} {B : A โ Set b}
โ decorate ((x : A) โ B x) โก (decorate A โ โ x โ decorate (B x))
{-# BUILTIN REWRITE _โก_ #-}
{-# REWRITE rewriteMe #-}
postulate A : Set
test : decorate (A โ A) โก (decorate A โ โ (x : A) โ decorate A)
test = refl
| {
"alphanum_fraction": 0.5491990847,
"avg_line_length": 25.7058823529,
"ext": "agda",
"hexsha": "18a849a3c6fcd14c13e5f8300684d6e2e783a1eb",
"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/Issue3971.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/Issue3971.agda",
"max_line_length": 80,
"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/Issue3971.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 145,
"size": 437
} |
module interactiveProgramsAgda where
open import NativeIO
open import Function
open import Size
open import Data.Maybe.Base
record IOInterface : Setโ where
field Command : Set
Response : (c : Command) โ Set
open IOInterface public
mutual
record IO (I : IOInterface) (i : Size) (A : Set) : Set where
coinductive
constructor delay
field force : {j : Size< i} โ IO' I j A
data IO' (I : IOInterface) (i : Size) (A : Set) : Set where
do' : (c : Command I) (f : Response I c โ IO I i A) โ IO' I i A
return' : (a : A) โ IO' I i A
open IO public
module _ {I : IOInterface} (let C = Command I) (let R = Response I) where
do : โ{i A} (c : C) (f : R c โ IO I i A) โ IO I i A
force (do c f) = do' c f
return : โ{i A} (a : A) โ IO I i A
force (return a) = return' a
infixl 2 _>>=_
_>>=_ : โ{i A B} (m : IO I i A) (k : A โ IO I i B) โ IO I i B
force (m >>= k) with force m
... | do' c f = do' c ฮป x โ f x >>= k
... | return' a = force (k a)
{-# NON_TERMINATING #-}
translateIO : โ {A} (tr : (c : C) โ NativeIO (R c)) โ IO I โ A โ NativeIO A
translateIO tr m = case (force m) of ฮป
{ (do' c f) โ (tr c) native>>= ฮป r โ translateIO tr (f r)
; (return' a) โ nativeReturn a
}
{- Specific case of Console IO -}
data ConsoleCommand : Set where
getLine : ConsoleCommand
putStrLn : String โ ConsoleCommand
ConsoleResponse : ConsoleCommand โ Set
ConsoleResponse getLine = String
ConsoleResponse (putStrLn s) = Unit
ConsoleInterface : IOInterface
Command ConsoleInterface = ConsoleCommand
Response ConsoleInterface = ConsoleResponse
IOConsole : (i : Size) โ Set โ Set
IOConsole i = IO ConsoleInterface i
translateIOConsoleLocal : (c : ConsoleCommand) โ NativeIO (ConsoleResponse c)
translateIOConsoleLocal (putStrLn s) = nativePutStrLn s
translateIOConsoleLocal getLine = nativeGetLine
translateIOConsole : {A : Set} โ IOConsole โ A โ NativeIO A
translateIOConsole = translateIO translateIOConsoleLocal
cat : โ {i} โ IOConsole i Unit
force cat = do' getLine ฮป line โ
do (putStrLn line) ฮป _ โ
cat
main : NativeIO Unit
main = translateIOConsole cat
| {
"alphanum_fraction": 0.6132917038,
"avg_line_length": 27.0120481928,
"ext": "agda",
"hexsha": "88da970a531e4e19e0d76496dad8935c06ef960a",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda",
"max_line_length": 77,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 715,
"size": 2242
} |
module _ where
open import Common.Prelude hiding (_>>=_)
open import Common.Reflection
open import Common.Equality
open import Imports.StaleMetaLiteral
macro
unquoteMeta : Meta โ Tactic
unquoteMeta m = give (meta m [])
thm : unquoteMeta staleMeta โก 42
thm = refl
| {
"alphanum_fraction": 0.7536764706,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "b9500a3f9c3f3f561a4fa7ffbc35a9e8d769b316",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/StaleMetaLiteral.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/StaleMetaLiteral.agda",
"max_line_length": 41,
"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/StaleMetaLiteral.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": 75,
"size": 272
} |
{-# OPTIONS --cubical #-}
module Data.Option.Equiv.Path where
import Lvl
open import Data
open import Data.Option
open import Data.Option.Functions
open import Data.Option.Equiv
open import Functional
open import Structure.Function.Domain
open import Structure.Operator
open import Structure.Relator
open import Type.Cubical.Path.Equality
open import Type
private variable โ : Lvl.Level
private variable T : Type{โ}
instance
Some-injectivity : Injective {B = Option(T)} (Some)
Injective.proof Some-injectivity {x}{y} = congruenceโโ(_or_)(x)
instance
Path-Option-extensionality : Extensionality{A = T} (Path-equiv)
Extensionality.cases-inequality (Path-Option-extensionality {T = T}) {x} p with () โ substituteโ(elim{A = T}{B = ฮป _ โ Type}(Option(T)) (const Empty)) p (Some x)
| {
"alphanum_fraction": 0.7506297229,
"avg_line_length": 29.4074074074,
"ext": "agda",
"hexsha": "3458c0585a47c2c48bc58f38b69c35186881410a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Option/Equiv/Path.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Option/Equiv/Path.agda",
"max_line_length": 163,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Option/Equiv/Path.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 216,
"size": 794
} |
module Cats.Category.Cat.Facts.Terminal where
open import Cats.Category
open import Cats.Category.Cat using (Cat)
open import Cats.Category.One using (One)
instance
hasTerminal : โ lo la lโ โ HasTerminal (Cat lo la lโ)
hasTerminal lo la lโ = record
{ One = One lo la lโ
; isTerminal = _
}
| {
"alphanum_fraction": 0.6815286624,
"avg_line_length": 22.4285714286,
"ext": "agda",
"hexsha": "758d4bb2c32934e5b7a6c7d1a95f5cad6c1e4bb1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Category/Cat/Facts/Terminal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Cat/Facts/Terminal.agda",
"max_line_length": 55,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Cat/Facts/Terminal.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 88,
"size": 314
} |
{-# OPTIONS --safe #-}
module Cubical.Homotopy.WedgeConnectivity where
open import Cubical.Foundations.Everything
open import Cubical.Data.Nat
open import Cubical.Data.Sigma
open import Cubical.HITs.Susp
open import Cubical.HITs.Truncation as Trunc
open import Cubical.Homotopy.Connected
module WedgeConnectivity {โ โ' โ''} (n m : โ)
(A : Pointed โ) (connA : isConnected (suc n) (typ A))
(B : Pointed โ') (connB : isConnected (suc m) (typ B))
(P : typ A โ typ B โ TypeOfHLevel โ'' (n + m))
(f : (a : typ A) โ P a (pt B) .fst)
(g : (b : typ B) โ P (pt A) b .fst)
(p : f (pt A) โก g (pt B))
where
private
Q : typ A โ TypeOfHLevel _ n
Q a =
( (ฮฃ[ k โ ((b : typ B) โ P a b .fst) ] k (pt B) โก f a)
, isOfHLevelRetract n
(ฮป {(h , q) โ h , funExt ฮป _ โ q})
(ฮป {(h , q) โ h , funExtโป q _})
(ฮป _ โ refl)
(isOfHLevelPrecomposeConnected n m (P a) (ฮป _ โ pt B)
(isConnectedPoint m connB (pt B)) (ฮป _ โ f a))
)
main : isContr (fiber (ฮป s _ โ s (pt A)) (ฮป _ โ g , p โปยน))
main =
elim.isEquivPrecompose (ฮป _ โ pt A) n Q
(isConnectedPoint n connA (pt A))
.equiv-proof (ฮป _ โ g , p โปยน)
extension : โ a b โ P a b .fst
extension a b = main .fst .fst a .fst b
left : โ a โ extension a (pt B) โก f a
left a = main .fst .fst a .snd
right : โ b โ extension (pt A) b โก g b
right = funExtโป (cong fst (funExtโป (main .fst .snd) _))
hom : left (pt A) โปยน โ right (pt B) โก p
hom i j = hcomp (ฮป k โ ฮป { (i = i1) โ p j
; (j = i0) โ (cong snd (funExtโป (main .fst .snd) tt)) i (~ j)
; (j = i1) โ right (pt B) (i โจ k)})
(cong snd (funExtโป (main .fst .snd) tt) i (~ j))
hom' : left (pt A) โก right (pt B) โ sym p
hom' = (lUnit (left _) โ cong (_โ left (pt A)) (sym (rCancel (right (pt B)))))
โโ sym (assoc _ _ _)
โโ cong (right (pt B) โ_) (sym (symDistr (left (pt A) โปยน) (right (pt B))) โ (cong sym hom))
homSquare : PathP (ฮป i โ extension (pt A) (pt B) โก p i) (left (pt A)) (right (pt B))
homSquare i j = hcomp (ฮป k โ ฮป { (i = i0) โ left (pt A) j
; (i = i1) โ compPath-filler (right (pt B)) (sym p) (~ k) j
; (j = i0) โ extension (pt A) (pt B)
; (j = i1) โ p (i โง k) })
(hom' i j)
| {
"alphanum_fraction": 0.4867219917,
"avg_line_length": 37.0769230769,
"ext": "agda",
"hexsha": "27f1795c8dc75136c8037ef7aa9c2567dc2eb77a",
"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/Homotopy/WedgeConnectivity.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/Homotopy/WedgeConnectivity.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/Homotopy/WedgeConnectivity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 914,
"size": 2410
} |
module #13 where
{-
Using propositions-as-types, derive the double negation of the principle of excluded
middle, i.e. prove not (not (P or not P)).
-}
open import Data.Sum
open import Relation.Nullary
excluded-middle : (P : Set) โ ยฌ (ยฌ (P โ (ยฌ P)))
excluded-middle P z = z (injโ (ฮป x โ z (injโ x)))
| {
"alphanum_fraction": 0.6568627451,
"avg_line_length": 23.5384615385,
"ext": "agda",
"hexsha": "0dee53a0240d0e12611ed56c29e8f11cac048c0b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CodaFi/HoTT-Exercises",
"max_forks_repo_path": "Chapter1/#13.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CodaFi/HoTT-Exercises",
"max_issues_repo_path": "Chapter1/#13.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": "Chapter1/#13.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 96,
"size": 306
} |
-- Andreas, 2015-06-24 Parsing of forall should be like lambda
open import Common.Prelude
open import Common.Product
test : โค ร โ (B : Set) โ B โ B -- should parse
test = _ , ฮป B b โ b
test1 : โค ร forall (B : Set) โ B โ B -- should parse
test1 = _ , ฮป B b โ b
| {
"alphanum_fraction": 0.6113207547,
"avg_line_length": 24.0909090909,
"ext": "agda",
"hexsha": "23d8a8720d406ff818bb447af12c038d8e44fcf6",
"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/Issue1583.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/Issue1583.agda",
"max_line_length": 62,
"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/Issue1583.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": 91,
"size": 265
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cohomology.Theory
open import cw.CW
module cw.cohomology.ZerothCohomologyGroupOnDiag {i} (OT : OrdinaryTheory i)
(โskel : โSkeleton {i} 0) (ac : โhas-cells-with-choice 0 โskel i) where
open OrdinaryTheory OT
open import cw.cohomology.TipAndAugment OT โskel
open import groups.KernelSndImageInl (C2 0) {H = CXโ 0}
{K = Lift-group {j = i} Unit-group}
cst-hom cst-hom (ฮป _ โ idp)
(C2รCXโ-is-abelian 0)
open import groups.KernelImage
(cst-hom {G = C2รCXโ 0} {H = Lift-group {j = i} Unit-group})
cw-coฮต (C2รCXโ-is-abelian 0)
C-cw-iso-ker/im : C 0 โโฆ โskel โง โแดณ Ker/Im
C-cw-iso-ker/im =
Ker-ฯ-snd-quot-Im-inl
โeแดณ full-subgroup (ker-cst-hom-is-full (CXโ 0) (Lift-group {j = i} Unit-group)) โปยนแดณ
| {
"alphanum_fraction": 0.6730523627,
"avg_line_length": 29,
"ext": "agda",
"hexsha": "83a599c7937a957b71d5868453ae5e0b89eb464d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/cohomology/ZerothCohomologyGroupOnDiag.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/cohomology/ZerothCohomologyGroupOnDiag.agda",
"max_line_length": 85,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/cohomology/ZerothCohomologyGroupOnDiag.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 330,
"size": 783
} |
module Data.Nat.Properties.Extra where
open import Data.Nat.Base
open import Data.Nat.Properties
open import Relation.Binary.PropositionalEquality
open โก-Reasoning
open import Data.Empty
โคโฒ-unique : โ {i u} (p q : i โคโฒ u) โ p โก q
โคโฒ-unique โคโฒ-refl โคโฒ-refl = refl
โคโฒ-unique โคโฒ-refl (โคโฒ-step q) = โฅ-elim (1+nโฐn (โคโฒโโค q))
โคโฒ-unique (โคโฒ-step p) โคโฒ-refl = โฅ-elim (1+nโฐn (โคโฒโโค p))
โคโฒ-unique (โคโฒ-step p) (โคโฒ-step q) = cong โคโฒ-step (โคโฒ-unique p q)
m+n+oโกn+m+o : โ m n o โ m + (n + o) โก n + (m + o)
m+n+oโกn+m+o m n o = begin
m + (n + o) โกโจ sym (+-assoc m n o) โฉ
(m + n) + o โกโจ cong (ฮป x โ x + o) (+-comm m n) โฉ
(n + m) + o โกโจ +-assoc n m o โฉ
n + (m + o) โ
| {
"alphanum_fraction": 0.5189681335,
"avg_line_length": 29.9545454545,
"ext": "agda",
"hexsha": "13d4ea10fa73950daf74c6d6b6f90c047594ca8e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Data/Nat/Properties/Extra.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Data/Nat/Properties/Extra.agda",
"max_line_length": 64,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Data/Nat/Properties/Extra.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 337,
"size": 659
} |
module Data.List.First {โ}{A : Set โ} where
open import Data.Product
open import Data.List
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Level
open import Function
open import Data.Empty
-- proof that an element is the first in a vector to satisfy the predicate B
data First {b}(B : A โ Set b) : (x : A) โ List A โ Set (โ โ b) where
here : โ {x : A} โ (p : B x) โ {v : List A} โ First B x (x โท v)
there : โ {x} {v : List A} (x' : A) โ ยฌ (B x') โ First B x v โ First B x (x' โท v)
-- get the witness of B x from the element โ First
firstโถwitness : โ {B : A โ Set} {x l} โ First B x l โ B x
firstโถwitness (here p) = p
firstโถwitness (there x ยฌpx f) = firstโถwitness f
-- more likable syntax for the above structure
first_โ_โ_ : โ {p} โ A โ List A โ (B : A โ Set p) โ Set (p โ โ)
first_โ_โ_ x v p = First p x v
-- a decision procedure to find the first element in a vector that satisfies a predicate
find : โ (P : A โ Set) โ ((a : A) โ Dec (P a)) โ (v : List A) โ
Dec (โ ฮป e โ first e โ v โ P)
find P dec [] = no (ฮป{ (e , ()) })
find P dec (x โท v) with dec x
find P dec (x โท v) | yes px = yes (x , here px)
find P dec (x โท v) | no ยฌpx with find P dec v
find P dec (x โท v) | no ยฌpx | yes firstv = yes (-, there x ยฌpx (projโ firstv))
find P dec (x โท v) | no ยฌpx | no ยฌfirstv = no $ helper ยฌpx ยฌfirstv
where
helper : ยฌ (P x) โ ยฌ (โ ฮป e โ First P e v) โ ยฌ (โ ฮป e โ First P e (x โท v))
helper ยฌpx ยฌfirstv (.x , here p) = ยฌpx p
helper ยฌpx ยฌfirstv (u , there ._ _ firstv) = ยฌfirstv (u , firstv)
| {
"alphanum_fraction": 0.5824246312,
"avg_line_length": 39.9743589744,
"ext": "agda",
"hexsha": "b350a774d08b9f919ccd6fc0e341ca5dafcbaf72",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Data/List/First.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Data/List/First.agda",
"max_line_length": 88,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Data/List/First.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": 586,
"size": 1559
} |
------------------------------------------------------------------------
-- Example: Left recursive expression grammar
------------------------------------------------------------------------
module TotalRecognisers.LeftRecursion.Expression where
open import Codata.Musical.Notation
open import Data.Bool hiding (_โง_; _โค_; _โค?_)
open import Data.Char as Char using (Char)
open import Data.Nat using (โ; _โค?_)
open import Data.String as String using (String)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary.Decidable
import TotalRecognisers.LeftRecursion as P
import TotalRecognisers.LeftRecursion.Lib as Lib
open P Char
open Lib Char
open KleeneStarโ
open Tok Char._โ_
------------------------------------------------------------------------
-- Recognisers for digits and numbers
-- Digits.
digit : P _
digit = sat in-range
where
in-range : Char โ Bool
in-range t = โ Char.toโ '0' โค? Char.toโ t โ โง
โ Char.toโ t โค? Char.toโ '9' โ
-- Numbers.
number : P _
number = digit +
------------------------------------------------------------------------
-- An expression grammar
-- t โท= t '+' f โฃ f
-- f โท= f '*' a โฃ a
-- a โท= '(' t ')' โฃ n
mutual
term = โฏ (โฏ term ยท โฏ tok '+') ยท โฏ factor
โฃ factor
factor = โฏ (โฏ factor ยท โฏ tok '*') ยท โฏ atom
โฃ atom
atom = โฏ (โฏ tok '(' ยท โฏ term) ยท โฏ tok ')'
โฃ number
------------------------------------------------------------------------
-- Unit tests
module Tests where
test : โ {n} โ P n โ String โ Bool
test p s = โ String.toList s โ? p โ
exโ : test term "1*(2+3)" โก true
exโ = refl
exโ : test term "1*(2+3" โก false
exโ = refl
| {
"alphanum_fraction": 0.4833333333,
"avg_line_length": 23.661971831,
"ext": "agda",
"hexsha": "9195bb533273f4632409cd13deb96b26f04d0be6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "TotalRecognisers/LeftRecursion/Expression.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"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/parser-combinators",
"max_issues_repo_path": "TotalRecognisers/LeftRecursion/Expression.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalRecognisers/LeftRecursion/Expression.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 456,
"size": 1680
} |
{-# OPTIONS --without-K --safe #-}
module Math.NumberTheory.Summation.Generic.Properties.Lemma where
-- agda-stdlib
open import Data.Nat
open import Data.Nat.Properties
open import Data.Nat.Solver
open import Relation.Binary.PropositionalEquality
open import Function.Base
lemmaโ : โ m n โ 2 + m + n โก suc m + suc n
lemmaโ = solve 2 (ฮป m n โ con 2 :+ m :+ n := con 1 :+ m :+ (con 1 :+ n)) refl
where open +-*-Solver
| {
"alphanum_fraction": 0.6888361045,
"avg_line_length": 28.0666666667,
"ext": "agda",
"hexsha": "59dc43967ecd8dcf237b5d3c5cdf44730003683e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "Math/NumberTheory/Summation/Generic/Properties/Lemma.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rei1024/agda-misc",
"max_issues_repo_path": "Math/NumberTheory/Summation/Generic/Properties/Lemma.agda",
"max_line_length": 77,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "Math/NumberTheory/Summation/Generic/Properties/Lemma.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 129,
"size": 421
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.Logic where
import Cubical.Data.Empty as โฅ
open import Cubical.Data.Prod as ร using (_ร_; _,_; projโ; projโ)
open import Cubical.Data.Sum as โ using (_โ_)
open import Cubical.Data.Unit
open import Cubical.Foundations.Prelude
open import Cubical.HITs.PropositionalTruncation as PropTrunc
open import Cubical.Foundations.HLevels using (hProp; ฮฃPropโก; isPropPi) public
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Function
open import Cubical.Relation.Nullary hiding (ยฌ_)
infix 10 ยฌ_
infixr 8 _โ_
infixr 8 _โโฒ_
infixr 8 _โ_
infixr 8 _โโฒ_
infixr 6 _โ_
infixr 4 _โ_
infix 30 _โกโ_
infix 30 _โขโ_
infix 2 โ[]-syntax
infix 2 โ[โถ]-syntax
infix 2 โ[โถ]-syntax
infix 2 โ[]-syntax
infix 2 โโถ_โโถ_
infix 2 โโถ_โโถ_
--------------------------------------------------------------------------------
-- The type hProp of mere propositions
-- the definition hProp is given in Foundations.HLevels
-- hProp โ = ฮฃ (Type โ) isProp
private
variable
โ โ' โ'' : Level
P Q R : hProp โ
A B C : Type โ
[_] : hProp โ โ Type โ
[_] = fst
โฅ_โฅโ : Type โ โ hProp โ
โฅ A โฅโ = โฅ A โฅ , propTruncIsProp
_โกโ_ : (x y : A) โ hProp _
x โกโ y = โฅ x โก y โฅโ
hPropโก : [ P ] โก [ Q ] โ P โก Q
hPropโก p = ฮฃPropโก (\ _ โ isPropIsProp) p
--------------------------------------------------------------------------------
-- Logical implication of mere propositions
_โ_ : (A : hProp โ) โ (B : hProp โ') โ hProp _
A โ B = ([ A ] โ [ B ]) , isPropPi ฮป _ โ B .snd
โtoPath : [ P โ Q ] โ [ Q โ P ] โ P โก Q
โtoPath {P = P} {Q = Q} PโQ QโP = hPropโก (isoToPath
(iso PโQ QโP (ฮป b โ Q .snd (PโQ (QโP b)) b) ฮป a โ P .snd (QโP (PโQ a)) a))
pathToโ : P โก Q โ [ P โ Q ]
pathToโ p x = subst fst p x
pathToโ : P โก Q โ [ Q โ P ]
pathToโ p x = subst fst (sym p) x
substโ : {x y : A} (B : A โ hProp โ) โ [ x โกโ y โ B x โ B y ]
substโ {x = x} {y = y} B = PropTrunc.elim (ฮป _ โ isPropPi ฮป _ โ B y .snd) (subst (fst โ B))
--------------------------------------------------------------------------------
-- Mixfix notations for โ-toPath
-- see โ-identityหก and โ-identityสณ for the difference
โโถ_โโถ_ : [ P โ Q ] โ [ Q โ P ] โ P โก Q
โโถ_โโถ_ = โtoPath
โโถ_โโถ_ : [ Q โ P ] โ [ P โ Q ] โ P โก Q
โโถ g โโถ f = โtoPath f g
--------------------------------------------------------------------------------
-- False and True
โฅ : hProp _
โฅ = โฅ.โฅ , ฮป ()
โค : hProp _
โค = Unit , (ฮป _ _ _ โ tt)
--------------------------------------------------------------------------------
-- Pseudo-complement of mere propositions
ยฌ_ : hProp โ โ hProp _
ยฌ A = ([ A ] โ โฅ.โฅ) , isPropPi ฮป _ โ โฅ.isPropโฅ
_โขโ_ : (x y : A) โ hProp _
x โขโ y = ยฌ x โกโ y
--------------------------------------------------------------------------------
-- Disjunction of mere propositions
_โโฒ_ : Type โ โ Type โ' โ Type _
A โโฒ B = โฅ A โ B โฅ
_โ_ : hProp โ โ hProp โ' โ hProp _
P โ Q = โฅ [ P ] โ [ Q ] โฅโ
inl : A โ A โโฒ B
inl x = โฃ โ.inl x โฃ
inr : B โ A โโฒ B
inr x = โฃ โ.inr x โฃ
โ-elim : (P : hProp โ) (Q : hProp โ') (R : [ P โ Q ] โ hProp โ'')
โ (โ x โ [ R (inl x) ]) โ (โ y โ [ R (inr y) ]) โ (โ z โ [ R z ])
โ-elim _ _ R PโR QโR = PropTrunc.elim (snd โ R) (โ.elim PโR QโR)
--------------------------------------------------------------------------------
-- Conjunction of mere propositions
_โโฒ_ : Type โ โ Type โ' โ Type _
A โโฒ B = A ร B
_โ_ : hProp โ โ hProp โ' โ hProp _
A โ B = [ A ] โโฒ [ B ] , ร.isOfHLevelProd 1 (A .snd) (B .snd)
โ-intro : (P : hProp โ) (Q : [ P ] โ hProp โ') (R : [ P ] โ hProp โ'')
โ (โ a โ [ Q a ]) โ (โ a โ [ R a ]) โ (โ (a : [ P ]) โ [ Q a โ R a ] )
โ-intro _ _ _ = ร.intro
--------------------------------------------------------------------------------
-- Logical bi-implication of mere propositions
_โ_ : hProp โ โ hProp โ' โ hProp _
A โ B = (A โ B) โ (B โ A)
--------------------------------------------------------------------------------
-- Universal Quantifier
โ[โถ]-syntax : (A โ hProp โ) โ hProp _
โ[โถ]-syntax {A = A} P = (โ x โ [ P x ]) , isPropPi (snd โ P)
โ[]-syntax : (A โ hProp โ) โ hProp _
โ[]-syntax {A = A} P = (โ x โ [ P x ]) , isPropPi (snd โ P)
syntax โ[โถ]-syntax {A = A} (ฮป a โ P) = โ[ a โถ A ] P
syntax โ[]-syntax (ฮป a โ P) = โ[ a ] P
--------------------------------------------------------------------------------
-- Existential Quantifier
โ[]-syntax : (A โ hProp โ) โ hProp _
โ[]-syntax {A = A} P = โฅ ฮฃ A (fst โ P) โฅโ
โ[โถ]-syntax : (A โ hProp โ) โ hProp _
โ[โถ]-syntax {A = A} P = โฅ ฮฃ A (fst โ P) โฅโ
syntax โ[]-syntax {A = A} (ฮป x โ P) = โ[ x โถ A ] P
syntax โ[โถ]-syntax (ฮป x โ P) = โ[ x ] P
--------------------------------------------------------------------------------
-- Decidable mere proposition
Decโ : (P : hProp โ) โ hProp โ
Decโ P = Dec [ P ] , isPropDec (snd P)
--------------------------------------------------------------------------------
-- Negation commutes with truncation
โฅยฌAโฅโกยฌโฅAโฅ : (A : Type โ) โ โฅ (A โ โฅ.โฅ) โฅโ โก (ยฌ โฅ A โฅโ)
โฅยฌAโฅโกยฌโฅAโฅ _ =
โโถ (ฮป ยฌA A โ PropTrunc.elim (ฮป _ โ โฅ.isPropโฅ)
(PropTrunc.elim (ฮป _ โ isPropPi ฮป _ โ โฅ.isPropโฅ) (ฮป ยฌp p โ ยฌp p) ยฌA) A)
โโถ ฮป ยฌp โ โฃ (ฮป p โ ยฌp โฃ p โฃ) โฃ
--------------------------------------------------------------------------------
-- (hProp, โ, โฅ) is a bounded โ-semilattice
โ-assoc : (P : hProp โ) (Q : hProp โ') (R : hProp โ'')
โ P โ (Q โ R) โก (P โ Q) โ R
โ-assoc P Q R =
โโถ โ-elim P (Q โ R) (ฮป _ โ (P โ Q) โ R)
(inl โ inl)
(โ-elim Q R (ฮป _ โ (P โ Q) โ R) (inl โ inr) inr)
โโถ assoc2
where
assoc2 : (A โโฒ B) โโฒ C โ A โโฒ (B โโฒ C)
assoc2 โฃ โ.inr a โฃ = โฃ โ.inr โฃ โ.inr a โฃ โฃ
assoc2 โฃ โ.inl โฃ โ.inr b โฃ โฃ = โฃ โ.inr โฃ โ.inl b โฃ โฃ
assoc2 โฃ โ.inl โฃ โ.inl c โฃ โฃ = โฃ โ.inl c โฃ
assoc2 โฃ โ.inl (squash x y i) โฃ = propTruncIsProp (assoc2 โฃ โ.inl x โฃ) (assoc2 โฃ โ.inl y โฃ) i
assoc2 (squash x y i) = propTruncIsProp (assoc2 x) (assoc2 y) i
โ-idem : (P : hProp โ) โ P โ P โก P
โ-idem P =
โโถ (โ-elim P P (\ _ โ P) (\ x โ x) (\ x โ x))
โโถ inl
โ-comm : (P : hProp โ) (Q : hProp โ') โ P โ Q โก Q โ P
โ-comm P Q =
โโถ (โ-elim P Q (\ _ โ (Q โ P)) inr inl)
โโถ (โ-elim Q P (\ _ โ (P โ Q)) inr inl)
โ-identityหก : (P : hProp โ) โ โฅ โ P โก P
โ-identityหก P =
โโถ (โ-elim โฅ P (ฮป _ โ P) (ฮป ()) (ฮป x โ x))
โโถ inr
โ-identityสณ : (P : hProp โ) โ P โ โฅ โก P
โ-identityสณ P = โtoPath (โ-elim P โฅ (ฮป _ โ P) (ฮป x โ x) ฮป ()) inl
--------------------------------------------------------------------------------
-- (hProp, โ, โค) is a bounded โ-lattice
โ-assoc : (P : hProp โ) (Q : hProp โ') (R : hProp โ'')
โ P โ Q โ R โก (P โ Q) โ R
โ-assoc _ _ _ =
โโถ (ฮป {(x , (y , z)) โ (x , y) , z})
โโถ (ฮป {((x , y) , z) โ x , (y , z) })
โ-comm : (P : hProp โ) (Q : hProp โ') โ P โ Q โก Q โ P
โ-comm _ _ = โtoPath ร.swap ร.swap
โ-idem : (P : hProp โ) โ P โ P โก P
โ-idem _ = โtoPath projโ (ฮป x โ x , x)
โ-identityหก : (P : hProp โ) โ โค โ P โก P
โ-identityหก _ = โtoPath projโ ฮป x โ tt , x
โ-identityสณ : (P : hProp โ) โ P โ โค โก P
โ-identityสณ _ = โtoPath projโ ฮป x โ x , tt
--------------------------------------------------------------------------------
-- Distributive laws
โ-โ-distrib : (P : hProp โ) (Q : hProp โ')(R : hProp โ'')
โ P โ (Q โ R) โก (P โ Q) โ (P โ R)
โ-โ-distrib _ _ _ =
โโถ (ฮป f โ (projโ โ f) , (projโ โ f))
โโถ (ฮป { (f , g) x โ f x , g x})
โ-โ-distribหก : (P : hProp โ) (Q : hProp โ')(R : hProp โ'')
โ P โ (Q โ R) โก (P โ Q) โ (P โ R)
โ-โ-distribหก P Q R =
โโถ (ฮป { (x , a) โ โ-elim Q R (ฮป _ โ (P โ Q) โ (P โ R))
(ฮป y โ โฃ โ.inl (x , y) โฃ )
(ฮป z โ โฃ โ.inr (x , z) โฃ ) a })
โโถ โ-elim (P โ Q) (P โ R) (ฮป _ โ P โ Q โ R)
(ฮป y โ projโ y , inl (projโ y))
(ฮป z โ projโ z , inr (projโ z))
โ-โ-distribหก : (P : hProp โ) (Q : hProp โ')(R : hProp โ'')
โ P โ (Q โ R) โก (P โ Q) โ (P โ R)
โ-โ-distribหก P Q R =
โโถ โ-elim P (Q โ R) (ฮป _ โ (P โ Q) โ (P โ R) )
(ร.intro inl inl) (ร.map inr inr)
โโถ (ฮป { (x , y) โ โ-elim P R (ฮป _ โ P โ Q โ R) inl
(ฮป z โ โ-elim P Q (ฮป _ โ P โ Q โ R) inl (ฮป y โ inr (y , z)) x) y })
โ-โ-distrib : (P : A โ hProp โ) (Q : A โ hProp โ')
โ (โ[ a โถ A ] P a) โ (โ[ a โถ A ] Q a) โก (โ[ a โถ A ] (P a โ Q a))
โ-โ-distrib P Q =
โโถ (ฮป {(p , q) a โ p a , q a})
โโถ ฮป pq โ (projโ โ pq ) , (projโ โ pq)
| {
"alphanum_fraction": 0.400122474,
"avg_line_length": 29.5833333333,
"ext": "agda",
"hexsha": "eca0c29eb0a8fc06035da96c0c1b478b83003215",
"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/Logic.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/Logic.agda",
"max_line_length": 97,
"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/Logic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3809,
"size": 8165
} |
module Monads.WriterT where
open import Class.Monad
open import Class.MonadTrans
open import Class.Monad.Except
open import Class.Monad.State
open import Class.Monad.Writer
open import Class.Monoid
open import Data.Product
open import Data.Unit.Polymorphic
open import Function
open import Level
private
variable
a : Level
A B W : Set a
WriterT : (Set a โ Set a) โ Set a โ Set a โ Set a
WriterT M W A = M (A ร W)
module _ {M : Set a โ Set a} {{_ : Monad M}} {W} {{_ : Monoid W}} where
WriterT-Monad : Monad (WriterT M W)
WriterT-Monad = record { _>>=_ = helper ; return = ฮป a โ return (a , mzero) }
where
helper : WriterT M W A โ (A โ WriterT M W B) โ WriterT M W B
helper a f = do
(a' , w) โ a
(b , w') โ f a'
return (b , w + w')
private
tell' : W โ WriterT M W โค
tell' w = return (tt , w)
listen' : WriterT M W A โ WriterT M W (A ร W)
listen' x = do
(a , w) โ x
return ((a , w) , w)
pass' : WriterT M W (A ร (W โ W)) โ WriterT M W A
pass' x = do
((a , f) , w) โ x
return (a , f w)
WriterT-MonadWriter : MonadWriter (WriterT M W) {{WriterT-Monad}} W
WriterT-MonadWriter = record { tell = tell' ; listen = listen' ; pass = pass' }
WriterT-MonadTrans : {W : Set a} {{_ : Monoid W}} โ MonadTrans (ฮป (M : Set a โ Set a) โ WriterT M W)
WriterT-MonadTrans = record { embed = ฮป x โ x >>= ฮป a โ return (a , mzero) }
module _ {M : Set a โ Set a} {{_ : Monad M}} {W} {{_ : Monoid W}} where
WriterT-MonadState : โ {S : Set a} {{_ : MonadState M S}} โ MonadState (WriterT M W) {{WriterT-Monad}} S
WriterT-MonadState = record
{ get = embed {{WriterT-MonadTrans}} get
; put = embed {{WriterT-MonadTrans}} โ put }
WriterT-MonadExcept : โ {E : Set a} {{_ : MonadExcept M E}} โ MonadExcept (WriterT M W) {{WriterT-Monad}} E
WriterT-MonadExcept = record
{ throwError = embed {{WriterT-MonadTrans}} โ throwError
; catchError = catchError }
| {
"alphanum_fraction": 0.5948144382,
"avg_line_length": 30.734375,
"ext": "agda",
"hexsha": "e6af81aa40de363e723f4d478c721cb4272a8bc2",
"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/Monads/WriterT.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/Monads/WriterT.agda",
"max_line_length": 109,
"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/Monads/WriterT.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": 675,
"size": 1967
} |
{-# OPTIONS --without-K #-}
module Pi1Cat where
-- Proving that Pi with one level of interesting 2 path structure is a
-- symmetric rig 2-groupoid
open import Level using () renaming (zero to lzero)
open import Data.Unit using (tt)
open import Data.Product using (_,_)
open import Function using (flip)
open import Categories.Category using (Category)
open import Categories.Terminal using (OneC)
open import Categories.Groupoid using (Groupoid)
open import Categories.Monoidal using (Monoidal)
open import Categories.Monoidal.Helpers using (module MonoidalHelperFunctors)
open import Categories.Functor using (Functor)
open import Categories.Bifunctor using (Bifunctor)
open import Categories.NaturalIsomorphism using (NaturalIsomorphism)
open import Categories.Monoidal.Braided using (Braided)
open import Categories.Monoidal.Symmetric using (Symmetric)
open import Categories.RigCategory
using (RigCategory; module BimonoidalHelperFunctors)
open import Categories.Bicategory using (Bicategory)
open import PiU using (U; PLUS; ZERO; TIMES; ONE)
open import PiLevel0
using (_โท_; idโท; _โ_;
!; !!;
_โ_;
uniteโl; unitiโl; uniteโr; unitiโr;
swapโ;
assocrโ; assoclโ;
_โ_;
uniteโl; unitiโl; uniteโr; unitiโr;
swapโ;
assocrโ; assoclโ;
absorbl; absorbr; factorzl; factorzr;
dist; factor; distl; factorl)
open import PiLevel1 using (_โ_; โEquiv; trivโก; trivโกEquiv; 2!;
idโ; transโ; _โก_;
assocโl; idrโl; idlโl; linvโl; rinvโl;
idโทโidโทโ; homโโโ; respโโ;
uniteโlโr; unitiโlโr; uniteโrโr; unitiโrโr;
assocrโr; assoclโl; triangleโl; pentagonโl;
idโทโidโทโ; homโโโ; respโโ;
uniterโโl; unitirโโl; uniterโโr; unitirโโr;
assocrโr; assoclโl; triangleโl; pentagonโl;
swaprโโ; uniteโl-coh-l; hexagonrโl; hexagonlโl;
swaprโโ; uniteโl-coh-l; hexagonrโl; hexagonlโl;
absorblโl; factorzrโl; absorbrโl; factorzlโl;
distlโl; factorlโl; distโl; factorโl;
swapโdistlโl; dist-swapโโl; assoclโ-dist-distโl; assoclโ-distlโl;
fully-distributeโl; absorbr0-absorbl0โ; absorbrโdistl-absorb-unite;
uniteโr0-absorbr1โ; absorblโกswapโโabsorbr;
absorbrโ[assoclโโ[absorbrโidโท]]โabsorbr;
[idโทโabsorbr]โabsorblโassoclโโ[absorblโidโท]โabsorbr;
elimโฅ-A[0โB]โl; elimโฅ-1[AโB]โl;
-- for bicategory
idrโr; idlโr; assocโr
)
------------------------------------------------------------------------------
-- Pi1 is a category...
Pi1Cat : Category lzero lzero lzero
Pi1Cat = record
{ Obj = U
; _โ_ = _โท_
; _โก_ = _โ_
; id = idโท
; _โ_ = ฮป yโทz xโทy โ xโทy โ yโทz
; assoc = assocโl
; identityหก = idrโl
; identityสณ = idlโl
; equiv = โEquiv
; โ-resp-โก = ฮป f g โ g โก f
}
-- and a groupoid ...
Pi1Groupoid : Groupoid Pi1Cat
Pi1Groupoid = record
{ _โปยน = !
; iso = record { isoหก = linvโl ; isoสณ = rinvโl }
}
-- additive bifunctor and monoidal structure
โ-bifunctor : Bifunctor Pi1Cat Pi1Cat Pi1Cat
โ-bifunctor = record
{ Fโ = ฮป {(u , v) โ PLUS u v}
; Fโ = ฮป {(xโทy , zโทw) โ xโทy โ zโทw }
; identity = idโทโidโทโ
; homomorphism = homโโโ
; F-resp-โก = ฮป {(x , y) โ respโโ x y}
}
module โh = MonoidalHelperFunctors Pi1Cat โ-bifunctor ZERO
-- note how powerful linvโl/rinvโl are in iso below
0โxโกx : NaturalIsomorphism โh.idโx โh.x
0โxโกx = record
{ FโG = record { ฮท = ฮป X โ uniteโl ; commute = ฮป f โ uniteโlโr }
; FโG = record { ฮท = ฮป X โ unitiโl ; commute = ฮป f โ unitiโlโr }
; iso = ฮป X โ record { isoหก = linvโl; isoสณ = rinvโl }
}
xโ0โกx : NaturalIsomorphism โh.xโid โh.x
xโ0โกx = record
{ FโG = record { ฮท = ฮป X โ uniteโr ; commute = ฮป f โ uniteโrโr }
; FโG = record { ฮท = ฮป X โ unitiโr ; commute = ฮป f โ unitiโrโr }
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
[xโy]โzโกxโ[yโz] : NaturalIsomorphism โh.[xโy]โz โh.xโ[yโz]
[xโy]โzโกxโ[yโz] = record
{ FโG = record
{ ฮท = ฮป X โ assocrโ
; commute = ฮป f โ assocrโr
}
; FโG = record
{ ฮท = ฮป X โ assoclโ
; commute = ฮป f โ assoclโl
}
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
-- and a monoidal category (additive)
Mโ : Monoidal Pi1Cat
Mโ = record
{ โ = โ-bifunctor
; id = ZERO
; identityหก = 0โxโกx
; identityสณ = xโ0โกx
; assoc = [xโy]โzโกxโ[yโz]
; triangle = triangleโl
; pentagon = pentagonโl
}
-- multiplicative bifunctor and monoidal structure
โ-bifunctor : Bifunctor Pi1Cat Pi1Cat Pi1Cat
โ-bifunctor = record
{ Fโ = ฮป {(u , v) โ TIMES u v}
; Fโ = ฮป {(xโทy , zโทw) โ xโทy โ zโทw }
; identity = idโทโidโทโ
; homomorphism = homโโโ
; F-resp-โก = ฮป {(x , y) โ respโโ x y}
}
module รh = MonoidalHelperFunctors Pi1Cat โ-bifunctor ONE
1โxโกx : NaturalIsomorphism รh.idโx รh.x
1โxโกx = record
{ FโG = record
{ ฮท = ฮป X โ uniteโl
; commute = ฮป f โ uniterโโl }
; FโG = record
{ ฮท = ฮป X โ unitiโl
; commute = ฮป f โ unitirโโl }
; iso = ฮป X โ record { isoหก = linvโl; isoสณ = rinvโl }
}
xโ1โกx : NaturalIsomorphism รh.xโid รh.x
xโ1โกx = record
{ FโG = record
{ ฮท = ฮป X โ uniteโr
; commute = ฮป f โ uniterโโr
}
; FโG = record
{ ฮท = ฮป X โ unitiโr
; commute = ฮป f โ unitirโโr
}
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
[xโy]โzโกxโ[yโz] : NaturalIsomorphism รh.[xโy]โz รh.xโ[yโz]
[xโy]โzโกxโ[yโz] = record
{ FโG = record
{ ฮท = ฮป X โ assocrโ
; commute = ฮป f โ assocrโr
}
; FโG = record
{ ฮท = ฮป X โ assoclโ
; commute = ฮป f โ assoclโl
}
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
-- and a monoidal category (multiplicative)
Mโ : Monoidal Pi1Cat
Mโ = record
{ โ = โ-bifunctor
; id = ONE
; identityหก = 1โxโกx
; identityสณ = xโ1โกx
; assoc = [xโy]โzโกxโ[yโz]
; triangle = triangleโl
; pentagon = pentagonโl
}
xโyโกyโx : NaturalIsomorphism โh.xโy โh.yโx
xโyโกyโx = record
{ FโG = record { ฮท = ฮป X โ swapโ ; commute = ฮป f โ swaprโโ }
; FโG = record { ฮท = ฮป X โ swapโ ; commute = ฮป f โ swaprโโ }
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl } }
BMโ : Braided Mโ
BMโ = record
{ braid = xโyโกyโx
; unit-coh = uniteโl-coh-l
; hexagonโ = hexagonrโl
; hexagonโ = hexagonlโl
}
xโyโกyโx : NaturalIsomorphism รh.xโy รh.yโx
xโyโกyโx = record
{ FโG = record { ฮท = ฮป X โ swapโ ; commute = ฮป f โ swaprโโ }
; FโG = record { ฮท = ฮป X โ swapโ ; commute = ฮป f โ swaprโโ }
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl } }
BMโ : Braided Mโ
BMโ = record
{ braid = xโyโกyโx
; unit-coh = uniteโl-coh-l
; hexagonโ = hexagonrโl
; hexagonโ = hexagonlโl
}
-- with both monoidal structures being symmetric
SBMโ : Symmetric BMโ
SBMโ = record { symmetry = linvโl }
SBMโ : Symmetric BMโ
SBMโ = record { symmetry = rinvโl }
module r = BimonoidalHelperFunctors BMโ BMโ
xโ0โก0 : NaturalIsomorphism r.xโ0 r.0โ
xโ0โก0 = record
{ FโG = record
{ ฮท = ฮป X โ absorbl
; commute = ฮป f โ absorblโl
}
; FโG = record
{ ฮท = ฮป X โ factorzr
; commute = ฮป f โ factorzrโl
}
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
0โxโก0 : NaturalIsomorphism r.0โx r.0โ
0โxโก0 = record
{ FโG = record { ฮท = ฮป X โ absorbr ; commute = ฮป f โ absorbrโl }
; FโG = record { ฮท = ฮป X โ factorzl ; commute = ฮป f โ factorzlโl }
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
xโ[yโz]โก[xโy]โ[xโz] : NaturalIsomorphism r.xโ[yโz] r.[xโy]โ[xโz]
xโ[yโz]โก[xโy]โ[xโz] = record
{ FโG = record { ฮท = ฮป _ โ distl ; commute = ฮป f โ distlโl }
; FโG = record { ฮท = ฮป _ โ factorl ; commute = ฮป f โ factorlโl }
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
[xโy]โzโก[xโz]โ[yโz] : NaturalIsomorphism r.[xโy]โz r.[xโz]โ[yโz]
[xโy]โzโก[xโz]โ[yโz] = record
{ FโG = record { ฮท = ฮป X โ dist ; commute = ฮป f โ distโl }
; FโG = record { ฮท = ฮป X โ factor ; commute = ฮป f โ factorโl }
; iso = ฮป X โ record { isoหก = linvโl ; isoสณ = rinvโl }
}
-- and the multiplicative structure distributing over the additive one
Pi1Rig : RigCategory SBMโ SBMโ
Pi1Rig = record
{ distribโ = xโ[yโz]โก[xโy]โ[xโz]
; distribแตฃ = [xโy]โzโก[xโz]โ[yโz]
; annโ = 0โxโก0
; annแตฃ = xโ0โก0
; laplazaI = swapโdistlโl
; laplazaII = dist-swapโโl
; laplazaIV = assoclโ-dist-distโl
; laplazaVI = assoclโ-distlโl
; laplazaIX = fully-distributeโl
; laplazaX = absorbr0-absorbl0โ
; laplazaXI = absorbrโdistl-absorb-unite
; laplazaXIII = uniteโr0-absorbr1โ
; laplazaXV = absorblโกswapโโabsorbr
; laplazaXVI = absorbrโ[assoclโโ[absorbrโidโท]]โabsorbr
; laplazaXVII = [idโทโabsorbr]โabsorblโassoclโโ[absorblโidโท]โabsorbr
; laplazaXIX = elimโฅ-A[0โB]โl
; laplazaXXIII = elimโฅ-1[AโB]โl
}
------------------------------------------------------------------------------
-- The morphisms of the Pi1 category have structure; they form a
-- category, something like another Symmetric Rig Groupoid but more
-- general
โทCat : (tโ tโ : U) โ Category lzero lzero lzero
โทCat tโ tโ = record
{ Obj = tโ โท tโ
; _โ_ = _โ_
; _โก_ = trivโก
; id = idโ
; _โ_ = flip transโ
; assoc = tt
; identityหก = tt
; identityสณ = tt
; equiv = trivโกEquiv
; โ-resp-โก = ฮป _ _ โ tt
}
โทGroupoid : (tโ tโ : U) โ Groupoid (โทCat tโ tโ)
โทGroupoid tโ tโ = record
{ _โปยน = 2!
; iso = record { isoหก = tt ; isoสณ = tt }
}
-- These feel like the right notions of bifunctor but of course they
-- are relating different categories so the rest of the development to
-- RigCategory would need to be generalized if we were to use these
-- definitions of bifunctors.
โโท-bifunctor : (tโ tโ tโ tโ : U) โ
Bifunctor (โทCat tโ tโ) (โทCat tโ tโ) (โทCat (PLUS tโ tโ) (PLUS tโ tโ))
โโท-bifunctor tโ tโ tโ tโ = record
{ Fโ = ฮป {(f , g) โ f โ g }
; Fโ = ฮป {(ฮฑ , ฮฒ) โ respโโ ฮฑ ฮฒ }
; identity = tt
; homomorphism = tt
; F-resp-โก = ฮป _ โ tt
}
โโท-bifunctor : (tโ tโ tโ tโ : U) โ
Bifunctor (โทCat tโ tโ) (โทCat tโ tโ) (โทCat (TIMES tโ tโ) (TIMES tโ tโ))
โโท-bifunctor tโ tโ tโ tโ = record
{ Fโ = ฮป {(f , g) โ f โ g }
; Fโ = ฮป {(ฮฑ , ฮฒ) โ respโโ ฮฑ ฮฒ }
; identity = tt
; homomorphism = tt
; F-resp-โก = ฮป _ โ tt
}
------------------------------------------------------------------------------
-- We have a 2-category but NOT a strict one.
idF : {t : U} โ Functor {lzero} {lzero} {lzero} OneC (โทCat t t)
idF {t} = record
{ Fโ = ฮป _ โ idโท {t}
; Fโ = ฮป _ โ idโ
; identity = tt
; homomorphism = tt
; F-resp-โก = ฮป _ โ tt
}
โ-bifunctor : {tโ tโ tโ : U} โ Bifunctor (โทCat tโ tโ) (โทCat tโ tโ) (โทCat tโ tโ)
โ-bifunctor = record
{ Fโ = ฮป {(f , g) โ g โ f}
; Fโ = ฮป {(ฮฑ , ฮฒ) โ ฮฒ โก ฮฑ}
; identity = tt
; homomorphism = tt
; F-resp-โก = ฮป _ โ tt
}
Pi1-Bicat : Bicategory lzero lzero lzero lzero
Pi1-Bicat = record
{ Obj = U
; _โ_ = โทCat
; id = idF
; โโโ = โ-bifunctor
; ฮปแตค = record
{ FโG = record { ฮท = ฮป X โ idrโl ; commute = ฮป {f โ tt} }
; FโG = record { ฮท = ฮป X โ idrโr ; commute = ฮป {X} {Y} f โ tt }
; iso = ฮป X โ record { isoหก = tt ; isoสณ = tt }
}
; ฯแตค = record
{ FโG = record { ฮท = ฮป X โ idlโl ; commute = ฮป {X} {Y} f โ tt }
; FโG = record { ฮท = ฮป X โ idlโr ; commute = ฮป {X} {Y} f โ tt }
; iso = ฮป X โ record { isoหก = tt ; isoสณ = tt }
}
; ฮฑ = record
{ FโG = record { ฮท = ฮป _ โ assocโr ; commute = ฮป {X} {Y} f โ tt }
; FโG = record { ฮท = ฮป _ โ assocโl ; commute = ฮป {X} {Y} f โ tt }
; iso = ฮป X โ record { isoหก = tt ; isoสณ = tt }
}
; triangle = ฮป {A} {B} {C} f g โ tt
; pentagon = ฮป {A} {B} {C} {D} {E} f g h i โ tt
}
{--
Here is why Pi1 is NOT a strict 2-Category:
Pi1-2Cat : 2-Category lzero lzero lzero lzero
Pi1-2Cat = record
{ Obj = U
; _โ_ = โทCat
; id = idF
; โโโ = โ-bifunctor
; assoc = {!!}
; identityหก = {!!} }
The definition of 2-Category is STRICT, which means that for proof of
identityหก requires the following diagram to commute:
Assume the following 1-paths:
cโ cโ : A โท B
id_B : B โท B
and the following 2-paths:
ฮฑ : cโ โ cโ
id_id_B : id_B โ id_B
We can construct the 2-path:
ฮฑ โก id_id_B : cโ โ id_B โ cโ โ id_B
The property identityหก requires that there is a 3-path between
ฮฑ and ฮฑ โก id_id_B
and indeed there are "equivalent" in some sense as:
ฮฑ โก id_id_B : cโ โ id_B โ cโ โ id_B
can be viewed as having the equivalent type:
ฮฑ โก id_id_B : cโ โ cโ
and we identify all 2-paths of the same type.
This reasoning however requires that identityหก is asserted up to the
2-paths relating cโ โ id_B and cโ on one hand and cโ โ id_B and cโ on
the other hand.
Formally the nlab page http://ncatlab.org/nlab/show/2-category
explains this as follows:
For some purposes, strict 2-categories are too strict: one would
like to allow composition of morphisms to be associative and unital
only up to coherent invertible 2-morphisms. A direct generalization
of the above โenrichedโ definition produces the classical notion of
bicategory.
So to conclude what we really need is a weak version of 2-Category
which is known as 'bicategory'.
--}
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.5705078428,
"avg_line_length": 27.9349240781,
"ext": "agda",
"hexsha": "e7029ce091e2f175df05c9e80722b241d768da8d",
"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/Pi1Cat.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/Pi1Cat.agda",
"max_line_length": 79,
"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/Pi1Cat.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": 6247,
"size": 12878
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Sums of nullary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Nullary.Sum where
open import Data.Sum
open import Data.Empty
open import Level
open import Relation.Nullary
-- Some properties which are preserved by _โ_.
infixr 1 _ยฌ-โ_ _โ-dec_
_ยฌ-โ_ : โ {p q} {P : Set p} {Q : Set q} โ
ยฌ P โ ยฌ Q โ ยฌ (P โ Q)
(ยฌp ยฌ-โ ยฌq) (injโ p) = ยฌp p
(ยฌp ยฌ-โ ยฌq) (injโ q) = ยฌq q
_โ-dec_ : โ {p q} {P : Set p} {Q : Set q} โ
Dec P โ Dec Q โ Dec (P โ Q)
yes p โ-dec _ = yes (injโ p)
_ โ-dec yes q = yes (injโ q)
no ยฌp โ-dec no ยฌq = no helper
where
helper : _ โ _ โ โฅ
helper (injโ p) = ยฌp p
helper (injโ q) = ยฌq q
| {
"alphanum_fraction": 0.4475271411,
"avg_line_length": 24.3823529412,
"ext": "agda",
"hexsha": "3705c0f35fad3f422fdfe23af7f3e972a17e7b0b",
"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/Relation/Nullary/Sum.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/Relation/Nullary/Sum.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Sum.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 299,
"size": 829
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties related to addition of integers
------------------------------------------------------------------------
module Data.Integer.Addition.Properties where
open import Algebra
import Algebra.FunctionProperties
open import Algebra.Structures
open import Data.Integer hiding (suc)
open import Data.Nat using (suc; zero) renaming (_+_ to _โ+_)
import Data.Nat.Properties as โ
open import Relation.Binary.PropositionalEquality
open Algebra.FunctionProperties (_โก_ {A = โค})
open CommutativeSemiring โ.commutativeSemiring
using (+-comm; +-assoc; +-identity)
------------------------------------------------------------------------
-- Addition and zero form a commutative monoid
private
comm : Commutative _+_
comm -[1+ a ] -[1+ b ] rewrite +-comm a b = refl
comm (+ a ) (+ b ) rewrite +-comm a b = refl
comm -[1+ _ ] (+ _ ) = refl
comm (+ _ ) -[1+ _ ] = refl
identityหก : LeftIdentity (+ 0) _+_
identityหก -[1+ _ ] = refl
identityหก (+ _ ) = refl
identityสณ : RightIdentity (+ 0) _+_
identityสณ x rewrite comm x (+ 0) = identityหก x
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สณ-โ-+-neg : โ a b c โ -[1+ a ] + (b โ c) โก b โ (suc a โ+ c)
distribสณ-โ-+-neg a b c
rewrite comm -[1+ a ] (b โ c)
| distribหก-โ-+-neg a b c
| +-comm a c
= refl
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สณ-โ-+-pos : โ a b c โ + a + (b โ c) โก a โ+ b โ c
distribสณ-โ-+-pos a b c
rewrite comm (+ a) (b โ c)
| distribหก-โ-+-pos a b c
| +-comm a b
= refl
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
isSemigroup : IsSemigroup _โก_ _+_
isSemigroup = record
{ isEquivalence = isEquivalence
; assoc = assoc
; โ-cong = congโ _+_
}
isCommutativeMonoid : IsCommutativeMonoid _โก_ _+_ (+ 0)
isCommutativeMonoid = record
{ isSemigroup = isSemigroup
; identityหก = identityหก
; comm = comm
}
commutativeMonoid : CommutativeMonoid _ _
commutativeMonoid = record
{ Carrier = โค
; _โ_ = _โก_
; _โ_ = _+_
; ฮต = + 0
; isCommutativeMonoid = isCommutativeMonoid
}
| {
"alphanum_fraction": 0.4994761655,
"avg_line_length": 32.3559322034,
"ext": "agda",
"hexsha": "d4cd9c311f5743ab0cdab3bb2b8a63f1578051d9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.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": 1430,
"size": 3818
} |
module Structure.Operator.Vector.Proofs where
open import Data.Tuple
open import Functional
open import Function.Equals
import Lvl
open import Logic
open import Logic.Propositional
open import Logic.Predicate
open import Structure.Setoid
open import Structure.Operator
open import Structure.Operator.Field
open import Structure.Operator.Group
open import Structure.Operator.Monoid
import Structure.Operator.Names as Names
open import Structure.Operator.Proofs
open import Structure.Operator.Properties
open import Structure.Operator.Vector
open import Structure.Relator.Properties
open import Syntax.Transitivity
open import Type
module _
{โแตฅ โโ โแตฅโ โโโ : Lvl.Level}
{V : Type{โแตฅ}}
โฆ equiv-V : Equiv{โแตฅโ}(V) โฆ
{S : Type{โโ}}
โฆ equiv-S : Equiv{โโโ}(S) โฆ
{_+แตฅ_ : V โ V โ V}
{_โ
โแตฅ_ : S โ V โ V}
{_+โ_ _โ
โ_ : S โ S โ S}
where
module _ โฆ vectorSpace : VectorSpace(_+แตฅ_)(_โ
โแตฅ_)(_+โ_)(_โ
โ_) โฆ where
open VectorSpace(vectorSpace)
[โ
โแตฅ]-absorberโ : โ{v} โ (๐โ โ
โแตฅ v โก ๐แตฅ)
[โ
โแตฅ]-absorberโ {v} = cancellationแตฃ(_+แตฅ_) โฆ One.cancellationแตฃ-by-associativity-inverse โฆ $
(๐โ โ
โแตฅ v) +แตฅ (๐โ โ
โแตฅ v) ๐-[ [โ
โแตฅ][+โ][+แตฅ]-distributivityแตฃ ]-sym
(๐โ +โ ๐โ) โ
โแตฅ v ๐-[ congruenceโโ(_โ
โแตฅ_)(v) (identityโ(_+โ_)(๐โ)) ]
๐โ โ
โแตฅ v ๐-[ identityโ(_+แตฅ_)(๐แตฅ) ]-sym
๐แตฅ +แตฅ (๐โ โ
โแตฅ v) ๐-end
[โ
โแตฅ]-absorberแตฃ : โ{s} โ (s โ
โแตฅ ๐แตฅ โก ๐แตฅ)
[โ
โแตฅ]-absorberแตฃ {s} = cancellationแตฃ(_+แตฅ_) โฆ One.cancellationแตฃ-by-associativity-inverse โฆ $
(s โ
โแตฅ ๐แตฅ) +แตฅ (s โ
โแตฅ ๐แตฅ) ๐-[ distributivityโ(_โ
โแตฅ_)(_+แตฅ_) ]-sym
s โ
โแตฅ (๐แตฅ +แตฅ ๐แตฅ) ๐-[ congruenceโแตฃ(_โ
โแตฅ_)(s) (identityโ(_+แตฅ_)(๐แตฅ)) ]
s โ
โแตฅ ๐แตฅ ๐-[ identityโ(_+แตฅ_)(๐แตฅ) ]-sym
๐แตฅ +แตฅ (s โ
โแตฅ ๐แตฅ) ๐-end
[โ
โแตฅ]-negation : โ{v} โ ((โโ ๐โ) โ
โแตฅ v โก โแตฅ v)
[โ
โแตฅ]-negation {v} = _โ_.proof (One.unique-inverseFunctionแตฃ-by-id (intro p) [+แตฅ]-inverseแตฃ) {v} where
p : Names.InverseFunctionแตฃ(_+แตฅ_) ๐แตฅ ((โโ ๐โ) โ
โแตฅ_)
p{v} =
v +แตฅ ((โโ ๐โ) โ
โแตฅ v) ๐-[ congruenceโโ(_+แตฅ_) _ (identityโ(_โ
โแตฅ_)(๐โ)) ]-sym
(๐โ โ
โแตฅ v) +แตฅ ((โโ ๐โ) โ
โแตฅ v) ๐-[ [โ
โแตฅ][+โ][+แตฅ]-distributivityแตฃ ]-sym
(๐โ +โ (โโ ๐โ))โ
โแตฅ v ๐-[ congruenceโโ(_โ
โแตฅ_) v (inverseFunctionแตฃ(_+โ_) โฆ [โ]-intro _ โฆ [+โ]-identityแตฃ โฆ โฆ (โโ_)) ]
๐โ โ
โแตฅ v ๐-[ [โ
โแตฅ]-absorberโ ]
๐แตฅ ๐-end
| {
"alphanum_fraction": 0.5802105263,
"avg_line_length": 39.5833333333,
"ext": "agda",
"hexsha": "9223da403506565149a14e1112ea3af66e739fd9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Operator/Vector/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Operator/Vector/Proofs.agda",
"max_line_length": 131,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Operator/Vector/Proofs.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 1399,
"size": 2375
} |
-- ASR (2016-02-15). In the Makefile in test/compiler founded in the
-- 2.4.2.3 tag, this test used the options `+RTS -H1G -M1.5G -RTS`.
module AllStdLib where
-- Ensure that the entire standard library is compiled.
import README
open import Data.Unit.Base
open import Data.String
open import IO
import IO.Primitive as Prim
main : Prim.IO โค
main = run (putStrLn "Hello World!")
| {
"alphanum_fraction": 0.7329842932,
"avg_line_length": 23.875,
"ext": "agda",
"hexsha": "884a624af40439bc909ac23b190e6f074545c039",
"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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Compiler/with-stdlib/AllStdLib.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/Compiler/with-stdlib/AllStdLib.agda",
"max_line_length": 68,
"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/Compiler/with-stdlib/AllStdLib.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 114,
"size": 382
} |
module maybe where
open import level
open import eq
open import bool
----------------------------------------------------------------------
-- datatypes
----------------------------------------------------------------------
data maybe {โ}(A : Set โ) : Set โ where
just : A โ maybe A
nothing : maybe A
----------------------------------------------------------------------
-- operations
----------------------------------------------------------------------
_โซ=maybe_ : โ {โ}{A B : Set โ} โ maybe A โ (A โ maybe B) โ maybe B
nothing โซ=maybe f = nothing
(just x) โซ=maybe f = f x
return-maybe : โ {โ}{A : Set โ} โ A โ maybe A
return-maybe a = just a
down-โก : โ{โ}{A : Set โ}{a a' : A} โ just a โก just a' โ a โก a'
down-โก refl = refl
isJust : โ{โ}{A : Set โ} โ maybe A โ ๐น
isJust nothing = ff
isJust (just _) = tt
maybe-extract : โ{โ}{A : Set โ} โ (x : maybe A) โ isJust x โก tt โ A
maybe-extract (just x) p = x
maybe-extract nothing ()
maybe-map : โ{โ}{A B : Set โ} โ (A โ B) โ maybe A โ maybe B
maybe-map f (just x) = just (f x)
maybe-map f nothing = nothing | {
"alphanum_fraction": 0.4307116105,
"avg_line_length": 27.3846153846,
"ext": "agda",
"hexsha": "dc93983dd928ef4f4f9b7e8c87d264ede3505463",
"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": "maybe.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": "maybe.agda",
"max_line_length": 70,
"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": "maybe.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 320,
"size": 1068
} |
{-# OPTIONS --without-K --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Properties.Reduction {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.RedSteps
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Properties.Reflexivity
open import Definition.LogicalRelation.Properties.Universe
open import Definition.LogicalRelation.Properties.Escape
open import Tools.Embedding
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Weak head expansion of reducible types.
redSubst* : โ {A B l ฮ}
โ ฮ โข A โ* B
โ ฮ โฉโจ l โฉ B
โ โ ฮป ([A] : ฮ โฉโจ l โฉ A)
โ ฮ โฉโจ l โฉ A โก B / [A]
redSubst* D (Uแตฃโฒ lโฒ l< โขฮ) rewrite redU* D =
Uแตฃโฒ lโฒ l< โขฮ , Uโ PE.refl
redSubst* D (โแตฃ [ โขB , โขโ , Dโฒ ]) =
let โขA = redFirst* D
in โแตฃ ([ โขA , โขโ , D โจ* Dโฒ ]) , ฮนx (โโ Dโฒ)
redSubst* D (neโฒ K [ โขB , โขK , Dโฒ ] neK KโกK) =
let โขA = redFirst* D
in (neโฒ K [ โขA , โขK , D โจ* Dโฒ ] neK KโกK)
, ฮนx (neโ _ [ โขB , โขK , Dโฒ ] neK KโกK)
redSubst* D (ฮ แตฃโฒ F G [ โขB , โขฮ FG , Dโฒ ] โขF โขG AโกA [F] [G] G-ext) =
let โขA = redFirst* D
in (ฮ แตฃโฒ F G [ โขA , โขฮ FG , D โจ* Dโฒ ] โขF โขG AโกA [F] [G] G-ext)
, (ฮ โ _ _ Dโฒ AโกA (ฮป ฯ โขฮ โ reflEq ([F] ฯ โขฮ))
(ฮป ฯ โขฮ [a] โ reflEq ([G] ฯ โขฮ [a])))
redSubst* D (embโฒ 0<1 x) with redSubst* D x
redSubst* D (embโฒ 0<1 x) | y , yโ = embโฒ 0<1 y , ฮนx yโ
-- Weak head expansion of reducible terms.
redSubst*Term : โ {A t u l ฮ}
โ ฮ โข t โ* u โท A
โ ([A] : ฮ โฉโจ l โฉ A)
โ ฮ โฉโจ l โฉ u โท A / [A]
โ ฮ โฉโจ l โฉ t โท A / [A]
ร ฮ โฉโจ l โฉ t โก u โท A / [A]
redSubst*Term tโu (Uแตฃโฒ .โฐ 0<1 โขฮ) (Uโ A [ โขt , โขu , d ] typeA AโกA [u]) =
let [d] = [ โขt , โขu , d ]
[dโฒ] = [ redFirst*Term tโu , โขu , tโu โจโท* d ]
q = redSubst* (univ* tโu) (univEq (Uแตฃโฒ โฐ 0<1 โขฮ) (Uโ A [d] typeA AโกA [u]))
in Uโ A [dโฒ] typeA AโกA (projโ q)
, Uโโ A A [dโฒ] [d] typeA typeA AโกA (projโ q) [u] (projโ q)
redSubst*Term tโu (โแตฃ D) (ฮนx (โโ n [ โขu , โขn , d ] nโกn prop)) =
let Aโกโ = subset* (red D)
โขt = conv (redFirst*Term tโu) Aโกโ
tโuโฒ = conv* tโu Aโกโ
in ฮนx (โโ n [ โขt , โขn , tโuโฒ โจโท* d ] nโกn prop)
, ฮนx (โโโ n n [ โขt , โขn , tโuโฒ โจโท* d ] [ โขu , โขn , d ]
nโกn (reflNatural-prop prop))
redSubst*Term tโu (neโฒ K D neK KโกK) (ฮนx (neโ k [ โขt , โขu , d ] (neNfโ neKโ โขk kโกk))) =
let AโกK = subset* (red D)
[d] = [ โขt , โขu , d ]
[dโฒ] = [ conv (redFirst*Term tโu) AโกK , โขu , conv* tโu AโกK โจโท* d ]
in ฮนx (neโ k [dโฒ] (neNfโ neKโ โขk kโกk)) , ฮนx (neโโ k k [dโฒ] [d] (neNfโโ neKโ neKโ kโกk))
redSubst*Term {A} {t} {u} {l} {ฮ} tโu (ฮ แตฃโฒ F G D โขF โขG AโกA [F] [G] G-ext)
(ฮ โ f [ โขt , โขu , d ] funcF fโกf [f] [f]โ) =
let Aโกฮ FG = subset* (red D)
tโuโฒ = conv* tโu Aโกฮ FG
[d] = [ โขt , โขu , d ]
[dโฒ] = [ conv (redFirst*Term tโu) Aโกฮ FG , โขu , conv* tโu Aโกฮ FG โจโท* d ]
in ฮ โ f [dโฒ] funcF fโกf [f] [f]โ
, ฮ โโ f f [dโฒ] [d] funcF funcF fโกf
(ฮ โ f [dโฒ] funcF fโกf [f] [f]โ)
(ฮ โ f [d] funcF fโกf [f] [f]โ)
(ฮป [ฯ] โขฮ [a] โ reflEqTerm ([G] [ฯ] โขฮ [a]) ([f]โ [ฯ] โขฮ [a]))
redSubst*Term tโu (embโฒ 0<1 x) (ฮนx [u]) =
let x = redSubst*Term tโu x [u] in
ฮนx (projโ x) , ฮนx (projโ x)
-- Weak head expansion of reducible types with single reduction step.
redSubst : โ {A B l ฮ}
โ ฮ โข A โ B
โ ฮ โฉโจ l โฉ B
โ โ ฮป ([A] : ฮ โฉโจ l โฉ A)
โ ฮ โฉโจ l โฉ A โก B / [A]
redSubst AโB [B] = redSubst* (AโB โจ id (escape [B])) [B]
-- Weak head expansion of reducible terms with single reduction step.
redSubstTerm : โ {A t u l ฮ}
โ ฮ โข t โ u โท A
โ ([A] : ฮ โฉโจ l โฉ A)
โ ฮ โฉโจ l โฉ u โท A / [A]
โ ฮ โฉโจ l โฉ t โท A / [A]
ร ฮ โฉโจ l โฉ t โก u โท A / [A]
redSubstTerm tโu [A] [u] = redSubst*Term (tโu โจ id (escapeTerm [A] [u])) [A] [u]
| {
"alphanum_fraction": 0.4769661491,
"avg_line_length": 39.29,
"ext": "agda",
"hexsha": "e51e2cecb4c5637debdc2760cdc95800aebff4fc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "loic-p/logrel-mltt",
"max_forks_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "loic-p/logrel-mltt",
"max_issues_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda",
"max_line_length": 88,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "loic-p/logrel-mltt",
"max_stars_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2059,
"size": 3929
} |
module Preliminary where
open import Prelude public
โ_ : โ {a b} {A : Set a} (B : A โ Set b) โ Set (a โ b)
โ_ = ฮฃ _
data IsYes {a} {P : Set a} : Dec P โ Set a where
yes : (p : P) โ IsYes (yes p)
getProof : โ {a} {P : Set a} โ {d : Dec P} โ IsYes d โ P
getProof (yes p) = p
add-zero : โ n โ n โก n +N 0
add-zero zero = refl
add-zero (suc n) = cong suc (add-zero n)
_โข_ : โ {โ} {A : Set โ} โ A โ A โ Set โ
a โข b = ยฌ (a โก b)
| {
"alphanum_fraction": 0.4823788546,
"avg_line_length": 21.619047619,
"ext": "agda",
"hexsha": "bb5b5d5331f490f05cb69f77e267ea46aa50ab6b",
"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/Preliminary.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/Preliminary.agda",
"max_line_length": 58,
"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/Preliminary.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 205,
"size": 454
} |
-- Andreas, 2014-08-19, issue reported by zcarterc
-- {-# OPTIONS -v tc.meta.assign:10 -v tc.constr.findInScope:10 #-}
-- {-# OPTIONS -v tc.constr.findInScope:49 #-}
-- {-# OPTIONS --show-implicit #-}
module Issue1254 where
open import Agda.Primitive
record Inhabited {i : Level} (carrier : Set i) : Set i where
field
elem : carrier
open Inhabited {{...}}
record Wrap {i : Level} (carrier : Set i) : Set i where
field
wrap-inhabited : Inhabited carrier
instance
wrap-as-inhabited : โ {i : Level} {carrier : Set i} โ Wrap carrier โ Inhabited carrier
wrap-as-inhabited cat = Wrap.wrap-inhabited cat
postulate
Nat : Set
one : Nat
instance
monoid-Nat : Wrap Nat
monoid-Nat = record { wrap-inhabited = record { elem = one } }
-- This is what caused the crash.
op : Nat
op = elem
| {
"alphanum_fraction": 0.6687344913,
"avg_line_length": 23.7058823529,
"ext": "agda",
"hexsha": "f6a4e63425593067f60628fea27240679d7b8806",
"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/Issue1254.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/Issue1254.agda",
"max_line_length": 88,
"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/Issue1254.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": 250,
"size": 806
} |
{-# OPTIONS --cubical --no-import-sorts --safe --experimental-lossy-unification #-}
module Cubical.Algebra.Group.EilenbergMacLane1 where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.GroupoidLaws renaming (assoc to โassoc)
open import Cubical.Foundations.Path
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
open import Cubical.Data.Unit
open import Cubical.Data.Sigma
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Homotopy.Connected
open import Cubical.HITs.Truncation as Trunc renaming (rec to trRec; elim to trElim)
open import Cubical.HITs.EilenbergMacLane1
private
variable โ : Level
module _ (Gฬ : Group โ) where
private
G = fst Gฬ
open GroupStr (snd Gฬ)
emloop-id : emloop 1g โก refl
emloop-id =
emloop 1g โกโจ rUnit (emloop 1g) โฉ
emloop 1g โ refl โกโจ cong (emloop 1g โ_) (rCancel (emloop 1g) โปยน) โฉ
emloop 1g โ (emloop 1g โ (emloop 1g) โปยน) โกโจ โassoc _ _ _ โฉ
(emloop 1g โ emloop 1g) โ (emloop 1g) โปยน โกโจ cong (_โ emloop 1g โปยน)
((emloop-comp Gฬ 1g 1g) โปยน) โฉ
emloop (1g ยท 1g) โ (emloop 1g) โปยน โกโจ cong (ฮป g โ emloop {Group = Gฬ} g
โ (emloop 1g) โปยน)
(rid 1g) โฉ
emloop 1g โ (emloop 1g) โปยน โกโจ rCancel (emloop 1g) โฉ
refl โ
emloop-inv : (g : G) โ emloop (inv g) โก (emloop g) โปยน
emloop-inv g =
emloop (inv g) โกโจ rUnit (emloop (inv g)) โฉ
emloop (inv g) โ refl โกโจ cong (emloop (inv g) โ_)
(rCancel (emloop g) โปยน) โฉ
emloop (inv g) โ (emloop g โ (emloop g) โปยน) โกโจ โassoc _ _ _ โฉ
(emloop (inv g) โ emloop g) โ (emloop g) โปยน โกโจ cong (_โ emloop g โปยน)
((emloop-comp Gฬ (inv g) g) โปยน) โฉ
emloop (inv g ยท g) โ (emloop g) โปยน โกโจ cong (ฮป h โ emloop {Group = Gฬ} h
โ (emloop g) โปยน)
(invl g) โฉ
emloop 1g โ (emloop g) โปยน โกโจ cong (_โ (emloop g) โปยน) emloop-id โฉ
refl โ (emloop g) โปยน โกโจ (lUnit ((emloop g) โปยน)) โปยน โฉ
(emloop g) โปยน โ
isGroupoidEMโ : isGroupoid (EMโ Gฬ)
isGroupoidEMโ = emsquash
isConnectedEMโ : isConnected 2 (EMโ Gฬ)
isConnectedEMโ = โฃ embase โฃ , h
where
h : (y : hLevelTrunc 2 (EMโ Gฬ)) โ โฃ embase โฃ โก y
h = trElim (ฮป y โ isOfHLevelSuc 1 (isOfHLevelTrunc 2 โฃ embase โฃ y))
(elimProp Gฬ (ฮป x โ isOfHLevelTrunc 2 โฃ embase โฃ โฃ x โฃ) refl)
{- since we write composition in diagrammatic order,
and function composition in the other order,
we need right multiplication here -}
rightEquiv : (g : G) โ G โ G
rightEquiv g = isoToEquiv isom
where
isom : Iso G G
isom .Iso.fun = _ยท g
isom .Iso.inv = _ยท inv g
isom .Iso.rightInv h =
(h ยท inv g) ยท g โกโจ (assoc h (inv g) g) โปยน โฉ
h ยท inv g ยท g โกโจ cong (h ยท_) (invl g) โฉ
h ยท 1g โกโจ rid h โฉ h โ
isom .Iso.leftInv h =
(h ยท g) ยท inv g โกโจ (assoc h g (inv g)) โปยน โฉ
h ยท g ยท inv g โกโจ cong (h ยท_) (invr g) โฉ
h ยท 1g โกโจ rid h โฉ h โ
compRightEquiv : (g h : G)
โ compEquiv (rightEquiv g) (rightEquiv h) โก rightEquiv (g ยท h)
compRightEquiv g h = equivEq (funExt (ฮป x โ (assoc x g h) โปยน))
CodesSet : EMโ Gฬ โ hSet โ
CodesSet = rec Gฬ (isOfHLevelTypeOfHLevel 2) (G , is-set) RE REComp
where
RE : (g : G) โ Path (hSet โ) (G , is-set) (G , is-set)
RE g = ฮฃโกProp (ฮป X โ isPropIsOfHLevel {A = X} 2) (ua (rightEquiv g))
lemmaโ : (g h : G) โ Square
(ua (rightEquiv g)) (ua (rightEquiv (g ยท h)))
refl (ua (rightEquiv h))
lemmaโ g h = invEq
(SquareโdoubleComp (ua (rightEquiv g)) (ua (rightEquiv (g ยท h)))
refl (ua (rightEquiv h)))
(ua (rightEquiv g) โ ua (rightEquiv h)
โกโจ (uaCompEquiv (rightEquiv g) (rightEquiv h)) โปยน โฉ
ua (compEquiv (rightEquiv g) (rightEquiv h))
โกโจ cong ua (compRightEquiv g h) โฉ
ua (rightEquiv (g ยท h)) โ)
lemmaโ : {Aโโ Aโโ : hSet โ} (pโโ : Aโโ โก Aโโ)
{Aโโ Aโโ : hSet โ} (pโโ : Aโโ โก Aโโ)
(pโโ : Aโโ โก Aโโ) (pโโ : Aโโ โก Aโโ)
(s : Square (cong fst pโโ) (cong fst pโโ) (cong fst pโโ) (cong fst pโโ))
โ Square pโโ pโโ pโโ pโโ
fst (lemmaโ pโโ pโโ pโโ pโโ s i j) = s i j
snd (lemmaโ pโโ pโโ pโโ pโโ s i j) =
isSetโSquareP {A = (ฮป i j โ isSet (s i j))}
(ฮป i j โ isPropโisSet (isPropIsOfHLevel 2))
(cong snd pโโ) (cong snd pโโ) (cong snd pโโ) (cong snd pโโ) i j
REComp : (g h : G) โ Square (RE g) (RE (g ยท h)) refl (RE h)
REComp g h = lemmaโ (RE g) (RE (g ยท h)) refl (RE h) (lemmaโ g h)
Codes : EMโ Gฬ โ Type โ
Codes x = CodesSet x .fst
encode : (x : EMโ Gฬ) โ embase โก x โ Codes x
encode x p = subst Codes p 1g
decode : (x : EMโ Gฬ) โ Codes x โ embase โก x
decode = elimSet Gฬ (ฮป x โ isOfHLevelฮ 2 (ฮป c โ isGroupoidEMโ (embase) x))
emloop ฮป g โ uaโ ฮป h โ emcomp h g
decode-encode : (x : EMโ Gฬ) (p : embase โก x) โ decode x (encode x p) โก p
decode-encode x p = J (ฮป y q โ decode y (encode y q) โก q)
(emloop (transport refl 1g) โกโจ cong emloop (transportRefl 1g) โฉ
emloop 1g โกโจ emloop-id โฉ refl โ) p
encode-decode : (x : EMโ Gฬ) (c : Codes x) โ encode x (decode x c) โก c
encode-decode = elimProp Gฬ (ฮป x โ isOfHLevelฮ 1 (ฮป c โ CodesSet x .snd _ _))
ฮป g โ encode embase (decode embase g) โกโจ refl โฉ
encode embase (emloop g) โกโจ refl โฉ
transport (ua (rightEquiv g)) 1g โกโจ uaฮฒ (rightEquiv g) 1g โฉ
1g ยท g โกโจ lid g โฉ
g โ
ฮฉEMโIso : Iso (Path (EMโ Gฬ) embase embase) G
Iso.fun ฮฉEMโIso = encode embase
Iso.inv ฮฉEMโIso = emloop
Iso.rightInv ฮฉEMโIso = encode-decode embase
Iso.leftInv ฮฉEMโIso = decode-encode embase
ฮฉEMโโก : (Path (EMโ Gฬ) embase embase) โก G
ฮฉEMโโก = isoToPath ฮฉEMโIso
| {
"alphanum_fraction": 0.523217891,
"avg_line_length": 42.3618421053,
"ext": "agda",
"hexsha": "93f0566b542de71d67612d1236579e9c7b10f84e",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda",
"max_line_length": 95,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 2529,
"size": 6439
} |
data A (B : Set) : Set where
module C where
record D : Set where
module E (F : Set) (G : A F) where
open C public using (module D)
module H (I : Set) (J : A I) where
open E I J using ()
| {
"alphanum_fraction": 0.6062176166,
"avg_line_length": 21.4444444444,
"ext": "agda",
"hexsha": "913998e71ce86d724990b5d435f544ce94eb6a4e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue1282.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue1282.agda",
"max_line_length": 34,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue1282.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 69,
"size": 193
} |
module noetherian where
open import sn-calculus
open import Esterel.Lang
open import Esterel.Lang.Properties
open import Esterel.Context
open import Esterel.Context.Properties
open import Esterel.Environment
open import Esterel.Variable.Signal as Signal using (Signal)
open import Esterel.Variable.Shared as SharedVar using (SharedVar)
open import Esterel.Variable.Sequential as SeqVar using (SeqVar)
open import Data.Nat as Nat
using (โ ; zero ; suc ; _+_ ; _>_ ; _โคโฒ_ ; _โค_ ; _*_ ; โคโฒ-refl)
open import Data.Nat.Properties
using (sโคโฒs ; zโคโฒn ; mโคโฒm+n ; nโคโฒm+n ; โคโpredโค)
open import Data.Nat.Properties.Simple using (+-comm ; +-assoc ; +-suc)
open import Data.MoreNatProp
open import Data.Sum as Sum using (injโ ; injโ ; _โ_)
open import Data.Maybe using (just ; nothing)
open import Data.Product using (_ร_ ; _,_ ; _,โฒ_ ; projโ)
open import Agda.Builtin.Equality using (refl ; _โก_)
open import Data.List using (List ; _โท_ ; [])
open import Data.Bool using (Bool ; true ; false)
open import Relation.Nullary.Decidable using (โ_โ)
open import Relation.Nullary
using (Dec ; yes ; no ; ยฌ_)
open import Relation.Binary.PropositionalEquality
using (sym ; inspect ; Reveal_ยท_is_ ; trans ; cong)
open import Data.Empty using (โฅ-elim ; โฅ)
SM = SigMap.Map Signal.Status
ShM = ShrMap.Map (SharedVar.Status ร โ)
is-unknownp : Signal.Status -> Bool
is-unknownp x = โ x Signal.โโโ Signal.unknown โ
is-notreadyp : SharedVar.Status ร โ -> Bool
is-notreadyp (SharedVar.ready , _) = false
is-notreadyp (SharedVar.new , _) = true
is-notreadyp (SharedVar.old , _) = true
is-notreadyp-status : SharedVar.Status -> Bool
is-notreadyp-status SharedVar.ready = false
is-notreadyp-status SharedVar.new = true
is-notreadyp-status SharedVar.old = true
is-notreadyp' : SharedVar.Status ร โ -> Bool
is-notreadyp' x = is-notreadyp-status (projโ x)
hunch : โ x -> is-notreadyp x โก is-notreadyp' x
hunch (SharedVar.ready , projโ) = refl
hunch (SharedVar.new , projโ) = refl
hunch (SharedVar.old , projโ) = refl
numstepsSig : SM -> โ
numstepsSig m = SigMap.count is-unknownp m
numstepsShr : ShM -> โ
numstepsShr m = ShrMap.count is-notreadyp m
numstepsฮธ : Env -> โ
numstepsฮธ (ฮ sigโ shrโ varโ) = (numstepsSig sigโ) + (numstepsShr shrโ)
โฅ_โฅs : Term -> โ
โฅ nothin โฅs = 0
โฅ pause โฅs = 0
{- one for stepping to ฯ ฮธ p
one for (maybe) setting S to absent
one for (maybe) this ฯ mergeing with another one
(same idea for `shared` and `var`) -}
โฅ (signl S p) โฅs = suc (suc (suc (โฅ p โฅs)))
โฅ (present S โฃโ p โฃโ q) โฅs = suc (โฅ p โฅs + โฅ q โฅs)
โฅ (emit S) โฅs = 1
โฅ (p โฅ q) โฅs = suc (โฅ p โฅs + โฅ q โฅs)
โฅ (loop p) โฅs = suc (suc (โฅ p โฅs + โฅ p โฅs))
โฅ (loopหข p q) โฅs = suc (โฅ p โฅs + โฅ q โฅs)
โฅ (p >> q) โฅs = suc (โฅ p โฅs + โฅ q โฅs)
โฅ (suspend p S) โฅs = suc (โฅ p โฅs)
โฅ (trap p) โฅs = suc (โฅ p โฅs)
โฅ (exit x) โฅs = 0
โฅ (shared s โ e in: p) โฅs = suc (suc (suc (โฅ p โฅs)))
โฅ (s โ e) โฅs = 1
โฅ (var x โ e in: p) โฅs = suc (suc (โฅ p โฅs))
โฅ (x โ e) โฅs = 1
โฅ (if x โฃโ p โฃโ q) โฅs = suc (โฅ p โฅs + โฅ q โฅs)
โฅ (ฯโจ ฮธ , A โฉยท p) โฅs = suc (numstepsฮธ ฮธ + โฅ p โฅs)
arith1 : โ a b c -> suc b โคโฒ c -> suc (suc (a + b)) โคโฒ suc (a + c)
arith1 a b c sucbโคโฒc rewrite sym (+-suc a b) = sโคโฒs (โคโฒ+r {z = a} sucbโคโฒc)
arith2 : โ x y z -> suc x โคโฒ y -> suc (suc (x + z)) โคโฒ suc (y + z)
arith2 x y z sucxโคโฒy = sโคโฒs (โคโฒ+l{z = z} sucxโคโฒy)
arith3 : โ x y z -> suc x โคโฒ y -> suc (suc (z + x)) โคโฒ suc (z + y)
arith3 x y z sucxโคโฒy rewrite sym (+-suc z x) = sโคโฒs (โคโฒ+r {z = z} sucxโคโฒy)
arith4 : โ x y z -> suc (suc x + y + z) โคโฒ suc (x + suc y + z)
arith4 x y z rewrite +-suc x y = sโคโฒs โคโฒ-refl
arith5 : โ x y -> suc x โคโฒ y -> suc (suc (suc (x + x))) โคโฒ suc (suc (y + y))
arith5 x y sucxโคโฒy rewrite sym (+-suc x x) =
sโคโฒs (sโคโฒs (โคโฒ+b x (suc x) y y (sucโคโฒโโคโฒ x y sucxโคโฒy) sucxโคโฒy))
decomposeโฅโฅs : โ E p -> โฅ E โฆ p โงe โฅs โก โฅ E โฆ nothin โงe โฅs + โฅ p โฅs
decomposeโฅโฅs [] p = refl
decomposeโฅโฅs (x โท E) p with decomposeโฅโฅs E
decomposeโฅโฅs (eparโ q โท E) p | R
rewrite R p
| +-assoc (โฅ E โฆ nothin โงe โฅs) โฅ p โฅs โฅ q โฅs
| +-assoc (โฅ E โฆ nothin โงe โฅs) โฅ q โฅs โฅ p โฅs
| +-comm (โฅ p โฅs) (โฅ q โฅs)
= cong suc refl
decomposeโฅโฅs (eparโ p โท E) pโ | R
rewrite R pโ
| +-assoc โฅ p โฅs โฅ E โฆ nothin โงe โฅs โฅ pโ โฅs
= cong suc refl
decomposeโฅโฅs (eseq q โท E) p | R
rewrite R p
| +-assoc (โฅ E โฆ nothin โงe โฅs) โฅ p โฅs โฅ q โฅs
| +-assoc (โฅ E โฆ nothin โงe โฅs) โฅ q โฅs โฅ p โฅs
| +-comm (โฅ p โฅs) (โฅ q โฅs)
= cong suc refl
decomposeโฅโฅs (eloopหข q โท E) p | R
rewrite R p
| +-assoc (โฅ E โฆ nothin โงe โฅs) โฅ p โฅs โฅ q โฅs
| +-assoc (โฅ E โฆ nothin โงe โฅs) โฅ q โฅs โฅ p โฅs
| +-comm (โฅ p โฅs) (โฅ q โฅs)
= cong suc refl
decomposeโฅโฅs (esuspend S โท E) p | R rewrite R p = refl
decomposeโฅโฅs (etrap โท E) p | R rewrite R p = refl
eplugโค : โ p q E ->
โฅ p โฅs โคโฒ โฅ q โฅs ->
โฅ E โฆ p โงe โฅs โคโฒ โฅ E โฆ q โงe โฅs
eplugโค p q E โฅpโฅsโคโฒโฅqโฅs
rewrite decomposeโฅโฅs E p | decomposeโฅโฅs E q
= โคโฒ+r{z = โฅ E โฆ nothin โงe โฅs} โฅpโฅsโคโฒโฅqโฅs
eplug< : โ p q E ->
suc โฅ p โฅs โคโฒ โฅ q โฅs ->
suc (โฅ (E โฆ p โงe) โฅs) โคโฒ (โฅ (E โฆ q โงe) โฅs)
eplug< p q E โฅpโฅs<โฅqโฅs
rewrite decomposeโฅโฅs E p | decomposeโฅโฅs E q
| sym (+-suc โฅ E โฆ nothin โงe โฅs โฅ p โฅs)
= โคโฒ+r{z = โฅ E โฆ nothin โงe โฅs} โฅpโฅs<โฅqโฅs
valuemax-norm : โ {p q} ->
(donep : done p) -> (doneq : done q) ->
(haltedporq : halted p โ halted q) ->
โฅ value-max donep doneq haltedporq โฅs โคโฒ โฅ p โฅs + โฅ q โฅs
valuemax-norm (dhalted hnothin) (dhalted p/haltedโ) _ = โคโฒ-refl
valuemax-norm (dhalted (hexit n)) (dhalted hnothin) _ = โคโฒ-refl
valuemax-norm (dhalted (hexit n)) (dhalted (hexit m)) _ = โคโฒ-refl
valuemax-norm (dhalted hnothin) (dpaused p/paused) _ = โคโฒ-refl
valuemax-norm{q = q} (dhalted (hexit n)) (dpaused p/paused) _ = mโคโฒm+n 0 โฅ q โฅs
valuemax-norm{p = p} (dpaused p/paused) (dhalted hnothin) _ = mโคโฒm+n โฅ p โฅs 0
valuemax-norm (dpaused p/paused) (dhalted (hexit n)) _ = zโคโฒn
valuemax-norm (dpaused p/paused) (dpaused p/pausedโ) (injโ x) =
โฅ-elim (halted-paused-disjoint x p/paused)
valuemax-norm (dpaused p/paused) (dpaused p/pausedโ) (injโ y) =
โฅ-elim (halted-paused-disjoint y p/pausedโ)
halted-norm : โ {p} -> (haltedp : halted p) -> โฅ โ haltedp โฅs โก 0
halted-norm hnothin = refl
halted-norm (hexit zero) = refl
halted-norm (hexit (suc n)) = refl
noetherianโ :
โ {p q} ->
p snโถโ q ->
(suc (โฅ q โฅs)) โคโฒ (โฅ p โฅs)
noetherianโ (rpar-done-right{p}{q} haltedp doneq) =
sโคโฒs (valuemax-norm (dhalted haltedp) doneq (injโ haltedp))
noetherianโ (rpar-done-left{p}{q} donep haltedq) =
sโคโฒs (valuemax-norm donep (dhalted haltedq) (injโ haltedq))
noetherianโ (ris-present{ฮธ}{S = S}{p = p}{q = q}{E = E} Sโ x xโ) with unplug xโ
... | refl =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ p โงe โฅs
โฅ E โฆ present S โฃโ p โฃโ q โงe โฅs
(eplug< p (present S โฃโ p โฃโ q) E (sโคโฒs (mโคโฒm+n โฅ p โฅs โฅ q โฅs)))
noetherianโ (ris-absent{ฮธ}{S}{p = p}{q = q}{E = E} Sโ x xโ) with unplug xโ
... | refl =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ q โงe โฅs
โฅ E โฆ present S โฃโ p โฃโ q โงe โฅs
(eplug< q (present S โฃโ p โฃโ q) E (sโคโฒs (nโคโฒm+n โฅ p โฅs โฅ q โฅs)))
noetherianโ (remit {ฮธ} {_} {S} {E} Sโ ยฌSโกa x) with unplug x
noetherianโ (remit {ฮธ} {_} {S} {E} Sโ ยฌSโกa x) | refl with
is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโ)
| inspect is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโ)
| SigMap.lookup{k = S} (sig ฮธ) Sโ
| inspect (SigMap.lookup{k = S} (sig ฮธ)) Sโ
... | true | Reveal_ยท_is_.[ eq1 ] | Signal.present | Reveal_ยท_is_.[ eq ]
rewrite eq = โฅ-elim (false-not-true eq1) where
false-not-true : false โก true -> โฅ
false-not-true ()
... | false | Reveal_ยท_is_.[ eq1 ] | Signal.absent | Reveal_ยท_is_.[ eq ]
= โฅ-elim (ยฌSโกa refl)
... | true | Reveal_ยท_is_.[ eq1 ] | Signal.absent | Reveal_ยท_is_.[ eq ]
= โฅ-elim (ยฌSโกa refl)
... | false | Reveal_ยท_is_.[ eq1 ] | Signal.unknown | Reveal_ยท_is_.[ eq ]
rewrite eq = โฅ-elim (true-not-false eq1) where
true-not-false : true โก false -> โฅ
true-not-false ()
noetherianโ (remit {ฮธ} {.(E โฆ emit S โงe)} {S} {E} Sโ ยฌSโกa x)
| refl | false | Reveal_ยท_is_.[ eq1 ] | Signal.present | Reveal_ยท_is_.[ eq ]
with sym (SigMap.getput-m S (sig ฮธ) Sโ)
... | updateฮธ-S-to-presentโกฮธ rewrite eq | updateฮธ-S-to-presentโกฮธ =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ nothin โงe โฅs
โฅ E โฆ emit S โงe โฅs
(eplug< nothin (emit S) E โคโฒ-refl)
noetherianโ (remit {ฮธ} {.(E โฆ emit S โงe)} {S} {E} Sโ ยฌSโกa x)
| refl | true | Reveal_ยท_is_.[ eq1 ] | Signal.unknown | Reveal_ยท_is_.[ eq ]
rewrite SigMap.change-one-count-goes-down
(sig ฮธ) is-unknownp
S Sโ eq1 Signal.present refl =
sโคโฒs (sโคโฒs (โคโฒ+r {z = numstepsฮธ (set-sig{S} ฮธ Sโ Signal.present)}
(eplugโค nothin (emit S) E (Nat.โคโฒ-step โคโฒ-refl))))
noetherianโ rloop-unroll = โคโฒ-refl
noetherianโ rseq-done = โคโฒ-refl
noetherianโ (rseq-exit{q}) = sโคโฒs zโคโฒn
noetherianโ (rloopหข-exit{q}) = sโคโฒs zโคโฒn
noetherianโ (rsuspend-done x) = โคโฒ-refl
noetherianโ (rtrap-done{p} haltedp)
rewrite halted-norm haltedp =
sโคโฒs zโคโฒn
noetherianโ (rraise-signal{p}{S}) = ans where
oneunknownโก1 : โ S ->
numstepsฮธ (ฮ SigMap.[ S โฆ Signal.unknown ] [] []) โก 1
oneunknownโก1 (zero Signal.โ) = refl
oneunknownโก1 (suc n Signal.โ) = oneunknownโก1 (n Signal.โ)
ans : suc (suc (numstepsฮธ (ฮ SigMap.[ S โฆ Signal.unknown ] [] []) + โฅ p โฅs))
โคโฒ suc (suc (suc โฅ p โฅs))
ans rewrite oneunknownโก1 S = โคโฒ-refl
noetherianโ (rraise-shared{ฮธ}{_}{s}{e}{p}{E} e' x) with unplug x
... | refl =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ ฯโจ [s,ฮดe]-env s (ฮด e') , WAIT โฉยท p โงe โฅs
โฅ E โฆ shared s โ e in: p โงe โฅs
(eplug< (ฯโจ [s,ฮดe]-env s (ฮด e') , WAIT โฉยท p)
(shared s โ e in: p) E newฮธโก1) where
silly : โ s -> numstepsฮธ ([s,ฮดe]-env s (ฮด e')) โก 1
silly (zero SharedVar.โโ) = refl
silly (suc xโ SharedVar.โโ) = silly (xโ SharedVar.โโ)
newฮธโก1 : suc (suc (numstepsฮธ ([s,ฮดe]-env s (ฮด e')) + โฅ p โฅs)) โคโฒ
suc (suc (suc โฅ p โฅs))
newฮธโก1 rewrite silly s = โคโฒ-refl
noetherianโ (rset-shared-value-old{ฮธ}{_}{s}{e}{E} e' sโ ฮธ[s]โกold x) with unplug x
... | refl = ans where
snotready : is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโ) โก true
snotready rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโ)
| ฮธ[s]โกold = refl
ฮธsame : numstepsฮธ (set-shr{s} ฮธ sโ (SharedVar.new) (ฮด e'))
โก numstepsฮธ ฮธ
ฮธsame rewrite
ShrMap.change-nothing-count-stays-same
(shr ฮธ) is-notreadyp s sโ
(SharedVar.new , ฮด e') snotready = refl
ans : suc โฅ (ฯโจ (set-shr{s} ฮธ sโ (SharedVar.new) (ฮด e')) , GO โฉยท
E โฆ nothin โงe) โฅs โคโฒ
โฅ ฯโจ ฮธ , GO โฉยท E โฆ s โ e โงe โฅs
ans rewrite ฮธsame =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ nothin โงe โฅs
โฅ E โฆ s โ e โงe โฅs
(eplug< nothin (s โ e) E โคโฒ-refl)
noetherianโ (rset-shared-value-new{ฮธ}{_}{s}{e}{E} e' sโ ฮธ[s]โกnew x) with unplug x
... | refl = ans where
snotready : is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโ) โก true
snotready rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโ)
| ฮธ[s]โกnew = refl
ฮธsame : numstepsฮธ (set-shr{s} ฮธ sโ (SharedVar.new) (shr-vals{s} ฮธ sโ + ฮด e'))
โก numstepsฮธ ฮธ
ฮธsame rewrite
ShrMap.change-nothing-count-stays-same
(shr ฮธ) is-notreadyp s sโ
(SharedVar.new , shr-vals{s} ฮธ sโ + ฮด e') snotready = refl
ans : suc โฅ (ฯโจ (set-shr{s} ฮธ sโ (SharedVar.new) (shr-vals{s} ฮธ sโ + ฮด e')) , GO โฉยท
E โฆ nothin โงe) โฅs โคโฒ
โฅ ฯโจ ฮธ , GO โฉยท E โฆ s โ e โงe โฅs
ans rewrite ฮธsame =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ nothin โงe โฅs
โฅ E โฆ s โ e โงe โฅs
(eplug< nothin (s โ e) E โคโฒ-refl)
noetherianโ (rraise-var{ฮธ}{r}{x}{p}{e}{E} e' xโ) with unplug xโ
... | refl =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ ฯโจ [x,ฮดe]-env x (ฮด e') , WAIT โฉยท p โงe โฅs
โฅ E โฆ var x โ e in: p โงe โฅs
(eplug< (ฯโจ [x,ฮดe]-env x (ฮด e') , WAIT โฉยท p)
(var x โ e in: p)
E
โคโฒ-refl)
noetherianโ (rset-var{ฮธ}{_}{x}{e}{E} xโ e' xโ) with unplug xโ
... | refl =
arith1 (numstepsฮธ ฮธ)
โฅ E โฆ nothin โงe โฅs
โฅ E โฆ x โ e โงe โฅs
(eplug< nothin (x โ e) E โคโฒ-refl)
noetherianโ (rif-false{ฮธ}{p = p}{q = q}{x = x}{E = E} xโ xโ xโ) with unplug xโ
... | refl = arith1 (numstepsฮธ ฮธ)
โฅ E โฆ q โงe โฅs
โฅ E โฆ if x โฃโ p โฃโ q โงe โฅs
(eplug< q (if x โฃโ p โฃโ q) E (sโคโฒs (nโคโฒm+n โฅ p โฅs โฅ q โฅs)))
noetherianโ (rif-true{ฮธ}{p = p}{q = q}{x = x}{E = E} xโ xโ xโ) with unplug xโ
... | refl = arith1 (numstepsฮธ ฮธ)
โฅ E โฆ p โงe โฅs
โฅ E โฆ if x โฃโ p โฃโ q โงe โฅs
(eplug< p (if x โฃโ p โฃโ q) E (sโคโฒs (mโคโฒm+n โฅ p โฅs โฅ q โฅs)))
noetherianโ (rabsence{ฮธ = ฮธ}{S = S} Sโ ฮธ[S]โกunk SฬธSโCanฮธ)
with is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโ)
| inspect is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโ)
... | false | Reveal_ยท_is_.[ eq ] rewrite ฮธ[S]โกunk
= โฅ-elim (absurd eq) where
absurd : true โก false -> โฅ
absurd ()
... | true | Reveal_ยท_is_.[ eq ] with
SigMap.change-one-count-goes-down
(sig ฮธ) is-unknownp
S Sโ eq Signal.absent refl
... | thing rewrite thing = โคโฒ-refl
noetherianโ (rreadyness {ฮธ}{p}{s} sโ (injโ ฮธs=old) sโCanฮธ)
with is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโ)
| inspect is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโ)
... | false | Reveal_ยท_is_.[ eq ]
rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโ) | ฮธs=old
= โฅ-elim (absurd eq) where
absurd : true โก false -> โฅ
absurd ()
... | true | Reveal_ยท_is_.[ eq ] rewrite ฮธs=old with
ShrMap.change-one-count-goes-down
(shr ฮธ) is-notreadyp
s sโ eq (SharedVar.ready ,โฒ shr-vals{s} ฮธ sโ) refl
... | thing rewrite thing =
arith4 (numstepsSig (sig ฮธ))
(numstepsShr (shr (set-shr{s} ฮธ sโ (SharedVar.ready)
(shr-vals{s} ฮธ sโ))))
(โฅ p โฅs)
noetherianโ (rreadyness {ฮธ}{p}{s} sโ (injโ ฮธs=new) sโCanฮธ)
with is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโ)
| inspect is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโ)
... | false | Reveal_ยท_is_.[ eq ]
rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโ) | ฮธs=new
= โฅ-elim (absurd eq) where
absurd : true โก false -> โฅ
absurd ()
... | true | Reveal_ยท_is_.[ eq ] rewrite ฮธs=new with
ShrMap.change-one-count-goes-down
(shr ฮธ) is-notreadyp
s sโ eq (SharedVar.ready ,โฒ shr-vals{s} ฮธ sโ) refl
... | thing rewrite thing =
arith4 (numstepsSig (sig ฮธ))
(numstepsShr (shr (set-shr{s} ฮธ sโ (SharedVar.ready)
(shr-vals{s} ฮธ sโ))))
(โฅ p โฅs)
noetherianโ (rmerge{ฮธโ}{ฮธโ}{_}{p}{E}{Aโ}{Aโ} x) with unplug x
... | refl rewrite decomposeโฅโฅs E (ฯโจ ฮธโ , Aโ โฉยท p)
| decomposeโฅโฅs E p
= sโคโฒs
(rearrange-things
(numstepsSig (SigMap.union (sig ฮธโ) (sig ฮธโ)))
(numstepsShr (ShrMap.union (shr ฮธโ) (shr ฮธโ)))
โฅ E โฆ nothin โงe โฅs
โฅ p โฅs
(numstepsSig (sig ฮธโ))
(numstepsShr (shr ฮธโ))
(numstepsSig (sig ฮธโ))
(numstepsShr (shr ฮธโ))
(โคโฒ+b (numstepsSig (SigMap.union (sig ฮธโ) (sig ฮธโ)))
(numstepsShr (ShrMap.union (shr ฮธโ) (shr ฮธโ)))
(numstepsSig (sig ฮธโ) + numstepsSig (sig ฮธโ))
(numstepsShr (shr ฮธโ) + numstepsShr (shr ฮธโ))
(SigMap.count-mergeโคโฒsum-count
(sig ฮธโ) (sig ฮธโ) is-unknownp)
(ShrMap.count-mergeโคโฒsum-count
(shr ฮธโ) (shr ฮธโ) is-notreadyp))) where
rearrange-more :
โ ab cd a b c d ->
ab + cd โคโฒ a + b + (c + d) ->
ab + cd โคโฒ a + c + (b + d)
rearrange-more ab cd a b c d simple rewrite
sym (+-assoc (a + c) b d)
| +-assoc a c b
| +-comm c b
| sym (+-assoc a b c)
| +-assoc (a + b) c d
= simple
rearrange-things : โ ab cd n p a c b d ->
ab + cd โคโฒ (a + b) + (c + d) ->
suc (ab + cd + (n + p)) โคโฒ a + c + (n + (suc (b + d + p)))
rearrange-things ab cd n p a c b d simple rewrite
+-suc n (b + d + p)
| +-suc (a + c) (n + (b + d + p))
| +-comm (b + d) p
| sym (+-assoc n p (b + d))
| +-comm (n + p) (b + d)
| sym (+-assoc (a + c) (b + d) (n + p))
= sโคโฒs (โคโฒ+l {z = n + p} (rearrange-more ab cd a b c d simple))
csteps : โ {p q C Cโฆpโง Cโฆqโง} ->
(suc (โฅ q โฅs)) โคโฒ (โฅ p โฅs) ->
Cโฆpโง โ C โฆ p โงc ->
Cโฆqโง โ C โฆ q โงc ->
(suc โฅ Cโฆqโง โฅs) โคโฒ โฅ Cโฆpโง โฅs
csteps sqโคp dchole dchole = sqโคp
csteps sqโคp (dcparโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcparโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith2 โฅ qp โฅs โฅ pp โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcparโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcparโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith1 โฅ qp โฅs โฅ qq โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcseqโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcseqโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith2 โฅ qp โฅs โฅ pp โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcseqโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcseqโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith1 โฅ pp โฅs โฅ qq โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcsuspend{p} Cโฆpโง=Cโฆpโงc) (dcsuspend{q} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = sโคโฒs sucnspโฐspโ
csteps sqโคp (dctrap{p} Cโฆpโง=Cโฆpโงc) (dctrap{q} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = sโคโฒs sucnspโฐspโ
csteps sqโคp (dcsignl{p} Cโฆpโง=Cโฆpโงc) (dcsignl{q} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = sโคโฒs (sโคโฒs (sโคโฒs sucnspโฐspโ))
csteps sqโคp (dcpresentโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcpresentโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith2 โฅ qp โฅs โฅ pp โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcpresentโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcpresentโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith1 โฅ pp โฅs โฅ qq โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcloop{p} Cโฆpโง=Cโฆpโงc) (dcloop{q} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith5 โฅ q โฅs โฅ p โฅs sucnspโฐspโ
csteps sqโคp (dcloopหขโ{pp}{pq} Cโฆpโง=Cโฆpโงc) (dcloopหขโ{qp}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith2 โฅ qp โฅs โฅ pp โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcloopหขโ{pp}{pq} Cโฆpโง=Cโฆpโงc) (dcloopหขโ{qp}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith1 โฅ pp โฅs โฅ qq โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcshared{p} Cโฆpโง=Cโฆpโงc) (dcshared{q} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = sโคโฒs (sโคโฒs (sโคโฒs sucnspโฐspโ))
csteps sqโคp (dcvar{p} Cโฆpโง=Cโฆpโงc) (dcvar{q} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = sโคโฒs (sโคโฒs sucnspโฐspโ)
csteps sqโคp (dcifโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcifโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith2 โฅ qp โฅs โฅ pp โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcifโ{pp}{pr}{pq} Cโฆpโง=Cโฆpโงc) (dcifโ{qp}{qr}{qq} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith1 โฅ pp โฅs โฅ qq โฅs โฅ pq โฅs sucnspโฐspโ
csteps sqโคp (dcenv{p = p1}{ฮธ = ฮธ} Cโฆpโง=Cโฆpโงc) (dcenv{p = p2} Cโฆqโง=Cโฆqโงc)
with csteps sqโคp Cโฆpโง=Cโฆpโงc Cโฆqโง=Cโฆqโงc
... | sucnspโฐspโ = arith3 โฅ p2 โฅs โฅ p1 โฅs (numstepsฮธ ฮธ) sucnspโฐspโ
noetherian : โ {p q} ->
p snโถ q ->
(suc (โฅ q โฅs)) โคโฒ (โฅ p โฅs)
noetherian (rcontext C dc pinsnโถโqin) =
csteps (noetherianโ pinsnโถโqin) dc Crefl
| {
"alphanum_fraction": 0.5417946982,
"avg_line_length": 39.1059063136,
"ext": "agda",
"hexsha": "5a2d6a971e29507882045970c1a8ba741ebfa84d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/noetherian.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "florence/esterel-calculus",
"max_issues_repo_path": "agda/noetherian.agda",
"max_line_length": 85,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/noetherian.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 9688,
"size": 19201
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
-- This is a selection of useful functions and definitions
-- from the standard library that we tend to use a lot.
module LibraBFT.Prelude where
open import Level
renaming (suc to โ+1; zero to โ0; _โ_ to _โโ_)
public
1โ : Level
1โ = โ+1 0โ
open import Agda.Builtin.Unit
public
open import Function
using (_โ_; _โโฒ_; id; case_of_; _on_; typeOf; flip; const; _โ_; _$_)
public
identity = id
infixl 1 _&_
_&_ = Function._|>_
open import Data.Unit.NonEta
public
open import Data.Empty
public
-- NOTE: This function is defined to give extra documentation when discharging
-- absurd cases where Agda can tell by pattern matching that `A` is not
-- inhabited. For example:
-- > absurd (just v โก nothing) case impossibleProof of ฮป ()
infix 0 absurd_case_of_
absurd_case_of_ : โ {โโ โโ} (A : Set โโ) {B : Set โโ} โ A โ (A โ โฅ) โ B
absurd A case x of f = โฅ-elim (f x)
open import Data.Nat
renaming (_โ_ to _โโ_; _โค?_ to _โค?โ_; _โฅ?_ to _โฅ?โ_; compare to compareโ; Ordering to Orderingโ)
public
max = _โ_
min = _โ_
open import Data.Nat.DivMod using (_/_)
div = _/_
open import Data.Nat.Properties
hiding (โก-irrelevant ; _โ_)
public
open import Data.List
renaming (map to List-map ; filter to List-filter ; lookup to List-lookup;
tabulate to List-tabulate; foldl to List-foldl)
hiding (fromMaybe; [_])
public
foldl' = List-foldl
open import Data.List.Properties
renaming (โก-dec to List-โก-dec; length-map to List-length-map; map-compose to List-map-compose; filter-++ to List-filter-++; length-filter to List-length-filter)
using (โท-injective; length-++; map-++-commute; sum-++-commute; map-tabulate; tabulate-lookup; ++-identityสณ; ++-identityหก)
public
open import Data.List.Relation.Binary.Subset.Propositional
renaming (_โ_ to _โList_)
public
open import Data.List.Relation.Unary.Any
using (Any; here; there)
renaming (lookup to Any-lookup; map to Any-map; satisfied to Any-satisfied
;index to Any-index; any to Any-any)
public
open import Data.List.Relation.Unary.Any.Properties
using (ยฌAny[])
renaming ( mapโบ to Any-mapโบ
; mapโป to Any-mapโป
; concatโบ to Any-concatโบ
; concatโป to Any-concatโป
; ++โป to Any-++โป
; ++โบสณ to Any-++สณ
; ++โบหก to Any-++หก
; singletonโป to Any-singletonโป
; tabulateโบ to Any-tabulateโบ
; filterโป to Any-filterโป
)
public
open import Data.List.Relation.Unary.All
using (All; []; _โท_)
renaming (head to All-head; tail to All-tail;
lookup to All-lookup; tabulate to All-tabulate;
reduce to All-reduce; map to All-map)
public
open import Data.List.Relation.Unary.All.Properties
hiding (All-map)
renaming ( tabulateโป to All-tabulateโป
; tabulateโบ to All-tabulateโบ
; mapโบ to All-mapโบ
; mapโป to All-mapโป
; ++โบ to All-++
)
public
open import Data.List.Membership.Propositional
using (_โ_; _โ_)
public
open import Data.List.Membership.Propositional.Properties
renaming (โ-filterโบ to List-โ-filterโบ; โ-filterโป to List-โ-filterโป)
public
open import Data.Vec
using (Vec; []; _โท_)
renaming (replicate to Vec-replicate; lookup to Vec-lookup
;map to Vec-map; head to Vec-head; tail to Vec-tail
;updateAt to Vec-updateAt; tabulate to Vec-tabulate
;allFin to Vec-allFin; toList to Vec-toList; fromList to Vec-fromList
;_++_ to _Vec-++_)
public
open import Data.Vec.Relation.Unary.All
using ([]; _โท_)
renaming (All to Vec-All; lookup to Vec-All-lookup)
public
open import Data.Vec.Properties
using ()
renaming (updateAt-minimal to Vec-updateAt-minimal
;[]=โlookup to Vec-[]=โlookup
;lookupโ[]= to Vec-lookupโ[]=
;lookupโtabulate to Vec-lookupโtabulate
;โก-dec to Vec-โก-dec)
public
open import Data.List.Relation.Binary.Pointwise
using (decidable-โก)
public
open import Data.Bool
renaming (_โ_ to _โBool_)
hiding (_โค?_; _<_; _<?_; _โค_; not)
public
open import Data.Maybe
renaming (map to Maybe-map; zip to Maybe-zip ; _>>=_ to _Maybe->>=_)
hiding (align; alignWith; zipWith)
public
-- a non-dependent eliminator
maybeS : โ {a b} {A : Set a} {B : Set b} โ
(x : Maybe A) โ B โ ((x : A) โ B) โ B
maybeS {B = B} x f t = maybe {B = const B} t f x
maybeHsk : โ {A B : Set} โ B โ (A โ B) โ Maybe A โ B
maybeHsk b aโb = ฮป where
nothing โ b
(just a) โ aโb a
open import Data.Maybe.Relation.Unary.Any
renaming (Any to Maybe-Any; dec to Maybe-Any-dec)
hiding (map; zip; zipWith; unzip ; unzipWith)
public
maybe-any-โฅ : โ{a}{A : Set a} โ Maybe-Any {A = A} (ฮป _ โ โค) nothing โ โฅ
maybe-any-โฅ ()
headMay : โ {A : Set} โ List A โ Maybe A
headMay [] = nothing
headMay (x โท _) = just x
lastMay : โ {A : Set} โ List A โ Maybe A
lastMay [] = nothing
lastMay (x โท []) = just x
lastMay (_ โท x โท xs) = lastMay (x โท xs)
open import Data.Maybe.Properties
using (just-injective)
renaming (โก-dec to Maybe-โก-dec)
public
open import Data.Fin
using (Fin; suc; zero; fromโ; fromโ< ; toโ ; cast)
renaming (_โ_ to _โFin_; _โค?_ to _โค?Fin_; _โค_ to _โคFin_ ; _<_ to _<Fin_;
injectโ to Fin-injectโ; inject+ to Fin-inject+; injectโค to Fin-injectโค)
public
fins : (n : โ) โ List (Fin n)
fins n = Vec-toList (Vec-allFin n)
open import Data.Fin.Properties
using (toโ-injective; toโ<n)
renaming (<-cmp to Fin-<-cmp; <โโข to <โโขFin; suc-injective to Fin-suc-injective)
public
open import Relation.Binary.PropositionalEquality
hiding (decSetoid)
public
open import Relation.Binary.HeterogeneousEquality
using (_โ
_)
renaming (cong to โ
-cong; congโ to โ
-congโ)
public
open import Relation.Binary
public
data Ordering : Set where
LT EQ GT : Ordering
compare : โ โ โ โ Ordering
compare m n
with <-cmp m n
... | tri< a ยฌb ยฌc = LT
... | triโ ยฌa b ยฌc = EQ
... | tri> ยฌa ยฌb c = GT
โก-irrelevant : โ{a}{A : Set a} โ Irrelevant {a} {A} _โก_
โก-irrelevant refl refl = refl
to-witness-lemma : โ{โ}{A : Set โ}{a : A}{f : Maybe A}(x : Is-just f)
โ to-witness x โก a โ f โก just a
to-witness-lemma (just x) refl = refl
open import Relation.Nullary
hiding (Irrelevant; proof)
public
open import Relation.Nullary.Decidable
hiding (map)
public
open import Data.Sum
renaming ([_,_] to either; map to โ-map; mapโ to โ-mapโ; mapโ to โ-mapโ)
public
open import Data.Sum.Properties
using (injโ-injective ; injโ-injective)
public
โ-elimหก : โ {โโ โโ}{Aโ : Set โโ}{Aโ : Set โโ} โ ยฌ Aโ โ Aโ โ Aโ โ Aโ
โ-elimหก ยฌa = either (โฅ-elim โ ยฌa) id
โ-elimสณ : โ {โโ โโ}{Aโ : Set โโ}{Aโ : Set โโ} โ ยฌ Aโ โ Aโ โ Aโ โ Aโ
โ-elimสณ ยฌa = either id (โฅ-elim โ ยฌa)
open import Data.Product
renaming (map to ร-map; mapโ to ร-mapโ; mapโ to ร-mapโ; <_,_> to split; swap to ร-swap)
hiding (zip)
public
fst = projโ
open import Data.Product.Properties
public
module _ {โA} {A : Set โA} where
NoneOfKind : โ {โ} {P : A โ Set โ} โ List A โ (p : (a : A) โ Dec (P a)) โ Set โA
NoneOfKind xs p = List-filter p xs โก []
postulate -- TODO-1: Replace with or prove using library properties? Move to Lemmas?
NoneOfKindโ : โ {โ} {P : A โ Set โ} {Q : A โ Set โ} {xs : List A}
โ (p : (a : A) โ Dec (P a))
โ {q : (a : A) โ Dec (Q a)}
โ (โ {a} โ P a โ Q a) -- TODO-1: Use proper notation (Relation.Unary?)
โ NoneOfKind xs q
โ NoneOfKind xs p
infix 4 _<?โ_
_<?โ_ : Decidable _<_
m <?โ n = suc m โค?โ n
infix 0 if-yes_then_else_
infix 0 if-dec_then_else_
if-yes_then_else_ : โ {โA โB} {A : Set โA} {B : Set โB} โ Dec A โ (A โ B) โ (ยฌ A โ B) โ B
if-yes (yes prf) then f else _ = f prf
if-yes (no prf) then _ else g = g prf
if-dec_then_else_ : โ {โA โB} {A : Set โA} {B : Set โB} โ Dec A โ B โ B โ B
if-dec x then f else g = if-yes x then const f else const g
open import Relation.Nullary.Negation
using (contradiction; contraposition)
public
open import Relation.Binary
using (Setoid; IsPreorder)
public
open import Relation.Unary
using (_โช_)
public
open import Relation.Unary.Properties
using (_โช?_)
public
-- Injectivity for a function of two potentially different types (A and B) via functions to a
-- common type (C).
Injective' : โ {b c d e}{B : Set b}{C : Set c}{D : Set d} โ (hB : B โ D) โ (hC : C โ D) โ (_โ_ : B โ C โ Set e) โ Set _
Injective' {C = C} hB hC _โ_ = โ {b c} โ hB b โก hC c โ b โ c
Injective : โ {c d e}{C : Set c}{D : Set d} โ (h : C โ D) โ (_โ_ : Rel C e) โ Set _
Injective h _โ_ = Injective' h h _โ_
Injective-โก : โ {c d}{C : Set c}{D : Set d} โ (h : C โ D) โ Set _
Injective-โก h = Injective h _โก_
Injective-int : โ{a b c d e}{A : Set a}{B : Set b}{C : Set c}{D : Set d}
โ (_โ_ : A โ B โ Set e)
โ (h : C โ D)
โ (fโ : A โ C)
โ (fโ : B โ C)
โ Set (a โโ b โโ d โโ e)
Injective-int _โ_ h fโ fโ = โ {aโ} {bโ} โ h (fโ aโ) โก h (fโ bโ) โ aโ โ bโ
NonInjective : โ{a b c}{A : Set a}{B : Set b}
โ (_โ_ : Rel A c)
โ (A โ B) โ Set (a โโ b โโ c)
NonInjective {A = A} _โ_ f
= ฮฃ (A ร A) (ฮป { (xโ , xโ) โ ยฌ (xโ โ xโ) ร f xโ โก f xโ })
NonInjective-โก : โ{a b}{A : Set a}{B : Set b}
โ (A โ B) โ Set (a โโ b)
NonInjective-โก = NonInjective _โก_
NonInjective-โก-preds : โ{a b}{A : Set a}{B : Set b}{โโ โโ : Level}
โ (A โ Set โโ)
โ (A โ Set โโ)
โ (A โ B) โ Set (a โโ b โโ โโ โโ โโ)
NonInjective-โก-preds Pred1 Pred2 f = ฮฃ (NonInjective _โก_ f) ฮป { ((aโ , aโ) , _ , _) โ Pred1 aโ ร Pred2 aโ }
NonInjective-โก-pred : โ{a b}{A : Set a}{B : Set b}{โ : Level}
โ (P : A โ Set โ)
โ (A โ B) โ Set (a โโ b โโ โ)
NonInjective-โก-pred Pred = NonInjective-โก-preds Pred Pred
NonInjective-โ : โ{a b c}{A : Set a}{B : Set b}{C : Set c}
โ {f : A โ B}(g : B โ C)
โ NonInjective-โก f
โ NonInjective-โก (g โ f)
NonInjective-โ g ((x0 , x1) , (x0โขx1 , fx0โกfx1))
= ((x0 , x1) , x0โขx1 , (cong g fx0โกfx1))
--------------------------------------------
-- Handy fmap and bind for specific types --
_<M$>_ : โ{a b}{A : Set a}{B : Set b}
โ (f : A โ B)
โ Maybe A โ Maybe B
_<M$>_ = Maybe-map
<M$>-univ : โ{a b}{A : Set a}{B : Set b}
โ (f : A โ B)(x : Maybe A)
โ {y : B} โ f <M$> x โก just y
โ โ[ x' ] (x โก just x' ร f x' โก y)
<M$>-univ f (just x) refl = x , (refl , refl)
maybe-lift : {A : Set}
โ {mx : Maybe A}{x : A}
โ (P : A โ Set)
โ P x โ mx โก just x
โ maybe {B = const Set} P โฅ mx
maybe-lift {mx = just .x} {x} P px refl = px
<M$>-nothing : โ {a b}{A : Set a}{B : Set b}(f : A โ B)
โ f <M$> nothing โก nothing
<M$>-nothing _ = refl
_<โ$>_ : โ{a b c}{A : Set a}{B : Set b}{C : Set c}
โ (A โ B) โ C โ A โ C โ B
f <โ$> (injโ hb) = injโ hb
f <โ$> (injโ x) = injโ (f x)
_โโซ=_ : โ{a b c}{A : Set a}{B : Set b}{C : Set c}
โ C โ A โ (A โ C โ B) โ C โ B
(injโ x) โโซ= _ = injโ x
(injโ a) โโซ= f = f a
-- Syntactic support for more faithful model of Haskell code
Either : โ {a b} โ Set a โ Set b โ Set (a โโ b)
Either A B = A โ B
pattern Left x = injโ x
pattern Right x = injโ x
isLeft : โ {a b} {A : Set a} {B : Set b} โ Either A B โ Bool
isLeft (Left _) = true
isLeft (Right _) = false
isRight : โ {a b} {A : Set a} {B : Set b} โ Either A B โ Bool
isRight = Data.Bool.not โ isLeft
-- a non-dependent eliminator
eitherS : โ {a b c} {A : Set a} {B : Set b} {C : Set c}
(x : Either A B) โ ((x : A) โ C) โ ((x : B) โ C) โ C
eitherS eab fa fb = case eab of ฮป where
(Left a) โ fa a
(Right b) โ fb b
module _ {โโ โโ โโ : Level} where
EL-type = Set โโ โ Set โโ โ Set โโ
EL-level = โโ โโ โโ โโ โโ
-- Utility to make passing between `Either` and `EitherD` more convenient
record EitherLike (E : EL-type) : Set (โ+1 EL-level) where
field
fromEither : โ {A : Set โโ} {B : Set โโ} โ Either A B โ E A B
toEither : โ {A : Set โโ} {B : Set โโ} โ E A B โ Either A B
open EitherLike โฆ ... โฆ public
EL-func : EL-type โ Set (โ+1 EL-level)
EL-func EL = โฆ mel : EitherLike EL โฆ โ Set EL-level
instance
EitherLike-Either : โ {โโ โโ} โ EitherLike{โโ โโ โโ}{โโ}{โโ} Either
EitherLike.fromEither EitherLike-Either = id
EitherLike.toEither EitherLike-Either = id
-- an approximation of Haskell's backtick notation for making infix operators; in Agda, must have
-- spaces between f and backticks
flip' : _ -- Avoids warning about definition and syntax declaration being in different scopes
flip' = flip
syntax flip' f = ` f `
open import Data.String as String
hiding (_==_ ; _โ_ ; concat)
check : Bool โ List String โ Either String Unit
check b t = if b then injโ unit else injโ (String.intersperse "; " t)
-- TODO-1: Maybe this belongs somewhere else? It's in a similar
-- category as Optics, so maybe should similarly be in a module that
-- is separate from the main project?
------------------
-- Guard Syntax --
--
-- Example Usage:
--
-- > f : โ โ โ
-- > f x = grdโ x โโ 10 โ 12
-- > โ otherwiseโ 40 + 2
--
--
-- > g : โ โ โ โ โ
-- > g x = case x of ฮป
-- > { (injโ x) โ grdโ x โค? 10 โ 2 * x
-- > โ otherwiseโ 42
-- > ; (injโ y) โ y
-- > }
--
-- To type: โ --> \Vert
-- โ --> \:=
record ToBool {a}(A : Set a) : Set a where
field
toBool : A โ Bool
open ToBool {{ ... }} public
not : โ {b} {B : Set b} โฆ _ : ToBool B โฆ โ B โ Bool
not b = Data.Bool.not (toBool b)
instance
ToBool-Bool : ToBool Bool
ToBool-Bool = record { toBool = id }
ToBool-Dec : โ{a}{A : Set a} โ ToBool (Dec A)
ToBool-Dec = record { toBool = โ_โ }
toWitnessT : โ{โ}{P : Set โ}{d : Dec P} โ โ d โ โก true โ P
toWitnessT {d = yes proof} _ = proof
toWitnessF : โ{โ}{P : Set โ}{d : Dec P} โ โ d โ โก false โ ยฌ P
toWitnessF{d = no proof} _ = proof
infix 3 _โ_
data GuardClause {a}{b}(A : Set a) : Set (a โโ โ+1 b) where
_โ_ : {B : Set b}{{ bb : ToBool B }} โ B โ A โ GuardClause A
infix 3 otherwiseโ_
data Guards {a}{b}(A : Set a) : Set (a โโ โ+1 b) where
otherwiseโ_ : A โ Guards A
clause : GuardClause{a}{b} A โ Guards{a}{b} A โ Guards A
infixr 2 _โ_
_โ_ : โ{a}{b}{A : Set a} โ GuardClause{a}{b} A โ Guards A โ Guards A
_โ_ = clause
infix 1 grdโ_
grdโ_ : โ{a}{b}{A : Set a} โ Guards{a}{b} A โ A
grdโ_ (otherwiseโ a) = a
grdโ_ (clause (b โ a) g) = if toBool b then a else (grdโ g)
Any-satisfied-โ : โ{a โ}{A : Set a}{P : A โ Set โ}{xs : List A}
โ Any P xs โ ฮฃ A (ฮป x โ P x ร x โ xs)
Any-satisfied-โ (here px) = _ , (px , here refl)
Any-satisfied-โ (there p) = let (a , px , prf) = Any-satisfied-โ p
in (a , px , there prf)
f-sum : โ{a}{A : Set a} โ (A โ โ) โ List A โ โ
f-sum f = sum โ List-map f
record Functor {โโ โโ : Level} (F : Set โโ โ Set โโ) : Set (โโ โโ โ+1 โโ) where
infixl 4 _<$>_
field
_<$>_ : โ {A B : Set โโ} โ (A โ B) โ F A โ F B
fmap = _<$>_
open Functor โฆ ... โฆ public
record Applicative {โโ โโ : Level} (F : Set โโ โ Set โโ) : Set (โโ โโ โ+1 โโ) where
infixl 4 _<*>_
field
pure : โ {A : Set โโ} โ A โ F A
_<*>_ : โ {A B : Set โโ} โ F (A โ B) โ F A โ F B
open Applicative โฆ ... โฆ public
instance
ApplicativeFunctor : โ {โโ โโ} {F : Set โโ โ Set โโ} โฆ _ : Applicative F โฆ โ Functor F
Functor._<$>_ ApplicativeFunctor f xs = pure f <*> xs
record Monad {โโ โโ : Level} (M : Set โโ โ Set โโ) : Set (โโ โโ โ+1 โโ) where
infixl 1 _>>=_ _>>_
field
return : โ {A : Set โโ} โ A โ M A
_>>=_ : โ {A B : Set โโ} โ M A โ (A โ M B) โ M B
_>>_ : โ {A B : Set โโ} โ M A โ M B โ M B
mโ >> mโ = mโ >>= ฮป _ โ mโ
open Monad โฆ ... โฆ public
instance
MonadApplicative : โ {โโ โโ} {M : Set โโ โ Set โโ} โฆ _ : Monad M โฆ โ Applicative M
Applicative.pure MonadApplicative = return
Applicative._<*>_ MonadApplicative fs xs = do
f โ fs
x โ xs
return (f x)
instance
Monad-Either : โ {โ}{C : Set โ} โ Monad{โ}{โ} (Either C)
Monad.return (Monad-Either{โ}{C}) = injโ
Monad._>>=_ (Monad-Either{โ}{C}) = either (const โ injโ) _&_
Monad-Maybe : โ {โ} โ Monad {โ} {โ} Maybe
Monad.return (Monad-Maybe{โ}) = just
Monad._>>=_ (Monad-Maybe{โ}) = _Maybe->>=_
Monad-List : โ {โ} โ Monad {โ}{โ} List
Monad.return Monad-List x = x โท []
Monad._>>=_ Monad-List x f = concat (List-map f x)
maybeSMP : โ {โ} {A B : Set} {m : Set โ Set โ} โฆ _ : Monad m โฆ โ m (Maybe A) โ B โ (A โ m B) โ m B
maybeSMP ma b f = do
x โ ma
case x of ฮป where
nothing โ pure b
(just j) โ f j
fromMaybeM : โ {โ} {A : Set} {m : Set โ Set โ} โฆ _ : Monad m โฆ โ m A โ m (Maybe A) โ m A
fromMaybeM ma mma = do
mma >>= ฮป where
nothing โ ma
(just a) โ pure a
forM_ : โ {โ} {A B : Set} {M : Set โ Set โ} โฆ _ : Monad M โฆ โ List A โ (A โ M B) โ M Unit
forM_ [] _ = return unit
forM_ (x โท xs) f = f x >> forM_ xs f
-- NOTE: because 'forM_' is defined above, it is necessary to
-- call 'forM' with parenthesis (e.g., recursive call in definition)
-- to disambiguate it for the Agda parser.
forM : โ {โ} {A B : Set} {M : Set โ Set โ} โฆ _ : Monad M โฆ โ List A โ (A โ M B) โ M (List B)
forM [] _ = return []
forM (x โท xs) f = do
fx โ f x
fxs โ (forM) xs f
return (fx โท fxs)
foldrM : โ {โโ โโ} {A B : Set โโ} {M : Set โโ โ Set โโ} โฆ _ : Monad M โฆ โ (A โ B โ M B) โ B โ List A โ M B
foldrM _ b [] = return b
foldrM f b (a โท as) = foldrM f b as >>= f a
foldlM : โ {โโ โโ} {A B : Set โโ} {M : Set โโ โ Set โโ} โฆ _ : Monad M โฆ โ (B โ A โ M B) โ B โ List A โ M B
foldlM _ z [] = pure z
foldlM f z (x โท xs) = do
z' โ f z x
foldlM f z' xs
foldM = foldlM
foldM_ : {A B : Set} {M : Set โ Set} โฆ _ : Monad M โฆ โ (B โ A โ M B) โ B โ List A โ M Unit
foldM_ f a xs = foldlM f a xs >> pure unit
open import LibraBFT.Base.Util public
record Eq {a} (A : Set a) : Set a where
infix 4 _โ_ _==_ _/=_
field
_โ_ : (a b : A) โ Dec (a โก b)
_==_ : A โ A โ Bool
a == b = toBool $ a โ b
_/=_ : A โ A โ Bool
a /= b = not (a == b)
open Eq โฆ ... โฆ public
elem : โ {โ} {A : Set โ} โฆ _ : Eq A โฆ โ A โ List A โ Bool
elem x = toBool โ Any-any (x โ_)
instance
Eq-Nat : Eq โ
Eq._โ_ Eq-Nat = _โโ_
Eq-Maybe : โ {a} {A : Set a} โฆ _ : Eq A โฆ โ Eq (Maybe A)
Eq._โ_ Eq-Maybe nothing nothing = yes refl
Eq._โ_ Eq-Maybe (just _) nothing = no ฮป ()
Eq._โ_ Eq-Maybe nothing (just _) = no ฮป ()
Eq._โ_ Eq-Maybe (just a) (just b)
with a โ b
... | no proof = no ฮป where refl โ proof refl
... | yes refl = yes refl
infixl 9 _!?_
_!?_ : {A : Set} โ List A โ โ โ Maybe A
[] !? _ = nothing
(x โท _ ) !? 0 = just x
(_ โท xs) !? (suc n) = xs !? n
-- Like a Haskell list-comprehension for โ : [ n | n <- [from .. to] ]
fromToList : โ โ โ โ List โ
fromToList from to with from โคโฒ? to
... | no ยฌpr = []
... | yes pr = fromToList-le from to pr []
where
fromToList-le : โ (from to : โ) (klel : from โคโฒ to) (acc : List โ) โ List โ
fromToList-le from ._ โคโฒ-refl acc = from โท acc
fromToList-le from (suc to) (โคโฒ-step klel) acc = fromToList-le from to klel (suc to โท acc)
_ : fromToList 1 1 โก 1 โท []
_ = refl
_ : fromToList 1 2 โก 1 โท 2 โท []
_ = refl
_ : fromToList 2 1 โก []
_ = refl
| {
"alphanum_fraction": 0.5291064325,
"avg_line_length": 31.3282674772,
"ext": "agda",
"hexsha": "fb92dc3d7356f043997b28ce0697485d9d6dd972",
"lang": "Agda",
"max_forks_count": 6,
"max_forks_repo_forks_event_max_datetime": "2022-02-18T01:04:32.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-12-16T19:43:52.000Z",
"max_forks_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "oracle/bft-consensus-agda",
"max_forks_repo_path": "LibraBFT/Prelude.agda",
"max_issues_count": 72,
"max_issues_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_issues_repo_issues_event_max_datetime": "2022-03-25T05:36:11.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-02-04T05:04:33.000Z",
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "oracle/bft-consensus-agda",
"max_issues_repo_path": "LibraBFT/Prelude.agda",
"max_line_length": 164,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "oracle/bft-consensus-agda",
"max_stars_repo_path": "LibraBFT/Prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-18T19:24:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-16T19:43:41.000Z",
"num_tokens": 8019,
"size": 20614
} |
{-
Please do not move this file. Changes should only be made if
necessary.
This file contains pointers to the code examples and main results from
the paper:
Synthetic Cohomology Theory in Cubical Agda
-}
-- The "--safe" flag ensures that there are no postulates or
-- unfinished goals
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Papers.ZCohomology where
-- Misc.
open import Cubical.Data.Int hiding (_+_)
open import Cubical.Data.Nat
open import Cubical.Foundations.Everything
open import Cubical.HITs.S1
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
-- II
import Cubical.Foundations.Prelude as Prelude
import Cubical.Foundations.GroupoidLaws as GroupoidLaws
import Cubical.Foundations.Path as Path
open import Cubical.HITs.S1 as S1
open import Cubical.HITs.Susp as Suspension
open import Cubical.HITs.Sn as Sn
open import Cubical.Homotopy.Loopspace as Loop
open import Cubical.Foundations.HLevels as n-types
open import Cubical.HITs.Truncation as Trunc
open import Cubical.Homotopy.Connected as Connected
import Cubical.HITs.Pushout as Push
import Cubical.HITs.Wedge as โ
import Cubical.Foundations.Univalence as Unival
import Cubical.Foundations.SIP as StructIdPrinc
import Cubical.Algebra.Group as Gr
-- III
import Cubical.ZCohomology.Base as coHom
renaming (coHomK to K)
import Cubical.HITs.Sn.Properties as S
import Cubical.ZCohomology.GroupStructure as GroupStructure
import Cubical.ZCohomology.Properties as Properties
renaming (KnโฮฉKn+1 to ฯ ; ฮฉKn+1โKn to ฯโปยน)
import Cubical.Experiments.ZCohomologyOld.Properties as oldCohom
-- IV
import Cubical.Homotopy.EilenbergSteenrod as ES-axioms
import Cubical.ZCohomology.EilenbergSteenrodZ as satisfies-ES-axioms
renaming (coHomFunctor to H^~ ; coHomFunctor' to Hฬ)
import Cubical.ZCohomology.MayerVietorisUnreduced as MayerVietoris
-- V
import Cubical.ZCohomology.Groups.Sn as HโฟSโฟ
renaming (Hโฟ-Sแตโ
0 to Hโฟ-Sแตโ
1)
import Cubical.ZCohomology.Groups.Torus as HโฟTยฒ
import Cubical.ZCohomology.Groups.Wedge as Hโฟ-wedge
import Cubical.ZCohomology.Groups.KleinBottle as Hโฟ๐ยฒ
import Cubical.ZCohomology.Groups.RP2 as HโฟโPยฒ
renaming (Hยน-RPยฒโ
0 to Hยน-RPยฒโ
1)
----- II. HOMOTOPY TYPE THEORY IN CUBICAL AGDA -----
-- II.A Important notions in Cubical Agda
open Prelude using ( PathP
; _โก_
; refl
; cong
; funExt)
open GroupoidLaws using (_โปยน)
open Prelude using ( transport
; subst
; hcomp)
--- II.B Important concepts from HoTT/UF in Cubical Agda
-- The circle, ๐ยน
open S1 using (Sยน)
-- Suspensions
open Suspension using (Susp)
-- n-spheres, ๐โฟ
open Sn using (Sโ)
-- Loop spaces
open Loop using (ฮฉ^_)
-- Eckmann-Hilton argument
open Loop using (Eckmann-Hilton)
-- n-types Note that we start indexing from 0 in the Cubical Library
-- (so (-2)-types as referred to as 0-types, (-1) as 1-types, and so
-- on)
open n-types using (isOfHLevel)
-- truncations
open Trunc using (hLevelTrunc)
-- elimination principle
open Trunc using (elim)
-- elimination principle for paths
truncPathElim : โ {โ โ'} {A : Type โ} {x y : A} (n : โ)
โ {B : Path (hLevelTrunc (suc n) A) โฃ x โฃ โฃ y โฃ โ Type โ'}
โ ((q : _) โ isOfHLevel n (B q))
โ ((p : x โก y) โ B (cong โฃ_โฃ p))
โ (q : _) โ B q
truncPathElim zero hlev ind q = hlev q .fst
truncPathElim (suc n) {B = B} hlev ind q =
subst B (Iso.leftInv (Trunc.PathIdTruncIso _) q)
(help (ฮฉTrunc.encode-fun โฃ _ โฃ โฃ _ โฃ q))
where
help : (q : _) โ B (ฮฉTrunc.decode-fun โฃ _ โฃ โฃ _ โฃ q)
help = Trunc.elim (ฮป _ โ hlev _) ind
-- Connectedness
open Connected using (isConnected)
-- Pushouts
open Push using (Pushout)
-- Wedge sum
open โ using (_โ_)
-- III.C Univalence
-- Univalence and the ua function respectively
open Unival using (univalence ; ua)
-- The structure identity principle and the sip function
-- respectively
open StructIdPrinc using (SIP ; sip)
-- Groups
open Gr using (Group)
----- III. โค-COHOMOLOGY IN CUBICAL AGDA -----
-- III.A Eilenberg-MacLane spaces
-- Eilenberg-MacLane spaces Kโ
open coHom using (K)
-- Proposition 1
open S using (sphereConnected)
-- Lemma 1
open S using (wedgeConSn)
-- restated to match the formulation in the paper
wedgeConSn' : โ {โ} (n m : โ) {A : (Sโ (suc n)) โ (Sโ (suc m)) โ Type โ}
โ ((x : Sโ (suc n)) (y : Sโ (suc m)) โ isOfHLevel ((suc n) + (suc m)) (A x y))
โ (fโ : (x : _) โ A x (ptSn (suc m)))
โ (fแตฃ : (x : _) โ A (ptSn (suc n)) x)
โ (p : fโ (ptSn (suc n)) โก fแตฃ (ptSn (suc m)))
โ ฮฃ[ F โ ((x : Sโ (suc n)) (y : Sโ (suc m)) โ A x y) ]
(ฮฃ[ (left , right) โ ((x : Sโ (suc n)) โ fโ x โก F x (ptSn (suc m)))
ร ((x : Sโ (suc m)) โ fแตฃ x โก F (ptSn (suc n)) x) ]
p โก left (ptSn (suc n)) โ (right (ptSn (suc m))) โปยน)
wedgeConSn' zero zero hlev fโ fแตฃ p =
(wedgeConSn 0 0 hlev fแตฃ fโ p .fst)
, ((ฮป x โ sym (wedgeConSn 0 0 hlev fแตฃ fโ p .snd .snd x))
, ฮป _ โ refl) -- right holds by refl
, rUnit _
wedgeConSn' zero (suc m) hlev fโ fแตฃ p =
(wedgeConSn 0 (suc m) hlev fแตฃ fโ p .fst)
, ((ฮป _ โ refl) -- left holds by refl
, (ฮป x โ sym (wedgeConSn 0 (suc m) hlev fแตฃ fโ p .snd .fst x)))
, lUnit _
wedgeConSn' (suc n) m hlev fโ fแตฃ p =
(wedgeConSn (suc n) m hlev fแตฃ fโ p .fst)
, ((ฮป x โ sym (wedgeConSn (suc n) m hlev fแตฃ fโ p .snd .snd x))
, ฮป _ โ refl) -- right holds by refl
, rUnit _
-- +โ (addition), -โ and 0โ
open GroupStructure using (_+โ_ ; -โ_ ; 0โ)
-- Group laws for +โ
open GroupStructure using ( rUnitโ ; lUnitโ
; rCancelโ ; lCancelโ
; commโ
; assocโ)
-- All group laws are equal to refl at 0โ
-- rUnitโ (definitional)
0-rUnitโกrefl : rUnitโ 0 (0โ 0) โก refl
1-rUnitโกrefl : rUnitโ 1 (0โ 1) โก refl
0-rUnitโกrefl = refl
1-rUnitโกrefl = refl
nโฅ2-rUnitโกrefl : {n : โ} โ rUnitโ (2 + n) (0โ (2 + n)) โก refl
nโฅ2-rUnitโกrefl = refl
-- rUnitโ (definitional)
0-lUnitโกrefl : lUnitโ 0 (0โ 0) โก refl
1-lUnitโกrefl : lUnitโ 1 (0โ 1) โก refl
nโฅ2-lUnitโกrefl : {n : โ} โ lUnitโ (2 + n) (0โ (2 + n)) โก refl
0-lUnitโกrefl = refl
1-lUnitโกrefl = refl
nโฅ2-lUnitโกrefl = refl
-- assocโ (definitional)
0-assocโกrefl : assocโ 0 (0โ 0) (0โ 0) (0โ 0) โก refl
1-assocโกrefl : assocโ 1 (0โ 1) (0โ 1) (0โ 1) โก refl
nโฅ2-assocโกrefl : {n : โ} โ assocโ (2 + n) (0โ (2 + n)) (0โ (2 + n)) (0โ (2 + n)) โก refl
0-assocโกrefl = refl
1-assocโกrefl = refl
nโฅ2-assocโกrefl = refl
-- commโ (โก refl โ refl for n โฅ 2)
0-commโกrefl : commโ 0 (0โ 0) (0โ 0) โก refl
1-commโกrefl : commโ 1 (0โ 1) (0โ 1) โก refl
nโฅ2-commโกrefl : {n : โ} โ commโ (2 + n) (0โ (2 + n)) (0โ (2 + n)) โก refl
0-commโกrefl = refl
1-commโกrefl = refl
nโฅ2-commโกrefl = sym (rUnit refl)
-- lCancelโ (โก refl โ transport refl refl for n = 1
-- and transport refl refl โ transport refl refl for n โฅ 2)
0-lCancelโกrefl : lCancelโ 0 (0โ 0) โก refl
1-lCancelโกrefl : lCancelโ 1 (0โ 1) โก refl
nโฅ2-lCancelโกrefl : {n : โ} โ lCancelโ (2 + n) (0โ (2 + n)) โก refl
0-lCancelโกrefl = refl
1-lCancelโกrefl = sym (lUnit _) โ transportRefl refl
nโฅ2-lCancelโกrefl = rCancel _
-- rCancelโ (โก transport refl refl for n โฅ 1)
0-rCancelโกrefl : rCancelโ 0 (0โ 0) โก refl
1-rCancelโกrefl : rCancelโ 1 (0โ 1) โก refl
nโฅ2-rCancelโกrefl : {n : โ} โ rCancelโ (2 + n) (0โ (2 + n)) โก refl
0-rCancelโกrefl = refl
1-rCancelโกrefl = transportRefl refl
nโฅ2-rCancelโกrefl = transportRefl refl
-- Proof that there is a unique h-structure on Kโ
-- +โ defines an h-Structure on Kโ
open GroupStructure using (_+โ_ ; 0โ ; rUnitโ ; lUnitโ ; lUnitโโกrUnitโ)
-- and so does Brunerie's addition
open oldCohom using (_+โ_ ; 0โ ; rUnitโ ; lUnitโ ; rUnitlUnit0)
-- consequently both additions agree
open GroupStructure using (+โ-unique)
open oldCohom using (addLemma)
additionsAgree : (n : โ) โ GroupStructure._+โ_ {n = n} โก oldCohom._+โ_ {n = n}
additionsAgree zero i x y = oldCohom.addLemma x y (~ i)
additionsAgree (suc n) i x y =
+โ-unique n (GroupStructure._+โ_) (oldCohom._+โ_)
(GroupStructure.rUnitโ (suc n)) (GroupStructure.lUnitโ (suc n))
(oldCohom.rUnitโ (suc n)) (oldCohom.lUnitโ (suc n))
(sym (lUnitโโกrUnitโ (suc n)))
(rUnitlUnit0 (suc n)) x y i
-- The function ฯ : Kโ โ ฮฉKโโโ
open Properties using (ฯ)
-- Theorem 1 (Kโ โ ฮฉKโโโ)
open Properties using (KnโฮฉKn+1)
-- ฯ and ฯโปยน are morphisms
-- (for ฯโปยน this is proved directly without using the fact that ฯ is a morphism)
open Properties using (KnโฮฉKn+1-hom ; ฮฉKn+1โKn-hom)
-- Lemma 2 (p โ q โก congยฒโ(p,q)) for n = 1 and n โฅ 2 respectively
open GroupStructure using (โโก+โ ; โโก+โ)
-- Lemma 3 (congยฒโ is commutative) and Theorem 2 respectively
open GroupStructure using (cong+โ-comm ; isCommฮฉK)
-- III.B Group structure on Hโฟ(A)
-- +โ (addition), -โ and 0โ
open GroupStructure using (_+โ_ ; -โ_ ; 0โ)
-- Cohomology group structure
open GroupStructure using ( rUnitโ ; lUnitโ
; rCancelโ ; lCancelโ
; commโ
; assocโ)
-- Reduced cohomology, group structure
open GroupStructure using (coHomRedGroupDir)
-- Equality of unreduced and reduced cohmology
open Properties using (coHomGroupโกcoHomRedGroup)
----- IV. THE EILENBERG-STEENROD AXIOMS -----
-- IV.A The axioms in HoTT/UF
-- The axioms are defined as a record type
open ES-axioms.coHomTheory
-- Proof of the claim that the alternative reduced cohomology functor
-- Hฬ is the same as the usual reduced cohomology functor
_ : โ {โ} โ satisfies-ES-axioms.H^~ {โ} โก satisfies-ES-axioms.Hฬ
_ = satisfies-ES-axioms.coHomFunctorโกcoHomFunctor'
-- IV.B Verifying the axioms
-- Propositions 2 and 3.
_ : โ {โ} โ ES-axioms.coHomTheory {โ} satisfies-ES-axioms.H^~
_ = satisfies-ES-axioms.isCohomTheoryZ
-- III.C Characterizing Z-cohomology groups using the axioms
-- Theorem 3
open MayerVietoris.MV using ( Ker-iโIm-d ; Im-dโKer-i
; Ker-ฮโIm-i ; Im-iโKer-ฮ
; Ker-dโIm-ฮ ; Im-ฮโKer-d)
----- V. CHARACTERIZING COHOMOLOGY GROUPS DIRECTLY -----
-- V.A
-- Proposition 4 and 5 respectively
open HโฟSโฟ using (Hโฟ-Sโฟโ
โค ; Hโฟ-Sแตโ
1)
-- V.B
-- Proposition 6 and 7 respectively
open HโฟTยฒ using (Hยน-Tยฒโ
โครโค ; Hยฒ-Tยฒโ
โค)
-- V.C
-- Proposition 8 and 9 respectively (Hโฟ(๐ยฒ))
-- โค/2โค is represented by Bool with the unique group structure
open Hโฟ๐ยฒ using (Hยน-๐ยฒโ
โค ; Hยฒ-๐ยฒโ
Bool)
-- First and second cohomology groups of โPยฒ respectively
open HโฟโPยฒ using (Hยน-RPยฒโ
1 ; Hยฒ-RPยฒโ
Bool)
----- VI. COMPUTING WITH THE COHOMOLOGY GROUPS -----
import Cubical.Experiments.ZCohomology.Benchmarks
| {
"alphanum_fraction": 0.6200234721,
"avg_line_length": 31.6485714286,
"ext": "agda",
"hexsha": "d86632ba48302c5c2828bd46154f73ed0de2fc40",
"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/Papers/ZCohomology.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/Papers/ZCohomology.agda",
"max_line_length": 90,
"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/Papers/ZCohomology.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4177,
"size": 11077
} |
{-# OPTIONS --cubical --safe #-}
module Data.List.Mapping.StringMap where
open import Data.String using (String; stringOrd)
open import Data.List.Mapping stringOrd public
open import Prelude
open import Data.Maybe
-- example : Record (โ
[ "name" ]๏ธ String [ "age" ]๏ธ โ [ "occ" ]๏ธ Bool)
-- example =
-- โ
[ "age" ]โ 30
-- [ "occ" ]โ true
-- [ "name" ]โ "Jo"
| {
"alphanum_fraction": 0.6129032258,
"avg_line_length": 24.8,
"ext": "agda",
"hexsha": "9e4aca304afc9dcad5264b583ffde4b97c14989f",
"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/List/Mapping/StringMap.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/List/Mapping/StringMap.agda",
"max_line_length": 71,
"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/List/Mapping/StringMap.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": 119,
"size": 372
} |
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Data.NatMinusOne.Base where
open import Cubical.Core.Primitives
open import Cubical.Data.Nat
open import Cubical.Data.Empty
open import Cubical.Data.Int.Base using (โค; pos; negsuc; -_)
record โโโ : Typeโ where
constructor -1+_
field
n : โ
pattern neg1 = -1+ zero
pattern โโโโโ n = -1+ (suc n)
1+_ : โโโ โ โ
1+_ (-1+ n) = n
sucโโ : โโโ โ โโโ
sucโโ (-1+ n) = -1+ (suc n)
-- Natural number and negative integer literals for โโโ
open import Cubical.Data.Nat.Literals public
instance
fromNatโโโ : FromNat โโโ
fromNatโโโ = record { Constraint = ฮป _ โ โค ; fromNat = โโโโโ }
instance
negativeโโโ : Negative โโโ
negativeโโโ = record { Constraint = ฮป { (suc (suc _)) โ โฅ ; _ โ โค }
; fromNeg = ฮป { zero โ 0 ; (suc zero) โ neg1 } }
| {
"alphanum_fraction": 0.6305882353,
"avg_line_length": 24.2857142857,
"ext": "agda",
"hexsha": "be040de923ad0fa61bdb654584d061a74db93c4a",
"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/Data/NatMinusOne/Base.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/Data/NatMinusOne/Base.agda",
"max_line_length": 70,
"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/Data/NatMinusOne/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 321,
"size": 850
} |
module Luau.Syntax where
open import Agda.Builtin.Equality using (_โก_)
open import Agda.Builtin.Float using (Float)
open import Properties.Dec using (โฅ)
open import Luau.Var using (Var)
open import Luau.Addr using (Addr)
open import Luau.Type using (Type)
infixr 5 _โ_
data Annotated : Set where
maybe : Annotated
yes : Annotated
data VarDec : Annotated โ Set where
var : Var โ VarDec maybe
var_โ_ : โ {a} โ Var โ Type โ VarDec a
name : โ {a} โ VarDec a โ Var
name (var x) = x
name (var x โ T) = x
data FunDec : Annotated โ Set where
_โจ_โฉโ_ : โ {a} โ Var โ VarDec a โ Type โ FunDec a
_โจ_โฉ : Var โ VarDec maybe โ FunDec maybe
fun : โ {a} โ FunDec a โ Var
fun (f โจ x โฉโ T) = f
fun (f โจ x โฉ) = f
arg : โ {a} โ FunDec a โ VarDec a
arg (f โจ x โฉโ T) = x
arg (f โจ x โฉ) = x
data BinaryOperator : Set where
+ : BinaryOperator
- : BinaryOperator
* : BinaryOperator
/ : BinaryOperator
data Block (a : Annotated) : Set
data Stat (a : Annotated) : Set
data Expr (a : Annotated) : Set
data Block a where
_โ_ : Stat a โ Block a โ Block a
done : Block a
data Stat a where
function_is_end : FunDec a โ Block a โ Stat a
local_โ_ : VarDec a โ Expr a โ Stat a
return : Expr a โ Stat a
data Expr a where
nil : Expr a
var : Var โ Expr a
addr : Addr โ Expr a
_$_ : Expr a โ Expr a โ Expr a
function_is_end : FunDec a โ Block a โ Expr a
block_is_end : Var โ Block a โ Expr a
number : Float โ Expr a
binexp : Expr a โ BinaryOperator โ Expr a โ Expr a
| {
"alphanum_fraction": 0.6336700337,
"avg_line_length": 23.203125,
"ext": "agda",
"hexsha": "c1c31e4241a6e757edd7234607abfdcbdded61e6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Tr4shh/Roblox-Luau",
"max_forks_repo_path": "prototyping/Luau/Syntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Tr4shh/Roblox-Luau",
"max_issues_repo_path": "prototyping/Luau/Syntax.agda",
"max_line_length": 52,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Tr4shh/Roblox-Luau",
"max_stars_repo_path": "prototyping/Luau/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 524,
"size": 1485
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Component functions of permutations found in `Data.Fin.Permutation`
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Fin.Permutation.Components where
open import Data.Fin
open import Data.Fin.Properties
open import Data.Nat as โ using (zero; suc; _โธ_)
import Data.Nat.Properties as โโ
open import Data.Product using (projโ)
open import Relation.Nullary using (yes; no)
open import Relation.Binary.PropositionalEquality
open import Algebra.FunctionProperties using (Involutive)
open โก-Reasoning
--------------------------------------------------------------------------------
-- Functions
--------------------------------------------------------------------------------
-- 'tranpose i j' swaps the places of 'i' and 'j'.
transpose : โ {n} โ Fin n โ Fin n โ Fin n โ Fin n
transpose i j k with k โ i
... | yes _ = j
... | no _ with k โ j
... | yes _ = i
... | no _ = k
-- reverse i = n โธ 1 โธ i
reverse : โ {n} โ Fin n โ Fin n
reverse {zero} ()
reverse {suc n} i = injectโค (n โ- i) (โโ.nโธmโคn (toโ i) (suc n))
--------------------------------------------------------------------------------
-- Properties
--------------------------------------------------------------------------------
transpose-inverse : โ {n} (i j : Fin n) {k} โ
transpose i j (transpose j i k) โก k
transpose-inverse i j {k} with k โ j
... | yes p rewrite โก-โ-identity _โ_ {a = i} refl = sym p
... | no ยฌp with k โ i
transpose-inverse i j {k} | no ยฌp | yes q with j โ i
... | yes r = trans r (sym q)
... | no ยฌr rewrite โก-โ-identity _โ_ {a = j} refl = sym q
transpose-inverse i j {k} | no ยฌp | no ยฌq
rewrite projโ (โข-โ-identity _โ_ ยฌq)
| projโ (โข-โ-identity _โ_ ยฌp) = refl
reverse-prop : โ {n} โ (i : Fin n) โ toโ (reverse i) โก n โธ suc (toโ i)
reverse-prop {zero} ()
reverse-prop {suc n} i = begin
toโ (injectโค (n โ- i) _) โกโจ toโ-injectโค _ _ โฉ
toโ (n โ- i) โกโจ toโโฟโ- n i โฉ
n โธ toโ i โ
reverse-involutive : โ {n} โ Involutive _โก_ (reverse {n})
reverse-involutive {zero} ()
reverse-involutive {suc n} i = toโ-injective (begin
toโ (reverse (reverse i)) โกโจ reverse-prop (reverse i) โฉ
n โธ (toโ (reverse i)) โกโจ cong (n โธ_) (reverse-prop i) โฉ
n โธ (n โธ (toโ i)) โกโจ โโ.mโธ[mโธn]โกn (โโ.โค-pred (toโ<n i)) โฉ
toโ i โ)
reverse-suc : โ {n}{i : Fin n} โ toโ (reverse (suc i)) โก toโ (reverse i)
reverse-suc {n} {i} = begin
toโ (reverse (suc i)) โกโจ reverse-prop (suc i) โฉ
suc n โธ suc (toโ (suc i)) โกโจโฉ
n โธ toโ (suc i) โกโจโฉ
n โธ suc (toโ i) โกโจ sym (reverse-prop i) โฉ
toโ (reverse i) โ
| {
"alphanum_fraction": 0.470545977,
"avg_line_length": 35.6923076923,
"ext": "agda",
"hexsha": "f6bfb50e81fd02a2e7bece4ec122831cf1c60775",
"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/Fin/Permutation/Components.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/Fin/Permutation/Components.agda",
"max_line_length": 80,
"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/Fin/Permutation/Components.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 940,
"size": 2784
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.Embedding where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Isomorphism
private
variable
โ : Level
A B : Type โ
f : A โ B
w x : A
y z : B
-- Embeddings are generalizations of injections. The usual
-- definition of injection as:
--
-- f x โก f y โ x โก y
--
-- is not well-behaved with higher h-levels, while embeddings
-- are.
isEmbedding : (A โ B) โ Type _
isEmbedding f = โ w x โ isEquiv {A = w โก x} (cong f)
isEmbeddingIsProp : isProp (isEmbedding f)
isEmbeddingIsProp {f = f}
= propPi ฮป w โ propPi ฮป x โ isPropIsEquiv (cong f)
-- If A and B are h-sets, then injective functions between
-- them are embeddings.
--
-- Note: It doesn't appear to be possible to omit either of
-- the `isSet` hypotheses.
injEmbedding
: {f : A โ B}
โ isSet A โ isSet B
โ (โ{w x} โ f w โก f x โ w โก x)
โ isEmbedding f
injEmbedding {f = f} iSA iSB inj w x
= isoToIsEquiv (iso (cong f) inj sect retr)
where
sect : section (cong f) inj
sect p = iSB (f w) (f x) _ p
retr : retract (cong f) inj
retr p = iSA w x _ p
private
lemmaโ : (p : y โก z) โ fiber f y โก fiber f z
lemmaโ {f = f} p = ฮป i โ fiber f (p i)
lemmaโ : isEmbedding f โ โ x โ isContr (fiber f (f x))
lemmaโ {f = f} iE x = value , path
where
value : fiber f (f x)
value = (x , refl)
path : โ(fi : fiber f (f x)) โ value โก fi
path (w , p) i
= case equiv-proof (iE w x) p of ฮป
{ ((q , sq) , _)
โ hfill (ฮป j โ ฮป { (i = i0) โ (x , refl)
; (i = i1) โ (w , sq j)
})
(inS (q (~ i) , ฮป j โ f (q (~ i โจ j))))
i1
}
-- If `f` is an embedding, we'd expect the fibers of `f` to be
-- propositions, like an injective function.
hasPropFibers : (A โ B) โ Type _
hasPropFibers f = โ y โ isProp (fiber f y)
hasPropFibersIsProp : isProp (hasPropFibers f)
hasPropFibersIsProp = propPi (ฮป _ โ isPropIsProp)
isEmbeddingโhasPropFibers : isEmbedding f โ hasPropFibers f
isEmbeddingโhasPropFibers iE y (x , p)
= subst (ฮป f โ isProp f) (lemmaโ p) (isContrโisProp (lemmaโ iE x)) (x , p)
private
fibCongโPathP
: {f : A โ B}
โ (p : f w โก f x)
โ (fi : fiber (cong f) p)
โ PathP (ฮป i โ fiber f (p i)) (w , refl) (x , refl)
fibCongโPathP p (q , r) i = q i , ฮป j โ r j i
PathPโfibCong
: {f : A โ B}
โ (p : f w โก f x)
โ (pp : PathP (ฮป i โ fiber f (p i)) (w , refl) (x , refl))
โ fiber (cong f) p
PathPโfibCong p pp = (ฮป i โ fst (pp i)) , (ฮป j i โ snd (pp i) j)
PathPโกfibCong
: {f : A โ B}
โ (p : f w โก f x)
โ PathP (ฮป i โ fiber f (p i)) (w , refl) (x , refl) โก fiber (cong f) p
PathPโกfibCong p
= isoToPath (iso (PathPโfibCong p) (fibCongโPathP p) (ฮป _ โ refl) (ฮป _ โ refl))
hasPropFibersโisEmbedding : hasPropFibers f โ isEmbedding f
hasPropFibersโisEmbedding {f = f} iP w x .equiv-proof p
= subst isContr (PathPโกfibCong p) (isPropโisContrPathP iP p fw fx)
where
fw : fiber f (f w)
fw = (w , refl)
fx : fiber f (f x)
fx = (x , refl)
isEmbeddingโกhasPropFibers : isEmbedding f โก hasPropFibers f
isEmbeddingโกhasPropFibers
= isoToPath
(iso isEmbeddingโhasPropFibers
hasPropFibersโisEmbedding
(ฮป _ โ hasPropFibersIsProp _ _)
(ฮป _ โ isEmbeddingIsProp _ _))
| {
"alphanum_fraction": 0.5960828839,
"avg_line_length": 27.7401574803,
"ext": "agda",
"hexsha": "a89627c264d41f0d320627e8bc6e4e54b604f560",
"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/Foundations/Embedding.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/Foundations/Embedding.agda",
"max_line_length": 81,
"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/Foundations/Embedding.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1330,
"size": 3523
} |
module ModuleDoesntExport where
module A where
postulate C : Set
open A using (B; module P) renaming (D to C)
| {
"alphanum_fraction": 0.7304347826,
"avg_line_length": 14.375,
"ext": "agda",
"hexsha": "0cc3aa5118fa01f6e1cecc78bd4ad00102d9af39",
"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/ModuleDoesntExport.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/ModuleDoesntExport.agda",
"max_line_length": 44,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/ModuleDoesntExport.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": 33,
"size": 115
} |
{-# OPTIONS --without-K --safe #-}
open import Level using (Level)
open import Relation.Binary.PropositionalEquality hiding (Extensionality)
open โก-Reasoning
open import Data.Nat using (โ; suc; zero; _+_)
open import Data.Nat.Properties
open import Data.Product using (_,_)
open import Data.Vec using (Vec; foldr; zipWith; map; []; _โท_; _++_; take; drop; splitAt; replicate)
open import Data.Vec.Properties
module FLA.Data.Vec.Properties where
private
variable
โ : Level
A B C : Set โ
m n : โ
++-identityโ : (v : Vec A n) โ [] ++ v โก v
++-identityโ _ = refl
| {
"alphanum_fraction": 0.6844827586,
"avg_line_length": 23.2,
"ext": "agda",
"hexsha": "716a6ee4768984736d8a6c6e5646421153220434",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z",
"max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "turion/functional-linear-algebra",
"max_forks_repo_path": "src/FLA/Data/Vec/Properties.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "turion/functional-linear-algebra",
"max_issues_repo_path": "src/FLA/Data/Vec/Properties.agda",
"max_line_length": 100,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "turion/functional-linear-algebra",
"max_stars_repo_path": "src/FLA/Data/Vec/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z",
"num_tokens": 174,
"size": 580
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed M-types (the dual of indexed W-types aka Petersson-Synek
-- trees).
------------------------------------------------------------------------
module Data.M.Indexed where
open import Level
open import Coinduction
open import Data.Product
open import Data.Container.Indexed.Core
open import Function
open import Relation.Unary
-- The family of indexed M-types.
module _ {โ c r} {O : Set โ} (C : Container O O c r) where
data M (o : O) : Set (โ โ c โ r) where
inf : โฆ C โง (โ โ M) o โ M o
open Container C
-- Projections.
head : M โ Command
head (inf (c , _)) = c
tail : โ {o} (m : M o) (r : Response (head m)) โ M (next (head m) r)
tail (inf (_ , k)) r = โญ (k r)
force : M โ โฆ C โง M
force (inf (c , k)) = c , ฮป r โ โญ (k r)
-- Coiteration.
coit : โ {โ} {X : Pred O โ} โ X โ โฆ C โง X โ X โ M
coit ฯ x = inf (projโ cs , ฮป r โ โฏ coit ฯ (projโ cs r))
where
cs = ฯ x
| {
"alphanum_fraction": 0.4911764706,
"avg_line_length": 23.7209302326,
"ext": "agda",
"hexsha": "efd87f9d0899f521e5a92c35deec456278a95c34",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/M/Indexed.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/M/Indexed.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/Data/M/Indexed.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": 335,
"size": 1020
} |
{-# OPTIONS --without-K #-}
module function.isomorphism.two-out-of-six where
open import sum
open import equality
open import function.core
open import function.isomorphism.core
open import function.overloading
open import hott.equivalence.core
open import hott.equivalence.biinvertible
module two-out-of-six
{i j k l}{X : Set i}{Y : Set j}{Z : Set k}{W : Set l}
(f : X โ Y)(g : Y โ Z)(h : Z โ W)
(gf-equiv : weak-equiv (g โ f))
(hg-equiv : weak-equiv (h โ g)) where
private
r : X โ
Z
r = โโโ
(g โ f , gf-equiv)
s : Y โ
W
s = โโโ
(h โ g , hg-equiv)
gl : Z โ Y
gl = invert s โ h
gr : Z โ Y
gr = f โ invert r
g-iso : Y โ
Z
g-iso = bโโ
(g , (gl , _โ
_.isoโ s) , (gr , _โ
_.isoโ r))
f-iso : X โ
Y
f-iso = record
{ to = f
; from = ฮป y โ invert r (g y)
; isoโ = _โ
_.isoโ r
; isoโ = ฮป y โ sym (_โ
_.isoโ g-iso (f (invert r (g y))))
ยท ap (invert g-iso) (_โ
_.isoโ r (g y))
ยท _โ
_.isoโ g-iso y }
h-iso : Z โ
W
h-iso = record
{ to = h
; from = ฮป w โ g (invert s w)
; isoโ = ฮป z โ sym (ap (ฮป z โ g (invert s (h z))) (_โ
_.isoโ g-iso z))
ยท ap g (_โ
_.isoโ s (invert g-iso z))
ยท _โ
_.isoโ g-iso z
; isoโ = _โ
_.isoโ s }
| {
"alphanum_fraction": 0.4937888199,
"avg_line_length": 25.76,
"ext": "agda",
"hexsha": "6ffefed050c26399766c28dc1e294f987844bba5",
"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/function/isomorphism/two-out-of-six.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/function/isomorphism/two-out-of-six.agda",
"max_line_length": 73,
"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/function/isomorphism/two-out-of-six.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": 500,
"size": 1288
} |
module _ {I : Set} where
postulate
f : โ {T : I โ Set} {i} โ T i โ Set
variable
i : I
T : I โ Set
v : T i
t : f v
t = {!!}
| {
"alphanum_fraction": 0.437037037,
"avg_line_length": 9.6428571429,
"ext": "agda",
"hexsha": "4fc1774492e4623f77b0f550c13b8e659ea66e21",
"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/Issue3401.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/Issue3401.agda",
"max_line_length": 37,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue3401.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 62,
"size": 135
} |
{-
Definition of finite sets
A set is finite if it is merely equivalent to `Fin n` for some `n`. We
can translate this to code in two ways: a truncated sigma of a nat and
an equivalence, or a sigma of a nat and a truncated equivalence. We
prove that both formulations are equivalent.
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.FinSet where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Logic
open import Cubical.Foundations.Function
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Equiv
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Data.Unit
open import Cubical.Data.Nat
open import Cubical.Data.Fin
open import Cubical.Data.Sigma
private
variable
โ : Level
A : Type โ
isFinSet : Type โ โ Type โ
isFinSet A = โ[ n โ โ ] A โ Fin n
isProp-isFinSet : isProp (isFinSet A)
isProp-isFinSet = propTruncIsProp
FinSet : Type (โ-suc โ)
FinSet = TypeWithStr _ isFinSet
isFinSetFin : โ {n} โ isFinSet (Fin n)
isFinSetFin = โฃ _ , pathToEquiv refl โฃ
isFinSetUnit : isFinSet Unit
isFinSetUnit = โฃ 1 , UnitโFin1 โฃ
isFinSetฮฃ : Type โ โ Type โ
isFinSetฮฃ A = ฮฃ[ n โ โ ] โฅ A โ Fin n โฅ
FinSetฮฃ : Type (โ-suc โ)
FinSetฮฃ = TypeWithStr _ isFinSetฮฃ
isProp-isFinSetฮฃ : isProp (isFinSetฮฃ A)
isProp-isFinSetฮฃ {A = A} (n , equivn) (m , equivm) =
ฮฃโกProp (ฮป _ โ propTruncIsProp) nโกm
where
Fin-nโFin-m : โฅ Fin n โ Fin m โฅ
Fin-nโFin-m = rec
propTruncIsProp
(rec
(isPropฮ ฮป _ โ propTruncIsProp)
(ฮป hm hn โ โฃ Fin n โโจ invEquiv hn โฉ A โโจ hm โฉ Fin m โ โฃ)
equivm
)
equivn
Fin-nโกFin-m : โฅ Fin n โก Fin m โฅ
Fin-nโกFin-m = rec propTruncIsProp (โฃ_โฃ โ ua) Fin-nโFin-m
โฅnโกmโฅ : โฅ n โก m โฅ
โฅnโกmโฅ = rec propTruncIsProp (โฃ_โฃ โ Fin-inj n m) Fin-nโกFin-m
nโกm : n โก m
nโกm = rec (isSetโ n m) (ฮป p โ p) โฅnโกmโฅ
isFinSetโกisFinSetฮฃ : isFinSet A โก isFinSetฮฃ A
isFinSetโกisFinSetฮฃ {A = A} = hPropExt isProp-isFinSet isProp-isFinSetฮฃ to from
where
to : isFinSet A โ isFinSetฮฃ A
to โฃ n , equiv โฃ = n , โฃ equiv โฃ
to (squash p q i) = isProp-isFinSetฮฃ (to p) (to q) i
from : isFinSetฮฃ A โ isFinSet A
from (n , โฃ isFinSet-A โฃ) = โฃ n , isFinSet-A โฃ
from (n , squash p q i) = isProp-isFinSet (from (n , p)) (from (n , q)) i
FinSetโกFinSetฮฃ : FinSet {โ} โก FinSetฮฃ
FinSetโกFinSetฮฃ = ua (isoToEquiv (iso to from to-from from-to))
where
to : FinSet โ FinSetฮฃ
to (A , isFinSetA) = A , transport isFinSetโกisFinSetฮฃ isFinSetA
from : FinSetฮฃ โ FinSet
from (A , isFinSetฮฃA) = A , transport (sym isFinSetโกisFinSetฮฃ) isFinSetฮฃA
to-from : โ A โ to (from A) โก A
to-from A = ฮฃโกProp (ฮป _ โ isProp-isFinSetฮฃ) refl
from-to : โ A โ from (to A) โก A
from-to A = ฮฃโกProp (ฮป _ โ isProp-isFinSet) refl
card : FinSet {โ} โ โ
card = fst โ snd โ transport FinSetโกFinSetฮฃ
| {
"alphanum_fraction": 0.6568127761,
"avg_line_length": 27.7641509434,
"ext": "agda",
"hexsha": "791a2cc10ebf0337972f6f334602feab6cc108c1",
"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": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/Data/FinSet.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"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": "knrafto/cubical",
"max_issues_repo_path": "Cubical/Data/FinSet.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/Data/FinSet.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1181,
"size": 2943
} |
module Data.Collection.Core where
open import Data.List public using (List; []; _โท_)
open import Data.String public using (String; _โ_)
open import Level using (zero)
open import Function using (flip)
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Relation.Nullary.Decidable renaming (map to mapDec; mapโฒ to mapDecโฒ)
open import Relation.Unary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
--------------------------------------------------------------------------------
-- Types
--------------------------------------------------------------------------------
Element : Set
Element = String
Collection : Set
Collection = List Element
Membership : Set _
Membership = Pred Element zero
--------------------------------------------------------------------------------
-- Membership
--------------------------------------------------------------------------------
infix 4 _โc_ _โc_
data _โc_ : REL Element Collection zero where
here : โ { x A} โ x โc x โท A
there : โ {a x A} โ x โc A โ x โc a โท A
_โc_ : REL Element Collection _
x โc A = ยฌ x โc A
infixr 6 _โ_
-- I know this notation is a bit confusing
_โ_ : โ {a โโ โโ} {A : Set a} โ Pred A โโ โ Pred A โโ โ Set _
P โ Q = โ {x} โ x โ P โ x โ Q
c[_] : REL Collection Element zero
c[_] = flip _โc_
infix 4 _โ?_
_โ?_ : (x : Element) โ (A : Collection) โ Dec (x โ c[ A ])
x โ? [] = no (ฮป ())
x โ? ( a โท A) with x โ a
x โ? (.x โท A) | yes refl = yes here
x โ? ( a โท A) | no ยฌp = mapDecโฒ there (there-if-not-here ยฌp) (x โ? A)
where
there-if-not-here : โ {x a A} โ x โข a โ x โ c[ a โท A ] โ x โ c[ A ]
there-if-not-here xโขa here = contradiction refl xโขa
there-if-not-here xโขa (there xโaโทA) = xโaโทA
--------------------------------------------------------------------------------
-- Miscs
--------------------------------------------------------------------------------
--
-- โท-โ-monotone : โ {a A B} โ c[ A ] โ c[ B ] โ c[ a โท A ] โ c[ a โท B ]
-- โท-โ-monotone f here = here
-- โท-โ-monotone f (there โA) = there (f โA)
| {
"alphanum_fraction": 0.4503061705,
"avg_line_length": 30.768115942,
"ext": "agda",
"hexsha": "0af8dee271db875cf28ab8e084757cf5e3a42091",
"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": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/lambda-calculus",
"max_forks_repo_path": "Data/Collection/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a",
"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/lambda-calculus",
"max_issues_repo_path": "Data/Collection/Core.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/lambda-calculus",
"max_stars_repo_path": "Data/Collection/Core.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 628,
"size": 2123
} |
------------------------------------------------------------------------
-- Parser monad
------------------------------------------------------------------------
open import Relation.Binary
open import Relation.Binary.OrderMorphism
open import Relation.Binary.PropositionalEquality hiding (poset)
import Relation.Binary.Properties.StrictTotalOrder as STOProps
open import Data.Product
open import Level
module MonadPostulates where
postulate
-- Input string positions.
Position : Set
_<P_ : Rel Position zero
posOrdered : IsStrictTotalOrder _โก_ _<P_
-- Input strings.
Input : Position -> Set
-- In order to be able to store results in a memo table (and avoid
-- having to lift the table code to Set1) the result types have to
-- come from the following universe:
Result : Set
โฆ_โง : Result -> Set
-- Memoisation keys. These keys must uniquely identify the
-- computation that they are associated with, when paired up with
-- the current input string position.
Key : let PosPoset = STOProps.poset
(record { Carrier = _ ; _โ_ = _; _<_ = _
; isStrictTotalOrder = posOrdered })
MonoFun = PosPoset โ-Poset PosPoset in
MonoFun -> Result -> Set
_โ'_ _<_ : Rel (โโ Key) zero
keyOrdered : IsStrictTotalOrder _โ'_ _<_
-- Furthermore the underlying equality needs to be strong enough.
funsEqual : _โ'_ =[ projโ ]โ _โก_
resultsEqual : _โ'_ =[ (\rfk -> projโ (projโ rfk)) ]โ _โก_
-- where
open _โ-Poset_
open STOProps (record { Carrier = _ ; _โ_ = _; _<_ = _
; isStrictTotalOrder = posOrdered })
import IndexedMap as Map -- renaming (Map to MemoTable)
open import Effect.Monad
open import Effect.Monad.State
import Data.List as List; open List using (List)
open import Data.Unit
open import Function
open import Data.Maybe
open import Data.Product.Relation.Binary.Lex.Strict
open import Data.Product.Relation.Binary.Pointwise.NonDependent
import Relation.Binary.Construct.On as On
------------------------------------------------------------------------
-- Monotone functions
MonoFun : Set
MonoFun = poset โ-Poset poset
------------------------------------------------------------------------
-- Memo tables
-- Indices and keys used by the memo table.
Index : Set
Index = Position ร MonoFun ร Result
data MemoTableKey : Index -> Set where
key : forall {f r} (key : Key f r) pos -> MemoTableKey (pos , f , r)
-- Input strings of a certain maximum length.
Inputโค : Position -> Set
Inputโค pos = โ \posโฒ -> posโฒ โค pos ร Input posโฒ
-- Memo table values.
Value : Index -> Set
Value (pos , f , r) = List (โฆ r โง ร Inputโค (fun f pos))
-- Shuffles the elements to simplify defining equality and order
-- relations for the keys.
shuffle : โ MemoTableKey -> Position ร โโ Key
shuffle ((pos , f , r) , key k .pos) = (pos , f , r , k)
-- Equality and order.
Eq : Rel (โ MemoTableKey) _
Eq = Pointwise _โก_ _โ'_ on shuffle
Lt : Rel (โ MemoTableKey) _
Lt = ร-Lex _โก_ _<P_ _<_ on shuffle
isOrdered : IsStrictTotalOrder Eq Lt
isOrdered = On.isStrictTotalOrder shuffle
(ร-isStrictTotalOrder posOrdered keyOrdered)
indicesEqualโฒ : Eq =[ projโ ]โ _โก_
indicesEqualโฒ {((_ , _ , _) , key _ ._)}
{((_ , _ , _) , key _ ._)} (eqโ , eqโ) =
congโ _,_ eqโ (congโ _,_ (funsEqual eqโ) (resultsEqual eqโ))
open Map isOrdered (\{kโ} {kโ} -> indicesEqualโฒ {kโ} {kโ}) Value
{-
------------------------------------------------------------------------
-- Parser monad
-- The parser monad is built upon a list monad, for backtracking, and
-- two state monads. One of the state monads stores a memo table, and
-- is unaffected by backtracking. The other state monad, which /is/
-- affected by backtracking, stores the remaining input string.
-- The memo table state monad.
module MemoState = RawMonadState (StateMonadState MemoTable)
-- The list monad.
module List = RawMonadPlus List.ListMonadPlus
-- The inner monad (memo table plus list).
module IM where
Inner : Set -> Set
Inner R = State MemoTable (List R)
InnerMonadPlus : RawMonadPlus Inner
InnerMonadPlus = record
{ monadZero = record
{ monad = record
{ return = \x -> return (List.return x)
; _>>=_ = \m f -> List.concat <$> (List.mapM monad f =<< m)
}
; โ
= return List.โ
}
; _โฃ_ = \mโ mโ -> List._โฃ_ <$> mโ โ mโ
}
where
open MemoState
InnerMonadState : RawMonadState MemoTable Inner
InnerMonadState = record
{ monad = RawMonadPlus.monad InnerMonadPlus
; get = List.return <$> get
; put = \s -> List.return <$> put s
}
where open MemoState
open RawMonadPlus InnerMonadPlus public
open RawMonadState InnerMonadState public
using (get; put; modify)
-- The complete parser monad.
module PM where
P : MonoFun -> Set -> Set
P f A = forall {n} -> Input n -> IM.Inner (A ร Inputโค (fun f n))
-- Memoises the computation, assuming that the key is sufficiently
-- unique.
memoise : forall {f r} -> Key f r -> P f โฆ r โง -> P f โฆ r โง
memoise k p {pos} xs =
let open IM in helper =<< lookup kโฒ <$> get
where
i = (pos , _)
kโฒ : MemoTableKey i
kโฒ = key k pos
helper : Maybe (Value i) -> State MemoTable (Value i)
helper (just ris) = return ris where open MemoState
helper nothing = p xs >>= \ris ->
modify (insert kโฒ ris) >>
return ris
where open MemoState
-- Other monadic operations.
return : forall {A} -> A -> P idM A
return a = \xs -> IM.return (a , _ , refl , xs)
_>>=_ : forall {A B f g} -> P f A -> (A -> P g B) -> P (g โM f) B
_>>=_ {g = g} mโ mโ xs =
mโ xs โจ IM._>>=_ โฉ \ays ->
let a = projโ ays
le = projโ $ projโ $ projโ ays
ys = projโ $ projโ $ projโ ays in
fix le โจ IM._<$>_ โฉ mโ a ys
where
lemma : forall {i j k} -> j โค k -> i โค fun g j -> i โค fun g k
lemma jโคk iโคgj = trans iโคgj (monotone g jโคk)
fix : forall {A i j} -> i โค j ->
A ร Inputโค (fun g i) ->
A ร Inputโค (fun g j)
fix le = map-ร id (map-ฮฃ id (map-ร (lemma le) id))
โ
: forall {A} -> P idM A
โ
= const IM.โ
_โฃ_ : forall {A f} -> P f A -> P f A -> P f A
mโ โฃ mโ = \xs -> IM._โฃ_ (mโ xs) (mโ xs)
put : forall {n} -> Input n -> P (constM n) โค
put xs = \_ -> IM.return (_ , _ , refl , xs)
modify : forall {A f} ->
(forall {n} -> Input n -> A ร Input (fun f n)) ->
P f A
modify g xs = IM.return (projโ gxs , _ , refl , projโ gxs)
where gxs = g xs
-}
| {
"alphanum_fraction": 0.5777272727,
"avg_line_length": 28.6956521739,
"ext": "agda",
"hexsha": "ebe16f2e27a97e320bdb2786a165aa3e8dc9f76d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "benchmark/monad/MonadPostulates.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "benchmark/monad/MonadPostulates.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "benchmark/monad/MonadPostulates.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1943,
"size": 6600
} |
module Prelude where
infixr 50 _,_
infixl 40 _โ_
infix 30 _โ_
data _ร_ (A B : Set) : Set where
_,_ : A -> B -> A ร B
data List (A : Set) : Set where
ฮต : List A
_โ_ : List A -> A -> List A
data _โ_ {A : Set}(x : A) : List A -> Set where
hd : forall {xs} -> x โ xs โ x
tl : forall {y xs} -> x โ xs -> x โ xs โ y
data Box {A : Set}(P : A -> Set) : List A -> Set where
โจโฉ : Box P ฮต
_โ_ : forall {xs x} -> Box P xs -> P x -> Box P (xs โ x)
_!_ : {A : Set}{P : A -> Set}{xs : List A}{x : A} ->
Box P xs -> x โ xs -> P x
โจโฉ ! ()
(_ โ v) ! hd = v
(ฯ โ _) ! tl x = ฯ ! x
| {
"alphanum_fraction": 0.4413680782,
"avg_line_length": 21.1724137931,
"ext": "agda",
"hexsha": "344b77163f73c18e4a32fcbc49822240e82fa685",
"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/sinatra/Prelude.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/sinatra/Prelude.agda",
"max_line_length": 58,
"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/sinatra/Prelude.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": 270,
"size": 614
} |
-- This module introduces the basic structure of an Agda program.
{- Every Agda file contains a single top-level module. To make it possible to
find the file corresponding to a particular module, the name of the file
should correspond to the name of the module. In this case the module
'Introduction.Basics' is defined in the file 'Introduction/Basics.agda'.
-}
module Basics where
{- The top-level module contains a sequence of declarations, such as datatype
declarations and function definitions. The most common forms of declarations
are introduced below.
A module can also contain sub-modules, see 'Introduction.Modules.SubModules'
for more information.
-}
-- Agda can be used as a pure logical framework. The 'postulate' declaration
-- introduces new constants :
postulate
N : Set -- Set is the first universe
z : N
s : N -> N -- The independent function space is written A -> B
-- Using 'postulate' it is not possible to introduce new computation rules. A
-- better way is to introduce a datatype and define functions by pattern
-- matching on elements of the datatype.
-- A datatype is introduced with the 'data' keyword. All constructors of the
-- datatype are given with their types after the 'where'. Datatypes can be
-- parameterised (see 'Introduction.Data.Parameterised').
data Bool : Set where
false : Bool
true : Bool
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- Functions over datatypes can be defined by pattern matching.
plus : Nat -> Nat -> Nat
plus zero m = m
plus (suc n) m = suc (plus n m)
-- With this definition plus (suc zero) (suc zero) will reduce to suc (suc
-- zero).
-- When defining mutually recursive functions you have to declare functions
-- before they can be called.
odd : Nat -> Bool
even : Nat -> Bool
even (suc n) = odd n
even zero = true
odd zero = false
odd (suc n) = even n
-- Agda is a monomorphic, but dependently typed, language. This means that
-- polymorphism is simulated by having functions take type arguments. For
-- instance, the polymorphic identity function can be represented as follows :
id : (A : Set) -> A -> A -- the dependent function space is written (x : A) -> B
id A x = x
one : Nat
one = id Nat (suc zero) -- a silly use of the identity function
-- To faithfully simulate a polymorphic function we would like to omit the type
-- argument when using the function. See 'Introduction.Implicit' for
-- information on how to do this.
-- Agda is both a programming language and a formal proof language, so we
-- expect to be able to prove theorems about our programs. As an example we
-- prove the very simple theorem n + 0 == n.
-- First we introduce datatypes for truth (a singleton type) and falsity (an
-- empty type).
data True : Set where -- Here it would make sense to declare True to be a
tt : True -- Prop (the universe of propositions) rather than a
-- Set. See 'Introduction.Universes' for more
-- information.
data False : Set where -- see 'Introduction.Data.Empty' for more information
-- on empty types.
-- Second, we define what it means for two natural numbers to be equal. Infix
-- operators are declared by enclosing the operator in _. See
-- 'Introduction.Operators' for more information.
_==_ : Nat -> Nat -> Set
zero == zero = True
zero == suc m = False
suc n == zero = False
suc n == suc m = n == m
-- Now we are ready to state and prove our theorem. The proof is by induction
-- (i.e. recursion) on 'n'.
thmPlusZero : (n : Nat) -> plus n zero == n -- A function from a number n to
-- P n can be seen as the
-- proposition โ n. P n.
thmPlusZero zero = tt
thmPlusZero (suc n) = thmPlusZero n
thmPlusZero' : (n : Nat) -> plus zero n == n
thmPlusZero' zero = tt
thmPlusZero' (suc n) = thmPlusZero' n
{- In both branches the reduction makes the proof very simple. In the first
case the goal is
plus zero zero == zero which reduces to
zero == zero and
True
In the second case we have
plus (suc n) zero == suc n
suc (plus n zero) == suc n
plus n zero == n
so the induction hypothesis (the recursive call) is directly applicable.
-}
| {
"alphanum_fraction": 0.6731920774,
"avg_line_length": 33.1450381679,
"ext": "agda",
"hexsha": "75f5723f471d5967d094d40abed113f62ff0b9c8",
"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": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/Basics.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"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": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/Basics.agda",
"max_line_length": 87,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/Basics.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 1080,
"size": 4342
} |
module nat-division where
open import bool
open import bool-thms
open import eq
open import neq
open import nat
open import nat-thms
open import product
open import product-thms
open import sum
{- a div-result for dividend x and divisor d consists of the quotient q, remainder r, and a proof that q * d + r = x -}
div-result : โ โ โ โ Set
div-result x d = ฮฃ โ (ฮป q โ ฮฃ โ (ฮป r โ q * d + r โก x โง r < d โก tt))
-- we use an upper bound n on the dividend x. For an alternative approach, see nat-division-wf.agda.
divh : (n : โ) โ (x : โ) โ (y : โ) โ x โค n โก tt โ y =โ 0 โก ff โ div-result x y
divh 0 0 0 p1 ()
divh 0 0 (suc y) p1 p2 = 0 , 0 , refl , refl
divh 0 (suc x) y () p2
divh (suc n) x y p1 p2 with keep (x < y)
divh (suc n) x y p1 p2 | tt , pl = 0 , x , refl , pl
divh (suc n) x y p1 p2 | ff , pl with divh n (x โธ y) y (โธโค2 n x y p1 p2) p2
divh (suc n) x y p1 p2 | ff , pl | q , r , pa , pb = suc q , r , lem{q}{r} pa , pb
where lem : โ{q r} โ q * y + r โก x โธ y โ y + q * y + r โก x
lem{q}{r} p rewrite sym (+assoc y (q * y) r) | p | +comm y (x โธ y) = โธ+2{x}{y} (<ff{x}{y} pl)
-- the div-result contains the quotient, remainder, and proof relating them to the inputs
_รท_!_ : (x : โ) โ (y : โ) โ y =โ 0 โก ff โ div-result x y
x รท y ! p = divh x x y (โค-refl x) p
-- return a pair of the quotient and remainder
_รท_!!_ : โ โ (y : โ) โ y =โ 0 โก ff โ โ ร โ
x รท y !! p with x รท y ! p
... | q , r , p' = q , r
-- return the quotient only
_รท_div_ : โ โ (y : โ) โ y =โ 0 โก ff โ โ
x รท y div p with x รท y ! p
... | q , r , p' = q
-- return the remainder only
_รท_mod_ : โ โ (y : โ) โ y =โ 0 โก ff โ โ
x รท y mod p with x รท y ! p
... | q , r , p' = r
| {
"alphanum_fraction": 0.5448524985,
"avg_line_length": 33.8979591837,
"ext": "agda",
"hexsha": "e118b1fe99add50335936bf66d854f7ffe9bd739",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "nat-division.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "nat-division.agda",
"max_line_length": 119,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "nat-division.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 716,
"size": 1661
} |
-- You can't use the same name more than once in the same scope.
module ClashingDefinition where
postulate
X : Set
X : Set
Y = X
| {
"alphanum_fraction": 0.6985294118,
"avg_line_length": 13.6,
"ext": "agda",
"hexsha": "8f1d256e8e59eaef85a47b1ab5535369bfa3075e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/ClashingDefinition.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/ClashingDefinition.agda",
"max_line_length": 64,
"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/ClashingDefinition.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": 39,
"size": 136
} |
------------------------------------------------------------------------
-- An LTS from Sectionย 6.2.5 of "Enhancements of the bisimulation
-- proof method" by Pous and Sangiorgi
------------------------------------------------------------------------
{-# OPTIONS --safe #-}
open import Prelude
module Labelled-transition-system.6-2-5 (Name : Type) where
open import Labelled-transition-system
infixr 12 _ยท_
infix 5 _[_]
infix 4 _[_]โถ_
-- Processes.
data Proc : Type where
op : Proc โ Proc
_ยท_ : Name โ Proc โ Proc
โ
: Proc
-- Transitions.
data _[_]โถ_ : Proc โ Name โ Proc โ Type where
action : โ {a P} โ a ยท P [ a ]โถ P
op : โ {a P Pโฒ Pโณ} โ P [ a ]โถ Pโฒ โ Pโฒ [ a ]โถ Pโณ โ op P [ a ]โถ Pโณ
-- The LTS.
6-2-5 : LTS lzero
6-2-5 = record
{ Proc = Proc
; Label = Name
; _[_]โถ_ = _[_]โถ_
; is-silent = ฮป _ โ false
}
open LTS 6-2-5 public hiding (Proc; _[_]โถ_)
-- Polyadic contexts.
data Context (n : โ) : Type where
hole : (x : Fin n) โ Context n
op : Context n โ Context n
_ยท_ : (a : Name) โ Context n โ Context n
โ
: Context n
-- Hole filling.
_[_] : โ {n} โ Context n โ (Fin n โ Proc) โ Proc
hole x [ ps ] = ps x
op C [ ps ] = op (C [ ps ])
a ยท C [ ps ] = a ยท (C [ ps ])
โ
[ ps ] = โ
| {
"alphanum_fraction": 0.4753184713,
"avg_line_length": 21.6551724138,
"ext": "agda",
"hexsha": "3bc7178d6b667ea8f1fcbfab538a3e30f7e0a867",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Labelled-transition-system/6-2-5.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/up-to",
"max_issues_repo_path": "src/Labelled-transition-system/6-2-5.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Labelled-transition-system/6-2-5.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 437,
"size": 1256
} |
-- Tests unreachable clause detection
module Unreachable where
data C : Set where
cโ : C
cโ : C -> C
data Bool : Set where
t : Bool
f : Bool
maj : Bool -> Bool -> Bool -> Bool
maj f f f = f
maj t f x = x
maj f x t = x
maj x t f = x
maj t t t = t
unreachable : C -> C
unreachable (cโ x) = cโ
unreachable (cโ (cโ y)) = cโ cโ
unreachable cโ = cโ
unreachable _ = cโ | {
"alphanum_fraction": 0.5968992248,
"avg_line_length": 16.8260869565,
"ext": "agda",
"hexsha": "6c0944e72fd15784df0389c5668d4057cfbae143",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Unreachable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Unreachable.agda",
"max_line_length": 37,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Unreachable.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": 142,
"size": 387
} |
{-# OPTIONS --guardedness #-}
record _โ_ {A : Set} (xs : Stream A) (ys : Stream A) : Set where
coinductive
field
hd-โ : hd xs โก hd ys
tl-โ : tl xs โ tl ys
even : โ {A} โ Stream A โ Stream A
hd (even x) = hd x
tl (even x) = even (tl (tl x))
odd : โ {A} โ Stream A โ Stream A
odd x = even (tl x)
split : โ {A} โ Stream A โ Stream A ร Stream A
split xs = even xs , odd xs
merge : โ {A} โ Stream A ร Stream A โ Stream A
hd (merge (fst , snd)) = hd fst
tl (merge (fst , snd)) = merge (snd , tl fst)
merge-split-id : โ {A} (xs : Stream A) โ merge (split xs) โ xs
hd-โ (merge-split-id _) = refl
tl-โ (merge-split-id xs) = merge-split-id (tl xs)
| {
"alphanum_fraction": 0.5616438356,
"avg_line_length": 25.2692307692,
"ext": "agda",
"hexsha": "cad1b63ab301b12085191353102b8441c1f1fa31",
"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": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "seanwestfall/agda_explorations",
"max_forks_repo_path": "src/coinduction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "seanwestfall/agda_explorations",
"max_issues_repo_path": "src/coinduction.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "seanwestfall/agda_explorations",
"max_stars_repo_path": "src/coinduction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 246,
"size": 657
} |
module exampleTypeAbbreviations where
postulate A : Set
A2 : Set
A2 = A -> A
A3 : Set
A3 = A2 -> A2
a2 : A2
a2 = \x -> x
a3 : A3
a3 = \x -> x | {
"alphanum_fraction": 0.5793103448,
"avg_line_length": 10.3571428571,
"ext": "agda",
"hexsha": "f6ff17d7f867f76c9e8218ccfce55d79c36219dc",
"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": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/exampleTypeAbbreviations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"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": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/exampleTypeAbbreviations.agda",
"max_line_length": 37,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/exampleTypeAbbreviations.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 67,
"size": 145
} |
------------------------------------------------------------------------
-- Theorems relating the coinductive definition of the delay
-- monad to the alternative one and to another type
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --sized-types #-}
open import Prelude hiding (โ)
module Delay-monad.Alternative.Equivalence {a} {A : Type a} where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_โ_)
open import Prelude.Size
open import Bijection equality-with-J using (_โ_)
open import Equality.Decision-procedures equality-with-J
open import Function-universe equality-with-J hiding (_โ_)
open import H-level equality-with-J
open import Surjection equality-with-J using (_โ _)
open import Delay-monad as D hiding (Delay)
open import Delay-monad.Alternative
open import Delay-monad.Alternative.Properties
open import Delay-monad.Bisimilarity as Bisimilarity
using ([_]_โผ_; now; later; force)
private
variable
i : Size
-- Building blocks used in the theorems below.
module DelayโDelay where
-- The function toโ is basically ฯ from Section 7.1 of
-- "Quotienting the Delay Monad by Weak Bisimilarity" by Chapman,
-- Uustalu and Veltri, but the function projโย โย from is different
-- from their function ฮต, which is defined so that (with the
-- terminology used here) ฮตย (nowย x)ย (sucย n)ย =ย nothing.
toโ : (โ โ Maybe A) โ D.Delay A i
toโ f = toโฒ (f 0)
module To where
toโฒ : Maybe A โ D.Delay A i
toโฒ (just x) = now x
toโฒ nothing =
later ฮป { .force โ toโ (f โ suc) }
to : Delay A โ D.Delay A i
to = toโ โ projโ
from : D.Delay A โ โ Delay A
from = ฮป x โ fromโ x , fromโ x
where
fromโ : D.Delay A โ โ โ โ Maybe A
fromโ (now x) _ = just x
fromโ (later x) zero = nothing
fromโ (later x) (suc n) = fromโ (force x) n
fromโ : โ x โ Increasing (fromโ x)
fromโ (now x) _ = injโ refl
fromโ (later x) zero = projโ LE-nothing-contractible
fromโ (later x) (suc n) = fromโ (force x) n
-- The two definitions of the delay monad are logically equivalent.
DelayโDelay : Delay A โ D.Delay A โ
DelayโDelay = record { to = DelayโDelay.to; from = DelayโDelay.from }
-- There is a split surjection from D.Delayย Aย โ to Delayย A.
Delayโ Delay : D.Delay A โ โ Delay A
Delayโ Delay = record
{ logical-equivalence = inverse DelayโDelay
; right-inverse-of = fromโto
}
where
open DelayโDelay
fromโto : โ x โ from (to x) โก x
fromโto x = ฮฃ-โก,โกโโก
(โจextโฉ (projโโfromโto x))
(โจextโฉ ฮป n โ
subst Increasing
(โจextโฉ (projโโfromโto x))
(projโ (from (to x)))
n โกโจ sym $ push-subst-application (โจextโฉ (projโโfromโto x)) (flip Increasing-at) โฉ
subst (Increasing-at n)
(โจextโฉ (projโโfromโto x))
(projโ (from (to x)) n) โกโจ uncurry projโโfromโto x n _ refl โฉโ
projโ x n โ)
where
projโโfromโtoโฒ :
(g : โ โ Maybe A) โ
Increasing g โ
โ x โ g 0 โก x โ โ n โ
projโ (from (To.toโฒ g x)) n โก g n
projโโfromโtoโฒ g g-inc (just x) g0โx n = sym $ โ-upwards-closedโ g-inc g0โx n
projโโfromโtoโฒ g g-inc nothing g0โ zero = sym g0โ
projโโfromโtoโฒ g g-inc nothing g0โ (suc n) =
projโโfromโtoโฒ (g โ suc) (g-inc โ suc) _ refl n
projโโfromโto :
(x : Delay A) โ
โ n โ projโ (from (to x)) n โก projโ x n
projโโfromโto (g , g-inc) = projโโfromโtoโฒ g g-inc (g 0) refl
โ-lemma :
(g : โ โ Maybe A) โ
(g-increasing : Increasing g) โ
โ n x (g0โx : g 0 โ x) p โ p โก g-increasing 0 โ
subst (Increasing-at n)
(โจextโฉ (sym โ โ-upwards-closedโ g-increasing g0โx))
(injโ refl)
โก
g-increasing n
โ-lemma g _ _ x g0โx (injโ (g0โ , _)) _ =
โฅ-elim $ โ.injโโขinjโ (
nothing โกโจ sym g0โ โฉ
g 0 โกโจ g0โx โฉโ
just x โ)
โ-lemma g g-inc zero x g0โx (injโ g0โกg1) โกg-inc0 =
subst (Increasing-at zero)
(โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx))
(injโ refl) โกโจ push-subst-injโ
{yโกz = โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx)}
(ฮป f โ f 0 โก f 1) (ฮป f โ f 0 โ ร ยฌ f 1 โ) โฉ
injโ (subst (ฮป f โ f 0 โก f 1)
(โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx))
refl) โกโจ cong injโ lemma โฉ
injโ g0โกg1 โกโจ โกg-inc0 โฉโ
g-inc zero โ
where
eq = โ-upwards-closedโ g-inc g0โx
lemma =
subst (ฮป f โ f 0 โก f 1) (โจextโฉ (sym โ eq)) refl โกโจ subst-in-terms-of-trans-and-cong {xโกy = โจextโฉ (sym โ eq)} โฉ
trans (sym (cong (_$ 0) (โจextโฉ (sym โ eq))))
(trans refl (cong (_$ 1) (โจextโฉ (sym โ eq)))) โกโจ cong (trans (sym (cong (_$ 0) (โจextโฉ (sym โ eq))))) $
trans-reflหก (cong (_$ 1) (โจextโฉ (sym โ eq))) โฉ
trans (sym (cong (_$ 0) (โจextโฉ (sym โ eq))))
(cong (_$ 1) (โจextโฉ (sym โ eq))) โกโจ congโ (ฮป p q โ trans (sym p) q) (cong-ext (sym โ eq)) (cong-ext (sym โ eq)) โฉ
trans (sym $ sym $ eq 0) (sym $ eq 1) โกโจ cong (ฮป eqโฒ โ trans eqโฒ (sym $ eq 1)) $ sym-sym _ โฉ
trans (eq 0) (sym $ eq 1) โกโจโฉ
trans g0โx (sym $ โ.step g-inc g0โx (g-inc 0)) โกโจ cong (ฮป eqโฒ โ trans g0โx (sym $ โ.step g-inc g0โx eqโฒ)) $ sym $ โกg-inc0 โฉ
trans g0โx (sym $ โ.step g-inc g0โx (injโ g0โกg1)) โกโจโฉ
trans g0โx (sym $ trans (sym g0โกg1) g0โx) โกโจ cong (trans g0โx) $ sym-trans (sym g0โกg1) g0โx โฉ
trans g0โx (trans (sym g0โx) (sym (sym g0โกg1))) โกโจ trans--[trans-sym] _ _ โฉ
sym (sym g0โกg1) โกโจ sym-sym _ โฉโ
g0โกg1 โ
โ-lemma g g-inc (suc n) x g0โx (injโ g0โกg1) โกg-inc0 =
subst (Increasing-at (suc n))
(โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx))
(injโ refl) โกโจโฉ
subst (Increasing-at n โ (_โ suc))
(โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx))
(injโ refl) โกโจ subst-โ (Increasing-at n) (_โ suc)
(โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx)) โฉ
subst (Increasing-at n)
(cong (_โ suc) (โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx)))
(injโ refl) โกโจ cong (ฮป eq โ subst (Increasing-at n) eq _) $
cong-pre-โ-ext (sym โ โ-upwards-closedโ g-inc g0โx) โฉ
subst (Increasing-at n)
(โจextโฉ (sym โ โ-upwards-closedโ g-inc g0โx โ suc))
(injโ refl) โกโจโฉ
subst (Increasing-at n)
(โจextโฉ (sym โ โ-upwards-closedโ (g-inc โ suc)
(โ.step g-inc g0โx (g-inc 0))))
(injโ refl) โกโจ cong (ฮป p โ subst (Increasing-at n)
(โจextโฉ (sym โ โ-upwards-closedโ (g-inc โ suc)
(โ.step g-inc g0โx p)))
(injโ refl))
(sym โกg-inc0) โฉ
subst (Increasing-at n)
(โจextโฉ (sym โ โ-upwards-closedโ (g-inc โ suc)
(โ.step g-inc g0โx (injโ g0โกg1))))
(injโ refl) โกโจโฉ
subst (Increasing-at n)
(โจextโฉ (sym โ โ-upwards-closedโ (g-inc โ suc)
(trans (sym g0โกg1) g0โx)))
(injโ refl) โกโจ โ-lemma (g โ suc) (g-inc โ suc) n _ _ _ refl โฉโ
g-inc (suc n) โ
projโโfromโto :
(g : โ โ Maybe A) โ
(g-increasing : Increasing g) โ
โ n y (g0โกy : g 0 โก y) โ
subst (Increasing-at n)
(โจextโฉ (projโโfromโtoโฒ g g-increasing y g0โกy))
(projโ (from (To.toโฒ g y)) n)
โก
g-increasing n
projโโfromโto g g-inc n (just y) g0โy =
โ-lemma g g-inc n y g0โy _ refl
projโโfromโto g g-inc zero nothing g0โ =
( $โจ monoโ 0 LE-nothing-contractible โฉ
Is-proposition (LE nothing (g 1)) โโจ subst (ฮป x โ Is-proposition (LE x (g 1))) (sym g0โ) โฉโก
Is-proposition (LE (g 0) (g 1)) โก) _ _
projโโfromโto g g-inc (suc n) nothing g0โ =
subst (Increasing-at (suc n))
(โจextโฉ (projโโfromโtoโฒ g g-inc nothing g0โ))
(projโ (from (to (g โ suc , g-inc โ suc))) n) โกโจโฉ
subst (Increasing-at n โ (_โ suc))
(โจextโฉ (projโโfromโtoโฒ g g-inc nothing g0โ))
(projโ (from (to (g โ suc , g-inc โ suc))) n) โกโจ subst-โ (Increasing-at n) (_โ suc)
(โจextโฉ (projโโfromโtoโฒ g g-inc nothing g0โ)) โฉ
subst (Increasing-at n)
(cong (_โ suc) (โจextโฉ (projโโfromโtoโฒ g g-inc nothing g0โ)))
(projโ (from (to (g โ suc , g-inc โ suc))) n) โกโจ cong (ฮป eq โ subst (Increasing-at n) eq
(projโ (from (to (g โ suc , g-inc โ suc))) n)) $
cong-pre-โ-ext (projโโfromโtoโฒ g g-inc nothing g0โ) โฉ
subst (Increasing-at n)
(โจextโฉ (projโโfromโtoโฒ g g-inc nothing g0โ โ suc))
(projโ (from (to (g โ suc , g-inc โ suc))) n) โกโจโฉ
subst (Increasing-at n)
(โจextโฉ (projโโfromโtoโฒ (g โ suc) (g-inc โ suc) _ refl))
(projโ (from (to (g โ suc , g-inc โ suc))) n) โกโจ projโโfromโto (g โ suc) (g-inc โ suc) n _ refl โฉโ
g-inc (suc n) โ
-- The two definitions of the delay monad are isomorphic (assuming
-- extensionality).
DelayโDelay : Bisimilarity.Extensionality a โ
Delay A โ D.Delay A โ
DelayโDelay delay-ext = record
{ surjection = record
{ logical-equivalence = DelayโDelay
; right-inverse-of = delay-ext โ toโfrom
}
; left-inverse-of = _โ _.right-inverse-of Delayโ Delay
}
where
open DelayโDelay
toโfrom : โ x โ [ i ] to (from x) โผ x
toโfrom (now x) = now
toโfrom (later x) = later ฮป { .force โ toโfrom (force x) }
-- There is a split surjection from โย โย Maybeย A (without any
-- requirement that the sequences are increasing) to D.Delayย Aย โ
-- (assuming extensionality).
--
-- Chapman, Uustalu and Veltri prove this result in "Quotienting the
-- Delay Monad by Weak Bisimilarity".
โโ Delay-coinductive : Bisimilarity.Extensionality a โ
(โ โ Maybe A) โ D.Delay A โ
โโ Delay-coinductive delay-ext = record
{ logical-equivalence = record
{ to = DelayโDelay.toโ
; from = projโ โ DelayโDelay.from
}
; right-inverse-of = _โ_.right-inverse-of (DelayโDelay delay-ext)
}
-- There is also a split surjection from โย โย Maybeย A to Delayย A.
โโ Delay-function : (โ โ Maybe A) โ Delay A
โโ Delay-function = record
{ logical-equivalence = record
{ to = DelayโDelay.from โ DelayโDelay.toโ
; from = projโ
}
; right-inverse-of = _โ _.right-inverse-of Delayโ Delay
}
| {
"alphanum_fraction": 0.4513382991,
"avg_line_length": 40.4536423841,
"ext": "agda",
"hexsha": "279fd5a58fe6f93a95aa48e5f2ed8c61523a2df6",
"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": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/partiality-monad",
"max_forks_repo_path": "src/Delay-monad/Alternative/Equivalence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"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/partiality-monad",
"max_issues_repo_path": "src/Delay-monad/Alternative/Equivalence.agda",
"max_line_length": 144,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/partiality-monad",
"max_stars_repo_path": "src/Delay-monad/Alternative/Equivalence.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z",
"num_tokens": 3994,
"size": 12217
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Object.NaturalNumber.Properties.F-Algebras where
open import Level
open import Function using (_$_)
open import Categories.Category
open import Categories.Category.Construction.F-Algebras
open import Categories.Category.Cocartesian
open import Categories.Functor
open import Categories.Functor.Algebra
open import Categories.Object.Terminal renaming (up-to-iso to โค-up-to-iso)
open import Categories.Object.Initial
import Categories.Morphism.Reasoning as MR
import Categories.Object.NaturalNumber as NNO
-- A NNO is an inital algebra for the 'X โฆ โค + X' endofunctor.
module _ {o โ e} (๐ : Category o โ e) (๐-Terminal : Terminal ๐) (๐-Coproducts : BinaryCoproducts ๐) where
open Terminal ๐-Terminal
open BinaryCoproducts ๐-Coproducts
open Category ๐
open HomReasoning
open Equiv
open MR ๐
open NNO ๐ ๐-Terminal
Maybe : Functor ๐ ๐
Maybe = record
{ Fโ = ฮป X โ โค + X
; Fโ = ฮป f โ [ iโ , iโ โ f ]
; identity = []-congโ refl identityสณ โ +-ฮท
; homomorphism = +-unique (pullสณ injectโ โ injectโ) (pullสณ injectโ โ pullหก injectโ โ assoc)
; F-resp-โ = ฮป eq โ []-congโ refl (โ-resp-โสณ eq)
}
private
module Maybe = Functor Maybe
InitialโNNO : Initial (F-Algebras Maybe) โ NaturalNumber
InitialโNNO initial = record
{ N = โฅ.A
; isNaturalNumber = record
{ z = โฅ.ฮฑ โ iโ
; s = โฅ.ฮฑ โ iโ
; universal = ฮป {A} q f โ
F-Algebra-Morphism.f (initial.! {A = alg q f})
; z-commute = ฮป {A} {q} {f} โ begin
q โโจ โบ injectโ โฉ
[ q , f ] โ iโ โโจ pushสณ (โบ injectโ) โฉ
(([ q , f ] โ [ iโ , iโ โ F-Algebra-Morphism.f initial.! ]) โ iโ) โโจ pushหก (โบ (F-Algebra-Morphism.commutes (initial.! {A = alg q f}))) โฉ
F-Algebra-Morphism.f initial.! โ โฅ.ฮฑ โ iโ โ
; s-commute = ฮป {A} {q} {f} โ begin
(f โ F-Algebra-Morphism.f initial.!) โโจ pushหก (โบ injectโ) โฉ
[ q , f ] โ iโ โ F-Algebra-Morphism.f initial.! โโจ pushสณ (โบ injectโ) โฉ
([ q , f ] โ [ iโ , iโ โ F-Algebra-Morphism.f initial.! ]) โ iโ โโจ pushหก (โบ (F-Algebra-Morphism.commutes (initial.! {A = alg q f}))) โฉ
F-Algebra-Morphism.f initial.! โ โฅ.ฮฑ โ iโ โ
; unique = ฮป {A} {f} {q} {u} eqแถป eqหข โ โบ $ initial.!-unique record
{ f = u
; commutes = begin
u โ โฅ.ฮฑ โโจ โบ +-g-ฮท โฉ
[ (u โ โฅ.ฮฑ) โ iโ , (u โ โฅ.ฮฑ) โ iโ ] โโจ []-congโ (assoc โ โบ eqแถป) (assoc โ โบ eqหข) โฉ
[ f , q โ u ] โโจ +-unique (pullสณ injectโ โ injectโ) (pullสณ injectโ โ pullหก injectโ) โฉ
[ f , q ] โ [ iโ , iโ โ u ] โ
}
}
}
where
module initial = Initial initial
module โฅ = F-Algebra initial.โฅ
alg : โ {A} โ (q : โค โ A) โ (f : A โ A) โ F-Algebra Maybe
alg {A} q f = record
{ A = A
; ฮฑ = [ q , f ]
}
NNOโInitial : NaturalNumber โ Initial (F-Algebras Maybe)
NNOโInitial NNO = record
{ โฅ = record
{ A = N
; ฮฑ = [ z , s ]
}
; โฅ-is-initial = record
{ ! = ฮป {alg} โ record
{ f = universal (F-Algebra.ฮฑ alg โ iโ) (F-Algebra.ฮฑ alg โ iโ)
; commutes = begin
universal _ _ โ [ z , s ] โโจ โ-distribหก-[] โฉ
[ universal _ _ โ z , universal _ _ โ s ] โโจ []-congโ (โบ z-commute) (โบ s-commute โ assoc) โฉ
[ F-Algebra.ฮฑ alg โ iโ , F-Algebra.ฮฑ alg โ (iโ โ universal _ _) ] โหโจ โ-distribหก-[] โฉ
F-Algebra.ฮฑ alg โ [ iโ , iโ โ universal _ _ ] โ
}
; !-unique = ฮป {A} f โ
let z-commutes = begin
F-Algebra.ฮฑ A โ iโ โโจ pushสณ (โบ injectโ) โฉ
(F-Algebra.ฮฑ A โ [ iโ , iโ โ F-Algebra-Morphism.f f ]) โ iโ โหโจ F-Algebra-Morphism.commutes f โฉโโจrefl โฉ
(F-Algebra-Morphism.f f โ [ z , s ]) โ iโ โโจ pullสณ injectโ โฉ
F-Algebra-Morphism.f f โ z โ
s-commutes = begin
(F-Algebra.ฮฑ A โ iโ) โ F-Algebra-Morphism.f f โโจ pullสณ (โบ injectโ) โ โบ assoc โฉ
(F-Algebra.ฮฑ A โ [ iโ , iโ โ F-Algebra-Morphism.f f ]) โ iโ โหโจ F-Algebra-Morphism.commutes f โฉโโจrefl โฉ
(F-Algebra-Morphism.f f โ [ z , s ]) โ iโ โโจ pullสณ injectโ โฉ
F-Algebra-Morphism.f f โ s โ
in โบ $ unique z-commutes s-commutes
}
}
where
open NaturalNumber NNO
| {
"alphanum_fraction": 0.4836518047,
"avg_line_length": 42.8181818182,
"ext": "agda",
"hexsha": "bffc3b9d67ce127b23a748ebba9ceb9e3310e49a",
"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/NaturalNumber/Properties/F-Algebras.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/NaturalNumber/Properties/F-Algebras.agda",
"max_line_length": 144,
"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/NaturalNumber/Properties/F-Algebras.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": 1702,
"size": 4710
} |
{-
This file contains:
- Properties of set truncations
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.SetTruncation.Properties where
open import Cubical.HITs.SetTruncation.Base
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
open import Cubical.Data.Sigma
private
variable
โ : Level
A : Type โ
rec : {B : Type โ} โ isSet B โ (A โ B) โ โฅ A โฅโ โ B
rec Bset f โฃ x โฃโ = f x
rec Bset f (squashโ x y p q i j) =
Bset _ _ (cong (rec Bset f) p) (cong (rec Bset f) q) i j
-- lemma 6.9.1 in HoTT book
elim : {B : โฅ A โฅโ โ Type โ}
(Bset : (x : โฅ A โฅโ) โ isSet (B x))
(g : (a : A) โ B (โฃ a โฃโ))
(x : โฅ A โฅโ) โ B x
elim Bset g โฃ a โฃโ = g a
elim Bset g (squashโ x y p q i j) =
isOfHLevelโisOfHLevelDep 2 Bset _ _
(cong (elim Bset g) p) (cong (elim Bset g) q) (squashโ x y p q) i j
setTruncUniversal : {B : Type โ} โ isSet B โ (โฅ A โฅโ โ B) โ (A โ B)
setTruncUniversal {B = B} Bset =
isoToEquiv (iso (ฮป h x โ h โฃ x โฃโ) (rec Bset) (ฮป _ โ refl) rinv)
where
rinv : (f : โฅ A โฅโ โ B) โ rec Bset (ฮป x โ f โฃ x โฃโ) โก f
rinv f i x =
elim (ฮป x โ isPropโisSet (Bset (rec Bset (ฮป x โ f โฃ x โฃโ) x) (f x)))
(ฮป _ โ refl) x i
elim2 : {B : โฅ A โฅโ โ โฅ A โฅโ โ Type โ}
(Bset : ((x y : โฅ A โฅโ) โ isSet (B x y)))
(g : (a b : A) โ B โฃ a โฃโ โฃ b โฃโ)
(x y : โฅ A โฅโ) โ B x y
elim2 Bset g = elim (ฮป _ โ isSetฮ (ฮป _ โ Bset _ _))
(ฮป a โ elim (ฮป _ โ Bset _ _) (g a))
elim3 : {B : (x y z : โฅ A โฅโ) โ Type โ}
(Bset : ((x y z : โฅ A โฅโ) โ isSet (B x y z)))
(g : (a b c : A) โ B โฃ a โฃโ โฃ b โฃโ โฃ c โฃโ)
(x y z : โฅ A โฅโ) โ B x y z
elim3 Bset g = elim2 (ฮป _ _ โ isSetฮ (ฮป _ โ Bset _ _ _))
(ฮป a b โ elim (ฮป _ โ Bset _ _ _) (g a b))
setTruncIsSet : isSet โฅ A โฅโ
setTruncIsSet a b p q = squashโ a b p q
setTruncIdempotentโ : isSet A โ โฅ A โฅโ โ A
setTruncIdempotentโ {A = A} hA = isoToEquiv f
where
f : Iso โฅ A โฅโ A
Iso.fun f = rec hA (idfun A)
Iso.inv f x = โฃ x โฃโ
Iso.rightInv f _ = refl
Iso.leftInv f = elim (ฮป _ โ isSetโisGroupoid setTruncIsSet _ _) (ฮป _ โ refl)
setTruncIdempotent : isSet A โ โฅ A โฅโ โก A
setTruncIdempotent hA = ua (setTruncIdempotentโ hA)
setSigmaIso : โ {โ} {B : A โ Type โ} โ Iso โฅ ฮฃ A B โฅโ โฅ ฮฃ A (ฮป x โ โฅ B x โฅโ) โฅโ
setSigmaIso {A = A} {B = B} = iso fun funinv sect retr
where
{- writing it out explicitly to avoid yellow highlighting -}
fun : โฅ ฮฃ A B โฅโ โ โฅ ฮฃ A (ฮป x โ โฅ B x โฅโ) โฅโ
fun = rec setTruncIsSet ฮป {(a , p) โ โฃ a , โฃ p โฃโ โฃโ}
funinv : โฅ ฮฃ A (ฮป x โ โฅ B x โฅโ) โฅโ โ โฅ ฮฃ A B โฅโ
funinv = rec setTruncIsSet (ฮป {(a , p) โ rec setTruncIsSet (ฮป p โ โฃ a , p โฃโ) p})
sect : section fun funinv
sect = elim (ฮป _ โ isOfHLevelPath 2 setTruncIsSet _ _)
ฮป { (a , p) โ elim {B = ฮป p โ fun (funinv โฃ a , p โฃโ) โก โฃ a , p โฃโ}
(ฮป p โ isOfHLevelPath 2 setTruncIsSet _ _) (ฮป _ โ refl) p }
retr : retract fun funinv
retr = elim (ฮป _ โ isOfHLevelPath 2 setTruncIsSet _ _)
ฮป { _ โ refl }
| {
"alphanum_fraction": 0.5459375,
"avg_line_length": 33.6842105263,
"ext": "agda",
"hexsha": "e27d8e73c15d181faa1ab8d03cbba5cbfa94a39e",
"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": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/HITs/SetTruncation/Properties.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/HITs/SetTruncation/Properties.agda",
"max_line_length": 83,
"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/HITs/SetTruncation/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1407,
"size": 3200
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.