{"text": "module L where\n\nopen import Data.Nat using (\u2115; suc) -- ; _*_)\nopen import Relation.Binary.PropositionalEquality using (_\u2261_; refl; cong; sym; trans)\nopen import Data.Product\nopen import Data.Empty\n\n-- Recursion principle\n\nrec\u2115 : (C : Set) \u2192 C \u2192 (\u2115 \u2192 C \u2192 C) \u2192 \u2115 \u2192 C\nrec\u2115 C c f 0 = c\nrec\u2115 C c f (suc n) = f n (rec\u2115 C c f n)\n\ndouble : \u2115 \u2192 \u2115\ndouble = rec\u2115 \u2115 0 (\u03bb n r \u2192 suc (suc r))\n\nadd : \u2115 \u2192 \u2115 \u2192 \u2115\nadd = rec\u2115 (\u2115 \u2192 \u2115) (\u03bb n \u2192 n) (\u03bb m r \u2192 \u03bb n \u2192 suc (r n))\n\n-- fact : \u2115 \u2192 \u2115\n-- fact = rec\u2115 \u2115 1 (\u03bb n r \u2192 suc n * r)\n\n-- Induction principle\n\nind\u2115 : (C : \u2115 \u2192 Set) \u2192 C 0 \u2192 ((n : \u2115) \u2192 C n \u2192 C (suc n)) \u2192 (n : \u2115) \u2192 C n\nind\u2115 C c f 0 = c\nind\u2115 C c f (suc n) = f n (ind\u2115 C c f n)\n\nadd-assoc : (i j k : \u2115) \u2192 add i (add j k) \u2261 add (add i j) k\nadd-assoc = ind\u2115\n              (\u03bb i \u2192 (j k : \u2115) \u2192 add i (add j k) \u2261 add (add i j) k)\n              (\u03bb j k \u2192 refl)\n              (\u03bb i i+[j+k]\u2261[i+j]+k j k \u2192 cong suc (i+[j+k]\u2261[i+j]+k j k))\n\nadd-right-unit : (i : \u2115) \u2192 add i 0 \u2261 i\nadd-right-unit = ind\u2115 (\u03bb i \u2192 add i 0 \u2261 i) refl (\u03bb i i+0\u2261i \u2192 cong suc i+0\u2261i) \n\nadd-suc : (i j : \u2115) \u2192 suc (add i j) \u2261 add i (suc j)\nadd-suc = ind\u2115 (\u03bb i \u2192 (j : \u2115) \u2192 suc (add i j) \u2261 add i (suc j))\n               (\u03bb j \u2192 refl)\n               (\u03bb i s[i+j]\u2261i+s[j] j \u2192 cong suc (s[i+j]\u2261i+s[j] j))\n\nadd-comm : (i j : \u2115) \u2192 add i j \u2261 add j i\nadd-comm = ind\u2115\n             (\u03bb i \u2192 (j : \u2115) \u2192 add i j \u2261 add j i)\n             (\u03bb j \u2192 sym (add-right-unit j))\n             (\u03bb i i+j\u2261j+i j \u2192 trans (cong suc (i+j\u2261j+i j)) (add-suc j i))\n\n-- Some type definitions\n\n_\u2264_ : (i j : \u2115) \u2192 Set\ni \u2264 j = \u03a3[ k \u2208 \u2115 ] (add i k \u2261 j)\n\ni\u2264i+j : (i j : \u2115) \u2192 i \u2264 add i j\ni\u2264i+j = ind\u2115\n          (\u03bb i \u2192 (j : \u2115) \u2192 i \u2264 add i j)\n          (\u03bb j \u2192 (j , refl))\n          (\u03bb i i\u2264i+j j \u2192 (j , refl))\n\n\u00ac : Set \u2192 Set\n\u00ac A = A \u2192 \u22a5\n\n_<_ : (i j : \u2115) \u2192 Set\ni < j = (i \u2264 j) \u00d7 \u00ac (i \u2261 j)\n\n0\u2260si : (i : \u2115) \u2192 \u00ac (0 \u2261 suc i)\n0\u2260si i = \u03bb ()\n\n0< : (i : \u2115) \u2192 (0 < suc i)\n0< = ind\u2115  (\u03bb i \u2192 0 < suc i)\n           {!!}\n           {!!}\n           \n", "meta": {"hexsha": "765fbf2afa4edf6d542731ec0082d2f1b1c68024", "size": 1919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "L.agda", "max_stars_repo_name": "andmkent/misc-HoTT", "max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z", "max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z", "max_issues_repo_path": "L.agda", "max_issues_repo_name": "andmkent/misc-HoTT", "max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "L.agda", "max_forks_repo_name": "andmkent/misc-HoTT", "max_forks_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.9324324324, "max_line_length": 85, "alphanum_fraction": 0.440333507, "num_tokens": 860, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951570602081, "lm_q2_score": 0.8558511506439707, "lm_q1q2_score": 0.7997031703261328}}
{"text": "module Nat where\n\ndata \u2115 : Set where\n  zero : \u2115\n  succ : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero   + b = b\nsucc a + b = succ (a + b)\n\n_\u00d7_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero   \u00d7 b = zero\nsucc a \u00d7 b = (a \u00d7 b) + b\n\n\nopen import Relation.Binary.PropositionalEquality\n\n0-is-right-identity-of-+ : \u2200 (n : \u2115) \u2192 n + zero \u2261 n\n0-is-right-identity-of-+ zero     = refl\n0-is-right-identity-of-+ (succ n) = cong succ (0-is-right-identity-of-+ n)\n\n\n+-is-associative : \u2200 (a b c : \u2115) \u2192 a + (b + c) \u2261 (a + b) + c\n+-is-associative zero     b c = refl\n+-is-associative (succ a) b c = cong succ (+-is-associative a b c)\n\n\nlemma : \u2200 (a b : \u2115) \u2192 a + succ b \u2261 succ (a + b)\nlemma zero     b = refl\nlemma (succ a) b = cong succ (lemma a b)\n\nimport Relation.Binary.EqReasoning as EqR\nopen module EqNat = EqR (setoid \u2115)\n\n+-is-commutative : \u2200 (a b : \u2115) \u2192 a + b \u2261 b + a\n+-is-commutative a zero     = 0-is-right-identity-of-+ a\n+-is-commutative a (succ b) =\n  begin\n    a + succ b\n      \u2248\u27e8 lemma a b \u27e9\n    succ (a + b)\n      \u2248\u27e8 cong succ (+-is-commutative a b) \u27e9\n    succ (b + a)\n      \u2248\u27e8 refl \u27e9\n    succ b + a\n  \u220e\n", "meta": {"hexsha": "ab6f04098af1d31543d938d560e00e478f519fe8", "size": 1081, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Nat.agda", "max_stars_repo_name": "piyush-kurur/sample-code", "max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z", "max_issues_repo_path": "agda/Nat.agda", "max_issues_repo_name": "piyush-kurur/sample-code", "max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z", "max_forks_repo_path": "agda/Nat.agda", "max_forks_repo_name": "piyush-kurur/sample-code", "max_forks_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0612244898, "max_line_length": 74, "alphanum_fraction": 0.5513413506, "num_tokens": 417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9643214511730025, "lm_q2_score": 0.8289388040954683, "lm_q1q2_score": 0.7993634704989552}}
{"text": "\nmodule Logic.Identity where\n\nopen import Logic.Equivalence\nopen import Logic.Base\n\ninfix 20 _\u2261_ _\u2262_\n\ndata _\u2261_ {A : Set}(x : A) : A -> Set where\n  refl : x \u2261 x\n\nsubst : {A : Set}(P : A -> Set){x y : A} -> x \u2261 y -> P y -> P x\nsubst P {x} .{x} refl px = px\n\nsym : {A : Set}{x y : A} -> x \u2261 y -> y \u2261 x\nsym {A} refl = refl\n\ntrans : {A : Set}{x y z : A} -> x \u2261 y -> y \u2261 z -> x \u2261 z\ntrans {A} refl xz = xz\n\ncong : {A B : Set}(f : A -> B){x y : A} -> x \u2261 y -> f x \u2261 f y\ncong {A} f refl = refl\n\ncong2 : {A B C : Set}(f : A -> B -> C){x z : A}{y w : B} -> x \u2261 z -> y \u2261 w -> f x y \u2261 f z w\ncong2 {A}{B} f refl refl = refl\n\nEquiv : {A : Set} -> Equivalence A\nEquiv = record\n\t{ _==_  = _\u2261_\n\t; refl  = \\x -> refl\n\t; sym   = \\x y -> sym\n\t; trans = \\x y z -> trans\n\t}\n\n_\u2262_ : {A : Set} -> A -> A -> Set\nx \u2262 y = \u00ac (x \u2261 y)\n\nsym\u2262 : {A : Set}{x y : A} -> x \u2262 y -> y \u2262 x\nsym\u2262 np p = np (sym p)\n\n", "meta": {"hexsha": "e45cfbbb1083623944c0ce9814651ddd029c2ca4", "size": 872, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 21.2682926829, "max_line_length": 91, "alphanum_fraction": 0.4564220183, "num_tokens": 407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.944176852582231, "lm_q2_score": 0.845942439250491, "lm_q1q2_score": 0.7987192697572637}}
{"text": "open import Relation.Binary.Core\n\nmodule PLRTree.Order {A : Set} where\n\nopen import Data.Nat\nopen import Data.Sum\nopen import PLRTree {A}\nopen import Relation.Binary\n\nopen DecTotalOrder decTotalOrder hiding (refl)\n\nheight : PLRTree \u2192 \u2115\nheight leaf = zero\nheight (node t x l r) \n    with total (height l) (height r)\n... | inj\u2081 hl\u2264hr = suc (height r)\n... | inj\u2082 hr\u2264hl = suc (height l)\n\n_\u227a_ : PLRTree \u2192 PLRTree \u2192 Set \nt \u227a t' = height t <\u2032 height t'\n", "meta": {"hexsha": "0fdc139867139aace9d2dcfed7b4a26a2acc9287", "size": 446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PLRTree/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/PLRTree/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/PLRTree/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.2380952381, "max_line_length": 46, "alphanum_fraction": 0.6883408072, "num_tokens": 143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9683812354689083, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7983934588616196}}
{"text": "open import Relation.Binary.Core\n\nmodule InsertSort.Impl1.Correctness.Permutation.Alternative {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_) where\n\nopen import Data.List\nopen import Data.Sum\nopen import Function\nopen import InsertSort.Impl1 _\u2264_ tot\u2264\nopen import List.Permutation.Alternative A renaming (_\u223c_ to _\u223c\u2032_)\nopen import List.Permutation.Alternative.Correctness A \nopen import List.Permutation.Base A\n\nlemma-insert\u223c\u2032 : (x : A)(xs : List A) \u2192 (x \u2237 xs) \u223c\u2032 insert x xs\nlemma-insert\u223c\u2032 x [] = \u223crefl\nlemma-insert\u223c\u2032 x (y \u2237 ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = \u223crefl\n... | inj\u2082 y\u2264x = \u223ctrans (\u223cswap \u223crefl) (\u223chead y (lemma-insert\u223c\u2032 x ys)) \n\nlemma-insertSort\u223c\u2032 : (xs : List A) \u2192 xs \u223c\u2032 insertSort xs\nlemma-insertSort\u223c\u2032 [] = \u223crefl\nlemma-insertSort\u223c\u2032 (x \u2237 xs) = \u223ctrans (\u223chead x (lemma-insertSort\u223c\u2032 xs)) (lemma-insert\u223c\u2032 x (insertSort xs))\n\ntheorem-insertSort\u223c : (xs : List A) \u2192 xs \u223c insertSort xs\ntheorem-insertSort\u223c = lemma-\u223c\u2032-\u223c \u2218 lemma-insertSort\u223c\u2032\n", "meta": {"hexsha": "32316d4e54fa16148b68b7d64ec1db86a983e217", "size": 984, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Alternative.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Alternative.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Alternative.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1428571429, "max_line_length": 105, "alphanum_fraction": 0.6493902439, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9683812318188366, "lm_q2_score": 0.824461928533133, "lm_q1q2_score": 0.798393457940649}}
{"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule SOList.Total.Properties {A : Set} \n               (_\u2264_ : A \u2192 A \u2192 Set) \n               (trans\u2264 : Transitive _\u2264_)  where\n\nopen import Bound.Total A\nopen import Bound.Total.Order _\u2264_ \nopen import Bound.Total.Order.Properties _\u2264_ trans\u2264\nopen import List.Order.Bounded _\u2264_\nopen import List.Order.Bounded.Properties _\u2264_ trans\u2264\nopen import List.Sorted _\u2264_\nopen import Size\nopen import SOList.Total _\u2264_\n\nlemma-solist\u2264 : {\u03b9 : Size}{b t : Bound} \u2192 SOList {\u03b9} b t \u2192 LeB b t\nlemma-solist\u2264 (onil b\u2264t) = b\u2264t\nlemma-solist\u2264 (ocons x xs ys) = transLeB (lemma-solist\u2264 xs) (lemma-solist\u2264 ys)\n\nlemma-solist\u2264* : {\u03b9 : Size}{b : Bound}{x : A} \u2192 (xs : SOList {\u03b9} b (val x)) \u2192 forget xs \u2264* (val x)\nlemma-solist\u2264* (onil _) = lenx\nlemma-solist\u2264* (ocons x xs ys) = lemma-++\u2264* (lemma-solist\u2264 ys) (lemma-solist\u2264* xs) (lemma-solist\u2264* ys)\n\nlemma-solist*\u2264 : {\u03b9 : Size}{b t : Bound} \u2192 (xs : SOList {\u03b9} b t) \u2192 b *\u2264 forget xs\nlemma-solist*\u2264 (onil _) = genx\nlemma-solist*\u2264 (ocons x xs ys) = lemma-++*\u2264 (lemma-solist\u2264 xs) (lemma-solist*\u2264 xs) (lemma-solist*\u2264 ys)\n\nlemma-solist-sorted : {\u03b9 : Size}{b t : Bound}(xs : SOList {\u03b9} b t) \u2192 Sorted (forget xs)\nlemma-solist-sorted (onil _) = nils\nlemma-solist-sorted (ocons x xs ys) = lemma-sorted++ (lemma-solist\u2264* xs) (lemma-solist*\u2264 ys) (lemma-solist-sorted xs) (lemma-solist-sorted ys)\n\n\n\n\n", "meta": {"hexsha": "f94618406025c1ea958cfa475757dc26d354579f", "size": 1367, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SOList/Total/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SOList/Total/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SOList/Total/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.9722222222, "max_line_length": 142, "alphanum_fraction": 0.6444769568, "num_tokens": 506, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545304202039, "lm_q2_score": 0.8418256532040708, "lm_q1q2_score": 0.7981808069093872}}
{"text": "module index where\n\n-- natural numbers\n--- additions\nimport Nats.Add.Assoc\n  using (nat-add-assoc) -- associative law\nimport Nats.Add.Comm\n  using (nat-add-comm) -- commutative law\nimport Nats.Add.Invert\n  using (nat-add-invert) -- a + a == b + b implies a == b\n  using (nat-add-invert-1) -- a + 1 == b + 1 implies a == b\n\n--- multiplications\nimport Nats.Multiply.Comm\n  using (nat-multiply-comm) -- commutative law\nimport Nats.Multiply.Distrib\n  using (nat-multiply-distrib) -- distributive law\nimport Nats.Multiply.Assoc\n  using (nat-multiply-assoc) -- associative law\n\n-- integers\n--- some properties\nimport Ints.Properties\n  using (eq-int-to-nat) -- for natrual number a, + a == + a implis a == a\n  using (eq-neg-int-to-nat) -- for natrual number a, - a == - a implis a == a\n  using (eq-nat-to-int) -- for natrual number a, a == a implis + a == + a\n  using (eq-neg-nat-to-int) -- for natrual number a, a == a implis - a == - a\n\n--- additions\nimport Ints.Add.Comm\n  using (int-add-comm) -- commutative law\nimport Ints.Add.Assoc\n  using (int-add-assoc) -- associative law\nimport Ints.Add.Invert\n  using (int-add-invert) -- a + a == b + b implis a == b\n\n-- non-negative rationals\n--- some properties\nimport Rationals.Properties\n  -- if b is not zero, n times b div b is the original number\n  using (times-div-id)\n\n-- additions\nimport Rationals.Add.Comm\n  using (rational-add-comm) -- commutative law\nimport Rationals.Add.Assoc\n  using (rational-add-assoc) -- associative law\n\n-- multiplications\nimport Rationals.Multiply.Comm\n  using (rational-multiply-comm) -- commutative law\n\n-- logics\n--- the \"and\" relations\nimport Logics.And\n  using (and-comm) -- commutative law\n  using (and-assoc) -- associative law\n\n--- the \"or\" relations\nimport Logics.Or\n  using (or-comm) -- commutative law\n  using (or-assoc) -- associative law\n  using (or-elim) -- elimination rule\n\n--- negations\nimport Logics.Not\n  -- law that negative twice will make a positive\n  using (not-not)\n  using (contrapositive) -- contrapositive\n\n-- vectors\n--- reverse twice gives the original vector\nimport Vecs.Reverse\n  using (vec-rev-rev-id)\n\n-- lists\n--- reverse twice gives the original vector\nimport Lists.Reverse\n  using (list-rev-rev-id)\n\n-- isomorphisms\n--- natrual numbers and others\nimport Isos.NatLike\n  using (iso-nat-vec) -- with vector\n  using (iso-nat-list) -- with list\n\n--- trees\nimport Isos.TreeLike\n  using (iso-seven-tree-in-one) -- seven trees in one\n\n-- groups\n--- s3 group, xxx=e, yy=e, yx=xxy\nimport Groups.Symm.S3\n  using (s3-property-1) -- given s3, prove xyx\u2261y\n", "meta": {"hexsha": "2060ef76fba93a2703a258e394967a8f4db09f6d", "size": 2552, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/index.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/index.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8631578947, "max_line_length": 77, "alphanum_fraction": 0.6947492163, "num_tokens": 772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545304202039, "lm_q2_score": 0.8418256452674009, "lm_q1q2_score": 0.7981807993841976}}
{"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl2.Correctness.Order  {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_) \n                  (trans\u2264 : Transitive _\u2264_)  where\n\nopen import BBSTree _\u2264_ \nopen import BBSTree.Properties _\u2264_ trans\u2264\nopen import Data.List\nopen import Function using (_\u2218_)\nopen import List.Sorted _\u2264_\nopen import TreeSort.Impl2 _\u2264_ tot\u2264\n\ntheorem-treeSort-sorted : (xs : List A) \u2192 Sorted (flatten (treeSort xs))\ntheorem-treeSort-sorted = lemma-bbst-sorted \u2218 treeSort\n\n\n\n\n", "meta": {"hexsha": "67c5b79db29e0d6c4d57252f58cbc7ab0b3ed26e", "size": 532, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl2/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl2/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl2/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3333333333, "max_line_length": 72, "alphanum_fraction": 0.6522556391, "num_tokens": 159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9626731094431571, "lm_q2_score": 0.8289388083214156, "lm_q1q2_score": 0.7979971001448823}}
{"text": "{-# OPTIONS --copatterns #-}\nmodule Copatterns where\n\nopen import Common.Equality\n\nrecord _\u00d7_ (A B : Set) : Set where\n  constructor _,_\n  field\n    fst : A\n    snd : B\nopen _\u00d7_\n\npair : {A B : Set} \u2192 A \u2192 B \u2192 A \u00d7 B\nfst (pair a b) = a\nsnd (pair a b) = b\n\nswap : {A B : Set} \u2192 A \u00d7 B \u2192 B \u00d7 A\nfst (swap p) = snd p\nsnd (swap p) = fst p\n\nswap3 : {A B C : Set} \u2192 A \u00d7 (B \u00d7 C) \u2192 C \u00d7 (B \u00d7 A)\nfst (swap3 t)       = snd (snd t)\nfst (snd (swap3 t)) = fst (snd t)\nsnd (snd (swap3 t)) = fst t\n\n-- should also work if we shuffle the clauses\nswap4 : {A B C D : Set} \u2192 A \u00d7 (B \u00d7 (C \u00d7 D)) \u2192 D \u00d7 (C \u00d7 (B \u00d7 A))\nfst (snd (swap4 t))       = fst (snd (snd t))\nsnd (snd (snd (swap4 t))) = fst t\nfst (swap4 t)             = snd (snd (snd t))\nfst (snd (snd (swap4 t))) = fst (snd t)\n\n-- State monad example\n\nrecord State (S A : Set) : Set where\n  constructor state\n  field\n    runState : S \u2192 A \u00d7 S\nopen State\n\nrecord Monad (M : Set \u2192 Set) : Set1 where\n  constructor monad\n  field\n    return : {A : Set}   \u2192 A \u2192 M A\n    _>>=_  : {A B : Set} \u2192 M A \u2192 (A \u2192 M B) \u2192 M B\nopen Monad {{...}}\n\nstateMonad : {S : Set} \u2192 Monad (State S)\nrunState (return {{stateMonad}} a  ) s  = a , s\nrunState (_>>=_  {{stateMonad}} m k) s\u2080 =\n  let a , s\u2081 = runState m s\u2080\n  in  runState (k a) s\u2081\n\nleftId : {A B S : Set}(a : A)(k : A \u2192 State S B) \u2192 (return a >>= k) \u2261 k a\nleftId a k = refl\n\nrightId : {A B S : Set}(m : State S A) \u2192 (m >>= return) \u2261 m\nrightId m = refl\n\nassoc : {A B C S : Set}(m : State S A)(k : A \u2192 State S B)(l : B \u2192 State S C) \u2192\n   ((m >>= k) >>= l) \u2261 (m >>= \u03bb a \u2192 k a >>= l)\nassoc m k l = refl\n\n-- multiple clauses with abstractions\n\nfswap3 : {A B C X : Set} \u2192 (X \u2192 A) \u00d7 ((X \u2192 B) \u00d7 C) \u2192 (X \u2192 C) \u00d7 (X \u2192 (B \u00d7 A))\nfst (fswap3 t) x       = snd (snd t)\nfst (snd (fswap3 t) y) = fst (snd t) y\nsnd (snd (fswap3 t) z) = fst t z\n\n", "meta": {"hexsha": "e135b64a1e96f81583b7e8db60939ce646ce19e1", "size": 1782, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Copatterns.agda", "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/Copatterns.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Copatterns.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0985915493, "max_line_length": 78, "alphanum_fraction": 0.5173961841, "num_tokens": 708, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096204605946, "lm_q2_score": 0.8705972600147106, "lm_q1q2_score": 0.7975625254461102}}
{"text": "module Spire.Examples.Standard where\n\n----------------------------------------------------------------------\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : (n : \u2115) \u2192 \u2115\n\ndata Vec (A : Set) : \u2115 \u2192 Set where\n  nil : Vec A zero\n  cons : (n : \u2115) (a : A) (xs : Vec A n) \u2192 Vec A (suc n)\n\n----------------------------------------------------------------------\n\nelim\u2115 : (P : \u2115 \u2192 Set)\n  (pzero : P zero)\n  (psuc : (m : \u2115) \u2192 P m \u2192 P (suc m))\n  (n : \u2115)\n  \u2192 P n\nelim\u2115 P pzero psuc zero = pzero\nelim\u2115 P pzero psuc (suc n) = psuc n (elim\u2115 P pzero psuc n)\n\nelimVec : (A : Set) (P : (n : \u2115) \u2192 Vec A n \u2192 Set)\n  (pnil : P zero nil)\n  (pcons : (n : \u2115) (a : A) (xs : Vec A n) \u2192 P n xs \u2192 P (suc n) (cons n a xs))\n  (n : \u2115)\n  (xs : Vec A n)\n  \u2192 P n xs\nelimVec A P pnil pcons .zero nil = pnil\nelimVec A P pnil pcons .(suc n) (cons n a xs) = pcons n a xs (elimVec A P pnil pcons n xs)\n\n----------------------------------------------------------------------\n\nmodule PatternMatching where\n\n  add : \u2115 \u2192 \u2115 \u2192 \u2115\n  add zero n = n\n  add (suc m) n = suc (add m n)\n  \n  mult : \u2115 \u2192 \u2115 \u2192 \u2115\n  mult zero n = zero\n  mult (suc m) n = add n (mult m n)\n\n  append : (A : Set) (m : \u2115) (xs : Vec A m) (n : \u2115) (ys : Vec A n) \u2192 Vec A (add m n)\n  append A .zero nil n ys = ys\n  append A .(suc m) (cons m x xs) n ys = cons (add m n) x (append A m xs n ys) \n  \n  concat : (A : Set) (m n : \u2115) (xss : Vec (Vec A m) n) \u2192 Vec A (mult n m)\n  concat A m .zero nil = nil\n  concat A m .(suc n) (cons n xs xss) = append A m xs (mult n m) (concat A m n xss)\n\n----------------------------------------------------------------------\n\nmodule Eliminator where\n\n  add : \u2115 \u2192 \u2115 \u2192 \u2115\n  add = elim\u2115 (\u03bb _ \u2192 \u2115 \u2192 \u2115)\n    (\u03bb n \u2192 n)\n    (\u03bb m ih n \u2192 suc (ih n))\n\n  mult : \u2115 \u2192 \u2115 \u2192 \u2115\n  mult = elim\u2115 (\u03bb _ \u2192 \u2115 \u2192 \u2115)\n    (\u03bb n \u2192 zero)\n    (\u03bb m ih n \u2192 add n (ih n))\n\n  append : (A : Set) (m : \u2115) (xs : Vec A m) (n : \u2115) (ys : Vec A n) \u2192 Vec A (add m n)\n  append A = elimVec A (\u03bb m xs \u2192 (n : \u2115) (ys : Vec A n) \u2192 Vec A (add m n))\n    (\u03bb n ys \u2192 ys)\n    (\u03bb m x xs ih n ys \u2192 cons (add m n) x (ih n ys))\n\n  concat : (A : Set) (m n : \u2115) (xss : Vec (Vec A m) n) \u2192 Vec A (mult n m)\n  concat A m = elimVec (Vec A m) (\u03bb n xss \u2192 Vec A (mult n m))\n    nil\n    (\u03bb n xs xss ih \u2192 append A m xs (mult n m) ih)\n\n----------------------------------------------------------------------\n", "meta": {"hexsha": "fb3bea7423703f96d7fd38011214d0a43598fa13", "size": 2267, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_stars_repo_name": "spire/spire", "max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 43, "max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z", "max_issues_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_issues_repo_name": "spire/spire", "max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_forks_repo_name": "spire/spire", "max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z", "avg_line_length": 29.4415584416, "max_line_length": 90, "alphanum_fraction": 0.4305249228, "num_tokens": 829, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133531922388, "lm_q2_score": 0.8479677526147223, "lm_q1q2_score": 0.7970162137589905}}
{"text": "module Ag01 where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e)\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n\nsuc m + n = suc (m + n)\n\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero *  n = zero\nsuc m * n = n + (m * n)\n\n_ : 3 * 4 \u2261 12\n_ = refl\n\n_^_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm ^ 0       = 1\nm ^ (suc n) = m * (m ^ n)\n\n_ : 3 ^ 4 \u2261 81\n_ = refl\n\n_\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm \u2238 zero = m\nzero \u2238 suc n = zero\nsuc m \u2238 suc n = m \u2238 n\n\ninfixl 6 _+_ _\u2238_\ninfixl 7 _*_\n\ndata Bin : Set where\n  nil : Bin\n  x0_ : Bin \u2192 Bin\n  x1_ : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc nil    = nil\ninc (x1 b) = x0 (inc b)\ninc (x0 b) = x1 b\n\n_ : inc (x0 nil) \u2261 (x1 nil)\n_ = refl\n\n_ : inc (x1 x1 x0 x1 nil) \u2261 x0 x0 x1 x1 nil\n_ = refl\n\nto : \u2115 \u2192 Bin\nto zero = x0 nil\nto (suc m) = inc (to m)\n\nfrom : Bin \u2192 \u2115\nfrom nil      = zero\nfrom (x1 b)   = suc (2 * (from b))\nfrom (x0 b)   = 2 * (from b)\n\n", "meta": {"hexsha": "5e40f7f6d4e6031abd3795ed3ffc5e6fa2095d7c", "size": 934, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Ag01.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Ag01.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Ag01.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 14.59375, "max_line_length": 50, "alphanum_fraction": 0.5149892934, "num_tokens": 434, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768588653856, "lm_q2_score": 0.8438950986284991, "lm_q1q2_score": 0.7967862234349511}}
{"text": "{- --- 4. Lists --- -}\n\ndata List (A : Set) : Set where\n  [] : List A\n  _\u2237_ : A \u2192 List A \u2192 List A\n\ninfixr 5 _\u2237_\n\nopen import Data.Nat\nopen import Relation.Binary.PropositionalEquality\n\n{- 4.1 Length -}\n\nlength : {A : Set} \u2192 List A \u2192 \u2115\nlength [] = 0\nlength (x \u2237 l) = 1 + (length l)\n\n\n{- 4.2 List reversal -}\n\nconcat : {A : Set} \u2192 List A \u2192 List A \u2192 List A\nconcat [] l = l\nconcat (x \u2237 k) l = x \u2237 (concat k l)\n\nconcat-length : {A : Set} \u2192 (k l : List A) \u2192 length (concat k l) \u2261 (length k) + (length l)\nconcat-length [] l = refl\nconcat-length (x \u2237 k) l rewrite concat-length k l = refl\n\nconcat-assoc : {A : Set} \u2192 (j k l : List A) \u2192 concat (concat j k) l \u2261 concat j (concat k l)\nconcat-assoc [] k l = refl\nconcat-assoc (x \u2237 j) k l rewrite concat-assoc j k l = refl\n\n\n{- 4.3 List reversal -}\n\nsnoc : {A : Set} \u2192 A -> List A \u2192 List A\nsnoc a [] = a \u2237 []\nsnoc a (x \u2237 l) = x \u2237 (snoc a l)\n\nrev : {A : Set} \u2192 List A \u2192 List A\nrev [] = []\nrev (x \u2237 l) = snoc x (rev l)\n\nsnoc-length : {A : Set} \u2192 (a : A) \u2192 (l : List A) \u2192 length (snoc a l) \u2261 suc (length l)\nsnoc-length a [] = refl\nsnoc-length a (x \u2237 l) rewrite snoc-length a l = refl \n\nrev-length : {A : Set} \u2192 (l : List A) \u2192 (length (rev l)) \u2261 (length l)\nrev-length [] = refl\nrev-length (x \u2237 l) rewrite snoc-length x (rev l) | rev-length l = refl\n\nsnoc-rev : {A : Set} \u2192 (a : A) \u2192 (l : List A) \u2192 rev (snoc a l) \u2261 a \u2237 (rev l)\nsnoc-rev a [] = refl\nsnoc-rev a (x \u2237 l) rewrite snoc-rev a l = refl\n\ndouble-rev : {A : Set} \u2192 (l : List A) \u2192 rev (rev l) \u2261 l\ndouble-rev [] = refl\ndouble-rev (x \u2237 l) rewrite snoc-rev x (rev l) | double-rev l = refl\n\n\n{- 4.4 Filtering -}\nopen import Data.Bool\n\nfilter : {A : Set} \u2192 (p : A \u2192 Bool) \u2192 (l : List A) \u2192 List A\nfilter p [] = []\nfilter p (x \u2237 l) with p x\nfilter p (x \u2237 l) | false = filter p l\nfilter p (x \u2237 l) | true = x \u2237 (filter p l)\n\nempty-list : {A : Set} \u2192 (l : List A) \u2192 filter (\u03bb _ \u2192 false) l \u2261 []\nempty-list [] = refl\nempty-list (x \u2237 l) = empty-list l\n\nidentity-list : {A : Set} \u2192 (l : List A) \u2192 filter (\u03bb _ \u2192 true) l \u2261 l\nidentity-list [] = refl\nidentity-list (x \u2237 l) rewrite identity-list l = refl\n", "meta": {"hexsha": "0ed03b0e3c0b242114cdef79a211fa8589861966", "size": 2074, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD6/List.agda", "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TD6/List.agda", "max_issues_repo_name": "erwinkn/program-eq-proof", "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TD6/List.agda", "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9350649351, "max_line_length": 91, "alphanum_fraction": 0.5597878496, "num_tokens": 802, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797148356994, "lm_q2_score": 0.874077222043951, "lm_q1q2_score": 0.7964414339263876}}
{"text": "module z05-00-internal-verification where\n\nopen import bool\nopen import eq\nopen import nat\nopen import nat-thms\nopen import product\nopen import sum\n\n{-\n------------------------------------------------------------------------------\nso far: EXTERNAL VERIFICATION\n- written programs (e.g., 'length')\n- proved properties (e.g., 'length-reverse')\n\nThis style of verification in type theory is called external verification\n- proofs are external to programs\n- proofs are distinct artifacts about some pre-existing programs\n\nINTERNAL VERIFICATION\n\nwrite functions with semantically expressive types\nwrite datatypes that put restrictions on data\nmay require embedding proofs in code\n\n------------------------------------------------------------------------------\n-- p 99 VECTORS - length of vector included in type : vector is INDEXED by its length\n\n-- vector.agda\n-}\ndata \ud835\udd4d {\u2113} (A : Set \u2113) : \u2115 \u2192 Set \u2113 where\n  []   : \ud835\udd4d A 0\n  _::_ : {n : \u2115} (x : A) (xs : \ud835\udd4d A n) \u2192 \ud835\udd4d A (suc n)\n\n-- compare to list (overloaded constructors OK)\ndata L {\u2113} (A : Set \u2113) :     Set \u2113 where\n  []   : L A\n  _::_ :         (x : A) (xs : L A)   \u2192 L A\n\ninfixr 6 _::_ _++\ud835\udd4d_\n\n-- p 101\n\n[_]\ud835\udd4d : \u2200 {\u2113} {A : Set \u2113} \u2192 A \u2192 \ud835\udd4d A 1\n[ x ]\ud835\udd4d = x :: []\n\n-- type level addition on length\n_++\ud835\udd4d_ : \u2200 {\u2113} {A : Set \u2113}{n m : \u2115} \u2192 \ud835\udd4d A n \u2192 \ud835\udd4d A m \u2192 \ud835\udd4d A (n + m)\n[]        ++\ud835\udd4d ys = ys\n(x :: xs) ++\ud835\udd4d ys = x :: xs ++\ud835\udd4d ys\n\n-- p 102\n\n-- no 'nil' list corner case\nhead\ud835\udd4d : \u2200 {\u2113} {A : Set \u2113} {n : \u2115} \u2192 \ud835\udd4d A (suc n) \u2192 A\nhead\ud835\udd4d (x :: _) = x\n\n-- type level subtraction\ntail\ud835\udd4d : \u2200 {\u2113} {A : Set \u2113} {n : \u2115} \u2192 \ud835\udd4d A n \u2192 \ud835\udd4d A (pred n)\ntail\ud835\udd4d       []  = []\ntail\ud835\udd4d (_ :: xs) = xs\n\n-- p 103\n\n-- length preserving (for lists, length preservation is separate proof)\nmap\ud835\udd4d : \u2200 {\u2113 \u2113'} {A : Set \u2113} {B : Set \u2113'} {n : \u2115} \u2192 (A \u2192 B) \u2192 \ud835\udd4d A n \u2192 \ud835\udd4d B n\nmap\ud835\udd4d f       []  = []\nmap\ud835\udd4d f (x :: xs) = f x :: map\ud835\udd4d f xs\n\n-- p 104\n\n-- takes a vector of length m\n-- each element is vector of length n\n-- concats into single vector of length m * n\nconcat\ud835\udd4d : \u2200{\u2113} {A : Set \u2113} {n m : \u2115} \u2192 \ud835\udd4d (\ud835\udd4d A n) m \u2192 \ud835\udd4d A (m * n)\nconcat\ud835\udd4d       []  = []\nconcat\ud835\udd4d (x :: xs) = x ++\ud835\udd4d (concat\ud835\udd4d xs)\n\n--  p 104\n\n-- no need for maybe result as in lists by requiring n < m\nnth\ud835\udd4d : \u2200 {\u2113} {A : Set \u2113} {m : \u2115}\n  \u2192 (n : \u2115)\n  \u2192 n < m \u2261 tt\n  \u2192 \ud835\udd4d A m\n  \u2192 A\nnth\ud835\udd4d      0   _ (x :: _) = x\n-- Proof p (that index is less than length of vector) reused in recursive call.\n-- index is suc n\n-- length of list is suc m, for implicit m\n-- Agda implicitly introduces .m with suc .m\n-- p proves suc n < suc m \u2261 tt\n-- def/eq to n < m \u2261 tt\n-- so p has correct type to make the recursive call\nnth\ud835\udd4d (suc n)  p (_ :: xs) = nth\ud835\udd4d n p xs\n-- us absurd pattern for the proof in last two cases\n-- length of list is zero, so no index can be smaller than that length\n-- must case-split on the index so Agda can the absurdity\n-- because the definition of _<_ splits on both inputs\n-- - returns ff separately for when the first input is is 0 and the second is 0\n-- - and  for the first input being suc n and second is 0\nnth\ud835\udd4d (suc n) ()       []\nnth\ud835\udd4d      0  ()       []\n\n-- p 105\n\nrepeat\ud835\udd4d : \u2200 {\u2113} {A : Set \u2113} \u2192 (a : A) (n : \u2115) \u2192 \ud835\udd4d A n\nrepeat\ud835\udd4d a      0  = []\nrepeat\ud835\udd4d a (suc n) = a :: (repeat\ud835\udd4d a n)\n\n{-\n------------------------------------------------------------------------------\n-- p 106 BRAUN TREES : balanced binary heaps\n\neither empty or\nnode consisting of some data x and a left and a right subtree\n\ndata may be stored so that x is smaller than all data in left and right subtrees\nif such an ordering property is desired\n\nBRAUN TREE PROPERTY (BTP) : crucial property : sizes of left and right trees:\n\nfor each node in the tree\n- either size (left) = size ( right ) or\n         size (left) = size ( right ) + 1\n\nensures depth of the trees is \u2264 log\u2082(N), where N is the number of nodes\n\nproperty maintained (via types) during insert\n\nmake the type A and ordering on that type be parameters of the module\n\nbraun-tree.adga\n-}\n\nmodule braun-tree {\u2113} (A : Set \u2113) (_<A_ : A \u2192 A \u2192 \ud835\udd39) where\n\n  -- index n is size (number of elements of type A) of the tree\n  data braun-tree : (n : \u2115) \u2192 Set \u2113 where\n    bt-empty : braun-tree 0\n    bt-node : \u2200 {n m : \u2115}\n      \u2192 A\n      \u2192 braun-tree n\n      \u2192 braun-tree m\n      \u2192 n \u2261 m \u2228 n \u2261 suc m        -- 'v' defined in sum.agda for disjunction of two types\n      \u2192 braun-tree (suc (n + m))\n\n{- -- p 107\nsum.agda\n\n-- types A and B, possibly at different levels, accounted via \u2294 in return type\n-- \u2294 part of Agda\u2019s primitive level system : imported from Agda.Primitive module in level.agda\n-- use this in code that intended to be run\ndata _\u228e_ {\u2113 \u2113'} (A : Set \u2113) (B : Set \u2113') : Set (\u2113 \u2294 \u2113') where\n  inj\u2081 : (x : A) \u2192 A \u228e B -- built from an A\n  inj\u2082 : (y : B) \u2192 A \u228e B -- built from an B\n\n-- use this to represent a logical proposition\n_\u2228_ : \u2200 {\u2113 \u2113'} (A : Set \u2113) (B : Set \u2113') \u2192 Set (\u2113 \u2294 \u2113')\n_\u2228_ = _\u228e_\n\nNO SEMANTIC DIFFERENCE - just different notation to help understanding code\n-}\n\n  {-\n  --------------------------------------------------\n  -- p 107-108 INSERTION\n  -- this version keeps smaller (_<A_) elements closer to root when inserting\n  -}\n\n  -- type says given BT of size n, returns BT of size suc n\n  bt-insert : \u2200 {n : \u2115} \u2192 A \u2192 braun-tree n \u2192 braun-tree (suc n)\n\n  -- insert into empty\n  -- Create node with element and empty subtrees (both with size 0).\n  -- 4th arg to BT constructor is BTP proof\n  -- - both 0 so 'refl'\n  -- - wrap in inj\u2081 to say 0 \u2261 0 (not n \u2261 suc n)\n  bt-insert a bt-empty = bt-node a bt-empty bt-empty (inj\u2081 refl)\n\n  -- insert info non empty: tree has left and right satisfying BTP\n  -- left of size n; right of size m\n  -- p is BTP proof\n  -- inferred type of return is BT (suc (suc (n + m)))\n  -- because type before insert is BT (suc (n + m)) - left plus node element plus right\n  -- insert adds ONE, so BT (suc (suc (m + n)))\n  bt-insert a (bt-node{n}{m} a' l r p)\n    -- regardless of what happens, left and right will be swapped, so size sum will have m first\n\n    -- do rewrite before case splitting on which disjunct of BTP holds (n \u2261 m or n \u2261 suc m)\n    -- does not change structure of tree\n    -- will change what proof is used for BTP for new node returned.\n\n    -- case split via WITH on P\n\n    -- could split on p directly in pattern for input BT,\n    -- but here rewrite is factored to be done once\n\n    -- could do WITH on an if_then_else_ term, to put the min of element being inserted (a)\n    -- and element at current root (a') as 1st component pair (a1), max as 2nd (a2)\n    -- want min (a1) to be data at root of new BT\n    -- want to insert max (a2) recursively into right\n    rewrite +comm n m\n    with p | if a <A a' then (a , a') else (a' , a)\n\n  -- inj\u2081 case\n  -- case where p is inj\u2081 for NEW new pattern variable 'p'\n  -- underscore in place of original proof/p\n  -- because considering case where original is 'inj\u2081 p'\n\n  -- p : n \u2261 m\n  -- so new node\n  -- with smaller element a1 at root and then swapped left and update right\n  -- has type 'inj\u2082 refl'\n\n  -- BTP for new node is suc m \u2261 n v suc m \u2261 suc n\n  -- because size of new left is suc m, since it is the updated version of old right\n  -- case has proof n \u2261 m\n  -- rewrite with that proof changes that to suc m \u2261 suc n\n  -- 'inj 2 refl' proves it\n  bt-insert a (bt-node{n}{m} a' l r _) | inj\u2081 p | (a1 , a2)\n    rewrite p = (bt-node a1 (bt-insert a2 r) l (inj\u2082 refl))\n\n  -- inj\u2082 case : n \u2261 suc m\n  -- so need proof suc m \u2261 n v suc m \u2261 suc n\n  -- 'sym p' gives 'suc m \u2261 n'\n  -- wrap in 'inj\u2081'\n  bt-insert a (bt-node{n}{m} a' l r _) | inj\u2082 p | (a1 , a2) =\n                (bt-node a1 (bt-insert a2 r) l (inj\u2081 (sym p)))\n\n  {-\n  --------------------------------------------------\n  -- p 110 REMOVE MIN ELEMENT\n  -}\n\n  -- input has at least one element; returns pair of element and a BT one smaller\n  bt-remove-min : \u2200 {p : \u2115} \u2192 braun-tree (suc p) \u2192 A \u00d7 braun-tree p\n\n  -- no need for case of empty input\n  -- because size would be 0, but input is 'suc p'\n\n  -- removing sole node; return data and bt-empty\n  bt-remove-min (bt-node a bt-empty bt-empty u) = a , bt-empty\n\n  -- next two equations for left is empty and right subtree is a node -- IMPOSSIBLE by BTP\n  -- still need to handle both proves with absurd\n  bt-remove-min (bt-node a bt-empty (bt-node _ _ _ _) (inj\u2081 ()))\n  bt-remove-min (bt-node a bt-empty (bt-node _ _ _ _) (inj\u2082 ()))\n\n  -- right empty, left node (implies left size is 1, but not needed)\n  -- return data left\n  -- need to confirm size relationships satisfied, because\n  -- size of input  is suc (suc (n\u2019 + m\u2019) + 0)\n  -- size of output is      suc (n\u2019 + m\u2019)\n  -- use +0 to drop the '+ 0'\n  bt-remove-min (bt-node a (bt-node{n\u2019}{m\u2019} a\u2019 l\u2019 r\u2019 u\u2019) bt-empty u)\n    rewrite +0 (n\u2019 + m\u2019) = a , bt-node a\u2019 l\u2019 r\u2019 u\u2019\n\n\n  -- left and right of input both nodes (not empty)\n  -- return data input (the min data)\n  -- reassemble output BT: remove min from left:\n  bt-remove-min (bt-node a (bt-node a1 l1 r1 u1) (bt-node a2 l2 r2 u2) u)\n    with bt-remove-min (bt-node a1 l1 r1 u1)\n  -- then match on result of recursive call to bt-remove-min.\n  -- produces min a1\u2019 of left and updated left l\u2019\n  -- then WITH to pick smaller of a1\u2019 (minimum of left) and a2, minimum of right\n  -- similar to the bt-insert with an if_then_else_ term.\n  bt-remove-min (bt-node a (bt-node a1 l1 r1 u1) (bt-node a2 l2 r2 u2) u) | a1\u2019 , l\u2019\n    with if a1\u2019 <A a2 then (a1\u2019 , a2) else (a2 , a1\u2019)\n\n  -- p 113 first words TODO\n  bt-remove-min (bt-node a (bt-node{n1}{m1} a1 l1 r1 u1) (bt-node{n2}{m2} _ l2 r2 u2) u)\n    | _ , l\u2019 | smaller , other\n    rewrite +suc  (n1 + m1) (n2 + m2) |\n            +comm (n1 + m1) (n2 + m2) = a , bt-node smaller (bt-node other l2 r2 u2) l\u2019 (lem u)\n    where lem : \u2200 {x y}\n              \u2192 suc x \u2261 y \u2228 suc x \u2261 suc y\n              \u2192     y \u2261 x \u2228     y \u2261 suc x\n          lem (inj\u2081 p) = inj\u2082 (sym          p)\n          lem (inj\u2082 p) = inj\u2081 (sym (suc-inj p))\n\n{-\n------------------------------------------------------------------------------\n-- p 114 Sigma Types\n\nAbove expresses invariant properties of data using internally verified datatypes.\n\nAny data constructed via the constructors are guaranteed to satisfy the property,\ndue to restrictions enforced by the constructors.\n\nDifferent case: state that a property holds of an existing data type.\n\ndone using \u03a3-types (\u201csigma\u201d)\n\nsimilar to Cartesian product type A \u00d7 B (elements of A \u00d7 B are pairs (a, b))\n- but generalization where type of 2nd element can depend on type of 1st\n- aka \"dependent product type\" (though the notation comes from sum types, see below)\n\nsee nat-nonzero.agda : type for nonzero natural numbers:\n\n-- a nat 'n' AND a proof 'iszero n \u2261 ff'\n\u2115\u207a : Set\n\u2115\u207a = \u03a3 \u2115 (\u03bb n \u2192 iszero n \u2261 ff)\n\nconceptually similar to Cartesian product : N \u00d7 (iszero n \u2261 ff)\n- pair of number and equality proof\n- in Cartesian product version, 'n' is free\n- \u03a3-types enable referring to 1st of pair\n\nsee product.agda : def of \u03a3\n\nparametrized by\n- type A\n- function B\n  - input : type A\n  - returns a type\n- types can be at different levels\n- Like sum types, \u03a3 type is then at level \u2113 \u2294 \u2113' (least upper bound of the two levels)\ndata \u03a3 {\u2113 \u2113'} (A : Set \u2113) (B : A \u2192 Set \u2113') : Set (\u2113 \u2294 \u2113') where\n  _,_ : (a : A) \u2192 (b : B a) \u2192 \u03a3 A B\n                         ^\n               B depends on\n\n------------------------------------------------------------------------------\n-- p 115 example: addition on nonzero nats\n-}\n\nopen import nat-nonzero hiding (_+\u207a_)\n\n_+\u207a_ : \u2115\u207a \u2192 \u2115\u207a \u2192 \u2115\u207a\n(zero         , ()) +\u207a n2 -- cannot happen, so uses absurd pattern\n(1            , p1) +\u207a y = suc\u207a y\n(suc (suc n1) , p1) +\u207a y = suc\u207a ((suc n1 , refl) +\u207a y) -- recursive call\n\n{-\n-- p 115 5.3.1 Why Sigma and Pi?\n\nwhy \u03a3 symbol for type of dependent pairs?\n- because \u03a3-types generalize disjoint unions\n- in math, a disjoint union is union of two sets\n  - where elements are tagged to indicate from which set they have come\n  - cardinality of A \u228e B, is sum of cardinalities of A and B\n    even if they have a nonempty intersection.\n- This is where we get the notation for sum types in Figure 5.2.\n- The disjoint union can be defined mathematically as\n    ({0} \u00d7 A) \u222a ({1} \u00d7 B)\n  - each element of union looks like (n, x)\n    where if the tag n is 0, then x P A, and\n          if         n is 1, then x P B.\n\n------------------------------------------------------------------------------\n-- p 116 Binary Search Trees\n\nfor some type A and an ordering relation on that type\nvalues in left  subtree always \u2264 value at node \u2115\nvalues in right subtree always > value at node \u2115\n\nsee z05-01-bst-test.agda\n    z05-01-bst.agda\n\n-- p 117-120\nTODO : read/understand discussion of\n       bool-relations.agda\n       relations.agda\n\n------------------------------------------------------------------------------\n-- p 123 Internal vs. External Verification\n\ninternal verification : datatypes defined with invariants; functions take proofs of preconditions\n- Datatypes with essential invariants : enforce via internal\n- Complex programs\n  - doing external of complex will cause reasoning about complexity\n    not relevant to property being proved\n  - internal weaves proofs thru code and datatype\n\nexternal verification : theorems about functions proved separately\n- Algebraic Properties e.g., proving associativity\n- Functions used in an internal verification's specification\n  -- e.g., min/max used in bst - need to externally prove properties about min/max\n\n------------------------------------------------------------------------------\n-- p 126 Exercises\n\n1. Nested vector type.\n   Fill in the hole to define a type for matrices of nats\n   where the type lists the dimensions of the matrix:\n-}\n\n-- inner vector is a row\n_by_matrix : \u2115 \u2192 \u2115 \u2192 Set\nrows by cols matrix = \ud835\udd4d (\ud835\udd4d \u2115 cols) rows\n\nmatrix-to-vec-vec : \u2200 {rows cols : \u2115} \u2192 rows by cols matrix \u2192 \ud835\udd4d (\ud835\udd4d \u2115 cols) rows\nmatrix-to-vec-vec \ud835\udd5e = \ud835\udd5e\n\n-- 2a\nzero-matrix : (rows cols : \u2115) \u2192 rows by cols matrix\nzero-matrix rows cols = repeat\ud835\udd4d (repeat\ud835\udd4d 0 cols) rows\n\n_ : zero-matrix 2 3 \u2261 (0 :: 0 :: 0 :: []) ::\n                      (0 :: 0 :: 0 :: []) :: []\n_ = refl\n\n_ : zero-matrix 0 0 \u2261 []\n_ = refl\n_ : zero-matrix 0 1 \u2261 []\n_ = refl\n_ : zero-matrix 1 0 \u2261 [] :: []\n_ = refl\n_ : zero-matrix 1 1 \u2261 (0 :: []) :: []\n_ = refl\n\n-- 2b\nmatrix-elt : \u2200 {rows cols : \u2115}\n  \u2192 rows by cols matrix\n  \u2192 (r : \u2115)\n  \u2192 (c : \u2115)\n  \u2192 r < rows \u2261 tt\n  \u2192 c < cols \u2261 tt\n  \u2192 \u2115\nmatrix-elt \ud835\udd5e r c r<rows c<cols = nth\ud835\udd4d c c<cols (nth\ud835\udd4d r r<rows (matrix-to-vec-vec \ud835\udd5e))\n\n-- 2c\ndiagonal-matrix : \u2115 \u2192 (n : \u2115) \u2192 n by n matrix\ndiagonal-matrix d n = mkRows n n n\n where\n  -- when constructing rows/cols\n  -- - row/col param corresponds to row/col - rows/cols\n  -- - e.g., for 2 x 3 matrix\n  --   row param 2 corresponds 2 - 2 = 0\n\n  mkElt  : \u2115 \u2192 \u2115 \u2192 \u2115\n  mkElt i col = if i =\u2115 col then d else zero\n\n  mkCols : (\u2115 \u2192 \u2115) \u2192 (cols : \u2115) \u2192 \ud835\udd4d \u2115 cols\n  mkCols _     zero   = []\n  mkCols f sc@(suc c) = f sc :: mkCols f c\n\n  mkRows : \u2115 \u2192 (rows : \u2115) \u2192 (cols : \u2115) \u2192 \ud835\udd4d (\ud835\udd4d \u2115 cols) rows\n  mkRows _  zero   _ = []\n  mkRows i (suc r) c = mkCols (mkElt i) c :: mkRows (i \u2238 1) r c\n\nidentity-matrix : (n : \u2115) \u2192 n by n matrix\nidentity-matrix = diagonal-matrix 1\n\nidm5 : 5 by 5 matrix\nidm5 = identity-matrix 5\n\n_ : idm5 \u2261 (1 :: 0 :: 0 :: 0 :: 0 :: []) ::\n           (0 :: 1 :: 0 :: 0 :: 0 :: []) ::\n           (0 :: 0 :: 1 :: 0 :: 0 :: []) ::\n           (0 :: 0 :: 0 :: 1 :: 0 :: []) ::\n           (0 :: 0 :: 0 :: 0 :: 1 :: []) :: []\n_ = refl\n\n_ : matrix-elt idm5 0 0 refl refl \u2261 1\n_ = refl\n_ : matrix-elt idm5 1 1 refl refl \u2261 1\n_ = refl\n_ : matrix-elt idm5 0 1 refl refl \u2261 0\n_ = refl\n\n-- 2d\n-- BEGIN https://typeslogicscats.gitlab.io/posts/agda-matrix.lagda.html\nprepend-column\n  : \u2200 {m n : \u2115}\n  \u2192 \ud835\udd4d \u2115 n                    -- a column\n  \u2192 n by     m matrix\n  \u2192 n by suc m matrix        -- prepends the given column to the matrix\nprepend-column      []           []  = []\nprepend-column (x :: xs) (vec :: vecs) = (x :: vec) :: (prepend-column xs vecs)\n\n-- inverse of prepend-column (NOT USED)\nunprepend-column\n  : \u2200 {m n : \u2115}\n  \u2192            n by suc m matrix\n  \u2192 (\ud835\udd4d \u2115 n) \u00d7 (n by     m matrix)\nunprepend-column                     [] = ([] , [])\nunprepend-column ((x :: vec) :: matrix) = let xs-vecs = unprepend-column matrix\n                                in x :: fst xs-vecs , vec :: snd xs-vecs\n\nfill-empty : (n : \u2115) \u2192 n by 0 matrix\nfill-empty       0 = []\nfill-empty (suc n) = [] :: fill-empty n\n\ntranspose : \u2200 {i : \u2115} {j : \u2115} \u2192 i by j matrix \u2192 j by i matrix\ntranspose     {0} {j}           []  = fill-empty j\ntranspose {suc _} {_} (row :: rows) = prepend-column row (transpose rows)\n-- END https://typeslogicscats.gitlab.io/posts/agda-matrix.lagda.html\n\nex2x3 : 2 by 3 matrix\nex2x3 = (1 :: 2 :: 3 :: []) ::\n        (0 :: 6 :: 7 :: []) :: []\n\n_ : transpose ex2x3 \u2261 (1 :: 0 :: []) ::\n                      (2 :: 6 :: []) ::\n                      (3 :: 7 :: []) :: []\n_ = refl\n\n-- BEGIN https://www.cs.nott.ac.uk/~psztxa/g53cfr/solutions/ex02.agda\nvreturn : {A : Set} {n : \u2115} \u2192 A \u2192 \ud835\udd4d A n\nvreturn {n = zero}  a = []\nvreturn {n = suc m} a = a :: vreturn {n = m} a\n\nvapp : {A B : Set} {n : \u2115} \u2192 \ud835\udd4d (A \u2192 B) n \u2192 \ud835\udd4d A n \u2192 \ud835\udd4d B n\nvapp      []       []  = []\nvapp (f :: fs) (a :: as) = f a :: vapp fs as\n\ntransposeX : {m n : \u2115} \u2192 m by n matrix \u2192 n by m matrix\ntransposeX         []  = vreturn []\ntransposeX (as :: ass) = vapp (vapp (vreturn _::_ ) as) (transposeX ass)\n\n_ : transposeX ex2x3 \u2261 (1 :: 0 :: []) ::\n                       (2 :: 6 :: []) ::\n                       (3 :: 7 :: []) :: []\n_ = refl\n-- END https://www.cs.nott.ac.uk/~psztxa/g53cfr/solutions/ex02.agda\n\n-- BEGIN HORRIBLE HACKY TRY\npostulate\n  yyy : (n : \u2115) \u2192 (rc : \u2115) \u2192 rc < n \u2261 tt\n\nxx : \u2200 {x y : \u2115}\n   \u2192 x =\u2115 0 \u2261 ff\n   \u2192 y =\u2115 0 \u2261 ff\n   \u2192 x \u2238 y < x \u2261 tt\nxx {x} {suc y} x\u22600 y\u22600\n  rewrite \u2238< {x} {y} x\u22600\n  = refl\n\ntranspose' : \u2200 {n m : \u2115} \u2192 n by m matrix \u2192 m by n matrix\ntranspose'             {0}       {m} _ = zero-matrix m 0\ntranspose'             {1}       {m} _ = zero-matrix m 1\ntranspose' n@{suc (suc _)}    {zero} \ud835\udd5e = zero-matrix zero n\ntranspose' n@{suc (suc _)} m@{suc _} \ud835\udd5e = mkRows m n\n where\n  mkElt : (newRow : \u2115)\n        \u2192 newRow =\u2115 0 \u2261 ff\n        \u2192 (newCol : \u2115)\n        \u2192 newCol =\u2115 0 \u2261 ff\n        \u2192 \u2115\n  mkElt newRow rp newCol cp =\n    matrix-elt \ud835\udd5e (n \u2238 newCol)         (m \u2238 newRow)\n--                 (xx cp refl) (xx rp refl)\n--              (yyy (n \u2238 newCol) n) (yyy (m \u2238 newRow) m)\n                    {!!} {!!}\n\n  mkCols : (\u2200 (new : \u2115) \u2192 new =\u2115 0 \u2261 ff \u2192 \u2115) \u2192 (cols : \u2115) \u2192 \ud835\udd4d \u2115 cols\n  mkCols _     zero   = []\n  mkCols f sc@(suc c) = f sc refl :: mkCols f c\n\n  mkRows : (rows : \u2115) \u2192 (cols : \u2115) \u2192 \ud835\udd4d (\ud835\udd4d \u2115 cols) rows\n  mkRows     zero   _ = []\n  mkRows sr@(suc r) c = mkCols (mkElt sr refl) c :: mkRows r c\n\n_ : transpose' ex2x3 \u2261 (1 :: 0 :: []) ::\n                       (2 :: 6 :: []) ::\n                       (3 :: 7 :: []) :: []\n_ = refl\n-- END HORRIBLE HACKY TRY\n\n-- 2e\ndotProduct\ud835\udd4d : \u2200 {n : \u2115} \u2192 \ud835\udd4d \u2115 n \u2192 \ud835\udd4d \u2115 n \u2192 \u2115\ndotProduct\ud835\udd4d       []        []  = 0\ndotProduct\ud835\udd4d (a :: as) (b :: bs) = a * b + (dotProduct\ud835\udd4d as bs)\n\n_ : dotProduct\ud835\udd4d (1 :: 3 :: 5 :: []) (4 :: 2 :: 1 :: []) \u2261 15\n_ = refl\n\nfoldr : \u2200 {A B : Set} {n : \u2115} \u2192 (A \u2192 B \u2192 B) \u2192 B \u2192 \ud835\udd4d A n \u2192 B\nfoldr f z       []  = z\nfoldr f z (x :: xs) = f x (foldr f z xs)\n\nzipWith : \u2200 {A B C : Set} {n : \u2115} \u2192 (A \u2192 B \u2192 C) \u2192 \ud835\udd4d A n \u2192 \ud835\udd4d B n \u2192 \ud835\udd4d C n\nzipWith _       []        []  = []\nzipWith f (x :: xs) (y :: ys) = f x y :: zipWith f xs ys\n\ndotProduct\ud835\udd4d' : \u2200 {n : \u2115} \u2192 \ud835\udd4d \u2115 n \u2192 \ud835\udd4d \u2115 n \u2192 \u2115\ndotProduct\ud835\udd4d' as bs = foldr _+_ 0 (zipWith _*_ as bs)\n\n_ : dotProduct\ud835\udd4d' (1 :: 3 :: 5 :: []) (4 :: 2 :: 1 :: []) \u2261 15\n_ = refl\n\n-- 2f\nmatrix-* : \u2200 {m n p : \u2115} \u2192 m by n matrix \u2192 n by p matrix \u2192 m by p matrix\nmatrix-* [] _ = []\nmatrix-* {m} {n} {p} (a :: as) bs =\n  doRow {n} {p} a (transpose bs) :: matrix-* as bs\n where\n  doRow : \u2200 {n p : \u2115} \u2192 \ud835\udd4d \u2115 n \u2192 p by n matrix \u2192 \ud835\udd4d \u2115 p\n  doRow a [] = []\n  doRow {n} {p} a (b :: bs) = dotProduct\ud835\udd4d a b :: doRow a bs\n\nma : 2 by 3 matrix\nma = (2 :: 3 :: 4 :: []) ::\n     (1 :: 0 :: 0 :: []) :: []\nmb : 3 by 2 matrix\nmb = (0 :: 1000 :: []) ::\n     (1 ::  100 :: []) ::\n     (0 ::   10 :: []) :: []\n\n_ : matrix-* ma mb \u2261 (3 :: 2340 :: []) ::\n                     (0 :: 1000 :: []) :: []\n_ = refl\n\nidentity-2 : 2 by 2 matrix\nidentity-2 = identity-matrix 2\n\nsome-mat : 2 by 2 matrix\nsome-mat =\n  (1 :: 2 :: []) ::\n  (3 :: 4 :: []) :: []\n\nsome-mat-trans : 2 by 2 matrix\nsome-mat-trans =\n  (1 :: 3 :: []) ::\n  (2 :: 4 :: []) :: []\n\n_ : matrix-* some-mat identity-2 \u2261 some-mat\n_ = refl\n\n_ : transpose some-mat \u2261 some-mat-trans\n_ = refl\n\nleft-mat : 2 by 3 matrix\nleft-mat =\n  (1 :: 2 :: 3 :: []) ::\n  (4 :: 5 :: 6 :: []) :: []\n\nright-mat : 3 by 2 matrix\nright-mat =\n  ( 7 ::  8 :: []) ::\n  ( 9 :: 10 :: []) ::\n  (11 :: 12 :: []) :: []\n\nproduct : 2 by 2 matrix\nproduct =\n  ( 58 ::  64 :: []) ::\n  (139 :: 154 :: []) :: []\n\n_ : matrix-* left-mat right-mat \u2261 product\n_ = refl\n\n-- TODO https://www.cs.nott.ac.uk/~psztxa/g53cfr/solutions/ex02.agda\n\n-- 3\n-- from list.agda\ndata \ud835\udd43 {\u2113} (A : Set \u2113) : Set \u2113 where\n  [] : \ud835\udd43 A\n  _::_ : (x : A) (xs : \ud835\udd43 A) \u2192 \ud835\udd43 A\n\n-- from vector.agda\n\ud835\udd4d-to-\ud835\udd43 : \u2200 {\u2113} {A : Set \u2113} {n : \u2115} \u2192 \ud835\udd4d A n \u2192 \ud835\udd43 A\n\ud835\udd4d-to-\ud835\udd43 [] = []\n\ud835\udd4d-to-\ud835\udd43 (x :: xs) = x :: (\ud835\udd4d-to-\ud835\udd43 xs)\n\n\ud835\udd43-to-\ud835\udd4d : \u2200 {\u2113} {A : Set \u2113} \u2192 \ud835\udd43 A \u2192 \u03a3 \u2115 (\u03bb n \u2192 \ud835\udd4d A n)\n\ud835\udd43-to-\ud835\udd4d [] = (0 , [])\n\ud835\udd43-to-\ud835\udd4d (x :: xs) with \ud835\udd43-to-\ud835\udd4d xs\n... | (n , v) = (suc n , x :: v)\n\ne3 : \u2200 {\u2113} {A : Set \u2113} {n : \u2115}\n   \u2192 (v : \ud835\udd4d A n)\n   \u2192 \ud835\udd43-to-\ud835\udd4d (\ud835\udd4d-to-\ud835\udd43 v) \u2261 n , v\ne3       [] = refl\ne3 (x :: v) with e3 v\n... | zz rewrite zz = refl\n\n-- 4. fun takes V (A \u00d7 B) n ; returns pair V A n and V B n\n--    similar to Haskell unzip\nunzip : \u2200 {\u2113} {A B : Set \u2113} {n : \u2115}\n      \u2192 \ud835\udd4d (A \u00d7 B) n\n      \u2192 \ud835\udd4d A n \u00d7 \ud835\udd4d B n\nunzip       [] = [] , []\nunzip ((a , b) :: v) =\n  let rest = unzip v\n   in a :: fst rest , b :: snd rest\n\n_ : unzip ((1 , 10) :: (2 , 20) :: (3 , 30) :: []) \u2261   ( 1 ::  2 ::  3 :: [])\n                                                     , (10 :: 20 :: 30 :: [])\n_ = refl\n\n{- TODO\n-- 5. Implement remove-min / remove-max functions for bst. type.\nUsing remove-min, define a general remove function\n- finds first value isomorphic to given one\n- returns bst without that value.\nIf node holding that value has two (non-leaf) nodes as left and right sub-trees,\nthen necessary to replace the removed element with its successor.\nThis is the minimum value in the right subtree.\n\n-- 6. In list-merge-sort.agda : merge-sort using Braun trees.\nState and prove theorems about merge-sort.\nE.g., prove length of input list and length of returned sorted list are the same.\n-}\n", "meta": {"hexsha": "bea1bfeb48922acafc7cb610fbc000f1851eb909", "size": 22151, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-00-internal-verification.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-00-internal-verification.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-00-internal-verification.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 31.7804878049, "max_line_length": 97, "alphanum_fraction": 0.5512166494, "num_tokens": 7721, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797100118214, "lm_q2_score": 0.874077222043951, "lm_q1q2_score": 0.7964414297099457}}
{"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Greatest Common Divisor for integers\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Integer.GCD where\n\nopen import Data.Integer.Base\nopen import Data.Integer.Divisibility\nopen import Data.Integer.Properties\nopen import Data.Nat.Base\nimport Data.Nat.GCD as \u2115\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------\n-- Definition\n------------------------------------------------------------------------\n\ngcd : \u2124 \u2192 \u2124 \u2192 \u2124\ngcd i j = + \u2115.gcd \u2223 i \u2223 \u2223 j \u2223\n\n------------------------------------------------------------------------\n-- Properties\n------------------------------------------------------------------------\n\ngcd[i,j]\u2223i : \u2200 i j \u2192 gcd i j \u2223 i\ngcd[i,j]\u2223i i j = \u2115.gcd[m,n]\u2223m \u2223 i \u2223 \u2223 j \u2223\n\ngcd[i,j]\u2223j : \u2200 i j \u2192 gcd i j \u2223 j\ngcd[i,j]\u2223j i j = \u2115.gcd[m,n]\u2223n \u2223 i \u2223 \u2223 j \u2223\n\ngcd-greatest : \u2200 {i j c} \u2192 c \u2223 i \u2192 c \u2223 j \u2192 c \u2223 gcd i j\ngcd-greatest c\u2223i c\u2223j = \u2115.gcd-greatest c\u2223i c\u2223j\n\ngcd[0,0]\u22610 : gcd 0\u2124 0\u2124 \u2261 0\u2124\ngcd[0,0]\u22610 = cong (+_) \u2115.gcd[0,0]\u22610\n\ngcd[i,j]\u22610\u21d2i\u22610 : \u2200 i j \u2192 gcd i j \u2261 0\u2124 \u2192 i \u2261 0\u2124\ngcd[i,j]\u22610\u21d2i\u22610 i j eq = \u2223n\u2223\u22610\u21d2n\u22610 (\u2115.gcd[m,n]\u22610\u21d2m\u22610 (+-injective eq))\n\ngcd[i,j]\u22610\u21d2j\u22610 : \u2200 {i j} \u2192 gcd i j \u2261 0\u2124 \u2192 j \u2261 0\u2124\ngcd[i,j]\u22610\u21d2j\u22610 {i} eq = \u2223n\u2223\u22610\u21d2n\u22610 (\u2115.gcd[m,n]\u22610\u21d2n\u22610 \u2223 i \u2223 (+-injective eq))\n\ngcd-comm : \u2200 i j \u2192 gcd i j \u2261 gcd j i\ngcd-comm i j = cong (+_) (\u2115.gcd-comm \u2223 i \u2223 \u2223 j \u2223)\n", "meta": {"hexsha": "262988a1782445c62681c8c331c84ac12d67cf63", "size": 1511, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/src/Data/Integer/GCD.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/src/Data/Integer/GCD.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/src/Data/Integer/GCD.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 30.8367346939, "max_line_length": 75, "alphanum_fraction": 0.4063534083, "num_tokens": 564, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418178895028, "lm_q2_score": 0.8615382094310357, "lm_q1q2_score": 0.7961834870448644}}
{"text": "{-# OPTIONS --safe #-}\nmodule TEST where\n\nopen import Data.Nat\nopen import Data.Nat.Properties\nopen import Relation.Binary.PropositionalEquality\n\narith-sum : \u2115 \u2192 \u2115\narith-sum zero = zero\narith-sum (suc n) = suc n + arith-sum n\n\narith-formula : \u2115 \u2192 \u2115\narith-formula n = \u230a n * (n + 1) /2\u230b\n\nsilly : \u2200 (n m : \u2115) \u2192  \u230a n + n + m * (m + 1) /2\u230b \u2261 n +  \u230a m * (m + 1) /2\u230b\nsilly zero m = refl\nsilly (suc n) m rewrite +-suc n n = cong suc (silly n m)\n\nlemma : \u2200 (n : \u2115) \u2192  \u230a suc n * (suc n + 1) /2\u230b \u2261 suc n +  \u230a n * (n + 1) /2\u230b\nlemma n rewrite *-comm n (suc n + 1) | +-assoc n 1 (n + (n + 1) * n) | *-comm (n + 1) n | +-comm n (suc (n + n * (n + 1)))\n                                     | +-assoc n (n * (n + 1)) n | +-comm (n * (n + 1)) n | sym (silly n n) | +-assoc n n (n * (n + 1)) = refl\n \narith-eq : (n : \u2115) -> arith-formula n \u2261 arith-sum n\narith-eq zero = refl\narith-eq (suc n) rewrite lemma n =  cong (_+_ (suc n)) (arith-eq n)\n", "meta": {"hexsha": "401c682e94c65daf36f954dafcf585483ad3bb85", "size": 923, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/TEST.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/TEST.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/TEST.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 35.5, "max_line_length": 142, "alphanum_fraction": 0.5135427952, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9504109798251321, "lm_q2_score": 0.8376199633332891, "lm_q1q2_score": 0.7960832100726826}}
{"text": "-- Length-indexed lists as a recursive family\n-- From \"Dependent Types at Work\", section 3.1\n\nmodule xx where\n\nopen import Level renaming (suc to lsuc)\nopen import Data.Nat hiding (_^_)\nopen import Data.Empty.Polymorphic\nopen import Data.Unit.Polymorphic\nopen import Data.Maybe hiding (map ; zip)\nopen import Data.Product hiding (map ; zip)\n\nprivate\n  variable\n    m n : \u2115\n    \u2113 \u2113\u2032 : Level\n    A : Set \u2113\n    B : Set \u2113\u2032\n\n-- Vec : Set \u2113 \u2192 \u2115 \u2192 Set \u2113\n-- Vec A zero = \u22a4\n-- Vec A (suc n) = A \u00d7 Vec A n\n\n-- Generalize Vec\n\nopen import Function\n\niter : A \u2192 (A \u2192 A) \u2192 \u2115 \u2192 A\niter z f zero    = z\niter z f (suc n) = f (iter z f n)\n\n-- Is iter defined somewhere standard?\n\nVec : Set \u2113 \u2192 \u2115 \u2192 Set \u2113\nVec A = iter \u22a4 (A \u00d7_)\n\nhead : Vec A (suc n) \u2192 A\nhead (a , _) = a\n\ntail : Vec A (suc n) \u2192 Vec A n\ntail (_ , as) = as\n\nmap : (A \u2192 B) \u2192 Vec A n \u2192 Vec B n\nmap {n = zero } _ _ = tt\nmap {n = suc n} f (a , as) = f a , map {n = n} f as\n\nzip : Vec A n \u2192 Vec B n \u2192 Vec (A \u00d7 B) n\nzip {n = zero } _ _ = tt\nzip {n = suc n} (a , as) (b , bs) = (a , b) , zip {n = n} as bs\n\nFin : \u2115 \u2192 Set\nFin zero    = \u22a5\nFin (suc n) = Maybe (Fin n)\n\nf5 : Fin 5\nf5 = nothing\nf4 : Fin 4\nf4 = nothing\nf3 : Fin 3\nf3 = nothing\nf2 : Fin 2\nf2 = just nothing -- an element of the type\nf1 : Fin 1\nf1 = nothing\n-- f0 : Fin 0\n-- f0 = {!!} -- no solution found\n\n_!_ : Vec A n \u2192 Fin n \u2192 A\n_!_ {n = suc m} (a , _ ) nothing = a\n_!_ {n = suc m} (_ , as) (just i) = as ! i\n\n_!'_ : Vec A n \u2192 Fin n \u2192 A\n_!'_ {n = suc m} (a , _)   nothing    = a\n_!'_ {n = suc m} (_ , as) (just finm) = as !' finm\n\n{-\n(0 , 1 , 2 , tt) !                  nothing\n(0 , 1 , 2 , tt) !             just nothing\n(0 , 1 , 2 , tt) !       just (just nothing)\n(0 , 1 , 2 , tt) ! just (just (just nothing))\n-}\n\n-- Perfect binary leaf tree\nBTree : Set \u2113 \u2192 \u2115 \u2192 Set \u2113\nBTree A = iter A (\u03bb \u03c4 \u2192 \u03c4 \u00d7 \u03c4)\n", "meta": {"hexsha": "45ff6949b18ea45025374a642c66854be4e19279", "size": 1802, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/xx.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/xx.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/xx.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 20.9534883721, "max_line_length": 63, "alphanum_fraction": 0.5410654828, "num_tokens": 718, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.931462503162843, "lm_q2_score": 0.8539127510928476, "lm_q1q2_score": 0.7953877086156135}}
{"text": "module List.Sorted  {A : Set}(_\u2264_ : A \u2192 A \u2192 Set) where\n\nopen import Data.List\n\ndata Sorted :  List A \u2192 Set where\n  nils : Sorted []\n  singls : (x : A) \n                   \u2192 Sorted [ x ]\n  conss : {x y : A}{xs : List A} \n                   \u2192 x \u2264 y \n                   \u2192 Sorted (y \u2237 xs) \n                   \u2192 Sorted (x \u2237 y \u2237 xs)\n\n\n\n\n", "meta": {"hexsha": "b68d745bb730bf741c6a26f9bbe238a387173d9b", "size": 331, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Sorted.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Sorted.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Sorted.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.4705882353, "max_line_length": 54, "alphanum_fraction": 0.4048338369, "num_tokens": 104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9621075777163567, "lm_q2_score": 0.8267117940706734, "lm_q1q2_score": 0.795385681662879}}
{"text": "------------------------------------------------------------------------------\n-- Common (interactive and automatic) properties using the induction principle\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule PA.Inductive.PropertiesByInduction where\n\nopen import PA.Inductive.Base\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\nsuccCong : \u2200 {m n} \u2192 m \u2261 n \u2192 succ m \u2261 succ n\nsuccCong refl = refl\n\n------------------------------------------------------------------------------\n\n+-leftIdentity : \u2200 n \u2192 zero + n \u2261 n\n+-leftIdentity n = refl\n\n+-rightIdentity : \u2200 n \u2192 n + zero \u2261 n\n+-rightIdentity n = \u2115-ind A A0 is n\n  where\n  A : \u2115 \u2192 Set\n  A i = i + zero \u2261 i\n\n  A0 : A zero\n  A0 = refl\n\n  is : \u2200 i \u2192 A i \u2192 A (succ i)\n  is i ih = succCong ih\n\n+-assoc : \u2200 m n o \u2192 m + n + o \u2261 m + (n + o)\n+-assoc m n o = \u2115-ind A A0 is m\n  where\n  A : \u2115 \u2192 Set\n  A i = i + n + o \u2261 i + (n + o)\n\n  A0 : A zero\n  A0 = refl\n\n  is : \u2200 i \u2192 A i \u2192 A (succ i)\n  is i ih = succCong ih\n\nx+Sy\u2261S[x+y] : \u2200 m n \u2192 m + succ n \u2261 succ (m + n)\nx+Sy\u2261S[x+y] m n = \u2115-ind A A0 is m\n  where\n  A : \u2115 \u2192 Set\n  A i = i + succ n \u2261 succ (i + n)\n\n  A0 : A zero\n  A0 = refl\n\n  is : \u2200 i \u2192 A i \u2192 A (succ i)\n  is i ih = succCong ih\n", "meta": {"hexsha": "831f456210057310780fcf2d3dcbadf2cc35783a", "size": 1436, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/PropertiesByInduction.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive/PropertiesByInduction.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive/PropertiesByInduction.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 23.9333333333, "max_line_length": 78, "alphanum_fraction": 0.4164345404, "num_tokens": 418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133481428692, "lm_q2_score": 0.8459424334245618, "lm_q1q2_score": 0.7951125849362061}}
{"text": "data \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + b = b\nsuc a + b = suc (a + b)\ninfix 100 _+_\n\ndata _\u2261_ : \u2115 \u2192 \u2115 \u2192 Set where\n  refl : {n : \u2115} \u2192 n \u2261 n\n\nsym : {n m : \u2115} \u2192 n \u2261 m \u2192 m \u2261 n\nsym refl = refl\n\ntrans : {m n o : \u2115} \u2192 m \u2261 n \u2192 n \u2261 o \u2192 m \u2261 o\ntrans refl p\u2082 = p\u2082\n\nsuc-inj : {m n : \u2115} \u2192 suc m \u2261 suc n \u2192 m \u2261 n\nsuc-inj refl = refl\n\ndata \u22a5 : Set where\n\n\u00ac : Set \u2192 Set\n\u00ac A = A \u2192 \u22a5\n\n_\u2262_ : \u2115 \u2192 \u2115 \u2192 Set\nm \u2262 n = \u00ac(m \u2261 n)\n\nzero-img : \u2200 {m} \u2192 suc m \u2262 0\nzero-img ()\n\ninduction : (P : \u2115 \u2192 Set) \u2192 P 0 \u2192 (\u2200 {n} \u2192 P n \u2192 P (suc n)) \u2192 (\u2200 m \u2192 P m)\ninduction pred base hypo zero = base\ninduction pred base hypo (suc m) = hypo (induction pred base hypo m)\n\ncong : \u2200 {m n} \u2192 (f : \u2115 \u2192 \u2115) \u2192 m \u2261 n \u2192 f m \u2261 f n\ncong f refl = refl\n\nassoc : \u2200 m n o \u2192 m + (n + o) \u2261 (m + n) + o\nassoc zero n o = refl\nassoc (suc m) n o = cong suc (assoc m n o)\n\nn+zero : \u2200 n \u2192 n \u2261 n + 0\nn+zero zero = refl\nn+zero (suc n) = cong suc (n+zero n)\n\nsuc+ : \u2200 m n \u2192 suc (n + m) \u2261 (n + suc m)\nsuc+ m zero = refl\nsuc+ m (suc n) = cong suc (suc+ m n)\n\ncomm : \u2200 m n \u2192 m + n \u2261 n + m\ncomm zero n = n+zero n\ncomm (suc m) n = trans (cong suc (comm m n)) (suc+ m n)\n\n\n-- Where to go from here?\n-- Agda:\n--   \u2022 Aaron Stump - Verified Functional Programming in Agda, https://svn.divms.uiowa.edu/repos/clc/projects/agda/book/book.pdf\n--   \u2022 Conor McBride - Dependently Typed Metaprogramming (in Agda), http://cs.ioc.ee/ewscs/2014/mcbride/mcbride-deptypedmetaprog.pdf\n-- Type theory:\n--   \u2022 So you want to learn type theory, http://purelytheoretical.com/sywtltt.html\n", "meta": {"hexsha": "ef1ab753322df632942d29a24a836915c97932da", "size": 1543, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "fpb-6/talk.agda", "max_stars_repo_name": "FPBrno/FPBrno.github.io", "max_stars_repo_head_hexsha": "970b31f80fc24481a088b099f32a8c8e4b120618", "max_stars_repo_licenses": ["Artistic-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-12-06T14:30:32.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T14:30:32.000Z", "max_issues_repo_path": "fpb-6/talk.agda", "max_issues_repo_name": "FPBrno/FPBrno.github.io", "max_issues_repo_head_hexsha": "970b31f80fc24481a088b099f32a8c8e4b120618", "max_issues_repo_licenses": ["Artistic-2.0"], "max_issues_count": 21, "max_issues_repo_issues_event_min_datetime": "2015-03-05T11:01:13.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-14T18:45:37.000Z", "max_forks_repo_path": "fpb-6/talk.agda", "max_forks_repo_name": "FPBrno/FPBrno.github.io", "max_forks_repo_head_hexsha": "970b31f80fc24481a088b099f32a8c8e4b120618", "max_forks_repo_licenses": ["Artistic-2.0"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-03-04T22:12:51.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-14T07:57:40.000Z", "avg_line_length": 23.7384615385, "max_line_length": 132, "alphanum_fraction": 0.5541153597, "num_tokens": 646, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.953966098909522, "lm_q2_score": 0.8333245953120233, "lm_q1q2_score": 0.794963413315167}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level\nopen import Categories.Category\nopen import Categories.Monad\n\nmodule Categories.Monad.Morphism {o \u2113 e} {C D : Category o \u2113 e} where\n\nopen import Categories.NaturalTransformation\nopen import Categories.Functor\n\nopen NaturalTransformation\n\n-- monad morphism in the sense of the nLab\n-- https://ncatlab.org/nlab/show/monad#the_bicategory_of_monads\n-- between generic monads t : a -> a & s : b -> b\nrecord Monad\u21d2 (M : Monad C) (N : Monad D) : Set (o \u2294 \u2113 \u2294 e) where\n\n  private\n    module M = Monad M\n    module N = Monad N\n\n  open module D = Category D using (_\u2218_; _\u2248_)\n\n  field\n    X : Functor C D\n    \u03b1 : NaturalTransformation (N.F \u2218F X) (X \u2218F M.F)\n\n  module X = Functor X\n  module \u03b1 = NaturalTransformation \u03b1\n\n  field\n    unit-comp : \u2200 {U} \u2192 \u03b1.\u03b7 U \u2218 (N.\u03b7.\u03b7 (X.\u2080 U)) \u2248 X.\u2081 (M.\u03b7.\u03b7 U)\n    mult-comp : \u2200 {U} \u2192 \u03b1.\u03b7 U \u2218 (N.\u03bc.\u03b7 (X.\u2080 U)) \u2248 X.\u2081 (M.\u03bc.\u03b7 U) \u2218 \u03b1.\u03b7 (M.F.\u2080 U) \u2218 N.F.\u2081 (\u03b1.\u03b7 U)\n\n-- monad morphism in a different sense:\n-- monads are on the same category, X is the identity\nrecord Monad\u21d2-id (M N : Monad C) : Set (o \u2294 \u2113 \u2294 e) where\n\n  private\n    module M = Monad M\n    module N = Monad N\n\n  field\n    \u03b1 : NaturalTransformation N.F M.F\n\n  module \u03b1 = NaturalTransformation \u03b1\n\n  open module C = Category C using (_\u2218_; _\u2248_)\n\n  field\n    unit-comp : \u2200 {U} \u2192 \u03b1.\u03b7 U \u2218 N.\u03b7.\u03b7 U \u2248 M.\u03b7.\u03b7 U\n    mult-comp : \u2200 {U} \u2192 \u03b1.\u03b7 U \u2218 (N.\u03bc.\u03b7 U) \u2248 M.\u03bc.\u03b7 U \u2218 \u03b1.\u03b7 (M.F.\u2080 U) \u2218 N.F.\u2081 (\u03b1.\u03b7 U)\n\n-- monad 2-cell in the sense of https://ncatlab.org/nlab/show/monad#the_bicategory_of_monads\nrecord Monad\u00b2\u21d2 {M : Monad C} {N : Monad D} (\u0393 \u0394 : Monad\u21d2 M N) : Set (o \u2294 \u2113 \u2294 e) where\n\n  private\n    module M = Monad M\n    module N = Monad N\n    module \u0393 = Monad\u21d2 \u0393\n    module \u0394 = Monad\u21d2 \u0394\n\n  field\n    m : NaturalTransformation \u0393.X \u0394.X\n\n  module m = NaturalTransformation m\n\n  open module D = Category D using (_\u2218_; _\u2248_)\n\n  field\n    comm : \u2200 {U} \u2192 \u0394.\u03b1.\u03b7 U \u2218 N.F.\u2081 (m.\u03b7 U) \u2248 m.\u03b7 (M.F.\u2080 U) \u2218 \u0393.\u03b1.\u03b7 U", "meta": {"hexsha": "72bb06a9c6d30a0383dcfa8636db2d4717238724", "size": 1908, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Monad/Morphism.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_issues_repo_path": "src/Categories/Monad/Morphism.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Monad/Morphism.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.5, "max_line_length": 95, "alphanum_fraction": 0.6137316562, "num_tokens": 727, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768572945969, "lm_q2_score": 0.8418256412990657, "lm_q1q2_score": 0.7948322883917605}}
{"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some examples showing where the natural numbers and some related\n-- operations and properties are defined, and how they can be used\n------------------------------------------------------------------------\n\nmodule README.Nat where\n\n-- The natural numbers and various arithmetic operations are defined\n-- in Data.Nat.\n\nopen import Data.Nat\n\nex\u2081 : \u2115\nex\u2081 = 1 + 3\n\n-- Propositional equality and some related properties can be found\n-- in Relation.Binary.PropositionalEquality.\n\nopen import Relation.Binary.PropositionalEquality\n\nex\u2082 : 3 + 5 \u2261 2 * 4\nex\u2082 = refl\n\n-- Data.Nat.Properties contains a number of properties about natural\n-- numbers. Algebra defines what a commutative semiring is, among\n-- other things.\n\nopen import Algebra\nimport Data.Nat.Properties as Nat\nprivate\n  module CS = CommutativeSemiring Nat.commutativeSemiring\n\nex\u2083 : \u2200 m n \u2192 m * n \u2261 n * m\nex\u2083 m n = CS.*-comm m n\n\n-- The module \u2261-Reasoning in Relation.Binary.PropositionalEquality\n-- provides some combinators for equational reasoning.\n\nopen \u2261-Reasoning\nopen import Data.Product\n\nex\u2084 : \u2200 m n \u2192 m * (n + 0) \u2261 n * m\nex\u2084 m n = begin\n  m * (n + 0)  \u2261\u27e8 cong (_*_ m) (proj\u2082 CS.+-identity n) \u27e9\n  m * n        \u2261\u27e8 CS.*-comm m n \u27e9\n  n * m        \u220e\n\n-- The module SemiringSolver in Data.Nat.Properties contains a solver\n-- for natural number equalities involving variables, constants, _+_\n-- and _*_.\n\nopen Nat.SemiringSolver\n\nex\u2085 : \u2200 m n \u2192 m * (n + 0) \u2261 n * m\nex\u2085 = solve 2 (\u03bb m n \u2192 m :* (n :+ con 0)  :=  n :* m) refl\n", "meta": {"hexsha": "4a2e9785b8f0222171d8e00c5fdcaad00dfbf05a", "size": 1586, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/README/Nat.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/README/Nat.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/README/Nat.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3448275862, "max_line_length": 72, "alphanum_fraction": 0.6292559899, "num_tokens": 446, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9489172615983308, "lm_q2_score": 0.8376199552262967, "lm_q1q2_score": 0.7948320341734539}}
{"text": "module x02induction where\n\n-- prove properties of inductive naturals and operations on them via induction\n\nimport      Relation.Binary.PropositionalEquality as Eq\nopen        Eq             using (_\u2261_; refl; cong; sym)\nopen        Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; step-\u2261; _\u220e)\nopen import Data.Nat       using (\u2115; zero; suc; _+_; _*_; _\u2238_; _^_)\n\n{-\n------------------------------------------------------------------------------\n## Properties of operators : identity, associativity, commutativity, distributivity\n\n* _Identity_.   left/right/both; sometimes called _unit_\n\n* _Associativity_.   e.g., `(m + n) + p \u2261 m + (n + p)`\n\n* _Commutativity_.   e.g., `m + n \u2261 n + m`\n\n* _Distributivity_.  e.g., from the left  `(m + n) * p \u2261 (m * p) + (n * p)`\n                           from the right `m * (p + q) \u2261 (m * p) + (m * q)`\n\n#### Exercise `operators` (practice) {name=operators} TODO : ops with different properties - no proofs\n\npair of operators\n- have an identity\n- are associative, commutative, and distribute over one another\n(do not prove)\n\noperator\n- has identity\n- is associative\n- not commutative\n(do not prove)\n-}\n\n{-\nHC not associative; right identity\n-}\n_ =\n  begin\n    (3 \u2238 1) \u2238 1 \u2238 0 \u2261\u27e8\u27e9\n     2      \u2238 1 \u2238 0 \u2261\u27e8\u27e9\n     1          \u2238 0 \u2261\u27e8\u27e9\n     1          \u2238 0\n  \u220e\n{-\n------------------------------------------------------------------------------\n## ASSOCIATIVITY of ADDITION : (m + n) + p \u2261 m + (n + p)\n-}\n\n_ : (3 + 4) + 5 \u2261 3 + (4 + 5)\n_ =\n  begin\n    (3 +  4) + 5  \u2261\u27e8\u27e9\n     7       + 5  \u2261\u27e8\u27e9\n    12            \u2261\u27e8\u27e9\n     3 +  9       \u2261\u27e8\u27e9\n     3 + (4  + 5)\n  \u220e\n\n{-\nuseful to read chains like above\n- from top down  until reaching simplest term (i.e., `12`)\n- from bottom up until reaching the same term\n\nWhy should `7 + 5` be the same as `3 + 9`?\nPerhaps gather more evidence, testing the proposition by choosing other numbers.\nBut infinite naturals so testing can never be complete.\n\n## PROOF BY INDUCTION\n\nnatural definition has\n- base case\n- inductive case\n\ninductive proof follows structure of definition: prove two cases\n- _base case_ : show property holds for `zero`\n- _inductive case_ :\n  - assume property holds for an arbitrary natural `m` (the _inductive hypothesis_)\n  - then show that the property holds for `suc m`\n\n    ------\n    P  zero\n\n    P      m\n    ---------\n    P (suc m)\n\n- initially, no properties are known.\n- base case : `P zero` holds : add it to set of known properties\n    -- On the first day, one property is known.\n    P zero\n- inductive case tells us that if `P m` holds\n    -- On the second day, two properties are known.\n    P zero\n    P (suc zero)\n  then `P (suc m)` also holds\n\n    -- On the third day, three properties are known.\n    P zero\n    P (suc zero)\n    P (suc (suc zero))\n\n    -- On the fourth day, four properties are known.\n    P zero\n    P (suc zero)\n    P (suc (suc zero))\n    P (suc (suc (suc zero)))\n\nthe process continues: property `P n` first appears on day _n+1_\n\n------------------------------------------------------------------------------\n## PROVE ASSOCIATIVITY of ADDITION\n\ntake `P m` to be the property:\n\n    (m + n) + p \u2261 m + (n + p)\n\n`n` and `p` are arbitrary natural numbers\n\nshow the equation holds for all `m` it will also hold for all `n` and `p`\n\n\n    -------------------------------\n     (zero + n) + p \u2261  zero + (n + p)\n\n\n        (m + n) + p \u2261     m + (n + p)\n    ---------------------------------\n    (suc m + n) + p \u2261 suc m + (n + p)\n\ndemonstrate both of above, then associativity of addition follows by induction\n-}\n\n-- signature says providing evidence for proposition\n+-assoc : \u2200 (m n p : \u2115)\n        \u2192 (m +  n) + p\n        \u2261  m + (n  + p)\n\n-- Evidence is a function that\n-- - takes three natural numbers, binds them to `m`, `n`, and `p`\n-- - returns evidence for the corresponding instance of the equation\n\n-- base case : show: (zero +  n) + p\n--                  \u2261 zero + (n  + p)\n+-assoc zero n p =\n  begin\n  (zero +  n) + p \u2261\u27e8\u27e9 -- _+_ base case\n           n  + p \u2261\u27e8\u27e9\n   zero + (n  + p)\n  \u220e\n\n-- inductive case : show: (suc m +  n) + p\n--                       \u2261 suc m + (n  + p)\n+-assoc (suc m) n p =\n  begin\n  (suc   m +  n) + p   \u2261\u27e8\u27e9 -- _+_ inductive case (left to right)\n   suc  (m +  n) + p   \u2261\u27e8\u27e9\n   suc ((m +  n) + p)  \u2261\u27e8 cong suc (+-assoc m n p) \u27e9\n                           -- simplifying both sides : suc ((m + n) + p) \u2261 suc (m + (n + p))\n                           -- follows by prefacing `suc` to both sides of the induction hypothesis:\n                           --                               (m + n) + p  \u2261      m + (n + p)\n   suc  (m + (n  + p)) \u2261\u27e8\u27e9 -- _+_ inductive case (right to left)\n   suc   m + (n  + p)\n  \u220e\n\n-- HC minimal version\n\n+-assoc' : \u2200 (m n p : \u2115)\n        \u2192 (m +  n) + p\n        \u2261  m + (n  + p)\n+-assoc'   zero  n p = refl\n+-assoc' (suc m) n p = cong suc (+-assoc m n p)\n\n{-\nidentifiers can have any characters NOT including spaces or the characters @.(){};_\n\nthe \"middle\" equation, does not follow from applying _+_ (i.e., \"simplification\") alone\n- `_\u2261\u27e8_\u27e9_` : called \"chain reasoning\"\n- justification for equation given in angle brackets:\n  - empty means \"simplification\", or\n  - something more, e.g.,:\n\n    \u27e8 cong suc (+-assoc m n p) \u27e9\n\nrecursive invocation `+-assoc m n p`\n- has type of the induction hypothesis\n- `cong suc` prefaces `suc` to each side of inductive hypothesis\n\nA relation is a CONGRUENCE for a given function\nif the relation is preserved by applying the function.\n\nif `e` is evidence that `x \u2261 y`, then `cong f e` is evidence `f x \u2261 f y`, for any `f`\n\nhere the inductive hypothesis is not assumed\n\ninstead, proved by recursive invocation of the function being defined, `+-assoc m n p`\n\nWELL FOUNDED : associativity of larger numbers is proved in of associativity of smaller numbers.\n\ne.g., `assoc (suc m) n p` is proved using `assoc m n p`.\n\n------------------------------------------------------------------------------\n## Induction as recursion\n\nConcrete example of how induction corresponds to recursion : instantiate `m` to `2`\n-}\n\n+-assoc-2 : \u2200 (n p : \u2115)\n          \u2192 (2 +  n) + p\n          \u2261  2 + (n  + p)\n+-assoc-2 n p =\n  begin\n         (2 +  n) + p   \u2261\u27e8\u27e9\n    suc  (1 +  n) + p   \u2261\u27e8\u27e9\n    suc ((1 +  n) + p)  \u2261\u27e8 cong suc (+-assoc-1 n p) \u27e9\n    suc  (1 + (n  + p)) \u2261\u27e8\u27e9\n          2 + (n  + p)\n  \u220e\n where\n  +-assoc-1 : \u2200 (n p : \u2115) \u2192 (1 + n) + p \u2261 1 + (n + p)\n  +-assoc-1 n p =\n    begin\n           (1 +  n) + p   \u2261\u27e8\u27e9\n      suc  (0 +  n) + p   \u2261\u27e8\u27e9\n      suc ((0 +  n) + p)  \u2261\u27e8 cong suc (+-assoc-0 n p) \u27e9\n      suc  (0 + (n  + p)) \u2261\u27e8\u27e9\n            1 + (n  + p)\n    \u220e\n   where\n    +-assoc-0 : \u2200 (n p : \u2115) \u2192 (0 + n) + p \u2261 0 + (n + p)\n    +-assoc-0 n p =\n      begin\n        (0 + n) + p  \u2261\u27e8\u27e9\n             n  + p  \u2261\u27e8\u27e9\n        0 + (n  + p)\n      \u220e\n{-\n------------------------------------------------------------------------------\n## Terminology and notation\n\nEvidence for a universal quantifier is a function.  The notations\n\n    +-assoc : \u2200 (m n p : \u2115)\n            \u2192 (m +  n) + p\n            \u2261  m + (n  + p)\n\nand\n\n    +-assoc : \u2200 (m : \u2115)\n            \u2192 \u2200 (n : \u2115)\n            \u2192 \u2200 (p : \u2115)\n            \u2192 (m +  n) + p\n            \u2261  m + (n  + p)\n\nare equivalent.\n\ndiffer from function type such as `\u2115 \u2192 \u2115 \u2192 \u2115`\n- variables are associated with each argument type\n- the result type may mention (or depend upon) these variables\n- hence called _DEPENDENT functions_\n\n------------------------------------------------------------------------------\n## COMMUTATIVITY of ADDITION : m + n \u2261 n + m\n\ntwo lemmas used in proof\n\n### first lemma\n\nThe base case of the definition of addition states that zero is a left-identity:\n\n    zero + n \u2261 n\n\nFirst lemma states that zero is also a right-identity:\n-}\n\n-- proof by induction on `m`\n+-identity\u02b3 : \u2200 (m : \u2115)\n            \u2192 m + zero\n            \u2261 m\n\n-- base case : show:\n--    zero + zero\n--  \u2261 zero\n+-identity\u02b3 zero =\n  begin\n    zero + zero \u2261\u27e8\u27e9 -- _+_ base\n    zero\n  \u220e\n\n-- inductive case : show:\n--     (suc m) + zero\n--    = suc m\n+-identity\u02b3 (suc m) =\n  begin\n    suc  m + zero  \u2261\u27e8\u27e9 -- _+_ inductive\n    suc (m + zero) \u2261\u27e8 cong suc (+-identity\u02b3 m) \u27e9\n                       -- recursive invocation `+-identity\u02b3 m`\n                       -- has type of induction hypothesis\n                       --      m + zero  \u2261     m\n                       -- `cong suc` prefaces `suc` to each side of that type, yielding\n                       -- suc (m + zero) \u2261 suc m\n    suc  m\n  \u220e\n{-\n### second lemma\n\ninductive case of _+_ pushes `suc` on 1st arg to the outside:\n\n    suc m + n \u2261 suc (m + n)\n\nsecond lemma does same for `suc` on 2nd arg:\n\n    m + suc n \u2261 suc (m + n)\n-}\n\n-- signature states defining `+-suc` which provides evidence for the proposition/type\n+-suc : \u2200 (m n : \u2115)\n      \u2192      m + suc n\n      \u2261 suc (m +     n)\n\n-- evidence is fun that takes two nats, binds to `m` and `n`\n-- returns evidence for the corresponding instance of the equation\n-- proof is by induction on `m`\n\n-- base case\n+-suc zero n =\n  begin\n         zero + suc n  \u2261\u27e8\u27e9 -- _+_ base\n                suc n  \u2261\u27e8\u27e9 -- _+_ base\n    suc (zero +     n)\n  \u220e\n-- inductive case : show:      suc m + suc n\n--                      \u2261 suc (suc m +     n)\n+-suc (suc m) n =\n  begin\n    suc       m + suc n   \u2261\u27e8\u27e9                       -- _+_ inductive\n    suc      (m + suc n)  \u2261\u27e8 cong suc (+-suc m n) \u27e9 -- induction\n    suc (suc (m +     n)) \u2261\u27e8\u27e9                       -- _+_ inductive\n    suc (suc  m +     n)\n  \u220e\n\n-------------------------\n\n+-comm : \u2200 (m n : \u2115)\n       \u2192 m + n\n       \u2261 n + m\n+-comm m zero =\n  begin\n           m + zero \u2261\u27e8 +-identity\u02b3 m \u27e9\n           m        \u2261\u27e8\u27e9\n    zero + m\n  \u220e\n+-comm m (suc n) =\n  begin\n         m + suc n  \u2261\u27e8 +-suc m n \u27e9\n    suc (m +     n) \u2261\u27e8 cong suc (+-comm m n) \u27e9 -- congruence and induction hypothesis\n    suc (n +     m) \u2261\u27e8\u27e9                        -- _+_ inductive\n    suc  n +     m\n  \u220e\n\n{-\ndefinition required BEFORE using them\n\n------------------------------------------------------------------------------\n## COROLLARY: REARRANGING : apply associativity to rearrange parentheses (SYM; sections)\n-}\n\n+-rearrange : \u2200 (m n p q : \u2115)\n            \u2192 (m +  n) + (p  + q)\n            \u2261  m + (n  +  p) + q\n+-rearrange m n p q =\n  begin\n    (m +   n) + (p   + q)  \u2261\u27e8                   +-assoc m n   (p + q) \u27e9\n     m +  (n  + (p   + q)) \u2261\u27e8 cong (m +_) (sym (+-assoc n p        q)) \u27e9\n     m + ((n  +  p)  + q)  \u2261\u27e8              sym (+-assoc m (n + p)  q) \u27e9\n    (m +  (n  +  p)) + q   \u2261\u27e8\u27e9\n     m +  (n  +  p)  + q\n  \u220e\n\n{-\nno induction is required\n\nNOTE:\n\naddition is left associative : m + (n + p)  + q\n                            = (m + (n + p)) + q\n\nSYM : interchange sides of an equation, e.g.,\n- `+-assoc n p q` shifts parens right to left:\n\n    (n + p) + q \u2261 n + (p + q)\n\n`sym (+-assoc n p q)`: to shift them left-to-right\n\n    n + (p + q) \u2261 (n + p) + q\n\ngeneral\n- if `e` provides evidence for `x \u2261 y`\n- then `sym e` provides evidence for `y \u2261 x`\n\nSECTION NOTATION (introduced by Richard Bird) : `(x +_)`    `(_+ x)`\n\n------------------------------------------------------------------------------\n## Creation, one last time\n\nbase case : `(zero + n) + p \u2261 zero + (n + p)`\n\ninductive case :\n- if `(m + n) + p \u2261     m + (n + p)` then\n `(suc m + n) + p \u2261 suc m + (n + p)`\n\nusing base case, associativity of zero on left:\n    (0 + 0) + 0 \u2261 0 + (0 + 0)   ...   (0 + 4) + 5 \u2261 0 + (4 + 5)   ...\nusing inductive case\n    (1 + 0) + 0 \u2261 1 + (0 + 0)   ...   (1 + 4) + 5 \u2261 1 + (4 + 5)   ...\n    (2 + 0) + 0 \u2261 2 + (0 + 0)   ...   (2 + 4) + 5 \u2261 2 + (4 + 5)   ...\n    (3 + 0) + 0 \u2261 3 + (0 + 0)   ...   (3 + 4) + 5 \u2261 3 + (4 + 5)   ...\n    ...\n\nthere is a finite approach to generating the same equations (following exercise)\n\n------------------------------------------------------------------------------\n#### Exercise `finite-|-assoc` (stretch) {name=finite-plus-assoc} TODO - first four days of creation - description, not proof\n\nWrite out what is known about associativity of addition on each of the\nfirst four days using a finite story of creation, as\n[earlier](/Naturals/#finite-creation).\n\n------------------------------------------------------------------------------\n## proof of ASSOCIATIVITY using `rewrite` (rather than chains of equations)\n\navoids chains of equations and the need to invoke `cong`\n-}\n\n+-assoc\u2032 : \u2200 (m n p : \u2115)\n         \u2192 (m +  n) + p\n         \u2261  m + (n  + p)\n\n-- base\n-- show: (zero + n) + p \u2261 zero + (n + p)\n-- _+_ base applied \"invisibly\", then terms equal/refl\n+-assoc\u2032 zero    n p                         = refl\n\n-- inductive\n-- show: (suc m + n) + p \u2261 suc m + (n + p)\n-- _+_ inductive applied \"invisibly\" giving: suc ((m + n) + p) \u2261 suc (m + (n + p))\n-- rewrite with the inductive hypothesis\n-- then terms are equal/refl\n+-assoc\u2032 (suc m) n p  rewrite +-assoc\u2032 m n p = refl\n\n{-\nrewriting by a given equation\n- indicated by keyword `rewrite`\n- followed by a proof of that equation\n\n------------------------------------------------------------------------------\n## COMMUTATIVITY with rewrite\n-}\n\n+-suc\u2032 : \u2200 (m n : \u2115) \u2192 m + suc n \u2261 suc (m + n)\n+-suc\u2032 zero n = refl\n+-suc\u2032 (suc m) n rewrite +-suc\u2032 m n = refl\n\n+-comm\u2032 : \u2200 (m n : \u2115) \u2192 m + n \u2261 n + m\n+-comm\u2032 m zero rewrite +-identity\u02b3 m = refl\n-- rewriting with two equations indicated by separating the two proofs\n-- of the relevant equations by a vertical bar\n-- left rewrite performed before right\n+-comm\u2032 m (suc n)  -- m + suc n \u2261 suc  n + m\n                   -- m + suc n \u2261 suc (n + m) -- def/eq\n  rewrite\n    +-suc\u2032  m n    -- suc (m + n) \u2261 suc (n + m)\n  | +-comm\u2032 m n    -- suc (n + m) \u2261 suc (n + m)\n  = refl\n\n+-comm\u2032\u2032 : \u2200 (m n : \u2115) \u2192 m + n \u2261 n + m\n+-comm\u2032\u2032 m   zero rewrite +-identity\u02b3 m = refl\n+-comm\u2032\u2032 m (suc n) =\n  begin\n    m +  suc n  \u2261\u27e8 +-suc\u2032  m n \u27e9\n    suc (m + n) \u2261\u27e8 cong suc (+-comm\u2032\u2032 m n) \u27e9\n    suc (n + m) \u2261\u27e8\u27e9 -- def/eq\n    suc  n + m\n  \u220e\n\n{-\n------------------------------------------------------------------------------\nHC\n-}\n\n*0 : \u2200 (m : \u2115) \u2192 m * 0 \u2261 0\n*0 zero    = refl\n*0 (suc m) = *0 m\n\n0* : \u2200 (m : \u2115) \u2192 0 * m \u2261 0\n0* m = refl\n\n*1 : \u2200 (n : \u2115) \u2192 n * 1 \u2261 n\n*1 zero = refl\n*1 (suc n) rewrite *1 n = refl\n\n1* : \u2200 (n : \u2115) \u2192 1 * n \u2261 n\n1* zero = refl\n1* (suc n) rewrite 1* n = refl\n\n{-\n------------------------------------------------------------------------------\n## Building proofs interactively\n\n    +-assoc\u2032 : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\n    +-assoc\u2032 m n p = ?\n\nC-c C-l\n\n    +-assoc\u2032 : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\n    +-assoc\u2032 m n p = { }0\n\nnew window at the bottom:\n\n    ?0 : ((m + n) + p) \u2261 (m + (n + p))\n\nindicates hole 0 needs to be filled with a proof of the stated judgment\n\nto prove the proposition by induction on `m`\nmove cursor into hole\nC-c C-c\nprompt: pattern variables to case (empty for split on result):\n\ntype `m` to case split on that variable\n\n    +-assoc\u2032 : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\n    +-assoc\u2032 zero n p = { }0\n    +-assoc\u2032 (suc m) n p = { }1\n\nThere are now two holes, and the window at the bottom tells you what\neach is required to prove:\n\n    ?0 : ((zero + n) + p) \u2261 (zero + (n + p))\n    ?1 : ((suc m + n) + p) \u2261 (suc m + (n + p))\n\ngoto hole 0\nC-c C-,\n\n    Goal: (n + p) \u2261 (n + p)\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    p : \u2115\n    n : \u2115\n\nindicates that after simplification the goal for hole 0 is as stated,\n and that variables `p` and `n` of the stated types are available to use in the proof.\n\nthe proof of the given goal is simple\ngoto goal\nC-c C-r\nfills in with refl\nC-c C-l renumbers remaining hole to 0:\n\n    +-assoc\u2032 : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\n    +-assoc\u2032 zero n p = refl\n    +-assoc\u2032 (suc m) n p = { }0\n\ngoto hole 0\nC-c C-,\n\n    Goal: suc ((m + n) + p) \u2261 suc (m + (n + p))\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    p : \u2115\n    n : \u2115\n    m : \u2115\n\ngives simplified goal and available variables\n\nneed to rewrite by the induction hypothesis\n\n    +-assoc\u2032 : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\n    +-assoc\u2032 zero n p = refl\n    +-assoc\u2032 (suc m) n p rewrite +-assoc\u2032 m n p = { }0\n\ngoto hole\nC-c C-,\n\n    Goal: suc (m + (n + p)) \u2261 suc (m + (n + p))\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    p : \u2115\n    n : \u2115\n    m : \u2115\n\ngoto goal\nC-c C-r\nfills in, completing proof\n\n    +-assoc\u2032 : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\n    +-assoc\u2032 zero n p = refl\n    +-assoc\u2032 (suc m) n p rewrite +-assoc\u2032 m n p = refl\n\n------------------------------------------------------------------------------\n#### Exercise `+-swap` (recommended) {name=plus-swap}\n\nShow\n\n    m + (n + p) \u2261 n + (m + p)\n\nfor all naturals `m`, `n`, and `p`\n- no induction\n- use associativity and commutativity of addtion\n-}\n\n+-swap : \u2200 (m n p : \u2115)\n       \u2192 m + (n + p)\n       \u2261 n + (m + p)\n+-swap m n p =\n  begin\n     m + (n  + p) \u2261\u27e8 sym (+-assoc m n p) \u27e9\n    (m +  n) + p  \u2261\u27e8 cong (_+ p) (sym (+-comm n m)) \u27e9\n    (n +  m) + p  \u2261\u27e8 +-assoc n m p \u27e9\n     n + (m  + p)\n  \u220e\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `*-distrib-+` (recommended) {name=times-distrib-plus} (m + n) * p \u2261 m * p + n * p\n-}\n\n*-distrib-+r : \u2200 (m n p : \u2115)\n             \u2192 (m     + n) * p\n             \u2261  m * p + n  * p\n*-distrib-+r  zero   y z = refl\n*-distrib-+r (suc x) y z            -- (suc x     + y) * z  \u2261 suc x * z + y * z\n                                    -- z + (x     + y) * z  \u2261 z + x * z + y * z\n  rewrite\n    *-distrib-+r x y z              -- z + (x * z + y  * z) \u2261 z + x * z + y * z\n  | sym (+-assoc z (x * z) (y * z)) -- z +  x * z + y  * z  \u2261 z + x * z + y * z\n  = refl\n\n{- TODO: agda loops on this : *-distrib-+r done with chain reasoning\n*-distrib-+r' : \u2200 (m n p : \u2115)\n             \u2192 (m     + n) * p\n             \u2261  m * p + n  * p\n*-distrib-+r'  zero   y z = refl\n*-distrib-+r' (suc x) y z\n  begin\n    (suc x     + y) * z  \u2261\u27e8\u27e9\n    z + (x     + y) * z  \u2261\u27e8 *-distrib-+r' x y z \u27e9\n    z + (x * z + y  * z) \u2261\u27e8 sym (+-assoc z (x * z) (y * z)) \u27e9\n    z +  x * z + y  * z  \u2261\u27e8\u27e9\n     suc x * z + y  * z\n  \u220e\n-}\n{-\n------------------------------------------------------------------------------\n#### Exercise `*-assoc` (recommended) {name=times-assoc} (m * n) * p \u2261 m * (n * p)\n-}\n\n*-assoc : \u2200 (m n p : \u2115)\n        \u2192 (m *  n) * p\n        \u2261  m * (n  * p)\n-- base case : show: (zero *  n) * p\n--                  \u2261 zero * (n  * p)\n*-assoc zero n p = refl      -- zero * n * p        \u2261 zero * (n * p)\n                             -- zero                \u2261 zero -- def/eq\n-- inductive case : show: (suc m *  n) * p\n--                       \u2261 suc m * (n  * p)\n*-assoc (suc m) n p          --     suc m * n  * p  \u2261     suc m * (n * p)\n                             --    (n + m * n) * p  \u2261 n * p + m * (n * p)\n  rewrite\n    *-distrib-+r n (m * n) p -- n * p + m *  n * p  \u2261 n * p + m * (n * p)\n  | *-assoc m n p            -- n * p + m * (n * p) \u2261 n * p + m * (n * p)\n  = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `*-comm` (practice) {name=times-comm} MULTIPLICATION is COMMUTATIVE : m * n \u2261 n * m\n-}\n\n*-suc : \u2200 (x y : \u2115) \u2192 x * (suc y) \u2261 x + (x * y)\n*-suc zero y = refl\n*-suc (suc x) y               --       suc x * suc y  \u2261 suc  x +  suc  x * y\n                              -- suc (y  + x * suc y) \u2261 suc (x + (y +  x * y))\n  rewrite\n    +-comm y (x * suc y)      -- suc (x  * suc y + y) \u2261 suc (x + (y +  x * y))\n  | *-suc x y                 -- suc (x + x  * y + y) \u2261 suc (x + (y +  x * y))\n  | +-comm y (x * y)          -- suc (x + x  * y + y) \u2261 suc (x + (x *  y + y))\n  | sym (+-assoc x (x * y) y) -- suc (x + x  * y + y) \u2261 suc (x +  x *  y + y)\n  = refl\n\n*-comm : \u2200 (m n : \u2115) \u2192 m * n  \u2261 n * m\n*-comm m zero rewrite *0 m = refl\n*-comm m (suc n) -- m * suc n \u2261 suc n * m\n                 -- m * suc n \u2261 m + n * m\n  rewrite\n    *-suc m n    -- m + m * n \u2261 m + n * m\n  | *-comm m n   -- m + n * m \u2261 m + n * m\n  = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `0\u2238n\u22610` (practice) {name=zero-monus} : Show zero \u2238 n \u2261 zero\n\nfor all naturals `n`. Did your proof require induction?\n-}\n\n0\u2238n\u22610 : \u2200 (n : \u2115) \u2192 0 \u2238 n \u2261 0\n0\u2238n\u22610  zero   = refl\n0\u2238n\u22610 (suc n) = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `\u2238-|-assoc` (practice) {name=monus-plus-assoc} : m \u2238 n \u2238 p \u2261 m \u2238 (n + p)\n\nshow that monus associates with addition\n-}\n\n\u2238-|-assoc : \u2200 (m n p : \u2115) \u2192 m \u2238 n \u2238 p \u2261 m \u2238 (n + p)\n\u2238-|-assoc      m       n   zero   --     m \u2238     n \u2238 zero   \u2261     m \u2238     (n + zero)\n                                  --     m \u2238     n          \u2261     m \u2238     (n + zero)\n  rewrite +-identity\u02b3 n = refl    --     m \u2238     n          \u2261     m \u2238      n\n\u2238-|-assoc      m   zero   (suc p) --     m \u2238  zero \u2238 suc p  \u2261     m \u2238  (zero + suc p)\n  = refl                          --     m \u2238         suc p  \u2261     m \u2238          suc p\n\u2238-|-assoc  zero   (suc n) (suc p) --  zero \u2238 suc n \u2238 suc p  \u2261  zero \u2238 (suc n + suc p)\n  = refl                          --  zero                  \u2261  zero\n\u2238-|-assoc (suc m) (suc n) (suc p) -- suc m \u2238 suc n \u2238 suc p  \u2261 suc m \u2238 (suc n + suc p)\n                                  --     m \u2238     n \u2238 suc p  \u2261     m \u2238     (n + suc p)\n  rewrite\n    \u2238-|-assoc m n (suc p)         --     m \u2238    (n + suc p) \u2261     m \u2238     (n + suc p)\n  = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `+*^` (stretch)\n\n     m ^ (n  + p) \u2261 (m ^  n) * (m ^ p)  (^-distrib\u02e1-|-*)\n     (m * n) ^ p  \u2261 (m ^  p) * (n ^ p)  (^-distrib\u02b3-*)\n     (m ^ n) ^ p  \u2261  m ^ (n  *  p)      (^-*-assoc)\n-}\n\n-------------------------\n-- this can be shortened\n^-distrib\u02e1-|-* : \u2200 (m n p : \u2115)\n               \u2192  m ^ (n  +      p)\n               \u2261 (m ^  n) * (m ^ p)\n^-distrib\u02e1-|-* m n zero              -- (m ^ (n + zero))        \u2261 (m ^ n) * (m ^ zero)\n                                     -- (m ^ (n + zero))        \u2261 (m ^ n) * 1\n  rewrite\n    +-identity\u02b3 n                    -- (m ^  n)                \u2261 (m ^ n) * 1\n  | *1 (m ^ n)                       -- (m ^  n)                \u2261 (m ^ n)\n  = refl\n^-distrib\u02e1-|-* m n (suc p)           -- (m ^ (n + suc p))       \u2261 (m ^ n) *      (m ^ suc p)\n                                     -- (m ^ (n + suc p))       \u2261 (m ^ n) * (m * (m ^     p))\n  rewrite\n    *-comm m (m ^ p)                 -- (m ^ (n + suc p))       \u2261 (m ^ n) *     ((m ^     p) * m)\n  | sym (*-assoc (m ^ n) (m ^ p) m)  -- (m ^ (n + suc p))       \u2261 (m ^ n) *      (m ^     p) * m\n  | +-comm n (suc p)                 -- (m ^ suc (p + n))       \u2261 (m ^ n) *      (m ^     p) * m\n                                     -- m * (m ^ (p + n))       \u2261 (m ^ n) *      (m ^     p) * m\n  | *-comm ((m ^ n) * (m ^     p)) m -- m * (m ^ (p + n))       \u2261  m * ((m ^ n) * (m ^ p))\n  | sym (*-assoc m (m ^ n) (m ^ p))  -- m * (m ^ (p + n))       \u2261  m *  (m ^ n) * (m ^ p)\n  | ^-distrib\u02e1-|-* m p n             -- m * ((m ^ p) * (m ^ n)) \u2261  m *  (m ^ n) * (m ^ p)\n  | sym (*-comm (m ^ n) (m ^ p))     -- m * ((m ^ n) * (m ^ p)) \u2261  m *  (m ^ n) * (m ^ p)\n  | *-assoc m (m ^ n) (m ^ p)        -- m * ((m ^ n) * (m ^ p)) \u2261  m * ((m ^ n) * (m ^ p))\n  = refl\n\n-------------------------\n^-distrib\u02b3-* : \u2200 (m n p : \u2115)\n             \u2192 (m * n) ^ p\n             \u2261 (m ^ p) * (n ^ p)\n^-distrib\u02b3-* m n zero = refl\n^-distrib\u02b3-* m n (suc p)            --      ((m * n) ^ suc p)      \u2261(m ^ suc p) * (n ^ suc p)\n                                    -- m * n * ((m      *  n) ^ p) \u2261 m * (m ^ p) * (n * (n ^ p))\n  rewrite\n    ^-distrib\u02b3-* m n p              -- m * n * ((m ^ p) * (n ^ p)) \u2261 m * (m ^ p) * (n * (n ^ p))\n  | *-comm (m * (m ^ p)) (n * (n ^ p))\n                                    -- m * n * ((m ^ p) * (n ^ p)) \u2261 n * (n ^ p) * (m * (m ^ p))\n  | *-assoc m n ((m ^ p) * (n ^ p)) -- m *(n * ((m ^ p) * (n ^ p)))\u2261 n * (n ^ p) * (m * (m ^ p))\n  | *-comm m (n * ((m ^ p) * (n ^ p)))\n                                    -- n *((m ^ p) * (n ^ p))* m  \u2261 n * (n ^ p) * (m * (m ^ p))\n  | *-comm (m ^ p) (n ^ p)          -- n *((n ^ p) * (m ^ p))* m  \u2261 n * (n ^ p) * (m * (m ^ p))\n  | sym (*-assoc n (n ^ p) (m ^ p)) -- n * (n ^ p) * (m ^ p) * m  \u2261 n * (n ^ p) * (m * (m ^ p))\n  | *-assoc n (n ^ p) (m * (m ^ p)) -- n * (n ^ p) * (m ^ p) * m  \u2261 n *((n ^ p) * (m * (m ^ p)))\n  | *-comm m (m ^ p)                -- n * (n ^ p) * (m ^ p) * m  \u2261 n *((n ^ p) * ((m ^ p) * m))\n  | *-assoc n (n ^ p) (m ^ p)       -- n *((n ^ p) * (m ^ p))* m  \u2261 n *((n ^ p) * ((m ^ p) * m))\n  | *-assoc n ((n ^ p) * (m ^ p)) m -- n *((n ^ p) * (m ^ p) * m) \u2261 n *((n ^ p) * ((m ^ p) * m))\n  | *-assoc (n ^ p) (m ^ p) m       -- n *((n ^ p) *((m ^ p) * m))\u2261 n *((n ^ p) * ((m ^ p) * m))\n  = refl\n\n-------------------------\n^-*-assoc : \u2200 (m n p : \u2115)\n          \u2192 (m ^  n) ^ p\n          \u2261  m ^ (n  * p)\n^-*-assoc m n  zero                 --        ((m ^ n) ^ zero) \u2261 (m ^ (n * zero))\n                                    --                      1  \u2261 (m ^ (n * zero))\n  rewrite *0 n                      --                      1  \u2261 (m ^ 0)\n                                    --                      1  \u2261 1\n  = refl\n^-*-assoc m n (suc p)               --       ((m ^ n) ^ suc p) \u2261 (m ^ (n * suc p))\n                                    -- (m ^ n) * ((m ^ n) ^ p) \u2261 (m ^ (n * suc p))\n  rewrite\n    *-suc n p                       -- (m ^ n) * ((m ^ n) ^ p) \u2261 (m ^ (n + n * p))\n  | ^-distrib\u02e1-|-* m n (n * p)      -- (m ^ n) * ((m ^ n) ^ p) \u2261 (m ^ n) * (m ^ (n * p))\n  | sym (^-*-assoc m n p)           -- (m ^ n) * ((m ^ n) ^ p) \u2261 (m ^ n) * ((m ^ n) ^ p)\n  = refl\n\n{-\n------------------------------------------------------------------------------\n#### Exercise `Bin-laws` (stretch) {name=Bin-laws}\n\nRecall that\nExercise [Bin](/Naturals/#Bin)\ndefines a datatype `Bin` of bitstrings representing natural numbers,\nand asks you to define functions\n-}\n\n-- begin duplicated from x01 (can't import because of \"duplicate\" pragma)\n\ndata Bin : Set where\n  \u27e8\u27e9 : Bin\n  _O : Bin \u2192 Bin\n  _I : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc  \u27e8\u27e9    = \u27e8\u27e9      I\ninc (b  O) =      b  I\ninc (b  I) = (inc b) O\n\n_ : inc (\u27e8\u27e9 I O I I) \u2261 \u27e8\u27e9 I I O O\n_ = refl\n\n-- end duplicated\n\ndbl : \u2115 \u2192 \u2115\ndbl   zero  = zero\ndbl (suc m) = suc (suc (dbl m))\n\nto : \u2115 \u2192 Bin\nto   zero  = \u27e8\u27e9 O\nto (suc m) = inc (to m)\n\n-- THIS IS THE CRITICAL STEP : defining in terms of 'dbl'\n-- Got hint from : https://cs.uwaterloo.ca/~plragde/842/\nfrom : Bin \u2192 \u2115\nfrom     \u27e8\u27e9 = 0\nfrom (b  O) =      dbl (from b)\nfrom (b  I) = suc (dbl (from b))\n\n_ : to 6 \u2261 \u27e8\u27e9 I I O\n_ = refl\n\n_ : from (\u27e8\u27e9 I I O) \u2261 6\n_ = refl\n\n{-\nConsider the following laws, where `n` ranges over naturals and `b`\nover bitstrings:\n\n    from (inc b) \u2261 suc (from b)\n    to (from b) \u2261 b\n    from (to n) \u2261 n\n\nFor each law: if it holds, prove; if not, give a counterexample.\n-}\n\n-------------------------\n-- fromInc\u2261sucFrom\n\n+1 : \u2200 (x : \u2115) \u2192 x + 1 \u2261 suc x\n+1 zero = refl\n+1 (suc n) rewrite +1 n = refl\n\nfromInc\u2261sucFrom : \u2200 (b : Bin)\n                \u2192 from (inc b) \u2261 suc (from b)\nfromInc\u2261sucFrom \u27e8\u27e9       --       from (inc \u27e8\u27e9)      \u2261 suc (from \u27e8\u27e9)\n                         --                        1 \u2261 1\n  = refl\nfromInc\u2261sucFrom (\u27e8\u27e9 I)   --       from (inc (\u27e8\u27e9 I))  \u2261 suc (from (\u27e8\u27e9 I))\n                         --                        2 \u2261 2\n  = refl\nfromInc\u2261sucFrom (b O)    --       from (inc (b O))   \u2261 suc (from (b O))\n                         --       dbl (from b) + 1   \u2261 suc (dbl (from b))\n  rewrite\n    +1 (dbl (from b))    --       suc (dbl (from b)) \u2261 suc (dbl (from b))\n  = refl\nfromInc\u2261sucFrom (b I)    --       from (inc (b I))   \u2261 suc (from (b I))\n                         --       dbl (from (inc b)) \u2261 suc (dbl (from b) + 1)\n  rewrite\n    +1 (dbl (from b))    --       dbl (from (inc b)) \u2261 suc (suc (dbl (from b)))\n  | fromInc\u2261sucFrom b    --       dbl (suc (from b)) \u2261 suc (suc (dbl (from b)))\n                         -- suc (suc (dbl (from b))) \u2261 suc (suc (dbl (from b)))\n  = refl\n\n-------------------------\n-- to-from\u2261b -- cannot be proved because there are TWO representations of ZERO\n\n-- NOT USED\nxx : \u2200 (b : Bin)\n   \u2192 (dbl (from b)) \u2261 from (b O)\nxx \u27e8\u27e9        -- dbl (from \u27e8\u27e9) \u2261 from (\u27e8\u27e9 O)\n             -- zero \u2261 zero\n  = refl\nxx (b O)     -- dbl (from (b O)) \u2261 from ((b O) O)\n             -- dbl (dbl (from b)) \u2261 dbl (dbl (from b))\n  = refl\nxx (b I)     -- dbl (from (b I)) \u2261 from ((b I) O)\n             -- suc (suc (dbl (dbl (from b)))) \u2261 suc (suc (dbl (dbl (from b))))\n  = refl\n\n-- CANNOT BE PROVED BECAUSE TWO REPRESENTATIONS OF ZERO : (\u27e8\u27e9) and (\u27e8\u27e9 O)\nyy : \u2200 (b : Bin)\n   \u2192 to (dbl (from b)) \u2261 (b O)\nyy \u27e8\u27e9        --                  to (dbl (from \u27e8\u27e9)) \u2261 (\u27e8\u27e9 O)\n             --                              (\u27e8\u27e9 O) \u2261 (\u27e8\u27e9 O)\n  = refl\nyy (b O)     --           to (dbl (from (b O)))     \u2261 ((b O) O)\n             --           to (dbl (dbl (from b)))   \u2261 ((b O) O)\n  rewrite\n    yy b\n  = {!!}\nyy (b I)     --           to (dbl (from (b I)))     \u2261 ((b I) O)\n             -- inc (inc (to (dbl (dbl (from b))))) \u2261 ((b I) O)\n  = {!!}\n\nto-from : \u2200 (b : Bin)\n       \u2192 to (from b) \u2261 b\nto-from \u27e8\u27e9       --       to (from \u27e8\u27e9)      \u2261 \u27e8\u27e9\n                 --               (\u27e8\u27e9 O)    \u2261 \u27e8\u27e9 -- *****\n  = {!!}\nto-from (\u27e8\u27e9 I)   --       to (from (\u27e8\u27e9 I))  \u2261 (\u27e8\u27e9 I)\n                 --       (\u27e8\u27e9 I)            \u2261 (\u27e8\u27e9 I)\n  = refl\nto-from (b O)    --       to (from (b O))   \u2261 (b O)\n                 --       to (dbl (from b)) \u2261 (b O)\n  rewrite\n    yy b         --                   (b O) \u2261 (b O)\n  = refl\nto-from (b I)    --         to (from (b I)) \u2261 (b I)\n                 -- inc (to (dbl (from b))) \u2261 (b I)\n  rewrite\n    yy b         --                   (b I) \u2261 (b I)\n  = refl\n\n-------------------------\n\n-- https://github.com/billyang98/plfa/blob/master/plfa/Induction.agda\n\nfrom-inc\u2261suc-from : \u2200 x \u2192 from (inc x) \u2261 suc (from x)\nfrom-inc\u2261suc-from \u27e8\u27e9    = refl\nfrom-inc\u2261suc-from (x O) = refl\nfrom-inc\u2261suc-from (x I)  --         from (inc (x I)) \u2261 suc           (from (x I))\n                         --    dbl (from (inc  x))   \u2261 suc (suc (dbl (from  x)))\n  rewrite\n    from-inc\u2261suc-from x  -- suc (suc (dbl (from x))) \u2261 suc (suc (dbl (from x)))\n  = refl\n\nfrom-to : \u2200 n \u2192 from (to n) \u2261 n\nfrom-to zero = refl\nfrom-to (suc n)              -- from (to (suc n)) \u2261 suc n\n                             -- from (inc (to n)) \u2261 suc n\n  rewrite\n    from-inc\u2261suc-from (to n) -- suc (from (to n)) \u2261 suc n\n  | cong suc (from-to n)     -- suc           n   \u2261 suc n\n  = refl\n\n{-\n------------------------------------------------------------------------------\n## Standard library\n\nDefinitions similar to those in this chapter can be found in the standard library:\n```\nimport Data.Nat.Properties using (+-assoc; +-identity\u02b3; +-suc; +-comm)\n```\n\n------------------------------------------------------------------------------\n## Unicode\n\nThis chapter uses the following unicode:\n\n    \u2200  U+2200  FOR ALL (\\forall, \\all)\n    \u02b3  U+02B3  MODIFIER LETTER SMALL R (\\^r)\n    \u2032  U+2032  PRIME (\\')\n    \u2033  U+2033  DOUBLE PRIME (\\')\n    \u2034  U+2034  TRIPLE PRIME (\\')\n    \u2057  U+2057  QUADRUPLE PRIME (\\')\n\nSimilar to `\\r`, the command `\\^r` gives access to a variety of\nsuperscript rightward arrows, and also a superscript letter `r`.\nThe command `\\'` gives access to a range of primes (`\u2032 \u2033 \u2034 \u2057`).\n-}\n\n-- ============================================================================\n\n-- this is here to ensure the Bin/in/from/to does not get broken if changed above\n\n_ : inc (\u27e8\u27e9 I O I I) \u2261 \u27e8\u27e9 I I O O\n_ = refl\n\n_ : inc (\u27e8\u27e9     O) \u2261 \u27e8\u27e9     I\n_ = refl\n_ : inc (\u27e8\u27e9     I) \u2261 \u27e8\u27e9   I O\n_ = refl\n_ : inc (\u27e8\u27e9   I O) \u2261 \u27e8\u27e9   I I\n_ = refl\n_ : inc (\u27e8\u27e9   I I) \u2261 \u27e8\u27e9 I O O\n_ = refl\n_ : inc (\u27e8\u27e9 I O O) \u2261 \u27e8\u27e9 I O I\n_ = refl\n\n_ : from (\u27e8\u27e9     O) \u2261 0\n_ = refl\n_ : from (\u27e8\u27e9     I) \u2261 1\n_ = refl\n_ : from (\u27e8\u27e9   I O) \u2261 2\n_ = refl\n_ : from (\u27e8\u27e9   I I) \u2261 3\n_ = refl\n_ : from (\u27e8\u27e9 I O O) \u2261 4\n_ = refl\n\n_ : to 0 \u2261 (\u27e8\u27e9     O)\n_ = refl\n_ : to 1 \u2261 (\u27e8\u27e9     I)\n_ = refl\n_ : to 2 \u2261 (\u27e8\u27e9   I O)\n_ = refl\n_ : to 3 \u2261 (\u27e8\u27e9   I I)\n_ = refl\n_ : to 4 \u2261 (\u27e8\u27e9 I O O)\n_ = refl\n\n_ : from (to 12) \u2261 12\n_ = refl\n\n_ : to (from (\u27e8\u27e9 I I O O)) \u2261 \u27e8\u27e9 I I O O\n_ = refl\n", "meta": {"hexsha": "41e8c42d615dfce97b5718c02f9d84dd18c20261", "size": 31652, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02induction.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02induction.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02induction.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 30.6408518877, "max_line_length": 125, "alphanum_fraction": 0.4053140402, "num_tokens": 11345, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9073122288794594, "lm_q2_score": 0.8757869803008764, "lm_q1q2_score": 0.7946122371203994}}
{"text": "module InequalityReasoningExercise where\n\nopen import EqualityAux\n\ninfix 4 _\u2264_\n\ndata _\u2264_ : \u2115 \u2192 \u2115 \u2192 Set where\n\n  z\u2264n : \u2200 {n : \u2115}\n      --------\n    \u2192 zero \u2264 n\n\n  s\u2264s : \u2200 {m n : \u2115}\n    \u2192 m \u2264 n\n      -------------\n    \u2192 suc m \u2264 suc n\n\n\u2264-refl : \u2200 {n : \u2115}\n    -----\n  \u2192 n \u2264 n\n\u2264-refl {zero}  = z\u2264n\n\u2264-refl {suc n} = s\u2264s \u2264-refl\n\n\u2264-trans : \u2200 {m n p : \u2115}\n  \u2192 m \u2264 n\n  \u2192 n \u2264 p\n    -----\n  \u2192 m \u2264 p\n\u2264-trans z\u2264n       _         = z\u2264n\n\u2264-trans (s\u2264s m\u2264n) (s\u2264s n\u2264p) = s\u2264s (\u2264-trans m\u2264n n\u2264p)\n\nmodule \u2264-Reasoning where\n\n  infix  1 \u2264-begin_\n  infixr 2 _\u2264\u27e8\u27e9_ _\u2264\u27e8_\u27e9_ _\u2264-\u2261\u27e8_\u27e9_\n  infix  3 _\u2264-\u220e\n\n  \u2264-begin_ : \u2200 {x y : \u2115}\n    \u2192 x \u2264 y\n      -----\n    \u2192 x \u2264 y\n  \u2264-begin x\u2264y = x\u2264y\n\n  _\u2264\u27e8\u27e9_ : \u2200 (x : \u2115) {y : \u2115}\n    \u2192 x \u2264 y\n      -----\n    \u2192 x \u2264 y\n  x \u2264\u27e8\u27e9 x\u2264y = x\u2264y\n\n  _\u2264\u27e8_\u27e9_ : \u2200 (x : \u2115) {y z : \u2115}\n    \u2192 x \u2264 y\n    \u2192 y \u2264 z\n      -----\n    \u2192 x \u2264 z\n  x \u2264\u27e8 x\u2264y \u27e9 y\u2264z = \u2264-trans x\u2264y y\u2264z\n\n  _\u2264-\u2261\u27e8_\u27e9_ : \u2200 (x : \u2115) {y z : \u2115}\n    \u2192 x \u2261 y\n    \u2192 y \u2264 z\n      -----\n    \u2192 x \u2264 z\n  x \u2264-\u2261\u27e8 refl \u27e9 y\u2264z = \u2264-trans \u2264-refl y\u2264z\n\n  _\u2264-\u220e : \u2200 (x : \u2115)\n      -----\n    \u2192 x \u2264 x\n  x \u2264-\u220e = \u2264-refl\n\nopen \u2264-Reasoning\n\n+-mono\u02b3-\u2264 : \u2200 (n p q : \u2115)\n  \u2192 p \u2264 q\n    -------------\n  \u2192 n + p \u2264 n + q\n+-mono\u02b3-\u2264 zero p q p\u2264q =\n  \u2264-begin\n    zero + p\n  \u2264\u27e8\u27e9\n    p\n  \u2264\u27e8 p\u2264q \u27e9\n    q\n  \u2264\u27e8\u27e9\n    zero + q\n  \u2264-\u220e\n\n+-mono\u02b3-\u2264 (suc n) p q p\u2264q =\n  \u2264-begin\n    (suc n) + p\n  \u2264\u27e8\u27e9\n    suc (n + p)\n  \u2264\u27e8 s\u2264s (+-mono\u02b3-\u2264 n p q p\u2264q) \u27e9\n    suc (n + q)\n  \u2264\u27e8\u27e9\n    (suc n) + q\n  \u2264-\u220e\n\n+-mono\u02e1-\u2264 : \u2200 (m n p : \u2115)\n  \u2192 m \u2264 n\n    -------------\n  \u2192 m + p \u2264 n + p\n+-mono\u02e1-\u2264 m n p m\u2264n =\n  \u2264-begin\n    m + p\n  \u2264-\u2261\u27e8 +-comm m p \u27e9\n    p + m\n  \u2264\u27e8 +-mono\u02b3-\u2264 p m n m\u2264n \u27e9\n    p + n\n  \u2264-\u2261\u27e8 +-comm p n \u27e9\n    n + p\n  \u2264-\u220e\n\n+-mono-\u2264 : \u2200 (m n p q : \u2115)\n  \u2192 m \u2264 n\n  \u2192 p \u2264 q\n    -------------\n  \u2192 m + p \u2264 n + q\n+-mono-\u2264 m n p q m\u2264n p\u2264q =\n  \u2264-begin\n    m + p\n  \u2264\u27e8 +-mono\u02e1-\u2264 m n p m\u2264n \u27e9\n    n + p\n  \u2264\u27e8 +-mono\u02b3-\u2264 n p q p\u2264q \u27e9\n    n + q\n  \u2264-\u220e\n\n\n", "meta": {"hexsha": "f11e62291cbeb2f22c0272e648fa915f263de5c6", "size": 1809, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_stars_repo_name": "abolotina/plfa.github.io", "max_stars_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_issues_repo_name": "abolotina/plfa.github.io", "max_issues_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_forks_repo_name": "abolotina/plfa.github.io", "max_forks_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.2440944882, "max_line_length": 51, "alphanum_fraction": 0.320066335, "num_tokens": 1023, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248157222395, "lm_q2_score": 0.8459424373085146, "lm_q1q2_score": 0.79436094130525}}
{"text": "-- A DSL example in the language Agda: \"polynomial types\"\nmodule TypeDSL where\nopen import Data.Nat using (\u2115;_+_;_*_)\n\ndata E : Set where\n  Zero  : E\n  One   : E\n  Add   : (x : E) -> (y : E) -> E\n  Mul   : (x : E) -> (y : E) -> E\n\ntwo : E\ntwo = Add One One\n\nfour : E\nfour = Mul two two\n\n-- First semantics: compute the natural number \"value\" of the expression\ncard : E -> \u2115\ncard Zero = 0\ncard One = 1\ncard (Add x y) = card x + card y\ncard (Mul x y) = card x * card y\n\ndata Empty : Set where\ndata Unit : Set where unit : Unit\ndata Either (a : Set) (b : Set) : Set where\n  Left  : a -> Either a b\n  Right : b -> Either a b\ndata Both (a : Set) (b : Set) : Set where\n  _,_ : a -> b -> Both a b\n\n-- Second semantics: compute the corresponding finite type\ntyp : E -> Set\ntyp Zero = Empty\ntyp One = Unit\ntyp (Add x y) = Either (typ x) (typ y)   -- disjoint union type    = sum type\ntyp (Mul x y) = Both   (typ x) (typ y)   -- cartesian product type = pair type\n\nBool : Set\nBool = typ two\n\nfalse : Bool\nfalse = Left unit\ntrue : Bool\ntrue = Right unit\n\nBothBoolBool : Set\nBothBoolBool = typ four\n\nex1 : BothBoolBool\nex1 = ( false , true )\n\nopen import Data.Vec as V\n\nvariable\n  a b : Set\n  m n : \u2115\n\nenumAdd : Vec a m -> Vec b n -> Vec (Either a b) (m + n)\nenumAdd as bs = V.map Left as ++ V.map Right bs\n\nenumMul : Vec a m -> Vec b n -> Vec (Both   a b) (m * n)\nenumMul as bs = concat (V.map (\\ a -> V.map (\\ b -> (a , b)) bs) as)\n\n-- Third semantics: enumerate all the values in a vector\nenumerate : (t : E) -> Vec (typ t) (card t)\nenumerate Zero = []\nenumerate One = [ unit ]\nenumerate (Add x y) = enumAdd (enumerate x) (enumerate y)\nenumerate (Mul x y) = enumMul (enumerate x) (enumerate y)\n\ntest2 : Vec (typ two) (card two) -- Vec Bool 2\ntest2 = enumerate two\n  -- false \u2237 true \u2237 []\n\ntest4 : Vec (typ four) (card four) -- Vec BothBoolBool 4\ntest4 = enumerate four\n{-\n(false , false) \u2237\n(false , true) \u2237\n(true , false) \u2237\n(true , true) \u2237 []\n-}\n\n-- Exercise: add a constructor for function types\n", "meta": {"hexsha": "4787ff189c69f1dced0db0a5d9886a52813a2a04", "size": 1987, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "L/01/agda/TypeDSL.agda", "max_stars_repo_name": "nicolabotta/DSLsofMath", "max_stars_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-02-24T21:27:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-24T21:27:31.000Z", "max_issues_repo_path": "L/01/agda/TypeDSL.agda", "max_issues_repo_name": "nicolabotta/DSLsofMath", "max_issues_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "L/01/agda/TypeDSL.agda", "max_forks_repo_name": "nicolabotta/DSLsofMath", "max_forks_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1046511628, "max_line_length": 78, "alphanum_fraction": 0.6149974836, "num_tokens": 662, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545318852121, "lm_q2_score": 0.8376199694135332, "lm_q1q2_score": 0.7941931699969943}}
{"text": "open import Common.Prelude\nopen import TestHarness\nopen import TestBool using ( not; _\u2227_ ; _\u2194_ )\n\nmodule TestNat where\n\n_*_ : Nat \u2192 Nat \u2192 Nat\nzero  * n = zero\nsuc m * n = n + (m * n)\n\n{-# COMPILED_JS _*_ function (x) { return function (y) { return x*y; }; } #-}\n\nfact : Nat \u2192 Nat\nfact zero    = 1\nfact (suc x) = suc x * fact x\n\n_\u225f_ : Nat \u2192 Nat \u2192 Bool\nzero  \u225f zero  = true\nsuc x \u225f suc y = x \u225f y\nx     \u225f y     = false\n\n{-# COMPILED_JS _\u225f_ function (x) { return function (y) { return x === y; }; } #-}\n\ntests : Tests\ntests _ = (\n    assert (0 \u225f 0) \"0=0\" ,\n    assert (not (0 \u225f 1)) \"0\u22601\" ,\n    assert ((1 + 2) \u225f 3) \"1+2=3\" ,\n    assert ((2 \u2238 1) \u225f 1) \"2\u22381=1\" ,\n    assert ((1 \u2238 2) \u225f 0) \"1\u22382=0\" ,\n    assert ((2 * 3) \u225f 6) \"2+3=6\" ,\n    assert (fact 0 \u225f 1) \"0!=1\" ,\n    assert (fact 1 \u225f 1) \"1!=1\" ,\n    assert (fact 2 \u225f 2) \"2!=2\" ,\n    assert (fact 3 \u225f 6) \"3!=6\" ,\n    assert (fact 4 \u225f 24) \"4!=24\"\n  )\n", "meta": {"hexsha": "b219efefa7723758332d7b065f4c42daa0fb4635", "size": 895, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/js/TestNat.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/js/TestNat.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/js/TestNat.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 23.5526315789, "max_line_length": 81, "alphanum_fraction": 0.4983240223, "num_tokens": 399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.962673109443157, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7936873262824284}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\n\nmodule Rings.Divisible.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A \u2192 A \u2192 A} (R : Ring S _+_ _*_) where\n\nopen Setoid S\nopen Equivalence eq\nopen Ring R\nopen import Rings.Divisible.Definition R\nopen import Rings.Units.Definition R\n\ndivisionTransitive : (x y z : A) \u2192 x \u2223 y \u2192 y \u2223 z \u2192 x \u2223 z\ndivisionTransitive x y z (a , pr) (b , pr2) = (a * b) , transitive (transitive *Associative (*WellDefined pr reflexive)) pr2\n\ndivisionReflexive : (x : A) \u2192 x \u2223 x\ndivisionReflexive x = 1R , transitive *Commutative identIsIdent\n\neverythingDividesZero : (r : A) \u2192 r \u2223 0R\neverythingDividesZero r = 0R , timesZero\n\nnonzeroInherits : {x y : A} (nz : (x \u223c 0R) \u2192 False) \u2192 y \u2223 x \u2192 (y \u223c 0R) \u2192 False\nnonzeroInherits {x} {y} nz (c , pr) y=0 = nz (transitive (symmetric pr) (transitive (*WellDefined y=0 reflexive) (transitive *Commutative timesZero)))\n\nnonunitInherits : {x y : A} (nonunit : Unit x \u2192 False) \u2192 x \u2223 y \u2192 Unit y \u2192 False\nnonunitInherits nu (s , pr) (a , b) = nu ((s * a) , transitive (transitive *Associative (*WellDefined pr reflexive)) b)\n", "meta": {"hexsha": "70623075906105b8808b7011e1efe30267009678", "size": 1257, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Divisible/Lemmas.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Divisible/Lemmas.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Divisible/Lemmas.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 40.5483870968, "max_line_length": 150, "alphanum_fraction": 0.6825775656, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9381240177362488, "lm_q2_score": 0.8459424334245617, "lm_q1q2_score": 0.7935989144178289}}
{"text": "data Bool : Set where\n  true  : Bool\n  false : Bool\n\n\nnot : Bool \u2192 Bool\nnot true = false\nnot false = true\n\n\ndata \u2115 : Set where\n  O : \u2115\n  S : \u2115 \u2192 \u2115\n\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nO   + a = a\nS a + b = S (a + b)\n\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nO   * a = O\nS a * b = a + (a * b)\n\n_or_ : Bool \u2192 Bool \u2192 Bool\ntrue  or _ = true\nfalse or b = b\n\n\nif_then_else_ : {A : Set} \u2192 Bool \u2192 A \u2192 A \u2192 A\nif true  then x else y = x\nif false then x else y = y\n\n\ninfixl 60 _*_\ninfixl 40 _+_\ninfixr 20 _or_\ninfix  5 if_then_else_\n\n\ninfixr 40 _::_\ndata List (A : Set) : Set where\n  []   : List A\n  _::_ : A -> List A -> List A\n\n\n_\u2218_ : {A : Set} -> {B : A -> Set} -> {C : (x : A) -> B x -> Set} ->\n      (f : {x : A} -> (y : B x) -> C x y) -> (g : (x : A) -> B x) ->\n      (x : A) -> C x (g x)\n_\u2218_ f g a = f (g a)\n\n\nplus-two = S \u2218 S\n\nmap : {A B : Set} -> (A -> B) -> List A -> List B\nmap f []        = []\nmap f (x :: xs) = f x :: map f xs\n\n_++_ : {A : Set} -> List A -> List A -> List A\n[]      ++ ys = ys\nx :: xs ++ ys = x :: (xs ++ ys)\n\n\ndata Vec (A : Set) : \u2115 -> Set where\n  nil  : Vec A O\n  cons : (n : \u2115) -> A -> Vec A n -> Vec A (S n)\n\nhead : {A : Set} {n : \u2115} -> Vec A (S n) -> A\nhead (cons n v vs) = v\n\n\nvmap : {A B : Set} (n : \u2115) -> (A -> B) -> Vec A n -> Vec B n\nvmap .O f nil = nil\nvmap .(S n) f (cons n x xs) = cons n (f x) (vmap n f xs)\n\n\nvmap\u2032 : {A B : Set} (n : \u2115) -> (A -> B) -> Vec A n -> Vec B n\nvmap\u2032 O f nil = nil\nvmap\u2032 (S n) f (cons .n x xs) = cons n (f x) (vmap n f xs)\n\n\ndata Fin : \u2115 -> Set where\n  fzero : {n : \u2115} -> Fin (S n)\n  fsuc  : {n : \u2115} -> Fin n -> Fin (S n)\n\n_!_ : {n : \u2115}{A : Set} -> Vec A n -> Fin n -> A\nnil ! ()\ncons n x a ! fzero = x\ncons n x a ! fsuc b = a ! b\n\n\n\ntabulate : {n : \u2115}{A : Set} -> (Fin n -> A) -> Vec A n\ntabulate {O} f = nil\ntabulate {S n} f = cons n (f fzero) (tabulate (f \u2218 fsuc))\n\n\ndata   False : Set where\nrecord True  : Set where\n\n\ntrivial : True\ntrivial = _\n\n\nisTrue : Bool -> Set\nisTrue true  = True\nisTrue false = False\n\n\n_<_ : \u2115 -> \u2115 -> Bool\n_   < O   = false\nO   < S n = true\nS m < S n = m < n\n\nlength : {A : Set} -> List A -> \u2115\nlength [] = O\nlength (x :: xs) = S (length xs)\n\nlookup : {A : Set}(xs : List A)(n : \u2115) -> isTrue (n < length xs) -> A\nlookup (x :: xs) O b = x\nlookup (x :: xs) (S n) b = lookup xs n b\nlookup [] a ()\n\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n  refl : x == x\n\n\ndata _\u2264_ : \u2115 -> \u2115 -> Set where\n  \u2264O : {m n : \u2115} -> m == n -> m \u2264 n\n  \u2264I : {m n : \u2115} -> m \u2264  n -> m \u2264 S n\n\n\nleq-trans : {l m n : \u2115} -> l \u2264 m -> m \u2264 n -> l \u2264 n\nleq-trans a (\u2264O refl) = a\nleq-trans a (\u2264I b)    = \u2264I (leq-trans a b)\n\n\nmin : \u2115 -> \u2115 -> \u2115\nmin a b with a < b\nmin a b | true  = a\nmin a b | false = b\n\n\nfilter : {A : Set} -> (A -> Bool) -> List A -> List A\nfilter f [] = []\nfilter f (x :: xs) with f x\n... | true  = x :: filter f xs\n... | false =      filter f xs\n\n\ndata _\u2260_ : \u2115 -> \u2115 -> Set where\n  z\u2260s : {n : \u2115}   -> O   \u2260 S n\n  s\u2260z : {n : \u2115}   -> S n \u2260 O\n  s\u2260s : {m n : \u2115} -> n   \u2260 m \u2192 S n \u2260 S m\n\n\ndata Equal? (n m : \u2115) : Set where\n  eq  : n == m -> Equal? n m\n  neq : n \u2260  m -> Equal? n m\n", "meta": {"hexsha": "08277dcd5fa4a72d9f6428edda57223223eaa22e", "size": 2998, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-tutorial/basics.agda", "max_stars_repo_name": "shouya/thinking-dumps", "max_stars_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2015-02-14T17:18:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T01:02:15.000Z", "max_issues_repo_path": "agda-tutorial/basics.agda", "max_issues_repo_name": "shouya/thinking-dumps", "max_issues_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-06-14T06:07:33.000Z", "max_issues_repo_issues_event_max_datetime": "2015-08-04T22:05:11.000Z", "max_forks_repo_path": "agda-tutorial/basics.agda", "max_forks_repo_name": "shouya/thinking-dumps", "max_forks_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-12-02T02:10:26.000Z", "max_forks_repo_forks_event_max_datetime": "2017-06-03T06:32:26.000Z", "avg_line_length": 18.6211180124, "max_line_length": 69, "alphanum_fraction": 0.4543028686, "num_tokens": 1289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625012602593, "lm_q2_score": 0.8519527944504227, "lm_q1q2_score": 0.7935620808744583}}
{"text": "{-# OPTIONS --cubical #-}\nmodule ExerciseSession1 where\n\nopen import Part1 hiding (B)\n\n-- We redefine B to be a family of types in this file\nvariable\n  B : A \u2192 Type \u2113\n\n-- Exercise 1: state and prove funExt for dependent functions f g : (x : A) \u2192 B x\n\n\n-- Exercise 2: generalize the type of cong to dependent function f : (x : A) \u2192 B x\n-- (hint: the result should be a PathP)\n\n\n-- Exercise 3 (easy) state and prove that inhabited propositions are contractible\n\n\n-- We could have stated isProp as follows:\nisProp' : Type \u2113 \u2192 Type \u2113\nisProp' A = (x y : A) \u2192 isContr (x \u2261 y)\n\n-- Exercise 4 (easy): prove that isProp' A implies isProp A\n\n-- For the converse we need path composition, see ExerciseSession2\n\n\n-- Exercise 5: prove isProp\u03a0\nisProp\u03a0 : (h : (x : A) \u2192 isProp (B x)) \u2192 isProp ((x : A) \u2192 B x)\nisProp\u03a0 h = {!!}\n\n\n-- Exercise 6: prove the inverse of funExt (sometimes called happly)\nfunExt\u207b : {f g : (x : A) \u2192 B x} \u2192 f \u2261 g \u2192 ((x : A) \u2192 f x \u2261 g x)\nfunExt\u207b p = {!!}\n\n\n-- Exercise 7: use funExt\u207b to prove isSet\u03a0\nisSet\u03a0 : (h : (x : A) \u2192 isSet (B x)) \u2192 isSet ((x : A) \u2192 B x)\nisSet\u03a0 h = {!!}\n\n\n-- We could have defined the type of singletons as follows\nsingl' : {A : Type \u2113} (a : A) \u2192 Type \u2113\nsingl' {A = A} a = \u03a3[ x \u2208 A ] x \u2261 a\n\n-- Exercise 8 (harder): prove the corresponding version of contractibility of singetons for singl'\n-- (hint: use a suitable combinations of connections and _~)\nisContrSingl' : (x : A) \u2192 isContr (singl' x)\nisContrSingl' x = {!!}\n", "meta": {"hexsha": "8862d2666ef1e603fca50c2d4c840b041d4b1869", "size": 1450, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda", "max_stars_repo_name": "tomdjong/EPIT-2020", "max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda", "max_issues_repo_name": "tomdjong/EPIT-2020", "max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda", "max_forks_repo_name": "tomdjong/EPIT-2020", "max_forks_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8846153846, "max_line_length": 98, "alphanum_fraction": 0.6386206897, "num_tokens": 490, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896780646392, "lm_q2_score": 0.8615382076534742, "lm_q1q2_score": 0.7932954888656288}}
{"text": "{-# OPTIONS --safe --warning=error #-}\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _\u2294_)\nopen import LogicalFormulae\nopen import Logic.PropositionalLogic\nopen import Functions.Definition\nopen import Numbers.Naturals.Naturals\nopen import Vectors\nopen import Boolean.Definition\n\nmodule Logic.PropositionalAxiomsTautology where\n\naxiomKTaut : {a : _} {A : Set a} (P Q : Propositions A) \u2192 Tautology (implies P (implies Q P))\naxiomKTaut P Q v with inspect (Valuation.v v P)\naxiomKTaut P Q v | BoolTrue with\u2261 pT with inspect (Valuation.v v Q)\naxiomKTaut P Q v | BoolTrue with\u2261 pT | BoolTrue with\u2261 qT = Valuation.vImplicationT v (Valuation.vImplicationT v pT)\naxiomKTaut P Q v | BoolTrue with\u2261 pT | BoolFalse with\u2261 qF = Valuation.vImplicationT v (Valuation.vImplicationVacuous v qF)\naxiomKTaut P Q v | BoolFalse with\u2261 pF = Valuation.vImplicationVacuous v pF\n\naxiomSTaut : {a : _} {A : Set a} (P Q R : Propositions A) \u2192 Tautology (implies (implies P (implies Q R)) (implies (implies P Q) (implies P R)))\naxiomSTaut P Q R v with inspect (Valuation.v v P)\naxiomSTaut P Q R v | BoolTrue with\u2261 pT with inspect (Valuation.v v Q)\naxiomSTaut P Q R v | BoolTrue with\u2261 pT | BoolTrue with\u2261 qT with inspect (Valuation.v v R)\naxiomSTaut P Q R v | BoolTrue with\u2261 pT | BoolTrue with\u2261 qT | BoolTrue with\u2261 rT = Valuation.vImplicationT v (Valuation.vImplicationT v (Valuation.vImplicationT v rT))\naxiomSTaut P Q R v | BoolTrue with\u2261 pT | BoolTrue with\u2261 qT | BoolFalse with\u2261 rF = Valuation.vImplicationVacuous v (Valuation.vImplicationF v pT (Valuation.vImplicationF v qT rF))\naxiomSTaut P Q R v | BoolTrue with\u2261 pT | BoolFalse with\u2261 qF = Valuation.vImplicationT v (Valuation.vImplicationVacuous v (Valuation.vImplicationF v pT qF))\naxiomSTaut P Q R v | BoolFalse with\u2261 pF = Valuation.vImplicationT v (Valuation.vImplicationT v (Valuation.vImplicationVacuous v pF))\n\nexcludedMiddleTaut : {a : _} {A : Set a} (P : Propositions A) \u2192 Tautology (implies (prNot (prNot P)) P)\nexcludedMiddleTaut P v with inspect (Valuation.v v P)\nexcludedMiddleTaut P v | BoolTrue with\u2261 pT = Valuation.vImplicationT v pT\nexcludedMiddleTaut P v | BoolFalse with\u2261 pF = Valuation.vImplicationVacuous v (Valuation.vImplicationF v (Valuation.vImplicationVacuous v pF) (Valuation.vFalse v))\n\npropositionalAxiomsTautology : {a : _} {A : Set a} (x : Sg ThreeElements (indexAxiom A)) \u2192 Tautology (IsSubset.ofElt propositionalAxioms x)\npropositionalAxiomsTautology (One , (fst ,, snd)) = axiomKTaut fst snd\npropositionalAxiomsTautology (Two , record { one = one ; two = two ; three = three }) = axiomSTaut one two three\npropositionalAxiomsTautology (Three , b) = excludedMiddleTaut b\n", "meta": {"hexsha": "90c30892206eef26e678d1e7838542b569f76414", "size": 2635, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Logic/PropositionalAxiomsTautology.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Logic/PropositionalAxiomsTautology.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Logic/PropositionalAxiomsTautology.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 69.3421052632, "max_line_length": 178, "alphanum_fraction": 0.7563567362, "num_tokens": 892, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107984180245, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.792826390725685}}
{"text": "{-\n\n        Agda Implementors' Meeting VI\n\n                  G\u00f6teborg\n             May 24 - 30, 2007\n\n\n                Hello Agda!\n\n                Ulf Norell\n\n-}\n\n-- Now we're getting somewhere! Inductive families of datatypes.\n\nmodule Families where\n\n-- You can import modules defined in other files.\n-- More details later...\n--open import Naturals\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\ninfixl 60 _+_\ninfixl 80 _*_\n\n_+_ : Nat -> Nat -> Nat\nzero  + m = m\nsuc n + m = suc (n + m)\n\n_*_ : Nat -> Nat -> Nat\nzero  * m = zero\nsuc n * m = m + n * m\n\n-- Think of an inductive family...\nmodule Vec where\n\n  data Vec (A : Set) : Nat -> Set where\n    []   : Vec A zero\n    _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\n  infixr 40 _::_\n\n  -- Some simple functions\n  head : {A : Set}{n : Nat} -> Vec A (suc n) -> A\n  head (x :: _) = x  -- no need for a [] case\n\n  -- Does the definition look familiar?\n  map : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n\n  map f []        = []\n  map f (x :: xs) = f x :: map f xs\n\n  t1 : Vec Nat (suc (suc zero))\n  t1 = map (_+_ three) (zero :: suc three :: [])\n     where three = suc (suc (suc zero))\n\n  infixr 40 _++_\n\n  _++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n  []        ++ ys = ys\n  (x :: xs) ++ ys = x :: (xs ++ ys)\n\n{-\n\n  Wait a second.. what's really going on here?\n\n  All the indices were conveniently implicit!\n\n-}\n\n-- Ok. Let's make the implicit stuff explicit.\n{-\nmodule WhatsGoingOnHere? where\n\n  open Vec using (Vec; []; _::_)\n-}\n\n  -- Now what's this funny dot thing?\n  map' : {A B : Set}(n : Nat) -> (A -> B) -> Vec A n -> Vec B n\n  map' .zero    f []              = []\n  map' .(suc _) f (x :: xs) = f x :: map' _ f xs\n\n  -- Basically the dot means: inside is not a pattern at all but a\n  -- term whose value is uniquely determined by type checking\n  -- the actual pattern.\n\n  -- In the cases above the types of the patterns\n  --   [] and (_::_ {n} x xs)\n  -- forces the first argument to be zero and suc n respectively.\n  -- So, that's what we write.\n\n  -- We could spend hours talking about this, but let's move on...\n\n-- Let's do some other interesting families.\n\n-- The identity type.\ndata _==_ {A : Set}(x : A) : A -> Set where\n  refl : x == x\n\ninfix 30 _==_\ninfix 20 \u00ac_\n\n-- In the presence of families we get a lot more empty types.\n\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n\ndata False : Set where\n\n\u00ac_ : Set -> Set\n\u00ac A = A -> False\n\n_\u2260_ : {A : Set} -> A -> A -> Set\nx \u2260 y = \u00ac x == y\n\ntrue\u2260false : true == false -> False -- true \u2260 false\ntrue\u2260false ()\n\n-- [The following example might have worked at AIM6, but it does not\n-- work now, so I commented it out. /NAD]\n\n-- lem : (n : Nat) -> n == suc n -> False\n-- lem n ()\n\n-- Why does this work: true == false is an empty type.\n\n{-\n\n  What's next?\n\n-}\n\n-- Actually, inductive families are sufficiently fun that\n-- you'll never get bored, but there's even more fun to be had.\n\n-- Move on to: With.agda\n", "meta": {"hexsha": "90f5424bc47cf9440cc3e75075010a1cdc0fc0e3", "size": 2964, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Families.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Families.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Families.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0212765957, "max_line_length": 68, "alphanum_fraction": 0.5617408907, "num_tokens": 940, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8539127548105611, "lm_q1q2_score": 0.7927801113982819}}
{"text": "-- notes-01-monday.agda\n\nopen import Data.Nat\nopen import Data.Bool\n\nf : \u2115 \u2192 \u2115\nf x = x + 2\n\n{-\n    f 3 =\n  = (x + 2)[x:=3] =\n  = 3 + 2 =\n  = 5\n-}\n\nn : \u2115\nn = 3\n\nf' : \u2115 \u2192 \u2115\nf' = \u03bb x \u2192 x + 2 -- \u03bb function (nameless function)\n\n{-\n    f' 3 =\n  = (\u03bb x \u2192 x + 2) 3 =\n  = (x + 2)[x := 3] = -- \u03b2-reduction\n  = 3 + 2 =\n  = 5\n-}\n\ng : \u2115 \u2192 \u2115 \u2192 \u2115 -- currying\ng = \u03bb x \u2192 (\u03bb y \u2192 x + y)\n\nk : (\u2115 \u2192 \u2115) \u2192 \u2115\nk h = h 2 + h 3\n\n{-\n    k f =\n  = f 2 + f 3 = \n  = (2 + 2) + (3 + 2) =\n  = 4 + 5 =\n  = 9\n-}\n\nvariable\n  A B C : Set -- polymorphic: Set actually means \"type\"\n\nid : A \u2192 A\nid x = x\n\n_\u2218_ : (B \u2192 C) \u2192 (A \u2192 B) \u2192 (A \u2192 C)\nf \u2218 g = \u03bb x \u2192 f (g x)\n\n{-\n  A combinator is a high-order function that uses only function application and\n  other combinators.\n-}\nK : A \u2192 B \u2192 A\nK x y = x\n\nS : (A \u2192 B \u2192 C) \u2192 (A \u2192 B) \u2192 A \u2192 C\nS f g x = f x (g x)\n\n-- in combinatory logic, every pure \u03bb-term can be translated into S,K\n-- \u03bb x \u2192 f x = f -- \u03b7-equality\n", "meta": {"hexsha": "c67c336023212bb4794fb6565d935393e3915b29", "size": 910, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type Theory/notes-01-monday.agda", "max_stars_repo_name": "FoxySeta/mgs-2021", "max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Type Theory/notes-01-monday.agda", "max_issues_repo_name": "FoxySeta/mgs-2021", "max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z", "max_forks_repo_path": "Type Theory/notes-01-monday.agda", "max_forks_repo_name": "FoxySeta/mgs-2021", "max_forks_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.0, "max_line_length": 79, "alphanum_fraction": 0.4516483516, "num_tokens": 418, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418283357702, "lm_q2_score": 0.8577681013541611, "lm_q1q2_score": 0.7926993814735367}}
{"text": "import      Lvl\nopen import Data.Boolean\nopen import Type\n\nmodule Data.List.Sorting.Functions {\u2113} {T : Type{\u2113}} (_\u2264?_ : T \u2192 T \u2192 Bool) where\n\nopen import Data.List\nimport      Data.List.Functions as List\n\n-- Inserts an element to a sorted list so that the resulting list is still sorted.\ninsert : T \u2192 List(T) \u2192 List(T)\ninsert x \u2205       = List.singleton(x)\ninsert x (y \u22b0 l) = if(x \u2264? y) then (x \u22b0 y \u22b0 l) else (y \u22b0 insert x l)\n\n-- Merges two sorted lists so that the resulting list is still sorted.\nmerge : List(T) \u2192 List(T) \u2192 List(T)\nmerge = List.fold\u1d63 insert\n\n-- Merges a list of sorted lists so that the resulting list is still sorted.\nmergeAll : List(List(T)) \u2192 List(T)\nmergeAll = List.fold\u1d63 merge \u2205\n\nopen import Data.Tuple\nopen import Data.Option\nimport      Data.Option.Functions as Option\n\n-- Extracts a smallest element from a list.\nextractMinimal : List(T) \u2192 Option(T \u2a2f List(T))\nextractMinimal \u2205               = None\nextractMinimal (x \u22b0 \u2205)         = Some(x , \u2205)\nextractMinimal (x \u22b0 l@(_ \u22b0 _)) = Option.map(\\{(la , las) \u2192 if(x \u2264? la) then (x , l) else (la , x \u22b0 las)}) (extractMinimal l)\n", "meta": {"hexsha": "619ba9d085a64ad5d58892eb88af4b0dd479d3f9", "size": 1093, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Sorting/Functions.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Sorting/Functions.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Sorting/Functions.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.15625, "max_line_length": 124, "alphanum_fraction": 0.6550777676, "num_tokens": 331, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951698485602, "lm_q2_score": 0.8479677506936878, "lm_q1q2_score": 0.79233697043553}}
{"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.CMonoidEnriched where\n\n-- A category where the Homs are not sets, but commutative monoids\n-- There are weak kind of Ab-enriched.\n-- The reason to do these \"by hand\" is that the\n-- \"free commutative monoid monad\", i.e. Bag, is very hard to work\n-- with in type theory, so it is easier to work axiomatically.\n\nopen import Level\nopen import Algebra.Bundles using (CommutativeMonoid)\nopen import Function.Base using (flip)\nopen import Relation.Binary using (Rel; IsEquivalence)\n\nopen import Categories.Category.Core using (Category)\n\nrecord CM-Category (o \u2113 e : Level) : Set (suc (o \u2294 \u2113 \u2294 e)) where\n  infix  4 _\u2248_ _\u21d2_\n  infixr 9 _\u2218_\n  infixl 7 _+_\n\n  open CommutativeMonoid using (_\u2219_; \u03b5) renaming (Carrier to \u2223_\u2223)\n  field\n    Obj : Set o\n    Hom : (A B : Obj) \u2192 CommutativeMonoid \u2113 e\n\n  _\u21d2_ : (A B : Obj) \u2192 Set \u2113\n  A \u21d2 B = \u2223 Hom A B \u2223\n\n  _+_ : {A B : Obj} \u2192 A \u21d2 B \u2192 A \u21d2 B \u2192 A \u21d2 B\n  _+_ {A} {B} f g = _\u2219_ (Hom A B) f g\n\n  0M : {A B : Obj} \u2192 A \u21d2 B\n  0M {A} {B} = \u03b5 (Hom A B)\n\n  field\n    _\u2248_ : \u2200 {A B : Obj} \u2192 Rel (A \u21d2 B) e\n\n    id  : \u2200 {A} \u2192 A \u21d2 A\n    _\u2218_ : \u2200 {A B C} \u2192 B \u21d2 C \u2192 A \u21d2 B \u2192 A \u21d2 C\n\n  -- The usual categorical structure\n  field\n    assoc     : \u2200 {A B C D} {f : A \u21d2 B} {g : B \u21d2 C} {h : C \u21d2 D} \u2192 (h \u2218 g) \u2218 f \u2248 h \u2218 (g \u2218 f)\n    -- We add a symmetric proof of associativity so that the opposite category of the\n    -- opposite category is definitionally equal to the original category. See how\n    -- `op` is implemented.\n    sym-assoc : \u2200 {A B C D} {f : A \u21d2 B} {g : B \u21d2 C} {h : C \u21d2 D} \u2192 h \u2218 (g \u2218 f) \u2248 (h \u2218 g) \u2218 f\n    identity\u02e1 : \u2200 {A B} {f : A \u21d2 B} \u2192 id \u2218 f \u2248 f\n    identity\u02b3 : \u2200 {A B} {f : A \u21d2 B} \u2192 f \u2218 id \u2248 f\n    -- We add a proof of \"neutral\" identity proof, in order to ensure the opposite of\n    -- constant functor is definitionally equal to itself.\n    identity\u00b2 : \u2200 {A} \u2192 id \u2218 id {A} \u2248 id {A}\n    equiv     : \u2200 {A B} \u2192 IsEquivalence (_\u2248_ {A} {B})\n    \u2218-resp-\u2248  : \u2200 {A B C} {f h : B \u21d2 C} {g i : A \u21d2 B} \u2192 f \u2248 h \u2192 g \u2248 i \u2192 f \u2218 g \u2248 h \u2218 i\n\n    -- preservation of additive structure\n    +-resp-\u2218 : \u2200 {A B C D} {f g : B \u21d2 C} {h : A \u21d2 B} {k : C \u21d2 D} \u2192\n      k \u2218 (f + g) \u2218 h \u2248 k \u2218 f \u2218 h + k \u2218 g \u2218 h\n\n    0-resp-\u2218 : \u2200 {A C D} {h : A \u21d2 C} {k : C \u21d2 D} \u2192 k \u2218 0M \u2218 h \u2248 0M\n\nUnderlying : {o \u2113 e : Level} \u2192 CM-Category o \u2113 e \u2192 Category o \u2113 e\nUnderlying C = record { CM-Category C }\n", "meta": {"hexsha": "b7898c2b879b0d1675a13a8052584fec13759437", "size": 2336, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/CMonoidEnriched.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/CMonoidEnriched.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/CMonoidEnriched.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 35.9384615385, "max_line_length": 91, "alphanum_fraction": 0.5505136986, "num_tokens": 931, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475794701961, "lm_q2_score": 0.8397339716830606, "lm_q1q2_score": 0.7921610095861095}}
{"text": "module Lec6Done where\n\nopen import Lec1Done\n\ndata List (X : Set) : Set where\n  []   : List X\n  _,-_ : X -> List X -> List X\ninfixr 4 _,-_\n\n-- ListF : Set -> Set -> Set\n-- ListF X T = One + (X * T)\n\nmkList : {X : Set} -> One + (X * List X) -> List X\nmkList (inl <>)        = []\nmkList (inr (x , xs))  = x ,- xs\n\nfoldr : {X T : Set} -> ((One + (X * T)) -> T) -> List X -> T\nfoldr alg []         = alg (inl <>)\nfoldr alg (x ,- xs)  = alg (inr (x , foldr alg xs))\n\nex1 = foldr mkList (1 ,- 2 ,- 3 ,- [])\n\nlength : {X : Set} -> List X -> Nat\nlength = foldr \\ { (inl <>) -> zero ; (inr (x , n)) -> suc n }\n\nrecord CoList (X : Set) : Set where\n  coinductive\n  field\n    force : One + (X * CoList X)\nopen CoList\n\n[]~ : {X : Set} -> CoList X\nforce []~ = inl <>\n\n_,~_ : {X : Set} -> X -> CoList X -> CoList X\nforce (x ,~ xs) = inr (x , xs)\ninfixr 4 _,~_\n\nunfoldr : {X S : Set} -> (S -> (One + (X * S))) -> S -> CoList X\nforce (unfoldr coalg s) with coalg s\nforce (unfoldr coalg s) | inl <>       = inl <>\nforce (unfoldr coalg s) | inr (x , s') = inr (x , unfoldr coalg s')\n\nex2 = unfoldr force (1 ,~ 2 ,~ 3 ,~ []~)\n\nrepeat : {X : Set} -> X -> CoList X\nrepeat = unfoldr \\ x -> inr (x , x)\n\nprefix : {X : Set} -> Nat -> CoList X -> List X\nprefix zero xs = []\nprefix (suc n) xs with force xs\nprefix (suc n) xs | inl <> = []\nprefix (suc n) xs | inr (x , xs') = x ,- prefix n xs'\n\nex2' = prefix 3 ex2\n\nrecord Stream (X : Set) : Set where\n  coinductive\n  field\n    hdTl : X * Stream X\nopen Stream\n\nforever : {X : Set} -> X -> Stream X\nfst (hdTl (forever x)) = x\nsnd (hdTl (forever x)) = forever x\n\nunfold : {X S : Set} -> (S -> X * S) -> S -> Stream X\nfst (hdTl (unfold coalg s)) = fst (coalg s)\nsnd (hdTl (unfold coalg s)) = unfold coalg (snd (coalg s))\n", "meta": {"hexsha": "a81e60c33379366fb66e4dd5a4e41c979c4e889a", "size": 1739, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_issues_repo_name": "ajnavarro/language-dataset", "max_issues_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 91, "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_forks_repo_path": "data/github.com/pigworker/CS410-17/ecf7c3bbe9b468eb72578d05c7dd4dfa913dce44/lectures/Lec6Done.agda", "max_forks_repo_name": "ajnavarro/language-dataset", "max_forks_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 24.8428571429, "max_line_length": 67, "alphanum_fraction": 0.5238642898, "num_tokens": 688, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802440252812, "lm_q2_score": 0.8615382058759129, "lm_q1q2_score": 0.7913058215700114}}
{"text": "{-# OPTIONS --no-termination-check #-}\n\nmodule qsort where\n\n  _o_ : {a : Set} -> {b : Set} -> {c : Set} -> (b -> c) -> (a -> b) -> a -> c\n  f o g = \\x -> f (g x)\n\n  data Bool : Set where\n    true  : Bool\n    false : Bool\n\n  not : Bool -> Bool\n  not true  = false\n  not false = true\n\n  if_then_else_ : {a : Set} -> Bool -> a -> a -> a\n  if true  then x else _ = x\n  if false then _ else y = y\n\n  data List (a : Set) : Set where\n    nil  : List a\n    _::_ : a -> List a -> List a\n\n  listrec : {a : Set} -> List a -> (a -> List a -> List a) -> List a -> List a\n  listrec e _  nil    = e\n  listrec e b (x :: xs) = b x (listrec e b xs)\n\n  filter : {a : Set} -> (a -> Bool) -> List a -> List a\n  filter f = listrec nil (\\x ih -> if (f x) then (x :: ih) else ih)\n\n  _++_ : {a : Set} -> List a -> List a -> List a\n  nil ++ ys = ys\n  (x :: xs) ++ ys = x :: (xs ++ ys)\n\n  data Nat : Set where\n    zero : Nat\n    succ : Nat -> Nat\n\n  _+_ : Nat -> Nat -> Nat\n  zero   + m = m\n  succ n + m = succ (n + m)\n\n  _*_ : Nat -> Nat -> Nat\n  zero   * m = zero\n  succ n * m = m + (n * m)\n\n  one : Nat\n  one = succ zero\n\n  fact : Nat -> Nat\n  fact  zero    = one\n  fact (succ n) = succ n * fact n \n\n  _<_ : Nat -> Nat -> Bool\n  zero     < zero     = false\n  zero     < n        = true\n  n        < zero     = false\n  (succ n) < (succ m) = n < m\n\n  --\n\n  qsort : {a : Set} -> (a -> a -> Bool) -> List a -> List a\n  qsort f nil       = nil\n  qsort f (x :: xs) = (qsort f (filter (not o (f x)) xs)) ++\n                    (x :: (qsort f (filter (f x) xs)))\n", "meta": {"hexsha": "ddefe0dc05e540b6552a3d70c5dcfe50a4e3019e", "size": 1531, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/qsort.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/qsort.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/qsort.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.196969697, "max_line_length": 78, "alphanum_fraction": 0.4559111692, "num_tokens": 572, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087946129329, "lm_q2_score": 0.8519528038477825, "lm_q1q2_score": 0.7909604756874282}}
{"text": "open import Tutorials.Monday-Complete\nmodule Tutorials.Tuesday-Complete where\n\n-----------\n-- Pi and Sigma types\n-----------\n\nmodule Product where\n  -- The open keyword opens a given module in the current namespace\n  -- By default all of the public names of the module are opened\n  -- The using keyword limits the imported definitions to those explicitly listed\n  open Fin\n  open Vec using (Vec; []; _\u2237_)\n  open Simple using (\u00ac_)\n\n  variable\n    P Q : A \u2192 Set\n\n  -- Pi types: dependent function types\n  -- For every x of type A, the predicate P x holds\n  \u03a0 : (A : Set) \u2192 (Pred A) \u2192 Set\n  \u03a0 A P = (x : A) \u2192 P x\n\n  infix 5 _,_\n  -- Sigma types: dependent product types, existential types\n  -- For this x of type A, the predicate P x holds\n  record \u03a3 (A : Set) (P : Pred A) : Set where\n    -- In the type P fst, fst refers to a previously introduced field\n    constructor _,_\n    field\n      fst : A\n      snd : P fst\n\n  open \u03a3 public\n\n  -- By depending on a boolean we can use pi types to represent product types\n  \u03a0-\u00d7 : Set \u2192 Set \u2192 Set\n  \u03a0-\u00d7 A B = \u03a0 Bool \u03bb where\n    true  \u2192 A\n    false \u2192 B\n\n  -- By depending on a boolean we can use sigma types to represent sum types\n  \u03a3-\u228e : Set \u2192 Set \u2192 Set\n  \u03a3-\u228e A B = \u03a3 Bool \u03bb where\n    true  \u2192 A\n    false \u2192 B\n\n  -- Use pi types to recover function types\n  \u03a0-\u2192 : Set \u2192 Set \u2192 Set\n  \u03a0-\u2192 A B = \u03a0 A \u03bb where\n    _     \u2192 B\n\n  -- Use sigma types to recover product types\n  \u03a3-\u00d7 : Set \u2192 Set \u2192 Set\n  \u03a3-\u00d7 A B = \u03a3 A \u03bb where\n    _     \u2192 B\n\n  infix 5 _\u00d7_\n  _\u00d7_ : Set \u2192 Set \u2192 Set\n  _\u00d7_ = \u03a3-\u00d7\n\n  -- 1) If we can transform the witness and\n  -- 2) transform the predicate as per the transformation on the witness\n  -- \u21d2) then we can transform a sigma type\n  map : (f : A \u2192 B) \u2192 (\u2200 {x} \u2192 P x \u2192 Q (f x)) \u2192 (\u03a3 A P \u2192 \u03a3 B Q)\n  map f g (x , y) = (f x , g y)\n\n  -- The syntax keyword introduces notation that can include binders\n  infix 4 \u03a3-syntax\n  \u03a3-syntax : (A : Set) \u2192 (A \u2192 Set) \u2192 Set\n  \u03a3-syntax = \u03a3\n  syntax \u03a3-syntax A (\u03bb x \u2192 B) = \u03a3[ x \u2208 A ] B\n\n  example\u2081 : \u03a3 \u2115 EvenData\n  example\u2081 = 0 , zero\n\n  one-is-not-even : \u00ac EvenData 1\n  one-is-not-even ()\n\n  example\u2082 : \u00ac \u03a0 \u2115 EvenData\n  example\u2082 f = one-is-not-even (f 1)\n\n\n  \u00ac\u2218 : Pred A \u2192 Pred A\n  \u00ac\u2218 P = \u00ac_ \u2218 P\n\n  -- These can be proven regardless of A\n\n  \u00ac\u2203\u21d2\u2200\u00ac : \u00ac (\u03a3 A P) \u2192 \u03a0 A (\u00ac\u2218 P)\n  \u00ac\u2203\u21d2\u2200\u00ac f x px = f (x , px)\n\n  \u2203\u00ac\u21d2\u00ac\u2200 : \u03a3 A (\u00ac\u2218 P) \u2192 \u00ac \u03a0 A P\n  \u2203\u00ac\u21d2\u00ac\u2200 (a , \u00acpa) f = \u00acpa (f a)\n\n  \u2200\u00ac\u21d2\u00ac\u2203 : \u03a0 A (\u00ac\u2218 P) \u2192 \u00ac \u03a3 A P\n  \u2200\u00ac\u21d2\u00ac\u2203 f (a , pa) = f a pa\n\n  -- Works in classical, not in constructive mathematics\n  postulate \u00ac\u2200\u21d2\u2203\u00ac : \u00ac \u03a0 A P \u2192 \u03a3 A (\u00ac\u2218 P)\n\n  -- Show that \u2264 is antisymmetric\n  \u2264-\u2261 : n \u2264 m \u2192 m \u2264 n \u2192 n \u2261 m\n  \u2264-\u2261 z\u2264n z\u2264n = refl\n  \u2264-\u2261 (s\u2264s x) (s\u2264s y) = cong suc (\u2264-\u2261 x y)\n\n  -- By using n \u2264 m instead of Fin m we can mention n in the output\n  take : Vec A m \u2192 n \u2264 m \u2192 Vec A n\n  take xs z\u2264n = []\n  take (x \u2237 xs) (s\u2264s lte) = x \u2237 take xs lte\n\n  Fin-to-\u2264 : (i : Fin m) \u2192 to-\u2115 i < m\n  Fin-to-\u2264 zero = s\u2264s z\u2264n\n  Fin-to-\u2264 (suc i) = s\u2264s (Fin-to-\u2264 i)\n\n  -- Proof combining sigma types and equality\n  \u2264-to-Fin : n < m \u2192 Fin m\n  \u2264-to-Fin (s\u2264s z\u2264n) = zero\n  \u2264-to-Fin (s\u2264s (s\u2264s i)) = suc (\u2264-to-Fin (s\u2264s i))\n\n  Fin-\u2264-inv : (i : Fin m) \u2192 \u2264-to-Fin (Fin-to-\u2264 i) \u2261 i\n  Fin-\u2264-inv zero = refl\n  Fin-\u2264-inv (suc zero) = refl\n  Fin-\u2264-inv (suc (suc i)) = cong suc (Fin-\u2264-inv (suc i))\n\n  \u2264-Fin-inv : (lt : \u03a3[ n \u2208 \u2115 ] n < m)\n            \u2192 (to-\u2115 (\u2264-to-Fin (snd lt)) , Fin-to-\u2264 (\u2264-to-Fin (snd lt))) \u2261 lt\n  \u2264-Fin-inv (.zero , s\u2264s z\u2264n) = refl\n  \u2264-Fin-inv (.(suc _) , s\u2264s (s\u2264s i)) =\n    cong (map suc s\u2264s) (\u2264-Fin-inv (_ , s\u2264s i))\n", "meta": {"hexsha": "b40ee744f2aa1c26f6ee9a6a6943b29dde109ecc", "size": 3455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tutorials/Tuesday-Complete.agda", "max_stars_repo_name": "poncev/agda-bcam", "max_stars_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2021-09-23T17:59:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T22:53:51.000Z", "max_issues_repo_path": "Tutorials/Tuesday-Complete.agda", "max_issues_repo_name": "poncev/agda-bcam", "max_issues_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tutorials/Tuesday-Complete.agda", "max_forks_repo_name": "poncev/agda-bcam", "max_forks_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-23T08:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-24T10:50:55.000Z", "avg_line_length": 26.5769230769, "max_line_length": 81, "alphanum_fraction": 0.5461649783, "num_tokens": 1419, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107931567176, "lm_q2_score": 0.843895106480586, "lm_q1q2_score": 0.7909076020857426}}
{"text": "{-# OPTIONS --without-K #-}\n\nmodule Lecture2 where\n\nimport Basics\nopen Basics public\n\n-- Definition 2.2.3 define the identity function, and show lambda-abstraction in so doing\nid : {i : Level} {A : UU i} \u2192 A \u2192 A\nid = \u03bb a \u2192 a -- can also use plain backslash \\ instead of lambda (as it resembles lambda?)\n\n-- Definition 2.2.4\ncomp : {i j k : Level} {A : UU i} {B : UU j} {C : UU k} \u2192 (B \u2192 C) \u2192 ((A \u2192 B) \u2192 (A \u2192 C))\ncomp = \u03bb g f a \u2192 g(f(a)) -- the lambda extends to cover g, f and a\n_\u2218_ : {i j k : Level} {A : UU i} {B : UU j} {C : UU k} \u2192 (B \u2192 C) \u2192 ((A \u2192 B) \u2192 (A \u2192 C))\ng \u2218 f = comp g f\n\ndata \u2115 : U where\n  Nzero : \u2115\n  Nsucc : \u2115 \u2192 \u2115\n\nadd : \u2115 \u2192 \u2115 \u2192 \u2115\nadd Nzero = id\nadd (Nsucc n) = Nsucc \u2218 (add n)\n\n-- try some examples, hit C-c C-n (or whatever \"compute normal form\" is bound to)\n-- and try entering \"add (Nsucc Nzero) (Nsucc (Nsucc Nzero))\"\n-- you should get \"Nsucc (Nsucc (Nsucc Nzero))\"\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nn + m = add n m\n\n-- Exercise 2.3\nconst : {i j : Level} (A : UU i) (B : UU j) (b : B) \u2192 A \u2192 B\nconst A B b x = b\n\n-- Exercise 2.4\nPi-swap : {i j k : Level} {A : UU i} {B : UU j} {C : A \u2192 (B \u2192 UU k)} \u2192\n  ((x : A) (y : B) \u2192 C x y) \u2192 ((y : B) (x : A) \u2192 C x y)\nPi-swap f y x = f x y\n\n-- Exercise 2.5(a)\n_**_ : \u2115 \u2192 (\u2115 \u2192 \u2115)\nNzero ** n = Nzero\n(Nsucc m) ** n = (m ** n) + n\n\n-- Exercise 2.5(b)\n_^_ : \u2115 \u2192 (\u2115 \u2192 \u2115)\nm ^ Nzero = Nsucc Nzero\nm ^ (Nsucc n) = m ** (m ^ n)\n\n-- Exercise 2.5(c)\nfactorial : \u2115 \u2192 \u2115\nfactorial Nzero = Nsucc Nzero\nfactorial (Nsucc m) = (Nsucc m) ** (factorial m)\n\n-- Exercise 2.6(a)\nNmax : \u2115 \u2192 (\u2115 \u2192 \u2115)\nNmax Nzero n = n\nNmax (Nsucc m) Nzero = Nsucc m\nNmax (Nsucc m) (Nsucc n) = Nsucc (Nmax m n)\n\n-- Exercise 2.6(b)\nNmin : \u2115 \u2192 (\u2115 \u2192 \u2115)\nNmin Nzero n = Nzero\nNmin (Nsucc m) Nzero = Nzero\nNmin (Nsucc m) (Nsucc n) = Nsucc (Nmin m n)\n\n-- Exercise 2.7\n-- induction: for any dependent type P over \u2115, define a section of P\n-- built out of a term in P 0 and a section of P n \u2192 P(Nsucc n)\nind-N : {i : Level} {P : \u2115 \u2192 UU i} \u2192 P Nzero \u2192 ((n : \u2115) \u2192 P n \u2192 P(Nsucc n)) \u2192 ((n : \u2115) \u2192 P n)\nind-N p0 pS Nzero = p0\nind-N p0 pS (Nsucc n) = pS n (ind-N p0 pS n)\n", "meta": {"hexsha": "cd19968c3bbaea8505a2ed77d482f5390ad1bfd3", "size": 2052, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lecture2.agda", "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_issues_repo_path": "Lecture2.agda", "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_forks_repo_path": "Lecture2.agda", "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "avg_line_length": 27.36, "max_line_length": 93, "alphanum_fraction": 0.5511695906, "num_tokens": 867, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070035949656, "lm_q2_score": 0.8688267745399465, "lm_q1q2_score": 0.7905515670647214}}
{"text": "module Bin where\n\nopen import Relation.Binary.PropositionalEquality using (_\u2261_; refl)\n\nopen import Naturals using (\u2115; zero; suc; _+_; _*_)\n\n-- 2\u9032\u6570\u306e\u8868\u73fe\ndata Bin : Set where\n  \u27e8\u27e9 : Bin\n  _O : Bin \u2192 Bin\n  _I : Bin \u2192 Bin\n\n-- 2\u9032\u6570\u306e\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\ninc : Bin \u2192 Bin\ninc \u27e8\u27e9    = \u27e8\u27e9 I\ninc (b O) = b I\ninc (b I) = inc b O\n\n_ : inc (\u27e8\u27e9 I O I I) \u2261 \u27e8\u27e9 I I O O\n_ = refl\n\n_ : inc (\u27e8\u27e9 O O O O) \u2261 \u27e8\u27e9 O O O I\n_ = refl\n\n_ : inc (\u27e8\u27e9 O O O I) \u2261 \u27e8\u27e9 O O I O\n_ = refl\n\n_ : inc (\u27e8\u27e9 O O I O) \u2261 \u27e8\u27e9 O O I I\n_ = refl\n\n_ : inc (\u27e8\u27e9 O O I I) \u2261 \u27e8\u27e9 O I O O\n_ = refl\n\n_ : inc (\u27e8\u27e9 O I O O) \u2261 \u27e8\u27e9 O I O I\n_ = refl\n\n-- \u81ea\u7136\u6570\u304b\u30892\u9032\u6570\u3078\u306e\u5909\u63db\nto : \u2115 \u2192 Bin\nto zero    = \u27e8\u27e9 O\nto (suc n) = inc (to n)\n\n_ : to 0 \u2261 \u27e8\u27e9 O\n_ = refl\n\n_ : to 1 \u2261 \u27e8\u27e9 I\n_ = refl\n\n_ : to 2 \u2261 \u27e8\u27e9 I O\n_ = refl\n\n_ : to 3 \u2261 \u27e8\u27e9 I I\n_ = refl\n\n_ : to 4 \u2261 \u27e8\u27e9 I O O\n_ = refl\n\n-- 2\u9032\u6570\u304b\u3089\u81ea\u7136\u6570\u3078\u306e\u5909\u63db\nfrom : Bin \u2192 \u2115\nfrom \u27e8\u27e9    = zero\nfrom (b O) = 2 * (from b)\nfrom (b I) = 2 * (from b) + 1\n\n_ : from (\u27e8\u27e9 O) \u2261 0\n_ = refl\n\n_ : from (\u27e8\u27e9 I) \u2261 1\n_ = refl\n\n_ : from (\u27e8\u27e9 I O) \u2261 2\n_ = refl\n\n_ : from (\u27e8\u27e9 I I) \u2261 3\n_ = refl\n\n_ : from (\u27e8\u27e9 I O O) \u2261 4\n_ = refl\n", "meta": {"hexsha": "606ee96b5e3ea2f462c40c80253f2769611efb15", "size": 1039, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/naturals/Bin.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/naturals/Bin.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/naturals/Bin.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.4935064935, "max_line_length": 67, "alphanum_fraction": 0.4773820982, "num_tokens": 550, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294404018582427, "lm_q2_score": 0.8499711699569787, "lm_q1q2_score": 0.7899975457727351}}
{"text": "module Two where\n\nopen import Relation.Binary.PropositionalEquality\nopen \u2261-Reasoning\n\nimport Data.Nat as \u2115\nimport Data.Nat.Properties as \u2115\u209a\n\nopen \u2115 using (\u2115; zero; suc; _+_)\n\n-- Our language consists of constants and addition\ndata Expr : Set where\n  const : \u2115 \u2192 Expr\n  plus : Expr \u2192 Expr \u2192 Expr\n\n-- Straightforward semantics\neval-expr : Expr \u2192 \u2115\neval-expr (const n) = n\neval-expr (plus e1 e2) = eval-expr e1 + eval-expr e2\n\n-- Tail recursive semantics\neval-expr-tail' : Expr \u2192 \u2115 \u2192 \u2115\neval-expr-tail' (const n) acc = n + acc\neval-expr-tail' (plus e1 e2) acc = eval-expr-tail' e2 (eval-expr-tail' e1 acc)\n\neval-expr-tail : Expr \u2192 \u2115\neval-expr-tail e = eval-expr-tail' e 0\n\n--\n-- Task: prove that eval-expr-tail is equivalent to eval-expr.\n--\n\n-- The tail recursive evaluation does not depend on its accumulator\neval-expr-tail-correct-lemma : \u2200 e acc \u2192 eval-expr-tail' e acc \u2261 eval-expr-tail' e 0 + acc\neval-expr-tail-correct-lemma e acc = ?\n\n-- The tail recursive evaluation agrees with the straightforward evaluation\neval-expr-tail-correct : \u2200 e \u2192 eval-expr-tail e \u2261 eval-expr e\neval-expr-tail-correct e = ?\n", "meta": {"hexsha": "b51a2c434d74358d16362b57835a2b9d2f2e0774", "size": 1105, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Exercises/Two.agda", "max_stars_repo_name": "UoG-Agda/Agda101", "max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Exercises/Two.agda", "max_issues_repo_name": "UoG-Agda/Agda101", "max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Exercises/Two.agda", "max_forks_repo_name": "UoG-Agda/Agda101", "max_forks_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.625, "max_line_length": 90, "alphanum_fraction": 0.7113122172, "num_tokens": 348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133515091156, "lm_q2_score": 0.8397339756938819, "lm_q1q2_score": 0.7892771754705107}}
{"text": "{-\n\nPart 3: Univalence and the SIP\n\n- Univalence from ua and ua\u03b2\n- Transporting with ua (examples: ua not : Bool = Bool, ua suc : Z = Z, ...)\n- Subst using ua\n- The SIP as a consequence of ua\n- Examples of using the SIP for math and programming (algebra, data\n  structures, etc.)\n\n-}\n\n{-# OPTIONS --cubical #-}\nmodule Part3 where\n\nopen import Cubical.Foundations.Prelude hiding (refl ; transport ; subst ; sym)\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Univalence\n\nopen import Cubical.Data.Int\n\nopen import Part2 public\n\n\n-- Another key concept in HoTT/UF is the Univalence Axiom. In Cubical\n-- Agda this is provable, we hence refer to it as the Univalence\n-- Theorem.\n\n-- The univalence theorem: equivalences of types give paths of types\nua' : {A B : Type \u2113} \u2192 A \u2243 B \u2192 A \u2261 B\nua' = ua\n\n-- Any isomorphism of types gives rise to an equivalence\nisoToEquiv' : {A B : Type \u2113} \u2192 Iso A B \u2192 A \u2243 B\nisoToEquiv' = isoToEquiv\n\n-- And hence to a path\nisoToPath' : {A B : Type \u2113} \u2192 Iso A B \u2192 A \u2261 B\nisoToPath' e = ua' (isoToEquiv' e)\n\n-- ua satisfies the following computation rule\n-- This suffices to be able to prove the standard formulation of univalence.\nua\u03b2' : {A B : Type \u2113} (e : A \u2243 B) (x : A)\n     \u2192 transport (ua' e) x \u2261 fst e x\nua\u03b2' e x = transportRefl (equivFun e x)\n\n\n\n-- Time for an example!\n\n-- Booleans\ndata Bool : Type\u2080 where\n  false true : Bool\n\nnot : Bool \u2192 Bool\nnot false = true\nnot true  = false\n\nnotPath : Bool \u2261 Bool\nnotPath = isoToPath' (iso not not rem rem)\n  where\n  rem : (b : Bool) \u2192 not (not b) \u2261 b\n  rem false = refl\n  rem true  = refl\n\n_ : transport notPath true \u2261 false\n_ = refl\n\n\n-- Another example, integers:\n\nsucPath : Int \u2261 Int\nsucPath = isoToPath' (iso sucInt predInt sucPred predSuc)\n\n_ : transport sucPath (pos 0) \u2261 pos 1\n_ = refl\n\n_ : transport (sucPath \u2219 sucPath) (pos 0) \u2261 pos 2\n_ = refl\n\n_ : transport (sym sucPath) (pos 0) \u2261 negsuc 0\n_ = refl\n\n\n\n-------------------------------------------------------------------------\n-- The structure identity principle\n\n-- A more efficient version of finite multisets based on association lists\nopen import Cubical.HITs.AssocList.Base\n\n-- data AssocList (A : Type) : Type where\n--  \u27e8\u27e9 : AssocList A\n--  \u27e8_,_\u27e9\u2237_ : (a : A) (n : \u2115) (xs : AssocList A) \u2192 AssocList A\n--  per : (a b : A) (m n : \u2115) (xs : AssocList A)\n--      \u2192 \u27e8 a , m \u27e9\u2237 \u27e8 b , n \u27e9\u2237 xs \u2261 \u27e8 b , n \u27e9\u2237 \u27e8 a , m \u27e9\u2237 xs\n--  agg : (a : A) (m n : \u2115) (xs : AssocList A)\n--      \u2192 \u27e8 a , m \u27e9\u2237 \u27e8 a , n \u27e9\u2237 xs \u2261 \u27e8 a , m + n \u27e9\u2237 xs\n--  del : (a : A) (xs : AssocList A) \u2192 \u27e8 a , 0 \u27e9\u2237 xs \u2261 xs\n--  trunc : (xs ys : AssocList A) (p q : xs \u2261 ys) \u2192 p \u2261 q\n\n\n-- Programming and proving is more complicated with AssocList compared\n-- to FMSet. This kind of example occurs everywhere in programming and\n-- mathematics: one representation is easier to work with, but not\n-- efficient, while another is efficient but difficult to work with.\n\n-- Solution: substitute using univalence\nsubstIso : {A B : Type \u2113} (P : Type \u2113 \u2192 Type \u2113') (e : Iso A B) \u2192 P A \u2192 P B\nsubstIso P e = subst P (isoToPath e)\n\n-- Can transport for example Monoid structure from FMSet to AssocList\n-- this way, but the achieved Monoid structure is not very efficient\n-- to work with. A better solution is to prove that FMSet and\n-- AssocList are equal *as monoids*, but how to do this?\n\n-- Solution: structure identity principle (SIP)\n-- This is a very useful consequence of univalence\nopen import Cubical.Foundations.SIP\n\n{-\nsip' : {\u2113 : Level} {S : Type \u2113 \u2192 Type \u2113} {\u03b9 : StrEquiv S \u2113}\n       (\u03b8 : UnivalentStr S \u03b9) (A B : TypeWithStr \u2113 S) \u2192 A \u2243[ \u03b9 ] B \u2192 A \u2261 B\nsip' = sip\n-}\n-- The tricky thing is to prove that (S,\u03b9) is a univalent structure.\n-- Luckily we provide automation for this in the library, see for example:\n-- open import Cubical.Algebra.Monoid.Base\n\n-- Another cool application of the SIP: matrices represented as\n-- functions out of pairs of Fin's and vectors are equal as abelian\n-- groups:\nopen import Cubical.Algebra.Matrix\n", "meta": {"hexsha": "3a4671b2636af99a7a6c69d76969358acf18d42c", "size": 3977, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_stars_repo_name": "tomdjong/EPIT-2020", "max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_issues_repo_name": "tomdjong/EPIT-2020", "max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_forks_repo_name": "tomdjong/EPIT-2020", "max_forks_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.2426470588, "max_line_length": 79, "alphanum_fraction": 0.6552677898, "num_tokens": 1261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.926303724190573, "lm_q2_score": 0.8519527963298947, "lm_q1q2_score": 0.7891670480749543}}
{"text": "-- Properties involving susbets and membership\n-- between sets.\n\nmodule sv20.assign2.SetTheory.Subset where\n\nopen import sv20.assign2.SetTheory.Logic\nopen import sv20.assign2.SetTheory.ZAxioms\n\nmemberEq : (x y z : \ud835\udce2) \u2192 x \u2208 y \u2227 y \u2261 z \u2192 x \u2208 z\nmemberEq x y z (x\u2081 , x\u2082) = subs _ x\u2082 x\u2081\n\n-- Theorem 1, p. 21 (Suppes 1960)\nnotInEmpty : \u2200 x \u2192 x \u2209 \u2205\nnotInEmpty x h  = (proj\u2082 _ empt) x h\n\nprop-\u2205 : (x A : \ud835\udce2) \u2192 x \u2208 A \u2192 A \u2262 \u2205\nprop-\u2205 x A x\u2208A h = notInEmpty x (subs _ h x\u2208A)\n\nprop\u2082-\u2205 : (x : \ud835\udce2) \u2192 \u2203 (\u03bb y \u2192 y \u2208 x) \u2192 x \u2262 \u2205\nprop\u2082-\u2205 x h\u2081 h\u2082 = cont _ (h\u2082 , prop-\u2205 _ _ aux-p)\n  where\n  aux : \ud835\udce2\n  aux = proj\u2081 h\u2081\n\n  aux-p : aux \u2208 x\n  aux-p = proj\u2082 _ h\u2081\n\n-- Theorem 3, p. 22 (Suppes 1960)\nsubsetOfItself : \u2200 {x} \u2192 x \u2286 x\nsubsetOfItself _ t\u2208x = t\u2208x\n\n-- Theorem 4, p. 22 (Suppes 1960)\nequalitySubset :  (x y : \ud835\udce2) \u2192 x \u2286 y \u2227 y \u2286 x \u2192 x \u2261 y\nequalitySubset x y (x\u2286y , y\u2286x) = ext x y ((x\u2286y x) , (y\u2286x x))\n\n-- Theorem 6, p. 23 (Suppes 1960)\ntrans-\u2286 : (x y z : \ud835\udce2) \u2192 x \u2286 y \u2227 y \u2286 z \u2192 x \u2286 z\ntrans-\u2286 x y z (x\u2286y , y\u2286z) t t\u2208x = y\u2286z t (x\u2286y t t\u2208x)\n\n-- Theorem 7, p. 23 (Suppes 1960)\nnotContainedInItself : \u2200 {x} \u2192 \u00ac (x \u2282 x)\nnotContainedInItself (_ , x\u2262x) = x\u2262x refl\n\n-- Theorem 8, p. 23 (Suppes 1960)\nnonSymmetry-\u2282 : (x y : \ud835\udce2) (p : x \u2282 y) \u2192 \u00ac (y \u2282 x)\nnonSymmetry-\u2282 x y (x\u2286y , x\u2262y) (y\u2286x , _) = x\u2262y (equalitySubset x y (x\u2286y , y\u2286x))\n\n-- Theorem 10, p. 23 (Suppes 1960)\n\u2282\u2192\u2286 : \u2200 {x y} \u2192 x \u2282 y \u2192 x \u2286 y\n\u2282\u2192\u2286 (x\u2286y , _) z z\u2208x = x\u2286y z z\u2208x\n\nprop-\u2286 : (x A B : \ud835\udce2) \u2192 x \u2208 A \u2192 A \u2286 B \u2192 x \u2208 B\nprop-\u2286 x A B x\u2081 x\u2082 = i x\u2081\n  where\n  i : x \u2208 A \u2192 x \u2208 B\n  i = x\u2082 _\n\n-- References\n--\n-- Suppes, Patrick (1960). Axiomatic Set Theory.\n-- The University Series in Undergraduate Mathematics.\n-- D. Van Nostrand Company, inc.\n--\n-- Enderton, Herbert B. (1977). Elements of Set Theory.\n-- Academic Press Inc.\n\n", "meta": {"hexsha": "9f558b292a09ce04aea3eff87a9268c11125288b", "size": 1733, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Subset.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8656716418, "max_line_length": 78, "alphanum_fraction": 0.5585689556, "num_tokens": 858, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297834483234, "lm_q2_score": 0.8757869900269366, "lm_q1q2_score": 0.7886722684758162}}
{"text": "------------------------------------------------------------------------------\n-- Group theory properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule GroupTheory.PropertiesATP where\n\nopen import GroupTheory.Base\n\n------------------------------------------------------------------------------\n\npostulate leftCancellation : \u2200 {a b c} \u2192 a \u00b7 b \u2261 a \u00b7 c \u2192 b \u2261 c\n{-# ATP prove leftCancellation #-}\n\npostulate rightIdentity : \u2200 a \u2192 a \u00b7 \u03b5 \u2261 a\n{-# ATP prove rightIdentity #-}\n\npostulate rightInverse : \u2200 a \u2192 a \u00b7 a \u207b\u00b9 \u2261 \u03b5\n{-# ATP prove rightInverse #-}\n\npostulate rightCancellation : \u2200 {a b c} \u2192 b \u00b7 a \u2261 c \u00b7 a \u2192 b \u2261 c\n{-# ATP prove rightCancellation #-}\n\npostulate y\u2261x\u207b\u00b9[xy] : \u2200 a b \u2192 b \u2261 a \u207b\u00b9 \u00b7 (a \u00b7 b)\n{-# ATP prove y\u2261x\u207b\u00b9[xy] #-}\n\npostulate x\u2261[xy]y\u207b\u00b9 : \u2200 a b \u2192 a \u2261 (a \u00b7 b) \u00b7 b \u207b\u00b9\n{-# ATP prove x\u2261[xy]y\u207b\u00b9 #-}\n\npostulate rightIdentityUnique : \u2200 r \u2192 (\u2200 a \u2192 a \u00b7 r \u2261 a) \u2192 r \u2261 \u03b5\n{-# ATP prove rightIdentityUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate rightIdentityUnique' : \u2200 a r \u2192 a \u00b7 r \u2261 a \u2192 r \u2261 \u03b5\n{-# ATP prove rightIdentityUnique' #-}\n\npostulate leftIdentityUnique : \u2200 l \u2192 (\u2200 a \u2192 l \u00b7 a \u2261 a) \u2192 l \u2261 \u03b5\n{-# ATP prove leftIdentityUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate leftIdentityUnique' : \u2200 a l \u2192 l \u00b7 a \u2261 a \u2192 l \u2261 \u03b5\n{-# ATP prove leftIdentityUnique' #-}\n\npostulate\n  rightInverseUnique : \u2200 {a} \u2192 \u2203[ r ] (a \u00b7 r \u2261 \u03b5) \u2227 (\u2200 r' \u2192 a \u00b7 r' \u2261 \u03b5 \u2192 r \u2261 r')\n{-# ATP prove rightInverseUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate rightInverseUnique' : \u2200 {a r} \u2192 a \u00b7 r \u2261 \u03b5 \u2192 a \u207b\u00b9 \u2261 r\n{-# ATP prove rightInverseUnique' #-}\n\npostulate\n  leftInverseUnique : \u2200 {a} \u2192 \u2203[ l ] (l \u00b7 a \u2261 \u03b5) \u2227 (\u2200 l' \u2192 l' \u00b7 a \u2261 \u03b5 \u2192 l \u2261 l')\n{-# ATP prove leftInverseUnique #-}\n\n-- A more appropiate version to be used in the proofs.\npostulate leftInverseUnique' : \u2200 {a l} \u2192 l \u00b7 a \u2261 \u03b5 \u2192 a \u207b\u00b9 \u2261 l\n{-# ATP prove leftInverseUnique' #-}\n\npostulate \u207b\u00b9-involutive : \u2200 a \u2192 a \u207b\u00b9 \u207b\u00b9 \u2261 a\n{-# ATP prove \u207b\u00b9-involutive #-}\n\npostulate identityInverse : \u03b5 \u207b\u00b9 \u2261 \u03b5\n{-# ATP prove identityInverse #-}\n\npostulate inverseDistributive : \u2200 a b \u2192 (a \u00b7 b) \u207b\u00b9 \u2261 b \u207b\u00b9 \u00b7 a \u207b\u00b9\n{-# ATP prove inverseDistributive #-}\n\n-- The equation xa = b has an unique solution.\npostulate\n  xa\u2261b-uniqueSolution : \u2200 a b \u2192 \u2203[ x ] (x \u00b7 a \u2261 b) \u2227 (\u2200 x' \u2192 x' \u00b7 a \u2261 b \u2192 x \u2261 x')\n{-# ATP prove xa\u2261b-uniqueSolution #-}\n\n-- The equation ax = b has an unique solution.\npostulate\n  ax\u2261b-uniqueSolution : \u2200 a b \u2192 \u2203[ x ] (a \u00b7 x \u2261 b) \u2227 (\u2200 x' \u2192 a \u00b7 x' \u2261 b \u2192 x \u2261 x')\n{-# ATP prove ax\u2261b-uniqueSolution #-}\n\n-- If the square of every element is the identity, the system is\n-- commutative. From: TPTP 6.4.0 problem GRP/GRP001-2.p.\npostulate x\u00b2\u2261\u03b5\u2192comm : (\u2200 a \u2192 a \u00b7 a \u2261 \u03b5) \u2192 \u2200 {b c d} \u2192 b \u00b7 c \u2261 d \u2192 c \u00b7 b \u2261 d\n{-# ATP prove x\u00b2\u2261\u03b5\u2192comm #-}\n", "meta": {"hexsha": "a1b0b94f2c188784bd9bea34c7e109c38f49d218", "size": 2929, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/PropertiesATP.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/GroupTheory/PropertiesATP.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/GroupTheory/PropertiesATP.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 33.6666666667, "max_line_length": 81, "alphanum_fraction": 0.5384090133, "num_tokens": 941, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248191350352, "lm_q2_score": 0.83973396967765, "lm_q1q2_score": 0.7885310389981004}}
{"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\n\nmodule Numbers.Naturals.Addition where\n\ninfix 15 _+N_\n_+N_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero +N y = y\nsucc x +N y = succ (x +N y)\n{-# BUILTIN NATPLUS _+N_ #-}\n\naddZeroRight : (x : \u2115) \u2192 (x +N zero) \u2261 x\naddZeroRight zero = refl\naddZeroRight (succ x) rewrite addZeroRight x = refl\n\nprivate\n  succExtracts : (x y : \u2115) \u2192 (x +N succ y) \u2261 (succ (x +N y))\n  succExtracts zero y = refl\n  succExtracts (succ x) y = applyEquality succ (succExtracts x y)\n\nsuccCanMove : (x y : \u2115) \u2192 (x +N succ y) \u2261 (succ x +N y)\nsuccCanMove x y = transitivity (succExtracts x y) refl\n\nadditionNIsCommutative : (x y : \u2115) \u2192 (x +N y) \u2261 (y +N x)\nadditionNIsCommutative zero y = equalityCommutative (addZeroRight y)\nadditionNIsCommutative (succ x) zero = transitivity (addZeroRight (succ x)) refl\nadditionNIsCommutative (succ x) (succ y) = transitivity refl (applyEquality succ (transitivity (succCanMove x y) (additionNIsCommutative (succ x) y)))\n\naddingPreservesEqualityRight : {a b : \u2115} (c : \u2115) \u2192 (a \u2261 b) \u2192 (a +N c \u2261 b +N c)\naddingPreservesEqualityRight {a} {b} c pr = applyEquality (\u03bb n -> n +N c) pr\naddingPreservesEqualityLeft : {a b : \u2115} (c : \u2115) \u2192 (a \u2261 b) \u2192 (c +N a \u2261 c +N b)\naddingPreservesEqualityLeft {a} {b} c pr = applyEquality (\u03bb n -> c +N n) pr\n\nadditionNIsAssociative : (a b c : \u2115) \u2192 ((a +N b) +N c) \u2261 (a +N (b +N c))\nadditionNIsAssociative zero b c = refl\nadditionNIsAssociative (succ a) zero c = transitivity (transitivity (applyEquality (\u03bb n \u2192 n +N c) (applyEquality succ (addZeroRight a))) refl) (transitivity refl refl)\nadditionNIsAssociative (succ a) (succ b) c = transitivity refl (transitivity refl (transitivity (applyEquality succ (additionNIsAssociative a (succ b) c)) refl))\n\nsuccIsAddOne : (a : \u2115) \u2192 succ a \u2261 a +N succ zero\nsuccIsAddOne a = equalityCommutative (transitivity (additionNIsCommutative a (succ zero)) refl)\n\ncanSubtractFromEqualityRight : {a b c : \u2115} \u2192 (a +N b \u2261 c +N b) \u2192 a \u2261 c\ncanSubtractFromEqualityRight {a} {zero} {c} pr = transitivity (equalityCommutative (addZeroRight a)) (transitivity pr (addZeroRight c))\ncanSubtractFromEqualityRight {a} {succ b} {c} pr rewrite additionNIsCommutative a (succ b) | additionNIsCommutative c (succ b) | additionNIsCommutative b a | additionNIsCommutative b c = canSubtractFromEqualityRight {a} {b} {c} (succInjective pr)\n\ncanSubtractFromEqualityLeft : {a b c : \u2115} \u2192 (a +N b \u2261 a +N c) \u2192 b \u2261 c\ncanSubtractFromEqualityLeft {a} {b} {c} pr rewrite additionNIsCommutative a b | additionNIsCommutative a c = canSubtractFromEqualityRight {b} {a} {c} pr\n", "meta": {"hexsha": "f892dbcfab15c9dc18dcc760328dc51d4dd72ce0", "size": 2597, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Naturals/Addition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Naturals/Addition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Naturals/Addition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 51.94, "max_line_length": 246, "alphanum_fraction": 0.7035040431, "num_tokens": 911, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750400464604, "lm_q2_score": 0.8267118004748677, "lm_q1q2_score": 0.7880837247045609}}
{"text": "module examplesPaperJFP.finn where\n\nopen import Data.Nat\n\ndata Fin : \u2115 \u2192 Set where\n  zero : {n : \u2115} \u2192 Fin (suc n)\n  suc  : {n : \u2115} (i : Fin n) \u2192 Fin (suc n)\n\nmutual\n  data Even : \u2115 \u2192 Set where\n    0p    : Even 0\n    sucp  : {n : \u2115}  \u2192  Odd n   \u2192  Even  (suc  n)\n\n  data Odd : \u2115 \u2192 Set where\n    sucp  : {n : \u2115}  \u2192  Even n  \u2192  Odd   (suc  n)\n", "meta": {"hexsha": "5e0a4e41e59fa5d3c777f979ec98aa3c1a310a4f", "size": 340, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/examplesPaperJFP/finn.agda", "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_issues_repo_path": "examples/examplesPaperJFP/finn.agda", "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/examplesPaperJFP/finn.agda", "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "avg_line_length": 21.25, "max_line_length": 49, "alphanum_fraction": 0.5176470588, "num_tokens": 143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9664104924150546, "lm_q2_score": 0.8152324938410784, "lm_q1q2_score": 0.7878492358057095}}
{"text": "module Naturals where\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_ ; refl ; cong )\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e )\n\ndata \u2115 : Set where\n  zero : \u2115 \n  suc : \u2115 \u2192 \u2115\n{-# BUILTIN NATURAL \u2115 #-}\n\ninfixl 6 _+_\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + x = x\n(suc a) + x = suc (a + x)\n\n-- Exercise: Write the reasoning chain of 3 + 4\n_ : 3 + 4 \u2261 7\n_ = \n  begin\n    3 + 4\n  \u2261\u27e8\u27e9\n    suc (2 + 4)\n  \u2261\u27e8\u27e9\n    suc (suc (1 + 4))\n  \u2261\u27e8\u27e9\n    suc (suc (suc (0 + 4)))\n  \u2261\u27e8\u27e9\n    suc (suc (suc 4))\n  \u2261\u27e8\u27e9\n    7\n  \u220e\n\ninfixl 7 _*_\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero * y = zero\nsuc x * y = y + (x * y)\n\n_ : 3 * 4 \u2261 12\n_ =\n  begin\n    3 * 4\n  \u2261\u27e8\u27e9\n    4 + (2 * 4)\n  \u2261\u27e8\u27e9\n    4 + (4 + (1 * 4))\n  \u2261\u27e8\u27e9\n    4 + (4 + (4 + (0 * 4)))\n  \u2261\u27e8\u27e9\n    4 + (4 + (4 + (0 * 4)))\n  \u2261\u27e8\u27e9\n    4 + (4 + (4 + 0))\n  \u2261\u27e8\u27e9\n    12\n  \u220e\n\n_^_ : \u2115 \u2192 \u2115 \u2192 \u2115\nx ^ zero = 1\nx ^ suc y = x * (x ^ y)\n\n-- Kinda like minus, but not exactly\ninfixl 6 _monus_\n_monus_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero monus y = zero\nsuc x monus zero = suc x\nsuc x monus suc y = x monus y\n\n_ : 5 monus 3 \u2261 2\n_ =\n  begin\n    5 monus 3\n  \u2261\u27e8\u27e9\n    4 monus 2\n  \u2261\u27e8\u27e9\n    3 monus 1\n  \u2261\u27e8\u27e9\n    2 monus 0\n  \u2261\u27e8\u27e9\n    2\n  \u220e\n\n_ : 3 monus 5 \u2261 0\n_ =\n  begin\n    2 monus 4\n  \u2261\u27e8\u27e9\n    1 monus 3\n  \u2261\u27e8\u27e9\n    0 monus 2\n  \u2261\u27e8\u27e9\n    0    \n  \u220e\n\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n{-# BUILTIN NATMINUS _monus_ #-}\n\ndata Bin : Set where\n  -- Empty bitstring\n  \u27e8\u27e9 : Bin\n  -- Append a zero\n  _O : Bin \u2192 Bin\n  -- Append a one\n  _I : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc \u27e8\u27e9 = \u27e8\u27e9 I\ninc (b O) = b I\ninc (b I) = (inc b) O\n\nto : \u2115 \u2192 Bin\nto zero = \u27e8\u27e9 O\nto (suc n) = inc (to n)\n\nfrom : Bin \u2192 \u2115\nfrom \u27e8\u27e9 = zero\nfrom (b O) = from b * 2\nfrom (b I) = from b * 2 + 1\n\n-- I tried to prove these things doing some basic stuff but sadly got nowhere\n-- I probably should just read the next chapter! (lol)\n--multCommutes : (a : \u2115) \u2192 (b : \u2115) \u2192 a * b \u2261 b * a\n--multCommutes zero zero = refl\n--multCommutes zero (suc b) = multCommutes zero b\n--multCommutes (suc a) zero = multCommutes a zero\n--multCommutes (suc a) (suc b) = {! cong (multCommutes a b) !}\n\n--multIsAssociative : (a : \u2115) \u2192 (b : \u2115) \u2192 (c : \u2115) \u2192 (a * b) * c \u2261 a * (b * c)\n--multIsAssociative zero b c = refl\n--multIsAssociative (suc a) zero c = refl\n--multIsAssociative (suc a) (suc b) zero = refl\n--multIsAssociative (suc a) (suc b) (suc c) = {! multIsAssociative a b c  !}\n\n", "meta": {"hexsha": "3a38d0b8aee32e452ebdce7ddc3a38b821096d38", "size": 2295, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Naturals.agda", "max_stars_repo_name": "GustavoMF31/upgraded-happiness", "max_stars_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Naturals.agda", "max_issues_repo_name": "GustavoMF31/upgraded-happiness", "max_issues_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Naturals.agda", "max_forks_repo_name": "GustavoMF31/upgraded-happiness", "max_forks_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.2556390977, "max_line_length": 77, "alphanum_fraction": 0.5128540305, "num_tokens": 1073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9553191335436404, "lm_q2_score": 0.824461932846258, "lm_q1q2_score": 0.7876242593264022}}
{"text": "module _<?_ where\n\nopen import Data.Nat using (\u2115; zero; suc)\nopen import Relation.Nullary using (\u00ac_)\nopen import decidable using (Dec; yes; no)\n\n-- \u53b3\u5bc6\u306a\u4e0d\u7b49\u5f0f (strict inequality)\ninfix 4 _<_\ndata _<_ : \u2115 \u2192 \u2115 \u2192 Set where\n  z<s : \u2200 {n : \u2115}\n      ------------\n    \u2192 zero < suc n\n\n  s<s : \u2200 {m n : \u2115}\n    \u2192 m < n\n      -------------\n    \u2192 suc m < suc n\n\n-- 0\u672a\u6e80\u306e\u81ea\u7136\u6570\u306f\u5b58\u5728\u3057\u306a\u3044\n\u00acm<z : \u2200 {m : \u2115} \u2192 \u00ac (m < zero)\n\u00acm<z ()\n\n-- m < n \u304c\u6210\u308a\u7acb\u305f\u306a\u3051\u308c\u3070 (m + 1) < (n + 1) \u3082\u6210\u308a\u7acb\u305f\u306a\u3044\n\u00acs<s : \u2200 {m n : \u2115} \u2192 \u00ac (m < n) \u2192 \u00ac (suc m < suc n)\n\u00acs<s \u00acm<n (s<s m<n) = \u00acm<n m<n\n\n-- decidable\u3092\u4f7f\u3063\u305f\u53b3\u5bc6\u306a\u4e0d\u7b49\u5f0f\n_<?_ : \u2200 (m n : \u2115) \u2192 Dec (m < n)\nm     <? zero                = no \u00acm<z\nzero  <? suc n               = yes z<s\nsuc m <? suc n with m <? n\n...               | yes m<n  = yes (s<s m<n)\n...               | no  \u00acm<n = no (\u00acs<s \u00acm<n)\n", "meta": {"hexsha": "a5cad5be969d29d74bad18bc80baa322baf02350", "size": 784, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/decidable/_<?_.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/decidable/_<?_.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/decidable/_<?_.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0588235294, "max_line_length": 50, "alphanum_fraction": 0.4323979592, "num_tokens": 341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9525741214369554, "lm_q2_score": 0.826711791935942, "lm_q1q2_score": 0.787504258884951}}
{"text": "module 050-group where\n\n-- We need monoids.\n\nopen import 040-monoid\n\n-- A group is a monoid where every element has an inverse. This is\n-- equivalent to saying that we have a function mapping every element\n-- to an inverse of that element: this function is called \"invert\"\n-- below.\n\nrecord Group\n  {M : Set}\n  (_==_ : M -> M -> Set)\n  (_*_ : M -> M -> M)\n  (id : M)\n  (invert : M -> M)\n  : Set1 where\n  field\n    monoid : Monoid _==_ _*_ id\n    icong : \u2200 {r s} -> (r == s) -> (invert r) == (invert s)\n    r*ir==id : \u2200 {r} -> (r * (invert r)) == id\n    ir*r==id : \u2200 {r} -> ((invert r) * r) == id\n\n  open Monoid monoid public\n\n  -- Trivial but useful equalities.\n  id==r*ir : \u2200 {r} -> id == (r * (invert r))\n  id==r*ir = symm r*ir==id\n  id==ir*r : \u2200 {r} -> id == ((invert r) * r)\n  id==ir*r = symm ir*r==id\n\n  -- Double inverse gets back original.\n  iir==r : \u2200 {r} -> (invert (invert r)) == r\n  iir==r {r} = trans3 iir==r*ir*iir r*ir*iir==r*id r*id==r\n    where iir==r*ir*iir :\n            (invert (invert r)) == (r * ((invert r) * (invert (invert r))))\n          iir==r*ir*iir = trans3 r==id*r (cong id==r*ir refl) assoc\n          -- assoc {r} {ir} {iir} : (r * ir) * iir == r * (ir * iir)\n          -- id==r*ir             : id == r * ir\n          -- cong % (refl {iir})  : id * iir == (r * ir) * iir \n          -- id*r==r {iir}        : iir == id * iir \n          -- trans3 % %% %%%%     : iir == r * (ir * iir)\n          r*ir*iir==r*id : (r * ((invert r) * (invert (invert r)))) == (r * id)\n          r*ir*iir==r*id = cong refl r*ir==id\n\n  -- Uniqueness of (left and right) inverse.\n  irleftunique : \u2200 {r} -> \u2200 {s} -> (s * r) == id -> s == (invert r)\n  irleftunique {r} {s} s*r==id = trans (symm s*r*ir==s) (s*r*ir==ir)\n    where s*r*ir==ir : ((s * r) * (invert r)) == (invert r)\n          s*r*ir==ir = trans (cong s*r==id refl) id*r==r\n          s*r*ir==s : ((s * r) * (invert r)) == s\n          s*r*ir==s = trans3 assoc (cong refl r*ir==id) r*id==r\n  irrightunique : \u2200 {r} -> \u2200 {s} -> (r * s) == id -> s == (invert r)\n  irrightunique {r} {s} r*s==id = trans (symm ir*r*s==s) (ir*r*s==ir)\n    where ir*r*s==ir : ((invert r) * (r * s)) == (invert r)\n          ir*r*s==ir = trans (cong refl r*s==id) r*id==r\n          ir*r*s==s : ((invert r) * (r * s)) == s\n          ir*r*s==s = trans3 (symm assoc) (cong ir*r==id refl) id*r==r\n", "meta": {"hexsha": "0a3a413faca02b54677ec1754d3fed592e98a988", "size": 2331, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "050-group.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "050-group.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "050-group.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.85, "max_line_length": 79, "alphanum_fraction": 0.4804804805, "num_tokens": 900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9449947086083138, "lm_q2_score": 0.8333245911726382, "lm_q1q2_score": 0.7874873292113295}}
{"text": "-- {-# OPTIONS -v tc.size:100 #-}\n\nmodule SizedTypesMergeSort where\n\nopen import Common.Size\nopen import Common.Prelude using (Bool; true; false; if_then_else_)\nopen import Common.Product\n\nmodule Old where\n\n  -- sized lists\n\n  data List (A : Set) : {_ : Size} -> Set where\n    []   : {size : Size} -> List A {\u2191 size}\n    _::_ : {size : Size} -> A -> List A {size} -> List A {\u2191 size}\n\n  -- CPS split (non-size increasing)\n\n  split : {A : Set}{i : Size} -> List A {i} ->\n          {C : Set} -> (List A {i} -> List A {i} -> C) -> C\n  split []        k = k [] []\n  split (x :: xs) k = split xs (\\ l r -> k (x :: r) l)\n\n\n  module Sort (A : Set) (compare : A -> A -> {B : Set} -> B -> B -> B) where\n\n    -- Andreas, 4 Sep 2008\n    -- the size indices i and j should not be necessary here\n    -- but without them, the termination checker does not recognise that\n    -- the pattern x :: xs is equal to the term x :: xs\n    -- I suspect that _::_ {\u221e} x xs is not equal to itself since \u221e is a term\n    -- not a constructor or variable\n    merge : {i j : Size} -> List A {i} -> List A {j} -> List A\n    merge [] ys = ys\n    merge xs [] = xs\n    merge (x :: xs) (y :: ys) =\n      compare x y (x :: merge xs (y :: ys))\n                  (y :: merge (x :: xs) ys)\n\n    sort : {i : Size} -> List A {i} -> List A\n    sort [] = []\n    sort (x :: []) = x :: []\n    sort (x :: (y :: xs)) = split xs (\\ l r -> merge (sort (x :: l))\n                                                     (sort (y :: r)))\n\nmodule New where\n\n  -- sized lists\n\n  data List A {i} : Set where\n    []   : List A\n    _::_ : {i' : Size< i} \u2192 A \u2192 List A {i'} \u2192 List A\n\n  module CPS where\n\n    -- CPS split (non-size increasing)\n\n    split : \u2200 {A i} \u2192 List A {i} \u2192\n            {C : Set} \u2192 (List A {i} \u2192 List A {i} \u2192 C) \u2192 C\n    split []        k = k [] []\n    split (x :: xs) k = split xs (\\ l r \u2192 k (x :: r) l)\n\n\n    module Sort (A : Set) (compare : A \u2192 A \u2192 {B : Set} \u2192 B \u2192 B \u2192 B) where\n\n      merge : List A \u2192 List A \u2192 List A\n      merge [] ys = ys\n      merge xs [] = xs\n      merge (x :: xs) (y :: ys) =\n        compare x y (x :: merge xs (y :: ys))\n                    (y :: merge (x :: xs) ys)\n\n      sort : {i : Size} \u2192 List A {i} \u2192 List A\n      sort []               = []\n      sort (x :: [])        = x :: []\n      sort (x :: (y :: xs)) = split xs (\\ l r \u2192 merge (sort (x :: l))\n                                                      (sort (y :: r)))\n\n  module Direct where\n\n    split : \u2200 {A i} \u2192 List A {i} \u2192 List A {i} \u00d7 List A {i}\n    split []        = [] , []\n    split (x :: xs) = let l , r = split xs in (x :: r) , l\n\n\n    module Sort (A : Set) (_\u2264_ : A \u2192 A \u2192 Bool) where\n\n      merge : List A \u2192 List A \u2192 List A\n      merge [] ys = ys\n      merge xs [] = xs\n      merge (x :: xs) (y :: ys) =\n        if x \u2264 y then (x :: merge xs (y :: ys))\n                 else (y :: merge (x :: xs) ys)\n\n      sort : {i : Size} \u2192 List A {i} \u2192 List A\n      sort []               = []\n      sort (x :: [])        = x :: []\n      sort (x :: (y :: xs)) = let l , r = split xs in merge (sort (x :: l))\n                                                            (sort (y :: r))\n", "meta": {"hexsha": "1f9a904db5df2a1d8b6c5f0c63cb912de1e089f4", "size": 3122, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/SizedTypesMergeSort.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/SizedTypesMergeSort.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/SizedTypesMergeSort.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 31.22, "max_line_length": 76, "alphanum_fraction": 0.4263292761, "num_tokens": 979, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213664574069, "lm_q2_score": 0.8757869851639066, "lm_q1q2_score": 0.7874387908261845}}
{"text": "\n-- There was a bug which caused the type checker to forget\n-- the name of implicit arguments which weren't used in the\n-- return type.\nmodule UnusedNamedImplicits where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\n-- Simple example\nf : {n m : Nat} -> Nat\nf {m = m} = m\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n  refl : x == x\n\ndata Even : Nat -> Set where\n  evenZ  : Even zero\n  evenSS : {n : Nat} -> Even n -> Even (suc (suc n))\n\nindex : {n : Nat} -> Even n -> Nat\nindex  evenZ     = zero\nindex (evenSS e) = suc (suc (index e))\n\nsameIndex : {n : Nat}(e : Even n) -> index e == n\nsameIndex evenZ = refl \nsameIndex (evenSS e) with index e | sameIndex e\n... | ._ | refl = refl\n\n-- It could also show up when the argument is used in the top level type,\n-- but not by the generated type for the with function.\n* : {n : Nat}{e : Even n} -> Even (index e)\n* {e = e} with index e | sameIndex e\n... | ._ | refl = e\n\n", "meta": {"hexsha": "75d512df6743360b06b7d78742ee77eb09d545fc", "size": 924, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/UnusedNamedImplicits.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_issues_repo_path": "test/succeed/UnusedNamedImplicits.agda", "max_issues_repo_name": "dagit/agda", "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/UnusedNamedImplicits.agda", "max_forks_repo_name": "dagit/agda", "max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.972972973, "max_line_length": 73, "alphanum_fraction": 0.6093073593, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418241572634, "lm_q2_score": 0.8519528076067262, "lm_q1q2_score": 0.787325221717582}}
{"text": "open import Relation.Binary.Core\n\nmodule InsertSort.Impl2.Correctness.Permutation.Base {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_) where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _\u2264_\nopen import Data.List\nopen import Data.Sum\nopen import InsertSort.Impl2 _\u2264_ tot\u2264\nopen import List.Permutation.Base A\nopen import OList _\u2264_\n\nlemma-forget-insert : {b : Bound} \u2192 (x : A) \u2192 (b\u2264x : LeB b (val x)) \u2192 (xs : OList b) \u2192 forget (insert b\u2264x xs) / x \u27f6 forget xs\nlemma-forget-insert x b\u2264x onil = /head\nlemma-forget-insert x b\u2264x (:< {x = y} b\u2264y ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = /head\n... | inj\u2082 y\u2264x = /tail (lemma-forget-insert x (lexy y\u2264x) ys)\n\ntheorem-insertSort\u223c : (xs : List A) \u2192 xs \u223c forget (insertSort xs)\ntheorem-insertSort\u223c [] = \u223c[]\ntheorem-insertSort\u223c (x \u2237 xs) = \u223cx /head (lemma-forget-insert x lebx (insertSort xs)) (theorem-insertSort\u223c xs)\n", "meta": {"hexsha": "1e6220ecb2344163c905f2b03863fddd78699e5e", "size": 899, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/InsertSort/Impl2/Correctness/Permutation/Base.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/InsertSort/Impl2/Correctness/Permutation/Base.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/InsertSort/Impl2/Correctness/Permutation/Base.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.96, "max_line_length": 125, "alphanum_fraction": 0.6418242492, "num_tokens": 318, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9496693702514737, "lm_q2_score": 0.8289388040954683, "lm_q1q2_score": 0.7872177920623531}}
{"text": "{-# OPTIONS --cubical #-}\nmodule SolutionsSession1 where\n\nopen import Part1 hiding (B)\n\nvariable\n  B : A \u2192 Type \u2113\n\n-- Solutions to ExerciseSession1\n\n-- Exercise 1:\nfunExtDep : {f g : (x : A) \u2192 B x}\n          \u2192 ((x : A) \u2192 f x \u2261 g x)\n          \u2192 f \u2261 g\nfunExtDep p i x = p x i\n\n-- Exercise 2:\ncongP : {x y : A} {B : A \u2192 Type \u2113'}\n        (f : (a : A) \u2192 B a) (p : x \u2261 y) \u2192\n        PathP (\u03bb i \u2192 B (p i)) (f x) (f y)\ncongP f p i = f (p i)\n\n-- Exercise 3:\nisContrInhProp : isProp A \u2192 A \u2192 isContr A\nisContrInhProp p x = x , p x\n\n\n-- We could have stated isProp as follows:\nisProp' : Type \u2113 \u2192 Type \u2113\nisProp' A = (x y : A) \u2192 isContr (x \u2261 y)\n\n-- Exercise 4:\nisProp'\u2192isProp : isProp' A \u2192 isProp A\nisProp'\u2192isProp h = \u03bb x y \u2192 h x y .fst\n\n-- Exercise 5:\nisProp\u03a0 : (h : (x : A) \u2192 isProp (B x)) \u2192 isProp ((x : A) \u2192 B x)\nisProp\u03a0 h p q i x = h x (p x) (q x) i\n\n-- Exercise 6:\nfunExt\u207b : {f g : (x : A) \u2192 B x} \u2192 f \u2261 g \u2192 ((x : A) \u2192 f x \u2261 g x)\nfunExt\u207b eq x i = eq i x\n\n-- Exercise 7:\nisSet\u03a0 : (h : (x : A) \u2192 isSet (B x)) \u2192 isSet ((x : A) \u2192 B x)\nisSet\u03a0 h f g p q i j x = h x (f x) (g x) (funExt\u207b p x) (funExt\u207b q x) i j\n\n\n-- We could have defined the type of singletons as follows\nsingl' : {A : Type \u2113} (a : A) \u2192 Type \u2113\nsingl' {A = A} a = \u03a3[ x \u2208 A ] x \u2261 a\n\n-- Exercise 8:\nisContrSingl' : (x : A) \u2192 isContr (singl' x)\nisContrSingl' x = ctr , prf\n  where\n  ctr : singl' x\n  ctr = x , refl\n\n  prf : (s : singl' x) \u2192 ctr \u2261 s\n  prf (y , pax) i = (pax (~ i)) , \u03bb j \u2192 pax (~ i \u2228 j)\n", "meta": {"hexsha": "964c6e4e0b22728db2f86ea5d9621872df96fb8b", "size": 1449, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/SolutionsSession1.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 97, "max_stars_repo_stars_event_min_datetime": "2021-03-19T14:13:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T13:58:25.000Z", "max_issues_repo_path": "04-cubical-type-theory/material/SolutionsSession1.agda", "max_issues_repo_name": "williamdemeo/EPIT-2020", "max_issues_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-03-31T18:27:23.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-13T09:03:56.000Z", "max_forks_repo_path": "04-cubical-type-theory/material/SolutionsSession1.agda", "max_forks_repo_name": "williamdemeo/EPIT-2020", "max_forks_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2021-03-19T12:36:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T19:37:21.000Z", "avg_line_length": 23.3709677419, "max_line_length": 72, "alphanum_fraction": 0.5175983437, "num_tokens": 638, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765257642905, "lm_q2_score": 0.8615382058759129, "lm_q1q2_score": 0.7871672347579042}}
{"text": "module z04-lists where\n\nopen import bool\nopen import eq\nopen import nat\nopen import nat-thms\nopen import product-thms using (keep)\nopen import logic -- needed for filter-idem\n\n{-\n-- p 75\n\n'data' : datatype declaration\n'\ud835\udd43'    : name of type being declared\n{\u2113}    : level\nA      : element type (polymorphic)\n\n\ud835\udd43 is a type level function\n- takes a type (bound to 'A') - at level \u2113\n- returns a type - at level same level \u2113\n-}\n\ndata  \ud835\udd43 {\u2113} (A : Set \u2113) : Set \u2113 where\n  []   :                      \ud835\udd43 A\n  _::_ : (x : A) (xs : \ud835\udd43 A) \u2192 \ud835\udd43 A\n\n-- from lists.agda\n\n[_] : \u2200 {\u2113} {A : Set \u2113} \u2192 A \u2192 \ud835\udd43 A\n[ x ] = x :: []\n\n-- p 77\n\nlength : \u2200 {\u2113} {A : Set \u2113 } \u2192 \ud835\udd43 A \u2192 \u2115\nlength       []  = 0\nlength (x :: xs) = suc (length xs)\n\n-- 78\n\n_++_ : \u2200 {\u2113} {A : Set \u2113} \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A\n[]        ++ ys =             ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\n-- 79\n\nmap : \u2200 {\u2113 \u2113'} {A : Set \u2113} {B : Set \u2113'}  \u2192 (A \u2192 B) \u2192 \ud835\udd43 A \u2192 \ud835\udd43 B\nmap f       []  = []\nmap f (x :: xs) = f x :: map f xs\n\n-- 80\n\nfilter : \u2200 {\u2113} {A : Set \u2113} \u2192 (A \u2192 \ud835\udd39) \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A\nfilter p       []  = []\nfilter p (x :: xs) = if p x then x :: r else r\n where\n  r = filter p xs\n\n-- p 81\n\nremove : \u2200 {\u2113} {A : Set \u2113} (eq : A \u2192 A \u2192 \ud835\udd39) (a : A) (l : \ud835\udd43 A) \u2192 \ud835\udd43 A\nremove eq a l = filter (\u03bb x \u2192 ~ (eq a x)) l\n\n-- p 82\n\ndata maybe {\u2113} (A : Set \u2113) : Set \u2113 where\n  just    : A \u2192 maybe A\n  nothing :     maybe A\n\nnth : \u2200 {\u2113} {A : Set \u2113} \u2192 \u2115 \u2192 \ud835\udd43 A \u2192 maybe A\nnth _             []  = nothing\nnth 0       (x :: xs) = just x\nnth (suc n) (x :: xs) = nth n xs\n\n-- p 83\n\n-- inefficient\nsreverse : \u2200 {\u2113} {A : Set \u2113} \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A\nsreverse      []  = []\nsreverse (h :: t) = sreverse t ++ [ h ]\n\nreverse-helper : \u2200 {\u2113}{A : Set \u2113} \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A\nreverse-helper h       []  = h\nreverse-helper h (x :: xs) = reverse-helper (x :: h) xs\n\nreverse : \u2200 {\u2113} {A : Set \u2113} \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A\nreverse l = reverse-helper [] l\n\n------------------------------------------------------------------------------\n-- p 84 Reasong about List Operations\n\nlength-++ : \u2200 {\u2113}{A : Set \u2113} (l1 l2 : \ud835\udd43 A)\n          \u2192 length (l1 ++ l2) \u2261 length l1 + length l2\nlength-++ [] l2 -- length ([] ++ l2) \u2261 length [] + length l2\n                -- length        l2  \u2261             length l2\n  = refl\nlength-++ (x :: xs) l2 --      length ((x :: xs) ++ l2)  \u2261      length (x :: xs) + length l2\n                       -- suc (length       (xs  ++ l2)) \u2261 suc (length       xs  + length l2)\n                       --                 |\n  rewrite              -- IH              \u2261\n                       --                 v\n    length-++ xs l2    -- suc (length  xs +  length l2)  \u2261 suc (length       xs  + length l2)\n  = refl\n\n-- p 86\n\n++-assoc : \u2200 {\u2113} {A : Set \u2113} (l1 l2 l3 : \ud835\udd43 A)\n         \u2192 (l1 ++  l2) ++ l3\n         \u2261  l1 ++ (l2  ++ l3)\n++-assoc [] l2 l3                  -- (([] ++ l2) ++ l3) \u2261 ([] ++ (l2 ++ l3))\n                                   --        (l2  ++ l3) \u2261        (l2 ++ l3)\n  = refl\n++-assoc (x :: xs) l2 l3 -- (((x ::   xs) ++ l2) ++ l3)   \u2261 ((x ::  xs) ++ (l2 ++ l3))\n                         --   (x :: ((xs  ++ l2) ++ l3))  \u2261  (x :: (xs  ++ (l2 ++ l3)))\n  rewrite                -- IH               v\n    ++-assoc xs l2 l3    --   (x ::  (xs ++ (l2  ++ l3))) \u2261  (x :: (xs  ++ (l2 ++ l3)))\n  = refl\n\n{-\n------------------------------------------------------------------------------\n-- p 87 - WITH\n\nfor\n- any type A (of any level),\n- any predicate p on A\n- any list of A\nthe length of the list after filtering l with p\n<=\nlength of l\n-}\n\nlength-filter : \u2200 {\u2113} {A : Set \u2113} (p : A \u2192 \ud835\udd39) (l : \ud835\udd43 A)\n              \u2192 length (filter p l) \u2264 length l \u2261 tt\n\n-- proof case-splits input list\n\nlength-filter p      []         -- length (filter p []) \u2264 length [] \u2261 tt\n                                --                   0  \u2264         0 \u2261 tt\n  = refl\n\n-- Consider cases where predicate returns tt or ff.\n-- The predicate return value is NOT an input to length-filter.\n-- WITH : extend pattern on left side with an additional pattern, here : | tt     and   | ff\n\nlength-filter p (x :: l) with p x\nlength-filter p (x :: l) | tt   --    length (filter p l)  <      length l\n                                -- || length (filter p l) =\u2115      length l  \u2261 tt\n  = length-filter p l           -- IH\nlength-filter p (x :: l) | ff   --    length (filter p l)  < suc (length l)\n  =                             -- || length (filter p l) =\u2115 suc (length l) \u2261 tt\n  \u2264-trans {length (filter p l)}\n          (length-filter p l)   -- IH\n          (\u2264-suc (length l))    -- \u2264-suc proves length l \u2264 suc (length l)\n\n{- this is to see the goal for the non-nil case\nlf : \u2200 {\u2113} {A : Set \u2113} (p : A \u2192 \ud835\udd39) (l : \ud835\udd43 A)\n   \u2192 length (filter p l) \u2264 length l \u2261 tt\nlf p      []  = refl\nlf p (x :: l) -- length                  (filter p (x :: l))                \u2264      length (x :: l) \u2261 tt\n              -- length (if p x then x :: filter p       l else filter p l) \u2264 suc (length       l) \u2261 tt\n  = {!!}\n\n------------------------------------------------------------------------------\n-- p 90 KEEP (called INSPECT in Agda standard library)\n\nfiltering a list twice using same predicate gives the same result as filtering it once\n\ncannot use WITH because Agda only applies the p \u2261 tt to the goal once, not the next iteration\n(see page 92 for more details)\n\n'with keep (p x)' : make additional variable (here p') available\n-}\n\nfilter-idem : \u2200 {\u2113} {A : Set \u2113} (p : A \u2192 \ud835\udd39) (l : \ud835\udd43 A)\n            \u2192 (filter p (filter p l)) \u2261 (filter p l)\nfilter-idem p []            -- filter p (filter p []) \u2261 filter p []\n                            --                    []  \u2261          []\n  = refl\n{-\nfilter-idem p (x :: l)           -- filter p (filter p (x :: l)) \u2261 filter p (x :: l)\n                                 --\n                                 -- filter p (if p x then x :: filter p l else filter p l)\n                                 -- \u2261 if p x then x :: filter p l else filter p l\n  = {!!}\n-}\nfilter-idem p (x :: l) with keep (p x)\n\nfilter-idem p (x :: l) | tt , p' -- filter p (if p x then x :: filter p l else filter p l)\n                                 -- \u2261 if p x then x :: filter p l else filter p l\n\n  rewrite\n    -- agda does not instantiate 'p x' in goal\n    -- must explicit use it below to change 'p x' to 'tt' (or 'ff' further below)\n\n    p'                           -- filter p (if tt then x :: filter p l else filter p l)\n                                 -- \u2261 if tt then x :: filter p l else filter p l\n                                 --\n                                 --   if p x then x :: filter p (filter p l) else filter p (filter p l)\n                                 -- \u2261 (x :: filter p l)\n\n  -- use it again to eliminate the if\n\n  | p'                           --   if tt  then x :: filter p (filter p l) else filter p (filter p l)\n                                 -- \u2261 (x :: filter p l)\n                                 --\n                                 --   (x :: filter p (filter p l)) \u2261 (x :: filter p l)\n\n\n  | filter-idem p l              --   (x :: filter p l) \u2261 (x :: filter p l)\n  = refl\n\nfilter-idem p (x :: l) | ff , p' -- filter p (if p x then x :: filter p l else filter p l)\n                                 -- \u2261 if p x then x :: filter p l else filter p l\n\n  rewrite p'                     -- filter p (if ff then x :: filter p l else filter p l)\n                                 -- \u2261 if ff  then x :: filter p l else filter p l\n                                 --\n                                 -- filter p (filter p l) \u2261 filter p l\n  = filter-idem p l\n\n{-\n------------------------------------------------------------------------------\n-- p 93\n\nreverse-helper args\n- reverse of the list processed so far\n- rest of list to be reversed\n\ntricky to figure out what general property of reverse-helper to prove\n-length of reverse-helper h l is sum of lengths of h and l\n-}\n\nlength-reverse-helper\n  : \u2200 {\u2113} {A : Set \u2113} (h l : \ud835\udd43 A)\n  \u2192 length (reverse-helper h l) \u2261 length h + length l\n\nlength-reverse-helper h []                     -- length (reverse-helper h []) \u2261 length h + length []\n                                               -- length h                     \u2261 length h + 0\n  rewrite\n    +comm (length h) 0                         -- length h                     \u2261 length h\n  -- also can do via\n  -- rewrite +0 (length h) = refl\n  = refl\nlength-reverse-helper h (x :: xs)\n                                               -- length (reverse-helper h (x :: xs)) \u2261 length h + length (x :: xs)\n                                               -- length (reverse-helper (x :: h) xs) \u2261 length h + suc (length xs)\n  rewrite\n    length-reverse-helper (x :: h) xs -- IH    --          suc (length h + length xs) \u2261 length h + suc (length xs)\n  | +suc (length h) (length xs)                --          suc (length h + length xs) \u2261 suc (length h + length xs)\n  = refl\n\nlength-reverse : \u2200 {\u2113} {A : Set \u2113} (l : \ud835\udd43 A)\n               \u2192 length (reverse l) \u2261 length l\nlength-reverse l = length-reverse-helper [] l\n\n{-\n------------------------------------------------------------------------------\n-- p 95  conclusion : WITH     and    KEEP (aka INSPECT)\n\n-- p 96 EXERCISES\n\n-- 1\n-}\n\n-------------------------\n-- NOT TRUE\n-- 1a : \u2200 {\u2113} {A : Set \u2113} (l1 l2 : \ud835\udd43 A) \u2192 l1 ++ l2 \u2261 l2 ++ l1\n\n-------------------------\n-- NOT TRUE\n-- 1b : \u2200 {\u2113 \u2113'} {A : Set \u2113} {B : Set \u2113'} (f : A \u2192 B) (l : \ud835\udd43 A) \u2192 length (map f l) \u2261 suc (length l)\n\n-------------------------\n-- 1c: TRUE\n\nrepeat : \u2200 {\u2113} {A : Set \u2113} \u2192 \u2115 \u2192 A \u2192 \ud835\udd43 A\nrepeat 0 a = []\nrepeat (suc n) a = a :: (repeat n a)\n\n1c : \u2200 {\u2113} {A : Set \u2113} {p : A \u2192 \ud835\udd39} {a : A} (n : \u2115)\n   \u2192 p a \u2261 ff\n   \u2192 filter p (repeat n a) \u2261 []\n1c 0 prop            -- filter p (repeat zero a) \u2261 []\n                     --                       [] \u2261 []\n  = refl\n1c (suc n) prop      -- filter p (repeat (suc n) a) \u2261 []\n                     -- if p a then a :: filter p (repeat n a) else filter p (repeat n a) \u2261 []\n  rewrite\n    prop             -- if ff  then a :: filter p (repeat n a) else filter p (repeat n a) \u2261 []\n                     --                                             filter p (repeat n a) \u2261 []\n  = 1c n prop -- IH\n\n-------------------------\n-- NOT TRUE\n-- 1d : \u2200 {\u2113} {A : Set \u2113} (l : \ud835\udd43 A) \u2192 is-empty l \u2261 tt \u2192 is-empty (reverse l) \u2261 ff\n\n-------------------------\n-- TRUE\n1e : \u2200 {\u2113} {A : Set \u2113} (p : A -> \ud835\udd39) (l1 l2 : \ud835\udd43 A)\n   \u2192 filter p (l1 ++          l2)\n   \u2261 filter p  l1 ++ filter p l2\n1e p       []  l2               -- filter p ([] ++ l2) \u2261 (filter p [] ++ filter p l2)\n                                -- filter p        l2  \u2261  filter p                l2\n  = refl\n1e p (x :: xs) l2 with keep (p x)\n1e p (x :: xs) l2 | tt , p' --     if p x then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n                            -- \u2261 ((if p x then x :: filter p xs else filter p xs) ++ filter p l2)\n  rewrite\n    p'                      --     if tt  then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n                            -- \u2261 ((if tt  then x :: filter p xs else filter p xs) ++ filter p l2)\n                            --\n                            --   (x ::  filter p (xs ++          l2))\n                            -- \u2261 (x :: (filter p  xs ++ filter p l2))\n\n  | 1e p xs l2              --   (x :: (filter p  xs ++ filter p l2))\n                            -- \u2261 (x :: (filter p  xs ++ filter p l2))\n  = refl\n1e p (x :: xs) l2 | ff , p' --     if p x then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n                            -- \u2261 ((if p x then x :: filter p xs else filter p xs) ++ filter p l2)\n  rewrite\n    p'                      --     if ff  then x :: filter p (xs ++ l2) else filter p (xs ++ l2)\n                            -- \u2261 ((if ff  then x :: filter p xs else filter p xs) ++ filter p l2)\n                            --\n                            -- filter p (xs ++ l2) \u2261 (filter p xs ++ filter p l2)\n  = 1e p xs l2              -- IH\n\n--------------------------------------------------\n-- 2\n\n-------------------------\n-- 2a [] : \ud835\udd43 Set  (\ud835\udd43 _A_277)\n\n-------------------------\n2b : \u2200 {\u2113} {A : Set \u2113} \u2192 \ud835\udd43 A \u2192 \u2115\n2b       []  = 0\n2b (x :: xs) = suc (2b xs)\n\n-------------------------\n-- Note: 2ci does not explicitly give \u2113\n-- Note: some other answers are probably OK - did not check\n2c : \u2200 {\u2113} {A : Set \u2113} {B : Set \u2113} {C : Set \u2113}\n   \u2192 (A \u2192 B)\n   \u2192 (B \u2192 C)\n   \u2192 \ud835\udd43 A\n   \u2192 \ud835\udd43 C\n2c f g x = map g (map f x)\n\n--------------------------------------------------\n-- 3\n\ntakeWhile : \u2200 {\u2113} {A : Set \u2113} \u2192 (A \u2192 \ud835\udd39) -> \ud835\udd43 A \u2192 \ud835\udd43 A\ntakeWhile p       []  = []\ntakeWhile p (x :: xs) = if p x then x :: takeWhile p xs else takeWhile p xs\n\n--------------------------------------------------\n-- 4\n\n4twr : \u2200 {\u2113} {A : Set \u2113} {p : A \u2192 \ud835\udd39} {a : A} (n : \u2115)\n     \u2192 p a \u2261 tt\n     \u2192 takeWhile p (repeat n a) \u2261 repeat n a\n4twr  zero p               -- takeWhile p\u2081 (repeat zero a) \u2261 repeat zero a\n                           --                           [] \u2261 []\n  = refl\n4twr {l} {A} {pred} {a} (suc n) p -- takeWhile p\u2081 (repeat (suc n) a) \u2261 repeat (suc n) a\n                                  --   if p\u2081 a then a :: takeWhile p\u2081 (repeat n a) else takeWhile p\u2081 (repeat n a)\n                                  -- \u2261             (a ::               repeat n a)\n  rewrite\n    p                             --   if tt   then a :: takeWhile p\u2081 (repeat n a) else takeWhile p\u2081 (repeat n a)\n                                  -- \u2261             (a ::               repeat n a)\n                                  --               (a :: takeWhile p\u2081 (repeat n a))\n                                  -- \u2261             (a ::               repeat n a)\n  | 4twr {l} {A} {pred} {a} n p   --               (a ::               repeat n a) \u2261 (a :: repeat n a)\n  = refl\n\n--------------------------------------------------\n-- 5\n\ntake    : \u2200 {\u2113} {A : Set \u2113} \u2192 \u2115 \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A\ntake         0         _  = []\ntake         _        []  = []\ntake    (suc n) (x :: xs) = x :: take n xs\n\n--------------------------------------------------\n-- 6\n\nnthTail : \u2200 {\u2113} {A : Set \u2113} \u2192 \u2115 \u2192 \ud835\udd43 A \u2192 \ud835\udd43 A\nnthTail      0        xs  = xs\nnthTail      _        []  = []\nnthTail (suc n) (x :: xs) = nthTail n xs\n{-\n6tn : \u2200 {\u2113} {A : Set \u2113} {a : A} (n : \u2115) (l : \ud835\udd43 A)\n    \u2192 take n l ++ nthTail n l \u2261 l\n6tn  zero   l              -- (take zero l ++ nthTail zero l) \u2261 l\n                           --                             l  \u2261 l\n  = refl\n6tn {\u2113} {A} {a} (suc n) l  -- (take (suc n) l ++ nthTail (suc n) l) \u2261 l\n  rewrite\n    6tn {\u2113} {A} {a} n l\n  = {!!}\n-}\n\n6tn : \u2200 {\u2113} {A : Set \u2113} {a : A} (n : \u2115) (l : \ud835\udd43 A)\n    \u2192 take n l ++ nthTail n l \u2261 l\n6tn               zero        []  --       (take zero      []      ++ nthTail   zero        []) \u2261 []\n                                  --                                                        []  \u2261 []\n  = refl\n6tn             (suc n)       []  --       (take (suc n)       []  ++ nthTail (suc n)       [])  \u2261 []\n                                  --                                                        []   \u2261 []\n  = refl\n6tn               zero  (x :: xs) --       (take   zero  (x :: xs) ++ nthTail   zero  (x :: xs)) \u2261 (x :: xs)\n                                  -- (x :: xs)  \u2261 (x :: xs)\n  = refl\n6tn {\u2113} {A} {a} (suc n) (x :: xs) --       (take (suc n) (x :: xs) ++ nthTail (suc n) (x :: xs)) \u2261 (x :: xs)\n                                  -- (x :: (take      n        xs  ++ nthTail      n        xs)) \u2261 (x :: xs)\n  rewrite\n    6tn {\u2113} {A} {a} n xs          -- (x :: xs)                                                   \u2261 (x :: xs)\n  = refl\n", "meta": {"hexsha": "ff6fb52052a86db45f26d510887608f0182e603c", "size": 15284, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z04-lists.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 36.6522781775, "max_line_length": 115, "alphanum_fraction": 0.3800706621, "num_tokens": 4834, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026595857203, "lm_q2_score": 0.8577680977182186, "lm_q1q2_score": 0.7868329573447059}}
{"text": "{-\n  Copyright 2019 Lisandra Silva\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n-}\n\nopen import Prelude\nopen import Data.Nat.Divisibility\n\nopen import StateMachineModel\n\n\n{-\n  This State Machine begins in a state equal to 0 or 1 and if :\n    - The current state s is Even then jump to state (s + 2)\n    - The current state is Odd jump to state (s + 1)\n\n  We want to prove that a state s always leads-to a state Even\n-}\n\nmodule Examples.SMCounterEven where\n\n  -- DEFINITIONS and proofs about Even and Odd\n  Even : \u2115 \u2192 Set\n  Even n = 2 \u2223 n\n\n  Odd : \u2115 \u2192 Set\n  Odd = \u00ac_ \u2218 Even\n\n  even? : (n : \u2115) \u2192 Dec (Even n)\n  even? n = 2 \u2223? n\n\n  evenK\u21d2even2+K : \u2200 {k} \u2192 Even k \u2192 Even (2 + k)\n  evenK\u21d2even2+K (divides q\u2081 refl) = divides (1 + q\u2081) refl\n\n\n  -- The following are mutually recursive properties.\n  oddK\u21d2even1+K : \u2200 {k} \u2192 Odd k \u2192 Even (suc k)\n  oddK\u21d2evenK-1 : \u2200 {k} \u2192 Odd k \u2192 Even (pred k)\n\n  oddK\u21d2even1+K {zero} x = \u22a5-elim (x (divides 0 refl))\n  oddK\u21d2even1+K {suc k} x = evenK\u21d2even2+K (oddK\u21d2evenK-1 x)\n\n  oddK\u21d2evenK-1 {zero} x = \u22a5-elim (x (divides 0 refl))\n  oddK\u21d2evenK-1 {suc k} x with even? k\n  ...| no imp = \u22a5-elim (x (oddK\u21d2even1+K imp))\n  ...| yes prf = prf\n\n\n  odd1 : Odd 1\n  odd1 (divides zero ())\n  odd1 (divides (suc q\u2081) ())\n\n\n   -----------------------------------------------------------------------------\n   -- SPECIFICATION\n   -----------------------------------------------------------------------------\n\n  data MyEvent : Set where\n    inc  : MyEvent\n    inc2 : MyEvent\n    -- TODO : Try with an event iddle that doesn't do anything and is in another\n    -- EventSet in the weakFairness relation (just to try)\n\n  -- If we are in a state that is odd then the enabled event is inc\n  -- otherwise the enabled event is inc2\n  data MyEnabled : MyEvent \u2192 \u2115 \u2192 Set where\n    odd  : \u2200 {n} \u2192 Odd n  \u2192 MyEnabled inc  n\n    even : \u2200 {n} \u2192 Even n \u2192 MyEnabled inc2 n\n\n  MyStateMachine : StateMachine \u2115 MyEvent\n  MyStateMachine = record\n                   { initial =  (0 \u2261_) \u222a (1 \u2261_)\n                   ; enabled = MyEnabled\n                   ; action  = \u03bb { {pre} {inc}  cond \u2192 1 + pre\n                                 ; {pre} {inc2} cond \u2192 2 + pre }\n                   }\n\n  MyEventSet : EventSet {Event = MyEvent}\n  MyEventSet inc  = \u22a4\n  MyEventSet inc2 = \u22a4\n\n  data MyWeakFairness : EventSet \u2192 Set where\n    wf : MyWeakFairness MyEventSet\n\n  MySystem : System \u2115 MyEvent\n  MySystem = record\n             { stateMachine = MyStateMachine\n             ; weakFairness = MyWeakFairness\n             }\n\n\n\n   -----------------------------------------------------------------------------\n   -- PROOFS\n   -----------------------------------------------------------------------------\n\n  open LeadsTo \u2115 MyEvent MySystem\n\n  -- In every state there is always an enabled transition\n  alwaysEnabled : \u2200 (s : \u2115) \u2192 enabledSet MyStateMachine MyEventSet s\n  alwaysEnabled s with even? s\n  ... | yes p = inc2 , tt , even p\n  ... | no \u00acp = inc  , tt , odd \u00acp\n\n\n  -- Any state n leads to an Even state\n  progressEven : \u2200 {n : \u2115} \u2192 (n \u2261_) l-t Even\n  progressEven = viaEvSet\n                   MyEventSet wf\n                   (\u03bb { inc  \u22a4 \u2192 hoare \u03bb { refl (odd x)  \u2192 oddK\u21d2even1+K  x }\n                      ; inc2 \u22a4 \u2192 hoare \u03bb { refl (even x) \u2192 evenK\u21d2even2+K x } })\n                   (\u03bb { inc  \u22a5 \u2192 \u22a5-elim (\u22a5 tt)\n                      ; inc2 \u22a5 \u2192 \u22a5-elim (\u22a5 tt) })\n                   \u03bb {s} rs n\u2261s \u2192 alwaysEnabled s\n\n\n  -- QUESTION : Although we don't have weakfairness (WF) on event inc it was\n  -- possible to prove this.\n  -- ANSWER : This is because of the 2nd constraint in the viaEvSet constructor:\n  --      - \u2200 event e \u2209 WF (in this case only inc) \u2192 [P] e [P \u222a Q], in this case\n  --   we achieve Q (Even), because the event inc is enabled only in Odd states.\n\n\n  -- REFACTOR: Maybe m is the one that should be explicit\n  myWFR : \u2200 {m} \u2192 \u2115 \u2192 Z \u2192 Set\n  myWFR {m} d s = m \u2261 d + s\n\n\n  -- For every m and even state s, or s is greater than m or there is a distance\n  -- x between s and m\n  [Q\u222aFx] :  \u2200 {m} \u2192 (s : Z) \u2192 Even s\n                       \u2192 (m \u2264 s \u00d7 Even s) \u228e \u2203[ x ] myWFR {m} x s\n  [Q\u222aFx] {m} s sEven with m \u2264? s\n  ... | yes m\u2264s = inj\u2081 (m\u2264s , sEven)\n  ... | no  s<m = inj\u2082 ( m \u2238 s , sym (m\u2238n+n\u2261m (<\u21d2\u2264 (\u2270\u21d2> s<m))) )\n\n\n\n  -- First constraint for WFR rule\n  [P]l-t[Q\u222aFx] : \u2200 {n m}\n                 \u2192 (n \u2261_) l-t ( ((m \u2264_) \u2229 Even) \u222a [\u2203 x \u2236 myWFR {m} x ] )\n  [P]l-t[Q\u222aFx] {n} {m} = viaEvSet\n                           MyEventSet wf\n                           (\u03bb { inc \u22a4\n                                    \u2192 hoare \u03bb { refl (odd x)\n                                      \u2192 [Q\u222aFx] (1 + n) (oddK\u21d2even1+K x) }\n                              ; inc2 \u22a4\n                                    \u2192 hoare \u03bb { refl (even x)\n                                      \u2192 [Q\u222aFx] (2 + n) (evenK\u21d2even2+K x) }})\n                           (\u03bb { inc  \u22a5 \u2192 \u22a5-elim (\u22a5 tt)\n                              ; inc2 \u22a5 \u2192 \u22a5-elim (\u22a5 tt) })\n                           \u03bb {s} rs n\u2261s \u2192 alwaysEnabled s\n\n\n\n  -- If we are at distance 0 from m, which means state s \u2261 m, then it leads-to a\n  -- state s\u2081 > m \u2229 Even s\u2081, because or we increment 1 if s is odd or we\n  -- increment 2 if s is even.\n  d\u22610\u21d2Q : \u2200 {m}\n          \u2192 myWFR {m} 0\n            l-t\n            ( (m \u2264_) \u2229 Even )\n  d\u22610\u21d2Q {m} = viaEvSet\n                MyEventSet wf\n                (\u03bb { inc  \u22a4\n                          \u2192 hoare \u03bb { refl (odd x)\n                           \u2192 m\u2264n+m m 1 , oddK\u21d2even1+K x }\n                   ; inc2 \u22a4\n                          \u2192 hoare \u03bb { refl (even x)\n                            \u2192 m\u2264n+m m 2 , evenK\u21d2even2+K x }})\n                (\u03bb { inc  \u22a5 \u2192 \u22a5-elim (\u22a5 tt)\n                   ; inc2 \u22a5 \u2192 \u22a5-elim (\u22a5 tt) })\n                \u03bb {s} rs F0 \u2192 alwaysEnabled s\n\n\n  -- If we are at distance 1 from m, which means m \u2261 s + 1.\n  -- If s is odd then s is incremented by 1 (because of the enabling\n  -- condition) then we go to an even state s\u2081 \u2261 s + 1 \u2261 m.\n  -- If if s is even then s is incremented by 2, which leads to a state\n  -- s\u2081 \u2261 s + 2 > s + 1 \u2261 m. As so, m \u2264 s\u2081 \u2229 Even s\u2081 will always  hold.\n  d\u22611\u21d2Q\u222ad\u22610 : \u2200 {m}\n              \u2192 myWFR {m} 1\n                l-t\n                ( ((m \u2264_) \u2229 Even) \u222a [\u2203 x \u21d2 _< 1 \u2236 myWFR {m} x ] )\n  d\u22611\u21d2Q\u222ad\u22610 {m} = viaEvSet\n                    MyEventSet wf\n                    (\u03bb { inc  \u22a4\n                          \u2192 hoare \u03bb { {ps} refl (odd x)\n                           \u2192 inj\u2081 (\u2264-refl , oddK\u21d2even1+K x) }\n                       ; inc2 \u22a4\n                         \u2192 hoare \u03bb { {ps} refl (even x)\n                           \u2192 inj\u2081 (m\u2264n+m (suc ps) 1 , evenK\u21d2even2+K x) }})\n                    (\u03bb { inc  \u22a5 \u2192 \u22a5-elim (\u22a5 tt)\n                       ; inc2 \u22a5 \u2192 \u22a5-elim (\u22a5 tt) })\n                    \u03bb {s} rs F1 \u2192 alwaysEnabled s\n\n\n  -- Auxiliary properties\n  assoc\u2218comm : \u2200 {w s : \u2115} n \u2192 n + w + s \u2261 w + (n + s)\n  assoc\u2218comm {w} {s} n = trans (cong (_+ s) (+-comm n w)) (+-assoc w n s)\n\n  assoc\u2218assoc : \u2200 {w s : \u2115} n p \u2192 (n + p) + w + s \u2261 n + w + (p + s)\n  assoc\u2218assoc {w} {s} n p\n    rewrite +-assoc n p w\n          | +-comm p w\n          | +-assoc n (w + p) s\n          | +-assoc w p s\n          | +-assoc n w (p + s) = refl\n\n\n  -- If we are at a distance greater o equal to 2 then with we decrease the\n  -- distance in 1 or 2, because we can jump 1 or 2 states (inc or onc2)\n  -- This property together with d\u22610\u21d2Q and d\u22611\u21d2Q\u222ad\u22610 allows to prove the\n  -- second constraint for the WFR rule (see below)\n  [d\u22612+w]\u21d2[d\u22611+w]\u222a[d\u2261w] : \u2200 {m w}\n                \u2192 myWFR {m} (2 + w)\n                  l-t\n                  ( myWFR {m} (1 + w) \u222a myWFR {m} w )\n  [d\u22612+w]\u21d2[d\u22611+w]\u222a[d\u2261w] {m} {w} =\n    viaEvSet\n      MyEventSet wf\n      (\u03bb { inc  \u22a4\n                \u2192 hoare \u03bb { {ps} refl (odd x) \u2192 inj\u2081 (assoc\u2218assoc 1 1) }\n         ; inc2 \u22a4\n                \u2192 hoare \u03bb { {ps} refl enEv \u2192 inj\u2082 (assoc\u2218comm 2) }})\n      (\u03bb { inc  \u22a5 \u2192 \u22a5-elim (\u22a5 tt)\n         ; inc2 \u22a5 \u2192 \u22a5-elim (\u22a5 tt) })\n      \u03bb {s} rs F2+d \u2192 alwaysEnabled s\n\n\n  -- Second constraint for WFR rule\n  [Fw]l-t[Q\u222aFx] : \u2200 {m w}\n                  \u2192 myWFR {m} w\n                    l-t\n                    ( ((m \u2264_) \u2229 Even) \u222a [\u2203 x \u21d2 _< w \u2236 myWFR {m} x ] )\n  [Fw]l-t[Q\u222aFx] {m} {zero}        = viaTrans d\u22610\u21d2Q (viaInv (\u03bb rs x \u2192 inj\u2081 x))\n  [Fw]l-t[Q\u222aFx] {m} {suc zero}    = d\u22611\u21d2Q\u222ad\u22610\n  [Fw]l-t[Q\u222aFx] {m} {suc (suc w)} =\n    viaTrans\n      [d\u22612+w]\u21d2[d\u22611+w]\u222a[d\u2261w]\n      (viaInv (\u03bb { rs (inj\u2081 mfr[1+w]) \u2192 inj\u2082 ( 1 + w , s\u2264s \u2264-refl , mfr[1+w] )\n                 ; rs (inj\u2082 mfr[w])   \u2192 inj\u2082 ( w , s\u2264s (m\u2264n+m w 1) , mfr[w]) }))\n\n\n\n\n  ------------------------------------------------------------------------------\n  -- MAIN PROPERTY\n  ------------------------------------------------------------------------------\n  -- From any n, we can reach any state m such that m is Even\n  progressAlwaysEven : \u2200 {n m : \u2115} \u2192 (n \u2261_) l-t ((m \u2264_) \u2229 Even)\n  progressAlwaysEven {n} {m} = viaWFR\n                                 (myWFR {m})\n                                 [P]l-t[Q\u222aFx]\n                                 \u03bb w \u2192 [Fw]l-t[Q\u222aFx]\n\n", "meta": {"hexsha": "8a62537dffb4e9edb9422364ad45dff4c3099a6c", "size": 9379, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Examples/SMCounterEven.agda", "max_stars_repo_name": "lisandrasilva/agda-liveness", "max_stars_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Examples/SMCounterEven.agda", "max_issues_repo_name": "lisandrasilva/agda-liveness", "max_issues_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Examples/SMCounterEven.agda", "max_forks_repo_name": "lisandrasilva/agda-liveness", "max_forks_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.9962686567, "max_line_length": 80, "alphanum_fraction": 0.4575114618, "num_tokens": 3215, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966747198243, "lm_q2_score": 0.8311430436757312, "lm_q1q2_score": 0.786757241359961}}
{"text": "module RandomAccessList.Standard.Numeral where\n\nopen import Data.List\nopen import Data.Nat\nopen import Data.Nat.Properties.Simple\nopen import Data.Unit using (\u22a4)\nopen import Data.Empty using (\u22a5; \u22a5-elim)\nopen import Relation.Nullary.Negation using (contraposition)\nopen import Relation.Binary.PropositionalEquality as PropEq\n    using (_\u2261_; _\u2262_; refl; cong; trans; sym; inspect)\nopen PropEq.\u2261-Reasoning\n\ndata Digit : Set where\n    zero : Digit\n    one  : Digit\n\nBinary : Set\nBinary = List Digit\n\nincr : Binary \u2192 Binary\nincr []          = one  \u2237 []\nincr (zero \u2237 xs) = one  \u2237 xs\nincr (one  \u2237 xs) = zero \u2237 incr xs\n\n\u27e6_\u27e7 : Binary \u2192 \u2115\n\u27e6 []        \u27e7 = 0\n\u27e6 zero \u2237 xs \u27e7 =     2 * \u27e6 xs \u27e7\n\u27e6 one  \u2237 xs \u27e7 = 1 + 2 * \u27e6 xs \u27e7\n\n*-0-absorb : (n m : \u2115) \u2192 n \u2261 0 \u2192 m * n \u2261 0\n*-0-absorb n m p =\n    begin\n        m * n\n    \u2261\u27e8 cong (_*_ m) p \u27e9\n        m * 0\n    \u2261\u27e8 *-right-zero m \u27e9\n        0\n    \u220e\n\ndecr : (xs : Binary) \u2192 \u27e6 xs \u27e7 \u2262 0 \u2192 Binary\ndecr []          p = \u22a5-elim (p refl)\ndecr (zero \u2237 xs) p = one  \u2237 decr xs (contraposition (*-0-absorb \u27e6 xs \u27e7 2) p)\ndecr (one  \u2237 xs) p = zero \u2237 xs\n", "meta": {"hexsha": "afd17efcddbda6679b52dc67f6c5f984ab4e1db8", "size": 1062, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "legacy/RandomAccessList/Standard/Numeral.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 24.1363636364, "max_line_length": 76, "alphanum_fraction": 0.5725047081, "num_tokens": 410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850075259039, "lm_q2_score": 0.839733963661418, "lm_q1q2_score": 0.7862303204864879}}
{"text": "module Peano where\n  data \u2115 : Set where\n    zero : \u2115\n    suc : \u2115 \u2192 \u2115\n\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  zero + zero = zero\n  zero + n    = n\n  (suc n) + m = suc (n + m)\n\n  data _even : \u2115 \u2192 Set where\n    ZERO : zero even\n    STEP : \u2200 x \u2192 x even \u2192 suc (suc x) even\n\n  proof\u2081 : suc (suc (suc (suc zero))) even\n  proof\u2081 = STEP (suc (suc zero)) (STEP zero ZERO)\n", "meta": {"hexsha": "9900b507e8bd083e40755157fb331753baa922f0", "size": 343, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Peano.agda", "max_stars_repo_name": "prt2121/tdd-playground", "max_stars_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/Peano.agda", "max_issues_repo_name": "prt2121/tdd-playground", "max_issues_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Peano.agda", "max_forks_repo_name": "prt2121/tdd-playground", "max_forks_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.1764705882, "max_line_length": 49, "alphanum_fraction": 0.527696793, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9664104933824753, "lm_q2_score": 0.8128673155708975, "lm_q1q2_score": 0.7855635034953593}}
{"text": "-- Long version, the final version is Nat.agda\nmodule NatTry where\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\none two three four : \u2115\none   = suc zero\ntwo   = suc one\nthree = suc two\nfour  = suc three\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  + b = b\nsuc a + b = suc (a + b)\n\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n\n_\u225f_ : \u2115 \u2192 \u2115 \u2192 Bool\nzero  \u225f zero  = true\nsuc a \u225f suc b = a \u225f b\n_     \u225f _     = false\n\ninfix 4 _\u225f_\n\nassocProp : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 Bool\nassocProp a b c =  (a + b) + c \u225f a + (b + c)\n\nreflProp : \u2115 \u2192 Bool\nreflProp n =  n \u225f n\n\nmodule isTrue-direct where\n\n  data isTrue : Bool \u2192 Set where\n    ok : isTrue true\n\n  unitTest : isTrue (assocProp one one two)\n  unitTest = ok\n\n  refl-True : (n : \u2115) \u2192 isTrue (reflProp n)\n  refl-True zero = ok\n  refl-True (suc n) = refl-True n\n\n  assocProp-zero-True : (n m : \u2115) \u2192 isTrue (assocProp zero n m)\n  assocProp-zero-True n m = refl-True (n + m)\n\n  assocProp-True : (n m k : \u2115) \u2192 isTrue (assocProp n m k)\n  assocProp-True zero    m k = assocProp-zero-True m k\n  assocProp-True (suc n) m k = assocProp-True n m k\n\n-------- switch to _\u2261_\n\nmodule \u2261-Bool where\n\n  -- propositional equalitiy on Bool\n  data _\u2261_ : Bool \u2192 Bool \u2192 Set where\n    refl : {a : Bool} \u2192 a \u2261 a  -- the Bool paramter is hidden\n\n  infix 4 _\u2261_\n\n  isTrue : Bool \u2192 Set\n  isTrue x = x \u2261 true\n\n-- generic propositional equality\ndata _\u2261_ {A : Set} : A \u2192 A \u2192 Set where\n  refl : {a : A} \u2192 a \u2261 a\n\ninfix 4 _\u2261_\n\n-- This is the type of the refl constructor\n-- The parameters are hidden\nrefl\u2032 : {A : Set} {a : A} \u2192 a \u2261 a\nrefl\u2032 = refl\n\nisTrue : Bool \u2192 Set\nisTrue x = x \u2261 true\n\nrefl-True : (n : \u2115) \u2192 isTrue (reflProp n)\nrefl-True zero = refl\nrefl-True (suc n) = refl-True n\n\nunitTest : isTrue (assocProp one one two)\nunitTest = refl\n\nassocProp-zero-True : (n m : \u2115) \u2192 isTrue (assocProp zero n m)\nassocProp-zero-True n m = refl-True (n + m)\n\nassocProp-True : (n m k : \u2115) \u2192 isTrue (assocProp n m k)\nassocProp-True zero    m k = assocProp-zero-True m k\nassocProp-True (suc n) m k = assocProp-True n m k\n\n\n---- switch from _\u225f_\n\ncong : {A B : Set} {a b : A} (f : A \u2192 B) \u2192 a \u2261 b \u2192 f a \u2261 f b\ncong f refl = refl\n\ncong-suc : {a b : \u2115} \u2192 a \u2261 b \u2192 suc a \u2261 suc b\ncong-suc = cong suc\n\n\u2261-to-\u225f : {a b : \u2115} \u2192 a \u2261 b \u2192 isTrue (a \u225f b)\n\u2261-to-\u225f {a} refl = refl-True a\n\n\u225f-to-\u2261 : (a b : \u2115) \u2192 isTrue (a \u225f b) \u2192 a \u2261 b\n\u225f-to-\u2261 zero zero i = refl\n\u225f-to-\u2261 zero (suc b) ()\n\u225f-to-\u2261 (suc a) zero ()\n\u225f-to-\u2261 (suc a) (suc b) i = cong-suc (\u225f-to-\u2261 a b i)\n\n\n-- the rest is in Nat.agda\n", "meta": {"hexsha": "e0a8f0faf74055e8e02b03784c2555bd7bb2f5a8", "size": 2429, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "NatTry.agda", "max_stars_repo_name": "divipp/agda-intro-prezi", "max_stars_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-11-27T02:50:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-21T14:53:25.000Z", "max_issues_repo_path": "NatTry.agda", "max_issues_repo_name": "divipp/agda-intro-prezi", "max_issues_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NatTry.agda", "max_forks_repo_name": "divipp/agda-intro-prezi", "max_forks_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1217391304, "max_line_length": 63, "alphanum_fraction": 0.5841910251, "num_tokens": 985, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898153067649, "lm_q2_score": 0.8670357735451835, "lm_q1q2_score": 0.7855255803385588}}
{"text": "module Numeral.Natural.Relation.Properties where\n\nimport Lvl\nopen import Data.Tuple as Tuple using (_\u2a2f_ ; _,_)\nopen import Functional\nopen import Logic.Propositional\nopen import Logic.Propositional.Theorems\nopen import Logic.Predicate\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.Proofs\nopen import Numeral.Natural.Induction\nopen import Numeral.Natural.Relation\nopen import Relator.Equals\nopen import Relator.Equals.Proofs\nopen import Structure.Function.Domain\nopen import Structure.Operator.Properties\nopen import Structure.Relator.Ordering\nopen import Structure.Relator.Properties\nopen import Type\n\n[\u2115]-zero-or-nonzero : \u2200{n : \u2115} \u2192 (n \u2261 \ud835\udfce)\u2228(n \u2262 \ud835\udfce)\n[\u2115]-zero-or-nonzero {\ud835\udfce}    = [\u2228]-intro\u2097 [\u2261]-intro\n[\u2115]-zero-or-nonzero {\ud835\udc12(_)} = [\u2228]-intro\u1d63 \\()\n\n[\u2261][\u2115]-excluded-middle : \u2200{a b : \u2115} \u2192 (a \u2261 b)\u2228(a \u2262 b)\n[\u2261][\u2115]-excluded-middle {\ud835\udfce}   {\ud835\udfce}    = [\u2228]-intro\u2097 [\u2261]-intro\n[\u2261][\u2115]-excluded-middle {\ud835\udfce}   {\ud835\udc12(_)} = [\u2228]-intro\u1d63 \\()\n[\u2261][\u2115]-excluded-middle {\ud835\udc12(_)}{\ud835\udfce}    = [\u2228]-intro\u1d63 \\()\n[\u2261][\u2115]-excluded-middle {\ud835\udc12(a)}{\ud835\udc12(b)} = [\u2228]-elim ([\u2228]-intro\u2097 \u2218 [\u2261]-with(\ud835\udc12)) ([\u2228]-intro\u1d63 \u2218 (contrapositive\u1d63(injective(\ud835\udc12)))) ([\u2261][\u2115]-excluded-middle {a}{b})\n", "meta": {"hexsha": "13d719c2fd63f6dd877570b0befc04b9663b5ce7", "size": 1166, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Relation/Properties.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Relation/Properties.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Relation/Properties.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.6129032258, "max_line_length": 152, "alphanum_fraction": 0.6861063465, "num_tokens": 457, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.926303728259492, "lm_q2_score": 0.8479677583778258, "lm_q1q2_score": 0.7854756960292242}}
{"text": "module Nats.Multiply.Comm where\n\nopen import Nats\nopen import Equality\nopen import Function\n\nopen import Nats.Add.Comm\nopen import Nats.Add.Assoc\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n  a*0=0*a : \u2200 a \u2192 a * 0 \u2261 0\n  a*0=0*a  zero   = refl\n  a*0=0*a (suc a) = a*0=0*a a\n\n  a+a*b=a*++b : \u2200 a b \u2192 a + a * b \u2261 a * suc b\n  a+a*b=a*++b  zero   _ = refl\n  a+a*b=a*++b (suc a) b\n    rewrite nat-add-comm b $ a * suc b\n          | nat-add-comm b $ a * b\n          | sym $ nat-add-assoc a (a * b) b\n          | a+a*b=a*++b a b\n            = refl\n\n  a*b=b*a : \u2200 a b \u2192 a * b \u2261 b * a\n  a*b=b*a  zero   b\n    rewrite a*0=0*a b = refl\n  a*b=b*a (suc a) b\n    rewrite a*b=b*a a b\n          | a+a*b=a*++b b a\n            = refl\n\n------------------------------------------------------------------------\n-- public aliases\n\nnat-multiply-comm : \u2200 a b \u2192 a * b \u2261 b * a\nnat-multiply-comm = a*b=b*a\n", "meta": {"hexsha": "1ffd22b0948c2d4b391f0d333c8dd5b8454aab63", "size": 937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Nats/Multiply/Comm.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Nats/Multiply/Comm.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Nats/Multiply/Comm.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.8536585366, "max_line_length": 72, "alphanum_fraction": 0.4258271078, "num_tokens": 321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9473810511092411, "lm_q2_score": 0.8289388146603364, "lm_q1q2_score": 0.7853209255381578}}
{"text": "module plfa.part1.Equality where\n\ndata _\u2261_ {A : Set} (x : A) : A \u2192 Set where\n  refl : x \u2261 x\n\ninfix 4 _\u2261_\n\nsym : \u2200 {A : Set} {x y : A} \u2192 x \u2261 y \u2192 y \u2261 x\nsym refl = refl\n\ntrans : \u2200 {A : Set} {x y z : A} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\ntrans refl refl = refl\n\ncong : \u2200 {A B : Set} (f : A \u2192 B) {x y : A} \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\ncong\u2082 : \u2200 {A B C : Set} (f : A \u2192 B \u2192 C) {u x : A} {v y : B} \u2192 u \u2261 x \u2192 v \u2261 y \u2192 f u v \u2261 f x y\ncong\u2082 f refl refl = refl\n\ncong-app : \u2200 {A B : Set} {f g : A \u2192 B} \u2192 f \u2261 g \u2192 \u2200 (x : A) \u2192 f x \u2261 g x\ncong-app refl x = refl\n\nsubst : \u2200 {A : Set} {x y : A} (P : A \u2192 Set) \u2192 x \u2261 y \u2192 P x \u2192 P y\nsubst P refl px = px\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero    + n  =  n\n(suc m) + n  =  suc (m + n)\n\npostulate\n  +-identity : \u2200 (m : \u2115) \u2192 m + zero \u2261 m\n  +-suc : \u2200 (m n : \u2115) \u2192 m + suc n \u2261 suc (m + n)\n", "meta": {"hexsha": "7140ac8940f22cfbab8bd1a16cfffb570c2f1d03", "size": 836, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.5945945946, "max_line_length": 91, "alphanum_fraction": 0.4413875598, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133447766225, "lm_q2_score": 0.8354835289107307, "lm_q1q2_score": 0.7852821181642609}}
{"text": "------------------------------------------------------------------------------\n-- Well-founded induction on natural numbers\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\n-- Adapted from\n-- http://www.iis.sinica.edu.tw/~scm/2008/well-founded-recursion-and-accessibility/\n-- and the Agda standard library\u00a00.8.1.\n\nmodule FOTC.Induction.WF where\n\nopen import Common.Relation.Unary\n\nopen import FOTC.Base\n\n------------------------------------------------------------------------------\n-- The accessibility predicate: x is accessible if everything which is\n-- smaller than x is also accessible (inductively).\ndata Acc (P : D \u2192 Set)(_<_ : D \u2192 D \u2192 Set)(x : D) : Set where\n acc : (\u2200 {y} \u2192 P y \u2192 y < x \u2192 Acc P _<_ y) \u2192 Acc P _<_ x\n\naccFold : {P Q : D \u2192 Set}(_<_ : D \u2192 D \u2192 Set) \u2192\n          (\u2200 {x} \u2192 Q x \u2192 (\u2200 {y} \u2192 Q y \u2192 y < x \u2192 P y) \u2192 P x) \u2192\n          \u2200 {x} \u2192 Q x \u2192 Acc Q _<_ x \u2192 P x\naccFold _<_ f Qx (acc h) = f Qx (\u03bb Qy y<x \u2192 accFold _<_ f Qy (h Qy y<x))\n\n-- The accessibility predicate encodes what it means to be\n-- well-founded; if all elements are accessible, then _<_ is\n-- well-founded.\nWellFounded : {P : D \u2192 Set} \u2192 (D \u2192 D \u2192 Set) \u2192 Set\nWellFounded {P} _<_ = \u2200 {x} \u2192 P x \u2192 Acc P _<_ x\n\nWellFoundedInduction : {P Q : D \u2192 Set}\n                       {_<_ : D \u2192 D \u2192 Set} \u2192\n                       WellFounded _<_ \u2192\n                       (\u2200 {x} \u2192 Q x \u2192 (\u2200 {y} \u2192 Q y \u2192 y < x \u2192 P y) \u2192 P x) \u2192\n                       \u2200 {x} \u2192 Q x \u2192 P x\nWellFoundedInduction {_<_ = _<_} wf f Qx = accFold _<_ f Qx (wf Qx)\n\nmodule Subrelation {P        : D \u2192 Set}\n                   {_<_ _<'_ : D \u2192 D \u2192 Set}\n                   (<\u21d2<'     : \u2200 {x y} \u2192 P x \u2192 x < y \u2192 x <' y)\n                   where\n\n  accessible : Acc P _<'_ \u2286 Acc P _<_\n  accessible (acc h) = acc (\u03bb Py y<x \u2192 accessible (h Py (<\u21d2<' Py y<x)))\n\n  well-founded : WellFounded _<'_ \u2192 WellFounded _<_\n  well-founded wf = \u03bb Px \u2192 accessible (wf Px)\n\nmodule InverseImage {P Q : D \u2192 Set}\n                    {_<_ : D \u2192 D \u2192 Set}\n                    {f   : D \u2192 D}\n                    (f-Q : \u2200 {x} \u2192 P x \u2192 Q (f x))\n                    where\n\n  accessible : \u2200 {x} \u2192 P x \u2192\n               Acc Q _<_ (f x) \u2192 Acc P (\u03bb x' y' \u2192 f x' < f y') x\n  accessible Px (acc h) =\n    acc (\u03bb {y} Py fy<fx \u2192 accessible Py (h (f-Q Py) fy<fx))\n\n  wellFounded : WellFounded _<_ \u2192 WellFounded (\u03bb x y \u2192 f x < f y)\n  wellFounded wf = \u03bb Px \u2192 accessible Px (wf (f-Q Px))\n", "meta": {"hexsha": "5e1f15d99ac87c14ada167d22984b37455ec3358", "size": 2571, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/FOTC/Induction/WF.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/FOTC/Induction/WF.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/FOTC/Induction/WF.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 37.8088235294, "max_line_length": 83, "alphanum_fraction": 0.4507973551, "num_tokens": 766, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582497090321, "lm_q2_score": 0.8438951084436077, "lm_q1q2_score": 0.7852091655404531}}
{"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl2.Correctness.Permutation  {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_)  where\n\nopen import BBSTree _\u2264_ \nopen import Bound.Total A\nopen import Bound.Total.Order _\u2264_\nopen import Data.List\nopen import Data.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import TreeSort.Impl2 _\u2264_ tot\u2264\n\nlemma-insert-/ : {a b : Bound}{x : A}(a\u2264x : LeB a (val x))(x\u2264b : LeB (val x) b)(t : BBSTree a b) \u2192 (flatten (insert a\u2264x x\u2264b t)) / x \u27f6 (flatten t) \nlemma-insert-/ a\u2264x x\u2264b (bslf _) = /head\nlemma-insert-/ {x = x} b\u2264x x\u2264t (bsnd {x = y} b\u2264y y\u2264t l r) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = lemma++/r (lemma-insert-/ b\u2264x (lexy x\u2264y) l)\n... | inj\u2082 y\u2264x = lemma++/l {xs = flatten l} (/tail (lemma-insert-/ (lexy y\u2264x) x\u2264t r))\n\ntheorem-treeSort\u223c : (xs : List A) \u2192 xs \u223c (flatten (treeSort xs))\ntheorem-treeSort\u223c [] = \u223c[]\ntheorem-treeSort\u223c (x \u2237 xs) = \u223cx /head (lemma-insert-/ lebx lext (treeSort xs)) (theorem-treeSort\u223c xs)\n\n\n\n\n", "meta": {"hexsha": "4373215c7d7e482dce204a26d5b86ec73f0552bd", "size": 1035, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl2/Correctness/Permutation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl2/Correctness/Permutation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl2/Correctness/Permutation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.5, "max_line_length": 146, "alphanum_fraction": 0.6183574879, "num_tokens": 396, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9572778000158576, "lm_q2_score": 0.8198933381139645, "lm_q1q2_score": 0.7848656909573936}}
{"text": "{-\n   Copyright (c) 2017 Diego Pedraza.\n\n   This is Free/Libre Open Source Software, released under the MIT License.\n   For the full copyright and license information, please view the LICENSE\n   file that was distributed with this source code.\n -}\n\nmodule R2 where\n\nopen import Data.List using (List; _\u2237_; _++_; [_]; [])\nopen import Data.Nat\nopen import Data.Bool\n\nrecord Pair (A B : Set) : Set where\n  constructor _,_\n  field\n    fst : A\n    snd : B\n\n{- --------------------------------------------------------------- \n  Ejercicio 1.1. Definir la funci\u00f3n\n     sumaImpares :: nat \u21d2 nat\n  tal que (sumaImpares n) es la suma de los n primeros n\u00fameros\n  impares. Por ejemplo,\n     sumaImpares 5  =  25\n  ---------------------------------------------------------------- -}\n\nsumaImpares : \u2115 \u2192 \u2115\nsumaImpares 0 = 0\nsumaImpares (suc n) = (2 * n + 1) + sumaImpares n\n\n{- --------------------------------------------------------------- \n  Ejercicio 1.2. Demostrar que \n     sumaImpares n = n*n\n  ----------------------------------------------------------------- -}\n_\u2261_ : \u2115 \u2192 \u2115 \u2192 Bool\n0 \u2261 0 = true\n(suc n) \u2261 (suc m) = n \u2261 m\nn \u2261 0 = false\n0 \u2261 m = false\n\nlemaSumaImpares : {n : \u2115} \u2192 (sumaImpares n) \u2261 (n * n)\nlemaSumaImpares {zero} = ?\nlemaSumaImpares {suc n} = ?\n\n{-\n\n{- --------------------------------------------------------------- \n  Ejercicio 2.1. Definir la funci\u00f3n\n     sumaPotenciasDeDosMasUno :: nat \u21d2 nat\n  tal que \n     (sumaPotenciasDeDosMasUno n) = 1 + 2^0 + 2^1 + 2^2 + ... + 2^n. \n  Por ejemplo, \n     sumaPotenciasDeDosMasUno 3  =  16\n  ---------------------------------------------------------------- -}\n \nfun sumaPotenciasDeDosMasUno :: \"nat \u21d2 nat\" where\n  \"sumaPotenciasDeDosMasUno n = undefined\"\n \n{- --------------------------------------------------------------- \n  Ejercicio 2.2. Demostrar que \n     sumaPotenciasDeDosMasUno n = 2^(n+1)\n  ----------------------------------------------------------------- -}\n \nlemma \"sumaPotenciasDeDosMasUno n = 2^(n+1)\"\n  oops\n \n{- --------------------------------------------------------------- \n  Ejercicio 3.1. Definir la funci\u00f3n\n     copia :: nat \u21d2 'a \u21d2 'a list\n  tal que (copia n x) es la lista formado por n copias del elemento\n  x. Por ejemplo, \n     copia 3 x = [x,x,x]\n  ---------------------------------------------------------------- -}\n \nfun copia :: \"nat \u21d2 'a \u21d2 'a list\" where\n  \"copia n x = undefined\"\n \n{- --------------------------------------------------------------- \n  Ejercicio 3.2. Definir la funci\u00f3n\n     todos :: ('a \u21d2 bool) \u21d2 'a list \u21d2 bool\n  tal que (todos p xs) se verifica si todos los elementos de xs cumplen\n  la propiedad p. Por ejemplo,\n     todos (\u03bbx. x>(1::nat)) [2,6,4] = True\n     todos (\u03bbx. x>(2::nat)) [2,6,4] = False\n  Nota: La conjunci\u00f3n se representa por \u2227\n  --------------------------------------------------------------- -}\n \nfun todos :: \"('a \u21d2 bool) \u21d2 'a list \u21d2 bool\" where\n  \"todos p xs = undefined\"\n \n{- --------------------------------------------------------------- \n  Ejercicio 3.3. Demostrar que todos los elementos de (copia n x) son\n  iguales a x. \n  ----------------------------------------------------------------- -}\n \nlemma \"todos (\u03bby. y=x) (copia n x)\"\n  oops\n \n{- --------------------------------------------------------------- \n  Ejercicio 4.1. Definir, recursivamente y sin usar (@), la funci\u00f3n\n     amplia :: 'a list \u21d2 'a \u21d2 'a list\n  tal que (amplia xs y) es la lista obtenida a\u00f1adiendo el elemento y al\n  final de la lista xs. Por ejemplo,\n     amplia [d,a] t = [d,a,t]\n  ---------------------------------------------------------------- -}\n \nfun amplia :: \"'a list \u21d2 'a \u21d2 'a list\" where\n  \"amplia xs y = undefined\"\n \n{- --------------------------------------------------------------- \n  Ejercicio 4.2. Demostrar que \n     amplia xs y = xs @ [y]\n  ----------------------------------------------------------------- -}\n \nlemma \"amplia xs y = xs @ [y]\"\n  oops\n-}\n", "meta": {"hexsha": "5acd9e505de31ab89114175458b6ef1104de696e", "size": 3867, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ejercicios/Agda/R2.agda", "max_stars_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_stars_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ejercicios/Agda/R2.agda", "max_issues_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_issues_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ejercicios/Agda/R2.agda", "max_forks_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_forks_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.225, "max_line_length": 75, "alphanum_fraction": 0.4290147401, "num_tokens": 1035, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942041005328, "lm_q2_score": 0.8688267864276107, "lm_q1q2_score": 0.7848062005473523}}
{"text": "\nmodule Agda.Builtin.Nat where\n\nopen import Agda.Builtin.Bool\n\ndata Nat : Set where\n  zero : Nat\n  suc  : (n : Nat) \u2192 Nat\n\n{-# BUILTIN NATURAL Nat #-}\n\ninfix  4 _==_ _<_\ninfixl 6 _+_ _-_\ninfixl 7 _*_\n\n_+_ : Nat \u2192 Nat \u2192 Nat\nzero  + m = m\nsuc n + m = suc (n + m)\n\n{-# BUILTIN NATPLUS _+_ #-}\n\n_-_ : Nat \u2192 Nat \u2192 Nat\nn     - zero = n\nzero  - suc m = zero\nsuc n - suc m = n - m\n\n{-# BUILTIN NATMINUS _-_ #-}\n\n_*_ : Nat \u2192 Nat \u2192 Nat\nzero  * m = zero\nsuc n * m = m + n * m\n\n{-# BUILTIN NATTIMES _*_ #-}\n\n_==_ : Nat \u2192 Nat \u2192 Bool\nzero  == zero  = true\nsuc n == suc m = n == m\n_     == _     = false\n\n{-# BUILTIN NATEQUALS _==_ #-}\n\n_<_ : Nat \u2192 Nat \u2192 Bool\n_     < zero  = false\nzero  < suc _ = true\nsuc n < suc m = n < m\n\n{-# BUILTIN NATLESS _<_ #-}\n\ndiv-helper : Nat \u2192 Nat \u2192 Nat \u2192 Nat \u2192 Nat\ndiv-helper k m  zero    j      = k\ndiv-helper k m (suc n)  zero   = div-helper (suc k) m n m\ndiv-helper k m (suc n) (suc j) = div-helper k m n j\n\n{-# BUILTIN NATDIVSUCAUX div-helper #-}\n\nmod-helper : Nat \u2192 Nat \u2192 Nat \u2192 Nat \u2192 Nat\nmod-helper k m  zero    j      = k\nmod-helper k m (suc n)  zero   = mod-helper 0 m n m\nmod-helper k m (suc n) (suc j) = mod-helper (suc k) m n j\n\n{-# BUILTIN NATMODSUCAUX mod-helper #-}\n", "meta": {"hexsha": "0e7c880b2195c173b2dd94e89882c8a0904aaa73", "size": 1195, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Nat.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Nat.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Nat.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.2741935484, "max_line_length": 57, "alphanum_fraction": 0.5556485356, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9518632302488963, "lm_q2_score": 0.8244619242200081, "lm_q1q2_score": 0.7847749904052777}}
{"text": "module *-assoc where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; cong)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; step-\u2261; _\u220e)\nopen import Data.Nat using (\u2115; zero; suc; _+_; _*_)\n\nopen import *-distrib-+ using (*-distrib-+)\n\n-- \u7a4d\u306e\u7d50\u5408\u5f8b (associativity)\n*-assoc : \u2200 (m n p : \u2115) \u2192 (m * n) * p \u2261 m * (n * p)\n*-assoc zero n p =\n  begin\n    (zero * n) * p\n  \u2261\u27e8\u27e9\n    zero * p\n  \u2261\u27e8\u27e9\n    zero\n  \u2261\u27e8\u27e9\n    zero * (n * p)\n  \u220e\n*-assoc (suc m) n p =\n  begin\n    ((suc m) * n) * p\n  \u2261\u27e8\u27e9\n    (n + m * n) * p\n  \u2261\u27e8 *-distrib-+ n (m * n) p \u27e9\n    (n * p) + m * n * p\n  \u2261\u27e8 cong ((n * p) +_) (*-assoc m n p) \u27e9\n    (n * p) + m * (n * p)\n  \u2261\u27e8\u27e9\n    (suc m) * (n * p)\n  \u220e\n", "meta": {"hexsha": "5600163ee3442b375da8314157fef2093ded19ee", "size": 669, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/induction/*-assoc.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/induction/*-assoc.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/induction/*-assoc.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.6764705882, "max_line_length": 53, "alphanum_fraction": 0.466367713, "num_tokens": 327, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9597620562254525, "lm_q2_score": 0.8175744695262775, "lm_q1q2_score": 0.7846769539899737}}
{"text": "module nat where\n\nopen import product\nopen import bool\nopen import maybe\nopen import eq\n\n----------------------------------------------------------------------\n-- datatypes\n----------------------------------------------------------------------\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\nnat = \u2115\n\n----------------------------------------------------------------------\n-- syntax\n----------------------------------------------------------------------\n\ninfixl 10 _*_\ninfixl 9 _+_ _\u2238_\ninfixl 8 _<_ _=\u2115_ _\u2264_ _>_ _\u2265_\n\n-- pragmas to get decimal notation:\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n----------------------------------------------------------------------\n-- operations\n----------------------------------------------------------------------\n\n---------------------------------------\n-- basic arithmetic operations\n---------------------------------------\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  + n = n\nsuc m + n = suc (m + n)\n\n{-# BUILTIN NATPLUS _+_ #-}\n\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  * n = zero\nsuc m * n = n + (m * n)\n\n{-# BUILTIN NATTIMES _*_ #-}\n\npred : \u2115 \u2192 \u2115\npred 0 = 0\npred (suc n) = n\n\n_\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm     \u2238 zero  = m\nzero  \u2238 suc n = zero\nsuc m \u2238 suc n = m \u2238 n\n\n-- see nat-division.agda for division function\n\n{-# BUILTIN NATMINUS _\u2238_ #-}\n\nsquare : \u2115 \u2192 \u2115\nsquare x = x * x\n\n--------------------------------------------------\n-- comparisons\n--------------------------------------------------\n\n_<_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\n0 < 0 = ff\n0 < (suc y) = tt\n(suc x) < (suc y) = x < y\n(suc x) < 0 = ff\n\n_=\u2115_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\n0 =\u2115 0 = tt\nsuc x =\u2115 suc y = x =\u2115 y\n_ =\u2115 _ = ff\n\n_\u2264_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\nx \u2264 y = (x < y) || x =\u2115 y\n\n_>_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\na > b = b < a\n\n_\u2265_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\na \u2265 b = b \u2264 a\n\nmin : \u2115 \u2192 \u2115 \u2192 \u2115\nmin x y = if x < y then x else y\n\nmax : \u2115 \u2192 \u2115 \u2192 \u2115\nmax x y = if x < y then y else x\n\ndata compare-t : Set where\n  compare-lt : compare-t\n  compare-eq : compare-t\n  compare-gt : compare-t\n\ncompare : \u2115 \u2192 \u2115 \u2192 compare-t\ncompare 0 0 = compare-eq\ncompare 0 (suc y) = compare-lt\ncompare (suc x) 0 = compare-gt\ncompare (suc x) (suc y) = compare x y \n\niszero : \u2115 \u2192 \ud835\udd39\niszero 0 = tt\niszero _ = ff\n\nparity : \u2115 \u2192 \ud835\udd39\nparity 0 = ff\nparity (suc x) = ~ (parity x)\n\n_pow_ : \u2115 \u2192 \u2115 \u2192 \u2115\nx pow 0 = 1\nx pow (suc y) = x * (x pow y)\n\nfactorial : \u2115 \u2192 \u2115\nfactorial 0 = 1\nfactorial (suc x) = (suc x) * (factorial x)\n\nis-even : \u2115 \u2192 \ud835\udd39\nis-odd : \u2115 \u2192 \ud835\udd39\nis-even 0 = tt\nis-even (suc x) = is-odd x\nis-odd 0 = ff\nis-odd (suc x) = is-even x\n", "meta": {"hexsha": "cae4676847dd3fdbfdfdeccc66bc03166e8803e6", "size": 2343, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nat.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nat.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nat.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.1627906977, "max_line_length": 70, "alphanum_fraction": 0.408023901, "num_tokens": 781, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475762847495, "lm_q2_score": 0.8311430457670241, "lm_q1q2_score": 0.7840567777702468}}
{"text": "module Sandbox.PrimitiveRecursion where\n\nopen import Data.Nat\nopen import Data.Fin using (Fin)\nopen import Data.Vec\n\ndata PR : \u2115 \u2192 Set where\n    -- Constant function: The 0-ary constant function 0 is primitive recursive.\n    K : PR 0\n\n    -- Successor function: The 1-ary successor function S, which returns the\n    -- successor of its argument (see Peano postulates), is primitive recursive.\n    -- That is, S(k) = k + 1.\n    S : PR 1\n\n    -- Projection function: For every n\u22651 and each i with 1\u2264i\u2264n, the n-ary\n    -- projection function P\u1d62\u207f, which returns its i-th argument, is primitive\n    -- recursive.\n    Proj : \u2200 {n} \u2192 (i : Fin n) \u2192 PR n\n\n    -- Composition: Given f, a m-ary primitive recursive function, and m n-ary\n    -- primitive recursive functions g1,...,gm, the composition of f with\n    -- g1,...,gk, is primitive recursive\n    --  f(\n    --      g\u2081(x\u2081, x\u2082, ..., x\u2099)\n    --      g\u2082(x\u2081, x\u2082, ..., x\u2099)\n    --      ...\n    --      g\u2098(x\u2081, x\u2082, ..., x\u2099)\n    --  )\n    Comp : \u2200 {m n} \u2192 (f : PR m) \u2192 Vec (PR n) m \u2192 PR n\n    -- Primitive recursion: Given f, a m-ary primitive recursive function,\n    -- and g, a (m+2)-ary primitive recursive function, the (m+1)-ary function\n    -- h is defined as the primitive recursion of f and g, i.e. the function h\n    -- is primitive recursive when\n    --  h(0   , x\u2081, x\u2082, .. x\u2098) = f(x\u2081, x\u2082, .. x\u2098)\n    --  h(S(n), x\u2081, x\u2082, .. x\u2098) = g(n, h(n, x\u2081, x\u2082, .. x\u2098), x\u2081, x\u2082, .. x\u2098)\n    Rec : \u2200 {n} \u2192 (f : PR {!   !}) (g : PR (suc (suc n))) \u2192 PR (suc n)\n\n\nmutual\n    \u27e6_\u27e7_ : \u2200 {a} \u2192 PR a \u2192 Vec \u2115 a \u2192 \u2115\n    \u27e6 K         \u27e7 args           = zero\n    \u27e6 S         \u27e7 args           = suc zero\n    \u27e6 Proj i    \u27e7 args           = lookup i args\n    \u27e6 Comp f gs \u27e7 args           = \u27e6 f \u27e7 (\u27e6 gs \u27e7* args)\n    \u27e6 Rec  f g  \u27e7 (zero  \u2237 args) = \u27e6 f \u27e7 args\n    \u27e6 Rec  f g  \u27e7 (suc x \u2237 args) = \u27e6 g \u27e7 (x \u2237 (\u27e6 f \u27e7 args) \u2237 args)\n\n    \u27e6_\u27e7* : {m n : \u2115} (gs : Vec (PR n) m) \u2192 Vec \u2115 n \u2192 Vec \u2115 m\n    \u27e6 []     \u27e7* args = []\n    \u27e6 g \u2237 gs \u27e7* args = (\u27e6 g \u27e7 args) \u2237 \u27e6 gs \u27e7* args\n", "meta": {"hexsha": "a3419422170d358a7b2c5e640e5ccbb0cde24942", "size": 1979, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sandbox/PrimitiveRecursion.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Sandbox/PrimitiveRecursion.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sandbox/PrimitiveRecursion.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 38.0576923077, "max_line_length": 80, "alphanum_fraction": 0.517433047, "num_tokens": 742, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475778774728, "lm_q2_score": 0.8311430436757313, "lm_q1q2_score": 0.7840567771212117}}
{"text": "module naturals where\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n-- 1)\nseven : \u2115\nseven = suc (suc (suc (suc (suc (suc (suc zero))))))\n\n{-# BUILTIN NATURAL \u2115 #-}\n\nopen import Relation.Binary.PropositionalEquality\nopen \u2261-Reasoning\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n\n(suc m) + n = suc (m + n)\n\n-- 2)\n_ : 3 + 4 \u2261 7\n_ =\n  begin\n    3 + 4\n  \u2261\u27e8\u27e9\n    suc (2 + 4)\n  \u2261\u27e8\u27e9\n    suc (suc (1 + 4))\n  \u2261\u27e8\u27e9\n    suc (suc (suc (0 + 4)))\n  \u2261\u27e8\u27e9\n    suc (suc (suc 4))\n  \u2261\u27e8\u27e9\n    suc (suc 5)\n  \u2261\u27e8\u27e9\n    suc 6\n  \u2261\u27e8\u27e9\n    7\n  \u220e\n\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero * n  =  zero\n(suc m) * n  =  n + (m * n)\n\n-- 3)\n_ : 3 * 4 \u2261 12\n_ =\n  begin\n    3 * 4\n  \u2261\u27e8\u27e9\n    4 + (2 * 4)\n  \u2261\u27e8\u27e9\n    4 + (4 + (1 * 4))\n  \u2261\u27e8\u27e9\n    4 + (4 + (4 + (0 * 4)))\n  \u2261\u27e8\u27e9\n    4 + (4 + (4 + 0))\n  \u2261\u27e8\u27e9\n    4 + (4 + (4))\n  \u2261\u27e8\u27e9\n    12\n  \u220e\n\n-- 4)\n_^_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm ^ zero = suc zero\nm ^ suc n = m * (m ^ n)\n\n\n_ : 3 ^ 4 \u2261 81\n_ =\n  begin\n    3 ^ 4\n  \u2261\u27e8\u27e9\n    3 * (3 ^ 3)\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 ^ 2))\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 * (3 ^ 1)))\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 * (3 * (3 ^ 0))))\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 * (3 * 1)))\n  \u2261\u27e8\u27e9\n    81\n  \u220e\n\n_\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm \u2238 zero   =  m\nzero \u2238 suc n  =  zero\nsuc m \u2238 suc n  =  m \u2238 n\n\n-- 5)\n_ : 5 \u2238 3 \u2261 2\n_ =\n  begin\n    5 \u2238 3\n  \u2261\u27e8\u27e9\n    4 \u2238 2\n  \u2261\u27e8\u27e9\n    3 \u2238 1\n  \u2261\u27e8\u27e9\n    2 \u2238 0\n  \u2261\u27e8\u27e9\n    2\n  \u220e\n\n_ : 3 \u2238 5 \u2261 0\n_ =\n  begin\n    3 \u2238 5\n  \u2261\u27e8\u27e9\n    2 \u2238 4\n  \u2261\u27e8\u27e9\n    1 \u2238 3\n  \u2261\u27e8\u27e9\n    0 \u2238 2\n  \u2261\u27e8\u27e9\n    0\n  \u220e\n\ninfixl 6  _+_  _\u2238_\ninfixl 7  _*_\n\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n{-# BUILTIN NATMINUS _\u2238_ #-}\n\n-- 6)\ndata Bin : Set where\n  - : Bin\n  _O : Bin \u2192 Bin\n  _I : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc - = - I\ninc (rest O) = rest I\ninc (rest I) = (inc rest) O\n\nto : \u2115 \u2192 Bin\nto zero = - O\nto (suc n) = inc (to n)\n\nfrom : Bin \u2192 \u2115\nfrom - = 0\nfrom (rest O) = 2 * from rest\nfrom (rest I) = 2 * from rest + 1\n", "meta": {"hexsha": "45e17078a875639c2eb555a43042125cc4892e97", "size": 1741, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/naturals.agda", "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plfa/naturals.agda", "max_issues_repo_name": "aronerben/agda-playground", "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/naturals.agda", "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 11.7635135135, "max_line_length": 52, "alphanum_fraction": 0.3716255026, "num_tokens": 1000, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012762876287, "lm_q2_score": 0.8289388125473629, "lm_q1q2_score": 0.7840113868716472}}
{"text": "module even where\n\nopen import Data.Nat \nopen import Data.Nat.Properties\nopen import Data.Empty\nopen import Data.Unit using (\u22a4 ; tt)\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Relation.Binary.Definitions\nopen import nat\nopen import logic\n\neven : (n : \u2115 ) \u2192 Set\neven zero = \u22a4\neven (suc zero) = \u22a5\neven (suc (suc n)) = even n\n\neven? : (n : \u2115 ) \u2192 Dec ( even n )\neven? zero = yes tt\neven? (suc zero) = no (\u03bb ())\neven? (suc (suc n)) = even? n\n\nn+even : {n m : \u2115 } \u2192 even n \u2192 even m  \u2192 even ( n + m )\nn+even {zero} {zero} tt tt = tt\nn+even {zero} {suc m} tt em = em\nn+even {suc (suc n)} {m} en em = n+even {n} {m} en em\n\nn*even : {m n : \u2115 } \u2192 even n \u2192 even ( m * n )\nn*even {zero} {n} en = tt\nn*even {suc m} {n} en = n+even {n} {m * n} en (n*even {m} {n} en) \n\neven*n : {n m : \u2115 } \u2192 even n \u2192 even ( n * m )\neven*n {n} {m} en = subst even (*-comm m n) (n*even {m} {n} en)\n\n\nrecord Even (i : \u2115) : Set where\n  field\n     j : \u2115\n     is-twice : i \u2261 2 * j\n\ne2 : (i : \u2115) \u2192 even i \u2192 Even i\ne2 zero en = record { j = 0 ; is-twice = refl }\ne2 (suc (suc i)) en = record { j = suc (Even.j (e2 i en )) ; is-twice = e21 } where\n   e21 : suc (suc i) \u2261 2 * suc (Even.j (e2 i en))\n   e21 = begin\n    suc (suc i)  \u2261\u27e8 cong (\u03bb k \u2192 suc (suc k)) (Even.is-twice (e2 i en))  \u27e9\n    suc (suc (2 * Even.j (e2 i en)))  \u2261\u27e8 sym (*-distrib\u02e1-+ 2 1 _) \u27e9\n    2 * suc (Even.j (e2 i en))      \u220e where open \u2261-Reasoning\n\nrecord Odd (i : \u2115) : Set where\n  field\n     j : \u2115\n     is-twice : i \u2261 suc (2 * j )\n\nodd2 : (i : \u2115) \u2192 \u00ac even i \u2192 even (suc i) \nodd2 zero ne = \u22a5-elim ( ne tt )\nodd2 (suc zero) ne = tt\nodd2 (suc (suc i)) ne = odd2 i ne \n\nodd3 : (i : \u2115) \u2192 \u00ac even i \u2192  Odd i\nodd3 zero ne = \u22a5-elim ( ne tt )\nodd3 (suc zero) ne = record { j = 0 ; is-twice = refl }\nodd3 (suc (suc i))  ne = record { j = Even.j (e2 (suc i) (odd2 i ne)) ; is-twice = odd31 } where\n  odd31 : suc (suc i) \u2261 suc (2 * Even.j (e2 (suc i) (odd2 i ne)))\n  odd31 = begin\n    suc (suc i) \u2261\u27e8  cong suc (Even.is-twice (e2 (suc i) (odd2 i ne)))  \u27e9\n    suc (2 * (Even.j (e2 (suc i) (odd2 i ne))))      \u220e where open \u2261-Reasoning\n\nodd4 : (i : \u2115) \u2192 even i \u2192 \u00ac even ( suc i )\nodd4 (suc (suc i)) en en1 = odd4 i en en1 \n\n", "meta": {"hexsha": "a1dc82bed38362aa973f43a5acc0ac4f71f44dab", "size": 2183, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/even.agda", "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/even.agda", "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/even.agda", "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.3194444444, "max_line_length": 96, "alphanum_fraction": 0.5478699038, "num_tokens": 924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545333502202, "lm_q2_score": 0.8267118004748677, "lm_q1q2_score": 0.7838505413943685}}
{"text": "module Nat.Sum where\n\nopen import Data.Nat \nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality \n\nopen DecTotalOrder decTotalOrder hiding (refl)\n\n+id : (n : \u2115) \u2192 n + zero \u2261  n\n+id zero = refl\n+id (suc n) = cong suc (+id n)\n\n+assoc : (m n : \u2115) \u2192 m + suc n \u2261 suc (m + n)\n+assoc zero n = refl\n+assoc (suc m) n = cong suc (+assoc m n)\n\n", "meta": {"hexsha": "be82a3f09ef970423398bc55dd8eb9a05a83edb1", "size": 358, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Nat/Sum.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/Nat/Sum.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Nat/Sum.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.0588235294, "max_line_length": 50, "alphanum_fraction": 0.656424581, "num_tokens": 119, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9697854111860906, "lm_q2_score": 0.8080672066194946, "lm_q1q2_score": 0.7836517882374823}}
{"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule Mergesort.Impl1.Correctness.Permutation {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_)  where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _\u2264_\nopen import Data.List\nopen import Data.Product\nopen import Data.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Permutation.Pair A\nopen import List.Permutation.Pair.Properties A\nopen import Mergesort.Impl1 _\u2264_ tot\u2264\nopen import Size\nopen import SList\nopen import SList.Properties\nopen import SOList.Lower _\u2264_\n\nlemma-deal : {\u03b9 : Size} \u2192 (xs : SList A {\u03b9}) \u2192 unsize A xs \u2248 unsize\u00d7 A (deal xs)\nlemma-deal snil = \u2248[]l []\nlemma-deal (x \u2219 snil) = \u2248[]r (x \u2237 [])\nlemma-deal (x \u2219 (y \u2219 xs)) \n    with lemma-deal xs\n... | xs\u2248ys,zs = \u2248xl (\u2248xr xs\u2248ys,zs)\n\nlemma-merge : {\u03b9 \u03b9' : Size}{b : Bound}(xs : SOList {\u03b9} b)(ys : SOList {\u03b9'} b) \u2192 forget (merge xs ys) \u2248 (forget xs , forget ys) \nlemma-merge onil ys = \u2248[]l (forget ys)\nlemma-merge xs onil \n    with xs\n... | onil = \u2248[]r []\n... | (:< {x = z} b\u2264z zs) = \u2248[]r (z \u2237 forget zs)\nlemma-merge (:< {x = x} b\u2264x xs)  (:< {x = y} b\u2264y ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = \u2248xl (lemma-merge xs (:< (lexy x\u2264y) ys))\n... | inj\u2082 y\u2264x = \u2248xr (lemma-merge (:< (lexy y\u2264x) xs) ys)\n\nlemma-mergesort : {\u03b9 : Size}(xs : SList A {\u2191 \u03b9}) \u2192 unsize A xs \u223c forget (mergesort xs)\nlemma-mergesort snil = \u223c[]\nlemma-mergesort (x \u2219 snil) = \u223cx /head /head \u223c[]\nlemma-mergesort (x \u2219 (y \u2219 xs)) = lemma\u2248 (\u2248xl (\u2248xr (lemma-deal xs))) (lemma-mergesort (x \u2219 ys)) (lemma-mergesort (y \u2219 zs)) (lemma-merge (mergesort (x \u2219 ys)) (mergesort (y \u2219 zs)))\n                where d = deal xs\n                      ys = proj\u2081 d\n                      zs = proj\u2082 d\n\ntheorem-mergesort-\u223c : (xs : List A) \u2192 xs \u223c (forget (mergesort (size A xs)))\ntheorem-mergesort-\u223c xs = trans\u223c (lemma-unsize-size A xs) (lemma-mergesort (size A xs))\n", "meta": {"hexsha": "8d7003eadcd98cb819e64331d80e6432605a96ca", "size": 1927, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Mergesort/Impl1/Correctness/Permutation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/Mergesort/Impl1/Correctness/Permutation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Mergesort/Impl1/Correctness/Permutation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.7843137255, "max_line_length": 177, "alphanum_fraction": 0.598858329, "num_tokens": 728, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92414182206801, "lm_q2_score": 0.847967764140929, "lm_q1q2_score": 0.7836424746081346}}
{"text": "module Nat where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e)\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero    + n  =  n\n(suc m) + n  =  suc (m + n)\n\n_ : 2 + 3 \u2261 5\n_ =\n  begin\n    2 + 3\n  \u2261\u27e8\u27e9\n    suc (1 + 3)\n  \u2261\u27e8\u27e9\n    suc (suc (0 + 3))\n  \u2261\u27e8\u27e9\n    suc (suc 3)\n  \u2261\u27e8\u27e9\n    5\n  \u220e\n\n\n", "meta": {"hexsha": "c48f04dc0d15c691a635bd307464d6d7268063b3", "size": 404, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Nat.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/Nat.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/Nat.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 12.625, "max_line_length": 50, "alphanum_fraction": 0.4876237624, "num_tokens": 192, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947163538936, "lm_q2_score": 0.8289388125473628, "lm_q1q2_score": 0.7833427980379285}}
{"text": "module treeThms where\r\n\r\nopen import lib\r\n\r\n-- simple Tree type storing natural numbers\r\ndata Tree : Set where\r\n  Node : \u2115 \u2192 Tree \u2192 Tree \u2192 Tree\r\n  Leaf : Tree\r\n\r\nmirror : Tree \u2192 Tree\r\nmirror (Node x t1 t2) = Node x (mirror t2) (mirror t1)\r\nmirror Leaf = Leaf\r\n\r\nmirror-mirror : \u2200 (t : Tree) \u2192 mirror (mirror t) \u2261 t\r\nmirror-mirror Leaf = refl\r\nmirror-mirror (Node x t1 t2) rewrite mirror-mirror t2 | mirror-mirror t1 = refl\r\n\r\n\r\nsize : Tree \u2192 \u2115\r\nsize (Node x t t\u2081) = 1 + size t + size t\u2081\r\nsize Leaf = 1\r\n\r\nheight : Tree \u2192 \u2115\r\nheight (Node x t t\u2081) = 1 + (max (height t) (height t\u2081))\r\nheight Leaf = 0\r\n\r\nnumLeaves : Tree \u2192 \u2115\r\nnumLeaves (Node x t t\u2081) = numLeaves t + numLeaves t\u2081\r\nnumLeaves Leaf = 1\r\n\r\nperfect : \u2115 \u2192 Tree\r\nperfect zero = Leaf\r\nperfect (suc n) = Node 1 (perfect n) (perfect n)\r\n\r\n-- I found I needed the +0 theorem from nat-thms.agda in the IAL\r\nperfect-numLeaves : \u2200(n : \u2115) \u2192 numLeaves (perfect n) \u2261 2 pow n\r\nperfect-numLeaves zero = refl\r\nperfect-numLeaves (suc n) rewrite +0 (2 pow n) |  perfect-numLeaves n  = refl\r\n\r\nperfect-size : \u2200(n : \u2115) \u2192 suc (size (perfect n)) \u2261 2 pow (suc n)\r\nperfect-size zero = refl\r\nperfect-size (suc n) rewrite  sym (perfect-size n) | +0 (size(perfect n)) | sym (+suc(size(perfect n))(size(perfect n)))= refl\r\n\r\n-- helper lemma I found I needed below\r\nmax-same : \u2200 (n : \u2115) \u2192 max n n \u2261 n\r\nmax-same n rewrite <-irrefl n = refl\r\n\r\nperfect-height : \u2200(n : \u2115) \u2192 height (perfect n) \u2261 n\r\nperfect-height zero = refl\r\nperfect-height (suc n) rewrite max-same (height(perfect n)) | perfect-height n = refl\r\n\r\nnumNodes : Tree \u2192 \u2115\r\nnumNodes (Node x t1 t2) = 1 + numNodes t1 + numNodes t2 \r\nnumNodes Leaf = 0\r\n\r\n-- flatten a tree into a list of all the values stored at the nodes\r\nprefixFlatten : Tree \u2192 \ud835\udd43 \u2115\r\nprefixFlatten (Node x t1 t2) = x :: prefixFlatten t1 ++ prefixFlatten t2\r\nprefixFlatten Leaf = []\r\n\r\n-- I found I needed a theorem from list-thms.agda in the IAL\r\nlength-flatten : \u2200(t : Tree) \u2192 numNodes t \u2261 length (prefixFlatten t)\r\nlength-flatten (Node x t1 t2) rewrite length-++(prefixFlatten t1) (prefixFlatten t2) | length-flatten t1 | length-flatten t2 = refl\r\nlength-flatten Leaf = refl\r\n", "meta": {"hexsha": "fa78d604d84f53c4712c4dcc8b9c3ad057fc784b", "size": 2131, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "treeThms.agda", "max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_stars_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "treeThms.agda", "max_issues_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_issues_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "treeThms.agda", "max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_forks_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7846153846, "max_line_length": 132, "alphanum_fraction": 0.6611919287, "num_tokens": 694, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952811593496, "lm_q2_score": 0.8723473846343393, "lm_q1q2_score": 0.7831021307179464}}
{"text": "{-# OPTIONS --safe #-}\nmodule Squaring where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Nat\nopen import Data.Product\nopen import Data.Bool hiding (_\u2264_;_<_)\nopen import Data.Nat.Properties\n\nopen \u2261-Reasoning\n\ndiv-mod2 : \u2115 \u2192 \u2115 \u00d7 Bool\ndiv-mod2 0 = 0 , false\ndiv-mod2 (suc 0) = 0 , true\ndiv-mod2 (suc (suc n)) = let q , r = div-mod2 n in suc q , r\n\n-- The first argument (k) helps Agda to prove\n-- that the function terminates\npow-sqr-aux : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 \u2115\npow-sqr-aux 0 _ _ = 1\npow-sqr-aux _ _ 0 = 1\npow-sqr-aux (suc k) b e with div-mod2 e\n... | e' , false = pow-sqr-aux k (b * b) e'\n... | e' , true = b * pow-sqr-aux k (b * b) e'\n\npow-sqr : \u2115 \u2192 \u2115 \u2192 \u2115\npow-sqr b e = pow-sqr-aux e b e\n\ndiv-mod2-spec : \u2200 n \u2192 let q , r = div-mod2 n in 2 * q + (if r then 1 else 0) \u2261 n\ndiv-mod2-spec 0 = refl\ndiv-mod2-spec 1 = refl\ndiv-mod2-spec (suc (suc n)) with div-mod2 n | div-mod2-spec n\n... | q , r | eq rewrite +-suc q (q + 0) | eq = refl\n\ndiv-mod2-lt : \u2200 n \u2192 0 < n \u2192 proj\u2081 (div-mod2 n) < n\ndiv-mod2-lt 0 lt = lt\ndiv-mod2-lt 1 lt = lt\ndiv-mod2-lt 2 lt = s\u2264s (s\u2264s z\u2264n)\ndiv-mod2-lt (suc (suc (suc n))) lt with\n  div-mod2 (suc n) | div-mod2-lt (suc n) (s\u2264s z\u2264n)\n... | q , r | ih = \u2264-step (s\u2264s ih)\n\npow-lemma : \u2200 b e \u2192 (b * b) ^ e \u2261 b ^ (2 * e)\npow-lemma b e = begin\n  (b * b) ^ e \u2261\u27e8 cong (\u03bb t \u2192 (b * t) ^ e) (sym (*-identity\u02b3 b)) \u27e9\n  (b ^ 2) ^ e \u2261\u27e8 ^-*-assoc b 2 e \u27e9\n  b ^ (2 * e) \u220e\n\npow-sqr-lemma : \u2200 k b e \u2192 e \u2264 k \u2192 pow-sqr-aux k b e \u2261 b ^ e\npow-sqr-lemma 0 _ 0 _ = refl\npow-sqr-lemma (suc k) _ 0 _ = refl\npow-sqr-lemma (suc k) b (suc e) (s\u2264s le) with\n  div-mod2 (suc e) | div-mod2-spec (suc e) | div-mod2-lt (suc e) (s\u2264s z\u2264n)\n... | e' , false | eq | lt = begin\n  pow-sqr-aux k (b * b) e' \u2261\u27e8 pow-sqr-lemma k (b * b) e' (\u2264-trans (\u2264-pred lt) le) \u27e9\n  (b * b) ^ e' \u2261\u27e8 pow-lemma b e' \u27e9\n  b ^ (2 * e') \u2261\u27e8 cong (b ^_) (trans (sym (+-identity\u02b3 (e' + (e' + 0)))) eq) \u27e9\n  b ^ suc e \u220e\n... | e' , true | eq | lt = cong (b *_) (begin\n  pow-sqr-aux k (b * b) e' \u2261\u27e8 pow-sqr-lemma k (b * b) e' (\u2264-trans (\u2264-pred lt) le) \u27e9\n  (b * b) ^ e' \u2261\u27e8 pow-lemma b e' \u27e9\n  b ^ (2 * e') \u2261\u27e8 cong (b ^_) (suc-injective (trans (+-comm 1 _) eq)) \u27e9\n  b ^ e \u220e)\n\n", "meta": {"hexsha": "0e79fa7c05b86b73e4be6e69d150ee04912055a0", "size": 2130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Squaring.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Squaring.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Squaring.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 32.7692307692, "max_line_length": 83, "alphanum_fraction": 0.541314554, "num_tokens": 993, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009457116781, "lm_q2_score": 0.855851143290548, "lm_q1q2_score": 0.7830190203849433}}
{"text": "open import Relation.Binary.Core\n\nmodule BBSTree.Properties  {A : Set} \n                     (_\u2264_ : A \u2192 A \u2192 Set)\n                     (trans\u2264 : Transitive _\u2264_) where\n\nopen import BBSTree _\u2264_\nopen import Bound.Total A\nopen import Bound.Total.Order.Properties _\u2264_ trans\u2264\nopen import List.Order.Simple _\u2264_\nopen import List.Order.Simple.Properties _\u2264_ trans\u2264\nopen import List.Sorted _\u2264_\n\nlemma-bbst-*\u2264 : {b : Bound}(x : A) \u2192 (t : BBSTree b (val x)) \u2192 flatten t *\u2264 x\nlemma-bbst-*\u2264 x (bslf _) = lenx\nlemma-bbst-*\u2264 x (bsnd {x = y} b\u2264y y\u2264x l r) = lemma-++-*\u2264 (lemma-LeB\u2264 y\u2264x) (lemma-bbst-*\u2264 y l) (lemma-bbst-*\u2264 x r)\n\nlemma-bbst-\u2264* : {b : Bound}(x : A) \u2192 (t : BBSTree (val x) b) \u2192 x \u2264* flatten t\nlemma-bbst-\u2264* x (bslf _) = genx\nlemma-bbst-\u2264* x (bsnd {x = y} x\u2264y y\u2264t l r) = lemma-\u2264*-++ (lemma-LeB\u2264 x\u2264y) (lemma-bbst-\u2264* x l) (lemma-bbst-\u2264* y r)\n\nlemma-bbst-sorted : {b t : Bound}(t : BBSTree b t) \u2192 Sorted (flatten t)\nlemma-bbst-sorted (bslf _) = nils\nlemma-bbst-sorted (bsnd {x = x} b\u2264x x\u2264t l r) = lemma-sorted++ (lemma-bbst-*\u2264 x l) (lemma-bbst-\u2264* x r) (lemma-bbst-sorted l) (lemma-bbst-sorted r)\n", "meta": {"hexsha": "4ad3c06cc886e1fccd72b9d044ff3379d6110948", "size": 1086, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BBSTree/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BBSTree/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BBSTree/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.44, "max_line_length": 145, "alphanum_fraction": 0.6012891344, "num_tokens": 445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693702514737, "lm_q2_score": 0.824461932846258, "lm_q1q2_score": 0.7829662445624186}}
{"text": "module x01-842Naturals-hc-2 where\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n{-# BUILTIN NATURAL \u2115 #-}\n\none : \u2115\none = suc zero\n\ntwo : \u2115\ntwo = suc (suc zero)\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e)\n\nseven : \u2115\nseven = suc (suc (suc (suc (suc (suc (suc zero))))))\n\n_ : seven \u2261 7\n_ = refl\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n\nsuc m + n = suc (m + n)\n\n_ : 2 + 3 \u2261 5\n_ = refl\n\n_ : 2 + 3 \u2261 5\n_ =\n  begin\n    2 + 3\n  \u2261\u27e8\u27e9    -- is shorthand for\n    (suc (suc zero)) + (suc (suc (suc zero)))\n  \u2261\u27e8\u27e9    -- many steps condensed\n    5\n  \u220e\n\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  * n = zero\nsuc m * n = n + (m * n)\n\n_ =\n  begin\n    2 * 3\n  \u2261\u27e8\u27e9    -- many steps condensed\n    6\n  \u220e\n\n_ : 3 * 4 \u2261 12\n_ = refl\n\n_^_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm ^ zero  = suc zero\nm ^ suc n = m * (m ^ n)\n\n_ : 2 ^ 0 \u2261 1\n_ = refl\n\n_ : 2 ^ 1 \u2261 2\n_ = refl\n\n_ : 2 ^ 2 \u2261 4\n_ = refl\n\n_ : 2 ^ 3 \u2261 8\n_ = refl\n\n_ : 3 ^ 3 \u2261 27\n_ = refl\n\n_\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  \u2238     n = zero\nm     \u2238  zero = m\nsuc m \u2238 suc n = m \u2238 n\n\n_ : 3 \u2238 2 \u2261 1\n_ = refl\n\n_ : 2 \u2238 3 \u2261 0\n_ = refl\n\ninfixl 6  _+_  _\u2238_\ninfixl 7  _*_\n\n{-# BUILTIN NATPLUS  _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n{-# BUILTIN NATMINUS _\u2238_ #-}\n\n-- Binary representation.\n\ndata Bin-\u2115 : Set where\n  bits : Bin-\u2115\n  _x0 : Bin-\u2115 \u2192 Bin-\u2115\n  _x1 : Bin-\u2115 \u2192 Bin-\u2115\n\n-- Our representation of zero is different from PLFA.\n-- We use the empty sequence of bits (more consistent).\n\nbin-zero : Bin-\u2115\nbin-zero = bits\n\nbin-one : Bin-\u2115\nbin-one = bits x1     -- 1 in binary\n\nbin-two : Bin-\u2115\nbin-two = bits x1 x0  -- 10 in binary\n\n-- 842 exercise: Increment (1 point)\n-- Define increment (add one).\n\ninc : Bin-\u2115 \u2192 Bin-\u2115\ninc  bits  = bits x1\ninc (m x0) = m    x1\ninc (m x1) = (inc m) x0\n\n_ : inc (bits) \u2261 bits x1\n_ = refl\n_ : inc (bits          x1) \u2261 bits       x1 x0\n_ = refl\n_ : inc (bits       x1 x0) \u2261 bits       x1 x1\n_ = refl\n_ : inc (bits       x1 x1) \u2261 bits    x1 x0 x0\n_ = refl\n_ : inc (bits    x1 x0 x0) \u2261 bits    x1 x0 x1\n_ = refl\n_ : inc (bits    x1 x0 x1) \u2261 bits    x1 x1 x0\n_ = refl\n_ : inc (bits    x1 x1 x0) \u2261 bits    x1 x1 x1\n_ = refl\n_ : inc (bits    x1 x1 x1) \u2261 bits x1 x0 x0 x0\n_ = refl\n_ : inc (bits x1 x0 x1 x1) \u2261 bits x1 x1 x0 x0\n_ = refl\n\ndbl : \u2115 \u2192 \u2115\ndbl zero = zero\ndbl (suc m) = suc (suc (dbl m))\n\ntob : \u2115 \u2192 Bin-\u2115\ntob  zero   = bits\ntob (suc m) = inc (tob m)\n\nfromb : Bin-\u2115 \u2192 \u2115\nfromb  bits  = zero\nfromb (n x0) =      dbl (fromb n)\nfromb (n x1) = suc (dbl (fromb n))\n\n_ : tob 6 \u2261 bits x1 x1 x0\n_ = refl\n\n_ : fromb  bits           \u2261 0\n_ = refl\n_ : fromb (bits       x0) \u2261 0\n_ = refl\n_ : fromb (bits       x1) \u2261 1\n_ = refl\n_ : fromb (bits    x1 x0) \u2261 2\n_ = refl\n_ : fromb (bits    x1 x1) \u2261 3\n_ = refl\n_ : fromb (bits x1 x1 x0) \u2261 6\n_ = refl\n_ : fromb (bits x1 x1 x0) \u2261 6\n_ = refl\n\n-- Do NOT use 'to' and 'from'. Work with Bin-\u2115 as if \u2115 did not exist.\n_bin-+_ : Bin-\u2115 \u2192 Bin-\u2115 \u2192 Bin-\u2115\nbits   bin-+     n  =                    n\nm      bin-+  bits  =            m\n(m x0) bin-+ (n x0) =           (m bin-+ n) x0\n(m x0) bin-+ (n x1) =      inc ((m bin-+ n) x0)\n(m x1) bin-+ (n x0) =      inc ((m bin-+ n) x0)\n(m x1) bin-+ (n x1) = inc (inc ((m bin-+ n) x0))\n\n_ : (bits x1 x0 x0 x0) bin-+ (bits x1) \u2261 (bits x1 x0 x0 x1)\n_ = refl\n_ : (bits x1 x0 x0 x1) bin-+ (bits x1) \u2261 (bits x1 x0 x1 x0)\n_ = refl\n_ : (bits x1 x0 x0 x0) bin-+ (bits x1 x1 x1) \u2261 (bits x1 x1 x1 x1)\n_ = refl\n_ : (tob 6) bin-+ (tob 2) \u2261 (tob 8)\n_ = refl\n_ : (bits x1 x0) bin-+ (bits x1 x1) \u2261 (bits x1 x0 x1)\n_ = refl\n", "meta": {"hexsha": "a929e643a2ec6107eaa30e1d1711192b9a590874", "size": 3416, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals-hc-2.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals-hc-2.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals-hc-2.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 18.170212766, "max_line_length": 69, "alphanum_fraction": 0.5181498829, "num_tokens": 1616, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361604769413, "lm_q2_score": 0.8577681013541611, "lm_q1q2_score": 0.7826586329791867}}
{"text": "\nmodule Logic.Relations where\n\nimport Logic.Base\nimport Data.Bool\n\nRel : Set -> Set1\nRel A = A -> A -> Set\n\nReflexive : {A : Set} -> Rel A -> Set\nReflexive {A} _R_ = (x : A) -> x R x\n\nSymmetric : {A : Set} -> Rel A -> Set\nSymmetric {A} _R_  = (x y : A) -> x R y -> y R x\n\nTransitive : {A : Set} -> Rel A -> Set\nTransitive {A} _R_ = (x y z : A) -> x R y -> y R z -> x R z\n\nCongruent : {A : Set} -> Rel A -> Set\nCongruent {A} _R_ = (f : A -> A)(x y : A) -> x R y -> f x R f y\n\nSubstitutive : {A : Set} -> Rel A -> Set1\nSubstitutive {A} _R_ = (P : A -> Set)(x y : A) -> x R y -> P x -> P y\n\nmodule PolyEq (_\u2261_ : {A : Set} -> Rel A) where\n\n  Antisymmetric : {A : Set} -> Rel A -> Set\n  Antisymmetric {A} _R_ = (x y : A) -> x R y -> y R x -> x \u2261 y\n\nmodule MonoEq {A : Set}(_\u2261_ : Rel A) where\n\n  Antisymmetric : Rel A -> Set\n  Antisymmetric _R_ = (x y : A) -> x R y -> y R x -> x \u2261 y\n\nopen Logic.Base\n\nTotal : {A : Set} -> Rel A -> Set\nTotal {A} _R_ = (x y : A) -> (x R y) \\/ (y R x)\n\nDecidable : (P : Set) -> Set\nDecidable P = P \\/ \u00ac P\n\n", "meta": {"hexsha": "a87a668b665b1195588a7885b36f559129963008", "size": 1032, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/lib/Logic/Relations.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/lib/Logic/Relations.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/lib/Logic/Relations.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 24.0, "max_line_length": 69, "alphanum_fraction": 0.5145348837, "num_tokens": 430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966717067253, "lm_q2_score": 0.8267117898012105, "lm_q1q2_score": 0.7825626286865358}}
{"text": "module Peano where\n  open import IPL\n\n  data \u2115 : Set where\n    zero : \u2115 -- Axiom 2.1. 0 is a natural number\n    _++ : \u2115 \u2192 \u2115 -- Axiom 2.2. If n is a natural number, then n++ is also a natural number\n\n  data _\u2261_ : \u2115 \u2192 \u2115 \u2192 Set where\n    refl : {a : \u2115} \u2192 a \u2261 a\n\n  axiom23 : {n : \u2115} \u2192 \u00ac (zero \u2261 (n ++))\n  axiom23 = \u03bb ()\n\n  axiom24 : {n m : \u2115} \u2192 (n ++) \u2261 (m ++) \u2192 n \u2261 m\n  axiom24 refl = refl\n\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115 -- Definition 2.2.1\n  zero + m = m\n  (n ++) + m = (n + m) ++\n\n  \u2261-sec : {n m : \u2115} \u2192 n \u2261 m \u2192 (n ++) \u2261 (m ++)\n  \u2261-sec refl = refl \n\n  \u2261-comm : {n m : \u2115} \u2192 n \u2261 m \u2192 m \u2261 n\n  \u2261-comm refl = refl\n\n  \u2261-trans : {n m p : \u2115} \u2192 n \u2261 m \u2192 m \u2261 p \u2192 n \u2261 p\n  \u2261-trans refl refl = refl\n\n  lemma222 : (n : \u2115) \u2192 (n + zero) \u2261 n\n  lemma222 zero = refl\n  lemma222 (n ++) = \u2261-sec (lemma222 n) \n\n  lemma223 : (n m : \u2115) \u2192 (n + (m ++)) \u2261 ((n + m) ++)\n  lemma223 zero m = refl\n  lemma223 (n ++) m = \u2261-sec (lemma223 n m)\n\n  -- Addition is commutative\n  prop224 : (n m : \u2115) \u2192 (n + m) \u2261 (m + n)\n  prop224 zero m = \u2261-comm (lemma222 m)\n  prop224 (n ++) m = \u2261-trans (\u2261-sec (prop224 n m)) (\u2261-comm (lemma223 m n))\n\n  -- Addition is associative\n  prop225 : (a b c : \u2115) \u2192 ((a + b) + c) \u2261 (a + (b + c))\n  prop225 zero b c = refl\n  prop225 (a ++) b c = \u2261-sec (prop225 a b c)\n\n  -- Cancellation law\n  prop226 : (a b c : \u2115) \u2192 (a + b) \u2261 (a + c) \u2192 b \u2261 c\n  prop226 zero b c = \u03bb z \u2192 z\n  prop226 (a ++) b c = \u03bb z \u2192 (prop226 a b c) (axiom24 z)\n", "meta": {"hexsha": "72bcadde4ad88ae3b39628483044f6b015332d48", "size": 1397, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "peano.agda", "max_stars_repo_name": "alf239/tao", "max_stars_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "peano.agda", "max_issues_repo_name": "alf239/tao", "max_issues_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "peano.agda", "max_forks_repo_name": "alf239/tao", "max_forks_repo_head_hexsha": "11f8071e325d07d19a53157cb065d88244b20cb4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8653846154, "max_line_length": 89, "alphanum_fraction": 0.4781675018, "num_tokens": 612, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422186079558, "lm_q2_score": 0.822189121808099, "lm_q1q2_score": 0.7820187854318821}}
{"text": "module x04equality where\n\n------------------------------------------------------------------------------\n-- EQUALITY\n\n-- for any      type A\n-- for any x of type A\n-- refl constructor provides evidence that x \u2261 x\n-- i.e., every value is equal to itself\ndata _\u2261_ {A : Set} (x : A) : A \u2192 Set where\n  refl : x \u2261 x\n\ninfix 4 _\u2261_\n\n-- tell Agda which type corresponds to equality\n{-# BUILTIN EQUALITY _\u2261_ #-}\n\n{-\nNote:\n- 1st arg to _\u2261_ is PARAMETER (x : A)\n  - BEST PRACTICE: use parameters when possible\n  - can be a parameter because it does not vary\n- 2nd arg is an INDEX in A \u2192 Set\n  - must be an index, so it can be required to be equal to the first\n\n------------------------------------------------------------------------------\n-- EQUALITY is an EQUIVALENCE RELATION (reflexive, symmetric, transitive)\n\nreflexivity in the def of equality, via refl constructor\n-}\n\n-- symmetry\nsym : \u2200 {A : Set} {x y : A}\n  \u2192 x \u2261 y  -- arg has type x \u2261 y\n    -----\n  \u2192 y \u2261 x\nsym refl -- LHS :instantiates arg to refl CONSTRUCTOR (only one possible)\n         -- refl requires x y to be the same\n  = refl -- RHS : need a term of type x \u2261 x, so refl\n\n-- transitive\ntrans : \u2200 {A : Set} {x y z : A}\n  \u2192 x \u2261 y\n  \u2192     y \u2261 z\n    -----\n  \u2192 x \u2261     z\ntrans refl refl = refl\n\n------------------------------------------------------------------------------\n-- EQUALITY SATISFIES CONGRUENCE\n\n-- if two terms are equal, they remain so after same function is applied to both\ncong : \u2200 {A B : Set} (f : A \u2192 B) {x y : A}\n  \u2192   x \u2261   y\n    ---------\n  \u2192 f x \u2261 f y\ncong f refl = refl\n\n-- where f takes two args\ncong\u2082 : \u2200 {A B C : Set} (f : A \u2192 B \u2192 C) {u x : A} {v y : B}\n  \u2192   u   \u2261   x\n  \u2192     v \u2261     y\n    -------------\n  \u2192 f u v \u2261 f x y\ncong\u2082 f refl refl = refl\n\n-- if two functions are equal, then applying them to same term yields equal terms\ncong-app : \u2200 {A B : Set} {f g : A \u2192 B}\n  \u2192             f   \u2261 g\n    ---------------------\n  \u2192 \u2200 (x : A) \u2192 f x \u2261 g x\ncong-app refl x = refl\n\n------------------------------------------------------------------------------\n-- EQUALITY SATISFIES SUBSTITUTION\n\n-- if two values are equal and a predicate holds of first then it also holds of second\nsubst : \u2200 {A : Set} {x y : A} (P : A \u2192 Set)\n  \u2192   x \u2261  y\n    ---------\n  \u2192 P x\n  \u2192     P y\nsubst P refl px = px\n\n------------------------------------------------------------------------------\n--  CHAINS OF EQUATIONS (aka EQUATIONAL REASONING)\n\nmodule \u2261-Reasoning {A : Set} where\n\n  infix  1 begin_\n  infixr 2 _\u2261\u27e8\u27e9_ _\u2261\u27e8_\u27e9_\n  infix  3 _\u220e\n\n  -- identity : this is just used to make proof look nice\n  begin_ : \u2200 {x y : A}\n    \u2192 x \u2261 y\n      -----\n    \u2192 x \u2261 y\n  begin x\u2261y = x\u2261y\n\n  -- think of _\u2261\u27e8\u27e9_ as equivalent to _\u2261\u27e8 refl \u27e9_\n  _\u2261\u27e8\u27e9_ : \u2200 (x : A) {y : A}\n    \u2192 x \u2261 y\n      -----\n    \u2192 x \u2261 y\n  x \u2261\u27e8\u27e9 x\u2261y = x\u2261y\n\n  _\u2261\u27e8_\u27e9_ : \u2200 (x : A) {y z : A}\n    \u2192 x \u2261 y\n    \u2192 y \u2261 z\n      -----\n    \u2192 x \u2261 z\n  x \u2261\u27e8 x\u2261y \u27e9 y\u2261z = trans x\u2261y y\u2261z\n\n  _\u220e : \u2200 (x : A)\n      -----\n    \u2192 x \u2261 x\n  x \u220e = refl\n\nopen \u2261-Reasoning\n\ntrans\u2032 : \u2200 {A : Set} {x y z : A}\n  \u2192 x \u2261 y\n  \u2192     y \u2261 z\n    -----\n  \u2192 x \u2261     z\ntrans\u2032 {A} {x} {y} {z} x\u2261y y\u2261z =\n  begin          -- Goal: x \u2261 z   ; y\u2261z : y \u2261 z; x\u2261y : x \u2261 y\n    x \u2261\u27e8 x\u2261y \u27e9   -- Goal: y \u2261 z\n    y \u2261\u27e8 y\u2261z \u27e9   -- Goal: z \u2261 z\n    z\n  \u220e\n\n{-\nEXERCISE trans and \u2261-Reasoning (practice) TODO\nCannot use definition of trans\u2019 using \u2261-Reasoning as the definition for trans.\nWhy?\nHint: look at the definition of _\u2261\u27e8_\u27e9_\n\n-- Your code goes here\n\n------------------------------------------------------------------------------\nChains of equations, another example : addition is commutative\n-}\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero    + n = n\n(suc m) + n = suc (m + n)\n\ninfixl 6  _+_\n\n-- to save space, postulate (rather than prove) two lemmas:\n-- POSTULATE : specifies a signature but no def. Use with care. DON'T postulate something false!\npostulate\n  +-identity : \u2200 (m   : \u2115) \u2192 m + zero  \u2261 m\n  +-suc      : \u2200 (m n : \u2115) \u2192 m + suc n \u2261 suc (m + n)\n\n+-comm : \u2200 (m n : \u2115) \u2192 m + n \u2261 n + m\n+-comm m zero =\n  begin\n    m + zero    \u2261\u27e8 +-identity m \u27e9\n    m           \u2261\u27e8\u27e9\n    zero + m\n  \u220e\n+-comm m (suc n) =\n  begin\n         m + suc n  \u2261\u27e8 +-suc m n \u27e9\n    suc (m +     n) \u2261\u27e8 cong suc (+-comm m n) \u27e9\n    suc (n +     m) \u2261\u27e8\u27e9 -- terms are equivalent to simplified term\n    suc  n +     m\n  \u220e\n\n{-\n------------------------------------------------------------------------------\nExercise \u2264-Reasoning (stretch)\n\nredo proof of +-mono\u02b3-\u2264 (from Chapter Relations) using an analogue of \u2261-Reasoning\n\ndefine \u2264-Reasoning\n\nuse it to write out proof that addition is monotonic with regard to inequality\nby redoing all of +-mono\u02e1-\u2264, +-mono\u02b3-\u2264, and +-mono-\u2264\n-}\n\nmodule \u2264-Reasoning {A : Set} where\n\n  data _\u2264_ : \u2115 \u2192 \u2115 \u2192 Set where\n    z\u2264n : \u2200 {n : \u2115}\n        --------\n      \u2192 zero \u2264 n\n\n    s\u2264s : \u2200 {m n : \u2115}\n      \u2192     m \u2264     n\n        -------------\n      \u2192 suc m \u2264 suc n\n\n  infix 4 _\u2264_\n\n  \u2264-trans : \u2200 {m n p : \u2115} \u2192 m \u2264 n \u2192 n \u2264 p \u2192 m \u2264 p\n  \u2264-trans      z\u2264n         _  = z\u2264n\n  \u2264-trans (s\u2264s m\u2264n) (s\u2264s n\u2264p) = s\u2264s (\u2264-trans m\u2264n n\u2264p)\n\n  infix  1 begin\u2264_\n  infixr 2 _\u2264\u27e8\u27e9_ _\u2264\u27e8_\u27e9_\n  infix  3 _\u220e\u2264\n\n  --------------------------------------------------\n\n  begin\u2264_ : \u2200 {x y : \u2115}\n    \u2192 x \u2264 y\n      -----\n    \u2192 x \u2264 y\n  begin\u2264 x\u2264y = x\u2264y\n\n  -- can think of _\u2264\u27e8\u27e9_ as equivalent to _\u2264\u27e8 refl \u27e9_\n  _\u2264\u27e8\u27e9_ : \u2200 (x : \u2115) {y : \u2115}\n    \u2192 x \u2264 y\n      -----\n    \u2192 x \u2264 y\n  x \u2264\u27e8\u27e9 x\u2264y = x\u2264y\n\n  _\u2264\u27e8_\u27e9_ : \u2200 (x : \u2115) {y z : \u2115}\n    \u2192 x \u2264 y\n    \u2192 y \u2264 z\n      -----\n    \u2192 x \u2264 z\n  x \u2264\u27e8 x\u2264y \u27e9 y\u2264z = \u2264-trans x\u2264y y\u2264z\n\n  _\u220e\u2264 : \u2200 (x : \u2115)\n      -----\n    \u2192 x \u2264 x\n  zero  \u220e\u2264 = z\u2264n\n  suc x \u220e\u2264 = s\u2264s (x \u220e\u2264)\n\n  --------------------------------------------------\n\n  +-mono\u02b3-\u2264 : \u2200 (n p q : \u2115)\n    \u2192      p  \u2264      q\n      -------------\n    \u2192 (n + p) \u2264 (n + q)\n\n  +-mono\u02b3-\u2264 zero    p q p\u2264q  =\n    begin\u2264\n      zero + p \u2264\u27e8\u27e9\n             p \u2264\u27e8 p\u2264q \u27e9\n             q \u2264\u27e8\u27e9\n      zero + q\n    \u220e\u2264\n\n  +-mono\u02b3-\u2264 (suc n) p q p\u2264q =\n    begin\u2264\n      suc n + p \u2264\u27e8 s\u2264s (+-mono\u02b3-\u2264 n p q p\u2264q) \u27e9\n      suc n + q\n    \u220e\u2264\n\n  -------------------------\n\n  postulate\n    +-comm-\u2264 : \u2200 (m n : \u2115) \u2192 m + n \u2264 n + m\n\n  +-mono\u02e1-\u2264 : \u2200 (m n p : \u2115)\n    \u2192 m     \u2264 n\n      -------------\n    \u2192 m + p \u2264 n + p\n\n  +-mono\u02e1-\u2264 m n p m\u2264n =\n    begin\u2264\n      m + p \u2264\u27e8 +-comm-\u2264 m p \u27e9\n      p + m \u2264\u27e8 +-mono\u02b3-\u2264 p m n m\u2264n \u27e9\n      p + n \u2264\u27e8 +-comm-\u2264 p n \u27e9\n      n + p\n    \u220e\u2264\n\n  -------------------------\n\n  +-mono-\u2264 : \u2200 (m n p q : \u2115)\n    \u2192 m     \u2264 n\n    \u2192     p \u2264     q\n      -------------\n    \u2192 m + p \u2264 n + q\n  +-mono-\u2264 m n p q m\u2264n p\u2264q =\n    begin\u2264\n      m + p \u2264\u27e8 +-mono\u02e1-\u2264 m n p m\u2264n \u27e9\n      n + p \u2264\u27e8 +-mono\u02b3-\u2264 n p q p\u2264q \u27e9\n      n + q\n    \u220e\u2264\n\n{-\n------------------------------------------------------------------------------\n-- Rewriting\n-}\n\ndata even : \u2115 \u2192 Set\ndata odd  : \u2115 \u2192 Set\n\ndata even where\n\n  even-zero : even zero\n\n  even-suc : \u2200 {n : \u2115}\n    \u2192 odd       n\n      ------------\n    \u2192 even (suc n)\n\ndata odd where\n  odd-suc : \u2200 {n : \u2115}\n    \u2192 even     n\n      -----------\n    \u2192 odd (suc n)\n\n{-\ngiven even (m + n) holds\nprove even (n + m) holds\n\nREWRITE: notation to support this kind of reasoning\n-}\n\n-- then use rewrite\neven-comm : \u2200 (m n : \u2115)\n  \u2192 even (m + n)\n    ------------\n  \u2192 even (n + m)\neven-comm m n ev      -- even (n + m)\n  rewrite +-comm n m  -- Goal: even (m + n); ev : even (m + n)\n  = ev\n\n{-\nkeyword REWRITE : followed by evidence of an equality\nThat equality is used to rewrite the type of the goal and of any variable in scope.\n-}\n\neven-comm' : \u2200 (m n : \u2115)\n  \u2192 even (m + n)\n    ------------\n  \u2192 even (n + m)\neven-comm' m n ev        -- Goal: even (n + m)  ; ev : even (m + n)\n  rewrite\n    +-comm m n           -- Goal: even (n + m)  ; ev : even (n + m) <-- rewrites evidence\n  = ev --   ^\n--          note: arg order diff than 'even-comm' above\n\n------------------------------------------------------------------------------\n-- Multiple rewrites : each separated by a vertical bar\n\n+-comm\u2032 : \u2200 (m n : \u2115) \u2192 m + n \u2261 n + m\n+-comm\u2032 zero    n        --    zero + n \u2261 n + zero\n                         --           n \u2261 n + zero\n  rewrite\n    +-identity n         --           n \u2261 n\n  = refl\n+-comm\u2032 (suc m) n        -- suc  m + n  \u2261 n + suc m\n                         -- suc (m + n) \u2261 n + suc m\n  rewrite\n    +-suc   n m          -- suc (m + n) \u2261 suc (n + m) <-- rewrites LHS\n  | +-comm\u2032 m n          -- suc (n + m) \u2261 suc (n + m) <-- rewrites RHS\n  = refl\n\n{-\nPrevious +-comm proof required cong suc (+-comm m n) (invoking inductive hypothesis).\nRewriting automatically takes congruence into account.\nProofs with rewriting are shorter.\nProofs as chains of equalities are easier to follow.\n-}\n\n+-comm\u2032' : \u2200 (m n : \u2115) \u2192 m + n \u2261 n + m\n+-comm\u2032' zero    n =\n  begin\n    zero + n \u2261\u27e8\u27e9\n           n \u2261\u27e8 +-comm\u2032 zero n \u27e9\n    n + zero\n  \u220e\n+-comm\u2032' (suc m) n =\n  begin\n    suc m + n \u2261\u27e8 +-comm\u2032 (suc m)  n \u27e9\n    n + suc m\n  \u220e\n\n{-\n------------------------------------------------------------------------------\n--rewrite is shorthand for 'WITH'\n-}\n\neven-comm\u2032 : \u2200 (m n : \u2115)\n  \u2192 even (m + n)\n    ------------\n  \u2192 even (n + m)\neven-comm\u2032 m n ev with   m + n  | +-comm m n\n...                  | .(n + m) | refl       = ev\n\n{-\nWITH : can be followed by one or more expressions, separated by bars\n- where each equation has the same number of patterns\n\n1st COLUMN asserts m + n and n + m are identical\n2nd COLUMN justifies assertion with evidence of the appropriate equality\n\nDOT PATTERN : .(n + m)\n- dot followed by an expression\n- used when other info forces value matched to be equal to value of expression in dot pattern\n\nHere: m + n \u2261 n + m justified by matching +-comm m n with refl\n\n------------------------------------------------------------------------------\n-- using SUBSTITUTION instead of REWRITE\n-}\n\neven-comm\u2033 : \u2200 (m n : \u2115)\n  \u2192 even (m + n)\n    ------------\n  \u2192 even (n + m)\neven-comm\u2033 m n\n  --      m + n \u2261 n + m\n  --            v\n--= subst even {!!}\n--= subst {!!}  (+-comm m n)\n--         ^\n-- Constraints\n-- ?0 (n + m) =< even (n + m)\n-- even (m + n) =< ?0 (m + n)\n  = subst even (+-comm m n)\n\n{-\n------------------------------------------------------------------------------\n-- Leibniz equality : TWO OBJECTS EQUAL IFF THEY SATISFY THE SAME PROPERTIES.\n\nThe form of asserting equality so far is due to Martin L\u00f6f (1975).\n\nAnother form is due to Leibniz (1686).\n\n\nDefine Leibniz equality and show that two terms satisfy Leibniz equality\nIFF they satisfy Martin L\u00f6f equality.\n\nx \u2250 y\nholds if\nevery property P that holds of x also holds of y\nalso ensures converse\nevery property P that holds of y also holds of x\n\nLet x and y be objects of type A.\nx \u2250 y holds if for every predicate P over type A we have that P x implies P y:\n-}\n\n_\u2250_ : \u2200 {A : Set} (x y : A) \u2192 Set\u2081\n_\u2250_ {A} x y = \u2200 (P : A \u2192 Set) \u2192 P x \u2192 P y\n\n{-\nwrite _\u2250_ {A} x y (instead of infix) to provide access to the implicit parameter A\n\nFIRST USE OF LEVELS\n\nCannot assign Set the type Set\n- would lead to contradictions such as Russell\u2019s Paradox and Girard\u2019s Paradox\n\nhierarchy of types, where Set : Set\u2081, Set\u2081 : Set\u2082, ...\n\n'Set' is an abbreviation for 'Set\u2080'\n\nSince the equation defining _\u2250_ mentions Set on the right-hand side,\nthe corresponding signature must use Set\u2081.\n\n------------------------------------------------------------------------------\nLeibniz equality is reflexive, transitive, symmetric\n-}\n\n-- reflexiviity follows by a variant of the identity function\nrefl-\u2250 : \u2200 {A : Set} {x : A}\n  \u2192 x \u2250 x\nrefl-\u2250 P Px = Px\n\n-- transitivity follows by a variant of function composition\ntrans-\u2250 : \u2200 {A : Set} {x y z : A}\n  \u2192 x \u2250 y\n  \u2192 y \u2250 z\n    -----\n  \u2192 x \u2250 z\ntrans-\u2250 x\u2250y y\u2250z P Px = y\u2250z P (x\u2250y P Px)\n\n-- show that if P x implies P y for all predicates P\n-- then         P y implies P x\nsym-\u2250 : \u2200 {A : Set} {x y : A}\n  \u2192 x \u2250 y           -- given x \u2250 y\n    -----\n  \u2192 y \u2250 x\nsym-\u2250 {A} {x} {y} x\u2250y P = Qy -- TODO : where is 'P' in the signature?\n  where\n    Q : A \u2192 Set     -- instantiate the equality with a predicate Q such that Q z holds\n    Q z = P z \u2192 P x -- if P z implies P x\n\n    Qx : Q x        -- The property Q x is by reflexivity, and hence Q y follows from x \u2250 y.\n    Qx = refl-\u2250 P\n\n    Qy : Q y        --  Q y is the required proof : P y implies P x\n    Qy = x\u2250y Q Qx\n\n{-\n------------------------------------------------------------------------------\nMartin L\u00f6f equality implies Leibniz equality\n\ngiven x \u2261 y\nneed for any P to take evidence of P x to evidence of P y\n\nthe equality of x and y implies that any proof of P x is also a proof of P y\nfollows from substitution\n-}\n\n\u2261-implies-\u2250 : \u2200 {A : Set} {x y : A}\n  \u2192 x \u2261 y\n    -----\n  \u2192 x \u2250 y\n\u2261-implies-\u2250 x\u2261y P = subst P x\u2261y\n\n{-\n------------------------------------------------------------------------------\nLeibniz equality implies Martin L\u00f6f equality\n\ngiven for any P we can take a proof of P x to a proof of P y\nshow x \u2261 y\n\nproof is similar to that for symmetry of Leibniz equality\n-}\n\n\u2250-implies-\u2261 : \u2200 {A : Set} {x y : A}\n  \u2192 x \u2250 y\n    -----\n  \u2192 x \u2261 y\n\u2250-implies-\u2261 {A} {x} {y} x\u2250y = Qy\n  where\n    Q : A \u2192 Set   -- Q is predicate that holds of z if x \u2261 z\n    Q z = x \u2261 z\n\n    Qx : Q x      -- Q x by reflexivity of Martin L\u00f6f equality\n    Qx = refl\n\n    Qy : Q y      -- Q y follows from x \u2250 y\n    Qy = x\u2250y Q Qx -- Q y is required proof : x \u2261 y\n\n{-\nThis section adapted from\n\u2250\u2243\u2261: Leibniz Equality is Isomorphic to Martin-L\u00f6f Identity, Parametrically\ndraft/2017\nby Andreas Abel, Jesper Cockx, Dominique Devries, Andreas Nuyts, and Philip Wadler\n\n------------------------------------------------------------------------------\nUNIVERSE POLYMORPHISM (aka LEVELs)\n\nevery type belongs somewhere in the hierarchy Set\u2080, Set\u2081, Set\u2082, ...\n\nSet abbreviates Set\u2080\n\nSet\u2080 : Set\u2081\nSet\u2081 : Set\u2082\n...\n\nto compare values of a type that belongs to Set \u2113 for some arbitrary level \u2113?\n\nvia UNIVERSE POLYMORPHISM\n\ndefinition is made with respect to an arbitrary level \u2113\n\nto use levels:\n-}\n\nopen import Level using (Level; _\u2294_) renaming (zero to lzero; suc to lsuc)\n\n{-\nrename constructors zero and suc to avoid confusion between levels and naturals\n\nLevels are isomorphic to natural numbers, and have similar constructors:\n\nlzero : Level\nlsuc  : Level \u2192 Level\n\nSet\u2080, Set\u2081, Set\u2082, ... abbreviations for\n\nSet lzero\nSet (lsuc lzero)\nSet (lsuc (lsuc lzero))\n\n_\u2294_ : Level \u2192 Level \u2192 Level\n\nthat given two levels returns the larger of the two.\n-}\n\n-- equality, generalised to an arbitrary level:\ndata _\u2261\u2032_ {\u2113 : Level} {A : Set \u2113} (x : A) : A \u2192 Set \u2113 where\n  refl\u2032 : x \u2261\u2032 x\n\n-- generalised definition of symmetry:\nsym\u2032 : \u2200 {\u2113 : Level} {A : Set \u2113} {x y : A}\n  \u2192 x \u2261\u2032 y\n    ------\n  \u2192 y \u2261\u2032 x\nsym\u2032 refl\u2032 = refl\u2032\n\n{-\nFor simplicity, this book avoids universe polymorphism.\nMost definitions in the standard library are generalised to arbitrary levels as above.\n-}\n\n-- generalised definition of Leibniz equality:\n_\u2250\u2032_ : \u2200 {\u2113 : Level} {A : Set \u2113} (x y : A) \u2192 Set (lsuc \u2113)\n_\u2250\u2032_ {\u2113} {A} x y = \u2200 (P : A \u2192 Set \u2113) \u2192 P x \u2192 P y\n\n{-\nBefore the signature used Set\u2081 as the type of a term that includes Set,\nwhereas here the signature uses Set (lsuc \u2113) as the type of a term that includes Set \u2113.\n\nMost other functions in the standard library are also generalised to arbitrary levels.\n-}\n\n-- definition of composition.\n_\u2218_ : \u2200 {\u2113\u2081 \u2113\u2082 \u2113\u2083 : Level} {A : Set \u2113\u2081} {B : Set \u2113\u2082} {C : Set \u2113\u2083}\n  \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 A \u2192 C\n(g \u2218 f) x = g (f x)\n\n{-\n------------------------------------------------------------------------------\nStandard library\n\nstandard library defines _\u2261\u27e8_\u27e9_ as step-\u2261,\nwhich reverses the order of the arguments\n\nstandard library defines a macro,imported when import step-\u2261\nwhich recovers the original argument order:\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; trans; sym; cong; cong-app; subst)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; step-\u2261; _\u220e)\n\n------------------------------------------------------------------------------\nUnicode\n\n\u2261  U+2261  IDENTICAL TO                     (\\==, \\equiv)\n\u27e8  U+27E8  MATHEMATICAL LEFT ANGLE BRACKET  (\\<)\n\u27e9  U+27E9  MATHEMATICAL RIGHT ANGLE BRACKET (\\>)\n\u220e  U+220E  END OF PROOF                     (\\qed)\n\u2250  U+2250  APPROACHES THE LIMIT             (\\.=)\n\u2113  U+2113  SCRIPT SMALL L                   (\\ell)\n\u2294  U+2294  SQUARE CUP                       (\\lub)\n\u2080  U+2080  SUBSCRIPT ZERO                   (\\_0)\n\u2081  U+2081  SUBSCRIPT ONE                    (\\_1)\n\u2082  U+2082  SUBSCRIPT TWO                    (\\_2)\n-}\n", "meta": {"hexsha": "9578edfd598bf78818bab8922dfcb6fe2488fa12", "size": 16140, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x04equality.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x04equality.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x04equality.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 24.7926267281, "max_line_length": 96, "alphanum_fraction": 0.4861833953, "num_tokens": 5461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.901920681802153, "lm_q2_score": 0.8670357598021707, "lm_q1q2_score": 0.7819974836276216}}
{"text": "{-# OPTIONS --safe #-}\n\nmodule Invert where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Nat\n\nopen import Data.Nat.Properties\n\n_\u2218_ : \u2200 {A B C : Set} \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 (A \u2192 C)\n(g \u2218 f) x = g (f x)\n\npred\u2082 : \u2115 \u2192 \u2115\npred\u2082 = pred \u2218 pred\n\nlemma : (a b : \u2115) \u2192 pred\u2082 (suc a + suc a) \u2261 pred\u2082 (suc b + suc b)\n        \u2192 a + a \u2261 b + b\nlemma a b p =\n  begin\n  a + a \u2261\u27e8\u27e9\n  pred\u2082 (suc (suc (a + a))) \u2261\u27e8\u27e9\n  pred\u2082 (suc (suc a + a)) \u2261\u27e8 cong (pred\u2082 \u2218 suc) (+-comm (suc a) a)  \u27e9\n  pred\u2082 (suc (a + suc a)) \u2261\u27e8\u27e9\n  pred\u2082 (suc a + suc a) \u2261\u27e8 p \u27e9\n  pred\u2082 (suc b + suc b) \u2261\u27e8\u27e9\n  pred\u2082 (suc (b + suc b)) \u2261\u27e8 cong (pred\u2082 \u2218 suc) (+-comm b (suc b)) \u27e9\n  pred\u2082 (suc (suc b + b)) \u2261\u27e8\u27e9\n  b + b\n  \u220e where open \u2261-Reasoning\n\ninvert : (a b : \u2115) \u2192 a + a \u2261 b + b \u2192 a \u2261 b\ninvert zero zero p = refl\ninvert (suc m) (suc n) p = cong suc (invert m n (lemma m n (cong pred\u2082 p)))\n", "meta": {"hexsha": "74049821bde48b8b288184acf2e4c6ca9ee734b2", "size": 853, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Invert.agda", "max_stars_repo_name": "anqurvanillapy/fpl", "max_stars_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-24T22:47:47.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-24T22:47:47.000Z", "max_issues_repo_path": "agda/Invert.agda", "max_issues_repo_name": "anqurvanillapy/fpl", "max_issues_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Invert.agda", "max_forks_repo_name": "anqurvanillapy/fpl", "max_forks_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0882352941, "max_line_length": 75, "alphanum_fraction": 0.5216881594, "num_tokens": 394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240194661945, "lm_q2_score": 0.8333245994514084, "lm_q1q2_score": 0.7817618227574118}}
{"text": "module Bin-laws where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; sym; cong)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; step-\u2261; _\u220e)\nopen import Data.Nat using (\u2115; zero; suc; _+_; _*_)\n\nopen import Induction\u2032 using (+-suc; +-identity\u02b3; +-comm; +-assoc)\n\n-- 2\u9032\u6570\u306e\u8868\u73fe\ndata Bin : Set where\n  \u27e8\u27e9 : Bin\n  _O : Bin \u2192 Bin\n  _I : Bin \u2192 Bin\n\n-- 2\u9032\u6570\u306e\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\ninc : Bin \u2192 Bin\ninc \u27e8\u27e9    = \u27e8\u27e9 I\ninc (b O) = b I\ninc (b I) = inc b O\n\n-- \u81ea\u7136\u6570\u304b\u30892\u9032\u6570\u3078\u306e\u5909\u63db\nto : \u2115 \u2192 Bin\nto zero    = \u27e8\u27e9 O\nto (suc n) = inc (to n)\n\n-- 2\u9032\u6570\u304b\u3089\u81ea\u7136\u6570\u3078\u306e\u5909\u63db\nfrom : Bin \u2192 \u2115\nfrom \u27e8\u27e9    = zero\nfrom (b O) = 2 * (from b)\nfrom (b I) = 2 * (from b) + 1\n\n2*n\u2261n+n : \u2200 (n : \u2115) \u2192 2 * n \u2261 n + n\n2*n\u2261n+n n =\n  begin\n    2 * n\n  \u2261\u27e8\u27e9\n    n + (1 * n)\n  \u2261\u27e8\u27e9\n    n + (n + (0 * n))\n  \u2261\u27e8\u27e9\n    n + (n + 0)\n  \u2261\u27e8 cong (n +_) (+-identity\u02b3 n) \u27e9\n    n + n\n  \u220e\n\n+-suc-suc : \u2200 (m n : \u2115) \u2192 (suc m) + (suc n) \u2261 suc (suc (m + n))\n+-suc-suc m n =\n  begin\n    (suc m) + (suc n)\n  \u2261\u27e8 +-suc (suc m) n \u27e9\n    suc ((suc m) + n)\n  \u2261\u27e8 cong suc (sym (+-assoc 1 m n)) \u27e9\n    suc (suc (m + n))\n  \u220e\n\n-- \u5909\u63db\u306e\u524d\u5f8c\u3069\u3061\u3089\u3067\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u3066\u3082\u7d50\u679c\u306f\u7b49\u3057\u3044\nfrom\u2218inc\u2261suc\u2218from : \u2200 (b : Bin) \u2192 from (inc b) \u2261 suc (from b)\nfrom\u2218inc\u2261suc\u2218from \u27e8\u27e9 =\n  begin\n    from (inc \u27e8\u27e9)\n  \u2261\u27e8\u27e9\n    from (\u27e8\u27e9 I)\n  \u2261\u27e8\u27e9\n    suc zero\n  \u2261\u27e8\u27e9\n    suc (from \u27e8\u27e9)\n  \u220e\nfrom\u2218inc\u2261suc\u2218from (b O) =\n  begin\n    from (inc (b O))\n  \u2261\u27e8\u27e9\n    from (b I)\n  \u2261\u27e8\u27e9\n    2 * (from b) + 1\n  \u2261\u27e8\u27e9\n    from (b O) + 1\n  \u2261\u27e8 +-suc (from (b O)) zero \u27e9\n    suc (from (b O) + zero)\n  \u2261\u27e8 cong suc (+-identity\u02b3 (from (b O))) \u27e9\n    suc (from (b O))\n  \u220e\nfrom\u2218inc\u2261suc\u2218from (b I) =\n  begin\n    from (inc (b I))\n  \u2261\u27e8\u27e9\n    from ((inc b) O)\n  \u2261\u27e8\u27e9\n    2 * (from (inc b))\n  \u2261\u27e8 cong (2 *_) (from\u2218inc\u2261suc\u2218from b) \u27e9\n    2 * (suc (from b))\n  \u2261\u27e8 2*n\u2261n+n (suc (from b)) \u27e9\n    (suc (from b)) + (suc (from b))\n  \u2261\u27e8 +-suc-suc (from b) (from b) \u27e9\n    suc (suc ((from b) + (from b)))\n  \u2261\u27e8 cong (\u03bb 2*fromb \u2192 suc (suc 2*fromb)) (sym (2*n\u2261n+n (from b))) \u27e9\n    suc (suc (2 * (from b)))\n  \u2261\u27e8 cong suc (+-comm 1 (2 * (from b))) \u27e9\n    suc (2 * (from b) + 1)\n  \u2261\u27e8\u27e9\n    suc (from (b I))\n  \u220e\n\n-- to\u2218from : \u2200 (b : Bin) \u2192 to (from b) \u2261 b\n-- to\u2218from \u27e8\u27e9 = {!!} -- (to zero) \u304c (\u27e8\u27e9 O) \u306b\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u308b\u305f\u3081\u6210\u308a\u7acb\u305f\u306a\u3044\n-- to\u2218from (b O) = {!!}\n-- to\u2218from (b I) = {!!}\n\nfrom\u2218to : \u2200 (n : \u2115) \u2192 from (to n) \u2261 n\nfrom\u2218to zero =\n  begin\n    from (to zero)\n  \u2261\u27e8\u27e9\n    from (\u27e8\u27e9 O)\n  \u2261\u27e8\u27e9\n    2 * (from \u27e8\u27e9)\n  \u2261\u27e8\u27e9\n    2 * zero\n  \u2261\u27e8\u27e9\n    zero\n  \u220e\nfrom\u2218to (suc n) =\n  begin\n    from (to (suc n))\n  \u2261\u27e8\u27e9\n    from (inc (to n))\n  \u2261\u27e8 from\u2218inc\u2261suc\u2218from (to n) \u27e9\n    suc (from (to n))\n  \u2261\u27e8 cong suc (from\u2218to n) \u27e9\n    suc n\n  \u220e\n", "meta": {"hexsha": "8dff0bd2bbde90268be9abcd037d73fe04a1dd20", "size": 2492, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/induction/Bin-laws.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/induction/Bin-laws.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/induction/Bin-laws.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.8787878788, "max_line_length": 68, "alphanum_fraction": 0.4582664526, "num_tokens": 1337, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037302939515, "lm_q2_score": 0.8438951045175643, "lm_q1q2_score": 0.781703183291424}}
{"text": "\nmodule Data.Permutation where\n\nopen import Prelude\nopen import Data.Fin as Fin hiding (_==_; _<_)\nopen import Data.Nat\nopen import Data.Vec\nopen import Logic.Identity\nopen import Logic.Base\nimport Logic.ChainReasoning\n\n-- What is a permutation?\n-- Answer 1: A bijection between Fin n and itself\n\ndata Permutation (n : Nat) : Set where\n  permutation :\n    (\u03c0 \u03c0\u207b\u00b9 : Fin n -> Fin n) ->\n    (forall {i} -> \u03c0 (\u03c0\u207b\u00b9 i) \u2261 i) ->\n    Permutation n\n\nmodule Permutation {n : Nat}(P : Permutation n) where\n\n  private\n    \u03c0' : Permutation n -> Fin n -> Fin n\n    \u03c0' (permutation x _ _) = x\n\n    \u03c0\u207b\u00b9' : Permutation n -> Fin n -> Fin n\n    \u03c0\u207b\u00b9' (permutation _ x _) = x\n\n    proof : (P : Permutation n) -> forall {i} -> \u03c0' P (\u03c0\u207b\u00b9' P i) \u2261 i\n    proof (permutation _ _ x) = x\n\n  \u03c0 : Fin n -> Fin n\n  \u03c0\t  = \u03c0' P\n\n  \u03c0\u207b\u00b9 : Fin n -> Fin n\n  \u03c0\u207b\u00b9\t  = \u03c0\u207b\u00b9' P\n\n  module Proofs where\n\n    \u03c0\u03c0\u207b\u00b9-id : {i : Fin n} -> \u03c0 (\u03c0\u207b\u00b9 i) \u2261 i\n    \u03c0\u03c0\u207b\u00b9-id = proof P\n\n    open module Chain = Logic.ChainReasoning.Poly.Homogenous _\u2261_ (\\x -> refl) (\\x y z -> trans)\n\n    \u03c0\u207b\u00b9-inj : (i j : Fin n) -> \u03c0\u207b\u00b9 i \u2261 \u03c0\u207b\u00b9 j -> i \u2261 j\n    \u03c0\u207b\u00b9-inj i j h =\n      chain> i\n\t === \u03c0 (\u03c0\u207b\u00b9 i)\tby sym \u03c0\u03c0\u207b\u00b9-id\n\t === \u03c0 (\u03c0\u207b\u00b9 j)\tby cong \u03c0 h\n\t === j\t\tby \u03c0\u03c0\u207b\u00b9-id\n\n    -- Generalise\n    lem : {n : Nat}(f g : Fin n -> Fin n)\n\t  -> (forall i -> f (g i) \u2261 i)\n\t  -> (forall i -> g (f i) \u2261 i)\n    lem {zero}  f g inv ()\n    lem {suc n} f g inv i  = ?\n      where\n\tgz\u2260gs : {i : Fin n} -> g fzero \u2262 g (fsuc i)\n\tgz\u2260gs {i} gz=gs = fzero\u2260fsuc $\n\t  chain> fzero\n\t     === f (g fzero)\t by sym (inv fzero)\n\t     === f (g (fsuc i))  by cong f gz=gs\n\t     === fsuc i\t\t by inv (fsuc i)\n\n\tz\u2260f-thin-gz : {i : Fin n} -> fzero \u2262 f (thin (g fzero) i)\n\tz\u2260f-thin-gz {i} z=f-thin-gz = ?\n-- \t  f (g fzero)\n-- \t  = fzero\n-- \t  = f (thin (g fzero) i)\n\n\tg' : Fin n -> Fin n\n\tg' j = thick (g fzero) (g (fsuc j)) gz\u2260gs\n\n\tf' : Fin n -> Fin n\n\tf' j = thick fzero (f (thin (g fzero) j)) ?\n\n\tg'f' : forall j -> g' (f' j) \u2261 j\n\tg'f' = lem {n} f' g' ?\n\n    \u03c0\u207b\u00b9\u03c0-id : forall {i} -> \u03c0\u207b\u00b9 (\u03c0 i) \u2261 i\n    \u03c0\u207b\u00b9\u03c0-id = ?\n\n-- Answer 2: A Vec (Fin n) n with no duplicates\n\n{-\ninfixr 40 _\u25c5_ _\u21a6_,_\ninfixr 20 _\u25cb_\n\ndata Permutation : Nat -> Set where\n  \u03b5   : Permutation zero\n  _\u25c5_ : {n : Nat} -> Fin (suc n) -> Permutation n -> Permutation (suc n)\n\n_\u21a6_,_ : {n : Nat}(i j : Fin (suc n)) -> Permutation n -> Permutation (suc n)\nfzero  \u21a6 j , \u03c0\t    = j \u25c5 \u03c0\nfsuc i \u21a6 j , j' \u25c5 \u03c0 = thin j j' \u25c5 i \u21a6 ? , \u03c0\n\nindices : {n : Nat} -> Permutation n -> Vec (Fin n) n\nindices  \u03b5\t= []\nindices (i \u25c5 \u03c0) = i :: map (thin i) (indices \u03c0)\n\n-- permute (i \u25c5 \u03c0) xs with xs [!] i where\n--   permute\u2081 (i \u25c5 \u03c0) .(insert i x xs) (ixV x xs) = x :: permute \u03c0 xs\n\npermute : {n : Nat}{A : Set} -> Permutation n -> Vec A n -> Vec A n\npermute (i \u25c5 \u03c0) xs = permute' \u03c0 i xs (xs [!] i)\n  where\n    permute' : {n : Nat}{A : Set} -> Permutation n -> (i : Fin (suc n))(xs : Vec A (suc n)) ->\n\t       IndexView i xs -> Vec A (suc n)\n    permute' \u03c0 i .(insert i x xs') (ixV x xs') = x :: permute \u03c0 xs'\n\ndelete : {n : Nat} -> Fin (suc n) -> Permutation (suc n) -> Permutation n\ndelete\t\tfzero    (j \u25c5 \u03c0) = \u03c0\ndelete {zero}  (fsuc ())  _\ndelete {suc _} (fsuc i)  (j \u25c5 \u03c0) = ? \u25c5 delete i \u03c0\n\nidentity : {n : Nat} -> Permutation n\nidentity {zero } = \u03b5\nidentity {suc n} = fzero \u25c5 identity\n\n_\u207b\u00b9 : {n : Nat} -> Permutation n -> Permutation n\n\u03b5\t\u207b\u00b9 = \u03b5\n(i \u25c5 \u03c0) \u207b\u00b9 = ?\n\n_\u25cb_ : {n : Nat} -> Permutation n -> Permutation n -> Permutation n\n\u03b5      \u25cb \u03c0\u2082 = \u03b5\ni \u25c5 \u03c0\u2081 \u25cb \u03c0\u2082 = (indices \u03c0\u2082 ! i) \u25c5 (\u03c0\u2081 \u25cb delete i \u03c0\u2082)\n-}\n\n", "meta": {"hexsha": "9db4549f15adf1152a36f5d04d6bba22e04d7264", "size": 3424, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Permutation.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 26.1374045802, "max_line_length": 95, "alphanum_fraction": 0.5268691589, "num_tokens": 1435, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026618464795, "lm_q2_score": 0.8519528038477824, "lm_q1q2_score": 0.7814985747371423}}
{"text": "module List.Permutation.Pair.Properties (A : Set) where\n\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Permutation.Base.Preorder A\nopen import List.Permutation.Pair A\nopen import Data.List\nopen import Data.Product\nopen import Relation.Binary.PreorderReasoning \u223c-preorder\nopen import Algebra\nopen import Algebra.Structures\n\nlemma\u2248\u223c : {xs ys zs : List A} \u2192 xs \u2248 (ys , zs) \u2192 xs \u223c (ys ++ zs)\nlemma\u2248\u223c (\u2248[]l zs) = refl\u223c \nlemma\u2248\u223c (\u2248[]r ys) rewrite ((proj\u2082 (IsMonoid.identity (Monoid.isMonoid (monoid A)))) ys) = refl\u223c\nlemma\u2248\u223c (\u2248xr {ys = ys} xs\u223cys,zs') = \u223cx /head (lemma++/l {xs = ys} /head) (lemma\u2248\u223c xs\u223cys,zs')\nlemma\u2248\u223c (\u2248xl xs\u223cys',zs) = \u223cx /head /head (lemma\u2248\u223c xs\u223cys',zs)\n\nlemma\u2248 : {xs ys zs ws ys' zs' : List A} \u2192 xs \u2248 (ys , zs) \u2192 ys \u223c ys' \u2192 zs \u223c zs' \u2192 ws \u2248 (ys' , zs') \u2192 xs \u223c ws\nlemma\u2248 {xs} {ys} {zs} {ws} {ys'} {zs'} xs\u223cys,zs ys\u223cys' zs\u223czs' ws\u223cys',zs' \n  =  begin\n        xs\n        \u223c\u27e8 lemma\u2248\u223c xs\u223cys,zs  \u27e9\n        ys ++ zs\n        \u223c\u27e8 lemma++\u223c ys\u223cys' zs\u223czs'  \u27e9\n        ys' ++ zs'\n        \u223c\u27e8 sym\u223c (lemma\u2248\u223c ws\u223cys',zs')  \u27e9\n        ws\n      \u220e\n", "meta": {"hexsha": "c40129b35cfef720c353ca69f92f5deb8c02a0ec", "size": 1138, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Permutation/Pair/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Permutation/Pair/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Permutation/Pair/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.7096774194, "max_line_length": 107, "alphanum_fraction": 0.5966608084, "num_tokens": 474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9473810451666346, "lm_q2_score": 0.824461932846258, "lm_q1q2_score": 0.7810796076399916}}
{"text": "module _^_ where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e)\n\nopen import Naturals using (\u2115; zero; suc; _*_)\n\n_^_ : \u2115 \u2192 \u2115 \u2192 \u2115\n_ ^ zero    = 1\nm ^ (suc n) = m * (m ^ n)\n\n_ : 3 ^ 4 \u2261 81\n_ =\n  begin\n    3 ^ 4\n  \u2261\u27e8\u27e9\n    3 * (3 ^ 3)\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 ^ 2))\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 * (3 ^ 1)))\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 * (3 * (3 ^ 0))))\n  \u2261\u27e8\u27e9\n    3 * (3 * (3 * (3 * 1)))\n  \u2261\u27e8\u27e9\n    81\n  \u220e\n", "meta": {"hexsha": "8a3749acc9e4e37289716e07a136b72a7bb365af", "size": 455, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/naturals/_^_.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/naturals/_^_.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/naturals/_^_.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.1666666667, "max_line_length": 50, "alphanum_fraction": 0.4175824176, "num_tokens": 242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9473810421953309, "lm_q2_score": 0.8244619350028204, "lm_q1q2_score": 0.7810796072333511}}
{"text": "module Data.List.Combinatorics where\n\nimport      Lvl\nopen import Data\nopen import Data.List\nopen import Data.List.Functions\nopen        Data.List.Functions.LongOper\nopen import Data.Tuple as Tuple using (_\u2a2f_ ; _,_)\nopen import Data.Tuple.Raise\u1d63 as Tuple\u208a using (_^_)\nimport      Data.Tuple.Raise\u1d63.Functions as Tuple\u208a\nopen import Functional\nopen import Numeral.Natural\nopen import Type\n\nprivate variable \u2113 : Lvl.Level\nprivate variable T : Type{\u2113}\n\n-- A list of all non-empty sublists of the specified list.\n-- The corresponding counting function is `(2 ^ n) \u2212 1` where `n` is the length of the list.\n-- Note:\n--   In the inductive case, all of these are permutations of each other:\n--   \u2022 `fold\u1d63 (prev \u21a6 rest \u21a6 (prev \u22b0 (x \u22b0 prev) \u22b0 rest)) \u2205 (sublists\u208a l)` (This is used because of its \"natural\" order)\n--   \u2022 `fold\u1d63 (prev \u21a6 rest \u21a6 ((x \u22b0 prev) \u22b0 prev \u22b0 rest)) \u2205 (sublists\u208a l)`\n--   \u2022 `(map (x \u22b0_) (sublists\u208a l)) ++ (sublists\u208a l)`\n--   \u2022 `(sublists\u208a l) ++ (map (x \u22b0_) (sublists\u208a l))`\n-- Examples:\n--   sublists\u208a []        = []\n--   sublists\u208a [1]       = [[1]]\n--   sublists\u208a [1,2]     = [[1],[2],[1,2]]\n--   sublists\u208a [1,2,3]   = [[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]\n--   sublists\u208a [1,2,3,4] = [[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3],[4],[1,4],[2,4],[1,2,4],[3,4],[1,3,4],[2,3,4],[1,2,3,4]]\nsublists\u208a : List(T) \u2192 List(List(T))\nsublists\u208a \u2205       = \u2205\nsublists\u208a (x \u22b0 l) = singleton(x) \u22b0 concatMap(y \u21a6 (y \u22b0 (x \u22b0 y) \u22b0 \u2205)) (sublists\u208a l)\n\n-- A list of all sublists of the specified list.\n-- This is also the list of all subsets when the given list is a set (distinct elements).\n-- The corresponding counting function is `2 ^ n` where `n` is the length of the list.\n-- Examples:\n--   sublists []        = [[]]\n--   sublists [1]       = [[],[1]]\n--   sublists [1,2]     = [[],[1],[2],[1,2]]\n--   sublists [1,2,3]   = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]\n--   sublists [1,2,3,4] = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3],[4],[1,4],[2,4],[1,2,4],[3,4],[1,3,4],[2,3,4],[1,2,3,4]]\nsublists : List(T) \u2192 List(List(T))\nsublists(l) = \u2205 \u22b0 sublists\u208a(l)\n\n-- A list of all combinations of the specified size of the specified list.\n-- The corresponding counting function is `\ud835\udc50\ud835\udc36(n,k)` where `n` is the length of the specified \"multiset\".\n-- All subsets of size `n` from the set `l`.\n-- Every unique subset of size n up to set equality.\n-- This is also a list of all sublists of the specified size of the specified list.\n-- Alternative definition that does not pass the termination checker:\n--   combinations : \u2115 \u2192 List(T) \u2192 List(List(T))\n--   combinations 0         _ = \u2205\n--   combinations _         \u2205 = \u2205\n--   combinations 1         l = map singleton l\n--   combinations (\ud835\udc12(\ud835\udc12(n))) l = concat(map f(tails l)) where\n--     f : List(T) \u2192 List(List(T))\n--     f \u2205      = \u2205\n--     f(x \u22b0 l) = map (x \u22b0_) (combinations (\ud835\udc12(n)) l)\n-- Examples:\n--   combinations _ []          = []\n--   combinations 0 [a,b,c,...] = [[]]              when the list is non-empty\n--   combinations 1 [a,b,c,...] = [[a],[b],[c],...] when the list is non-empty\n--   combinations n l           = []  when (n \u2265 length(l))\n--   combinations n l           = [l] when (n = length(l))\n--   combinations 2 [a,b,c]     = [[a,b],[a,c],[b,c]]\n--   combinations 2 [a,b,c,d]   = [[a,b],[a,c],[a,d],[b,c],[b,d],[c,d]]\n--   combinations 2 [a,b,c,d,e] = [[a,b],[a,c],[a,d],[a,e],[b,c],[b,d],[b,e],[c,d],[c,e],[d,e]]\n--   combinations 3 [a,b,c,d]   = [[a,b,c],[a,b,d],[a,c,d],[b,c,d]]\n--   combinations 3 [a,b,c,d,e] = [[a,b,c],[a,b,d],[a,b,e],[a,c,d],[a,c,e],[a,d,e],[b,c,d],[b,c,e],[b,d,e],[c,d,e]]\n--   combinations 4 [a,b,c,d,e] = [[a,b,c,d],[a,b,c,e],[a,b,d,e],[a,c,d,e],[b,c,d,e]]\ncombinations : (k : \u2115) \u2192 List(T) \u2192 List(T ^ k)\ncombinations 0         _         = singleton(<>)\ncombinations (\ud835\udc12(_))    \u2205         = \u2205\ncombinations 1         l@(_ \u22b0 _) = l\ncombinations (\ud835\udc12(\ud835\udc12(k))) (x \u22b0 l)   = (map(x ,_) (combinations (\ud835\udc12(k)) l)) ++ (combinations(\ud835\udc12(\ud835\udc12(k))) l)\n\n-- The corresponding counting function is `\ud835\udc50\ud835\udc36(n + k \u2212 1 , k)` where `n` is the length of the specified \"multiset\".\n-- Examples:\n--   repeatableCombinations _ []          = []\n--   repeatableCombinations 0 [a,b,c,...] = [[]]              when the list is non-empty\n--   repeatableCombinations 1 [a,b,c,...] = [[a],[b],[c],...] when the list is non-empty\n--   repeatableCombinations n [a]         = [repeat n a]\n--   repeatableCombinations 2 [a,b]       = [[a,a],[a,b],[b,b]]\n--   repeatableCombinations 2 [a,b,c]     = [[a,a],[a,b],[a,c],[b,b],[b,c],[c,c]]\n--   repeatableCombinations 3 [a,b]       = [[a,a,a],[a,a,b],[a,b,b],[b,b,b]]\n--   repeatableCombinations 3 [a,b,c]     = [[a,a,a],[a,a,b],[a,a,c],[a,b,b],[a,b,c],[a,c,c],[b,b,b],[b,b,c],[b,c,c],[c,c,c]]\n--   repeatableCombinations 4 [a,b]       = [[a,a,a,a],[a,a,a,b],[a,a,b,b],[a,b,b,b],[b,b,b,b]]\n--   repeatableCombinations 4 [a,b,c]     = [[a,a,a,a],[a,a,a,b],[a,a,a,c],[a,a,b,b],[a,a,b,c],[a,a,c,c],[a,b,b,b],[a,b,b,c],[a,b,c,c],[a,c,c,c],[b,b,b,b],[b,b,b,c],[b,b,c,c],[b,c,c,c],[c,c,c,c]]\nrepeatableCombinations : (k : \u2115) \u2192 List(T) \u2192 List(T ^ k)\nrepeatableCombinations 0         _         = singleton(<>)\nrepeatableCombinations (\ud835\udc12(_))    \u2205         = \u2205\nrepeatableCombinations 1         l@(_ \u22b0 _) = l\nrepeatableCombinations (\ud835\udc12(\ud835\udc12(k))) (x \u22b0 l)   = (map (x ,_) (repeatableCombinations (\ud835\udc12(k)) (x \u22b0 l))) ++ (repeatableCombinations (\ud835\udc12(\ud835\udc12(k))) l)\n\n-- A list of all tuples of length `n` from the \"multiset\" `l`.\n-- Every tuple combination of length `n`.\n-- The corresponding counting function is `k ^ n` where `k` is the length of the list.\n-- Examples:\n--   tuples 0 [a]     = [()]\n--   tuples 1 [a]     = [a]\n--   tuples 2 [a]     = [(a,a)]\n--   tuples 0 [a,b]   = [()]\n--   tuples 1 [a,b]   = [a,b]\n--   tuples 2 [a,b]   = [(a,a) , (a,b) , (b,a) , (b,b)]\n--   tuples 0 [a,b,c] = [()]\n--   tuples 1 [a,b,c] = [a,b,c]\n--   tuples 2 [a,b,c] = [(a,a) , (a,b) , (a,c) , (b,a) , (b,b) , (b,c) , (c,a) , (c,b), (c,c)]\ntuples : (n : \u2115) \u2192 List(T) \u2192 List(T ^ n)\ntuples 0           = const(singleton(<>))\ntuples 1           = id\ntuples (\ud835\udc12(\ud835\udc12(n))) l = concatMap(x \u21a6 map (Tuple\u208a.prepend x) (tuples (\ud835\udc12(n)) l)) l\n\n-- A list of all rotations of a list.\n-- Examples:\n--   rotations []        = []\n--   rotations [a]       = [[a]]\n--   rotations [a,b]     = [[a,b] , [b,a]]\n--   rotations [a,b,c]   = [[a,b,c] , [b,c,a] , [c,a,b]]\n--   rotations [a,b,c,d] = [[a,b,c,d] , [b,c,d,a] , [c,d,a,b] , [d,a,b,c]]\nrotations : List(T) \u2192 List(List(T))\nrotations l = accumulateIterate\u2080(length l) (rotate\u2097(1)) l\n\n-- Accumulated `insertAt` for every position of the given list.\n-- Examples:\n--   insertedEverywhere i []        = [[i]]\n--   insertedEverywhere i [a]       = [[i,a],[a,i]]\n--   insertedEverywhere i [a,b]     = [[i,a,b],[a,i,b],[a,b,i]]\n--   insertedEverywhere i [a,b,c]   = [[i,a,b,c],[a,i,b,c],[a,b,i,c],[a,b,c,i]]\n--   insertedEverywhere i [a,b,c,d] = [[i,a,b,c,d],[a,i,b,c,d],[a,b,i,c,d],[a,b,c,i,d],[a,b,c,d,i]\ninsertedEverywhere : T \u2192 List(T) \u2192 List(List(T))\ninsertedEverywhere i \u2205       = singleton(singleton i)\ninsertedEverywhere i (x \u22b0 l) = (i \u22b0 x \u22b0 l) \u22b0 (map (prepend x) (insertedEverywhere i l))\n\n-- Every reordering of the list's elements.\n-- Examples:\n--   permutations []        = [[]]\n--   permutations [a]       = [[a]]\n--   permutations [a,b]     = [[a,b],[b,a]]\n--   permutations [a,b,c]   = [[a,b,c],[b,a,c],[b,c,a],[a,c,b],[c,a,b],[c,b,a]]\n--   permutations [a,b,c,d] = [[a,b,c,d],[b,a,c,d],[b,c,a,d],[b,c,d,a],[a,c,b,d],[c,a,b,d],[c,b,a,d],[c,b,d,a],[a,c,d,b],[c,a,d,b],[c,d,a,b],[c,d,b,a],[a,b,d,c],[b,a,d,c],[b,d,a,c],[b,d,c,a],[a,d,b,c],[d,a,b,c],[d,b,a,c],[d,b,c,a],[a,d,c,b],[d,a,c,b],[d,c,a,b],[d,c,b,a]]\npermutations : List(T) \u2192 List(List(T))\npermutations \u2205               = singleton(\u2205)\npermutations (x \u22b0 \u2205)         = singleton(singleton x)\npermutations (x \u22b0 l@(_ \u22b0 _)) = concatMap (insertedEverywhere x) (permutations l)\n", "meta": {"hexsha": "9477d58d0657829d43fb0218570075f54eb2b980", "size": 7784, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Combinatorics.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Combinatorics.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Combinatorics.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.5945945946, "max_line_length": 271, "alphanum_fraction": 0.526336074, "num_tokens": 2930, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505325302034, "lm_q2_score": 0.8633916152464016, "lm_q1q2_score": 0.7810676845147697}}
{"text": "module Nat1 where\n\ndata \u2115 : Set where\n  zero : \u2115\n  succ : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero   + b = b\nsucc a + b = succ (a + b)\n\nopen import Equality\none   = succ zero\ntwo   = succ one\nthree = succ two\n\n0-is-id : \u2200 (n : \u2115) \u2192 (n + zero) \u2261 n\n0-is-id zero     =\n  begin\n    (zero + zero) \u2248 zero by definition\n  \u220e\n0-is-id (succ y) =\n  begin\n    (succ y + zero) \u2248 succ (y + zero) by definition\n                    \u2248 succ y          by cong succ (0-is-id y)\n  \u220e\n\n+-assoc : \u2200 (a b c : \u2115) \u2192 (a + b) + c \u2261 a + (b + c)\n+-assoc zero     b c = definition\n+-assoc (succ a) b c =\n  begin ((succ a + b) + c)\n               \u2248 succ (a + b) + c by definition\n               \u2248 succ ((a + b) + c) by definition\n               \u2248 succ (a + (b + c)) by cong succ (+-assoc a b c)\n               \u2248 succ a + (b + c) by definition\n  \u220e\n{-\n+-assoc zero     b c     = definition\n+-assoc (succ a) b c     =\n  begin ((succ a + b) + c)\n               \u2248 succ (a + b)  + c   by definition\n               \u2248 succ ((a + b) + c)  by definition\n               \u2248 succ (a  + (b + c)) by cong succ (+-assoc a b c)\n               \u2248 succ a   + (b + c)  by definition\n  \u220e\n-}\n", "meta": {"hexsha": "dd661c3134861008f0887630e9bc130d379b1f8f", "size": 1123, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Nat1.agda", "max_stars_repo_name": "piyush-kurur/sample-code", "max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z", "max_issues_repo_path": "agda/Nat1.agda", "max_issues_repo_name": "piyush-kurur/sample-code", "max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z", "max_forks_repo_path": "agda/Nat1.agda", "max_forks_repo_name": "piyush-kurur/sample-code", "max_forks_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4130434783, "max_line_length": 65, "alphanum_fraction": 0.4443455031, "num_tokens": 400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.966410494349896, "lm_q2_score": 0.8080672158638527, "lm_q1q2_score": 0.78092463755093}}
{"text": "open import Data.Nat using (_+_; _*_; zero; suc; \u2115)\nopen import Relation.Binary.PropositionalEquality as PropEq\n  using (_\u2261_; _\u2262_; refl; cong)\nimport Data.Nat.Properties\nopen Data.Nat.Properties.SemiringSolver\n  using (solve; _:=_; con; var; _:+_; _:*_; :-_; _:-_)\nopen PropEq.\u2261-Reasoning\n\nlem1 : (4 + 6 \u2261 10)\nlem1 = refl\n\nlem3 : (x : \u2115) \u2192 (2 * (x + 4) \u2261 8 + 2 * x)\nlem3 = solve 1 (\u03bb x' \u2192 con 2 :* (x' :+ con 4) := con 8 :+ con 2 :* x') refl\n\nsum : \u2115 \u2192 \u2115\nsum zero    = 0\nsum (suc n) = 1 + 2 * n + sum n\n\ntheorem : (n : \u2115) \u2192 (sum n \u2261 n * n)\ntheorem 0       = refl\ntheorem (suc p) =\n  begin\n    sum (suc p)\n  \u2261\u27e8 refl \u27e9\n    1 + 2 * p + sum p\n  \u2261\u27e8 cong (\u03bb x \u2192 1 + 2 * p + x)  (theorem p)\u27e9\n    1 + 2 * p + p * p\n  \u2261\u27e8 solve 1 (\u03bb p \u2192 con 1 :+ con 2 :* p :+ p :* p := (con 1 :+ p) :* (con 1 :+ p)) refl p \u27e9\n    (1 + p) * (1 + p)\n  \u2261\u27e8 refl \u27e9\n    (suc p) * (suc p)\n  \u220e\n", "meta": {"hexsha": "e85dd84ef58f8150694b82e8d876356adf84a123", "size": 859, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/comparison/sumodd.agda", "max_stars_repo_name": "jota191/pml", "max_stars_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2017-12-22T12:10:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-17T18:31:08.000Z", "max_issues_repo_path": "tests/comparison/sumodd.agda", "max_issues_repo_name": "jota191/pml", "max_issues_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 36, "max_issues_repo_issues_event_min_datetime": "2017-11-01T16:27:45.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-08T09:43:31.000Z", "max_forks_repo_path": "tests/comparison/sumodd.agda", "max_forks_repo_name": "jota191/pml", "max_forks_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-07-18T22:03:24.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-18T22:03:24.000Z", "avg_line_length": 26.0303030303, "max_line_length": 91, "alphanum_fraction": 0.4994179278, "num_tokens": 402, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.960361162033533, "lm_q2_score": 0.8128673155708975, "lm_q1q2_score": 0.7806461997607457}}
{"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule Mergesort.Impl1.Correctness.Order {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_)  where\n\nopen import Data.List\nopen import Function using (_\u2218_)\nopen import List.Sorted _\u2264_\nopen import Mergesort.Impl1 _\u2264_ tot\u2264\nopen import SList\nopen import SOList.Lower _\u2264_\nopen import SOList.Lower.Properties _\u2264_\n\ntheorem-mergesort-sorted : (xs : List A) \u2192 Sorted (forget (mergesort (size A xs)))\ntheorem-mergesort-sorted = lemma-solist-sorted  \u2218 mergesort \u2218 (size A)\n", "meta": {"hexsha": "b5ee4b8f6b35b9571c81446eb78440901044f704", "size": 560, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Mergesort/Impl1/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/Mergesort/Impl1/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Mergesort/Impl1/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1111111111, "max_line_length": 82, "alphanum_fraction": 0.6821428571, "num_tokens": 172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9441768635777511, "lm_q2_score": 0.8267117919359419, "lm_q1q2_score": 0.78056214679282}}
{"text": "module Type.Properties.MereProposition {\u2113 \u2113\u2091} where\n\nimport      Lvl\nopen import Lang.Instance\nopen import Structure.Setoid\nopen import Type\n\n-- A type is a mere proposition type when there is at most one inhabitant (there is at most one object with this type).\n-- In other words: If there is an inhabitant of type T, it is unique (essentially only allowing empty or singleton types, but this is not provable (excluded midd\u00f6e)).\n-- Also called:\n-- \u2022 \"Irrelevance\" / \"Irrelevancy\" / \"Proof irrelevance\" (in the context of proofs).\n--   A proof of the proposition T is unique (using equality to determine uniqueness).\n-- \u2022 \"isProp\" / \"h-proposition\" / \"is of h-level 1\" / \"a mere proposition\" (in homotopy type theory).\n--   Classically, when MereProposition(T), T is either empty or a singleton (which in the context of proofs corresponds to types isomorphic to \u22a5 or \u22a4).\n-- \u2022 \"subsingleton\" (in set theory)\n--   When a type and its inhabitants is interpreted as a set and its elements.\n-- \u2022 \"subterminal object\" (in category theory).\nmodule _ (T : Type{\u2113}) \u2983 _ : Equiv{\u2113\u2091}(T) \u2984 where\n  record MereProposition : Type{\u2113 Lvl.\u2294 \u2113\u2091} where\n    constructor intro\n    field uniqueness : \u2200{x y : T} \u2192 (x \u2261 y)\n  uniqueness = inst-fn MereProposition.uniqueness\n\n-- TODO: Consider using unicode \u25d0\u25cb\u25cf\u29ed\u29b5\u29b3\n", "meta": {"hexsha": "ffd712aea25936fa3c7eaa10c865d1bd38485b52", "size": 1289, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type/Properties/MereProposition.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Type/Properties/MereProposition.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Type/Properties/MereProposition.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 51.56, "max_line_length": 166, "alphanum_fraction": 0.7160589604, "num_tokens": 377, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9518632288833652, "lm_q2_score": 0.8198933359135361, "lm_q1q2_score": 0.780426318062612}}
{"text": "module x00-playpen where\n\n-- prove properties of inductive naturals and operations on them via induction\n\nimport      Relation.Binary.PropositionalEquality as Eq\nopen        Eq             using (_\u2261_; refl; cong; sym)\nopen        Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; step-\u2261; _\u220e)\nopen import Data.Nat       using (\u2115; zero; suc; _+_; _*_; _\u2238_; _^_)\n\n*-assoc : \u2200 (m n p : \u2115)\n        \u2192 (m *  n) * p\n        \u2261  m * (n  * p)\n*-assoc m n p = {!!}\n\n+-xx : \u2200 (n  : \u2115)\n       \u2192 (n ^ 3) \u2238 ((n * n) * n)\n       \u2261 zero\n+-xx zero = refl\n+-xx (suc n) = {!!}\n{-\n  begin\n              (n * (n ^ 2))   \u2238 ((n * n) * n)\n  \u2261\u27e8\u27e9\n         (n * (n * (n ^ 1)))  \u2238 ((n * n) * n)\n  \u2261\u27e8\u27e9\n    (n * (n * (n * (n ^ 0)))) \u2238 ((n * n) * n)\n  \u2261\u27e8\u27e9\n    (n * (n * (n *  1     ))) \u2238 ((n * n) * n)\n  \u2261\u27e8\u27e9\n    (n * (n *  n          ))  \u2238 ((n * n) * n)\n  \u2261\u27e8 cong ( ((n * (n *  n))) \u2238_) (*-assoc n n n) \u27e9\n    (n * (n *  n          ))  \u2238 ( n * (n * n))\n  \u220e\n-}\n", "meta": {"hexsha": "995d37bbba0f82cc8955d762cd9938e0d21bd349", "size": 913, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 26.0857142857, "max_line_length": 78, "alphanum_fraction": 0.3713033954, "num_tokens": 405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9362850039701655, "lm_q2_score": 0.8333246015211009, "lm_q1q2_score": 0.7802293278436205}}
{"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.core.univalence  where\n\nopen import hott.core.universe\nopen import hott.functions\nopen import hott.core.equality\nopen import hott.core.sigma\n\n\n-- The core idea of univalence is to \"identify\" isomorphic types as\n-- equal. Of course the normal definition of isomorphism is that there\n-- should be a map from A to B that is witnesses the equivalence of the\n-- two type. This is captured by the following record.\nrecord _\u2243_  {a b : Level}(A : Type a)(B : Type b) : Type (a \u2294 b) where\n\n  constructor IdentifyTypesVia\n  field\n    equiv     : (A \u2192 B)  -- The equivalence\n    left-inv  : (B \u2192 A)  -- its left inverse\n    right-inv : (B \u2192 A)  -- and its right inverse\n\n    -- The proofs of the fact that the left and right inverses are actually\n    -- left and right inverses.\n    left-inv\u2218equiv~idA  : left-inv \u2218 equiv ~ id\n    iso\u2218right-equiv~idB : equiv    \u2218 right-inv ~ id\n\n-- Of course a type should be equivalent to itself via identity.\nA\u2243A : {\u2113 : Level}{A : Type \u2113} \u2192 A \u2243 A\nA\u2243A {\u2113} {A} = IdentifyTypesVia id id id (\u03bb _ \u2192  refl) (\u03bb _ \u2192 refl)\n\n-- Equal types are equivalent.\n\u2261\u2192\u2243 : {\u2113 : Level}{A B : Type \u2113} \u2192 A \u2261 B \u2192 A \u2243 B\n\u2261\u2192\u2243 refl = A\u2243A\n\n\n-- For the converse we need the univalence. However Univalence says\n-- something. Not only can we infer A \u2261 B from A \u2243 B via the postulate\n-- ua, this map together with \u2261\u2192\u2243 gives an equivalence of types.\nmodule Univalence {\u2113 : Level}{A B : Type \u2113} where\n\n  -- The main axiom is to identify A \u2243 B with A \u2261 B\n  postulate ua : A \u2243 B \u2192 A \u2261 B\n\n  -- Now we are ready for the univalence axiom.\n  UnivalenceAxiom : (A \u2243 B) \u2243 (A \u2261 B)\n  UnivalenceAxiom = IdentifyTypesVia ua \u2261\u2192\u2243 \u2261\u2192\u2243 linv-prf rinv-prf\n    where postulate rinv-prf :  ua \u2218 \u2261\u2192\u2243 ~ id\n          postulate linv-prf :  \u2261\u2192\u2243 \u2218 ua ~ id\n\n  -- The next function helps in clean use of the univalence\n  -- axioms in equational reasoning.\n  --\n  --\n  -- begin ...\n  --       \u2261    B by univalence\n  --       ...\n  --\n  -- provided an appropriate instance of A \u2243 B is available in the\n  -- vicinity.\n  --\n  univalence : \u2983 a\u2243b : A \u2243 B \u2984 \u2192 A \u2261 B\n  univalence \u2983 a\u2243b \u2984 = ua a\u2243b\n\nopen Univalence public\n", "meta": {"hexsha": "5ec7c02e47dc7dc040ab8ab4430fb9e4f77c4924", "size": 2115, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/core/univalence.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/core/univalence.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/core/univalence.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0454545455, "max_line_length": 75, "alphanum_fraction": 0.6368794326, "num_tokens": 696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765187126079, "lm_q2_score": 0.8539127473751341, "lm_q1q2_score": 0.7802000263060311}}
{"text": "-- Solutions to ExerciseSession2\n{-# OPTIONS --cubical #-}\nmodule SolutionsSession2 where\n\nopen import Part1\nopen import Part2\nopen import ExerciseSession1\n\n-- Exercise 1\nJEq : {x : A} (P : (z : A) \u2192 x \u2261 z \u2192 Type \u2113'')\n      (d : P x refl) \u2192 J P d refl \u2261 d\nJEq P p d = transportRefl p d\n\n\n-- Exercise 2\nisContr\u2192isProp : isContr A \u2192 isProp A\nisContr\u2192isProp (x , p) a b = sym (p a) \u2219 p b\n\n\n-- Exercise 3\nisProp\u2192isProp' : isProp A \u2192 isProp' A\nisProp\u2192isProp' p x y = p x y , isProp\u2192isSet p _ _ (p x y)\n\n\n-- Exercise 4\nisContr\u2192isContr\u2261 : isContr A \u2192 (x y : A) \u2192 isContr (x \u2261 y)\nisContr\u2192isContr\u2261 h = isProp\u2192isProp' (isContr\u2192isProp h)\n\n\n-- Exercise 5\nfromPathP : {A : I \u2192 Type \u2113} {x : A i0} {y : A i1}\n          \u2192 PathP A x y\n          \u2192 transport (\u03bb i \u2192 A i) x \u2261 y\nfromPathP {A = A} p i = transp (\u03bb j \u2192 A (i \u2228 j)) i (p i)\n\n\n-- The converse is harder to prove so we give it:\ntoPathP : {A : I \u2192 Type \u2113} {x : A i0} {y : A i1}\n        \u2192 transport (\u03bb i \u2192 A i) x \u2261 y\n        \u2192 PathP A x y\ntoPathP {A = A} {x = x} p i =\n  hcomp (\u03bb j \u2192 \u03bb { (i = i0) \u2192 x\n                 ; (i = i1) \u2192 p j })\n        (transp (\u03bb j \u2192 A (i \u2227 j)) (~ i) x)\n\n\n-- Exercise 6\n\u03a3\u2261Prop : {B : A \u2192 Type \u2113'} {u v : \u03a3 A B} (h : (x : A) \u2192 isProp (B x))\n       \u2192 (p : fst u \u2261 fst v) \u2192 u \u2261 v\n\u03a3\u2261Prop {B = B} {u = u} {v = v} h p =\n  \u03a3PathP (p , toPathP (h _ (transport (\u03bb i \u2192 B (p i)) (snd u)) (snd v)))\n\n\n-- Exercice 7 (thanks Lo\u00efc for the slick proof!)\nisPropIsContr : isProp (isContr A)\nisPropIsContr (c0 , h0) (c1 , h1) j =\n  h0 c1 j , \u03bb y i \u2192 hcomp (\u03bb k \u2192 \u03bb { (i = i0) \u2192 h0 (h0 c1 j) k;\n                                     (i = i1) \u2192 h0 y k;\n                                     (j = i0) \u2192 h0 (h0 y i) k;\n                                     (j = i1) \u2192 h0 (h1 y i) k}) c0\n\n\n-- Exercises about Part 3:\n\n-- Exercise 8 (a bit longer, but very good):\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Int hiding (addEq ; subEq)\n\n-- Compose sucPathInt with itself n times. Transporting along this\n-- will be addition, transporting with it backwards will be subtraction.\n\n-- a) Define a path \"addEq n\" by composing sucPathInt with itself n\n-- times.\naddEq : \u2115 \u2192 Int \u2261 Int\naddEq zero = refl\naddEq (suc n) = (addEq n) \u2219 sucPathInt\n\n-- b) Define another path \"subEq n\" by composing \"sym sucPathInt\" with\n-- itself n times.\nsubEq : \u2115 \u2192 Int \u2261 Int\nsubEq zero = refl\nsubEq (suc n) = (subEq n) \u2219 sym sucPathInt\n\n\n-- c) Define addition on integers by pattern-matching and transporting\n-- along addEq/subEq appropriately.\n_+Int_ : Int \u2192 Int \u2192 Int\nm +Int pos n    = transport (addEq n) m\nm +Int negsuc n = transport (subEq (suc n)) m\n\n-- d) Do some concrete computations using _+Int_ (this would not work\n-- in HoTT as the transport would be stuck!)\n\n\n-- Exercise 9: prove that hSet is not an hSet\n\nopen import Cubical.Data.Bool renaming (notEq to notPath)\nopen import Cubical.Data.Empty\n\n-- Just define hSets of level 0 for simplicity\nhSet : Type\u2081\nhSet = \u03a3[ A \u2208 Type\u2080 ] isSet A\n\n-- Bool is an hSet\nBoolSet : hSet\nBoolSet = Bool , isSetBool\n\nnotPath\u2262refl : (notPath \u2261 refl) \u2192 \u22a5\nnotPath\u2262refl e = true\u2262false (transport (\u03bb i \u2192 transport (e i) true \u2261 false) refl)\n\n\u00acisSet-hSet : isSet hSet \u2192 \u22a5\n\u00acisSet-hSet h = notPath\u2262refl (cong (cong fst) (h BoolSet BoolSet p refl))\n where\n p : BoolSet \u2261 BoolSet\n p = \u03a3\u2261Prop (\u03bb A \u2192 isPropIsSet {A = A}) notPath\n\n\n-- Exercise 10: squivalence between FinData and Fin\n\n-- Thanks to Elies for the PR with the code. On the development\n-- version of the library there is now:\n--\n-- open import Cubical.Data.Fin using (FinData\u2261Fin)\n\n", "meta": {"hexsha": "df867fde78127db5d16213cab2089c4430147030", "size": 3498, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/SolutionsSession2.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04-cubical-type-theory/material/SolutionsSession2.agda", "max_issues_repo_name": "williamdemeo/EPIT-2020", "max_issues_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/SolutionsSession2.agda", "max_forks_repo_name": "williamdemeo/EPIT-2020", "max_forks_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "avg_line_length": 27.7619047619, "max_line_length": 81, "alphanum_fraction": 0.598913665, "num_tokens": 1268, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976953003183443, "lm_q2_score": 0.8688267796346599, "lm_q1q2_score": 0.779941716868756}}
{"text": "module TerminationArgumentSwapping where\n\n-- subtyping simple types\n\ndata Bool : Set where\n   true  : Bool\n   false : Bool\n\n_&&_ : Bool -> Bool -> Bool\ntrue && a = a\nfalse && a = false\n\ndata Ty : Set where\n   bot : Ty\n   top : Ty\n   arr : Ty -> Ty -> Ty\n\nsubty : Ty -> Ty -> Bool\nsubty bot _ = true\nsubty _ top = true\nsubty (arr a b) (arr a' b') = subty a' a && subty b b'\nsubty _ _ = false\n\n\n-- maximum with happy swapping\n\ndata Nat : Set where\n    zero : Nat\n    succ : Nat -> Nat\n\n-- Maximum of 3 numbers\n\nmax3 : Nat -> Nat -> Nat -> Nat\nmax3 zero zero z = z\nmax3 zero y zero = y\nmax3 x zero zero = x\nmax3 (succ x) (succ y) zero = succ (max3 x y zero)\nmax3 (succ x) zero (succ z) = succ (max3 x z zero)\nmax3 zero (succ y) (succ z) = succ (max3 y z zero)\nmax3 (succ x) (succ y) (succ z) = succ (max3 z x y)\n\n-- can also be done with sized types\n-- max3 : Nat^i -> Nat^i -> Nat^i -> Nat^i\n\n-- swapping with higher-order datatypes\n\ndata Ord : Set where\n   ozero : Ord\n   olim  : (Nat -> Ord) -> Ord\n\nfoo : Ord -> (Nat -> Ord) -> Ord\nfoo ozero    g = ozero\nfoo (olim f) g = olim (\\n -> foo (g n) f)\n", "meta": {"hexsha": "6fd523eccdbd4e9f791a42811bba03a36cf2f428", "size": 1098, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/TerminationArgumentSwapping.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/TerminationArgumentSwapping.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/TerminationArgumentSwapping.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.3333333333, "max_line_length": 54, "alphanum_fraction": 0.5974499089, "num_tokens": 385, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308036221031, "lm_q2_score": 0.8354835330070839, "lm_q1q2_score": 0.7798660656278362}}
{"text": "module plfa-exercises.Practice where\n\n--------------------------------------- Naturals ---------------------------------------\n\n-- Inductive definition of Numbers (new datatype)\ndata \u2115 : Set where\n-- Judgements (two in total for this case)\n  zero : \u2115       -- No hypothesis and one conclusion\n  suc  : \u2115 \u2192 \u2115   -- One hypothesis and one conclusion\n\nseven : \u2115\nseven = suc (suc (suc (suc (suc (suc (suc zero))))))\n--seven\u2032 = --7\n\npred : \u2115 \u2192 \u2115\npred zero = zero\npred (suc n) = n\n\n---\n\n-- Gives us the power of writing 3 to signify suc (suc (suc zero)) :)\n{-# BUILTIN NATURAL \u2115 #-}\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; _\u2262_; refl; cong; sym; trans)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u2261\u27e8_\u27e9_; _\u220e)\nopen import Function.Base using (flip)\nopen import Relation.Nullary using (\u00ac_)\nopen import Data.Empty using (\u22a5; \u22a5-elim)\nopen import Data.Product using (_\u00d7_; \u2203-syntax) renaming (_,_ to \u27e8_,_\u27e9)\nopen import Data.Sum using (_\u228e_; inj\u2081; inj\u2082)\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n                -- +-def\u2080\n(suc m) + n = suc (m + n)   -- +-def\u2081\n\n--_ : (suc (suc zero)) + (suc (suc (suc zero))) \u2261 (suc (suc (suc (suc (suc zero)))))\n--_ =\n--  begin\n--    (suc (suc zero)) + (suc (suc (suc zero)))\n--  \u2261\u27e8\u27e9    -- inductive case\n--    suc ((suc zero) + (suc (suc (suc zero))))\n--  \u2261\u27e8\u27e9    -- inductive case\n--    suc (suc (zero + (suc (suc (suc zero)))))\n--  \u2261\u27e8\u27e9    -- base case\n--    suc (suc (suc (suc (suc zero))))\n--  \u220e\n--\n--_ : 2 + 3 \u2261 5\n--_ =\n--  begin\n--    2 + 3\n--    (suc 1) + 3\n--  \u2261\u27e8\u27e9\n--    suc (1 + 3)\n--  \u2261\u27e8\u27e9\n--    suc (suc 0 + 3)\n--  \u2261\u27e8\u27e9\n--    suc (suc (0 + 3))\n--  \u2261\u27e8\u27e9\n--    suc (suc 3)\n--  \u2261\u27e8\u27e9\n--    suc 4\n--  \u2261\u27e8\u27e9\n--    5\n--  \u220e\n--\n--\n--_ : (suc (suc zero)) + (suc (suc (suc zero))) \u2261 (suc (suc (suc (suc (suc zero)))))\n--_ = refl\n\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero    * n  =  zero\n(suc m) * n  =  n + (m * n)\n\n_^_ : \u2115 \u2192 \u2115 \u2192 \u2115\nn ^ zero  =  suc zero\nn ^ (suc m)  =  n * (n ^ m)\n\n-- Monus\n_\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm     \u2238 zero   =  m\nzero  \u2238 suc n  =  zero\nsuc m \u2238 suc n  =  m \u2238 n\n\ninfixl 6  _+_  _\u2238_\ninfixl 7  _*_\ninfixr 8  _^_\n\n\n-- Superfun binary numbers :D\ndata Bin : Set where\n  \u27e8\u27e9 : Bin\n  _O : Bin \u2192 Bin\n  _I : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc \u27e8\u27e9 = \u27e8\u27e9 I\ninc (b O) = b I\ninc (b I) = (inc b) O\n\n_ : inc (\u27e8\u27e9 I O I I) \u2261 \u27e8\u27e9 I I O O\n_ = refl\n\nto\u1d47 : \u2115 \u2192 Bin\nto\u1d47 zero = \u27e8\u27e9 O\nto\u1d47 (suc n) = inc (to\u1d47 n)\n\nfrom\u1d47 : Bin \u2192 \u2115\nfrom\u1d47 \u27e8\u27e9 = zero\nfrom\u1d47 (b O) = let n = from\u1d47 b in n + n\nfrom\u1d47 (b I) = let n = from\u1d47 b in suc (n + n)\n\n_ : to\u1d47 11 \u2261 (\u27e8\u27e9 I O I I)\n_ = refl\n\n_ : from\u1d47 (inc (\u27e8\u27e9 I O I I)) \u2261 12\n_ = refl\n--_ = begin\n--      (from\u1d47 (\u27e8\u27e9 I I O O))\n--    \u2261\u27e8 12 \u2261\u27e8\u27e9 12 \u220e \u27e9 \n--      12\n--    \u220e\n\n--_ : Set\u2089\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\u2081\n--_ : Set\u2080\n_ : Set\n_ = suc 11 \u2261 12\n\n_+\u1d47_ : Bin \u2192 Bin \u2192 Bin\n\u27e8\u27e9    +\u1d47 b     = b\nb     +\u1d47 \u27e8\u27e9    = b\n--(b O) +\u1d47 \u27e8\u27e9    = b O\n(b O) +\u1d47 (d O) = (b +\u1d47 d) O\n(b O) +\u1d47 (d I) = (b +\u1d47 d) I\n--(b I) +\u1d47 \u27e8\u27e9    = b I\n(b I) +\u1d47 (d O) = (b +\u1d47 d) I\n(b I) +\u1d47 (d I) = (inc (b +\u1d47 d)) O\n\n-- Proving the following is trivial\nmod-left : \u2200 {b : Bin} \u2192 \u27e8\u27e9 +\u1d47 b \u2261 b\nmod-left = refl\n-- But not its complement. This is due to \"case trees\" (or how Agda implements\n-- functions under the hood)\n-- https://agda.readthedocs.io/en/v2.6.0.1/language/function-definitions.html#case-trees\nmod-right : \u2200 {b : Bin} \u2192 b +\u1d47 \u27e8\u27e9 \u2261 b\nmod-right {\u27e8\u27e9}  = refl\nmod-right {b O} = refl\nmod-right {b I} = refl\n-- Also, I'm confused on the implications of improper \"case trees\". If the\n-- second rule wasn't reachable, the following code would run even\n-- if the rule was nonesense (eg, changing `b +\u1d47 \u27e8\u27e9 = b O O`) but it doesn't\n-- work! The rule must make sense. So, Agda is applying the rule after all and\n-- not ignoring it even thought it can't be reached directly in proofs\n_ : (\u27e8\u27e9 I O I I I) +\u1d47 (\u27e8\u27e9 O O I) \u2261 \u27e8\u27e9 I I O O O\n_ = refl\n\n\n---proppre : \u2200 (n : \u2115) \u2192 zero + suc n \u2261 suc (zero + n)\n---proppre zero = refl\n---proppre (suc n) =\n---  begin\n---    zero + suc (suc n)\n---  \u2261\u27e8\u27e9\n---    zero + suc (zero + suc n)\n---  \u2261\u27e8\u27e9\n---    suc (zero + suc n)\n---  \u220e\n  --\u2261\u27e8 cong suc (proppre n) \u27e9\n\n-- Taken it from book\nassoc-+ : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\nassoc-+ zero n p = refl\nassoc-+ (suc m) n p rewrite assoc-+ m n p = refl\n\ncomm-+\u2080 : \u2200 (m : \u2115) \u2192 m + zero \u2261 m\ncomm-+\u2080 zero = refl\ncomm-+\u2080 (suc n) rewrite comm-+\u2080 n = refl\n--comm-+\u2080 (suc n) =\n--  begin\n--    zero + suc n\n--  \u2261\u27e8\u27e9\n--    zero + suc (zero + n)\n--  \u2261\u27e8\u27e9\n--    suc (zero + n)\n--  \u2261\u27e8 cong suc (comm-+\u2080 n) \u27e9\n--    suc (n + zero)\n--  \u2261\u27e8\u27e9\n--    suc n + zero\n--  \u220e\n\nsucc_right : \u2200 (n m : \u2115) \u2192 suc (n + m) \u2261 n + suc m\nsucc_right zero m = refl\nsucc_right (suc n) m rewrite succ_right n m = refl\n--succ_right (suc n) m = cong suc (succ_right n m)\n--succ_right (suc n) m =\n--  begin\n--    suc (suc n + m)\n--  \u2261\u27e8\u27e9\n--    suc (suc (n + m))\n--  \u2261\u27e8 cong suc (succ_right n m) \u27e9\n--    suc (n + suc m)\n--  \u2261\u27e8\u27e9\n--    suc n + suc m\n--  \u220e\n\ncomm-+ : \u2200 (n m : \u2115) \u2192 n + m \u2261 m + n\ncomm-+ zero n = sym (comm-+\u2080 n)\ncomm-+ (suc n) m rewrite comm-+ n m | succ_right m n = refl\n--comm-+ (suc n) m = trans (cong suc (comm-+ n m)) (succ_right m n)\n--comm-+ (suc n) m =\n--  begin\n--    suc n + m\n--  \u2261\u27e8\u27e9 -- +-def\u2081\n--    suc (n + m)\n--  \u2261\u27e8 cong suc (comm-+ n m) \u27e9\n--    suc (m + n)\n--  \u2261\u27e8 succ_right m n \u27e9\n--    m + suc n\n--  \u220e\n\n-- Try evaluating and type-checking the following expressions:\n-- comm-+ zero\n-- (flip comm-+) zero\n-- \u03bb n m \u2192 cong suc (comm-+ n m)\n-- \u03bb m n \u2192 succ_right m n\n-- \u03bb m n \u2192 sym (succ_right m n)\n-- \u03bb n m \u2192 trans (cong suc (comm-+ n m)) (succ_right m n)\n\nmonus : \u2200 (n : \u2115) \u2192 zero \u2238 n \u2261 zero\nmonus zero = refl\nmonus (suc n) = refl\n--monus : \u2200 {n : \u2115} \u2192 zero \u2238 n \u2261 zero\n--monus {zero} = refl\n--monus {suc n} = refl\n\ninc\u2261suc : \u2200 (b : Bin) \u2192 from\u1d47 (inc b) \u2261 suc (from\u1d47 b)\ninc\u2261suc \u27e8\u27e9 = refl\ninc\u2261suc (b O) rewrite sym (comm-+\u2080 (from\u1d47 b)) = refl\ninc\u2261suc (b I)\n  rewrite\n    comm-+\u2080 (from\u1d47 (inc b))\n  | inc\u2261suc b\n  | succ_right (from\u1d47 b) (from\u1d47 b)\n  | comm-+\u2080 (from\u1d47 b)\n  | succ_right (from\u1d47 b) (from\u1d47 b) = refl\n\n-- `to\u1d47 (from\u1d47 b) \u2261 b` doesn't hold for all values, just for some.\n-- So the following is false\n--tofromb\u2262b : \u2200 (b : Bin) \u2192 \u00ac (to\u1d47 (from\u1d47 b) \u2261 b)\n--tofromb\u2262b \u27e8\u27e9 = \u03bb()\n--tofromb\u2262b = ? -- impossible to prove\n\n_ : \u00ac (to\u1d47 (from\u1d47 \u27e8\u27e9) \u2261 \u27e8\u27e9)\n_ = \u03bb()\n\n--from\u2218to\u1d47\u2080 : \u2200 (n : \u2115) \u2192 from\u1d47 ((to\u1d47 n) O) \u2261 from\u1d47 (to\u1d47 n) + from\u1d47 (to\u1d47 n)\n--from\u2218to\u1d47\u2080 zero = refl\n--from\u2218to\u1d47\u2080 (suc n) = refl\n--\n--from\u2218to\u1d47\u2081 : \u2200 (n : \u2115) \u2192 from\u1d47 ((to\u1d47 n) I) \u2261 suc (from\u1d47 (to\u1d47 n) + from\u1d47 (to\u1d47 n))\n--from\u2218to\u1d47\u2081 zero = refl\n--from\u2218to\u1d47\u2081 (suc n) = refl\n\nmonobin\u2080 : \u2200 (b : Bin) \u2192 inc (inc (b +\u1d47 b)) \u2261 (inc b +\u1d47 inc b)\nmonobin\u2080 \u27e8\u27e9 = refl\nmonobin\u2080 (b O) = refl\nmonobin\u2080 (b I) rewrite monobin\u2080 b = refl\n\nmonobin : \u2200 (n : \u2115) \u2192 to\u1d47 (n + n) \u2261 (to\u1d47 n) +\u1d47 (to\u1d47 n)\nmonobin zero = refl\nmonobin (suc n) rewrite\n    sym (succ_right n n)\n  | monobin n\n  | monobin\u2080 (to\u1d47 n) = refl\n\n--mononat\u2080 : \u2200 (a : Bin) \u2192 a +\u1d47 \u27e8\u27e9 \u2261 a\n--mononat\u2080 \u27e8\u27e9 = refl\n--mononat\u2080 (b O) = refl\n--mononat\u2080 (b I) = refl\n--\n--mononat\u2081 : \u2200 (a b : Bin) \u2192 from\u1d47 (inc (a +\u1d47 b)) \u2261 suc (from\u1d47 a + from\u1d47 b)\n--mononat\u2081 \u27e8\u27e9 b rewrite inc\u2261suc b = refl\n--mononat\u2081 a \u27e8\u27e9 rewrite mononat\u2080 a | comm-+\u2080 (from\u1d47 a) | inc\u2261suc a = refl\n--mononat\u2081 = ?\n---- \u03bb a \u2192 from\u1d47 (inc (a +\u1d47 \u27e8\u27e9)) \u2261 suc (from\u1d47 a + from\u1d47 \u27e8\u27e9)\n---- from\u1d47 (inc b) \u2261 suc (from\u1d47 b)\n--\n--mononat : \u2200 (a b : Bin) \u2192 from\u1d47 (a +\u1d47 b) \u2261 from\u1d47 a + from\u1d47 b\n--mononat \u27e8\u27e9 _ = refl\n--mononat a \u27e8\u27e9 rewrite mononat\u2080 a | comm-+\u2080 (from\u1d47 a) = refl\n----mononat a \u27e8\u27e9 = \n----  begin\n----    from\u1d47 (a +\u1d47 \u27e8\u27e9)\n----    \u2261\u27e8 cong from\u1d47 (mononat\u2080 a) \u27e9\n----    from\u1d47 (a)\n----    \u2261\u27e8 sym (comm-+\u2080 (from\u1d47 a)) \u27e9\n----    from\u1d47 a + zero\n----    \u2261\u27e8\u27e9\n----    from\u1d47 a + from\u1d47 \u27e8\u27e9\n----  \u220e\n--mononat (a O) (b O) rewrite\n--    mononat a b\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | comm-+ (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 a) (from\u1d47 b + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 b)\n--  = refl\n--mononat (a I) (b O) rewrite\n--    mononat a b\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | comm-+ (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 a) (from\u1d47 b + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 b)\n--  = refl\n--mononat (a O) (b I) rewrite\n--    mononat a b\n--  | sym (succ_right (from\u1d47 a + from\u1d47 a) (from\u1d47 b + from\u1d47 b))\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | comm-+ (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 a) (from\u1d47 b + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 b)\n--  = refl\n--mononat (a I) (b I) rewrite\n--    mononat\u2081 a b\n--  | sym (succ_right (from\u1d47 a + from\u1d47 a) (from\u1d47 b + from\u1d47 b))\n--  | sym (succ_right (from\u1d47 a + from\u1d47 b) (from\u1d47 a + from\u1d47 b))\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | comm-+ (from\u1d47 b) (from\u1d47 a + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 a) (from\u1d47 b + from\u1d47 b)\n--  | assoc-+ (from\u1d47 a) (from\u1d47 b) (from\u1d47 b)\n--  = refl\n\n-- Really hard!! Keep working on it!\n-- IT WASN'T HARD!!! I JUST COULDN'T SEE THE RIGHT REWRITE!!\nfrom\u2218to\u1d47 : \u2200 (n : \u2115) \u2192 from\u1d47 (to\u1d47 n) \u2261 n\nfrom\u2218to\u1d47 zero = refl\nfrom\u2218to\u1d47 (suc n) rewrite inc\u2261suc (to\u1d47 n) | from\u2218to\u1d47 n = refl\n--from\u2218to\u1d47 (suc n) =\n--  begin\n--    from\u1d47 (to\u1d47 (suc n))\n--  \u2261\u27e8\u27e9\n--    from\u1d47 (inc (to\u1d47 n))\n--  \u2261\u27e8 inc\u2261suc (to\u1d47 n) \u27e9\n--    suc (from\u1d47 (to\u1d47 n))\n--  \u2261\u27e8 cong suc (from\u2218to\u1d47 n) \u27e9\n--    suc n\n--  \u220e\n\nswap-m-n-+ : \u2200 (m n p) \u2192 m + (n + p) \u2261 n + (m + p)\nswap-m-n-+ m n p rewrite\n    sym (assoc-+ m n p)\n  | sym (assoc-+ n m p)\n  | comm-+ m n\n  = refl\n\nright-zero-* : \u2200 (n : \u2115) \u2192 n * 0 \u2261 0\nright-zero-* zero    = refl\nright-zero-* (suc n) rewrite right-zero-* n = refl\n\nsuc-right-* : \u2200 (m n) \u2192 m * suc n \u2261 m + m * n\nsuc-right-* zero n = refl\nsuc-right-* (suc m) n\n  rewrite\n    suc-right-* m n\n  | sym (assoc-+ n m (m * n))\n  | comm-+ n m\n  | assoc-+ m n (m * n)\n  = refl\n\ncomm-* : \u2200 (m n : \u2115) \u2192 m * n \u2261 n * m\ncomm-* zero n rewrite right-zero-* n = refl\ncomm-* (suc m) n\n  rewrite\n    comm-* m n\n  | suc-right-* n m\n  = refl\n\ndistr-*-+ : \u2200 (m n p) \u2192 (m + n) * p \u2261 m * p + n * p\ndistr-*-+ zero _ _ = refl\ndistr-*-+ (suc m) n p rewrite distr-*-+ m n p | assoc-+ p (m * p) (n * p) = refl\n\ndistl-*-+ : \u2200 (p m n) \u2192 p * (m + n) \u2261 p * m + p * n\ndistl-*-+ zero _ _ = refl\ndistl-*-+ (suc p) m n\n  rewrite\n    distl-*-+ p m n\n  | sym (assoc-+ (m + n) (p * m) (p * n))\n  | sym (assoc-+ (m + p * m) n (p * n))\n  | assoc-+ m n (p * m)\n  | comm-+ n (p * m)\n  | assoc-+ m (p * m) n\n  = refl\n\nassoc-* : \u2200 (m n p : \u2115) \u2192 (m * n) * p \u2261 m * (n * p)\nassoc-* zero n p = refl\nassoc-* (suc m) n p\n  rewrite\n    assoc-* m n p\n  | distr-*-+ n (m * n) p\n  | assoc-* m n p\n  = refl\n\nswap-m-n-* : \u2200 (m n p) \u2192 m * (n * p) \u2261 n * (m * p)\nswap-m-n-* m n p rewrite\n    sym (assoc-* m n p)\n  | sym (assoc-* n m p)\n  | comm-* m n\n  = refl\n\ndistr-^-* : \u2200 (m n p) \u2192 (m * n) ^ p \u2261 (m ^ p) * (n ^ p)\n--distr-^-* m n zero    =\n--  begin\n--    (m * n) ^ zero\n--  \u2261\u27e8\u27e9\n--    (m * n) ^ 0\n--  \u2261\u27e8\u27e9\n--    suc 0\n--  \u2261\u27e8\u27e9\n--    1\n--  \u2261\u27e8\u27e9\n--    1 + 0\n--  \u2261\u27e8\u27e9\n--    1 + 0 * 1\n--  \u2261\u27e8\u27e9\n--    (suc 0) * 1\n--  \u2261\u27e8\u27e9\n--    (suc 0) * 1\n--  \u2261\u27e8\u27e9\n--    1 * 1\n--  \u2261\u27e8\u27e9\n--    1 * (n ^ 0)\n--  \u2261\u27e8\u27e9\n--    (m ^ zero) * (n ^ zero)\n--  \u2261\u27e8\u27e9\n--    (m ^ 0) * (n ^ 0)\n--  \u220e\ndistr-^-* _       _       zero    = refl\ndistr-^-* zero    zero    (suc p) = refl\ndistr-^-* zero    (suc n) (suc p) = refl\ndistr-^-* (suc m) zero    (suc p)\n  rewrite\n    right-zero-* (suc m ^ suc p)\n  | right-zero-* m\n  = refl\ndistr-^-* (suc m) (suc n) (suc p)\n  rewrite\n--  (suc m * suc n) ^ suc p \u2261 suc m ^ suc p * suc n ^ suc p\n--\n--    suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n--  \u2261 (suc m ^ p + m * suc m ^ p) * (suc n ^ p + n * suc n ^ p)\n    distr-*-+ (suc m ^ p) (m * suc m ^ p) (suc n ^ p + n * suc n ^ p)\n--    suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n--  \u2261\n--    suc m ^ p * (suc n ^ p + n * suc n ^ p)\n--    + m * suc m ^ p * (suc n ^ p + n * suc n ^ p)\n  | assoc-* m (suc m ^ p) (suc n ^ p + n * suc n ^ p)\n--    suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n--  \u2261\n--    suc m ^ p * (suc n ^ p + n * suc n ^ p)\n--    + m * (suc m ^ p * (suc n ^ p + n * suc n ^ p))\n  | distl-*-+ (suc m ^ p) (suc n ^ p) (n * suc n ^ p)\n--    suc (n + m * suc n) ^ p + (n + m * suc n) * suc (n + m * suc n) ^ p\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n  | comm-* m (suc n)\n--    suc (n + (m + n * m)) ^ p\n--    + (n + (m + n * m)) * suc (n + (m + n * m)) ^ p\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n  | comm-* n m\n--    suc (n + (m + m * n)) ^ p\n--    + (n + (m + m * n)) * suc (n + (m + m * n)) ^ p\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n  | sym (suc-right-* m n)\n--    suc (n + m * suc n) ^ p\n--    + (n + m * suc n) * suc (n + m * suc n) ^ p\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n  | distr-^-* (suc m) (suc n) p\n--    suc m ^ p * suc n ^ p + (n + m * suc n) * (suc m ^ p * suc n ^ p)\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n  | distr-*-+ n (m * suc n) (suc m ^ p * suc n ^ p)\n--    suc m ^ p * suc n ^ p + (n * (suc m ^ p * suc n ^ p)\n--    + m * suc n * (suc m ^ p * suc n ^ p))\n--    \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + m * (suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p))\n  | distl-*-+ m (suc m ^ p * suc n ^ p) (suc m ^ p * (n * suc n ^ p))\n--    suc m ^ p * suc n ^ p + (n * (suc m ^ p * suc n ^ p)\n--    + m * suc n * (suc m ^ p * suc n ^ p))\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n  | comm-* m (suc n)\n--    suc m ^ p * suc n ^ p + (n * (suc m ^ p * suc n ^ p)\n--    + (m + n * m) * (suc m ^ p * suc n ^ p))\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p)\n--    + (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n  | distr-*-+ m (n * m) (suc m ^ p * suc n ^ p)\n--    suc m ^ p * suc n ^ p +\n--    (n * (suc m ^ p * suc n ^ p) +\n--     (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p) +\n--    (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n  | swap-m-n-* n (suc m ^ p) (suc n ^ p)\n--    suc m ^ p * suc n ^ p +\n--    (suc m ^ p * (n * suc n ^ p) +\n--     (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n--  \u2261\n--    suc m ^ p * suc n ^ p + suc m ^ p * (n * suc n ^ p) +\n--    (m * (suc m ^ p * suc n ^ p) + m * (suc m ^ p * (n * suc n ^ p)))\n  | swap-m-n-* (suc m ^ p) n (suc n ^ p)\n--    suc m ^ p * suc n ^ p +\n--    (n * (suc m ^ p * suc n ^ p) +\n--     (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n--  \u2261\n--    suc m ^ p * suc n ^ p + n * (suc m ^ p * suc n ^ p) +\n--    (m * (suc m ^ p * suc n ^ p) + m * (n * (suc m ^ p * suc n ^ p)))\n  | sym (assoc-* m n (suc m ^ p * suc n ^ p))\n--    suc m ^ p * suc n ^ p +\n--    (n * (suc m ^ p * suc n ^ p) +\n--     (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n--  \u2261\n--    suc m ^ p * suc n ^ p + n * (suc m ^ p * suc n ^ p) +\n--    (m * (suc m ^ p * suc n ^ p) + m * n * (suc m ^ p * suc n ^ p))\n  | comm-* m n\n--    suc m ^ p * suc n ^ p +\n--    (n * (suc m ^ p * suc n ^ p) +\n--     (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n--    \u2261\n--    suc m ^ p * suc n ^ p + n * (suc m ^ p * suc n ^ p) +\n--    (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p))\n  | assoc-+ (suc m ^ p * suc n ^ p) (n * (suc m ^ p * suc n ^ p))\n    (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p))\n--    suc m ^ p * suc n ^ p +\n--    (n * (suc m ^ p * suc n ^ p) +\n--     (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n--    \u2261\n--    suc m ^ p * suc n ^ p +\n--    (n * (suc m ^ p * suc n ^ p) +\n--     (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p)))\n-- QED\n  = refl\n\n--distr-^-* (suc m) (suc n) (suc p)\n--  rewrite\n--    distr-*-+ (suc m ^ p) (m * suc m ^ p) (suc n ^ p + n * suc n ^ p)\n--  | assoc-* m (suc m ^ p) (suc n ^ p + n * suc n ^ p)\n--  | distl-*-+ (suc m ^ p) (suc n ^ p) (n * suc n ^ p)\n--  | comm-* m (suc n)\n--  | comm-* n m\n--  | sym (suc-right-* m n)\n--  | distr-^-* (suc m) (suc n) p\n--  | distr-*-+ n (m * suc n) (suc m ^ p * suc n ^ p)\n--  | distl-*-+ m (suc m ^ p * suc n ^ p) (suc m ^ p * (n * suc n ^ p))\n--  | comm-* m (suc n)\n--  | distr-*-+ m (n * m) (suc m ^ p * suc n ^ p)\n--  | swap-m-n-* n (suc m ^ p) (suc n ^ p)\n--  | swap-m-n-* (suc m ^ p) n (suc n ^ p)\n--  | sym (assoc-* m n (suc m ^ p * suc n ^ p))\n--  | comm-* m n\n--  | assoc-+ (suc m ^ p * suc n ^ p) (n * (suc m ^ p * suc n ^ p))\n--    (m * (suc m ^ p * suc n ^ p) + n * m * (suc m ^ p * suc n ^ p))\n--  = refl\n\n--------------------------------------- Relations ---------------------------------------\n\ndata _\u2264_ : \u2115 \u2192 \u2115 \u2192 Set where\n  z\u2264n : \u2200 {n : \u2115} \u2192 zero \u2264 n\n  s\u2264s : \u2200 {m n : \u2115} \u2192 m \u2264 n \u2192 suc m \u2264 suc n\n\n_ : 2 \u2264 4\n_ = s\u2264s (s\u2264s z\u2264n)\n--_ = s\u2264s {1} {3} (s\u2264s {0} {2} (z\u2264n {2}))\n\ninv-s\u2264s : \u2200 {m n : \u2115} \u2192 suc m \u2264 suc n \u2192 m \u2264 n\ninv-s\u2264s (s\u2264s m\u2264n) = m\u2264n\n\ninv-z\u2264n : \u2200 {m : \u2115} \u2192 m \u2264 zero \u2192 m \u2261 zero\ninv-z\u2264n z\u2264n = refl\n\nrefl-\u2264 : \u2200 {n : \u2115} \u2192 n \u2264 n\nrefl-\u2264 {zero}  = z\u2264n\nrefl-\u2264 {suc o} = s\u2264s refl-\u2264\n\ntrans-\u2264 : \u2200 {m n p : \u2115} \u2192 m \u2264 n \u2192 n \u2264 p \u2192 m \u2264 p\ntrans-\u2264 z\u2264n       _         = z\u2264n\ntrans-\u2264 (s\u2264s m\u2264n) (s\u2264s n\u2264p) = s\u2264s (trans-\u2264 m\u2264n n\u2264p)\n\nantisym-\u2264 : \u2200 {m n : \u2115} \u2192 m \u2264 n \u2192 n \u2264 m \u2192 m \u2261 n\nantisym-\u2264 z\u2264n       n\u2264m       = sym (inv-z\u2264n n\u2264m)\nantisym-\u2264 (s\u2264s m\u2264n) (s\u2264s n\u2264m) = cong suc (antisym-\u2264 m\u2264n n\u2264m)\n\nopen import Data.Sum using (_\u228e_; inj\u2081; inj\u2082) renaming ([_,_] to case-\u228e)\n\n--data Total (m n : \u2115) : Set where\n--  forward : m \u2264 n \u2192 Total m n\n--  flipped : n \u2264 m \u2192 Total m n\n--\n--total-\u2264 : \u2200 (m n : \u2115) \u2192 Total m n\n--total-\u2264 zero    _    = forward z\u2264n\n--total-\u2264 (suc m) zero = flipped z\u2264n\n--total-\u2264 (suc m) (suc n) with total-\u2264 m n\n--...                     | forward m\u2264n = forward (s\u2264s m\u2264n)\n--...                     | flipped n\u2264m = flipped (s\u2264s n\u2264m)\n\ntotal-\u2264` : \u2200 (m n : \u2115) \u2192 m \u2264 n \u228e n \u2264 m\ntotal-\u2264` zero    _       = inj\u2081 z\u2264n\ntotal-\u2264` _       zero    = inj\u2082 z\u2264n\ntotal-\u2264` (suc m) (suc n) with total-\u2264` m n\n...                      | inj\u2081 m\u2264n = inj\u2081 (s\u2264s m\u2264n)\n...                      | inj\u2082 n\u2264m = inj\u2082 (s\u2264s n\u2264m)\n\n--+-mono\u02b3-\u2264 : \u2200 (n p q : \u2115) \u2192 p \u2264 q \u2192 (n + p) \u2264 (n + q)\n--+-mono\u02b3-\u2264 zero    _ _ p\u2264q = p\u2264q\n--+-mono\u02b3-\u2264 (suc n) p q p\u2264q = s\u2264s (+-mono\u02b3-\u2264 n p q p\u2264q)\n\n+-mono\u02b3-\u2264 : \u2200 {n p q : \u2115} \u2192 p \u2264 q \u2192 (n + p) \u2264 (n + q)\n+-mono\u02b3-\u2264 {zero}  p\u2264q = p\u2264q\n+-mono\u02b3-\u2264 {suc n} p\u2264q = s\u2264s (+-mono\u02b3-\u2264 {n} p\u2264q)\n\n+-mono\u02e1-\u2264 : \u2200 {m n p : \u2115} \u2192 m \u2264 n \u2192 (m + p) \u2264 (n + p)\n+-mono\u02e1-\u2264 {m} {n} {p} m\u2264n rewrite comm-+ m p | comm-+ n p = +-mono\u02b3-\u2264 m\u2264n\n\n-- From book\n\u2264-trans : \u2200 {m n p : \u2115} \u2192 m \u2264 n \u2192 n \u2264 p \u2192 m \u2264 p\n\u2264-trans z\u2264n       _          =  z\u2264n\n\u2264-trans (s\u2264s m\u2264n) (s\u2264s n\u2264p)  =  s\u2264s (\u2264-trans m\u2264n n\u2264p)\n\n+-mono-\u2264 : \u2200 {m n p q : \u2115} \u2192 m \u2264 n \u2192 p \u2264 q \u2192 (m + p) \u2264 (n + q)\n+-mono-\u2264 m\u2264n p\u2264q = \u2264-trans (+-mono\u02e1-\u2264 m\u2264n) (+-mono\u02b3-\u2264 p\u2264q)\n\n-- Exercises\n*-mono\u02b3-\u2264 : \u2200 {n p q : \u2115} \u2192 p \u2264 q \u2192 (n * p) \u2264 (n * q)\n*-mono\u02b3-\u2264 {zero}  p\u2264q = z\u2264n\n*-mono\u02b3-\u2264 {suc n} p\u2264q = +-mono-\u2264 p\u2264q (*-mono\u02b3-\u2264 {n} p\u2264q)\n\n*-mono\u02e1-\u2264 : \u2200 {m n p : \u2115} \u2192 m \u2264 n \u2192 (m * p) \u2264 (n * p)\n*-mono\u02e1-\u2264 {m} {n} {p} m\u2264n rewrite comm-* m p | comm-* n p = *-mono\u02b3-\u2264 {p} {m} {n} m\u2264n\n\n*-mono-\u2264 : \u2200 {m n p q : \u2115} \u2192 m \u2264 n \u2192 p \u2264 q \u2192 (m * p) \u2264 (n * q)\n*-mono-\u2264 {_} {n} m\u2264n p\u2264q = \u2264-trans (*-mono\u02e1-\u2264 m\u2264n) (*-mono\u02b3-\u2264 {n} p\u2264q)\n\ninfix 4 _<_\n\ndata _<_ : \u2115 \u2192 \u2115 \u2192 Set where\n  z<s : \u2200 {n : \u2115} \u2192 zero < suc n\n  s<s : \u2200 {m n : \u2115} \u2192 m < n \u2192 suc m < suc n\n\n<-trans : \u2200 {m n p} \u2192 m < n \u2192 n < p \u2192 m < p\n--<-trans {m} {suc n} {suc p} z<s (s<s n<p) = z<s {p}\n--<-trans {suc m} {suc n} {suc p} (s<s m<n) (s<s n<p) = s<s (<-trans m<n n<p)\n<-trans z<s       (s<s n<p) = z<s\n<-trans (s<s m<n) (s<s n<p) = s<s (<-trans m<n n<p)\n\ntrichotomy : \u2200 (m n) \u2192 (m \u2261 n) \u228e (m < n) \u228e (n < m)\ntrichotomy zero    zero    = inj\u2081 refl\ntrichotomy zero    (suc n) = inj\u2082 (inj\u2081 z<s)\ntrichotomy (suc m) zero    = inj\u2082 (inj\u2082 z<s)\ntrichotomy (suc m) (suc n) with trichotomy m n\n...                       | inj\u2081 m\u2261n        = inj\u2081 (cong suc m\u2261n)\n...                       | inj\u2082 (inj\u2081 m<n) = inj\u2082 (inj\u2081 (s<s m<n))\n...                       | inj\u2082 (inj\u2082 n<m) = inj\u2082 (inj\u2082 (s<s n<m))\n\n+-mono\u02b3-< : \u2200 {n p q} \u2192 p < q \u2192 (n + p) < (n + q)\n+-mono\u02b3-< {zero}  p<q = p<q\n+-mono\u02b3-< {suc n} p<q = s<s (+-mono\u02b3-< p<q)\n\n+-mono\u02e1-< : \u2200 {m n p} \u2192 m < n \u2192 (m + p) < (n + p)\n+-mono\u02e1-< {m} {n} {p} m<n rewrite comm-+ m p | comm-+ n p = +-mono\u02b3-< m<n\n\n+-mono-< : \u2200 {m n p q} \u2192 m < n \u2192 p < q \u2192 (m + p) < (n + q)\n+-mono-< m<n p<q = <-trans (+-mono\u02e1-< m<n) (+-mono\u02b3-< p<q)\n\n-- From Software Verification Class (nice exercises but the two first are\n-- unnecessary in Agda because the proofs are basically the relation\n-- definition)\n\u22610 : \u2200 {n : \u2115} \u2192 \u00ac( 0 < n ) \u2192 n \u2261 0\n\u22610 {zero}  _    = refl\n\u22610 {suc n} \u00ac0<n = \u22a5-elim (\u00ac0<n z<s)\n\n--0< : \u2200 {n : \u2115} \u2192 n \u2262 0 \u2192 0 < n\n0< : \u2200 {n : \u2115} \u2192 \u00ac( n \u2261 0 ) \u2192 0 < n\n0< {zero} 0\u22620 = \u22a5-elim (0\u22620 refl)\n0< {suc n} s\u22620 = z<s\n\n\u00acn<z : \u2200 {n : \u2115} \u2192 \u00ac( n < 0 )\n\u00acn<z ()\n\nm<sn\u2192m<n\u228em\u2261n : {m n : \u2115} \u2192 (m < suc n) \u2192 (m < n) \u228e (m \u2261 n)\nm<sn\u2192m<n\u228em\u2261n {zero}  {zero}  _ = inj\u2082 refl\nm<sn\u2192m<n\u228em\u2261n {zero}  {suc n} _ = inj\u2081 z<s\nm<sn\u2192m<n\u228em\u2261n {suc m} {zero}  (s<s ())\nm<sn\u2192m<n\u228em\u2261n {suc m} {suc n} (s<s m<sn) with m<sn\u2192m<n\u228em\u2261n {m} {n} m<sn\n...                 | inj\u2081 m<n = inj\u2081 (s<s m<n)\n...                 | inj\u2082 m\u2261n = inj\u2082 (cong suc m\u2261n)\n\nsuc-step : {m n : \u2115} \u2192 (m < suc n) \u00d7 (m \u2262 n) \u2192 m < n\nsuc-step {zero}  {zero}  \u27e8 0<1      , 0\u22620   \u27e9 = 0< 0\u22620\nsuc-step {zero}  {suc n} \u27e8 0<ssn    , 0\u2262sn  \u27e9 = z<s\nsuc-step {suc m} {zero}  \u27e8 s<s m<0  , sm\u22620  \u27e9 = \u22a5-elim (\u00acn<z m<0)\nsuc-step {suc m} {suc n} \u27e8 s<s m<sn , sm\u2262sn \u27e9 with m<sn\u2192m<n\u228em\u2261n m<sn\n...                 | inj\u2081 m<n = s<s m<n\n...                 | inj\u2082 m\u2261n = \u22a5-elim (sm\u2262sn (cong suc m\u2261n))\n\n-- This idea of using returning \u2203 in Athena might be fundamental but it is\n-- clumsy or cumbersome in Agda\ndiscrete : \u2200 {n : \u2115} \u2192 \u00ac (\u2203[ m ] (n < m \u00d7 m < suc n))\ndiscrete {zero}  \u27e8 _     , \u27e8 z<s , s<s () \u27e9 \u27e9\ndiscrete {suc n} \u27e8 zero  , \u27e8 ()  , _      \u27e9 \u27e9\ndiscrete {suc n} \u27e8 suc m , \u27e8 s<s n<m , s<s m<sn \u27e9 \u27e9 = discrete \u27e8 m , \u27e8 n<m , m<sn \u27e9 \u27e9\n\n-- This is unnecessary because it is the same as pred n\n-- proj\u2081 (S4 {_} {n} _) \u2261 pred n\n--S4 : \u2200 {m n : \u2115} \u2192 suc m < n \u2192 \u2203[ n' ] ( n \u2261 suc n' )\nS4 : \u2200 {m n : \u2115} \u2192 m < n \u2192 \u2203[ n' ] ( n \u2261 suc n' )\nS4 {_} {zero} ()\nS4 {_} {suc n} _ = \u27e8 n , refl \u27e9\n\n-- more interesting is:\nS4' : \u2200 {m n : \u2115} \u2192 suc m \u2264 n \u2192 \u2203[ n' ] ( n \u2261 suc n' )\nS4' {_} {zero} ()\nS4' {_} {suc n} _ = \u27e8 n , refl \u27e9\n-- It is more interesting because, this is not true:\n-- S4' : \u2200 {m n : \u2115} \u2192 m \u2264 n \u2192 \u2203[ n' ] ( n \u2261 suc n' )\n-- as opposed to S4.\n-- But still, it's something that isn't necessary in Agda\n\nirreflexive : \u2200 {m : \u2115} \u2192 \u00ac(m < m)\nirreflexive {zero} ()\nirreflexive {suc m} (s<s m<m) = irreflexive m<m\n\ntrichotomy\u2082 : \u2200 (m n) \u2192 (m \u2261 n \u00d7 \u00ac(m < n) \u00d7 \u00ac(n < m))\n                      \u228e (m < n \u00d7   m \u2262 n  \u00d7 \u00ac(n < m))\n                      \u228e (n < m \u00d7   m \u2262 n  \u00d7 \u00ac(m < n))\ntrichotomy\u2082 zero    zero    = inj\u2081 \u27e8 refl , \u27e8 irreflexive , irreflexive \u27e9 \u27e9\ntrichotomy\u2082 zero    (suc n) = inj\u2082 (inj\u2081 \u27e8 z<s , \u27e8 (\u03bb()) , (\u03bb()) \u27e9 \u27e9)\ntrichotomy\u2082 (suc m) zero    = inj\u2082 (inj\u2082 \u27e8 z<s , \u27e8 (\u03bb()) , (\u03bb()) \u27e9 \u27e9)\ntrichotomy\u2082 (suc m) (suc n) with trichotomy\u2082 m n\n...                       | inj\u2081 \u27e8 m\u2261n , \u27e8 \u00acm<n , \u00acn<m \u27e9 \u27e9 =\n      inj\u2081 \u27e8 cong suc m\u2261n , \u27e8 (\u03bb{(s<s m<n) \u2192 \u00acm<n m<n}) , (\u03bb{(s<s n<m) \u2192 \u00acn<m n<m}) \u27e9 \u27e9\n...                       | inj\u2082 (inj\u2081 \u27e8 m<n , \u27e8 m\u2262n , \u00acn<m \u27e9 \u27e9) =\n      inj\u2082 (inj\u2081 \u27e8 s<s m<n , \u27e8 (\u03bb{sm\u2261sn \u2192 m\u2262n (cong pred sm\u2261sn)}) , (\u03bb{(s<s n<m) \u2192 \u00acn<m n<m}) \u27e9 \u27e9)\n...                       | inj\u2082 (inj\u2082 \u27e8 n<m , \u27e8 m\u2262n , \u00acm<n \u27e9 \u27e9) =\n      inj\u2082 (inj\u2082 \u27e8 s<s n<m , \u27e8 (\u03bb{sm\u2261sn \u2192 m\u2262n (cong pred sm\u2261sn)}) , (\u03bb{(s<s m<n) \u2192 \u00acm<n m<n}) \u27e9 \u27e9)\n\n--open import Function.Equivalence using (_\u21d4_)\nrecord _\u21d4_ (A B : Set) : Set where\n  field\n    to   : A \u2192 B\n    from : B \u2192 A\n\nopen _\u21d4_\n\n<-if-\u2264 : \u2200 {m n} \u2192 suc m \u2264 n \u2192 m < n\n<-if-\u2264 {zero}  {suc n} z\u2264s        = z<s\n<-if-\u2264 {suc m} {suc n} (s\u2264s sm\u2264n) = s<s (<-if-\u2264 sm\u2264n)\n\n\u2264-if-< : \u2200 {m n} \u2192 m < n \u2192 suc m \u2264 n\n\u2264-if-< {zero} {suc n} z<s = s\u2264s z\u2264n\n\u2264-if-< {suc m} {suc n} (s<s m<n) = s\u2264s (\u2264-if-< m<n)\n\n\u2264-iff-< : \u2200 {m n} \u2192 (suc m \u2264 n) \u21d4 (m < n)\n\u2264-iff-< = record\n  { to   = <-if-\u2264\n  ; from = \u2264-if-<\n  }\n\npred-smaller : \u2200 {m n} \u2192 suc m \u2264 n \u2192 m \u2264 n\npred-smaller {zero}          _          = z\u2264n\npred-smaller {suc m} {suc n} (s\u2264s sm\u2264n) = s\u2264s (pred-smaller sm\u2264n)\n\n<-trans-revisited : \u2200 {m n p} \u2192 m < n \u2192 n < p \u2192 m < p\n<-trans-revisited {m} {n} {p} m<n n<p\n  = <-if-\u2264 (\u2264-trans (\u2264-if-< m<n) (pred-smaller (\u2264-if-< n<p)))\n\n---\n\ndata even : \u2115 \u2192 Set\ndata odd  : \u2115 \u2192 Set\n\ndata even where \n  zero-e : even zero\n  suc-e  : \u2200 {n : \u2115} \u2192 odd n \u2192 even (suc n)\n\ndata odd where \n  suc-o : \u2200 {n : \u2115} \u2192 even n \u2192 odd (suc n)\n\n\n--- \n\ndata Can : Bin \u2192 Set\ndata One : Bin \u2192 Set\n\ndata Can where\n  zero-C : Can (\u27e8\u27e9 O)\n  one-C : \u2200 {b : Bin} \u2192 One b \u2192 Can b\n\ndata One where\n  oneO : One (\u27e8\u27e9 I)\n  oneO-O : \u2200 {b : Bin} \u2192 One b \u2192 One (b O)\n  oneO-I : \u2200 {b : Bin} \u2192 One b \u2192 One (b I)\n\n_ : Can (\u27e8\u27e9 I)\n_ = one-C oneO\n\ninc-Bin : \u2200 {b : Bin} \u2192 One b \u2192 One (inc b)\ninc-Bin oneO        = oneO-O oneO\ninc-Bin (oneO-O ob) = oneO-I ob\ninc-Bin (oneO-I ob) = oneO-O (inc-Bin ob)\n\ninc-Can : \u2200 {b : Bin} \u2192 Can b \u2192 Can (inc b)\ninc-Can zero-C     = one-C oneO\ninc-Can (one-C ob) = one-C (inc-Bin ob)\n\nto-Can : \u2200 (n : \u2115) \u2192 Can (to\u1d47 n)\nto-Can zero = zero-C\nto-Can (suc n) = inc-Can (to-Can n)\n\ntwicebinisO : \u2200 {b : Bin} \u2192 One b \u2192 b +\u1d47 b \u2261 b O\ntwicebinisO {\u27e8\u27e9 I} _ = refl\ntwicebinisO {b O} (oneO-O ob) rewrite twicebinisO ob = refl\ntwicebinisO {b I} (oneO-I ob) rewrite twicebinisO ob = refl\n\nto\u2218from-Can : \u2200 {b : Bin} \u2192 Can b \u2192 to\u1d47 (from\u1d47 b) \u2261 b\nto\u2218from-Can zero-C = refl\nto\u2218from-Can (one-C oneO) = refl\nto\u2218from-Can {b O} (one-C (oneO-O ob))\n  rewrite monobin (from\u1d47 b)\n        | to\u2218from-Can (one-C ob)\n        | twicebinisO ob = refl\nto\u2218from-Can {b I} (one-C (oneO-I ob))\n  rewrite monobin (from\u1d47 b)\n        | to\u2218from-Can (one-C ob)\n        | twicebinisO ob = refl\n\n--------------------------------------- Equality ---------------------------------------\n\nmodule \u2264-Reasoning where\n  infix  1 begin\u2264_\n  infixr 2 _\u2264\u27e8\u27e9_ _\u2264\u27e8_\u27e9_\n  infix  3 _\u220e\u2264\n  \n  begin\u2264_ : \u2200 {x y : \u2115} \u2192 x \u2264 y \u2192 x \u2264 y\n  begin\u2264 x\u2264y = x\u2264y\n  \n  _\u2264\u27e8\u27e9_ : \u2200 (x : \u2115) {y : \u2115} \u2192 x \u2264 y \u2192 x \u2264 y\n  x \u2264\u27e8\u27e9 x\u2264y = x\u2264y\n\n  _\u2264\u27e8_\u27e9_ : \u2200 (x : \u2115) {y z : \u2115} \u2192 x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 z\n  x \u2264\u27e8 x\u2264y \u27e9 y\u2264z = trans-\u2264 x\u2264y y\u2264z\n  \n  _\u220e\u2264 : \u2200 (x : \u2115) \u2192 x \u2264 x\n  x \u220e\u2264 = refl-\u2264\n\nopen \u2264-Reasoning\n\n+-mono\u02b3-\u2264` : \u2200 {n p q : \u2115} \u2192 p \u2264 q \u2192 (n + p) \u2264 (n + q)\n+-mono\u02b3-\u2264` {zero} p\u2264q = p\u2264q\n+-mono\u02b3-\u2264` {suc n} {p} {q} p\u2264q =\n  begin\u2264\n    suc n + p\n  \u2264\u27e8\u27e9\n    suc (n + p)\n  \u2264\u27e8 s\u2264s (+-mono\u02b3-\u2264` p\u2264q) \u27e9\n    suc (n + q)\n  \u2264\u27e8\u27e9\n    suc n + q\n  \u220e\u2264\n\npred\u2261 : \u2200 {m n : \u2115} \u2192 suc m \u2261 suc n \u2192 m \u2261 n\npred\u2261 = cong pred\n\n\u2261to\u2264 : \u2200 {m n : \u2115} \u2192 m \u2261 n \u2192 m \u2264 n\n\u2261to\u2264 {zero}  {zero}  _     = refl-\u2264\n\u2261to\u2264 {suc m} {suc n} sm\u2261sn = s\u2264s (\u2261to\u2264 (cong pred sm\u2261sn))\n\n+-mono\u02e1-\u2264` : \u2200 {m n p : \u2115} \u2192 m \u2264 n \u2192 (m + p) \u2264 (n + p)\n+-mono\u02e1-\u2264` {m} {n} {p} m\u2264n =\n  begin\u2264\n    m + p\n  \u2264\u27e8 \u2261to\u2264 (comm-+ m p) \u27e9\n    p + m\n  \u2264\u27e8 +-mono\u02b3-\u2264` {p} {m} {n} m\u2264n \u27e9\n    p + n\n  \u2264\u27e8 \u2261to\u2264 (comm-+ p n) \u27e9\n    n + p\n  \u220e\u2264\n\n+-mono-\u2264` : \u2200 {m n p q : \u2115} \u2192 m \u2264 n \u2192 p \u2264 q \u2192 (m + p) \u2264 (n + q)\n+-mono-\u2264` {m} {n} {p} {q} m\u2264n p\u2264q =\n  begin\u2264\n    m + p\n  \u2264\u27e8 +-mono\u02e1-\u2264` m\u2264n \u27e9\n    n + p\n  \u2264\u27e8 +-mono\u02b3-\u2264` p\u2264q \u27e9\n    n + q\n  \u220e\u2264\n\n--even-comm\u2032 : \u2200 (m n : \u2115)\n--  \u2192 even (m + n)\n--    ------------\n--  \u2192 even (n + m)\n--even-comm\u2032 m n ev with   m + n  | comm-+ m n\n--...                  | .(n + m) | refl       = ev\n\n--------------------------------------- Isomorphism ---------------------------------------\n\npostulate\n  extensionality : \u2200 {A B : Set} {f g : A \u2192 B}\n    \u2192 (\u2200 (x : A) \u2192 f x \u2261 g x)\n      -----------------------\n    \u2192 f \u2261 g\n\n_+\u2032_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm +\u2032 zero  = m\nm +\u2032 suc n = suc (m +\u2032 n)\n\nsame-app : \u2200 (m n : \u2115) \u2192 m +\u2032 n \u2261 m + n\nsame-app m n rewrite comm-+ m n = helper m n\n  where\n    helper : \u2200 (m n : \u2115) \u2192 m +\u2032 n \u2261 n + m\n    helper _ zero    = refl\n    helper m (suc n) = cong suc (helper m n)\n\nsame-+-+\u2032 : _+\u2032_ \u2261 _+_\nsame-+-+\u2032 = extensionality (\u03bb m \u2192 extensionality (\u03bb n \u2192 same-app m n))\n\n--open import Level using (Level; _\u2294_) renaming (zero to lzero; suc to lsuc)\n--\n--private\n--  variable\n--    \u2113 \u2113\u2081 : Level\n\n--infix 0 _\u2243_\n--record _\u2243_ (A : Set \u2113) (B : Set \u2113\u2081) : Set (\u2113 \u2294 \u2113\u2081) where\nrecord _\u2243_ (A B : Set) : Set where\n  field\n    to   : A \u2192 B\n    from : B \u2192 A\n    from\u2218to : \u2200 (x : A) \u2192 from (to x) \u2261 x\n    to\u2218from : \u2200 (y : B) \u2192 to (from y) \u2261 y\nopen _\u2243_\n\n\u2243-refl : \u2200 {A : Set} \u2192 A \u2243 A\n\u2243-refl =\n  record\n    { to      = \u03bb x \u2192 x\n    ; from    = \u03bb y \u2192 y\n    ; from\u2218to = \u03bb x \u2192 refl\n    ; to\u2218from = \u03bb y \u2192 refl\n    }\n\n\u2243-sym : \u2200 {A B : Set} \u2192 A \u2243 B \u2192 B \u2243 A\n\u2243-sym A\u2243B =\n  record\n    { to      = from A\u2243B\n    ; from    = to A\u2243B\n    ; from\u2218to = to\u2218from A\u2243B\n    ; to\u2218from = from\u2218to A\u2243B\n    }\n\nopen import Function.Base using (_\u2218_)\n\n\u2243-trans : \u2200 {A B C : Set} \u2192 A \u2243 B \u2192 B \u2243 C \u2192 A \u2243 C\n\u2243-trans A\u2243B B\u2243C =\n  record\n    { to      = to B\u2243C \u2218 to A\u2243B\n    ; from    = from A\u2243B \u2218 from B\u2243C\n    ; from\u2218to = \u03bb{x \u2192\n        begin\n          from A\u2243B (from B\u2243C (to B\u2243C (to A\u2243B x)))\n        \u2261\u27e8 cong (from A\u2243B) (from\u2218to B\u2243C (to A\u2243B x)) \u27e9\n          from A\u2243B (to A\u2243B x)\n        \u2261\u27e8 from\u2218to A\u2243B x \u27e9\n          x\n        \u220e\n      }\n    ; to\u2218from = \u03bb{y \u2192\n        begin\n          to B\u2243C (to A\u2243B (from A\u2243B (from B\u2243C y)))\n        \u2261\u27e8 cong (to B\u2243C) (to\u2218from A\u2243B (from B\u2243C y)) \u27e9\n          to B\u2243C (from B\u2243C y)\n        \u2261\u27e8 to\u2218from B\u2243C y \u27e9\n          y\n        \u220e\n      }\n    }\n\ninfix 0 _\u2272_\nrecord _\u2272_ (A B : Set) : Set where\n  field\n    to      : A \u2192 B\n    from    : B \u2192 A\n    from\u2218to : \u2200 (x : A) \u2192 from (to x) \u2261 x\nopen _\u2272_\n\n\u2243-implies-\u2272 : \u2200 {A B : Set} \u2192 A \u2243 B \u2192 A \u2272 B\n\u2243-implies-\u2272 A\u2243B =\n  record\n  { to   = to A\u2243B\n  ; from = from A\u2243B\n  ; from\u2218to = from\u2218to A\u2243B\n  }\n\n-- Idea: Prove that (\u2115) is isomorph to (Can)\n-- Idea: Prove that (+, \u2115) is isomorph to (+\u1d47, Can)\n--record _\u21d4_ (A B : Set) : Set where\n--  field\n--    to   : A \u2192 B\n--    from : B \u2192 A\n\n-- Exercise: implement reflexive, symetric and transitive properties on _\u21d4_\n\n\u2115\u2272Bin : \u2115 \u2272 Bin\n\u2115\u2272Bin =\n  record\n  { to   = to\u1d47\n  ; from = from\u1d47\n  ; from\u2218to = from\u2218to\u1d47\n  }\n\ndata Dec-Can : Set where\n  num : \u2200 (b : Bin) \u2192 Can b \u2192 Dec-Can\n\nto\u1d48\u1d9c : \u2115 \u2192 Dec-Can\nto\u1d48\u1d9c n = num (to\u1d47 n) (to-Can n)\n--to\u1d48\u1d9c n = num (to-Can n)\n\nfrom\u1d48\u1d9c : Dec-Can \u2192 \u2115\nfrom\u1d48\u1d9c (num b _) = from\u1d47 b\n\n--from\u2218to\u1d48\u1d9c (suc n) = ?\n-- \u03bb n \u2192 from\u1d48\u1d9c (to\u1d48\u1d9c (suc n)) \u2261 suc n\n-- \u03bb cb \u2192 to\u1d48\u1d9c (from\u1d48\u1d9c (num cb)) \u2261 num cb\n-- \u03bb b ob \u2192 to\u1d48\u1d9c (from\u1d48\u1d9c (num (b O) (one-C (oneO-O ob))))\n\n--to\u2218from\u1d48\u1d9c : \u2200 (y : Dec-Can) \u2192 to\u1d48\u1d9c (from\u1d48\u1d9c y) \u2261 y\n--to\u2218from\u1d48\u1d9c (num (\u27e8\u27e9 O) zero-C)       = refl\n--to\u2218from\u1d48\u1d9c (num (\u27e8\u27e9 I) (one-C oneO)) = refl\n--to\u2218from\u1d48\u1d9c (num (b O) (one-C (oneO-O {b} ob))) rewrite monobin (from\u1d47 b) = ?\n---- \u03bb b ob \u2192 to\u1d48\u1d9c (from\u1d48\u1d9c (num (b O) (one-C (oneO-O ob))))\n---- \u03bb b ob \u2192 \u03bb b ob \u2192 num (to\u1d47 (from\u1d47 b + from\u1d47 b)) (to-Can (from\u1d47 b + from\u1d47 b))\n--to\u2218from\u1d48\u1d9c = ?\n----to\u2218from\u1d48\u1d9c (num b cb) =\n----  begin\n----    to\u1d48\u1d9c (from\u1d48\u1d9c (num b cb))\n----  \u2261\u27e8\u27e9\n----    to\u1d48\u1d9c (from\u1d47 b)\n----  \u2261\u27e8\u27e9\n----    num (to\u1d47 (from\u1d47 b)) (to-Can (from\u1d47 b))\n----  \u2261\u27e8 ? \u27e9\n----    num b cb\n----  \u220e\n\n--\u2115\u2243Can : \u2115 \u2243 Dec-Can\n--\u2115\u2243Can =\n--  record\n--  { to      = to\u1d48\u1d9c\n--  ; from    = from\u1d48\u1d9c\n--  ; from\u2218to = from\u2218to\u1d47\n--  ; to\u2218from = ? -- to\u2218from\u1d48\u1d9c -- to\u2218from-Can\n--  }\n\n--num (zero-C)\n\n--------------------------------------- Decidable ---------------------------------------\n-- Use `Dec` to create elements for `Can`. Look if this is enough to prove `\u2115 \u2243 Can`\n-- Ans: NO. Decidables don't do what you thought they do\n\n--------------------------------------- Last ---------------------------------------\n-- Prove that `sqrt 2` is irrational\n\n-- Stuff to take into account and add to agda neovim:\n-- IOTCM \"plfa/part1/Naturals.agda\" None Direct (Cmd_load \"plfa/part1/Naturals.agda\" [])\n-- IOTCM \"plfa/part1/Naturals.agda\" None Direct (Cmd_compute_toplevel DefaultCompute \"2 + suc 3\") # Already done by plugin\n-- IOTCM \"plfa/part1/Naturals.agda\" None Direct (Cmd_infer_toplevel AsIs \"2 + suc 3\")  # THIS SHOULD BE PART OF THE STUFF IN MAGDA\n--\n-- Other stuff:\n-- IOTCM \"plfa/part1/Naturals.agda\" None Direct (Cmd_show_module_contents_toplevel AsIs \"Eq\")\n-- IOTCM \"plfa/part1/Naturals.agda\" None Direct (Cmd_why_in_scope_toplevel \"Eq\")\n-- IOTCM \"plfa/part1/Naturals.agda\" None Direct (Cmd_why_in_scope (InteractionId 1) (Range (Just \"plfa/part1/Naturals.agda\") (Interval (Pn () 1 76 1) (Pn () 1 76 19))) \"Eq\")\n---- IOTCM \"plfa/part1/Naturals.agda\" None Direct (Cmd_autoOne (InteractionId 1) noRange \"\")\n---- IOTCM \"plfa/part1/Naturals.agda\" NonInteractive Indirect (Cmd_infer Simplified 103992 (intervalsToRange (Just (mkAbsolute \"plfa/part1/Naturals.agda\")) [Interval (Pn () 50 75 1) (Pn () 52 79 1)]) \"3 + suc 2\")\n", "meta": {"hexsha": "f0cc33c8df8e4996f9c39df5a70268b8fd86a957", "size": 32345, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/Practice.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5388127854, "max_line_length": 212, "alphanum_fraction": 0.4476735199, "num_tokens": 15718, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797172476384, "lm_q2_score": 0.8558511451289037, "lm_q1q2_score": 0.7798342044246219}}
{"text": "\nmodule PartialOrder where\n\nopen import Prelude\n\nrecord PartialOrder (A : Set) : Set1 where\n  field\n    _==_    : A -> A -> Set\n    _\u2264_     : A -> A -> Set\n    ==-def  : forall {x y} -> (x == y) \u21d0\u21d2 (x \u2264 y) \u2227 (y \u2264 x)\n    \u2264-refl  : forall {x} -> x \u2264 x\n    \u2264-trans : forall {x y z} -> x \u2264 y -> y \u2264 z -> x \u2264 z\n\nmodule POrder {A : Set}(ord : PartialOrder A) where\n\n  private module POrd = PartialOrder ord\n  open POrd public\n\n  infix 60 _\u2264_ _==_\n\n  Monotone : (A -> A) -> Set\n  Monotone f = forall {x y} -> x \u2264 y -> f x \u2264 f y\n  \n  Antitone : (A -> A) -> Set\n  Antitone f = forall {x y} -> x \u2264 y -> f y \u2264 f x\n\n  \u2264-antisym : forall {x y} -> x \u2264 y -> y \u2264 x -> x == y\n  \u2264-antisym p q = snd ==-def (p , q)\n\n  ==\u2264-L : forall {x y} -> x == y -> x \u2264 y\n  ==\u2264-L x=y = fst (fst ==-def x=y)\n\n  ==\u2264-R : forall {x y} -> x == y -> y \u2264 x\n  ==\u2264-R x=y = snd (fst ==-def x=y)\n\n  ==-refl : forall {x} -> x == x\n  ==-refl = \u2264-antisym \u2264-refl \u2264-refl\n\n  ==-sym : forall {x y} -> x == y -> y == x\n  ==-sym xy = snd ==-def (swap (fst ==-def xy))\n\n  ==-trans : forall {x y z} -> x == y -> y == z -> x == z\n  ==-trans xy yz = \u2264-antisym\n                           (\u2264-trans x\u2264y y\u2264z)\n                           (\u2264-trans z\u2264y y\u2264x)\n    where\n      x\u2264y = ==\u2264-L xy\n      y\u2264z = ==\u2264-L yz\n      y\u2264x = ==\u2264-R xy\n      z\u2264y = ==\u2264-R yz\n\n  Dual : PartialOrder A\n  Dual = record\n    { _==_    = _==_\n    ; _\u2264_     = \\x y -> y \u2264 x\n    ; ==-def  = (swap \u2218 fst ==-def , snd ==-def \u2218 swap)\n    ; \u2264-refl  = \u2264-refl\n    ; \u2264-trans = \\yx zy -> \u2264-trans zy yx\n    }\n", "meta": {"hexsha": "50f3c8c37e924e2c4b0e373478c3d99e84a1a60d", "size": 1504, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/lattice/PartialOrder.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/lattice/PartialOrder.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/lattice/PartialOrder.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.0666666667, "max_line_length": 59, "alphanum_fraction": 0.4208776596, "num_tokens": 646, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012701768144, "lm_q2_score": 0.824461919906883, "lm_q1q2_score": 0.779777131060345}}
{"text": "\nmodule Lib.Vec where\n\nopen import Lib.Prelude\nopen import Lib.Nat\nopen import Lib.Fin\n\ninfixr 40 _::_ _++_\n\ndata Vec (A : Set) : Nat -> Set where\n  []   : Vec A 0\n  _::_ : forall {n} -> A -> Vec A n -> Vec A (suc n)\n\n_++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n[]        ++ ys = ys\n(x :: xs) ++ ys = x :: xs ++ ys\n\n_!_ : forall {A n} -> Vec A n -> Fin n -> A\n[]      ! ()\nx :: xs ! zero  = x\nx :: xs ! suc i = xs ! i\n\ntabulate : forall {A n} -> (Fin n -> A) -> Vec A n\ntabulate {n = zero}  f = []\ntabulate {n = suc n} f = f zero :: tabulate (f \u2218 suc)\n\nvec : forall {A n} -> A -> Vec A n\nvec x = tabulate (\\_ -> x)\n\ninfixl 30 _<*>_\n\n_<*>_ : forall {A B n} -> Vec (A -> B) n -> Vec A n -> Vec B n\n[]      <*> []      = []\nf :: fs <*> x :: xs = f x :: (fs <*> xs)\n\nmap : forall {A B n} -> (A -> B) -> Vec A n -> Vec B n\nmap f xs = vec f <*> xs\n\nzip : forall {A B C n} -> (A -> B -> C) -> Vec A n -> Vec B n -> Vec C n\nzip f xs ys = vec f <*> xs <*> ys\n", "meta": {"hexsha": "6394315f305aacf874d571d51830f603f1209c13", "size": 973, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/simple-lib/Lib/Vec.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/simple-lib/Lib/Vec.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/simple-lib/Lib/Vec.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 23.7317073171, "max_line_length": 72, "alphanum_fraction": 0.4563206578, "num_tokens": 381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9481545362802364, "lm_q2_score": 0.8221891305219504, "lm_q1q2_score": 0.7795623537846906}}
{"text": "module Issue246 where\n\nmodule James where\n\n  data Nat : Set where\n    zero  : Nat\n    suc   : Nat -> Nat\n\n  data Zero : Set where\n\n  data One : Set where\n    void : One\n\n  propLEQ : Nat -> Nat -> Set\n  propLEQ zero    _       = One\n  propLEQ (suc n) (suc m) = propLEQ n m\n  propLEQ (suc n) zero    = Zero\n\n  data Fin : Nat -> Set where\n    fzero : {n : Nat} -> Fin (suc n)\n    fsuc  : {n : Nat} -> Fin n -> Fin (suc n)\n\n  toFin : {n : Nat} -> (i : Nat) -> (propLEQ (suc i) n) -> Fin n\n  toFin {zero}  zero      ()\n  toFin {zero}  (suc _)   ()\n  toFin {suc n} zero    k  = fzero\n  toFin {suc n} (suc i) k  = fsuc (toFin i k)\n\n  one : Nat\n  one = suc zero\n\n  two : Nat\n  two = suc one\n\n  three : Nat\n  three = suc two\n\n  null : Fin three\n  null = toFin zero void\n\nmodule Conor where\n\n  data Nat : Set where\n   ze : Nat\n   su : Nat -> Nat\n\n  data Bool : Set where\n   tt ff : Bool\n\n  record One : Set where\n  data Zero : Set where\n\n  So : Bool -> Set\n  So tt = One\n  So ff = Zero\n\n  _<_ : Nat -> Nat -> Bool\n  _ < ze = ff\n  ze < su n = tt\n  su m < su n = m < n\n\n  data Lt (m n : Nat) : Set where\n   lt : So (m < n) -> Lt m n\n\n  boo : {m n : Nat} -> So (m < n) -> Lt (su m) (su n)\n  boo p = lt p\n\nmodule Alan where\n\n  data \u2115 : Set where\n    zero : \u2115\n    suc  : \u2115 \u2192 \u2115\n\n  {-# BUILTIN NATURAL \u2115 #-}\n  {-# BUILTIN ZERO zero #-}\n  {-# BUILTIN SUC suc #-}\n\n  data Bool : Set where\n    true false : Bool\n\n  infixr 5 _\u2237_\n\n  _lt_ : \u2115 \u2192 \u2115 \u2192 Bool\n  _     lt zero  = false\n  zero  lt suc _ = true\n  suc x lt suc y = x lt y\n\n  data List<? (X : \u2115 \u2192 Set) (n : \u2115) : Bool \u2192 Set where\n    [] : List<? X n true\n    _\u2237_ : {m : \u2115} \u2192 (x : X m) \u2192 (List<? X m true) \u2192 (List<? X n (m lt n))\n\n  List< : (\u2115 \u2192 Set) \u2192 \u2115 \u2192 Set\n  List< X n = List<? X n true\n\n  data A : \u2115 \u2192 Set where\n    a1 : A 1\n    a2 : A 2\n\n  as : List< A 3\n  as = a2 \u2237 a1 \u2237 ([] {A})\n\n  as' : List< A 3\n  as' = a2 \u2237 a1 \u2237 []\n", "meta": {"hexsha": "a2b82f4e36a1bf31cbedcd99b1527e6a31a69ba6", "size": 1858, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Issue246.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/Issue246.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Issue246.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.8653846154, "max_line_length": 73, "alphanum_fraction": 0.5026910657, "num_tokens": 736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361557147439, "lm_q2_score": 0.8539127566694178, "lm_q1q2_score": 0.7791408730112231}}
{"text": "module test where\n\ndata Bool : Set where\n    True  : Bool\n    False : Bool\n\n!_ : Bool \u2192 Bool\n! True  = False\n! False = True\n\nif_then_else_ : {A : Set} \u2192 Bool \u2192 A \u2192 A \u2192 A\nif True then x else y = x\nif False then x else y = y\n\ndata \u2115 : Set where\n    zero : \u2115\n    suc  : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + a = a\nsuc a + b = suc (a + b)\n\nlow = suc zero\nhigh = low + (low + low)\n\ndata List (A : Set) : Set where\n    Nil  : List A\n    Cons : A \u2192 List A \u2192 List A\n\nlength : {A : Set} \u2192 List A \u2192 \u2115\nlength Nil = zero\nlength (Cons x x\u2081) = suc (length x\u2081)\n\nmap : {A B : Set} \u2192 (A \u2192 B) \u2192 List A \u2192 List B\nmap f Nil = Nil\nmap f (Cons x l) = Cons (f x) (map f l)\n\nconcat : {A : Set} \u2192 List A \u2192 List A \u2192 List A\nconcat Nil m = m\nconcat (Cons x l) m = Cons x (concat l m)\n", "meta": {"hexsha": "b1932deb831155f26baf2ec422ef04a347d63e23", "size": 747, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test.agda", "max_stars_repo_name": "foxx3r/agda_tasks", "max_stars_repo_head_hexsha": "2867aee2c18b4e1d4e8f4dc8e8453006fde4d349", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-24T02:30:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-24T02:30:55.000Z", "max_issues_repo_path": "test.agda", "max_issues_repo_name": "foxx3r/agda_tasks", "max_issues_repo_head_hexsha": "2867aee2c18b4e1d4e8f4dc8e8453006fde4d349", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test.agda", "max_forks_repo_name": "foxx3r/agda_tasks", "max_forks_repo_head_hexsha": "2867aee2c18b4e1d4e8f4dc8e8453006fde4d349", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.2195121951, "max_line_length": 45, "alphanum_fraction": 0.5488621151, "num_tokens": 280, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.960951711746926, "lm_q2_score": 0.810478913248044, "lm_q1q2_score": 0.7788310990204962}}
{"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Addition\nopen import Numbers.Naturals.Multiplication\nopen import Numbers.Naturals.Order\n\nmodule Numbers.Naturals.Exponentiation where\n\n_^N_ : \u2115 \u2192 \u2115 \u2192 \u2115\na ^N zero = 1\na ^N succ b = a *N (a ^N b)\n\nexponentiationIncreases : (a b : \u2115) \u2192 (a \u2261 0) || (a \u2264N a ^N (succ b))\nexponentiationIncreases zero b = inl refl\nexponentiationIncreases (succ a) zero = inr (inr (applyEquality succ (transitivity (additionNIsCommutative 0 a) (multiplicationNIsCommutative 1 a))))\nexponentiationIncreases (succ a) (succ b) with exponentiationIncreases (succ a) b\nexponentiationIncreases (succ a) (succ b) | inr (inl x) = inr (inl (canAddToOneSideOfInequality _ x))\nexponentiationIncreases (succ a) (succ b) | inr (inr x) with productOne x\nexponentiationIncreases (succ 0) (succ b) | inr (inr x) | inr pr rewrite pr = inr (inr refl)\nexponentiationIncreases (succ (succ a)) (succ b) | inr (inr x) | inr pr rewrite pr | productWithOneRight a = inr (inl (le (succ (a +N a *N succ (succ a))) (additionNIsCommutative _ (succ (succ a)))))\n", "meta": {"hexsha": "66f40430ad7d81ea2b9655caf66d6376a8e8e333", "size": 1157, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Naturals/Exponentiation.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Naturals/Exponentiation.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Naturals/Exponentiation.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 50.3043478261, "max_line_length": 199, "alphanum_fraction": 0.7312013829, "num_tokens": 375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9553191348157373, "lm_q2_score": 0.8152324983301567, "lm_q1q2_score": 0.7788072049784373}}
{"text": "module z where\n\n-- http://www.cse.chalmers.se/~ulfn/papers/afp08/tutorial.pdf\n{-\nDependently Typed Programming in Agda\nUlf Norell1   : Chalmers University, Gothenburg   : ulfn@chalmers.se\nJames Chapman : Institute of Cybernetics, Tallinn : james@cs.ioc.ee\n\n------------------------------------------------------------------------------\n1 Introduction\n\nIn Hindley-Milner languages (Haskell, ML) : separation between types and values.\n\nDependently typed : types can contain (depend on) arbitrary values and\n                    appear as arguments and results of ordinary functions\n\nDependent types enables types to talk about values,\nso can encode properties of values as types\nwhose elements are proofs that the property is true.\n\nSo dependently typed programming language can be used as a logic.\n\nTo be consistent programs must be total.\n\n------------------------------------------------------------------------------\n2 BASICS\n\nbased on intuitionistic type theory[4]\n\n--------------------------------------------------\n2.1 DATATYPES AND PATTERN MATCHING\n-}\n\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n\n{-\ntype of Bool is\n- Set, the type of small types\n- There is hierarchy of increasingly large types\n- type of Set is Set1, whose type is Set2, ...\n-}\n\nnot : Bool \u2192 Bool\nnot true  = false\nnot false = true\n\ndata Nat : Set where\n zero :       Nat\n suc  : Nat \u2192 Nat\n{-# BUILTIN NATURAL Nat #-}\n\n_+_ : Nat \u2192 Nat \u2192 Nat\nzero  + m =          m\nsuc n + m = suc (n + m)\ninfixl 40 _+_\n\n_*_ : Nat \u2192 Nat \u2192 Nat\nzero  * m = zero\nsuc n * m = m + n * m\ninfixl 60 _*_\n\n{-\nfunctions must not crash and must terminate\n\nrecursive calls have to be made on structurally smaller arguments\n\nmixfix via  _ : args where the underscores are\n-}\n\n_or_ : Bool \u2192 Bool \u2192 Bool\nfalse or x = x\ntrue  or _ = true -- uses wildcard pattern on \"don't care\" args\ninfixr 20 _or_\n\n-- polymorphic function over type A\nif_then_else_ : {A : Set} \u2192 Bool \u2192 A \u2192 A \u2192 A\nif  true then x else y = x\nif false then x else y = y\ninfix 5 if_then_else_\n\n-- types parameterize by other types\ndata List (A : Set) : Set where\n  []   :                List A\n  _::_ : A \u2192 List A \u2192 List A\ninfixr 40 _::_\n\n-- liberal naming policy enables naming above\ndata _\u22c6 (\u03b1 : Set) : Set where\n  \u03b5 : \u03b1 \u22c6\n  _C_ : \u03b1 \u2192 \u03b1 \u22c6 \u2192 \u03b1 \u22c6\n\n{-\nwhitespace important\n\n--------------------------------------------------\n2.2 DEPENDENT FUNCTIONS\n\nresult type depends on VALUE of an arg\n  (x : A) \u2192 B for the\ntype of functions\n- given   : arg x of type A\n- returns : result of type B\n  - where x may appear in B\n\nspecial case is when x itself is a type, e.g.,\n-}\n\nidentity : (A : Set) \u2192 A \u2192 A\nidentity A x = x\n\nzero\u2019 : Nat\nzero\u2019 = identity Nat zero\n\n{-\nidentity is a dependent function\n- given\n  - a type argument A and\n  - an element of A\n- returns\n  - the element\n\nThis is how polymorphic functions are encoded in Agda.\n\nexample : function which takes a dependent function and applies it to an argument:\n-}\n\napply : (A : Set) (B : A \u2192 Set) \u2192 ((x : A) \u2192 B x) \u2192 (a : A) \u2192 B a\napply A B f a = f a\n\n{-\nshorthand for dependent function types:\n\n        (x : A)   (y : B) \u2192 C\nfor     (x : A) \u2192 (y : B) \u2192 C\n\n        (x y : A)       \u2192 B\nfor     (x : A) (y : A) \u2192 B\n\n\nelements of dependent function types are lambda terms which may carry explicit type info\n\nalternative ways to identity\nidentity function above are:\n-}\n\nidentity2 : (A : Set) \u2192 A \u2192 A\nidentity2 = \\A x \u2192 x\n\nidentity3 : (A : Set) \u2192 A \u2192 A\nidentity3 = \\(A : Set) (x : A) \u2192 x\n\nidentity4 : (A : Set) \u2192 A \u2192 A\nidentity4 = \\(A : Set) x \u2192 x\n\n{-\n--------------------------------------------------\n2.3 IMPLICIT ARGUMENTS\n\nPrevious section showed how dependent functions taking types as\narguments used to model polymorphic types.\n\nBut it is not necessary to say at which point it is applied - that can be inferred.\n\nThe identity functions above explicitly provide the type argument.\n\nAvoid explicit type arg via implicit arguments using {}\n-}\n\nid : {A : Set} \u2192 A \u2192 A\nid x = x\n\ntrue\u2019 : Bool\ntrue\u2019 = id true\n\n{-\nNo restrictions on what arguments can be made implicit.\nNot guarantees that an implicit argument can be inferred.\n\nE.g., make 2nd arg of identity function implicit as well:\n-}\n\nsilly : {A : Set} {x : A} \u2192 A -- but type checker cannot figure out 2nd arg\nsilly {_} {x} = x\n\nfalse\u2019 : Bool\nfalse\u2019 = silly {x = false} -- must provide via named implicit application syntax f {v}\n                           -- must use name if not in order\n-- type checker fills in term\n-- will not search, only looks at typing constraints and performs unification\none : Nat\none = identity _ (suc zero)\n\n-- example of inferring the typing constraints\n_\u25e6_ : {A : Set}{B : A \u2192 Set}{C : (x : A) \u2192 B x \u2192 Set}\n      (f : {x : A}(y : B x) \u2192 C x y)(g : (x : A) \u2192 B x)\n      (x : A) \u2192 C x (g x)\n(f \u25e6 g) x = f (g x)\n\nplus-two = suc \u25e6 suc\n\n-- other functions\n\nmap : {A B : Set} \u2192 (A \u2192 B) \u2192 List A \u2192 List B\nmap f       []  = []\nmap f (x :: xs) = f x :: map f xs\n\n_++_ : {A : Set} \u2192 List A \u2192 List A \u2192 List A\n[]        ++ ys =             ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\n{-\n--------------------------------------------------\n-- 2.4 DATATYPE FAMILIES\n\nSo far, only used dependent types is to represent polymorphism\n-}\n\ndata Vec (A : Set) : Nat \u2192 Set where\n  []   :                           Vec A  zero\n  _::_ : {n : Nat} \u2192 A \u2192 Vec A n \u2192 Vec A (suc n)\n\n{-\ntype of Vec A is Nat \u2192 Set\n- means that Vec A is a family of types indexed by natural numbers\n- for each Nat n, Vec A n is a type\n- []   constructs an element in Vec A zero\n- _::_ constructs an element in Vec A (suc n) for some n\n\ndistinction between parameters and indices of a datatype\n- parameterised by type A\n- indexed over Nat\n\ntype of _::_ is a dependent function type\n- 1st arg is an implicit Nat n\n- returns type that depends on n 'suc n'\n\nsame constructor names for Vec as for List\n-  constructor names are not required to be distinct between different datatypes\n-}\n\n-- safe head\nhead : {A : Set} {n : Nat} \u2192 Vec A (suc n) \u2192     A\nhead (x :: xs) = x\n\ntail : {A : Set} {n : Nat} \u2192 Vec A (suc n) \u2192 Vec A n\ntail (x :: xs) = xs\n\n{-\nrule for when to include a particular case is:\n  if it is type correct you have to include it\n-}\n\n--------------------------------------------------\n-- DOT PATTERNS : indicate value of an arg deduced by type checking, not pattern matching\n\nvmap : {A B : Set} {n : Nat} \u2192 (A \u2192 B) \u2192 Vec A n \u2192 Vec B n\nvmap f       []  = []\nvmap f (x :: xs) = f x :: vmap f xs\n\n{-\nmap on Vec is exactly the same map on List\nonly change is the type\n\nbehind the scenes, what happens with the length argument when pattern matching\n\nto see, define new versions of Vec and vmap with fewer implicit arguments:\n-}\n\ndata Vec2 (A : Set) : Nat \u2192 Set where\n  nil  :                            Vec2 A  zero\n  cons : (n : Nat) \u2192 A \u2192 Vec2 A n \u2192 Vec2 A (suc n)\n\nvmap2 : {A B : Set} (n : Nat) \u2192 (A \u2192 B) \u2192 Vec2 A n \u2192 Vec2 B n\nvmap2 .zero    f  nil          = nil\nvmap2 .(suc n) f (cons n x xs) = cons n (f x) (vmap2 n f xs)\n\n{-\npattern matching on list argument reveals its length\n- if nil  then zero\n- if cons then suc n\n\nto indicate value of an arg deduced by type checking,\nrather than observed by pattern matching,\nit is prefixed by a dot (.)\n\ncould choose to define vmap by first pattern matching on the length rather than on the list\n-}\n\nvmap3 : {A B : Set} (n : Nat) \u2192 (A \u2192 B) \u2192 Vec2 A n \u2192 Vec2 B n\nvmap3  zero   f  nil           = nil\nvmap3 (suc n) f (cons .n x xs) = cons n (f x) (vmap3 n f xs)\n\n{-\nrule for when arg should be dotted:\n- if there is a unique type correct value for the argument it should be dotted\n\nabove, the terms under the dots were valid patterns\n- in general they can be arbitrary terms\ne.g.,\n-}\n\ndata Image_el_ {A B : Set}(f : A \u2192 B) : B \u2192 Set where\n  im : (x : A) \u2192 Image f el f x\n\n{-\nonly way to construct an element in the image of f\nis to pick an argument x and apply f to x\n\nknowing  that a particular y is in the image of f enables computing the inverse of f on y:\n-}\n\ninv : {A B : Set} (f : A \u2192 B) (y : B) \u2192 Image f el y \u2192 A\ninv f .(f x) (im x) = x\n\n{-\n--------------------------------------------------\nABSURD PATTERNS\n-}\n\n-- family of numbers smaller than a given natural number\ndata Fin : Nat \u2192 Set where\n  fzero : {n : Nat} \u2192         Fin (suc n) -- smaller than suc n for any n\n  fsuc  : {n : Nat} \u2192 Fin n \u2192 Fin (suc n) -- if i smaller than n then fsuc i is smaller than suc n\n\n-- Now way to construct a Fin smaller than zero.\n-- When no possible constructor patterns for a given argument\n-- then pattern match with absurd pattern ()\n\nmagic : {A : Set} \u2192 Fin zero \u2192 A\nmagic ()\n\n{-\nUsing absurd pattern means no need to give a right hand side,\nsince no way anyting could given as an arg that would match.\n\nSeems the clause not needed, that checker could tell.\nBut a case can only be omitted if no type correct way of writing it.\n\n'magic a' has a type correct left hand side\n\nabsurd pattern can only be used if there are no valid constructor patterns for the arg.\nIt is not enough that there are no closed inhabitants of the type.\nE.g.,\n-}\n\ndata Empty : Set where\n  empty : Fin zero \u2192 Empty\n\n{-\nArgs of type Empty cannot be matched with absurd pattern,\nsince there is a valid constructor pattern: 'empty x'\nSo must write:\n-}\n\nmagic\u2019 : {A : Set} \u2192 Empty \u2192 A\nmagic\u2019 (empty ()) -- magic\u2019 () -- not accepted\n\n-- Extract ith element of the list (starting from 0):\n-- Turns a list into a function from indices to elements.\n_!_ : {n : Nat} {A : Set} \u2192 Vec A n \u2192 Fin n \u2192 A\n[]        ! ()\n(x :: xs) !  fzero   = x\n(x :: xs) ! (fsuc i) = xs ! i\n\n{-\ntypes ensure no danger of indexing outside the list\n\nreflected in use of absurd in empty case : no possible values for the index\n-}\n\n-- constructing a list given a function from indices to elements\ntabulate : {n : Nat} {A : Set} \u2192 (Fin n \u2192 A) \u2192 Vec A n\ntabulate  {zero} f = []\ntabulate {suc n} f = f fzero :: tabulate (f \u25e6 fsuc) -- recursive call implicitly gets 'n'\n\n{-\ntabulate is defined by recursion over the length of the result list,\neven though it is an implicit argument.\n\nIn general, no correspondance between implicit data and computationally irrelevant data.\n\n------------------------------------------------------------------------------\n-- 2.5 PROGRAMS AS PROOFS\n\nType system can represent propositions as types whose elements are proofs of the proposition.\n-}\n\ndata   False : Set where -- datatype with no constructors\nrecord True  : Set where -- record type with no fields\n                         -- has a single element : the empty record\n\n{-\nCould have defined True as datatype with a single element.\nBut using record def lets checker know there is a unique element of True\nand will fill in any implicit arguments of type True with this element.\n\nexploited in trivial:\n-}\n\ntrivial : True\ntrivial = _\n\ntrivial' : True\ntrivial' = record {}\n\n{-\nwhere right hand is underscore,\ninstead of explicitly writing 'record {}'\n\nThe 'False' and 'True' propositions enable working with decidable propositions.\nCan model decidable propositions as booleans and define\n-}\n\n-- takes a VALUE of type Bool\n-- returns a Set (i.e., a TYPE)\nisTrue : Bool \u2192 Set\nisTrue true  = True\nisTrue false = False\n\nisFalse : Bool \u2192 Set\nisFalse x = isTrue (not x)\n\n{-\nisTrue b is the type of proofs that b equals true.\n\nThis technique enables defining safe list lookup function in a different way,\nworking on simply typed lists and numbers.\n-}\n\n-- takes   Nat  VALUES\n-- returns Bool VALUES\n_<_ : Nat \u2192 Nat \u2192 Bool\n_     < zero  = false\nzero  < suc n = true\nsuc m < suc n = m < n\n\nlength : {A : Set} \u2192 List A \u2192 Nat\nlength        [] = zero\nlength (x :: xs) = suc (length xs)\n\n--                                             |\n--                                             v\nlookup : {A : Set} (xs : List A) (n : Nat) \u2192 isTrue (n < length xs) \u2192 A\nlookup       []       n ()\nlookup (x :: xs)  zero   p = x\nlookup (x :: xs) (suc n) p = lookup xs n p\n\n{-\nRather than there being no index into the empty list,\nthere is no proof that a number n is smaller than zero.\n\nIn this example, using indexed types to capture the precondition,\nas done in '_!_' above, is a little bit nicer,\nsince do not have to pass an explicit proof object\nas done in 'lookup' above.\n\nWhen properties cannot be easily captured by indexed types, this is a useful alternative.\n\n--------------------------------------------------\nDEFINE PROPOSITIONS USING DATATYPE FAMILIES\n-}\n\n-- family of proofs of \u201cbeing equal to x\u201d\n-- specify the type by giving it two args\n-- type can only be constructed when the two args reduce to the same thing\ndata _\u2261_ {A : Set} (x : A) : A \u2192 Set where\n  refl : x \u2261 x -- only inhabited at index x where the single proof is refl\n\n-- another exampla\n-- compare to def of '_<_' above\ndata _\u2264_ : Nat \u2192 Nat \u2192 Set where\n  leq-zero :   {n : Nat} \u2192         zero  \u2264     n\n  leq-suc  : {m n : Nat} \u2192 m \u2264 n \u2192 suc m \u2264 suc n\n\n{-\nadvantage of this approach\n- PATTERN MATCH ON PROOF OBJECT\n- makes proving properties of _\u2264_ easier\n- e.g.,\n-}\n\nleq-trans : {l m n : Nat} \u2192 l \u2264 m \u2192 m \u2264 n \u2192 l \u2264 n\nleq-trans  leq-zero            _  = leq-zero\nleq-trans (leq-suc p) (leq-suc q) = leq-suc (leq-trans p q)\n\n{-\n------------------------------------------------------------------------------\n-- 2.6 WITH : PATTERN MATCH ON RESULT OF INTERMEDIATE COMPUTATION\n\nHaskell : done on right hand side using case\n\nwhen matching expression in dependently typed language, learn\n- shape of expression\n- things about other expressions\n  - e.g., matching 'Vec A n' reveals info about n\n- not captured by usual case expression\n\nto pattern match on an expression e in the def of fun f\n- abstract f over value of e\n- effectively adding another argument to f\n- can then be matched on in usual way\n-}\n\nmin : Nat \u2192 Nat \u2192 Nat\nmin x y with x < y\nmin x y | true  = x\nmin x y | false = y\n\n{-\nCan abstract over multiple expressions at same time, separated by vertical bars.\n\nCan nest with abstractions.\n\nWhen matching on arg using WITH, no need to match on args again:\n- use ...\n-}\n\nfilter : {A : Set} \u2192 (A \u2192 Bool) \u2192 List A \u2192 List A\nfilter p [] = []\nfilter p (x :: xs) with p x\n... | true  = x :: filter p xs\n... | false =      filter p xs\n\n{-\nExample of revealing info via matching.\n\nCompare numbers for equality.\nInstead of returning boolean,\nreturn proof of equality or\nexplanation of why they are not equal.\n-}\n\ndata _\u2260_ : Nat \u2192 Nat \u2192 Set where\n  z\u2260s :   {n : Nat} \u2192          zero \u2260 suc n -- different if one is zero and other suc\n  s\u2260z :   {n : Nat} \u2192         suc n \u2260 zero  -- vice versa\n  s\u2260s : {m n : Nat} \u2192 m \u2260 n \u2192 suc m \u2260 suc n -- both suc but their predecessors are different\n\ndata Equal? (n m : Nat) : Set where\n  eq  : n \u2261 m \u2192 Equal? n m\n  neq : n \u2260 m \u2192 Equal? n m\n\n-- now function that returns the explanation\n\nequal? : (n m : Nat) \u2192 Equal? n m\n--                                  Equal? zero zero\n--                                      zero \u2261 zero\nequal?  zero    zero             = eq  refl\nequal?  zero   (suc _)           = neq z\u2260s\nequal? (suc _)  zero             = neq s\u2260z\nequal? (suc n) (suc m) with equal? n m -- matching on proof reveals if predecessors are equal\nequal? (suc _) (suc _) | eq refl = eq refl\n--                                 Equal? (suc n) (suc m)\n--                                      suc n \u2260 suc m\n--                                          n \u2260     m\nequal? (suc _) (suc _) | neq p   = neq (s\u2260s p)\n\n{-\nusing WITH : expression is abstracted from entire context\n\nmeans that if expression occurs in type of arg to function or in result type,\noccurrence is replaced by the with-argument on the left hand side.\n\ne.g., prove 'filter' only removes some elements\n-}\n\n-- to make a sublist, each element can either be dropped or kept\ninfix 20 _\u2286_\ndata _\u2286_ {A : Set} : List A \u2192 List A \u2192 Set where\n  stop :                                   [] \u2286      []\n  drop : forall {xs y ys} \u2192 xs \u2286 ys \u2192      xs \u2286 y :: ys\n  keep : forall {x xs ys} \u2192 xs \u2286 ys \u2192 x :: xs \u2286 x :: ys\n\n{-\nWhen checker can infer type of an arg in fun type, then can use forall:\n\u2013 forall {x y} a b \u2192 A    shorthand for   {x : _} {y : _} (a : _) (b : _) \u2192 A\n-}\n\n-- proof that filter computes a sublist of its argument:\nlem-filter : {A : Set} (p : A \u2192 Bool) (xs : List A)\n           \u2192 filter p xs \u2286 xs\nlem-filter p       [] = stop\nlem-filter p (x :: xs) with p x\n... | true            = keep (lem-filter p xs)\n... | false           = drop (lem-filter p xs)\n\n{-\nto prove     lem-filter p (x :: xs)\n\nneed to prove : (filter p (x :: xs) | p x) \u2286 x :: xs\n\nwhen abstracting over p x it will be abstracted from goal type, giving\n             lem-filter p (x :: xs) with p x\n             ... | px = ?\n\nwhere p x has been replaced by px in the goal type\n                (filter p (x :: xs) | px) \u2286 x :: xs\n\nmatch px reduce call to filter\n\n             lem-filter p (x :: xs) with p x\n             ... | true  = ? {- x :: filter p xs \u2286 x :: xs -}\n             ... | false = ? {-      filter p xs \u2286 x :: xs -}\n\nSometimes WITH useful to abstract over expr that will not be matched,\ne.g., expect expr to be instantiated by matching on something else\n-}\n\nlem-plus-zero : (n : Nat) \u2192 n + zero \u2261 n\nlem-plus-zero zero = refl\nlem-plus-zero (suc n) with n + zero | lem-plus-zero n\n... | _ | refl = refl -- suc n \u2261 suc n\n\n{-\nIn suc (\"step\" case) : match on induction hypothesis : n + zero \u2261 n\nto prove suc n + zero \u2261 suc n\n\nbut n + zero does not unify with n\n\nso abstract over n + zero, calling it _,\nleft with the induction hypothesis m \u2261 n and goal suc m \u2261 suc n\nNow match on induction hypothesis, instantiating _ to n\n\n--------------------------------------------------\n-- 2.7 Modules TODO\n\n--------------------------------------------------\n-- 2.8 Records\n-}\n\nrecord Point : Set where\n  field\n    x : Nat\n    y : Nat\n\nmkPoint : Nat \u2192 Nat \u2192 Point\nmkPoint a b = record { x = a; y = b }\n\n{-\nfield projections via module of the same name.\n- parameterised by element of record type\n- contains projection functions for the fields\n- i.e.,\n   module Point (p : Point) where\n     x : Nat\n     y : Nat\n- can be used as is or instantiated to a particular record\n-}\n\ngetX : Point \u2192 Nat\ngetX = Point.x\n\nabs2 : Point \u2192 Nat\nabs2 p = let open Point p in x * x + y * y\n\n-- TODO pattern match on records\n\n-- can add functions to the module of a record\n\nrecord Monad (M : Set \u2192 Set) : Set1 where\n  field\n    return :   {A : Set} \u2192   A \u2192             M A\n    _>>=_  : {A B : Set} \u2192 M A \u2192 (A \u2192 M B) \u2192 M B\n\n  mapM : {A B : Set} \u2192 (A \u2192 M B) \u2192 List A \u2192 M (List B)\n  mapM f [] = return []\n  mapM f (x :: xs) = f x >>= \\y \u2192\n              mapM f xs >>= \\ys \u2192\n              return (y :: ys)\n\nmapM\u2019 : {M : Set \u2192 Set}\n      \u2192 Monad M\n      \u2192 {A B : Set}\n      \u2192 (A \u2192 M B)\n      \u2192 List A\n      \u2192 M (List B)\nmapM\u2019 Mon f xs = Monad.mapM Mon f xs\n\n--------------------------------------------------\n-- 2.9 Exercises\n\n-------------------------\n-- Exercise 2.1. Matrix transposition\n-- inner vectors are rows\nMatrix : Set \u2192 Nat \u2192 Nat \u2192 Set\nMatrix A n m = Vec (Vec A n) m\n\n-- (a) function to compute vector containing n copies of element x\n\nvec : {n : Nat} {A : Set} \u2192 A \u2192 Vec A n\nvec  {zero} x = []\nvec {suc n} x = x :: vec {n} x\n\nvecTest : Vec Nat 3\nvecTest = vec zero\n\n-- (b) point-wise application of vector of functions to vector of arguments\n\ninfixl 90 _$_\n_$_ : {n : Nat} {A B : Set} \u2192 Vec (A \u2192 B) n \u2192 Vec A n \u2192 Vec B n\n_$_       []        []  = []\n_$_ (f :: fs) (x :: xs) = f x :: fs $ xs\n\n$TestInputFs : Vec (Nat \u2192 Nat) 2\n$TestInputFs = (_+ 1) :: (_* 2) :: []\n\n$TestInputXs : Vec Nat 2\n$TestInputXs =     0 ::      2  :: []\n\n$TestOutput  : Vec Nat 2\n$TestOutput  =     1 ::      4  :: []\n\n$Test : $TestInputFs $ $TestInputXs \u2261 $TestOutput\n$Test = refl\n\n-- (c) matrix transposition in terms of 'vec' and _$_\n\ntranspose : forall {A n m} \u2192 Matrix A n m \u2192 Matrix A m n\ntranspose         []  = vec []\ntranspose (xs :: xss) = (vmap _::_ xs) $ (transpose xss)\n\ntransposeTestInput : Matrix Nat 2 3\ntransposeTestInput = r1 :: r2 :: r3 :: []\n where\n  r1 = 1 :: 2 :: []\n  r2 = 3 :: 4 :: []\n  r3 = 5 :: 6 :: []\n\ntransposeTestOuput : Matrix Nat 3 2\ntransposeTestOuput = r1 :: r2 :: []\n where\n  r1 = 1 ::  3 :: 5 :: []\n  r2 = 2  :: 4 :: 6 :: []\n\ntransposeTest : transpose transposeTestInput \u2261 transposeTestOuput\ntransposeTest = refl\n\n-------------------------\n-- Exercise 2.2. Vector lookup\n\n-- function composition\n_\u2218_  : \u2200 {A B C : Set} \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 (A \u2192 C)\n(g \u2218 f) x = g (f x)\n\n-- prove 'tabulate' and '!' are each other\u2019s inverses\n\n-- (a) relatively easy\nlem-!-tab : \u2200 {A n}\n          \u2192 (f : Fin n \u2192 A) \u2192 (i : Fin n)\n          \u2192 ((tabulate f) ! i) \u2261 f i\nlem-!-tab f  fzero   = refl                   -- (tabulate f ! fzero)  \u2261 f  fzero\nlem-!-tab f (fsuc i) = lem-!-tab (f \u2218 fsuc) i -- (tabulate f ! fsuc i) \u2261 f (fsuc i)\n\n-- (b) trickier\nlem-tab-! : forall {A n}\n          \u2192 (xs : Vec A n)\n          \u2192 tabulate (xs !_) \u2261 xs\nlem-tab-!       [] = refl\nlem-tab-! (x :: xs) -- tabulate (_!_ (x :: xs)) \u2261 (x :: xs)\n  with tabulate (xs !_) | lem-tab-! xs\n... | _y     | refl = refl -- (x :: _y) \u2261 (x :: xs)\n--    ^        ^\n-- Vec A n     _y \u2261 xs\n\n-------------------------\n-- Exercise 2.3. Sublists (see def above)\n\n-- (a) prove reflexivity and transitivity of \u2286\n\n-- need to name implicits since the interesting one does not come first\n\u2286-refl : {A : Set} {xs : List A}\n       \u2192 xs \u2286 xs\n\u2286-refl {xs =       []} = stop\n\u2286-refl {xs = x :: xss} = keep (\u2286-refl { xs = xss })\n\n{-\n   []    []    []\n   []    []   [z]\n   []   [z]   [z]\n  [z]   [z]   [z]\n  [z]   [z] [z,z]\n  [z] [z,z] [z,z]\n[z,z] [z,z] [z,z]\n-}\n\n\u2286-trans : {A : Set} {xs ys zs : List A}\n        \u2192 xs \u2286 ys\n        \u2192      ys \u2286 zs\n        \u2192 xs \u2286      zs\n--       []   []    []\n\u2286-trans  stop      stop     = stop\n\n--       []   []   [z]\n--      [z]  [z] [z,z]\n\u2286-trans       xy  (drop yz) = drop (\u2286-trans xy yz)\n\n--      []   [z]   [z]\n--     [z] [z,z] [z,z]\n\u2286-trans (drop xy) (keep yz) = drop (\u2286-trans xy yz)\n\n--     [z]   [z]   [z]\n\u2286-trans (keep xy) (keep yz) = keep (\u2286-trans xy yz)\n\n\u2286-trans' : {A : Set} {xs ys zs : List A}\n        \u2192 xs \u2286 ys\n        \u2192      ys \u2286 zs\n        \u2192 xs \u2286      zs\n\u2286-trans'  stop        stop     = stop\n\u2286-trans'  stop       (drop yz) = drop (\u2286-trans'  stop     yz)\n\u2286-trans' (drop xy)   (drop yz) = drop (\u2286-trans' (drop xy) yz)\n\u2286-trans' (drop xy)   (keep yz) = drop (\u2286-trans'       xy  yz)\n\u2286-trans' (keep xy)   (drop yz) = drop (\u2286-trans' (keep xy) yz)\n\u2286-trans' (keep xy)   (keep yz) = keep (\u2286-trans'       xy  yz)\n\n-- sublist TYPE of a specific list (compare to existing sublist RELATION above)\ninfixr 30 _:::_\ndata SubList {A : Set} : List A \u2192 Set where\n  []    : SubList []\n  _:::_ : forall x {xs} \u2192 SubList xs \u2192 SubList (x :: xs)\n  skip  : forall {x xs} \u2192 SubList xs \u2192 SubList (x :: xs)\n\n-- (b) extract list corresponding to a sublist\nforget : {A : Set} {xs : List A}\n       \u2192 SubList xs\n       \u2192 List A\nforget       []  = []\nforget (x ::: s) = x :: forget s\nforget  (skip s) =      forget s\n\n-- (c) prove SubList is a sublist in the sense of \u2286\nlem-forget : {A : Set} {xs : List A}\n           \u2192 (zs : SubList xs)\n           \u2192 forget zs \u2286 xs\nlem-forget        []  = stop\nlem-forget (x ::: zs) = keep (lem-forget zs)\nlem-forget  (skip zs) = drop (lem-forget zs)\n\n-- (d) alternative def of filter : satisfies sublist property by construction\nfilter' : {A : Set}\n        \u2192 (A \u2192 Bool) \u2192 (xs : List A)\n        \u2192 SubList xs\nfilter' p       []  = []\nfilter' p (x :: xs) with p x\n... | true  = x ::: filter' p xs\n... | false = skip (filter' p xs)\n\n-- (e) complement of a sublist\ncomplement : {A : Set} {xs : List A}\n           \u2192 SubList xs\n           \u2192 SubList xs\ncomplement              []  = []\ncomplement       (x ::: xs) = skip (complement xs)\ncomplement (skip {x}    xs) = x ::: complement xs\n\nmodule ComplementTest where\n  ll : List Nat\n  ll = 1 :: 2 :: 3 :: 4 :: []\n\n  p1 : Nat \u2192 Bool\n  p1 2 = true\n  p1 3 = true\n  p1 4 = true\n  p1 _ = false\n\n  p2 : Nat \u2192 Bool\n  p2 2 = true\n  p2 4 = true\n  p2 _ = false\n\n  sl1 : SubList ll\n  sl1 = filter' p1 ll\n\n  sl2 : SubList ll\n  sl2 = filter' p2 ll\n\n  sl1Test : sl1 \u2261 skip (2 ::: 3 ::: 4 ::: [])\n  sl1Test = refl\n\n  sl2Test : sl2 \u2261 skip (2 ::: skip (4 ::: []))\n  sl2Test = refl\n\n  c1 : SubList ll\n  c1 = complement sl1\n\n  c2 : SubList ll\n  c2 = complement sl2\n\n  cTest1 : c1 \u2261 1 ::: skip (skip (skip []))\n  cTest1 = refl\n\n  cTest2 : c2 \u2261 1 ::: skip (3 ::: skip [])\n  cTest2 = refl\n\n-- https://medium.com/@angerman/powersets-in-haskell-1df9684db52a\n-- (f) compute all sublists of a given list\nsublists : {A : Set}\n         \u2192 (xs : List A)\n         \u2192 List (SubList xs)\nsublists        [] = [] :: []\nsublists (x :: xs) = map (x :::_) (sublists xs) ++ (map skip (sublists xs))\n\n-- 2^3 elements - expected output MUST be in same element ORDER as function result\nsublistsTest : sublists (1 :: 2 :: 3 :: []) \u2261\n  (1 ::: 2 ::: 3 ::: [])  ::\n  (1 ::: 2 ::: skip  [])  ::\n  (1 ::: skip (3 ::: [])) ::\n  (1 ::: skip (skip  [])) ::\n  skip  (2 ::: 3 ::: [])  ::\n  skip  (2 ::: skip  [])  ::\n  skip  (skip (3 ::: [])) ::\n  skip  (skip (skip  [])) ::\n  []\nsublistsTest = refl\n\n{-\n------------------------------------------------------------------------------\n3 Programming Techniques : VIEWS and UNIVERSE constructions\n\n--------------------------------------------------\n3.1 VIEWS\n\nmatching can reveal info about term being matched AND terms INSIDE the type matched term\n\nVIEW[5]: datatypes whose purpose is to reveal info about its indices\n\nto use a view, define a view function\n- computes an element of the view for arbitrary indices\n-}\n\n-- view datatype expressing\n-- any Nat can be expressed as 2k or 2k + 1 for some k\n-- element of Parity n says if n is even or odd and what k is\ndata Parity : Nat \u2192 Set where\n  even : (k : Nat) \u2192 Parity     (k * 2)\n  odd  : (k : Nat) \u2192 Parity (1 + k * 2)\n\nparity : (n : Nat) \u2192 Parity n\nparity  zero = even zero\nparity (suc n) with parity n\n...  | even k = odd k\n...  | odd  k = even (suc k)\n{-\nparity (suc     .(k * 2)) | even k = odd k\nparity (suc .(1 + k * 2)) | odd  k = even (suc k)\n-}\n\nhalf : Nat \u2192 Nat\nhalf n with parity n\n...  | even k = k\n...  | odd  k = k\n{-\n-- Note that k is bound in the pattern for the view,\n-- not in the dotted pattern for the natural number.\nhalf     .(k * 2) | even k = k\nhalf .(1 + k * 2) | odd  k = k\n-}\n\n-------------------------\n-- FINDING AN ELEMENT IN A LIST\n\n-- given predicate and list\n-- returns if P holds for all elements\n-- A proof of All P xs is a list of proofs of P x for each element x of xs.\n-- P does not have to be a decidable predicate.\ninfixr 30 _:all:_\ndata All {A : Set} (P : A \u2192 Set) : List A \u2192 Set where\n  all[]   :                                  All P       []\n  _:all:_ : forall {x xs} \u2192 P x \u2192 All P xs \u2192 All P (x :: xs)\n\n-- to turn a decidable predicate into a general predicate, define:\nsatisfies : {A : Set} \u2192 (A \u2192 Bool) \u2192 A \u2192 Set\nsatisfies p x = isTrue (p x)\n\n-------------------------\n-- exercise : use All to prove 2nd part of correctness of filter\n-- - all elements of result satisfies the predicate\n--    All (satisfies p) (filter p xs)\n\n-- https://www.javaer101.com/en/article/18631037.html\n{-\nopen import Relation.Binary.PropositionalEquality\n\nfilter-lem-b : {A : Set} \u2192 (p : A \u2192 Bool) \u2192 (xs : List A) \u2192 All (satisfies p) (filter p xs)\nfilter-lem-b p []        = vacuo\nfilter-lem-b p (x :: xs) with p x | inspect p x\n... | true  | [ eq ] = holds _ _ (subst isTrue (sym eq) _) (filter-lem-b p xs)\n... | false | [ eq ] = filter-lem-b p xs\n-}\n\n-- https://stackoverflow.com/questions/38572464/agda-type-isnt-simplified-in-with-block\nlem-all-filter : {A : Set}\n               \u2192 (p : A \u2192 Bool) \u2192 (xs : List A)\n               \u2192 All (satisfies p) (filter p xs)\nlem-all-filter p [] = all[]\n--                                           isTrue   (p x)\nlem-all-filter p (x :: xs) with p x | \u03bb (y : satisfies p x) \u2192 y :all: lem-all-filter p xs\n-- onTrue : (y : True) \u2192 All (\u03bb x\u2081 \u2192 isTrue (p x\u2081)) (x :: filter p xs)\n... | true  | onTrue = onTrue _\n... | false |      _ = lem-all-filter p xs\n\n-------------------------\n-- VIEWS ON LISTS\n\n-- given : decidable predicate on elements of list\n-- find element in list that satisfies  predicate,\n--  or else all elements satifies negation of the predicate\n\ndata Find {A : Set} (p : A \u2192 Bool) : List A \u2192 Set where\n  -- does NOT specify which element to use as a witness in the found case.\n  -- (If the view was always to return first (or last) matching element,\n  -- force elements of xs (or ys) to satisfy the negation of p.)\n  found     : (xs : List A) \u2192 (y : A) \u2192 satisfies p y \u2192 (ys : List A)\n            \u2192 Find p (xs ++ y :: ys)\n  not-found : forall {xs} \u2192 All (satisfies (not \u25e6 p)) xs\n            \u2192 Find p  xs\n\n-- view function computing an element of Find p xs for any p and xs\n\n-- 1st attempt\n{-\nfind1 : {A : Set} (p : A \u2192 Bool) (xs : List A) \u2192 Find p xs\nfind1 p [] = not-found all[]\nfind1 p (x :: xs) with p x\n-- Need to return found on first match.\n-- ({ }) is isTrue (p x), even though already matched on p x and found out that it was true.\n-- Problem : when abstracting over p x did not know that needed to use the found constructor,\n--    so there were no p x to abstract over.\n-- WITH does not remember connection between the with-term and the pattern.\n... | true  = found [] x {! !} xs\n... | false = {! !}\n-}\n\n{-\nA solution : make this connection explicit with a proof object.\nDo NOT abstract over the term itself\n- instead rather over arbitrary term of same type\n  AND a proof that it is equal to the original term\n-}\n\n-- type of elements of type A AND proofs they are equal to some given x in A\ndata Inspect {A : Set} (x : A) : Set where\n  it : (y : A) \u2192 x \u2261 y \u2192 Inspect x\n\n-- construct an element of Inspect x by picking x as thing which is equal to x.\ninspect : {A : Set} \u2192 (x : A) \u2192 Inspect x\ninspect x = it x refl\n\n-- lemmas\ntrueIsTrue   : {x : Bool} \u2192 x \u2261 true  \u2192 isTrue  x\nfalseIsFalse : {x : Bool} \u2192 x \u2261 false \u2192 isFalse x\ntrueIsTrue   refl = _\nfalseIsFalse refl = _\n\n{-\nnow define find by abstracting over inspect (p x) rather than p x\nprovide either a proof of p x == true or a proof of p x == false\n- can be use in args to 'found' and 'not-found\n-}\n\nfind : {A : Set}\n     \u2192 (p : A \u2192 Bool) \u2192 (xs : List A)\n     \u2192 Find p xs\nfind p       [] = not-found all[]\nfind p (x :: xs) with inspect (p x)\n-- When p x is true, inspect (p x) matches 'it true prf' where prf : p x == true.\n-- Use lemma to turn into proof of isTrue (p x) needed by 3rd arg of 'found'\n... | it true  prf = found [] x (trueIsTrue prf) xs\n... | it false prf with find p xs\nfind p (x :: ._) | it false _   | found xs y py ys = found (x :: xs) y py ys\n-- p x is false : use lemma\nfind p (x :: xs) | it false prf | not-found npxs   = not-found (falseIsFalse prf :all: npxs)\n\n-------------------------\n-- INDEXING INTO A LIST\n\n{-\nPreviously showed two ways of safely indexing into a list.\nBoth cases used type system to guarantee the index didn\u2019t point outside the list.\n\nIn situations where there is no control over value of index (i.e., it might be outside)\na solution is to wrap result of lookup in MAYBE, but MAYBE provides no info.\n-}\n\n-- type of proofs that an element x is in a list xs.\ndata _\u2208_ {A : Set} (x : A) : List A \u2192 Set where\n  hd : forall   {xs} \u2192          x \u2208 x :: xs -- 1st el is a member\n  tl : forall {y xs} \u2192 x \u2208 xs \u2192 x \u2208 y :: xs -- any el in tail is member\n\n\n-- Given proof of x \u2208 xs, compute index where x occurs.\n-- Count number of tls in proof.\nindex : forall {A} {x : A} {xs} \u2192 x \u2208 xs \u2192 Nat\nindex  hd    = zero\nindex (tl p) = suc (index p)\n\n-- view on Nat with respect to list\ndata Lookup {A : Set} (xs : List A) : Nat \u2192 Set where\n  inside  : (x : A) \u2192 (p : x \u2208 xs) \u2192 Lookup xs (index p)\n  outside : (m : Nat)              \u2192 Lookup xs (length xs + m)\n\n{-\nWhen n is valid, get element at that position and guarantee that element is returned.\nNo way for 'lookup' to cheat.\n\nWhen n is outside, get out-of-bounds proof showing by how much.\n-}\n\n-- now, guaranteed 'lookup' function\n_!'_ : {A : Set}\n     \u2192 (xs : List A) \u2192 (n : Nat)\n     \u2192 Lookup xs n\n[] !' n           = outside n\n(x :: xs) !' zero = inside x hd\n(x :: xs) !' suc n with xs !' n\n...                               | inside y p = inside y (tl p)\n(x :: xs) !' suc .(length xs + n) | outside n  = outside n\n{-\n(x :: xs) !' suc .(index p)       | inside y p = inside y (tl p)\n(x :: xs) !' suc .(length xs + n) | outside n  = outside n\n-}\n\n--------------------------------------------------\n-- TYPE CHECKER FOR \u03bb-CALCULUS\n\n", "meta": {"hexsha": "222e4655c4d6a46f92aa762b4649477c2cdc122b", "size": 32168, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2008-Ulf_Norell_and_Chapman-Dependently_Typed_Programming_in_Agda/z.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2008-Ulf_Norell_and_Chapman-Dependently_Typed_Programming_in_Agda/z.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2008-Ulf_Norell_and_Chapman-Dependently_Typed_Programming_in_Agda/z.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 28.568383659, "max_line_length": 98, "alphanum_fraction": 0.5756652574, "num_tokens": 9827, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632976542184, "lm_q2_score": 0.83973396967765, "lm_q1q2_score": 0.7787384632725329}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Setoids.Setoids\nopen import Groups.Definition\nopen import Groups.Subgroups.Definition\nopen import Groups.Actions.Definition\nopen import Sets.EquivalenceRelations\nopen import Groups.Actions.Definition\n\nmodule Groups.Actions.Stabiliser {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A \u2192 A \u2192 A} {G : Group S _+_} (act : GroupAction G T) where\n\nopen GroupAction act\nopen Setoid T\n\nstabiliserPred : (x : B) \u2192 (g : A) \u2192 Set d\nstabiliserPred x g = (action g x) \u223c x\n\nstabiliserWellDefined : (x : B) \u2192 {g h : A} \u2192 Setoid._\u223c_ S g h \u2192 (stabiliserPred x g) \u2192 stabiliserPred x h\nstabiliserWellDefined x {g} {h} g=h gx=x = transitive (actionWellDefined1 (Equivalence.symmetric (Setoid.eq S) g=h)) gx=x\n  where\n    open Equivalence eq\n\nopen Setoid T\nopen Equivalence (Setoid.eq T)\n\nstabiliserSubgroup : (x : B) \u2192 Subgroup G (stabiliserPred x)\nSubgroup.isSubset (stabiliserSubgroup x) = stabiliserWellDefined x\nSubgroup.closedUnderPlus (stabiliserSubgroup x) gx=x hx=x = transitive associativeAction (transitive (actionWellDefined2 hx=x) gx=x)\nSubgroup.containsIdentity (stabiliserSubgroup x) = identityAction\nSubgroup.closedUnderInverse (stabiliserSubgroup x) {g} gx=x = transitive (transitive (transitive (actionWellDefined2 (symmetric gx=x)) (symmetric associativeAction)) (actionWellDefined1 (invLeft {g}))) identityAction\n  where\n    open Group G\n", "meta": {"hexsha": "50fa96831a26b26807355f2caa8c6a95644fc654", "size": 1444, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Actions/Stabiliser.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Actions/Stabiliser.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Actions/Stabiliser.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 43.7575757576, "max_line_length": 216, "alphanum_fraction": 0.737534626, "num_tokens": 447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9416541610257063, "lm_q2_score": 0.8267117983401363, "lm_q1q2_score": 0.778476604876034}}
{"text": "\nmodule plfa.part1.Midterm where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; cong; sym)\n-- you can add any import definitions that you need\nopen import Data.Nat using (\u2115; zero; suc; _+_; _*_; _\u2264_; _>_; z\u2264n; s\u2264s; _\u2264?_)\nopen import Data.Nat.Properties using (+-assoc; +-suc; *-suc; +-comm; *-distrib\u02e1-+; *-identity\u02b3)\nopen import Relation.Nullary using (yes; no)\nopen import plfa.part1.Induction using (*-distrib-+; *-zero)\n-- used for rewrite\nsimplify : \u2200 {A : Set} (x : A) \u2192 x \u2261 x\nsimplify x = refl\n\nsum : \u2115 \u2192 \u2115\nsum 0 = 0\nsum n@(suc sn) = sum sn + n\n\n-- Problem 1\n-- remove the \"postulate\" and prove this theorem, which is a version of\n--   sum n \u2261 n * (n + 1) / 2\n---postulate\nsimple : \u2200 (n : \u2115) \u2192 (sum n) * 2 \u2261 (suc n) * n\nsimple zero = refl\nsimple (suc n) rewrite *-distrib-+ (sum n) (suc n) 2 \n                | simple n \n                | simplify  n \n                | *-suc n n \n                | +-comm n (n * n)\n                | sym (+-assoc n (n * n) n) \n                | +-comm n (n * n) | +-assoc (n * n) n n \n                | sym (+-suc (n * n)  (n + n)) | sym (+-assoc n (n * n) (suc (n + n))) \n                | +-comm n (n * n) \n                | sym (+-suc (n * n) n) \n                | +-assoc (n * n) n (suc (n + n)) \n                | sym (+-suc (n * n) (n + suc (n + n))) \n                | sym (+-suc n (suc (n + n))) \n                | sym (+-assoc (n * n) n (suc (suc (n + n)))) \n                | *-suc n 1 \n                | *-identity\u02b3 n = refl \n\n\n-- Problem 2\n-- remove the postulate and implement this function, which gives an Natural\n-- number approximation of square root\npostulate \n  sqrt : \u2115 \u2192 \u2115\n\n-- you can run these test cases\n-- _ : sqrt 0 \u2261 0\n-- _ = refl\n-- _ : sqrt 1 \u2261 1\n-- _ = refl\n-- _ : sqrt 2 \u2261 1\n-- _ = refl\n-- _ : sqrt 3 \u2261 1\n-- _ = refl\n-- _ : sqrt 4 \u2261 2\n-- _ = refl\n-- _ : sqrt 5 \u2261 2\n-- _ = refl\n-- _ : sqrt 6 \u2261 2\n-- _ = refl\n-- _ : sqrt 7 \u2261 2\n-- _ = refl\n-- _ : sqrt 8 \u2261 2\n-- _ = refl\n-- _ : sqrt 9 \u2261 3\n-- _ = refl\n-- _ : sqrt 10 \u2261 3\n-- _ = refl\n-- _ : sqrt 11 \u2261 3\n-- _ = refl\n-- _ : sqrt 12 \u2261 3\n-- _ = refl\n-- _ : sqrt 13 \u2261 3\n-- _ = refl\n-- _ : sqrt 14 \u2261 3\n-- _ = refl\n-- _ : sqrt 15 \u2261 3\n-- _ = refl\n-- _ : sqrt 16 \u2261 4\n-- _ = refl\n-- _ : sqrt 17 \u2261 4\n-- _ = refl\n-- _ : sqrt 18 \u2261 4\n-- _ = refl\n-- _ : sqrt 19 \u2261 4\n-- _ = refl\n-- _ : sqrt 20 \u2261 4\n-- _ = refl\n-- _ : sqrt 21 \u2261 4\n-- _ = refl\n-- _ : sqrt 22 \u2261 4\n-- _ = refl\n-- _ : sqrt 23 \u2261 4\n-- _ = refl\n-- _ : sqrt 24 \u2261 4\n-- _ = refl\n-- _ : sqrt 24 \u2261 4\n-- _ = refl\n-- _ : sqrt 24 \u2261 4\n-- _ = refl\n-- _ : sqrt 25 \u2261 5\n-- _ = refl\n-- _ : sqrt 26 \u2261 5\n-- _ = refl\n-- _ : sqrt 27 \u2261 5\n-- _ = refl\n\n", "meta": {"hexsha": "609407830588d0fba1168a13dec1826f4125322c", "size": 2619, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/part1/Midterm.agda", "max_stars_repo_name": "zrz1996/plfa.github.io", "max_stars_repo_head_hexsha": "a30af28dc669502ec79d36379afd6925ad8f74da", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/part1/Midterm.agda", "max_issues_repo_name": "zrz1996/plfa.github.io", "max_issues_repo_head_hexsha": "a30af28dc669502ec79d36379afd6925ad8f74da", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/part1/Midterm.agda", "max_forks_repo_name": "zrz1996/plfa.github.io", "max_forks_repo_head_hexsha": "a30af28dc669502ec79d36379afd6925ad8f74da", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5945945946, "max_line_length": 96, "alphanum_fraction": 0.4688812524, "num_tokens": 1073, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248242542283, "lm_q2_score": 0.8289388125473628, "lm_q1q2_score": 0.778394122769796}}
{"text": "module map-is-fold-Tree where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; sym; trans; cong)\nopen Eq.\u2261-Reasoning\n\nopen import map-Tree using (Tree; leaf; node; map-Tree)\nopen import fold-Tree using (fold-Tree)\n\npostulate\n  -- \u5916\u5ef6\u6027\u306e\u516c\u7406\n  extensionality : \u2200 {A B : Set} {f g : A \u2192 B}\n    \u2192 (\u2200 (x : A) \u2192 f x \u2261 g x)\n      -----------------------\n    \u2192 f \u2261 g\n\n-- \u5916\u5ef6\u6027\u306e\u516c\u7406\u3092\u5229\u7528\u3057\u305f\u8a3c\u660e\u306e\u305f\u3081\u306e\u88dc\u984c\nlemma : \u2200 {A B C D : Set} \u2192 (f : A \u2192 C) \u2192 (g : B \u2192 D) \u2192 (tree : Tree A B)\n  \u2192 map-Tree f g tree \u2261 fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3) tree\nlemma f g (leaf a) =\n  begin\n    map-Tree f g (leaf a)\n  \u2261\u27e8\u27e9\n    leaf (f a)\n  \u2261\u27e8\u27e9\n    fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3) (leaf a)\n  \u220e\nlemma f g (node tree\u02e1 b tree\u02b3) =\n  begin\n    map-Tree f g (node tree\u02e1 b tree\u02b3)\n  \u2261\u27e8\u27e9\n    node (map-Tree f g tree\u02e1) (g b) (map-Tree f g tree\u02b3)\n  \u2261\u27e8 cong (\u03bb tree\u02b3\u2032 \u2192 node (map-Tree f g tree\u02e1) (g b) tree\u02b3\u2032) (lemma f g tree\u02b3) \u27e9\n    node (map-Tree f g tree\u02e1)\n         (g b)\n         (fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3) tree\u02b3)\n  \u2261\u27e8 cong (\u03bb tree\u02e1\u2032 \u2192 node tree\u02e1\u2032\n                           (g b)\n                           (fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3) tree\u02b3))\n          (lemma f g tree\u02e1) \u27e9\n    node (fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3) tree\u02e1)\n         (g b)\n         (fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3) tree\u02b3)\n  \u2261\u27e8\u27e9\n    fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3) (node tree\u02e1 b tree\u02b3)\n  \u220e\n\n-- Tree\u306emap\u304c\u7573\u307f\u8fbc\u307f\u3067\u8868\u73fe\u3067\u304d\u308b\u3053\u3068\u306e\u8a3c\u660e\nmap-is-fold-Tree : \u2200 {A B C D : Set} \u2192 (f : A \u2192 C) \u2192 (g : B \u2192 D)\n  \u2192 map-Tree f g \u2261 fold-Tree (\u03bb a \u2192 leaf (f a)) (\u03bb tree\u02e1 b tree\u02b3 \u2192 node tree\u02e1 (g b) tree\u02b3)\nmap-is-fold-Tree f g = extensionality (lemma f g)\n", "meta": {"hexsha": "15647b4007f56f78d297c7005e3e04e581cbabdc", "size": 1853, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/map-is-fold-Tree.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/map-is-fold-Tree.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/map-is-fold-Tree.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.6346153846, "max_line_length": 107, "alphanum_fraction": 0.5450620615, "num_tokens": 819, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213772699435, "lm_q2_score": 0.8652240964782011, "lm_q1q2_score": 0.7779414812726226}}
{"text": "open import Peano using (\u2115; zero; succ; _+_; Rel)\n\nmodule Semigroup where\n\n  infix 4 _\u2261_\n\n  data _\u2261_ {a} {A : Set a} (x : A) : A \u2192 Set a where\n    refl : x \u2261 x\n\n  record Semigroup {A : Set} (_\u25c7_ : A \u2192 A \u2192 A) : Set where\n    field\n      associativity : \u2200 x y z \u2192 (x \u25c7 y) \u25c7 z \u2261 x \u25c7 (y \u25c7 z)\n\n  record \u2115+-isSemigroup : Semigroup _+_ where\n    field\n      associativity : \u2200 x y z \u2192 (x + y) + z \u2261 x + (y + z)\n", "meta": {"hexsha": "c343313de40eb46c2bc1bdb3f989926a8f4ec5ed", "size": 403, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Semigroup.agda", "max_stars_repo_name": "cantsin/agda-experiments", "max_stars_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Semigroup.agda", "max_issues_repo_name": "cantsin/agda-experiments", "max_issues_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Semigroup.agda", "max_forks_repo_name": "cantsin/agda-experiments", "max_forks_repo_head_hexsha": "382fcfae193079783621fc5cf54b6588e22ef759", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.7058823529, "max_line_length": 58, "alphanum_fraction": 0.5260545906, "num_tokens": 164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9626731158685838, "lm_q2_score": 0.8080672181749422, "lm_q1q2_score": 0.7779045867517304}}
{"text": "{- Name: Bowornmet (Ben) Hudson and Theodore (Ted) Kim\n\n    -- COMP360 Final Project: Group Theory in Agda --\n\nIn this project, we define some fundamental ideas of group theory and\nprove a few basic theorems about the topic using Agda. For example, we\ndefine what a group is, and give several elementary examples of groups.\nWe utilize the notion of propositional equality in Agda to prove our\ntheorems using equation chains.\n\n-}\n\nopen import Preliminaries\n\nmodule finalproject where\n\n  -- addition of nats\n  plusNat : Nat \u2192 Nat \u2192 Nat\n  plusNat Z m = m\n  plusNat (S n) m = S (plusNat n m)\n\n  -- integers\n  data Int : Set where\n    _-_ : (n : Nat) \u2192 (m : Nat) \u2192 Int\n\n  -- negation\n  -_ : Int \u2192 Int\n  - (n - m) = m - n\n \n  -- addition of ints\n  plusInt : Int \u2192 Int \u2192 Int\n  plusInt (n1 - m1) (n2 - m2) = plusNat n1 n2 - plusNat m1 m2\n\n  -- operation\n  Op : Set \u2192 Set\n  Op el = el \u2192 el \u2192 el\n\n  -- record of Group\n  {- Definition: a Group is a set G with a binary operation, *, with three properties:\n     1.) G has an identity element, e \u2208 G, such that \u2200 x \u2208 G, e*x = x = x*e.\n     2.) \u2200 x \u2208 G, \u2203 x' \u2208 G such that x*x' = e = x'*x, where e is the identity element of G.\n     3.) G is associative. That is, \u2200 x y z \u2208 G, (x*y)*z = x*(y*z).\n  -}\n  record Group : Set1 where\n    field\n      el : Set\n      _*_ : Op el\n      e : el\n      inv : el \u2192 el\n      assoc :  \u2200 x y z \u2192 ((x * y) * z) == (x * (y * z))\n      ident-l : \u2200 x \u2192 (e * x) == x\n      ident-r : \u2200 x \u2192 (x * e) == x\n      inv-l : \u2200 x \u2192 ((inv x) * x) == e\n      inv-r : \u2200 x \u2192 (x * (inv x)) == e\n\n  -- first example, Bools with \"multiplication\" operation. Comparable to Z mod 2\n  -- with addition\n\n  -- multiplication of bools\n  multB : Bool \u2192 Bool \u2192 Bool\n  multB True True = True\n  multB True False = False\n  multB False True = False\n  multB False False = True\n\n  -- associativity of bools\n  assocB : \u2200 (x y z : Bool) \u2192 multB (multB x y) z == multB x (multB y z)\n  assocB True True True = Refl\n  assocB True True False = Refl\n  assocB True False True = Refl\n  assocB True False False = Refl\n  assocB False True True = Refl\n  assocB False True False = Refl\n  assocB False False True = Refl\n  assocB False False False = Refl\n\n  -- proof of identity\n  multTruel : \u2200 (x : Bool) \u2192 (multB True x == x)\n  multTruel True = Refl\n  multTruel False = Refl\n\n  multTruer : \u2200 (x : Bool) \u2192 (multB x True == x)\n  multTruer True = Refl\n  multTruer False = Refl\n\n  -- inverses of bools\n  invB : Bool \u2192 Bool\n  invB True = True\n  invB False = False\n\n  -- proof of inverses with identity\n  invBMultl : \u2200 (x : Bool) \u2192 (multB (invB x) x == True)\n  invBMultl True = Refl\n  invBMultl False = Refl\n\n  invBMultr : \u2200 (x : Bool) \u2192 (multB x (invB x) == True)\n  invBMultr True = Refl\n  invBMultr False = Refl\n\n  -- proof that the Booleans are a group on multiplication\n  Bool*-isgroup : Group\n  Bool*-isgroup = record {\n               el = Bool;\n               _*_ = multB;\n               e = True;\n               inv = invB;\n               assoc = assocB;\n               ident-l = multTruel;\n               ident-r = multTruer;\n               inv-l = invBMultl;\n               inv-r = invBMultr }\n\n  -- second example of a group, ints with the addition operation\n\n  -- congruence\n  congruenceNatInt : \u2200 (a b c d : Nat) \u2192 a == c \u2192 b == d \u2192 a - b == c - d\n  congruenceNatInt .c .d c d Refl Refl = Refl \n\n  congruenceNat : \u2200 (x y : Nat) \u2192 x == y \u2192 (S x) == (S y)\n  congruenceNat .y y Refl = Refl\n\n  congruenceNat' : \u2200 (n m : Nat) \u2192 n == m \u2192 S n == S m\n  congruenceNat' .m m Refl = Refl\n\n  -- lemma\n  addZNat : \u2200 (x : Nat) \u2192 plusNat x Z == x\n  addZNat Z = Refl\n  addZNat (S x) = congruenceNat (plusNat x Z) x (addZNat x)\n\n  -- proof of associativity\n  assocNat+ : (x y z : Nat) \u2192 plusNat (plusNat x y) z == plusNat x (plusNat y z)\n  assocNat+ Z y z = Refl\n  assocNat+ (S x) y z = congruenceNat (plusNat (plusNat x y) z) (plusNat x (plusNat y z)) (assocNat+ x y z)\n\n  assocInt+ : \u2200 (a b c : Int) \u2192 plusInt (plusInt a b) c == plusInt a (plusInt b c)\n  assocInt+ (n1 - m1) (n2 - m2) (n3 - m3) = congruenceNatInt (plusNat (plusNat n1 n2) n3)\n                                              (plusNat (plusNat m1 m2) m3) (plusNat n1 (plusNat n2 n3))\n                                              (plusNat m1 (plusNat m2 m3)) (assocNat+ n1 n2 n3) (assocNat+ m1 m2 m3) \n\n  -- proof of identity\n  addIntZl : \u2200 (n : Int) \u2192 (plusInt (Z - Z) n == n)\n  addIntZl (n - m) = Refl\n\n  addIntZr : \u2200 (n : Int) \u2192 (plusInt n (Z - Z) == n)\n  addIntZr (n - m) = congruenceNatInt (plusNat n 0) (plusNat m 0) n m (addZNat n) (addZNat m)\n\n  -- proof of inverses\n  -- issue with quotient type: impossible to prove that (S n) - (S n) = 0 - 0 without equality constructor\n  -- had problems in including the equality constructor, only thing we could not work out\n  invIntl : \u2200 (n : Int) \u2192 plusInt (- n) n == (Z - Z)\n  invIntl (n - m) = {!!}\n\n  invIntr : \u2200 (n : Int) \u2192 plusInt n (- n) == (Z - Z)\n  invIntr (n - m) = {!!}\n\n  -- proof that the integers on addition are a group\n  Int+-isgroup : Group\n  Int+-isgroup = record {\n              el = Int;\n              _*_ = plusInt;\n              e = Z - Z;\n              inv = -_;\n              assoc = assocInt+;\n              ident-l = addIntZl;\n              ident-r = addIntZr;\n              inv-l = invIntl;\n              inv-r = invIntr }\n\n   {- Definition: an group is called abelian if it is commutative.\n      That is, \u2200 x y \u2208 G, x*y = y*x. Our record of an abelian group\n      requires a group and a proof that the group operation\n      is commutative.\n   -}\n  record AbelianGroup (G : Group) : Set where\n    open Group G\n    field\n      comm : \u2200 (x y : el) \u2192 x * y == y * x\n\n  -- proof of commutativity for multiplication on bools\n  commB : \u2200 (x y : Bool) \u2192 multB x y == multB y x\n  commB True True = Refl\n  commB True False = Refl\n  commB False True = Refl\n  commB False False = Refl\n\n  Bool*-isAbelian : AbelianGroup Bool*-isgroup\n  Bool*-isAbelian = record {\n                 comm = commB }\n\n  -- some theorems\n  module Theorems (G : Group) where\n    open Group G\n    congruenceOP : {a b c : el} \u2192 a == b \u2192 a * c == b * c\n    congruenceOP Refl = Refl\n\n    congruenceOP' : {a b c : el} \u2192 b == c \u2192 a * b == a * c\n    congruenceOP' Refl = Refl\n\n    sym : {a b : el} \u2192 a == b \u2192 b == a\n    sym Refl = Refl\n\n    -- extremely simple theorem\n    babytheorem : (a b : el) \u2192 ((a * e) * b) == (a * b)\n    babytheorem a b = congruenceOP (ident-r a)\n\n    -- theorem 1: Let G be a group, and let a and b \u2208 G. Then (a * b)^-1 = b^-1 * a^-1.\n    theorem1 : \u2200 (a b : el) \u2192 inv (a * b) == (inv b * inv a)\n    theorem1 a b  = inv (a * b)                                      =\u27e8 sym (ident-r (inv (a * b))) \u27e9\n                    (inv (a * b) * e)                               =\u27e8 sym (congruenceOP' (inv-r a)) \u27e9 \n                    (inv (a * b) * (a * inv a))                     =\u27e8 congruenceOP' (congruenceOP (sym (ident-r a))) \u27e9\n                    (inv (a * b) * ((a * e) * inv a))               =\u27e8 congruenceOP' (congruenceOP (congruenceOP' (sym (inv-r b)))) \u27e9\n                    (inv (a * b) * ((a * (b * inv b)) * inv a))     =\u27e8 congruenceOP' (congruenceOP (sym (assoc a b (inv b)))) \u27e9\n                    (inv (a * b) * (((a * b) * inv b) * inv a))     =\u27e8 congruenceOP' (assoc (a * b) (inv b) (inv a)) \u27e9\n                    (inv (a * b) * ((a * b) * (inv b * inv a)))     =\u27e8 sym (assoc (inv (a * b)) (a * b) (inv b * inv a)) \u27e9\n                    ((inv (a * b) * (a * b)) * (inv b * inv a))     =\u27e8 congruenceOP (inv-l (a * b)) \u27e9\n                    (e * (inv b * inv a))                           =\u27e8 ident-l (inv b * inv a) \u27e9\n                    (inv b * inv a)                                 \u220e\n\n    -- theorem 2: Let G be a group, and let a, b, and c \u2208 G. If a * c = b * c, then a = b.\n    theorem2 : \u2200 (a b c : el) \u2192 (a * c) == (b * c) \u2192 a == b\n    theorem2 a b c p = a                            =\u27e8 sym (ident-r a) \u27e9\n                       a * e                        =\u27e8 congruenceOP' (sym (inv-r c)) \u27e9\n                       (a * (c * inv c))            =\u27e8 sym (assoc a c (inv c)) \u27e9\n                       (a * c) * inv c              =\u27e8 congruenceOP p \u27e9\n                       (b * c) * inv c              =\u27e8 assoc b c (inv c) \u27e9\n                       (b * (c * inv c))            =\u27e8 congruenceOP' (inv-r c) \u27e9\n                       (b * e)                      =\u27e8 ident-r b \u27e9\n                       b                            \u220e\n\n    -- theorem 3: Let G be a group, and let g \u2208 G. If g * g = g, then g = e.\n    theorem3 : \u2200 (g : el) \u2192 (g * g) == g \u2192 g == e\n    theorem3 g p = g                       =\u27e8 sym (ident-r g) \u27e9\n                   (g * e)                 =\u27e8 congruenceOP' (sym (inv-r g)) \u27e9\n                   (g * (g * inv g))       =\u27e8 sym (assoc g g (inv g)) \u27e9\n                   (g * g) * inv g         =\u27e8 congruenceOP p \u27e9\n                   g * inv g               =\u27e8 inv-r g \u27e9\n                   e                       \u220e\n\n    -- lemma 1: for all x \u2208 G, if x * x = e, x^-1 = x. That is, x is its own inverse.\n    lemma1 : \u2200 (x : el) \u2192 (p : x * x == e) \u2192 inv x == x\n    lemma1 x p = (inv x)                          =\u27e8 sym (ident-r (inv x)) \u27e9\n                 (inv x * e)                      =\u27e8 congruenceOP' (sym p) \u27e9\n                 inv x * (x * x)                  =\u27e8 sym (assoc (inv x) x x) \u27e9\n                 (inv x * x) * x                  =\u27e8 congruenceOP (inv-l x) \u27e9\n                 (e * x)                          =\u27e8 ident-l x \u27e9\n                 x                                \u220e                            \n\n    -- theorem 4: let G be a group. If \u2200 x \u2208 G, x * x = e, then G is abelian.\n    theorem4 : (p : \u2200 x \u2192 (x * x) == e) \u2192 AbelianGroup G\n    theorem4 p = record {\n                comm = \u03bb a b \u2192 a * b                            =\u27e8 congruenceOP (sym (ident-r a)) \u27e9\n                               (a * e) * b                      =\u27e8 congruenceOP (congruenceOP' (sym (inv-r a))) \u27e9\n                               (a * (a * inv a)) * b            =\u27e8 congruenceOP (sym (assoc a a (inv a))) \u27e9\n                               ((a * a) * inv a) * b            =\u27e8 congruenceOP (congruenceOP (p a)) \u27e9\n                               (e * inv a) * b                  =\u27e8 congruenceOP (ident-l (inv a)) \u27e9\n                               inv a * b                        =\u27e8 congruenceOP' (sym (ident-r b)) \u27e9\n                               inv a * (b * e)                  =\u27e8 congruenceOP' (congruenceOP' (sym (inv-r b))) \u27e9\n                               inv a * (b * (b * inv b))        =\u27e8 congruenceOP' (sym (assoc b b (inv b))) \u27e9 \n                               inv a * ((b * b) * inv b)        =\u27e8 congruenceOP' (congruenceOP (p b)) \u27e9\n                               inv a * (e * inv b)              =\u27e8 congruenceOP' (ident-l (inv b)) \u27e9\n                               (inv a * inv b)                  =\u27e8 sym (theorem1 b a) \u27e9\n                               (inv (b * a))                    =\u27e8 lemma1 (b * a) (p (b * a)) \u27e9\n                               (b * a)                          \u220e }\n\n    -- theorem 5: Let G be a group, and a, b, and c \u2208 G. If (a * b) * c = e, then (b * c) * a = e as well.\n    theorem5 : \u2200 (a b c : el) \u2192 ((a * b) * c) == e \u2192 ((b * c) * a) == e \n    theorem5 a b c p = ((b * c) * a)                         =\u27e8 sym (ident-l ((b * c) * a)) \u27e9\n                       e * ((b * c) * a)                     =\u27e8 congruenceOP (sym (inv-l a)) \u27e9\n                       (inv a * a) * ((b * c) * a)           =\u27e8 assoc (inv a) a ((b * c) * a) \u27e9\n                       inv a * (a * ((b * c) * a))           =\u27e8 sym (congruenceOP' (assoc a (b * c) a)) \u27e9\n                       inv a * ((a * (b * c)) * a)           =\u27e8 congruenceOP' (congruenceOP (sym (assoc a b c))) \u27e9\n                       inv a * (((a * b) * c) * a)           =\u27e8 congruenceOP' (congruenceOP p) \u27e9\n                       inv a * (e * a)                       =\u27e8 congruenceOP' (ident-l a) \u27e9\n                       (inv a * a)                           =\u27e8 inv-l a \u27e9\n                       e                                     \u220e\n\n  {- Definition: a homomorphism is a function f from a group (G , *) to another group (H , \u2218)\n     such that (\u2200 a,b \u2208 G), f(a*b) = f(a)\u2218f(b). Our definition of a homomorphism also includes a\n     proof that homomorphisms preserve identity elements between groups. That is, f(e_G) = e_H,\n     where e_G and e_H are the identity elements in G and H, respectively.\n  -}\n  -- record of homomorphisms\n  record Homomorphism (G : Group) (H : Group) : Set where\n    open Group renaming (_*_ to *)\n    field\n      f : el G \u2192 el H\n      preserve-id : f (e G) == e H\n      preserve-op : \u2200 (a b : el G) \u2192 (f (* G a b)) == * H (f a) (f b)\n\n  -- third example of a group, Z mod 2 under addition.\n  -- Z mod 2\n  data Zmod2 : Set where\n    Zero : Zmod2\n    One : Zmod2\n\n  -- addition mod 2\n  plusmod2 : Zmod2 \u2192 Zmod2 \u2192 Zmod2\n  plusmod2 Zero Zero = Zero\n  plusmod2 Zero One = One\n  plusmod2 One Zero = One\n  plusmod2 One One = Zero\n\n  -- identity of Z mod 2\n  idenZmod2-l : (x : Zmod2) \u2192 plusmod2 Zero x == x\n  idenZmod2-l Zero = Refl\n  idenZmod2-l One = Refl\n\n  idenZmod2-r : (x : Zmod2) \u2192 plusmod2 x Zero == x\n  idenZmod2-r Zero = Refl\n  idenZmod2-r One = Refl\n\n  -- inverses of Z mod 2 (the inverse of anything in Z mod 2 is itself)\n  invZmod2 : Zmod2 \u2192 Zmod2\n  invZmod2 x = x\n\n  -- left and right inverses of Z mod 2\n  invZmod2-lr : (x : Zmod2) \u2192 plusmod2 x x == Zero\n  invZmod2-lr Zero = Refl\n  invZmod2-lr One = Refl\n\n  -- associativity of addition in Z mod 2\n  assocZmod2 : (x y z : Zmod2) \u2192 plusmod2 (plusmod2 x y) z == plusmod2 x (plusmod2 y z)\n  assocZmod2 Zero Zero Zero = Refl\n  assocZmod2 Zero Zero One = Refl\n  assocZmod2 Zero One Zero = Refl\n  assocZmod2 Zero One One = Refl\n  assocZmod2 One Zero Zero = Refl\n  assocZmod2 One Zero One = Refl\n  assocZmod2 One One Zero = Refl\n  assocZmod2 One One One = Refl\n\n  -- commutativity of addition in Z mod 2\n  commZmod2 : (x y : Zmod2) \u2192 plusmod2 x y == plusmod2 y x\n  commZmod2 Zero Zero = Refl\n  commZmod2 Zero One = Refl\n  commZmod2 One Zero = Refl\n  commZmod2 One One = Refl\n\n  -- Zmod2 is a group on addition.\n  Zmod2+-isgroup : Group\n  Zmod2+-isgroup = record {\n                el = Zmod2;\n                _*_ = plusmod2;\n                e = Zero;\n                inv = invZmod2;\n                assoc = assocZmod2;\n                ident-l = idenZmod2-l;\n                ident-r = idenZmod2-r;\n                inv-l = \u03bb x \u2192 invZmod2-lr x;\n                inv-r = \u03bb x \u2192 invZmod2-lr x }\n\n  -- proof that Z mod 2 on addition is an abelian group.\n  Zmod2+-isAbelian : AbelianGroup (Zmod2+-isgroup)\n  Zmod2+-isAbelian = record {\n                  comm = commZmod2 }\n\n  -- example of a homomorphism: mapBool-to-Zmod2 is a homomorphism from Bools on multiplication to Zmod2 with addition.\n  -- map from Bools to the elements of Zmod2.\n  mapBool-to-Zmod2 : Bool \u2192 Zmod2\n  mapBool-to-Zmod2 True = Zero\n  mapBool-to-Zmod2 False = One\n\n  -- proof that the map from Bools to Zmod2 preserves composition.\n  mapBool-to-Zmod2-preserve-op : (a b : Bool) \u2192 mapBool-to-Zmod2 (multB a b) == plusmod2 (mapBool-to-Zmod2 a) (mapBool-to-Zmod2 b)\n  mapBool-to-Zmod2-preserve-op True True = Refl\n  mapBool-to-Zmod2-preserve-op True False = Refl\n  mapBool-to-Zmod2-preserve-op False True = Refl\n  mapBool-to-Zmod2-preserve-op False False = Refl\n\n  homomorphism-example : Homomorphism (Bool*-isgroup) (Zmod2+-isgroup)\n  homomorphism-example = record {\n                      f = mapBool-to-Zmod2;\n                      preserve-id = Refl;\n                      preserve-op = mapBool-to-Zmod2-preserve-op }\n\n   -- record of isomorphisms.\n  {- Definition: a homomorphism between two groups is called an isomorphism\n     if it is bijective (both one-to-one and onto). The isomorphism record\n     requires a homomorphism along with proofs that it is both one-to-one\n     (injective) and onto (surjective).\n  -}\n  record Isomorphism (G : Group) (H : Group) : Set where\n    open Group\n    open Homomorphism\n    field\n      homomorphism : Homomorphism G H\n      injective : \u2200 (a b : el G) \u2192 f homomorphism a == f homomorphism b \u2192 a == b\n      surjective : \u2200 (b : el H) \u2192 \u03a3 (\u03bb g \u2192 f homomorphism g == b)\n\n  -- example of an isomorphism\n  -- proof that this map from Bools to Zmod2 is injective (that is, \u2200 a b : Bool, f(a) = f(b) implies a = b).\n  mapB-Zmod2-inj : (a b : Bool) \u2192 mapBool-to-Zmod2 a == mapBool-to-Zmod2 b \u2192 a == b \n  mapB-Zmod2-inj True True p = Refl\n  mapB-Zmod2-inj True False ()\n  mapB-Zmod2-inj False True ()\n  mapB-Zmod2-inj False False p = Refl\n\n  -- proof that this map from Bools to Zmod2 is surjective (that is, \u2200 b : Zmod2, \u2203 a \u2208 Bool such that f(a) = b).\n  mapB-Zmod2-sur : (n : Zmod2) \u2192 \u03a3 (\u03bb bool \u2192 mapBool-to-Zmod2 bool == n)\n  mapB-Zmod2-sur Zero = True , Refl\n  mapB-Zmod2-sur One = False , Refl\n\n  -- the homomorphism between Bools on multiplication to Zmod2 with addition is isomorphic\n  isomorphism-example : Isomorphism Bool*-isgroup Zmod2+-isgroup\n  isomorphism-example = record { \n                     homomorphism = homomorphism-example;\n                     injective = mapB-Zmod2-inj;\n                     surjective = mapB-Zmod2-sur }\n", "meta": {"hexsha": "54b184bb6cc1ee372f89b936a8698a69d67072f4", "size": 17044, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "ug/finalproject.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "ug/finalproject.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "ug/finalproject.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6723716381, "max_line_length": 133, "alphanum_fraction": 0.4983571931, "num_tokens": 5672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037221561135, "lm_q2_score": 0.8397339616560073, "lm_q1q2_score": 0.7778486943028586}}
{"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.types.nat where\n\nopen import hott.core.universe\nopen import hott.core.equality\nopen import hott.functions\n\ndata \u2115 : Type\u2080 where\n  zero : \u2115\n  succ : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n-- Addition.\n_+_   : \u2115 \u2192 \u2115 \u2192 \u2115\n0       + y = y\nsucc x  + y = succ (x + y)\n\n-- Multiplication\n_*_   : \u2115 \u2192 \u2115 \u2192 \u2115\nzero   * y = zero\nsucc x * y = y + (x * y)\n\n-- The interated fucntion\niterate : \u2200{\u2113} {A : Type \u2113} \u2192 (A \u2192 A) \u2192 \u2115 \u2192 A \u2192 A\niterate _ zero     = id\niterate f (succ n) = f \u2218 iterate f n\n", "meta": {"hexsha": "b671dcb00184b0846b9078718d8000a1da9b4bd4", "size": 515, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/types/nat.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/types/nat.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/types/nat.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7586206897, "max_line_length": 49, "alphanum_fraction": 0.572815534, "num_tokens": 180, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9648551495568569, "lm_q2_score": 0.8056321889812553, "lm_q1q2_score": 0.7773183661873271}}
{"text": "open import Functional using (id)\nimport      Structure.Logic.Constructive.NaturalDeduction\n\nmodule Structure.Logic.Constructive.Functions.Properties {\u2113\u2097} {Formula} {\u2113\u2098\u2097} {Proof} {\u2113\u2092} {Domain} \u2983 constructiveLogicSign : _ \u2984 where\nopen Structure.Logic.Constructive.NaturalDeduction.ConstructiveLogicSignature {\u2113\u2097} {Formula} {\u2113\u2098\u2097} {Proof} {\u2113\u2092} {Domain} (constructiveLogicSign)\n\nopen import Structure.Logic.Constructive.Functions(Domain)\nopen import Syntax.Function\n\n-- States whether the function f is defined on the element x.\n-- Whether f(x) yields/returns an element in the domain.\n-- In other words: Whether the logic can interpret f(x) as anything meaningful.\nDefined : Function \u2192 Domain \u2192 Formula\nDefined f(x) = \u2203\u2097(y \u21a6 f(x) \u2261 y)\n\n-- States whether the function f can yield/return the element y.\nValue : Function \u2192 Domain \u2192 Formula\nValue f(y) = \u2203\u2097(x \u21a6 f(x) \u2261 y)\n\nInjective : Function \u2192 Formula\nInjective(f) = \u2200\u2097(x \u21a6 \u2200\u2097(y \u21a6 (f(x) \u2261 f(y)) \u27f6 (x \u2261 y)))\n\nSurjective : Function \u2192 Formula\nSurjective(f) = \u2200\u2097(y \u21a6 \u2203\u2097(x \u21a6 f(x) \u2261 y))\n\nBijective : Function \u2192 Formula\nBijective(f) =\n  Injective(f)\n  \u2227 Surjective(f)\n\nPreserving\u2081 : Function \u2192 Function \u2192 Function \u2192 Formula\nPreserving\u2081(f)(g\u2081)(g\u2082) = \u2200\u2097(x \u21a6 f(g\u2081(x)) \u2261 g\u2082(f(x)))\n\nPreserving\u2082 : Function \u2192 BinaryOperator \u2192 BinaryOperator \u2192 Formula\nPreserving\u2082(f)(_\u25ab\u2081_)(_\u25ab\u2082_) = \u2200\u2097(x \u21a6 \u2200\u2097(y \u21a6 f(x \u25ab\u2081 y) \u2261 (f(x) \u25ab\u2082 f(y))))\n\nFixpoint : Function \u2192 Domain \u2192 Formula\nFixpoint f(x) = (f(x) \u2261 x)\n", "meta": {"hexsha": "723453903abf619871362a5f4c4cc7e30307f62a", "size": 1421, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Structure/Logic/Constructive/Functions/Properties.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Structure/Logic/Constructive/Functions/Properties.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Structure/Logic/Constructive/Functions/Properties.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.4358974359, "max_line_length": 144, "alphanum_fraction": 0.6952850106, "num_tokens": 472, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.953275045356249, "lm_q2_score": 0.815232489352, "lm_q1q2_score": 0.7771407882629155}}
{"text": "module Rev {A : Set} where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; sym; trans; cong; cong\u2082; _\u2262_)\nopen Eq.\u2261-Reasoning\nopen import Data.Empty using (\u22a5; \u22a5-elim)\nopen import Data.List\n  using (List; []; _\u2237_; _++_; map; foldr; replicate; length; _\u2237\u02b3_)\n  -- renaming (reverse to rev)\nopen import Data.List.Properties\n  using (++-assoc; ++-identity\u02b3)\n  -- renaming (unfold-reverse to rev\u02b3;\n  --           reverse-++-commute to rev-++;\n  --           reverse-involutive to rev-inv)\nopen import Data.List.All using (All; []; _\u2237_)\nopen import Data.List.All.Properties\n  renaming (++\u207a to _++All_)\n\npattern [_]       x        =  x \u2237 []\npattern [_,_]     x y      =  x \u2237 y \u2237 []\npattern [_,_,_]   x y z    =  x \u2237 y \u2237 z \u2237 []\npattern [_,_,_,_] x y z w  =  x \u2237 y \u2237 z \u2237 w \u2237 []\n\nrev : List A \u2192 List A\nrev [] =  []\nrev (x \u2237 xs) =  rev xs ++ [ x ]\n\nrev-++ : \u2200 xs ys \u2192 rev (xs ++ ys) \u2261 rev ys ++ rev xs\nrev-++ [] ys =\n  begin\n    rev ([] ++ ys)\n  \u2261\u27e8 sym (++-identity\u02b3 (rev ys)) \u27e9\n    rev ys ++ rev []\n  \u220e\nrev-++ (x \u2237 xs) ys =\n  begin\n    rev (x \u2237 xs ++ ys)\n  \u2261\u27e8\u27e9\n    rev (xs ++ ys) ++ [ x ]\n  \u2261\u27e8 cong (_++ [ x ]) (rev-++ xs ys) \u27e9\n    (rev ys ++ rev xs) ++ [ x ]\n  \u2261\u27e8 ++-assoc (rev ys) (rev xs) [ x ] \u27e9\n    rev ys ++ (rev xs ++ [ x ])\n  \u2261\u27e8\u27e9\n    rev ys ++ (rev (x \u2237 xs))\n  \u220e\n\nrev-inv : \u2200 xs \u2192 rev (rev xs) \u2261 xs\nrev-inv [] =\n  begin\n    rev (rev [])\n  \u2261\u27e8\u27e9\n    []\n  \u220e\nrev-inv (x \u2237 xs) =\n  begin\n    rev (rev (x \u2237 xs))\n  \u2261\u27e8\u27e9\n    rev (rev xs ++ [ x ])\n  \u2261\u27e8 rev-++ (rev xs) [ x ] \u27e9\n    rev [ x ] ++ rev (rev xs)\n  \u2261\u27e8 cong (rev [ x ] ++_) (rev-inv xs) \u27e9\n    rev [ x ] ++ xs\n  \u2261\u27e8\u27e9\n    x \u2237 xs\n  \u220e\n\nrevAll : \u2200 (P : A \u2192 Set) \u2192 \u2200 {xs} \u2192 All P xs \u2192 All P (rev xs)\nrevAll P [] = []\nrevAll P (Px \u2237 Pxs) =  revAll P Pxs ++All [ Px ]\n\n", "meta": {"hexsha": "88889804fd26968edf5fceff5868ce9007391d8f", "size": 1733, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Rev.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/Rev.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/Rev.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 24.0694444444, "max_line_length": 66, "alphanum_fraction": 0.4795152914, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.8856314723088733, "lm_q1q2_score": 0.777121059214403}}
{"text": "module plfa-code.Induction where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; cong; sym)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_)\nopen import Data.Nat using (\u2115; zero; suc; _+_; _*_; _\u2238_)\nopen import Function\n\nopen import plfa-code.Reasoning-legacy \n\n_ : (3 + 4) + 5 \u2261 3 + (4 + 5)\n_ =\n  begin\n    (3 + 4) + 5\n  \u2261\u27e8\u27e9\n    7 + 5\n  \u2261\u27e8\u27e9\n    12\n  \u2261\u27e8\u27e9\n    3 + 9\n  \u2261\u27e8\u27e9\n    3 + (4 + 5)\n  \u220e\n\n+-assoc : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)\n+-assoc zero n p =\n  begin\n    (zero + n) + p\n  \u2261\u27e8\u27e9\n    n + p\n  \u2261\u27e8\u27e9\n    zero + (n + p)\n  \u220e\n+-assoc (suc m) n p =\n  begin\n    (suc m + n) + p\n  \u2261\u27e8\u27e9\n    suc (m + n) + p\n  \u2261\u27e8\u27e9\n    suc ((m + n) + p)\n  \u2261\u27e8 cong suc (+-assoc m n p) \u27e9\n    suc (m + (n + p))\n  \u2261\u27e8\u27e9\n    suc m + (n + p)\n  \u220e\n\n+-identity\u02b3 : \u2200 (m : \u2115) \u2192 m + zero \u2261 m\n+-identity\u02b3 zero =\n  begin\n    zero + zero\n  \u2261\u27e8\u27e9\n    zero\n  \u220e\n+-identity\u02b3 (suc m) =\n  begin\n    suc m + zero\n  \u2261\u27e8\u27e9\n    suc (m + zero)\n  \u2261\u27e8 cong suc (+-identity\u02b3 m)\u27e9\n    suc m\n  \u220e\n\n+-suc : \u2200 (m n : \u2115) \u2192 m + suc n \u2261 suc (m + n)\n+-suc zero n =\n  begin\n    zero + suc n\n  \u2261\u27e8\u27e9\n    suc n\n  \u2261\u27e8\u27e9\n    suc (zero + n)\n  \u220e\n+-suc (suc m) n =\n  begin\n    suc m + suc n\n  \u2261\u27e8\u27e9\n    suc (m + suc n)\n  \u2261\u27e8 cong suc (+-suc m n) \u27e9\n    suc (suc (m + n))\n  \u2261\u27e8\u27e9\n    suc (suc m + n)\n  \u220e\n\n+-comm : \u2200 (m n : \u2115) \u2192 m + n \u2261 n + m\n+-comm zero n =\n  begin\n    zero + n\n  \u2261\u27e8\u27e9\n    n\n  \u2261\u27e8 sym (+-identity\u02b3 n) \u27e9\n    n + zero\n  \u220e\n+-comm (suc m) n =\n  begin\n    suc m + n\n  \u2261\u27e8\u27e9\n    suc (m + n)\n  \u2261\u27e8 cong suc (+-comm m n) \u27e9\n    suc (n + m)\n  \u2261\u27e8 sym (+-suc n m) \u27e9\n    n + suc m\n  \u220e\n\n+-rearrange : \u2200 (m n p q : \u2115) \u2192 (m + n) + (p + q) \u2261 m + (n + p) + q\n+-rearrange m n p q =\n  begin\n    (m + n) + (p + q)\n  \u2261\u27e8 +-assoc m n (p + q) \u27e9\n    m + (n + (p + q))\n  \u2261\u27e8 cong (m +_) (sym (+-assoc n p q)) \u27e9\n    m + ((n + p) + q)\n  \u2261\u27e8 sym (+-assoc m (n + p) q) \u27e9\n    (m + (n + p)) + q\n  \u220e\n\n+-assoc\u2032 : \u2200 (m n p : \u2115) \u2192 (m + n) + p \u2261 m + (n + p)  \n+-assoc\u2032 zero n p = refl\n+-assoc\u2032 (suc m) n p rewrite +-assoc\u2032 m n p = refl\n\n\n-- practice\n\n+-swap : \u2200 (m n p : \u2115) \u2192 m + (n + p) \u2261 n + (m + p)\n+-swap m zero p = refl\n+-swap m (suc n) p\n  rewrite +-suc m (n + p)\n  | sym (+-assoc m n p)\n  | +-comm m n\n  | +-assoc n m p = refl\n\n*-distrib-+ : \u2200 (m n p : \u2115) \u2192 (m + n) * p \u2261 m * p + n * p\n*-distrib-+ zero n p = refl\n*-distrib-+ (suc m) n p rewrite *-distrib-+ m n p\n                                | sym (+-assoc p (m * p) (n * p)) = refl\n\n*-assoc : \u2200 (m n p : \u2115) \u2192 (m * n) * p \u2261 m * (n * p)\n*-assoc zero n p = refl\n*-assoc (suc m) n p rewrite *-distrib-+ n (m * n) p | *-assoc m n p = refl\n\n*-zero\u02b3 : \u2200 (n : \u2115) \u2192 n * zero \u2261 zero\n*-zero\u02b3 zero = refl\n*-zero\u02b3 (suc n) rewrite *-zero\u02b3 n = refl\n\n*-suc : \u2200 (m n : \u2115) \u2192 m * suc n \u2261 m * n + m\n*-suc zero n = refl\n*-suc (suc m) n =\n  begin\n    (suc m) * (suc n)\n  \u2261\u27e8\u27e9\n    (suc n) + m * (suc n)\n  \u2261\u27e8 cong ((suc n) +_) (*-suc m n) \u27e9\n    suc n + (m * n + m)\n  \u2261\u27e8 +-swap (suc n) (m * n) m \u27e9\n    m * n + (suc n + m)\n  \u2261\u27e8 cong ((m * n) +_) (sym (+-suc n m)) \u27e9\n    m * n + (n + suc m)\n  \u2261\u27e8 sym (+-assoc (m * n) n (suc m)) \u27e9\n    m * n + n + suc m\n  \u2261\u27e8 cong (_+ (suc m)) (+-comm (m * n) n) \u27e9\n    (suc m) * n + (suc m)\n  \u220e\n\n*-comm : \u2200 (m n : \u2115) \u2192 m * n \u2261 n * m\n*-comm zero n rewrite *-zero\u02b3 n = refl\n*-comm (suc m) n =\n  begin\n    suc m * n\n  \u2261\u27e8\u27e9\n    n + m * n\n  \u2261\u27e8 +-comm n (m * n) \u27e9\n    m * n + n\n  \u2261\u27e8 cong (_+ n) (*-comm m n) \u27e9\n    n * m + n\n  \u2261\u27e8 sym (*-suc n m) \u27e9\n    n * suc m\n  \u220e\n\nz\u2238n\u2261z : \u2200 (n : \u2115) \u2192 zero \u2238 n \u2261 zero\nz\u2238n\u2261z zero = refl\nz\u2238n\u2261z (suc n) = refl\n\n\u2238-+-assoc : \u2200 (m n p : \u2115) \u2192 m \u2238 n \u2238 p \u2261 m \u2238 (n + p)\n\u2238-+-assoc zero n p rewrite z\u2238n\u2261z n | z\u2238n\u2261z p | z\u2238n\u2261z (n + p) = refl\n\u2238-+-assoc (suc m) zero p = refl\n\u2238-+-assoc (suc m) (suc n) p rewrite \u2238-+-assoc m n p = refl\n\n---------- Bin ----------\ndata Bin : Set where\n  nil : Bin\n  x0_ : Bin \u2192 Bin\n  x1_ : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc nil    = x1 nil\ninc (x0 t) = x1 t\ninc (x1 t) = x0 (inc t)\n\nto : \u2115 \u2192 Bin\nto zero    = x0 nil\nto (suc n) = inc (to n)\n\nfrom : Bin \u2192 \u2115\nfrom nil      = 0\nfrom (x0 t)   = 2 * (from t)\nfrom (x1 t)   = suc (2 * (from t))\n--------------------------------------\n\n+1\u2261suc : \u2200 {n : \u2115} \u2192 n + 1 \u2261 suc n\n+1\u2261suc {zero}   = refl\n+1\u2261suc {suc n}  = cong suc +1\u2261suc\n\nsuc-from-inc : \u2200 (x : Bin) \u2192 from (inc x) \u2261 suc (from x)\nsuc-from-inc nil                                                        = refl\nsuc-from-inc (x0 x) rewrite +1\u2261suc {from x * 2}                         = refl\nsuc-from-inc (x1 x) rewrite suc-from-inc x | +-suc (from x) (from x + 0) = refl\n\n-- t4 is \u22a5 , because `to (from nil) \u2261 x0 nil \u2262 nil`\n-- t4 : \u2200 (x : Bin) \u2192 to (from x) \u2261 x\n\nfrom-to-const : \u2200 (n : \u2115) \u2192 from (to n) \u2261 n\nfrom-to-const zero                                                  = refl\nfrom-to-const (suc n) rewrite suc-from-inc (to n) | from-to-const n = refl\n", "meta": {"hexsha": "65e24d368b6d4c2688b807a97795e7974621f5e7", "size": 4670, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa-code/Induction.agda", "max_stars_repo_name": "chirsz-ever/plfa-code", "max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa-code/Induction.agda", "max_issues_repo_name": "chirsz-ever/plfa-code", "max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa-code/Induction.agda", "max_forks_repo_name": "chirsz-ever/plfa-code", "max_forks_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.036036036, "max_line_length": 79, "alphanum_fraction": 0.4209850107, "num_tokens": 2235, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480237330998, "lm_q2_score": 0.8459424353665382, "lm_q1q2_score": 0.7769814088038205}}
{"text": "\nmodule Data.Nat where\n\nimport Prelude\nimport Data.Bool as Bool\n\nopen Prelude\nopen Bool\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN ZERO zero #-}\n\ninfix 40 _==_ _<_ _\u2264_ _>_ _\u2265_\ninfixl 60 _+_ _-_\ninfixl 70 _*_\ninfixr 80 _^_\ninfix 100 _!\n\n_+_ : Nat -> Nat -> Nat\nzero  + m = m\nsuc n + m = suc (n + m)\n\n_-_ : Nat -> Nat -> Nat\nzero  - m     = zero\nsuc n - zero  = suc n\nsuc n - suc m = n - m\n\n_*_ : Nat -> Nat -> Nat\nzero  * m = zero\nsuc n * m = m + n * m\n\n_^_ : Nat -> Nat -> Nat\nn ^ zero  = 1\nn ^ suc m = n * n ^ m\n\n_! : Nat -> Nat\nzero  ! = 1\nsuc n ! = suc n * n !\n\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATMINUS _-_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n\n_==_ : Nat -> Nat -> Bool\nzero  == zero  = true\nzero  == suc _ = false\nsuc _ == zero  = false\nsuc n == suc m = n == m\n\n_<_ : Nat -> Nat -> Bool\nn     < zero  = false\nzero  < suc m = true\nsuc n < suc m = n < m\n\n_\u2264_ : Nat -> Nat -> Bool\nn \u2264 m = n < suc m\n\n_>_ = flip _<_\n_\u2265_ = flip _\u2264_\n\n{-# BUILTIN NATEQUALS _==_ #-}\n{-# BUILTIN NATLESS   _<_  #-}\n\ndivSuc : Nat -> Nat -> Nat\ndivSuc  zero   _ = zero\ndivSuc (suc n) m = 1 + divSuc (n - m) m\n\nmodSuc : Nat -> Nat -> Nat\nmodSuc  zero   _ = zero\nmodSuc (suc n) m =\n  ! n \u2264 m  => suc n\n  ! otherwise modSuc (n - m) m\n\n{-# BUILTIN NATDIVSUC divSuc #-}\n-- {-# BUILTIN NATMODSUC modSuc #-}\n\ndiv : Nat -> Nat -> Nat\ndiv n  zero   = zero\ndiv n (suc m) = divSuc n m\n\nmod : Nat -> Nat -> Nat\nmod n  zero   = zero\nmod n (suc m) = modSuc n m\n\ngcd : Nat -> Nat -> Nat\ngcd a 0 = a\ngcd a b = gcd b (mod a b)\n\nlcm : Nat -> Nat -> Nat\nlcm a b = div (a * b) (gcd a b)\n\neven : Nat -> Bool\neven n = mod n 2 == 0\n\nodd : Nat -> Bool\nodd n = mod n 2 == 1\n\n", "meta": {"hexsha": "4e920f84871f3e8832a094fb38fd3045fb1ce2bc", "size": 1709, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Nat.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Nat.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Nat.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.5922330097, "max_line_length": 39, "alphanum_fraction": 0.5330602692, "num_tokens": 676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9252299570920387, "lm_q2_score": 0.8397339716830606, "lm_q1q2_score": 0.7769470265890455}}
{"text": "module PlfaInduction where\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_ ; refl ; cong ; sym)\nopen Eq.\u2261-Reasoning using (begin_ ; _\u2261\u27e8\u27e9_ ; _\u2261\u27e8_\u27e9_ ; _\u220e )\nopen import Data.Nat using (\u2115 ; zero ; suc ; _+_ ; _*_ ; _^_ )\n\n+-assoc : \u2200 (a b c : \u2115) \u2192 (a + b) + c \u2261 a + (b + c)\n+-assoc zero b c =\n  begin\n    (zero + b) + c\n  \u2261\u27e8\u27e9\n    b + c\n  \u2261\u27e8\u27e9\n    zero + (b + c)\n  \u220e\n\n+-assoc (suc a) b c =\n  begin\n    (suc a + b) + c \n  \u2261\u27e8\u27e9\n    suc (a + b) + c \n  \u2261\u27e8\u27e9\n    suc ((a + b) + c) \n  \u2261\u27e8 cong suc (+-assoc a b c) \u27e9 \n    suc (a + (b + c)) \n  \u2261\u27e8\u27e9\n    suc a + (b + c)\n  \u220e\n\n+-identity\u02b3 : \u2200 (a : \u2115) \u2192 a + zero \u2261 a\n+-identity\u02b3 zero =\n  begin\n    zero + zero\n  \u2261\u27e8\u27e9\n    zero\n  \u220e\n\n+-identity\u02b3 (suc a) =\n  begin\n    suc a + zero\n  \u2261\u27e8\u27e9\n    suc (a + zero)\n  \u2261\u27e8 cong suc (+-identity\u02b3 a) \u27e9\n    suc a\n  \u220e\n\n+-suc : \u2200 (a b : \u2115) \u2192 a + suc b \u2261 suc (a + b)\n+-suc zero b =\n  begin\n    zero + suc b\n  \u2261\u27e8\u27e9\n    suc b\n  \u2261\u27e8\u27e9\n   suc (zero + b) \n  \u220e\n\n+-suc (suc a) b =\n  begin\n    suc a + suc b\n  \u2261\u27e8\u27e9\n    suc (a + suc b) \n  \u2261\u27e8 cong suc (+-suc a b) \u27e9\n    suc (suc a + b)\n  \u220e\n\n+-comm : \u2200 (a b : \u2115) \u2192 a + b \u2261 b + a\n+-comm zero b =\n  begin\n    zero + b\n  \u2261\u27e8\u27e9\n    b\n  \u2261\u27e8 sym (+-identity\u02b3 b) \u27e9\n    b + zero\n  \u220e\n  \n+-comm (suc a) b =\n  begin\n    suc a + b\n  \u2261\u27e8\u27e9\n    suc (a + b)\n  \u2261\u27e8 cong suc (+-comm a b) \u27e9\n    suc (b + a)\n  \u2261\u27e8 sym (+-suc b a) \u27e9\n    b + suc a\n  \u220e\n\n+-rearrange : \u2200 (a b c d : \u2115) \u2192 (a + b) + (c + d)  \u2261 (a + (b + c)) + d\n+-rearrange a b c d =\n  begin\n    -- Because addition associates to the left\n    -- a + b + (c + d)\n    -- is the same as\n    (a + b) + (c + d)\n  \u2261\u27e8 +-assoc a b (c + d) \u27e9\n    a + (b + (c + d))\n  -- Lesson: The + and the _ in in (a +_) MUST be next to each other (no spaces allowed)\n  \u2261\u27e8 cong (a +_) (sym (+-assoc b c d)) \u27e9\n    a + ((b + c) + d)\n  \u2261\u27e8 sym (+-assoc a (b + c) d) \u27e9\n    (a + (b + c)) + d\n  \u220e  \n\n-- Let's do it again, now using the rewrite magic\n--+-assoc' : \u2200 (a b c : \u2115) \u2192 a + b + c \u2261 a + (b + c)\n--+-assoc' zero b c = refl\n--+-assoc' (suc a) b c rewrite +-assoc' a b c = refl\n\n--+-suc' : \u2200 (a b : \u2115) \u2192 a + suc b \u2261 suc (a + b)\n--+-suc' zero b = refl\n--+-suc' (suc a) b rewrite +-suc' a b = refl\n\n+-swap : \u2200 (a b c : \u2115) \u2192 a + (b + c) \u2261 b + (a + c)\n+-swap a b c rewrite sym (+-assoc a b c) | +-comm a b | +-assoc b a c = refl \n\n*-zero : \u2200 (a : \u2115) \u2192 a * zero \u2261 zero \n*-zero zero = refl\n*-zero (suc a) rewrite *-zero a = refl\n\n*-rsucdist : \u2200 (n m : \u2115) \u2192 n * suc m \u2261 n + n * m\n*-rsucdist zero m = refl\n*-rsucdist (suc n) m rewrite *-rsucdist n m | +-swap m n (n * m) = refl\n\n*-distrib : \u2200 (x b c : \u2115) \u2192 (b + c) * x \u2261 b * x + c * x \n*-distrib zero b c rewrite *-zero (b + c) | *-zero b | *-zero c = refl\n*-distrib (suc x) b c rewrite *-rsucdist (b + c) x\n                            | *-distrib x b c\n                            | +-rearrange b c (b * x) (c * x)\n                            | +-comm c (b * x)\n                            | sym (+-rearrange b (b * x) c (c * x) )\n                            | sym (*-rsucdist b x)\n                            | sym (*-rsucdist c x) = refl\n\n*-assoc : \u2200 (a b c : \u2115) \u2192 (a * b) * c \u2261 a * (b * c) \n*-assoc zero b c = refl\n*-assoc (suc a) b c =\n  begin\n    (suc a * b) * c\n  \u2261\u27e8\u27e9\n    (b + a * b) * c\n  \u2261\u27e8 *-distrib c b (a * b) \u27e9\n    b * c + (a * b) * c\n  \u2261\u27e8 cong (\u03bb { x \u2192 b * c + x }) (*-assoc a b c) \u27e9\n    suc a * (b * c)\n  \u220e\n\n*-comm : \u2200 (a b : \u2115) \u2192 a * b \u2261 b * a\n*-comm zero b rewrite *-zero b = refl\n*-comm (suc a) b rewrite *-comm a b | sym (*-rsucdist b a) = refl\n\ninfixl 6 _\u2238_\n_\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm \u2238 zero = m\nzero \u2238 (suc n) = zero\n(suc m) \u2238 (suc n) = m \u2238 n\n\n\u2238-zero : \u2200 (a : \u2115) \u2192 zero \u2238 a \u2261 zero\n\u2238-zero zero = refl\n\u2238-zero (suc a) = refl\n\n\u2238-suc : \u2200 (a b : \u2115) \u2192 a \u2238 suc b \u2261 a \u2238 1 \u2238 b\n\u2238-suc zero b rewrite \u2238-zero b = refl\n\u2238-suc (suc a) b = refl\n\n-- \u2238-+-assoc : \u2200 (a b c : \u2115) \u2192 a \u2238 b \u2238 c \u2261 a \u2238 (b + c)\n-- \u2238-+-assoc a zero c = refl\n-- \u2238-+-assoc a (suc b) c =\n--   begin\n--     a \u2238 suc b \u2238 c \n--   \u2261\u27e8 cong (\u03bb x \u2192 x \u2238 c) (\u2238-suc a b) \u27e9\n--     a \u2238 1 \u2238 b \u2238 c -- Remember this is equal to ((a \u2238 1) \u2238 b) \u2238 c \n--   \u2261\u27e8 \u2238-+-assoc  \u27e9\n--   \u2261\u27e8 \u2238-suc a (b + c) \u27e9\n--     a \u2238 (b + c) \n--   \u220e\n", "meta": {"hexsha": "48629a8b183f20bd62ffef34842eeaeaa10bb4b2", "size": 4031, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "PlfaInduction.agda", "max_stars_repo_name": "GustavoMF31/upgraded-happiness", "max_stars_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "PlfaInduction.agda", "max_issues_repo_name": "GustavoMF31/upgraded-happiness", "max_issues_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PlfaInduction.agda", "max_forks_repo_name": "GustavoMF31/upgraded-happiness", "max_forks_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0342857143, "max_line_length": 88, "alphanum_fraction": 0.4177623419, "num_tokens": 1881, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9252299509069105, "lm_q2_score": 0.8397339736884712, "lm_q1q2_score": 0.7769470232506491}}
{"text": "{-\n\nBased on Nicolai Kraus' blog post:\n  The Truncation Map |_| : \u2115 -> \u2016\u2115\u2016 is nearly Invertible\n  https://homotopytypetheory.org/2013/10/28/the-truncation-map-_-\u2115-\u2016\u2115\u2016-is-nearly-invertible/\n\nDefines [recover], which definitionally satisfies `recover \u2223 x \u2223 \u2261 x` ([recover\u2223\u2223]) for homogeneous types\n\nAlso see the follow-up post by Jason Gross:\n  Composition is not what you think it is! Why \u201cnearly invertible\u201d isn\u2019t.\n  https://homotopytypetheory.org/2014/02/24/composition-is-not-what-you-think-it-is-why-nearly-invertible-isnt/\n\n-}\n{-# OPTIONS --cubical --safe #-}\n\nmodule Cubical.HITs.PropositionalTruncation.MagicTrick where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Path\nopen import Cubical.Foundations.Pointed\nopen import Cubical.Foundations.Pointed.Homogeneous\n\nopen import Cubical.HITs.PropositionalTruncation.Base\nopen import Cubical.HITs.PropositionalTruncation.Properties\n\nmodule Recover {\u2113} (A\u2219 : Pointed \u2113) (h : isHomogeneous A\u2219) where\n  private\n    A = typ A\u2219\n    a = pt A\u2219\n\n  toEquivPtd : \u2225 A \u2225 \u2192 \u03a3[ B\u2219 \u2208 Pointed \u2113 ] (A , a) \u2261 B\u2219\n  toEquivPtd = recPropTrunc (isContr\u2192isProp (_ , \u03bb p \u2192 contrSingl (snd p)))\n                            (\u03bb x \u2192 (A , x) , h x)\n  private\n    B\u2219 : \u2225 A \u2225 \u2192 Pointed \u2113\n    B\u2219 tx = fst (toEquivPtd tx)\n\n  -- the key observation is that B\u2219 \u2223 x \u2223 is definitionally equal to (A , x)\n  private\n    obvs : \u2200 x \u2192 B\u2219 \u2223 x \u2223 \u2261 (A , x)\n    obvs x = refl -- try it: `C-c C-n B\u2219 \u2223 x \u2223` gives `(A , x)`\n\n  -- thus any truncated element (of a homogeneous type) can be recovered by agda's normalizer!\n\n  recover : \u2200 (tx : \u2225 A \u2225) \u2192 typ (B\u2219 tx)\n  recover tx = pt (B\u2219 tx)\n\n  recover\u2223\u2223 : \u2200 (x : A) \u2192 recover \u2223 x \u2223 \u2261 x\n  recover\u2223\u2223 x = refl -- try it: `C-c C-n recover \u2223 x \u2223` gives `x`\n\n  private\n    -- notice that the following typechecks because typ (B\u2219 \u2223 x \u2223) is definitionally equal to to A, but\n    --  `recover : \u2225 A \u2225 \u2192 A` does not because typ (B\u2219 tx) is not definitionally equal to A (though it is\n    --  judegmentally equal to A by cong typ (snd (toEquivPtd tx)) : A \u2261 typ (B\u2219 tx))\n    obvs2 : A \u2192 A\n    obvs2 = recover \u2218 \u2223_\u2223\n\n    -- one might wonder if (cong recover (squash \u2223 x \u2223 \u2223 y \u2223)) therefore has type x \u2261 y, but thankfully\n    --  typ (B\u2219 (squash \u2223 x \u2223 \u2223 y \u2223 i)) is *not* A (it's a messy hcomp involving h x and h y)\n    recover-squash : \u2200 x y \u2192 -- x \u2261 y -- this raises an error\n                             PathP (\u03bb i \u2192 typ (B\u2219 (squash \u2223 x \u2223 \u2223 y \u2223 i))) x y\n    recover-squash x y = cong recover (squash \u2223 x \u2223 \u2223 y \u2223)\n\n\n-- Demo, adapted from:\n-- https://bitbucket.org/nicolaikraus/agda/src/e30d70c72c6af8e62b72eefabcc57623dd921f04/trunc-inverse.lagda\n\nprivate\n  open import Cubical.Data.Nat\n  open Recover (\u2115 , zero) (isHomogeneousDiscrete discrete\u2115)\n\n  -- only `\u2223hidden\u2223` is exported, `hidden` is no longer in scope\n  module _ where\n    private\n      hidden : \u2115\n      hidden = 17\n\n    \u2223hidden\u2223 : \u2225 \u2115 \u2225\n    \u2223hidden\u2223 = \u2223 hidden \u2223\n\n  -- we can still recover the value, even though agda can no longer see `hidden`!\n  test : recover \u2223hidden\u2223 \u2261 17\n  test = refl -- try it: `C-c C-n recover \u2223hidden\u2223` gives `17`\n              --         `C-c C-n hidden` gives an error\n\n  -- Finally, note that the definition of recover is independent of the proof that A is homogeneous. Thus we\n  --  still can definitionally recover information hidden by \u2223_\u2223 as long as we permit holes. Try replacing\n  --  `isHomogeneousDiscrete discrete\u2115` above with a hole (`?`) and notice that everything still works\n", "meta": {"hexsha": "00be68b228efcd0621cf689ccc82bb2f2b18c3d3", "size": 3487, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/HITs/PropositionalTruncation/MagicTrick.agda", "max_stars_repo_name": "oisdk/cubical", "max_stars_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/HITs/PropositionalTruncation/MagicTrick.agda", "max_issues_repo_name": "oisdk/cubical", "max_issues_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/HITs/PropositionalTruncation/MagicTrick.agda", "max_forks_repo_name": "oisdk/cubical", "max_forks_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.7444444444, "max_line_length": 111, "alphanum_fraction": 0.6472612561, "num_tokens": 1206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8976952893703476, "lm_q2_score": 0.8652240686758841, "lm_q1q2_score": 0.7767075707001873}}
{"text": "module nat-to-string where\n\nopen import bool\nopen import char\nopen import eq\nopen import list\nopen import maybe\nopen import nat\nopen import nat-division\nopen import nat-thms\nopen import product\nopen import string\nopen import termination\n\n\u2115-to-digitsh : (base : \u2115) \u2192 1 < base \u2261 tt \u2192 (x : \u2115) \u2192 \u2193\ud835\udd39 _>_ x \u2192 \ud835\udd43 \u2115\n\u2115-to-digitsh _ _ 0 _ = []\n\u2115-to-digitsh base bp (suc x) (pf\u2193 fx) with (suc x) \u00f7 base ! (<=\u2115ff2 base bp)\n... | q , r , p , _ = r :: (\u2115-to-digitsh base bp q (fx (\u00f7<{base}{q}{r}{x} bp p)))\n\n\u2115-to-digits : \u2115 \u2192 \ud835\udd43 \u2115\n\u2115-to-digits x = reverse (\u2115-to-digitsh 10 refl x (\u2193-> x))\n\ndigit-to-string : \u2115 \u2192 string\ndigit-to-string 0 = \"0\"\ndigit-to-string 1 = \"1\"\ndigit-to-string 2 = \"2\"\ndigit-to-string 3 = \"3\"\ndigit-to-string 4 = \"4\"\ndigit-to-string 5 = \"5\"\ndigit-to-string 6 = \"6\"\ndigit-to-string 7 = \"7\"\ndigit-to-string 8 = \"8\"\ndigit-to-string 9 = \"9\"\ndigit-to-string _ = \"unexpected-digit\"\n\ndigits-to-string : \ud835\udd43 \u2115 \u2192 string\ndigits-to-string [] = \"\"\ndigits-to-string (d :: ds) = (digit-to-string d) ^ (digits-to-string ds)\n\n\u2115-to-string : \u2115 \u2192 string\n\u2115-to-string 0 = \"0\"\n\u2115-to-string (suc x) = digits-to-string (\u2115-to-digits (suc x))\n\nstring-to-digit : char \u2192 maybe \u2115 \nstring-to-digit '0' = just 0\nstring-to-digit '1' = just 1\nstring-to-digit '2' = just 2\nstring-to-digit '3' = just 3\nstring-to-digit '4' = just 4\nstring-to-digit '5' = just 5\nstring-to-digit '6' = just 6\nstring-to-digit '7' = just 7\nstring-to-digit '8' = just 8\nstring-to-digit '9' = just 9\nstring-to-digit _ = nothing\n\n-- the digits are in order from least to most significant\ndigits-to-\u2115h : \u2115 \u2192 \u2115 \u2192 \ud835\udd43 \u2115 \u2192 \u2115\ndigits-to-\u2115h multiplier sum [] = sum\ndigits-to-\u2115h multiplier sum (x :: xs) = digits-to-\u2115h (10 * multiplier) (x * multiplier + sum) xs\n\ndigits-to-\u2115 : \ud835\udd43 \u2115 \u2192 \u2115\ndigits-to-\u2115 digits = digits-to-\u2115h 1 0 digits\n\nstring-to-\u2115 : string \u2192 maybe \u2115\nstring-to-\u2115 s with \ud835\udd43maybe-map string-to-digit (reverse (string-to-\ud835\udd43char s)) \n... | nothing = nothing\n... | just ds = just (digits-to-\u2115 ds)\n", "meta": {"hexsha": "db05bf422ebdaf27a13686a7d65a1762322ef5cc", "size": 1935, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nat-to-string.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nat-to-string.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nat-to-string.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.0434782609, "max_line_length": 96, "alphanum_fraction": 0.650129199, "num_tokens": 697, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.934395157060208, "lm_q2_score": 0.8311430478583168, "lm_q1q2_score": 0.776616038743072}}
{"text": "-- Exercises for session 2\n--\n-- If unsure which exercises to do start with those marked with *\n--\n{-# OPTIONS --cubical --allow-unsolved-metas #-}\nmodule ExerciseSession2 where\n\nopen import Part1\nopen import Part2\nopen import ExerciseSession1\n\nopen import Cubical.Foundations.Equiv\n\n-- Exercises about Part 2:\n\n-- Exercise* 1: prove that the computation rule for J on refl\n-- holds up to a path.\n-- (hint: normalize the goal using C-u C-u C-c C-,)\nJEq : {x : A} (P : (z : A) \u2192 x \u2261 z \u2192 Type \u2113'')\n      (d : P x refl) \u2192 J P d refl \u2261 d\nJEq P p d = {!!}\n\n\n-- Exercise* 2: prove that isContr implies isProp\nisContr\u2192isProp : isContr A \u2192 isProp A\nisContr\u2192isProp = {!!}\n\n\n-- Exercise 3: prove that isProp implies isProp'\n-- (hint: use isProp\u2192isSet from the Part2)\nisProp\u2192isProp' : isProp A \u2192 isProp' A\nisProp\u2192isProp' = {!!}\n\n\n-- Exercise 4: prove the following lemma\n-- (hint: use the solutions to exercises 2 and 3)\nisContr\u2192isContr\u2261 : isContr A \u2192 (x y : A) \u2192 isContr (x \u2261 y)\nisContr\u2192isContr\u2261 = {!!}\n\n\n-- Exercise 5: use transp to turn a PathP into a transport\nfromPathP : {A : I \u2192 Type \u2113} {x : A i0} {y : A i1}\n          \u2192 PathP A x y\n          \u2192 transport (\u03bb i \u2192 A i) x \u2261 y\nfromPathP {A = A} p i = {!!}\n\n\n-- The converse is harder to prove so we give it:\ntoPathP : {A : I \u2192 Type \u2113} {x : A i0} {y : A i1}\n        \u2192 transport (\u03bb i \u2192 A i) x \u2261 y\n        \u2192 PathP A x y\ntoPathP {A = A} {x = x} p i =\n  hcomp (\u03bb j \u2192 \u03bb { (i = i0) \u2192 x\n                 ; (i = i1) \u2192 p j })\n        (transp (\u03bb j \u2192 A (i \u2227 j)) (~ i) x)\n\n\n-- Exercise* 6: prove that two \u03a3-types where the second component is a\n-- proposition is equal if the first projections are equal.\n-- (hint: use \u03a3PathP and toPathP)\n\u03a3\u2261Prop : {B : A \u2192 Type \u2113'} {u v : \u03a3 A B} (h : (x : A) \u2192 isProp (B x))\n       \u2192 (p : fst u \u2261 fst v) \u2192 u \u2261 v\n\u03a3\u2261Prop {B = B} {u = u} {v = v} h p = {!!}\n\n-- Exercice 7 (harder): prove that being contractible is a proposition.\n-- (hint: the second component can be given by a suitable higher\n-- dimensional hcomp)\nisPropIsContr : isProp (isContr A)\nisPropIsContr = {!!}\n\n\n\n\n-- Exercises about Part 3:\n\n-- Exercise* 8: compose sucPathInt with itself n times. Transporting\n-- along this will be addition, transporting with it backwards will be\n-- subtraction.\n\nopen import Cubical.Data.Nat\nopen import Cubical.Data.Int hiding (addEq ; subEq)\n\n-- a) Define a path \"addEq n\" by composing sucPathInt with itself n times.\naddEq : \u2115 \u2192 Int \u2261 Int\naddEq n = {!!}\n\n-- b) Define another path \"subEq n\" by composing \"sym sucPathInt\" with\n-- itself n times.\nsubEq : \u2115 \u2192 Int \u2261 Int\nsubEq n = {!!}\n\n-- c) Define addition on integers by pattern-matching and transporting\n-- along addEq/subEq appropriately.\n_+Int_ : Int \u2192 Int \u2192 Int\nm +Int n = {!!}\n\n-- d) Do some concrete computations using _+Int_ (this would not work\n-- in HoTT as the transport would be stuck!)\n\n-- e) Use isEquivTransport from\n\nopen import Cubical.Foundations.Transport\n\n-- to prove that +Int with a fixed number is an equivalence.\n--\n-- Note that proving this for the usual _+_ function would be a lot\n-- longer, but now we get it for free as addition is defined using\n-- transport which we already know is an equivalence.\n\n-- Exercise* 9 (harder): prove that hSet is not a set\n\n-- Let's import Bool instead so that we get it from the library\nopen import Cubical.Data.Bool renaming (notEq to notPath)\n\n-- The empty type \u22a5 (written \\bot)\nopen import Cubical.Data.Empty\n\n-- Just define hSets of level 0 for simplicity\nhSet : Type\u2081\nhSet = \u03a3[ A \u2208 Type\u2080 ] isSet A\n\n-- Bool is an hSet\nBoolSet : hSet\nBoolSet = Bool , isSetBool\n\n-- (hint: use a suitable nested transport)\nnotPath\u2262refl : (notPath \u2261 refl) \u2192 \u22a5\nnotPath\u2262refl e = true\u2262false {!!}\n\n-- (hint: use notPath\u2262refl and define two elements of BoolSet \u2261\n-- BoolSet, one based on notPath and one based on refl. \u03a3\u2261Prop and\n-- isPropIsSet is probably handy)\n\u00acisSet-hSet : isSet hSet \u2192 \u22a5\n\u00acisSet-hSet h = {!!}\n\n\n\n-- Exercise 10 (more work): prove that FinData and Fin are equivalent\n-- and hence equal. Transport some functions and proofs between the\n-- two.\n\n-- Orderings on \u2115\nopen import Cubical.Data.Nat.Order\n\ndata FinData : \u2115 \u2192 Type\u2080 where\n  zero : {n : \u2115} \u2192 FinData (suc n)\n  suc  : {n : \u2115} (i : FinData n) \u2192 FinData (suc n)\n\nFin : \u2115 \u2192 Type\u2080\nFin n = \u03a3[ k \u2208 \u2115 ] k < n\n", "meta": {"hexsha": "7a02ab01149e022f5d6a4b9ac1029928d357bae1", "size": 4229, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-04-03T16:28:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-03T16:28:06.000Z", "max_issues_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_issues_repo_name": "EgbertRijke/EPIT-2020", "max_issues_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04-cubical-type-theory/material/ExerciseSession2.agda", "max_forks_repo_name": "EgbertRijke/EPIT-2020", "max_forks_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "avg_line_length": 28.0066225166, "max_line_length": 74, "alphanum_fraction": 0.6538188697, "num_tokens": 1353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.903294214513915, "lm_q2_score": 0.8596637505099167, "lm_q1q2_score": 0.7765292922629414}}
{"text": "module relations where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; cong)\nopen import Data.Nat using (\u2115; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm; +-identity\u02b3)\n\ndata _\u2264_ : \u2115 \u2192 \u2115 \u2192 Set where\n  z\u2264n : \u2200 {n : \u2115} \u2192 zero \u2264 n\n  s\u2264s : \u2200 {m n : \u2115} \u2192 m \u2264 n \u2192 suc m \u2264 suc n\n\ninfix 4 _\u2264_\n\nfoo : 2 \u2264 4\nfoo = s\u2264s (s\u2264s z\u2264n)\n\ninv-s\u2264s : \u2200 {m n : \u2115} \u2192 suc m \u2264 suc n \u2192 m \u2264 n\ninv-s\u2264s (s\u2264s m\u2264n) = m\u2264n\n\nbar : 1 \u2264 3\nbar = inv-s\u2264s foo\n", "meta": {"hexsha": "99c017d4ec32c8b881ed28606522a50595fc16df", "size": 465, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/relations.agda", "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plfa/relations.agda", "max_issues_repo_name": "aronerben/agda-playground", "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/relations.agda", "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.1363636364, "max_line_length": 59, "alphanum_fraction": 0.5806451613, "num_tokens": 206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9609517106286378, "lm_q2_score": 0.8080672158638527, "lm_q1q2_score": 0.77651357338729}}
{"text": "module z03-natural-numbers where\n\nopen import bool\nopen import bool-thms using (\ud835\udd39-contra)\nopen import eq\nopen import level\n\n-- p 50\n\ndata \u2115 : Set where\n  zero :     \u2115\n  suc  : \u2115 \u2192 \u2115\n\n-- p 51\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n-------------------------\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  + n =          n\nsuc m + n = suc (m + n) -- recursive call on structurally smaller left side 'm' -- termination\n\n-- p 53\n\n-------------------------\n0+ : \u2200 (x : \u2115)\n   \u2192 0 + x \u2261 x\n0+ _ = refl -- via definitional equality\n\n{- fails because _+_ defined in terms of pattern matching on left arg\n+0 : \u2200 (x : \u2115)\n    \u2192 x + 0 \u2261 x\n+0 _ = refl\n\n-- p 55\n\nsolution is for proof to call itself recursively:\n-------------------------\n-}\n+0 : \u2200 (x : \u2115)\n   \u2192 x + 0 \u2261 x\n\n-- BASE\n+0  zero                = refl -- via definitional equality\n\n-- INDUCTIVE\n-- note: name of 'y' variable, if renamed to 'x', is not same as 'x' in signature\n+0 (suc y) rewrite +0 y = refl\n{-    ^\n      |\n'x' in sig instantiated to 'suc y'\n\nso trying to prove (the goal) : suc y + 0 \u2261 suc y\n\ngoal can be simplified by inductive case of def of _+_\n\nso goal definitionally equal to : suc (y + 0) \u2261 suc y\n\n       rewrite recursive call proves   y + 0  \u2261     y\n\n  type of proof is x + 0 \u2261 x\n  so Agda with replace occurrences of x + 0 with x\n\n                       leaving  : suc  y      \u2261 suc y\n\n-- p 57\n\nPROOF BY INDUCTION: recursive proofs\n\n------------------------------------------------------------------------------\n+ ASSOCIATIVITY\n\nWhen theorem has multiple variables, must decide which one to use for induction.\nGenerally: var used where a recursive fun will patten match on it.\nIf several vars are pattern matched, prefer the one that is matched the most.\n\nSince _+_ matches on 1st arg, then do induction here on 1st arg.\nHere 'x' is matched twice but 'y' only once -- so use 'x'.\n-}\n\n-------------------------\n+assoc : \u2200 (x y z : \u2115)\n       \u2192  x + (y  + z)\n       \u2261 (x +  y) + z\n{-\nBASE case\n  goal: zero + (y + z) \u2261 (zero + y) + z\n  via def/eq\n-}\n+assoc  zero   y z                      = refl\n\n{-\nINDUCTIVE case\n  goal          : suc (x + (y + z)) \u2261 suc ((x + y) + z)\n  need proof of :     (x + (y + z)) \u2261     ((x + y) + z)\n    that is exactly the inductive hypotheses\n    so use rewrite to recursively apply the proof\n-}\n+assoc (suc x) y z rewrite +assoc x y z = refl\n\n------------------------------------------------------------------------------\n-- p 60 + COMMUTATIVITY (rewrite with multiple equations)\n\n-------------------------\n+suc : \u2200 (x y : \u2115) \u2192 x + (suc y) \u2261 suc (x + y)\n+suc  zero   y                  = refl\n+suc (suc x) y rewrite +suc x y = refl\n\n-------------------------\n+comm : \u2200 (x y : \u2115) \u2192 x + y \u2261 y + x\n{-\nBASE\n Goal:         : y \u2261 (y + zero)\n so rewrite right hand side using +0 proof\n simplifies to : y \u2261  y\n-}\n+comm  zero   y rewrite +0 y = refl\n{-\nINDUCTIVE\n Goal : suc (x + y) \u2261 (y + suc x)\n-}\n+comm (suc x) y rewrite +suc y x | +comm x y = refl\n\n------------------------------------------------------------------------------\n-- p 62 MULTIPLICATION\n\n-------------------------\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  * n = zero\nsuc m * n = n + (m * n)\n\n-------------------------\n-- p 63 - right distributivity of * over +\n\n-- variable counts x : 2; y : 1; z : 0 : so use x\n\n*distribr : \u2200 (x y z : \u2115)\n          \u2192 (x + y) * z \u2261 (x * z) + (y * z)\n\n-- BASE\n*distribr  zero   y z = refl\n\n{-\nINDUCTIVE\nGoal:  ((suc x + y) * z)   \u2261 ((suc x * z)  + (y * z))\nGoal: (z + ((x + y) * z)) \u2261 ((z + (x * z)) + (y * z))\n\n*distribr (suc x) y z rewrite *distribr x y z = {!!}\nGoal: (z + ((x * z) + (y * z))) \u2261 ((z + (x * z)) + (y * z))\n      right-associated                left-associated\nso reassociate: to prove\nA + (B + C) \u2261 (A + B) + C\n^    ^   ^\n|    |   |\nz    |   |\n   x * z |\n       y * z\n-}\n*distribr (suc x) y z\n  rewrite\n    *distribr x y z\n  = +assoc z (x * z) (y * z)\n\n------------------------------------------------------------------------------\n-- p 65 * COMMUTATIVITY\n\n-------------------------\n*0 : \u2200 (x : \u2115)\n   \u2192 x * 0 \u2261 0\n\n-- BASE\n*0 zero = refl -- def/eq : (zero * 0) \u2261 0\n{-\nINDUCTIVE\n(suc x * 0) \u2261 0\n    (x * 0) \u2261 0 -- IH\nrewrite\n         0  \u2261 0\n-}\n*0 (suc y) rewrite *0 y = refl\n\n-------------------------\n\n*suc : \u2200 (x y : \u2115) \u2192 x * (suc y) \u2261 x + (x * y)\n{-\nBASE\n         (zero * suc y) \u2261 (zero + (zero * y))\ndef/eq    zero          \u2261  zero\n-}\n*suc zero y = refl\n{-\nINDUCTIVE\n                (suc x *   suc y)   \u2261 (suc   x +   (suc x * y))\ndef/eq    suc  (y + (x *   suc y))  \u2261  suc  (x + (y  + (x * y)))\nrw *suc   suc  (y + (x  + (x * y))) \u2261  suc  (x + (y  + (x * y)))\nrw +assoc suc ((y +  x) + (x * y))  \u2261  suc  (x + (y  + (x * y)))\nrw +assoc suc ((y +  x) + (x * y))  \u2261  suc ((x +  y) + (x * y))\nrw +comm  suc ((x +  y) + (x * y))  \u2261  suc ((x +  y) + (x * y))\n-}\n*suc (suc x) y\n  rewrite\n    *suc   x y\n  | +assoc y x (x * y)\n  | +assoc x y (x * y)\n  | +comm  y x = refl\n\n-------------------------\n\n*comm : \u2200 (x y : \u2115) \u2192 x * y \u2261 y * x\n{-\nBASE\n             (zero * y) \u2261 (y * zero)\ndef/eq        zero      \u2261 (y * zero)\nrs *0         zero      \u2261      zero\n-}\n*comm zero y rewrite *0 y = refl\n{-\nINDUCTIVE\n           (suc x * y)  \u2261 (y *  suc x)\ndef/eq    (y + (x * y)) \u2261 (y *  suc x)\nrw *suc   (y + (x * y)) \u2261 (y + (y * x))\nrw *comm  (y + (y * x)) \u2261 (y + (y * x))\n-}\n*comm (suc x) y\n  rewrite\n    *suc  y x\n  | *comm x y = refl\n\n------------------------------------------------------------------------------\n-- p 66 * ASSOCIATIVITY\n\n*assoc : \u2200 (x y z : \u2115) \u2192 x * (y * z) \u2261 (x * y) * z\n{-\nBASE\n        (zero * (y * z)) \u2261 ((zero * y) * z)\ndef/eq   zero            \u2261   zero\n-}\n*assoc  zero   y z = refl\n{-\nINDUCTIVE\n\n                      (suc x *  (y  * z))  \u2261        ((suc x * y)  * z)\ndef/eq        ((y * z) +  (x *  (y  * z))) \u2261 ((y      +  (x * y)) * z)\nrw *distribr  ((y * z) +  (x *  (y  * z))) \u2261 ((y * z) + ((x * y)  * z))\nrw *assoc     ((y * z) + ((x *   y) * z))  \u2261 ((y * z) + ((x * y)  * z))\n-}\n*assoc (suc x) y z\n  rewrite\n    *distribr y (x * y) z\n  | *assoc x y z = refl\n\n------------------------------------------------------------------------------\n-- p 67 LESS-THEN <\n\n_<_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\n0       <      0  = ff\n0       < (suc y) = tt\n(suc x) < (suc y) = x < y\n(suc x) <      0  = ff\n\n-------------------------\n-- < is TRANSITIVE\n\n{-\nxx : \u2200 {x y z : \u2115}\n   \u2192 x < y\n   \u2192 y < z\n   \u2192 x < z\n\nAbove will not type check because _<_ returns \ud835\udd39 VALUE, not a type\nTypes have type Set in Agda -- \ud835\udd39 is not the same as Set.\nCould define _<_ as a relation: \u2115 \u2192 \u2115 \u2192 Set.\nBut then _<_ could not be used computationally.\nExpressions with type Set describe code -- they are NOT code themselves\n- e.g., cannot pattern-match on expressions of type Set\n        cannot compute with them\nTransitivity theorem is statement about behavior of the PROGRAM _<_.\n-}\n\n-- p 69\n\n-------------------------\n<-0 : \u2200 (x : \u2115) \u2192 x < 0 \u2261 ff\n<-0      0  = refl --  (zero < 0) \u2261 ff; ff \u2261 ff\n<-0 (suc y) = refl -- (suc y < 0) \u2261 ff; ff \u2261 ff\n\n-------------------------\n<-trans : \u2200 {x y z : \u2115}\n        \u2192 x < y \u2261 tt\n        \u2192 y < z \u2261 tt\n        \u2192 x < z \u2261 tt\n{-\n       p1 : (x < zero) \u2261 tt    ; p2 : (zero < z) \u2261 tt      = Goal: (x < z) \u2261 tt\nrw <-0 p1 : ff         \u2261 tt    ; p2 : (0    < z) \u2261 tt      = Goal: (x < z) \u2261 tt\n-}\n<-trans     {x}     {0}         p1 p2 rewrite <-0 x = \ud835\udd39-contra p1\n\n-- can't be called like this so no proof needed\n<-trans     {0} {suc y}     {0} p1 ()\n\n--     p1 : (zero < suc y) \u2261 tt ; p2 : (suc y < suc z) \u2261 tt = Goal: (zero < suc z) \u2261 tt\n<-trans     {0} {suc y} {suc z} p1 p2 = refl\n\n-- can't be called like this so no proof needed\n<-trans {suc x} {suc y}     {0} p1 ()\n\n--     p1 : (suc x < suc y) \u2261 tt; p2 : (suc y < suc z) \u2261 tt = Goal: (suc x < suc z) \u2261 tt\n<-trans {suc x} {suc y} {suc z} p1 p2 = <-trans {x} {y} {z} p1 p2 -- uses IH via recursive call\n\n------------------------------------------------------------------------------\n-- p 71 EQUALITY TEST for \u2115\n{-\nso far, rely on\n- def/eq : done automatically during type checking\n- \u2261      : express, as a TYPE, a proposition that two VALUES are equal\n\nthere are other kinds of equality, e,g.,\n\nCOMPUTATIONAL EQUALITY : tests VALUE equality\n-}\n\n_=\u2115_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\n0     =\u2115     0 = tt\nsuc x =\u2115 suc y = x =\u2115 y\n_     =\u2115     _ = ff\n\n_\u2264_  : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\nx \u2264 y = (x < y) || x =\u2115 y\n\n-------------------------\n\n=\u2115-refl : \u2200 (x : \u2115) \u2192 (x =\u2115 x) \u2261 tt\n=\u2115-refl 0 = refl\n=\u2115-refl (suc x) = (=\u2115-refl x)\n\n-------------------------\n\n-- SOUNDNESS property: things indicated to be true really are true\n=\u2115-to-\u2261 : \u2200 {x y : \u2115} \u2192 x =\u2115 y \u2261 tt \u2192 x \u2261 y\n=\u2115-to-\u2261     {0}     {0} _ = refl\n=\u2115-to-\u2261 {suc x}     {0} ()\n=\u2115-to-\u2261     {0} {suc y} ()\n=\u2115-to-\u2261 {suc x} {suc y} p\n  rewrite\n    =\u2115-to-\u2261 {x} {y} p = refl\n\n-------------------------\n\n=\u2115-from-\u2261 : \u2200 {x y : \u2115}\n          \u2192 x \u2261 y\n          \u2192 x =\u2115 y \u2261 tt\n=\u2115-from-\u2261 {x} refl = =\u2115-refl x\n\n------------------------------------------------------------------------------\n-- p 73 EXERCISES\n\n-- 1 nat-thms\n\n--------------------------------------------------\n-- properties of addition\n--------------------------------------------------\n\n+1 : \u2200 (x : \u2115) \u2192 x + 1 \u2261 suc x\n+1 zero = refl\n+1 (suc n) rewrite +1 n = refl\n\n+perm : \u2200 (x y z : \u2115) \u2192 x + (y + z) \u2261 y + (x + z)\n+perm zero y z = refl\n+perm (suc x) y z -- (suc  x + (y + z)) \u2261 (y + (suc  x + z))\n                  --  suc (x + (y + z)) \u2261 (y +  suc (x + z))\n  rewrite\n    +suc y (x + z) -- suc (x + (y + z)) \u2261 suc (y + (x + z))\n  | +assoc x y z   -- suc ((x + y) + z) \u2261 suc (y + (x + z))\n  | +comm x y      -- suc ((y + x) + z) \u2261 suc (y + (x + z))\n  | +assoc y x z   -- suc ((y + x) + z) \u2261 suc ((y + x) + z)\n  = refl\n\n--------------------------------------------------\n-- properties of multiplication\n--------------------------------------------------\n\n*1 : \u2200 {n : \u2115} \u2192 n * 1 \u2261 n\n*1 {zero} = refl\n*1 {suc n}    -- (suc n * 1) \u2261 suc n\n              -- suc (n * 1) \u2261 suc n\n  rewrite\n    *comm n 1 -- suc (n + 0) \u2261 suc n\n  | +0 n      -- suc  n      \u2261 suc n\n  = refl\n\n--------------------------------------------------\n-- properties of <, \u2264, and =\u2115, iszero\n--------------------------------------------------\n\n0-\u2264 : \u2200 (x : \u2115) \u2192 0 \u2264 x \u2261 tt\n0-\u2264 zero = refl\n0-\u2264 (suc n)      -- (0 \u2264 suc n) \u2261 tt\n  rewrite 0-\u2264 n  --          tt \u2261 tt\n  = refl\n\n=\u2115-sym : \u2200 (x y : \u2115) \u2192 (x =\u2115 y) \u2261 (y =\u2115 x)\n=\u2115-sym zero zero  = refl\n=\u2115-sym (suc x) zero = refl -- (suc x =\u2115 zero) \u2261 (zero =\u2115 suc x);  ff \u2261 ff\n=\u2115-sym zero (suc y) = refl -- (zero =\u2115 suc y) \u2261 (suc y =\u2115 zero);  ff \u2261 ff\n=\u2115-sym (suc x) (suc y) rewrite =\u2115-sym x y = refl\n\n=\u2115-suc : \u2200 (x : \u2115) \u2192 suc x =\u2115 x \u2261 ff\n=\u2115-suc zero = refl\n=\u2115-suc (suc n) rewrite =\u2115-suc n = refl\n\n<-suc : \u2200 (n : \u2115) \u2192 n < suc n \u2261 tt\n<-suc zero = refl\n<-suc (suc n) rewrite <-suc n = refl\n\n-- TODO: understand\nsuc-inj : \u2200 {n m : \u2115} \u2192 suc n \u2261 suc m \u2192 n \u2261 m\nsuc-inj         {0}  {0} _ = refl\nsuc-inj {m = suc m} refl   = refl\n\n<=\u2115ff : \u2200 (x : \u2115) \u2192 0 < x \u2261 tt \u2192 x =\u2115 0 \u2261 ff\n<=\u2115ff (suc x) _ = refl\n\n<\u2264 : \u2200 {n m : \u2115} \u2192 n < m \u2261 tt \u2192 n \u2264 m \u2261 tt\n<\u2264     {0}     {0} _ = refl\n<\u2264 {suc _}     {0} ()\n<\u2264     {0} {suc _} _ = refl\n<\u2264 {suc n} {suc m} p rewrite <\u2264 {n} {m} p = refl\n\n--------------------------------------------------\n-- ordering properties of < and \u2264\u2115\n--------------------------------------------------\n\n<-irrefl : \u2200 (n : \u2115) \u2192 n < n \u2261 ff\n<-irrefl zero = refl\n<-irrefl (suc n) rewrite <-irrefl n = refl\n\n<-asym : \u2200 {x y : \u2115}\n       \u2192 x < y \u2261 tt\n       \u2192 y < x \u2261 ff\n<-asym {0}         {0} _ = refl\n<-asym {0}     {suc _} _ = refl\n<-asym {suc _}     {0}     ()\n<-asym {suc x} {suc y} p = <-asym {x} {y} p\n\n\u2115-trichotomy\ud835\udd39 : \u2200 (n m : \u2115) \u2192 n < m || n =\u2115 m || m < n \u2261 tt\n\u2115-trichotomy\ud835\udd39      0       0  = refl\n\u2115-trichotomy\ud835\udd39      0  (suc m) = refl\n\u2115-trichotomy\ud835\udd39 (suc n)      0  = refl\n\u2115-trichotomy\ud835\udd39 (suc n) (suc m) = \u2115-trichotomy\ud835\udd39 n m\n\n<\u2264-trans : \u2200 {x y z : \u2115}\n         \u2192 x < y \u2261 tt\n         \u2192 y \u2264 z \u2261 tt\n         \u2192 x < z \u2261 tt\n<\u2264-trans     {x}     {0}         p1 _  rewrite <-0 x = \ud835\udd39-contra p1\n<\u2264-trans     {0} {suc y}     {0} _  ()\n<\u2264-trans     {0} {suc y} {suc z} _  _  = refl\n<\u2264-trans {suc x} {suc y}     {0} _  ()\n<\u2264-trans {suc x} {suc y} {suc z} p1 p2 = <\u2264-trans {x} {y} {z} p1 p2\n\n\u2264-refl : \u2200 (x : \u2115) \u2192 x \u2264 x \u2261 tt\n\u2264-refl zero = refl\n\u2264-refl (suc x) rewrite \u2264-refl x = refl\n\n--------------------------------------------------\n-- injectivity properties of addition\n--------------------------------------------------\n\n+inj1 : \u2200 {x y z : \u2115}\n      \u2192 x + y \u2261 x + z\n      \u2192     y \u2261     z\n+inj1 {0} {y} {z} p = p\n+inj1 {suc x} {y} {z} p = +inj1 {x} {y} {z} (suc-inj p)\n\n+inj2 : \u2200 {x y z : \u2115}\n      \u2192 x + z \u2261 y + z\n      \u2192 x     \u2261 y\n+inj2 {x} {y} {z} p        -- p : (x + z) \u2261 (y + z); Goal: x \u2261 y\n  rewrite\n    +comm x z              -- p : (z + x) \u2261 (y + z); Goal: x \u2261 y\n  | +comm y z              -- p : (z + x) \u2261 (z + y); Goal: x \u2261 y\n  = +inj1 {z} {x} {y} p    -- NOTE: '+inj1'\n\n------------------------------------------------------------------------------\n\n-- 2\n\n{- TODO\nnat.agda\n\n>, >= : defined in terms of < and <=\n\nProve versions of theorems like <-trans and <+\n- modified to use _>_ instead of _<_\n\nfor practice writing out formulas in Agda\nsince the proofs can be written just to invoke the theorems dealing with _<_\n-}\n\n_>_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\na > b = b < a\n\n_\u2265_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\na \u2265 b = b \u2264 a\n\n<-trans2 : \u2200 {x y z : \u2115}\n         \u2192 y > x \u2261 tt\n         \u2192 z > y \u2261 tt\n         \u2192 z > x \u2261 tt\n<-trans2 {x} {y} {z} = <-trans {x} {y} {z}\n\n------------------------------------------------------------------------------\n\n-- 3a\n\nf : (n : \u2115) \u2192 \u2115\nf      0  = 1\nf (suc x) = (suc x) * (f x)\n\nf-is-factorial : f 5 \u2261 120\nf-is-factorial = refl\n\n-- 3b\n\nf' : \u2115 \u2192 \ud835\udd39\nfb : \u2115 \u2192 \ud835\udd39\n\n-- is-odd\nf'      0  = ff\nf' (suc x) = fb x\n\n-- is-even\nfb      0  = tt\nfb (suc x) = f' x\n\nf'-is-odd : f' (suc 0) \u2261 tt\nf'-is-odd = refl\n\nfb-is-even : fb (suc (suc 0)) \u2261 tt\nfb-is-even = refl\n", "meta": {"hexsha": "b8ecc2f982821bf43142fcea0d2d821fe50a33ad", "size": 13568, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z03-natural-numbers.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 25.0794824399, "max_line_length": 95, "alphanum_fraction": 0.4037441038, "num_tokens": 5260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797124237605, "lm_q2_score": 0.8519528019683106, "lm_q1q2_score": 0.7762821090961022}}
{"text": "module Misc.PosBinary where  -- Positive Binary Numbers\n\nopen import Data.Nat\nopen import Data.List\nopen import Relation.Binary.PropositionalEquality\n  using (_\u2261_; refl; sym)\n\nopen import Induction.WellFounded\nopen import Induction.Nat using (<-well-founded)\n\ndata Bin+ : Set where\n  [] : Bin+\n  1\u2237_ : Bin+ \u2192 Bin+\n  2\u2237_ : Bin+ \u2192 Bin+\n\ndecimal : Bin+ \u2192 \u2115\ndecimal [] = 0\ndecimal (1\u2237 xs) = 1 + 2 * decimal xs\ndecimal (2\u2237 xs) = 2 + 2 * decimal xs\n\n-- A even/odd view. Surprised that we don't have it in StdLib\n\ndata Div2 : \u2115 \u2192 Set where\n  even : \u2200 n \u2192 Div2 (2 * n)\n  odd  : \u2200 n \u2192 Div2 (1 + 2 * n)\n\nopen import Data.Nat.Properties.Simple using (+-suc)\n  -- +-suc : \u2200 m n \u2192 m + suc n \u2261 suc (m + n)\nopen import Data.Nat.Properties using (m\u2264\u2032m+n)\n  -- m\u2264\u2032m+n : \u2200 m n \u2192 m \u2264\u2032 m + n\n\n_div2 : \u2200 n \u2192 Div2 n\nzero div2 = even 0\nsuc n div2 with n div2\nsuc .(n + (n + 0)) div2       | even n = odd n\nsuc .(suc (n + (n + 0))) div2 | odd n\n      rewrite sym (+-suc n (n + zero)) = even (1 + n)\n\nbin+' : (n : \u2115) \u2192 Acc _<\u2032_ n \u2192 Bin+\nbin+' n _ with n div2\nbin+' .0 _                              | even zero = []\nbin+' .(suc (m + suc (m + 0))) (acc rs) | even (suc m) =\n   2\u2237 bin+' m (rs m (m\u2264\u2032m+n (suc m) _))\nbin+' .(suc (m + (m + 0)))     (acc rs) | odd m  =\n   1\u2237 bin+' m (rs m (m\u2264\u2032m+n (suc m) _))\n\nbin+ : \u2115 \u2192 Bin+\nbin+ n = bin+' n (<-well-founded n)\n\n{-  For reference.\n\nbin' : (n : \u2115) \u2192 Acc _<\u2032_ n \u2192 List \u2115\nbin' n _ with n div2\nbin' .0 (acc rs) | even 0 = []\nbin' .(suc m + (suc m + 0)) (acc rs) | even (suc m) =\n     0 \u2237 bin' m (rs m (m\u2264\u2032m+n (suc m) _))\nbin' .(suc (m + (m + 0))) (acc rs)   | odd m =\n     1 \u2237 bin' m (rs m (m\u2264\u2032m+n (suc m) _))\n\nbin : \u2115 \u2192 List \u2115\nbin n = bin' n (<-well-founded n)\n-}\n\nlInv' : \u2200 n \u2192 (ac : Acc _<\u2032_ n) \u2192 decimal (bin+' n ac) \u2261 n\nlInv' n ac with n div2\nlInv' .0 ac | even zero = refl\nlInv' .(suc (m + suc (m + 0))) (acc rs) | even (suc m)\n  rewrite lInv' m (rs m (m\u2264\u2032m+n (suc m) (suc (m + zero))))\n        | +-suc m (m + 0) = refl\nlInv' .(suc (m + (m + 0))) (acc rs) | odd m\n  rewrite lInv' m (rs m (m\u2264\u2032m+n (suc m) (m + zero))) = refl\n\nlInv : \u2200 n \u2192 decimal (bin+ n) \u2261 n\nlInv n = lInv' n (<-well-founded n)\n", "meta": {"hexsha": "ce3ece786399470079de66c00a77ccfc61e0ba85", "size": 2118, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/Misc/PosBinary.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "legacy/Misc/PosBinary.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "legacy/Misc/PosBinary.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 28.24, "max_line_length": 61, "alphanum_fraction": 0.5226628895, "num_tokens": 901, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218370002787, "lm_q2_score": 0.8418256532040708, "lm_q1q2_score": 0.7760974526358565}}
{"text": "module Nats.Add.Comm where\n\nopen import Equality\nopen import Nats\nopen import Function\n\n------------------------------------------------------------------------\n-- internal stuffs\n\nprivate\n\n  a+0=0+a : \u2200 a \u2192 a + 0 \u2261 a\n  a+0=0+a  zero   = refl\n  a+0=0+a (suc a) = cong suc $ a+0=0+a a\n\n  ++a+b=a+b++ : \u2200 a b \u2192 suc (a + b) \u2261 a + suc b\n  ++a+b=a+b++  zero   b = refl\n  ++a+b=a+b++ (suc a) b = cong suc $ ++a+b=a+b++ a b\n\n  a+b=b+a : \u2200 a b \u2192 a + b \u2261 b + a\n  a+b=b+a zero b = sym (a+0=0+a b)\n  a+b=b+a (suc a) b = suc (a + b) \u2261\u27e8 cong suc (a+b=b+a a b) \u27e9 ++a+b=a+b++ b a\n\n------------------------------------------------------------------------\n-- public aliases\n\nnat-add-comm : \u2200 a b \u2192 a + b \u2261 b + a\nnat-add-comm = a+b=b+a\n", "meta": {"hexsha": "7b6f1464f23ebfe28254b968d1919ba464ff58a6", "size": 718, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Nats/Add/Comm.agda", "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_issues_repo_path": "src/Nats/Add/Comm.agda", "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Nats/Add/Comm.agda", "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.7586206897, "max_line_length": 77, "alphanum_fraction": 0.3997214485, "num_tokens": 262, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9518632343454896, "lm_q2_score": 0.8152324960856175, "lm_q1q2_score": 0.7759898404676026}}
{"text": "-- agad-mode\u306e\u4f7f\u3044\u65b9\n-- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html\n{-# OPTIONS --without-K --safe #-}\nmodule Learn.Interactive where\n\n-- \u30ed\u30fc\u30c9\n-- \u30bf\u30a4\u30d7\u30c1\u30a7\u30c3\u30af\u3059\u308b\n-- C-c C-l\n-- Ctrl\u3092\u62bc\u3057\u306a\u304c\u3089\u3001c\u3092\u62bc\u3057\u3066\u6b21\u306bl\u3092\u62bc\u3059\n-- \u3053\u306e\u3068\u304d\u3001\u30bd\u30fc\u30b9\u5185\u306b\"?\"\u304c\u5b58\u5728\u3059\u308c\u3070\u305d\u308c\u3092\u30b4\u30fc\u30eb\u306b\u3059\u308b\n-- \u30b4\u30fc\u30eb\u306b\u306f\u756a\u53f7\u304c\u632f\u3089\u308c\u308b\n\n-- \u578b\u63a8\u8ad6\u3059\u308b\n-- C-c C-d\n\n-- \u8a55\u4fa1\u3059\u308b\n-- C-c C-n\n\n-- \u7d42\u4e86\u3055\u305b\u308b\n-- C-c C-x C-q\n-- Ctrl\u3092\u62bc\u3057\u306a\u304c\u3089\u3001c\u3001x\u3001q\u3068\u62bc\u3059\n\n-- \u518d\u30b9\u30bf\u30fc\u30c8\u3055\u305b\u308b\n-- C-c C-x C-r\n\n----------------------------------------------------------------------------\n-- \u30b4\u30fc\u30eb\u3078\u306e\u64cd\u4f5c\n-- \u30b4\u30fc\u30eb\u5185\u306b\u5024\u3092\u66f8\u3044\u3066\u304b\u3089\u30b4\u30fc\u30eb\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b\u5b9f\u884c\u3059\u308b\u3002\n\n-- \u4e0e\u3048\u308b\n-- C-c C-SPC\n-- Ctrl\u3092\u62bc\u3057\u306a\u304c\u3089\u3001c\u3092\u62bc\u3057\u3066\u6b21\u306b\u30b9\u30da\u30fc\u30b9\u3092\u62bc\u3059\n-- \u578b\u304c\u5408\u3063\u3066\u3044\u308c\u3070\u30b4\u30fc\u30eb\u306f\u6d88\u3048\u308b\n\n-- \u30ea\u30d5\u30a1\u30a4\u30f3\n-- C-c C-r\n-- \u4f55\u3082\u306a\u3044\u72b6\u614b\u3067\u884c\u3046\u3068\u95a2\u6570\u306a\u3089\u30e9\u30e0\u30c0\u3001\u30ec\u30b3\u30fc\u30c9\u578b\u306a\u3089\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u633f\u5165\u3059\u308b\n-- \u30b4\u30fc\u30eb\u306b\u95a2\u6570\u304c\u3042\u308b\u5834\u5408\u3001\u95a2\u6570\u306e\u5f15\u6570\u3092\u30b4\u30fc\u30eb\u306b\u3059\u308b\n\n-- \u30b1\u30fc\u30b9\u30b9\u30d7\u30ea\u30c3\u30c8\n-- C-c C-c\n-- \u30b4\u30fc\u30eb\u5185\u306b\u5909\u6570\u3092\u66f8\u304f\u3001\u307e\u305f\u306fC-c C-c\u3057\u3066\u51fa\u3066\u304d\u305f\u5165\u529b\u67a0\u306b\u5909\u6570\u3092\u5165\u529b\u3059\u308b\u3068\n-- \u305d\u306e\u5909\u6570\u3067\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u3092\u884c\u3046\n\n-- \u30b4\u30fc\u30eb\u306e\u578b\u3092\u78ba\u8a8d\u3059\u308b\n-- C-c C-t\n\n-- \u74b0\u5883\u3092\u78ba\u8a8d\u3059\u308b\n-- C-c C-e\n\n----------------------------------------------------------------------------\n-- \u81ea\u7136\u6570\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n-- \u7b49\u4fa1\u6027\ninfix 3 _\u2261_\ndata _\u2261_ {A : Set} (x : A) : A \u2192 Set where\n  refl : x \u2261 x\n\ncong : \u2200 {A B : Set} (f : A \u2192 B) {x y} \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\n-- \u8db3\u3057\u7b97\n-- \u53f3\u8fba\u306b?\u3068\u66f8\u3044\u3066C-c C-l(\u30ed\u30fc\u30c9)\u3059\u308b\n-- \u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u7121\u8996\u3067\nmodule Step1 where\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  m + n = {!   !}\n\n-- \u30b4\u30fc\u30eb\u306b\"m\"\u3068\u5165\u529b\u3059\u308b\nmodule Step2 where\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  m + n = {! m  !}\n\n--\u3000\u30b4\u30fc\u30eb\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b C-c C-c (\u30b1\u30fc\u30b9\u30b9\u30d7\u30ea\u30c3\u30c8)\u3059\u308b\nmodule Step3 where\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  zero + n = {!   !}\n  suc m + n = {!   !}\n\n-- \u30a4\u30f3\u30c7\u30f3\u30c8\u3092\u6574\u3048\u308b\nmodule Step4 where\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  zero  + n = {!   !}\n  suc m + n = {!   !}\n\n-- \u30b4\u30fc\u30eb\u5185\u306b\u53f3\u8fba\u5024\u3092\u66f8\u304f\nmodule Step5 where\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  zero  + n = {! zero  !}\n  suc m + n = {!   !}\n\n-- \u30b4\u30fc\u30eb\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b C-c C-SPC (Give)\u3059\u308b\nmodule Step6 where\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  zero  + n = zero\n  suc m + n = {!   !}\n\n-- \u3082\u3046\u4e00\u65b9\u306e\u30b4\u30fc\u30eb\u3082\u540c\u69d8\u306b\u3059\u308b\n-- \u3053\u306e\u3068\u304dm\u306f\u518d\u5e30\u7684\u306a\u547c\u3073\u51fa\u3057\u3092\u3059\u308b\u3068\u304d\u306b\u5c0f\u3055\u304f\u306a\u3063\u3066\u3044\u308b\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  + n = zero\nsuc m + n = suc (m + n)\n\n-- +\u306e\u7d50\u5408\u6027\n-- \u8a3c\u660e\u3057\u305f\u3044\u578b\u3092\u66f8\u304f\u3002\u53f3\u8fba\u3092?\u306b\u3057\u3066\u30b4\u30fc\u30eb\u306b\u3059\u308b\nmodule Assoc1 where\n  +-assoc : \u2200 m n o \u2192 (m + n) + o \u2261 m + (n + o)\n  +-assoc m n o = {!   !}\n\n-- \u3053\u306e\u3068\u304d+\u306e\u5b9a\u7fa9\u304b\u3089+\u306e\u5de6\u306e\u5909\u6570\u3067\u5e30\u7d0d\u3059\u308b\u3068\u3088\u3044\u3068\u308f\u304b\u308b\n-- \u5358\u4e00\u306e\u5909\u6570\u3067\u3042\u308b\u306a\u3089\u3070\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u3067\u304d\u308b\u306e\u3067m\u3092\u9078\u3073\u30b4\u30fc\u30eb\u306b\u66f8\u304f\nmodule Assoc2 where\n  +-assoc : \u2200 m n o \u2192 (m + n) + o \u2261 m + (n + o)\n  +-assoc m n o = {! m  !}\n\n-- C-c C-c\u3059\u308b\n-- \u3053\u3053\u3067 +-assoc zero n o \u306e\u53f3\u8fba\u306e\u30b4\u30fc\u30eb\u3067C-c C-t\u3059\u308b\u3068\u3000zero \u2261 zero \u3068\u308f\u304b\u308b\n-- \u540c\u3058\u5f62\u306a\u3089refl\u304c\u4f7f\u3048\u308b\u306e\u3067refl\u3092C-c C-SPC\u3059\u308b\nmodule Assoc3 where\n  +-assoc : \u2200 m n o \u2192 (m + n) + o \u2261 m + (n + o)\n  +-assoc zero    n o = refl\n  +-assoc (suc m) n o = {!   !}\n\n-- \u6b21\u306b +-assoc (suc m) n o \u306e\u53f3\u8fba\u3067C-c C-t\u3059\u308b\u3068\n-- suc ((m + n) + o) \u2261 suc (m + (n + o)) \u3068\u308f\u304b\u308b\n-- \u4e21\u8fba\u306b\u540c\u3058\u95a2\u6570\uff08suc\uff09\u304c\u639b\u304b\u3063\u3066\u3044\u308b\u306e\u3067cong\u304c\u4f7f\u3048\u308b\n-- cong\u3068\u30b4\u30fc\u30eb\u5185\u306b\u66f8\u304f\nmodule Assoc4 where\n  +-assoc : \u2200 m n o \u2192 (m + n) + o \u2261 m + (n + o)\n  +-assoc zero    n o = refl\n  +-assoc (suc m) n o = {!cong   !}\n\n-- C-c C-r\u3059\u308b\u3068\u30b4\u30fc\u30eb\u304c\u5206\u304b\u308c\u308b\n-- \u524d\u306fsuc\u3092\u4e0e\u3048\u308b\nmodule Assoc5 where\n  +-assoc : \u2200 m n o \u2192 (m + n) + o \u2261 m + (n + o)\n  +-assoc zero    n o = refl\n  +-assoc (suc m) n o = cong suc {!   !}\n\n-- \u5f8c\u308d\u306f+-assoc m n o\u306e\u578b\u3068\u540c\u3058\u306a\u306e\u3067\u305d\u308c\u3092\u4e0e\u3048\u308b\n-- \u3053\u308c\u3067\u8a3c\u660e\u7d42\u4e86\nmodule Assoc6 where\n  +-assoc : \u2200 m n o \u2192 (m + n) + o \u2261 m + (n + o)\n  +-assoc zero    n o = refl\n  +-assoc (suc m) n o = cong suc (+-assoc m n o)\n", "meta": {"hexsha": "ebe13bcc8c0492b1a2da3128e5c14745c0a7ba29", "size": 2957, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Learn/Interactive.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Learn/Interactive.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Learn/Interactive.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.8456375839, "max_line_length": 76, "alphanum_fraction": 0.5262089956, "num_tokens": 1652, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297941266014, "lm_q2_score": 0.8615382094310357, "lm_q1q2_score": 0.7758408263711313}}
{"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule Quicksort.Correctness.Order {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_)\n                  (trans\u2264 : Transitive _\u2264_)  where\n\nopen import Data.List\nopen import Function using (_\u2218_)\nopen import List.Sorted _\u2264_\nopen import Quicksort _\u2264_ tot\u2264\nopen import SBList _\u2264_\nopen import Size\nopen import SOList.Total _\u2264_\nopen import SOList.Total.Properties _\u2264_ trans\u2264\n\ntheorem-quickSort-sorted : (xs : List A) \u2192 Sorted (forget (quickSort (bound xs)))\ntheorem-quickSort-sorted = lemma-solist-sorted \u2218 quickSort \u2218 bound\n", "meta": {"hexsha": "42cfa525b7173a288cab7ed85298efae71ace757", "size": 616, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Quicksort/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/Quicksort/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/Quicksort/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.8, "max_line_length": 81, "alphanum_fraction": 0.6672077922, "num_tokens": 178, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172572644806, "lm_q2_score": 0.8175744673038222, "lm_q1q2_score": 0.7758105211234118}}
{"text": "module plfa.working.Naturals where\n\n    data \u2115 : Set where\n      zero : \u2115\n      suc : \u2115 \u2192 \u2115\n\n    seven : \u2115\n    seven = suc(suc(suc(suc(suc(suc(suc(zero)))))))\n\n    {-# BUILTIN NATURAL \u2115 #-}\n\n    import Relation.Binary.PropositionalEquality as Eq\n    open Eq using (_\u2261_; refl)\n    open Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e)\n\n\n    _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n    zero + n = n\n    (suc m) + n = suc(m + n)\n\n\n    _ : 2 + 3 \u2261 5\n    _ =\n      begin\n        2 + 3\n      \u2261\u27e8\u27e9\n        (suc (suc zero)) + (suc (suc (suc zero)))\n      \u2261\u27e8\u27e9\n        suc( (suc zero) + (suc (suc (suc zero))))\n      \u2261\u27e8\u27e9\n        (suc(suc (zero + (suc (suc (suc zero))))))\n      \u2261\u27e8\u27e9\n        (suc (suc (suc (suc (suc zero)))))\n      \u2261\u27e8\u27e9\n        5\n      \u220e\n\n    _ : 2 + 3 \u2261 5\n    _ =\n      begin\n        2 + 3\n      \u2261\u27e8\u27e9\n        suc (1 + 3)\n      \u2261\u27e8\u27e9\n        suc (suc (0 + 3))\n      \u2261\u27e8\u27e9\n        suc (suc 3)\n      \u2261\u27e8\u27e9\n        5\n      \u220e\n\n    _ : 3 + 4 \u2261 7\n    _ =\n      begin\n        3 + 4\n      \u2261\u27e8\u27e9\n        suc (2 + 4)\n      \u2261\u27e8\u27e9\n        suc (2 + (suc 3))\n      \u2261\u27e8\u27e9\n        suc (suc (2 + 3))\n      \u2261\u27e8\u27e9\n        suc (suc  5)\n      \u2261\u27e8\u27e9\n        7\n      \u220e\n\n    _*_ : \u2115 \u2192 \u2115 \u2192 \u2115\n    zero * n = zero\n    (suc m) * n = n + (n * m)\n\n\n    _ : 3 * 4 \u2261 12\n    _ =\n      begin\n        3 * 4\n      \u2261\u27e8\u27e9\n        (suc 2) * 4\n      \u2261\u27e8\u27e9\n        4 + (4 * 2)\n      \u2261\u27e8\u27e9\n        4 + ((suc 3) * 2)\n      \u2261\u27e8\u27e9\n        4 + (2 + (2 * 3))\n      \u2261\u27e8\u27e9\n        4 + (2 + (suc 1 * 3))\n      \u2261\u27e8\u27e9\n        4 + (2 + (3 + (3 * 1)))\n      \u2261\u27e8\u27e9\n        4 + (2 + (3 + (suc 2 * 1)))\n      \u2261\u27e8\u27e9\n        4 + (2 + (3 + (1 + (1 * 2))))\n      \u2261\u27e8\u27e9\n        12\n      \u220e\n\n    _^_ : \u2115 \u2192 \u2115 \u2192 \u2115\n    n ^ zero = suc zero\n    n ^ (suc m) = n * (n ^ m)\n\n    _ : 3 ^ 4 \u2261 81\n    _ =\n      begin\n        3 ^ 4\n      \u2261\u27e8\u27e9\n        3 ^ (1 + 3)\n      \u2261\u27e8\u27e9\n        3 * (3 ^ 3)\n      \u2261\u27e8\u27e9\n        3 * (3 * (3 ^ 2))\n      \u2261\u27e8\u27e9\n        3 * (3 * (3 * (3 ^ 1)))\n      \u2261\u27e8\u27e9\n        3 * (3 * (3 * 3))\n      \u2261\u27e8\u27e9\n        81\n      \u220e\n\n    _\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\n    m \u2238 zero = m\n    zero \u2238 suc n = zero\n    suc m \u2238 suc n = m \u2238 n\n\n    _ : 5 \u2238 3 \u2261 2\n    _ =\n      begin\n        5 \u2238 3\n      \u2261\u27e8\u27e9\n        (1 + 4) \u2238 (1 + 2)\n      \u2261\u27e8\u27e9\n        4 \u2238 2\n      \u2261\u27e8\u27e9\n        3 \u2238 1\n      \u2261\u27e8\u27e9\n        2 \u2238 0\n      \u2261\u27e8\u27e9\n        2\n      \u220e\n\n    _ : 2 \u2238 5 \u2261 0\n    _ =\n      begin\n        2 \u2238 5\n      \u2261\u27e8\u27e9\n        1 \u2238 4\n      \u2261\u27e8\u27e9\n        0 \u2238 3\n      \u2261\u27e8\u27e9\n        0\n      \u220e\n\n    data Bin : Set where\n      \u27e8\u27e9 : Bin\n      _O : Bin \u2192 Bin\n      _I : Bin \u2192 Bin\n\n    inc : Bin \u2192 Bin\n    inc \u27e8\u27e9 = \u27e8\u27e9 I\n    inc (p O) = p I\n    inc (p I) = (inc p) O\n\n    _ : inc (\u27e8\u27e9 O O O O) \u2261 \u27e8\u27e9 O O O I\n    _ = refl\n\n    _ : inc (\u27e8\u27e9 O O O I) \u2261 \u27e8\u27e9 O O I O\n    _ = refl\n\n    _ : inc (\u27e8\u27e9 O O I O) \u2261 \u27e8\u27e9 O O I I\n    _ = refl\n\n    _ : inc (\u27e8\u27e9 O O I I) \u2261 \u27e8\u27e9 O I O O\n    _ = refl\n\n    _ : inc (\u27e8\u27e9 I O I I) \u2261 \u27e8\u27e9 I I O O\n    _ = refl\n\n    to : \u2115 \u2192 Bin\n    to zero = \u27e8\u27e9 O\n    to (suc n) = inc (to n)\n\n    from : Bin \u2192 \u2115\n    from \u27e8\u27e9 = zero\n    from (p O) = from p * 2\n    from (p I) = suc ((from p) * 2)\n\n    _ : to 3 \u2261 \u27e8\u27e9 I I\n    _ = refl\n\n    _ : from (\u27e8\u27e9 I I) \u2261 3\n    _ = refl\n", "meta": {"hexsha": "35077b0bf60002b445a1c6cc16fd55efa3d8140d", "size": 2974, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/working/Naturals.agda", "max_stars_repo_name": "kaychaks/plfa.github.io", "max_stars_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/working/Naturals.agda", "max_issues_repo_name": "kaychaks/plfa.github.io", "max_issues_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/working/Naturals.agda", "max_forks_repo_name": "kaychaks/plfa.github.io", "max_forks_repo_head_hexsha": "5365a4ba8ba0dc80cb77ab73aee92c645d0787d9", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.5706806283, "max_line_length": 54, "alphanum_fraction": 0.284129119, "num_tokens": 1444, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009480320036, "lm_q2_score": 0.847967764140929, "lm_q1q2_score": 0.7758065113131144}}
{"text": "module Nat where\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + a = a\nsuc a + b = suc (a + b)\n\ndata _\u2261_ {A : Set} : A \u2192 A \u2192 Set where\n   refl : {a : A} \u2192 a \u2261 a\n\ninfix 4 _\u2261_\n\ncong : {A B : Set} {a b : A} (f : A \u2192 B) \u2192 a \u2261 b \u2192 f a \u2261 f b\ncong f refl = refl\n\n+-assoc : (a b c : \u2115) \u2192 (a + b) + c \u2261 a + (b + c)\n+-assoc zero b c = refl\n+-assoc (suc a) b c = cong suc (+-assoc a b c)\n", "meta": {"hexsha": "cba1fa9dbd68d565381e97c46eed596ce5ac9d38", "size": 398, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Nat.agda", "max_stars_repo_name": "divipp/agda-intro-prezi", "max_stars_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-11-27T02:50:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-21T14:53:25.000Z", "max_issues_repo_path": "Nat.agda", "max_issues_repo_name": "divipp/agda-intro-prezi", "max_issues_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Nat.agda", "max_forks_repo_name": "divipp/agda-intro-prezi", "max_forks_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.0909090909, "max_line_length": 60, "alphanum_fraction": 0.4623115578, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.965899575269305, "lm_q2_score": 0.803173801068221, "lm_q1q2_score": 0.775785233319228}}
{"text": "------------------------------------------------------------------------------\n-- Axiomatic PA properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule PA.Axiomatic.Standard.PropertiesI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import PA.Axiomatic.Standard.Base\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\nsuccCong : \u2200 {m n} \u2192 m \u2261 n \u2192 succ m \u2261 succ n\nsuccCong refl = refl\n\n+-leftCong : \u2200 {m n o} \u2192 m \u2261 n \u2192 m + o \u2261 n + o\n+-leftCong refl = refl\n\n+-rightCong : \u2200 {m n o} \u2192 n \u2261 o \u2192 m + n \u2261 m + o\n+-rightCong refl = refl\n\n------------------------------------------------------------------------------\n\n+-leftIdentity : \u2200 n \u2192 zero + n \u2261 n\n+-leftIdentity = PA\u2083\n\n+-rightIdentity : \u2200 n \u2192 n + zero \u2261 n\n+-rightIdentity = \u2115-ind A A0 is\n  where\n  A : \u2115 \u2192 Set\n  A i = i + zero \u2261 i\n\n  A0 : A zero\n  A0 = +-leftIdentity zero\n\n  is : \u2200 i \u2192 A i \u2192 A (succ i)\n  is i ih = succ i + zero   \u2261\u27e8 PA\u2084 i zero \u27e9\n            succ (i + zero) \u2261\u27e8 succCong ih \u27e9\n            succ i          \u220e\n\n+-asocc : \u2200 m n o \u2192 m + n + o \u2261 m + (n + o)\n+-asocc m n o = \u2115-ind A A0 is m\n  where\n  A : \u2115 \u2192 Set\n  A i = i + n + o \u2261 i + (n + o)\n\n  A0 : A zero\n  A0 = zero + n + o   \u2261\u27e8 +-leftCong (+-leftIdentity n) \u27e9\n       n + o          \u2261\u27e8 sym (+-leftIdentity (n + o)) \u27e9\n       zero + (n + o) \u220e\n\n  is : \u2200 i \u2192 A i \u2192 A (succ i)\n  is i ih = succ i + n + o     \u2261\u27e8 +-leftCong (PA\u2084 i n) \u27e9\n            succ (i + n) + o   \u2261\u27e8 PA\u2084 (i + n) o \u27e9\n            succ (i + n + o)   \u2261\u27e8 succCong ih \u27e9\n            succ (i + (n + o)) \u2261\u27e8 sym (PA\u2084 i (n + o)) \u27e9\n            succ i + (n + o)   \u220e\n\nx+Sy\u2261S[x+y] : \u2200 m n \u2192 m + succ n \u2261 succ (m + n)\nx+Sy\u2261S[x+y] m n = \u2115-ind A A0 is m\n  where\n  A : \u2115 \u2192 Set\n  A i = i + succ n \u2261 succ (i + n)\n\n  A0 : A zero\n  A0 = zero + succ n   \u2261\u27e8 +-leftIdentity (succ n) \u27e9\n       succ n          \u2261\u27e8 succCong (sym (+-leftIdentity n)) \u27e9\n       succ (zero + n) \u220e\n\n  is : \u2200 i \u2192 A i \u2192 A (succ i)\n  is i ih = succ i + succ n     \u2261\u27e8 PA\u2084 i (succ n) \u27e9\n            succ (i + succ n)   \u2261\u27e8 succCong ih \u27e9\n            succ (succ (i + n)) \u2261\u27e8 succCong (sym (PA\u2084 i n)) \u27e9\n            succ (succ i + n)   \u220e\n\n+-comm : \u2200 m n \u2192 m + n \u2261 n + m\n+-comm m n = \u2115-ind A A0 is m\n  where\n  A : \u2115 \u2192 Set\n  A i = i + n \u2261 n + i\n\n  A0 : A zero\n  A0 = zero + n \u2261\u27e8 +-leftIdentity n \u27e9\n       n        \u2261\u27e8 sym (+-rightIdentity n) \u27e9\n       n + zero \u220e\n\n  is : \u2200 i \u2192 A i \u2192 A (succ i)\n  is i ih = succ i + n   \u2261\u27e8 PA\u2084 i n \u27e9\n            succ (i + n) \u2261\u27e8 succCong ih \u27e9\n            succ (n + i) \u2261\u27e8 sym (x+Sy\u2261S[x+y] n i) \u27e9\n            n + succ i   \u220e\n", "meta": {"hexsha": "f884f7fa85c7226fc6b40bcbb94bcac94459118a", "size": 2747, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Axiomatic/Standard/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Axiomatic/Standard/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Axiomatic/Standard/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 28.0306122449, "max_line_length": 78, "alphanum_fraction": 0.4022570076, "num_tokens": 1004, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897442783526, "lm_q2_score": 0.824461928533133, "lm_q1q2_score": 0.7756453269119237}}
{"text": "module List.Order.Bounded {A : Set}(_\u2264_ : A \u2192 A \u2192 Set)  where\n\nopen import Bound.Total A\nopen import Bound.Total.Order _\u2264_\nopen import Data.List\n\ndata _\u2264*_ : List A \u2192 Bound \u2192 Set where\n  lenx : {t : Bound} \u2192 [] \u2264* t\n  lecx : {t : Bound}{x : A}{xs : List A} \u2192 LeB (val x) t \u2192 xs \u2264* t \u2192 (x \u2237 xs) \u2264* t\n\ndata _*\u2264_ : Bound \u2192 List A \u2192 Set where\n  genx : {b : Bound} \u2192 b *\u2264 []\n  gecx : {b : Bound}{x : A}{xs : List A} \u2192 LeB b (val x) \u2192 b *\u2264 xs \u2192 b *\u2264 (x \u2237 xs)\n", "meta": {"hexsha": "05b689d82ee781ee9b1f03d25629876fb9d5a3d4", "size": 453, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Order/Bounded.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Order/Bounded.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Order/Bounded.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3571428571, "max_line_length": 82, "alphanum_fraction": 0.5342163355, "num_tokens": 188, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9626731169394881, "lm_q2_score": 0.8056321959813275, "lm_q1q2_score": 0.7755604572121491}}
{"text": "module Id1 where\n\nimport Level\nopen import Data.Empty using (\u22a5)\nopen import Data.Unit using (\u22a4)\nopen import Data.Bool using (Bool)\nopen import Data.Sum using (_\u228e_)\nopen import Data.Nat \nopen import Data.Product\nopen import Data.Vec \nopen import Function using (id)\n\n-- Study identity types from first principles\n\n-- As we have seen for the previous types, we need to define the type,\n-- its constructors, and then focus on the recursion and induction\n-- principles. All computations and all properties of the identity\n-- type should be derivable from these (recursion and induction)\n-- principles.\n\n------------------------------------------------------------------------------\n\ndata _\u2261_ {A : Set} : (x y : A) \u2192 Set where\n  refl : (x : A) \u2192 x \u2261 x\n\n-- We have to write (refl x) for some x. This is different from the\n-- Agda library which leaves the 'x' implicit\n\ninfix 4 _\u2261_\n\n{-- \nConvention:\nmultiplicative          precedence 7\nadditive                precedence 6\nequality and comparison precedence 4 \n--}\n\n-- Simple examples\n\nprivate\n  p\u2081 : 3 \u2261 3\n  p\u2081 = refl 3\n\n  p\u2082 : 3 * 1 \u2261 1 + 2\n  p\u2082 = refl (4 \u2238 1)\n  \n-- Let's try to derive the recursion principle for identity\n-- types... This type has one constructor just like \u22a4 in some sense.\n-- Recall the recursion principle for \u22a4:\n-- rec\u22a4 : (C : Set) \u2192 C \u2192 (v : \u22a4) \u2192 C\n\n-- So at first approximation, the recursion principle for \u2261 looks like:\n\n-- \n-- rec\u2261 : (C : Set) \u2192 C \u2192 ({A : Set} {x y : A} (p : x \u2261 y) \u2192 C)\n-- \n\n-- In the case of \u22a4, we wanted to map the element of \u22a4 to an element\n-- of C. For \u2261, we also want to map the element of (x \u2261 y) to an\n-- element of C. Note that the element of (x \u2261 y) is some kind of\n-- relation between x and y so it makes sense to insist that the\n-- target C is also a relation between x and y, i.e., we map relations\n-- to relations.\n\n-- So as a second approximation, the recursion principle for \u2261 looks like:\n\n--\n-- rec\u2261 : {A : Set} {x y : A} \u2192 \n--        (R : A \u2192 A \u2192 Set) \u2192 R x y \u2192 (p : x \u2261 y) \u2192 R x y\n-- \n\n-- In the case of \u22a4, the second argument to the recursion operation\n-- specified an element of C which would serve as the target for\n-- tt. Now in the case of \u2261, we want to specify an element of R x y\n-- which would be the target of refl. This requires two adjustments:\n-- first the second argument of type (R x y) makes no sense in general\n-- as we don't want to insist that the relation R is universal (i.e.,\n-- holds between arbitrary x and y). Second we must insist that the\n-- relation R is reflexive. \n\nrec\u2261 : {A : Set} \u2192\n       (R : A \u2192 A \u2192 Set) {reflexiveR : {a : A} \u2192 R a a} \u2192\n       ({x y : A} (p : x \u2261 y) \u2192 R x y)\nrec\u2261 R {reflR} (refl y) = reflR {y}\n\n-- A special case of reflexive relations on A is the class of\n-- functions from C a -> C a for some predicate C. Let's specialize\n-- the above recursion principle to this special case.\n\nrec\u2261S : {A : Set} {C : A \u2192 Set} \u2192\n        ({x y : A} (p : x \u2261 y) \u2192 C x \u2192 C y)\nrec\u2261S {C = C} p = rec\u2261 (\u03bb a b \u2192 C a \u2192 C b) {id} p\n      \n-- Or we can prove the specialized version directly (rename to subst)\n\nsubst : {A : Set} {C : A \u2192 Set} \u2192\n        ({x y : A} (p : x \u2261 y) \u2192 C x \u2192 C y)\nsubst {x = x} {y = .x} (refl .x) = id\n\n-- So the recursion principle for the identity type says\n-- equals may be substituted for equals OR \n-- indiscernability of identicals OR \n-- every type family respects equality\n\n-- Examples:\n\nprivate\n\n  ex\u2081 : \u2200 {n} \u2192 (p : n + 0 \u2261 n) \u2192 (n + 0 > 0) \u2192 (n > 0) \n  ex\u2081 {n} p = subst {C = \u03bb m \u2192 m > 0} {n + 0} {n} p\n\n  ex\u2082 : \u2200 {A n} \u2192 (p : n + 0 \u2261 n) \u2192 (Vec A (n + 0)) \u2192 (Vec A n)\n  ex\u2082 {A} {n} p = subst {C = \u03bb m \u2192 Vec A m} {n + 0} {n} p\n\n  {-- \n\n  From Data.Nat library:\n\n  data _\u2264_ : Rel \u2115 Level.zero where\n    z\u2264n : \u2200 {n}                 \u2192 zero  \u2264 n\n    s\u2264s : \u2200 {m n} (m\u2264n : m \u2264 n) \u2192 suc m \u2264 suc n\n\n  --}\n\n  \u2264-reflexive : {a : \u2115} \u2192 a \u2264 a\n  \u2264-reflexive {zero} = z\u2264n \n  \u2264-reflexive {suc a} = s\u2264s (\u2264-reflexive {a}) \n\n  ex\u2083 : \u2200 {n} \u2192 (p : n + 0 \u2261 n) \u2192 (n + 0 \u2264 n)\n  ex\u2083 {n} = rec\u2261 {\u2115} (_\u2264_) {\u2264-reflexive} {n + 0} {n}\n\n------------------------------------------------------------------------------\n-- Now let's look at the induction principle for identity types\n\n-- Our usual idiom is to use the same code for the recursion principle\n-- and just make the eliminator a dependent function\n\n-- Let's look at rec\u2261 again\n\n-- rec\u2261 : {A : Set} \u2192\n--        (R : A \u2192 A \u2192 Set) {reflexiveR : {a : A} \u2192 R a a} \u2192\n--        ({x y : A} (p : x \u2261 y) \u2192 R x y)\n-- rec\u2261 R {reflR} (refl y) = reflR {y}\n\n-- The relation R is already dependent on x and y; we just need to\n-- make it dependent on p too\n\nind\u2261 : {A : Set} \u2192 \n       (R : (x : A) \u2192 (y : A) \u2192 (p : x \u2261 y) \u2192 Set)\n       {reflexiveR : {a : A} \u2192 R a a (refl a)} \u2192\n       ({x y : A} (p : x \u2261 y) \u2192 R x y p)\nind\u2261 R {reflR} (refl y) = reflR {y}\n\n-- Changing some implicit argument to being explicit and vice-versa,\n-- and changing names of bound variables we get:\n\nJ : {A : Set} \u2192\n    (R : {x y : A} \u2192 (p : x \u2261 y) \u2192 Set)\n    (r : (a : A) \u2192 R (refl a)) \u2192\n    ({a b : A} (p : a \u2261 b) \u2192 R p)\nJ R r (refl y) = r y\n\n-- Examples\n\nsym : {A : Set} {x y : A} \u2192 (x \u2261 y) \u2192 (y \u2261 x)\nsym = J (\u03bb {x} {y} p \u2192 y \u2261 x) (\u03bb a \u2192 refl a)\n\n-- Next we want to prove:\n-- trans : {A : Set} {x y z : A} \u2192 (x \u2261 y) \u2192 (y \u2261 z) \u2192 (x \u2261 z)\n-- if we try to directly use J we discover that the definition of R \n-- (\u03bb {x} {y} p \u2192 y \u2261 z \u2192 x \u2261 z)\n-- refers to an unbound z\n\ntrans' : {A : Set} {x y : A} \u2192 (x \u2261 y) \u2192 ((z : A) \u2192 (q : y \u2261 z) \u2192 (x \u2261 z))\ntrans' {A} = \n  J (\u03bb {x} {y} p \u2192 ((z : A) \u2192 (q : y \u2261 z) \u2192 (x \u2261 z)))\n    (\u03bb a z \u2192 id)\n\n-- then\n\ntrans : {A : Set} {x y z : A} \u2192 (x \u2261 y) \u2192 (y \u2261 z) \u2192 (x \u2261 z)\ntrans {A} {x} {y} {z} p q = trans' {A} {x} {y} p z q\n\n-- trans' refl q will simplify to q because we did induction on the first argument\n\nidR : {A : Set} {x y : A} (q : x \u2261 y) \u2192 trans (refl x) q \u2261 q\nidR q = refl q\n\n-- but trans' p refl will NOT simplify\n\n-- idL : {A : Set} {x y : A} (p : x \u2261 y) \u2192 trans p (refl y) \u2261 p\n-- idL p = refl p -- does not work\n\n-- We can do induction on the right and get the reverse situation\n-- OR we can do induction twice and lose BOTH and ONLY get\n-- trans refl refl = refl\n-- Even though this seems \"worse\", it is symmetric at least and easy to work is.\n\ntrans2' : {A : Set} {x y : A} \u2192 (x \u2261 y) \u2192 ((z : A) \u2192 (q : y \u2261 z) \u2192 (x \u2261 z))\ntrans2' {A} =\n  J (\u03bb {x} {y} p \u2192 ((z : A) \u2192 (q : y \u2261 z) \u2192 (x \u2261 z)))\n    (\u03bb a z \u2192 J (\u03bb {x'} {y'} q \u2192 x' \u2261 y') (\u03bb b \u2192 refl b))\n\ntrans2 : {A : Set} {x y z : A} \u2192 (x \u2261 y) \u2192 (y \u2261 z) \u2192 (x \u2261 z)\ntrans2 {A} {x} {y} {z} p q = trans2' {A} {x} {y} p z q\n\nidLR : {A : Set} {a : A} \u2192 trans2 (refl a) (refl a) \u2261 refl a\nidLR {A} {a} = refl (refl a)\n\n------------------------------------------------------------------------------\n\n-- If we restrict ourselves to proofs about \"points\" like numbers,\n-- booleans, etc. all we are saying is that if we normalize the\n-- calculation for each point they each reduce to same identical\n-- result. Things get much more interesting if we start thinking about\n-- identity in higher universes... So for example, say we want to\n-- prove that groups are the same, in that case we might have to prove\n-- that two types are the same etc. Unfortunately J by itself is\n-- helpless here... This motivates the univalence axiom to be discussed next...\n\n------------------------------------------------------------------------------\n", "meta": {"hexsha": "9ef58ff62d135584dbc2c014adcc7955085ff25e", "size": 7261, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Id1.agda", "max_stars_repo_name": "andmkent/misc-HoTT", "max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z", "max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z", "max_issues_repo_path": "Id1.agda", "max_issues_repo_name": "andmkent/misc-HoTT", "max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Id1.agda", "max_forks_repo_name": "andmkent/misc-HoTT", "max_forks_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.7072072072, "max_line_length": 82, "alphanum_fraction": 0.5464812009, "num_tokens": 2543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.938124016006303, "lm_q2_score": 0.8267117876664789, "lm_q1q2_score": 0.7755581823254273}}
{"text": "\nmodule Nat where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\n", "meta": {"hexsha": "c1b27f0a4c3f2c9f21fc17bea7cd6b300675f44d", "size": 74, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Nat.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/Nat.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Nat.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 9.25, "max_line_length": 20, "alphanum_fraction": 0.6081081081, "num_tokens": 24, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9304582593509315, "lm_q2_score": 0.8333245994514084, "lm_q1q2_score": 0.7753737562798696}}
{"text": "{- \n\nThis is the Agda formalization of\n\n      NOTIONS OF ANONYMOUS EXISTENCE IN MARTIN-LOF TYPE THEORY\n\n                              by\n\nNicolai Kraus, Martin Escardo, Thierry Coquand, Thorsten Altenkirch\n\nThis file stays very close to the article. Because of this, not all \nproofs are given in the way that is most elegant for a formalization. \nIn fact, often re-ordering statements would lead to a shorter \npresentation. The order that we have chosen in the article makes our \nresults, as we hope, understandable and gives sufficient motivation.\n\nThis file type check with Agda 2.4.2.5.\n-}\n\nmodule INDEX_NotionsOfAnonymousExistence where\n\n-- We use the following library files:\n\nopen import library.Basics hiding (Type ; \u03a3)\nopen import library.types.Sigma\nopen import library.types.Pi\nopen import library.types.Bool\nopen import library.NType2\nopen import library.types.Paths\n\n-- OUR FORMALIZATION\n\n-- Section 1: Introduction\n-- (no formalization)\n\n-- Section 2: Preliminaries\nopen import Sec2preliminaries\n\n-- Section 3: Hedberg's Theorem\nopen import Sec3hedberg\n\n-- Section 4: Collapsibility implies H-Stability\nopen import Sec4hasConstToSplit\n\n-- Section 5: Factorizing Weakly Constant Functions\nopen import Sec5factorConst\n\n-- Section 6: Populatedness\nopen import Sec6populatedness\n\n-- Section 7: Taboos and Counter-Models\nopen import Sec7taboos\n\n-- Section 8: Propositional Truncation with Judgmental Computation Rule\nopen import Sec8judgmentalBeta\n\n-- Section 9: Conclusion and Open Problems\n-- (no formalization)\n", "meta": {"hexsha": "6dfeaca766b9135ad6928ef22f401ee03681341c", "size": 1522, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/anonymousExistence/INDEX_NotionsOfAnonymousExistence.agda", "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "nicolai/anonymousExistence/INDEX_NotionsOfAnonymousExistence.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nicolai/anonymousExistence/INDEX_NotionsOfAnonymousExistence.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.7966101695, "max_line_length": 71, "alphanum_fraction": 0.776609724, "num_tokens": 387, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9353465098415279, "lm_q2_score": 0.8289388083214156, "lm_q1q2_score": 0.7753450212356314}}
{"text": "{-# OPTIONS --allow-unsolved-metas #-}\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n-- CS410 2017/18 Exercise 1  VECTORS AND FRIENDS (worth 25%)\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n\n-- NOTE (19/9/17) This file is currently incomplete: more will arrive on\n-- GitHub.\n\n-- MARK SCHEME (transcribed from paper): the (m) numbers add up to slightly\n-- more than 25, so should be taken as the maximum number of marks losable on\n-- the exercise. In fact, I did mark it negatively, but mostly because it was\n-- done so well (with Agda's help) that it was easier to find the errors.\n\n\n------------------------------------------------------------------------------\n-- Dependencies\n------------------------------------------------------------------------------\n\nopen import CS410-Prelude\n\n\n------------------------------------------------------------------------------\n-- Vectors\n------------------------------------------------------------------------------\n\ndata Vec (X : Set) : Nat -> Set where  -- like lists, but length-indexed\n  []   :                              Vec X zero\n  _,-_ : {n : Nat} -> X -> Vec X n -> Vec X (suc n)\ninfixr 4 _,-_   -- the \"cons\" operator associates to the right\n\n-- I like to use the asymmetric ,- to remind myself that the element is to\n-- the left and the rest of the list is to the right.\n\n-- Vectors are useful when there are important length-related safety\n-- properties.\n\n\n------------------------------------------------------------------------------\n-- Heads and Tails\n------------------------------------------------------------------------------\n\n-- We can rule out nasty head and tail errors by insisting on nonemptiness!\n\n--??--1.1-(2)-----------------------------------------------------------------\n\nvHead : {X : Set}{n : Nat} -> Vec X (suc n) -> X\nvHead xs = {!!}\n\nvTail : {X : Set}{n : Nat} -> Vec X (suc n) -> Vec X n\nvTail xs = {!!}\n\nvHeadTailFact :  {X : Set}{n : Nat}(xs : Vec X (suc n)) ->\n                 (vHead xs ,- vTail xs) == xs\nvHeadTailFact xs = {!!}                 \n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Concatenation and its Inverse\n------------------------------------------------------------------------------\n\n--??--1.2-(2)-----------------------------------------------------------------\n\n_+V_ : {X : Set}{m n : Nat} -> Vec X m -> Vec X n -> Vec X (m +N n)\nxs +V ys = {!!}\ninfixr 4 _+V_\n\nvChop : {X : Set}(m : Nat){n : Nat} -> Vec X (m +N n) -> Vec X m * Vec X n\nvChop m xs = {!!}\n\nvChopAppendFact : {X : Set}{m n : Nat}(xs : Vec X m)(ys : Vec X n) ->\n                  vChop m (xs +V ys) == (xs , ys)\nvChopAppendFact xs ys = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Map, take I\n------------------------------------------------------------------------------\n\n-- Implement the higher-order function that takes an operation on\n-- elements and does it to each element of a vector. Use recursion\n-- on the vector.\n-- Note that the type tells you the size remains the same.\n\n-- Show that if the elementwise function \"does nothing\", neither does\n-- its vMap. \"map of identity is identity\"\n\n-- Show that two vMaps in a row can be collapsed to just one, or\n-- \"composition of maps is map of compositions\"\n\n--??--1.3-(2)-----------------------------------------------------------------\n\nvMap : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvMap f xs = {!!}\n\nvMapIdFact : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n             {n : Nat}(xs : Vec X n) -> vMap f xs == xs\nvMapIdFact feq xs = {!!}\n\nvMapCpFact : {X Y Z : Set}{f : Y -> Z}{g : X -> Y}{h : X -> Z}\n               (heq : (x : X) -> f (g x) == h x) ->\n             {n : Nat}(xs : Vec X n) ->\n               vMap f (vMap g xs) == vMap h xs\nvMapCpFact heq xs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- vMap and +V\n------------------------------------------------------------------------------\n\n-- Show that if you've got two vectors of Xs and a function from X to Y,\n-- and you want to concatenate and map, it doesn't matter which you do\n-- first.\n\n--??--1.4-(1)-----------------------------------------------------------------\n\nvMap+VFact : {X Y : Set}(f : X -> Y) ->\n             {m n : Nat}(xs : Vec X m)(xs' : Vec X n) ->\n             vMap f (xs +V xs') == (vMap f xs +V vMap f xs')\nvMap+VFact f xs xs' = {!!}\n\n--??--------------------------------------------------------------------------\n\n-- Think about what you could prove, relating vMap with vHead, vTail, vChop...\n-- Now google \"Philip Wadler\" \"Theorems for Free\"\n\n\n------------------------------------------------------------------------------\n-- Applicative Structure (giving mapping and zipping cheaply)\n------------------------------------------------------------------------------\n\n--??--1.5-(2)-----------------------------------------------------------------\n\n-- HINT: you will need to override the default invisibility of n to do this.\nvPure : {X : Set} -> X -> {n : Nat} -> Vec X n\nvPure x {n} = {!!}\n\n_$V_ : {X Y : Set}{n : Nat} -> Vec (X -> Y) n -> Vec X n -> Vec Y n\nfs $V xs = {!!}\ninfixl 3 _$V_  -- \"Application associates to the left,\n               --  rather as we all did in the sixties.\" (Roger Hindley)\n\n-- Pattern matching and recursion are forbidden for the next two tasks.\n\n-- implement vMap again, but as a one-liner\nvec : {X Y : Set} -> (X -> Y) -> {n : Nat} -> Vec X n -> Vec Y n\nvec f xs = {!!}\n\n-- implement the operation which pairs up corresponding elements\nvZip : {X Y : Set}{n : Nat} -> Vec X n -> Vec Y n -> Vec (X * Y) n\nvZip xs ys = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Applicative Laws\n------------------------------------------------------------------------------\n\n-- According to \"Applicative programming with effects\" by\n--   Conor McBride and Ross Paterson\n-- some laws should hold for applicative functors.\n-- Check that this is the case.\n\n--??--1.6-(2)-----------------------------------------------------------------\n\nvIdentity : {X : Set}{f : X -> X}(feq : (x : X) -> f x == x) ->\n            {n : Nat}(xs : Vec X n) -> (vPure f $V xs) == xs\nvIdentity feq xs = {!!}\n\nvHomomorphism : {X Y : Set}(f : X -> Y)(x : X) ->\n                {n : Nat} -> (vPure f $V vPure x) == vPure (f x) {n}\nvHomomorphism f x {n} = {!!}\n\nvInterchange : {X Y : Set}{n : Nat}(fs : Vec (X -> Y) n)(x : X) ->\n               (fs $V vPure x) == (vPure (_$ x) $V fs)\nvInterchange fs x = {!!}\n\nvComposition : {X Y Z : Set}{n : Nat}\n               (fs : Vec (Y -> Z) n)(gs : Vec (X -> Y) n)(xs : Vec X n) ->\n               (vPure _<<_ $V fs $V gs $V xs) == (fs $V (gs $V xs))\nvComposition fs gs xs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings (also known in the business as \"thinnings\")\n------------------------------------------------------------------------------\n\n-- What have these to do with Pascal's Triangle?\n\ndata _<=_ : Nat -> Nat -> Set where\n  oz :                          zero  <= zero\n  os : {n m : Nat} -> n <= m -> suc n <= suc m\n  o' : {n m : Nat} -> n <= m ->     n <= suc m\n\n-- Find all the values in each of the following <= types.\n-- This is a good opportunity to learn to use C-c C-a with the -l option\n--   (a.k.a. \"google the type\" without \"I feel lucky\")\n-- The -s n option also helps.\n\n--??--1.7-(1)-----------------------------------------------------------------\n\nall0<=4 : Vec (0 <= 4) {!!}\nall0<=4 = {!!}\n\nall1<=4 : Vec (1 <= 4) {!!}\nall1<=4 = {!!}\n\nall2<=4 : Vec (2 <= 4) {!!}\nall2<=4 = {!!}\n       \nall3<=4 : Vec (3 <= 4) {!!}\nall3<=4 = {!!}\n\nall4<=4 : Vec (4 <= 4) {!!}\nall4<=4 = {!!}\n\n-- Prove the following. A massive case analysis \"rant\" is fine.\n\nno5<=4 : 5 <= 4 -> Zero\nno5<=4 th = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Order-Preserving Embeddings Select From Vectors\n------------------------------------------------------------------------------\n\n-- Use n <= m to encode the choice of n elements from an m-Vector.\n-- The os constructor tells you to take the next element of the vector;\n-- the o' constructor tells you to omit the next element of the vector.\n\n--??--1.8-(2)-----------------------------------------------------------------\n\n_<?=_ : {X : Set}{n m : Nat} -> n <= m -> Vec X m\n                     -> Vec X n\nth <?= xs = {!!}\n\n-- it shouldn't matter whether you map then select or select then map\n\nvMap<?=Fact : {X Y : Set}(f : X -> Y)\n              {n m : Nat}(th : n <= m)(xs : Vec X m) ->\n              vMap f (th <?= xs) == (th <?= vMap f xs)\nvMap<?=Fact f th xs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Our Favourite Thinnings\n------------------------------------------------------------------------------\n\n-- Construct the identity thinning and the empty thinning.\n\n--??--1.9-(1)-----------------------------------------------------------------\n\noi : {n : Nat} -> n <= n\noi {n}  = {!!}\n\noe : {n : Nat} -> 0 <= n\noe {n}  = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that all empty thinnings are equal to yours.\n\n--??--1.10-(1)----------------------------------------------------------------\n\noeUnique : {n : Nat}(th : 0 <= n) -> th == oe\noeUnique i = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that there are no thinnings of form big <= small  (TRICKY)\n-- Then show that all the identity thinnings are equal to yours.\n-- Note that you can try the second even if you haven't finished the first.\n-- HINT: you WILL need to expose the invisible numbers.\n-- HINT: check CS410-Prelude for a reminder of >=\n\n--??--1.11-(3)----------------------------------------------------------------\n\noTooBig : {n m : Nat} -> n >= m -> suc n <= m -> Zero\noTooBig {n} {m} n>=m th = {!!}\n\noiUnique : {n : Nat}(th : n <= n) -> th == oi\noiUnique th = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n-- Show that the identity thinning selects the whole vector\n\n--??--1.12-(1)----------------------------------------------------------------\n\nid-<?= : {X : Set}{n : Nat}(xs : Vec X n) -> (oi <?= xs) == xs\nid-<?= xs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Composition of Thinnings\n------------------------------------------------------------------------------\n\n-- Define the composition of thinnings and show that selecting by a\n-- composite thinning is like selecting then selecting again.\n-- A small bonus applies to minimizing the length of the proof.\n-- To collect the bonus, you will need to think carefully about\n-- how to make the composition as *lazy* as possible.\n\n--??--1.13-(3)----------------------------------------------------------------\n\n_o>>_ : {p n m : Nat} -> p <= n -> n <= m -> p <= m\nth o>> th' = {!!}\n\ncp-<?= : {p n m : Nat}(th : p <= n)(th' : n <= m) ->\n         {X : Set}(xs : Vec X m) ->\n         ((th o>> th') <?= xs) == (th <?= (th' <?= xs))\ncp-<?= th th' xs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Thinning Dominoes\n------------------------------------------------------------------------------\n\n--??--1.14-(3)----------------------------------------------------------------\n\nidThen-o>> : {n m : Nat}(th : n <= m) -> (oi o>> th) == th\nidThen-o>> th = {!!}\n\nidAfter-o>> : {n m : Nat}(th : n <= m) -> (th o>> oi) == th\nidAfter-o>> th = {!!}\n\nassoc-o>> : {q p n m : Nat}(th0 : q <= p)(th1 : p <= n)(th2 : n <= m) ->\n            ((th0 o>> th1) o>> th2) == (th0 o>> (th1 o>> th2))\nassoc-o>> th0 th1 th2 = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n-- Vectors as Arrays\n------------------------------------------------------------------------------\n\n-- We can use 1 <= n as the type of bounded indices into a vector and do\n-- a kind of \"array projection\". First we select a 1-element vector from\n-- the n-element vector, then we take its head to get the element out.\n\nvProject : {n : Nat}{X : Set} -> Vec X n -> 1 <= n -> X\nvProject xs i = vHead (i <?= xs)\n\n-- Your (TRICKY) mission is to reverse the process, tabulating a function\n-- from indices as a vector. Then show that these operations are inverses.\n\n--??--1.15-(3)----------------------------------------------------------------\n\n-- HINT: composition of functions\nvTabulate : {n : Nat}{X : Set} -> (1 <= n -> X) -> Vec X n\nvTabulate {n} f = {!!}\n\n-- This should be easy if vTabulate is correct.\nvTabulateProjections : {n : Nat}{X : Set}(xs : Vec X n) ->\n                       vTabulate (vProject xs) == xs\nvTabulateProjections xs = {!!}\n\n-- HINT: oeUnique\nvProjectFromTable : {n : Nat}{X : Set}(f : 1 <= n -> X)(i : 1 <= n) ->\n                    vProject (vTabulate f) i == f i\nvProjectFromTable f i = {!!}\n\n--??--------------------------------------------------------------------------\n", "meta": {"hexsha": "75c052b25e1ac227bc906c3434739d59a9849bd2", "size": 13994, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/Ex1.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/Ex1.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/Ex1.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 36.2538860104, "max_line_length": 78, "alphanum_fraction": 0.3686579963, "num_tokens": 3240, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473779969194, "lm_q2_score": 0.888758801595206, "lm_q1q2_score": 0.7753064102432623}}
{"text": "-- Simple test to check if constraint solving for injective\n-- functions is working.\nmodule Injectivity where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\n_+_ : Nat -> Nat -> Nat\nzero  + m = m\nsuc n + m = suc (n + m)\n\n{-# BUILTIN NATURAL Nat  #-}\n{-# BUILTIN ZERO    zero #-}\n{-# BUILTIN SUC     suc  #-}\n{-# BUILTIN NATPLUS _+_  #-}\n\ninfixr 40 _::_\ndata List (A : Set) : Set where\n  []   : List A\n  _::_ : A -> List A -> List A\n\nfoldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B\nfoldr f z []        = z\nfoldr f z (x :: xs) = f x (foldr f z xs)\n\ndata U : Set where\n  nat  : U\n  list : U -> U\n\nEl : U -> Set\nEl nat      = Nat\nEl (list a) = List (El a)\n\nsum : {a : U} -> El a -> Nat\nsum {nat}    n  = n\nsum {list a} xs = foldr (\\a b -> sum a + b) zero xs\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n  refl : x == x\n\ntest\u2081 = sum (1 :: 2 :: 3 :: [])\n\nok\u2081 : test\u2081 == 6\nok\u2081 = refl\n\ntest\u2082 = sum ((1 :: []) :: (3 :: 5 :: []) :: [])\n\nok\u2082 : test\u2082 == 9\nok\u2082 = refl\n\n", "meta": {"hexsha": "c9aafa6d9ee1effab2cdc4dc7e0777f3a1172ce1", "size": 973, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/Injectivity.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_issues_repo_path": "test/succeed/Injectivity.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/Injectivity.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.7115384615, "max_line_length": 59, "alphanum_fraction": 0.4964028777, "num_tokens": 365, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391579526934, "lm_q2_score": 0.839733963661418, "lm_q1q2_score": 0.7751073307223129}}
{"text": "\nopen import Common.Prelude\nopen import Common.Equality\n\ninfixr 5 _\u2237_\n\ndata Vec (A : Set) : Nat \u2192 Set where\n  [] : Vec A zero\n  _\u2237_ : \u2200 {n} \u2192 A \u2192 Vec A n \u2192 Vec A (suc n)\n\nrecord Eq (A : Set) : Set where\n  field\n    _==_ : (x y : A) \u2192 Maybe (x \u2261 y)\n\nopen Eq {{...}}\n\ndata \u03a3 (A : Set) (B : A \u2192 Set) : Set where\n  _,_ : (x : A) \u2192 B x \u2192 \u03a3 A B\n\neqNat : \u2200 n m \u2192 Maybe (n \u2261 m)\neqNat zero zero = just refl\neqNat zero (suc m) = nothing\neqNat (suc n) zero = nothing\neqNat (suc n) (suc m) with eqNat n m\neqNat (suc n) (suc m) | nothing = nothing\neqNat (suc n) (suc .n) | just refl = just refl\n\neqVec : \u2200 {A n} {{EqA : Eq A}} (xs ys : Vec A n) \u2192 Maybe (xs \u2261 ys)\neqVec [] [] = just refl\neqVec (x \u2237 xs) ( y \u2237  ys) with x == y    | eqVec xs ys\neqVec (x \u2237 xs) ( y \u2237  ys)    | nothing   | _         = nothing\neqVec (x \u2237 xs) ( y \u2237  ys)    | _         | nothing   = nothing\neqVec (x \u2237 xs) (.x \u2237 .xs)    | just refl | just refl = just refl\n\neqSigma : \u2200 {A B} {{EqA : Eq A}} {{EqB : \u2200 {x} \u2192 Eq (B x)}} (x y : \u03a3 A B) \u2192 Maybe (x \u2261 y)\neqSigma (x , y) (x\u2081 , y\u2081) with x == x\u2081\neqSigma (x , y) (x\u2081 , y\u2081) | nothing = nothing\neqSigma (x , y) (.x , y\u2081) | just refl with y == y\u2081\neqSigma (x , y) (.x , y\u2081) | just refl | nothing = nothing\neqSigma (x , y) (.x , .y) | just refl | just refl = just refl\n\ninstance\n  EqNat : Eq Nat\n  EqNat = record { _==_ = eqNat }\n\n  EqVec : \u2200 {A n} {{_ : Eq A}} \u2192 Eq (Vec A n)\n  EqVec = record { _==_ = eqVec }\n\n  EqSigma : \u2200 {A B} {{_ : Eq A}} {{_ : \u2200 {x} \u2192 Eq (B x)}} \u2192 Eq (\u03a3 A B)\n  EqSigma = record { _==_ = eqSigma }\n\ncmpSigma : (xs ys : \u03a3 Nat (Vec Nat)) \u2192 Maybe (xs \u2261 ys)\ncmpSigma xs ys = xs == ys\n", "meta": {"hexsha": "e099c6ebd303784b5c639810b8160d4b6e570e14", "size": 1601, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/DependentInstanceSearch.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/DependentInstanceSearch.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/DependentInstanceSearch.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.6481481481, "max_line_length": 89, "alphanum_fraction": 0.519675203, "num_tokens": 669, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533051062237, "lm_q2_score": 0.8311430520409023, "lm_q1q2_score": 0.7750020858916135}}
{"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Dagger where\n\nopen import Level using (_\u2294_; suc)\nopen import Relation.Unary using (Pred)\n\nopen import Categories.Category.Core using (Category)\nopen import Categories.Functor.Core using (Functor)\nopen import Categories.Morphism using (Iso)\n\nrecord HasDagger {o \u2113 e} (C : Category o \u2113 e) : Set (o \u2294 \u2113 \u2294 e) where\n  open Category C\n  infix 10 _\u2020\n\n  field\n    _\u2020 : \u2200 {A B} \u2192 A \u21d2 B \u2192 B \u21d2 A\n    \u2020-identity : \u2200 {A} \u2192 id {A} \u2020 \u2248 id\n    \u2020-homomorphism : \u2200 {A B C} {f : A \u21d2 B} {g : B \u21d2 C} \u2192 (g \u2218 f) \u2020 \u2248 f \u2020 \u2218 g \u2020\n    \u2020-resp-\u2248 : \u2200 {A B} {f g : A \u21d2 B} \u2192 f \u2248 g \u2192 f \u2020 \u2248 g \u2020\n    \u2020-involutive : \u2200 {A B} (f : A \u21d2 B) \u2192 f \u2020 \u2020 \u2248 f\n\n  \u2020-Functor : Functor op C\n  \u2020-Functor = record\n    { F\u2080 = \u03bb A \u2192 A\n    ; F\u2081 = _\u2020\n    ; identity = \u2020-identity\n    ; homomorphism = \u2020-homomorphism\n    ; F-resp-\u2248 = \u2020-resp-\u2248\n    }\n\n  isUnitary : \u2200 {A B} \u2192 Pred (A \u21d2 B) e\n  isUnitary f = Iso C f (f \u2020)\n\n  isSelfAdjoint : \u2200 {A} \u2192 Pred (A \u21d2 A) e\n  isSelfAdjoint f = f \u2020 \u2248 f\n\nrecord DaggerCategory o \u2113 e : Set (suc (o \u2294 \u2113 \u2294 e)) where\n  field\n    C : Category o \u2113 e\n    hasDagger : HasDagger C\n\n  open Category C public\n  open HasDagger hasDagger public\n", "meta": {"hexsha": "bdd8ef843121e6674ad0c43a76b92ab3832a2b5d", "size": 1169, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Dagger.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Dagger.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Dagger.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 26.5681818182, "max_line_length": 78, "alphanum_fraction": 0.5620188195, "num_tokens": 474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951552333004, "lm_q2_score": 0.8289388146603365, "lm_q1q2_score": 0.7745564124034532}}
{"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- A bunch of properties about natural number operations\n------------------------------------------------------------------------\n\nmodule Data.Nat.Properties.Simple where\n\nopen import Data.Nat as Nat\nopen import Function\nopen import Relation.Binary.PropositionalEquality as PropEq\n  using (_\u2261_; _\u2262_; refl; sym; cong; cong\u2082)\nopen PropEq.\u2261-Reasoning\nopen import Data.Product\nopen import Data.Sum\n\n------------------------------------------------------------------------\n\n+-assoc : \u2200 m n o \u2192 (m + n) + o \u2261 m + (n + o)\n+-assoc zero    _ _ = refl\n+-assoc (suc m) n o = cong suc $ +-assoc m n o\n\n+-right-identity : \u2200 n \u2192 n + 0 \u2261 n\n+-right-identity zero = refl\n+-right-identity (suc n) = cong suc $ +-right-identity n\n\n+-suc : \u2200 m n \u2192 m + suc n \u2261 suc (m + n)\n+-suc zero    n = refl\n+-suc (suc m) n = cong suc (+-suc m n)\n\n+-comm : \u2200 m n \u2192 m + n \u2261 n + m\n+-comm zero    n = sym $ +-right-identity n\n+-comm (suc m) n =\n  begin\n    suc m + n\n  \u2261\u27e8 refl \u27e9\n    suc (m + n)\n  \u2261\u27e8 cong suc (+-comm m n) \u27e9\n    suc (n + m)\n  \u2261\u27e8 sym (+-suc n m) \u27e9\n    n + suc m\n  \u220e\n\n+-*-suc : \u2200 m n \u2192 m * suc n \u2261 m + m * n\n+-*-suc zero    n = refl\n+-*-suc (suc m) n =\n  begin\n    suc m * suc n\n  \u2261\u27e8 refl \u27e9\n    suc n + m * suc n\n  \u2261\u27e8 cong (\u03bb x \u2192 suc n + x) (+-*-suc m n) \u27e9\n    suc n + (m + m * n)\n  \u2261\u27e8 refl \u27e9\n    suc (n + (m + m * n))\n  \u2261\u27e8 cong suc (sym $ +-assoc n m (m * n)) \u27e9\n    suc (n + m + m * n)\n  \u2261\u27e8 cong (\u03bb x \u2192 suc (x + m * n)) (+-comm n m) \u27e9\n    suc (m + n + m * n)\n  \u2261\u27e8 cong suc (+-assoc m n (m * n)) \u27e9\n    suc (m + (n + m * n))\n  \u2261\u27e8 refl \u27e9\n    suc m + suc m * n\n  \u220e\n\n*-right-zero : \u2200 n \u2192 n * 0 \u2261 0\n*-right-zero zero = refl\n*-right-zero (suc n) = *-right-zero n\n\n*-comm : \u2200 m n \u2192 m * n \u2261 n * m\n*-comm zero    n = sym $ *-right-zero n\n*-comm (suc m) n =\n  begin\n    suc m * n\n  \u2261\u27e8 refl \u27e9\n    n + m * n\n  \u2261\u27e8 cong (\u03bb x \u2192 n + x) (*-comm m n) \u27e9\n    n + n * m\n  \u2261\u27e8 sym (+-*-suc n m) \u27e9\n    n * suc m\n  \u220e\n\ndistrib\u02b3-*-+ : \u2200 m n o \u2192 (n + o) * m \u2261 n * m + o * m\ndistrib\u02b3-*-+ m zero    o = refl\ndistrib\u02b3-*-+ m (suc n) o =\n  begin\n    (suc n + o) * m\n  \u2261\u27e8 refl \u27e9\n    m + (n + o) * m\n  \u2261\u27e8 cong (_+_ m) $ distrib\u02b3-*-+ m n o \u27e9\n    m + (n * m + o * m)\n  \u2261\u27e8 sym $ +-assoc m (n * m) (o * m) \u27e9\n    m + n * m + o * m\n  \u2261\u27e8 refl \u27e9\n    suc n * m + o * m\n  \u220e\n\n*-assoc : \u2200 m n o \u2192 (m * n) * o \u2261 m * (n * o)\n*-assoc zero    n o = refl\n*-assoc (suc m) n o =\n  begin\n    (suc m * n) * o\n  \u2261\u27e8 refl \u27e9\n    (n + m * n) * o\n  \u2261\u27e8 distrib\u02b3-*-+ o n (m * n) \u27e9\n    n * o + (m * n) * o\n  \u2261\u27e8 cong (\u03bb x \u2192 n * o + x) $ *-assoc m n o \u27e9\n    n * o + m * (n * o)\n  \u2261\u27e8 refl \u27e9\n    suc m * (n * o)\n  \u220e\n", "meta": {"hexsha": "6c5cb93c5abd78775059fbbb22d5917b66fe6ce7", "size": 2630, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6936936937, "max_line_length": 72, "alphanum_fraction": 0.4182509506, "num_tokens": 1112, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850093037731, "lm_q2_score": 0.8267117962054048, "lm_q1q2_score": 0.7740378618017164}}
{"text": "\n-- statically checked sorted lists\n-- see http://www2.tcs.ifi.lmu.de/~abel/DepTypes.pdf\n\nmodule SortedList where\n\nopen import Data.Nat using (\u2115; zero; suc; _+_; _*_)\nopen import Data.Bool using (Bool; true; false)\n\n----------------------------------------------------------------------\n-- Curry-Howard stuff\n\nProposition = Set\n\n-- intentionally blank. signifies the empty set in the type system.\ndata Absurd : Proposition where\n\n-- tt = trivially true\ndata Truth : Proposition where\n  tt : Truth\n\n-- \u2227 = conjunction\ndata _\u2227_ (A B : Proposition) : Proposition where\n    _,_ : A \u2192 B \u2192 A \u2227 B\n\nfst : {A B : Proposition} \u2192 A \u2227 B \u2192 A\nfst (a , b) = a\n\nsnd : {A B : Proposition} \u2192 A \u2227 B \u2192 B\nsnd (a , b) = b\n\n-- Cartesian product = conjunction\n_\u00d7_ = _\u2227_\n\n-- \u2228 = disjunction\ndata _\u2228_ (A B : Proposition) : Proposition where\n  inl : A \u2192 A \u2228 B\n  inr : B \u2192 A \u2228 B\n\n-- given: A or B is true, A implies C, B implies C. then C is true.\ncase : {A B C : Proposition} \u2192 A \u2228 B \u2192 (A \u2192 C) \u2192 (B \u2192 C) \u2192 C\ncase (inl a) f g = f a\ncase (inr b) f g = g b\n\n-- map booleans to propositions by mapping true to Truth and false to Absurd\nTrue : Bool \u2192 Proposition\nTrue true = Truth\nTrue false = Absurd\n\n----------------------------------------------------------------------\n\n_\u2264_ : \u2115 \u2192 \u2115 \u2192 Bool\nzero \u2264 n = true\nsuc m \u2264 zero = false\nsuc m \u2264 suc n = m \u2264 n\n\n-- proposition: \u2264 is reflexive. proof: induction.\nrefl\u2264 : (n : \u2115) \u2192 True (n \u2264 n)\nrefl\u2264 zero = tt\nrefl\u2264 (suc n) = refl\u2264 n\n\n----------------------------------------------------------------------\n\ndata SortedList : \u2115 \u2192 Set where\n  \u2205 : SortedList zero\n  \u22c9 : {n : \u2115} (m : \u2115) \u2192 True (n \u2264 m) \u2192 SortedList n \u2192 SortedList m\n\n-- the arguments to \u22c9 are\n-- m : a natural number to prepend to the given sorted list xs\n-- p : a proof that m (the new head) is \u2265 head xs\n-- xs : a list such that head xs = n\n\n-- for constant natural numbers, proofs that n \u2264 m are trivial since\n-- \u2264 is decidable; this is why we pass in `tt` in the examples below\n\n-- examples:\none : \u2115\none = suc zero\n\ns1 = \u22c9 one tt (\u22c9 zero tt \u2205)\n-- s2 = \u22c9 zero tt (\u22c9 one tt \u2205) -- fails statically, as desired\ns3 = \u22c9 one tt s1       -- normal form: \u22c9 1 tt (\u22c9 1 tt (\u22c9 0 tt \u2205))\ns4 = \u22c9 (suc one) tt s1 -- normal form: \u22c9 2 tt (\u22c9 1 tt (\u22c9 0 tt \u2205))\n\n", "meta": {"hexsha": "815d3a9f967f4ac1f6d3bd8f1ebc2b6a4cb6a3cf", "size": 2214, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "SortedList.agda", "max_stars_repo_name": "sshastry/agda-examples", "max_stars_repo_head_hexsha": "e70ef1ea1891cff6157fba682a61c6f227a26fd8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SortedList.agda", "max_issues_repo_name": "sshastry/agda-examples", "max_issues_repo_head_hexsha": "e70ef1ea1891cff6157fba682a61c6f227a26fd8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SortedList.agda", "max_forks_repo_name": "sshastry/agda-examples", "max_forks_repo_head_hexsha": "e70ef1ea1891cff6157fba682a61c6f227a26fd8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.0470588235, "max_line_length": 76, "alphanum_fraction": 0.5555555556, "num_tokens": 722, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966702001757, "lm_q2_score": 0.8175744761936437, "lm_q1q2_score": 0.7739132768055559}}
{"text": "\nmodule Haskell.Prim.Tuple where\n\nopen import Agda.Builtin.List\n\nopen import Haskell.Prim\n\nprivate\n  variable\n    as : List Set\n\n--------------------------------------------------\n-- Tuples\n\ninfixr 5 _\u2237_\ndata Tuple : List Set \u2192 Set where\n  []  : Tuple []\n  _\u2237_ : a \u2192 Tuple as \u2192 Tuple (a \u2237 as)\n\ninfix 3 _\u00d7_ _\u00d7_\u00d7_\n\n_\u00d7_ : (a b : Set) \u2192 Set\na \u00d7 b = Tuple (a \u2237 b \u2237 [])\n\n_\u00d7_\u00d7_ : (a b c : Set) \u2192 Set\na \u00d7 b \u00d7 c = Tuple (a \u2237 b \u2237 c \u2237 [])\n\ninfix -1 _,_ _,_,_\n\npattern _,_     x y     = x Tuple.\u2237 y Tuple.\u2237 []\npattern _,_,_   x y z   = x Tuple.\u2237 y Tuple.\u2237 z Tuple.\u2237 []\n\nuncurry : (a \u2192 b \u2192 c) \u2192 a \u00d7 b \u2192 c\nuncurry f (x , y) = f x y\n\ncurry : (a \u00d7 b \u2192 c) \u2192 a \u2192 b \u2192 c\ncurry f x y = f (x , y)\n\nfst : a \u00d7 b \u2192 a\nfst (x , _) = x\n\nsnd : a \u00d7 b \u2192 b\nsnd (_ , y) = y\n\nfirst : (a \u2192 b) \u2192 a \u00d7 c \u2192 b \u00d7 c\nfirst f (x , y) = f x , y\n\nsecond : (a \u2192 b) \u2192 c \u00d7 a \u2192 c \u00d7 b\nsecond f (x , y) = x , f y\n\n_***_ : (a \u2192 b) \u2192 (c \u2192 d) \u2192 a \u00d7 c \u2192 b \u00d7 d\n(f *** g) (x , y) = f x , g y\n", "meta": {"hexsha": "e20333953639cd19be7f8312059d51b1b17a1b7d", "size": 934, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "lib/Haskell/Prim/Tuple.agda", "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 55, "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_issues_repo_path": "lib/Haskell/Prim/Tuple.agda", "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 63, "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_forks_repo_path": "lib/Haskell/Prim/Tuple.agda", "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 18, "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "avg_line_length": 17.6226415094, "max_line_length": 58, "alphanum_fraction": 0.4421841542, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308165850442, "lm_q2_score": 0.8289388104343893, "lm_q1q2_score": 0.7737570307228072}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Functions.Definition\nopen import Lists.Definition\nopen import Lists.Monad\nopen import Boolean.Definition\n\nmodule Lists.Filter.AllTrue where\n\nallTrue : {a b : _} {A : Set a} (f : A \u2192 Set b) (l : List A) \u2192 Set b\nallTrue f [] = True'\nallTrue f (x :: l) = f x && allTrue f l\n\nallTrueConcat : {a b : _} {A : Set a} (f : A \u2192 Set b) (l m : List A) \u2192 allTrue f l \u2192 allTrue f m \u2192 allTrue f (l ++ m)\nallTrueConcat f [] m fl fm = fm\nallTrueConcat f (x :: l) m (fst ,, snd) fm = fst ,, allTrueConcat f l m snd fm\n\nallTrueFlatten : {a b : _} {A : Set a} (f : A \u2192 Set b) (l : List (List A)) \u2192 allTrue (\u03bb i \u2192 allTrue f i) l \u2192 allTrue f (flatten l)\nallTrueFlatten f [] pr = record {}\nallTrueFlatten f ([] :: ls) pr = allTrueFlatten f ls (_&&_.snd pr)\nallTrueFlatten f ((x :: l) :: ls) ((fx ,, fl) ,, snd) = fx ,, allTrueConcat f l (flatten ls) fl (allTrueFlatten f ls snd)\n\nallTrueMap : {a b c : _} {A : Set a} {B : Set b} (pred : B \u2192 Set c) (f : A \u2192 B) (l : List A) \u2192 allTrue (pred \u2218 f) l \u2192 allTrue pred (map f l)\nallTrueMap pred f [] pr = record {}\nallTrueMap pred f (x :: l) pr = _&&_.fst pr ,, allTrueMap pred f l (_&&_.snd pr)\n\nallTrueExtension : {a b : _} {A : Set a} (f g : A \u2192 Set b) (l : List A) \u2192 ({x : A} \u2192 f x \u2192 g x) \u2192 allTrue f l \u2192 allTrue g l\nallTrueExtension f g [] pred t = record {}\nallTrueExtension f g (x :: l) pred (fg ,, snd) = pred {x} fg ,, allTrueExtension f g l pred snd\n\nallTrueTail : {a b : _} {A : Set a} (pred : A \u2192 Set b) (x : A) (l : List A) \u2192 allTrue pred (x :: l) \u2192 allTrue pred l\nallTrueTail pred x l (fst ,, snd) = snd\n\nfilter : {a : _} {A : Set a} (l : List A) (f : A \u2192 Bool) \u2192 List A\nfilter [] f = []\nfilter (x :: l) f with f x\nfilter (x :: l) f | BoolTrue = x :: filter l f\nfilter (x :: l) f | BoolFalse = filter l f\n", "meta": {"hexsha": "51d971e8ac39277a6c422d60a05af032d8095ba7", "size": 1831, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lists/Filter/AllTrue.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Lists/Filter/AllTrue.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Lists/Filter/AllTrue.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 45.775, "max_line_length": 140, "alphanum_fraction": 0.5903877662, "num_tokens": 667, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.888758793492457, "lm_q2_score": 0.8705972700870909, "lm_q1q2_score": 0.7737509793804296}}
{"text": "{-\n\n          Types Summer School 2007\n\n                 Bertinoro\n             Aug 19 - 31, 2007\n\n\n                   Agda\n\n                Ulf Norell\n\n-}\n\n-- Now we're getting somewhere! Inductive families of datatypes.\n\nmodule Families where\n\n-- You can import modules defined in other files.\n-- More details later...\n-- open import Nat\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\n_+_ : Nat -> Nat -> Nat\nzero + m = m\nsuc n + m = suc (n + m)\n\n-- Think of an inductive family...\n\ndata Vec (A : Set) : Nat -> Set where\n  []   : Vec A zero\n  _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\ninfixr 40 _::_\n\n-- Some simple functions\nhead : {A : Set}{n : Nat} -> Vec A (suc n) -> A\nhead (x :: _) = x  -- no need for a [] case\n\n-- Does the definition look familiar?\nmap : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n\nmap f []        = []\nmap f (x :: xs) = f x :: map f xs\n\ninfixr 40 _++_\n\n_++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n[]        ++ ys = ys\n(x :: xs) ++ ys = x :: (xs ++ ys)\n\n-- Why does this type check? Let's walk through it slowly.\n-- When pattern matching on the first vector, n is instantiated.\n\n-- What happens if we make the lengths explicit?\n\ncat : {A : Set}(n m : Nat) -> Vec A n -> Vec A m -> Vec A (n + m)\ncat .zero    m []              ys = ys\ncat .(suc n) m (_::_ {n} x xs) ys = x :: (cat n m xs ys)\n\n-- Patterns which get instantiated by pattern matching on other stuff\n-- get tagged by a dot. If you erase all the dotted things you get a\n-- well-formed linear first-order pattern.\n\n-- Inside the dot we could have arbitrary terms. For instance,\n\ndata Image_\u220b_ {A B : Set}(f : A -> B) : B -> Set where\n  im : (x : A) -> Image f \u220b f x\n\ninv : {A B : Set}(f : A -> B)(y : B) -> Image f \u220b y -> A\ninv f .(f x) (im x) = x\n\n-- Let's do some other interesting families.\n\n-- The identity type.\ndata _==_ {A : Set} : A -> A -> Set where\n  refl : (x : A) -> x == x\n\nsubst : {A : Set}(C : A -> Set)(x y : A) -> x == y -> C x -> C y\nsubst C .x .x (refl x) cx = cx\n\n-- Finite sets\n\n{-\n\nFin zero        -\nFin (suc zero)  fzero\nFin 2           fzero, fsuc fzero\n\n-}\n\ndata Fin : Nat -> Set where\n  fzero : {n : Nat} -> Fin (suc n)\n  fsuc  : {n : Nat} -> Fin n -> Fin (suc n)\n\n_!_ : {A : Set}{n : Nat} -> Vec A n -> Fin n -> A\n[]        ! ()\n(x :: xs) ! fzero  = x\n(x :: xs) ! fsuc i = xs ! i\n\n{-\n\n  What's next?\n\n-}\n\n-- Actually, inductive families are sufficiently fun that\n-- you'll never get bored, but there's even more fun to be had.\n\n-- Move on to: Filter.agda\n", "meta": {"hexsha": "7f9e86f494d167ec284841c3dd98a80781194c00", "size": 2521, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Families.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 22.3097345133, "max_line_length": 69, "alphanum_fraction": 0.535898453, "num_tokens": 839, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9546474168650673, "lm_q2_score": 0.8104789178257654, "lm_q1q2_score": 0.7737216053259621}}
{"text": "------------------------------------------------------------------------------\n-- Inductive PA properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule PA.Inductive.PropertiesI where\n\nopen import PA.Inductive.Base\nopen import PA.Inductive.Relation.Binary.EqReasoning\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\nsuccCong : \u2200 {m n} \u2192 m \u2261 n \u2192 succ m \u2261 succ n\nsuccCong refl = refl\n\n+-leftCong : \u2200 {m n o} \u2192 m \u2261 n \u2192 m + o \u2261 n + o\n+-leftCong refl = refl\n\n+-rightCong : \u2200 {m n o} \u2192 n \u2261 o \u2192 m + n \u2261 m + o\n+-rightCong refl = refl\n\n------------------------------------------------------------------------------\n-- Peano's third axiom.\nP\u2083 : \u2200 {m n} \u2192 succ m \u2261 succ n \u2192 m \u2261 n\nP\u2083 refl = refl\n\n-- Peano's fourth axiom.\nP\u2084 : \u2200 {n} \u2192 zero \u2262 succ n\nP\u2084 ()\n\nx\u2262Sx : \u2200 {n} \u2192 n \u2262 succ n\nx\u2262Sx {zero} ()\nx\u2262Sx {succ n} h = x\u2262Sx (P\u2083 h)\n\n+-leftIdentity : \u2200 n \u2192 zero + n \u2261 n\n+-leftIdentity n = refl\n\n-- Adapted from the Agda standard library\u00a00.8.1 (see\n-- Data.Nat.Properties.Simple.+-rightIdentity).\n+-rightIdentity : \u2200 n \u2192 n + zero \u2261 n\n+-rightIdentity zero     = refl\n+-rightIdentity (succ n) = succCong (+-rightIdentity n)\n\n-- Adapted from the Agda standard library_0.8.1 (see\n-- Data.Nat.Properties.Simple.+-assoc).\n+-assoc : \u2200 m n o \u2192 m + n + o \u2261 m + (n + o)\n+-assoc zero     _ _ = refl\n+-assoc (succ m) n o = succCong (+-assoc m n o)\n\n-- Adapted from the Agda standard library 0.8.1 (see\n-- Data.Nat.Properties.Simple.+-suc).\nx+Sy\u2261S[x+y] : \u2200 m n \u2192 m + succ n \u2261 succ (m + n)\nx+Sy\u2261S[x+y] zero     _ = refl\nx+Sy\u2261S[x+y] (succ m) n = succCong (x+Sy\u2261S[x+y] m n)\n\n-- Adapted from the Agda standard library 0.8.1 (see\n-- Data.Nat.Properties.Simple.+-comm).\n+-comm : \u2200 m n \u2192 m + n \u2261 n + m\n+-comm zero     n = sym (+-rightIdentity n)\n+-comm (succ m) n = succ (m + n) \u2261\u27e8 succCong (+-comm m n) \u27e9\n                    succ (n + m) \u2261\u27e8 sym (x+Sy\u2261S[x+y] n m) \u27e9\n                    n + succ m   \u220e\n", "meta": {"hexsha": "e3e49b172bfc2261fefff8dca461596804f0b4e7", "size": 2133, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 31.3676470588, "max_line_length": 78, "alphanum_fraction": 0.4857008908, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087965937711, "lm_q2_score": 0.8333245994514084, "lm_q1q2_score": 0.7736658885486684}}
{"text": "\nmodule Unique where\n\nopen import Category\n\nmodule Uniq (\u2102 : Cat) where\n\n  private open module C = Cat \u2102\n\n  -- We say that f \u2208! P iff f is the unique arrow satisfying P.\n  data _\u2208!_ {A B : Obj}(f : A \u2500\u2192 B)(P : A \u2500\u2192 B -> Set) : Set where\n    unique : (forall g -> P g -> f == g) -> f \u2208! P\n\n  itsUnique : {A B : Obj}{f : A \u2500\u2192 B}{P : A \u2500\u2192 B -> Set} ->\n\t      f \u2208! P -> (g : A \u2500\u2192 B) -> P g -> f == g\n  itsUnique (unique h) = h\n\n  data \u2203! {A B : Obj}(P : A \u2500\u2192 B -> Set) : Set where\n    witness : (f : A \u2500\u2192 B) -> f \u2208! P -> \u2203! P\n\n  getWitness : {A B : Obj}{P : A \u2500\u2192 B -> Set} -> \u2203! P -> A \u2500\u2192 B\n  getWitness (witness w _) = w\n\n  uniqueWitness : {A B : Obj}{P : A \u2500\u2192 B -> Set}(u : \u2203! P) ->\n\t\t  getWitness u \u2208! P\n  uniqueWitness (witness _ u) = u\n\n  witnessEqual : {A B : Obj}{P : A \u2500\u2192 B -> Set} -> \u2203! P ->\n\t\t {f g : A \u2500\u2192 B} -> P f -> P g -> f == g\n  witnessEqual u {f} {g} pf pg = trans (sym hf) hg\n    where\n      h = getWitness u\n\n      hf : h == f\n      hf = itsUnique (uniqueWitness u) f pf\n\n      hg : h == g\n      hg = itsUnique (uniqueWitness u) g pg\n", "meta": {"hexsha": "eadeb8244134885ab00e0f2545506b009d97431a", "size": 1049, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Unique.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Unique.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Unique.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 26.8974358974, "max_line_length": 66, "alphanum_fraction": 0.4775977121, "num_tokens": 422, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9433475746920261, "lm_q2_score": 0.8198933403143929, "lm_q1q2_score": 0.7734443940917265}}
{"text": "{-# OPTIONS --rewriting #-}\n\nmodule RewritingNat where\n\nopen import Common.Equality\n\n{-# BUILTIN REWRITE _\u2261_ #-}\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat \u2192 Nat\n\n_+_ : Nat \u2192 Nat \u2192 Nat\nzero + n = n\n(suc m) + n = suc (m + n)\n\nplusAssoc : \u2200 x {y z : Nat} \u2192 ((x + y) + z) \u2261 (x + (y + z))\nplusAssoc zero = refl\nplusAssoc (suc x) {y} {z} rewrite plusAssoc x {y} {z} = refl\n\nplus0T : Set\nplus0T = \u2200{x} \u2192 (x + zero) \u2261 x\n\nplusSucT : Set\nplusSucT = \u2200{x y} \u2192 (x + (suc y)) \u2261 suc (x + y)\n\npostulate\n  plus0p : plus0T\n  {-# REWRITE plus0p #-}\n\n  plusSucp : plusSucT\n\n{-# REWRITE plusSucp plusAssoc #-}\n\nplus0 : plus0T\nplus0 = refl\n\ndata Vec (A : Set) : Nat \u2192 Set where\n  [] : Vec A zero\n  _\u2237_ : \u2200 {n} (x : A) (xs : Vec A n) \u2192 Vec A (suc n)\n\n-- Needs REWRITE plus0p plusSucp\nreverseAcc : \u2200{A n m} \u2192 Vec A n \u2192 Vec A m \u2192 Vec A (n + m)\nreverseAcc [] acc = acc\nreverseAcc (x \u2237 xs) acc = reverseAcc xs (x \u2237 acc)\n\nappend : \u2200{A n m} \u2192 Vec A n \u2192 Vec A m \u2192 Vec A (n + m)\nappend []       ys = ys\nappend (x \u2237 xs) ys = x \u2237 append xs ys\n\n-- Note: appendAssoc needs REWRITE plusAssoc to be well-typed.\nappendAssoc : \u2200{A n m l} (u : Vec A n) {v : Vec A m}{w : Vec A l} \u2192\n  append (append u v) w \u2261 append u (append v w)\nappendAssoc [] = refl\nappendAssoc (x \u2237 xs) {v} {w} rewrite appendAssoc xs {v} {w} = refl\n", "meta": {"hexsha": "8d79d148d068a5e866b5ca4a4d3d91c0c291fb16", "size": 1285, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/RewritingNat.agda", "max_stars_repo_name": "alhassy/agda", "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/RewritingNat.agda", "max_issues_repo_name": "alhassy/agda", "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/RewritingNat.agda", "max_forks_repo_name": "alhassy/agda", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 22.9464285714, "max_line_length": 67, "alphanum_fraction": 0.5750972763, "num_tokens": 501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582574225517, "lm_q2_score": 0.8311430457670241, "lm_q1q2_score": 0.7733439100332574}}
{"text": "{-# OPTIONS --type-in-type #-}\nmodule Record where\n\ninfixr 2 _,_\nrecord \u03a3 (A : Set)(B : A \u2192 Set) : Set where\n  constructor _,_\n  field fst : A\n        snd : B fst\n\nopen \u03a3\n\ndata \u22a4 : Set where\n  tt : \u22a4\n\n\u2203 : {A : Set}(B : A \u2192 Set) \u2192 Set\n\u2203 B = \u03a3 _ B\n\ninfix 10 _\u2261_\n\ndata _\u2261_ {A : Set}(a : A) : {B : Set} \u2192 B \u2192 Set where\n  refl : a \u2261 a\n\ntrans : \u2200 {A B C}{a : A}{b : B}{c : C} \u2192 a \u2261 b \u2192 b \u2261 c \u2192 a \u2261 c\ntrans refl p = p\n\nsym : \u2200 {A B}{a : A}{b : B} \u2192 a \u2261 b \u2192 b \u2261 a\nsym refl = refl\n\nresp : \u2200 {A}{B : A \u2192 Set}{a a' : A} \u2192\n       (f : (a : A) \u2192 B a) \u2192 a \u2261 a' \u2192 f a \u2261 f a'\nresp f refl = refl\n\nCat : Set\nCat =\n  \u2203 \u03bb (Obj : Set) \u2192\n  \u2203 \u03bb (Hom : Obj \u2192 Obj \u2192 Set) \u2192\n  \u2203 \u03bb (id : \u2200 X \u2192 Hom X X) \u2192\n  \u2203 \u03bb (_\u25cb_ : \u2200 {X Y Z} \u2192 Hom Y Z \u2192 Hom X Y \u2192 Hom X Z) \u2192\n  \u2203 \u03bb (idl : \u2200 {X Y}{f : Hom X Y} \u2192 id Y \u25cb f \u2261 f) \u2192\n  \u2203 \u03bb (idr : \u2200 {X Y}{f : Hom X Y} \u2192 f \u25cb id X \u2261 f) \u2192\n  \u2203 \u03bb (assoc : \u2200 {W X Y Z}{f : Hom W X}{g : Hom X Y}{h : Hom Y Z} \u2192\n                (h \u25cb g) \u25cb f \u2261 h \u25cb (g \u25cb f)) \u2192\n  \u22a4\n\nObj : (C : Cat) \u2192 Set\nObj C = fst C\n\nHom : (C : Cat) \u2192 Obj C \u2192 Obj C \u2192 Set\nHom C = fst (snd C)\n\nid : (C : Cat) \u2192 \u2200 X \u2192 Hom C X X\nid C = fst (snd (snd C))\n\ncomp : (C : Cat) \u2192 \u2200 {X Y Z} \u2192 Hom C Y Z \u2192 Hom C X Y \u2192 Hom C X Z\ncomp C = fst (snd (snd (snd C)))\n\nidl : (C : Cat) \u2192 \u2200 {X Y}{f : Hom C X Y} \u2192 comp C (id C Y) f \u2261 f\nidl C = fst (snd (snd (snd (snd C))))\n\nidr : (C : Cat) \u2192 \u2200 {X Y}{f : Hom C X Y} \u2192 comp C f (id C X) \u2261 f\nidr C = fst (snd (snd (snd (snd (snd C)))))\n\nassoc : (C : Cat) \u2192 \u2200 {W X Y Z}{f : Hom C W X}{g : Hom C X Y}{h : Hom C Y Z} \u2192\n        comp C (comp C h g) f \u2261 comp C h (comp C g f)\nassoc C = fst (snd (snd (snd (snd (snd (snd C))))))\n", "meta": {"hexsha": "84a1b075c7942e5b2c8d205309391741af76db6c", "size": 1608, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "benchmark/proj/Record.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "benchmark/proj/Record.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "benchmark/proj/Record.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 24.3636363636, "max_line_length": 78, "alphanum_fraction": 0.4322139303, "num_tokens": 748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465152482724, "lm_q2_score": 0.8267118004748677, "lm_q1q2_score": 0.7732620016887926}}
{"text": "module 747Negation where\n\n-- Library\n\nopen import Relation.Binary.PropositionalEquality using (_\u2261_; refl) -- added last\nopen import Data.Nat using (\u2115; zero; suc) \nopen import Data.Empty using (\u22a5; \u22a5-elim)\nopen import Data.Sum using (_\u228e_; inj\u2081; inj\u2082)\nopen import Data.Product using (_\u00d7_; proj\u2081; proj\u2082)\n\n-- Negation is defined as implying false.\n\n\u00ac_ : Set \u2192 Set\n\u00ac A = A \u2192 \u22a5\n\n-- if both \u00ac A and A hold, then \u22a5 holds (not surprisingly).\n\n\u00ac-elim : \u2200 {A : Set}\n  \u2192 \u00ac A\n  \u2192 A\n    ---\n  \u2192 \u22a5\n\n\u00ac-elim = {!!}\n\ninfix 3 \u00ac_\n\n-- Double negation introduction.\n\n\u00ac\u00ac-intro : \u2200 {A : Set}\n  \u2192 A\n    -----\n  \u2192 \u00ac \u00ac A\n\n\u00ac\u00ac-intro = {!!}\n\n-- Double negation cannot be eliminated in intuitionistic logic.\n\n-- Triple negation elimination.\n\n\u00ac\u00ac\u00ac-elim : \u2200 {A : Set}\n  \u2192 \u00ac \u00ac \u00ac A\n    -------\n  \u2192 \u00ac A\n\n\u00ac\u00ac\u00ac-elim = {!!}\n\n-- One direction of the contrapositive.\n\ncontraposition : \u2200 {A B : Set}\n  \u2192 (A \u2192 B)\n    -----------\n  \u2192 (\u00ac B \u2192 \u00ac A)\n\ncontraposition = {!!}\n\n-- The other direction cannot be proved in intuitionistic logic.\n\n-- not-equal-to.\n\n_\u2262_ : \u2200 {A : Set} \u2192 A \u2192 A \u2192 Set\nx \u2262 y  =  \u00ac (x \u2261 y)\n\n_ : 1 \u2262 2\n_ = {!!}\n\n-- One of the first-order Peano axioms.\n\npeano : \u2200 {m : \u2115} \u2192 zero \u2262 suc m\npeano = {!!}\n\n-- Copied from 747Isomorphism.\n\npostulate\n  extensionality : \u2200 {A B : Set} {f g : A \u2192 B}\n    \u2192 (\u2200 (x : A) \u2192 f x \u2261 g x)\n      -----------------------\n    \u2192 f \u2261 g\n\n-- Two proofs of \u22a5 \u2192 \u22a5 which look different but are the same\n-- (assuming extensionality).\n   \nid : \u22a5 \u2192 \u22a5\nid x = x\n\nid\u2032 : \u22a5 \u2192 \u22a5\nid\u2032 ()\n\nid\u2261id\u2032 : id \u2261 id\u2032\nid\u2261id\u2032 = extensionality (\u03bb())\n\n-- Assuming extensionality, any two proofs of a negation are the same\n\nassimilation : \u2200 {A : Set} (\u00acx \u00acx\u2032 : \u00ac A) \u2192 \u00acx \u2261 \u00acx\u2032\nassimilation \u00acx \u00acx\u2032 = extensionality \u03bb x \u2192 \u22a5-elim (\u00acx x)\n\n-- Strict inequality (copied from 747Relations).\n\ninfix 4 _<_\n\ndata _<_ : \u2115 \u2192 \u2115 \u2192 Set where\n\n  z<s : \u2200 {n : \u2115}\n      ------------\n    \u2192 zero < suc n\n\n  s<s : \u2200 {m n : \u2115}\n    \u2192 m < n\n      -------------\n    \u2192 suc m < suc n\n\n-- 747/PLFA exercise: NotFourLTThree (1 point)\n-- Show \u00ac (4 < 3).\n\n\u00ac4<3 : \u00ac (4 < 3)\n\u00ac4<3 = {!!}\n\n-- 747/PLFA exercise: LTIrrefl (1 point)\n-- < is irreflexive (never reflexive).\n\n\u00acn<n : \u2200 (n : \u2115) \u2192 \u00ac (n < n)\n\u00acn<n n = {!!}\n\n-- 747/PLFA exercise: LTTrich (3 points)\n-- Show that strict inequality satisfies trichotomy,\n-- in the sense that exactly one of the three possibilities holds.\n-- Here is the expanded definition of trichotomy.\n\ndata Trichotomy (m n : \u2115) : Set where\n  is-< : m < n \u2192 \u00ac m \u2261 n \u2192 \u00ac n < m \u2192 Trichotomy m n\n  is-\u2261 : m \u2261 n \u2192 \u00ac m < n \u2192 \u00ac n < m \u2192 Trichotomy m n\n  is-> : n < m \u2192 \u00ac m \u2261 n \u2192 \u00ac m < n \u2192 Trichotomy m n\n\n<-trichotomy : \u2200 (m n : \u2115) \u2192 Trichotomy m n\n<-trichotomy m n = {!!}\n\n-- PLFA exercise: one of DeMorgan's Laws as isomorphism\n-- \u228e-dual-\u00d7 : \u2200 {A B : Set} \u2192 \u00ac (A \u228e B) \u2243 (\u00ac A) \u00d7 (\u00ac B)\n-- Expand negation as implies-false, then look in 747Relations\n-- for a law of which this is a special case.\n\n-- What about \u00ac (A \u00d7 B) \u2243 (\u00ac A) \u228e (\u00ac B)?\n-- Answer: RHS implies LHS but converse cannot be proved in intuitionistic logic.\n\n-- Intuitionistic vs classical logic.\n\n-- The law of the excluded middle (LEM, or just em) cannot be\n-- proved in intuitionistic logic.\n-- But we can add it, and get classical logic.\n\n-- postulate\n--  em : \u2200 {A : Set} \u2192 A \u228e \u00ac A\n\n-- How do we know this does not give a contradiction?\n-- The following theorem of intuitionistic logic demonstrates this.\n-- (The proof is compact, but takes some thought.)\n\nem-irrefutable : \u2200 {A : Set} \u2192 \u00ac \u00ac (A \u228e \u00ac A)\nem-irrefutable = {!!}\n\n-- PLFA exercise: classical equivalences\n-- Excluded middle cannot be proved in intuitionistic logic,\n-- but adding it is consistent and gives classical logic.\n-- Here are four other classical theorems with the same property.\n-- You can show that each of them is logically equivalent to all the others.\n-- You do not need to prove twenty implications, since implication is transitive.\n-- But there is a lot of choice as to how to proceed!\n\n-- Excluded Middle\nem = \u2200 {A : Set} \u2192 A \u228e \u00ac A\n\n-- Double Negation Elimination\ndne = \u2200 {A : Set} \u2192 \u00ac \u00ac A \u2192 A\n\n-- Peirce\u2019s Law\npeirce =  \u2200 {A B : Set} \u2192 ((A \u2192 B) \u2192 A) \u2192 A\n\n-- Implication as disjunction\niad =  \u2200 {A B : Set} \u2192 (A \u2192 B) \u2192 \u00ac A \u228e B\n\n-- De Morgan:\ndem = \u2200 {A B : Set} \u2192 \u00ac (\u00ac A \u00d7 \u00ac B) \u2192 A \u228e B\n\n-- End of classical five exercise.\n\n-- Definition: a formula is stable if double negation holds for it.\n\nStable : Set \u2192 Set\nStable A = \u00ac \u00ac A \u2192 A\n\n-- PLFA exercise: every negated formula is stable.\n-- This is triple negation elimination.\n\n-- PLFA exercise: the conjunction of two stable formulas is stable.\n-- This is the version of DeMorgan's Law that is a special case, above.\n\n-- Where negation sits in the standard library.\n\nimport Relation.Nullary using (\u00ac_)\nimport Relation.Nullary.Negation using (contraposition)\n\n-- Unicode used in this chapter:\n\n{-\n\n  \u00ac  U+00AC  NOT SIGN (\\neg)\n  \u2262  U+2262  NOT IDENTICAL TO (\\==n)\n\n-}\n", "meta": {"hexsha": "c7bc080f842876b7a6f9640cc85da89d6065a6a6", "size": 4804, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 22.8761904762, "max_line_length": 81, "alphanum_fraction": 0.5980432973, "num_tokens": 1574, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896693699845, "lm_q2_score": 0.8397339696776499, "lm_q1q2_score": 0.7732183642982279}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Level using (Level)\n\nopen import Relation.Binary.PropositionalEquality\nopen \u2261-Reasoning\n\nopen import Data.Nat using (\u2115)\nopen import Data.Vec using (Vec; foldr; zipWith; map)\n\nopen import FLA.Algebra.Structures\nopen import FLA.Algebra.Properties.Field\n\nmodule FLA.Algebra.LinearAlgebra where\n\nprivate\n  variable\n    \u2113 : Level\n    A : Set \u2113\n    m n p q : \u2115\n\nmodule _ {\u2113 : Level} {A : Set \u2113} \u2983 F : Field A \u2984 where\n  open Field F\n\n  -- Vector addition\n  _+\u2c7d_ : Vec A n \u2192 Vec A n \u2192 Vec A n\n  _+\u2c7d_ = zipWith _+_\n\n  -- Vector substraction\n  _-\u2c7d_ : Vec A n \u2192 Vec A n \u2192 Vec A n\n  a -\u2c7d b = a +\u2c7d (map (-_) b)\n\n  -- Vector Hadamard product\n  _*\u2c7d_ : Vec A n \u2192 Vec A n \u2192 Vec A n\n  _*\u2c7d_ = zipWith _*_\n\n  -- Multiply vector by a constant\n  _\u2218\u2c7d_ : A \u2192 Vec A n \u2192 Vec A n\n  c \u2218\u2c7d v = map (c *_) v\n\n  -- Match the fixity of Haskell\n  infixl  6 _+\u2c7d_\n  infixl  6 _-\u2c7d_\n  infixl  7 _*\u2c7d_\n  infixl 10 _\u2218\u2c7d_\n\n  sum : Vec A n \u2192 A\n  sum = foldr _ _+_ 0\u1da0\n\n  -- Inner product\n  \u27e8_,_\u27e9 : Vec A n \u2192 Vec A n \u2192 A\n  \u27e8 v\u2081 , v\u2082 \u27e9 = sum (v\u2081 *\u2c7d v\u2082)\n", "meta": {"hexsha": "a25ad16d2b8f61cad3ee0900c1c3513fa79e3900", "size": 1054, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 21, "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_issues_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_forks_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "avg_line_length": 19.8867924528, "max_line_length": 54, "alphanum_fraction": 0.6138519924, "num_tokens": 433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480248488136, "lm_q2_score": 0.8418256412990658, "lm_q1q2_score": 0.7732002242040504}}
{"text": "module x05isomorphism where\n\n{-\n------------------------------------------------------------------------------\nIsomorphism: Isomorphism and Embedding\n\nisomorphism\n- way of asserting two types are equal\n\nembedding\n- way of asserting that one type is smaller than another\n\napply isomorphisms in next chapter to show 'product' and 'sum' satisfy properties\nsimilar to associativity, commutativity, and distributivity\n-}\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen        Eq                  using (_\u2261_; refl; cong; cong-app)\nopen        Eq.\u2261-Reasoning\nopen import Data.Nat            using (\u2115; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\n{-\n------------------------------------------------------------------------------\nLAMBDA EXPRESSIONS : ANONYMOUS FUNS\n\n\u03bb{ P\u2081 \u2192 N\u2081; \u22ef ; Pp\u2099 \u2192 Np }\n\nequivalent def by equations\n\nf P\u2081 = N\u2081\n\u22ef\nf Pp = Np\u2099\n\nwhere\n- P are patterns    (left-hand sides of an equation)\n- N are expressions (right-hand side of an equation)\n\nfor case of one equation and pattern is a variable:\n\n\u03bb x \u2192 N\n\nor\n\n\u03bb (x : A) \u2192 N\n\nequivalent to\n\n\u03bb{x \u2192 N}\n\n------------------------------------------------------------------------------\nFunction composition\n-}\n\n-- first apply f, then apply g to result\n_\u2218_ : \u2200 {A B C : Set} \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 (A \u2192 C)\n(g \u2218 f) x  = g (f x)\n\n\n-- equivalent\n_\u2218\u2032_ : \u2200 {A B C : Set} \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 (A \u2192 C)\ng \u2218\u2032 f  =  \u03bb x \u2192 g (f x)\n\n{-\n------------------------------------------------------------------------------\nEXTENSIONALITY : only way to distinguish functions is by applying them\n\nIf two functions applied to same arg always give same result, then they are same.\n\nconverse of cong-app\n\nAgda does not presume extensionality, so\n-}\n\npostulate\n  extensionality : \u2200 {A B : Set} {f g : A \u2192 B}\n    \u2192 (\u2200 (x : A) \u2192 f x \u2261 g x)\n      -----------------------\n    \u2192              f   \u2261 g\n\n{-\nPostulating extensionality does not lead to difficulties.\nIt is known to be consistent with the theory that underlies Agda.\n\nexample\n-}\n\n-- version that matches on right\n_+\u2032_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm +\u2032 zero  = m\nm +\u2032 suc n = suc (m +\u2032 n)\n\n-- using commutativity, show + and +\u2032 always return same result for same arg\nsame-app : \u2200 (m n : \u2115) \u2192 m +\u2032 n \u2261 m + n\nsame-app m n                --     (m +\u2032 n) \u2261      m + n\n  rewrite +-comm m n        --     (m +\u2032 n) \u2261      n + m\n  = helper m n\n where\n  helper : \u2200 (m n : \u2115) \u2192 m +\u2032 n \u2261 n + m\n  helper m   zero  = refl\n  helper m (suc n)          -- suc (m +\u2032 n) \u2261 suc (n + m)\n    = cong suc (helper m n)\n\n-- now assert + and +\u2032 to be indistinguishable (via two applications of extensionality)\nsame : _+\u2032_ \u2261 _+_\nsame = extensionality (\u03bb m \u2192 extensionality (\u03bb n \u2192 same-app m n))\n\n{-\nto postulate extensionality in what follows\n(and to postulate extensionality for dependent functions):\n-}\n\n-- type of f and g has changed from A \u2192 B to \u2200 (x : A) \u2192 B x\npostulate\n  \u2200-extensionality : \u2200 {A : Set} {B : A \u2192 Set} {f g : \u2200(x : A) \u2192 B x}\n    \u2192 (\u2200 (x : A) \u2192 f x \u2261 g x)\n      -----------------------\n    \u2192              f   \u2261 g\n\n{-\n------------------------------------------------------------------------------\nISOMORPHISM : sets are isomorphic if they are in one-to-one correspondence\n\nformal definition:\n-}\n\ninfix 0 _\u2243_\n\n-- RECORD\n-- isomorphism between sets A and B consists of four things\nrecord _\u2243_ (A B : Set) : Set where\n  field\n    to      : A \u2192 B                       -- function from A to B\n    from    : B \u2192 A                       -- function from B to A\n    from\u2218to : \u2200 (x : A) \u2192 from (to x) \u2261 x -- evidence asserting 'from' is a  left-inverse for 'to'\n    to\u2218from : \u2200 (y : B) \u2192 to (from y) \u2261 y -- evidence asserting 'from' is a right-inverse for 'to'\nopen _\u2243_ -- makes field names 'to', etc., available without needing to write '_\u2243_.to'\n\n{-\nfrom \u2218 to AND to \u2218 from are identities\n\nrecord declaration behaves similar to single-constructor data declaration\n(there are minor differences - see Connectives):\n-}\ndata _\u2243\u2032_ (A B : Set): Set where\n  mk-\u2243\u2032 : \u2200 (to      : A \u2192 B)\n        \u2192 \u2200 (from    : B \u2192 A)\n        \u2192 \u2200 (from\u2218to : (\u2200 (x : A) \u2192 from (to x) \u2261 x))\n        \u2192 \u2200 (to\u2218from : (\u2200 (y : B) \u2192 to (from y) \u2261 y))\n        \u2192 A \u2243\u2032 B\n\nto\u2032      : \u2200 {A B : Set} \u2192 (A \u2243\u2032 B) \u2192 (A \u2192 B)\nto\u2032      (mk-\u2243\u2032 f g g\u2218f f\u2218g) = f\n\nfrom\u2032    : \u2200 {A B : Set} \u2192 (A \u2243\u2032 B) \u2192 (B \u2192 A)\nfrom\u2032    (mk-\u2243\u2032 f g g\u2218f f\u2218g) = g\n\nfrom\u2218to\u2032 : \u2200 {A B : Set} \u2192 (A\u2243B : A \u2243\u2032 B) \u2192 (\u2200 (x : A) \u2192 from\u2032 A\u2243B (to\u2032 A\u2243B x) \u2261 x)\nfrom\u2218to\u2032 (mk-\u2243\u2032 f g g\u2218f f\u2218g) = g\u2218f\n\nto\u2218from\u2032 : \u2200 {A B : Set} \u2192 (A\u2243B : A \u2243\u2032 B) \u2192 (\u2200 (y : B) \u2192 to\u2032 A\u2243B (from\u2032 A\u2243B y) \u2261 y)\nto\u2218from\u2032 (mk-\u2243\u2032 f g g\u2218f f\u2218g) = f\u2218g\n\n{-\nconstruct record values via\n\nrecord\n  { to      = f\n  ; from    = g\n  ; from\u2218to = g\u2218f\n  ; to\u2218from = f\u2218g\n  }\n\ncorresponds to using the constructor of the corresponding inductive type\n\nmk-\u2243\u2032 f g g\u2218f f\u2218g\n\n------------------------------------------------------------------------------\nISOMORPHISM is an EQUIVALENCE : REFLEXIVE, SYMMETRIC, and TRANSITIVE\n-}\n\n-- REFLEXIVE\n\u2243-refl : \u2200 {A : Set}\n    -----\n  \u2192 A \u2243 A\n\u2243-refl =\n  record\n    { to      = \u03bb{x \u2192 x}    -- bind to identity function\n    ; from    = \u03bb{y \u2192 y}    -- ditto\n    -- refl next is proof since for left inverse, from (to x) simplifies to x, and vice versa\n    ; from\u2218to = \u03bb{x \u2192 refl} -- bound to fun that discards arg; returns refl\n    ; to\u2218from = \u03bb{y \u2192 refl} -- ditto\n    }\n\n-- SYMMETRIC : swap roles of to/from and from\u2218to/to\u2218from\n\u2243-sym : \u2200 {A B : Set}\n  \u2192 A \u2243 B\n    -----\n  \u2192 B \u2243 A\n\u2243-sym A\u2243B =\n  record\n    { to      = from    A\u2243B\n    ; from    = to      A\u2243B\n    ; from\u2218to = to\u2218from A\u2243B\n    ; to\u2218from = from\u2218to A\u2243B\n    }\n\n-- TRANSITIVE : compose to/from and use equational reasoning to combine inverses\n\u2243-trans : \u2200 {A B C : Set}\n  \u2192 A \u2243 B\n  \u2192 B \u2243 C\n    -----\n  \u2192 A \u2243 C\n\u2243-trans A\u2243B B\u2243C =\n  record\n    { to       = to   B\u2243C \u2218 to   A\u2243B\n    ; from     = from A\u2243B \u2218 from B\u2243C\n    ; from\u2218to  = \u03bb{x \u2192\n      begin\n        (from A\u2243B \u2218 from B\u2243C) ((to B\u2243C \u2218 to A\u2243B) x)   \u2261\u27e8\u27e9\n         from A\u2243B  (from B\u2243C   (to B\u2243C  (to A\u2243B  x))) \u2261\u27e8 cong (from A\u2243B) (from\u2218to B\u2243C (to A\u2243B x)) \u27e9\n         from A\u2243B                       (to A\u2243B  x)   \u2261\u27e8 from\u2218to A\u2243B x \u27e9\n                                                 x\n      \u220e}\n    ; to\u2218from = \u03bb{y \u2192\n      begin\n        (to B\u2243C \u2218 to A\u2243B) ((from A\u2243B \u2218 from B\u2243C) y)   \u2261\u27e8\u27e9\n         to B\u2243C  (to A\u2243B   (from A\u2243B  (from B\u2243C  y))) \u2261\u27e8 cong (to B\u2243C) (to\u2218from A\u2243B (from B\u2243C y)) \u27e9\n         to B\u2243C                       (from B\u2243C  y)   \u2261\u27e8 to\u2218from B\u2243C y \u27e9\n                                                 y\n      \u220e}\n     }\n{-\n------------------------------------------------------------------------------\nEQUATIONAL REASONING FOR ISOMORPHISM\n\nEssentially copy previous definition of equality for isomorphism.\nOmit the form that corresponds to _\u2261\u27e8\u27e9_,\nsince simple isomorphisms arise less often than simple equalities\n-}\n\nmodule \u2243-Reasoning where\n\n  infix  1 \u2243-begin_\n  infixr 2 _\u2243\u27e8_\u27e9_\n  infix  3 _\u2243-\u220e\n\n  \u2243-begin_ : \u2200 {A B : Set}\n    \u2192 A \u2243 B\n      -----\n    \u2192 A \u2243 B\n  \u2243-begin A\u2243B = A\u2243B\n\n  _\u2243\u27e8_\u27e9_ : \u2200 (A : Set) {B C : Set}\n    \u2192 A \u2243 B\n    \u2192 B \u2243 C\n      -----\n    \u2192 A \u2243 C\n  A \u2243\u27e8 A\u2243B \u27e9 B\u2243C = \u2243-trans A\u2243B B\u2243C\n\n  _\u2243-\u220e : \u2200 (A : Set)\n      -----\n    \u2192 A \u2243 A\n  A \u2243-\u220e = \u2243-refl\n\nopen \u2243-Reasoning\n\n{-\n------------------------------------------------------------------------------\nEMBEDDING : WEAKENING of ISOMORPHISM : EMBEDDING SHOWS 1ST TYPE INCLUDED IN SECOND\ni.e., there is many-to-one correspondence between second type and first\n-}\n\ninfix 0 _\u2272_\nrecord _\u2272_ (A B : Set) : Set where\n  field\n    to      : A \u2192 B\n    from    : B \u2192 A\n    from\u2218to : \u2200 (x : A) \u2192 from (to x) \u2261 x\nopen _\u2272_\n\n{-\nsame as isomorphism, except it omits 'to\u2218from' field\n- says 'from' is left-inverse for 'to', but not a right-inverse\n\nEMBEDDING IS NOT SYMMETRIC\n\nproofs of REFLEXIVE and TRANSITIVE same as ISOMORPHISM except omitting one unneeded case\n-}\n\n-- REFLEXIVE\n\u2272-refl : \u2200 {A : Set} \u2192 A \u2272 A\n\u2272-refl =\n  record\n    { to      = \u03bb{x \u2192 x}\n    ; from    = \u03bb{y \u2192 y}\n    ; from\u2218to = \u03bb{x \u2192 refl}\n    }\n\n-- TRANSITIVE\n\u2272-trans : \u2200 {A B C : Set} \u2192 A \u2272 B \u2192 B \u2272 C \u2192 A \u2272 C\n\u2272-trans A\u2272B B\u2272C =\n  record\n    { to      = \u03bb{x \u2192 to   B\u2272C (to   A\u2272B x)}\n    ; from    = \u03bb{y \u2192 from A\u2272B (from B\u2272C y)}\n    ; from\u2218to = \u03bb{x \u2192\n      begin\n        from A\u2272B (from B\u2272C (to B\u2272C (to A\u2272B x))) \u2261\u27e8 cong (from A\u2272B) (from\u2218to B\u2272C (to A\u2272B x)) \u27e9\n        from A\u2272B                   (to A\u2272B x)   \u2261\u27e8 from\u2218to A\u2272B x \u27e9\n                                           x\n      \u220e}\n     }\n{-\nweak form of ANTI-SYMMETRY\nif two types embed in each other, and embedding functions correspond, they are isomorphic\n-}\n\n\u2272-antisym : \u2200 {A B : Set}\n  \u2192 (A\u2272B : A \u2272 B)\n  \u2192 (B\u2272A : B \u2272 A)\n  \u2192 (to   A\u2272B \u2261 from B\u2272A)\n  \u2192 (from A\u2272B \u2261 to   B\u2272A)\n    -------------------\n  \u2192 A \u2243 B\n\u2272-antisym A\u2272B B\u2272A to\u2261from from\u2261to =\n  record\n    { to      = to      A\u2272B\n    ; from    = from    A\u2272B\n    ; from\u2218to = from\u2218to A\u2272B\n    ; to\u2218from = \u03bb{y \u2192\n      begin\n        to   A\u2272B (from A\u2272B y)   \u2261\u27e8 cong (to A\u2272B) (cong-app from\u2261to y) \u27e9\n        to   A\u2272B (to   B\u2272A y)   \u2261\u27e8 cong-app to\u2261from (to B\u2272A y) \u27e9\n        from B\u2272A (to   B\u2272A y)   \u2261\u27e8 from\u2218to B\u2272A y \u27e9\n                           y\n      \u220e}\n    }\n\n{-\nFirst three components are copied from the embedding.\nThe last combines left inverse of B \u2272 A with the equivalences of the 'to' and 'from' components\nfrom the two embeddings to obtain the right inverse of the isomorphism.\n\n------------------------------------------------------------------------------\nEquational reasoning for embedding\n-}\n\nmodule \u2272-Reasoning where\n\n  infix  1 \u2272-begin_\n  infixr 2 _\u2272\u27e8_\u27e9_\n  infix  3 _\u2272-\u220e\n\n  \u2272-begin_ : \u2200 {A B : Set}\n    \u2192 A \u2272 B\n      -----\n    \u2192 A \u2272 B\n  \u2272-begin A\u2272B = A\u2272B\n\n  _\u2272\u27e8_\u27e9_ : \u2200 (A : Set) {B C : Set}\n    \u2192 A \u2272 B\n    \u2192     B \u2272 C\n      -----\n    \u2192 A \u2272     C\n  A \u2272\u27e8 A\u2272B \u27e9 B\u2272C = \u2272-trans A\u2272B B\u2272C\n\n  _\u2272-\u220e : \u2200 (A : Set)\n      -----\n    \u2192 A \u2272 A\n  A \u2272-\u220e = \u2272-refl\n\nopen \u2272-Reasoning\n\n{-\n------------------------------------------------------------------------------\nExercise \u2243-implies-\u2272 (practice) Show that every isomorphism implies an embedding. TODO\n\npostulate\n  \u2243-implies-\u2272 : \u2200 {A B : Set}\n    \u2192 A \u2243 B\n      -----\n    \u2192 A \u2272 B\n-- Your code goes here\n\n------------------------------------------------------------------------------\nExercise _\u21d4_ (practice) Define equivalence of propositions TODO\n(also known as \u201cif and only if\u201d) as follows:\n\nrecord _\u21d4_ (A B : Set) : Set where\n  field\n    to   : A \u2192 B\n    from : B \u2192 A\nShow that equivalence is reflexive, symmetric, and transitive.\n\n-- Your code goes here\n\n------------------------------------------------------------------------------\nExercise Bin-embedding (stretch) TODO\n\nBin and Bin-laws define a datatype Bin of bitstrings representing natural numbers\nwith functions\n\nto : \u2115 \u2192 Bin\nfrom : Bin \u2192 \u2115\n\nthat satisfy\n\nfrom (to n) \u2261 n\n\nUsing the above, establish that there is an embedding of \u2115 into Bin.\n\n-- Your code goes here\n\nWhy do to and from not form an isomorphism?\n\n------------------------------------------------------------------------------\nStandard library\n\nimport Function             using (_\u2218_)\nimport Function.Inverse     using (_\u2194_)\nimport Function.LeftInverse using (_\u219e_)\n\nThe standard library _\u2194\ufe0e_ and _\u219e_ correspond to our _\u2243_ and _\u2272_, respectively,\nbut those in the standard library are less convenient,\nsince they depend on a nested record structure\nand are parameterised with regard to an arbitrary notion of equivalence.\n\n------------------------------------------------------------------------------\nUnicode\nThis chapter uses the following unicode:\n\n\u2218  U+2218  RING OPERATOR              (\\o, \\circ, \\comp)\n\u03bb  U+03BB  GREEK SMALL LETTER LAMBDA  (\\lambda, \\Gl)\n\u2243  U+2243  ASYMPTOTICALLY EQUAL TO    (\\~-)\n\u2272  U+2272  LESS-THAN OR EQUIVALENT TO (\\<~)\n\u21d4 U+21D4  LEFT RIGHT DOUBLE ARROW    (\\<=>)\n-}\n", "meta": {"hexsha": "2c2be464e1364b8ca3a116cf4e796be4674138ca", "size": 11547, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05isomorphism.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05isomorphism.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05isomorphism.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 26.3630136986, "max_line_length": 99, "alphanum_fraction": 0.489564389, "num_tokens": 4030, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.907312213841788, "lm_q2_score": 0.8519528038477824, "lm_q1q2_score": 0.77298718454785}}
{"text": "module hott.types.int where\n\n\nopen import hott.functions\nopen import hott.core\nimport hott.types.nat as nat\n\nopen nat using (\u2115)\n\ndata \u2124 : Type\u2080 where\n  zero : \u2124\n  +ve  : \u2115 \u2192 \u2124\n  -ve  : \u2115 \u2192 \u2124\n\nfromNat : \u2115 \u2192 \u2124\nfromNat nat.zero = zero\nfromNat (nat.succ n) = +ve n\n\nneg : \u2124 \u2192 \u2124\nneg zero = zero\nneg (+ve n) = -ve n\nneg (-ve n) = +ve n\n\n\nsuc : \u2124 \u2192 \u2124\nsuc zero                 = +ve 0\nsuc (+ve x)              = +ve (nat.succ x)\nsuc (-ve 0)              = zero\nsuc (-ve (nat.succ x))   = -ve x\n\n\npred : \u2124 \u2192 \u2124\npred zero                 = -ve 0\npred (-ve x)              = -ve (nat.succ x)\npred (+ve 0)              = zero\npred (+ve (nat.succ x))   = +ve x\n\n\nsuc\u2218pred~id : suc \u2218 pred ~ id\nsuc\u2218pred~id zero               = refl\nsuc\u2218pred~id (+ve 0)            = refl\nsuc\u2218pred~id (+ve (nat.succ x)) = refl\nsuc\u2218pred~id (-ve x)            = refl\n\n\npred\u2218suc~id : pred \u2218 suc ~ id\npred\u2218suc~id zero               = refl\npred\u2218suc~id (+ve x)            = refl\npred\u2218suc~id (-ve 0)            = refl\npred\u2218suc~id (-ve (nat.succ x)) = refl\n", "meta": {"hexsha": "4d5ec9a2b93a6697edf34ee3d1d023236100c2f3", "size": 1015, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/types/int.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/types/int.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/types/int.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.9019607843, "max_line_length": 44, "alphanum_fraction": 0.4985221675, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9653811651448431, "lm_q2_score": 0.8006920116079208, "lm_q1q2_score": 0.7729729870882228}}
{"text": "module #8 where\n\n{-\n  Define multiplication and exponentiation using recN. Verify that (N, +, 0, \u00d7, 1) is\n  a semiring using only indN. You will probably also need to use symmetry and transitivity of\n  equality, Lemmas 2.1.1 and 2.1.2.\n-}\n\nopen import Data.Nat\n\nrec\u2099 : \u2200{c}{C : Set c} \u2192 C \u2192 (\u2115 \u2192 C \u2192 C) \u2192 \u2115 \u2192 C\nrec\u2099 c\u2080 c\u209b zero = c\u2080\nrec\u2099 c\u2080 c\u209b (suc n) = c\u209b n (rec\u2099 c\u2080 c\u209b n)\n\nmul-rec\u2099 : \u2115 \u2192 \u2115 \u2192 \u2115\nmul-rec\u2099 n = rec\u2099 0 (\u03bb _ z \u2192 z + n)\n\nexp-rec\u2099 : \u2115 \u2192 \u2115 \u2192 \u2115\nexp-rec\u2099 n = rec\u2099 1 (\u03bb _ z \u2192 z * n)\n\nind-\u2115 : \u2200{k}{C : \u2115 \u2192 Set k} \u2192 C zero \u2192 ((n : \u2115) \u2192 C n \u2192 C (suc n)) \u2192 (n : \u2115) \u2192 C n\nind-\u2115 c0 cs zero = c0\nind-\u2115 c0 cs (suc n) = cs n (ind-\u2115 c0 cs n)\n\nrecord Semiring (X : Set) : Set where\n  field\n    \u03b5 : X\n    _\u2295_ : X \u2192 X \u2192 X\n    _\u229b_ : X \u2192 X \u2192 X\nopen Semiring {{...}} public\n\nnatIsSemiring : Semiring \u2115\nnatIsSemiring = record { \u03b5 = zero\n                       ; _\u2295_ = _+_\n                       ; _\u229b_ = _*_\n                       }\n\n{- Semiring Laws Follow -}\n\n\n", "meta": {"hexsha": "1fada7ccbf1f7dba8746424964a31642f2cdb124", "size": 951, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Chapter1/#8.agda", "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Chapter1/#8.agda", "max_issues_repo_name": "CodaFi/HoTT-Exercises", "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter1/#8.agda", "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1951219512, "max_line_length": 93, "alphanum_fraction": 0.523659306, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533163686646, "lm_q2_score": 0.8289388125473629, "lm_q1q2_score": 0.7729467448264913}}
{"text": "------------------------------------------------------------------------------\n-- Properties related with the group commutator\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule GroupTheory.Commutator.PropertiesI where\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\nopen import GroupTheory.Base\nopen import GroupTheory.Commutator\nopen import GroupTheory.PropertiesI\n\n------------------------------------------------------------------------------\n-- Kurosh (1960), p. 99.\ncommutatorInverse : \u2200 a b \u2192 [ a , b ] \u00b7 [ b , a ] \u2261 \u03b5\ncommutatorInverse a b =\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a \u00b7 b \u00b7 (b \u207b\u00b9 \u00b7 a \u207b\u00b9 \u00b7 b \u00b7 a)\n    \u2261\u27e8 assoc (a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a) b (b \u207b\u00b9 \u00b7 a \u207b\u00b9 \u00b7 b \u00b7 a) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a \u00b7 (b \u00b7 (b \u207b\u00b9 \u00b7 a \u207b\u00b9 \u00b7 b \u00b7 a))\n    \u2261\u27e8 \u00b7-rightCong (\u00b7-rightCong (assoc (b \u207b\u00b9 \u00b7 a \u207b\u00b9) b a)) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a \u00b7 (b \u00b7 (b \u207b\u00b9 \u00b7 a \u207b\u00b9 \u00b7 (b \u00b7 a)))\n    \u2261\u27e8 \u00b7-rightCong (\u00b7-rightCong (assoc (b \u207b\u00b9) (a \u207b\u00b9) (b \u00b7 a))) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a \u00b7 (b \u00b7 (b \u207b\u00b9 \u00b7 (a \u207b\u00b9 \u00b7 (b \u00b7 a))))\n    \u2261\u27e8 \u00b7-rightCong (sym (assoc b (b \u207b\u00b9) (a \u207b\u00b9 \u00b7 (b \u00b7 a)))) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a \u00b7 (b \u00b7 b \u207b\u00b9 \u00b7 (a \u207b\u00b9 \u00b7 (b \u00b7 a)))\n    \u2261\u27e8 \u00b7-rightCong (\u00b7-leftCong (rightInverse b)) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a \u00b7 (\u03b5 \u00b7 (a \u207b\u00b9 \u00b7 (b \u00b7 a)))\n    \u2261\u27e8 \u00b7-rightCong (leftIdentity (a \u207b\u00b9 \u00b7 (b \u00b7 a))) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 a \u00b7 (a \u207b\u00b9 \u00b7 (b \u00b7 a))\n    \u2261\u27e8 assoc (a \u207b\u00b9 \u00b7 b \u207b\u00b9) a (a \u207b\u00b9 \u00b7 (b \u00b7 a)) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 (a \u00b7 (a \u207b\u00b9 \u00b7 (b \u00b7 a)))\n    \u2261\u27e8 \u00b7-rightCong (sym (assoc a (a \u207b\u00b9) (b \u00b7 a))) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 (a \u00b7 a \u207b\u00b9 \u00b7 (b \u00b7 a))\n    \u2261\u27e8 \u00b7-rightCong (\u00b7-leftCong (rightInverse a)) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 (\u03b5 \u00b7 (b \u00b7 a))\n    \u2261\u27e8 \u00b7-rightCong (leftIdentity (b \u00b7 a)) \u27e9\n  a \u207b\u00b9 \u00b7 b \u207b\u00b9 \u00b7 (b \u00b7 a)\n    \u2261\u27e8 assoc (a \u207b\u00b9) (b \u207b\u00b9) (b \u00b7 a) \u27e9\n  a \u207b\u00b9 \u00b7 (b \u207b\u00b9 \u00b7 (b \u00b7 a))\n     \u2261\u27e8 \u00b7-rightCong (sym (assoc (b \u207b\u00b9) b a)) \u27e9\n  a \u207b\u00b9 \u00b7 ((b \u207b\u00b9 \u00b7 b) \u00b7 a)\n     \u2261\u27e8 \u00b7-rightCong (\u00b7-leftCong (leftInverse b)) \u27e9\n  a \u207b\u00b9 \u00b7 (\u03b5 \u00b7 a)\n     \u2261\u27e8 \u00b7-rightCong (leftIdentity a) \u27e9\n  a \u207b\u00b9 \u00b7 a\n     \u2261\u27e8 leftInverse a \u27e9\n  \u03b5 \u220e\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Kurosh, A. G. (1960). The Theory of Groups. 2nd\n-- ed. Vol. 1. Translated and edited by K. A. Hirsch. Chelsea\n-- Publising Company.\n", "meta": {"hexsha": "1eed7cc852e1713825e7f435059dc43890f2547c", "size": 2279, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/Commutator/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/GroupTheory/Commutator/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/GroupTheory/Commutator/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 37.9833333333, "max_line_length": 78, "alphanum_fraction": 0.4028082492, "num_tokens": 935, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970873650401, "lm_q2_score": 0.8774767938900121, "lm_q1q2_score": 0.7728790042887363}}
{"text": "------------------------------------------------------------------------------\n-- Even predicate\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule FOTC.Even where\n\nopen import FOTC.Base\nopen import FOTC.Data.Nat.Type\n\n------------------------------------------------------------------------------\n\ndata Even : D \u2192 Set where\n  ezero :                  Even zero\n  enext : \u2200 {n} \u2192 Even n \u2192 Even (succ\u2081 (succ\u2081 n))\n\nEven-ind : (A : D \u2192 Set) \u2192\n           A zero \u2192\n           (\u2200 {n} \u2192 A n \u2192 A (succ\u2081 (succ\u2081 n))) \u2192\n           \u2200 {n} \u2192 Even n \u2192 A n\nEven-ind A A0 h ezero      = A0\nEven-ind A A0 h (enext En) = h (Even-ind A A0 h En)\n\nEven\u2192N : \u2200 {n} \u2192 Even n \u2192 N n\nEven\u2192N ezero      = nzero\nEven\u2192N (enext En) = nsucc (nsucc (Even\u2192N En))\n", "meta": {"hexsha": "1c10510d44e0775ad2a859ad05a6d61731b10add", "size": 937, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/thesis/report/FOTC/Even.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/thesis/report/FOTC/Even.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/thesis/report/FOTC/Even.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.2258064516, "max_line_length": 78, "alphanum_fraction": 0.3820704376, "num_tokens": 234, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947179030095, "lm_q2_score": 0.8175744695262775, "lm_q1q2_score": 0.7726035551946873}}
{"text": "open import x1-Base\n\nmodule x4-Nat where\n\ndata \u2115 : Set where\n  zero :     \u2115\n  suc  : \u2115 \u2192 \u2115\n{-# BUILTIN NATURAL \u2115 #-}\n\ndata _\u2264_ : Rel \u2115 where\n  z\u2264n : \u2200 {x}   \u2192 zero \u2264 x\n  s\u2264s : \u2200 {x y} \u2192     x \u2264     y\n                \u2192 suc x \u2264 suc y\n\n\u2264-suc : \u2200 {x y} \u2192 suc x \u2264 suc y\n                \u2192     x \u2264     y\n\u2264-suc (s\u2264s x\u2264y) = x\u2264y\n\n_\u2264?_ : Decidable _\u2264_\nzero  \u2264? _      = left  z\u2264n\nsuc _ \u2264? zero   = right \u03bb()\nsuc x \u2264? suc y with x \u2264? y\n... | left  x\u2264y = left  (s\u2264s x\u2264y)\n... | right x>y = right (\u03bb sx\u2264sy \u2192 x>y (\u2264-suc sx\u2264sy))\n\nopen import x3-PropositionalEquality using (_\u2261_; refl; cong; equivalence)\n\nantisym : \u2200 {x y} \u2192 x \u2264 y \u2192 y \u2264 x \u2192 x \u2261 y\nantisym  z\u2264n       z\u2264n      = refl\nantisym (s\u2264s x\u2264y) (s\u2264s y\u2264x) = cong suc (antisym x\u2264y y\u2264x)\n\ntrans : \u2200 {x y z} \u2192 x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 z\ntrans  z\u2264n             _  = z\u2264n\ntrans (s\u2264s x\u2264y) (s\u2264s y\u2264z) = s\u2264s (trans x\u2264y y\u2264z)\n\ntotal : \u2200 x y \u2192 Either (x \u2264 y) (y \u2264 x)\ntotal  zero        _ = left  z\u2264n\ntotal (suc x)   zero = right z\u2264n\ntotal (suc x) (suc y) with total x y\n... | left  x\u2264y      = left  (s\u2264s x\u2264y)\n... | right y\u2264x      = right (s\u2264s y\u2264x)\n\nreflexive : \u2200 {x y} \u2192 x \u2261 y \u2192 x \u2264 y\nreflexive {zero}  refl = z\u2264n\nreflexive {suc _} refl = s\u2264s (reflexive refl)\n\ntotalOrder : TotalOrder _\u2261_ _\u2264_\ntotalOrder = record\n  { antisym     = antisym\n  ; trans       = trans\n  ; total       = total\n  ; reflexive   = reflexive\n  ; equivalence = equivalence\n  }\n\n", "meta": {"hexsha": "6cbd099bd646bad9274e6d75322d1b26e2cb3880", "size": 1368, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x4-Nat.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x4-Nat.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/topic/order/2013-04-01-sorting-francesco-mazzo/x4-Nat.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 24.4285714286, "max_line_length": 73, "alphanum_fraction": 0.4970760234, "num_tokens": 620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9504109770159682, "lm_q2_score": 0.8128673178375735, "lm_q1q2_score": 0.7725580217303578}}
{"text": "-- exercises-01-monday.agda\n\nopen import Data.Nat\n\nvariable\n  A B C : Set\n\n-- Exercise 1\n\nadd3 : \u2115 \u2192 \u2115\nadd3 x = x + 3\n\ntw : (A \u2192 A) \u2192 A \u2192 A\ntw f n = f (f n) -- tw = \u03bb f n \u2192 f (f n)\n\n-- evaluate: \"tw tw add3 1\"; derive the result (in a comment) step by step\n{-\n    tw tw add3 1 =\n  = tw (tw add3) 1 =\n  = (tw add3) (tw add3 1) =\n  = (tw add3) (add3 (add3 1))\n  = tw add3 7 =\n  = add3 (add3 7) =\n  = 13\n-}\n\n-- Exercise 2\n\n-- derive lambda terms with the following types\n\nf\u2080 : (A \u2192 B) \u2192 (B \u2192 C) \u2192 (A \u2192 C)\nf\u2080 f g a = g (f a)\n\nf\u2081 : (A \u2192 B) \u2192 ((A \u2192 C) \u2192 C) \u2192 ((B \u2192 C) \u2192 C)\nf\u2081 f g h = g \u03bb a -> h (f a)\n\nf\u2082 : (A \u2192 B \u2192 C) \u2192 B \u2192 A \u2192 C\nf\u2082 f b a = f a b\n\n-- Exercise 3\n\n-- derive a function tw-c which behaves the same as tw using only S, K (and I\n-- which is defined using S and K below).\n\nK : A \u2192 B \u2192 A\nK = \u03bb a b \u2192 a\n\nS : (A \u2192 B \u2192 C) \u2192 (A \u2192 B) \u2192 A \u2192 C\nS = \u03bb f g x \u2192 f x (g x)\n\n-- I = \u03bb x \u2192 x\nI : A \u2192 A\nI {A} = S K (K {B = A})\n\n{-\n    \u03bb f n \u2192 f (f n) =\n  = \u03bb f \u2192 \u03bb n \u2192 f (f n) =\n  = \u03bb f \u2192 S (\u03bb n \u2192 f) (\u03bb n \u2192 f n) =\n  = \u03bb f \u2192 S (K f) f =\n  = S (\u03bb f \u2192 S (K f) (\u03bb f \u2192 f) =\n  = S (S (\u03bb f \u2192 S) (\u03bb f \u2192 (K f)) I =\n  = S (S (K S) K) I =\n-}\n\ntw-c : (A \u2192 A) \u2192 A \u2192 A\ntw-c = S (S (K S) K) I\n", "meta": {"hexsha": "3b8af5ba63501576f184f8c91471b6c2573831c7", "size": 1168, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Type Theory/exercises-01-monday.agda", "max_stars_repo_name": "FoxySeta/mgs-2021", "max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Type Theory/exercises-01-monday.agda", "max_issues_repo_name": "FoxySeta/mgs-2021", "max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z", "max_forks_repo_path": "Type Theory/exercises-01-monday.agda", "max_forks_repo_name": "FoxySeta/mgs-2021", "max_forks_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.4328358209, "max_line_length": 77, "alphanum_fraction": 0.4409246575, "num_tokens": 546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9086178870347122, "lm_q2_score": 0.8499711775577735, "lm_q1q2_score": 0.7722990153929504}}
{"text": "{-# OPTIONS --sized-types #-}\nmodule SNat.Order where\n\nopen import Size\nopen import SNat\n\ndata _\u2264_ : {\u03b9 \u03b9' : Size} \u2192 SNat {\u03b9} \u2192 SNat {\u03b9'} \u2192 Set where\n  z\u2264n : {\u03b9 \u03b9' : Size} \n                   \u2192 (n : SNat {\u03b9'}) \n                   \u2192  _\u2264_ (zero {\u03b9}) n\n  s\u2264s : {\u03b9 \u03b9' : Size}{m : SNat {\u03b9}}{n : SNat {\u03b9'}} \n                   \u2192 m \u2264 n \n                   \u2192 (succ m) \u2264 (succ n)\n\ndata _\u2245_ : {\u03b9 \u03b9' : Size} \u2192 SNat {\u03b9} \u2192 SNat {\u03b9'} \u2192 Set where\n  z\u2245z : {\u03b9 \u03b9' : Size} \n                   \u2192 zero {\u03b9} \u2245 zero {\u03b9'}\n  s\u2245s : {\u03b9 \u03b9' : Size}{m : SNat {\u03b9}}{n : SNat {\u03b9'}} \n                   \u2192 m \u2245 n \n                   \u2192 succ m \u2245 succ n\n\ndata _\u2264\u2032_ : {\u03b9 \u03b9' : Size} \u2192 SNat {\u03b9} \u2192 SNat {\u03b9'} \u2192 Set where\n  \u2264\u2032-eq : {\u03b9 \u03b9' : Size}{m : SNat {\u03b9}}{n : SNat {\u03b9'}} \n                   \u2192 m \u2245 n \n                   \u2192 m \u2264\u2032 n\n  \u2264\u2032-step : {\u03b9 \u03b9' : Size}{m : SNat {\u03b9}}{n : SNat {\u03b9'}} \n                   \u2192 m \u2264\u2032 n \n                   \u2192 m \u2264\u2032 succ n\n", "meta": {"hexsha": "653609f43a358946ac44370a671ba888eb9cb663", "size": 904, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SNat/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SNat/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SNat/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.1724137931, "max_line_length": 60, "alphanum_fraction": 0.3462389381, "num_tokens": 362, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377261041521, "lm_q2_score": 0.8056321913146127, "lm_q1q2_score": 0.7722288487390141}}
{"text": "\nmodule Prelude.Fin where\n\nopen import Prelude.Nat\nopen import Prelude.Equality\nopen import Prelude.Decidable\nopen import Prelude.Ord\nopen import Prelude.Bool\nopen import Prelude.Function\nopen import Prelude.Number\nopen import Prelude.Nat.Properties using (suc-inj)\n\ndata Fin : Nat \u2192 Set where\n  zero : \u2200 {n} \u2192 Fin (suc n)\n  suc  : \u2200 {n} (i : Fin n) \u2192 Fin (suc n)\n\nfinToNat : \u2200 {@erased n} \u2192 Fin n \u2192 Nat\nfinToNat  zero   = zero\nfinToNat (suc i) = suc (finToNat i)\n\nfinToNat-inj : \u2200 {@erased n} {i j : Fin n} \u2192 finToNat i \u2261 finToNat j \u2192 i \u2261 j\nfinToNat-inj {i = zero } {zero } p = refl\nfinToNat-inj {i = zero } {suc j} ()\nfinToNat-inj {i = suc i} {zero } ()\nfinToNat-inj {i = suc i} {suc j} p rewrite finToNat-inj (suc-inj p) = refl\n\nnatToFin : \u2200 {n} (m : Nat) {{m<n : IsTrue (lessNat m n)}} \u2192 Fin n\nnatToFin {zero }  _   {{}}\nnatToFin {suc n}  zero   = zero\nnatToFin {suc n} (suc m) = suc (natToFin m)\n\ninstance\n  NumberFin : \u2200 {n} \u2192 Number (Fin n)\n  Number.Constraint (NumberFin {n}) k = IsTrue (lessNat k n)\n  fromNat {{NumberFin}} = natToFin\n\n--- Equality ---\n\nfsuc-inj : \u2200 {@erased n} {i j : Fin n} \u2192 Fin.suc i \u2261 suc j \u2192 i \u2261 j\nfsuc-inj refl = refl\n\nprivate\n  eqFin : \u2200 {@erased n} (i j : Fin n) \u2192 Dec (i \u2261 j)\n  eqFin  zero    zero    = yes refl\n  eqFin  zero   (suc  j) = no \u03bb ()\n  eqFin (suc i)  zero    = no \u03bb ()\n  eqFin (suc i) (suc  j) with eqFin i j\n  eqFin (suc i) (suc .i) | yes refl = yes refl\n  eqFin (suc i) (suc  j) | no neq   = no \u03bb eq \u2192 neq (fsuc-inj eq)\n\ninstance\n  EqFin : \u2200 {n} \u2192 Eq (Fin n)\n  _==_ {{EqFin}} = eqFin\n\n--- Ord ---\n\ninstance\n  OrdFin : \u2200 {n} \u2192 Ord (Fin n)\n  OrdFin = OrdBy finToNat-inj\n\n  OrdLawsFin : \u2200 {n} \u2192 Ord/Laws (Fin n)\n  OrdLawsFin = OrdLawsBy finToNat-inj\n", "meta": {"hexsha": "657d7566dba652024ce9c87319177f4e191b1127", "size": 1698, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Fin.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Fin.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Fin.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 26.9523809524, "max_line_length": 76, "alphanum_fraction": 0.6083627797, "num_tokens": 665, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218284193597, "lm_q2_score": 0.8376199694135333, "lm_q1q2_score": 0.7722201337222928}}
{"text": "------------------------------------------------------------------------------\n-- Data and postulates\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\n-- Are the FOTC natural numbers defined by data and postulates the\n-- same?\n\nmodule DataPostulate where\n\n------------------------------------------------------------------------------\npostulate\n  D    : Set\n  zero : D\n  succ : D \u2192 D\n\n-- The FOTC natural numbers using data.\ndata N : D \u2192 Set where\n  zN :               N zero\n  sN : \u2200 {n} \u2192 N n \u2192 N (succ n)\n\nN-ind : (P : D \u2192 Set) \u2192\n        P zero \u2192\n        (\u2200 {n} \u2192 N n \u2192 P n \u2192 P (succ n)) \u2192\n        \u2200 {n} \u2192 N n \u2192 P n\nN-ind P P0 h zN      = P0\nN-ind P P0 h (sN Nn) = h Nn (N-ind P P0 h Nn)\n\n-- The FOTC natural numbers using postulates (we chose 'M' by 'Model').\npostulate\n  M    : D \u2192 Set\n  zM   : M zero\n  sM   : \u2200 {n} \u2192 M n \u2192 M (succ n)\n  M-ind : (P : D \u2192 Set) \u2192\n          P zero \u2192\n          (\u2200 {n} \u2192 M n \u2192 P n \u2192 P (succ n)) \u2192\n          \u2200 {n} \u2192 M n \u2192 P n\n\n------------------------------------------------------------------------------\n-- The predicates\n\n-- From the data predicate to the postulated one: Using the induction\n-- principle.\nnat-D2P : \u2200 {n} \u2192 N n \u2192 M n\nnat-D2P = N-ind M zM (\u03bb _ Mn \u2192 sM Mn)\n\n-- From the data predicate to the postulated one: Using pattern\n-- matching.\nnat-D2P' : \u2200 {n} \u2192 N n \u2192 M n\nnat-D2P' zN      = zM\nnat-D2P' (sN Nn) = sM (nat-D2P' Nn)\n\n-- From the postulated predicate to the data one.\nnat-P2D : \u2200 {n} \u2192 M n \u2192 N n\nnat-P2D = M-ind N zN (\u03bb _ Nn \u2192 sN Nn)\n\n------------------------------------------------------------------------------\n-- The induction principles\n\n-- The postulated inductive principle from the data one.\nD2P-ind : (P : D \u2192 Set) \u2192 P zero \u2192\n          (\u2200 {n} \u2192 M n \u2192 P n \u2192 P (succ n)) \u2192\n          \u2200 {n} \u2192 M n \u2192 P n\nD2P-ind P P0 ih Mn = N-ind P P0 (\u03bb {_} Nn \u2192 ih (nat-D2P Nn)) (nat-P2D Mn)\n\n-- The data inductive principle from the postulated one.\nP2D-ind : (P : D \u2192 Set) \u2192 P zero \u2192\n          (\u2200 {n} \u2192 N n \u2192 P n \u2192 P (succ n)) \u2192\n          \u2200 {n} \u2192 N n \u2192 P n\nP2D-ind P P0 ih Nn = M-ind P P0 (\u03bb {_} Mn \u2192 ih (nat-P2D Mn)) (nat-D2P Nn)\n", "meta": {"hexsha": "d4a576932de3da699f1921e2c2cd8505c61b26ec", "size": 2282, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/DataPostulate.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/DataPostulate.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/DataPostulate.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.4266666667, "max_line_length": 78, "alphanum_fraction": 0.430324277, "num_tokens": 709, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026505426831, "lm_q2_score": 0.8418256492357358, "lm_q1q2_score": 0.7722088993387555}}
{"text": "module List.Permutation.Base.Equivalence (A : Set) where\n\nopen import List.Permutation.Base A\nopen import Data.List\nopen import Data.Product renaming (_\u00d7_ to _\u2227_)\n\nrefl\u223c : {xs : List A} \u2192 xs \u223c xs\nrefl\u223c {[]}     = \u223c[] \nrefl\u223c {x \u2237 xs} = \u223cx /head /head refl\u223c\n\nsym\u223c : {xs ys : List A} \u2192 xs \u223c ys \u2192 ys \u223c xs\nsym\u223c \u223c[] = \u223c[] \nsym\u223c (\u223cx xs/x\u27f6xs' ys/x\u27f6ys' xs'\u223cys') = \u223cx ys/x\u27f6ys' xs/x\u27f6xs' (sym\u223c xs'\u223cys')\n\nlemma// : {x y : A}{xs ys zs : List A} \u2192 xs / x \u27f6 ys \u2192 ys / y \u27f6 zs \u2192 \u2203 (\u03bb ws \u2192 xs / y \u27f6 ws \u2227 ws / x \u27f6 zs)\nlemma//  (/head {x = x}) (/head {xs = xs}) = x \u2237 xs , /tail /head , /head\nlemma// (/head {x = x}) (/tail {x = u} {ys = us'} us/y\u27f6us') = x \u2237 u \u2237 us' , /tail (/tail us/y\u27f6us') , /head\nlemma// (/tail {xs = us} us/x\u27f6us') /head = us , /head , us/x\u27f6us'\nlemma// (/tail {x = u} us/x\u27f6us') (/tail us'/y\u27f6us'') \n    with lemma// us/x\u27f6us' us'/y\u27f6us''\n... | ws' , us/y\u27f6ws' , ws'/x\u27f6us'' = u \u2237 ws' , /tail us/y\u27f6ws' ,  /tail ws'/x\u27f6us''\n\nlemma\u223c/\u2237 : {x : A}{xs ys : List A} \u2192 (x \u2237 xs) \u223c ys \u2192 \u2203 (\u03bb ys' \u2192 ys / x \u27f6 ys' \u2227 xs \u223c ys')\nlemma\u223c/\u2237  (\u223cx {ys' = vs'} /head ys/x\u27f6vs' xs\u223cvs') = vs' , ys/x\u27f6vs' , xs\u223cvs'\nlemma\u223c/\u2237  (\u223cx (/tail xs/u\u27f6us') ys/u\u27f6vs' x\u2237us'\u223cvs') \n    with lemma\u223c/\u2237 x\u2237us'\u223cvs' \n... | _ , vs'/x\u27f6zs , us'\u223czs \n    with lemma// ys/u\u27f6vs' vs'/x\u27f6zs\n... | ws , ys/x\u27f6ws , ws/u\u27f6zs = ws , ys/x\u27f6ws , \u223cx xs/u\u27f6us' ws/u\u27f6zs us'\u223czs\n\nlemma\u223c/ : {x : A}{xs xs' ys : List A} \u2192 xs \u223c ys \u2192 xs / x  \u27f6 xs' \u2192 \n                   \u2203 (\u03bb ys' \u2192 ys / x \u27f6 ys' \u2227 xs' \u223c ys')\nlemma\u223c/ u\u2237us\u223cys /head = lemma\u223c/\u2237 u\u2237us\u223cys\nlemma\u223c/ u\u2237us\u223cys (/tail us/x\u27f6xs') \n    with lemma\u223c/\u2237 u\u2237us\u223cys \n... | _ , ys/u\u27f6ys' , us\u223cys' \n    with lemma\u223c/ us\u223cys' us/x\u27f6xs'\n... | _ , ys'/x\u27f6vs , xs'\u223cvs \n    with lemma// ys/u\u27f6ys' ys'/x\u27f6vs\n... | ws , ys/x\u27f6ws , ws/u\u27f6vs = ws , ys/x\u27f6ws , \u223cx /head ws/u\u27f6vs xs'\u223cvs\n\ntrans\u223c : {xs ys zs : List A} \u2192 xs \u223c ys \u2192 ys \u223c zs \u2192 xs \u223c zs\ntrans\u223c \u223c[] \u223c[] = \u223c[]\ntrans\u223c \u223c[] (\u223cx .{xs = []} () zs/x\u27f6zs' ys'\u223czs') \ntrans\u223c {zs = zs} (\u223cx {ys = ys} xs/x\u27f6xs' ys/x\u27f6ys' xs'\u223cys') ys\u223czs \n    with lemma\u223c/ {xs = ys} ys\u223czs ys/x\u27f6ys'\n... | _ , zs/x\u27f6us , ys'\u223cus = \u223cx xs/x\u27f6xs' zs/x\u27f6us (trans\u223c xs'\u223cys' ys'\u223cus)\n\n", "meta": {"hexsha": "e0ccccb2b88f2a4e1b80e1aae48de4852ee0bbfd", "size": 2030, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Permutation/Base/Equivalence.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Permutation/Base/Equivalence.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Permutation/Base/Equivalence.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.4285714286, "max_line_length": 106, "alphanum_fraction": 0.4689655172, "num_tokens": 1057, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625050654263, "lm_q2_score": 0.8289388040954683, "lm_q1q2_score": 0.7721254150087035}}
{"text": "module HC-Lec1 where\n\n-- ==============================================================================\n-- Lecture 1 : Programs and Proofs\n-- https://www.youtube.com/watch?v=O4oczQry9Jw&t=1412s\n\n------------------------------------------------------------------------------\n-- some basic logical types\n\n-- 13:22 -- like Haskell Void\ndata Zero : Set where\n  -- No constructors, so no inhabitants\n  -- Represents logical impossibility.\n\n-- 16:45 -- like Haskell ()\nrecord One : Set where\n  constructor <> -- added in video Lecture 2 4:50\n  -- This record has no fields.\n  -- This record has exactly one inhabitant.\n\n-- 18:42 -- like Haskell Either\ndata _+_ (S : Set) (T : Set) : Set where\n  inl : S -> S + T -- left  constructor\n  inr : T -> S + T -- right constructor\n\n-- 24:50 -- like Haskell pair ( , )\nrecord _*_ (S : Set) (T : Set) : Set where\n  constructor _,_ -- added in video Lecture 2 4:58\n  field\n    fst : S\n    snd : T\n\n------------------------------------------------------------------------------\n-- examples\n\n-- 28:36\ncomm-* : {A : Set} {B : Set} -> A * B -> B * A\ncomm-* record { fst = a ; snd = b } = record { fst = b ; snd = a }\n\n-- 43:00\nassocLR-+ : {A B C : Set} -> (A + B) + C -> A + (B + C)\nassocLR-+ (inl (inl a)) =      inl a\nassocLR-+ (inl (inr b)) = inr (inl b)\nassocLR-+      (inr c)  = inr (inr c)\n\n-- 47:34\n-- If you can arrive at a contradiction, then you can derive any conclusion.\n-- Given a Zero, must produce an X for ANY X.\n-- But there are no inhabitants of Zero.\n-- So use 'absurd' pattern that indicates something that is IMPOSSIBLE.\nnaughtE : {X : Set} -> Zero -> X\nnaughtE ()\n\n-- standard composition: f << g is \"f after g\"\n_<<_ : {X Y Z : Set} -> (Y -> Z) -> (X -> Y) -> (X -> Z)\n(f << g) x = f (g x)\n\n-- diagrammatic composition: f >> g is \"f then g\"\n_>>_ : {X Y Z : Set} -> (X -> Y) -> (Y -> Z) -> (X -> Z)\n                     --       ^^^^^^^^          dominoes!\n(f >> g) x = g (f x)\n\n-- infix application\n_$_ : {S : Set}{T : S -> Set}(f : (x : S) -> T x)(s : S) -> T s\nf $ s = f s\ninfixl 2 _$_\n\n-- ==============================================================================\n-- Lecture 2 : more Programs and Proof, Introducing \"with\"\n-- https://www.youtube.com/watch?v=qcVZxQTouDk\n\n-- 2:25\n_$*_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A * B -> A' * B'\n(a\u2192a' $* b\u2192b') (a , b) = (a\u2192a' a) , (b\u2192b' b)\n\n-- 6:53\n_$+_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A + B -> A' + B'\n(a\u2192a' $+ b\u2192b') (inl a) = inl (a\u2192a' a)\n(a\u2192a' $+ b\u2192b') (inr b) = inr (b\u2192b' b)\n\n-- 8:52 -- like Haskell const ; this is pure for applicative functor needing an E\ncombinatorK : {A E : Set} -> A -> E -> A\ncombinatorK a _ = a\n\n-- 11:25 -- this is application\ncombinatorS : {S T E : Set} -> (E -> S -> T) -> (E -> S) -> E -> T\ncombinatorS e\u2192s\u2192t e\u2192s e = e\u2192s\u2192t e (e\u2192s e)\n\n-- 14:50\nidK : {X : Set} -> X -> X\nidK x = combinatorK x x\n\n-- 19:00\nidSKK : {X : Set} -> X -> X\nidSKK {X} = combinatorS combinatorK (combinatorK {E = X}) -- 'Zero' and 'One' also work\n\nid : {X : Set} -> X -> X\n-- id x = x -- is the easy way; let's do it a funny way to make a point\nid = combinatorS combinatorK (combinatorK {_} {Zero})\n--                          no choice for -^   ^^^^- could be anything\n\n-- 30:25\n-- naughtE\n\n------------------------------------------------------------------------------\n-- from logic to data\n\n-- 32:05\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat -- recursive data type\n{-# BUILTIN NATURAL Nat #-} -- enables decimal notation\n\n-- 32:58\n_+N_ : Nat -> Nat -> Nat\nzero  +N y = y\nsuc x +N y = suc (x +N y)\n\nfour : Nat\nfour = 2 +N 2\n\n------------------------------------------------------------------------------\n-- and back to logic\n\n-- 36:46\ndata _==_ {X : Set} : X -> X -> Set where\n  refl : (x : X) -> x == x -- the relation that is \"only reflexive\"\n{-# BUILTIN EQUALITY _==_ #-}\n\nsee4 : (2 +N 2) == 4\nsee4 = refl 4\n\n-- 42:35\n-- application of equalities\n_=$=_ : {X Y : Set} {f f' : X -> Y} {x x' : X}\n     -> f   == f'\n     ->   x ==    x'\n     -> f x == f' x\nrefl f =$= refl x = refl (f x)\n\n------------------------------------------------------------------------------\n-- computing types\n\n-- 45:00\n_>=_ : Nat -> Nat -> Set\nx     >= zero  = One     -- i.e., true\nzero  >= suc y = Zero    -- i.e., false\nsuc x >= suc y = x >= y\n\n--a0 : 2 >= 4\n--a0 = {!!}\n\na1 : 4 >= 2\na1 = <>\n\nrefl->= : (n : Nat) -> n >= n\nrefl->=  zero   = <>\nrefl->= (suc n) = refl->= n\n\ntrans->= : (x y z : Nat) -> x >= y -> y >= z  -> x >= z\ntrans->= zero     zero        z  x>=y y>=z = y>=z\ntrans->= (suc x)  zero    zero   x>=y y>=z = <>\ntrans->= (suc x) (suc y)  zero   x>=y y>=z = <>\ntrans->= (suc x) (suc y) (suc z) x>=y y>=z = trans->= x y z x>=y y>=z\n\n------------------------------------------------------------------------------\n-- construction by proof\n\n-- 47:38\n\nrecord Sg (S : Set) (T : S -> Set) : Set where -- Sg is short for \"Sigma\"\n  constructor _,_\n  field\n    fst : S       -- a value\n    snd : T fst   -- some evidence about that value\n\ndifference : (m n : Nat) -> m >= n -> Sg Nat \u03bb d -> m == (n +N d)\ndifference      m   zero   m>=n = m , refl m\ndifference  zero   (suc n) ()\ndifference (suc m) (suc n) m>=n\n  with difference m n m>=n\n...| d , e\n   = d , xxx m n d e\n where\n  xxx : \u2200 (m n d : Nat) -> m == (n +N d) -> suc m == suc (n +N d)\n  xxx m n d p rewrite p = refl (suc (n +N d))\n\n-- ==============================================================================\n-- Lecture 3 : Proof by induction\n-- https://www.youtube.com/watch?v=8xFT9FPlm18\n\n-- 6:20\n-- Nat with zero, +N and assocLR-+ form a monoid.\n\n-- 8:48\nzero-+N : (n : Nat) -> (zero +N n) == n\nzero-+N n = refl n -- by definition\n\n-- 9:36\n-- version in video\n-- +N-zero' : (n : Nat) -> (n +N zero) == n\n-- +N-zero'  zero   = refl zero -- by definition\n-- +N-zero' (suc n) = refl suc =$= +N-zero' n -- TODO : does not compile\n\n-- HC alternate version\n+N-zero : (n : Nat) -> (n +N zero) == n\n+N-zero  zero   = refl zero -- by definition\n+N-zero (suc n)\n  with +N-zero n\n...| n+N0==n\n  rewrite n+N0==n\n   = refl (suc n)\n\n-- 26:00\n-- version in video\n-- assocLR-+N' : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z))\n-- assocLR-+N'  zero   y z = refl (y +N z)\n-- assocLR-+N' (suc x) y z = refl suc =$= assocLR-+N' x y z -- TODO : does not compile\n\n-- 30:21\nassocLR-+N : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z))\nassocLR-+N  zero   y z = refl (y +N z)\nassocLR-+N (suc x) y z\n  rewrite assocLR-+N x y z\n  = refl (suc (x +N (y +N z)))\n\n------------------------------------------------------------------------------\n-- computing types\n\n-- 34:46\nrefl->=' : (n : Nat) -> n >= n\nrefl->='  zero   = <>\nrefl->=' (suc n) = refl->=' n\n\n-- 41:00\ntrans->=' : (x y z : Nat) -> x >= y -> y >= z  -> x >= z\n-- start with 'z'\ntrans->='      x       y   zero   x>=y y>=z = <>\ntrans->=' (suc x) (suc y) (suc z) x>=y y>=z = trans->=' x y z x>=y y>=z\n\n-- ==============================================================================\n-- Lecture 4 : Sigma, Difference, Vector Take\n-- https://www.youtube.com/watch?v=OZeDRtRmgkw\n\n-- 0:46 Sigma type (see above)\n\n-- 5:10 -- make _*_ from Sg\n_*'_ : (S : Set) -> (T : Set) -> Set\ns *' t = Sg s \u03bb _ -> t\n\n-- 10:55 difference (see above)\ndifference' : (m n : Nat) -> m >= n -> Sg Nat \u03bb d -> m == (n +N d)\n-- 1st clause of >= matches on right, so start with 'n'\ndifference'      m   zero   m>=n = m , refl m\ndifference' (suc m) (suc n) m>=n\n  with difference' m n m>=n\n...| d , m==n+Nd\n  rewrite m==n+Nd\n  = d , refl (suc (n +N d)) -- video also uses refl suc =$= m==n+Nd\n\n-- 27:24 -- pattern match on proof of equation ; here 'm==n+Nd'\ndifference'' : (m n : Nat) -> m >= n -> Sg Nat \u03bb d -> m == (n +N d)\n-- 1st clause of >= matches on right, so start with 'n'\ndifference''      m   zero   m>=n = m , refl m\ndifference'' (suc m) (suc n) m>=n\n  with difference'' m n m>=n\n...| d , m==n+Nd\n  with m==n+Nd\n... | refl .(n +N d) = d , (refl (suc (n +N d)))\n\ntryMe     = difference 42 37\n-- dontTryMe = difference 37 42 {!!}\n\n------------------------------------------------------------------------------\n-- things to remember to say\n\n{-\n-- 34:22 : = VIZ ==\n=  : makes a definition (part of Agda programming language)\n== : makes a type (by user built definition)\n\nfunction type is both IMPLICATION and UNIVERSAL QUANTIFICATION : why call Pi?\n\nwhy is Sigma called Sigma?\n\n-- 38:50 : B or not B\nmust be able to return a\n- inl B      for any B : not possible because nothing known about B\n- inR B\u2192Zero for any B : not possible because Zero has no elements\nexMiddle : {B : Set} -> B + (B -> Zero)\nexMiddle = ?\n\n-- 40:45\n-- not possible to \"look inside\" 'notAandB' to determine 'inl' or 'inr'\ndeMorgan : {A B : Set} -> ((A * B) -> Zero) -> (A -> Zero) + (B -> Zero)\ndeMorgan notAandB = {!!}\n-}\n\n\n\n\n\n", "meta": {"hexsha": "745c976e72a62b33388de67f988026eb069f69dd", "size": 8719, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec1.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 28.6809210526, "max_line_length": 87, "alphanum_fraction": 0.4688611079, "num_tokens": 3049, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9241418262465169, "lm_q2_score": 0.8354835391516133, "lm_q1q2_score": 0.7721052836704753}}
{"text": "-- A DSL example in the language Agda: \"polynomial types\"\nmodule TypeDSL where\nopen import Data.Empty\nopen import Data.Unit\nopen import Data.Sum\nopen import Data.Product\nopen import Data.Nat\n\ndata E : Set1 where\n  Add   : E -> E -> E\n  Mul   : E -> E -> E\n  Zero  : E\n  One   : E\n\neval : E -> Set\neval (Add x y)  = (eval x) \u228e (eval y)\neval (Mul x y)  = (eval x) \u00d7 (eval y)\neval Zero       = \u22a5\neval One        = \u22a4\n\ntwo   = Add One One\nthree = Add One two\n\ntest1 : eval One\ntest1 = tt\n\nfalse : eval two\nfalse = inj\u2081 tt\ntrue : eval two\ntrue = inj\u2082 tt\n\ntest3 : eval three\ntest3 = inj\u2081 tt\n\ncard : E -> \u2115\ncard (Add x y)  = card x + card y\ncard (Mul x y)  = card x * card y\ncard Zero       = 0\ncard One        = 1\n\nopen import Data.Vec as V\n\nvariable\n    m n : \u2115\n    A B : Set\n\nenumAdd : Vec A m -> Vec B n -> Vec (A \u228e B) (m + n)\nenumAdd xs ys = V.map inj\u2081 xs ++ V.map inj\u2082 ys\n\n-- cartesianProduct\nenumMul : Vec A m \u2192 Vec B n \u2192 Vec (A \u00d7 B) (m * n)\nenumMul xs ys = concat (V.map  (\\a -> V.map  ((a ,_)) ys)  xs)\n\nenumerate : (t : E) -> Vec (eval t) (card t)\nenumerate (Add x y)  =  enumAdd  (enumerate x) (enumerate y)\nenumerate (Mul x y)  =  enumMul  (enumerate x) (enumerate y) \nenumerate Zero       =  []\nenumerate One        =  [ tt ]\n\ntest : Vec (eval three) 3\ntest = enumerate three\n-- inj\u2081 tt \u2237 inj\u2082 (inj\u2081 tt) \u2237 inj\u2082 (inj\u2082 tt) \u2237 []\n\n-- Exercise: add a constructor for function types to the syntax E \n", "meta": {"hexsha": "56de41055c9400ccb85a2ae356673800639a6544", "size": 1399, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "L/01/TypeDSL.agda", "max_stars_repo_name": "felixwellen/DSLsofMath", "max_stars_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "L/01/TypeDSL.agda", "max_issues_repo_name": "felixwellen/DSLsofMath", "max_issues_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "L/01/TypeDSL.agda", "max_forks_repo_name": "felixwellen/DSLsofMath", "max_forks_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.5230769231, "max_line_length": 66, "alphanum_fraction": 0.5947105075, "num_tokens": 489, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9496693645535724, "lm_q2_score": 0.8128673223709251, "lm_q1q2_score": 0.7719551935023603}}
{"text": "-- Problem 4: ``50 shades of continuity''\n\n{-\nC(f)        =  \u2200 c : X. Cat(f,c)\nCat(f,c)    =  \u2200 \u03b5 > 0. \u2203 \u03b4 > 0. Q(f,c,\u03b5,\u03b4)\nQ(f,c,\u03b5,\u03b4)  =  \u2200 x : X.  abs(x - c) < \u03b4  \u21d2  abs(f x - f c) < \u03b5\n\nC'(f)       =  \u2203 get\u03b4 : X -> RPos -> RPos. \u2200 c : X. \u2200 \u03b5 > 0. Q(f,c,\u03b5,get\u03b4 c \u03b5)\n\n4a: Define UC(f):\n\nUC(f) = \u2200 \u03b5 > 0. \u2203 \u03b4 > 0. \u2200 y : X. Q(f,y,\u03b5,\u03b4)\n\n4b: Define UC'(f):\n\nUC'(f) = \u2203 new\u03b4 : RPos -> RPos. \u2200 \u03b5 > 0. \u2200 y : X. Q(f,y,\u03b5,new\u03b4 \u03b5)\n\nThe function |new\u03b4| computes a suitable \"global\" |\u03b4| from any |\u03b5|,\nwhich shows |Q| for any |y|.\n\n4c: Prove |\u2200 f : X -> \u211d. UC'(f) => C'(f)|.\n\nThe proof is a function from a pair (new\u03b4, puc) to a pair (get\u03b4, pc).\n\nproof f (new\u03b4, puc) = (get\u03b4, pc)\n  where  get\u03b4 c \u03b5 = new\u03b4 \u03b5\n         pc c \u03b5 = puc \u03b5 c   -- (1)\n\nThe type of (1) is\n\n  Q(f,c,\u03b5,new\u03b4 \u03b5)\n=\n  Q(f,c,\u03b5,get\u03b4 c \u03b5)\n\nwhich is the type of |pc c \u03b5|.\n\n----------------\n\nBelow is a self-contained proof in Agda just to check the above. It is\nnot part of the exam question.\n\n-}\n\npostulate\n  R RPos : Set\n  abs : R -> RPos\n  _-_ : R -> R -> R\n  _<_ : RPos -> RPos -> Set\n\nX = R  -- to avoid trouble with lack of subtyping\n\nrecord Sigma (A : Set) (B : A -> Set) : Set where\n  constructor _,_\n  field\n    fst : A\n    snd : B fst\n\nQ : (X -> R) -> X -> RPos -> RPos -> Set\nQ f c \u03b5 \u03b4  =  (x : X) -> (abs(  x -   c) < \u03b4)  ->\n                         (abs(f x - f c) < \u03b5)\n\nCat : (X -> R) -> X -> Set\nCat f c    =  (\u03b5 : RPos) -> Sigma RPos (\\\u03b4 ->\n                                  Q f c \u03b5 \u03b4)\n\nC : (X -> R) -> Set\nC f        =  (c : X) -> Cat f c\n\nC' : (X -> R) -> Set\nC' f =  Sigma (X -> RPos -> RPos) (\\get\u03b4 ->\n              (c : X) -> (\u03b5 : RPos) -> Q f c \u03b5 (get\u03b4 c \u03b5))\n\nUC : (X -> R) -> Set\nUC f = (\u03b5 : RPos) -> Sigma RPos (\\\u03b4 ->\n                           (y : X) -> Q f y \u03b5 \u03b4)\n\nUC' : (X -> R) -> Set\nUC' f = Sigma (RPos -> RPos) (\\new\u03b4 ->\n              (\u03b5 : RPos) -> (y : X) -> Q f y \u03b5 (new\u03b4 \u03b5))\n\nproof : (f : X -> R) -> UC' f -> C' f\nproof f (new\u03b4 , puc) = (get\u03b4 , pc)\n  where  get\u03b4  = \\c -> new\u03b4\n         pc    = \\c \u03b5 -> puc \u03b5 c\n", "meta": {"hexsha": "eb9e02811a509eff1f63211a6324a194a8087110", "size": 1993, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Exam/2017-08/P4.agda", "max_stars_repo_name": "nicolabotta/DSLsofMath", "max_stars_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 248, "max_stars_repo_stars_event_min_datetime": "2015-04-27T21:04:02.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:12:24.000Z", "max_issues_repo_path": "Exam/2017-08/P4.agda", "max_issues_repo_name": "nicolabotta/DSLsofMath", "max_issues_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 51, "max_issues_repo_issues_event_min_datetime": "2016-01-30T15:59:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-03T20:06:39.000Z", "max_forks_repo_path": "Exam/2017-08/P4.agda", "max_forks_repo_name": "nicolabotta/DSLsofMath", "max_forks_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 47, "max_forks_repo_forks_event_min_datetime": "2015-11-16T08:41:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:57:42.000Z", "avg_line_length": 23.4470588235, "max_line_length": 78, "alphanum_fraction": 0.4320120421, "num_tokens": 821, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391727723469, "lm_q2_score": 0.8354835371034368, "lm_q1q2_score": 0.7711840329528707}}
{"text": "module BSTree  {A : Set}(_\u2264_ : A \u2192 A \u2192 Set) where\n\nopen import BTree {A}\n\ndata _\u22b4*_ : A \u2192 BTree \u2192 Set where\n  gelf : {x : A} \n                   \u2192 x \u22b4* leaf\n  gend : {x y : A}{l r : BTree} \n                   \u2192 x \u2264 y \n                   \u2192 x \u22b4* l \n                   \u2192 x \u22b4* (node y l r)\n\ndata _*\u22b4_ : BTree \u2192 A \u2192 Set where\n  lelf : {x : A} \n                   \u2192 leaf *\u22b4 x\n  lend : {x y : A}{l r : BTree} \n                   \u2192 y \u2264 x \n                   \u2192 r *\u22b4 x \n                   \u2192 (node y l r) *\u22b4 x\n\ndata BSTree : BTree \u2192 Set where\n  slf : BSTree leaf\n  snd : {x : A}{l r : BTree} \n                   \u2192 BSTree l \n                   \u2192 BSTree r \n                   \u2192 l *\u22b4 x \n                   \u2192 x \u22b4* r \n                   \u2192 BSTree (node x l r) \n\n\n\n", "meta": {"hexsha": "adfe6d5f21762f6d5f167f86afc7fbcc08f6f754", "size": 747, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BSTree.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BSTree.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BSTree.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.34375, "max_line_length": 49, "alphanum_fraction": 0.3172690763, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9688561703644736, "lm_q2_score": 0.7956581073313275, "lm_q1q2_score": 0.7708782667884753}}
{"text": "----------------------------------------------------------------------\n-- Copyright: 2013, Jan Stolarek, Lodz University of Technology     --\n--                                                                  --\n-- License: See LICENSE file in root of the repo                    --\n-- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps   --\n--                                                                  --\n-- Definition of natural numbers and operations on them.            --\n----------------------------------------------------------------------\n\nmodule Basics.Nat where\n\nopen import Basics.Bool\n\n-- Nat represents natural numbers (starting with 0)\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat \u2192 Nat\n\n-- We define a constant 1 as it will be useful later on\none : Nat\none = suc zero\n\n-- Addition\n_+_ : Nat \u2192 Nat \u2192 Nat\nzero  + m = m\nsuc n + m = suc (n + m)\n\ninfixl 6 _+_\n\n-- Comparisons needed in our code\n_<_ : Nat \u2192 Nat \u2192 Bool\nn     < zero  = false\nzero  < suc n = true\nsuc n < suc m = n < m\n\n_\u2265_ : Nat \u2192 Nat \u2192 Bool\nm     \u2265 zero  = true\nzero  \u2265 suc n = false\nsuc m \u2265 suc n = m \u2265 n\n\ninfixl 4 _<_ _\u2265_\n", "meta": {"hexsha": "271fdbf0fe30a1fac74c048a355a223725111fa1", "size": 1123, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Basics/Nat.agda", "max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z", "max_issues_repo_path": "src/Basics/Nat.agda", "max_issues_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Basics/Nat.agda", "max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_forks_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.7380952381, "max_line_length": 70, "alphanum_fraction": 0.4612644702, "num_tokens": 272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9591542817548989, "lm_q2_score": 0.8031737940012418, "lm_q1q2_score": 0.7703675835096182}}
{"text": "import      Lvl\nopen import Structure.Operator.Vector\nopen import Structure.Setoid\nopen import Type\n\nmodule Structure.Operator.Vector.LinearCombination\n  {\u2113\u1d65 \u2113\u209b \u2113\u1d65\u2091 \u2113\u209b\u2091}\n  {V : Type{\u2113\u1d65}} \u2983 equiv-V : Equiv{\u2113\u1d65\u2091}(V) \u2984\n  {S : Type{\u2113\u209b}} \u2983 equiv-S : Equiv{\u2113\u209b\u2091}(S) \u2984\n  {_+\u1d65_ : V \u2192 V \u2192 V}\n  {_\u22c5\u209b\u1d65_ : S \u2192 V \u2192 V}\n  {_+\u209b_ _\u22c5\u209b_ : S \u2192 S \u2192 S}\n  \u2983 vectorSpace : VectorSpace(_+\u1d65_)(_\u22c5\u209b\u1d65_)(_+\u209b_)(_\u22c5\u209b_) \u2984\n  where\n\nopen VectorSpace(vectorSpace)\n\nopen import Data.Tuple using (_\u2a2f_ ; _,_)\nopen import Functional using (id ; _\u2218_ ; _\u2218\u2082_ ; _$_ ; swap ; _on\u2082_)\nopen import Function.Equals\nopen import Logic\nopen import Logic.Predicate\nopen import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec)\nopen import Numeral.Finite\nopen import Numeral.Natural\nopen import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _\u2208_ ; [\u220b]-binaryRelator)\nopen import Structure.Function.Domain\nopen import Syntax.Function\n\nprivate variable \u2113 \u2113\u2097 : Lvl.Level\nprivate variable n : \u2115\n\n-- A linear combination constructed from a sequence of vectors and a sequence of scalars.\n-- Linear combination of 0 scalars and vectors are the zero vector.\n-- Linear combination of 1 scalar and vector is just scalar on vector multiplication.\n-- Example: LinearCombination {4} sf vf = (sf[0] \u22c5\u209b\u1d65 vf[0]) +\u1d65 (sf[1] \u22c5\u209b\u1d65 vf[1]) +\u1d65 (sf[2] \u22c5\u209b\u1d65 vf[2]) +\u1d65 (sf[3] \u22c5\u209b\u1d65 vf[3])\n-- Inlined definition:\n--   LinearCombination {0}       _  _  = \ud835\udfce\u1d65\n--   LinearCombination {1}       vf sf = Vec.proj(sf)(0) \u22c5\u209b\u1d65 Vec.proj(vf)(0)\n--   LinearCombination {\ud835\udc12(\ud835\udc12(n))} vf sf = (Vec.proj(sf)(0) \u22c5\u209b\u1d65 Vec.proj(vf)(0)) +\u1d65 (LinearCombination {\ud835\udc12(n)} (Vec.tail vf) (Vec.tail sf))\nlinearCombination : Vec(n)(V) \u2192 Vec(n)(S) \u2192 V\nlinearCombination = Vec.reduceOr\u1d63(_+\u1d65_) \ud835\udfce\u1d65 \u2218\u2082 Vec.map\u2082(_\u22c5\u1d65\u209b_)\n\n-- Whether the two specified vectors are linearly dependent or not.\n-- TODO: Is this definition neccessary?\nLinearlyDependentPair : V \u2192 V \u2192 Stmt\nLinearlyDependentPair v\u2081 v\u2082 = \u2203{Obj = S \u2a2f S}(\\{(s\u2081 , s\u2082) \u2192 s\u2081 \u22c5\u209b\u1d65 v\u2081 \u2261 s\u2082 \u22c5\u209b\u1d65 v\u2082})\n", "meta": {"hexsha": "c21de1c4bdee976daa6bca866302c971b593831e", "size": 1946, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Operator/Vector/LinearCombination.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Operator/Vector/LinearCombination.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Operator/Vector/LinearCombination.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.5416666667, "max_line_length": 136, "alphanum_fraction": 0.6891058582, "num_tokens": 783, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009549929797, "lm_q2_score": 0.8418256452674008, "lm_q1q2_score": 0.7701870867927264}}
{"text": "{-# BUILTIN NATURAL \u2115 #-}\n\nmodule the-naturals where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e)\n\ninfixl 6  _+_  _\u2238_\ninfixl 7  _*_\n\n-- the naturals\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n-- addition\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n\n(suc m) + n = suc (m + n)\n\n-- multiplication\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero    * n  =  zero\n(suc m) * n  =  n + (m * n)\n\n-- monus ( subtraction for the naturals )\n_\u2238_ : \u2115 \u2192 \u2115 \u2192 \u2115\nm     \u2238 zero   =  m\nzero  \u2238 suc n  =  zero\nsuc m \u2238 suc n  =  m \u2238 n\n\n", "meta": {"hexsha": "a2ffecbed0a3b576537d1af7c6705da337243dee", "size": 552, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/the-naturals.agda", "max_stars_repo_name": "seanwestfall/agda_explorations", "max_stars_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/the-naturals.agda", "max_issues_repo_name": "seanwestfall/agda_explorations", "max_issues_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/the-naturals.agda", "max_forks_repo_name": "seanwestfall/agda_explorations", "max_forks_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.7272727273, "max_line_length": 50, "alphanum_fraction": 0.5615942029, "num_tokens": 227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9648551546097942, "lm_q2_score": 0.7981867705385763, "lm_q1q2_score": 0.7701346198954904}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\n\nmodule Setoids.Product {m n o p : _} {A : Set m} {B : Set n} (R : Setoid {m} {o} A) (S : Setoid {n} {p} B) where\n\nopen Setoid\n\nproductSetoid : Setoid (A && B)\n_\u223c_ (productSetoid) (a ,, b) (c ,, d) = (Setoid._\u223c_ R a c) && (Setoid._\u223c_ S b d)\nEquivalence.reflexive (eq (productSetoid)) {(a ,, b)} = Equivalence.reflexive (Setoid.eq R) ,, Equivalence.reflexive (Setoid.eq S)\nEquivalence.symmetric (eq (productSetoid)) {(a ,, b)} {(c ,, d)} (fst ,, snd) = Equivalence.symmetric (Setoid.eq R) fst ,, Equivalence.symmetric (Setoid.eq S) snd\nEquivalence.transitive (eq (productSetoid)) {a ,, b} {c ,, d} {e ,, f} (fst1 ,, snd1) (fst2 ,, snd2) = Equivalence.transitive (Setoid.eq R) fst1 fst2 ,, Equivalence.transitive (Setoid.eq S) snd1 snd2\n\nproductLift : {r s : A} {t u : B} \u2192 (Setoid._\u223c_ R r s) \u2192 (Setoid._\u223c_ S t u) \u2192 Setoid._\u223c_ productSetoid (r ,, t) (s ,, u)\n_&&_.fst (productLift r=s t=u) = r=s\n_&&_.snd (productLift r=s t=u) = t=u\n", "meta": {"hexsha": "09a9e50f324e54848e837605534f2aa7e86ddd5a", "size": 1077, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Setoids/Product.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Setoids/Product.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Setoids/Product.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 53.85, "max_line_length": 199, "alphanum_fraction": 0.6425255339, "num_tokens": 397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9314625069680098, "lm_q2_score": 0.8267117962054048, "lm_q1q2_score": 0.7700510422335127}}
{"text": "\nmodule Data.Fin where\n\nopen import Data.Nat hiding (_==_; _<_)\nopen import Data.Bool\nopen import Logic.Identity\nopen import Logic.Base\n\ndata Fin : Nat -> Set where\n  fzero : {n : Nat} -> Fin (suc n)\n  fsuc  : {n : Nat} -> Fin n -> Fin (suc n)\n\npred : {n : Nat} -> Fin (suc (suc n)) -> Fin (suc n)\npred fzero    = fzero\npred (fsuc i) = i\n\nfzero\u2260fsuc : {n : Nat}{i : Fin n} -> fzero \u2262 fsuc i\nfzero\u2260fsuc ()\n\nfsuc-inj : {n : Nat}{i j : Fin n} -> fsuc i \u2261 fsuc j -> i \u2261 j\nfsuc-inj refl = refl\n\n_==_ : {n : Nat}(i j : Fin n) -> i \u2261 j \\/ i \u2262 j\nfzero  == fzero  = \\/-IL refl\nfzero  == fsuc j = \\/-IR fzero\u2260fsuc\nfsuc i == fzero  = \\/-IR (sym\u2262 fzero\u2260fsuc)\nfsuc i == fsuc j = aux i j (i == j)\n  where\n    aux : {n : Nat}(i j : Fin n) -> i \u2261 j \\/ i \u2262 j -> fsuc i \u2261 fsuc j \\/ fsuc i \u2262 fsuc j\n    aux i .i (\\/-IL refl) = \\/-IL refl\n    aux i j  (\\/-IR i\u2260j)  = \\/-IR \\si=sj -> i\u2260j (fsuc-inj si=sj)\n\n_<_ : {n : Nat} -> Fin n -> Fin n -> Bool\n_      < fzero  = false\nfzero  < fsuc j = true\nfsuc i < fsuc j = i < j\n\nfromNat : (n : Nat) -> Fin (suc n)\nfromNat  zero\t= fzero\nfromNat (suc n) = fsuc (fromNat n)\n\nliftSuc : {n : Nat} -> Fin n -> Fin (suc n)\nliftSuc  fzero\t = fzero\nliftSuc (fsuc i) = fsuc (liftSuc i)\n\nlift+ : {n : Nat}(m : Nat) -> Fin n -> Fin (m + n)\nlift+  zero   i = i\nlift+ (suc m) i = liftSuc (lift+ m i)\n\nthin : {n : Nat} -> Fin (suc n) -> Fin n -> Fin (suc n)\nthin  fzero i\t       = fsuc i\nthin (fsuc j) fzero    = fzero\nthin (fsuc j) (fsuc i) = fsuc (thin j i)\n\n-- Two elements of Fin n are either the same or one is the thinning of\n-- something with respect to the other.\ndata ThinView : {n : Nat}(i j : Fin n) -> Set where\n  same : {n : Nat}{i : Fin n}\t\t       -> ThinView i i\n  diff : {n : Nat}{i : Fin (suc n)}(j : Fin n) -> ThinView i (thin i j)\n\nthinView : {n : Nat}(i j : Fin n) -> ThinView i j\nthinView fzero fzero\t\t      = same\nthinView  fzero (fsuc j) = diff j\nthinView {suc zero} (fsuc ()) fzero\nthinView {suc (suc n)} (fsuc i) fzero\t = diff fzero\nthinView (fsuc i) (fsuc j) = aux i j (thinView i j)\n  where\n    aux : {n : Nat}(i j : Fin n) -> ThinView i j -> ThinView (fsuc i) (fsuc j)\n    aux i .i\t       same    = same\n    aux i .(thin i j) (diff j) = diff (fsuc j)\n\nthin-ij\u2260i : {n : Nat}(i : Fin (suc n))(j : Fin n) -> thin i j \u2262 i\nthin-ij\u2260i  fzero    j\t    ()\nthin-ij\u2260i (fsuc i)  fzero   ()\nthin-ij\u2260i (fsuc i) (fsuc j) eq = thin-ij\u2260i i j (fsuc-inj eq)\n\n-- Thickening.\n--    thin i (thick i j) \u2261 j  ?\n--    thick i (thin i j) \u2261 j\nthick : {n : Nat}(i j : Fin (suc n)) -> i \u2262 j -> Fin n\nthick i j i\u2260j = thick' i j i\u2260j (thinView i j) where\n  thick' : {n : Nat}(i j : Fin (suc n)) -> i \u2262 j -> ThinView i j -> Fin n\n  thick' i .i\t       i\u2260i same\t   = elim-False (i\u2260i refl)\n  thick' i .(thin i j) _  (diff j) = j\n\n-- thin\u2218thick=id : {n : Nat}(i j : Fin (suc n))(p : i \u2262 j) ->\n-- \t\tthin i (thick i j p) \u2261 j\n-- thin\u2218thick=id i j p = ?\n--\n-- thick\u2218thin=id : {n : Nat}(i : Fin (suc n))(j : Fin n) ->\n-- \t\tthick i (thin i j) (sym\u2262 (thin-ij\u2260i i j)) \u2261 j\n-- thick\u2218thin=id i j = ?\n--\n", "meta": {"hexsha": "eeb59d8ef2b32ce5eb51660468715368e5024696", "size": 2988, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Fin.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Fin.agda", "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Fin.agda", "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 31.7872340426, "max_line_length": 88, "alphanum_fraction": 0.5331325301, "num_tokens": 1273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037323284109, "lm_q2_score": 0.8311430499496095, "lm_q1q2_score": 0.7698909092671421}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Experiment.Zero where\n\nopen import Level using (_\u2294_)\n\n-- Empty type\ndata \u22a5 : Set where\n\n-- Unit type\nrecord \u22a4 : Set where\n  constructor tt\n\n-- Boolean\ndata Bool : Set where\n  true false : Bool\n\n-- Natural number\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n-- Propositional Equality\ndata _\u2261_ {a} {A : Set a} (x : A) : A \u2192 Set a where\n  refl : x \u2261 x\n\n-- Sum type\ndata _\u228e_ {a} {b} (A : Set a) (B : Set b) : Set (a \u2294 b) where\n  inj\u2081 : A \u2192 A \u228e B\n  inj\u2082 : B \u2192 A \u228e B\n\n-- Dependent Product type\nrecord \u03a3 {a} {b} (A : Set a) (B : A \u2192 Set b) : Set (a \u2294 b) where\n  constructor _,_\n  field\n    fst : A\n    snd : B fst\n\n-- Induction\n\u22a4-ind : \u2200 {p} {P : \u22a4 \u2192 Set p} \u2192 P tt \u2192 \u2200 x \u2192 P x\n\u22a4-ind P\u22a4 tt = P\u22a4\n\n\u22a5-ind : \u2200 {p} {P : \u22a5 \u2192 Set p} \u2192 \u2200 x \u2192 P x\n\u22a5-ind ()\n\nBool-ind : \u2200 {p} {P : Bool \u2192 Set p} \u2192 P true \u2192 P false \u2192 \u2200 x \u2192 P x\nBool-ind t e true  = t\nBool-ind t e false = e\n\n\u2115-ind : \u2200 {p} {P : \u2115 \u2192 Set p} \u2192 P zero \u2192 (\u2200 m \u2192 P m \u2192 P (suc m)) \u2192 \u2200 n \u2192 P n\n\u2115-ind P0 Ps zero    = P0\n\u2115-ind P0 Ps (suc n) = Ps n (\u2115-ind P0 Ps n)\n\n\u2261-ind : \u2200 {a p} {A : Set a}\n        (P : (x y : A) \u2192 x \u2261 y \u2192 Set p) \u2192\n        (\u2200 x \u2192 P x x refl) \u2192\n        \u2200 x y (eq : x \u2261 y) \u2192 P x y eq\n\u2261-ind P Pr x .x refl = Pr x\n\n\u228e-ind : \u2200 {a b p} {A : Set a} {B : Set b} {P : A \u228e B \u2192 Set p} \u2192\n        (\u2200 x \u2192 P (inj\u2081 x)) \u2192 (\u2200 y \u2192 P (inj\u2082 y)) \u2192 \u2200 s \u2192 P s\n\u228e-ind i1 i2 (inj\u2081 x) = i1 x\n\u228e-ind i1 i2 (inj\u2082 y) = i2 y\n\n\u03a3-ind : \u2200 {a b p} {A : Set a} {B : A \u2192 Set b} {P : \u03a3 A B \u2192 Set p} \u2192\n        (\u2200 x y \u2192 P (x , y)) \u2192 \u2200 p \u2192 P p\n\u03a3-ind f (x , y) = f x y\n", "meta": {"hexsha": "15211498c51d3fdb09bda4ed4d919c6c6228a802", "size": 1523, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Experiment/Zero.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Experiment/Zero.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Experiment/Zero.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.3970588235, "max_line_length": 76, "alphanum_fraction": 0.4674983585, "num_tokens": 703, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933093975331751, "lm_q2_score": 0.8615382076534742, "lm_q1q2_score": 0.7696201772307365}}
{"text": "\nmodule Problem3 where\n\nopen import Problem1\nopen import Problem2\n\ndata Fin : Nat -> Set where\n  fzero : {n : Nat} -> Fin (suc n)\n  fsuc  : {n : Nat} -> Fin n -> Fin (suc n)\n\ndata False : Set where\n\n-- 3.1\n\nempty : Fin zero -> False\nempty ()\n\n-- 3.2\n\n_!_ : {A : Set}{n : Nat} -> Vec A n -> Fin n -> A\n\u03b5        ! ()\n(x \u25ba xs) ! fzero  = x\n(x \u25ba xs) ! fsuc i = xs ! i\n\n-- 3.3\n\n-- The simply typed composition would do here, but the more\n-- dependent version is more interesting.\n-- _\u2218_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C\n\n_\u2218_ : {A B : Set}{C : B -> Set}(f : (x : B) -> C x)\n      (g : A -> B)(x : A) -> C (g x)\n(f \u2218 g) x = f (g x)\n\ntabulate : {A : Set}{n : Nat} -> (Fin n -> A) -> Vec A n\ntabulate {n = zero } f = \u03b5\ntabulate {n = suc n} f = f fzero \u25ba tabulate (f \u2218 fsuc)\n", "meta": {"hexsha": "9fc78185cc7e29371f7a84eeef404b2c68692444", "size": 782, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Solutions/Problem3.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Solutions/Problem3.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Solutions/Problem3.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.5789473684, "max_line_length": 59, "alphanum_fraction": 0.5012787724, "num_tokens": 310, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308147331957, "lm_q2_score": 0.8244619285331332, "lm_q1q2_score": 0.7695781696671842}}
{"text": "module Nat where\n\ndata Nat : Set\n\ndata Nat where\n  zero : Nat\n  suc  : Nat -> Nat\n\nplus : Nat -> Nat -> Nat\nplus zero    n = n\nplus (suc m) n = suc (plus m n)\n\nelim : (P : (n : Nat) -> Set) ->\n       (z : P (plus zero zero)) ->\n       (s : (n : Nat) -> P (plus zero n) -> P (plus (suc zero) n)) ->\n       (n : Nat) -> P n\nelim P z s zero    = z\nelim P z s (suc n) = s n (elim P z s n)\n", "meta": {"hexsha": "4ab64de6a2384eaa3940d66fe10269bd07df7b96", "size": 385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/prototyping/term/examples/Nat.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "src/prototyping/term/examples/Nat.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/prototyping/term/examples/Nat.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 20.2631578947, "max_line_length": 69, "alphanum_fraction": 0.4831168831, "num_tokens": 146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9579122720843812, "lm_q2_score": 0.803173791645582, "lm_q1q2_score": 0.7693700316338469}}
{"text": "module Ag13 where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl)\nopen Eq.\u2261-Reasoning\nopen import Data.Nat using (\u2115; zero; suc)\nopen import Data.Product using (_\u00d7_) renaming (_,_ to \u27e8_,_\u27e9)\nopen import Data.Sum using (_\u228e_; inj\u2081; inj\u2082)\nopen import Relation.Nullary using (\u00ac_)\nopen import Relation.Nullary.Negation using ()\n  renaming (contradiction to \u00ac\u00ac-intro)\nopen import Data.Unit using (\u22a4; tt)\nopen import Data.Empty using (\u22a5; \u22a5-elim)\nopen import Ag09 using (_\u21d4_)\n\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n\nT : Bool \u2192 Set\nT true   =  \u22a4\nT false  =  \u22a5\n\nT\u2192\u2261 : \u2200 (b : Bool) \u2192 T b \u2192 b \u2261 true\nT\u2192\u2261 true tt   =  refl\nT\u2192\u2261 false ()\n\n\u2261\u2192T : \u2200 {b : Bool} \u2192 b \u2261 true \u2192 T b\n\u2261\u2192T refl  =  tt\n\ndata Dec (A : Set) : Set where\n  yes :   A \u2192 Dec A\n  no  : \u00ac A \u2192 Dec A\n\ninfix 4 _\u2264_\n\ndata _\u2264_ : \u2115 \u2192 \u2115 \u2192 Set where\n\n  z\u2264n : \u2200 {n : \u2115}\n      --------\n    \u2192 zero \u2264 n\n\n  s\u2264s : \u2200 {m n : \u2115}\n    \u2192 m \u2264 n\n      -------------\n    \u2192 suc m \u2264 suc n\n\n\u00acs\u2264z : \u2200 {m : \u2115} \u2192 \u00ac (suc m \u2264 zero)\n\u00acs\u2264z ()\n\n\u00acs\u2264s : \u2200 {m n : \u2115} \u2192 \u00ac (m \u2264 n) \u2192 \u00ac (suc m \u2264 suc n)\n\u00acs\u2264s \u00acm\u2264n (s\u2264s m\u2264n) = \u00acm\u2264n m\u2264n\n\n_\u2264?_ : \u2200 (m n : \u2115) \u2192 Dec (m \u2264 n)\nzero  \u2264? n                   =  yes z\u2264n\nsuc m \u2264? zero                =  no \u00acs\u2264z\nsuc m \u2264? suc n with m \u2264? n\n...               | yes m\u2264n  =  yes (s\u2264s m\u2264n)\n...               | no \u00acm\u2264n  =  no (\u00acs\u2264s \u00acm\u2264n)\n\n\n", "meta": {"hexsha": "a34c317f1a8815c1d76005a6bade258219473616", "size": 1319, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Ag13.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Ag13.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Ag13.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 21.2741935484, "max_line_length": 60, "alphanum_fraction": 0.5003790751, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9161096112990283, "lm_q2_score": 0.8397339736884712, "lm_q1q2_score": 0.7692883642303339}}
{"text": "module Algebra.Dioid where\n\nrecord Dioid A (_\u2261_ : A -> A -> Set) : Set where\n  field\n    zero : A\n    one  : A\n    _+_  : A -> A -> A\n    _*_  : A -> A -> A\n\n    reflexivity  : \u2200 {r     : A} ->                   r \u2261 r\n    symmetry     : \u2200 {r s   : A} -> r \u2261 s ->          s \u2261 r\n    transitivity : \u2200 {r s t : A} -> r \u2261 s -> s \u2261 t -> r \u2261 t\n\n    +left-congruence  : \u2200 {r s t : A} -> r \u2261 s -> (r + t) \u2261 (s + t)\n    -- +right-congruence holds but as a theorem, please see below\n    *left-congruence  : \u2200 {r s t : A} -> r \u2261 s -> (r * t) \u2261 (s * t)\n    *right-congruence : \u2200 {r s t : A} -> r \u2261 s -> (t * r) \u2261 (t * s)\n\n    +idempotence   : \u2200 {r : A}      -> (r + r)       \u2261 r\n    +commutativity : \u2200 {r s : A}    -> (r + s)       \u2261 (s + r)\n    +associativity : \u2200 {r s t : A}  -> (r + (s + t)) \u2261 ((r + s) + t)\n    +zero-identity : \u2200 {r : A}      -> (r + zero)    \u2261 r\n\n    *associativity  : \u2200 {r s t : A} -> (r * (s * t)) \u2261 ((r * s) * t)\n    *left-zero      : \u2200 {r : A}     -> (zero * r)    \u2261 zero\n    *right-zero     : \u2200 {r : A}     -> (r * zero)    \u2261 zero\n    *left-identity  : \u2200 {r : A}     -> (one * r)     \u2261 r\n    *right-identity : \u2200 {r : A}     -> (r * one)     \u2261 r\n\n    left-distributivity  : \u2200 {r s t : A} -> (r * (s + t)) \u2261 ((r * s) + (r * t))\n    right-distributivity : \u2200 {r s t : A} -> ((r + s) * t) \u2261 ((r * t) + (s * t))\n\n  -- For convenience to avoid `Dioid._+_ d r s`\n  plus : A -> A -> A\n  plus x y = x + y\n\n  times : A -> A -> A\n  times x y = x * y\n\n+right-congruence : \u2200 {D eq} {d : Dioid D eq} {r s t : D} -> eq r s -> eq (Dioid.plus d t r) (Dioid.plus d t s)\n+right-congruence {_} {_} {d} {r} {s} {t} e = trans commut (trans (Dioid.+left-congruence d e) commut)\n  where\n    trans = Dioid.transitivity d\n    commut = Dioid.+commutativity d\n", "meta": {"hexsha": "fdb959123b24fa66fbb299406cebe83e7a0ecdb7", "size": 1746, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Dioid.agda", "max_stars_repo_name": "snowleopard/alga-proofs", "max_stars_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 60, "max_stars_repo_stars_event_min_datetime": "2017-12-27T14:57:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:05:29.000Z", "max_issues_repo_path": "src/Algebra/Dioid.agda", "max_issues_repo_name": "snowleopard/alga-proofs", "max_issues_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-04-12T16:25:13.000Z", "max_issues_repo_issues_event_max_datetime": "2018-06-23T13:54:02.000Z", "max_forks_repo_path": "src/Algebra/Dioid.agda", "max_forks_repo_name": "snowleopard/alga-proofs", "max_forks_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2017-12-17T20:48:20.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-09T23:53:28.000Z", "avg_line_length": 38.8, "max_line_length": 111, "alphanum_fraction": 0.4163802978, "num_tokens": 736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582516374121, "lm_q2_score": 0.8267117919359419, "lm_q1q2_score": 0.7692208085327485}}
{"text": "module Acc where\n\ndata Acc ( A : Set ) ( Lt : A -> A -> Set) : A -> Set where\n  acc :    (   b : A ) \n        -> ( ( a : A ) -> Lt a b  ->  Acc A Lt a )\n        -> ( Acc A Lt b )\n\ndata Nat : Set where\n  zero : Nat\n  succ : Nat -> Nat\n\ndata Lt : Nat -> Nat -> Set where\n  ltzero : ( x : Nat ) -> Lt zero (succ x)\n  ltsucc : ( x : Nat ) -> (y : Nat) -> Lt x y -> Lt (succ x) (succ y)\n\nltstep : (x : Nat) ->  Lt x (succ x)\nltstep zero = ltzero _\nltstep (succ x) = ltsucc _ _ (ltstep x)\n\nnotLt0 : ( x : Nat ) -> Lt x zero -> (C : Set) -> C\nnotLt0 x ()\n\nwkLt : ( x y : Nat ) -> Lt (succ x) (succ y) -> Lt x y\nwkLt zero (succ y) _ = ltzero y\nwkLt x zero (ltsucc .x .zero ())\nwkLt x y (ltsucc .x .y p) = p \n\n{-\nwkLt1 : ( x y : Nat ) -> Lt (succ x) y -> Lt x y\nwkLt1 x zero ()\nwkLt1 zero (succ y) _ = ltzero y \nwkLt1 (succ x) (succ y) (ltsucc .(succ x)  .y p) = ltsucc x y (wkLt1 x y p)   \n-}\n\nwkLt2 : (x y : Nat ) -> Lt x y -> Lt x (succ y)\nwkLt2 x zero () \nwkLt2 zero y p = ltzero y \nwkLt2 (succ x) (succ y) (ltsucc .x .y p) = ltsucc x (succ y) (wkLt2 x y p) \n\nltcase : ( x : Nat ) -> ( y : Nat ) -> Lt x (succ y) ->  \n         ( P : Nat -> Set ) -> ( (x' : Nat ) -> Lt x' y -> P x') -> P y -> P x\nltcase zero zero      _ P hx' hy = hy\nltcase zero (succ y') _ P hx' hy = hx' zero (ltzero y')\nltcase (succ x') zero (ltsucc .x' .zero ()) _ _ _\nltcase (succ x') (succ y') (ltsucc .x' .(succ y') p) P hx' hy = \n  ltcase x' y' p (\\ n -> P (succ n))\n    (\\ x'' p' -> hx' (succ x'') (ltsucc x'' y' p')) hy\n\naccSucc : (x : Nat) -> Acc Nat Lt x -> Acc Nat Lt (succ x)\naccSucc x (acc .x h) = acc (succ x) (\\ y p -> ltcase y x p (Acc Nat Lt) h (acc x h))\n\n\naccLt : ( x : Nat ) -> Acc Nat Lt x\naccLt zero = acc zero (\\a -> \\p -> notLt0 a p (Acc Nat Lt a) )\naccLt (succ x) = accSucc x (accLt x)\n\n\n-- subtraction x - y\n\nsub : Nat -> Nat -> Nat\nsub zero y = zero\nsub (succ x) zero = succ x\nsub (succ x) (succ y) = sub x y\n\nsubLt : (x y : Nat) -> Lt (sub (succ x) (succ y)) (succ x)\nsubLt zero y = ltzero _\nsubLt (succ x') zero = ltstep (succ x')\nsubLt (succ x') (succ y') = wkLt2 _ _ (subLt x' y')\n\n-- division  x / (y + 1)\n\ndiv' : (x y : Nat) -> Acc Nat Lt x -> Nat\ndiv' zero _ _ = zero\ndiv' (succ x') y' (acc ._ h) = succ (div' z y' (h _ p)) \n  where z = sub (succ x') (succ y')\n        p = subLt x' y'\n\n\n----\n\ndata WO ( A : Set ) ( Lt : A -> A -> Set ) : Set where\n  wo : ((x : A) -> Acc A Lt x) -> WO A Lt \n\nwoLt : WO Nat Lt\nwoLt = wo accLt\n\n\n", "meta": {"hexsha": "e3ec5b648993552555e8d0e7316088178e4bb95a", "size": 2426, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AccP.agda", "max_stars_repo_name": "andreasabel/miniagda", "max_stars_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 85, "max_stars_repo_stars_event_min_datetime": "2016-12-16T15:53:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T16:54:56.000Z", "max_issues_repo_path": "examples/AccP.agda", "max_issues_repo_name": "andreasabel/miniagda", "max_issues_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2016-12-16T15:48:25.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-17T08:09:01.000Z", "max_forks_repo_path": "examples/AccP.agda", "max_forks_repo_name": "andreasabel/miniagda", "max_forks_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2019-03-30T00:17:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-16T07:47:36.000Z", "avg_line_length": 27.5681818182, "max_line_length": 84, "alphanum_fraction": 0.5028854081, "num_tokens": 986, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897492587141, "lm_q2_score": 0.817574471748733, "lm_q1q2_score": 0.7691656822768161}}
{"text": "data Nat : Set where\n  zero : Nat\n  suc  : Nat \u2192 Nat\n\n_+_ : Nat \u2192 Nat \u2192 Nat\nzero  + n = n\nsuc m + n = suc ?\n", "meta": {"hexsha": "ece36b73ddadb65c5055ea9a5da58fcfd96b855e", "size": 108, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue1541.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue1541.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue1541.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 13.5, "max_line_length": 21, "alphanum_fraction": 0.5185185185, "num_tokens": 43, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9511422241476943, "lm_q2_score": 0.8080672066194946, "lm_q1q2_score": 0.7685868401648805}}
{"text": "module Issue637 where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat \u2192 Nat\n\ninfixl 60 _+_\n_+_ : Nat \u2192 Nat \u2192 Nat\nzero + n = n\nsuc m + n = suc (n + m)\n\ndata _\u2261_ {A : Set}(x : A) : A \u2192 Set where\n  refl : x \u2261 x\n\n`1 = suc zero\n`2 = suc `1\n`3 = suc `2\n`4 = `2 + `2\n`8 = `4 + `4\n`16 = `8 + `8\n`32 = `16 + `16\n`50 = `32 + `16 + `2\n`64 = `32 + `32\n`100 = `64 + `32 + `4\n`200 = `100 + `100\n`400 = `200 + `200\n`800 = `400 + `400\n`1000 = `800 + `200\n`2000 = `1000 + `1000\n`4000 = `2000 + `2000\n\nprf : `16 \u2261 (`4 + (`4 + `8))\nprf = refl\n\ninfixr 40 _\u2237_\ndata Vec : Nat \u2192 Set where\n  [] : Vec zero\n  _\u2237_ : \u2200 {n} \u2192 Nat \u2192 Vec n \u2192 Vec (suc n)\n\nfromN : \u2200 {n} \u2192 Nat \u2192 Vec n\nfromN {zero} _ = []\nfromN {suc n} x = x \u2237 fromN (suc x)\n\nsum : \u2200 {n} \u2192 Vec n \u2192 Nat\nsum [] = zero\nsum (n \u2237 ns) = n + sum ns\n\nprf\u2081 : sum (fromN {`100} `1) \u2261 (`4000 + `1000 + `50)\nprf\u2081 = refl\n", "meta": {"hexsha": "d9c552f3bf1f8f808372d35ebb1e5dc38226ff71", "size": 842, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Issue637.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Issue637.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Issue637.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 16.84, "max_line_length": 52, "alphanum_fraction": 0.4798099762, "num_tokens": 407, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107984180245, "lm_q2_score": 0.8198933425148213, "lm_q1q2_score": 0.7684128941559384}}
{"text": "open import Agda.Builtin.Nat\nopen import Agda.Builtin.Equality\n\ncong : {A B : Set} (f : A \u2192 B)\n     \u2192 {x y : A} \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\n+-identity\u02b3 : (x : Nat) \u2192 x + 0 \u2261 x\n+-identity\u02b3 zero    = refl\n+-identity\u02b3 (suc n) = cong suc (+-identity\u02b3 n)\n\n+-assoc : (x y z : Nat) \u2192 (x + y) + z \u2261 x + (y + z)\n+-assoc zero    _ _ = refl\n+-assoc (suc m) n o = cong suc (+-assoc m n o)\n\ndata Bin : Set where\n  nil : Bin\n  x0_ : Bin \u2192 Bin\n  x1_ : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc nil = x1 nil\ninc (x0 x) = x1 x\ninc (x1 x) = x0 (inc x)\n\nto : Nat \u2192 Bin\nto zero = (x0 nil)\nto (suc x) = inc (to x)\n\npostulate\n  from : Bin \u2192 Nat\n\ndata Can : Bin \u2192 Set where\n  Can- : \u2200 {n} \u2192 from (to n) \u2261 n \u2192 Can (to n)\n\ndata \u03a3 (A : Set) (B : A \u2192 Set) : Set where\n  \u27e8_,_\u27e9 : (x : A) \u2192 B x \u2192 \u03a3 A B\n\npostulate\n  to'' : (x : Nat) \u2192 \u03a3 Bin Can\n\nto\u2218from' : (a : Bin) \u2192 (b : Can a) \u2192 to'' (from a) \u2261 \u27e8 a , b \u27e9\nto\u2218from' .(to _) (Can- x) = {!!}\n", "meta": {"hexsha": "7e99d65d5190319f03df495f902b320107f963c0", "size": 913, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Fail/Issue3813.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Fail/Issue3813.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Fail/Issue3813.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.75, "max_line_length": 62, "alphanum_fraction": 0.5082146769, "num_tokens": 405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067163548471, "lm_q2_score": 0.8152324871074608, "lm_q1q2_score": 0.768362094489448}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring -- for length\nopen import Lists.Definition\nopen import Lists.Fold.Fold\n\nmodule Lists.Length where\n\nlength : {a : _} {A : Set a} (l : List A) \u2192 \u2115\nlength [] = zero\nlength (x :: l) = succ (length l)\n\nlength' : {a : _} {A : Set a} \u2192 (l : List A) \u2192 \u2115\nlength' = fold (\u03bb _ \u2192 succ) 0\n\nlength=length' : {a : _} {A : Set a} (l : List A) \u2192 length l \u2261 length' l\nlength=length' [] = refl\nlength=length' (x :: l) = applyEquality succ (length=length' l)\n", "meta": {"hexsha": "d770c9aad3d0d663795f4b6470ea26687c4a6bb5", "size": 557, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lists/Length.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Lists/Length.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Lists/Length.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 27.85, "max_line_length": 72, "alphanum_fraction": 0.6337522442, "num_tokens": 181, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9173026618464795, "lm_q2_score": 0.8376199673867852, "lm_q1q2_score": 0.7683510256996594}}
{"text": "\nmodule Prelude where\n\nid : {A : Set} -> A -> A\nid x = x\n\n_\u00b7_ : {A B C : Set} -> (B -> C) -> (A -> B) -> (A -> C)\nf \u00b7 g = \\ x -> f (g x)\n\nflip : {A B C : Set} -> (A -> B -> C) -> B -> A -> C\nflip f x y = f y x\n\nRel : Set -> Set1\nRel X = X -> X -> Set\n\ndata False : Set where\nrecord True : Set where\n\ntt : True\ntt = _\n\n! : {A : Set} -> A -> True\n! = _\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n  refl : x == x\n\nsubst : {A : Set}(P : A -> Set){x y : A} -> x == y -> P y -> P x\nsubst P refl p = p\n\ncong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y\ncong f refl = refl\n\nsym : {A : Set}{x y : A} -> x == y -> y == x\nsym refl = refl\n\ntrans : {A : Set}{x y z : A} -> x == y -> y == z -> x == z\ntrans refl yz = yz\n\ndata _\u00d7_ (A B : Set) : Set where\n  _,_ : A -> B -> A \u00d7 B\n\ninfixr 10 _,_\n\nrecord \u03a3 (A : Set)(B : A -> Set) : Set where\n  field\n    fst : A\n    snd : B fst\n\n_,,_ : {A : Set}{B : A -> Set}(x : A) -> B x -> \u03a3 A B\nx ,, y = record { fst = x; snd = y }\n\nprivate module \u03a3p {A : Set}{B : A -> Set} = \u03a3 {A}{B}\nopen \u03a3p public\n\ndata _\u2228_ (A B : Set) : Set where\n  inl : A -> A \u2228 B\n  inr : B -> A \u2228 B\n\ndata Bool : Set where\n  false : Bool\n  true  : Bool\n\nIsTrue : Bool -> Set\nIsTrue false = False\nIsTrue true  = True\n\nIsFalse : Bool -> Set\nIsFalse true  = False\nIsFalse false = True\n\ndata Inspect (b : Bool) : Set where\n  itsTrue  : IsTrue b -> Inspect b\n  itsFalse : IsFalse b -> Inspect b\n\ninspect : (b : Bool) -> Inspect b \ninspect true  = itsTrue  _\ninspect false = itsFalse _\n\ndata LeqBool : Rel Bool where\n  ref : {b : Bool} -> LeqBool b b\n  up  : LeqBool false true\n\nOne : Rel True\nOne _ _ = True\n\n_[\u00d7]_ : {A B : Set} -> Rel A -> Rel B -> Rel (A \u00d7 B)\n(R [\u00d7] S) (a\u2081 , b\u2081) (a\u2082 , b\u2082) = R a\u2081 a\u2082 \u00d7 S b\u2081 b\u2082\n", "meta": {"hexsha": "95c9defc30a18b5b09df754ae9fc41378aa7b079", "size": 1717, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/Path/Prelude.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/AIM6/Path/Prelude.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM6/Path/Prelude.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.2921348315, "max_line_length": 64, "alphanum_fraction": 0.495049505, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026595857204, "lm_q2_score": 0.8376199552262967, "lm_q1q2_score": 0.768351012651154}}
{"text": "\nmodule Numeric.Nat.GCD where\n\nopen import Prelude\nopen import Control.WellFounded\nopen import Numeric.Nat.Properties\nopen import Numeric.Nat.DivMod\nopen import Numeric.Nat.Divide\nopen import Numeric.Nat.Divide.Properties\nopen import Tactic.Nat\n\n--- GCD ---\n\nrecord IsGCD (d a b : Nat) : Set where\n  no-eta-equality\n  constructor is-gcd\n  field d|a : d Divides a\n        d|b : d Divides b\n        g   : \u2200 k \u2192 k Divides a \u2192 k Divides b \u2192 k Divides d\n\nrecord GCD (a b : Nat) : Set where\n  no-eta-equality\n  constructor gcd-res\n  field d     : Nat\n        isGCD : IsGCD d a b\n\nopen GCD public using () renaming (d to get-gcd)\n\n-- Projections --\n\nis-gcd-factor\u2081 : \u2200 {a b d} \u2192 IsGCD d a b \u2192 Nat\nis-gcd-factor\u2081 g = get-factor (IsGCD.d|a g)\n\nis-gcd-factor\u2082 : \u2200 {a b d} \u2192 IsGCD d a b \u2192 Nat\nis-gcd-factor\u2082 g = get-factor (IsGCD.d|b g)\n\ngcd-factor\u2081 : \u2200 {a b} \u2192 GCD a b \u2192 Nat\ngcd-factor\u2081 g = is-gcd-factor\u2081 (GCD.isGCD g)\n\ngcd-factor\u2082 : \u2200 {a b} \u2192 GCD a b \u2192 Nat\ngcd-factor\u2082 g = is-gcd-factor\u2082 (GCD.isGCD g)\n\n-- Euclid's algorithm --\n\nisGCD-step : \u2200 {d r\u2080 r\u2081 r\u2082} q \u2192 q * r\u2081 + r\u2082 \u2261 r\u2080 \u2192 IsGCD d r\u2081 r\u2082 \u2192 IsGCD d r\u2080 r\u2081\nisGCD-step q refl (is-gcd d|r\u2081 d|r\u2082 g) =\n  is-gcd (divides-add (divides-mul-r q d|r\u2081) d|r\u2082)\n         d|r\u2081 (\u03bb k k|r\u2080 k|r\u2081 \u2192 g k k|r\u2081 (divides-sub-l k|r\u2080 (divides-mul-r q k|r\u2081)))\n\nprivate\n  gcd-step : \u2200 {a b} q {r} \u2192 q * suc b + r \u2261 a \u2192 GCD (suc b) r \u2192 GCD a (suc b)\n  gcd-step q eq (gcd-res d p) = gcd-res d (isGCD-step q eq p)\n\n  gcd-cert-acc : \u2200 a b \u2192 Acc _<_ b \u2192 GCD a b\n  gcd-cert-acc a zero _ = gcd-res a (is-gcd (factor 1 auto) (factor! 0) (\u03bb k k|a _ \u2192 k|a))\n  gcd-cert-acc a (suc b) (acc wf) =\n    case a divmod suc b of \u03bb\n    { (qr q r lt eq) \u2192 gcd-step q eq (gcd-cert-acc (suc b) r (wf r lt)) }\n\neraseIsGCD : \u2200 {d a b} \u2192 IsGCD d a b \u2192 IsGCD d a b\neraseIsGCD (is-gcd d|a d|b g) =\n  is-gcd (fast-divides d|a) (fast-divides d|b)\n         \u03bb k k|a k|b \u2192 fast-divides (g k k|a k|b)\n\neraseGCD : \u2200 {a b} \u2192 GCD a b \u2192 GCD a b\neraseGCD (gcd-res d p) = gcd-res d (eraseIsGCD p)\n\ngcd : \u2200 a b \u2192 GCD a b\ngcd 0 b = gcd-res b (is-gcd (factor! 0) divides-refl (\u03bb _ _ k|b \u2192 k|b))\ngcd 1 b = gcd-res 1 (is-gcd divides-refl (factor b auto) (\u03bb _ k|1 _ \u2192 k|1))\ngcd a b = eraseGCD (gcd-cert-acc a b (wfNat b))\n\ngcd! : Nat \u2192 Nat \u2192 Nat\ngcd! a b = get-gcd (gcd a b)\n\nCoprime : Nat \u2192 Nat \u2192 Set\nCoprime a b = gcd! a b \u2261 1\n", "meta": {"hexsha": "d749bab4ef2352be2baa9575419135d09ef61461", "size": 2302, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Numeric/Nat/GCD.agda", "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Numeric/Nat/GCD.agda", "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Numeric/Nat/GCD.agda", "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.5128205128, "max_line_length": 90, "alphanum_fraction": 0.6059947871, "num_tokens": 933, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.921921841290738, "lm_q2_score": 0.833324587033253, "lm_q1q2_score": 0.7682601376705404}}
{"text": "module Fin where\n\ndata Nat : Set where\n  zero : Nat\n  succ : Nat -> Nat\n\ndata Fin : Nat -> Set where\n    fzero : {n : Nat} -> Fin (succ n)\n    fsucc : {n : Nat} -> Fin n -> Fin (succ n)\n", "meta": {"hexsha": "2476f46c256bd8855039d89a21454c0d67805cd6", "size": 186, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Fin.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Fin.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Fin.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.6, "max_line_length": 46, "alphanum_fraction": 0.5483870968, "num_tokens": 63, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9653811621568289, "lm_q2_score": 0.7956580927949807, "lm_q1q2_score": 0.7681133343019044}}
{"text": "\nmodule Problem2 where\n\nopen import Problem1\n\ninfixr 40 _\u25ba_\n\ndata Vec (A : Set) : Nat -> Set where\n  \u03b5   : Vec A zero\n  _\u25ba_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)\n\n-- 2.1\n\nvec : {A : Set}{n : Nat} -> A -> Vec A n\nvec {n = zero } x = \u03b5\nvec {n = suc n} x = x \u25ba vec x\n\n-- 2.2\n\ninfixl 80 _<*>_\n\n_<*>_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n\n\u03b5        <*> \u03b5        = \u03b5\n(f \u25ba fs) <*> (x \u25ba xs) = f x \u25ba fs <*> xs\n\n-- 2.3\n\nmap : {A B : Set}{n : Nat} -> (A -> B) -> Vec A n -> Vec B n\nmap f xs = vec f <*> xs\n\n-- 2.4\n\nzip : {A B C : Set}{n : Nat} -> (A -> B -> C) ->\n      Vec A n -> Vec B n -> Vec C n\nzip f xs ys = vec f <*> xs <*> ys\n", "meta": {"hexsha": "3be2ea86ad9aae2e4ff43a70597c3c0ce8c47e8e", "size": 654, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Solutions/Problem2.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Solutions/Problem2.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Solutions/Problem2.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 18.1666666667, "max_line_length": 68, "alphanum_fraction": 0.4311926606, "num_tokens": 279, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850093037731, "lm_q2_score": 0.8198933381139646, "lm_q1q2_score": 0.767653841704135}}
{"text": "module Prelude.Fin where\n\nopen import Prelude.Eq\nopen import Prelude.Nat\n\ndata Fin : Nat -> Set where\n  fz : \u2200{n} -> Fin (S n)\n  fs : \u2200{n} -> Fin n -> Fin (S n)\n\nforget : {n : Nat} -> Fin n -> Nat\nforget fz     = Z\nforget (fs n) = S (forget n)\n\ninject : (n : Nat) -> Fin (S n)\ninject Z = fz\ninject (S n) = fs (inject n)\n\ninc : {n : Nat} -> Fin n -> Fin (S n)\ninc fz     = fz\ninc (fs n) = fs (inc n)\n", "meta": {"hexsha": "bcd8ec4ffd940f44530bf16b6f04a0abd0600dd2", "size": 399, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/epic/Prelude/Fin.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/epic/Prelude/Fin.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/epic/Prelude/Fin.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 19.0, "max_line_length": 37, "alphanum_fraction": 0.5438596491, "num_tokens": 147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9362850039701653, "lm_q2_score": 0.8198933315126792, "lm_q1q2_score": 0.7676538311504609}}
{"text": "module plfa-exercises.part1.Decidable where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; sym; cong)\nopen Eq.\u2261-Reasoning\nopen import Data.Nat using (\u2115; zero; suc; pred)\nopen import Data.Product using (_\u00d7_) renaming (_,_ to \u27e8_,_\u27e9)\nopen import Data.Sum using (_\u228e_; inj\u2081; inj\u2082)\nopen import Relation.Nullary using (\u00ac_)\nopen import Relation.Nullary.Negation using ()\n  renaming (contradiction to \u00ac\u00ac-intro)\nopen import Data.Unit using (\u22a4; tt)\nopen import Data.Empty using (\u22a5; \u22a5-elim)\nopen import plfa.part1.Relations using (_<_; z<s; s<s)\nopen import plfa.part1.Isomorphism using (_\u21d4_)\nopen import Function.Base using (_\u2218_)\n\ninfix 4 _\u2264_\n\ndata _\u2264_ : \u2115 \u2192 \u2115 \u2192 Set where\n\n  z\u2264n : \u2200 {n : \u2115}\n      --------\n    \u2192 zero \u2264 n\n\n  s\u2264s : \u2200 {m n : \u2115}\n    \u2192 m \u2264 n\n      -------------\n    \u2192 suc m \u2264 suc n\n    \n\n_ : 2 \u2264 4\n_ = s\u2264s (s\u2264s z\u2264n)\n\n\u00ac4\u22642 : \u00ac (4 \u2264 2)\n--\u00ac4\u22642 (s\u2264s (s\u2264s ())) = ? -- This causes Agda to die! TODO: Report\n\u00ac4\u22642 (s\u2264s (s\u2264s ()))\n\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n\ninfix 4 _\u2264\u1d47_\n\n_\u2264\u1d47_ : \u2115 \u2192 \u2115 \u2192 Bool\nzero \u2264\u1d47 n       =  true\nsuc m \u2264\u1d47 zero   =  false\nsuc m \u2264\u1d47 suc n  =  m \u2264\u1d47 n\n\n_ : (2 \u2264\u1d47 4) \u2261 true\n_ = refl\n_ : (5 \u2264\u1d47 4) \u2261 false\n_ = refl\n\nT : Bool \u2192 Set\nT true = \u22a4\nT false = \u22a5\n\n\u2264\u2192\u2264\u1d47 : \u2200 {m n} \u2192 (m \u2264 n) \u2192 T (m \u2264\u1d47 n)\n\u2264\u2192\u2264\u1d47 z\u2264n = tt\n\u2264\u2192\u2264\u1d47 (s\u2264s m\u2264n) = \u2264\u2192\u2264\u1d47 m\u2264n\n\n\u2264\u1d47\u2192\u2264 : \u2200 {m n} \u2192 T (m \u2264\u1d47 n) \u2192 (m \u2264 n)\n\u2264\u1d47\u2192\u2264 {zero} {_} tt = z\u2264n\n-- What is going on in here? Left `t` has type `T (suc m \u2264\u1d47 suc n)` and the right `t` has type `T (m \u2264\u1d47 n)`\n-- \u03bb m n \u2192 T (suc m \u2264\u1d47 suc n)   => reduces to:  \u03bb m n \u2192 T (m \u2264\u1d47 n)\n-- Ohh! Ok. It is because the third rule of `\u2264\u1d47` reduces `suc m \u2264\u1d47 suc n` to `m \u2264\u1d47 n`\n\u2264\u1d47\u2192\u2264 {suc m} {suc n} t = s\u2264s (\u2264\u1d47\u2192\u2264 {m} {n} t)\n-- \u03bb m \u2192 T (suc m \u2264\u1d47 zero)   => reduces to:  \u03bb m \u2192 \u22a5\n-- which means that there are no rules for `from\u1d47 {suc m} {zero}`\n\u2264\u1d47\u2192\u2264 {suc m} {zero} ()\n\nproof\u2261computation : \u2200 {m n} \u2192 (m \u2264 n) \u21d4 T (m \u2264\u1d47 n)\nproof\u2261computation {m} {n} =\n  record\n    { from = \u2264\u1d47\u2192\u2264\n    ; to = \u2264\u2192\u2264\u1d47\n    }\n\nT\u2192\u2261 : \u2200 (b : Bool) \u2192 T b \u2192 b \u2261 true\nT\u2192\u2261 true tt = refl\nT\u2192\u2261 false ()\n\n--postulate\n--  lie : false \u2261 true\n\n\u2261\u2192T : \u2200 {b : Bool} \u2192 b \u2261 true \u2192 T b\n--\u2261\u2192T {false} refl = ? -- This is impossible because of refl's definition. Unification forces `b` to be `true`\n--\u2261\u2192T {false} rewrite lie = \u03bb refl \u2192 ? -- Even postulating a lie, it is impossible to create a bottom value\n\u2261\u2192T refl = tt\n\n_ : 2 \u2264 4\n_ = \u2264\u1d47\u2192\u2264 tt\n\n\u00ac4\u22642\u2082 : \u00ac (4 \u2264 2)\n--\u00ac4\u22642\u2082 4\u22642 = \u2264\u2192\u2264\u1d47 4\u22642\n--\u00ac4\u22642\u2082 = \u2264\u2192\u2264\u1d47 {4} {2}\n-- The type of `T (4 \u2264\u1d47 2)` which reduces to `T false` and then `\u22a5`\n\u00ac4\u22642\u2082 = \u2264\u2192\u2264\u1d47\n-- Notice how defining \u2264\u1d47 lifts from us the demand of computing the correct\n-- `evidence` (implementation) for the `proof` (function type)\n\n\ndata Dec (A : Set) : Set where\n  yes :   A \u2192 Dec A\n  no  : \u00ac A \u2192 Dec A\n\n\u00acs\u2264z : {m : \u2115} \u2192 \u00ac (suc m) \u2264 zero\n--\u00acs\u2264z = \u2264\u2192\u2264\u1d47\n\u00acs\u2264z ()\n\n\u00acs\u2264s : {m n : \u2115} \u2192 \u00ac m \u2264 n \u2192 \u00ac suc m \u2264 suc n\n\u00acs\u2264s \u00acm\u2264n = \u03bb { (s\u2264s m\u2264n) \u2192 \u00acm\u2264n m\u2264n }\n\n_\u2264?_ : (m n : \u2115) \u2192 Dec (m \u2264 n)\nzero    \u2264? n       = yes z\u2264n\n(suc m) \u2264? zero    = no \u00acs\u2264z\n(suc m) \u2264? (suc n) with m \u2264? n\n...                   | yes  m\u2264n = yes (s\u2264s m\u2264n)\n...                   | no  \u00acm\u2264n = no  (\u00acs\u2264s \u00acm\u2264n)\n\n-- `2 \u2264? 4` reduces to `yes (s\u2264s (s\u2264s z\u2264n))`\n_ : Dec (2 \u2264 4)\n_ = 2 \u2264? 4\n_ = yes (s\u2264s (s\u2264s (z\u2264n {2})))\n\n\u230a_\u230b : \u2200 {A : Set} \u2192 Dec A \u2192 Bool\n\u230a yes x \u230b  =  true\n\u230a no \u00acx \u230b  =  false\n\n_ : Bool\n_ = true\n_ = \u230a 3 \u2264? 4 \u230b\n\n_ : \u230a 3 \u2264? 4 \u230b \u2261 true\n_ = refl\n\n_ : \u230a 3 \u2264? 2 \u230b \u2261 false\n_ = refl\n\ntoWitness : \u2200 {A : Set} {D : Dec A} \u2192 T \u230a D \u230b \u2192 A\ntoWitness {_} {yes v} tt = v\n--toWitness {_} {no _} = ? -- `T \u230a no x \u230b \u2192 A` reduces to `\u22a5 \u2192 A`\ntoWitness {_} {no _} () -- Empty because there is no value for `\u22a5`\n\nfromWitness : \u2200 {A : Set} {D : Dec A} \u2192 A \u2192 T \u230a D \u230b\nfromWitness {_} {yes _} _ = tt\nfromWitness {_} {no \u00aca} a = \u00aca a -- with type \u22a5\n\n_ : 2 \u2264 4\n--_ = toWitness {D = 2 \u2264? 4} tt\n_ = toWitness {_} {2 \u2264? 4} tt\n\n\u00ac4\u22642\u2083 : \u00ac (4 \u2264 2)\n--\u00ac4\u22642\u2083 = fromWitness {D = 4 \u2264? 2}\n\u00ac4\u22642\u2083 = fromWitness {_} {4 \u2264? 2}\n\n\u00acz<z : \u00ac (zero < zero)\n\u00acz<z ()\n\n\u00acs<z : \u2200 {m : \u2115} \u2192 \u00ac (suc m < zero)\n\u00acs<z ()\n\n_<?_ : \u2200 (m n : \u2115) \u2192 Dec (m < n)\nzero <? zero = no \u00acz<z\nzero <? suc n = yes z<s\nsuc m <? zero = no \u00acs<z\nsuc m <? suc n with m <? n\n...               | yes m<n = yes (s<s m<n)\n...               | no \u00acm<n = no \u03bb{(s<s m<n) \u2192 \u00acm<n m<n}\n\n_ : \u230a 2 <? 4 \u230b \u2261 true\n_ = refl\n\n\u00acz\u2261sn : \u2200 {n : \u2115} \u2192 \u00ac zero \u2261 suc n\n\u00acz\u2261sn ()\n\n_\u2261\u2115?_ : \u2200 (m n : \u2115) \u2192 Dec (m \u2261 n)\nzero    \u2261\u2115? zero    = yes refl\nzero    \u2261\u2115? (suc n) = no \u00acz\u2261sn\n--(suc m) \u2261\u2115? zero    = no (\u03bb{sn\u2261z \u2192 \u00acz\u2261sn (sym sn\u2261z)})\n--(suc m) \u2261\u2115? zero    = no (\u00acz\u2261sn \u2218 sym)\n(suc m) \u2261\u2115? zero    = no ((\u03bb()) \u2218 sym)\n--The following doesn't work though\n--(suc m) \u2261\u2115? zero    with zero \u2261\u2115? (suc m)\n--...                 | yes  z\u2261sm = yes (sym z\u2261sm)\n--...                 | no  \u00acz\u2261sm = no (\u00acz\u2261sm \u2218 sym)\n(suc m) \u2261\u2115? (suc n) with m \u2261\u2115? n\n...               | yes m\u2261n = yes (cong suc m\u2261n)\n...               | no \u00acm\u2261n = no  (\u00acm\u2261n \u2218 (cong pred))\n\n\ninfixr 6 _\u00d7-dec_\n\n_\u00d7-dec_ : \u2200 {A B : Set} \u2192 Dec A \u2192 Dec B \u2192 Dec (A \u00d7 B)\nyes x \u00d7-dec yes y = yes \u27e8 x , y \u27e9\nno \u00acx \u00d7-dec _     = no \u03bb{ \u27e8 x , y \u27e9 \u2192 \u00acx x }\n_     \u00d7-dec no \u00acy = no \u03bb{ \u27e8 x , y \u27e9 \u2192 \u00acy y }\n\ninfixr 6 _\u228e-dec_\n\n_\u228e-dec_ : \u2200 {A B : Set} \u2192 Dec A \u2192 Dec B \u2192 Dec (A \u228e B)\nyes x \u228e-dec _     = yes (inj\u2081 x)\n_     \u228e-dec yes y = yes (inj\u2082 y)\nno \u00acx \u228e-dec no \u00acy = no \u03bb{(inj\u2081 x) \u2192 \u00acx x; (inj\u2082 y) \u2192 \u00acy y}\n\n\u00ac? : \u2200 {A : Set} \u2192 Dec A \u2192 Dec (\u00ac A)\n\u00ac? (yes x) = no (\u00ac\u00ac-intro x)\n\u00ac? (no \u00acx) = yes \u00acx\n\n_\u2192-dec_ : \u2200 {A B : Set} \u2192 Dec A \u2192 Dec B \u2192 Dec (A \u2192 B)\n_     \u2192-dec yes y = yes (\u03bb _ \u2192 y)\n--no \u00acx \u2192-dec _     = yes ((\u03bb()) \u2218 \u00acx)\nno \u00acx \u2192-dec _     = yes (\u22a5-elim \u2218 \u00acx)\nyes x \u2192-dec no \u00acy = no (\u03bb{x\u2192y \u2192 \u00acy (x\u2192y x)})\n\n\ninfixr 6 _\u2227_\n\n_\u2227_ : Bool \u2192 Bool \u2192 Bool\ntrue  \u2227 true  = true\nfalse \u2227 _     = false\n_     \u2227 false = false\n\n\u2227-\u00d7 : \u2200 {A B : Set} (x : Dec A) (y : Dec B) \u2192 \u230a x \u230b \u2227 \u230a y \u230b \u2261 \u230a x \u00d7-dec y \u230b\n\u2227-\u00d7 (yes x) (yes y) = refl\n\u2227-\u00d7 (no \u00acx) _       = refl\n\u2227-\u00d7 (yes x) (no \u00acy) = refl\n\n_iff_ : Bool \u2192 Bool \u2192 Bool\ntrue  iff true  = true\nfalse iff false = true\n_     iff _     = false\n\n_\u21d4-dec_ : \u2200 {A B : Set} \u2192 Dec A \u2192 Dec B \u2192 Dec (A \u21d4 B)\nyes x \u21d4-dec yes y = yes (record { from = \u03bb{_ \u2192 x} ; to = \u03bb{_ \u2192 y} })\nno \u00acx \u21d4-dec no \u00acy = yes (record { from = (\u03bb()) \u2218 \u00acy ; to = (\u03bb()) \u2218 \u00acx })\nyes x \u21d4-dec no \u00acy = no (\u03bb x\u21d4y \u2192 \u00acy (_\u21d4_.to   x\u21d4y x))\nno \u00acx \u21d4-dec yes y = no (\u03bb x\u21d4y \u2192 \u00acx (_\u21d4_.from x\u21d4y y))\n\niff-\u21d4 : \u2200 {A B : Set} (x : Dec A) (y : Dec B) \u2192 \u230a x \u230b iff \u230a y \u230b \u2261 \u230a x \u21d4-dec y \u230b\niff-\u21d4 (yes x) (yes y) = refl\niff-\u21d4 (no \u00acx) (no \u00acy) = refl\niff-\u21d4 (no \u00acx) (yes y) = refl\niff-\u21d4 (yes x) (no \u00acy) = refl\n", "meta": {"hexsha": "59cb9f34e7e10aac67ff77cffd26bbe070da660f", "size": 6333, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Decidable.agda", "max_stars_repo_name": "helq/old_code", "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Decidable.agda", "max_issues_repo_name": "helq/old_code", "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Decidable.agda", "max_forks_repo_name": "helq/old_code", "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.743902439, "max_line_length": 110, "alphanum_fraction": 0.4719722091, "num_tokens": 3163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9073122288794595, "lm_q2_score": 0.8459424431344437, "lm_q1q2_score": 0.7675339235840475}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Groups.Definition\nopen import Groups.Abelian.Definition\nopen import Setoids.Setoids\nopen import Rings.Definition\n\nopen import Agda.Primitive using (Level; lzero; lsuc; _\u2294_)\n\nmodule Modules.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+R_ : A \u2192 A \u2192 A} {_*_ : A \u2192 A \u2192 A} (R : Ring S _+R_ _*_) {m n : _} {M : Set m} {T : Setoid {m} {n} M} {_+_ : M \u2192 M \u2192 M} {G' : Group T _+_} (G : AbelianGroup G') (_\u00b7_ : A \u2192 M \u2192 M) where\n\nrecord Module : Set (a \u2294 b \u2294 m \u2294 n) where\n  field\n    dotWellDefined : {r s : A} {t u : M} \u2192 Setoid._\u223c_ S r s \u2192 Setoid._\u223c_ T t u \u2192 Setoid._\u223c_ T (r \u00b7 t) (s \u00b7 u)\n    dotDistributesLeft : {r : A} {x y : M} \u2192 Setoid._\u223c_ T (r \u00b7 (x + y)) ((r \u00b7 x) + (r \u00b7 y))\n    dotDistributesRight : {r s : A} {x : M} \u2192 Setoid._\u223c_ T ((r +R s) \u00b7 x) ((r \u00b7 x) + (s \u00b7 x))\n    dotAssociative : {r s : A} {x : M} \u2192 Setoid._\u223c_ T ((r * s) \u00b7 x) (r \u00b7 (s \u00b7 x))\n    dotIdentity : {x : M} \u2192 Setoid._\u223c_ T ((Ring.1R R) \u00b7 x) x\n", "meta": {"hexsha": "2323a297c88f440dac644e59c4e2e730789995be", "size": 986, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Modules/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Modules/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Modules/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 51.8947368421, "max_line_length": 257, "alphanum_fraction": 0.5385395538, "num_tokens": 423, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377249197138, "lm_q2_score": 0.8006919949619792, "lm_q1q2_score": 0.7674934832122825}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Relation.Binary using (Rel)\n\nmodule Algebra.Structures.Field\n  {a \u2113} {A : Set a}\n  (_\u2248_ : Rel A \u2113)\n  where\n\nopen import Algebra.Linear.Core\n\nopen import Relation.Nullary using (\u00ac_)\n\nopen import Algebra.Structures _\u2248_\nopen import Algebra.FunctionProperties _\u2248_\n\nopen import Level using (_\u2294_)\n\nrecord NonZero\u00a0(0# : A) : Set (a \u2294 \u2113) where\n  field\n    value    : A\n    non-zero : \u00ac (value \u2248 0#)\n\nMultiplicativeInverse : \u2200 (0# : A) -> Set (a \u2294 \u2113)\nMultiplicativeInverse 0# = NonZero 0# \u2192 NonZero 0#\n\nrecord IsField\u00a0(_+_ _*_ : Op\u2082 A) (0# 1# : A) (-_ : Op\u2081 A) (_\u207b\u00b9 : MultiplicativeInverse 0#) : Set (a \u2294 \u2113) where\n  field\n    isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#\n    _\u207b\u00b9-involutive : \u2200 (x : NonZero 0#) \u2192 NonZero.value ((x \u207b\u00b9) \u207b\u00b9) \u2248 NonZero.value x\n    _\u207b\u00b9-inverse  : \u2200 (x : NonZero 0#) \u2192 ((NonZero.value x) * (NonZero.value (x \u207b\u00b9))) \u2248 1#\n    0#-not-1#    : \u00ac (0# \u2248 1#)\n\n  open IsCommutativeRing isCommutativeRing public\n\n  open import Algebra.Properties.Ring (record { isRing = isRing }) public\n", "meta": {"hexsha": "9de497b077e85ca77fd2819d7a9a975d7002ab1d", "size": 1053, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Algebra/Structures/Field.agda", "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_issues_repo_path": "src/Algebra/Structures/Field.agda", "max_issues_repo_name": "felko/linear-algebra", "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Structures/Field.agda", "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.4594594595, "max_line_length": 110, "alphanum_fraction": 0.6353276353, "num_tokens": 386, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768620069627, "lm_q2_score": 0.8128673087708699, "lm_q1q2_score": 0.7674905048233248}}
{"text": "module Data.List.First {\u2113}{A : Set \u2113} where\n\nopen import Data.Product\nopen import Data.List\nopen import Relation.Nullary\nopen import Relation.Binary.PropositionalEquality\nopen import Level\nopen import Function\nopen import Data.Empty\n\n-- proof that an element is the first in a vector to satisfy the predicate B\ndata First {b}(B : A \u2192 Set b) : (x : A) \u2192 List A \u2192 Set (\u2113 \u2294 b) where\n\n  here  : \u2200 {x : A} \u2192 (p : B x) \u2192 {v : List A} \u2192 First B x (x \u2237 v)\n  there : \u2200 {x} {v : List A} (x' : A) \u2192 \u00ac (B x') \u2192 First B x v \u2192 First B x (x' \u2237 v)\n\n-- get the witness of B x from the element \u2208 First\nfirst\u27f6witness : \u2200 {B : A \u2192 Set} {x l} \u2192 First B x l \u2192 B x\nfirst\u27f6witness (here p) = p\nfirst\u27f6witness (there x \u00acpx f) = first\u27f6witness f\n\n-- more likable syntax for the above structure\nfirst_\u2208_\u21d2_ : \u2200 {p} \u2192 A \u2192 List A \u2192 (B : A \u2192 Set p) \u2192 Set (p \u2294 \u2113)\nfirst_\u2208_\u21d2_ x v p = First p x v\n\n-- a decision procedure to find the first element in a vector that satisfies a predicate\nfind : \u2200 (P : A \u2192 Set) \u2192 ((a : A) \u2192 Dec (P a)) \u2192 (v : List A) \u2192\n       Dec (\u2203 \u03bb e \u2192 first e \u2208 v \u21d2 P)\nfind P dec [] = no (\u03bb{ (e , ()) })\nfind P dec (x \u2237 v) with dec x\nfind P dec (x \u2237 v) | yes px = yes (x , here px)\nfind P dec (x \u2237 v) | no \u00acpx with find P dec v\nfind P dec (x \u2237 v) | no \u00acpx | yes firstv = yes (-, there x \u00acpx (proj\u2082 firstv))\nfind P dec (x \u2237 v) | no \u00acpx | no \u00acfirstv = no $ helper \u00acpx \u00acfirstv\n  where\n    helper : \u00ac (P x) \u2192 \u00ac (\u2203 \u03bb e \u2192 First P e v) \u2192 \u00ac (\u2203 \u03bb e \u2192 First P e (x \u2237 v))\n    helper \u00acpx \u00acfirstv (.x , here p) = \u00acpx p\n    helper \u00acpx \u00acfirstv (u  , there ._ _ firstv) = \u00acfirstv (u , firstv)\n", "meta": {"hexsha": "b350a774d08b9f919ccd6fc0e341ca5dafcbaf72", "size": 1559, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/First.agda", "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Data/List/First.agda", "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Data/List/First.agda", "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 39.9743589744, "max_line_length": 88, "alphanum_fraction": 0.5824246312, "num_tokens": 586, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308184368928, "lm_q2_score": 0.8221891305219504, "lm_q1q2_score": 0.7674566730130215}}
{"text": "\n-- This module introduces the basic structure of an Agda program.\n\n{- Every Agda file contains a single top-level module. To make it possible to\n   find the file corresponding to a particular module, the name of the file\n   should correspond to the name of the module. In this case the module\n   'Introduction.Basics' is defined in the file 'Introduction/Basics.agda'.\n-}\nmodule Basics where\n\n{- The top-level module contains a sequence of declarations, such as datatype\n   declarations and function definitions. The most common forms of declarations\n   are introduced below.\n\n   A module can also contain sub-modules, see 'Introduction.Modules.SubModules'\n   for more information.\n-}\n\n-- Agda can be used as a pure logical framework. The 'postulate' declaration\n-- introduces new constants :\npostulate\n  N : Set     -- Set is the first universe\n  z : N\n  s : N -> N  -- The independent function space is written A -> B\n\n-- Using 'postulate' it is not possible to introduce new computation rules. A\n-- better way is to introduce a datatype and define functions by pattern\n-- matching on elements of the datatype.\n\n-- A datatype is introduced with the 'data' keyword. All constructors of the\n-- datatype are given with their types after the 'where'. Datatypes can be\n-- parameterised (see 'Introduction.Data.Parameterised').\n\ndata Bool : Set where\n  false : Bool\n  true  : Bool\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\n-- Functions over datatypes can be defined by pattern matching.\n\nplus : Nat -> Nat -> Nat\nplus  zero   m = m\nplus (suc n) m = suc (plus n m)\n\n-- With this definition plus (suc zero) (suc zero) will reduce to suc (suc\n-- zero).\n\n-- When defining mutually recursive functions you have to declare functions\n-- before they can be called.\n\nodd : Nat -> Bool\n\neven : Nat -> Bool\neven (suc n) = odd n\neven zero    = true\n\nodd zero    = false\nodd (suc n) = even n\n\n-- Agda is a monomorphic, but dependently typed, language. This means that\n-- polymorphism is simulated by having functions take type arguments. For\n-- instance, the polymorphic identity function can be represented as follows :\n\nid : (A : Set) -> A -> A        -- the dependent function space is written (x : A) -> B\nid A x = x\n\none : Nat\none = id Nat (suc zero) -- a silly use of the identity function\n\n-- To faithfully simulate a polymorphic function we would like to omit the type\n-- argument when using the function. See 'Introduction.Implicit' for\n-- information on how to do this.\n\n-- Agda is both a programming language and a formal proof language, so we\n-- expect to be able to prove theorems about our programs. As an example we\n-- prove the very simple theorem n + 0 == n.\n\n-- First we introduce datatypes for truth (a singleton type) and falsity (an\n-- empty type).\n\ndata True : Set where   -- Here it would make sense to declare True to be a\n  tt : True             -- Prop (the universe of propositions) rather than a\n                        -- Set. See 'Introduction.Universes' for more\n                        -- information.\n\ndata False : Set where  -- see 'Introduction.Data.Empty' for more information\n                        -- on empty types.\n\n-- Second, we define what it means for two natural numbers to be equal. Infix\n-- operators are declared by enclosing the operator in _. See\n-- 'Introduction.Operators' for more information.\n\n_==_ : Nat -> Nat -> Set\nzero  == zero  = True\nzero  == suc m = False\nsuc n == zero  = False\nsuc n == suc m = n == m\n\n-- Now we are ready to state and prove our theorem. The proof is by induction\n-- (i.e. recursion) on 'n'.\n\nthmPlusZero : (n : Nat) -> plus n zero == n   -- A function from a number n to\n                                            -- P n can be seen as the\n                                            -- proposition \u2200 n. P n.\nthmPlusZero  zero   = tt\nthmPlusZero (suc n) = thmPlusZero n\n\nthmPlusZero' : (n : Nat) -> plus zero n == n\nthmPlusZero'  zero   = tt\nthmPlusZero' (suc n) = thmPlusZero' n\n\n\n{- In both branches the reduction makes the proof very simple. In the first\n   case the goal is\n\n    plus zero zero == zero    which reduces to\n    zero == zero              and\n    True\n\n  In the second case we have\n\n    plus (suc n) zero == suc n\n    suc (plus n zero) == suc n\n    plus n zero == n\n\n  so the induction hypothesis (the recursive call) is directly applicable.\n-}\n", "meta": {"hexsha": "75f5723f471d5967d094d40abed113f62ff0b9c8", "size": 4342, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Basics.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Basics.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Basics.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1450381679, "max_line_length": 87, "alphanum_fraction": 0.6731920774, "num_tokens": 1080, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802417938535, "lm_q2_score": 0.8354835432479661, "lm_q1q2_score": 0.7673751268171773}}
{"text": "{-\n\nThis file introduces the \"powerset\" of a type in the style of\nEscard\u00f3's lecture notes:\n\nhttps://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#propositionalextensionality\n\n-}\n{-# OPTIONS --cubical --no-import-sorts --safe #-}\nmodule Cubical.Foundations.Powerset where\n\nopen import Cubical.Foundations.Prelude\nopen import Cubical.Foundations.Equiv\nopen import Cubical.Foundations.HLevels\nopen import Cubical.Foundations.Isomorphism\nopen import Cubical.Foundations.Structure\nopen import Cubical.Foundations.Function\nopen import Cubical.Foundations.Univalence using (hPropExt)\n\nopen import Cubical.Data.Sigma\n\nprivate\n  variable\n    \u2113 : Level\n    X : Type \u2113\n\n\u2119 : Type \u2113 \u2192 Type (\u2113-suc \u2113)\n\u2119 X = X \u2192 hProp _\n\ninfix 5 _\u2208_\n\n_\u2208_ : {X : Type \u2113} \u2192 X \u2192 \u2119 X \u2192 Type \u2113\nx \u2208 A = \u27e8 A x \u27e9\n\n_\u2286_ : {X : Type \u2113} \u2192 \u2119 X \u2192 \u2119 X \u2192 Type \u2113\nA \u2286 B = \u2200 x \u2192 x \u2208 A \u2192 x \u2208 B\n\n\u2208-isProp : (A : \u2119 X) (x : X) \u2192 isProp (x \u2208 A)\n\u2208-isProp A = snd \u2218 A\n\n\u2286-isProp : (A B : \u2119 X) \u2192 isProp (A \u2286 B)\n\u2286-isProp A B = isProp\u03a02 (\u03bb x _ \u2192 \u2208-isProp B x)\n\n\u2286-refl : (A : \u2119 X) \u2192 A \u2286 A\n\u2286-refl A x = idfun (x \u2208 A)\n\n\u2286-refl-consequence : (A B : \u2119 X) \u2192 A \u2261 B \u2192 (A \u2286 B) \u00d7 (B \u2286 A)\n\u2286-refl-consequence A B p = subst (A \u2286_) p (\u2286-refl A)\n                          , subst (B \u2286_) (sym p) (\u2286-refl B)\n\n\u2286-extensionality : (A B : \u2119 X) \u2192 (A \u2286 B) \u00d7 (B \u2286 A) \u2192 A \u2261 B\n\u2286-extensionality A B (\u03c6 , \u03c8) =\n  funExt (\u03bb x \u2192 TypeOfHLevel\u2261 1 (hPropExt (A x .snd) (B x .snd) (\u03c6 x) (\u03c8 x)))\n\npowersets-are-sets : isSet (\u2119 X)\npowersets-are-sets = isSet\u03a0 (\u03bb _ \u2192 isSetHProp)\n\n\u2286-extensionalityEquiv : (A B : \u2119 X) \u2192 (A \u2286 B) \u00d7 (B \u2286 A) \u2243 (A \u2261 B)\n\u2286-extensionalityEquiv A B = isoToEquiv (iso (\u2286-extensionality A B)\n                                            (\u2286-refl-consequence A B)\n                                            (\u03bb _ \u2192 powersets-are-sets A B _ _)\n                                            (\u03bb _ \u2192 isProp\u03a3 (\u2286-isProp A B) (\u03bb _ \u2192 \u2286-isProp B A) _ _))\n", "meta": {"hexsha": "6ce7c884b5c612cb05330f991ffd423d43b1261b", "size": 1886, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Foundations/Powerset.agda", "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Foundations/Powerset.agda", "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_forks_repo_path": "Cubical/Foundations/Powerset.agda", "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9365079365, "max_line_length": 106, "alphanum_fraction": 0.5699893955, "num_tokens": 764, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587964389113, "lm_q2_score": 0.8633916117313211, "lm_q1q2_score": 0.7673468896977808}}
{"text": "{- 1. Booleans -}\n\ndata Bool : Set where\n  true : Bool\n  false : Bool\n\nnot : Bool \u2192 Bool\nnot true = false\nnot false = true\n\n_\u2227_ : Bool \u2192 Bool \u2192 Bool\ntrue \u2227 true = true\ntrue \u2227 false = false\nfalse \u2227 true = false\nfalse \u2227 false = false\n\n_\u2228_ : Bool \u2192 Bool \u2192 Bool\ntrue \u2228 true = true\ntrue \u2228 false = true\nfalse \u2228 true = true\nfalse \u2228 false = false\n\n{- 2. Equality -}\ndata _\u2261_ {A : Set} (x : A) : (y : A) \u2192 Set where\n  refl : x \u2261 x\n\ninfix 4 _\u2261_\n\nnot-inv : (b : Bool) \u2192 not (not b) \u2261 b\nnot-inv true = refl\nnot-inv false = refl\n\nf : (b : Bool) \u2192 (not b) \u2227 b \u2261 false\nf true = refl\nf false = refl\n\n\n", "meta": {"hexsha": "b6f61cc449028916401ed577c8f3181101912d89", "size": 585, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD6/Bool.agda", "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TD6/Bool.agda", "max_issues_repo_name": "erwinkn/program-eq-proof", "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TD6/Bool.agda", "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.3947368421, "max_line_length": 48, "alphanum_fraction": 0.5829059829, "num_tokens": 220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9770226287518853, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.7672642491711807}}
{"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Definition\nopen import Numbers.Naturals.Addition\nopen import Numbers.Naturals.Multiplication\nopen import Semirings.Definition\nopen import Monoids.Definition\n\nmodule Numbers.Naturals.Semiring where\n\nopen Numbers.Naturals.Definition using (\u2115 ; zero ; succ ; succInjective ; naughtE) public\nopen Numbers.Naturals.Addition using (_+N_ ; canSubtractFromEqualityRight ; canSubtractFromEqualityLeft) public\nopen Numbers.Naturals.Multiplication using (_*N_ ; multiplicationNIsCommutative) public\n\n\u2115Semiring : Semiring 0 1 _+N_ _*N_\nMonoid.associative (Semiring.monoid \u2115Semiring) a b c = equalityCommutative (additionNIsAssociative a b c)\nMonoid.idLeft (Semiring.monoid \u2115Semiring) _ = refl\nMonoid.idRight (Semiring.monoid \u2115Semiring) a = additionNIsCommutative a 0\nSemiring.commutative \u2115Semiring = additionNIsCommutative\nMonoid.associative (Semiring.multMonoid \u2115Semiring) = multiplicationNIsAssociative\nMonoid.idLeft (Semiring.multMonoid \u2115Semiring) a = additionNIsCommutative a 0\nMonoid.idRight (Semiring.multMonoid \u2115Semiring) a = transitivity (multiplicationNIsCommutative a 1) (additionNIsCommutative a 0)\nSemiring.productZeroLeft \u2115Semiring _ = refl\nSemiring.productZeroRight \u2115Semiring a = multiplicationNIsCommutative a 0\nSemiring.+DistributesOver* \u2115Semiring = productDistributes\nSemiring.+DistributesOver*' \u2115Semiring a b c rewrite multiplicationNIsCommutative (a +N b) c | multiplicationNIsCommutative a c | multiplicationNIsCommutative b c = productDistributes c a b\n\nsuccExtracts : (x y : \u2115) \u2192 (x +N succ y) \u2261 (succ (x +N y))\nsuccExtracts x y = transitivity (Semiring.commutative \u2115Semiring x (succ y)) (applyEquality succ (Semiring.commutative \u2115Semiring y x))\n\nproductZeroImpliesOperandZero : {a b : \u2115} \u2192 a *N b \u2261 0 \u2192 (a \u2261 0) || (b \u2261 0)\nproductZeroImpliesOperandZero {zero} {b} pr = inl refl\nproductZeroImpliesOperandZero {succ a} {zero} pr = inr refl\nproductZeroImpliesOperandZero {succ a} {succ b} ()\n\n*NWellDefined : {a b c d : \u2115} \u2192 (a \u2261 c) \u2192 (b \u2261 d) \u2192 a *N b \u2261 c *N d\n*NWellDefined refl refl = refl\n\n+NWellDefined : {a b c d : \u2115} \u2192 (a \u2261 c) \u2192 (b \u2261 d) \u2192 a +N b \u2261 c +N d\n+NWellDefined refl refl = refl\n", "meta": {"hexsha": "40c7b910a65edc9eaf468909da427d6e415b434a", "size": 2208, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Naturals/Semiring.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Naturals/Semiring.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Naturals/Semiring.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 52.5714285714, "max_line_length": 188, "alphanum_fraction": 0.7753623188, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765257642906, "lm_q2_score": 0.8397339676722393, "lm_q1q2_score": 0.7672452141490347}}
{"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl1.Correctness.Permutation  {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_)  where\n\nopen import BTree {A}\nopen import Data.List\nopen import Data.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import List.Permutation.Base.Equivalence A\nopen import TreeSort.Impl1 _\u2264_ tot\u2264\n\nlemma-++\u223c : {x : A}{xs ys : List A} \u2192 (x \u2237 (xs ++ ys)) \u223c (xs ++ (x \u2237 ys))\nlemma-++\u223c {xs = xs} = \u223cx /head (lemma++/l {xs = xs} /head) refl\u223c\n\nlemma-flatten\u223c : (x : A) \u2192 (t : BTree) \u2192 (x \u2237 flatten t) \u223c flatten (insert x t)\nlemma-flatten\u223c x leaf = \u223cx /head /head \u223c[]\nlemma-flatten\u223c x (node y l r) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = lemma++\u223cr (lemma-flatten\u223c x l)\n... | inj\u2082 y\u2264x = trans\u223c (lemma-++\u223c {xs = flatten l}) (lemma++\u223cl {xs = flatten l} (\u223cx (/tail /head) /head (lemma-flatten\u223c x r)))\n\ntheorem-treeSort\u223c : (xs : List A) \u2192 xs \u223c (flatten (treeSort xs))\ntheorem-treeSort\u223c [] = \u223c[]\ntheorem-treeSort\u223c (x \u2237 xs) = trans\u223c (\u223cx /head /head (theorem-treeSort\u223c xs)) (lemma-flatten\u223c x (treeSort xs)) \n\n\n\n\n", "meta": {"hexsha": "f37837655194338e96ced6a0c43fecb1011e1333", "size": 1105, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl1/Correctness/Permutation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl1/Correctness/Permutation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl1/Correctness/Permutation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.53125, "max_line_length": 127, "alphanum_fraction": 0.6045248869, "num_tokens": 413, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9465966671870767, "lm_q2_score": 0.8104789155369048, "lm_q1q2_score": 0.7671966402726302}}
{"text": "module Graph where\n\nimport      Lvl\nopen import Data.Tuple as Tuple using (_\u2a2f_ ; _,_)\nopen import Functional\nopen import Data.List\nopen import Logic.Propositional{Lvl.\ud835\udfce}\nopen import Logic.Predicate{Lvl.\ud835\udfce}{Lvl.\ud835\udfce}\nopen import Relator.Equals{Lvl.\ud835\udfce}\nopen import Data.List.Relation.Membership{Lvl.\ud835\udfce} using (_\u2208_)\n\n-- EdgeClass(V)(E) means that E is a type which can represent an edge between vertices of type V.\nrecord EdgeClass (V : Set) (Self : Set) : Set where\n  constructor edgeInstance\n  field\n    from           : Self \u2192 V\n    to             : Self \u2192 V\n    _withVertices_ : Self \u2192 (V \u2a2f V) \u2192 Self\n\nmodule Edge where\n  open EdgeClass \u2983 ... \u2984 public\n\ninstance\n  EdgeInstance-Tuple : \u2200{V} \u2192 EdgeClass(V)(V \u2a2f V)\n  Edge.from          \u2983 EdgeInstance-Tuple \u2984 (v\u2081 , v\u2082) = v\u2081\n  Edge.to            \u2983 EdgeInstance-Tuple \u2984 (v\u2081 , v\u2082) = v\u2082\n  Edge._withVertices_ \u2983 EdgeInstance-Tuple \u2984 (v\u2081 , v\u2082) (w\u2081 , w\u2082) = (w\u2081 , w\u2082)\n\nrecord Graph (V : Set) (E : Set) \u2983 _ : EdgeClass(V)(E) \u2984 : Set where\n  constructor graph\n\n  field\n    edges : List(E)\n\n  -- Propositions\n  HasEdge[_\u27f6_] : V \u2192 V \u2192 Set\n  HasEdge[_\u27f6_](v\u2081)(v\u2082) = \u2203(edge \u21a6 (edge \u2208 edges)\u2227(Edge.from(edge) \u2261 v\u2081)\u2227(Edge.to(edge) \u2261 v\u2082))\n\n  HasEdge[_\u27f5_] : V \u2192 V \u2192 Set\n  HasEdge[_\u27f5_](v\u2081)(v\u2082) = HasEdge[_\u27f6_](v\u2082)(v\u2081)\n\n  HasEdge[_\u27f7_] : V \u2192 V \u2192 Set\n  HasEdge[_\u27f7_](v\u2081)(v\u2082) = HasEdge[_\u27f5_](v\u2081)(v\u2082) \u2227 HasEdge[_\u27f6_](v\u2081)(v\u2082)\n\n  data Path : V \u2192 V \u2192 Set where\n    PathIntro        : \u2200{v\u2081 v\u2082 : V} \u2192 HasEdge[ v\u2081 \u27f6 v\u2082 ] \u2192 Path(v\u2081)(v\u2082)\n    PathTransitivity : \u2200{v\u2081 v\u2082 v\u2083 : V} \u2192 Path(v\u2081)(v\u2082) \u2192 Path(v\u2082)(v\u2083) \u2192 Path(v\u2081)(v\u2083)\n\n  Connected : V \u2192 V \u2192 Set\n  Connected(v\u2081)(v\u2082) = Path(v\u2081)(v\u2082)\n\n  Disconnected : V \u2192 V \u2192 Set\n  Disconnected(v\u2081)(v\u2082) = \u00ac(Connected(v\u2081)(v\u2082))\n\n  -- Constructions\n  mapVertices : \u2200{V\u2082} \u2192 \u2983 _ : EdgeClass(V\u2082)(E) \u2984 \u2192 (V \u2192 V\u2082) \u2192 Graph(V\u2082)(E)\n  mapVertices(f) = record{edges = map(edge \u21a6 (edge Edge.withVertices(f(Edge.from(edge)) , f(Edge.to(edge))))) (edges)}\n\n  -- Boolean testing\n  -- with-edge\n  -- without-edge\n  -- has-edge\n  -- is-connected\n  -- is-disconnected\n", "meta": {"hexsha": "f3ef25f4368f0104341d40d7eadad0f4b09097c7", "size": 1987, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "old/Graph.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "old/Graph.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "old/Graph.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.5692307692, "max_line_length": 118, "alphanum_fraction": 0.6059386009, "num_tokens": 775, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92522995296862, "lm_q2_score": 0.8289388104343892, "lm_q1q2_score": 0.7669590165920738}}
{"text": "module fib1 where\n\ndata \u2115 : Set where\n  Z : \u2115 \n  S : \u2115 -> \u2115 \n\n\n_+_ : \u2115 -> \u2115 ->  \u2115\nn + Z   = n\nn + S m = S (n + m)\n\none : \u2115 \none = S Z\n\nfib : \u2115 -> \u2115\nfib Z         = one\nfib (S Z)     = one\nfib (S (S n)) = fib n + fib (S n)\n", "meta": {"hexsha": "b86b813c518a2bf0b9c9d0de5cfdbf57fe957f61", "size": 222, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/fib1.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/fib1.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/fib1.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 11.6842105263, "max_line_length": 33, "alphanum_fraction": 0.4099099099, "num_tokens": 97, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9693242018339896, "lm_q2_score": 0.79053032607222, "lm_q1q2_score": 0.7662801773455181}}
{"text": "module start where\n\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Product\nopen import Function hiding (id)\n\n\ninjective : {A B : Set} \u2192 (f : A \u2192 B) \u2192 Set\ninjective f = \u2200 a\u2081 a\u2082 \u2192 f a\u2081 \u2261 f a\u2082 \u2192 a\u2081 \u2261 a\u2082\n\nsurjective : {A B : Set} \u2192 (f : A \u2192 B) \u2192 Set\nsurjective f = \u2200 b \u2192 \u2203 (\u03bb a \u2192 f a \u2261 b)\n\nbijective : {A B : Set} \u2192 (f : A \u2192 B) \u2192 Set\nbijective f = injective f \u00d7 surjective f\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\n\nlemma-suc-inj : \u2200 {a\u2081 a\u2082} \u2192 suc a\u2081 \u2261 suc a\u2082 \u2192 a\u2081 \u2261 a\u2082\nlemma-suc-inj refl = refl\n\nsuc-injective : injective suc\nsuc-injective a\u2081 a\u2082 = lemma-suc-inj\n\nid : {A : Set} \u2192 A \u2192 A\nid x = x\n\nlemma-id-inj : \u2200 {A} {a\u2081 a\u2082 : A} \u2192 id a\u2081 \u2261 id a\u2082 \u2192 a\u2081 \u2261 a\u2082\nlemma-id-inj refl = refl\n\nid-injective : \u2200 {A} \u2192 injective (id {A})\nid-injective a\u2081 a\u2082 = lemma-id-inj\n\nlemma-id-surj : \u2200 {A} (b : A) \u2192 \u2203 (\u03bb a \u2192 id a \u2261 b)\nlemma-id-surj b = b , refl\n\nid-surjective : \u2200 {A} \u2192 surjective (id {A})\nid-surjective = lemma-id-surj\n\nbijective\u2192injective : \u2200 {A B} {f : A \u2192 B} \u2192 bijective f \u2192 injective f\nbijective\u2192injective b = proj\u2081 b\n\nbijective\u2192surjective : \u2200 {A B} {f : A \u2192 B} \u2192 bijective f \u2192 surjective f\nbijective\u2192surjective b = proj\u2082 b\n\nleft-inverse : \u2200 {A B} \u2192 (f : A \u2192 B) \u2192 Set\nleft-inverse f = \u2203 (\u03bb g \u2192 g \u2218 f \u2261 id)\n\nright-inverse : \u2200 {A B} \u2192 (f : A \u2192 B) \u2192 Set\nright-inverse f = \u2203 (\u03bb g \u2192 f \u2218 g \u2261 id)\n\ninfix 5 _s~_\n_s~_ : {A : Set} {a b c : A} \u2192 a \u2261 b \u2192 a \u2261 c \u2192 c \u2261 b\n_s~_ refl refl = refl\n\ninfix 5 _~_\n_~_ : {A : Set} {a b c : A} \u2192 a \u2261 b \u2192 b \u2261 c \u2192 a \u2261 c\n_~_ = trans\n\n\nlemma-left-id\u2081 : \u2200 {A B : Set} (g : B \u2192 A) (f : A \u2192 B) \u2192 g \u2218 f \u2261 id \u2192 (\u2200 a \u2192 g (f a) \u2261 a)\nlemma-left-id\u2081 g f idcomp a = cong (\u03bb f\u2081 \u2192 f\u2081 a) idcomp\n\n\nlemma-left-id : \u2200 {A B : Set} (a\u2081 a\u2082 : A) (g : B \u2192 A) (f : A \u2192 B) \u2192 g \u2218 f \u2261 id \u2192 g (f a\u2081) \u2261 g (f a\u2082) \u2192 a\u2081 \u2261 a\u2082\nlemma-left-id a\u2081 a\u2082 g f idcomp comp = (comp ~ lemma-left-id\u2081 g f idcomp a\u2082) s~ lemma-left-id\u2081 g f idcomp a\u2081\n\n\nlemma-left-inj : \u2200 {A B : Set} (a\u2081 a\u2082 : A) \u2192 (f : A \u2192 B) \u2192 \u2203 (\u03bb g \u2192 g \u2218 f \u2261 id) \u2192 f a\u2081 \u2261 f a\u2082 \u2192 a\u2081 \u2261 a\u2082\nlemma-left-inj a\u2081 a\u2082 f (g , idcomp) eq = lemma-left-id a\u2081 a\u2082 g f idcomp (cong (\u03bb x \u2192 g x) eq)\n\nleft-inverse\u2192injective : \u2200 {A B} (f : A \u2192 B) \u2192 left-inverse f \u2192 injective f\nleft-inverse\u2192injective f left-inv a\u2081 a\u2082 fas = lemma-left-inj a\u2081 a\u2082 f left-inv fas\n\nright-inverse\u2192surjective : \u2200 {A B} (f : A \u2192 B) \u2192 right-inverse f \u2192 surjective f\nright-inverse\u2192surjective f (g , right) b = g b , cong (\u03bb f\u2081 \u2192 f\u2081 b) right\n\n\n\npostulate extensionality : {A : Set} {B : Set} {f g : A \u2192 B} \u2192 (\u2200 x \u2192 f x \u2261 g x) \u2192 f \u2261 g\n\nid-unique : \u2200 {A : Set} \u2192 (f : A \u2192 A) \u2192 (\u2200 a \u2192 f a \u2261 a) \u2192 f \u2261 id\nid-unique f fa-prop = extensionality {f = f} {g = id} fa-prop\n\nsurjective\u2192right-inverse : \u2200 {A B} (f : A \u2192 B) \u2192 surjective f \u2192 right-inverse f\nsurjective\u2192right-inverse f right = g , id-unique (f \u2218 g) (\u03bb b \u2192 proj\u2082 (right b))\n  where g = \u03bb b \u2192 proj\u2081 (right b)\n\n", "meta": {"hexsha": "c271b13ce3f16eb560ab939047f32cd8ab78ed67", "size": 2775, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "start.agda", "max_stars_repo_name": "Chobbes/AbstractAgdabra", "max_stars_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "start.agda", "max_issues_repo_name": "Chobbes/AbstractAgdabra", "max_issues_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "start.agda", "max_forks_repo_name": "Chobbes/AbstractAgdabra", "max_forks_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1630434783, "max_line_length": 110, "alphanum_fraction": 0.5636036036, "num_tokens": 1167, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.92414182206801, "lm_q2_score": 0.8289388146603364, "lm_q1q2_score": 0.7660570265630997}}
{"text": "module nat-division where\n\nopen import bool\nopen import bool-thms\nopen import eq\nopen import neq\nopen import nat\nopen import nat-thms\nopen import product\nopen import product-thms\nopen import sum\n\n{- a div-result for dividend x and divisor d consists of the quotient q, remainder r, and a proof that q * d + r = x -}\ndiv-result : \u2115 \u2192 \u2115 \u2192 Set \ndiv-result x d = \u03a3 \u2115 (\u03bb q \u2192 \u03a3 \u2115 (\u03bb r \u2192 q * d + r \u2261 x \u2227 r < d \u2261 tt))\n\n-- we use an upper bound n on the dividend x.  For an alternative approach, see nat-division-wf.agda.\ndivh : (n : \u2115) \u2192 (x : \u2115) \u2192 (y : \u2115) \u2192 x \u2264 n \u2261 tt \u2192 y =\u2115 0 \u2261 ff \u2192 div-result x y\ndivh 0 0 0 p1 ()\ndivh 0 0 (suc y) p1 p2 = 0 , 0 , refl , refl\ndivh 0 (suc x) y () p2 \ndivh (suc n) x y p1 p2 with keep (x < y)\ndivh (suc n) x y p1 p2 | tt , pl = 0 , x , refl , pl\ndivh (suc n) x y p1 p2 | ff , pl with divh n (x \u2238 y) y (\u2238\u22642 n x y p1 p2) p2\ndivh (suc n) x y p1 p2 | ff , pl | q , r , pa , pb = suc q , r , lem{q}{r} pa , pb\n  where lem : \u2200{q r} \u2192 q * y + r \u2261 x \u2238 y \u2192 y + q * y + r \u2261 x\n        lem{q}{r} p rewrite sym (+assoc y (q * y) r) | p | +comm y (x \u2238 y) = \u2238+2{x}{y} (<ff{x}{y} pl)\n\n-- the div-result contains the quotient, remainder, and proof relating them to the inputs\n_\u00f7_!_ : (x : \u2115) \u2192 (y : \u2115) \u2192 y =\u2115 0 \u2261 ff \u2192 div-result x y \nx \u00f7 y ! p = divh x x y (\u2264-refl x) p \n\n-- return a pair of the quotient and remainder\n_\u00f7_!!_ : \u2115 \u2192 (y : \u2115) \u2192 y =\u2115 0 \u2261 ff \u2192 \u2115 \u00d7 \u2115\nx \u00f7 y !! p with x \u00f7 y ! p\n... | q , r , p' = q , r\n\n-- return the quotient only\n_\u00f7_div_ : \u2115 \u2192 (y : \u2115) \u2192 y =\u2115 0 \u2261 ff \u2192 \u2115 \nx \u00f7 y div p with x \u00f7 y ! p\n... | q , r , p' = q\n\n-- return the remainder only\n_\u00f7_mod_ : \u2115 \u2192 (y : \u2115) \u2192 y =\u2115 0 \u2261 ff \u2192 \u2115 \nx \u00f7 y mod p with x \u00f7 y ! p\n... | q , r , p' = r\n\n\n", "meta": {"hexsha": "e118b1fe99add50335936bf66d854f7ffe9bd739", "size": 1661, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nat-division.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nat-division.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nat-division.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8979591837, "max_line_length": 119, "alphanum_fraction": 0.5448524985, "num_tokens": 716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037262250327, "lm_q2_score": 0.8267118004748677, "lm_q1q2_score": 0.7657862212940757}}
{"text": "module z where\n\n------------------------------------------------------------------------------\n-- 1 intro\n\n-- data types\n\ndata Nat : Set where\n  zero :       Nat\n  suc  : Nat \u2192 Nat\n{-# BUILTIN NATURAL Nat #-}\n\n--------------------------------------------------\n-- begin : from later - here to use in tests\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n\ndata IsTrue : Bool \u2192 Set where\n  is-true : IsTrue true\n\n_=Nat_ : Nat \u2192 Nat \u2192 Bool\nzero    =Nat  zero   = true\n(suc x) =Nat (suc y) = x =Nat y\n_       =Nat  _      = false\n-- end : from later\n--------------------------------------------------\n\n-- pattern matching\n\n_+_ : Nat \u2192 Nat \u2192 Nat\nzero    + y =          y\n(suc x) + y = suc (x + y)\ninfixl 9 _+_\n-- {-# BUILTIN NATPLUS _+_ #-}\n\n-- ex 1.1\nhalve : Nat \u2192 Nat\nhalve       zero    = zero\nhalve (suc  zero)   = zero\nhalve (suc (suc n)) = suc (halve n)\n\nhalve-0  : IsTrue (halve   0 =Nat 0)\nhalve-0  = is-true\nhalve-1  : IsTrue (halve   1 =Nat 0)\nhalve-1  = is-true\nhalve-2  : IsTrue (halve   2 =Nat 1)\nhalve-2  = is-true\nhalve-3  : IsTrue (halve   3 =Nat 1)\nhalve-3  = is-true\nhalve-4  : IsTrue (halve   4 =Nat 2)\nhalve-4  = is-true\nhalve-14 : IsTrue (halve  14 =Nat 7)\nhalve-14 = is-true\nhalve-15 : IsTrue (halve  15 =Nat 7)\nhalve-15 = is-true\nhalve-16 : IsTrue (halve  16 =Nat 8)\nhalve-16 = is-true\n\n-- ex 1.2\n_*_ : Nat \u2192 Nat \u2192 Nat\nzero    * y    = zero\n(suc x) * y = y + (x * y)\n\n2*0 : IsTrue ((2 * 0) =Nat  0)\n2*0 = is-true\n2*1 : IsTrue ((2 * 1) =Nat  2)\n2*1 = is-true\n2*2 : IsTrue ((2 * 2) =Nat  4)\n2*2 = is-true\n3*3 : IsTrue ((3 * 3) =Nat  9)\n3*3 = is-true\n4*4 : IsTrue ((4 * 4) =Nat 16)\n4*4 = is-true\n\n{-\n-- ex 1.3\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n-}\n\nnot : Bool \u2192 Bool\nnot true  = false\nnot false = true\n\n_&&_ : Bool \u2192 Bool \u2192 Bool\n_&&_ true  y = y\n_&&_ false _ = false\n\n_||_ : Bool \u2192 Bool \u2192 Bool\n_||_ true  _ = true\n_||_ false y = y\n\n-- types are 1st class\n-- equivalent to Haskell type alias : type MyNat = Nat\nMyNat : Set\nMyNat = Nat\n\n-- Set used to implement polymorphic functions\nidA : (A : Set) \u2192 A \u2192 A\nidA _ x = x\n\n-- implicit args\nid : {A : Set} \u2192 A \u2192 A\nid  x = x\n\n-- polymorphic data types\ndata List (A : Set) : Set where\n  []   :              List A\n  _::_ : A \u2192 List A \u2192 List A\ninfixr 5 _::_\n\n-- ex 1.4\nlength : {A : Set} \u2192 List A \u2192 Nat\nlength       []  = zero\nlength (_ :: xs) = 1 + length xs\n\n_++_ :  {A : Set} \u2192 List A \u2192 List A \u2192 List A\n_++_       []  l2 =            l2\n_++_ (x :: xs) l2 = x :: xs ++ l2\n\nmap : { A B : Set } \u2192 (A \u2192 B) \u2192 List A \u2192 List B\nmap _       []  = []\nmap f (x :: xs) = f x :: map f xs\n\n-- ex 1.5\ndata Maybe (A : Set) : Set where\n  just    : A \u2192 Maybe A\n  nothing :     Maybe A\n\nlookup : {A : Set} \u2192 List A \u2192 Nat \u2192 Maybe A\nlookup       []       _  = nothing\nlookup (x ::  _)  zero   = just x\nlookup (_ :: xs) (suc n) = lookup xs n\n\n_=List-Nat_ : List Nat \u2192 List Nat \u2192 Bool\n[]        =List-Nat       []  = true\n(x :: xs) =List-Nat (y :: ys) = (x =Nat y) && (xs =List-Nat ys)\n_         =List-Nat        _  = false\n\nex-xs  : List Nat\nex-xs  = 0 :: 1 :: 2 :: 3 :: []\n\nlength++ : IsTrue ((length ex-xs + length ex-xs) =Nat (length (ex-xs ++ ex-xs)))\nlength++ = is-true\n\nmap2* : IsTrue (map (2 *_) ex-xs =List-Nat (0 :: 2 :: 4 :: 6 :: []))\nmap2* = is-true\n\n_=Maybe-Nat_ : Maybe Nat \u2192 Maybe Nat \u2192 Bool\nnothing   =Maybe-Nat  nothing  = true\n(just x)  =Maybe-Nat  (just y) = x =Nat y\n_         =Maybe-Nat        _  = false\n\nlookup[]0    : IsTrue (lookup    [] 0 =Maybe-Nat nothing)\nlookup[]0    = is-true\nlookupex-xs0 : IsTrue (lookup ex-xs 0 =Maybe-Nat (just 0))\nlookupex-xs0 = is-true\nlookupex-xs1 : IsTrue (lookup ex-xs 1 =Maybe-Nat (just 1))\nlookupex-xs1 = is-true\nlookupex-xs9 : IsTrue (lookup ex-xs 9 =Maybe-Nat nothing)\nlookupex-xs9 = is-true\n\ndata _\u00d7_ (A B : Set) : Set where\n  _,_ : A \u2192 B \u2192 A \u00d7 B\ninfixr 4 _,_\n\nfst : {A B : Set} \u2192 A \u00d7 B \u2192 A\nfst (a , _) = a\n\nsnd : {A B : Set} \u2192 A \u00d7 B \u2192 B\nsnd (_ , b) = b\n\n-- ex 1.6\n-- NO.  Regardless of the value of 'Nat', there is NO way to construct an A if given [].\n\n------------------------------------------------------------------------------\n-- 2 dependent types\n\n--      parameter         : bound for ENTIRE def\n--                  index : varies according to constructor\n--          v         v\ndata Vec (A : Set) : Nat \u2192 Set where              -- Vec is dependent TYPE\n  []   :                           Vec A 0\n  _::_ : {n : Nat} \u2192 A \u2192 Vec A n \u2192 Vec A (suc n)\n--infixr 5 _::_\n\n-- dependent FUNCTION : return TYPE depends on inputs\nzeroes : (n : Nat) \u2192 Vec Nat n\nzeroes  zero   = []\nzeroes (suc n) = 0 :: zeroes n\n\n-- ex 2.1\ndownFrom : (n : Nat) \u2192 Vec Nat n\ndownFrom   zero  = []\ndownFrom (suc n) = n :: downFrom n\n\n_=Vec-Nat_ : {n : Nat} \u2192 Vec Nat n \u2192 Vec Nat n \u2192 Bool\n[]        =Vec-Nat       []  = true\n(x :: xs) =Vec-Nat (y :: ys) = (x =Nat y) && (xs =Vec-Nat ys)\n\ndownFrom0 : IsTrue (downFrom 0 =Vec-Nat                                     [])\ndownFrom0 = is-true\ndownFrom1 : IsTrue (downFrom 1 =Vec-Nat                               (0 :: []))\ndownFrom1 = is-true\ndownFrom2 : IsTrue (downFrom 2 =Vec-Nat                          (1 :: 0 :: []))\ndownFrom2 = is-true\ndownFrom3 : IsTrue (downFrom 3 =Vec-Nat                     (2 :: 1 :: 0 :: []))\ndownFrom3 = is-true\ndownFrom7 : IsTrue (downFrom 7 =Vec-Nat (6 :: 5 :: 4 :: 3 :: 2 :: 1 :: 0 :: []))\ndownFrom7 = is-true\n\n-- ex 2.2\ntail : {A : Set} {n : Nat} \u2192 Vec A (suc n) \u2192 Vec A n\ntail (_ :: xs) = xs\n\n-- ex 2.3\ndotProduct : {n : Nat} \u2192 Vec Nat n \u2192 Vec Nat n \u2192 Nat\ndotProduct       []        []  = 0\ndotProduct (x :: xs) (y :: ys) = (x * y) + dotProduct xs ys\n\ndotProduct32 : IsTrue (dotProduct (1 :: 2 :: 3 :: []) (1 :: 5 :: 7 :: []) =Nat 32)\ndotProduct32 = is-true\n\n-- finite type family\ndata Fin : Nat \u2192 Set where\n  zero : {n : Nat} \u2192         Fin (suc n)\n  suc  : {n : Nat} \u2192 Fin n \u2192 Fin (suc n)\n\nlookupVec : {A : Set} {n : Nat} \u2192 Vec A n \u2192 Fin n \u2192 A\nlookupVec       []   ()\nlookupVec (x ::  _)  zero   = x\nlookupVec (_ :: xs) (suc i) = lookupVec xs i\n\n-- ex 2.4\nputVec : {A : Set} {n : Nat} \u2192 Fin n \u2192 A \u2192 Vec A n \u2192 Vec A n\nputVec  zero   a (_ :: xs) = a ::            xs\nputVec (suc i) a (x :: xs) = x :: putVec i a xs\n\nex-vxs  : Vec Nat 4\nex-vxs  = 0 :: 1 :: 2 :: 3 :: []\n\nlookupVecex-vxs0 : IsTrue (lookupVec ex-vxs                zero    =Nat 0)\nlookupVecex-vxs0 = is-true\nlookupVecex-vxs3 : IsTrue (lookupVec ex-vxs (suc (suc (suc zero))) =Nat 3)\nlookupVecex-vxs3 = is-true\n\nputVecex-vxs3 : IsTrue (putVec (suc (suc zero)) 22 ex-vxs  =Vec-Nat (0 :: 1 :: 22 :: 3 :: []))\nputVecex-vxs3 = is-true\n\n{-\ndependent pair type - aka \u03a3 type\n\naka \u03a3 type because can be seen as sum (or disjoint union) of all the types B x\n- where 1st component is viewed as a label indicating\n  which type of the family the 2nd belong to\n\ngeneralization of pair type A \u00d7 B\n- where type of 2nd component can be different depending on value of 1st\n- e.g.,                   \u03a3 Nat (Vec Bool)\n        (or equivalently, \u03a3 Nat (\u03bbn \u2192 Vec Bool n))\n contains elements\n        2 , (true :: false :: [])\n and\n        0 , []\n but not\n        2 , [] (since [] does not have type Vec Bool 2).\n-}\n\n--               function\n--                  v\ndata \u03a3 (A : Set) (B : A \u2192 Set) : Set where\n  _,_ : (x : A) \u2192 B x \u2192 \u03a3 A B\n\n-- see \u03a3 as generalization of normal pair : normal pair ignores its input\n_\u00d7'_ : (A B : Set) \u2192 Set\nA \u00d7' B = \u03a3 A (\u03bb _ \u2192 B)\n\n-- ex 2.5\n\u00d7-to-\u00d7' : {A B : Set} \u2192 (A \u00d7 B) \u2192 (A \u00d7' B)\n\u00d7-to-\u00d7' (a , b) =  a , b\n\n\u00d7'-to-\u00d7 : {A B : Set} \u2192 (A \u00d7' B) \u2192 (A \u00d7 B)\n\u00d7'-to-\u00d7 (a , b) =  a , b\n\n-- \u03a3 USE CASE : hide type info\n\n-- e.g., hide length of vector\n\nList' : (A : Set) \u2192 Set\nList' A = \u03a3 Nat (Vec A)\n\n-- ex 2.6\nlist-to-vec : {A : Set} \u2192 (l : List A) \u2192 Vec A (length l)\nlist-to-vec       []  = []\nlist-to-vec (x :: xs) = x :: list-to-vec xs\n\nvec-to-list : {A : Set} {n : Nat} \u2192 Vec A n \u2192 List A\nvec-to-list       []  = []\nvec-to-list (x :: xs) = x :: vec-to-list xs\n\nlist-to-list' : {A : Set} \u2192 List A \u2192 List' A\nlist-to-list' l = length l , list-to-vec l\n\nlist'-to-list : {A : Set} \u2192 List' A \u2192 List A\nlist'-to-list (_ , v) = vec-to-list v\n\n-- if Nat relations existed at this point this function would be very different\nlookup-List' : {A : Set} \u2192 List' A -> Nat -> Maybe A\nlookup-List' (_ ,       [])       _  =  nothing\nlookup-List' (_ , (x ::  _))  zero   = just x\nlookup-List' (_ , (_ :: xs)) (suc n) = lookup-List' ((list-to-list' (vec-to-list xs))) n\n\nex-l'xs  : List' Nat\nex-l'xs  = (4 , 0 :: 1 :: 2 :: 3 :: [])\n\nlookup-List'[]0      : IsTrue (lookup-List' (0 , []) 0 =Maybe-Nat nothing)\nlookup-List'[]0      = is-true\nlookup-List'ex-l'xs0 : IsTrue (lookup-List'  ex-l'xs 0 =Maybe-Nat (just 0))\nlookup-List'ex-l'xs0 = is-true\nlookup-List'ex-l'xs1 : IsTrue (lookup-List'  ex-l'xs 1 =Maybe-Nat (just 1))\nlookup-List'ex-l'xs1 = is-true\nlookup-List'ex-l'xs9 : IsTrue (lookup-List'  ex-l'xs 9 =Maybe-Nat nothing)\nlookup-List'ex-l'xs9 = is-true\n\n------------------------------------------------------------------------------\n-- 3 The Curry-Howard correspondence\n-- can interpret logical propositions \u2014 such as \u201cP and Q\u201d, \u201cnot P\u201d, \u201cP implies Q\u201d, ...\n-- as types whose inhabitants are valid proofs of that proposition.\n\n--------------------------------------------------\n-- PROPOSITIONAL LOGIC\n\n-- ex 3.1\ndata Either (A B : Set) : Set where\n  left  : A \u2192 Either A B\n  right : B \u2192 Either A B\n\ncases : {A B C : Set} \u2192 Either A B \u2192 (A \u2192 C) \u2192 (B \u2192 C) \u2192 C\ncases (left  a) fac   _ = fac a\ncases (right b) _   fbc = fbc b\n\ncases-left  : IsTrue (cases (left  3) (2 +_) (2 *_) =Nat 5)\ncases-left  = is-true\ncases-right : IsTrue (cases (right 3) (2 +_) (2 *_) =Nat 6)\ncases-right = is-true\n\n{-\n-------------------------\nTRUTH : true : the proposition that always holds no matter what.\nProving it is straightforward: do not need to provide any assumptions.\nAssuming true in a proof does not provide any new information.\n'true' corresponds to the unit type\n-}\n\ndata \u22a4 : Set where\n  tt : \u22a4\n\n{-\n-------------------------\nFALSITY. the proposition that is never true.\nThere are no ways to prove it.\nRepresented by empty type : datatype with no constructors\n-}\n\ndata \u22a5 : Set where\n\n{-\ngiven a proof p of \u201cfalse\u201d (which can't happen because no constructors)\n- \u201cex falso quodlibet\u201d : \u201cfrom falsity follows anything\u201d)\n- can can get a proof of any proposition\n-}\nabsurd : {A : Set} \u2192 \u22a5 \u2192 A\nabsurd ()\n\n{-\n-------------------------\nNEGATION : the type P \u2192 \u22a5\nEQUIVALENCE. \u201cP is equivalent to Q\u201d as (P \u2192 Q) \u00d7 (Q \u2192 P)\n\nPropositional logic versus boolean logic.\n\ntypes \u22a4 and \u22a5 seem similar to booleans true and false\n- true and false are VALUES : can manipulate and return\n- \u22a4    and and \u22a5 are TYPES\n  - not possible to check whether a given type \u22a4 or \u22a5\n-}\n\ncurryCompose : {P Q R : Set} \u2192 (P \u2192 Q) \u00d7 (Q \u2192 R) -> (P \u2192 R)\ncurryCompose (f , g) = \u03bb x \u2192 g (f x)\n\n-- ex 3.2\nif-A-then-B-implies-A : {A B : Set} \u2192 A \u2192 (B \u2192 A)\nif-A-then-B-implies-A a = \u03bb _ \u2192 a\n\nif-A-and-true-then-A-or-false : {A : Set} \u2192 (A \u00d7 \u22a4) \u2192 Either A \u22a5\nif-A-and-true-then-A-or-false (a , \u22a4) = left a\n\nuncurry : {A B C : Set} \u2192 (A \u2192 (B \u2192 C)) \u2192 (A \u00d7 B) \u2192 C\nuncurry f = \u03bb a\u00d7b \u2192 f (fst a\u00d7b) (snd a\u00d7b)\n\nex32x : {A B C : Set} \u2192 (A \u00d7 Either B C) \u2192 Either (A \u00d7 B) (A \u00d7 C)\nex32x (a , left  b) = left  (a , b)\nex32x (a , right c) = right (a , c)\n\nex32y : {A B C D : Set} \u2192 ((A \u2192 C) \u00d7 (B \u2192 D)) \u2192 (A \u00d7 B) \u2192 (C \u00d7 D)\nex32y (ac , bd) (a , b) = ac a , bd b\n\n{-\n--------------------------------------------------\n-- PREDICATE LOGIC\n\nto prove propositions that say something about a given VALUE or FUNCTION\n\ne.g., 6 is even\n      length (map f xs) is equal to length xs for all xs\n      there exists a number n such that n + n = 12\n\nCurry-Howard : propositions are types\n\ncan define new propositions by defining new data types\n\ne.g.,\n-}\n\n--           index\n--             v\ndata IsEven : Nat \u2192 Set where\n  even-zero :                        IsEven  zero\n  even-suc2 : {n : Nat} \u2192 IsEven n \u2192 IsEven (suc (suc n))\n\n6-is-even : IsEven 6\n6-is-even = even-suc2 (even-suc2 (even-suc2 even-zero))\n\n7-is-not-even : IsEven 7 \u2192 \u22a5\n7-is-not-even (even-suc2 (even-suc2 (even-suc2 ())))\n--                                             ^   -- absurb pattern as arg\n\n{-\n-- useful predicate\n-- states that a given Bool is true\ndata IsTrue : Bool \u2192 Set where\n  is-true : IsTrue true\n\n_=Nat_ : Nat \u2192 Nat \u2192 Bool\nzero    =Nat  zero   = true\n(suc x) =Nat (suc y) = x =Nat y\n_       =Nat  _      = false\n-}\n\nlength-is-3 : IsTrue (length (1 :: 2 :: 3 :: []) =Nat 3)\nlength-is-3 = is-true\n\n{-\nDefining properties as functions.\n\nCan define properties as\n- data types, or\n- functions that return a value of type Set\ne..g.,\n-}\n\nIsTrue\u2019 : Bool \u2192 Set\nIsTrue\u2019 true  = \u22a4\nIsTrue\u2019 false = \u22a5\n\n{-\nFunction approach often results in proofs that are shorter, but less readable.\n\nAlso less general, as some types (e.g., identity type in next section)\ncan only be defined as a data type.\n\nBEST PRACTICE: use data types (not functions)\n\n--------------------------------------------------\nUNIVERSAL QUANTIFICATION : \u201c\u2200 x of type A, P(x)\u201d\n\nto prove : provide proof of P(v) for EVERY concrete value v : A.\n\ni.e., a function \u03bbv \u2192 P v\n\nin opposite direction\nassume a f of \u201c\u2200 x of type A, P(x)\u201d\nand given a concrete v : A\nthen can the proof to the case of v to get a proof f v of P(v)\n\nunder Curry-Howard, universal quantification corresponds to dependent function\n  (x : A) \u2192 P x\n-}\n\ndouble : Nat \u2192 Nat\ndouble  zero   = zero\ndouble (suc n) = suc (suc (double n))\n\n-- \u2200 n : Nat, double n is an even number\n-- 'double-is-even' is a dependent function : return TYPE depends on input VALUE\n-- pattern matching here is \"proof by cases\"\n-- recursion here is \"induction on n\"\ndouble-is-even : (n : Nat) \u2192 IsEven (double n)\ndouble-is-even  zero   = even-zero\ndouble-is-even (suc m) = even-suc2 (double-is-even m)\n\nn-equals-n : (n : Nat) \u2192 IsTrue (n =Nat n)\nn-equals-n  zero   = is-true\nn-equals-n (suc m) = n-equals-n m\n\n{-\n--------------------------------------------------\nEXISTENTIAL QUANTIFICATION : \u201c\u2203 a x : A such that P( x )\u201d\n\nto prove : provide a concrete v : A, and a proof that P(v) holds\n\ni.e. a pair (v : A, P v)\n\nin opposite direction\ngiven proof z of \u201c\u2203 a x : A such that P( x )\u201d\nthen extract the witness fst z : A\nand the proof snd z : P (fst z)\n\nunder Curry-Howard, existential quantification corresponds to the dependent pair type\n  \u03a3 A ( \u03bb x \u2192 P x ).\n-}\n\n-- \u2203 an n such that n + n = 12\nhalf-a-dozen : \u03a3 Nat (\u03bb n \u2192 IsTrue ((n + n) =Nat 12))\nhalf-a-dozen = 6 , is-true\n\n-- any number n is either 0 or the successor of another number m\n-- \u2200 n, n is 0\n-- or \u2203 m such that n is suc m\nzero-or-suc : (n : Nat) \u2192 Either (IsTrue (n =Nat 0))\n                                 (\u03a3 Nat (\u03bb m \u2192 IsTrue (n =Nat (suc m))))\nzero-or-suc  zero   = left is-true\nzero-or-suc (suc m) = right (m , n-equals-n m)\n\n{-\n--------------------------------------------------\n\nPropositional logic                              Type System\n------------------------------------------------------------\nproposition                  P                   type\nproof of a proposition       p : P               program of a type\nconjunction                  P \u00d7 Q               pair type\ndisjunction                  Either P Q          either type\nimplication                  P \u2192 Q               function type\ntruth                        \u22a4                   unit type\nfalsity                      \u22a5                   empty type\nnegation                     P \u2192 \u22a5               function to \u22a5\nequivalence                  (P \u2192 Q) \u00d7 (Q \u2192 P)   pair of two functions\n------------------------------------------------------------\nPredicate log\nuniversal quantification     (x : A) \u2192 P x       dependent function type\nexistential quantification   \u03a3 A (\u03bb x \u2192 P x )    dependent pair type\n\n\n--------------------------------------------------\n-- IDENTITY TYPE : EQUALITY at any type (to avoid =Nat, =Vec-Nat, ...)\n\nMartin-L\u00f6f introduced a new type x \u2261 y, called the IDENTITY TYPE (NOT FUNCTION)\n\nif x and y are equal, then x \u2261 y has a single inhabitant refl\n- behaves like the unit type \u22a4\n\nif x and y are distinct, then x \u2261 y has no constructors\n- behaves like the empty type \u22a5\n-}\n\ndata _\u2261_ {A : Set} : A \u2192 A \u2192 Set where\n  -- \u2018reflexivity\u2019\n  refl : {x : A} \u2192 x \u2261 x\ninfix 4 _\u2261_\n{-# BUILTIN EQUALITY _\u2261_ #-}\n\none-plus-one-IsTrue : IsTrue ((1 + 1) =Nat 2)\none-plus-one-IsTrue = is-true\n\none-plus-one : 1 + 1 \u2261 2\none-plus-one = refl\n\n{-\nzero-not-one-not-IsTrue : IsTrue (0 =Nat 1)\nzero-not-one-not-IsTrue = {!!}\n-}\n\nzero-not-one : 0 \u2261 1 \u2192 \u22a5\nzero-not-one ()\n\n-- prove facts about polymorphic types\nid-returns-input : {A : Set}\n                 \u2192 (x : A)\n                 \u2192 id x \u2261 x\nid-returns-input _ = refl\n\n-- unit tests using identity type\nlength-test1 : length (1 :: 2 :: []) \u2261 2\nlength-test1 = refl\n\n-- symmetry of equality\nsym : {A : Set} {x y : A} \u2192 x \u2261 y \u2192 y \u2261 x\nsym refl = refl\n\n-- transitivity of equality\ntrans : {A : Set} {x y z : A} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\ntrans refl refl = refl\n\n-- congruence of equality\ncong : {A B : Set} {x y : A} \u2192 (f : A \u2192 B) \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\n{-\nIf a and b can be unified by instantiating some of the variables, then can match on refl.\nIf a and b are different (e.g. different constructors), then match on absurb pattern ().\nAgda canNOT always tell if they are different.\n-}\n\n------------------------------------------------------------------------------\n-- 4 EQUATIONAL REASONING\n\nbegin_ : {A : Set} \u2192 {x y : A} \u2192 x \u2261 y \u2192 x \u2261 y\nbegin p = p\n\n_end : {A : Set} \u2192 (x : A) \u2192 x \u2261 x\nx end = refl\n\n_=\u27e8_\u27e9_ : {A : Set} \u2192 (x : A) \u2192 {y z : A} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\nx =\u27e8 p \u27e9 q = trans p q\n\n_=\u27e8\u27e9_  : {A : Set} \u2192 (x : A) \u2192 {y   : A} \u2192 x \u2261 y         \u2192 x \u2261 y\nx =\u27e8\u27e9 q = x =\u27e8 refl \u27e9 q\n\ninfix 1 begin_\ninfix 3 _end\ninfixr 2 _=\u27e8_\u27e9_\ninfixr 2 _=\u27e8\u27e9_\n\n-- create singleton list\n[_] : {A : Set} \u2192 A \u2192 List A\n[ x ] = x :: []\n\nreverse : {A : Set} \u2192 List A \u2192 List A\nreverse       []  = []\nreverse (x :: xs) = reverse xs ++ [ x ]\n\n-- reverse has no effect on singleton lists\nreverse-singleton : {A : Set}\n                  \u2192 (x : A)\n                  \u2192 reverse [ x ] \u2261 [ x ]\nreverse-singleton x =\n  begin\n  reverse       [ x ]  =\u27e8\u27e9 -- definition of [_]\n  reverse   (x :: [])  =\u27e8\u27e9 -- applying reverse (second clause)\n  reverse [] ++ [ x ]  =\u27e8\u27e9 -- applying reverse (first clause)\n          [] ++ [ x ]  =\u27e8\u27e9 -- applying _++_\n                [ x ]\n  end\n\n-- proof by cases and induction\nnot-not : (b : Bool)\n        \u2192 not (not b) \u2261 b\n\nnot-not true  =\n  begin\n  not (not true) =\u27e8\u27e9\n       not false =\u27e8\u27e9 -- apply inner not\n           true      -- apply not\n  end\n\nnot-not false =\n  begin\n  not (not false) =\u27e8\u27e9\n       not true   =\u27e8\u27e9\n           false\n  end\n\n-- prove fact about Nat by induction (i.e., recursion)\nadd-n-zero : (n : Nat)\n           \u2192 n + zero \u2261 n\nadd-n-zero  zero   =\n  begin\n  zero + zero =\u27e8\u27e9\n  zero        =\u27e8\u27e9\n  zero\n  end\n\nadd-n-zero (suc n) =\n  begin\n  (suc n) + zero  =\u27e8\u27e9                          -- applying +\n  suc (n  + zero) =\u27e8 cong suc (add-n-zero n) \u27e9 -- using induction hypothesis\n  suc n\n  end\n\nadd-n-zero' : (n : Nat)\n            \u2192 n + zero \u2261 n\nadd-n-zero'  zero   = refl\nadd-n-zero' (suc n) = cong suc (add-n-zero' n)\n\nadd-assoc : (x y z : Nat)\n          \u2192 x + (y + z) \u2261 (x + y) + z\nadd-assoc zero y z =\n  begin\n  zero + (y + z) =\u27e8\u27e9 -- def of +\n          y + z  =\u27e8\u27e9 -- unapply +\n  (zero + y) + z\n  end\nadd-assoc (suc x) y z =\n  begin\n     (suc   x) + (y   + z)  =\u27e8\u27e9 -- def of +\n      suc  (x  + (y   + z)) =\u27e8 cong suc (add-assoc x y z) \u27e9 -- inductive hypo\n      suc ((x  +  y)  + z)  =\u27e8\u27e9 -- unapply outer add\n     (suc  (x  +  y)) + z   =\u27e8\u27e9 -- unapply inner add\n    ((suc   x) +  y)  + z\n  end\n\n-- ex 4.1\nadd-suc : (m n : Nat)\n        \u2192 m + suc n \u2261 suc (m + n)\nadd-suc zero n    =\n  begin\n  zero + suc n =\u27e8\u27e9 -- def of +\n         suc n =\u27e8\u27e9\n  suc (zero + n)\n  end\nadd-suc (suc m) n = -- cong suc (add-suc m n)\n  begin\n  suc m + suc n    =\u27e8\u27e9 -- def of +\n  suc (m + suc n)  =\u27e8 cong suc (add-suc m n) \u27e9\n  suc (suc m + n)\n  end\n\n--use add-suc and add-n-zero\n+-comm : (m n : Nat)\n       \u2192 m + n \u2261 n + m\n+-comm zero n = sym (add-n-zero n)\n+-comm (suc m) n\n  rewrite                 -- suc  m     +     n  \u2261 n + suc m\n                          -- suc (m     +     n) \u2261 n + suc m\n    +-comm m n            -- suc (n     +     m) \u2261 n + suc m\n  | sym (add-suc n m)     --      n     + suc m  \u2261 n + suc m\n  = refl\n\n+-comm' : (m n : Nat)\n        \u2192 m + n \u2261 n + m\n+-comm' zero n =\n  begin\n  zero + n =\u27e8\u27e9                     -- def of +\n         n =\u27e8 sym (add-n-zero n) \u27e9 -- add zero to right\n  n + zero\n  end\n+-comm' (suc m) n =\n  begin\n  suc  m     +     n  =\u27e8\u27e9 -- def of +\n  suc (m     +     n) =\u27e8 cong suc (+-comm m n) \u27e9\n  suc (n     +     m) =\u27e8 sym (add-suc n m) \u27e9\n       n     + suc m\n  end\n\n--------------------------------------------------\n-- induction on lists\n\n-- ex 4.2\nreplicate : {A : Set} \u2192 Nat \u2192 A \u2192 List A\nreplicate  zero   x = []\nreplicate (suc n) x = x :: replicate n x\n\nlength-replicate : {A : Set} {a : A}\n                 \u2192 (n : Nat)\n                 \u2192 length (replicate n a) \u2261 n\nlength-replicate  zero   = refl\nlength-replicate (suc n) = cong suc (length-replicate n)\n\n-- ex 4.3\nappend-[] : {A : Set}\n          \u2192 (xs : List A)\n          \u2192 xs ++ [] \u2261 xs\nappend-[]       []  = refl\nappend-[] (x :: xs) = cong (x ::_) (append-[] xs)\n\nappend-assoc : {A : Set}\n             \u2192 (xs ys zs : List A)\n             \u2192 (xs ++ ys) ++ zs \u2261 xs ++ (ys ++ zs)\nappend-assoc       []  ys zs = refl\nappend-assoc (x :: xs) ys zs -- (((x ::   xs) ++ ys) ++ zs) \u2261 ((x ::  xs) ++ (ys ++ zs))\n                             --    x :: ((xs  ++ ys) ++ zs) \u2261   x :: (xs  ++ (ys ++ zs))\n  = cong (x ::_) (append-assoc xs ys zs)\n\nreverse-distributivity : {A : Set}\n                       \u2192 (xs ys : List A)\n                       \u2192 reverse (xs ++ ys) \u2261 reverse ys ++ reverse xs\nreverse-distributivity       []  ys = sym (append-[] (reverse ys))\nreverse-distributivity (x :: xs) ys\n                   -- reverse ((x :: xs) ++ ys)         \u2261 (reverse ys ++  reverse       (x :: xs))\n                   -- (reverse (xs ++ ys) ++ (x :: [])) \u2261 (reverse ys ++ (reverse xs ++ (x :: [])))\n  rewrite\n    reverse-distributivity xs ys\n                   -- ((reverse ys ++ reverse xs) ++ (x :: []))\n                   --                                   \u2261 (reverse ys ++ (reverse xs ++ (x :: [])))\n  | sym (append-assoc (reverse ys) (reverse xs) (x :: []))\n  = refl\n\nreverse-reverse : {A : Set}\n                \u2192 (xs : List A)\n                \u2192 reverse (reverse xs) \u2261 xs\nreverse-reverse       [] = refl\nreverse-reverse (x :: xs) -- reverse (reverse (x :: xs))       \u2261 x :: xs\n                          -- reverse (reverse xs ++ (x :: [])) \u2261 x :: xs\n  rewrite\n    --                       NOTE\n    --                        v\n    reverse-distributivity (reverse xs) [ x ]\n                          --         x :: reverse (reverse xs) \u2261 x :: xs\n-- can rewrite here then refl\n--| reverse-reverse xs    --                          x :: xs  \u2261 x :: xs\n--= refl\n-- or use 'cong' on rightof '='\n  = cong (x ::_) (reverse-reverse xs)\n\n{-\nmap satisfies functor laws:\n- identity    : map id      = id\n- composition : map (g . h) = map g . h\n-}\n\nmap-id : {A : Set}\n       \u2192 (xs : List A)\n       \u2192 map id xs \u2261 xs\nmap-id       []  = refl\nmap-id (x :: xs) --         map id (x :: xs) \u2261 x :: xs\n                 -- id x :: map id       xs  \u2261 x :: xs\n  = cong (x ::_) (map-id xs)\n\n_\u25e6_ : {A B C : Set} \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 (A \u2192 C)\ng \u25e6 h = \u03bb x \u2192 g (h x)\n\nmap-compose : {A B C : Set}\n            \u2192 (f : B \u2192 C) \u2192 (g : A \u2192 B) \u2192 (xs : List A)\n            \u2192 map (f \u25e6 g) xs \u2261 map f (map g xs)\nmap-compose f g       [] = refl\nmap-compose f g (x :: xs)\n                         --              map (f \u25e6 g) (x :: xs) \u2261            map f (map g (x :: xs))\n                         -- (f \u25e6 g) x :: map (f \u25e6 g)       xs  \u2261 f (g x) :: map f (map g       xs)\n{- this\n  rewrite\n    sym (map-compose f g xs)\n                         --   f (g x) :: map (\u03bb x\u2081 \u2192 f (g x\u2081)) xs \u2261\n                              f (g x) :: map (\u03bb x\u2081 \u2192 f (g x\u2081)) xs\n  = refl\n-}\n  -- or this\n  = cong (f (g x) ::_) (map-compose f g xs)\n\n-- ex 4.4\nlength-map : {A B : Set} {f : A \u2192 B}\n           \u2192 (xs : List A)\n           \u2192 length (map f xs) \u2261 length xs\nlength-map       []  = refl\nlength-map (x :: xs) --      length (map f (x :: xs)) \u2261      length (x :: xs)\n                     -- suc (length (map f       xs)) \u2261 suc (length       xs)\n  = cong suc (length-map xs)\n\n-- ex 4.5\ntake : {A : Set} \u2192 List A \u2192 Nat \u2192 List A\ntake        _   zero   = []\ntake       []  (suc n) = []\ntake (x :: xs) (suc n) = x :: take xs n\n\ntake-0 : take ex-xs 0 \u2261 []\ntake-0 = refl\ntake-1 : take ex-xs 1 \u2261 0 :: []\ntake-1 = refl\ntake-2 : take ex-xs 2 \u2261 0 :: 1 :: []\ntake-2 = refl\ntake-3 : take ex-xs 3 \u2261 0 :: 1 :: 2 :: []\ntake-3 = refl\ntake-4 : take ex-xs 4 \u2261 ex-xs\ntake-4 = refl\ntake-5 : take ex-xs 5 \u2261 ex-xs\ntake-5 = refl\n\ndrop : {A : Set} \u2192 List A \u2192 Nat \u2192 List A\ndrop       xs   zero   = xs\ndrop       []  (suc x) = []\ndrop (_ :: xs) (suc n) = drop xs n\n\ndrop-0 : drop ex-xs 0 \u2261 ex-xs\ndrop-0 = refl\ndrop-1 : drop ex-xs 1 \u2261 1 :: 2 :: 3 :: []\ndrop-1 = refl\ndrop-2 : drop ex-xs 2 \u2261      2 :: 3 :: []\ndrop-2 = refl\ndrop-3 : drop ex-xs 3 \u2261           3 :: []\ndrop-3 = refl\ndrop-4 : drop ex-xs 4 \u2261                []\ndrop-4 = refl\ndrop-5 : drop ex-xs 5 \u2261                []\ndrop-5 = refl\n\ntake-drop : {A : Set} \u2192 (xs : List A) \u2192 (n : Nat) \u2192 take xs n ++ drop xs n \u2261 xs\ntake-drop       []   zero   = refl\ntake-drop       []  (suc n) = refl\ntake-drop (x :: xs)  zero   = refl\ntake-drop (x :: xs) (suc n) --      (take (x :: xs) (suc n) ++ drop (x :: xs) (suc n)) \u2261 x :: xs\n                            -- x :: (take       xs       n  ++ drop       xs       n)  \u2261 x :: xs\n  = cong (x ::_) (take-drop xs n)\n\n--------------------------------------------------\n-- verifying optimizations\n\n-- list optimization\n\nreverse-acc : {A : Set} \u2192 List A \u2192 List A \u2192 List A\nreverse-acc       []  ys = ys\nreverse-acc (x :: xs) ys = reverse-acc xs (x :: ys)\n\nreverse' : {A : Set} \u2192 List A \u2192 List A\nreverse' xs = reverse-acc xs []\n\nreverse-acc-lemma : {A : Set}\n                  \u2192 (xs ys : List A)\n                  \u2192 reverse-acc xs ys \u2261 reverse xs ++ ys\nreverse-acc-lemma       []   _ = refl\nreverse-acc-lemma (x :: xs) ys   -- reverse-acc (x :: xs) ys  \u2261  (reverse (x :: xs)        ++ ys)\n                                 -- reverse-acc xs (x :: ys)  \u2261 ((reverse xs ++ (x :: [])) ++ ys)\n  rewrite\n    append-assoc (reverse xs) [ x ] ys\n                                 -- reverse-acc xs (x :: ys)  \u2261 (reverse xs ++ (x :: ys))\n  | reverse-acc-lemma xs (x :: ys)\n                                 -- (reverse xs ++ (x :: ys)) \u2261 (reverse xs ++ (x :: ys))\n  = refl\n\nreverse'-reverse : {A : Set}\n                 \u2192 (xs : List A)\n                 \u2192 reverse' xs \u2261 reverse xs\nreverse'-reverse       []  = refl\nreverse'-reverse (x :: xs)     --  reverse' (x :: xs)       \u2261  reverse (x :: xs)\n                               --  reverse' (x :: xs)       \u2261 (reverse xs ++ (x :: []))\n  rewrite\n    reverse-acc-lemma xs [ x ] -- (reverse xs ++ (x :: [])) \u2261 (reverse xs ++ (x :: []))\n  = refl\n\n-- tree optimization\n\ndata Tree (A : Set) : Set where\n  leaf : A               \u2192 Tree A\n  node : Tree A \u2192 Tree A \u2192 Tree A\n\nflatten : {A : Set} \u2192 Tree A \u2192 List A\nflatten (leaf a)     = [ a ]\nflatten (node t1 t2) = flatten t1 ++ flatten t2\n\nflatten-acc : {A : Set} \u2192 Tree A \u2192 List A \u2192 List A\nflatten-acc (leaf x)     xs = x :: xs\nflatten-acc (node t1 t2) xs = flatten-acc t1 (flatten-acc t2 xs)\n\nflatten' : {A : Set} \u2192 Tree A \u2192 List A\nflatten' t = flatten-acc t []\n\nflatten-acc-lemma : {A : Set}\n                  \u2192 (t : Tree A) \u2192 (ys : List A)\n                  \u2192 flatten-acc t ys \u2261 flatten t ++ ys\nflatten-acc-lemma (leaf x)    _ = refl\nflatten-acc-lemma (node t1 t2) ys\n                     --  flatten-acc (node t1 t2) ys         \u2261  (flatten (node t1 t2)      ++ ys)\n                     --  flatten-acc t1 (flatten-acc t2 ys)  \u2261 ((flatten t1 ++ flatten t2) ++ ys)\n  rewrite\n    flatten-acc-lemma t1 (flatten-acc t2 ys)\n                     -- (flatten t1 ++   flatten-acc t2 ys)  \u2261 ((flatten t1 ++ flatten t2) ++ ys)\n  | flatten-acc-lemma t2 ys\n                     -- (flatten t1 ++  (flatten t2 ++  ys)) \u2261 ((flatten t1 ++ flatten t2) ++ ys)\n  | append-assoc (flatten t1) (flatten t2) ys\n                     -- (flatten t1 ++  (flatten t2 ++  ys)) \u2261  (flatten t1 ++ (flatten t2 ++ ys))\n  = refl\n\nflatten-acc-flatten : {A : Set}\n                    \u2192 (t : Tree A) \u2192 (ys : List A)\n                    \u2192 flatten-acc t ys \u2261 flatten t ++ ys\nflatten-acc-flatten (leaf x)     ys = refl\n                      --  flatten-acc (leaf x)           ys   \u2261  (flatten (leaf x)          ++ ys)\nflatten-acc-flatten (node t1 t2) ys\n                      --  flatten-acc (node t1 t2)       ys   \u2261  (flatten (node t1 t2)      ++ ys)\n                      --  flatten-acc t1 (flatten-acc t2 ys)  \u2261 ((flatten t1 ++ flatten t2) ++ ys)\n  rewrite\n    flatten-acc-lemma t2 ys\n                      --  flatten-acc t1 (flatten t2 ++  ys)  \u2261 ((flatten t1 ++ flatten t2) ++ ys)\n  | flatten-acc-lemma t1 (flatten t2 ++ ys)\n                      -- (flatten t1 ++  (flatten t2 ++  ys)) \u2261 ((flatten t1 ++ flatten t2) ++ ys)\n\n  | append-assoc (flatten t1) (flatten t2) ys\n                      -- (flatten t1 ++  (flatten t2 ++  ys)) \u2261  (flatten t1 ++ (flatten t2 ++ ys))\n  = refl\n\n-- ex 4.6\nflatten'-flatten : {A : Set}\n                 \u2192 (t : Tree A)\n                 \u2192 flatten' t \u2261 flatten t\nflatten'-flatten (leaf x)     = refl\nflatten'-flatten (node t1 t2)\n                    -- flatten' (node t1 t2)              \u2261  flatten (node t1 t2)\n                    -- flatten' (node t1 t2)              \u2261 (flatten t1 ++ flatten t2)\n  rewrite\n    sym (flatten-acc-flatten t1 (flatten t2))\n                    -- flatten-acc t1 (flatten-acc t2 []) \u2261 flatten-acc t1 (flatten t2)\n  | flatten-acc-flatten t2 []\n                    -- flatten-acc t1 (flatten t2 ++  []) \u2261 flatten-acc t1 (flatten t2)\n  | append-[] (flatten t2)\n                    -- flatten-acc t1 (flatten t2)        \u2261 flatten-acc t1 (flatten t2)\n  = refl\n\n--------------------------------------------------\n-- compiler correctness\n\ndata Expr : Set where\n  valE : Nat  \u2192        Expr\n  addE : Expr \u2192 Expr \u2192 Expr\n\neval : Expr \u2192 Nat\neval (valE x)     = x\neval (addE e1 e2) = eval e1 + eval e2\n\ndata Op : Set where\n  PUSH : Nat \u2192 Op\n  ADD  : Op\n\nStack = List Nat\nCode  = List Op\n\nexec : Code \u2192 Stack \u2192 Stack\nexec []                       s  = s\nexec (PUSH x :: c)            s  = exec c (x :: s)\nexec (ADD :: c)    (m :: n :: s) = exec c (n + m :: s)\nexec (ADD :: c)               _  = []\n\ncompile' : Expr \u2192 Code \u2192 Code\ncompile' (valE x) c = PUSH x :: c\ncompile' (addE e1 e2) c = compile' e1 (compile' e2 (ADD :: c))\n\ncompile : Expr \u2192 Code\ncompile e = compile' e []\n\ncompile'-exec-eval : (e : Expr) \u2192 (s : Stack) \u2192 (c : Code)\n                   \u2192 exec (compile' e c) s \u2261 exec c (eval e :: s)\ncompile'-exec-eval (valE _)     _ _ = refl\ncompile'-exec-eval (addE e1 e2) s c\n        -- exec (compile' (addE e1 e2) c)              s \u2261 exec c (eval (addE e1 e2) :: s)\n        -- exec (compile' e1 (compile' e2 (ADD :: c))) s \u2261 exec c (eval e1 + eval e2 :: s)\n  rewrite\n    compile'-exec-eval e1 s (compile' e2 (ADD :: c))\n        -- exec (compile' e2 (ADD :: c)) (eval e1 :: s)  \u2261 exec c (eval e1 + eval e2 :: s)\n  | compile'-exec-eval e2 (eval e1 :: s) (ADD :: c)\n        -- exec c (eval e1 + eval e2 :: s)               \u2261 exec c (eval e1 + eval e2 :: s)\n  = refl\n\ncompile-exec-eval : (e : Expr) \u2192 exec (compile e) [] \u2261 [ eval e ]\ncompile-exec-eval e = compile'-exec-eval e [] []\n", "meta": {"hexsha": "43858fda06af1dbd85accae6afff72b146d88105", "size": 31349, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2021-03-Jesper_Cockx-Programming_and_Proving_in_Agda/z.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2021-03-Jesper_Cockx-Programming_and_Proving_in_Agda/z.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2021-03-Jesper_Cockx-Programming_and_Proving_in_Agda/z.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 29.7146919431, "max_line_length": 99, "alphanum_fraction": 0.4924240008, "num_tokens": 10670, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887588052782737, "lm_q2_score": 0.86153820232079, "lm_q1q2_score": 0.765699663396217}}
{"text": "module my-nat where\n\nopen import product\nopen import bool\nopen import eq\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\ninfixl 10 _*_\ninfixl 9 _+_\n--infixl 8 _<_ _=\u2115_ _\u2264_ _>_ _\u2265_\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n\nsuc m + n = suc (m + n)\n\n0+ : \u2200 (x : \u2115) \u2192 0 + x \u2261 x\n0+ x = refl\n\n+0 : \u2200 (x : \u2115) \u2192 x + 0 \u2261 x\n+0 zero = refl\n+0 (suc x) rewrite +0 x = refl\n\n+assoc : \u2200 (x y z : \u2115) \u2192 x + (y + z) \u2261 (x + y) + z\n+assoc zero y z = refl\n+assoc (suc x) y z rewrite +assoc x y z = refl\n\n+suc : \u2200 (x y : \u2115) \u2192 x + (suc y) \u2261 suc(x + y)\n+suc zero y = refl\n+suc (suc x) y rewrite +suc x y = refl\n\n+comm : \u2200 (x y : \u2115) \u2192 x + y \u2261 y + x\n+comm zero y rewrite +0 y = refl\n+comm (suc x) y rewrite +suc y x | +comm x y = refl\n\n_*_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  * n = zero\nsuc m * n = n + (m * n)\n\n*distribr : \u2200 (x y z : \u2115) \u2192 (x + y) * z \u2261 x * z + y * z\n--*distribr : \u2200 (x y z : \u2115) \u2192 (x + y) * z \u2261 x * z + y * z\n*distribr zero y z = refl\n*distribr (suc x) y z rewrite *distribr x y z = +assoc z (x * z) (y * z)\n\n*0 : \u2200 (x : \u2115) \u2192 x * 0 \u2261 0\n*0 zero = refl\n*0 (suc x) = *0 x\n\n*suc : \u2200 (x y : \u2115) \u2192 x * (suc y) \u2261 x + x * y\n*suc zero y = refl\n*suc (suc x) y rewrite *suc x y\n                       | +assoc y x (x * y)\n                       | +assoc x y (x * y)\n                       | +comm x y = refl\n\n*comm : \u2200 (x y : \u2115) \u2192 x * y \u2261 y * x\n*comm zero y rewrite *0 y = refl\n*comm (suc x) y rewrite *suc y x | *comm x y = refl\n\n*assoc : \u2200 (x y z : \u2115) \u2192 x * (y * z) \u2261 (x * y) * z\n*assoc zero y z = refl\n*assoc (suc x) y z rewrite *distribr y (x * y) z\n                           | *assoc x y z = refl\n\n_<_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\n0 < 0 = ff\n0 < (suc y) = tt\n(suc x) < (suc y) = x < y\n(suc x) < 0 = ff\n\n_=\u2115_ : \u2115 \u2192 \u2115 \u2192 \ud835\udd39\n0 =\u2115 0 = tt\nsuc x =\u2115 suc y = x =\u2115 y\n_ =\u2115 _ = ff\n\n=\u2115-refl : \u2200 (x : \u2115) \u2192 (x =\u2115 x) \u2261 tt\n=\u2115-refl zero = refl\n=\u2115-refl (suc x) = =\u2115-refl x\n\n=\u2115-to-\u2261 : \u2200 {x y : \u2115} \u2192 x =\u2115 y \u2261 tt \u2192 x \u2261 y\n=\u2115-to-\u2261 {zero} {zero} u = refl\n=\u2115-to-\u2261 {zero} {suc y} ()\n=\u2115-to-\u2261 {suc x} {zero} ()\n=\u2115-to-\u2261 {suc x} {suc y} u rewrite =\u2115-to-\u2261 {x} {y} u = refl\n\n=\u2115-from-\u2261 : \u2200 {x y : \u2115} \u2192 x \u2261 y \u2192 x =\u2115 y \u2261 tt\n=\u2115-from-\u2261 {x} {.x} refl = =\u2115-refl x\n\nis-even : \u2115 \u2192 \ud835\udd39\nis-odd : \u2115 \u2192 \ud835\udd39\nis-even 0 = tt\nis-even (suc x) = is-odd x\nis-odd 0 = ff\nis-odd (suc x) = is-even x\n\neven~odd : \u2200 (x : \u2115) \u2192 is-even x \u2261 ~ is-odd x\nodd~even : \u2200 (x : \u2115) \u2192 is-odd x \u2261 ~ is-even x\neven~odd zero = refl\neven~odd (suc x) = odd~even x\nodd~even zero = refl\nodd~even (suc x) = even~odd x\n", "meta": {"hexsha": "5681e4ad1dd05269c07f98c3481d356ff00cb7c2", "size": 2396, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "my-nat.agda", "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "my-nat.agda", "max_issues_repo_name": "logicshan/IAL", "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "my-nat.agda", "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.6037735849, "max_line_length": 72, "alphanum_fraction": 0.4661936561, "num_tokens": 1163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9473810451666345, "lm_q2_score": 0.8080672227971211, "lm_q1q2_score": 0.7655475700984362}}
{"text": "module Numeral.Natural.Oper.Divisibility where\n\nimport      Lvl\nopen import Data\nopen import Data.Boolean\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.Modulo\n\n-- Divisibility check\n_\u2223?_ : \u2115 \u2192 \u2115 \u2192 Bool\n\ud835\udfce    \u2223? _ = \ud835\udc39\n\ud835\udc12(y) \u2223? x = zero?(x mod \ud835\udc12(y))\n\n-- Divisibility check\n_\u2223\u2080?_ : \u2115 \u2192 \u2115 \u2192 Bool\n\ud835\udfce \u2223\u2080? \ud835\udfce    = \ud835\udc47\n\ud835\udfce \u2223\u2080? \ud835\udc12(_) = \ud835\udc39\n\ud835\udc12(y) \u2223\u2080? x = zero?(x mod \ud835\udc12(y))\n\n{-\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.UnclosedOper\nopen import Data.Option as Option using (Option)\n\n{-# TERMINATING #-}\n_\u2223?_ : \u2115 \u2192 \u2115 \u2192 Bool\n_    \u2223? \ud835\udfce    = \ud835\udc47\n\ud835\udfce    \u2223? \ud835\udc12(_) = \ud835\udc39\n\ud835\udc12(x) \u2223? \ud835\udc12(y) with (x \u2212? y)\n... | Option.Some(xy) = xy \u2223? \ud835\udc12(y)\n... | Option.None     = \ud835\udc39\n-}\n", "meta": {"hexsha": "5455e184559b589382a73c2ec75af51a1b8438cf", "size": 704, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/Divisibility.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/Divisibility.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/Divisibility.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.7058823529, "max_line_length": 48, "alphanum_fraction": 0.6221590909, "num_tokens": 305, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9473810451666346, "lm_q2_score": 0.8080672089305841, "lm_q1q2_score": 0.7655475569615421}}
{"text": "module Data.List.First.Properties {\u2113}{A : Set \u2113} where\n\nopen import Data.Product\nopen import Data.List\nopen import Data.List.Any\nopen import Relation.Binary.PropositionalEquality\nopen import Function\nopen import Data.Empty\nopen import Data.List.First\nopen import Data.List.Membership.Propositional\n\nfirst\u27f6\u2208 : \u2200 {B : A \u2192 Set} {x l} \u2192 First B x l \u2192 (x \u2208 l \u00d7 B x)\nfirst\u27f6\u2208 (here {x = x} p) = here refl , p\nfirst\u27f6\u2208 (there x' \u00acpx f) with (first\u27f6\u2208 f)\nfirst\u27f6\u2208 (there x' \u00acpx f) | x\u2208l , p = there x\u2208l , p\n\nfirst-unique : \u2200 {P : A \u2192 Set}{x y v} \u2192 First P x v \u2192 First P y v \u2192 x \u2261 y\nfirst-unique (here x) (here y) = refl\nfirst-unique (here {x = x} px) (there .x \u00acpx r) = \u22a5-elim (\u00acpx px)\nfirst-unique (there x \u00acpx l) (here {x = .x} px) = \u22a5-elim (\u00acpx px)\nfirst-unique (there x' _ l) (there .x' _ r) = first-unique l r\n", "meta": {"hexsha": "cf04cce1e0d6821b487b102225c4fb2320e8e8c8", "size": 803, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/First/Properties.agda", "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Data/List/First/Properties.agda", "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Data/List/First/Properties.agda", "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 36.5, "max_line_length": 73, "alphanum_fraction": 0.6400996264, "num_tokens": 301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284088064979619, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7654377130702825}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category.Core\nopen import Categories.Object.Terminal hiding (up-to-iso)\n\nmodule Categories.Object.NaturalNumber {o \u2113 e} (\ud835\udc9e : Category o \u2113 e) (\ud835\udc9e-Terminal : Terminal \ud835\udc9e) where\n\nopen import Level\n\nopen import Categories.Morphism \ud835\udc9e\nopen import Categories.Morphism.Reasoning \ud835\udc9e\n\nopen Category \ud835\udc9e\nopen HomReasoning\nopen Equiv\n\nopen Terminal \ud835\udc9e-Terminal\n\nprivate\n  variable\n    A B C D X Y Z : Obj\n    h i j : A \u21d2 B\n\nrecord IsNaturalNumber (N : Obj) : Set (o \u2294 \u2113 \u2294 e) where\n  field\n    z : \u22a4 \u21d2 N\n    s : N \u21d2 N\n    universal : \u2200 {A} \u2192 \u22a4 \u21d2 A \u2192 A \u21d2 A \u2192 N \u21d2 A\n    z-commute : \u2200 {A} {q : \u22a4 \u21d2 A} {f : A \u21d2 A} \u2192 q \u2248 universal q f \u2218 z\n    s-commute : \u2200 {A} {q : \u22a4 \u21d2 A} {f : A \u21d2 A} \u2192 f \u2218 universal q f \u2248 universal q f \u2218 s\n    unique    : \u2200 {A} {q : \u22a4 \u21d2 A} {f : A \u21d2 A} {u : N \u21d2 A} \u2192 q \u2248 u \u2218 z \u2192 f \u2218 u \u2248 u \u2218 s \u2192 u \u2248 universal q f\n\n  \u03b7 : universal z s \u2248 id\n  \u03b7 = \u27fa (unique (\u27fa identity\u02e1) id-comm)\n\n  universal-cong : \u2200 {A} \u2192 {f f\u2032 : \u22a4 \u21d2 A} \u2192 {g g\u2032 : A \u21d2 A} \u2192 f \u2248 f\u2032 \u2192 g \u2248 g\u2032 \u2192 universal f g \u2248 universal f\u2032 g\u2032\n  universal-cong f\u2248f\u2032 g\u2248g\u2032 = unique (\u27fa f\u2248f\u2032 \u25cb  z-commute) (\u2218-resp-\u2248\u02e1 (\u27fa g\u2248g\u2032) \u25cb s-commute)\n\nrecord NaturalNumber : Set (o \u2294 \u2113 \u2294 e) where\n  field\n    N : Obj\n    isNaturalNumber : IsNaturalNumber N\n\n  open IsNaturalNumber isNaturalNumber public\n\nopen NaturalNumber\n\nmodule _ (N : NaturalNumber) (N\u2032 : NaturalNumber) where\n  private\n    module N = NaturalNumber N\n    module N\u2032 = NaturalNumber N\u2032\n\n  up-to-iso : N.N \u2245 N\u2032.N\n  up-to-iso = record\n    { from = N.universal N\u2032.z N\u2032.s\n    ; to = N\u2032.universal N.z N.s\n    ; iso = record\n      { iso\u02e1 = universal-\u2218 N N\u2032\n      ; iso\u02b3 = universal-\u2218 N\u2032 N\n      }\n    }\n    where\n      universal-\u2218 : \u2200 (N N\u2032 : NaturalNumber) \u2192 universal N\u2032 (z N) (s N) \u2218 universal N (z N\u2032) (s N\u2032) \u2248 id  \n      universal-\u2218 N N\u2032 = unique N (z-commute N\u2032 \u25cb push\u02b3 (z-commute N)) (pull\u02e1 (s-commute N\u2032) \u25cb assoc \u25cb \u2218-resp-\u2248\u02b3 (s-commute N) \u25cb \u27fa assoc) \u25cb (\u03b7 N)\n      \n", "meta": {"hexsha": "6362992022cb42a5761147dff881505258d17675", "size": 1919, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Object/NaturalNumber.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 29.0757575758, "max_line_length": 145, "alphanum_fraction": 0.5659197499, "num_tokens": 769, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7654377032715285}}
{"text": "{-# OPTIONS --without-K #-}\n\nmodule Ch2-1 where\n\nopen import Level\n\ninfixl 4 _\u2261_\ndata _\u2261_ {a} {A : Set a} (x : A) : A \u2192 Set a where\n  refl : x \u2261 x\n\n\nJ : {a b : Level} (A : Set a) (C : (x y : A) \u2192 x \u2261 y \u2192 Set b)\n    \u2192 ((x : A) \u2192 C x x refl)\n    \u2192 (x y : A) (P : x \u2261 y)\n    \u2192 C x y P\nJ A C b x .x refl = b x\n\n-- K : (A : Set) (x : A) (C : x \u2261 x \u2192 Set)\n--   \u2192 C refl\n--   \u2192 (loop : x \u2261 x)\n--   \u2192 C loop\n-- K A x C b p = {! p  !}\n\n-- Lemma 2.1.1 (inversion of paths)\ninfix 6 \u00ac_\n\u00ac_ : {a : Level} {A : Set a} {x y : A} \u2192 x \u2261 y \u2192 y \u2261 x\n\u00ac_ {a} {A} {x} {y} p = J A D d x y p\n\n  where\n    D : (x y : A) (p : x \u2261 y) \u2192 Set a\n    D x y p = y \u2261 x\n\n    d : (x : A) \u2192 D x x refl\n    d x = refl\n\n\n-- Lemma 2.1.2 (concatenation of paths)\ninfixl 5 _\u2219_\n_\u2219_ : {a : Level} {A : Set a} {x y z : A} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\n_\u2219_ {a} {A} {x} {y} {z} p q = J {a} {a} A D d x y p z q\n\n  where\n    -- the predicate\n    D : (x y : A) (p : x \u2261 y) \u2192 Set a\n    D x y p = (z : A) (q : y \u2261 z) \u2192 x \u2261 z\n\n    -- base case\n    d : (x : A) \u2192 D x x refl\n    d x z q = J A E e x z q\n      where\n        -- the predicate\n        E : (x z : A) (q : x \u2261 z) \u2192 Set a\n        E x z q = x \u2261 z\n\n        -- base case\n        e : (x : A) \u2192 E x x refl\n        e x = refl\n\n\n-- Lemma 2.1.4.i (identity of path concatenation)\n\u2219-identity\u02b3 : {a : Level} {A : Set a} {x y : A} (p : x \u2261 y) \u2192 p \u2261 p \u2219 refl\n\u2219-identity\u02b3 {a} {A} {x} {y} p = J A D d x y p\n\n  where\n    -- the predicate\n    D : (x y : A) (p : x \u2261 y) \u2192 Set a\n    D x y p = p \u2261 p \u2219 refl\n\n    -- base case\n    d : (x : A) \u2192 D x x refl\n    d x = refl\n\n\u2219-identity\u02e1 : {a : Level} {A : Set a} {x y : A} (p : x \u2261 y) \u2192 p \u2261 refl \u2219 p\n\u2219-identity\u02e1 {a} {A} {x} {y} p = J A D d x y p\n  where\n    -- the predicate\n    D : (x y : A) (p : x \u2261 y) \u2192 Set a\n    D x y p = p \u2261 refl \u2219 p\n\n    -- base case\n    d : (x : A) \u2192 D x x refl\n    d x = refl\n\n-- Lemma 2.1.4.ii (identity of path inversion)\n\u00ac-identity\u02b3 : {a : Level} {A : Set a} {x y : A} (p : x \u2261 y) \u2192 \u00ac p \u2219 p \u2261 refl\n\u00ac-identity\u02b3 {a} {A} {x} {y} p = J A D d x y p\n  where\n    -- the predicate\n    D : (x y : A) (p : x \u2261 y) \u2192 Set a\n    D x y p = \u00ac p \u2219 p \u2261 refl\n\n    -- base case\n    d : (x : A) \u2192 D x x refl\n    d x = refl\n\n\u00ac-identity\u02e1 : {a : Level} {A : Set a} {x y : A} (p : x \u2261 y) \u2192 p \u2219 \u00ac p \u2261 refl\n\u00ac-identity\u02e1 {a} {A} {x} {y} p = J A D d x y p\n  where\n    -- the predicate\n    D : (x y : A) (p : x \u2261 y) \u2192 Set a\n    D x y p = p \u2219 \u00ac p \u2261 refl\n\n    -- base case\n    d : (x : A) \u2192 D x x refl\n    d x = refl\n\n-- Lemma 2.1.4.iii (involution of path inversion)\ninvolution : {A : Set} {x y : A} (p : x \u2261 y) \u2192 \u00ac \u00ac p \u2261 p\ninvolution {A} {x} {y} p = J A D d x y p\n  where\n    -- the predicate\n    D : (x y : A) (p : x \u2261 y) \u2192 Set\n    D x y p = \u00ac \u00ac p \u2261 p\n\n    -- base case\n    d : (x : A) \u2192 D x x refl\n    d x = refl\n\n-- Lemma 2.1.4.iv (associativity of path concatenation)\n\u2219-assoc : {a : Level} {A : Set a} {w x y z : A}\n  \u2192 (p : w \u2261 x) (q : x \u2261 y) (r : y \u2261 z)\n  \u2192 p \u2219 (q \u2219 r) \u2261 (p \u2219 q) \u2219 r\n\u2219-assoc {a} {A} {w} {x} {y} {z} p q r = J A D d w x p y q z r\n  where\n    -- the predicate\n    D : (w x : A) (p : w \u2261 x) \u2192 Set a\n    D w x p = (y : A) (q : x \u2261 y)\n            \u2192 (z : A) (r : y \u2261 z)\n            \u2192 p \u2219 (q \u2219 r) \u2261 (p \u2219 q) \u2219 r\n\n    -- base case\n    d : (x : A) \u2192 D x x refl\n    d x y q z r = J A E e x y q z r\n      where\n        -- the predicate\n        E : (x y : A) (q : x \u2261 y) \u2192 Set a\n        E x y q = (z : A) (r : y \u2261 z)\n                \u2192 refl \u2219 (q \u2219 r) \u2261 refl \u2219 q \u2219 r\n\n        -- base case\n        e : (x : A) \u2192 E x x refl\n        e x z r = J A F f x z r\n          where\n            -- the predicate\n            F : (y z : A) (r : y \u2261 z) \u2192 Set a\n            F y z r = refl \u2219 (refl \u2219 r) \u2261 refl \u2219 refl \u2219 r\n\n            -- base case\n            f : (x : A) \u2192 F x x refl\n            f x = refl\n\n\nopen import Relation.Binary\n\nisEquivalence : \u2200 {a} {A : Set a} \u2192 IsEquivalence (_\u2261_ {a} {A})\nisEquivalence = record\n  { refl = refl\n  ; sym = \u00ac_\n  ; trans = _\u2219_\n  }\n\nsetoid : \u2200 {a} \u2192 Set a \u2192 Setoid _ _\nsetoid {a} A = record\n  { Carrier       = A\n  ; _\u2248_           = _\u2261_\n  ; isEquivalence = isEquivalence {a} {A}\n  }\n-- module EckmannHilton where\n--\n--     -- begin\n--     --   p \u2219 refl\n--     -- \u2248\u27e8 \u00ac \u2219-identity\u02b3 p \u27e9\n--     --   p\n--     -- \u2248\u27e8 \u03b1 \u27e9\n--     --   q\n--     -- \u2248\u27e8 \u2219-identity\u02b3 q \u27e9\n--     --   q \u2219 refl\n--     -- \u220e\n--     -- where\n--     --   open import Relation.Binary.Reasoning.Setoid (setoid (a \u2261 x))\n--\n--   -- whisker right\n--   infixl 6 _\u2219r_\n--   _\u2219r_ : {A : Set} {a b c : A} {p q : a \u2261 b}\n--     \u2192 (\u03b1 : p \u2261 q) (r : b \u2261 c)\n--     \u2192 p \u2219 r \u2261 q \u2219 r\n--   _\u2219r_ {A} {a} {b} {c} {p} {q} \u03b1 r = J A D d b c r a p q \u03b1\n--     where\n--       -- the predicate\n--       D : (b c : A) (r : b \u2261 c) \u2192 Set\n--       D b c r = (a : A) (p q : a \u2261 b) (\u03b1 : p \u2261 q)\n--         \u2192 p \u2219 r \u2261 q \u2219 r\n--\n--       -- base case\n--       d : (x : A) \u2192 D x x refl\n--       d x a p q \u03b1 = J A E e a x p q\n--         where\n--           -- the predicate\n--           E : (a x : A) (p : a \u2261 x) \u2192 Set\n--           E a x p = (q : a \u2261 x) \u2192 p \u2219 refl \u2261 q \u2219 refl\n--\n--           -- base case\n--           e : (x : A) \u2192 E x x refl\n--           e x q = {!   !}\n--             where\n--               -- the predicate\n--               F : (a x : A) (q : a \u2261 x) \u2192 Set\n--               F a x q = {!   !}\n--                 -- refl \u2219 refl \u2261 q \u2219 refl\n--                 -- refl \u2219 refl \u2261 q \u2219 refl\n--\n--               -- base case\n--               f : (x : A) \u2192 F x x refl\n--               f x = {!   !}\n--         --\n--         -- \u00ac \u2219-identity\u02b3 p \u2219 \u03b1 \u2219 \u2219-identity\u02b3 q\n--   --\n--   --\n--   -- -- whisker left\n--   -- infixl 6 _\u2219l_\n--   -- _\u2219l_ : {A : Set} {a b c : A} {r s : b \u2261 c}\n--   --   \u2192 (q : a \u2261 b) (\u03b2 : r \u2261 s)\n--   --   \u2192 q \u2219 r \u2261 q \u2219 s\n--   -- _\u2219l_ {A} {a} {b} {c} {r} {s} q \u03b2 = J A D d a b q c r s \u03b2\n--   --   where\n--   --     -- the predicate\n--   --     D : (a b : A) (q : a \u2261 b) \u2192 Set\n--   --     D a b q = (c : A) (r s : b \u2261 c) (\u03b2 : r \u2261 s)\n--   --       \u2192 q \u2219 r \u2261 q \u2219 s\n--   --\n--   --     -- base case\n--   --     d : (x : A) \u2192 D x x refl\n--   --     d x c r s \u03b2 = \u00ac \u2219-identity\u02e1 r \u2219 \u03b2 \u2219 \u2219-identity\u02e1 s\n--   --\n--   -- -- horizontal composition\n--   -- _\u22c6_ : {A : Set} {a b c : A} {p q : a \u2261 b} {r s : b \u2261 c}\n--   --   \u2192 (\u03b1 : p \u2261 q) (\u03b2 : r \u2261 s)\n--   --   \u2192 p \u2219 r \u2261 q \u2219 s\n--   -- _\u22c6_ {A} {a} {b} {c} {p} {q} {r} {s} \u03b1 \u03b2 = (\u03b1 \u2219r r) \u2219 (q \u2219l \u03b2)\n--   --\n--   --   where\n--   --     whisker-right-lemma : \u2200 {A : Set} {a b : A}\n--   --       \u2192 {p q : a \u2261 b} {\u03b1 : p \u2261 q}\n--   --       \u2192 \u03b1 \u2219r refl \u2261 \u00ac \u2219-identity\u02b3 p \u2219 \u03b1 \u2219 \u2219-identity\u02b3 q\n--   --     whisker-right-lemma {A} {a} {b} {p} {q} {\u03b1} = refl\n--   --\n--   --     whisker-left-lemma : \u2200 {A : Set} {b c : A}\n--   --       \u2192 {r s : b \u2261 c} {\u03b2 : r \u2261 s}\n--   --       \u2192 refl \u2219l \u03b2 \u2261 \u00ac \u2219-identity\u02e1 r \u2219 \u03b2 \u2219 \u2219-identity\u02e1 s\n--   --     whisker-left-lemma {A} {b} {c} {r} {s} {\u03b1} = refl\n--   --\n--   -- cong : {A B : Set} {x y : A}\n--   --   \u2192 (f : A \u2192 B) (p : x \u2261 y)\n--   --   \u2192 f x \u2261 f y\n--   -- cong {A} {B} {x} {y} f p = J A D d x y p f\n--   --   where\n--   --     -- the predicate\n--   --     D : (x y : A) (p : x \u2261 y) \u2192 Set\n--   --     D x y p = (f : A \u2192 B) \u2192 f x \u2261 f y\n--   --\n--   --     -- base case\n--   --     d : (x : A) \u2192 D x x refl\n--   --     d x f = refl\n--   --\n--   -- cong2 : {A B C : Set} {x y : A} {a b : B}\n--   --   \u2192 (f : A \u2192 B \u2192 C) (p : x \u2261 y) (q : a \u2261 b)\n--   --   \u2192 f x a \u2261 f y b\n--   -- cong2 {A} {B} {C} {x} {y} {a} {b} f p q = J A D d x y p a b q f\n--   --   -- J A D d x y p f\n--   --   where\n--   --     -- the predicate\n--   --     D : (x y : A) (p : x \u2261 y) \u2192 Set\n--   --     D x y p = (a b : B) (q : a \u2261 b) (f : A \u2192 B \u2192 C) \u2192 f x a \u2261 f y b\n--   --\n--   --     -- base case\n--   --     d : (x : A) \u2192 D x x refl\n--   --     d x a b q f = cong (f x) q\n--   --\n--   --\n--   -- -- theorem : {A : Set} {a b c : A}\n--   -- --   \u2192 {p q : a \u2261 b} {r s : b \u2261 c}\n--   -- --   \u2192 (\u03b1 : p \u2261 q) (\u03b2 : r \u2261 s)\n--   -- --   \u2192 \u03b1 \u22c6 \u03b2 \u2261 cong2 _\u2219_ \u03b1 \u03b2\n--   -- -- theorem {A} {a} {b} {c} {p} {q} {r} {s} \u03b1 \u03b2 = J A D d a b p q c r s \u03b1 \u03b2\n--   -- --\n--   -- --   where\n--   -- --     -- the predicate\n--   -- --     D : (a b : A) (p : a \u2261 b) \u2192 Set\n--   -- --     D a b p = (q : a \u2261 b) (c : A) (r s : b \u2261 c) (\u03b1 : p \u2261 q) (\u03b2 : r \u2261 s)\n--   -- --       \u2192 \u03b1 \u22c6 \u03b2 \u2261 cong2 _\u2219_ \u03b1 \u03b2\n--   -- --\n--   -- --     -- base case \u02b3\u02e1\n--   -- --     d : (x : A) \u2192 D x x refl\n--   -- --     d x q c r s \u03b1 \u03b2 = J A E e x c r s q \u03b1 \u03b2\n--   -- --\n--   -- --       where\n--   -- --         -- the predicate\n--   -- --         E : (b c : A) (r : b \u2261 c) \u2192 Set\n--   -- --         E b c r = (s : b \u2261 c) (q : b \u2261 b) (\u03b1 : refl \u2261 q) (\u03b2 : r \u2261 s)\n--   -- --           \u2192 \u03b1 \u22c6 \u03b2 \u2261 cong2 _\u2219_ \u03b1 \u03b2\n--   -- --\n--   -- --         -- base case\n--   -- --         e : (x : A) \u2192 E x x refl\n--   -- --         e x s q \u03b1 \u03b2 = {!   !}\n", "meta": {"hexsha": "90f8a2a29cdd48a1a9481e6c6eb133450176fb2f", "size": 8611, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Ch2-1.agda", "max_stars_repo_name": "banacorn/hott", "max_stars_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Ch2-1.agda", "max_issues_repo_name": "banacorn/hott", "max_issues_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Ch2-1.agda", "max_forks_repo_name": "banacorn/hott", "max_forks_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2327868852, "max_line_length": 82, "alphanum_fraction": 0.3445592846, "num_tokens": 3968, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513703624557, "lm_q2_score": 0.853912747375134, "lm_q1q2_score": 0.7653204700049333}}
{"text": "module Lectures.One where\n\n-- Check background color\n-- Check fontsize\n-- Ask questions at *any* time\n\ndata \u22a4 : Set where\n  tt : \u22a4\n\ndata \u22a5 : Set where\n\nabsurd : \u22a5 \u2192 {P : Set} \u2192 P\nabsurd ()\n\n-- Introduce most common key bindings\n-- C-c C-l     load\n-- C-c C-,     show context\n-- C-c C-.     show context + type\n-- C-c C-SPACE input\n-- C-c C-A     auto\n-- C-c C-r     refine\n-- C-c C-d     type inference\n-- C-c C-c     pattern match\n\n-- Briefly introduce syntax\n-- Introduce Set 0\n\nmodus-ponens : {P Q : Set} \u2192 P \u2192 (P \u2192 Q) \u2192 Q\nmodus-ponens p f = f p\n\n-- Introduce misfix operators\n\n\u00ac_ : Set \u2192 Set\n\u00ac P = P \u2192 \u22a5\n\ncontra-elim : {P : Set} \u2192 P \u2192 \u00ac P \u2192 \u22a5\ncontra-elim = modus-ponens\n\n-- no-dne : {P : Set} \u2192 \u00ac \u00ac P \u2192 P\n-- no-dne \u00ac\u00acP = {!!}\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n\nsuc m + n = suc (m + n)\n\n_isEven : \u2115 \u2192 Set\nzero isEven = \u22a4\nsuc zero isEven = \u22a5\nsuc (suc n) isEven = n isEven\n\nhalf : (n : \u2115) \u2192 n isEven \u2192 \u2115\nhalf zero tt = zero\nhalf (suc (suc n)) p = suc (half n p)\n\n_ : \u2115\n_ = half 8 tt\n\n-- Comment on termination checking\n\n-- brexit : \u22a5\n-- brexit = brexit\n", "meta": {"hexsha": "6e928a760818091fa9fc63baab1d3b6465d509a3", "size": 1123, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lectures/One.agda", "max_stars_repo_name": "UoG-Agda/Agda101", "max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lectures/One.agda", "max_issues_repo_name": "UoG-Agda/Agda101", "max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lectures/One.agda", "max_forks_repo_name": "UoG-Agda/Agda101", "max_forks_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.5147058824, "max_line_length": 44, "alphanum_fraction": 0.5592163847, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505376715775, "lm_q2_score": 0.8459424334245617, "lm_q1q2_score": 0.7652822772367324}}
{"text": "------------------------------------------------------------------------\n-- One form of induction for natural numbers\n------------------------------------------------------------------------\n\n-- I want universe polymorphism.\n\nmodule Induction1.Nat where\n\nopen import Data.Nat\nimport Induction1.WellFounded as WF\n\n------------------------------------------------------------------------\n-- Complete induction based on <\u2032\n\nopen WF _<\u2032_ using (Acc; acc)\n\nallAcc : \u2200 n \u2192 Acc n\nallAcc n = acc (helper n)\n  where\n  helper : \u2200 n m \u2192 m <\u2032 n \u2192 Acc m\n  helper zero     _ ()\n  helper (suc n) .n \u2264\u2032-refl        = acc (helper n)\n  helper (suc n)  m (\u2264\u2032-step m<\u2032n) = helper n m m<\u2032n\n\nopen WF _<\u2032_ public using () renaming (WfRec to <-Rec)\nopen WF.All _<\u2032_ allAcc public\n  renaming ( wfRec-builder to <-rec-builder\n           ; wfRec to <-rec\n           )\n", "meta": {"hexsha": "15846f13010cfe1136a4bd9b364b55f60e34010a", "size": 841, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "vendor/stdlib/src/Induction1/Nat.agda", "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 56, "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_issues_repo_path": "vendor/stdlib/src/Induction1/Nat.agda", "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_forks_repo_path": "vendor/stdlib/src/Induction1/Nat.agda", "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "avg_line_length": 28.0333333333, "max_line_length": 72, "alphanum_fraction": 0.4601664685, "num_tokens": 208, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9441768557238083, "lm_q2_score": 0.8104789040926008, "lm_q1q2_score": 0.7652354232966299}}
{"text": "module Logic where\n\n-- The true proposition.\ndata \u22a4 : Set where\n  obvious : \u22a4 -- The proof of truth.\n\n-- The false proposition.\ndata \u22a5 : Set where\n  -- There is nothing here so one can never prove false.\n\n-- The AND of two statments.\ndata _\u2227_ (A B : Set)  : Set where\n  -- The only way to construct a proof of A \u2227 B is by pairing a a\n  -- proof of A with a proof of and B.\n  \u27e8_,_\u27e9 : (a : A)  -- Proof of A\n        \u2192 (b : B)  -- Proof of B\n        \u2192 A \u2227 B    -- Proof of A \u2227 B\n\n-- The OR of two statements.\ndata _\u2228_ (A B : Set) : Set where\n  -- There are two ways of constructing a proof of A \u2228 B.\n  inl : (a : A) \u2192  A \u2228 B   -- From a proof of A by left introduction\n  inr : (b : B) \u2192  A \u2228 B   -- From a proof of B by right introduction\n\n-- The not of statement A\n\u00ac_ : (A : Set) \u2192 Set\n\u00ac A = A \u2192 \u22a5  -- Given a proof of A one should be able to get a proof\n             -- of \u22a5.\n\n-- The statement A \u2194 B are equivalent.\n_\u2194_ : (A B : Set) \u2192 Set\nA \u2194 B = (A \u2192 B) -- If\n           \u2227    -- and\n        (B \u2192 A) -- only if\n\n\ninfixr 1 _\u2227_\ninfixr 1 _\u2228_\ninfixr 0 _\u2194_\ninfix  2 \u00ac_\n\n-- Function composition\n_\u2218_   : {A B C : Set} \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 A \u2192 C\n(f \u2218 g) x = f (g x)\n\n-- Double negation\ndoubleNegation : \u2200 {A : Set} \u2192 A \u2192 \u00ac (\u00ac A)\ndoubleNegation a negNegA = negNegA a\n\n{-\n\ndoubleNegation' : \u2200 {A : Set} \u2192 \u00ac ( \u00ac (\u00ac A)) \u2192 \u00ac A\n\n-}\n\n\ndeMorgan1 : \u2200 (A B : Set) \u2192 \u00ac (A \u2228 B) \u2192 \u00ac A \u2227 \u00ac B\ndeMorgan1 A B notAorB = \u27e8 notAorB \u2218 inl , notAorB \u2218 inr \u27e9\n\ndeMorgan2 : \u2200 (A B : Set) \u2192 \u00ac A \u2227 \u00ac B \u2192 \u00ac (A \u2228 B)\ndeMorgan2 A B \u27e8 notA , notB \u27e9 (inl a) = notA a\ndeMorgan2 A B \u27e8 notA , notB \u27e9 (inr b) = notB b\n\n\ndeMorgan : \u2200 (A B : Set) \u2192 \u00ac (A \u2228 B) \u2194 \u00ac A \u2227 \u00ac B\ndeMorgan A B = \u27e8 deMorgan1 A B , deMorgan2 A B \u27e9\n", "meta": {"hexsha": "a5c7ead3416ce38aa342d6260aeca46faff6a050", "size": 1674, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/Logic.agda", "max_stars_repo_name": "piyush-kurur/sample-code", "max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z", "max_issues_repo_path": "agda/Logic.agda", "max_issues_repo_name": "piyush-kurur/sample-code", "max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z", "max_forks_repo_path": "agda/Logic.agda", "max_forks_repo_name": "piyush-kurur/sample-code", "max_forks_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.9850746269, "max_line_length": 69, "alphanum_fraction": 0.5346475508, "num_tokens": 663, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693659780477, "lm_q2_score": 0.8056321913146127, "lm_q1q2_score": 0.7650842123372535}}
{"text": "module W where\n\nopen import Function using (_\u2218_)\nopen import Data.Bool using (Bool; true; false)\nopen import Data.Product\nopen import Data.Unit using (\u22a4; tt)\nopen import Data.Empty using (\u22a5; \u22a5-elim)\n\ndata W (S : Set) (P : S \u2192 Set) : Set where\n    max : (s : S) \u2192 (f : P s \u2192 W S P) \u2192 W S P\n\n-- data \u2115 : Set where\n--     zero : \u2115             _^0\n--     succ : \u2115 \u2192 \u2115        \u2223\u2115\u2223\n\n\u2115 : Set\n\u2115 = W Bool f\n    where   f : Bool \u2192 Set\n            f true = \u22a4 -- 1\n            f false = \u22a5 -- 0\n\nzero : \u2115\nzero = max false \u22a5-elim\n\nsucc : \u2115 \u2192 \u2115\nsucc n = max true (\u03bb _ \u2192 n)\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n(max true f) + y = max true (\u03bb _ \u2192 f tt + y)\n(max false f) + y = y\n\n-- data Tree : Set where\n--     leaf : Tree                   _^0\n--     node : Tree \u2192 Tree \u2192 Tree    |\u2115| x |\u2115|\n\nTree : Set\nTree = W Bool \u03bb { true \u2192 Bool ; false \u2192 \u22a5 }\n\nleaf : Tree\nleaf = max false \u22a5-elim       -- _^0\n\nnode : Tree \u2192 Tree \u2192 Tree\nnode l r = max true \u03bb { true \u2192 l      -- \u2223Tree\u2223^2\n                     ; false \u2192 r }\n\n\n\ndata LW (S : Set) (LP : S \u2192 Set \u00d7 Set) : Set where\n     lmax : (s : \u03a3 S (proj\u2081 \u2218 LP)) \u2192 (proj\u2082 (LP (proj\u2081 s)) \u2192 LW S LP) \u2192 LW S LP\n\nList : (X : Set) \u2192 Set\nList X = LW Bool (\u03bb { true \u2192 X , \u22a4      -- cons\n                    ; false \u2192 \u22a4 , \u22a5 })  -- nil\n\nnil : {X : Set} \u2192 List X\nnil = lmax (false , tt) \u22a5-elim\n\ncons : {X : Set} \u2192 (x : X) \u2192 List X \u2192 List X\ncons {X} x xs = lmax (true , x) \u03bb _ \u2192 xs\n\n\n\n-- induction principle on W-types\nindW : (S : Set)\n     \u2192 (P : S \u2192 Set)\n     \u2192 (C : W S P \u2192 Set)    --  property\n     \u2192 (c : (s : S)                     -- given a shape\n          \u2192 (f : P s \u2192 W S P)           -- and a bunch of kids\n          \u2192 (h : (p : P s) \u2192 C (f p))   -- if C holds for all kids\n          \u2192 C (max s f))                -- C holds for (max s f)\n     \u2192 (x : W S P)\n     \u2192 C x\nindW S P C step (max s f) = step s f (\u03bb p \u2192 {!   !} S P C step (f p))\n\nind\u2115 : (C : \u2115 \u2192 Set) \u2192 C zero \u2192 ((n : \u2115) \u2192 C n \u2192 C (succ n)) \u2192 (x : \u2115) \u2192 C x\nind\u2115 C base step (max true f) = step (f tt) (ind\u2115 C base step (f tt))\nind\u2115 C base step (max false f) = {! base  !}\n", "meta": {"hexsha": "c8f125ea9ae5ee3dd974b47f36237a1e2f37ee42", "size": 2030, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Sandbox/W.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "Sandbox/W.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sandbox/W.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 26.0256410256, "max_line_length": 79, "alphanum_fraction": 0.4532019704, "num_tokens": 758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582593509315, "lm_q2_score": 0.8221891327004133, "lm_q1q2_score": 0.7650126692696786}}
{"text": "import      Lvl\nopen import Data.Boolean\nopen import Type\n\nmodule Data.List.Sorting {\u2113} {T : Type{\u2113}} (_\u2264?_ : T \u2192 T \u2192 Bool) where\n\nopen import Functional using (_\u2218\u2082_)\nopen import Data.Boolean.Stmt\nopen import Data.List\nimport      Data.List.Relation.Pairwise\nopen import Data.List.Relation.Permutation\nopen import Logic\n\nopen Data.List.Relation.Pairwise using (empty ; single ; step) public\nSorted = Data.List.Relation.Pairwise.AdjacentlyPairwise(IsTrue \u2218\u2082 (_\u2264?_))\n\n-- A sorting algorithm is a function that given a list, always return a sorted list which is a permutation of the original one.\nrecord SortingAlgorithm (f : List(T) \u2192 List(T)) : Stmt{Lvl.\ud835\udc12(\u2113)} where\n  constructor intro\n  field\n    \u2983 sorts \u2984    : \u2200{l} \u2192 Sorted(f(l))\n    \u2983 permutes \u2984 : \u2200{l} \u2192 (f(l) permutes l)\n", "meta": {"hexsha": "1b42f2ffc35b424d03f6fa9dcba1385aec228af6", "size": 776, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Sorting.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Sorting.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Sorting.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.7391304348, "max_line_length": 127, "alphanum_fraction": 0.7100515464, "num_tokens": 236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9674102571131692, "lm_q2_score": 0.7905303137346446, "lm_q1q2_score": 0.7647671340657868}}
{"text": "module examplesPaperJFP.Collatz where\n\nopen import Data.Nat.Base\nopen import Data.Nat.DivMod\nopen import Data.Fin using (Fin; zero; suc)\n\nopen import examplesPaperJFP.Colists\n\ncollatzStep            :  \u2115 \u2192 ListF \u2115 \u2115\ncollatzStep 1          =  nil\ncollatzStep n          with n divMod 2\n... | result q zero _  =  cons n q\n... | _                =  cons n (1 + 3 * n)\n\ncollatzSequence  :  \u2115 \u2192 Colist \u2115\ncollatzSequence  =  unfold collatzStep\n\nopen Colist\nopen import Data.List\n\ndisplayList : Colist \u2115 \u2192 \u2115 \u2192 List \u2115\ndisplayList s 0 = []\ndisplayList s (suc m) with  force s\n... | nil = []\n... | (cons k s\u2032) =  k \u2237 displayList s\u2032 m\n\n\ndisplayCollatz : \u2115 \u2192 \u2115 \u2192 List \u2115\ndisplayCollatz n m = displayList (collatzSequence n) m\n", "meta": {"hexsha": "6da90d2653fa6b7e8e9b103ea3be79826f242a21", "size": 713, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/examplesPaperJFP/Collatz.agda", "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_issues_repo_path": "examples/examplesPaperJFP/Collatz.agda", "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/examplesPaperJFP/Collatz.agda", "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "avg_line_length": 23.7666666667, "max_line_length": 54, "alphanum_fraction": 0.6479663394, "num_tokens": 226, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9579122756889438, "lm_q2_score": 0.7981867729389246, "lm_q1q2_score": 0.7645929080907395}}
{"text": "\nmodule Lib.Fin where\n\nopen import Lib.Nat\nopen import Lib.Bool\nopen import Lib.Id\n\ndata Fin : Nat -> Set where\n  zero : {n : Nat} -> Fin (suc n)\n  suc  : {n : Nat} -> Fin n -> Fin (suc n)\n\nfromNat : (n : Nat) -> Fin (suc n)\nfromNat zero    = zero\nfromNat (suc n) = suc (fromNat n)\n\ntoNat : {n : Nat} -> Fin n -> Nat\ntoNat zero    = zero\ntoNat (suc n) = suc (toNat n)\n\nweaken : {n : Nat} -> Fin n -> Fin (suc n)\nweaken zero    = zero\nweaken (suc n) = suc (weaken n)\n\nlem-toNat-weaken : forall {n} (i : Fin n) -> toNat i \u2261 toNat (weaken i)\nlem-toNat-weaken zero    = refl\nlem-toNat-weaken (suc i) with toNat i | lem-toNat-weaken i\n... | .(toNat (weaken i)) | refl = refl\n\nlem-toNat-fromNat : (n : Nat) -> toNat (fromNat n) \u2261 n\nlem-toNat-fromNat zero = refl\nlem-toNat-fromNat (suc n) with toNat (fromNat n) | lem-toNat-fromNat n\n... | .n | refl = refl\n\nfinEq : {n : Nat} -> Fin n -> Fin n -> Bool\nfinEq  zero    zero   = true\nfinEq  zero   (suc _) = false\nfinEq (suc _)  zero   = false\nfinEq (suc i) (suc j) = finEq i j\n\n-- A view telling you if a given element is the maximal one.\ndata MaxView {n : Nat} : Fin (suc n) -> Set where\n  theMax : MaxView (fromNat n)\n  notMax : (i : Fin n) -> MaxView (weaken i)\n\nmaxView : {n : Nat}(i : Fin (suc n)) -> MaxView i\nmaxView {zero} zero = theMax\nmaxView {zero} (suc ())\nmaxView {suc n} zero = notMax zero\nmaxView {suc n} (suc i) with maxView i\nmaxView {suc n} (suc .(fromNat n)) | theMax   = theMax\nmaxView {suc n} (suc .(weaken i))  | notMax i = notMax (suc i)\n\n-- The non zero view\n\ndata NonEmptyView : {n : Nat} -> Fin n -> Set where\n  ne : {n : Nat}{i : Fin (suc n)} -> NonEmptyView i\n\nnonEmpty : {n : Nat}(i : Fin n) -> NonEmptyView i\nnonEmpty zero    = ne\nnonEmpty (suc _) = ne\n\n-- The thinning view\n\nthin : {n : Nat} -> Fin (suc n) -> Fin n -> Fin (suc n)\nthin zero    j       = suc j\nthin (suc i) zero    = zero\nthin (suc i) (suc j) = suc (thin i j)\n\ndata EqView : {n : Nat} -> Fin n -> Fin n -> Set where\n  equal    : {n : Nat}{i : Fin n} -> EqView i i\n  notequal : {n : Nat}{i : Fin (suc n)}(j : Fin n) -> EqView i (thin i j)\n\ncompare : {n : Nat}(i j : Fin n) -> EqView i j\ncompare zero    zero    = equal\ncompare zero    (suc j) = notequal j\ncompare (suc i) zero    with nonEmpty i\n...                | ne = notequal zero\ncompare (suc i) (suc j) with compare i j\ncompare (suc i) (suc .i)          | equal      = equal\ncompare (suc i) (suc .(thin i j)) | notequal j = notequal (suc j)", "meta": {"hexsha": "f83c36e385fd814f198e8aa1b4fdac6f15255b7e", "size": 2434, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/simple-lib/Lib/Fin.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.425, "max_line_length": 73, "alphanum_fraction": 0.5903861956, "num_tokens": 916, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026618464796, "lm_q2_score": 0.8333246015211008, "lm_q1q2_score": 0.7644108751574626}}
{"text": "module Bin-embedding where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; sym; cong)\nopen Eq.\u2261-Reasoning\nopen import Data.Nat using (\u2115; zero; suc; _+_; _*_)\nopen import Data.Nat.Properties using (+-identity\u02b3; +-suc; +-comm; +-assoc)\n\nopen import Isomorphism using (_\u2272_)\n\n-- 2\u9032\u6570\u306e\u8868\u73fe\ndata Bin : Set where\n  \u27e8\u27e9 : Bin\n  _O : Bin \u2192 Bin\n  _I : Bin \u2192 Bin\n\n-- 2\u9032\u6570\u306e\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\ninc : Bin \u2192 Bin\ninc \u27e8\u27e9    = \u27e8\u27e9 I\ninc (b O) = b I\ninc (b I) = inc b O\n\n-- \u81ea\u7136\u6570\u304b\u30892\u9032\u6570\u3078\u306e\u5909\u63db\nto : \u2115 \u2192 Bin\nto zero    = \u27e8\u27e9 O\nto (suc n) = inc (to n)\n\n-- 2\u9032\u6570\u304b\u3089\u81ea\u7136\u6570\u3078\u306e\u5909\u63db\nfrom : Bin \u2192 \u2115\nfrom \u27e8\u27e9    = zero\nfrom (b O) = 2 * (from b)\nfrom (b I) = 2 * (from b) + 1\n\n2*n\u2261n+n : \u2200 (n : \u2115) \u2192 2 * n \u2261 n + n\n2*n\u2261n+n n rewrite +-identity\u02b3 n = refl\n\n+-suc-suc : \u2200 (m n : \u2115) \u2192 (suc m) + (suc n) \u2261 suc (suc (m + n))\n+-suc-suc m n rewrite +-suc (suc m) n | +-assoc 1 m n = refl\n\nfrom\u2218inc\u2261suc\u2218from : \u2200 (b : Bin) \u2192 from (inc b) \u2261 suc (from b)\nfrom\u2218inc\u2261suc\u2218from \u27e8\u27e9 = refl\nfrom\u2218inc\u2261suc\u2218from (b O) rewrite +-suc (from (b O)) zero = cong suc (+-identity\u02b3 (from (b O)))\nfrom\u2218inc\u2261suc\u2218from (b I) rewrite from\u2218inc\u2261suc\u2218from b | 2*n\u2261n+n (suc (from b)) | +-suc-suc (from b) (from b) | sym (2*n\u2261n+n (from b)) | +-comm 1 (2 * (from b)) = refl\n\nfrom\u2218to : \u2200 (n : \u2115) \u2192 from (to n) \u2261 n\nfrom\u2218to zero = refl\nfrom\u2218to (suc n) rewrite from\u2218inc\u2261suc\u2218from (to n) = cong suc (from\u2218to n)\n\nBin-embedding : \u2115 \u2272 Bin\nBin-embedding =\n  record\n    { to      = to\n    ; from    = from\n    ; from\u2218to = from\u2218to\n    }\n", "meta": {"hexsha": "e5195f878bbe794f7eb5c069f95b0ddc63684adf", "size": 1444, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/isomorphism/Bin-embedding.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/isomorphism/Bin-embedding.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/isomorphism/Bin-embedding.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.7857142857, "max_line_length": 164, "alphanum_fraction": 0.5734072022, "num_tokens": 664, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009549929797, "lm_q2_score": 0.8354835411997897, "lm_q1q2_score": 0.7643846897246042}}
{"text": "module Data.Boolean.Operators where\n\nopen import Data.Boolean\n\n-- Definition of boolean operators with conventions from logic\nmodule Logic where\n  infixl 1005 _\u2227_\n  infixl 1004 _\u2228_ _\u2295_\n  infixl 1003 _\u27f5_ _\u27f7_ _\u27f6_\n\n  _\u2227_ : Bool \u2192 Bool \u2192 Bool\n  _\u2227_ \ud835\udc47 \ud835\udc47 = \ud835\udc47\n  _\u2227_ \ud835\udc39 \ud835\udc47 = \ud835\udc39\n  _\u2227_ \ud835\udc47 \ud835\udc39 = \ud835\udc39\n  _\u2227_ \ud835\udc39 \ud835\udc39 = \ud835\udc39\n\n  _\u2228_ : Bool \u2192 Bool \u2192 Bool\n  _\u2228_ \ud835\udc47 \ud835\udc47 = \ud835\udc47\n  _\u2228_ \ud835\udc39 \ud835\udc47 = \ud835\udc47\n  _\u2228_ \ud835\udc47 \ud835\udc39 = \ud835\udc47\n  _\u2228_ \ud835\udc39 \ud835\udc39 = \ud835\udc39\n\n  open Data.Boolean using () renaming (not to \u00ac) public\n\n  _\u2295_ : Bool \u2192 Bool \u2192 Bool\n  _\u2295_ \ud835\udc47 \ud835\udc47 = \ud835\udc39\n  _\u2295_ \ud835\udc39 \ud835\udc47 = \ud835\udc47\n  _\u2295_ \ud835\udc47 \ud835\udc39 = \ud835\udc47\n  _\u2295_ \ud835\udc39 \ud835\udc39 = \ud835\udc39\n\n  _\u27f6_ : Bool \u2192 Bool \u2192 Bool\n  _\u27f6_ \ud835\udc47 \ud835\udc47 = \ud835\udc47\n  _\u27f6_ \ud835\udc39 \ud835\udc47 = \ud835\udc47\n  _\u27f6_ \ud835\udc47 \ud835\udc39 = \ud835\udc39\n  _\u27f6_ \ud835\udc39 \ud835\udc39 = \ud835\udc47\n\n  _\u27f5_ : Bool \u2192 Bool \u2192 Bool\n  _\u27f5_ \ud835\udc47 \ud835\udc47 = \ud835\udc47\n  _\u27f5_ \ud835\udc39 \ud835\udc47 = \ud835\udc39\n  _\u27f5_ \ud835\udc47 \ud835\udc39 = \ud835\udc47\n  _\u27f5_ \ud835\udc39 \ud835\udc39 = \ud835\udc47\n\n  _\u27f7_ : Bool \u2192 Bool \u2192 Bool\n  _\u27f7_ \ud835\udc47 \ud835\udc47 = \ud835\udc47\n  _\u27f7_ \ud835\udc39 \ud835\udc47 = \ud835\udc39\n  _\u27f7_ \ud835\udc47 \ud835\udc39 = \ud835\udc39\n  _\u27f7_ \ud835\udc39 \ud835\udc39 = \ud835\udc47\n\n  _\u22bc_ : Bool \u2192 Bool \u2192 Bool\n  _\u22bc_ \ud835\udc47 \ud835\udc47 = \ud835\udc39\n  _\u22bc_ \ud835\udc39 \ud835\udc47 = \ud835\udc47\n  _\u22bc_ \ud835\udc47 \ud835\udc39 = \ud835\udc47\n  _\u22bc_ \ud835\udc39 \ud835\udc39 = \ud835\udc47\n\n  _\u22bd_ : Bool \u2192 Bool \u2192 Bool\n  _\u22bd_ \ud835\udc47 \ud835\udc47 = \ud835\udc39\n  _\u22bd_ \ud835\udc39 \ud835\udc47 = \ud835\udc39\n  _\u22bd_ \ud835\udc47 \ud835\udc39 = \ud835\udc39\n  _\u22bd_ \ud835\udc39 \ud835\udc39 = \ud835\udc47\n\n  \u22a4 : Bool\n  \u22a4 = \ud835\udc47\n\n  \u22a5 : Bool\n  \u22a5 = \ud835\udc39\n\n-- Definition of boolean operators with conventions from typical programming languages\nmodule Programming where\n  open Logic using () renaming\n    (_\u2227_  to _&&_\n    ; _\u2228_ to _||_\n    ; \u00ac   to !\n    ; _\u27f7_ to _==_\n    ; _\u2295_ to _!=_\n    ; _\u27f6_ to _\u2192?_\n    ; _\u27f5_ to _\u2190?_\n    ) public\n", "meta": {"hexsha": "62c22c1d2c85604ba4e8a14b2ff5367e192da084", "size": 1260, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/Boolean/Operators.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/Boolean/Operators.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/Boolean/Operators.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.1538461538, "max_line_length": 86, "alphanum_fraction": 0.5119047619, "num_tokens": 830, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9458012701768145, "lm_q2_score": 0.8080672112416737, "lm_q1q2_score": 0.7642709947806112}}
{"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.topology.loopspace where\n\nopen import hott.core\nopen import hott.types\nopen import hott.functions\n\n\n-- The pointed loop space\n\n\u03a9\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113\n\u03a9\u2219 (A , a) = (a \u2261 a , refl)\n\n-- The loops space. It is obtained by suppressing the base point of\n-- the corresponding pointed loop space.\n\u03a9 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113\n\u03a9 = space \u2218 \u03a9\u2219\n\n--\n\n-- The iterated pointed loop space\n\n\u03a9\u0302\u2219 : \u2200{\u2113}  \u2192 \u2115 \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113\n\u03a9\u0302\u2219 = iterate \u03a9\u2219\n\n\n-- The iterated loop space. It is obtained by suppressing the base\n-- point of the iterated pointed loop space.\n\n\u03a9\u0302 : \u2200{\u2113}  \u2192 \u2115 \u2192 Type\u25cf \u2113 \u2192 Type \u2113\n\u03a9\u0302 n = space \u2218 \u03a9\u0302\u2219 n\n\n-- Some short hands\n\n\n\u03a9\u00b2\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u00b2\u2219 = \u03a9\u0302\u2219 2\n\u03a9\u00b3\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u00b3\u2219 = \u03a9\u0302\u2219 3\n\u03a9\u2074\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u2074\u2219 = \u03a9\u0302\u2219 4\n\u03a9\u2075\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u2075\u2219 = \u03a9\u0302\u2219 5\n\u03a9\u2076\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u2076\u2219 = \u03a9\u0302\u2219 6\n\u03a9\u2077\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u2077\u2219 = \u03a9\u0302\u2219 7\n\u03a9\u2078\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u2078\u2219 = \u03a9\u0302\u2219 8\n\u03a9\u2079\u2219 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type\u25cf \u2113; \u03a9\u2079\u2219 = \u03a9\u0302\u2219 9\n\n\n\u03a9\u00b2 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u00b2 = \u03a9\u0302 2\n\u03a9\u00b3 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u00b3 = \u03a9\u0302 3\n\u03a9\u2074 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u2074 = \u03a9\u0302 4\n\u03a9\u2075 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u2075 = \u03a9\u0302 5\n\u03a9\u2076 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u2076 = \u03a9\u0302 6\n\u03a9\u2077 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u2077 = \u03a9\u0302 7\n\u03a9\u2078 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u2078 = \u03a9\u0302 8\n\u03a9\u2079 : \u2200{\u2113} \u2192 Type\u25cf \u2113 \u2192 Type \u2113; \u03a9\u2079 = \u03a9\u0302 9\n", "meta": {"hexsha": "a91421817c975e3091319a1cf787a1158afd98f4", "size": 1340, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/topology/loopspace.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/topology/loopspace.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/topology/loopspace.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.3636363636, "max_line_length": 67, "alphanum_fraction": 0.5171641791, "num_tokens": 804, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9294404096760996, "lm_q2_score": 0.8221891348788759, "lm_q1q2_score": 0.7641758063530604}}
{"text": "module CS410-Prelude where\n\nopen import Agda.Primitive\n\n\n----------------------------------------------------------------------------\n-- Zero -- the empty type (logically, a false proposition)\n----------------------------------------------------------------------------\n\ndata Zero : Set where\n\nmagic : forall {l}{A : Set l} -> Zero -> A\nmagic ()\n\n\n----------------------------------------------------------------------------\n-- One -- the type with one value (logically, a true proposition)\n----------------------------------------------------------------------------\n\nrecord One : Set where\n  constructor <>\nopen One public\n{-# COMPILED_DATA One () () #-}\n\n----------------------------------------------------------------------------\n-- Two -- the type of Boolean values\n----------------------------------------------------------------------------\n\ndata Two : Set where tt ff : Two\n{-# BUILTIN BOOL Two #-}\n{-# BUILTIN TRUE tt #-}\n{-# BUILTIN FALSE ff #-}\n{-# COMPILED_DATA Two Bool True False #-}\n\n-- nondependent conditional with traditional syntax\nif_then_else_ : {l : Level}{X : Set l} -> Two -> X -> X -> X\nif tt then t else e = t\nif ff then t else e = e\n\n-- dependent conditional cooked for partial application\ncaseTwo : forall {l}{P : Two -> Set l} -> P tt -> P ff -> (b : Two) -> P b\ncaseTwo t f tt = t\ncaseTwo t f ff = f\n\n\n----------------------------------------------------------------------------\n-- \"Sigma\" -- the type of dependent pairs, giving binary products and sums\n----------------------------------------------------------------------------\n\nrecord Sg {l : Level}(S : Set l)(T : S -> Set l) : Set l where\n  constructor _,_\n  field\n    fst : S\n    snd : T fst\nopen Sg public\n_*_ : {l : Level} -> Set l -> Set l -> Set l\nS * T = Sg S \\ _ -> T\ninfixr 4 _,_ _*_\n\n_+_ : Set -> Set -> Set\nS + T = Sg Two (caseTwo S T)\n\npattern inl s = tt , s\npattern inr t = ff , t\n\n\n----------------------------------------------------------------------------\n-- \"Equality\" -- the type of evidence that things are the same\n----------------------------------------------------------------------------\n\ndata _==_ {l}{X : Set l}(x : X) : X -> Set l where\n  refl : x == x\ninfix 1 _==_\n{-# BUILTIN EQUALITY _==_ #-}\n{-# BUILTIN REFL refl #-}\n\nsym : forall {l}{X : Set l}{x y : X} -> x == y -> y == x\nsym refl = refl\n\n-- this proof principle is useful for proving laws, don't use it for\n-- fixing type problems in your programs\n\npostulate ext : forall {l m}{A : Set l}{B : Set m}{f g : A -> B} ->\n            (forall a -> f a == g a) -> f == g\n\n----------------------------------------------------------------------------\n-- functional plumbing\n----------------------------------------------------------------------------\n\nid : forall {l}{X : Set l} -> X -> X\nid x = x\n\n-- the type of composition can be generalized further\n_o_ : forall {l}{X Y Z : Set l} -> (Y -> Z) -> (X -> Y) -> X -> Z\n(f o g) x = f (g x)\n\n_$_ : forall{l}{X Y : Set l} -> (X -> Y) -> X -> Y\nf $ x = f x\n\n\n----------------------------------------------------------------------------\n-- lists\n----------------------------------------------------------------------------\n\ndata List (X : Set) : Set where  -- X scopes over the whole declaration...\n  []    : List X                 -- ...so you can use it here...\n  _::_  : X -> List X -> List X  -- ...and here.\ninfixr 3 _::_\n{-# COMPILED_DATA List [] [] (:) #-}\n{-# BUILTIN LIST List #-}\n{-# BUILTIN NIL [] #-}\n{-# BUILTIN CONS _::_ #-}\n\n----------------------------------------------------------------------------\n-- chars and strings\n----------------------------------------------------------------------------\n\npostulate       -- this means that we just suppose the following things exist...\n  Char : Set\n  String : Set\n{-# BUILTIN CHAR Char #-}\n{-# COMPILED_TYPE Char Char #-}      -- ...and by the time we reach Haskell...\n{-# BUILTIN STRING String #-}\n{-# COMPILED_TYPE String String #-}  -- ...they *do* exist!\n\nprimitive       -- these are baked in; they even work!\n  primCharEquality    : Char -> Char -> Two\n  primStringAppend    : String -> String -> String\n  primStringToList    : String -> List Char\n  primStringFromList  : List Char -> String\n\n\n---------------------------------------------------------------------------\n-- COLOURS\n---------------------------------------------------------------------------\n\n-- We're going to be making displays from coloured text.\n\ndata Colour : Set where\n  black red green yellow blue magenta cyan white : Colour\n{-# COMPILED_DATA Colour HaskellSetup.Colour\n      HaskellSetup.Black HaskellSetup.Red HaskellSetup.Green\n      HaskellSetup.Yellow HaskellSetup.Blue HaskellSetup.Magenta\n      HaskellSetup.Cyan HaskellSetup.White #-}\n\n", "meta": {"hexsha": "5bcbb52a32d28e4dde3a1e4470b1509c008ae967", "size": 4693, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/CS410-Prelude.agda", "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "notes/CS410-Prelude.agda", "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "notes/CS410-Prelude.agda", "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1438356164, "max_line_length": 80, "alphanum_fraction": 0.4278712977, "num_tokens": 1005, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951643678381, "lm_q2_score": 0.817574478416099, "lm_q1q2_score": 0.7639376391425603}}
{"text": "module Data.Nat.Literal where\n\nopen import Data.Nat using (\u2115; suc; zero)\nopen import Data.Fin using (Fin; suc; zero)\nopen import Data.Unit using (\u22a4)\nopen import Data.Empty using (\u22a5)\nopen import Agda.Builtin.FromNat using (Number; fromNat) public\n\n_\u2264_ : \u2115 \u2192 \u2115 \u2192 Set\nzero  \u2264 n     = \u22a4\nsuc m \u2264 zero  = \u22a5\nsuc m \u2264 suc n = m \u2264 n\n\ninstance\n  \u2115-num : Number \u2115\n  \u2115-num .Number.Constraint _ = \u22a4\n  \u2115-num .Number.fromNat n = n\n\ninstance\n  Fin-num : {n : \u2115} \u2192 Number (Fin (suc n))\n  Fin-num {n} .Number.Constraint m = m \u2264 n\n  Fin-num {n} .Number.fromNat m \u2983 p \u2984 = from m n p where\n    from : (m n : \u2115) \u2192 m \u2264 n \u2192 Fin (suc n)\n    from zero _ _ = zero\n    from (suc _) zero ()\n    from (suc m) (suc n) p = suc (from m n p)\n", "meta": {"hexsha": "df010b3202fe630f912cd06312b3416397d508af", "size": 707, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "formalization/Data/Nat/Literal.agda", "max_stars_repo_name": "brunoczim/Celeste", "max_stars_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-16T17:31:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-16T17:31:57.000Z", "max_issues_repo_path": "formalization/Data/Nat/Literal.agda", "max_issues_repo_name": "brunoczim/Celeste", "max_issues_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "formalization/Data/Nat/Literal.agda", "max_forks_repo_name": "brunoczim/Celeste", "max_forks_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.1851851852, "max_line_length": 63, "alphanum_fraction": 0.6067892504, "num_tokens": 261, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9343951661947456, "lm_q2_score": 0.8175744695262775, "lm_q1q2_score": 0.7639376323295871}}
{"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule SelectSort.Correctness.Order  {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_)\n                  (trans\u2264 : Transitive _\u2264_)  where\n\nopen import Data.List\nopen import Data.Product\nopen import Data.Sum\nopen import Function using (_\u2218_)\nopen import List.Sorted _\u2264_\nopen import Order.Total _\u2264_ tot\u2264\nopen import Size\nopen import SList\nopen import SList.Order _\u2264_\nopen import SList.Order.Properties _\u2264_\nopen import SelectSort _\u2264_ tot\u2264\n\nlemma-select-\u2264 : {\u03b9 : Size}(x : A) \u2192 (xs : SList A {\u03b9}) \u2192 proj\u2081 (select x xs) \u2264 x\nlemma-select-\u2264 x snil = refl\u2264\nlemma-select-\u2264 x (y \u2219 ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = lemma-select-\u2264 x ys\n... | inj\u2082 y\u2264x = trans\u2264 (lemma-select-\u2264 y ys) y\u2264x\n\nlemma-select-*\u2264 : {\u03b9 : Size}(x : A) \u2192 (xs : SList A {\u03b9}) \u2192 proj\u2081 (select x xs) *\u2264 proj\u2082 (select x xs)\nlemma-select-*\u2264 x snil = genx\nlemma-select-*\u2264 x (y \u2219 ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = gecx (trans\u2264 (lemma-select-\u2264 x ys) x\u2264y) (lemma-select-*\u2264 x ys)\n... | inj\u2082 y\u2264x = gecx (trans\u2264 (lemma-select-\u2264 y ys) y\u2264x) (lemma-select-*\u2264 y ys)\n\nlemma-select-\u2264-*\u2264 : {\u03b9 : Size}{b x : A}{xs : SList A {\u03b9}} \u2192 b \u2264 x \u2192 b *\u2264 xs \u2192 b \u2264 proj\u2081 (select x xs) \u00d7 b *\u2264 proj\u2082 (select x xs) \nlemma-select-\u2264-*\u2264 b\u2264x genx = b\u2264x , genx\nlemma-select-\u2264-*\u2264 {x = x} b\u2264x (gecx {x = y} b\u2264y b*\u2264ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = proj\u2081 (lemma-select-\u2264-*\u2264 b\u2264x b*\u2264ys) , gecx (trans\u2264 b\u2264x x\u2264y) (proj\u2082 (lemma-select-\u2264-*\u2264 b\u2264x b*\u2264ys))\n... | inj\u2082 y\u2264x = proj\u2081 (lemma-select-\u2264-*\u2264 b\u2264y b*\u2264ys) , gecx (trans\u2264 b\u2264y y\u2264x) (proj\u2082 (lemma-select-\u2264-*\u2264 b\u2264y b*\u2264ys))\n\nlemma-selectSort-*\u2264 : {\u03b9 : Size}{x : A}{xs : SList A {\u03b9}} \u2192 x *\u2264 xs \u2192 x *\u2264 selectSort xs\nlemma-selectSort-*\u2264 genx = genx\nlemma-selectSort-*\u2264 (gecx x\u2264y x*\u2264ys) \n    with lemma-select-\u2264-*\u2264 x\u2264y x*\u2264ys\n... | (x\u2264z , x*\u2264zs) = gecx x\u2264z (lemma-selectSort-*\u2264 x*\u2264zs)\n\nlemma-selectSort-sorted : {\u03b9 : Size}(xs : SList A {\u03b9}) \u2192 Sorted (unsize A (selectSort xs))\nlemma-selectSort-sorted snil = nils\nlemma-selectSort-sorted (x \u2219 xs) = lemma-slist-sorted (lemma-selectSort-*\u2264 (lemma-select-*\u2264 x xs)) (lemma-selectSort-sorted (proj\u2082 (select x xs)))\n\ntheorem-selectSort-sorted : (xs : List A) \u2192 Sorted (unsize A (selectSort (size A xs)))\ntheorem-selectSort-sorted = lemma-selectSort-sorted \u2218 (size A)\n\n", "meta": {"hexsha": "897f934286bcc1798b6dcad213ab108d62a7cc0f", "size": 2276, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SelectSort/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SelectSort/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SelectSort/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.3818181818, "max_line_length": 146, "alphanum_fraction": 0.6001757469, "num_tokens": 932, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422172230208, "lm_q2_score": 0.8031737892899222, "lm_q1q2_score": 0.763932498760632}}
{"text": "module Numeral.Natural.Oper.Comparisons where\n\nimport      Lvl\nopen import Data.Boolean\nimport      Data.Boolean.Operators\nopen        Data.Boolean.Operators.Programming\nopen import Numeral.Natural\nopen import Numeral.Sign\n\n\u2115bool : Bool \u2192 \u2115\n\u2115bool = if_then 1 else 0\n\n-- Compare\n_\u22da?_ : \u2115 \u2192 \u2115 \u2192 (\u2212|0|+)\n\ud835\udfce    \u22da? \ud835\udfce    = \ud835\udfce\n\ud835\udfce    \u22da? \ud835\udc12(b) = \u2796\n\ud835\udc12(a) \u22da? \ud835\udfce    = \u2795\n\ud835\udc12(a) \u22da? \ud835\udc12(b) = a \u22da? b\n\n-- Equality check\n_\u2261?_ : \u2115 \u2192 \u2115 \u2192 Bool\na \u2261? b = elim\u2083 \ud835\udc39 \ud835\udc47 \ud835\udc39 (a \u22da? b)\n{-# BUILTIN NATEQUALS _\u2261?_ #-}\n\n-- Non-equality check\n_\u2262?_ : \u2115 \u2192 \u2115 \u2192 Bool\nx \u2262? y = !(x \u2261? y)\n\n-- Positivity check\npositive? : \u2115 \u2192 Bool\npositive? (\ud835\udfce)    = \ud835\udc39\npositive? (\ud835\udc12(_)) = \ud835\udc47\n\n-- Zero check\nzero? : \u2115 \u2192 Bool\nzero? n = !(positive? n)\n\n-- Lesser-than check\n_<?_ : \u2115 \u2192 \u2115 \u2192 Bool\n_    <? \ud835\udfce    = \ud835\udc39\n\ud835\udfce    <? \ud835\udc12(_) = \ud835\udc47\n\ud835\udc12(x) <? \ud835\udc12(y) = (x <? y)\n{-# BUILTIN NATLESS _<?_ #-}\n\n-- Lesser-than or equals check\n_\u2264?_ : \u2115 \u2192 \u2115 \u2192 Bool\nx \u2264? y = x <? \ud835\udc12(y)\n\n-- Greater-than check\n_>?_ : \u2115 \u2192 \u2115 \u2192 Bool\nx >? y = y <? x\n\n-- Greater-than or equals check\n_\u2265?_ : \u2115 \u2192 \u2115 \u2192 Bool\nx \u2265? y = y \u2264? x\n", "meta": {"hexsha": "1b37b597b4ab15bf65213df7b0ef5089995655eb", "size": 1005, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/Comparisons.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/Comparisons.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/Comparisons.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.9464285714, "max_line_length": 46, "alphanum_fraction": 0.5402985075, "num_tokens": 463, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9425067195846918, "lm_q2_score": 0.8104789063814616, "lm_q1q2_score": 0.7638818153461798}}
{"text": "module LearnYouAn2 where\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n\nzero + n     = n\n(suc n) + n\u2032 = suc (n + n\u2032)\n\n\ndata _even : \u2115 \u2192 Set where\n  ZERO : zero even\n  STEP : \u2200 x \u2192 x even \u2192 (suc (suc x)) even\n\n\n-- To prove four is even\nproof\u2081 : suc (suc (suc (suc zero))) even\nproof\u2081 = STEP (suc (suc zero)) (STEP zero ZERO)\n\nproof\u2082\u2032 : (A : Set) \u2192 A \u2192 A\nproof\u2082\u2032 _ a = a\n\nproof\u2082 : \u2115 \u2192 \u2115\nproof\u2082 = proof\u2082\u2032 \u2115\n", "meta": {"hexsha": "eb970e92d23f52ae1e76844d9a677dc85401d545", "size": 421, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "learyouanagda/LearnYouAn2.agda", "max_stars_repo_name": "shouya/thinking-dumps", "max_stars_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 24, "max_stars_repo_stars_event_min_datetime": "2015-02-14T17:18:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-09T01:02:15.000Z", "max_issues_repo_path": "learyouanagda/LearnYouAn2.agda", "max_issues_repo_name": "shouya/thinking-dumps", "max_issues_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-06-14T06:07:33.000Z", "max_issues_repo_issues_event_max_datetime": "2015-08-04T22:05:11.000Z", "max_forks_repo_path": "learyouanagda/LearnYouAn2.agda", "max_forks_repo_name": "shouya/thinking-dumps", "max_forks_repo_head_hexsha": "a6fc111e02dc631f56302bb059d855446792bebc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2015-12-02T02:10:26.000Z", "max_forks_repo_forks_event_max_datetime": "2017-06-03T06:32:26.000Z", "avg_line_length": 15.5925925926, "max_line_length": 47, "alphanum_fraction": 0.5558194774, "num_tokens": 169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.953966101527047, "lm_q2_score": 0.8006920044739461, "lm_q1q2_score": 0.7638330300318872}}
{"text": "\nmodule Nat where\n\n  data Nat : Set where\n    zero : Nat\n    suc  : Nat -> Nat\n\n  one : Nat\n  one = suc zero\n", "meta": {"hexsha": "d6fd5231615618318dddfb684c8f146647b1e99a", "size": 109, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "tests/covered/Nat.agda", "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_issues_repo_path": "tests/covered/Nat.agda", "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/covered/Nat.agda", "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 10.9, "max_line_length": 22, "alphanum_fraction": 0.5596330275, "num_tokens": 36, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.953966101527047, "lm_q2_score": 0.800691997339971, "lm_q1q2_score": 0.7638330232263167}}
{"text": "{-# OPTIONS --without-K #-}\n\nmodule hott.types.coproduct where\n\nopen import hott.core.universe\n\ndata _\u2210_ {\u2113\u2080 \u2113\u2081 : Level}\n         (A : Type \u2113\u2080)\n         (B : Type \u2113\u2081) : Type (\u2113\u2080 \u2294 \u2113\u2081)  where\n\n     inl : (a : A) \u2192 A \u2210 B -- left  introduction\n     inr : (b : B) \u2192 A \u2210 B -- right introduction\n\n-- A more suggestive way of building elements of nested co-product\n-- types. For example if we have a : A, b : B and c : C then the\n-- expressions, a \u2223\u2219, \u2219\u2223 b \u2223\u2219 and \u2219\u2223 \u2219\u2223 c are elements inl a, inr (inl\n-- b) and inr (inr c) of A \u2210 B \u2210 C respectively.\n\n_\u2223\u2219 : {\u2113\u2080 \u2113\u2081 : Level}{A : Type \u2113\u2080}{B : Type \u2113\u2081}\n    \u2192 A \u2192 A \u2210 B\n_\u2223\u2219 = inl\n\n\u2219\u2223_ : {\u2113\u2080 \u2113\u2081 : Level}{A : Type \u2113\u2080}{B : Type \u2113\u2081}\n   \u2192 B \u2192 A \u2210 B\n\u2219\u2223_ = inr\n\ninfixr 0 \u2219\u2223_\ninfixr 0 _\u2223\u2219\n\n-- A more suggestive way of building a case by case analysis.\n-- For example, one can just write f1 \u2223 f2 \u2223 f3\n_\u2223_ : {a b c : Level}\n      {A : Type a}\n      {B : Type b}\n      {C : Type c}\n    \u2192 (A \u2192 C)\n    \u2192 (B \u2192 C)\n    \u2192 (A \u2210 B \u2192 C)\n\n(f \u2223 g) (inl a) = f a\n(f \u2223 g) (inr b) = g b\n\ninfixr 0 _\u2210_\ninfixr 0 _\u2223_\n\n\n-- Case by case analysis.\neither : {\u2113\u2080 \u2113\u2081 \u2113\u2083 : Level}\n         {A : Type \u2113\u2080}{B : Type \u2113\u2081}{C : Type \u2113\u2083}\n       \u2192 (A \u2192 C) \u2192 (B \u2192 C) \u2192 (A \u2210 B \u2192 C)\neither f g (inl a) = f a\neither f g (inr b) = g b\n", "meta": {"hexsha": "392ccdff6016bc66ec0028558d639ef55de62c9d", "size": 1223, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/hott/types/coproduct.agda", "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/hott/types/coproduct.agda", "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/hott/types/coproduct.agda", "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0754716981, "max_line_length": 70, "alphanum_fraction": 0.517579722, "num_tokens": 547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297887874625, "lm_q2_score": 0.8479677564567913, "lm_q1q2_score": 0.7636202246206127}}
{"text": "module BHeap {A : Set}(_\u2264_ : A \u2192 A \u2192 Set) where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _\u2264_\nopen import BTree {A} hiding (flatten)\nopen import Data.Nat hiding (_\u2264_)\nopen import Data.List\nopen import Data.Sum renaming (_\u228e_ to _\u2228_)\nopen import Relation.Binary\nopen import Relation.Binary.Core\nopen import Relation.Binary.PropositionalEquality hiding (trans)\n\nopen DecTotalOrder decTotalOrder hiding (refl ; _\u2264_)\n\ndata BHeap : Bound \u2192 Set where\n  lf : {b : Bound} \n                   \u2192 BHeap b\n  nd : {b : Bound}{x : A} \n                   \u2192 LeB b (val x) \n                   \u2192 (l r : BHeap (val x)) \n                   \u2192 BHeap b\n\nforget : {b : Bound} \u2192 BHeap b \u2192 BTree\nforget lf = leaf\nforget (nd {x = x} _ l r) = node x (forget l) (forget r)\n\n# : {b : Bound} \u2192 BHeap b \u2192 \u2115\n# lf = zero\n# (nd _ l r) = suc (# l + # r)\n\nheight : {b : Bound} \u2192 BHeap b \u2192 \u2115\nheight lf = zero\nheight (nd _ l r) \n    with total (height l) (height r) \n... | inj\u2081 hl\u2264hr = suc (height r)\n... | inj\u2082 hr\u2264hl = suc (height l)\n\nmerge : {b : Bound} \u2192 Total _\u2264_ \u2192 (l r : BHeap b) \u2192 BHeap b\nmerge _ lf r = r\nmerge _ l lf = l\nmerge tot\u2264 (nd {x = x} b\u2264x l r) (nd {x = x'} b\u2264x' l' r') \n    with tot\u2264 x x'\n... | inj\u2081 x\u2264x' = nd b\u2264x (merge tot\u2264 l r) (nd (lexy x\u2264x') l' r') \n... | inj\u2082 x'\u2264x = nd b\u2264x' (nd (lexy x'\u2264x) l r) (merge tot\u2264 l' r')\n\nflatten : {b : Bound}(h : BHeap b) \u2192 List A\nflatten lf = []\nflatten (nd {x = x} b\u2264x l r) = x \u2237 (flatten l ++ flatten r)\n\n", "meta": {"hexsha": "e66d700fbe4517caacb7a6a7f9180375cd0f0fa9", "size": 1436, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BHeap.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BHeap.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BHeap.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.72, "max_line_length": 65, "alphanum_fraction": 0.5619777159, "num_tokens": 537, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9449947148047777, "lm_q2_score": 0.8080672158638528, "lm_q1q2_score": 0.7636192481983523}}
{"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Some examples showing where the natural numbers and some related\n-- operations and properties are defined, and how they can be used\n------------------------------------------------------------------------\n\n{-# OPTIONS --without-K #-}\n\nmodule README.Data.Nat where\n\n-- The natural numbers and various arithmetic operations are defined\n-- in Data.Nat.\n\nopen import Data.Nat using (\u2115; _+_; _*_)\n\n-- _*_ has precedence 7 over precedence 6 of _+_\n-- precedence of both defined in module Agda.Builtin.Nat\nex\u2081 : \u2115\nex\u2081 = 1 + 3 * 4\n\n-- Propositional equality and some related properties can be found\n-- in Relation.Binary.PropositionalEquality.\n\nopen import Relation.Binary.PropositionalEquality using (_\u2261_; refl)\n\nex\u2082 : 3 + 5 \u2261 2 * 4\nex\u2082 = refl\n\n-- Data.Nat.Properties contains a number of properties about natural\n-- numbers.\n\nopen import Data.Nat.Properties using (*-comm; +-identity\u02b3)\n\nex\u2083 : \u2200 m n \u2192 m * n \u2261 n * m\nex\u2083 m n = *-comm m n\n\n-- The module \u2261-Reasoning in Relation.Binary.PropositionalEquality\n-- provides some combinators for equational reasoning.\n\nopen Relation.Binary.PropositionalEquality using (cong; module \u2261-Reasoning)\n\nex\u2084 : \u2200 m n \u2192 m * (n + 0) \u2261 n * m\nex\u2084 m n = begin\n  m * (n + 0)  \u2261\u27e8 cong (_*_ m) (+-identity\u02b3 n) \u27e9\n  m * n        \u2261\u27e8 *-comm m n \u27e9\n  n * m        \u220e\n  where open \u2261-Reasoning\n\n-- The module SemiringSolver in Data.Nat.Solver contains a solver\n-- for natural number equalities involving variables, constants, _+_\n-- and _*_.\n\nopen import Data.Nat.Solver using (module +-*-Solver)\nopen +-*-Solver using (solve; _:*_; _:+_; con; _:=_)\n\nex\u2085 : \u2200 m n \u2192 m * (n + 0) \u2261 n * m\nex\u2085 = solve 2 (\u03bb m n \u2192 m :* (n :+ con 0)  :=  n :* m) refl\n", "meta": {"hexsha": "60dbf266bfb4312a9d67dd67d76d1055ab9239cc", "size": 1761, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib/README/Data/Nat.agda", "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_issues_repo_path": "agda-stdlib/README/Data/Nat.agda", "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib/README/Data/Nat.agda", "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "avg_line_length": 29.8474576271, "max_line_length": 75, "alphanum_fraction": 0.617830778, "num_tokens": 510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.918480248488136, "lm_q2_score": 0.8311430520409023, "lm_q1q2_score": 0.7633884769677157}}
{"text": "module StalinSort where\n\n  import Relation.Binary.PropositionalEquality as Eq\n  open Eq using (_\u2261_; refl)\n  open import Data.Nat using (\u2115; _\u2264_; _\u2264?_)\n  open import Data.List using (List; _\u2237_; [])\n  open import Relation.Nullary using (Dec; yes; no)\n\n  -- Implementation of Stalin Sort\n  stalinSort : List \u2115 \u2192 List \u2115\n  stalinSort [] = []\n  stalinSort (x \u2237 []) = x \u2237 []\n  stalinSort (x \u2237 y \u2237 zs) with x \u2264? y\n  ...| yes m\u2264n = x \u2237 stalinSort (y \u2237 zs)\n  ...| no m\u2270n  = stalinSort (x \u2237 zs)\n\n  -- Example Test\n  _ : stalinSort (2 \u2237 3 \u2237 5 \u2237 4 \u2237 6 \u2237 []) \u2261 (2 \u2237 3 \u2237 5 \u2237 6 \u2237 [])\n  _ = refl\n\n  -------------------- Correctness of Stalin Sort -------------------------\n  {-\n     This section is only interesting for Logic and Formal Verification\n     enthusiasts. Although I tried to sketch the formal proof that\n     Stalin Sort always returns a Sorted List, there is a point in the proof\n     that I couldn't solve yet. I declared it as a postulate, so somebody can\n     try improving it by giving an lemma that remove the postulate and\n     finish the proof =D\n  -}\n\n  -- A proof that x is less than all values in xs (thanks to Twan van Laarhoven)\n  data _\u2264*_ (x : \u2115) : List \u2115 \u2192 Set where\n    []  : x \u2264* []\n    _\u2237_ : \u2200 {y ys} \u2192 (x \u2264 y) \u2192 y \u2264* ys \u2192 x \u2264* (y \u2237 ys)\n\n  -- Proof that a list is sorted (thanks to Twan van Laarhoven)\n  data SortedList : List \u2115 \u2192 Set where\n    []  : SortedList []\n    _\u2237_ : \u2200 {x xs} \u2192 x \u2264* xs \u2192 SortedList xs \u2192 SortedList (x \u2237 xs)\n\n  -- This is necessary to prove the correctness, I can't find a way yet ...\n  postulate\n    less-stalin : \u2200 (x y : \u2115) (zs : List \u2115) \u2192 x \u2264 y \u2192 x \u2264* stalinSort (y \u2237 zs)\n\n  -- Proof that Stalin Sort returns a sorted list\n  stalinSort-correctness : \u2200 (xs : List \u2115) \u2192 SortedList (stalinSort xs)\n  stalinSort-correctness [] = []\n  stalinSort-correctness (x \u2237 []) = [] \u2237 []\n  stalinSort-correctness (x \u2237 y \u2237 zs) with x \u2264? y\n  ...| yes m\u2264n = less-stalin x y zs m\u2264n \u2237 (stalinSort-correctness (y \u2237 zs))\n  ...| no m\u2270n  = stalinSort-correctness (x \u2237 zs)\n", "meta": {"hexsha": "f094536808f0584a228af71a650d5ee661372fcc", "size": 1989, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/StalinSort.agda", "max_stars_repo_name": "bluoxy/stalin-sort", "max_stars_repo_head_hexsha": "6098af3dbebdcbb8d23491a0be51775bddaee4a4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "agda/StalinSort.agda", "max_issues_repo_name": "bluoxy/stalin-sort", "max_issues_repo_head_hexsha": "6098af3dbebdcbb8d23491a0be51775bddaee4a4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/StalinSort.agda", "max_forks_repo_name": "bluoxy/stalin-sort", "max_forks_repo_head_hexsha": "6098af3dbebdcbb8d23491a0be51775bddaee4a4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.25, "max_line_length": 80, "alphanum_fraction": 0.5987933635, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802440252811, "lm_q2_score": 0.8311430541321951, "lm_q1q2_score": 0.763388475179256}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Functions.Lemmas\nopen import Agda.Primitive using (Level; lzero; lsuc; _\u2294_)\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Order\nopen import Numbers.Integers.Integers\nopen import Numbers.Rationals.Definition\nopen import Sets.FinSet.Definition\nopen import Sets.FinSet.Lemmas\nopen import Sets.Cardinality.Finite.Definition\nopen import Groups.Definition\nopen import Groups.Groups\nopen import Groups.Abelian.Definition\nopen import Groups.FiniteGroups.Definition\nopen import Rings.Definition\nopen import Numbers.Modulo.Group\nopen import Numbers.Modulo.Definition\nopen import Semirings.Definition\n\nmodule Groups.LectureNotes.Lecture1 where\n\n\u2124IsGroup : _\n\u2124IsGroup = \u2124Group\n\n\u211aIsGroup : _\n\u211aIsGroup = Ring.additiveGroup \u211aRing\n\n-- TODO: R is a group with +\n\nintegersMinusNotGroup : Group (reflSetoid \u2124) (_-Z_) \u2192 False\nintegersMinusNotGroup record { +WellDefined = wellDefined ; 0G = identity ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with multAssoc {nonneg 3} {nonneg 2} {nonneg 1}\nintegersMinusNotGroup record { +WellDefined = wellDefined ; 0G = identity ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | ()\n\nnegSuccInjective : {a b : \u2115} \u2192 (negSucc a \u2261 negSucc b) \u2192 a \u2261 b\nnegSuccInjective {a} {.a} refl = refl\n\nnonnegInjective : {a b : \u2115} \u2192 (nonneg a \u2261 nonneg b) \u2192 a \u2261 b\nnonnegInjective {a} {.a} refl = refl\n\nintegersTimesNotGroup : Group (reflSetoid \u2124) (_*Z_) \u2192 False\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg zero) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with multIdentLeft {negSucc 1}\n... | ()\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with invLeft {nonneg zero}\n... | bl with inverse (nonneg zero)\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | () | nonneg zero\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | p | nonneg (succ x) = naughtE (nonnegInjective (transitivity (applyEquality nonneg (equalityCommutative (Semiring.productZeroRight \u2115Semiring x))) p))\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ zero)) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | () | negSucc x\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (nonneg (succ (succ x))) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with succInjective (negSuccInjective (multIdentLeft {negSucc 1}))\n... | ()\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (negSucc x) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } with multIdentLeft {nonneg 2}\nintegersTimesNotGroup record { +WellDefined = wellDefined ; 0G = (negSucc x) ; inverse = inverse ; +Associative = multAssoc ; identRight = multIdentRight ; identLeft = multIdentLeft ; invLeft = invLeft ; invRight = invRight } | ()\n\n-- TODO: Q is not a group with *Q\n-- TODO: Q without 0 is a group with *Q\n-- TODO: {1, -1} is a group with *\n\n\u2124nIsGroup : (n : \u2115) \u2192 (0<n : 0 <N n) \u2192 _\n\u2124nIsGroup n pr = \u2124nGroup n pr\n\n-- Groups example 8.9 from lecture 1\ndata Weird : Set where\n  e : Weird\n  a : Weird\n  b : Weird\n  c : Weird\n\n_+W_ : Weird \u2192 Weird \u2192 Weird\ne +W t = t\na +W e = a\na +W a = e\na +W b = c\na +W c = b\nb +W e = b\nb +W a = c\nb +W b = e\nb +W c = a\nc +W e = c\nc +W a = b\nc +W b = a\nc +W c = e\n\n+WAssoc : {x y z : Weird} \u2192 (x +W (y +W z)) \u2261 (x +W y) +W z\n+WAssoc {e} {y} {z} = refl\n+WAssoc {a} {e} {z} = refl\n+WAssoc {a} {a} {e} = refl\n+WAssoc {a} {a} {a} = refl\n+WAssoc {a} {a} {b} = refl\n+WAssoc {a} {a} {c} = refl\n+WAssoc {a} {b} {e} = refl\n+WAssoc {a} {b} {a} = refl\n+WAssoc {a} {b} {b} = refl\n+WAssoc {a} {b} {c} = refl\n+WAssoc {a} {c} {e} = refl\n+WAssoc {a} {c} {a} = refl\n+WAssoc {a} {c} {b} = refl\n+WAssoc {a} {c} {c} = refl\n+WAssoc {b} {e} {z} = refl\n+WAssoc {b} {a} {e} = refl\n+WAssoc {b} {a} {a} = refl\n+WAssoc {b} {a} {b} = refl\n+WAssoc {b} {a} {c} = refl\n+WAssoc {b} {b} {e} = refl\n+WAssoc {b} {b} {a} = refl\n+WAssoc {b} {b} {b} = refl\n+WAssoc {b} {b} {c} = refl\n+WAssoc {b} {c} {e} = refl\n+WAssoc {b} {c} {a} = refl\n+WAssoc {b} {c} {b} = refl\n+WAssoc {b} {c} {c} = refl\n+WAssoc {c} {e} {z} = refl\n+WAssoc {c} {a} {e} = refl\n+WAssoc {c} {a} {a} = refl\n+WAssoc {c} {a} {b} = refl\n+WAssoc {c} {a} {c} = refl\n+WAssoc {c} {b} {e} = refl\n+WAssoc {c} {b} {a} = refl\n+WAssoc {c} {b} {b} = refl\n+WAssoc {c} {b} {c} = refl\n+WAssoc {c} {c} {e} = refl\n+WAssoc {c} {c} {a} = refl\n+WAssoc {c} {c} {b} = refl\n+WAssoc {c} {c} {c} = refl\n\nweirdGroup : Group (reflSetoid Weird) _+W_\nGroup.+WellDefined weirdGroup = reflGroupWellDefined\nGroup.0G weirdGroup = e\nGroup.inverse weirdGroup t = t\nGroup.+Associative weirdGroup {r} {s} {t} = +WAssoc {r} {s} {t}\nGroup.identRight weirdGroup {e} = refl\nGroup.identRight weirdGroup {a} = refl\nGroup.identRight weirdGroup {b} = refl\nGroup.identRight weirdGroup {c} = refl\nGroup.identLeft weirdGroup {e} = refl\nGroup.identLeft weirdGroup {a} = refl\nGroup.identLeft weirdGroup {b} = refl\nGroup.identLeft weirdGroup {c} = refl\nGroup.invLeft weirdGroup {e} = refl\nGroup.invLeft weirdGroup {a} = refl\nGroup.invLeft weirdGroup {b} = refl\nGroup.invLeft weirdGroup {c} = refl\nGroup.invRight weirdGroup {e} = refl\nGroup.invRight weirdGroup {a} = refl\nGroup.invRight weirdGroup {b} = refl\nGroup.invRight weirdGroup {c} = refl\n\nweirdAb : AbelianGroup weirdGroup\nAbelianGroup.commutative weirdAb {e} {e} = refl\nAbelianGroup.commutative weirdAb {e} {a} = refl\nAbelianGroup.commutative weirdAb {e} {b} = refl\nAbelianGroup.commutative weirdAb {e} {c} = refl\nAbelianGroup.commutative weirdAb {a} {e} = refl\nAbelianGroup.commutative weirdAb {a} {a} = refl\nAbelianGroup.commutative weirdAb {a} {b} = refl\nAbelianGroup.commutative weirdAb {a} {c} = refl\nAbelianGroup.commutative weirdAb {b} {e} = refl\nAbelianGroup.commutative weirdAb {b} {a} = refl\nAbelianGroup.commutative weirdAb {b} {b} = refl\nAbelianGroup.commutative weirdAb {b} {c} = refl\nAbelianGroup.commutative weirdAb {c} {e} = refl\nAbelianGroup.commutative weirdAb {c} {a} = refl\nAbelianGroup.commutative weirdAb {c} {b} = refl\nAbelianGroup.commutative weirdAb {c} {c} = refl\n\nweirdProjection : Weird \u2192 FinSet 4\nweirdProjection a = ofNat 0 (le 3 refl)\nweirdProjection b = ofNat 1 (le 2 refl)\nweirdProjection c = ofNat 2 (le 1 refl)\nweirdProjection e = ofNat 3 (le zero refl)\n\nweirdProjectionSurj : Surjection weirdProjection\nweirdProjectionSurj fzero = a , refl\nweirdProjectionSurj (fsucc fzero) = b , refl\nweirdProjectionSurj (fsucc (fsucc fzero)) = c , refl\nweirdProjectionSurj (fsucc (fsucc (fsucc fzero))) = e , refl\nweirdProjectionSurj (fsucc (fsucc (fsucc (fsucc ()))))\n\nweirdProjectionInj : (x y : Weird) \u2192 weirdProjection x \u2261 weirdProjection y \u2192 Setoid._\u223c_ (reflSetoid Weird) x y\nweirdProjectionInj e e fx=fy = refl\nweirdProjectionInj e a ()\nweirdProjectionInj e b ()\nweirdProjectionInj e c ()\nweirdProjectionInj a e ()\nweirdProjectionInj a a fx=fy = refl\nweirdProjectionInj a b ()\nweirdProjectionInj a c ()\nweirdProjectionInj b e ()\nweirdProjectionInj b a ()\nweirdProjectionInj b b fx=fy = refl\nweirdProjectionInj b c ()\nweirdProjectionInj c e ()\nweirdProjectionInj c a ()\nweirdProjectionInj c b ()\nweirdProjectionInj c c fx=fy = refl\n\nweirdFinite : FiniteGroup weirdGroup (FinSet 4)\nSetoidToSet.project (FiniteGroup.toSet weirdFinite) = weirdProjection\nSetoidToSet.wellDefined (FiniteGroup.toSet weirdFinite) x y = applyEquality weirdProjection\nSetoidToSet.surj (FiniteGroup.toSet weirdFinite) = weirdProjectionSurj\nSetoidToSet.inj (FiniteGroup.toSet weirdFinite) = weirdProjectionInj\nFiniteSet.size (FiniteGroup.finite weirdFinite) = 4\nFiniteSet.mapping (FiniteGroup.finite weirdFinite) = id\nFiniteSet.bij (FiniteGroup.finite weirdFinite) = idIsBijective\n\nweirdOrder : groupOrder weirdFinite \u2261 4\nweirdOrder = refl\n\n-- TODO: dihedral groups\n-- TODO: matrix groups on R\n-- TODO: general linear groups on R\n", "meta": {"hexsha": "cfbf7733befd7b7245fb59862b15103ec46e6124", "size": 8963, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/LectureNotes/Lecture1.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/LectureNotes/Lecture1.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/LectureNotes/Lecture1.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 41.8831775701, "max_line_length": 386, "alphanum_fraction": 0.7110342519, "num_tokens": 3016, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802395624259, "lm_q2_score": 0.8311430520409023, "lm_q1q2_score": 0.7633884695491737}}
{"text": "module Data.Vec.Membership where\n\nopen import Data.Vec as Vec\nopen import Data.Vec.Any\nopen import Data.Vec.Any.Membership.Propositional\nopen import Data.Product as Prod hiding (map)\nopen import Function using (_\u2218_; id)\n\nfind : \u2200 {a p}{A : Set a}{P : A \u2192 Set p}{n}{xs : Vec A n} \u2192\n  Any P xs \u2192 \u2203 \u03bb x \u2192 x \u2208 xs \u00d7 P x\n-- find = Prod.map id (Prod.map \u2208\u2032\u2192\u2208 id) \u2218 find\u2032\nfind (here px) = , here , px\nfind (there p) = Prod.map id (Prod.map there id) (find p)\n\nlose : \u2200 {a p}{A : Set a}{P : A \u2192 Set p}{n x}{xs : Vec A n} \u2192\n  x \u2208 xs \u2192 P x \u2192 Any P xs\nlose = lose\u2032 \u2218 \u2208\u2192\u2208\u2032\n\nopen import Function.Related as Related public using (Kind; Symmetric-kind)\n            renaming (implication to subset\n              ;  reverse-implication to superset\n              ;  equivalence to set\n              ;  injection to subbag\n              ;  reverse-injection to superbag\n              ;  bijection to bag)\n   \n_\u223c[_]_ : \u2200 {a m n}{A : Set a} \u2192 Vec A m \u2192 Kind \u2192 Vec A n \u2192 Set _\nxs \u223c[ k ] ys = \u2200 {x} \u2192 (x \u2208 xs) Related.\u223c[ k ] (x \u2208 ys)\n\n\n", "meta": {"hexsha": "a60c19eb29d17aab068bbe4df4e307136f9fc22b", "size": 1012, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Vec/Membership.agda", "max_stars_repo_name": "tizmd/agda-vector-any", "max_stars_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Vec/Membership.agda", "max_issues_repo_name": "tizmd/agda-vector-any", "max_issues_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Vec/Membership.agda", "max_forks_repo_name": "tizmd/agda-vector-any", "max_forks_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6451612903, "max_line_length": 75, "alphanum_fraction": 0.5711462451, "num_tokens": 336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284088025362857, "lm_q2_score": 0.822189121808099, "lm_q1q2_score": 0.7633276180362175}}
{"text": "{-# OPTIONS --sized-types #-}\nmodule SList.Order {A : Set}(_\u2264_ : A \u2192 A \u2192 Set) where\n\nopen import List.Sorted _\u2264_\nopen import Size\nopen import SList\n\ndata _*\u2264_ : {\u03b9 : Size} \u2192 A \u2192 SList A {\u03b9} \u2192 Set where\n  genx : {\u03b9 : Size}{b : A} \n                   \u2192 (_*\u2264_) {\u2191 \u03b9} b snil\n  gecx : {\u03b9 : Size}{b x : A}{xs : SList A {\u03b9}} \n                   \u2192 b \u2264 x \n                   \u2192 b *\u2264 xs \n                   \u2192 b *\u2264 (x \u2219 xs)\n\ndata _\u2264*_ : {\u03b9 : Size} \u2192 SList A {\u03b9} \u2192 A \u2192 Set where\n  lenx : {\u03b9 : Size}{t : A} \n                   \u2192 (_\u2264*_) {\u2191 \u03b9} snil t\n  lecx : {\u03b9 : Size}{x t : A}{xs : SList A {\u03b9}} \n                   \u2192 x \u2264 t \n                   \u2192 xs \u2264* t \n                   \u2192 (x \u2219 xs) \u2264* t\n\n\n", "meta": {"hexsha": "f1aab2fd78ddcd60d189b7079ad13e2aa3dac2f9", "size": 678, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SList/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SList/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SList/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.12, "max_line_length": 53, "alphanum_fraction": 0.3716814159, "num_tokens": 253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9591542852576265, "lm_q2_score": 0.7956581000631541, "lm_q1q2_score": 0.7631588762755156}}
{"text": "import Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; sym; trans; cong)\nopen Eq.\u2261-Reasoning\nopen import Data.Nat using (\u2115; zero; suc; _+_; _*_)\nopen import Data.Nat.Properties.Simple using (+-suc)\nopen import Data.Product using (\u2203; \u2203-syntax; _,_)\n\ndata even : \u2115 \u2192 Set\ndata odd  : \u2115 \u2192 Set\n\ndata even where\n  even-zero : even zero\n  even-suc  : \u2200 {n : \u2115} \u2192 odd n \u2192 even (suc n)\n\ndata odd where\n  odd-suc   : \u2200 {n : \u2115} \u2192 even n \u2192 odd (suc n)\n\nlemma : \u2200 (m : \u2115) \u2192 2 * suc m \u2261 suc (suc (2 * m))\nlemma m =\n  begin\n    2 * suc m\n  \u2261\u27e8\u27e9\n    suc m + (suc m + zero)\n  \u2261\u27e8\u27e9\n    suc (m + (suc (m + zero)))\n  \u2261\u27e8 cong suc (+-suc m (m + zero)) \u27e9\n    suc (suc (m + (m + zero)))\n  \u2261\u27e8\u27e9\n    suc (suc (2 * m))\n  \u220e\n\n\u2203-even : \u2200 {n : \u2115} \u2192 even n \u2192 \u2203[ m ] (2 * m \u2261 n)\n\u2203-odd  : \u2200 {n : \u2115} \u2192  odd n \u2192 \u2203[ m ] (1 + 2 * m \u2261 n)\n\n\u2203-even even-zero =  zero , refl\n\u2203-even (even-suc o) with \u2203-odd o\n...                    | m , refl = suc m , lemma m\n\n\u2203-odd  (odd-suc e)  with \u2203-even e\n...                    | m , refl = m , refl\n\n\u2203-even\u2032 : \u2200 {n : \u2115} \u2192 even n \u2192 \u2203[ m ] (n \u2261 2 * m)\n\u2203-odd\u2032  : \u2200 {n : \u2115} \u2192  odd n \u2192 \u2203[ m ] (n \u2261 1 + 2 * m)\n\n\u2203-even\u2032 even-zero =  zero , refl\n\u2203-even\u2032 (even-suc o) with \u2203-odd\u2032 o\n...                     | m , eqn rewrite eqn | +-suc m (m + 0) = suc m , {!!}\n\n\u2203-odd\u2032  (odd-suc e)  with \u2203-even\u2032 e\n...                     | m , eqn rewrite eqn = m , refl\n\ndata Even : \u2115 \u2192 Set where\n  ev0 : Even zero\n  ev2 : \u2200 {n} \u2192 Even n \u2192 Even (suc (suc n))\n\nev-ex : \u2200 {n : \u2115} \u2192 Even n \u2192 \u2203[ m ] (2 * m \u2261 n)\nev-ex ev0 =  (zero , refl)\nev-ex (ev2 ev) with ev-ex ev\n... | (m , refl) = (suc m , lemma m)\n\n", "meta": {"hexsha": "3055800aa7ad38106ec0cbeb371dcbcea77c963a", "size": 1595, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/RewriteWTF.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/RewriteWTF.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/RewriteWTF.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 26.1475409836, "max_line_length": 78, "alphanum_fraction": 0.473354232, "num_tokens": 681, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.933430812881347, "lm_q2_score": 0.8175744828610095, "lm_q1q2_score": 0.7631492141279991}}
{"text": "module algebra where\n\nopen import Relation.Binary.PropositionalEquality\nopen \u2261-Reasoning\n\n-- Goals are written as normalised\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + y = y\nsuc x + y = suc (x + y)\n\nrecord Semigroup (a : Set) : Set where\n  field\n    _\u229b_ : a \u2192 a \u2192 a\n    assoc : \u2200 a b c \u2192 (a \u229b b) \u229b c \u2261 a \u229b (b \u229b c)\n\nrecord Monoid (a : Set) : Set where\n  field\n    semigroup : Semigroup a\n  open Semigroup semigroup\n  field\n    e : a\n    idl : \u2200 a \u2192 e \u229b a \u2261 a\n    idr : \u2200 a \u2192 a \u229b e \u2261 a\n\nrecord Group (a : Set) : Set where\n  field\n    monoid : Monoid a\n  open Monoid monoid\n  open Semigroup semigroup\n  field\n  -- TODO [aerben] fix this\n    invl : \u2200 a \u2203 b \u2192 a \u229b b \u2261 e\n    invr : \u2200 a \u2203 b \u2192 b \u229b a \u2261 e\n\nrecord AbelianGroup (a : Set) : Set where\n  field\n    group : Group a\n  open Group group\n  open Monoid monoid\n  open Semigroup semigroup\n  field\n    commutative : \u2200 a b \u2192 a \u229b b \u2261 b \u229b a\n\nrecord CommutativeSemigroup (a : Set) : Set where\n  field\n    _\u229b_ : a \u2192 a \u2192 a\n    associative : \u2200 a b c \u2192 (a \u229b b) \u229b c \u2261 a \u229b (b \u229b c)\n    commutative : \u2200 a b \u2192 a \u229b b \u2261 b \u229b a\n\nplusAssociative : \u2200 a b c -> (a + b) + c \u2261 a + (b + c)\n-- Goal: (b + c) \u2261 (b + c)\n-- Follows from reflexivity\nplusAssociative zero b c = refl\n-- Goal: suc ((a + b) + c) \u2261 suc (a + (b + c))\n-- Inductive step\n-- Follows from induction assumption and congruence\nplusAssociative (suc a) b c =\n  begin\n    suc ((a + b) + c)\n  \u2261\u27e8 cong suc (plusAssociative a b c) \u27e9\n    suc (a + (b + c))\n  \u220e\n\nplusCommutativeLemma : \u2200 a b -> a + suc b \u2261 suc (a + b)\n-- Goal: suc b \u2261 suc b\n-- Follows from reflexivity\nplusCommutativeLemma zero b = refl\n-- Goal: suc (a + suc b) \u2261 suc (suc (a + b))\n-- Inductive step\n-- Follows from induction assumption and congruence\nplusCommutativeLemma (suc a) b =\n  begin\n    suc (a + suc b)\n  \u2261\u27e8 cong suc (plusCommutativeLemma a b) \u27e9\n    suc (suc (a + b))\n  \u220e\n\nplusCommutative : \u2200 a b -> a + b \u2261 b + a\n-- Goal: zero \u2261 zero\n-- Follows from reflexivity\nplusCommutative zero zero = refl\n-- Goal: suc (a + zero) \u2261 suc a\n-- One-sided inductive step\n-- Follows from induction assumption and congruence\nplusCommutative (suc a) zero =\n  begin\n    suc (a + zero)\n  \u2261\u27e8 cong suc (plusCommutative a zero) \u27e9\n    suc a\n  \u220e\n-- Goal: suc b \u2261 suc (b + zero)\n-- One-sided inductive step\n-- Follows from induction assumption and congruence\nplusCommutative zero (suc b) =\n  begin\n    suc b\n  \u2261\u27e8 cong suc (plusCommutative zero b) \u27e9\n    suc (b + zero)\n  \u220e\n-- plusCommutative (suc a) (suc b) rewrite plusCommutativeAux a b | plusCommutativeAux b a = cong suc (cong suc (plusCommutative a b))\n-- Goal: suc (a + suc b) \u2261 suc (b + suc a)\nplusCommutative (suc a) (suc b) =\n  begin\n    suc (a + suc b)\n  \u2261\u27e8 cong suc (plusCommutativeLemma a b) \u27e9\n    suc (suc (a + b))\n  \u2261\u27e8 cong suc (cong suc (plusCommutative a b)) \u27e9\n    suc (suc (b + a))\n    -- Need to invoke symmetry since definitional equivalence does not guarantee it\n  \u2261\u27e8 cong suc (sym (plusCommutativeLemma b a)) \u27e9\n    suc (b + suc a)\n  \u220e\n\nplusSemigroup : CommutativeSemigroup \u2115\nplusSemigroup = record\n  { _\u229b_ = _+_\n  ; associative = plusAssociative\n  ; commutative = plusCommutative\n  }\n", "meta": {"hexsha": "9133b1ecb3050de975ed0fa480f450b0e9a63191", "size": 3111, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "experiments/algebra.agda", "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "experiments/algebra.agda", "max_issues_repo_name": "aronerben/agda-playground", "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "experiments/algebra.agda", "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.888, "max_line_length": 134, "alphanum_fraction": 0.6097717776, "num_tokens": 1164, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768620069626, "lm_q2_score": 0.8080672112416737, "lm_q1q2_score": 0.7629583638008809}}
{"text": "module bool where\n\n------------------------\n-- Datatypes\n------------------------\ndata \ud835\udd39 : Set where\n  true  : \ud835\udd39\n  false : \ud835\udd39\n\n----------------------\n-- AND\n----------------------\ninfixr 6 _\u2227_\n_\u2227_ : \ud835\udd39 \u2192 \ud835\udd39 \u2192 \ud835\udd39\ntrue  \u2227 b  = b\nfalse \u2227 b = false\n\n---------------------\n-- OR\n---------------------\ninfixr 5 _\u2228_\n_\u2228_ : \ud835\udd39 \u2192 \ud835\udd39 \u2192 \ud835\udd39\ntrue  \u2228 b = true\nfalse \u2228 b = b\n\n--------------------\n-- NEFATION\n--------------------\ninfixr 7 \u00ac_\n\u00ac_ : \ud835\udd39 \u2192 \ud835\udd39\n\u00ac true  = false\n\u00ac false = true\n", "meta": {"hexsha": "5ed0c3335476cde35966ce46f6535bc2419b636f", "size": 461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "bool.agda", "max_stars_repo_name": "mrLSD/agda-emacs", "max_stars_repo_head_hexsha": "2c92eb9520dc83f0258e43b4227ce281dfadaffe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bool.agda", "max_issues_repo_name": "mrLSD/agda-emacs", "max_issues_repo_head_hexsha": "2c92eb9520dc83f0258e43b4227ce281dfadaffe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bool.agda", "max_forks_repo_name": "mrLSD/agda-emacs", "max_forks_repo_head_hexsha": "2c92eb9520dc83f0258e43b4227ce281dfadaffe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.9696969697, "max_line_length": 24, "alphanum_fraction": 0.3275488069, "num_tokens": 168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768651485396, "lm_q2_score": 0.8080672043084051, "lm_q1q2_score": 0.7629583597932543}}
{"text": "module Data.Vec.Any.Membership.Propositional  where\n  open import Relation.Binary.PropositionalEquality \n  open import Data.Vec\n  open import Data.Vec.Any hiding (map)   \n  open import Function.Inverse using (_\u2194_)\n  open import Function using (_\u2218_)\n  open import Data.Nat  \n  open import Data.Product hiding (map)\n  import Data.Vec.Any.Membership as Mem\n  open import Function.Related using (\u2194\u21d2)\n  module _ {a} {A : Set a} where\n    private module M = Mem (setoid A)\n    open M public hiding (lose\u2032)\n\n    \u2208\u2032\u2192\u2208 : \u2200 {n x}{xs : Vec A n} \u2192 x \u2208\u2032 xs \u2192 x \u2208 xs\n    \u2208\u2032\u2192\u2208 {xs = .(_ \u2237 _)} (here refl) = here\n    \u2208\u2032\u2192\u2208 {xs = .(_ \u2237 _)} (there p) = there (\u2208\u2032\u2192\u2208 p)\n\n    \u2208\u2192\u2208\u2032 : \u2200 {n x}{xs : Vec A n} \u2192 x \u2208 xs \u2192 x \u2208\u2032 xs\n    \u2208\u2192\u2208\u2032 {xs = .(_ \u2237 _)} here = here refl\n    \u2208\u2192\u2208\u2032 {xs = .(_ \u2237 _)} (there p) = there (\u2208\u2192\u2208\u2032 p)\n  \n    \u2208\u2194\u2208\u2032 : \u2200 {n x}{xs : Vec A n} \u2192 x \u2208 xs \u2194 x \u2208\u2032 xs\n    \u2208\u2194\u2208\u2032 = record {\n         to = \u2192-to-\u27f6 \u2208\u2192\u2208\u2032\n         ; from =  \u2192-to-\u27f6 \u2208\u2032\u2192\u2208\n         ; inverse-of = record {\n             left-inverse-of = left-inverse\n           ; right-inverse-of = right-inverse\n         }\n         }\n         where\n           left-inverse : \u2200 {n x}{xs : Vec A n}(p : x \u2208 xs) \u2192 \u2208\u2032\u2192\u2208 (\u2208\u2192\u2208\u2032 p) \u2261 p \n           left-inverse {xs = .(_ \u2237 _)} here = refl\n           left-inverse {xs = .(_ \u2237 _)} (there p) = cong there (left-inverse p)\n\n           right-inverse : \u2200 {n x}{xs : Vec A n}(p : x \u2208\u2032 xs) \u2192 \u2208\u2192\u2208\u2032 (\u2208\u2032\u2192\u2208 p) \u2261 p\n           right-inverse {xs = .(_ \u2237 _)} (here refl) = refl\n           right-inverse {xs = .(_ \u2237 _)} (there p) = cong there (right-inverse p)\n\n    \u2208\u2032\u2192\u2208-there : \u2200 {n x}{xs : Vec A n}(x\u2208\u2032xs : x \u2208\u2032 xs) \u2192 \u2208\u2032\u2192\u2208 (there {x = x} x\u2208\u2032xs) \u2261 there (\u2208\u2032\u2192\u2208 x\u2208\u2032xs)\n    \u2208\u2032\u2192\u2208-there (here refl) = refl\n    \u2208\u2032\u2192\u2208-there (there p) rewrite \u2208\u2032\u2192\u2208-there p = refl\n    \n    lose\u2032 : \u2200 {p}{P : A \u2192 Set p} {n x} {xs : Vec A n} \u2192\n      x \u2208\u2032 xs \u2192 P x \u2192 Any P xs\n    lose\u2032 {P = P} = M.lose\u2032 (subst P) \n\n  open import Function.Related as Related public using (Kind; Symmetric-kind)\n              renaming (implication to subset\n                     ;  reverse-implication to superset\n                     ;  equivalence to set\n                     ;  injection to subbag\n                     ;  reverse-injection to superbag\n                     ;  bijection to bag)\n  infix 4 _\u223c[_]_\n  _\u223c[_]_ : \u2200 {a m n}{A : Set a} \u2192 Vec A m \u2192 Kind \u2192 Vec A n \u2192 Set _\n  xs \u223c[ k ] ys = \u2200 {x} \u2192 (x \u2208\u2032 xs) Related.\u223c[ k ] (x \u2208\u2032 ys)\n    \n  bag-=\u21d2 : \u2200 {k a m n} {A : Set a} {xs : Vec A m} {ys : Vec A n} \u2192\n           xs \u223c[ bag ] ys \u2192 xs \u223c[ k ] ys\n  bag-=\u21d2 xs\u2248ys = \u2194\u21d2 xs\u2248ys\n", "meta": {"hexsha": "da4281e3da7c850bb96c570782d7cab88f1cb8ff", "size": 2498, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Vec/Any/Membership/Propositional.agda", "max_stars_repo_name": "tizmd/agda-vector-any", "max_stars_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Vec/Any/Membership/Propositional.agda", "max_issues_repo_name": "tizmd/agda-vector-any", "max_issues_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Vec/Any/Membership/Propositional.agda", "max_forks_repo_name": "tizmd/agda-vector-any", "max_forks_repo_head_hexsha": "1a60f72b9ea1dd61845311ee97dc380aa542b874", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.6507936508, "max_line_length": 105, "alphanum_fraction": 0.4707766213, "num_tokens": 939, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898178450964, "lm_q2_score": 0.8418256492357359, "lm_q1q2_score": 0.7626854666084143}}
{"text": "\nmodule Examples where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\ndata Bool : Set where\n  true  : Bool\n  false : Bool\n\nif_then_else_ : {A : Set} -> Bool -> A -> A -> A\nif true  then x else y = x\nif false then x else y = y\n\nnot : Bool -> Bool\nnot x = if x then false else true\n\nisZero : Nat -> Bool\nisZero zero    = true\nisZero (suc _) = false\n\nF : Bool -> Set\nF true  = Nat\nF false = Bool\n\nf : (x : Bool) -> F x -> F (not x)\nf true n  = isZero n\nf false b = if b then zero else suc zero\n\ntest : Bool\ntest = f ? zero\n\n", "meta": {"hexsha": "d92b2c050073aacf92ac66b52992ccbc160405e1", "size": 530, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/talks/MetaVars/Examples.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "notes/talks/MetaVars/Examples.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "notes/talks/MetaVars/Examples.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 15.5882352941, "max_line_length": 48, "alphanum_fraction": 0.5981132075, "num_tokens": 182, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9553191297273498, "lm_q2_score": 0.7981867777396212, "lm_q1q2_score": 0.7625230978700925}}
{"text": "{-# OPTIONS --sized-types #-}\nmodule SList.Order.Properties {A  : Set}(_\u2264_ : A \u2192 A \u2192 Set) where\n\nopen import List.Sorted _\u2264_\nopen import Size\nopen import SList\nopen import SList.Order _\u2264_\n\nlemma-slist-sorted : {\u03b9 : Size}{x : A}{xs : SList A {\u03b9}} \u2192 x *\u2264 xs \u2192 Sorted (unsize A xs) \u2192 Sorted (unsize A (x \u2219 xs))\nlemma-slist-sorted {x = x} genx nils = singls x\nlemma-slist-sorted (gecx x\u2264y genx) (singls y) = conss x\u2264y (singls y)\nlemma-slist-sorted (gecx x\u2264y x*\u2264zys ) syzys = conss x\u2264y syzys\n\nlemma-sorted\u2295 : {\u03b9 : Size}{x : A}{xs : SList A {\u03b9}} \u2192 xs \u2264* x \u2192 Sorted (unsize A xs) \u2192 Sorted (unsize A (_\u2295_ A xs (x \u2219 snil)))\nlemma-sorted\u2295 {x = x} {xs = snil} _ nils = singls x\nlemma-sorted\u2295 {x = x} {xs = y \u2219 snil} (lecx y\u2264x _) (singls .y)  = conss y\u2264x (singls x)\nlemma-sorted\u2295 {xs = y \u2219 (z \u2219 ys)} (lecx y\u2264x zys\u2264*x) (conss y\u2264z szys) = conss y\u2264z (lemma-sorted\u2295 zys\u2264*x szys)\n\nlemma-\u2295\u2264* : {\u03b9 : Size}{x t : A}{xs : SList A {\u03b9}} \u2192 x \u2264 t \u2192 xs \u2264* t \u2192 (_\u2295_ A xs (x \u2219 snil)) \u2264* t\nlemma-\u2295\u2264* x\u2264t lenx = lecx x\u2264t lenx\nlemma-\u2295\u2264* x\u2264t (lecx y\u2264t ys\u2264*t) = lecx y\u2264t (lemma-\u2295\u2264* x\u2264t ys\u2264*t)\n", "meta": {"hexsha": "1df392bffeeea716d5f3343cbeb06f3fc8b7da65", "size": 1060, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SList/Order/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SList/Order/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SList/Order/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.1818181818, "max_line_length": 126, "alphanum_fraction": 0.5877358491, "num_tokens": 515, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632916317102, "lm_q2_score": 0.8221891283434876, "lm_q1q2_score": 0.7624680164044232}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Category.Instance.Simplex where\n\nopen import Level\nopen import Data.Product\nopen import Data.Fin.Base using (Fin; _\u2264_)\nopen import Data.Nat.Base using (\u2115; z\u2264n; s\u2264s)\nopen import Function renaming (id to idF; _\u2218_ to _\u2219_)\n\nopen import Relation.Binary using (_=[_]\u21d2_)\nopen import Relation.Binary.PropositionalEquality\n\n\u0394 : Category 0\u2113 0\u2113 0\u2113\n\u0394 = record\n  { Obj       = \u2115\n  ; _\u21d2_       = \u03bb m n \u2192 \u03a3 (Fin m \u2192 Fin n) (\u03bb f \u2192 _\u2264_ =[ f ]\u21d2 _\u2264_)\n  ; _\u2248_       = \u03bb { (f , mf) (g , mg) \u2192 \u2200 x \u2192 f x \u2261 g x }\n  ; id        = idF , idF\n  ; _\u2218_       = \u03bb { (f , mf) (g , mg) \u2192 f \u2219 g , mf \u2219 mg }\n  ; assoc     = \u03bb _ \u2192 refl\n  ; sym-assoc = \u03bb _ \u2192 refl\n  ; identity\u02e1 = \u03bb _ \u2192 refl\n  ; identity\u02b3 = \u03bb _ \u2192 refl\n  ; identity\u00b2 = \u03bb _ \u2192 refl\n  ; equiv     = record\n    { refl  = \u03bb _ \u2192 refl\n    ; sym   = \u03bb eq x \u2192 sym (eq x)\n    ; trans = \u03bb eq\u2081 eq\u2082 x \u2192 trans (eq\u2081 x) (eq\u2082 x)\n    }\n  ; \u2218-resp-\u2248  = \u03bb {_ _ _ f g h i} eq\u2081 eq\u2082 x \u2192 trans (cong (\u03bb t \u2192 proj\u2081 f t) (eq\u2082 x)) (eq\u2081 (proj\u2081 i x))\n  }\n\nopen Category \u0394\n\n--------------------------------------------------------------------------------\n-- Face + Degeneracy Maps\n\nface-map : \u2200 {n} \u2192 Fin (\u2115.suc n) \u2192 Fin n \u2192 Fin (\u2115.suc n)\nface-map Fin.zero    k           = Fin.suc k\nface-map (Fin.suc i) Fin.zero    = Fin.zero\nface-map (Fin.suc i) (Fin.suc k) = Fin.suc (face-map i k)\n\nface-mono : \u2200 {n} \u2192 (i : Fin (\u2115.suc n)) \u2192 _\u2264_ =[ face-map i ]\u21d2 _\u2264_\nface-mono Fin.zero    {_}         {_}         le       = s\u2264s le\nface-mono (Fin.suc i) {Fin.zero}  {_}         _        = z\u2264n\nface-mono (Fin.suc i) {Fin.suc _} {Fin.suc _} (s\u2264s le) = s\u2264s (face-mono i le)\n\nface : \u2200 {n} \u2192 Fin (\u2115.suc n) \u2192 n \u21d2 \u2115.suc n\nface i = face-map i , face-mono i\n\ndegeneracy-map : \u2200 {n} \u2192 Fin n \u2192 Fin (\u2115.suc n) \u2192 Fin n\ndegeneracy-map Fin.zero    Fin.zero    = Fin.zero\ndegeneracy-map Fin.zero    (Fin.suc k) = k\ndegeneracy-map (Fin.suc i) Fin.zero    = Fin.zero\ndegeneracy-map (Fin.suc i) (Fin.suc k) = Fin.suc (degeneracy-map i k)\n\ndegeneracy-mono : \u2200 {n} \u2192 (i : Fin n) \u2192 _\u2264_ =[ degeneracy-map i ]\u21d2 _\u2264_\ndegeneracy-mono Fin.zero    {Fin.zero}  {_}         _        = z\u2264n\ndegeneracy-mono Fin.zero    {Fin.suc _} {Fin.suc _} (s\u2264s le) = le\ndegeneracy-mono (Fin.suc i) {Fin.zero}  {_}         _        = z\u2264n\ndegeneracy-mono (Fin.suc i) {Fin.suc _} {Fin.suc _} (s\u2264s le) = s\u2264s (degeneracy-mono i le)\n\ndegeneracy : \u2200 {n} \u2192 Fin n \u2192 \u2115.suc n \u21d2 n\ndegeneracy i = degeneracy-map i , degeneracy-mono i\n", "meta": {"hexsha": "7894b0f3bf41a0bb6d916e7d8f740b27224e1a91", "size": 2445, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Instance/Simplex.agda", "max_stars_repo_name": "jaykru/agda-categories", "max_stars_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Instance/Simplex.agda", "max_issues_repo_name": "jaykru/agda-categories", "max_issues_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Instance/Simplex.agda", "max_forks_repo_name": "jaykru/agda-categories", "max_forks_repo_head_hexsha": "a4053cf700bcefdf73b857c3352f1eae29382a60", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.9558823529, "max_line_length": 102, "alphanum_fraction": 0.5386503067, "num_tokens": 961, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218348550491, "lm_q2_score": 0.8267117962054049, "lm_q1q2_score": 0.7621636560540003}}
{"text": "module List.Permutation.Base.Concatenation (A : Set) where\n\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Permutation.Base.Preorder A\nopen import Data.List\nopen import Data.Product\nopen import Relation.Binary.PreorderReasoning \u223c-preorder\nopen import Algebra\nopen import Algebra.Structures\n\nlemma++/r : {x : A}{xs ys xs' : List A} \u2192 (xs / x \u27f6 xs') \u2192 (xs ++ ys) / x \u27f6 (xs' ++ ys)\nlemma++/r /head = /head\nlemma++/r (/tail xs/x\u27f6xs') = /tail (lemma++/r xs/x\u27f6xs')\n\nlemma++/l : {y : A}{xs ys ys' : List A} \u2192 (ys / y \u27f6 ys') \u2192 (xs ++ ys) / y \u27f6 (xs ++ ys')\nlemma++/l {xs = []} ys/y\u27f6ys' = ys/y\u27f6ys'\nlemma++/l {xs = x \u2237 xs} ys/y\u27f6ys' = /tail (lemma++/l {xs = xs} ys/y\u27f6ys')\n\nlemma++/ : {y : A}{xs ys : List A} \u2192 (xs ++ y \u2237 ys) / y \u27f6 (xs ++ ys)\nlemma++/ {xs = xs} = lemma++/l {xs = xs} /head\n\nlemma++\u223cr : {xs xs' ys : List A} \u2192  xs \u223c xs' \u2192 (xs ++ ys) \u223c (xs' ++ ys)\nlemma++\u223cr {xs} {xs'} {[]} xs\u223cxs' \n                   rewrite ((proj\u2082 (IsMonoid.identity (Monoid.isMonoid (monoid A)))) xs) \n                            | ((proj\u2082 (IsMonoid.identity (Monoid.isMonoid (monoid A)))) xs') = xs\u223cxs'\nlemma++\u223cr {xs} {xs'} {y \u2237 ys} xs\u223cxs' =  \u223cx (lemma++/ {y} {xs} {ys}) (lemma++/ {y} {xs'} {ys}) (lemma++\u223cr xs\u223cxs') \n\nlemma++\u223cl : {xs ys ys' : List A} \u2192  ys \u223c  ys' \u2192 (xs ++ ys) \u223c (xs ++ ys')\nlemma++\u223cl {xs = []} ys\u223cys' = ys\u223cys'\nlemma++\u223cl {xs = x \u2237 xs} ys\u223cys' = \u223cx /head /head (lemma++\u223cl {xs = xs} ys\u223cys')\n\nlemma++\u223c : {xs ys xs' ys' : List A} \u2192  xs \u223c  xs' \u2192  ys \u223c ys' \u2192 (xs ++ ys) \u223c (xs' ++ ys')\nlemma++\u223c {xs} {ys} {xs'} {ys'} xs\u223cxs' ys\u223cys' \n  = begin\n     xs ++ ys\n     \u223c\u27e8 lemma++\u223cr xs\u223cxs'  \u27e9\n     xs' ++ ys\n     \u223c\u27e8 lemma++\u223cl {xs = xs'} ys\u223cys'  \u27e9\n     xs' ++ ys'\n    \u220e\n", "meta": {"hexsha": "6f315efa0e390b75313cfac41a19e56cc51de14f", "size": 1695, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Permutation/Base/Concatenation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Permutation/Base/Concatenation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Permutation/Base/Concatenation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.3571428571, "max_line_length": 113, "alphanum_fraction": 0.5126843658, "num_tokens": 728, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218370002787, "lm_q2_score": 0.8267117855317474, "lm_q1q2_score": 0.762163647987209}}
{"text": "module AnyBoolean where\nopen import Data.Bool\nopen import Data.Nat\nopen import Data.List hiding (any)\nopen import Relation.Binary.PropositionalEquality\n\neven : \u2115 \u2192 Bool\neven zero = true\neven (suc zero) = false\neven (suc (suc n)) = even n\n\ntest-6-even : even 6 \u2261 true\ntest-6-even = refl\n\nodd : \u2115 \u2192 Bool\nodd zero = false\nodd (suc zero) = true\nodd (suc (suc n)) = odd n\n\ntest-5-odd : odd 5 \u2261 true\ntest-5-odd = refl\n\nany : {A : Set} \u2192 (A \u2192 Bool) \u2192 List A \u2192 Bool\nany _ [] = false\nany p (x \u2237 xs) with p x\n... | true = true\n... | false = any p xs\n\ntest-any-even-true : \n  any even (3 \u2237 6 \u2237 9 \u2237 []) \u2261 true\ntest-any-even-true = refl\n\ntest-any-even-false : \n  any even (3 \u2237 7 \u2237 9 \u2237 []) \u2261 false\ntest-any-even-false = refl\n\ntest-any-odd-true : \n  any odd (4 \u2237 7 \u2237 10 \u2237 []) \u2261 true\ntest-any-odd-true = refl\n\ntest-any-odd-false : \n  any odd (4 \u2237 8 \u2237 10 \u2237 []) \u2261 false\ntest-any-odd-false = refl\n", "meta": {"hexsha": "d08ca99a2258f57dc222ad2fa643095efa5a90e8", "size": 878, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "AnyBoolean.agda", "max_stars_repo_name": "larrytheliquid/bahug-april2010", "max_stars_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "AnyBoolean.agda", "max_issues_repo_name": "larrytheliquid/bahug-april2010", "max_issues_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AnyBoolean.agda", "max_forks_repo_name": "larrytheliquid/bahug-april2010", "max_forks_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T12:03:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T12:03:09.000Z", "avg_line_length": 19.9545454545, "max_line_length": 49, "alphanum_fraction": 0.6195899772, "num_tokens": 334, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133548753619, "lm_q2_score": 0.8104789018037399, "lm_q1q2_score": 0.7617799436500522}}
{"text": "\nmodule Prelude.Nat.Properties where\n\nopen import Prelude.Bool\nopen import Prelude.Nat.Core\nopen import Prelude.Equality\nopen import Prelude.Semiring\n\nsuc-inj : \u2200 {n m} \u2192 suc n \u2261 suc m \u2192 n \u2261 m\nsuc-inj refl = refl\n\n--- Addition ---\n\nadd-zero-r : (n : Nat) \u2192 n + 0 \u2261 n\nadd-zero-r zero    = refl\nadd-zero-r (suc n) = suc $\u2261 add-zero-r n\n\nadd-suc-r : (n m : Nat) \u2192 n + suc m \u2261 suc (n + m)\nadd-suc-r zero    m = refl\nadd-suc-r (suc n) m = suc $\u2261 add-suc-r n m\n\nadd-commute : (a b : Nat) \u2192 a + b \u2261 b + a\nadd-commute zero    b = sym (add-zero-r _)\nadd-commute (suc a) b = suc $\u2261 add-commute a b \u27e8\u2261\u27e9\u02b3 add-suc-r b _\n\nadd-assoc : (a b c : Nat) \u2192 a + (b + c) \u2261 a + b + c\nadd-assoc zero    b c = refl\nadd-assoc (suc a) b c = suc $\u2261 add-assoc a b c\n\nadd-inj\u2082 : (a b c : Nat) \u2192 a + b \u2261 a + c \u2192 b \u2261 c\nadd-inj\u2082 zero    b c eq = eq\nadd-inj\u2082 (suc a) b c eq = add-inj\u2082 a b c (suc-inj eq)\n\nadd-inj\u2081 : (a b c : Nat) \u2192 a + c \u2261 b + c \u2192 a \u2261 b\nadd-inj\u2081 a b c eq = add-inj\u2082 c a b (add-commute c a \u27e8\u2261\u27e9 eq \u27e8\u2261\u27e9 add-commute b c)\n\n--- Subtraction ---\n\n--- Multiplication ---\n\nmul-one-r : (x : Nat) \u2192 x * 1 \u2261 x\nmul-one-r zero    = refl\nmul-one-r (suc x) = suc $\u2261 mul-one-r x\n\nmul-zero-r : (x : Nat) \u2192 x * 0 \u2261 0\nmul-zero-r zero    = refl\nmul-zero-r (suc x) = mul-zero-r x\n\nmul-distr-r : (x y z : Nat) \u2192 (x + y) * z \u2261 x * z + y * z\nmul-distr-r zero    y z = refl\nmul-distr-r (suc x) y z = z +_ $\u2261 mul-distr-r x y z \u27e8\u2261\u27e9 add-assoc z _ _\n\nprivate\n  shuffle : (a b c d : Nat) \u2192 a + b + (c + d) \u2261 a + c + (b + d)\n  shuffle a b c d = add-assoc a _ _ \u02b3\u27e8\u2261\u27e9\n                    a +_ $\u2261 (add-assoc b c d \u27e8\u2261\u27e9 _+ d $\u2261 add-commute b c \u27e8\u2261\u27e9\u02b3 add-assoc c b d) \u27e8\u2261\u27e9\n                    add-assoc a _ _\n\nmul-distr-l : (x y z : Nat) \u2192 x * (y + z) \u2261 x * y + x * z\nmul-distr-l zero    y z = refl\nmul-distr-l (suc x) y z = y + z +_ $\u2261 mul-distr-l x y z \u27e8\u2261\u27e9 shuffle y z (x * y) (x * z)\n\nmul-assoc : (x y z : Nat) \u2192 x * (y * z) \u2261 x * y * z\nmul-assoc zero    y z = refl\nmul-assoc (suc x) y z = y * z +_ $\u2261 mul-assoc x y z \u27e8\u2261\u27e9\u02b3 mul-distr-r y (x * y) z\n\nmul-commute : (x y : Nat) \u2192 x * y \u2261 y * x\nmul-commute x zero    = mul-zero-r x\nmul-commute x (suc y) = mul-distr-l x 1 y \u27e8\u2261\u27e9 _+ x * y $\u2261 mul-one-r x \u27e8\u2261\u27e9 x +_ $\u2261 mul-commute x y\n\nmul-inj\u2081 : (x y z : Nat) {{_ : NonZero z}} \u2192 x * z \u2261 y * z \u2192 x \u2261 y\nmul-inj\u2081 x        y      zero {{}}\nmul-inj\u2081 zero     zero   (suc z) eq = refl\nmul-inj\u2081 zero    (suc y) (suc z) ()\nmul-inj\u2081 (suc x) zero    (suc z) ()\nmul-inj\u2081 (suc x) (suc y) (suc z) eq = suc $\u2261 mul-inj\u2081 x y (suc z) (add-inj\u2082 z _ _ (suc-inj eq))\n\nmul-inj\u2082 : (x y z : Nat) {{_ : NonZero x}} \u2192 x * y \u2261 x * z \u2192 y \u2261 z\nmul-inj\u2082 x y z eq = mul-inj\u2081 y z x (mul-commute y x \u27e8\u2261\u27e9 eq \u27e8\u2261\u27e9 mul-commute x z)\n", "meta": {"hexsha": "356c41f6c253821e2c4a36025ff75e85db08f15e", "size": 2631, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Prelude/Nat/Properties.agda", "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 111, "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_issues_repo_path": "src/Prelude/Nat/Properties.agda", "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 59, "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_forks_repo_path": "src/Prelude/Nat/Properties.agda", "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 24, "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "avg_line_length": 32.8875, "max_line_length": 98, "alphanum_fraction": 0.5229950589, "num_tokens": 1168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951588871157, "lm_q2_score": 0.8152324938410784, "lm_q1q2_score": 0.761749295612574}}
{"text": "open import Relation.Binary.Core\n\nmodule PLRTree.Insert {A : Set} \n                     (_\u2264_ : A \u2192 A \u2192 Set)\n                     (tot\u2264 : Total _\u2264_) where\n\nopen import Data.Sum\nopen import PLRTree {A}\n\ninsert : A \u2192 PLRTree \u2192 PLRTree\ninsert x leaf = node perfect x leaf leaf \ninsert x (node perfect y l r) \n    with tot\u2264 x y | l | r\n... | inj\u2081 x\u2264y | leaf | leaf = node right x (node perfect y leaf leaf) leaf\n... | inj\u2081 x\u2264y | _ | _ = node left x (insert y l) r  \n... | inj\u2082 y\u2264x | leaf | leaf = node right y (node perfect x leaf leaf) leaf\n... | inj\u2082 y\u2264x | _ | _ = node left y (insert x l) r  \ninsert x (node left y l r)\n    with tot\u2264 x y\n... | inj\u2081 x\u2264y \n    with insert y l \n... | node perfect y' l' r' = node right x (node perfect y' l' r') r \n... | t = node left x t r \ninsert x (node left y l r) | inj\u2082 y\u2264x \n    with insert x l\n... | node perfect y' l' r' = node right y (node perfect y' l' r') r \n... | t = node left y t r \ninsert x (node right y l r)\n    with tot\u2264 x y \n... | inj\u2081 x\u2264y \n    with insert y r\n... | node perfect y' l' r' = node perfect x l (node perfect y' l' r') \n... | t = node right x l t \ninsert x (node right y l r) | inj\u2082 y\u2264x \n    with insert x r\n... | node perfect y' l' r' = node perfect y l (node perfect y' l' r') \n... | t = node right y l t \n", "meta": {"hexsha": "816020d8f10d47441a705fa093c5a9a9e530c624", "size": 1269, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/PLRTree/Insert.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/PLRTree/Insert.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/PLRTree/Insert.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.3947368421, "max_line_length": 75, "alphanum_fraction": 0.5626477541, "num_tokens": 445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9603611643025387, "lm_q2_score": 0.7931059536292271, "lm_q1q2_score": 0.7616681570426398}}
{"text": "module plfa.part1.Bin where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; cong)\nopen import Data.Nat using (\u2115; zero; suc; _*_; _+_)\nopen import Data.Nat.Properties using (+-suc)\n\ndata Bin : Set where\n  \u27e8\u27e9 : Bin\n  _O : Bin \u2192 Bin\n  _I : Bin \u2192 Bin\n\ninc : Bin \u2192 Bin\ninc \u27e8\u27e9    = \u27e8\u27e9 I\ninc (b O) = b I\ninc (b I) = (inc b) O\n\nto : \u2115 \u2192 Bin\nto zero    = \u27e8\u27e9 O\nto (suc n) = inc (to n)\n\nfrom : Bin \u2192 \u2115\nfrom \u27e8\u27e9    = 0\nfrom (b O) = 2 * from b\nfrom (b I) = suc (2 * from b)\n\ninc-suc-law : \u2200 b \u2192 from (inc b) \u2261 suc (from b)\ninc-suc-law \u27e8\u27e9 = refl\ninc-suc-law (b O) = refl\ninc-suc-law (b I) rewrite\n    inc-suc-law b\n  | +-suc (suc (from b)) ((from b) + 0) = refl\n\nfrom-to-identity : \u2200 n \u2192 from (to n) \u2261 n\nfrom-to-identity zero = refl\nfrom-to-identity (suc n) rewrite\n    inc-suc-law (to n)\n  | from-to-identity n = refl\n\n", "meta": {"hexsha": "4c1eae40d2fb2a16d8370a07ec18878b67746772", "size": 835, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/plfa/part1/Bin.agda", "max_stars_repo_name": "abolotina/plfa.github.io", "max_stars_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/plfa/part1/Bin.agda", "max_issues_repo_name": "abolotina/plfa.github.io", "max_issues_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plfa/part1/Bin.agda", "max_forks_repo_name": "abolotina/plfa.github.io", "max_forks_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.875, "max_line_length": 51, "alphanum_fraction": 0.5880239521, "num_tokens": 326, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802507195636, "lm_q2_score": 0.8289388146603364, "lm_q1q2_score": 0.7613639303204036}}
{"text": "-- {-# OPTIONS -v tc.constr.findInScope:50 #-}\nmodule 06-listEquality where\n\ninfixr 5 _\u2237_\n\ndata List (A : Set) : Set where\n  []  : List A\n  _\u2237_ : (x : A) (xs : List A) \u2192 List A\n\ndata Bool : Set where\n  true : Bool\n  false : Bool\n\nid : {A : Set} \u2192 A \u2192 A\nid v = v\n\nor : Bool \u2192 Bool \u2192 Bool\nor true _ = true\nor _ true = true\nor false false = false\n\nand : Bool \u2192 Bool \u2192 Bool\nand false _ = false\nand _ false = false\nand true true = false\n\nnot : Bool \u2192 Bool\nnot true = false\nnot false = true\n\nrecord Eq (A : Set) : Set where\n  field eq : A \u2192 A \u2192 Bool\n\nlistEq : {A : Set} \u2192 Eq A \u2192 Eq (List A)\nlistEq {A} eqA = record { eq = eq' } where\n  eq' : List A \u2192 List A \u2192 Bool\n  eq' [] [] = true\n  eq' (a \u2237 as) (b \u2237 bs) = and (Eq.eq eqA a b) (eq' as bs)\n  eq' _ _ = false\n\nprimEqBool : Bool \u2192 Bool \u2192 Bool\nprimEqBool true = id\nprimEqBool false = not\n\neqBool : Eq Bool\neqBool = record { eq = primEqBool }\n\nopen Eq {{...}}\n\ntest = eq (true \u2237 false \u2237 true \u2237 []) (true \u2237 false \u2237 [])\n  where listBoolEq = listEq eqBool\n", "meta": {"hexsha": "15133c8c8bc723cddcc02192889170309b28540e", "size": 995, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/instance-arguments/06-listEquality.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/instance-arguments/06-listEquality.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/instance-arguments/06-listEquality.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 19.1346153846, "max_line_length": 57, "alphanum_fraction": 0.5869346734, "num_tokens": 364, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802440252811, "lm_q2_score": 0.8289388019824946, "lm_q1q2_score": 0.7613639131269058}}
{"text": "module z where\n\n------------------------------------------------------------------------------\n-- inductive data types and function that are defined by pattern matching\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero  + n =          n\nsuc m + n = suc (m + n)\n\ndata List {\u2113} (A : Set \u2113) : Set \u2113 where\n  []   :                         List A\n  _::_ : (x : A) (xs : List A) \u2192 List A\n\n_#_ : {A : Set} \u2192 List A \u2192 List A \u2192 List A\n[]        # ys =            ys\n(x :: xs) # ys = x :: (xs # ys)\n\nsum : List \u2115 \u2192 List \u2115 \u2192 List \u2115\nsum       []        ys  =                   ys\nsum (x :: xs)       []  =  x      ::     xs\nsum (x :: xs) (y :: ys) = (x + y) :: sum xs ys\n\n-- inductively defined predicates\n-- P over S is a data type S -> Set\n\ndata _reverseOf_ {A : Set} : List A \u2192 List A \u2192 Set where\n  rev-\u039b :       []  reverseOf  []\n  rev-t : {x : A} {xs ys : List A}\n        \u2192       xs  reverseOf  ys\n        \u2192 (x :: xs) reverseOf (ys # (x :: []))\n\ndata _\u2286_ {A : Set} : List A \u2192 List A \u2192 Set where\n  sub-\u039b     : [] \u2286 []\n  sub-right : {n : A} {ys xs : List A}\n            \u2192 ys \u2286 xs \u2192       ys  \u2286 (n :: xs)\n  sub-ind   : {n : A} {ys xs : List A}\n            \u2192 ys \u2286 xs \u2192 (n :: ys) \u2286 (n :: xs)\n\n------------------------------------------------------------------------------\n-- coinductive records and copattern matching\n\n-- inductive pair\nrecord Pair (A B : Set) : Set where\n  constructor _,_\n  field\n    fst : A\n    snd : B\n\n-- coinductive infinite list (e.g., \"stream\")\nrecord Stream (A : Set) : Set where\n  coinductive\n  field\n    hd :        A\n    tl : Stream A\nopen Stream\n\n-- functions cannot be defined inductively (by pattern matching).\n-- use copattern matching [APTS13]\n-- - specify how the result of the function will be observed\n\nzeros : Stream \u2115\nhd zeros = zero\ntl zeros = zeros\n\nnatsFrom : \u2115 \u2192 Stream \u2115\nhd (natsFrom n) = n\ntl (natsFrom n) = natsFrom (suc n)\n\nsumS : Stream \u2115 \u2192 Stream \u2115 \u2192 Stream \u2115\nhd (sumS a b) =       hd a + hd b\ntl (sumS a b) = sumS (tl a) (tl b)\n\n------------------------------------------------------------------------------\n-- possibly infinite streams\n\n--open import Codata.Thunk\nopen import Size\nopen import Relation.Unary\n\n{-\nA thunk is a coinductive record with only one field, the suspended computation.\nTakes a function from Size to Set (e.g., Colist A).\nAccessing forces the computation and implicitly decreases the size.\n'Size < i' represents all the sizes smaller than i.\n-}\nrecord Thunk {\u2113} (F : Size \u2192 Set \u2113) (i : Size) : Set \u2113 where\n  coinductive\n  field force : {j : Size< i} \u2192 F j\nopen Thunk public\n\n-- 'Size' represents an approximation level.\n-- - Can be \u221e.\n-- - Can help termination checker by tracking depth of data structures.\n-- 'Thunk' simulates laziness\ndata Colist {a} (A : Set a) (i : Size) : Set a where\n  []   : Colist A i\n  _::_ : A \u2192 Thunk (Colist A) i \u2192 Colist A i\n\n{-\nAlternative Colist impl: follows pattern used for coinductive types.\nTo represent a structure which can be either finite or infinite, use a coinductive record\nwith a field representing the whole observation which can be made on the structure.\nThis field is typically a variant type, since the observation can take different shapes,\ne.g., if colist is non-empty then observe the pair consisting of head and tail, otherwise nothing.\n-}\nopen import Data.Maybe\nopen import Data.Product\n\nrecord MyColist (A : Set) : Set where\n  constructor CoL_\n  coinductive\n  field\n    list : Maybe (A \u00d7 MyColist A)\n\n-- Either of these two approaches can be used for possibly infinite structures.\n\ndata StreamT {\u2113} (A : Set \u2113) (i : Size) : Set \u2113 where\n  _::_ : A \u2192 Thunk (StreamT A) i \u2192 StreamT A i\n\nrecord MyStream_bis (A : Set) : Set where\n  coinductive\n  field\n    stream : A \u00d7 (MyStream_bis A)\n\n------------------------------------------------------------------------------\n-- equality properties\n\n-- stdlib equality and properties\n\ndata _\u2261_ {a} {A : Set a} (x : A) : A \u2192 Set a where\n  instance refl : x \u2261 x\n\n-- Each property is a function that takes proofs as input and returns a new proof.\n\nsym : \u2200 {A : Set} {x y : A} \u2192 x \u2261 y \u2192 y \u2261 x\nsym refl = refl\n\ntrans : \u2200 {A : Set} {x y z : A} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\ntrans refl refl = refl\n\ncong : \u2200 {A B : Set} (f : A \u2192 B) {x y : A} \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\nsubst : \u2200 {A : Set} {x y : A} (P : A \u2192 Set) \u2192 x \u2261 y \u2192 P x \u2192 P y\nsubst P refl px = px\n\n------------------------------------------------------------------------------\n-- Chapter 2 - Inductive reasoning\n\ndata _memberOf_ {A : Set} : A \u2192 List A \u2192 Set where\n  mem-h : {x   : A} \u2192 {xs : List A} \u2192 x memberOf     (x            :: xs)\n  mem-t : {x y : A} \u2192 {xs : List A} \u2192 x memberOf xs \u2192 x memberOf(y :: xs)\n", "meta": {"hexsha": "02856f45b85997380ba005bb928eda87a62a27a6", "size": 4639, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/paper/2020-02-luca-ciccone-flexible-coinduction-in-agda/z.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/paper/2020-02-luca-ciccone-flexible-coinduction-in-agda/z.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/paper/2020-02-luca-ciccone-flexible-coinduction-in-agda/z.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 29.5477707006, "max_line_length": 98, "alphanum_fraction": 0.5442983402, "num_tokens": 1395, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314647623016, "lm_q2_score": 0.8596637487122111, "lm_q1q2_score": 0.7613452649750466}}
{"text": "module Numeral.PositiveInteger.Oper where\n\nopen import Numeral.PositiveInteger\n\ninfixl 10010 _+_\ninfixl 10020 _\u22c5_\ninfixl 10030 _^_\n\n-- Addition\n_+_ : \u2115\u208a \u2192 \u2115\u208a \u2192 \u2115\u208a\nx + \ud835\udfcf    = \ud835\udc12(x)\nx + \ud835\udc12(y) = \ud835\udc12(x + y)\n\n-- Multiplication\n_\u22c5_ : \u2115\u208a \u2192 \u2115\u208a \u2192 \u2115\u208a\nx \u22c5 \ud835\udfcf    = x\nx \u22c5 \ud835\udc12(y) = x + (x \u22c5 y)\n\n-- Exponentiation\n_^_ : \u2115\u208a \u2192 \u2115\u208a \u2192 \u2115\u208a\nx ^ \ud835\udfcf    = x\nx ^ \ud835\udc12(y) = x \u22c5 (x ^ y)\n\n-- Factorial\n_! : \u2115\u208a \u2192 \u2115\u208a\n\ud835\udfcf !    = \ud835\udfcf\n\ud835\udc12(x) ! = \ud835\udc12(x) \u22c5 (x !)\n\nopen import Data.Option\nopen import Data.Option.Functions\n-- Truncated subtraction\n_\u2212\u2080_ : \u2115\u208a \u2192 \u2115\u208a \u2192 Option(\u2115\u208a)\n\ud835\udfcf    \u2212\u2080 _    = None\n\ud835\udc12(x) \u2212\u2080 \ud835\udfcf    = Some x\n\ud835\udc12(x) \u2212\u2080 \ud835\udc12(y) = x \u2212\u2080 y\n\nopen import Data.Boolean\nopen import Type\n_\u2264?_ : \u2115\u208a \u2192 \u2115\u208a \u2192 Bool\n\ud835\udfcf    \u2264? _    = \ud835\udc47\n\ud835\udc12(x) \u2264? \ud835\udfcf    = \ud835\udc39\n\ud835\udc12(x) \u2264? \ud835\udc12(y) = x \u2264? y\n", "meta": {"hexsha": "d4c6172b98513180cb52dce565ed2ecbedb3e61e", "size": 704, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/PositiveInteger/Oper.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/PositiveInteger/Oper.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/PositiveInteger/Oper.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.3720930233, "max_line_length": 41, "alphanum_fraction": 0.5213068182, "num_tokens": 391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9693242000616579, "lm_q2_score": 0.7853085859124002, "lm_q1q2_score": 0.761218616841089}}
{"text": "module Numeral.Natural.Induction{\u2113} where\n\nopen import Logic\nopen import Logic.Propositional\nopen import Functional\nopen import Numeral.Natural\n\n-- The induction proof method on natural numbers\n-- TODO: There seems to be a problem making i implicit with unsolved metas.\n-- TODO: Maybe rename to elim because this is the elimination rule for \u2115\n\u2115-elim : \u2200{T : \u2115 \u2192 Stmt{\u2113}} \u2192 T(\ud835\udfce) \u2192 ((i : \u2115) \u2192 T(i) \u2192 T(\ud835\udc12(i))) \u2192 ((n : \u2115) \u2192 T(n))\n\u2115-elim {T} base step \ud835\udfce      = base\n\u2115-elim {T} base step (\ud835\udc12(n)) = step n (\u2115-elim {T} base step n)\n\n[\u2115]-induction : \u2200{\u03c6 : \u2115 \u2192 Stmt{\u2113}} \u2192 \u03c6(\ud835\udfce) \u2192 (\u2200(i : \u2115) \u2192 \u03c6(i) \u2192 \u03c6(\ud835\udc12(i))) \u2192 (\u2200{n} \u2192 \u03c6(n))\n[\u2115]-induction {\u03c6} base step {n} = \u2115-elim {\u03c6} base step n\n\n[\u2115]-induction\u1d62 : \u2200{\u03c6 : \u2115 \u2192 Stmt{\u2113}} \u2192 \u03c6(\ud835\udfce) \u2192 (\u2200{i : \u2115} \u2192 \u03c6(i) \u2192 \u03c6(\ud835\udc12(i))) \u2192 (\u2200{n} \u2192 \u03c6(n))\n[\u2115]-induction\u1d62 {\u03c6} base step = [\u2115]-induction {\u03c6} base (i \u21a6 step{i})\n", "meta": {"hexsha": "b5cabb5dcdd4326ab715819f924180132e6ad3e5", "size": 827, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Induction.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Induction.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Induction.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.35, "max_line_length": 88, "alphanum_fraction": 0.592503023, "num_tokens": 347, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9390248157222396, "lm_q2_score": 0.8104789063814616, "lm_q1q2_score": 0.7610598057116142}}
{"text": "module Dave.Algebra.Naturals.Addition where  \n  open import Dave.Algebra.Naturals.Definition public\n  open import Dave.Extensionality\n\n  _+_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  zero + b = b\n  suc a + b = suc (a + b)\n\n  infixl 6 _+_\n\n  {- Semigroup -}\n  +-assoc : associative _+_\n  +-assoc zero n p = refl\n  +-assoc (suc m) n p = cong suc (+-assoc m n p)\n\n  +-assoc' : associative _+_\n  +-assoc' zero n p = begin\n    (zero + n) + p \u2261\u27e8\u27e9\n    n + p \u2261\u27e8\u27e9\n    zero + (n + p) \u220e\n  +-assoc' (suc m) n p = begin\n    (suc m + n) + p \u2261\u27e8\u27e9\n    suc (m + n) + p \u2261\u27e8\u27e9\n    suc ((m + n) + p) \u2261\u27e8 cong suc (+-assoc' m n p) \u27e9\n    suc (m + (n + p)) \u220e\n   \n  \u2115-+-IsSemigroup : IsSemigroup _+_\n  IsSemigroup.assoc \u2115-+-IsSemigroup = +-assoc\n\n  \u2115-+-Semigroup : Semigroup\n  Semigroup.Carrier \u2115-+-Semigroup = \u2115\n  Semigroup._\u00b7_ \u2115-+-Semigroup = _+_\n  Semigroup.isSemigroup \u2115-+-Semigroup = \u2115-+-IsSemigroup\n\n  {- Identity -}\n  +-right-identity : right-identity _+_ 0\n  +-right-identity zero = refl\n  +-right-identity (suc n) = cong suc (+-right-identity n)\n\n  +-left-identity : left-identity _+_ 0\n  +-left-identity m = refl\n\n  \u2115-+-HasIdentity : Identity _+_ 0\n  Identity.left \u2115-+-HasIdentity = +-left-identity\n  Identity.right \u2115-+-HasIdentity = +-right-identity\n\n  {- Monoid -}\n  \u2115-+-IsMonoid : IsMonoid _+_ 0\n  IsMonoid.semigroup \u2115-+-IsMonoid = \u2115-+-IsSemigroup\n  IsMonoid.identity \u2115-+-IsMonoid = \u2115-+-HasIdentity\n\n  \u2115-+-Monoid : Monoid\n  Monoid.Carrier \u2115-+-Monoid = \u2115\n  Monoid._\u00b7_ \u2115-+-Monoid = _+_\n  Monoid.e \u2115-+-Monoid = 0\n  Monoid.isMonoid \u2115-+-Monoid = \u2115-+-IsMonoid\n\n  {- Commutative Monoid -}\n  +-suc : \u2200 (m n : \u2115) \u2192 m + suc n \u2261 suc (m + n)\n  +-suc zero n = refl\n  +-suc (suc m) n = cong suc (+-suc m n)\n\n  +-comm : commutative _+_\n  +-comm m zero = +-right-identity m\n  +-comm m (suc n) = trans (+-suc m n) (cong suc (+-comm m n))\n\n  +-comm' : commutative _+_\n  +-comm' m zero = +-right-identity m\n  +-comm' m (suc n) = begin\n      (m + suc n) \u2261\u27e8 +-suc m n \u27e9\n      suc (m + n) \u2261\u27e8 cong suc (+-comm' m n) \u27e9\n      suc (n + m) \u220e\n\n  \u2115-+-IsCommutativeMonoid : IsCommutativeMonoid _+_ 0\n  IsCommutativeMonoid.isSemigroup \u2115-+-IsCommutativeMonoid = \u2115-+-IsSemigroup\n  IsCommutativeMonoid.leftIdentity \u2115-+-IsCommutativeMonoid = +-left-identity\n  IsCommutativeMonoid.comm \u2115-+-IsCommutativeMonoid = +-comm\n\n  {- Additional Theorems -}\n  +-add1\u1d63 : \u2200 (m : \u2115) \u2192 m + 1 \u2261 suc m\n  +-add1\u1d63 zero = refl\n  +-add1\u1d63 (suc m) = cong suc (+-add1\u1d63 m)\n\n  +-add1\u2097 : \u2200 (m : \u2115) \u2192 1 + m \u2261 suc m\n  +-add1\u2097 m = refl\n\n  {- Another equal Addition Definition -}\n  _+\u00b4_ : \u2115 \u2192 \u2115 \u2192 \u2115\n  m +\u00b4 zero = m\n  m +\u00b4 suc n = suc (m +\u00b4 n)\n\n  app-+\u2261+\u00b4 : \u2200 (m n : \u2115) \u2192 m + n \u2261 m +\u00b4 n\n  app-+\u2261+\u00b4 zero zero = refl\n  app-+\u2261+\u00b4 zero (suc n) = cong suc (app-+\u2261+\u00b4 zero n)\n  app-+\u2261+\u00b4 (suc m) zero = cong suc (app-+\u2261+\u00b4 m zero)\n  app-+\u2261+\u00b4 (suc m) (suc n) = cong suc ( \n    begin\n      m + suc n \u2261\u27e8 +-suc m n \u27e9\n      suc m + n \u2261\u27e8 app-+\u2261+\u00b4 (suc m) n \u27e9\n      suc m +\u00b4 n \u220e )\n\n  +\u2261+\u00b4 : _+_ \u2261 _+\u00b4_\n  +\u2261+\u00b4 = extensionality (\u03bb m \u2192 extensionality (\u03bb n \u2192 app-+\u2261+\u00b4 m n))\n  ", "meta": {"hexsha": "afbe5a867ed49fc87df673b4079d78536acd51b9", "size": 2945, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Dave/Algebra/Naturals/Addition.agda", "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Dave/Algebra/Naturals/Addition.agda", "max_issues_repo_name": "DavidStahl97/formal-proofs", "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Dave/Algebra/Naturals/Addition.agda", "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.3173076923, "max_line_length": 76, "alphanum_fraction": 0.5643463497, "num_tokens": 1236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750440288019, "lm_q2_score": 0.7981867801399695, "lm_q1q2_score": 0.7608915379811371}}
{"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nmodule Basic_Types where\n\n-- Already in the builtin's of agda, there are \u03a0 types, which is \u2200, and lambda\n-- abstraction, which is \u03bb{ } and function types, which is \u2192.\n\n\n-- ------------------------------------\n-- Some operations for function types\n-- The curly brackts \u2200{} should be viewed as contexts.\n\n-- identity function\nid : \u2200 {A : Set} \u2192 A \u2192 A\nid = \u03bb{ x \u2192 x }\n\n-- function composition\ncomp : \u2200 {A B C : Set} \u2192 (B \u2192 C) \u2192 (A \u2192 B) \u2192 A \u2192 C\ncomp {A} {B} {C} = \u03bb (f : B \u2192 C) (g : A \u2192 B) (x : A) \u2192 f (g x)\n-- The judgemental equality of association of functions is builtin in agda,\n-- i.e., all the rules of derivation in the basic language of type theory,\n-- e.g., the \u03b2-, \u03b7- reduction is automatic in agda.\n\n-- swapping the argument\nswap : \u2200 {A B : Set} {C : A \u2192 B \u2192 Set} \u2192\n      (\u2200 (a : A) (b : B) \u2192 C a b) \u2192 (\u2200 (b : B) (a : A) \u2192 C a b)\nswap {A} {B} {C} = \u03bb { p \u2192 \u03bb (b : B) (a : A) \u2192 p a b }\n\n\n-- ------------------------------------\n-- the unit type\ndata \ud835\udfd9 : Set where\n  \u22c6 : \ud835\udfd9\n\n\ud835\udfd9-ind : \u2200 {A : \ud835\udfd9 \u2192 Set} \u2192 \u2200 (a : A \u22c6) \u2192 \u2200 (x : \ud835\udfd9) \u2192 A x\n\ud835\udfd9-ind {A} a = \ud835\udfd9-indhelper\n  where \ud835\udfd9-indhelper : \u2200 (x : \ud835\udfd9) \u2192 A x\n        \ud835\udfd9-indhelper \u22c6 = a\n\n-- ------------------------------------\n-- the empty type\ndata \ud835\udfd8 : Set where\n\n\ud835\udfd8-ind : \u2200 {A : \ud835\udfd8 \u2192 Set} \u2192 \u2200 (x : \ud835\udfd8) \u2192 A x\n\ud835\udfd8-ind {A} ()\n\n-- define negation\n\u00ac_ : \u2200 (A : Set) \u2192 Set\n\u00ac A = A \u2192 \ud835\udfd8\n\n-- ------------------------------------\n-- the boolean type\ndata \ud835\udfda : Set where\n  tt ff : \ud835\udfda\n\n\ud835\udfda-ind : \u2200 {A : \ud835\udfda \u2192 Set} \u2192 A ff \u2192 A tt \u2192 \u2200 (x : \ud835\udfda) \u2192 A x\n\ud835\udfda-ind Aff _ ff = Aff\n\ud835\udfda-ind _ Att tt = Att\n\n-- ------------------------------------\n-- natural numbers\ndata \u2115 : Set where\n  zero : \u2115\n  succ : \u2115 \u2192 \u2115\n\n{-# BUILTIN NATURAL \u2115 #-}\n\n-- \u2115 induction\n\u2115-ind : \u2200 {A : \u2115 \u2192 Set} \u2192\n        \u2200 (a : A 0) \u2192 (\u2200 (n : \u2115) \u2192 A n \u2192 A (succ n)) \u2192 \u2200 (m : \u2115) \u2192 A m\n\u2115-ind {A} a p = \u2115-indhelper\n  where \u2115-indhelper : \u2200 (m : \u2115) \u2192 A m\n        \u2115-indhelper 0        = a\n        \u2115-indhelper (succ n) = p n (\u2115-indhelper n)\n-- From this exercise, we can actually see that the idea of induction is\n-- builtin in agda, since we essentially use the induction builtin in agda\n-- to prove \u2115-ind.\n\n-- \u2115 recursion, which is a special case for \u2115 induction, where the type is not\n-- dependent on \u2115\n\u2115-rec : \u2200 {A : Set} \u2192\n        \u2200 (a : A) \u2192 (\u2200 (n : \u2115) \u2192 A \u2192 A) \u2192 \u2200 (m : \u2115) \u2192 A\n\u2115-rec {A} = \u2115-ind {\u03bb { n \u2192 A }}\n\n-- for example, we can use \u2115-rec to define addition\nadd : \u2115 \u2192 \u2115 \u2192 \u2115\nadd = \u2115-rec {\u2115 \u2192 \u2115} (id {\u2115}) (\u03bb (n : \u2115) (p : \u2115 \u2192 \u2115) \u2192 comp succ p)\n\n-- ------------------------------------\n-- the sum type\nrecord \u03a3 (A : Set) (B : A \u2192 Set) : Set where\n  constructor\n    _,_\n  field\n    a : A\n    b : B a\n\n-- the two projections\n\u03c0\u2081 : \u2200 {A : Set} {B : A \u2192 Set} \u2192 \u03a3 A B \u2192 A\n\u03c0\u2081 (x , y) = x\n\n\u03c0\u2082 : \u2200 {A : Set} {B : A \u2192 Set} \u2192 \u2200 (z : \u03a3 A B) \u2192 B (\u03c0\u2081 z)\n\u03c0\u2082 (x , y) = y\n\nsyntax \u03a3 A (\u03bb a \u2192 b) = \u03a3 a \u2236 A , b\n\n-- \u03a3 induction\n\u03a3-ind : \u2200 {A : Set} {B : A \u2192 Set} {P : \u03a3 A B \u2192 Set} \u2192\n       (\u2200 (a : A) (b : B a) \u2192 P (a , b)) \u2192 \u2200 (z : \u03a3 A B) \u2192 P z\n\u03a3-ind {A} {B} {P} = \u03bb (f : \u2200 (a : A) (b : B a) \u2192 P (a , b)) \u2192\n                    \u03bb (z : \u03a3 A B) \u2192 f (\u03c0\u2081 z) (\u03c0\u2082 z)\n\n-- cartesion product type\n_\u00d7_ : Set \u2192 Set \u2192 Set\nA \u00d7 B = \u03a3 a \u2236 A , B\n\n\u00d7-ind : \u2200 {A : Set} {B : Set} {P : A \u00d7 B \u2192 Set} \u2192\n       (\u2200 (a : A) (b : B) \u2192 P (a , b)) \u2192 \u2200 (z : A \u00d7 B) \u2192 P z\n\u00d7-ind {A} {B} {P} = \u03a3-ind {A} {\u03bb (a : A) \u2192 B} {P}\n\n-- ------------------------------------\n-- the coproduct type\n\ndata _\u228e_ (A : Set) (B : Set) : Set where\n  inl : A \u2192 A \u228e B\n  inr : B \u2192 A \u228e B\n\n\u228e-ind : \u2200 {A : Set} {B : Set} {P : A \u228e B \u2192 Set} \u2192\n       (\u2200 (a : A) \u2192 P (inl a)) \u2192 (\u2200 (b : B) \u2192 P (inr b)) \u2192\n        \u2200 (u : A \u228e B) \u2192 P u\n\u228e-ind f _ (inl x) = f x\n\u228e-ind _ g (inr y) = g y\n", "meta": {"hexsha": "3915693ceb51f001de8ce12b4ac883debedc76a5", "size": 3613, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "HoTT/Basic_Types.agda", "max_stars_repo_name": "andyfreeyy/agda_and_math", "max_stars_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-03-23T09:01:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-24T10:56:36.000Z", "max_issues_repo_path": "HoTT/Basic_Types.agda", "max_issues_repo_name": "andyfreeyy/agda_and_math", "max_issues_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "HoTT/Basic_Types.agda", "max_forks_repo_name": "andyfreeyy/agda_and_math", "max_forks_repo_head_hexsha": "76b9ef64626b6d3bbb7ace4f1a16aeb447c54328", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.1654135338, "max_line_length": 78, "alphanum_fraction": 0.4439523941, "num_tokens": 1474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213853793453, "lm_q2_score": 0.8459424431344437, "lm_q1q2_score": 0.760604941422229}}
{"text": "module Structure.Setoid.Uniqueness where\n\nimport      Lvl\nopen import Functional\nopen import Logic\nopen import Logic.Propositional\nopen import Logic.Predicate\nopen import Structure.Setoid\nopen import Type\n\nprivate variable \u2113\u2097 \u2113\u2097\u2081 \u2113\u2097\u2082 : Lvl.Level\n\nmodule _ {\u2113\u2081}{\u2113\u2082} where\n  -- Definition of uniqueness of a property.\n  -- This means that there is at most one element that satisfies this property.\n  -- This is similiar to \"Injective\" for functions.\n  Unique : \u2200{Obj : Type{\u2113\u2081}}{\u2113\u2097} \u2192 \u2983 equiv : Equiv{\u2113\u2097}(Obj) \u2984 \u2192 (Pred : Obj \u2192 Stmt{\u2113\u2082}) \u2192 Stmt\n  Unique {Obj = Obj} Pred = \u2200{x y : Obj} \u2192 Pred(x) \u2192 Pred(y) \u2192 (x \u2261 y)\n\n  -- Definition of existence of an unique element satisfying a property.\n  -- This means that there is one and only one element that satisfies this property.\n  \u2203! : \u2200{Obj : Type{\u2113\u2081}}{\u2113\u2097} \u2192 \u2983 equiv : Equiv{\u2113\u2097}(Obj) \u2984 \u2192 (Pred : Obj \u2192 Stmt{\u2113\u2082}) \u2192 Stmt\n  \u2203! {Obj} Pred = \u2203(Pred) \u2227 Unique(Pred)\n\n  [\u2203!]-intro : \u2200{T} \u2192 \u2983 _ : Equiv{\u2113\u2097}(T) \u2984 \u2192 \u2200{property} \u2192 \u2203(property) \u2192 Unique{T}(property) \u2192 \u2203!(property)\n  [\u2203!]-intro = [\u2227]-intro\n\n  [\u2203!]-existence : \u2200{Obj} \u2192 \u2983 _ : Equiv{\u2113\u2097}(Obj) \u2984 \u2192 \u2200{Pred} \u2192 \u2203!{Obj}(Pred) \u2192 \u2203(Pred)\n  [\u2203!]-existence  = [\u2227]-elim\u2097\n\n  [\u2203!]-uniqueness : \u2200{Obj} \u2192 \u2983 _ : Equiv{\u2113\u2097}(Obj) \u2984 \u2192 \u2200{Pred} \u2192 \u2203!{Obj}(Pred) \u2192 Unique(Pred)\n  [\u2203!]-uniqueness = [\u2227]-elim\u1d63\n\n  [\u2203!]-witness : \u2200{Obj} \u2192 \u2983 _ : Equiv{\u2113\u2097}(Obj) \u2984 \u2192 \u2200{Pred} \u2192 \u2203!{Obj}(Pred) \u2192 Obj\n  [\u2203!]-witness e = [\u2203]-witness ([\u2203!]-existence e)\n\n  [\u2203!]-proof : \u2200{Obj} \u2192 \u2983 _ : Equiv{\u2113\u2097}(Obj) \u2984 \u2192 \u2200{Pred} \u2192 (e : \u2203!{Obj}(Pred)) \u2192 Pred([\u2203!]-witness(e))\n  [\u2203!]-proof e = [\u2203]-proof ([\u2203!]-existence e)\n\n  [\u2203!]-existence-eq : \u2200{T} \u2192 \u2983 _ : Equiv{\u2113\u2097}(T) \u2984 \u2192 \u2200{P} \u2192 (e : \u2203!(P)) \u2192 \u2200{x} \u2192 P(x) \u2192 (x \u2261 [\u2203!]-witness e)\n  [\u2203!]-existence-eq e {x} px = [\u2203!]-uniqueness e {x} {[\u2203!]-witness e} px ([\u2203!]-proof e)\n\n  [\u2203!]-existence-eq-any : \u2200{T} \u2192 \u2983 _ : Equiv{\u2113\u2097}(T) \u2984 \u2192 \u2200{P} \u2192 (e : \u2203!(P)) \u2192 \u2200{x} \u2192 P(x) \u2192 ([\u2203!]-witness e \u2261 x)\n  [\u2203!]-existence-eq-any e {x} px = [\u2203!]-uniqueness e {[\u2203!]-witness e} {x} ([\u2203!]-proof e) px\n\n  -- TODO: [\u2203!]-equivalence {T} property = \u2203(a \u21a6 \u2203{property(a)}(pa \u21a6 pa \u2227 Uniqueness{T}(property){a}(pa)))\n", "meta": {"hexsha": "6adb16b7a2b6614c7d0abdd30760a22736a25f01", "size": 2073, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Structure/Setoid/Uniqueness.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Structure/Setoid/Uniqueness.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Structure/Setoid/Uniqueness.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.1063829787, "max_line_length": 111, "alphanum_fraction": 0.5504100338, "num_tokens": 943, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894661025424, "lm_q2_score": 0.849971181358171, "lm_q1q2_score": 0.7605452595700251}}
{"text": "--------------------------------------------------------------------------------\n-- This is part of Agda Inference Systems\n\nopen import Data.Nat\nopen import Relation.Binary.PropositionalEquality\nopen import Data.Sum\n\nmodule Examples.Colists.Auxiliary.MaxOf where\n\n  max : \u2115 \u2192 \u2115 \u2192 \u2115\n  max zero zero = zero\n  max zero (suc y) = suc y\n  max (suc x) zero = suc x\n  max (suc x) (suc y) = suc (max x y)\n\n  max-refl : (x y : \u2115) \u2192 (x \u2261 max x y) \u228e (y \u2261 max x y)\n  max-refl zero zero = inj\u2082 refl\n  max-refl zero (suc y) = inj\u2082 refl\n  max-refl (suc x) zero = inj\u2081 refl\n  max-refl (suc x) (suc y) with max-refl x y\n  max-refl (suc x) (suc y) | inj\u2081 eq = inj\u2081 (cong (\u03bb x\u2081 \u2192 suc x\u2081) eq)\n  max-refl (suc x) (suc y) | inj\u2082 eq = inj\u2082 (cong (\u03bb x\u2081 \u2192 suc x\u2081) eq)\n\n  max-refl-eq : \u2200{x y z} \u2192 z \u2261 max x y \u2192 z \u2261 x \u228e z \u2261 y\n  max-refl-eq {x} {y} {z} refl with max-refl x y\n  max-refl-eq {x} {y} {.(max x y)} refl | inj\u2081 x\u2081 = inj\u2081 (sym x\u2081)\n  max-refl-eq {x} {y} {.(max x y)} refl | inj\u2082 y\u2081 = inj\u2082 (sym y\u2081)\n\n  max-self : \u2200 {n} \u2192 n \u2261 max n n\n  max-self {zero} = refl\n  max-self {suc n} = cong (\u03bb x \u2192 suc x) max-self\n\n  max-trans : \u2200{x y z} \u2192 y \u2261 max y z \u2192 x \u2261 max x y \u2192 x \u2261 max x z\n  max-trans {zero} {zero} {zero} _ _ = refl\n  max-trans {suc x} {zero} {zero} refl refl = refl\n  max-trans {suc x} {suc y} {zero} refl _ = refl\n  max-trans {suc x} {suc y} {suc z} eq eq1 =\n    let eq-pred = cong pred eq in\n    let eq1-pred = cong pred eq1 in\n    cong suc (max-trans eq-pred eq1-pred)\n\n  max-comm : \u2200{x y z} \u2192 x \u2261 max y z \u2192 x \u2261 max z y\n  max-comm {x} {zero} {zero} eq = eq\n  max-comm {x} {suc y} {zero} eq = eq\n  max-comm {x} {zero} {suc z} eq = eq\n  max-comm {suc x} {suc y} {suc z} eq = cong suc (max-comm (cong pred eq))", "meta": {"hexsha": "fe01bdc8693c343ab9fdccfbf4b2fe33c4f69b75", "size": 1693, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_issues_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_issues_repo_name": "LcicC/inference-systems-agda", "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.8043478261, "max_line_length": 80, "alphanum_fraction": 0.5528647372, "num_tokens": 686, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009480320036, "lm_q2_score": 0.8311430499496095, "lm_q1q2_score": 0.7604135643491087}}
{"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule BubbleSort.Correctness.Permutation {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_) where\n\nopen import BubbleSort _\u2264_ tot\u2264\nopen import Data.Product\nopen import Data.List\nopen import Data.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Equivalence A\nopen import Size\nopen import SList\nopen import SList.Properties A\nopen import SList.Concatenation A\n\nlemma-swap*\u223c : {\u03b9 : Size}(x : A) \u2192 (xs : SList A {\u03b9}) \u2192 unsize A (x \u2219 xs) \u223c unsize A (proj\u2082 (swap* x xs) \u2219 proj\u2081 (swap* x xs))\nlemma-swap*\u223c x snil = \u223cx /head /head \u223c[]\nlemma-swap*\u223c x (y \u2219 ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = \u223cx /head (/tail /head) (lemma-swap*\u223c y ys)\n... | inj\u2082 y\u2264x = \u223cx (/tail /head) (/tail /head) (lemma-swap*\u223c x ys)\n\nlemma-bubbleSort\u223c : {\u03b9 : Size}(xs : SList A {\u03b9}) \u2192 unsize A xs \u223c unsize A (bubbleSort xs)\nlemma-bubbleSort\u223c snil = \u223c[]\nlemma-bubbleSort\u223c (x \u2219 xs) = trans\u223c (lemma-swap*\u223c x xs) (trans\u223c (lemma-\u2295\u223c y (lemma-bubbleSort\u223c ys)) (lemma-size-unsize y (bubbleSort ys)))\n                  where sxxs = swap* x xs\n                        ys = proj\u2081 sxxs\n                        y = proj\u2082 sxxs\n\ntheorem-bubbleSort\u223c : (xs : List A) \u2192 xs \u223c unsize A (bubbleSort (size A xs))\ntheorem-bubbleSort\u223c xs = trans\u223c (lemma-unsize-size xs) (lemma-bubbleSort\u223c (size A xs))\n\n\n", "meta": {"hexsha": "72d99f16ad8a6a0335dcfc32cd725eb4c1a0618b", "size": 1369, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BubbleSort/Correctness/Permutation.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BubbleSort/Correctness/Permutation.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BubbleSort/Correctness/Permutation.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.0, "max_line_length": 138, "alphanum_fraction": 0.6128560993, "num_tokens": 481, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632896242073, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.7603389790931454}}
{"text": "{-# OPTIONS --prop --without-K #-}\n\nmodule Data.Nat.Square where\n\nopen import Data.Nat\nopen import Data.Nat.Properties\n\nopen import Relation.Nullary\nopen import Relation.Binary\nopen import Relation.Binary.PropositionalEquality as Eq using (_\u2261_; refl)\n\n_\u00b2 : \u2115 \u2192 \u2115\nn \u00b2 = n * n\n\nn^2\u2261n\u00b2 : \u2200 n \u2192 n ^ 2 \u2261 n \u00b2\nn^2\u2261n\u00b2 n = Eq.cong (n *_) (*-identity\u02b3 n)\n\n\u00b2-mono : _\u00b2 Preserves _\u2264_ \u27f6 _\u2264_\n\u00b2-mono m\u2264n = *-mono-\u2264 m\u2264n m\u2264n\n", "meta": {"hexsha": "f0e82fca790ed677fafb7fdb7a7fd439e09d2aed", "size": 408, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Nat/Square.agda", "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_issues_repo_path": "src/Data/Nat/Square.agda", "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Nat/Square.agda", "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "avg_line_length": 20.4, "max_line_length": 73, "alphanum_fraction": 0.6642156863, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9353465116437761, "lm_q2_score": 0.8128673110375458, "lm_q1q2_score": 0.7603126038082249}}
{"text": "module Numeral.Natural.Relation where\n\nopen import Data.Boolean.Stmt\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper.Comparisons\nopen import Logic.Propositional\nopen import Logic\nimport      Lvl\nopen import Relator.Equals\nopen import Type\n\nPositive : \u2115 \u2192 Stmt\nPositive(n) = IsTrue(positive? n)\n\nzero-not-positive : \u00ac Positive(\ud835\udfce)\nzero-not-positive ()\n\npositive-not-zero : \u2200{n} \u2192 \u2983 _ : Positive(n) \u2984 \u2192 (n \u2262 \ud835\udfce)\npositive-not-zero {\ud835\udfce} \u2983 pos \u2984 _ = pos\n\nnon-zero-positive : \u2200{n} \u2192 (n \u2262 \ud835\udfce) \u2192 Positive(n)\nnon-zero-positive {\ud835\udfce}   p = p [\u2261]-intro\nnon-zero-positive {\ud835\udc12 n} p = [\u22a4]-intro\n", "meta": {"hexsha": "921027508c716cd596f94e5d4bc869e53889cbe5", "size": 587, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Relation.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Relation.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Relation.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.4583333333, "max_line_length": 56, "alphanum_fraction": 0.6984667802, "num_tokens": 200, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9465966671870766, "lm_q2_score": 0.8031737963569016, "lm_q1q2_score": 0.7602816388034348}}
{"text": "open import Data.List\n\n{- --- 6. Vectors --- -}\n\n{- 6.1 Warmup -}\n\n{- Problem: what do we return for the empty list ? -}\nhead2 : {A : Set} \u2192 List A \u2192 A\nhead2 [] = {!!}\nhead2 (x \u2237 l) = x\n\n{- 6.2 Definition -}\nopen import Data.Nat\n\ndata Vec (A : Set) : \u2115 \u2192 Set where\n  [] : Vec A zero\n  _::_ : {n : \u2115} \u2192 A \u2192 Vec A n \u2192 Vec A (suc n)\n\n{- 6.3 Head and tail -}\nhead-vec : {A : Set} \u2192 {n : \u2115} \u2192 Vec A (suc n) \u2192 A\nhead-vec (x :: v) = x\n\ntail-vec : {A : Set} \u2192 {n : \u2115} \u2192 Vec A (suc n) \u2192 Vec A n\ntail-vec (x :: v) = v\n\n{- 6.4 Concatenation -}\nconcat-vec : {A : Set} \u2192 {m n : \u2115} \u2192 Vec A m \u2192 Vec A n \u2192 Vec A (m + n)\nconcat-vec [] v2 = v2\nconcat-vec (x :: v1) v2 = x :: (concat-vec v1 v2)\n\n{- 6.5 Reversal -}\nsnoc-vec : {A : Set} \u2192 {n : \u2115} \u2192 A \u2192 Vec A n \u2192 Vec A (suc n)\nsnoc-vec a [] = a :: []\nsnoc-vec a (x :: v) = x :: (snoc-vec a v)\n\nrev-vec : {A : Set} \u2192 {n : \u2115} \u2192 Vec A n \u2192 Vec A n\nrev-vec [] = []\nrev-vec (x :: v) = snoc-vec x (rev-vec v)\n\n{- 6.6 Accessing an element -}\ndata Fin : \u2115 \u2192 Set where\n  zero : {n : \u2115} \u2192 Fin (suc n)\n  suc : {n : \u2115} (i : Fin n) \u2192 Fin (suc n)\n\n{- 6.7 Zipping -}\nopen import Data.Product hiding (zip)\n\nzip-vec : {A : Set} \u2192 {n : \u2115} \u2192 Vec A n \u2192 Vec A n \u2192 Vec (A \u00d7 A) n\nzip-vec [] [] = []\nzip-vec (x\u2081 :: y\u2081) (x\u2082 :: y\u2082) = (x\u2081 , x\u2082) :: (zip-vec y\u2081 y\u2082)\n", "meta": {"hexsha": "7dbfa743e4eb6b8515652373ad997f9146618130", "size": 1266, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "TD6/Vector.agda", "max_stars_repo_name": "erwinkn/program-eq-proof", "max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TD6/Vector.agda", "max_issues_repo_name": "erwinkn/program-eq-proof", "max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TD6/Vector.agda", "max_forks_repo_name": "erwinkn/program-eq-proof", "max_forks_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8235294118, "max_line_length": 70, "alphanum_fraction": 0.4944707741, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.907312221360624, "lm_q2_score": 0.8376199653600372, "lm_q1q2_score": 0.7599828314268243}}
{"text": "{-# OPTIONS  --sized-types --show-implicit #-}\n\nmodule SizedNatAnnotated where\n\nopen import Size\n\ndata Nat : {i : Size} -> Set where\n  zero : {i : Size} -> Nat {\u2191 i}\n  suc  : {i : Size} -> Nat {i} -> Nat {\u2191 i}\n\n-- subtraction is non size increasing\nsub : {i : Size} -> Nat {i} -> Nat {\u221e} -> Nat {i}\nsub .{\u2191 i} (zero {i})  n       = zero {i}\nsub .{\u2191 i} (suc {i} m) zero    = suc {i} m\nsub .{\u2191 i} (suc {i} m) (suc n) = sub {i} m n\n\n-- div' m n  computes  ceiling(m/(n+1))\ndiv' : {i : Size} -> Nat {i} -> Nat -> Nat {i}\ndiv' .{\u2191 i} (zero {i})  n = zero {i}\ndiv' .{\u2191 i} (suc {i} m) n = suc  {i} (div' {i} (sub {i} m n) n)\n\n", "meta": {"hexsha": "76bde41a1bb83d9ad183c620adf14db6a88e9d36", "size": 619, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/Termination/Sized/SizedNatAnnotated.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/Termination/Sized/SizedNatAnnotated.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/Termination/Sized/SizedNatAnnotated.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 28.1363636364, "max_line_length": 63, "alphanum_fraction": 0.4894991922, "num_tokens": 260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9579122696813394, "lm_q2_score": 0.7931059414036511, "lm_q1q2_score": 0.7597259124277268}}
{"text": "module Data.Nat.Etc where\n\nopen import Data.Nat\nopen import Data.Nat.Properties.Simple\nopen import Function\nopen import Relation.Nullary.Negation using (contradiction; contraposition)\nopen import Relation.Binary\n\nopen import Relation.Binary.PropositionalEquality as PropEq\n    using (_\u2261_; _\u2262_; refl; cong; trans; sym)\nopen PropEq.\u2261-Reasoning\n\n-- exponention\n_^_ : \u2115 \u2192 \u2115 \u2192 \u2115\na ^ zero  = 1\na ^ suc b = a * (a ^ b)\n\n--------------------------------------------------------------------------------\n-- Properties\n--------------------------------------------------------------------------------\n\ndistrib-left-*-+ : \u2200 m n o \u2192 m * (n + o) \u2261 m * n + m * o\ndistrib-left-*-+ m n o =\n        begin\n            m * (n + o)\n        \u2261\u27e8 *-comm m (n + o) \u27e9\n            (n + o) * m\n        \u2261\u27e8 distrib\u02b3-*-+ m n o \u27e9\n            n * m + o * m\n        \u2261\u27e8 cong (flip _+_ (o * m)) (*-comm n m) \u27e9\n            m * n + o * m\n        \u2261\u27e8 cong (_+_ (m * n)) (*-comm o m) \u27e9\n            m * n + m * o\n        \u220e\n{-\nno-zero-divisor : \u2200 m n \u2192 m \u2262 0 \u2192 m * n \u2261 0 \u2192 n \u2261 0\nno-zero-divisor zero    n       p q = contradiction q p\nno-zero-divisor (suc m) zero    p q = refl\nno-zero-divisor (suc m) (suc n) p ()\n\nm^n\u22620 : \u2200 m n \u2192 {m\u22620 : m \u2262 0} \u2192 m ^ n \u2262 0\nm^n\u22620 m zero    {p} = \u03bb ()\nm^n\u22620 m (suc n) {p} = contraposition (no-zero-divisor m (m ^ n) p) (m^n\u22620 m n {p})\n\nm\u2270n\u21d2n<m : (m n : \u2115) \u2192 m \u2270 n \u2192 m > n\nm\u2270n\u21d2n<m zero n p = contradiction p (\u03bb z \u2192 z z\u2264n)\nm\u2270n\u21d2n<m (suc m) zero p = s\u2264s z\u2264n\nm\u2270n\u21d2n<m (suc m) (suc n) p = s\u2264s (m\u2270n\u21d2n<m m n (\u03bb z \u2192 p (s\u2264s z)))\n-}\n\n>\u21d2\u2270 : _>_ \u21d2 _\u2270_\n>\u21d2\u2270 {zero} ()\n>\u21d2\u2270 {suc m} {zero} rel ()\n>\u21d2\u2270 {suc m} {suc n} (s\u2264s rel) (s\u2264s x) = contradiction x (>\u21d2\u2270 rel)\n\n>\u21d2\u2262 : _>_ \u21d2 _\u2262_\n>\u21d2\u2262 {zero}  ()      m\u2261n\n>\u21d2\u2262 {suc m} {zero}   m>n ()\n>\u21d2\u2262 {suc m} {suc n} (s\u2264s m>n) m\u2261n = >\u21d2\u2262 m>n (cong pred m\u2261n)\n\n{-\n\u2270\u21d2> : _\u2270_ \u21d2 _>_\n\u2270\u21d2> {zero}          z\u2270n with z\u2270n z\u2264n\n... | ()\n\u2270\u21d2> {suc m} {zero}  _   = s\u2264s z\u2264n\n\u2270\u21d2> {suc m} {suc n} m\u2270n = s\u2264s (\u2270\u21d2> (m\u2270n \u2218 s\u2264s))\n-}\n{-\n    begin\n        {!   !}\n    \u2261\u27e8 {!   !} \u27e9\n        {!   !}\n    \u2261\u27e8 {!   !} \u27e9\n        {!   !}\n    \u2261\u27e8 {!   !} \u27e9\n        {!   !}\n    \u2261\u27e8 {!   !} \u27e9\n        {!   !}\n    \u220e\n-}\n", "meta": {"hexsha": "b622648bcfa3f87460f5eb7cefe295815c4bffb7", "size": 2082, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "legacy/Data/Nat/Etc.agda", "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_issues_repo_path": "legacy/Data/Nat/Etc.agda", "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "legacy/Data/Nat/Etc.agda", "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "avg_line_length": 25.7037037037, "max_line_length": 82, "alphanum_fraction": 0.3991354467, "num_tokens": 966, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505273888291, "lm_q2_score": 0.8397339656668286, "lm_q1q2_score": 0.7596657749068094}}
{"text": "{-# OPTIONS --copatterns #-}\n\nopen import Common.Size\nopen import Common.Prelude\nopen import Common.Product renaming (proj\u2081 to fst; proj\u2082 to snd)\n\nrecord Stream (i : Size) (A : Set) : Set where\n  coinductive\n  field force : \u2200{j : Size< i} \u2192 A \u00d7 Stream j A\nopen Stream\n\nhead : \u2200{i A} \u2192 Stream (\u2191 i) A \u2192  A\nhead s = fst (force s)\n\ntail : \u2200{i A} \u2192 Stream (\u2191 i) A \u2192 Stream i A\ntail s = snd (force s)\n\nsmap : \u2200{i A B} (f : A \u2192 B) \u2192 Stream i A \u2192 Stream i B\nforce (smap f s) with force s\n... | a , as = f a , smap f as\n\nscanl : \u2200{i A B} (f : B \u2192 A \u2192 B) (b : B) (s : Stream i A) \u2192 Stream i B\nforce (scanl f b s) with force s\n... | a , as = b , scanl f (f b a) as\n\n_!_ : \u2200{A} (s : Stream _ A) (n : Nat) \u2192 A\ns ! zero  = head s\ns ! suc n = tail s ! n\n\n_!!_ : \u2200{A} (s : Stream _ A) (n : Nat) \u2192 A\ns !! n with force s\n_ !! zero  | a , as = a\n_ !! suc n | a , as = as !! n\n\nnats : \u2200{i} \u2192 Stream i Nat\nforce nats = 0 , smap suc nats\n\nsums : Stream _ Nat\nsums = scanl (_+_) 0 (tail nats)\n\nmain : IO Unit\nmain = printNat (sums ! 100)\n-- Expected output, due to Gauss: 5050\n", "meta": {"hexsha": "0252795029122598c91b930a01b8f8e45df6f7fb", "size": 1055, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9772727273, "max_line_length": 70, "alphanum_fraction": 0.5620853081, "num_tokens": 415, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107949104866, "lm_q2_score": 0.8104789086703225, "lm_q1q2_score": 0.7595895822530966}}
{"text": "{-\nThis second-order signature was created from the following second-order syntax description:\n\nsyntax Prod | P\n\ntype\n  _\u2297_ : 2-ary | l40\n\nterm\n  pair : \u03b1  \u03b2  ->  \u03b1 \u2297 \u03b2 | \u27e8_,_\u27e9 \n  fst  : \u03b1 \u2297 \u03b2  ->  \u03b1\n  snd  : \u03b1 \u2297 \u03b2  ->  \u03b2\n\ntheory\n  (f\u03b2) a : \u03b1  b : \u03b2 |> fst (pair(a, b))      = a\n  (s\u03b2) a : \u03b1  b : \u03b2 |> snd (pair(a, b))      = b\n  (p\u03b7) p : \u03b1 \u2297 \u03b2    |> pair (fst(p), snd(p)) = p\n-}\n\nmodule Prod.Signature where\n\nopen import SOAS.Context\n\n-- Type declaration\ndata PT : Set where\n  _\u2297_ : PT \u2192 PT \u2192 PT\ninfixl 40 _\u2297_\n\n\nopen import SOAS.Syntax.Signature PT public\nopen import SOAS.Syntax.Build PT public\n\n-- Operator symbols\ndata P\u2092 : Set where\n  pair\u2092 fst\u2092 snd\u2092 : {\u03b1 \u03b2 : PT} \u2192 P\u2092\n\n-- Term signature\nP:Sig : Signature P\u2092\nP:Sig = sig \u03bb\n  { (pair\u2092 {\u03b1}{\u03b2}) \u2192 (\u22a2\u2080 \u03b1) , (\u22a2\u2080 \u03b2) \u27fc\u2082 \u03b1 \u2297 \u03b2\n  ; (fst\u2092  {\u03b1}{\u03b2}) \u2192 (\u22a2\u2080 \u03b1 \u2297 \u03b2) \u27fc\u2081 \u03b1\n  ; (snd\u2092  {\u03b1}{\u03b2}) \u2192 (\u22a2\u2080 \u03b1 \u2297 \u03b2) \u27fc\u2081 \u03b2\n  }\n\nopen Signature P:Sig public\n", "meta": {"hexsha": "7552e7d313d57a4e47c4e72c0092a3de6cff060d", "size": 881, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "out/Prod/Signature.agda", "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 39, "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_issues_repo_path": "out/Prod/Signature.agda", "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_forks_repo_path": "out/Prod/Signature.agda", "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "avg_line_length": 19.152173913, "max_line_length": 91, "alphanum_fraction": 0.5550510783, "num_tokens": 380, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9372107949104866, "lm_q2_score": 0.8104789063814616, "lm_q1q2_score": 0.7595895801079515}}
{"text": "------------------------------------------------------------------------------\n-- Distributive laws on a binary operation (Stanovsk\u00fd example)\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule DistributiveLaws.README where\n\n------------------------------------------------------------------------------\n-- Description\n\n-- Let _\u00b7_ be a left-associative binary operation which satifies the\n-- left and right distributive axioms:\n--\n-- \u2200 x y z \u2192 x \u2219 (y \u2219 z) \u2261 (x \u2219 y) \u2219 (x \u2219 z)\n-- \u2200 x y z \u2192 (x \u2219 y) \u2219 z \u2261 (x \u2219 z) \u2219 (y \u2219 z).\n\n-- We prove some properties of Stanovsk\u00fd (2008): Task\u00a0B, Lemma\u00a03,\n-- Lemma\u00a04, Lemma\u00a05 (Task\u00a0A) and Lemma\u00a06.\n\n------------------------------------------------------------------------------\n-- The axioms\nopen import DistributiveLaws.Base\n\n-- The interactive and combined proofs\nopen import DistributiveLaws.Lemma3-ATP\nopen import DistributiveLaws.Lemma4-ATP\nopen import DistributiveLaws.Lemma5-ATP\nopen import DistributiveLaws.Lemma6-ATP\nopen import DistributiveLaws.TaskB-AllStepsATP\nopen import DistributiveLaws.TaskB-HalvedStepsATP\nopen import DistributiveLaws.TaskB-I\nopen import DistributiveLaws.TaskB-TopDownATP\n\n-- Unproven theorem by the ATPs\nopen import DistributiveLaws.TaskB.UnprovedATP\n\n------------------------------------------------------------------------------\n-- References:\n--\n-- Stanovsk\u00fd, David (2008). Distributive Groupoids are\n-- Symmetrical-by-Medial: An Elementary Proof. Commentations\n-- Mathematicae Universitatis Carolinae 49.4, pp. 541\u2013546.\n", "meta": {"hexsha": "d66c03388c488dfe49c780a7e2985d934253ae67", "size": 1700, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/DistributiveLaws/README.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/DistributiveLaws/README.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/DistributiveLaws/README.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 36.170212766, "max_line_length": 78, "alphanum_fraction": 0.5488235294, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.926303728259492, "lm_q2_score": 0.8198933447152497, "lm_q1q2_score": 0.7594702619848807}}
{"text": "{-# OPTIONS --without-K #-}\n\nmodule Lecture3 where\n\nimport Lecture2\nopen Lecture2 public\n\ndata unit : U where\n  star : unit\n\n\ud835\udfd9 = unit\n\nind-unit : {i : Level} {P : unit \u2192 UU i} \u2192 P star \u2192 ((x : unit) \u2192 P x)\nind-unit p star = p\n\ndata empty : U where\n\n\ud835\udfd8 = empty\n\nind-empty : {i : Level} {P : empty \u2192 UU i} \u2192 ((x : empty) \u2192 P x)\nind-empty ()\n\n\u00ac : {i : Level} \u2192 UU i \u2192 UU i\n\u00ac A = A \u2192 empty\n\ndata bool : U where\n  true false : bool\n\nnot : bool \u2192 bool\nnot true = false\nnot false = true\n\nind-bool : {i : Level} {P : bool \u2192 UU i} \u2192 P true \u2192 P false \u2192 (x : bool) \u2192 P x\nind-bool Pt Pf true = Pt\nind-bool Pt Pf false = Pf\n\ndata coprod {i j : Level} (A : UU i) (B : UU j) : UU (i \u2294 j)  where\n  inl : A \u2192 coprod A B\n  inr : B \u2192 coprod A B\n\ndata Sigma {i j : Level} (A : UU i) (B : A \u2192 UU j) : UU (i \u2294 j) where\n  dpair : (x : A) \u2192 (B x \u2192 Sigma A B)\n\n\u03a3 = Sigma\n\nind-\u03a3 : {i j k : Level} {A : UU i} {B : A \u2192 UU j} {C : \u03a3 A B \u2192 UU k} \u2192\n  ((x : A) (y : B x) \u2192 C (dpair x y)) \u2192 ((t : \u03a3 A B) \u2192 C t)\nind-\u03a3 f (dpair x y) = f x y\n\npr1 : {i j : Level} {A : UU i} {B : A \u2192 UU j} \u2192 Sigma A B \u2192 A\npr1 (dpair a b) = a\n\npr2 : {i j : Level} {A : UU i} {B : A \u2192 UU j} \u2192 (t : Sigma A B) \u2192 B (pr1 t)\npr2 (dpair a b) = b\n\nweaken : {i j : Level} (A : UU i) (B : UU j) \u2192 (A \u2192 UU j)\nweaken A B = \u03bb a \u2192 B\n\nprod : {i j : Level} (A : UU i) (B : UU j) \u2192 UU (i \u2294 j)\nprod A B = Sigma A (\u03bb a \u2192 B)\n\n_\u00d7_ :  {i j : Level} (A : UU i) (B : UU j) \u2192 UU (i \u2294 j)\nA \u00d7 B = prod A B\n\n-- WARNING, can't use pair in pattern matching as it's not recognized as a ctor\npair : {i j : Level} {A : UU i} {B : UU j} \u2192 A \u2192 (B \u2192 prod A B)\npair a b = dpair a b\n\n-- Pointed types\nU-pt : Type\nU-pt = Sigma U (\u03bb X \u2192 X)\n\n-- Graphs\nGph : Type\nGph = Sigma U (\u03bb X \u2192 (X \u2192 X \u2192 U))\n\n-- Reflexive graphs\nrGph : Type\nrGph = Sigma U (\u03bb X \u2192 Sigma (X \u2192 X \u2192 U) (\u03bb R \u2192 (x : X) \u2192 R x x))\n\n-- Finite sets\nFin : \u2115 \u2192 U\nFin Nzero = empty\nFin (Nsucc n) = coprod (Fin n) unit\n\n-- Observational equality on the natural numbers\nEqN : \u2115 \u2192 (\u2115 \u2192 U)\nEqN Nzero Nzero = \ud835\udfd9\nEqN Nzero (Nsucc n) = \ud835\udfd8\nEqN (Nsucc m) Nzero = \ud835\udfd8\nEqN (Nsucc m) (Nsucc n) = EqN m n\n\n-- The integers\n\u2124 : U\n\u2124 = coprod \u2115 (coprod unit \u2115)\n--         ^         ^^^^ ^\n--     (-\u221e, -1]       0   [1, \u221e)\n--     -(n+1)              n+1\n\n-- Inclusion of the negative integers\nin-neg : \u2115 \u2192 \u2124\nin-neg n = inl n\n\n-- Negative one\nZneg-one : \u2124\nZneg-one = in-neg Nzero\n\n-- Zero\nZzero : \u2124\nZzero = inr (inl star)\n\n-- One\nZone : \u2124\nZone = inr (inr Nzero)\n\n-- Inclusion of the positive integers\nin-pos : \u2115 \u2192 \u2124\nin-pos n = inr (inr n)\n\n-- Since Agda is already strong with nested induction, I dont think we need this definition.\nind-\u2124 : {i : Level} (P : \u2124 \u2192 UU i) \u2192 P Zneg-one \u2192 ((n : \u2115) \u2192 P (inl n) \u2192 P (inl (Nsucc n))) \u2192 P Zzero \u2192 P Zone \u2192 ((n : \u2115) \u2192 P (inr (inr (n))) \u2192 P (inr (inr (Nsucc n)))) \u2192 (k : \u2124) \u2192 P k\nind-\u2124 P p-1 p-S p0 p1 pS (inl Nzero) = p-1\nind-\u2124 P p-1 p-S p0 p1 pS (inl (Nsucc x)) = p-S x (ind-\u2124 P p-1 p-S p0 p1 pS (inl x))\nind-\u2124 P p-1 p-S p0 p1 pS (inr (inl star)) = p0\nind-\u2124 P p-1 p-S p0 p1 pS (inr (inr Nzero)) = p1\nind-\u2124 P p-1 p-S p0 p1 pS (inr (inr (Nsucc x))) = pS x (ind-\u2124 P p-1 p-S p0 p1 pS (inr (inr (x))))\n\nZsucc : \u2124 \u2192 \u2124\nZsucc (inl Nzero) = Zzero\nZsucc (inl (Nsucc x)) = inl x\nZsucc (inr (inl star)) = Zone\nZsucc (inr (inr x)) = inr (inr (Nsucc x))\n\n-- Exercise 3.1\n-- In this exercise we were asked to show that (A + \u00acA) implies (\u00ac\u00acA \u2192 A).\n-- In other words, we get double negation elimination for the types that are decidable\ndne-dec : {i : Level} (A : UU i) \u2192 (coprod A (\u00ac A)) \u2192 (\u00ac (\u00ac A) \u2192 A)\ndne-dec A (inl x) = \u03bb f \u2192 x\ndne-dec A (inr x) = \u03bb f \u2192 ind-empty (f x)\n\n-- Exercise 3.3\n-- In this exercise we were asked to show that the observational equality on \u2115 is an equivalence relation.\nreflexive-EqN : (n : \u2115) \u2192 EqN n n\nreflexive-EqN Nzero = star\nreflexive-EqN (Nsucc n) = reflexive-EqN n\n\nsymmetric-EqN : (m n : \u2115) \u2192 EqN m n \u2192 EqN n m\nsymmetric-EqN Nzero Nzero t = t\nsymmetric-EqN Nzero (Nsucc n) t = t\nsymmetric-EqN (Nsucc n) Nzero t = t\nsymmetric-EqN (Nsucc m) (Nsucc n) t = symmetric-EqN m n t\n\ntransitive-EqN : (l m n : \u2115) \u2192 EqN l m \u2192 EqN m n \u2192 EqN l n\ntransitive-EqN Nzero Nzero Nzero s t = star\ntransitive-EqN (Nsucc n) Nzero Nzero s t = ind-empty s\ntransitive-EqN Nzero (Nsucc n) Nzero s t = ind-empty s\ntransitive-EqN Nzero Nzero (Nsucc n) s t = ind-empty t\ntransitive-EqN (Nsucc l) (Nsucc m) Nzero s t = ind-empty t\ntransitive-EqN (Nsucc l) Nzero (Nsucc n) s t = ind-empty s\ntransitive-EqN Nzero (Nsucc m) (Nsucc n) s t = ind-empty s\ntransitive-EqN (Nsucc l) (Nsucc m) (Nsucc n) s t = transitive-EqN l m n s t\n\n-- Exercise 3.4\n-- In this exercise we were asked to show that observational equality on the natural numbers is the least reflexive relation, in the sense that it implies all other reflexive relation. As we will see once we introduce the identity type, it follows that observationally equal natural numbers can be identified.\n\n-- We first make an auxilary construction, where the relation is quantified over inside the scope of the variables n and m. This is to ensure that the inductive hypothesis is strong enough to make the induction go through.\nleast-reflexive-EqN' : {i : Level} (n m : \u2115)\n                     (R : \u2115 \u2192 \u2115 \u2192 UU i) (\u03c1 : (n : \u2115) \u2192 R n n) \u2192 EqN n m \u2192 R n m\nleast-reflexive-EqN' Nzero Nzero R \u03c1 p = \u03c1 Nzero\nleast-reflexive-EqN' Nzero (Nsucc m) R \u03c1 = ind-empty\nleast-reflexive-EqN' (Nsucc n) Nzero R \u03c1 = ind-empty\nleast-reflexive-EqN' (Nsucc n) (Nsucc m) R \u03c1 =\n  least-reflexive-EqN' n m (\u03bb x y \u2192 R (Nsucc x) (Nsucc y)) (\u03bb x \u2192 \u03c1 (Nsucc x))\n\n-- Now we solve the actual exercise by rearranging the order of the variables.\nleast-reflexive-EqN : {i : Level} {R : \u2115 \u2192 \u2115 \u2192 UU i}\n  (\u03c1 : (n : \u2115) \u2192 R n n) \u2192 (n m : \u2115) \u2192 EqN n m \u2192 R n m\nleast-reflexive-EqN \u03c1 n m p = least-reflexive-EqN' n m _ \u03c1 p\n\n-- Exercise 3.5\n-- In this exercise we were asked to show that any function on the natural numbers preserves observational equality. The quick solution uses the fact that observational equality is the least reflexive relation.\npreserve_EqN : (f : \u2115 \u2192 \u2115) (n m : \u2115) \u2192 (EqN n m) \u2192 (EqN (f n) (f m))\npreserve_EqN f =\n    least-reflexive-EqN {_} {\u03bb x y \u2192 EqN (f x) (f y)}\n      (\u03bb x \u2192 reflexive-EqN (f x))\n\n-- Exercise 3.6\n-- In this exercise we were asked to construct the relations \u2264 and < on the natural numbers, and show basic properties about them.\n\n-- Definition of \u2264\nleqN : \u2115 \u2192 \u2115 \u2192 U\nleqN Nzero Nzero = unit\nleqN Nzero (Nsucc m) = unit\nleqN (Nsucc n) Nzero = empty\nleqN (Nsucc n) (Nsucc m) = leqN n m\n\n_\u2264_ = leqN\n\n-- Definition of <\nleN : \u2115 \u2192 \u2115 \u2192 U\nleN Nzero Nzero = empty\nleN Nzero (Nsucc m) = unit\nleN (Nsucc n) Nzero = empty\nleN (Nsucc n) (Nsucc m) = leN n m\n\n_<_ = leN\n\nreflexive-leqN : (n : \u2115) \u2192 n \u2264 n\nreflexive-leqN Nzero = star\nreflexive-leqN (Nsucc n) = reflexive-leqN n\n\nanti-reflexive-leN : (n : \u2115) \u2192 \u00ac (n < n)\nanti-reflexive-leN Nzero = ind-empty\nanti-reflexive-leN (Nsucc n) = anti-reflexive-leN n\n\ntransitive-leqN : (n m l : \u2115) \u2192 (n \u2264 m) \u2192 (m \u2264 l) \u2192 (n \u2264 l)\ntransitive-leqN Nzero Nzero Nzero p q = reflexive-leqN Nzero\ntransitive-leqN Nzero Nzero (Nsucc l) p q = q\ntransitive-leqN Nzero (Nsucc m) Nzero p q = star\ntransitive-leqN Nzero (Nsucc m) (Nsucc l) p q = star\ntransitive-leqN (Nsucc n) Nzero l p q = ind-empty p\ntransitive-leqN (Nsucc n) (Nsucc m) Nzero p q = ind-empty q\ntransitive-leqN (Nsucc n) (Nsucc m) (Nsucc l) p q = transitive-leqN n m l p q\n\ntransitive-leN : (n m l : \u2115) \u2192 (leN n m) \u2192 (leN m l) \u2192 (leN n l)\ntransitive-leN Nzero Nzero Nzero p q = p\ntransitive-leN Nzero Nzero (Nsucc l) p q = q\ntransitive-leN Nzero (Nsucc m) Nzero p q = ind-empty q\ntransitive-leN Nzero (Nsucc m) (Nsucc l) p q = star\ntransitive-leN (Nsucc n) Nzero l p q = ind-empty p\ntransitive-leN (Nsucc n) (Nsucc m) Nzero p q = ind-empty q\ntransitive-leN (Nsucc n) (Nsucc m) (Nsucc l) p q = transitive-leN n m l p q\n\nsucc-leN : (n : \u2115) \u2192 leN n (Nsucc n)\nsucc-leN Nzero = star\nsucc-leN (Nsucc n) = succ-leN n\n\n-- Exercise 3.7\n-- With the construction of the divisibility relation we open the door to basic number theory.\ndivides : (d n : \u2115) \u2192 U\ndivides d n = \u03a3 \u2115 (\u03bb m \u2192 EqN (d ** m) n)\n\n-- Exercise 3.8\n-- In this exercise we were asked to construct observational equality on the booleans. This construction is analogous to, but simpler than, the construction of observational equality on the natural numbers.\nEq2 : bool \u2192 bool \u2192 U\nEq2 true true = unit\nEq2 true false = empty\nEq2 false true = empty\nEq2 false false = unit\n\nreflexive-Eq2 : (x : bool) \u2192 Eq2 x x\nreflexive-Eq2 true = star\nreflexive-Eq2 false = star\n\nleast-reflexive-Eq2 : {i : Level}\n  (R : bool \u2192 bool \u2192 UU i) (\u03c1 : (x : bool) \u2192 R x x)\n  (x y : bool) \u2192 Eq2 x y \u2192 R x y\nleast-reflexive-Eq2 R \u03c1 true true p = \u03c1 true\nleast-reflexive-Eq2 R \u03c1 true false p = ind-empty p\nleast-reflexive-Eq2 R \u03c1 false true p = ind-empty p\nleast-reflexive-Eq2 R \u03c1 false false p = \u03c1 false\n\n-- Exercise 3.9\n-- In this exercise we were asked to show that 1 + 1 satisfies the induction principle of the booleans. In other words, type theory cannot distinguish the booleans from the type 1 + 1. We will see later that they are indeed equivalent types.\nt0 : coprod unit unit\nt0 = inl star\n\nt1 : coprod unit unit\nt1 = inr star\n\nind-coprod-unit-unit : {i : Level} {P : coprod unit unit \u2192 UU i} \u2192\n  P t0 \u2192 P t1 \u2192 (x : coprod unit unit) \u2192 P x\nind-coprod-unit-unit p0 p1 (inl star) = p0\nind-coprod-unit-unit p0 p1 (inr star) = p1\n\n-- Exercise 3.10\n-- In this exercise we were asked to define the relations \u2264 and < on the integers. As a criterion of correctness, we were then also asked to show that the type of all integers l satisfying k \u2264 l satisfy the induction principle of the natural numbers.\n-- It turns out that this is a long exercise that requires to develop intermediate properties of the relation \u2264, involving long proofs. None of them is really hard, but they are probably unintelligible because induction on the integers splits into so many cases.\n\nleqZ : \u2124 \u2192 \u2124 \u2192 U\nleqZ (inl Nzero) (inl Nzero) = unit\nleqZ (inl Nzero) (inl (Nsucc x)) = empty\nleqZ (inl Nzero) (inr l) = unit\nleqZ (inl (Nsucc x)) (inl Nzero) = unit\nleqZ (inl (Nsucc x)) (inl (Nsucc y)) = leqZ (inl x) (inl y)\nleqZ (inl (Nsucc x)) (inr l) = unit\nleqZ (inr k) (inl x) = empty\nleqZ (inr (inl star)) (inr l) = unit\nleqZ (inr (inr x)) (inr (inl star)) = empty\nleqZ (inr (inr Nzero)) (inr (inr y)) = unit\nleqZ (inr (inr (Nsucc x))) (inr (inr Nzero)) = empty\nleqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y))) =\n  leqZ (inr (inr (x))) (inr (inr (y)))\n\nreflexive-leqZ : (k : \u2124) \u2192 leqZ k k\nreflexive-leqZ (inl Nzero) = star\nreflexive-leqZ (inl (Nsucc x)) = reflexive-leqZ (inl x)\nreflexive-leqZ (inr (inl star)) = star\nreflexive-leqZ (inr (inr Nzero)) = star\nreflexive-leqZ (inr (inr (Nsucc x))) = reflexive-leqZ (inr (inr x))\n\ntransitive-leqZ : (k l m : \u2124) \u2192 leqZ k l \u2192 leqZ l m \u2192 leqZ k m\ntransitive-leqZ (inl Nzero) (inl Nzero) m p q = q\ntransitive-leqZ (inl Nzero) (inl (Nsucc x)) m p q = ind-empty p\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inl Nzero) star q =\n  reflexive-leqZ (inl Nzero)\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inl (Nsucc x)) star q =\n  ind-empty q\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inr (inl star)) star q = star\ntransitive-leqZ (inl Nzero) (inr (inl star)) (inr (inr x)) star q = star\ntransitive-leqZ (inl Nzero) (inr (inr x)) (inl y) star q = ind-empty q\ntransitive-leqZ (inl Nzero) (inr (inr x)) (inr (inl star)) star q =\n  ind-empty q\ntransitive-leqZ (inl Nzero) (inr (inr x)) (inr (inr y)) star q = star\ntransitive-leqZ (inl (Nsucc x)) (inl Nzero) (inl Nzero) star q = star\ntransitive-leqZ (inl (Nsucc x)) (inl Nzero) (inl (Nsucc y)) star q =\n  ind-empty q\ntransitive-leqZ (inl (Nsucc x)) (inl Nzero) (inr m) star q = star\ntransitive-leqZ (inl (Nsucc x)) (inl (Nsucc y)) (inl Nzero) p q = star\ntransitive-leqZ (inl (Nsucc x)) (inl (Nsucc y)) (inl (Nsucc z)) p q =\n  transitive-leqZ (inl x) (inl y) (inl z) p q\ntransitive-leqZ (inl (Nsucc x)) (inl (Nsucc y)) (inr m) p q = star\ntransitive-leqZ (inl (Nsucc x)) (inr y) (inl z) star q = ind-empty q\ntransitive-leqZ (inl (Nsucc x)) (inr y) (inr z) star q = star\ntransitive-leqZ (inr k) (inl x) m p q = ind-empty p\ntransitive-leqZ (inr (inl star)) (inr l) (inl x) star q = ind-empty q\ntransitive-leqZ (inr (inl star)) (inr l) (inr m) star q = star\ntransitive-leqZ (inr (inr x)) (inr (inl star)) m p q = ind-empty p\ntransitive-leqZ (inr (inr Nzero)) (inr (inr Nzero)) m p q = q\ntransitive-leqZ (inr (inr Nzero)) (inr (inr (Nsucc y))) (inl x) star q =\n  ind-empty q\ntransitive-leqZ (inr (inr Nzero)) (inr (inr (Nsucc y))) (inr (inl star))\n                star q =\n  ind-empty q\ntransitive-leqZ (inr (inr Nzero)) (inr (inr (Nsucc y))) (inr (inr z))\n                star q = star\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr Nzero)) m p q = ind-empty p\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y))) (inl z) p q =\n  ind-empty q\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y)))\n  (inr (inl star)) p q = ind-empty q\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y)))\n  (inr (inr Nzero)) p q = ind-empty q\ntransitive-leqZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y)))\n  (inr (inr (Nsucc z))) p q =\n  transitive-leqZ (inr (inr x)) (inr (inr y)) (inr (inr z)) p q\n\nsucc-leqZ : (k : \u2124) \u2192 leqZ k (Zsucc k)\nsucc-leqZ (inl Nzero) = star\nsucc-leqZ (inl (Nsucc Nzero)) = star\nsucc-leqZ (inl (Nsucc (Nsucc x))) = succ-leqZ (inl (Nsucc x))\nsucc-leqZ (inr (inl star)) = star\nsucc-leqZ (inr (inr Nzero)) = star\nsucc-leqZ (inr (inr (Nsucc x))) = succ-leqZ (inr (inr x))\n\nleqZ-succ-leqZ : (k l : \u2124) \u2192 leqZ k l \u2192 leqZ k (Zsucc l)\nleqZ-succ-leqZ k l p = transitive-leqZ k l (Zsucc l) p (succ-leqZ l)\n\nleZ : \u2124 \u2192 \u2124 \u2192 U\nleZ (inl Nzero) (inl x) = empty\nleZ (inl Nzero) (inr y) = unit\nleZ (inl (Nsucc x)) (inl Nzero) = unit\nleZ (inl (Nsucc x)) (inl (Nsucc y)) = leZ (inl x) (inl y)\nleZ (inl (Nsucc x)) (inr y) = unit\nleZ (inr x) (inl y) = empty\nleZ (inr (inl star)) (inr (inl star)) = empty\nleZ (inr (inl star)) (inr (inr x)) = unit\nleZ (inr (inr x)) (inr (inl star)) = empty\nleZ (inr (inr Nzero)) (inr (inr Nzero)) = empty\nleZ (inr (inr Nzero)) (inr (inr (Nsucc y))) = unit\nleZ (inr (inr (Nsucc x))) (inr (inr Nzero)) = empty\nleZ (inr (inr (Nsucc x))) (inr (inr (Nsucc y))) =\n  leZ (inr (inr x)) (inr (inr y))\n\nfam-shift-leqZ : (k : \u2124) {i : Level} (P : (l : \u2124) \u2192 leqZ k l \u2192 UU i) \u2192 (l : \u2124) \u2192 (leqZ (Zsucc k) l) \u2192 UU i\nfam-shift-leqZ k P l p = P l (transitive-leqZ k (Zsucc k) l (succ-leqZ k) p)\n\n-- ind-Z-leqZ : (k : \u2124) {i : Level} (P : (l : \u2124) \u2192 (leqZ k l) \u2192 UU i) \u2192\n--   P k (reflexive-leqZ k) \u2192\n--   ((l : \u2124) (p : leqZ k l) \u2192 P l p \u2192 P (Zsucc l) (leqZ-succ-leqZ k l p)) \u2192\n--   (l : \u2124) (p : leqZ k l) \u2192 P l p\n-- ind-Z-leqZ (inl Nzero) P pk pS (inl Nzero) star = pk\n-- ind-Z-leqZ (inl Nzero) P pk pS (inl (Nsucc x)) ()\n-- ind-Z-leqZ (inl Nzero) P pk pS (inr (inl star)) star = pS (inl Nzero) star pk\n-- ind-Z-leqZ (inl Nzero) P pk pS (inr (inr Nzero)) star = pS (inr (inl star)) star (pS (inl Nzero) star pk)\n-- ind-Z-leqZ (inl Nzero) P pk pS (inr (inr (Nsucc x))) star = pS (inr (inr x)) star (ind-Z-leqZ (inl Nzero) P pk pS (inr (inr x)) star)\n-- ind-Z-leqZ (inl (Nsucc Nzero)) {i} P pk pS (inl Nzero) star = pS {!!} {!!} {!!}\n-- ind-Z-leqZ (inl (Nsucc (Nsucc x))) {i} P pk pS (inl Nzero) star = {!!}\n-- ind-Z-leqZ (inl (Nsucc x)) P pk pS (inl (Nsucc y)) p = {!!}\n-- ind-Z-leqZ (inl (Nsucc x)) P pk pS (inr y) p = {!!}\n-- ind-Z-leqZ (inr k) P pk pS l p = {!!}\n\n-- Exercise 3.11\nZpred : \u2124 \u2192 \u2124\nZpred (inl x) = inl (Nsucc x)\nZpred (inr (inl star)) = inl Nzero\nZpred (inr (inr Nzero)) = inr (inl star)\nZpred (inr (inr (Nsucc x))) = inr (inr x)\n\n-- Exercise 3.12\nZadd : \u2124 \u2192 \u2124 \u2192 \u2124\nZadd (inl Nzero) l = Zpred l\nZadd (inl (Nsucc x)) l = Zpred (Zadd (inl x) l)\nZadd (inr (inl star)) l = l\nZadd (inr (inr Nzero)) l = Zsucc l\nZadd (inr (inr (Nsucc x))) l = Zsucc (Zadd (inr (inr x)) l)\n\nZneg : \u2124 \u2192 \u2124\nZneg (inl x) = inr (inr x)\nZneg (inr (inl star)) = inr (inl star)\nZneg (inr (inr x)) = inl x\n", "meta": {"hexsha": "a16826f44c06bdf7148fe15178743ab2af5034eb", "size": 15789, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Lecture3.agda", "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_issues_repo_path": "Lecture3.agda", "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_forks_repo_path": "Lecture3.agda", "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "avg_line_length": 38.322815534, "max_line_length": 309, "alphanum_fraction": 0.6227120147, "num_tokens": 6597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952948443462, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.759398549167618}}
{"text": "module L.Base.Nat.Properties where\n\nopen import L.Base.Nat\nopen import L.Base.Id.Core\nopen import L.Base.Id.Properties using (ap;sym;transport)\n\n-- Properties of +\n+-idl : \u2200{x} \u2192 zero + x \u2261 x\n+-idl = refl\n\n+-idr : \u2200{x} \u2192 x + zero \u2261 x\n+-idr {x} = ind (\u03bb n \u2192 n + zero \u2261 n) refl (\u03bb _ p \u2192 ap succ p) x\n\n+-assoc : {x y z : Nat} \u2192 (x + y) + z \u2261 x + (y + z)\n+-assoc {x}{y}{z} = ind (\u03bb n \u2192 (n + y) + z \u2261 n + (y + z))\n          refl (\u03bb _ p \u2192 ap succ p) x\n\n+-succ : {x y : Nat} \u2192 x + succ y \u2261 succ (x + y)\n+-succ {x}{y} = ind (\u03bb n \u2192 n + succ y \u2261 succ (n + y)) refl (\u03bb _ p \u2192 ap succ p) x\n\n+-comm : {x y : Nat} \u2192 x + y \u2261 y + x\n+-comm {x}{y} = ind (\u03bb n \u2192 n + y \u2261 y + n) (sym +-idr) (\u03bb n p \u2192 sym\n                (transport (\u03bb q \u2192 y + succ n \u2261 succ q) (sym p) +-succ)) x\n\n-- Properties of *\n*-zl : \u2200{x} \u2192 zero * x \u2261 zero\n*-zl = refl\n\n*-zr : \u2200{x} \u2192 x * zero \u2261 zero\n*-zr {x} = ind (\u03bb n \u2192 n * zero \u2261 zero) refl (\u03bb _ p \u2192 p) x\n\n*-idl : \u2200{x} \u2192 1 * x \u2261 x\n*-idl = +-idr\n\n*-idr : \u2200{x} \u2192 x * 1 \u2261 x\n*-idr {x} = ind (\u03bb n \u2192 n * 1 \u2261 n) refl (\u03bb _ p \u2192 ap succ p) x\n\n*-distrib-+ : {x y z : Nat} \u2192 (x + y) * z \u2261 x * z + y * z\n*-distrib-+ {x}{y}{z} = ind (\u03bb n \u2192 (n + y) * z \u2261 n * z + y * z) refl\n                        (\u03bb m p \u2192 transport (\u03bb s \u2192 z + (m + y) * z \u2261 s)\n                        (sym (+-assoc {z} {m * z} {y * z}))\n                        (ap (\u03bb k \u2192 z + k) p)) x\n\n*-assoc : {x y z : Nat} \u2192 (x * y) * z \u2261 x * (y * z)\n*-assoc {x}{y}{z} = ind (\u03bb n \u2192 (n * y) * z \u2261 n * (y * z)) refl (\u03bb n p\n                    \u2192 transport (\u03bb q \u2192 (y + n * y) * z \u2261 y * z + q) p\n                    (*-distrib-+ {y}{n * y})) x\n", "meta": {"hexsha": "f63c90931e2caaead9c9381f9393af09cd01f4ea", "size": 1582, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/L/Base/Nat/Properties.agda", "max_stars_repo_name": "borszag/smallib", "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/L/Base/Nat/Properties.agda", "max_issues_repo_name": "borszag/smallib", "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 10, "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_forks_repo_path": "src/L/Base/Nat/Properties.agda", "max_forks_repo_name": "borszag/smallib", "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9583333333, "max_line_length": 80, "alphanum_fraction": 0.4032869785, "num_tokens": 689, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9136765234137297, "lm_q2_score": 0.831143054132195, "lm_q1q2_score": 0.7593958961589733}}
{"text": "module plfa.part1.Negation where\n\nopen import Relation.Binary.PropositionalEquality using (_\u2261_; refl)\nopen import Data.Nat using (\u2115; zero; suc; _<_)\nopen import Data.Empty using (\u22a5; \u22a5-elim)\nopen import Data.Sum using (_\u228e_; inj\u2081; inj\u2082)\nopen import Data.Product using (_\u00d7_; _,_)\nopen import plfa.part1.Isomorphism using (_\u2243_; extensionality)\n\n\u00ac_ : Set \u2192 Set\n\u00ac A = A \u2192 \u22a5\n\n\u00ac-elim : \u2200 {A : Set}\n  \u2192 \u00ac A\n  \u2192 A\n    ---\n  \u2192 \u22a5\n\u00ac-elim \u00acx x = \u00acx x\n\ninfix 3 \u00ac_\n\n\u00ac\u00ac-intro : \u2200 {A : Set}\n  \u2192 A\n    -----\n  \u2192 \u00ac \u00ac A\n\u00ac\u00ac-intro x  =  \u03bb{\u00acx \u2192 \u00acx x}\n\n\u00ac\u00ac\u00ac-elim : \u2200 {A : Set}\n  \u2192 \u00ac \u00ac \u00ac A\n    -------\n  \u2192 \u00ac A\n\u00ac\u00ac\u00ac-elim \u00ac\u00ac\u00acx  =  \u03bb x \u2192 \u00ac\u00ac\u00acx (\u00ac\u00ac-intro x)\n\ncontraposition : \u2200 {A B : Set}\n  \u2192 (A \u2192 B)\n    -----------\n  \u2192 (\u00ac B \u2192 \u00ac A)\ncontraposition f \u00acy x = \u00acy (f x)\n\n_\u2262_ : \u2200 {A : Set} \u2192 A \u2192 A \u2192 Set\nx \u2262 y  =  \u00ac (x \u2261 y)\n\n_ : 1 \u2262 2\n_ = \u03bb()\n\npeano : \u2200 {m : \u2115} \u2192 zero \u2262 suc m\npeano = \u03bb()\n\nid : \u22a5 \u2192 \u22a5\nid x = x\n\nid\u2032 : \u22a5 \u2192 \u22a5\nid\u2032 ()\n\nassimilation : \u2200 {A : Set} (\u00acx \u00acx\u2032 : \u00ac A) \u2192 \u00acx \u2261 \u00acx\u2032\nassimilation \u00acx \u00acx\u2032 = extensionality (\u03bb x \u2192 \u22a5-elim (\u00acx x))\n\nassimilation' : \u2200 {A : Set} {\u00acx \u00acx\u2032 : \u00ac A} \u2192 \u00acx \u2261 \u00acx\u2032\nassimilation' {A} {\u00acx} {\u00acx\u2032} = assimilation \u00acx \u00acx\u2032\n\n<-irreflexive : \u2200 {n : \u2115} \u2192 \u00ac (n < n)\n<-irreflexive (Data.Nat.s\u2264s x) = <-irreflexive x\n\n\u228e-dual-\u00d7 : \u2200 {A B : Set} \u2192 \u00ac (A \u228e B) \u2243 (\u00ac A) \u00d7 (\u00ac B)\n\u228e-dual-\u00d7 = record {\n                  to = \u03bb {x \u2192 (\u03bb z \u2192 x (inj\u2081 z)) , \u03bb x\u2081 \u2192 x (inj\u2082 x\u2081) };\n                  from = \u03bb { (fst , snd) (inj\u2081 x) \u2192 fst x ;\n                             (fst , snd) (inj\u2082 y) \u2192 snd y} ;\n                  from\u2218to = \u03bb {\u00acx \u2192 assimilation'} ;\n                  to\u2218from = \u03bb { (fst , snd) \u2192 refl} }\n", "meta": {"hexsha": "11f5d783179f1fd080a93d90e86bfec476ead14c", "size": 1575, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/part1/Negation.agda", "max_stars_repo_name": "UnsoundWitch/proofs", "max_stars_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-01-03T03:29:40.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-18T10:58:03.000Z", "max_issues_repo_path": "plfa/part1/Negation.agda", "max_issues_repo_name": "sym-cereal/proofs", "max_issues_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/part1/Negation.agda", "max_forks_repo_name": "sym-cereal/proofs", "max_forks_repo_head_hexsha": "275ecc582b3a6a1da1af387251c6b4d74d9a5203", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.1830985915, "max_line_length": 72, "alphanum_fraction": 0.4457142857, "num_tokens": 682, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797100118214, "lm_q2_score": 0.8333245891029456, "lm_q1q2_score": 0.7593084574445422}}
{"text": "module 110-natural-model where\n\nopen import 010-false-true\nopen import 020-equivalence\nopen import 100-natural\n\n-- We prove that there is a model of the naturals within Agda's lambda\n-- calculus. This also shows that the Peano axioms are consistent.\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 -> \u2115\n\nthm-\u2115-is-natural : Natural zero suc _\u2261_\nthm-\u2115-is-natural = record {\n  equiv = thm-\u2261-is-equivalence;\n  sucn!=zero = sucn!=zero;\n  sucinjective = sucinjective;\n  cong = cong;\n  induction = induction\n  }\n  where\n    sucn!=zero : \u2200 {r} -> suc r \u2261 zero -> False\n    sucn!=zero ()\n    sucinjective : \u2200 {r s} -> suc r \u2261 suc s -> r \u2261 s\n    sucinjective refl = refl\n    cong : \u2200 {r s} -> r \u2261 s -> suc r \u2261 suc s\n    cong refl = refl\n\n    -- This is the only tricky bit: proving the principle of induction.\n    induction : (p : \u2115 -> Set) -> p zero -> (\u2200 n -> p n -> p (suc n)) -> \u2200 n -> p n\n    -- We first prove that p n holds for n equal to zero. This is just\n    -- the base case.\n    induction p base hypothesis zero = base\n    -- Then we prove that p (suc n) holds, using induction on n, that is,\n    -- we may assume that p n is proven, or more precisely, that\n    -- \"induction p base hypothesis n\" is a proof of p n.\n    induction p base hypothesis (suc n) =\n      hypothesis n (induction p base hypothesis n)\n", "meta": {"hexsha": "e524375942c9c7a1700dfd574c911c429137b6e3", "size": 1304, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "110-natural-model.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "110-natural-model.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "110-natural-model.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6, "max_line_length": 83, "alphanum_fraction": 0.6357361963, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9416541544761566, "lm_q2_score": 0.8056321889812553, "lm_q1q2_score": 0.7586268977339192}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import Sets.EquivalenceRelations\nopen import Setoids.Setoids\nopen import Agda.Primitive using (Level; lzero; lsuc; _\u2294_)\nopen import Groups.Definition\n\nmodule Groups.Homomorphisms.Definition where\n\nrecord GroupHom {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_\u00b7A_ : A \u2192 A \u2192 A} {B : Set n} {T : Setoid {n} {p} B} {_\u00b7B_ : B \u2192 B \u2192 B} (G : Group S _\u00b7A_) (H : Group T _\u00b7B_) (f : A \u2192 B) : Set (m \u2294 n \u2294 o \u2294 p) where\n  open Group H\n  open Setoid T\n  field\n    groupHom : {x y : A} \u2192 f (x \u00b7A y) \u223c (f x) \u00b7B (f y)\n    wellDefined : {x y : A} \u2192 Setoid._\u223c_ S x y \u2192 f x \u223c f y\n  groupHom' : {x y : A} \u2192 (f x) \u00b7B (f y) \u223c f (x \u00b7A y)\n  groupHom' = Equivalence.symmetric eq groupHom\n\nrecord InjectiveGroupHom {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_\u00b7A_ : A \u2192 A \u2192 A} {B : Set n} {T : Setoid {n} {p} B} {_\u00b7B_ : B \u2192 B \u2192 B} {G : Group S _\u00b7A_} {H : Group T _\u00b7B_} {underf : A \u2192 B} (f : GroupHom G H underf) : Set (m \u2294 n \u2294 o \u2294 p) where\n  open Setoid S renaming (_\u223c_ to _\u223cA_)\n  open Setoid T renaming (_\u223c_ to _\u223cB_)\n  field\n    injective : SetoidInjection S T underf\n", "meta": {"hexsha": "f9080768704877a2f3278a1a94be862e04d2e952", "size": 1111, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Homomorphisms/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Homomorphisms/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Homomorphisms/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 46.2916666667, "max_line_length": 255, "alphanum_fraction": 0.5796579658, "num_tokens": 466, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582554941718, "lm_q2_score": 0.8152324915965392, "lm_q1q2_score": 0.758539801953083}}
{"text": "{-\n\n          Types Summer School 2007\n\n                 Bertinoro\n             Aug 19 - 31, 2007\n\n\n                   Agda\n\n                Ulf Norell\n\n-}\n\n-- Records are labeled sigma types.\n\nmodule Records where\n\nopen import Nat\nopen import Bool\n\n{-\n\n  A very simple record.\n\n-}\n\nrecord Point : Set where\n  field\n    x : Nat\n    y : Nat\n\n-- A record can be seen as a one constructor datatype. In this case:\ndata Point' : Set where\n  mkPoint : (x : Nat)(y : Nat) -> Point'\n\n-- There are a few differences, though:\n\n-- To construct a record you use the syntax record { ..; x = e; .. }\norigin : Point\norigin = record { x = 0; y = 0 }\n\n-- instead of\norigin' : Point'\norigin' = mkPoint 0 0\n\n-- What's more interesting is that you get projection functions\n-- for free when you declare a record. More precisely, you get a module\n-- parameterised over a record, containing functions corresponding to the\n-- fields. In the Point example you get:\n{-\n  module Point (p : Point) where\n    x : Nat\n    y : Nat\n-}\n\n-- So Point.x : Point -> Nat is the projection function for the field x.\ngetX : Point -> Nat\ngetX = Point.x\n\n-- A nifty thing with having the projection functions in a module is that\n-- you can apply the module to a record value, in effect opening the record.\nsum : Point -> Nat\nsum p = x + y\n  where\n   open module Pp = Point p\n\n-- The final difference between records and datatypes is that we have\n-- \u03b7-equality on records.\n\ndata _==_ {A : Set}(x : A) : A -> Set where\n  refl : x == x\n\n\u03b7-Point : (p : Point) -> p == record { x = Point.x p; y = Point.y p }\n\u03b7-Point p = refl\n\n{-\n\n  The empty record\n\n-}\n\n-- One interesting benefit of this is that we get a unit type with\n-- \u03b7-equality.\nrecord True : Set where\n\ntt : True\ntt = record{}\n\n-- Now, since any element of True is equal to tt, metavariables of\n-- type True will simply disappear. The following cute example exploits\n-- this:\n\ndata False : Set where\n\nNonZero : Nat -> Set\nNonZero zero    = False\nNonZero (suc _) = True\n\n-- We make the proof that m is non-zero implicit.\n\n_/_ : (n m : Nat){p : NonZero m} -> Nat\n(n / zero) {}\nzero  / suc m = zero\nsuc n / suc m = div (suc n) (suc m) m\n  where\n    div : Nat -> Nat -> Nat -> Nat\n    div  zero    zero   c = suc zero\n    div  zero   (suc y) c = zero\n    div (suc x)  zero   c = suc (div x c c)\n    div (suc x) (suc y) c = div x y c\n\n-- Now, as long as we're dividing by things which are obviously\n-- NonZero we can completely ignore the proof.\n\nfive = 17 / 3\n\n{-\n\n  A dependent record\n\n-}\n\n-- Of course, records can be dependent, and have parameters.\nrecord \u2203 {A : Set}(P : A -> Set) : Set where\n  field\n    witness : A\n    proof   : P witness\n", "meta": {"hexsha": "1dda8aab2e493903d2c933061c4328d63f7f9156", "size": 2653, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Records.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.5658914729, "max_line_length": 76, "alphanum_fraction": 0.6268375424, "num_tokens": 771, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026595857203, "lm_q2_score": 0.8267117940706734, "lm_q1q2_score": 0.7583449274119111}}
{"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl1.Correctness.Order  {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_) \n                  (trans\u2264 : Transitive _\u2264_)  where\n\nopen import BSTree _\u2264_\nopen import BSTree.Properties _\u2264_ trans\u2264\nopen import BTree {A}\nopen import Data.List\nopen import Data.Sum\nopen import Function using (_\u2218_)\nopen import List.Sorted _\u2264_\nopen import TreeSort.Impl1 _\u2264_ tot\u2264\n\nlemma-insert-*\u22b4 : {x y : A}{t : BTree} \u2192 x \u2264 y \u2192 t *\u22b4 y \u2192 insert x t *\u22b4 y\nlemma-insert-*\u22b4 x\u2264y lelf = lend x\u2264y lelf\nlemma-insert-*\u22b4 {x = x}{t = node z l r} x\u2264y (lend z\u2264y r\u2264y) \n    with tot\u2264 x z\n... | inj\u2081 x\u2264z = lend z\u2264y r\u2264y\n... | inj\u2082 z\u2264x = lend z\u2264y (lemma-insert-*\u22b4 x\u2264y r\u2264y) \n\nlemma-insert-\u22b4* : {x y : A}{t : BTree} \u2192 y \u2264 x \u2192 y \u22b4* t \u2192 y \u22b4* insert x t\nlemma-insert-\u22b4* y\u2264x gelf = gend y\u2264x gelf\nlemma-insert-\u22b4* {x = x} {t = node z l r} y\u2264x (gend y\u2264z y\u2264l) \n    with tot\u2264 x z\n... | inj\u2081 x\u2264z = gend y\u2264z (lemma-insert-\u22b4* y\u2264x y\u2264l)\n... | inj\u2082 z\u2264x = gend y\u2264z y\u2264l\n\nlemma-insert-bst : {t : BTree}(x : A) \u2192 BSTree t \u2192 BSTree (insert x t)\nlemma-insert-bst x slf = snd slf slf lelf gelf\nlemma-insert-bst x (snd {x = y} sl sr l\u2264y y\u2264r) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = snd (lemma-insert-bst x sl) sr (lemma-insert-*\u22b4 x\u2264y l\u2264y) y\u2264r\n... | inj\u2082 y\u2264x = snd sl (lemma-insert-bst x sr) l\u2264y (lemma-insert-\u22b4* y\u2264x y\u2264r)\n\nlemma-treeSort-bst : (xs : List A) \u2192 BSTree (treeSort xs)\nlemma-treeSort-bst [] = slf\nlemma-treeSort-bst (x \u2237 xs) = lemma-insert-bst x (lemma-treeSort-bst xs)\n\ntheorem-treeSort-sorted : (xs : List A) \u2192 Sorted (flatten (treeSort xs))\ntheorem-treeSort-sorted = lemma-bst-sorted \u2218 lemma-treeSort-bst \n\n\n\n\n", "meta": {"hexsha": "fa5ac1f31386d9ea159bf9f8a52e86e71f9f4895", "size": 1637, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl1/Correctness/Order.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl1/Correctness/Order.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl1/Correctness/Order.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1041666667, "max_line_length": 77, "alphanum_fraction": 0.5998778253, "num_tokens": 693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768557238084, "lm_q2_score": 0.8031737963569014, "lm_q1q2_score": 0.7583381096440136}}
{"text": "\nmodule Isomorphism where\n\n  import Sets\n  open Sets\n\n  infix 20 _\u2245_\n\n  data _\u2245_ (A B : Set) : Set where\n    iso : (i : A -> B)(j : B -> A) ->\n\t  (forall x -> j (i x) == x) ->\n\t  (forall y -> i (j y) == y) ->\n\t  A \u2245 B\n\n  refl-\u2245 : (A : Set) -> A \u2245 A\n  refl-\u2245 A = iso id id (\\x -> refl) (\\x -> refl)\n\n  iso[\u00d7] : {A\u2081 A\u2082 B\u2081 B\u2082 : Set} -> A\u2081 \u2245 A\u2082 -> B\u2081 \u2245 B\u2082 -> A\u2081 [\u00d7] B\u2081 \u2245 A\u2082 [\u00d7] B\u2082\n  iso[\u00d7] (iso a\u2081\u2082 a\u2082\u2081 p\u2081\u2081 p\u2082\u2082) (iso b\u2081\u2082 b\u2082\u2081 q\u2081\u2081 q\u2082\u2082) =\n    iso ab\u2081\u2082 ab\u2082\u2081 pq\u2081\u2081 pq\u2082\u2082 where\n\n    ab\u2081\u2082 = a\u2081\u2082 <\u00d7> b\u2081\u2082\n    ab\u2082\u2081 = a\u2082\u2081 <\u00d7> b\u2082\u2081\n\n    pq\u2082\u2082 : (z : _ [\u00d7] _) -> ab\u2081\u2082 (ab\u2082\u2081 z) == z\n    pq\u2082\u2082 < x , y > =\n      subst (\\ \u2219 -> < \u2219 , b\u2081\u2082 (b\u2082\u2081 y) > == < x , y >) (p\u2082\u2082 x)\n      $ cong < x ,\u2219> (q\u2082\u2082 y)\n\n    pq\u2081\u2081 : (z : _ [\u00d7] _) -> ab\u2082\u2081 (ab\u2081\u2082 z) == z\n    pq\u2081\u2081 < x , y > =\n      subst (\\ \u2219 -> < \u2219 , b\u2082\u2081 (b\u2081\u2082 y) > == < x , y >) (p\u2081\u2081 x)\n      $ cong < x ,\u2219> (q\u2081\u2081 y)\n\n  iso[+] : {A\u2081 A\u2082 B\u2081 B\u2082 : Set} -> A\u2081 \u2245 A\u2082 -> B\u2081 \u2245 B\u2082 -> A\u2081 [+] B\u2081 \u2245 A\u2082 [+] B\u2082\n  iso[+] (iso a\u2081\u2082 a\u2082\u2081 p\u2081\u2081 p\u2082\u2082) (iso b\u2081\u2082 b\u2082\u2081 q\u2081\u2081 q\u2082\u2082) =\n    iso ab\u2081\u2082 ab\u2082\u2081 pq\u2081\u2081 pq\u2082\u2082 where\n\n    ab\u2081\u2082 = a\u2081\u2082 <+> b\u2081\u2082\n    ab\u2082\u2081 = a\u2082\u2081 <+> b\u2082\u2081\n\n    pq\u2082\u2082 : (z : _ [+] _) -> ab\u2081\u2082 (ab\u2082\u2081 z) == z\n    pq\u2082\u2082 (inl x) = cong inl (p\u2082\u2082 x)\n    pq\u2082\u2082 (inr y) = cong inr (q\u2082\u2082 y)\n\n    pq\u2081\u2081 : (z : _ [+] _) -> ab\u2082\u2081 (ab\u2081\u2082 z) == z\n    pq\u2081\u2081 (inl x) = cong inl (p\u2081\u2081 x)\n    pq\u2081\u2081 (inr y) = cong inr (q\u2081\u2081 y)\n\n", "meta": {"hexsha": "91f9fecdf1f6af52dba068e8d287c9e0f622381c", "size": 1289, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/outdated-and-incorrect/clowns/Isomorphism.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/outdated-and-incorrect/clowns/Isomorphism.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/outdated-and-incorrect/clowns/Isomorphism.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 25.78, "max_line_length": 77, "alphanum_fraction": 0.4321179209, "num_tokens": 679, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768620069627, "lm_q2_score": 0.8031737892899222, "lm_q1q2_score": 0.7583381080180003}}
{"text": "open import Nat\nopen import Prelude\nopen import core\nopen import contexts\n\nmodule htype-decidable where\n  lemma-l : \u2200{t1 t2 t4} \u2192 t1 ==> t2 == t1 ==> t4 \u2192 t2 == t4\n  lemma-l refl = refl\n\n  lemma-r : \u2200{t1 t2 t3} \u2192 t1 ==> t2 == t3 ==> t2 \u2192 t1 == t3\n  lemma-r refl = refl\n\n  lemma-b : \u2200{t1 t2 t3 t4} \u2192 t1 ==> t2 == t3 ==> t4 \u2192 t1 == t3\n  lemma-b refl = refl\n\n  htype-dec : (t1 t2 : htyp) \u2192 t1 == t2 + (t1 == t2 \u2192 \u22a5)\n  htype-dec b b = Inl refl\n  htype-dec b \u2987-\u2988 = Inr (\u03bb ())\n  htype-dec b (t2 ==> t3) = Inr (\u03bb ())\n  htype-dec \u2987-\u2988 b = Inr (\u03bb ())\n  htype-dec \u2987-\u2988 \u2987-\u2988 = Inl refl\n  htype-dec \u2987-\u2988 (t2 ==> t3) = Inr (\u03bb ())\n  htype-dec (t1 ==> t2) b = Inr (\u03bb ())\n  htype-dec (t1 ==> t2) \u2987-\u2988 = Inr (\u03bb ())\n  htype-dec (t1 ==> t2) (t3 ==> t4) with htype-dec t1 t3 | htype-dec t2 t4\n  htype-dec (t1 ==> t2) (.t1 ==> .t2) | Inl refl | Inl refl = Inl refl\n  htype-dec (t1 ==> t2) (.t1 ==> t4)  | Inl refl | Inr x\u2081   = Inr (\u03bb x \u2192 x\u2081 (lemma-l x))\n  htype-dec (t1 ==> t2) (t3 ==> .t2)  | Inr x    | Inl refl = Inr (\u03bb x\u2081 \u2192 x (lemma-r x\u2081))\n  htype-dec (t1 ==> t2) (t3 ==> t4)   | Inr x    | Inr x\u2081   = Inr (\u03bb x\u2082 \u2192 x (lemma-b x\u2082))\n\n  -- if an arrow is disequal, it disagrees in the first or second argument\n  ne-factor : \u2200{\u03c41 \u03c42 \u03c43 \u03c44} \u2192 (\u03c41 ==> \u03c42) \u2260 (\u03c43 ==> \u03c44) \u2192 (\u03c41 \u2260 \u03c43) + (\u03c42 \u2260 \u03c44)\n  ne-factor {\u03c41} {\u03c42} {\u03c43} {\u03c44} ne with htype-dec \u03c41 \u03c43 | htype-dec \u03c42 \u03c44\n  ne-factor ne | Inl refl | Inl refl = Inl (\u03bb x \u2192 ne refl)\n  ne-factor ne | Inl x | Inr x\u2081 = Inr x\u2081\n  ne-factor ne | Inr x | Inl x\u2081 = Inl x\n  ne-factor ne | Inr x | Inr x\u2081 = Inl x\n", "meta": {"hexsha": "374ea88a99c03ac8ec0e809a3bf10ea11051f33a", "size": 1519, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "htype-decidable.agda", "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_issues_repo_path": "htype-decidable.agda", "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_forks_repo_path": "htype-decidable.agda", "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "avg_line_length": 39.9736842105, "max_line_length": 89, "alphanum_fraction": 0.5233706386, "num_tokens": 724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465098415279, "lm_q2_score": 0.8104789178257654, "lm_q1q2_score": 0.7580786270884682}}
{"text": "module fizzbuzz where\n\nimport Data.Nat        as N\nimport Data.Nat.DivMod as N\nimport Data.Nat.Show   as N\nimport Data.Bool       as B\nimport Data.Fin        as F\nimport Data.Unit       as U\nimport Data.String     as S\nopen import Data.Product using (_,_ ; _\u00d7_)\nopen import IO\nopen import Agda.Builtin.Coinduction\nopen import Relation.Nullary\nopen import Function\n\ncongruent : N.\u2115 \u2192 N.\u2115 \u2192 B.Bool\ncongruent n N.zero    = B.false\ncongruent n (N.suc m) with N._\u225f_ 0 $ F.to\u2115 (N._mod_ n (N.suc m) {U.tt})\n... | yes _ = B.true\n... | no  _ = B.false\n\n_and_ : {A B : Set} \u2192 A \u2192 B \u2192 A \u00d7 B\n_and_ = _,_\n\nfizzbuzz : N.\u2115 \u2192 S.String\nfizzbuzz N.zero    = \"fizzbuzz\"\nfizzbuzz n with congruent n 3 and congruent n 5\n... | B.true  , B.true   = \"fizzbuzz\"\n... | B.true  , B.false  = \"fizz\"\n... | B.false , B.true   = \"buzz\"\n... | B.false , B.false  = N.show n\n\nworker : N.\u2115 \u2192 IO U.\u22a4\nworker N.zero    = putStrLn $ fizzbuzz N.zero\nworker (N.suc n) = \u266f worker n >> \u266f putStrLn (fizzbuzz $ N.suc n)\n\nmain = run $ worker 100\n", "meta": {"hexsha": "d9a2ef9b0ec1a4ac525875d3af47aef3d038b69e", "size": 1000, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/examples-that-run/fizzbuzz/src-agda/fizzbuzz.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/examples-that-run/fizzbuzz/src-agda/fizzbuzz.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/examples-that-run/fizzbuzz/src-agda/fizzbuzz.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 26.3157894737, "max_line_length": 71, "alphanum_fraction": 0.623, "num_tokens": 357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377261041521, "lm_q2_score": 0.7905303260722198, "lm_q1q2_score": 0.7577531411696395}}
{"text": "{-# OPTIONS --copatterns #-}\n\nmodule LecStr where\n\nopen import CS410-Prelude\nopen import CS410-Nat\nopen import CS410-Functor\n\nrecord Stream (X : Set) : Set where\n  coinductive\n  field\n    head : X\n    tail : Stream X\nopen Stream\n\ncount : Nat -> Stream Nat\nhead (count n) = n\ntail (count n) = count (suc n)\n\nnats : Stream Nat\nnats = count zero\n\npoke : Nat\npoke = head (tail (tail (tail nats)))\n\nrepeat : {X : Set} -> X -> Stream X\nhead (repeat x) = x\ntail (repeat x) = repeat x\n\nstrApp : {S T : Set} -> Stream (S -> T) -> Stream S -> Stream T\nhead (strApp fs ss) = (head fs) (head ss)\ntail (strApp fs ss) = strApp (tail fs) (tail ss)\n\nstrMap : {S T : Set} -> (S -> T) -> Stream S -> Stream T\nstrMap f ss = strApp (repeat f) ss\n\ndiagonal : {X : Set} -> Stream (Stream X) -> Stream X\nhead (diagonal xss) = head (head xss)\ntail (diagonal xss) = diagonal (strMap tail (tail xss))\n\n{- productivity checker rejects\nfibo : Stream Nat\nhead fibo = 1\nhead (tail fibo) = 1\ntail (tail fibo) = strApp (strApp (repeat _+N_) (tail fibo)) fibo\n-}\n\ndata CoList' (X : Set) : Set\nrecord CoList (X : Set) : Set where\n  coinductive\n  constructor thunk\n  field\n    force : CoList' X\ndata CoList' X where\n  [] : CoList' X\n  _::_ : X -> CoList X -> CoList' X\n\nmodule CoListExamples where\n  open CoList\n\n  short : CoList Nat\n  short = thunk (0 :: thunk (1 :: thunk (2 :: thunk [])))\n\n  long : forall {X} -> Stream X -> CoList X\n  force (long s) = head s :: long (tail s)\n\n  _++_ : forall {X} -> CoList X -> CoList X -> CoList X\n  force (xs ++ ys) with force xs\n  force (xs ++ ys) | [] = force ys\n  force (xs ++ ys) | x :: xs' = x :: (xs' ++ ys)\n\n{-\n  concat : forall {X} -> CoList (CoList X) -> CoList X\n  force (concat xss) with force xss\n  force (concat xss) | [] = []\n  force (concat xss) | xs :: xss' with force xs\n  force (concat xss) | xs :: xss' | [] = ? -- oops force (concat xss')\n  force (concat xss) | xs :: xss' | x :: xs' = x :: concat (thunk (xs' :: xss'))\n-}\n\n-- nonempty CoLists\n-- tails for Streams\n-- \" n.e. CoLists\n", "meta": {"hexsha": "ce3a7d1a3832d31d167c2b72cf5584437ecec8ee", "size": 2008, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "LecStr.agda", "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LecStr.agda", "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LecStr.agda", "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.9047619048, "max_line_length": 80, "alphanum_fraction": 0.6035856574, "num_tokens": 699, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.8539127529517043, "lm_q1q2_score": 0.757595317052373}}
{"text": "------------------------------------------------------------------------------\n-- Proving that two group theory formalisations are equivalents\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\n-- We prove that group theory axioms based on the signature (G, \u00b7, \u03b5,)\n-- (see for example [p. 39, 1]), i.e.\n\n-- \u2200 a b c. abc = a(bc)\n\n-- \u2200 a. \u03b5a = a\u03b5 = a\n\n-- \u2200 a. \u2203 a'. a'a = aa' = \u03b5\n\n-- are equivalents to the axioms based on the signature (G, \u00b7, _\u207b\u00b9, \u03b5,)\n-- (see for example [2,3]), i.e.\n\n-- \u2200 a b c. abc = a(bc)\n\n-- \u2200 a. \u03b5a = a\u03b5  = a\n\n-- \u2200 a. a\u207b\u00b9a = aa\u207b\u00b9 = \u03b5\n\n-- [1] C. C. Chang and H. J. Keisler. Model Theory, volume 73 of Studies\n--  in Logic and the Foundations of Mathematics. North-Holland, 3rd\n--  edition, 3rd impression 1992.\n\n-- [2] Agda standard library_0.8.1 (see Algebra/Structures.agda)\n\n-- [3] Coq implementation\n--     (http://coq.inria.fr/pylons/contribs/files/GroupTheory/v8.3/GroupTheory.g1.html)\n\nmodule FOT.GroupTheory.FormalisationsSL where\n\nopen import Data.Product\nopen import Relation.Binary.PropositionalEquality\n\n------------------------------------------------------------------------------\n\n-- NB. We only write the proof for the left-inverse property.\n\ninfixl 10 _\u00b7_ -- The symbol is '\\cdot'.\n\npostulate\n  G   : Set        -- The universe\n  \u03b5   : G          -- The identity element.\n  _\u00b7_ : G \u2192 G \u2192 G  -- The binary operation.\n\n-- Left-inverse property based on the signature (G, \u00b7, \u03b5,).\nleftInverse\u2081 : Set\nleftInverse\u2081 = \u2200 a \u2192 \u03a3 G (\u03bb a' \u2192 a' \u00b7 a \u2261 \u03b5)\n\n-- Left-inverse property based on the signature (G, \u00b7, _\u207b\u00b9, \u03b5,).\ninfix  11 _\u207b\u00b9\n\npostulate  _\u207b\u00b9 : G \u2192 G -- The inverse function.\n\nleftInverse\u2082 : Set\nleftInverse\u2082 = \u2200 a \u2192 a \u207b\u00b9 \u00b7 a \u2261 \u03b5\n\n-- From the left-inverse property based on the signature (G, \u00b7, _\u207b\u00b9, \u03b5,)\n-- to the one based on the signature (G, \u00b7, \u03b5,).\nleftInverse\u2082\u208b\u2081 : leftInverse\u2082 \u2192 leftInverse\u2081\nleftInverse\u2082\u208b\u2081 h a = (a \u207b\u00b9) , (h a)\n\n-- From the left-inverse property based on the signature (G, \u00b7, \u03b5,) to\n-- the one based on the signature (G, \u00b7, _\u207b\u00b9, \u03b5,).\n--\n-- In this case we prove the existence of the inverse function.\nleftInverse\u2081\u208b\u2082 : leftInverse\u2081 \u2192 \u03a3 (G \u2192 G) (\u03bb f \u2192 \u2200 a \u2192 f a \u00b7 a \u2261 \u03b5)\nleftInverse\u2081\u208b\u2082 h = f , prf\n  where\n  f : G \u2192 G  --  The inverse function.\n  f a = proj\u2081 (h a)\n\n  prf : \u2200 a \u2192 f a \u00b7 a \u2261 \u03b5\n  prf a = proj\u2082 (h a)\n", "meta": {"hexsha": "dc7766198371bc669abd46421c4534dd983e1836", "size": 2469, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/FOT/GroupTheory/FormalisationsSL.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/FOT/GroupTheory/FormalisationsSL.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/FOT/GroupTheory/FormalisationsSL.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 30.1097560976, "max_line_length": 87, "alphanum_fraction": 0.5536654516, "num_tokens": 754, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952866333484, "lm_q2_score": 0.8438951045175643, "lm_q1q2_score": 0.7575606577383744}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Functions.Definition\nopen import Sets.EquivalenceRelations\nopen import Rings.Definition\n\nmodule Rings.Divisible.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A \u2192 A \u2192 A} (R : Ring S _+_ _*_) where\n\nopen Setoid S\nopen Equivalence eq\nopen Ring R\n\n_\u2223_ : Rel A\na \u2223 b = Sg A (\u03bb c \u2192 (a * c) \u223c b)\n\ndivisibleWellDefined : {x y a b : A} \u2192 (x \u223c y) \u2192 (a \u223c b) \u2192 x \u2223 a \u2192 y \u2223 b\ndivisibleWellDefined x=y a=b (c , xc=a) = c , transitive (*WellDefined (symmetric x=y) reflexive) (transitive xc=a a=b)\n", "meta": {"hexsha": "3447436857ce4dbfc13a814955593c1da6b90190", "size": 624, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Rings/Divisible/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Rings/Divisible/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Rings/Divisible/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 31.2, "max_line_length": 127, "alphanum_fraction": 0.6554487179, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172644875642, "lm_q2_score": 0.7981867801399695, "lm_q1q2_score": 0.7574132159605567}}
{"text": "module Issue790 where\n\nopen import Common.Level   renaming (lzero to zero; lsuc to suc)\nopen import Common.Prelude using (Bool; true; false; zero; suc) renaming (Nat to \u2115)\n\neven? : \u2115 -> Bool\neven? 0             = true\neven? (suc (suc n)) = even? n\neven? _             = false\n\n-- Name overlap between Level's suc and Nat's suc should not matter,\n-- since only one is a constructor.\n", "meta": {"hexsha": "f57df7375fd4e63ae8fd4ecbf6a1a7723db0ae32", "size": 382, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/Issue790.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/Issue790.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/Issue790.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 29.3846153846, "max_line_length": 83, "alphanum_fraction": 0.6596858639, "num_tokens": 105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9111796979521252, "lm_q2_score": 0.8311430394931456, "lm_q1q2_score": 0.7573206636803756}}
{"text": "module Naturals where\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n-- suc (suc (suc (suc (suc (suc (suc zero))))))\n\n{-# BUILTIN NATURAL \u2115 #-}\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl)\nopen Eq.\u2261-Reasoning using (begin_; _\u2261\u27e8\u27e9_; _\u220e)\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n  = n           -- 0 + n       \u2261 n\nsuc m + n = suc (m + n) -- (1 + m) + n \u2261 1 + (m + n)\n\n_ : 1 + 1 \u2261 2\n_ = refl\n\n\n_ : 3 + 4 \u2261 7\n_ =\n  begin\n    3 + 4\n  \u2261\u27e8\u27e9\n    suc 1 + 4\n  \u220e", "meta": {"hexsha": "af5b1436ff5734b6f4b2874aa8341530ea7b74b1", "size": 466, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "plfa/src/Naturals.agda", "max_stars_repo_name": "xiongxin/playground", "max_stars_repo_head_hexsha": "9f23862b35c00b810e20f2e1e661142c024baa33", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "plfa/src/Naturals.agda", "max_issues_repo_name": "xiongxin/playground", "max_issues_repo_head_hexsha": "9f23862b35c00b810e20f2e1e661142c024baa33", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plfa/src/Naturals.agda", "max_forks_repo_name": "xiongxin/playground", "max_forks_repo_head_hexsha": "9f23862b35c00b810e20f2e1e661142c024baa33", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.0689655172, "max_line_length": 52, "alphanum_fraction": 0.491416309, "num_tokens": 210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9343951607140233, "lm_q2_score": 0.8104789109591832, "lm_q1q2_score": 0.7573075722610326}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Setoids.Setoids\nopen import Agda.Primitive using (Level; lzero; lsuc; _\u2294_)\nopen import Groups.Definition\n\nmodule Groups.Subgroups.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A \u2192 A \u2192 A} (G : Group S _+_) where\n\nopen import Setoids.Subset S\nopen Group G\n\nrecord Subgroup {c : _} (pred : A \u2192 Set c) : Set (a \u2294 b \u2294 c) where\n  field\n    isSubset : subset pred\n    closedUnderPlus : {g h : A} \u2192 (pred g) \u2192 (pred h) \u2192 pred (g + h)\n    containsIdentity : pred 0G\n    closedUnderInverse : ({g : A} \u2192 (pred g) \u2192 (pred (inverse g)))\n\nsubgroupOp : {c : _} {pred : A \u2192 Set c} \u2192 (s : Subgroup pred) \u2192 Sg A pred \u2192 Sg A pred \u2192 Sg A pred\nsubgroupOp {pred = pred} record { closedUnderPlus = one } (a , prA) (b , prB) = (a + b) , one prA prB\n\nsubgroupIsGroup : {c : _} {pred : A \u2192 Set c} \u2192 (s : Subgroup pred) \u2192 Group (subsetSetoid (Subgroup.isSubset s)) (subgroupOp s)\nGroup.+WellDefined (subgroupIsGroup s) {m , prM} {n , prN} {x , prX} {y , prY} m=x n=y = +WellDefined m=x n=y\nGroup.0G (subgroupIsGroup record { containsIdentity = two }) = 0G , two\nGroup.inverse (subgroupIsGroup record { closedUnderInverse = three }) (a , prA) = (inverse a) , three prA\nGroup.+Associative (subgroupIsGroup s) {a , prA} {b , prB} {c , prC} = +Associative\nGroup.identRight (subgroupIsGroup s) {a , prA} = identRight\nGroup.identLeft (subgroupIsGroup s) {a , prA} = identLeft\nGroup.invLeft (subgroupIsGroup s) {a , prA} = invLeft\nGroup.invRight (subgroupIsGroup s) {a , prA} = invRight\n", "meta": {"hexsha": "2e078dec351bd97200040608159b04cec1faa6c9", "size": 1562, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Groups/Subgroups/Definition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Groups/Subgroups/Definition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Groups/Subgroups/Definition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 48.8125, "max_line_length": 126, "alphanum_fraction": 0.6542893726, "num_tokens": 555, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802462567085, "lm_q2_score": 0.8244619263765707, "lm_q1q2_score": 0.7572519931676329}}
{"text": "-- 2014-04-24\n\nmodule _ where\n\nopen import Common.Size\nopen import Common.Prelude using (Bool; true; false; if_then_else_)\nopen import Common.Product\n\n-- sized lists\n\ndata List A {i} : Set where\n  []  : List A\n  _\u2237_ : {i' : Size< i} (x : A) (xs : List A {i'}) \u2192 List A\n\n_++_ : \u2200{A} \u2192 List A \u2192 List A \u2192 List A\n[]       ++ ys = ys\n(x \u2237 xs) ++ ys = x \u2237 (xs ++ ys)\n\npartition : \u2200{A i} (p : A \u2192 Bool) (l : List A {i}) \u2192 List A {i} \u00d7 List A {i}\npartition p []       = [] , []\npartition p (x \u2237 xs) = let l , r = partition p xs in\n  if p x then ((x \u2237 l) , r) else (l , (x \u2237 r))\n\nmodule Sort {A : Set} (_\u2264_ : A \u2192 A \u2192 Bool) where\n\n  quicksort : \u2200{i} \u2192 List A {i} \u2192 List A\n  quicksort []       = []\n  quicksort (x \u2237 []) = x \u2237 []\n  quicksort (x \u2237 xs) = let x\u2264 , \u2264x = partition (_\u2264_ x) xs in\n    quicksort \u2264x ++ (x \u2237 quicksort x\u2264)\n", "meta": {"hexsha": "0a11af416a2793f248bc96f383691f4eceeaae69", "size": 818, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/SizedQuicksort.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_issues_repo_path": "test/Succeed/SizedQuicksort.agda", "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/Succeed/SizedQuicksort.agda", "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "avg_line_length": 26.3870967742, "max_line_length": 76, "alphanum_fraction": 0.5171149144, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133515091157, "lm_q2_score": 0.8056321913146127, "lm_q1q2_score": 0.7572244530221507}}
{"text": "module 030-semigroup where\n\n-- We need equivalence.\n\nopen import 020-equivalence\n\n-- Semigroups are basically a set with equality and some binary\n-- operator which is associative and respects equality.\n\nrecord SemiGroup\n  {M : Set}\n  (_==_ : M -> M -> Set)\n  (_*_ : M -> M -> M)\n  : Set1 where\n\n  field\n    equiv : Equivalence _==_\n    assoc : \u2200 {r s t} -> ((r * s) * t) == (r * (s * t))\n    cong : \u2200 {r s u v} -> (r == s) -> (u == v) -> (r * u) == (s * v)\n\n  -- The next line brings all fields and declarations of Equivalence\n  -- into this record's namespace so we can refer to them in an\n  -- unqualified way in proofs (for example, we can write \"refl\" for\n  -- \"Equivalence.symm equiv\" and so on).\n\n  open Equivalence equiv public\n\n  -- No theorems here yet.\n", "meta": {"hexsha": "38e65ddf8b5cfa869a5dc916239b944440ec16ac", "size": 763, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "030-semigroup.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "030-semigroup.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "030-semigroup.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.3103448276, "max_line_length": 68, "alphanum_fraction": 0.6186107471, "num_tokens": 230, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9609517072737735, "lm_q2_score": 0.7879311981328135, "lm_q1q2_score": 0.7571638300599971}}
{"text": "-- Proof of: \u2200 (x : ND \u2115) \u2192 always (even (double (eo x))) \u2261 tt\n\nmodule even-double-eo where\n\nopen import bool\nopen import nat\nopen import eq\nopen import nat-thms\nopen import nondet\nopen import nondet-thms\nopen import functions\n\n----------------------------------------------------------------------\n\n-- A definition of double with addition.\ndouble : \u2115 \u2192 \u2115\ndouble x = x + x\n\n-- even is a deterministic predicate:\neven : \u2115 \u2192 \ud835\udd39\neven zero = tt\neven (suc 0) = ff\neven (suc (suc x)) = even x\n\n-- eo yields an even and odd number close to the input value:\neo : \u2115 \u2192 ND \u2115\neo n = Val n ?? Val (suc n)\n\n-- auxiliary property for x+x instead of double:\neven-x+x : (x : \u2115) \u2192 even (x + x) \u2261 tt\neven-x+x zero = refl\neven-x+x (suc x) rewrite +suc x x | even-x+x x = refl\n\n-- (even (double x)) is always true:\neven-double-is-true : \u2200 (x : \u2115) \u2192 even (double x) \u2261 tt\neven-double-is-true x rewrite even-x+x x = refl\n\n-- Proof of main result:\neven-double-eo-true : (n : \u2115) \u2192 always ((even \u2218 double) $* (eo n)) \u2261 tt\neven-double-eo-true n = always-$* (even \u2218 double) (eo n) even-double-is-true\n\n-- Alternative statement and proof:\ndouble-eo-satisfy-even : \u2200 (n : \u2115) \u2192 (double $* (eo n)) satisfy even \u2261 tt\ndouble-eo-satisfy-even n\n  rewrite even-double-is-true n | +suc n n | even-double-is-true n = refl\n\n\n----------------------------------------------------------------------\n", "meta": {"hexsha": "c6929b0908a0beb9ce9d1b3248bf3416c93cc671", "size": 1354, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nondet/even-double-eo.agda", "max_stars_repo_name": "mihanus/curry-agda", "max_stars_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "nondet/even-double-eo.agda", "max_issues_repo_name": "mihanus/curry-agda", "max_issues_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nondet/even-double-eo.agda", "max_forks_repo_name": "mihanus/curry-agda", "max_forks_repo_head_hexsha": "b7cfdda11cdadeba882b6b72d75448acd8b0a294", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6326530612, "max_line_length": 76, "alphanum_fraction": 0.582717873, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625126757597, "lm_q2_score": 0.8128673201042492, "lm_q1q2_score": 0.7571554364563151}}
{"text": "module Lib where\n\n\n-- Natural numbers\n\ndata Nat : Set where\n  zero :        Nat\n  suc  : Nat -> Nat\n\n{-# BUILTIN NATURAL Nat #-}\n\n_+_ : Nat -> Nat -> Nat\nzero  + n  = n\nsuc k + n = suc (k + n)\n\n\n-- Finite sets\n\ndata Fin : Nat -> Set where\n  fzero : forall {n} ->          Fin (suc n)\n  fsuc  : forall {n} -> Fin n -> Fin (suc n)\n\nfin : forall {n} (k : Nat) -> Fin (suc (k + n))\nfin zero    = fzero\nfin (suc i) = fsuc (fin i)\n\n\n-- Lists\n\ninfixl 0 _,_\n\ndata List (X : Set) : Set where\n  []  :                List X\n  _,_ : List X -> X -> List X\n\n\n-- List membership\n\ndata LMem {X : Set} (a : X) : List X -> Set where\n  lzero : forall {l}               -> LMem a (l , a)\n  lsuc  : forall {l b} -> LMem a l -> LMem a (l , b)\n\n\n-- Vectors\n\ndata Vec (X : Set) : Nat -> Set where\n  []  :                               Vec X zero\n  _,_ : forall {n} -> Vec X n -> X -> Vec X (suc n)\n\nproj : forall {X n} -> Vec X n -> Fin n -> X\nproj []      ()\nproj (_ , a) fzero    = a\nproj (v , _) (fsuc i) = proj v i\n\n\n-- Vector membership\n\ndata VMem {X : Set} (a : X) : forall {n} -> Fin n -> Vec X n -> Set where\n  mzero : forall {n}     {v : Vec X n}               -> VMem a fzero    (v , a)\n  msuc  : forall {n i b} {v : Vec X n} -> VMem a i v -> VMem a (fsuc i) (v , b)\n\nfmem : forall {X n} -> (i : Fin n) -> {v : Vec X n} -> VMem (proj v i) i v\nfmem {_} {zero}  ()\nfmem {_} {suc n} fzero    {_ , a} = mzero\nfmem {_} {suc n} (fsuc i) {v , _} = msuc (fmem i)\n\nmem : forall {X n} -> (k : Nat) -> {v : Vec X (suc (k + n))} -> VMem (proj v (fin k)) (fin k) v\nmem i = fmem (fin i)\n", "meta": {"hexsha": "1ea71170036f6dc08f1cfb317a695c1805f97225", "size": 1559, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Lib.agda", "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": ["X11"], "max_stars_count": 26, "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_issues_repo_path": "src/Lib.agda", "max_issues_repo_name": "mietek/formal-logic", "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_issues_repo_licenses": ["X11"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Lib.agda", "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.5942028986, "max_line_length": 95, "alphanum_fraction": 0.4746632457, "num_tokens": 597, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9314625107731765, "lm_q2_score": 0.8128673155708976, "lm_q1q2_score": 0.7571554306871203}}
{"text": "-- Functions used in googology\n\n{-# OPTIONS --without-K --safe --exact-split #-}\n\nmodule Math.Googology.Function where\n\n-- agda-stdlib\nopen import Data.Nat\nopen import Data.Nat.GeneralisedArithmetic\nopen import Function\n\n-- Ackermann function.\n-- ack m n = Ack(m, n)\nack : \u2115 \u2192 \u2115 \u2192 \u2115\nack 0       n       = 1 + n\nack (suc m) zero    = ack m 1\nack (suc m) (suc n) = ack m (ack (suc m) n)\n\n-- Hyperoperation.\n-- H n a b \u2261 H\u2099(a, b)\nH : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 \u2115\nH 0                     a b       = 1 + b\nH 1                     a 0       = a\nH 1                     a (suc b) = H 0 a (H 1 a b)\nH 2                     a 0       = 0\nH 2                     a (suc b) = H 1 a (H 2 a b)\nH (suc (suc (suc _)))   a 0       = 1\nH (suc n@(suc (suc _))) a (suc b) = H n a (H (suc n) a b)\n\n-- Knuth's up-arrow notation.\n-- a \u2191[ n ] b =`a \u2191\u207f b`\n_\u2191[_]_ : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 \u2115\na \u2191[ n ] b = H (2 + n) a b\n\ninfixr 8 _\u2191_ _\u2191\u2191_ _\u2191\u2191\u2191_ _\u2191\u2191\u2191\u2191_\n\n-- Exponentiation.\n_\u2191_ : \u2115 \u2192 \u2115 \u2192 \u2115\n_\u2191_ a b = a \u2191[ 1 ] b\n\n-- Tetration.\n_\u2191\u2191_ : \u2115 \u2192 \u2115 \u2192 \u2115\n_\u2191\u2191_ a b = a \u2191[ 2 ] b\n\n-- Pentation.\n_\u2191\u2191\u2191_ : \u2115 \u2192 \u2115 \u2192 \u2115\n_\u2191\u2191\u2191_ a b = a \u2191[ 3 ] b\n\n-- Hexation.\n_\u2191\u2191\u2191\u2191_ : \u2115 \u2192 \u2115 \u2192 \u2115\n_\u2191\u2191\u2191\u2191_ a b = a \u2191[ 4 ] b\n\n-- Heptation.\n_\u2191\u2191\u2191\u2191\u2191_ : \u2115 \u2192 \u2115 \u2192 \u2115\n_\u2191\u2191\u2191\u2191\u2191_ a b = a \u2191[ 5 ] b\n\n-- Graham's number.\ngraham's-number : \u2115\ngraham's-number = go 64 where\n  go : \u2115 \u2192 \u2115\n  go 0       = 4\n  go (suc n) = 3 \u2191[ go n ] 3\n\n-- Fast-growing hierarchy\nFGH\u2115[_][_] : \u2115 \u2192 \u2115 \u2192 \u2115\nFGH\u2115[ zero  ][ x ] = suc x\nFGH\u2115[ suc n ][ x ] = fold x FGH\u2115[ n ][_] x\n\nFGH\u03c9 : \u2115 \u2192 \u2115\nFGH\u03c9 n = FGH\u2115[ n ][ n ]\n", "meta": {"hexsha": "51c2b0c42f6d91684b1e58535a5cb6bd366a3a16", "size": 1472, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Math/Googology/Function.agda", "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_issues_repo_path": "Math/Googology/Function.agda", "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Math/Googology/Function.agda", "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.7323943662, "max_line_length": 57, "alphanum_fraction": 0.457201087, "num_tokens": 660, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9546474168650673, "lm_q2_score": 0.7931059438487663, "lm_q1q2_score": 0.7571365405955558}}
{"text": "------------------------------------------------------------------------------\n-- Group theory properties\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule GroupTheory.PropertiesI where\n\nopen import GroupTheory.Base\n\nopen import Common.FOL.Relation.Binary.EqReasoning\n\n------------------------------------------------------------------------------\n-- Congruence properties\n\n-- The propositional equality is compatible with the binary operation.\n\n\u00b7-leftCong : \u2200 {a b c} \u2192 a \u2261 b \u2192 a \u00b7 c \u2261 b \u00b7 c\n\u00b7-leftCong refl = refl\n\n\u00b7-rightCong : \u2200 {a b c} \u2192 b \u2261 c \u2192 a \u00b7 b \u2261 a \u00b7 c\n\u00b7-rightCong refl = refl\n\n-- The propositional equality is compatible with the inverse function.\n\u207b\u00b9-cong : \u2200 {a b} \u2192 a \u2261 b \u2192 a \u207b\u00b9 \u2261 b \u207b\u00b9\n\u207b\u00b9-cong refl = refl\n\n------------------------------------------------------------------------------\n\nleftCancellation : \u2200 {a b c} \u2192 a \u00b7 b \u2261 a \u00b7 c \u2192 b \u2261 c\nleftCancellation {a} {b} {c} h =\n  b              \u2261\u27e8 sym (leftIdentity b) \u27e9\n  \u03b5 \u00b7 b          \u2261\u27e8 \u00b7-leftCong (sym (leftInverse a)) \u27e9\n  a \u207b\u00b9 \u00b7 a \u00b7 b   \u2261\u27e8 assoc (a \u207b\u00b9) a b \u27e9\n  a \u207b\u00b9 \u00b7 (a \u00b7 b) \u2261\u27e8 \u00b7-rightCong h \u27e9\n  a \u207b\u00b9 \u00b7 (a \u00b7 c) \u2261\u27e8 sym (assoc (a \u207b\u00b9) a c) \u27e9\n  a \u207b\u00b9 \u00b7 a \u00b7 c   \u2261\u27e8 \u00b7-leftCong (leftInverse a) \u27e9\n  \u03b5 \u00b7 c          \u2261\u27e8 leftIdentity c \u27e9\n  c              \u220e\n\n-- A different proof without using congruence.\nleftCancellation' : \u2200 {a b c} \u2192 a \u00b7 b \u2261 a \u00b7 c \u2192 b \u2261 c\n-- Paper proof (Mac Lane and Garret Birkhoff 1999. p. 48):\n--\n-- 1. a\u207b\u00b9(ab) = a\u207b\u00b9(ac)  (hypothesis ab = ac)\n-- 2. a\u207b\u00b9a(b) = a\u207b\u00b9a(c)  (associative axiom)\n-- 3. \u03b5b      = \u03b5c       (left-inverse axiom for a\u207b\u00b9)\n-- 4. b       = c        (left-identity axiom)\nleftCancellation' {a} {b} {c} h =\n  b              \u2261\u27e8 sym (leftIdentity b) \u27e9\n  \u03b5 \u00b7 b          \u2261\u27e8 subst (\u03bb t \u2192 \u03b5 \u00b7 b \u2261 t \u00b7 b) (sym (leftInverse a)) refl \u27e9\n  a \u207b\u00b9 \u00b7 a \u00b7 b   \u2261\u27e8 assoc (a \u207b\u00b9) a b \u27e9\n  a \u207b\u00b9 \u00b7 (a \u00b7 b) \u2261\u27e8 subst (\u03bb t \u2192 a \u207b\u00b9 \u00b7 (a \u00b7 b) \u2261 a \u207b\u00b9 \u00b7 t) h refl \u27e9\n  a \u207b\u00b9 \u00b7 (a \u00b7 c) \u2261\u27e8 sym (assoc (a \u207b\u00b9) a c) \u27e9\n  a \u207b\u00b9 \u00b7 a \u00b7 c   \u2261\u27e8 subst (\u03bb t \u2192 a \u207b\u00b9 \u00b7 a \u00b7 c \u2261 t \u00b7 c) (leftInverse a) refl \u27e9\n  \u03b5 \u00b7 c          \u2261\u27e8 leftIdentity c \u27e9\n  c              \u220e\n\n-- Mac Lane and Garret Birkhoff (1999) p. 50, exercise 6.\nrightIdentity : \u2200 a \u2192 a \u00b7 \u03b5 \u2261 a\nrightIdentity a = leftCancellation prf\n  where\n  prf : a \u207b\u00b9 \u00b7 (a \u00b7 \u03b5) \u2261 a \u207b\u00b9 \u00b7 a\n  prf = a \u207b\u00b9 \u00b7 (a \u00b7 \u03b5) \u2261\u27e8 sym (assoc (a \u207b\u00b9) a \u03b5) \u27e9\n        a \u207b\u00b9 \u00b7 a \u00b7 \u03b5   \u2261\u27e8 \u00b7-leftCong (leftInverse a) \u27e9\n        \u03b5 \u00b7 \u03b5          \u2261\u27e8 leftIdentity \u03b5 \u27e9\n        \u03b5              \u2261\u27e8 sym (leftInverse a) \u27e9\n        a \u207b\u00b9 \u00b7 a       \u220e\n\n-- Mac Lane and Garret Birkhoff (1999) p. 50, exercise 6.\nrightInverse : \u2200 a \u2192 a \u00b7 a \u207b\u00b9 \u2261 \u03b5\nrightInverse a = leftCancellation prf\n  where\n  prf : a \u207b\u00b9 \u00b7 (a \u00b7 a \u207b\u00b9) \u2261 a \u207b\u00b9 \u00b7 \u03b5\n  prf = a \u207b\u00b9 \u00b7 (a \u00b7 a \u207b\u00b9) \u2261\u27e8 sym (assoc (a \u207b\u00b9) a (a \u207b\u00b9)) \u27e9\n        a \u207b\u00b9 \u00b7 a \u00b7 a \u207b\u00b9   \u2261\u27e8 \u00b7-leftCong (leftInverse a) \u27e9\n        \u03b5 \u00b7 a \u207b\u00b9          \u2261\u27e8 leftIdentity (a \u207b\u00b9)  \u27e9\n        a \u207b\u00b9              \u2261\u27e8 sym (rightIdentity (a \u207b\u00b9)) \u27e9\n        a \u207b\u00b9 \u00b7 \u03b5          \u220e\n\nrightCancellation : \u2200 {a b c} \u2192 b \u00b7 a \u2261 c \u00b7 a \u2192 b \u2261 c\nrightCancellation {a} {b} {c} h =\n-- Paper proof:\n--\n-- 1. (ba)a\u207b\u00b9 = (ca)a\u207b\u00b9  (hypothesis ab = ac)\n-- 2. (b)aa\u207b\u00b9 = (c)aa\u207b\u00b9  (associative axiom)\n-- 3. b\u03b5      = c\u03b5       (right-inverse axiom for a\u207b\u00b9)\n-- 4. b       = c        (right-identity axiom)\n  b              \u2261\u27e8 sym (rightIdentity b) \u27e9\n  b \u00b7 \u03b5          \u2261\u27e8 \u00b7-rightCong (sym (rightInverse a)) \u27e9\n  b \u00b7 (a \u00b7 a \u207b\u00b9) \u2261\u27e8 sym (assoc b a (a \u207b\u00b9)) \u27e9\n  b \u00b7 a \u00b7 a \u207b\u00b9   \u2261\u27e8 \u00b7-leftCong h \u27e9\n  c \u00b7 a \u00b7 a \u207b\u00b9   \u2261\u27e8 assoc c a (a \u207b\u00b9) \u27e9\n  c \u00b7 (a \u00b7 a \u207b\u00b9) \u2261\u27e8 \u00b7-rightCong (rightInverse a) \u27e9\n  c \u00b7 \u03b5          \u2261\u27e8 rightIdentity c \u27e9\n  c              \u220e\n\n-- Adapted from the Agda standard library\u00a00.8.1 (see\n-- Algebra.Properties.Group.right-helper).\ny\u2261x\u207b\u00b9[xy] : \u2200 a b \u2192 b \u2261 a \u207b\u00b9 \u00b7 (a \u00b7 b)\ny\u2261x\u207b\u00b9[xy] a b = b              \u2261\u27e8 sym (leftIdentity b) \u27e9\n                \u03b5 \u00b7 b          \u2261\u27e8 \u00b7-leftCong (sym (leftInverse a)) \u27e9\n                a \u207b\u00b9 \u00b7 a \u00b7 b   \u2261\u27e8 assoc (a \u207b\u00b9) a b \u27e9\n                a \u207b\u00b9 \u00b7 (a \u00b7 b) \u220e\n\n-- Adapted from the Agda standard library\u00a00.8.1 (see\n-- Algebra.Properties.Group.left-helper).\nx\u2261[xy]y\u207b\u00b9 : \u2200 a b \u2192 a \u2261 (a \u00b7 b) \u00b7 b \u207b\u00b9\nx\u2261[xy]y\u207b\u00b9 a b = a              \u2261\u27e8 sym (rightIdentity a) \u27e9\n                a \u00b7 \u03b5          \u2261\u27e8 \u00b7-rightCong (sym (rightInverse b)) \u27e9\n                a \u00b7 (b \u00b7 b \u207b\u00b9) \u2261\u27e8 sym (assoc a b (b \u207b\u00b9)) \u27e9\n                a \u00b7 b \u00b7 b \u207b\u00b9   \u220e\n\nrightIdentityUnique : \u2200 r \u2192 (\u2200 a \u2192 a \u00b7 r \u2261 a) \u2192 r \u2261 \u03b5\n-- Paper proof (Mac Lane and Garret 1999. p. 48):\n--\n-- 1. r  = \u03b5r (\u03b5 is an identity)\n-- 2. \u03b5r = r  (hypothesis)\n-- 3. r  = \u03b5  (transitivity)\nrightIdentityUnique r h = trans (sym (leftIdentity r)) (h \u03b5)\n\n-- A more appropiate version to be used in the proofs. Adapted from\n-- the Agda standard library\u00a00.8.1 (see\n-- Algebra.Properties.Group.right-identity-unique).\nrightIdentityUnique' : \u2200 a r \u2192 a \u00b7 r \u2261 a \u2192 r \u2261 \u03b5\nrightIdentityUnique' a r h = r              \u2261\u27e8 y\u2261x\u207b\u00b9[xy] a r \u27e9\n                             a \u207b\u00b9 \u00b7 (a \u00b7 r) \u2261\u27e8 \u00b7-rightCong h \u27e9\n                             a \u207b\u00b9 \u00b7 a       \u2261\u27e8 leftInverse a \u27e9\n                             \u03b5              \u220e\n\nleftIdentityUnique : \u2200 l \u2192 (\u2200 a \u2192 l \u00b7 a \u2261 a) \u2192 l \u2261 \u03b5\n-- Paper proof:\n-- 1. l  = le (\u03b5 is an identity)\n-- 2. le = e  (hypothesis)\n-- 3. l  = e  (transitivity)\nleftIdentityUnique l h = trans (sym (rightIdentity l)) (h \u03b5)\n\n-- A more appropiate version to be used in the proofs. Adapted from\n-- the Agda standard library\u00a00.8.1 (see\n-- Algebra.Properties.Group.left-identity-unique).\nleftIdentityUnique' : \u2200 a l \u2192 l \u00b7 a \u2261 a \u2192 l \u2261 \u03b5\nleftIdentityUnique' a l h = l            \u2261\u27e8 x\u2261[xy]y\u207b\u00b9 l a \u27e9\n                            l \u00b7 a \u00b7 a \u207b\u00b9 \u2261\u27e8 \u00b7-leftCong h \u27e9\n                            a \u00b7 a \u207b\u00b9     \u2261\u27e8 rightInverse a \u27e9\n                            \u03b5            \u220e\n\nrightInverseUnique : \u2200 {a} \u2192 \u2203[ r ] (a \u00b7 r \u2261 \u03b5) \u2227\n                                    (\u2200 r' \u2192 a \u00b7 r' \u2261 \u03b5 \u2192 r \u2261 r')\nrightInverseUnique {a} =\n-- Paper proof:\n--\n-- 1.   We know that (a\u207b\u00b9) is a right inverse for a.\n-- 2.   Let's suppose there is other right inverse r for a, i.e. ar \u2261 \u03b5, then\n-- 2.1. aa\u207b\u00b9 = \u03b5  (right-inverse axiom)\n-- 2.2. ar   = \u03b5  (hypothesis)\n-- 2.3. aa\u207b\u00b9 = ar (transitivity)\n-- 2.4  a\u207b\u00b9  = a  (left-cancellation)\n  _ , rightInverse a , prf\n    where\n    prf : \u2200 r' \u2192 a \u00b7 r' \u2261 \u03b5 \u2192 a \u207b\u00b9 \u2261 r'\n    prf r' ar'\u2261\u03b5 = leftCancellation aa\u207b\u00b9\u2261ar'\n      where\n      aa\u207b\u00b9\u2261ar' : a \u00b7 a \u207b\u00b9 \u2261 a \u00b7 r'\n      aa\u207b\u00b9\u2261ar' = a \u00b7 a \u207b\u00b9 \u2261\u27e8 rightInverse a \u27e9\n                 \u03b5        \u2261\u27e8 sym ar'\u2261\u03b5 \u27e9\n                 a \u00b7 r'   \u220e\n\n-- A more appropiate version to be used in the proofs.\nrightInverseUnique' : \u2200 {a r} \u2192 a \u00b7 r \u2261 \u03b5 \u2192 a \u207b\u00b9 \u2261 r\nrightInverseUnique' {a} {r} ar\u2261\u03b5 = leftCancellation aa\u207b\u00b9\u2261ar\n  where\n  aa\u207b\u00b9\u2261ar : a \u00b7 a \u207b\u00b9 \u2261 a \u00b7 r\n  aa\u207b\u00b9\u2261ar = a \u00b7 a \u207b\u00b9 \u2261\u27e8 rightInverse a \u27e9\n            \u03b5        \u2261\u27e8 sym ar\u2261\u03b5 \u27e9\n            a \u00b7 r    \u220e\n\nleftInverseUnique : \u2200 {a} \u2192 \u2203[ l ] (l \u00b7 a \u2261 \u03b5) \u2227\n                                   (\u2200 l' \u2192 l' \u00b7 a \u2261 \u03b5 \u2192 l \u2261 l')\nleftInverseUnique {a} =\n-- Paper proof:\n--\n-- 1.   We know that (a\u207b\u00b9) is a left inverse for a.\n-- 2.   Let's suppose there is other right inverse l for a, i.e. la \u2261 \u03b5, then\n-- 2.1. a\u207b\u00b9a = \u03b5  (left-inverse axiom)\n-- 2.2. la   = \u03b5  (hypothesis)\n-- 2.3. a\u207b\u00b9a = la (transitivity)\n-- 2.4  a\u207b\u00b9  = l  (right-cancellation)\n  _ , leftInverse a , prf\n    where\n    prf : \u2200 l' \u2192 l' \u00b7 a \u2261 \u03b5 \u2192 a \u207b\u00b9 \u2261 l'\n    prf l' l'a\u2261\u03b5 = rightCancellation a\u207b\u00b9a\u2261l'a\n      where\n      a\u207b\u00b9a\u2261l'a : a \u207b\u00b9 \u00b7 a \u2261 l' \u00b7 a\n      a\u207b\u00b9a\u2261l'a = a \u207b\u00b9 \u00b7 a \u2261\u27e8 leftInverse a \u27e9\n                 \u03b5        \u2261\u27e8 sym l'a\u2261\u03b5 \u27e9\n                 l' \u00b7 a   \u220e\n\n-- A more appropiate version to be used in the proofs.\nleftInverseUnique' : \u2200 {a l} \u2192 l \u00b7 a \u2261 \u03b5 \u2192 a \u207b\u00b9 \u2261 l\nleftInverseUnique' {a} {l} la\u2261\u03b5 = rightCancellation a\u207b\u00b9a\u2261la\n  where\n  a\u207b\u00b9a\u2261la : a \u207b\u00b9 \u00b7 a \u2261 l \u00b7 a\n  a\u207b\u00b9a\u2261la = a \u207b\u00b9 \u00b7 a \u2261\u27e8 leftInverse a \u27e9\n            \u03b5        \u2261\u27e8 sym la\u2261\u03b5 \u27e9\n            l \u00b7 a    \u220e\n\n\u207b\u00b9-involutive : \u2200 a \u2192 a \u207b\u00b9 \u207b\u00b9 \u2261 a\n-- Paper proof:\n--\n-- 1. a\u207b\u00b9a = \u03b5  (left-inverse axiom)\n-- 2. The previous equation states that a is the unique right\n-- inverse (a\u207b\u00b9)\u207b\u00b9 of a\u207b\u00b9.\n\u207b\u00b9-involutive a = rightInverseUnique' (leftInverse a)\n\nidentityInverse : \u03b5 \u207b\u00b9 \u2261 \u03b5\n-- Paper proof:\n--\n-- 1. \u03b5\u03b5 = \u03b5  (left/right-identity axiom)\n-- 2. The previous equation states that \u03b5 is the unique left/right\n-- inverse \u03b5\u207b\u00b9 of \u03b5.\nidentityInverse = rightInverseUnique' (leftIdentity \u03b5)\n\ninverseDistribution : \u2200 a b \u2192 (a \u00b7 b) \u207b\u00b9 \u2261 b \u207b\u00b9 \u00b7 a \u207b\u00b9\n-- Paper proof:\n--\n-- (b\u207b\u00b9a\u207b\u00b9)(ab) = b\u207b\u00b9(a\u207b\u00b9(ab)) (associative axiom)\n--              = b\u207b\u00b9(a\u207b\u00b9a)b   (associative axiom)\n--              = b\u207b\u00b9(\u03b5b)      (left-inverse axiom)\n--              = b\u207b\u00b9b         (left-identity axiom)\n--              = \u03b5            (left-inverse axiom)\n-- Therefore, b\u207b\u00b9a\u207b\u00b9 is the unique left inverse of ab.\ninverseDistribution a b = leftInverseUnique' b\u207b\u00b9a\u207b\u00b9[ab]\u2261\u03b5\n  where\n  b\u207b\u00b9a\u207b\u00b9[ab]\u2261\u03b5 : b \u207b\u00b9 \u00b7 a \u207b\u00b9 \u00b7 (a \u00b7 b) \u2261 \u03b5\n  b\u207b\u00b9a\u207b\u00b9[ab]\u2261\u03b5 =\n    b \u207b\u00b9 \u00b7 a \u207b\u00b9 \u00b7 (a \u00b7 b)\n      \u2261\u27e8 assoc (b \u207b\u00b9) (a \u207b\u00b9) (a \u00b7 b) \u27e9\n    b \u207b\u00b9 \u00b7 (a \u207b\u00b9 \u00b7 (a \u00b7 b))\n      \u2261\u27e8 \u00b7-rightCong (sym (assoc (a \u207b\u00b9) a b)) \u27e9\n    b \u207b\u00b9 \u00b7 (a \u207b\u00b9 \u00b7 a \u00b7 b)\n      \u2261\u27e8 \u00b7-rightCong (\u00b7-leftCong (leftInverse a)) \u27e9\n    b \u207b\u00b9 \u00b7 (\u03b5 \u00b7 b)\n      \u2261\u27e8 \u00b7-rightCong (leftIdentity b) \u27e9\n    b \u207b\u00b9 \u00b7 b\n      \u2261\u27e8 leftInverse b \u27e9\n    \u03b5 \u220e\n\n-- If the square of every element is the identity, the system is\n-- commutative. From: TPTP 6.4.0 problem GRP/GRP001-2.p.\nx\u00b2\u2261\u03b5\u2192comm : (\u2200 a \u2192 a \u00b7 a \u2261 \u03b5) \u2192 \u2200 {b c d} \u2192 b \u00b7 c \u2261 d \u2192 c \u00b7 b \u2261 d\n-- Paper proof:\n--\n-- 1. d(bc)  = dd  (hypothesis bc = d)\n-- 2. d(bc)  = \u03b5   (hypothesis dd = \u03b5)\n-- 3. d(bc)c = c   (by 2)\n-- 4. db(cc) = c   (associativity axiom)\n-- 5. db     = c   (hypothesis cc = \u03b5)\n-- 6. (db)b  = cb  (by 5)\n-- 7. d(bb)  = cb  (associativity axiom)\n-- 6. d      = cb  (hypothesis bb = \u03b5)\nx\u00b2\u2261\u03b5\u2192comm h {b} {c} {d} bc\u2261d = sym d\u2261cb\n  where\n  db\u2261c : d \u00b7 b \u2261 c\n  db\u2261c =\n    d \u00b7 b\n      \u2261\u27e8 sym (rightIdentity (d \u00b7 b)) \u27e9\n    d \u00b7 b \u00b7 \u03b5\n      \u2261\u27e8 \u00b7-rightCong (sym (h c)) \u27e9\n    d \u00b7 b \u00b7 (c \u00b7 c)\n      \u2261\u27e8 assoc d b (c \u00b7 c) \u27e9\n    d \u00b7 (b \u00b7 (c \u00b7 c))\n      \u2261\u27e8 \u00b7-rightCong (sym (assoc b c c)) \u27e9\n    d \u00b7 ((b \u00b7 c) \u00b7 c)\n      \u2261\u27e8 \u00b7-rightCong (\u00b7-leftCong bc\u2261d) \u27e9\n    d \u00b7 (d \u00b7 c)\n      \u2261\u27e8 sym (assoc d d c) \u27e9\n    d \u00b7 d \u00b7 c\n      \u2261\u27e8 \u00b7-leftCong (h d) \u27e9\n    \u03b5 \u00b7 c\n      \u2261\u27e8 leftIdentity c \u27e9\n    c \u220e\n\n  d\u2261cb : d \u2261 c \u00b7 b\n  d\u2261cb = d           \u2261\u27e8 sym (rightIdentity d) \u27e9\n         d \u00b7 \u03b5       \u2261\u27e8 \u00b7-rightCong (sym (h b)) \u27e9\n         d \u00b7 (b \u00b7 b) \u2261\u27e8 sym (assoc d b b) \u27e9\n         d \u00b7 b \u00b7 b   \u2261\u27e8 \u00b7-leftCong db\u2261c \u27e9\n         c \u00b7 b       \u220e\n\n------------------------------------------------------------------------------\n-- References\n--\n-- Mac Lane, S. and Birkhof, G. (1999). Algebra. 3rd ed. AMS Chelsea\n-- Publishing.\n", "meta": {"hexsha": "59a71e166027325073c19b09cd78b186c43978de", "size": 10461, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/GroupTheory/PropertiesI.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/GroupTheory/PropertiesI.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/GroupTheory/PropertiesI.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 35.1040268456, "max_line_length": 78, "alphanum_fraction": 0.4613325686, "num_tokens": 4273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8947894604912848, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.7569403805612883}}
{"text": "module Data.List.Relation.Permutation where\n\nimport      Data\nopen import Data.Boolean\nopen import Data.List\nopen import Data.List.Functions renaming (module LongOper to List)\nopen import Data.List.Relation\nopen import Functional using (id ; _\u2218_ ; const)\nopen import Logic.Propositional\nopen import Logic\nimport      Lvl\nopen import Numeral.Finite\nopen import Syntax.Function\nopen import Type\n\nprivate variable \u2113 : Lvl.Level\nprivate variable T A B : Type{\u2113}\nprivate variable l l\u2081 l\u2082 l\u2083 l\u2084 : List(T)\nprivate variable x y z : T\nprivate variable f : A \u2192 B\nprivate variable P : T \u2192 Bool\n\n-- The relation for two lists that are permutations of each other.\n-- This means that they contain the same elements and the same number of them but possibly in a different order.\n-- Or in other words, the first list is a reordered list of the second.\ndata _permutes_ {\u2113} : List{\u2113}(T) \u2192 List{\u2113}(T) \u2192 Stmt{Lvl.\ud835\udc12(\u2113)} where\n  empty   : \u2205 permutes (\u2205 {T = T})\n  prepend : (l\u2081 permutes l\u2082) \u2192 ((x \u22b0 l\u2081) permutes (x \u22b0 l\u2082))\n  swap    : (x \u22b0 y \u22b0 l) permutes (y \u22b0 x \u22b0 l)\n  trans   : (l\u2081 permutes l\u2082) \u2192 (l\u2082 permutes l\u2083) \u2192 (l\u2081 permutes l\u2083)\n\ntrans-swap : (l\u2081 permutes l\u2082) \u2192 ((x \u22b0 y \u22b0 l\u2081) permutes (y \u22b0 x \u22b0 l\u2082))\ntrans-swap p = trans swap (prepend (prepend p))\n\n-- TODO\n-- _partition-of_ : List(List(T)) \u2192 List(T) \u2192 Stmt\n-- p partition-of l = (fold\u1d63 (x \u21a6 \u00ac Empty(x) \u2227_) Data.Unit p) \u2227 (concat(p) permutes l)\n\n-- The permutation as a function between the permutated elements' indices.\n-- Example:\n--   p : [a,b,c,d,e,f] permutes [a,f,e,d,b,c]\n--   map(permutation-mapping(p)) [0,1,2,3,4,5] = [0,4,5,3,2,1]\npermutation-mapping : (l\u2081 permutes l\u2082) \u2192 (\ud835\udd5f(length(l\u2081)) \u2192 \ud835\udd5f(length(l\u2082)))\npermutation-mapping empty                = id\npermutation-mapping (prepend p) \ud835\udfce        = \ud835\udfce\npermutation-mapping (prepend p) (\ud835\udc12 n)    = \ud835\udc12(permutation-mapping p n)\npermutation-mapping swap        \ud835\udfce        = \ud835\udc12(\ud835\udfce)\npermutation-mapping swap        (\ud835\udc12 \ud835\udfce)    = \ud835\udfce\npermutation-mapping swap        (\ud835\udc12(\ud835\udc12 n)) = \ud835\udc12 (\ud835\udc12 n)\npermutation-mapping (trans p q)          = permutation-mapping q \u2218 permutation-mapping p\n\n-- TODO: It should be possible to make (_permutes_) the morphism of a category with some correct notion of equivalence (maybe trans swap swap \u2261 refl for example?). Then permutation-mapping would be an instance of Functor(length) for the ((_\u2192_) on\u2082 \ud835\udd5f) category?\n\nmodule Proofs where\n  open import Data.List.Proofs\n  open import Data.List.Equiv.Id\n  open import Lang.Inspect\n  open import Logic.Predicate\n  open import Numeral.Natural\n  open import Numeral.Finite.Proofs\n  open import Relator.Equals\n  open import Relator.Equals.Proofs\n  open import Structure.Function.Domain\n  open import Structure.Function.Domain.Proofs\n  import      Structure.Function.Names as Names\n  open import Structure.Function.Proofs\n  open import Structure.Function\n  import      Structure.Operator.Names as Names\n  open import Structure.Operator.Properties\n  open import Structure.Operator\n  import      Structure.Relator.Names as Names\n  open import Structure.Relator.Equivalence\n  open import Structure.Relator.Properties\n  open import Structure.Setoid using (Equiv)\n  open import Syntax.Function\n  open import Syntax.Transitivity\n\n  instance\n    permutes-reflexivity : Reflexivity(_permutes_ {T = T})\n    permutes-reflexivity = intro proof where\n      proof : Names.Reflexivity(_permutes_)\n      proof {\u2205}     = empty\n      proof {_ \u22b0 _} = prepend proof\n\n  instance\n    permutes-symmetry : Symmetry(_permutes_ {T = T})\n    permutes-symmetry = intro proof where\n      proof : Names.Symmetry(_permutes_)\n      proof empty       = empty\n      proof (prepend p) = prepend (proof p)\n      proof swap        = swap\n      proof (trans p q) = trans (proof q) (proof p)\n\n  instance\n    permutes-transitivity : Transitivity(_permutes_ {T = T})\n    permutes-transitivity = intro trans\n\n  instance\n    permutes-equivalence : Equivalence(_permutes_ {T = T})\n    permutes-equivalence = intro\n\n  permutes-equiv : Equiv(List(T))\n  Equiv._\u2261_         permutes-equiv = _permutes_\n  Equiv.equivalence permutes-equiv = permutes-equivalence\n\n  -- If permutation relation had empty, prepend and trans-swap\n  module _ where\n    swap-from-trans-swap : (x \u22b0 y \u22b0 l) permutes (y \u22b0 x \u22b0 l)\n    swap-from-trans-swap = trans-swap(reflexivity(_permutes_))\n\n  PermutationMappingCorrectness : (l\u2081 l\u2082 : List(T)) \u2192 (\ud835\udd5f(length(l\u2081)) \u2192 \ud835\udd5f(length(l\u2082))) \u2192 Stmt\n  PermutationMappingCorrectness l\u2081 l\u2082 mapping = \u2200{i} \u2192 (index l\u2081(i) \u2261 index l\u2082(mapping i))\n\n  permutation-mapping-correctness : (p : (l\u2081 permutes l\u2082)) \u2192 PermutationMappingCorrectness l\u2081 l\u2082 (permutation-mapping p)\n  permutation-mapping-correctness empty                 = reflexivity(_\u2261_)\n  permutation-mapping-correctness (prepend p) {\ud835\udfce}       = reflexivity(_\u2261_)\n  permutation-mapping-correctness (prepend p) {\ud835\udc12 i}     = permutation-mapping-correctness p {i}\n  permutation-mapping-correctness swap        {\ud835\udfce}       = reflexivity(_\u2261_)\n  permutation-mapping-correctness swap        {\ud835\udc12 \ud835\udfce}     = reflexivity(_\u2261_)\n  permutation-mapping-correctness swap        {\ud835\udc12 (\ud835\udc12 i)} = reflexivity(_\u2261_)\n  permutation-mapping-correctness (trans p q)           = permutation-mapping-correctness p \ud83d\udf56 permutation-mapping-correctness q\n\n  instance\n    permutation-mapping-injective : \u2200{p : (l\u2081 permutes l\u2082)} \u2192 Injective(permutation-mapping p)\n    permutation-mapping-injective {p = p} = intro(proof p) where\n      proof : (p : (l\u2081 permutes l\u2082)) \u2192 Names.Injective(permutation-mapping p)\n      proof (prepend p) {\ud835\udfce}   {\ud835\udfce}   eq = [\u2261]-intro\n      proof (prepend p) {\ud835\udc12 x} {\ud835\udc12 y} eq = congruence\u2081(\ud835\udc12) (proof p (injective(\ud835\udc12) \u2983 [\ud835\udc12]-injective \u2984 eq))\n      proof swap {\ud835\udfce}       {\ud835\udfce}       eq = [\u2261]-intro\n      proof swap {\ud835\udfce}       {\ud835\udc12 (\ud835\udc12 y)} ()\n      proof swap {\ud835\udc12 (\ud835\udc12 x)} {\ud835\udfce}       ()\n      proof swap {\ud835\udc12 \ud835\udfce}     {\ud835\udc12 \ud835\udfce}     eq = [\u2261]-intro\n      proof swap {\ud835\udc12 (\ud835\udc12 x)} {\ud835\udc12 (\ud835\udc12 y)} eq = eq\n      proof (trans p q) = proof p \u2218 proof q\n\n  instance\n    permutation-mapping-surjective : \u2200{p : (l\u2081 permutes l\u2082)} \u2192 Surjective(permutation-mapping p)\n    permutation-mapping-surjective {p = p} = intro(proof p) where\n      proof : (p : (l\u2081 permutes l\u2082)) \u2192 Names.Surjective(permutation-mapping p)\n      \u2203.witness (proof p {y}) = permutation-mapping(symmetry(_permutes_) p) y\n      \u2203.proof (proof (prepend p) {\ud835\udfce})   = [\u2261]-intro\n      \u2203.proof (proof (prepend p) {\ud835\udc12 y}) = congruence\u2081(\ud835\udc12) (\u2203.proof (proof p {y}))\n      \u2203.proof (proof swap {\ud835\udfce})       = [\u2261]-intro\n      \u2203.proof (proof swap {\ud835\udc12 \ud835\udfce})     = [\u2261]-intro\n      \u2203.proof (proof swap {\ud835\udc12 (\ud835\udc12 y)}) = [\u2261]-intro\n      \u2203.proof (proof (trans p q) {y}) =\n        permutation-mapping (trans p q) (\u2203.witness (proof (trans p q))) \ud83d\udf56[ _\u2261_ ]-[]\n        (permutation-mapping (trans p q) \u2218 permutation-mapping(symmetry(_permutes_) p) \u2218 permutation-mapping (symmetry(_permutes_) q)) y \ud83d\udf56[ _\u2261_ ]-[]\n        (permutation-mapping q \u2218 permutation-mapping p \u2218 permutation-mapping(symmetry(_permutes_) p) \u2218 permutation-mapping (symmetry(_permutes_) q)) y \ud83d\udf56[ _\u2261_ ]-[ congruence\u2081(permutation-mapping q) (\u2203.proof (proof p {_})) ]\n        (permutation-mapping q \u2218 permutation-mapping (symmetry(_permutes_) q)) y \ud83d\udf56[ _\u2261_ ]-[ \u2203.proof (proof q {y}) ]\n        y \ud83d\udf56[ _\u2261_ ]-end\n\n  permutation-mapping-bijective : \u2200{p : (l\u2081 permutes l\u2082)} \u2192 Bijective(permutation-mapping p)\n  permutation-mapping-bijective {p = p} = injective-surjective-to-bijective(permutation-mapping p) \u2983 permutation-mapping-injective {p = p} \u2984 \u2983 permutation-mapping-surjective {p = p} \u2984\n\n  {-\n  permutation-from-mapping : (p : \ud835\udd5f(length(l\u2081)) \u2192 \ud835\udd5f(length(l\u2082))) \u2983 bij : Bijective(p) \u2984 (correctness : PermutationMappingCorrectness l\u2081 l\u2082 p) \u2192 (l\u2081 permutes l\u2082)\n  permutation-from-mapping {l\u2081 = \u2205} {l\u2082 = \u2205} p _ = empty\n  permutation-from-mapping {l\u2081 = \u2205} {l\u2082 = x\u2082 \u22b0 l\u2082} p _ = {!!}\n  permutation-from-mapping {l\u2081 = x\u2081 \u22b0 l\u2081} {l\u2082 = \u2205} p _ = {!!}\n  permutation-from-mapping {l\u2081 = x\u2081 \u22b0 l\u2081} {l\u2082 = x\u2082 \u22b0 l\u2082} p correctness with p(\ud835\udfce) | correctness{\ud835\udfce}\n  ... | \ud835\udfce   | [\u2261]-intro = prepend (permutation-from-mapping (forgetFirstCutoffOfBij p) \u2983 forgetFirstCutoffOfBij-bijective \u2984 {!!}) where\n    bijective-equinumerous : \u2200{a b}{f : \ud835\udd5f(a) \u2192 \ud835\udd5f(b)} \u2192 Bijective(f) \u2192 (a \u2261 b)\n    forgetFirstCutoff : \u2200{a} \u2192 (\ud835\udd5f(\ud835\udc12(a)) \u2192 \ud835\udd5f(\ud835\udc12(a))) \u2192 (\ud835\udd5f(a) \u2192 \ud835\udd5f(a))\n    forgetFirstCutoff {\ud835\udc12(a)} f(x) with f(\ud835\udc12(x))\n    ... | \ud835\udfce    = \ud835\udfce\n    ... | \ud835\udc12(y) = y\n\n    forgetFirstCutoffOfBij : \u2200{a b} \u2192 (f : \ud835\udd5f(\ud835\udc12(a)) \u2192 \ud835\udd5f(\ud835\udc12(b))) \u2983 bij : Bijective(f) \u2984 \u2192 (\ud835\udd5f(a) \u2192 \ud835\udd5f(b))\n    forgetFirstCutoffOfBij {\ud835\udc12 a} f \u2983 bij \u2984 with [\u2261]-intro \u2190 bijective-equinumerous bij = forgetFirstCutoff f\n    forgetFirstCutoffOfBij-bijective : \u2200{a b}{f : \ud835\udd5f(\ud835\udc12(a)) \u2192 \ud835\udd5f(\ud835\udc12(b))} \u2983 bij : Bijective(f) \u2984 \u2192 Bijective(forgetFirstCutoffOfBij f)\n\n    -- proof : \u2200{l\u2081 l\u2082 : List(T)}{p : \ud835\udd5f(length(l\u2081)) \u2192 \ud835\udd5f(length(l\u2082))} \u2192 PermutationMappingCorrectness l\u2081 l\u2082 (forgetFirstCutoffOfBij p)\n    proof : PermutationMappingCorrectness l\u2081 l\u2082 (forgetFirstCutoffOfBij p)\n    proof {i} =\n      index l\u2081 i                            \ud83d\udf56[ _\u2261_ ]-[ {!correctness!} ]\n      index l\u2082 (forgetFirstCutoffOfBij p i) \ud83d\udf56-end \n  ... | \ud835\udc12 w | _ = {!!}\n  -}\n\n  permutes-prepend-function : Function \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 (List.prepend x)\n  permutes-prepend-function = intro prepend\n\n  permutes-postpend-function : Function \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 (postpend x)\n  permutes-postpend-function = intro proof where\n    proof : (l\u2081 permutes l\u2082) \u2192 (postpend x l\u2081) permutes (postpend x l\u2082)\n    proof empty       = prepend empty\n    proof (prepend x) = prepend (proof x)\n    proof swap        = swap\n    proof (trans x y) = trans (proof x) (proof y)\n\n  postpend-prepend-permutes : (postpend x l) permutes (List.prepend x l)\n  postpend-prepend-permutes {l = \u2205} = prepend empty\n  postpend-prepend-permutes {l = x \u22b0 l} = trans (prepend postpend-prepend-permutes) swap\n\n  permutes-reverse : (reverse l) permutes l\n  permutes-reverse {l = \u2205} = empty\n  permutes-reverse {l = x \u22b0 l} = trans (Function.congruence \u2983 _ \u2984 \u2983 _ \u2984 permutes-postpend-function(permutes-reverse {l = l})) postpend-prepend-permutes\n\n  permutes-length-function : Function \u2983 permutes-equiv {T = T} \u2984 (length)\n  permutes-length-function = intro proof where\n    proof : (l\u2081 permutes l\u2082) \u2192 (length l\u2081 \u2261 length l\u2082)\n    proof empty       = [\u2261]-intro\n    proof (prepend p) = congruence\u2081(\ud835\udc12) (proof p)\n    proof swap        = [\u2261]-intro\n    proof (trans p q) = transitivity(_\u2261_) (proof p) (proof q)\n\n  permutes-count\u1d63-function : Function \u2983 permutes-equiv \u2984 (count P)\n  permutes-count\u1d63-function = intro proof where\n    proof : (l\u2081 permutes l\u2082) \u2192 (count P l\u2081 \u2261 count P l\u2082)\n    proof empty = [\u2261]-intro\n    proof {l\u2081 = x\u2081 \u22b0 l\u2081} {P = P} (prepend {x = x} p) with P(x)\n    ... | \ud835\udc47 = [\u2261]-with \ud835\udc12(proof {l\u2081 = l\u2081} {P = P} p)\n    ... | \ud835\udc39 = proof {l\u2081 = l\u2081} {P = P} p\n    proof {P = P} (swap {x = x} {y = y}) with P(x) | P(y)\n    ... | \ud835\udc47 | \ud835\udc47 = [\u2261]-intro\n    ... | \ud835\udc47 | \ud835\udc39 = [\u2261]-intro\n    ... | \ud835\udc39 | \ud835\udc47 = [\u2261]-intro\n    ... | \ud835\udc39 | \ud835\udc39 = [\u2261]-intro\n    proof (trans p q) = proof p \ud83d\udf56 proof q\n\n  permutes-satisfiesAny-function\u1d63 : Function \u2983 permutes-equiv \u2984 (satisfiesAny f)\n  permutes-satisfiesAny-function\u1d63 = intro proof where\n    proof : (l\u2081 permutes l\u2082) \u2192 (satisfiesAny f l\u2081 \u2261 satisfiesAny f l\u2082)\n    proof empty = [\u2261]-intro\n    proof {f = f} (prepend{x = x} p) with f(x)\n    ... | \ud835\udc47 = [\u2261]-intro\n    ... | \ud835\udc39 = proof p\n    proof {l\u2081 = x \u22b0 y \u22b0 l\u2081}{y \u22b0 x \u22b0 l\u2082}{f = f} (swap{x = x}{y = y}) with f(x) | f(y) | inspect f(x) | inspect f(y)\n    ... | \ud835\udc47 | \ud835\udc47 | intro _ | intro _ = [\u2261]-intro\n    ... | \ud835\udc47 | \ud835\udc39 | intro _ | intro _ with \ud835\udc47 \u2190 f(x) = [\u2261]-intro\n    ... | \ud835\udc39 | \ud835\udc47 | intro _ | intro _ with \ud835\udc47 \u2190 f(y) = [\u2261]-intro\n    ... | \ud835\udc39 | \ud835\udc39 | intro _ | intro _ with \ud835\udc39 \u2190 f(x) | \ud835\udc39 \u2190 f(y)= reflexivity(_\u2261_)\n    proof (trans p q) = proof p \ud83d\udf56 proof q\n\n  {- TODO\n  permutes-count\u2097 : (\u2200{P} \u2192 count P l\u2081 \u2261 count P l\u2082) \u2192 (l\u2081 permutes l\u2082)\n  permutes-count\u2097 {l\u2081 = \u2205} {l\u2082 = \u2205} p = empty\n  permutes-count\u2097 {l\u2081 = \u2205} {l\u2082 = x \u22b0 l\u2082} p with () \u2190 p{const \ud835\udc47}\n  permutes-count\u2097 {l\u2081 = x \u22b0 l\u2081} {l\u2082 = \u2205} p with () \u2190 p{const \ud835\udc47}\n  permutes-count\u2097 {l\u2081 = x \u22b0 l\u2081} {l\u2082 = x\u2081 \u22b0 l\u2082} p = {!!} -- TODO: The rest of the cases from _permutes_. Maybe decidable equality on the items are required?\n  -}\n\n  permutes-[++]-function : BinaryOperator \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 (_++_ {T = T})\n  permutes-[++]-function = binaryOperator-from-function \u2983 _ \u2984 \u2983 _ \u2984 \u2983 _ \u2984 \u2983 \\{l} \u2192 intro(R{l = l}) \u2984 \u2983 intro L \u2984 where\n    L : Names.Congruence\u2081 \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 (_++ l)\n    L {l = l} empty = reflexivity(_permutes_)\n    L {l = l} (prepend l12) = prepend (L {l = l} l12)\n    L {l = l} swap = swap\n    L {l = l} (trans l13 l32) = transitivity(_permutes_) (L {l = l} l13) (L {l = l} l32)\n\n    R : Names.Congruence\u2081 \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 (l ++_)\n    R {l = \u2205}     l12 = l12\n    R {l = x \u22b0 l} l12 = prepend (R {l = l} l12)\n\n  permutes-[++]-commutativity : Commutativity \u2983 permutes-equiv {T = T} \u2984 (_++_)\n  permutes-[++]-commutativity = intro(\\{l\u2081}{l\u2082} \u2192 proof{l\u2081}{l\u2082}) where\n    proof : Names.Commutativity \u2983 permutes-equiv \u2984 (_++_)\n    proof {\u2205}      {l\u2082} rewrite identity\u1d63(_++_)(\u2205) {l\u2082} = reflexivity(_permutes_)\n    proof {x \u22b0 l\u2081} {l\u2082} =\n      (x \u22b0 l\u2081) ++ l\u2082        \ud83d\udf56[ _permutes_ ]-[]\n      x \u22b0 (l\u2081 ++ l\u2082)        \ud83d\udf56[ _permutes_ ]-[ prepend (proof {l\u2081} {l\u2082}) ]\n      x \u22b0 (l\u2082 ++ l\u2081)        \ud83d\udf56[ _permutes_ ]-[]\n      (x \u22b0 l\u2082) ++ l\u2081        \ud83d\udf56[ _permutes_ ]-[ BinaryOperator.congruence \u2983 _ \u2984 \u2983 _ \u2984 \u2983 _ \u2984 permutes-[++]-function (postpend-prepend-permutes {l = l\u2082}) (reflexivity(_permutes_)) ]-sym\n      (postpend x l\u2082) ++ l\u2081 \ud83d\udf56[ _permutes_ ]-[ sub\u2082(_\u2261_)(_permutes_) ([++]-middle-prepend-postpend {l\u2081 = l\u2082}{l\u2082 = l\u2081}) ]\n      l\u2082 ++ (x \u22b0 l\u2081)        \ud83d\udf56[ _permutes_ ]-end\n\n  permutes-empty-not-empty : \u00ac(\u2205 permutes (x \u22b0 l))\n  permutes-empty-not-empty (trans {l\u2082 = \u2205}     p q) = permutes-empty-not-empty q\n  permutes-empty-not-empty (trans {l\u2082 = _ \u22b0 _} p q) = permutes-empty-not-empty p\n\n  permutes-map : \u2200{f : A \u2192 B} \u2192 Function \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 (map f)\n  permutes-map {f = f} = intro proof where\n    proof : Names.Congruence\u2081 \u2983 permutes-equiv \u2984 \u2983 permutes-equiv \u2984 (map f)\n    proof empty       = empty\n    proof (prepend p) = prepend (proof p)\n    proof swap        = swap\n    proof (trans p q) = trans(proof p) (proof q)\n\n  permutes-on-empty : (l permutes \u2205) \u2192 (l \u2261 \u2205)\n  permutes-on-empty empty = [\u2261]-intro\n  permutes-on-empty (trans p q)\n    rewrite permutes-on-empty q\n    rewrite permutes-on-empty p\n    = [\u2261]-intro\n\n  permutes-on-singleton : (l permutes (singleton x)) \u2192 (l \u2261 singleton x)\n  permutes-on-singleton (prepend empty) = [\u2261]-intro\n  permutes-on-singleton (prepend (trans p q))\n    rewrite permutes-on-empty q\n    rewrite permutes-on-empty p\n    = [\u2261]-intro\n  permutes-on-singleton (trans p q)\n    rewrite permutes-on-singleton q\n    rewrite permutes-on-singleton p\n    = [\u2261]-intro\n\n  permutes-insertIn : \u2200{n} \u2192 ((insertIn x l n) permutes (x \u22b0 l))\n  permutes-insertIn {n = \ud835\udfce}               = reflexivity(_permutes_)\n  permutes-insertIn {l = x \u22b0 l} {n = \ud835\udc12 n} = trans (prepend (permutes-insertIn {n = n})) swap\n\nmodule InsertionPermutation where\n  data _insertion-permutes_ {\u2113} : List{\u2113}(T) \u2192 List{\u2113}(T) \u2192 Stmt{Lvl.\ud835\udc12(\u2113)} where\n    empty : \u2205 insertion-permutes (\u2205 {T = T})\n    ins : (n : \ud835\udd5f\u208c(length l\u2081)) \u2192 (l\u2081 insertion-permutes l\u2082) \u2192 ((insertIn x l\u2081 n) insertion-permutes (x \u22b0 l\u2082))\n\n  open import Data.List.Proofs.Length\n  open import Relator.Equals.Proofs\n  open import Structure.Relator\n\n  insertion-permutation-mapping : (l\u2081 insertion-permutes l\u2082) \u2192 (\ud835\udd5f(length(l\u2081)) \u2192 \ud835\udd5f(length(l\u2082)))\n  insertion-permutation-mapping empty              ()\n  insertion-permutation-mapping (ins \ud835\udfce p)          \ud835\udfce              = \ud835\udfce\n  insertion-permutation-mapping (ins \ud835\udfce p)          (\ud835\udc12 i)          = \ud835\udc12(insertion-permutation-mapping p i)\n  insertion-permutation-mapping (ins {l\u2081 = x \u22b0 l\u2081} (\ud835\udc12 n) p) \ud835\udfce     = \ud835\udfce\n  insertion-permutation-mapping (ins {l\u2081 = x \u22b0 l\u2081} (\ud835\udc12 n) p) (\ud835\udc12 i) = \ud835\udc12(insertion-permutation-mapping p (substitute\u2081(\ud835\udd5f) (length-insertIn {l = l\u2081} {n = n}) i))\n\n  open import Data using ()\n  open import Numeral.Natural\n  open import Relator.Equals\n  open import Syntax.Number\n\n  insertion-permutes-prepend : (l\u2081 insertion-permutes l\u2082) \u2192 ((x \u22b0 l\u2081) insertion-permutes (x \u22b0 l\u2082))\n  insertion-permutes-prepend p = ins \ud835\udfce p\n\n  insertion-permutes-refl : l insertion-permutes l\n  insertion-permutes-refl {l = \u2205} = empty\n  insertion-permutes-refl {l = x \u22b0 l} = insertion-permutes-prepend insertion-permutes-refl\n\n  insertion-permutes-swap : (x \u22b0 y \u22b0 l) insertion-permutes (y \u22b0 x \u22b0 l)\n  insertion-permutes-swap = ins 1 (insertion-permutes-prepend insertion-permutes-refl)\n\n  insertion-permutes-to-permutes : (l\u2081 insertion-permutes l\u2082) \u2192 (l\u2081 permutes l\u2082)\n  insertion-permutes-to-permutes empty     = empty\n  insertion-permutes-to-permutes (ins n p) = trans Proofs.permutes-insertIn (prepend (insertion-permutes-to-permutes p))\n\n  insertion-permutes-flipped-ins : \u2200{n} \u2192 (l\u2081 insertion-permutes l\u2082) \u2192 ((x \u22b0  l\u2081) insertion-permutes (insertIn x l\u2082 n))\n  insertion-permutes-flipped-ins {n = \ud835\udfce}   empty      = insertion-permutes-refl\n  insertion-permutes-flipped-ins {n = \ud835\udfce}   (ins k p)  = insertion-permutes-prepend (ins k p)\n  insertion-permutes-flipped-ins {n = \ud835\udc12 n} (ins k p) = ins (\ud835\udc12 k) (insertion-permutes-flipped-ins {n = n} p)\n\n  insertion-permutes-sym : (l\u2081 insertion-permutes l\u2082) \u2192 (l\u2082 insertion-permutes l\u2081)\n  insertion-permutes-sym empty = empty\n  insertion-permutes-sym (ins n p) = insertion-permutes-flipped-ins(insertion-permutes-sym p)\n\n  {-\n  insertion-permutes-trans : (l\u2081 insertion-permutes l\u2082) \u2192 (l\u2083 insertion-permutes l\u2082) \u2192 (l\u2081 insertion-permutes l\u2083)\n  ins2 : \u2200{n\u2081 n\u2082} \u2192 (l\u2081 insertion-permutes l\u2082) \u2192 ((insertIn x l\u2081 n\u2081) insertion-permutes (insertIn x l\u2082 n\u2082))\n\n  ins2 {l\u2081 = l\u2081} {l\u2082} {n\u2081 = n\u2081} {\ud835\udfce} p = ins n\u2081 p\n  ins2 {l\u2081 = .(insertIn x _ n)} {x \u22b0 l\u2082} {n\u2081 = \ud835\udfce} {\ud835\udc12 n\u2082} (ins n p) = insertion-permutes-trans (insertion-permutes-prepend (ins n p)) (ins(\ud835\udc12 n\u2082) insertion-permutes-refl)\n  ins2 {l\u2081 = .(insertIn x _ n)} {x \u22b0 l\u2082} {n\u2081 = \ud835\udc12 n\u2081} {\ud835\udc12 n\u2082} (ins n p) = {!!}\n\n  insertion-permutes-trans empty     empty     = empty\n  insertion-permutes-trans (ins m p) (ins n q) = {!!}\n  -- ins2(insertion-permutes-trans p q)\n  -}\n\n  {-\n  insertion-permutation-mapping-correctness : (p : (l\u2081 insertion-permutes l\u2082)) \u2192 Proofs.PermutationMappingCorrectness l\u2081 l\u2082 (insertion-permutation-mapping p)\n  insertion-permutation-mapping-correctness (ins {l\u2081 = \u2205} \ud835\udfce p) {\ud835\udfce} = [\u2261]-intro\n  insertion-permutation-mapping-correctness (ins {l\u2081 = x \u22b0 l\u2081} \ud835\udfce p) {\ud835\udfce} = [\u2261]-intro\n  insertion-permutation-mapping-correctness (ins {l\u2081 = x \u22b0 l\u2081} \ud835\udfce p) {\ud835\udc12 i} = insertion-permutation-mapping-correctness p\n  insertion-permutation-mapping-correctness (ins {l\u2081 = x \u22b0 l\u2081} (\ud835\udc12 n) p) {\ud835\udfce} = {!!}\n  insertion-permutation-mapping-correctness (ins {l\u2081 = x \u22b0 l\u2081} (\ud835\udc12 n) p) {\ud835\udc12 i} = {!!}\n  -}\n\n  -- test : (p : (l\u2081 insertion-permutes l\u2082)) \u2192 (\u2200{i} \u2192 (index l\u2081(insertion-permutation-mapping p i) \u2261 index l\u2082(i)))\n  -- test p = ?\n\n  {-\n  open import Data.Boolean.Stmt\n  open import Numeral.Finite.Oper.Comparisons\n  test : \u2200{l : List(T)}{n\u2081 : \ud835\udd5f(\ud835\udc12(length l))}{n\u2082 : \ud835\udd5f(\ud835\udc12(length (insertIn y l n\u2081)))} \u2192 IsTrue(n\u2081 >? n\u2082) \u2192 (insertIn y (insertIn x l n\u2081) n\u2082 \u2261 insertIn x (insertIn y l n\u2081) n\u2082)\n  test p = {!!}\n  -}\n\n  {-\n  ins2 : \u2200{n\u2081 n\u2082} \u2192 (l\u2081 insertion-permutes l\u2082) \u2192 ((insertIn x l\u2081 n\u2081) insertion-permutes (insertIn x l\u2082 n\u2082))\n  ins2 {n\u2081 = \ud835\udfce} {\ud835\udfce} empty = insertion-permutes-refl\n  ins2 {n\u2081 = n\u2081} {\ud835\udfce} (ins n p) = ins n\u2081 (ins n p)\n  ins2 {x = x} {n\u2081 = n\u2081} {\ud835\udc12 n\u2082} (ins {x = y} n p) = {!(ins2 {x = x}{n\u2081 = n}{n\u2082 = n\u2082} p)!}\n\n  insertion-permutes-trans : (l\u2081 insertion-permutes l\u2082) \u2192 (l\u2083 insertion-permutes l\u2082) \u2192 (l\u2081 insertion-permutes l\u2083)\n  insertion-permutes-trans empty empty = empty\n  insertion-permutes-trans (ins m p) (ins n q) = {!!}\n  -}\n\n  {-\n  test : \u2200{n} \u2192 (l\u2081 insertion-permutes (y \u22b0 insertIn x l\u2082 n)) \u2192 (l\u2081 insertion-permutes (x \u22b0 insertIn y l\u2082 n))\n  test {l\u2082 = l\u2082} (ins {l\u2081 = l\u2081} n p) = {!!}\n\n  ins2 : \u2200{n\u2081 n\u2082} \u2192 (l\u2081 insertion-permutes l\u2082) \u2192 ((insertIn x l\u2081 n\u2081) insertion-permutes (insertIn x l\u2082 n\u2082))\n  ins2 {n\u2081 = n\u2081} {\ud835\udfce} p = ins n\u2081 p\n  ins2 {n\u2081 = n\u2081} {\ud835\udc12 n\u2082} (ins {x = x} n p) = test(ins n\u2081 (ins2{x = x}{n}{n\u2082} p))\n\n  -- insertIn x\u2081 (insertIn x l\u2081 n) n\u2081\n  -- x \u22b0 insertIn x\u2081 l\u2082 n\u2082\n\n  tr : (l\u2081 insertion-permutes l\u2082) \u2192 (l\u2083 insertion-permutes l\u2082) \u2192 (l\u2081 insertion-permutes l\u2083)\n  tr {l\u2082 = \u2205}       empty      empty      = empty\n  tr {l\u2082 = x\u2082 \u22b0 l\u2082} (ins n\u2081 p) (ins n\u2082 q) = ins2(tr p q)\n\n  sym : (l\u2081 insertion-permutes l\u2082) \u2192 (l\u2082 insertion-permutes l\u2081)\n  sym = tr insertion-permutes-refl\n  -}\n", "meta": {"hexsha": "6569ef05376ccf6560bf6021296f98f7acf8160c", "size": 20188, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Data/List/Relation/Permutation.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Data/List/Relation/Permutation.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/List/Relation/Permutation.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 49.601965602, "max_line_length": 260, "alphanum_fraction": 0.6315137706, "num_tokens": 7474, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898203834277, "lm_q2_score": 0.8354835350552603, "lm_q1q2_score": 0.7569395778580265}}
{"text": "{-# OPTIONS --warning=error --safe --without-K #-}\n\nopen import LogicalFormulae\nopen import Numbers.Naturals.Semiring\nopen import Numbers.Naturals.Naturals\nopen import Numbers.Naturals.Order\nopen import Numbers.Naturals.Order.Lemmas\nopen import Numbers.Naturals.Order.WellFounded\nopen import Orders.WellFounded.Induction\nopen import Orders.Total.Definition\nopen import Semirings.Definition\n\nmodule Numbers.Naturals.Division where\n\nopen import Numbers.Naturals.EuclideanAlgorithm public using (_\u2223_ ; zeroDividesNothing ; divisionAlgResult ; divides ; biggerThanCantDivide ; aDivA ; aDivZero ; divEquality ; oneDivN ; dividesBothImpliesDividesSum ; dividesBothImpliesDividesDifference)\n\ndivOneImpliesOne : {a : \u2115} \u2192 a \u2223 1 \u2192 a \u2261 1\ndivOneImpliesOne {zero} a|1 = exFalso (zeroDividesNothing _ a|1)\ndivOneImpliesOne {succ zero} a|1 = refl\ndivOneImpliesOne {succ (succ a)} (divides record { quot = zero ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = quotSmall } refl) rewrite Semiring.sumZeroRight \u2115Semiring (a *N zero) | multiplicationNIsCommutative a 0 = exFalso (naughtE pr)\ndivOneImpliesOne {succ (succ a)} (divides record { quot = (succ quot) ; rem = .0 ; pr = pr ; remIsSmall = remIsSmall ; quotSmall = quotSmall } refl) rewrite Semiring.commutative \u2115Semiring quot (succ (quot +N a *N succ quot)) = exFalso (naughtE (equalityCommutative (succInjective pr)))\n", "meta": {"hexsha": "5f33221c8b35cc9889cab7e43b0ad050553076f7", "size": 1371, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numbers/Naturals/Division.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Numbers/Naturals/Division.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Numbers/Naturals/Division.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 62.3181818182, "max_line_length": 285, "alphanum_fraction": 0.7753464624, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9284088045171238, "lm_q2_score": 0.8152324960856175, "lm_q1q2_score": 0.756869027094359}}
{"text": "open import Relation.Binary.Core\n\nmodule TreeSort.Impl2  {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_)  where\n\nopen import BBSTree _\u2264_\nopen import Bound.Total A \nopen import Bound.Total.Order _\u2264_\nopen import Data.List\nopen import Data.Sum\n\ninsert : {x : A}{b t : Bound} \u2192 LeB b (val x) \u2192 LeB (val x) t \u2192 BBSTree b t \u2192 BBSTree b t\ninsert b\u2264x x\u2264t (bslf _) = bsnd b\u2264x x\u2264t (bslf b\u2264x) (bslf x\u2264t)\ninsert {x = x} b\u2264x x\u2264t (bsnd {x = y} b\u2264y y\u2264t l r) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y = bsnd b\u2264y y\u2264t (insert b\u2264x (lexy x\u2264y) l) r\n... | inj\u2082 y\u2264x = bsnd b\u2264y y\u2264t l (insert (lexy y\u2264x) x\u2264t r)\n\ntreeSort : List A \u2192 BBSTree bot top\ntreeSort [] = bslf lebx\ntreeSort (x \u2237 xs) = insert {x = x} lebx lext (treeSort xs)\n\n\n\n\n", "meta": {"hexsha": "669efe0c46ccb7fb374adfe09c5f4f3a25e44d93", "size": 739, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/TreeSort/Impl2.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/TreeSort/Impl2.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/TreeSort/Impl2.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3703703704, "max_line_length": 89, "alphanum_fraction": 0.5832205683, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.970239908635611, "lm_q2_score": 0.7799929053683038, "lm_q1q2_score": 0.7567802452409679}}
{"text": "module +-mono-< where\n\nopen import Data.Nat using (\u2115; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\nopen import Relations using (_<_; z<s; s<s)\nopen import <-trans using (<-trans)\n\n+-mono\u02b3-< : \u2200 (n p q : \u2115)\n  \u2192 p < q\n    -------------\n  \u2192 n + p < n + q\n+-mono\u02b3-< zero    p q p<q = p<q\n+-mono\u02b3-< (suc n) p q p<q = s<s (+-mono\u02b3-< n p q p<q)\n\n+-mono\u02e1-< : \u2200 (m n p : \u2115)\n  \u2192 m < n\n    -------------\n  \u2192 m + p < n + p\n+-mono\u02e1-< m n p m<n rewrite +-comm m p | +-comm n p = +-mono\u02b3-< p m n m<n\n\n+-mono-< : \u2200 (m n p q : \u2115)\n  \u2192 m < n\n  \u2192 p < q\n    -------------\n  \u2192 m + p < n + q\n+-mono-< m n p q m<n p<q = <-trans (+-mono\u02e1-< m n p m<n) (+-mono\u02b3-< n p q p<q)\n", "meta": {"hexsha": "14d2d4f27e25523272cfeb3519a38e6fa859e3dc", "size": 667, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/relations/+-mono-<.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/relations/+-mono-<.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/relations/+-mono-<.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.8214285714, "max_line_length": 78, "alphanum_fraction": 0.4512743628, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248191350352, "lm_q2_score": 0.8056321866478979, "lm_q1q2_score": 0.7565086183564053}}
{"text": "{-\n\n          Types Summer School 2007\n\n                 Bertinoro\n             Aug 19 - 31, 2007\n\n\n                   Agda\n\n                Ulf Norell\n\n-}\n\nmodule Parity where\n\nopen import Nat\n\n-- Parity n tells us whether n is even or odd.\n\ndata Parity : Nat -> Set where\n  even : (k : Nat) -> Parity (2 * k)\n  odd  : (k : Nat) -> Parity (2 * k + 1)\n\n-- Every number is either even or odd.\n\nparity : (n : Nat) -> Parity n\nparity  zero = even zero\nparity (suc n)         with parity n\nparity (suc .(2 * k))     | even k = {! !}\nparity (suc .(2 * k + 1)) | odd  k = {! !}\n\nhalf : Nat -> Nat\nhalf n         with parity n\nhalf .(2 * k)     | even k = k\nhalf .(2 * k + 1) | odd  k = k\n\n", "meta": {"hexsha": "6390ff69f1f0a3db573f3e3b2e5037fc6ed760df", "size": 683, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Parity.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Parity.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "examples/SummerSchool07/Lecture/Parity.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 17.9736842105, "max_line_length": 46, "alphanum_fraction": 0.4919472914, "num_tokens": 229, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.966410494349896, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.756373238093176}}
{"text": "module Auto.Prelude where\n\nopen import Agda.Primitive public\n  using    (Level)\n\n\ndata \u22a5 : Set where\n\n\u00ac : Set \u2192 Set\n\u00ac A = A \u2192 \u22a5\n\n\u22a5-e : (A : Set) \u2192 \u22a5 \u2192 A\n\u22a5-e A ()\n\n\nrecord \u22a4 : Set where\n\n\n\nrecord _\u2227_ (A B : Set) : Set where\n constructor \u2227-i\n field fst : A\n       snd : B\n\ndata _\u2228_ (A B : Set) : Set where\n \u2228-i\u2081 : A \u2192 A \u2228 B\n \u2228-i\u2082 : B \u2192 A \u2228 B\n\n\u2228-e : (A B C : Set) \u2192 A \u2228 B \u2192 (A \u2192 C) \u2192 (B \u2192 C) \u2192 C\n\u2228-e A B C (\u2228-i\u2081 x) h\u2081 h\u2082 = h\u2081 x\n\u2228-e A B C (\u2228-i\u2082 x) h\u2081 h\u2082 = h\u2082 x\n\n\ndata \u03a0 (A : Set) (F : A \u2192 Set) : Set where\n  fun : ((a : A) \u2192 F a) \u2192 \u03a0 A F\n\nrecord \u03a3 (X : Set) (P : X \u2192 Set) : Set where\n constructor \u03a3-i\n field wit : X\n       prf : P wit\n\n\ndata \u2115 : Set where\n zero : \u2115\n succ : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero   + n = n\nsucc m + n = succ (m + n)\n\n\ndata Fin : \u2115 \u2192 Set where\n  zero : \u2200 {n} \u2192 Fin (succ n)\n  suc  : \u2200 {n} \u2192 Fin n \u2192 Fin (succ n)\n\n\ndata List (X : Set) : Set where\n  []  : List X\n  _\u2237_ : X \u2192 List X \u2192 List X\n\n_++_ : {X : Set} \u2192 List X \u2192 List X \u2192 List X\n[] ++ ys = ys\n(x \u2237 xs) ++ ys = x \u2237 (xs ++ ys)\n\n\ndata Vec (X : Set) : \u2115 \u2192 Set where\n  []  : Vec X zero\n  _\u2237_ : \u2200 {n} \u2192 X \u2192 Vec X n \u2192 Vec X (succ n)\n\n-- -----------------------------------\n\ndata _\u2261_ {a} {A : Set a} (x : A) : A \u2192 Set where\n  refl : x \u2261 x\n\nsubst : {i j : Level} {X : Set i} \u2192 (P : X \u2192 Set j) \u2192 (x y : X) \u2192 y \u2261 x \u2192 P x \u2192 P y\nsubst P x .x refl h = h\n\ntrans : \u2200 {a} {A : Set a} \u2192 {x y z : A} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\ntrans refl refl = refl\n\nsym : \u2200 {a} {A : Set a} \u2192 {x y : A} \u2192 x \u2261 y \u2192 y \u2261 x\nsym refl = refl\n\ncong : \u2200 {a b} {A : Set a} {B : Set b}\n       (f : A \u2192 B) {x y} \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\ndata _IsRelatedTo_ {a : Level} {Carrier : Set a} (x y : Carrier) : Set a where\n  relTo : (x\u223cy : x \u2261 y) \u2192 x IsRelatedTo y\n\nbegin_ : {a : Level} {Carrier : Set a} \u2192 {x y : Carrier} \u2192 x IsRelatedTo y \u2192 x \u2261 y\nbegin relTo x\u223cy = x\u223cy\n\n_\u220e : {a : Level} {Carrier : Set a} \u2192 (x : Carrier) \u2192 x IsRelatedTo x\n_\u220e _ = relTo refl\n\n_\u2261\u27e8_\u27e9_ : {a : Level} {Carrier : Set a} \u2192 (x : Carrier) {y z : Carrier} \u2192 x \u2261 y \u2192 y IsRelatedTo z \u2192 x IsRelatedTo z\n_ \u2261\u27e8 x\u223cy \u27e9 relTo y\u223cz = relTo (trans x\u223cy y\u223cz)\n\n-- -----------------------------------\n", "meta": {"hexsha": "adf68ce6285d47bd5b8424f3ee8b9b965263be4c", "size": 2090, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/interaction/Auto/Prelude.agda", "max_stars_repo_name": "shlevy/agda", "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/interaction/Auto/Prelude.agda", "max_issues_repo_name": "shlevy/agda", "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/interaction/Auto/Prelude.agda", "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 20.6930693069, "max_line_length": 114, "alphanum_fraction": 0.4641148325, "num_tokens": 927, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026618464796, "lm_q2_score": 0.8244619350028204, "lm_q1q2_score": 0.7562811275691864}}
{"text": "{-# OPTIONS --exact-split #-}\n\n-- The --exact-split flag causes Agda to raise an error whenever\n-- a clause in a definition by pattern matching cannot be made to\n-- hold definitionally (i.e. as a reduction rule). Specific clauses\n-- can be excluded from this check by means of the {-# CATCHALL #-}\n-- pragma.\n\nmodule ExactSplit where\n\ndata Bool : Set where\n  true false : Bool\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero    + n    = zero\n(suc m) + n    = suc (m + n)\n\neq : \u2115 \u2192 \u2115 \u2192 Bool\neq zero    zero    = true\neq (suc m) (suc n) = eq m n\n{-# CATCHALL #-}\neq _       _       = false\n\n-- See also fail/ExactSplitMin.agda\nmin : \u2115 \u2192 \u2115 \u2192 \u2115\nmin zero    y       = zero\n{-# CATCHALL #-}\nmin x       zero    = zero\nmin (suc x) (suc y) = suc (min x y)\n\n-- See also fail/ExactSplitBerry.agda\nmaj : Bool \u2192 Bool \u2192 Bool \u2192 Bool\nmaj true  true  true  = true\n{-# CATCHALL #-}\nmaj x     true  false = x\n{-# CATCHALL #-}\nmaj false y     true  = y\nmaj true  false z     = z\nmaj false false false = false\n\n-- See also fail/ExactSplitParity.agda\nparity : \u2115 \u2192 \u2115 \u2192 Bool\nparity zero          zero          = true\nparity zero          (suc zero)    = false\nparity zero          (suc (suc n)) = parity zero n\nparity (suc zero)    zero          = false\nparity (suc (suc m)) zero          = parity m zero\n{-# CATCHALL #-}\nparity (suc m)       (suc n)       = parity m n\n", "meta": {"hexsha": "00a87798c9fdcd2e068a2c5d797066d6cf1f6f97", "size": 1367, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/ExactSplit.agda", "max_stars_repo_name": "cruhland/agda", "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1989, "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_issues_repo_path": "test/Succeed/ExactSplit.agda", "max_issues_repo_name": "cruhland/agda", "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4066, "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_forks_repo_path": "test/Succeed/ExactSplit.agda", "max_forks_repo_name": "cruhland/agda", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 371, "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "avg_line_length": 25.3148148148, "max_line_length": 67, "alphanum_fraction": 0.5815654718, "num_tokens": 423, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070011518829, "lm_q2_score": 0.8311430478583168, "lm_q1q2_score": 0.756262878204997}}
{"text": "module foldr-++ where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; cong)\nopen Eq.\u2261-Reasoning\nopen import lists using (List; _\u2237_; []; _++_; foldr)\n \n-- \u7d50\u5408\u3057\u305f\u30ea\u30b9\u30c8\u306e\u91cd\u7573\u306f\u3001\u91cd\u7573\u3057\u305f\u7d50\u679c\u3092\u521d\u671f\u5024\u3068\u3057\u305f\u91cd\u7573\u3068\u7b49\u3057\u3044\u3053\u3068\u306e\u8a3c\u660e\nfoldr-++ : \u2200 {A B : Set} \u2192 (_\u2297_ : A \u2192 B \u2192 B) \u2192 (e : B) \u2192 (xs ys : List A)\n  \u2192 foldr _\u2297_ e (xs ++ ys) \u2261 foldr _\u2297_ (foldr _\u2297_ e ys) xs\nfoldr-++ _\u2297_ e [] ys =\n  begin\n    foldr _\u2297_ e ([] ++ ys)\n  \u2261\u27e8\u27e9\n    foldr _\u2297_ e ys\n  \u2261\u27e8\u27e9\n    foldr _\u2297_ (foldr _\u2297_ e ys) []\n  \u220e\nfoldr-++ _\u2297_ e (x \u2237 xs) ys =\n  begin\n    foldr _\u2297_ e ((x \u2237 xs) ++ ys)\n  \u2261\u27e8\u27e9\n    x \u2297 (foldr _\u2297_ e (xs ++ ys))\n  \u2261\u27e8 cong (x \u2297_) (foldr-++ _\u2297_ e xs ys) \u27e9\n    x \u2297 (foldr _\u2297_ (foldr _\u2297_ e ys) xs)\n  \u2261\u27e8\u27e9\n    foldr _\u2297_ (foldr _\u2297_ e ys) (x \u2237 xs)\n  \u220e\n", "meta": {"hexsha": "28335f0d8944a3f0abdcbc4a25260a8ffdb033d9", "size": 716, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/foldr-++.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/foldr-++.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/foldr-++.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.6896551724, "max_line_length": 73, "alphanum_fraction": 0.5195530726, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218370002787, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.7558775683610707}}
{"text": "{-# OPTIONS --without-K #-}\n\nopen import library.Basics hiding (Type ; \u03a3)\nopen import library.types.Sigma\nopen import library.types.Bool\n\nopen import Sec2preliminaries \nopen import Sec4hasConstToSplit\n\nmodule Sec6hasConstToDecEq where\n\n-- Lemma 6.1\nhasConst-family-dec : {X : Type} \u2192 (x\u2081 x\u2082 : X) \u2192 ((x : X) \u2192 hasConst ((x\u2081 == x) + (x\u2082 == x))) \u2192 (x\u2081 == x\u2082) + \u00ac(x\u2081 == x\u2082)\nhasConst-family-dec {X} x\u2081 x\u2082 hasConst-fam = solution where\n  f\u208b : (x : X) \u2192 (x\u2081 == x) + (x\u2082 == x) \u2192 (x\u2081 == x) + (x\u2082 == x)\n  f\u208b x = fst (hasConst-fam x)\n\n  E\u208b : X \u2192 Type\n  E\u208b x = fix (f\u208b x)\n\n  E : Type\n  E = \u03a3 X \u03bb x \u2192 (E\u208b x)\n\n  E-fst-determines-eq : (e\u2081 e\u2082 : E) \u2192 (fst e\u2081 == fst e\u2082) \u2192 e\u2081 == e\u2082\n  E-fst-determines-eq e\u2081 e\u2082 p = second-comp-triv (\u03bb x \u2192 fixed-point (f\u208b x) (snd (hasConst-fam x))) _ _ p\n\n  r : Bool \u2192 E\n  r true = x\u2081 , to-fix (f\u208b x\u2081) (snd (hasConst-fam x\u2081)) (inl idp) \n  r false = x\u2082 , to-fix (f\u208b x\u2082) (snd (hasConst-fam x\u2082)) (inr idp)\n\n  about-r : (r true == r false) \u2194 (x\u2081 == x\u2082)\n  about-r = (\u03bb p \u2192 ap fst p) , (\u03bb p \u2192 E-fst-determines-eq _ _ p)\n\n  s : E \u2192 Bool\n  s (_ , inl _ , _) = true\n  s (_ , inr _ , _) = false\n\n  s-section-of-r : (e : E) \u2192 r(s e) == e\n  s-section-of-r (x , inl p , q) = E-fst-determines-eq _ _ p\n  s-section-of-r (x , inr p , q) = E-fst-determines-eq _ _ p\n\n  about-s : (e\u2081 e\u2082 : E) \u2192 (s e\u2081 == s e\u2082) \u2194 (e\u2081 == e\u2082)\n  about-s e\u2081 e\u2082 = one , two where\n    one : (s e\u2081 == s e\u2082) \u2192 (e\u2081 == e\u2082)\n    one p = \n      e\u2081       =\u27e8 ! (s-section-of-r e\u2081) \u27e9\n      r(s(e\u2081)) =\u27e8 ap r p \u27e9\n      r(s(e\u2082)) =\u27e8 s-section-of-r e\u2082 \u27e9\n      e\u2082       \u220e\n    two : (e\u2081 == e\u2082) \u2192 (s e\u2081 == s e\u2082)\n    two p = ap s p\n\n  combine : (s (r true) == s (r false)) \u2194 (x\u2081 == x\u2082)\n  combine = (about-s _ _) \u25ce about-r\n\n  check-bool : (s (r true) == s (r false)) + \u00ac(s (r true) == s (r false))\n  check-bool = Bool-has-dec-eq _ _\n\n  solution : (x\u2081 == x\u2082) + \u00ac(x\u2081 == x\u2082)\n  solution with check-bool \n  solution | inl p = inl (fst combine p)\n  solution | inr np = inr (\u03bb p \u2192 np (snd combine p))\n\n\n-- Theorem 6.2\nall-hasConst\u2192dec-eq : ((X : Type) \u2192 hasConst X) \u2192 (X : Type) \u2192 has-dec-eq X\nall-hasConst\u2192dec-eq all-hasConst X x\u2081 x\u2082 = hasConst-family-dec x\u2081 x\u2082 (\u03bb x \u2192 all-hasConst _)\n", "meta": {"hexsha": "52bfdc76e510bce52b4b9de76a2ace6664fe90f7", "size": 2130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_issues_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nicolai/anonymousExistence/Sec6hasConstToDecEq.agda", "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.3235294118, "max_line_length": 120, "alphanum_fraction": 0.5375586854, "num_tokens": 910, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218348550491, "lm_q2_score": 0.8198933337131076, "lm_q1q2_score": 0.7558775666022112}}
{"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Properties of functions, such as associativity and commutativity\n------------------------------------------------------------------------\n\n-- These properties can (for instance) be used to define algebraic\n-- structures.\n\nopen import Level\nopen import Relation.Binary\n\n-- The properties are specified using the following relation as\n-- \"equality\".\n\nmodule Algebra.FunctionProperties\n         {a \u2113} {A : Set a} (_\u2248_ : Rel A \u2113) where\n\nopen import Data.Product\n\n------------------------------------------------------------------------\n-- Unary and binary operations\n\nopen import Algebra.FunctionProperties.Core public\n\n------------------------------------------------------------------------\n-- Properties of operations\n\nAssociative : Op\u2082 A \u2192 Set _\nAssociative _\u2219_ = \u2200 x y z \u2192 ((x \u2219 y) \u2219 z) \u2248 (x \u2219 (y \u2219 z))\n\nCommutative : Op\u2082 A \u2192 Set _\nCommutative _\u2219_ = \u2200 x y \u2192 (x \u2219 y) \u2248 (y \u2219 x)\n\nLeftIdentity : A \u2192 Op\u2082 A \u2192 Set _\nLeftIdentity e _\u2219_ = \u2200 x \u2192 (e \u2219 x) \u2248 x\n\nRightIdentity : A \u2192 Op\u2082 A \u2192 Set _\nRightIdentity e _\u2219_ = \u2200 x \u2192 (x \u2219 e) \u2248 x\n\nIdentity : A \u2192 Op\u2082 A \u2192 Set _\nIdentity e \u2219 = LeftIdentity e \u2219 \u00d7 RightIdentity e \u2219\n\nLeftZero : A \u2192 Op\u2082 A \u2192 Set _\nLeftZero z _\u2219_ = \u2200 x \u2192 (z \u2219 x) \u2248 z\n\nRightZero : A \u2192 Op\u2082 A \u2192 Set _\nRightZero z _\u2219_ = \u2200 x \u2192 (x \u2219 z) \u2248 z\n\nZero : A \u2192 Op\u2082 A \u2192 Set _\nZero z \u2219 = LeftZero z \u2219 \u00d7 RightZero z \u2219\n\nLeftInverse : A \u2192 Op\u2081 A \u2192 Op\u2082 A \u2192 Set _\nLeftInverse e _\u207b\u00b9 _\u2219_ = \u2200 x \u2192 (x \u207b\u00b9 \u2219 x) \u2248 e\n\nRightInverse : A \u2192 Op\u2081 A \u2192 Op\u2082 A \u2192 Set _\nRightInverse e _\u207b\u00b9 _\u2219_ = \u2200 x \u2192 (x \u2219 (x \u207b\u00b9)) \u2248 e\n\nInverse : A \u2192 Op\u2081 A \u2192 Op\u2082 A \u2192 Set _\nInverse e \u207b\u00b9 \u2219 = LeftInverse e \u207b\u00b9 \u2219 \u00d7 RightInverse e \u207b\u00b9 \u2219\n\n_DistributesOver\u02e1_ : Op\u2082 A \u2192 Op\u2082 A \u2192 Set _\n_*_ DistributesOver\u02e1 _+_ =\n  \u2200 x y z \u2192 (x * (y + z)) \u2248 ((x * y) + (x * z))\n\n_DistributesOver\u02b3_ : Op\u2082 A \u2192 Op\u2082 A \u2192 Set _\n_*_ DistributesOver\u02b3 _+_ =\n  \u2200 x y z \u2192 ((y + z) * x) \u2248 ((y * x) + (z * x))\n\n_DistributesOver_ : Op\u2082 A \u2192 Op\u2082 A \u2192 Set _\n* DistributesOver + = (* DistributesOver\u02e1 +) \u00d7 (* DistributesOver\u02b3 +)\n\n_IdempotentOn_ : Op\u2082 A \u2192 A \u2192 Set _\n_\u2219_ IdempotentOn x = (x \u2219 x) \u2248 x\n\nIdempotent : Op\u2082 A \u2192 Set _\nIdempotent \u2219 = \u2200 x \u2192 \u2219 IdempotentOn x\n\nIdempotentFun : Op\u2081 A \u2192 Set _\nIdempotentFun f = \u2200 x \u2192 f (f x) \u2248 f x\n\n_Absorbs_ : Op\u2082 A \u2192 Op\u2082 A \u2192 Set _\n_\u2219_ Absorbs _\u2218_ = \u2200 x y \u2192 (x \u2219 (x \u2218 y)) \u2248 x\n\nAbsorptive : Op\u2082 A \u2192 Op\u2082 A \u2192 Set _\nAbsorptive \u2219 \u2218 = (\u2219 Absorbs \u2218) \u00d7 (\u2218 Absorbs \u2219)\n\nInvolutive : Op\u2081 A \u2192 Set _\nInvolutive f = \u2200 x \u2192 f (f x) \u2248 x\n", "meta": {"hexsha": "1d49422474c1181033fb9d7678a311a3ff552f56", "size": 2462, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Algebra/FunctionProperties.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Algebra/FunctionProperties.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Algebra/FunctionProperties.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.3555555556, "max_line_length": 72, "alphanum_fraction": 0.5296506905, "num_tokens": 866, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240090865197, "lm_q2_score": 0.8056321843145404, "lm_q1q2_score": 0.7557828945982866}}
{"text": "module EqTest where\n\nimport Common.Level\n\ndata _\u2261_ {a : Set} (x : a) : a -> Set where\n  refl : x \u2261 x\n\ndata Maybe (a : Set) : Set where\n  just    : a -> Maybe a\n  nothing : Maybe a\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc  : \u2115 -> \u2115\n\n_\u225f_ : (x y : \u2115) -> Maybe (x \u2261 y)\nsuc m  \u225f suc n with m \u225f n\nsuc .n \u225f suc n |    just refl = just refl\nsuc m  \u225f suc n |    nothing   = nothing\nzero   \u225f suc _ = nothing\nsuc m  \u225f zero  = nothing\nzero   \u225f zero  = just refl\n", "meta": {"hexsha": "e22fe438ed9c66f9a8e98ca4fe14a2b19a8109f1", "size": 446, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/EqTest.agda", "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_issues_repo_path": "test/succeed/EqTest.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/EqTest.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 19.3913043478, "max_line_length": 43, "alphanum_fraction": 0.5538116592, "num_tokens": 177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9407897558991952, "lm_q2_score": 0.8031737987125613, "lm_q1q2_score": 0.7556176820354199}}
{"text": "module nat where\n\ndata N : Set where\n  zero : N\n  suc  : N -> N\n\n_+_ : N -> N -> N\nn + zero = n\nn + (suc m) = suc (n + m)\n\n_*_ : N -> N -> N\nn * zero = zero\nn * (suc m) = (m * n) + m\n", "meta": {"hexsha": "034e4c86817c034e57fbeaab49991c282c3212b9", "size": 183, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "nat.agda", "max_stars_repo_name": "uedatakumi/nat", "max_stars_repo_head_hexsha": "2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-02T15:31:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-02T15:31:17.000Z", "max_issues_repo_path": "nat.agda", "max_issues_repo_name": "uedatakumi/nat", "max_issues_repo_head_hexsha": "2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "nat.agda", "max_forks_repo_name": "uedatakumi/nat", "max_forks_repo_head_hexsha": "2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.0714285714, "max_line_length": 25, "alphanum_fraction": 0.4371584699, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9783846691281406, "lm_q2_score": 0.7718434978390746, "lm_q1q2_score": 0.7551598452519896}}
{"text": "{-# OPTIONS --allow-unsolved-metas #-}\n\nopen import Tutorials.Monday-Complete\nmodule Tutorials.Tuesday where\n\n-----------\n-- Pi and Sigma types\n-----------\n\nmodule Product where\n  -- The open keyword opens a given module in the current namespace\n  -- By default all of the public names of the module are opened\n  -- The using keyword limits the imported definitions to those explicitly listed\n  open Fin\n  open Vec using (Vec; []; _\u2237_)\n  open Simple using (\u00ac_)\n\n  variable\n    P Q : A \u2192 Set\n\n  -- Pi types: dependent function types\n  -- For every x of type A, the predicate P x holds\n  \u03a0 : (A : Set) \u2192 (Pred A) \u2192 Set\n  \u03a0 A P = (x : A) \u2192 P x\n\n  infix 5 _,_\n  -- Sigma types: dependent product types, existential types\n  -- For this x of type A, the predicate P x holds\n  record \u03a3 (A : Set) (P : Pred A) : Set where\n    -- In the type P fst, fst refers to a previously introduced field\n    constructor _,_\n    field\n      fst : A\n      snd : P fst\n\n  open \u03a3 public\n\n  -- By depending on a boolean we can use pi types to represent product types\n  \u03a0-\u00d7 : Set \u2192 Set \u2192 Set\n  \u03a0-\u00d7 A B = \u03a0 Bool \u03bb where\n    true  \u2192 A\n    false \u2192 B\n\n  -- By depending on a boolean we can use sigma types to represent sum types\n  \u03a3-\u228e : Set \u2192 Set \u2192 Set\n  \u03a3-\u228e A B = \u03a3 Bool \u03bb where\n    true  \u2192 A\n    false \u2192 B\n\n  -- Use pi types to recover function types\n  \u03a0-\u2192 : Set \u2192 Set \u2192 Set\n  \u03a0-\u2192 A B = \u03a0 A \u03bb where\n    _     \u2192 B\n\n  -- Use sigma types to recover product types\n  \u03a3-\u00d7 : Set \u2192 Set \u2192 Set\n  \u03a3-\u00d7 A B = \u03a3 A \u03bb where\n    _     \u2192 B\n\n  infix 5 _\u00d7_\n  _\u00d7_ : Set \u2192 Set \u2192 Set\n  _\u00d7_ = \u03a3-\u00d7\n\n  -- 1) If we can transform the witness and\n  -- 2) transform the predicate as per the transformation on the witness\n  -- \u21d2) then we can transform a sigma type\n  map : (f : A \u2192 B) \u2192 (\u2200 {x} \u2192 P x \u2192 Q (f x)) \u2192 (\u03a3 A P \u2192 \u03a3 B Q)\n  map f g (x , y) = (f x , g y)\n\n  -- The syntax keyword introduces notation that can include binders\n  infix 4 \u03a3-syntax\n  \u03a3-syntax : (A : Set) \u2192 (A \u2192 Set) \u2192 Set\n  \u03a3-syntax = \u03a3\n  syntax \u03a3-syntax A (\u03bb x \u2192 B) = \u03a3[ x \u2208 A ] B\n\n  \u00ac\u2218 : Pred A \u2192 Pred A\n  \u00ac\u2218 P = \u00ac_ \u2218 P\n\n  -- These can be proven regardless of A\n\n  \u00ac\u2203\u21d2\u2200\u00ac : \u00ac (\u03a3 A P) \u2192 \u03a0 A (\u00ac\u2218 P)\n  \u00ac\u2203\u21d2\u2200\u00ac = {!!}\n\n  \u2203\u00ac\u21d2\u00ac\u2200 : \u03a3 A (\u00ac\u2218 P) \u2192 \u00ac \u03a0 A P\n  \u2203\u00ac\u21d2\u00ac\u2200 = {!!}\n\n  \u2200\u00ac\u21d2\u00ac\u2203 : \u03a0 A (\u00ac\u2218 P) \u2192 \u00ac \u03a3 A P\n  \u2200\u00ac\u21d2\u00ac\u2203 = {!!}\n\n  -- Works in classical, not in constructive mathematics\n  postulate \u00ac\u2200\u21d2\u2203\u00ac : \u00ac \u03a0 A P \u2192 \u03a3 A (\u00ac\u2218 P)\n\n  -- Show that \u2264 is antisymmetric\n  \u2264-\u2261 : n \u2264 m \u2192 m \u2264 n \u2192 n \u2261 m\n  \u2264-\u2261 x y = {!!}\n\n  -- By using n \u2264 m instead of Fin m we can mention n in the output\n  take : Vec A m \u2192 n \u2264 m \u2192 Vec A n\n  take xs lte = {!!}\n\n  Fin-to-\u2264 : (i : Fin m) \u2192 to-\u2115 i < m\n  Fin-to-\u2264 i = {!!}\n\n  -- Proof combining sigma types and equality\n  \u2264-to-Fin : n < m \u2192 Fin m\n  \u2264-to-Fin lt = {!!}\n\n  Fin-\u2264-inv : (i : Fin m) \u2192 \u2264-to-Fin (Fin-to-\u2264 i) \u2261 i\n  Fin-\u2264-inv i = {!!}\n\n  \u2264-Fin-inv : (lt : \u03a3[ n \u2208 \u2115 ] n < m)\n            \u2192 (to-\u2115 (\u2264-to-Fin (snd lt)) , Fin-to-\u2264 (\u2264-to-Fin (snd lt))) \u2261 lt\n  \u2264-Fin-inv lt = {!!}\n", "meta": {"hexsha": "564f8167f1258e2ffa46bf5fbfb33ad66725075c", "size": 2891, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Tutorials/Tuesday.agda", "max_stars_repo_name": "poncev/agda-bcam", "max_stars_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 27, "max_stars_repo_stars_event_min_datetime": "2021-09-23T17:59:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T22:53:51.000Z", "max_issues_repo_path": "Tutorials/Tuesday.agda", "max_issues_repo_name": "poncev/agda-bcam", "max_issues_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Tutorials/Tuesday.agda", "max_forks_repo_name": "poncev/agda-bcam", "max_forks_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-11-23T08:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-24T10:50:55.000Z", "avg_line_length": 25.3596491228, "max_line_length": 81, "alphanum_fraction": 0.5468695953, "num_tokens": 1099, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9343951680216529, "lm_q2_score": 0.8080672135527632, "lm_q1q2_score": 0.755054099780423}}
{"text": "module reverse-++-distrib where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; sym; cong)\nopen Eq.\u2261-Reasoning\nopen import lists using (List; []; _\u2237_; [_]; _++_; ++-assoc; ++-identity\u02b3; reverse)\n\n-- \u7d50\u5408\u3057\u305f\u30ea\u30b9\u30c8\u306e\u9006\u9806\u306f\u3001\u9006\u9806\u306b\u3057\u305f\u30ea\u30b9\u30c8\u306e\u9006\u9806\u306e\u7d50\u5408\u3068\u7b49\u3057\u3044\u3053\u3068\u306e\u8a3c\u660e\nreverse-++-distrib : \u2200 {A : Set} \u2192 (xs ys : List A)\n  \u2192 reverse (xs ++ ys) \u2261 reverse ys ++ reverse xs\nreverse-++-distrib [] ys =\n  begin\n    reverse ([] ++ ys)\n  \u2261\u27e8\u27e9\n    reverse ys\n  \u2261\u27e8 sym (++-identity\u02b3 (reverse ys)) \u27e9\n    reverse ys ++ []\n  \u2261\u27e8\u27e9\n    reverse ys ++ reverse []\n  \u220e\nreverse-++-distrib (x \u2237 xs) ys =\n  begin\n    reverse (x \u2237 xs ++ ys)\n  \u2261\u27e8\u27e9\n    reverse (xs ++ ys) ++ [ x ]\n  \u2261\u27e8 cong (_++ [ x ]) (reverse-++-distrib xs ys) \u27e9\n    (reverse ys ++ reverse xs) ++ [ x ]\n  \u2261\u27e8 ++-assoc (reverse ys) (reverse xs) [ x ] \u27e9\n    reverse ys ++ (reverse xs ++ [ x ])\n  \u2261\u27e8\u27e9\n    reverse ys ++ reverse (x \u2237 xs)\n  \u220e\n", "meta": {"hexsha": "443635d03c57db39e921481c794cd9f0f6f40d92", "size": 875, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/reverse-++-distrib.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/reverse-++-distrib.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/reverse-++-distrib.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.5151515152, "max_line_length": 83, "alphanum_fraction": 0.5565714286, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172601537141, "lm_q2_score": 0.7956581024858785, "lm_q1q2_score": 0.755013706630003}}
{"text": "{-# OPTIONS --safe #-}\nmodule Cubical.Algebra.Monoid.Instances.NatVec where\n\nopen import Cubical.Foundations.Prelude\n\nopen import Cubical.Data.Nat using (\u2115 ; isSet\u2115)\nopen import Cubical.Data.Vec\nopen import Cubical.Data.Vec.OperationsNat\n\nopen import Cubical.Algebra.Monoid\n\n\nNatVecMonoid : (n : \u2115) \u2192 Monoid \u2113-zero\nfst (NatVecMonoid n) = Vec \u2115 n\nMonoidStr.\u03b5 (snd (NatVecMonoid n)) = replicate 0\nMonoidStr._\u00b7_ (snd (NatVecMonoid n)) = _+n-vec_\nMonoidStr.isMonoid (snd (NatVecMonoid n)) = makeIsMonoid (VecPath.isOfHLevelVec 0 n isSet\u2115)\n                                                       +n-vec-assoc +n-vec-rid +n-vec-lid\n", "meta": {"hexsha": "ff2a19041e3af9025ac1b31295ae66a8304a1639", "size": 625, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Cubical/Algebra/Monoid/Instances/NatVec.agda", "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Cubical/Algebra/Monoid/Instances/NatVec.agda", "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Cubical/Algebra/Monoid/Instances/NatVec.agda", "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.8947368421, "max_line_length": 91, "alphanum_fraction": 0.688, "num_tokens": 201, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172615983308, "lm_q2_score": 0.7956580903722561, "lm_q1q2_score": 0.7550136962845985}}
{"text": "{-# OPTIONS --type-in-type #-}  -- yes, I will let you cheat in this exercise\n{-# OPTIONS --allow-unsolved-metas #-}  -- allows import, unfinished\n\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n-- CS410 2017/18 Exercise 3  WINDOWS AND OTHER STORIES (worth 25%)\n------------------------------------------------------------------------------\n------------------------------------------------------------------------------\n\n------------------------------------------------------------------------------\n-- Dependencies\n------------------------------------------------------------------------------\n\nopen import CS410-Prelude\nopen import CS410-Categories\nopen import Ex2\n\n\n------------------------------------------------------------------------------\n--  PART I:  Splittings\n------------------------------------------------------------------------------\n\n-- The type    ls <[ ms ]> rs\n-- is similar to that found in Lec2.agda, but it works on lists, not numbers.\n-- It provides the evidence that a list ms can be split into a left sublist ls\n-- and a right sublist rs. In effect, it's a vector of bits that say which\n-- elements of ms go left and which go right.\n\ndata _<[_]>_ {X : Set} : List X -> List X -> List X -> Set where\n  sz : [] <[ [] ]> []\n  sl : forall {l ls ms rs} -> ls <[ ms ]> rs -> (l ,- ls) <[ l ,- ms ]> rs\n  sr : forall {r ls ms rs} -> ls <[ ms ]> rs -> ls <[ r ,- ms ]> (r ,- rs)\n\n\n--??--3.1---------------------------------------------------------------------\n\n-- Adapt _>[_]<_ from Lec2 to work for All. Given a P for each element of\n-- ls and rs, riffle them together to get Ps for all the ms.\n\n_>[_]<_ : {X : Set}{ls ms rs : List X} -> {P : X -> Set} ->\n          All P ls -> ls <[ ms ]> rs -> All P rs ->\n          All P ms\npl >[ s ]< pr = {!!}\n\n-- Now, buikd the view that shows riffling can be inverted, using a splitting\n-- as the instructions to discover how to split an All in two.\n\ndata IsRiffle {X : Set}{ls ms rs : List X}(s : ls <[ ms ]> rs){P : X -> Set}\n  : All P ms -> Set where\n  mkRiffle : (pl : All P ls)(pr : All P rs) -> IsRiffle s (pl >[ s ]< pr)\n  \nisRiffle : {X : Set}{ls ms rs : List X}(s : ls <[ ms ]> rs)\n           {P : X -> Set}(pm : All P ms) -> IsRiffle s pm\nisRiffle s pm = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.2---------------------------------------------------------------------\n\n-- Construct the \"all on the right\" splitting.\n\nsrs : forall {X : Set}{xs : List X} -> [] <[ xs ]> xs\nsrs = {!!}\n\n-- Construct a view to show that any \"none on the left\" splitting is\n-- \"all on the right\". Come up with the type yourself.\n\n\n-- Construct the splitting that corresponds to concatenation.\n\nslrs : forall {X : Set}(xs ys : List X) -> xs <[ xs +L ys ]> ys\nslrs xs ys = {!!}\n\n--??--------------------------------------------------------------------------\n\n--??--3.3---------------------------------------------------------------------\n\n-- Invent other useful operations which transform splittings.\n-- You will need some to do later parts of the exercise, so maybe\n-- wait until you see what you need.\n\n-- I expect you will need at least something that takes a pair of splittings\n-- that make a tree, like\n--\n--                  ms\n--               <[    ]>\n--            ls          rs\n--                     <[    ]>\n--                 lrs          rrs\n--\n-- and compute a \"rotated\" pair of splittings like\n--\n--                  ms\n--               <[    ]>\n--            ??          rrs\n--         <[    ]>\n--      ls          lrs\n\n-- HINT: Sg is your friend\n\n-- You'll probably need some other stuff, too.\n\n--??--------------------------------------------------------------------------\n\n\n------------------------------------------------------------------------------\n--  PART II:  Permutations\n------------------------------------------------------------------------------\n\n-- When is one list a permutation of another?\n\ndata _~_ {X : Set} : List X -> List X -> Set where\n\n  -- [] is a permutation of []\n  []   : [] ~ []\n\n  -- if xs ~ ys, then (x ,- xs) is a permutation of any list made by\n  -- shoving x somewhere into ys\n  _,-_ : forall {x xs ys' ys} ->\n           (x ,- []) <[ ys' ]> ys ->\n           xs ~ ys ->\n           (x ,- xs) ~ ys'\n\n\n--??--3.4---------------------------------------------------------------------\n\n-- Show that every list is a permutation of itself.\n\nreflP : {X : Set}{xs : List X} -> xs ~ xs\nreflP = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.5---------------------------------------------------------------------\n\n-- Construct an \"unbiased\" insertion operator which lets you grow a\n-- permutation by inserting a new element anywhere, left and right\n\ninsP : forall {X : Set}{z : X}{xs xs' ys ys'} ->\n         (z ,- []) <[ xs' ]> xs ->\n         (z ,- []) <[ ys' ]> ys ->\n         xs ~ ys -> xs' ~ ys'\ninsP l r p = {!!}\n\n-- Now show that, given a permutation, and any element on the left,\n-- you can find out where it ended up on the right, and why the\n-- remaining elements form a permutation.\n\nfindLonR : forall {X : Set}{z : X}{xs xs' ys'} ->\n                  (z ,- []) <[ xs' ]> xs ->\n                  xs' ~ ys' ->\n                  {!!}\nfindLonR l p = {!!}\n\n-- HINT: again, you may need Sg to give a sensible return type.\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.6---------------------------------------------------------------------\n\n-- Show that permutation is transitive.\n\ntransP : {X : Set}{xs ys zs : List X} -> xs ~ ys -> ys ~ zs -> xs ~ zs\ntransP p q = {!!}\n\n-- HINT: you will need to define some useful operations on splittings to\n-- get this to work.\n\n-- HINT: this may help you figure out what you need for findLonR\n\n-- For a small bonus, show that permutations are the morphisms of a\n-- Category.\n\n-- Show that permutation is symmetric.\n\nsymP : {X : Set}{xs ys : List X} -> xs ~ ys -> ys ~ xs\nsymP p = {!!}\n\n-- A category where all morphisms are invertible is called a \"groupoid\".\n\n--??--------------------------------------------------------------------------\n\n\n--??--3.7---------------------------------------------------------------------\n\n-- Make permutations act on All.\n\npermute : {X : Set}{xs ys : List X} -> xs ~ ys ->\n          {Q : X -> Set} -> All Q xs -> All Q ys\n\npermute p qs = {!!}\n\n--??--------------------------------------------------------------------------\n\n\n\n-- MORE TO FOLLOW\n", "meta": {"hexsha": "3534de0eff1bef19987253152ef623b54cec9593", "size": 6560, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Ex3.agda", "max_stars_repo_name": "m-schmidt/CS410-17-Exercises", "max_stars_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ex3.agda", "max_issues_repo_name": "m-schmidt/CS410-17-Exercises", "max_issues_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ex3.agda", "max_forks_repo_name": "m-schmidt/CS410-17-Exercises", "max_forks_repo_head_hexsha": "5db8e95bbcbe8dc0eec810f3e73130ecd78d207c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6368159204, "max_line_length": 78, "alphanum_fraction": 0.3972560976, "num_tokens": 1503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942290328344, "lm_q2_score": 0.8479677602988602, "lm_q1q2_score": 0.754940803399973}}
{"text": "module map-++-distribute where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; cong)\nopen Eq.\u2261-Reasoning\nopen import lists using (List; []; _\u2237_; _++_; map)\n\n-- \u30ea\u30b9\u30c8\u306e\u7d50\u5408\u306b\u95a2\u3059\u308bmap\u306e\u5206\u914d\u6cd5\u5247\u306e\u8a3c\u660e\nmap-++-distribute : {A B : Set} \u2192 (f : A \u2192 B) \u2192 (xs ys : List A)\n  \u2192 map f (xs ++ ys) \u2261 map f xs ++ map f ys\nmap-++-distribute f [] ys =\n  begin\n    map f ([] ++ ys)\n  \u2261\u27e8\u27e9\n    map f ys\n  \u2261\u27e8\u27e9\n    map f [] ++ map f ys\n  \u220e\nmap-++-distribute f (x \u2237 xs) ys =\n  begin\n    map f ((x \u2237 xs) ++ ys)\n  \u2261\u27e8\u27e9\n    f x \u2237 map f (xs ++ ys)\n  \u2261\u27e8 cong (f x \u2237_) (map-++-distribute f xs ys) \u27e9\n    f x \u2237 map f xs ++ map f ys\n  \u2261\u27e8\u27e9\n    map f (x \u2237 xs) ++ map f ys\n  \u220e\n", "meta": {"hexsha": "fe56b00ced79c4a2a5fe6271f61e97095f15a3c6", "size": 655, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/lists/map-++-distribute.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/lists/map-++-distribute.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/lists/map-++-distribute.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.5862068966, "max_line_length": 64, "alphanum_fraction": 0.5267175573, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9314625145783428, "lm_q2_score": 0.8104789155369047, "lm_q1q2_score": 0.7549307286787336}}
{"text": "{-# OPTIONS --sized-types #-}\nmodule BBHeap.Height {A : Set}(_\u2264_ : A \u2192 A \u2192 Set) where\n\nopen import BBHeap _\u2264_ hiding (#)\nopen import Bound.Lower A \nopen import Bound.Lower.Order _\u2264_\nopen import SNat\n\n# : {b : Bound} \u2192 BBHeap b \u2192 SNat\n# leaf = zero\n# (left {l = l} {r = r} _ _) = succ (# l + # r)\n# (right {l = l} {r = r} _ _) = succ (# l + # r)\n\nheight : {b : Bound} \u2192 BBHeap b \u2192 SNat\nheight leaf = zero\nheight (left {l = l} _ _) = succ (height l)\nheight (right {l = l} _ _) = succ (height l)\n\n#' : {b : Bound} \u2192 BBHeap b \u2192 SNat\n#' leaf = zero\n#' (left {r = r}  _ _) = succ (#' r + #' r)\n#' (right {r = r} _ _) = succ (#' r + #' r)\n\nheight' : {b : Bound} \u2192 BBHeap b \u2192 SNat\nheight' leaf = zero\nheight' (left {r = r} _ _) = succ (height' r)\nheight' (right {r = r} _ _) = succ (height' r)\n\n\n", "meta": {"hexsha": "8b43eba04cbad30261357ffd41b04d83bf5cf7cc", "size": 788, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BBHeap/Height.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BBHeap/Height.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BBHeap/Height.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.2666666667, "max_line_length": 55, "alphanum_fraction": 0.5393401015, "num_tokens": 297, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9546474168650673, "lm_q2_score": 0.7905303236047049, "lm_q1q2_score": 0.7546777313827372}}
{"text": "module List.Order.Bounded.Properties {A : Set} \n                   (_\u2264_ : A \u2192 A \u2192 Set) \n                   (trans\u2264 : {x y z : A} \u2192 x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 z)  where\n\nopen import Bound.Total A\nopen import Bound.Total.Order _\u2264_\nopen import Bound.Total.Order.Properties _\u2264_ trans\u2264\nopen import Data.List\nopen import List.Order.Bounded _\u2264_\nopen import List.Sorted _\u2264_\n\nlemma-sorted++ : {x : A}{xs ys : List A} \u2192 xs \u2264* (val x) \u2192 (val x) *\u2264 ys \u2192 Sorted xs \u2192 Sorted ys \u2192 Sorted (xs ++ (x \u2237 ys))\nlemma-sorted++ {x = x} lenx genx _ _ = singls x\nlemma-sorted++ lenx (gecx u\u2264y _) _ sys = conss (lemma-LeB\u2264 u\u2264y) sys\nlemma-sorted++ (lecx x\u2264u xs\u2264*u) u*\u2264ys (singls x) sys = conss (lemma-LeB\u2264 x\u2264u) (lemma-sorted++ xs\u2264*u u*\u2264ys nils sys)\nlemma-sorted++ (lecx x\u2264u xs\u2264*u) u*\u2264ys (conss x\u2264z sxs) sys = conss x\u2264z (lemma-sorted++ xs\u2264*u u*\u2264ys sxs sys)\n\nlemma-++\u2264* : {t : Bound}{x : A}{xs ys : List A} \u2192 LeB (val x) t \u2192 xs \u2264* (val x) \u2192 ys \u2264* t \u2192 (xs ++ (x \u2237 ys)) \u2264* t\nlemma-++\u2264* u\u2264t lenx ys\u2264*t = lecx u\u2264t ys\u2264*t\nlemma-++\u2264* u\u2264t (lecx x\u2264u xs\u2264*u) ys\u2264*u = lecx (transLeB x\u2264u u\u2264t) (lemma-++\u2264* u\u2264t xs\u2264*u ys\u2264*u)\n\nlemma-*\u2264 : {b : Bound}{x : A}{xs : List A} \u2192 LeB b (val x) \u2192 (val x) *\u2264 xs \u2192 b *\u2264 xs\nlemma-*\u2264 _ genx = genx\nlemma-*\u2264 b\u2264u (gecx u\u2264x u*\u2264xs) = gecx (transLeB b\u2264u u\u2264x) (lemma-*\u2264 b\u2264u u*\u2264xs)\n\nlemma-++*\u2264 : {b : Bound}{x : A}{xs ys : List A} \u2192 LeB b (val x) \u2192 b *\u2264 xs \u2192 (val x) *\u2264 ys \u2192 b *\u2264 (xs ++ (x \u2237 ys))\nlemma-++*\u2264 b\u2264u genx u*\u2264ys = gecx b\u2264u (lemma-*\u2264 b\u2264u u*\u2264ys)\nlemma-++*\u2264 b\u2264u (gecx b\u2264x b*\u2264xs) u*\u2264ys = gecx b\u2264x (lemma-++*\u2264 b\u2264u b*\u2264xs u*\u2264ys)\n", "meta": {"hexsha": "5aacdd88f68bdd9ae07d1da0a3d3d1944e17c4a9", "size": 1510, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 52.0689655172, "max_line_length": 122, "alphanum_fraction": 0.540397351, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087985746092, "lm_q2_score": 0.8128673246376009, "lm_q1q2_score": 0.754673176267352}}
{"text": "module trichotomy where\n\nopen import Relation.Binary.PropositionalEquality using (_\u2261_; refl)\nopen import Data.Nat using (\u2115; zero; suc)\nopen import Data.Sum using (_\u228e_; inj\u2081; inj\u2082)\nopen import Data.Product using (_\u00d7_) renaming (_,_ to \u27e8_,_\u27e9)\n\nopen import Negation using (\u00ac_; _\u2262_)\n\ninfix 4 _<_\ndata _<_ : \u2115 \u2192 \u2115 \u2192 Set where\n  z<s : \u2200 {n : \u2115}\n      ------------\n    \u2192 zero < suc n\n\n  s<s : \u2200 {m n : \u2115}\n    \u2192 m < n\n      -------------\n    \u2192 suc m < suc n\n\ninfix 4 _\u226e_\n_\u226e_ : \u2200 (m n : \u2115) \u2192 Set\nm \u226e n = \u00ac (m < n)\n\n-- 1 + m \u2261 1 + n \u306a\u3089\u3070 m \u2261 n\nsm\u2261sn\u2192m\u2261n : \u2200 {m n : \u2115} \u2192 suc m \u2261 suc n \u2192 m \u2261 n\nsm\u2261sn\u2192m\u2261n refl = refl\n\n-- m \u2262 n \u306a\u3089\u3070 1 + m \u2262 1 + n\nm\u2262n\u2192sm\u2262sn : \u2200 {m n : \u2115} \u2192 m \u2262 n \u2192 suc m \u2262 suc n\nm\u2262n\u2192sm\u2262sn m\u2262n = \u03bb{ sm\u2261sn \u2192 m\u2262n (sm\u2261sn\u2192m\u2261n sm\u2261sn) }\n\n-- m \u226e n \u306a\u3089\u3070 1 + m \u226e 1 + n\nm\u226en\u2192sm\u226esn : \u2200 {m n : \u2115} \u2192 m \u226e n \u2192 suc m \u226e suc n\nm\u226en\u2192sm\u226esn m\u226en = \u03bb{ (s<s m<n) \u2192 m\u226en m<n }\n\n-- \u4e09\u5206\u5f8b\u306e\u8a3c\u660e\ntrichotomy : \u2200 (m n : \u2115)\n  \u2192 (m < n \u00d7 m \u2262 n \u00d7 n \u226e m)\n  \u228e (m \u226e n \u00d7 m \u2261 n \u00d7 n \u226e m)\n  \u228e (m \u226e n \u00d7 m \u2262 n \u00d7 n < m)\ntrichotomy zero    zero                                              = inj\u2082 (inj\u2081 \u27e8 (\u03bb()) , \u27e8 refl , (\u03bb()) \u27e9 \u27e9)\ntrichotomy zero    (suc n)                                           = inj\u2081 \u27e8 z<s , \u27e8 (\u03bb()) , (\u03bb()) \u27e9 \u27e9\ntrichotomy (suc m) zero                                              = inj\u2082 (inj\u2082 \u27e8 (\u03bb()) , \u27e8 (\u03bb()) , z<s \u27e9 \u27e9)\ntrichotomy (suc m) (suc n) with trichotomy m n\n...                           | inj\u2081 \u27e8 m<n , \u27e8 m\u2262n , n\u226em \u27e9 \u27e9         = inj\u2081 \u27e8 s<s m<n , \u27e8 m\u2262n\u2192sm\u2262sn m\u2262n , m\u226en\u2192sm\u226esn n\u226em \u27e9 \u27e9\n...                           | inj\u2082 (inj\u2081 \u27e8 m\u226en , \u27e8 refl , n\u226em \u27e9 \u27e9) = inj\u2082 (inj\u2081 \u27e8 m\u226en\u2192sm\u226esn m\u226en , \u27e8 refl , m\u226en\u2192sm\u226esn n\u226em \u27e9 \u27e9)\n...                           | inj\u2082 (inj\u2082 \u27e8 m\u226en , \u27e8 m\u2262n , n<m \u27e9 \u27e9)  = inj\u2082 (inj\u2082 \u27e8 m\u226en\u2192sm\u226esn m\u226en , \u27e8 m\u2262n\u2192sm\u2262sn m\u2262n , s<s n<m \u27e9 \u27e9)\n", "meta": {"hexsha": "45cbab416bf929a3edc3491fc144937ae8a1cb82", "size": 1724, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "part1/negation/trichotomy.agda", "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_issues_repo_path": "part1/negation/trichotomy.agda", "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "part1/negation/trichotomy.agda", "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.1836734694, "max_line_length": 130, "alphanum_fraction": 0.4042923434, "num_tokens": 817, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9362850110816423, "lm_q2_score": 0.8056321889812553, "lm_q1q2_score": 0.7543013429880424}}
{"text": "\n{-  This example test that the order in which unification\n    constraints are generated doesn't matter. The pattern\n    matching in foo generates the unification problem\n      [x, zero] = [n + m, n]\n    with n and m flexible. The first equation can only be\n    solved after the second one has been solved. For completeness\n    we check that the other way around also works.\n-}\nmodule PostponedUnification where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\n_+_ : Nat -> Nat -> Nat\nzero  + m = m\nsuc n + m = suc (n + m)\n\ndata T : Nat -> Nat -> Set where\n  t  : (x : Nat) -> T x zero\n\nfoo : (n m : Nat) -> T (n + m) n -> Set\nfoo ._ ._ (t x) = Nat\n\ndata U : Nat -> Nat -> Set where\n  u  : (x : Nat) -> U zero x\n\nbar : (n m : Nat) -> U n (n + m) -> Set\nbar ._ ._ (u x) = Nat\n\n", "meta": {"hexsha": "d062795f2d3ea2daa3579a5fcdf5a2df2022a61a", "size": 783, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/Succeed/PostponedUnification.agda", "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/PostponedUnification.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/PostponedUnification.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "avg_line_length": 24.46875, "max_line_length": 65, "alphanum_fraction": 0.6002554278, "num_tokens": 250, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.933430805473952, "lm_q2_score": 0.8080672181749422, "lm_q1q2_score": 0.754274834338132}}
{"text": "module Ag04 where\n\ndata _\u2261_ {A : Set} (x : A) : A \u2192 Set where\n  refl : x \u2261 x\n\ninfix 4 _\u2261_\n\n\u2261-sym : \u2200 {A : Set} {x y : A} \u2192 x \u2261 y \u2192 y \u2261 x\n\u2261-sym refl = refl\n\n\ntrans : \u2200 {A : Set} {x y z : A} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\ntrans refl refl = refl\n\ncong : \u2200 {A B : Set} (f : A \u2192 B) {x y : A} \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\ncong\u2082 : \u2200 {A B C : Set} (f : A \u2192 B \u2192 C) {u x : A} {v y : B}\n  \u2192 u \u2261 x \u2192 v \u2261 y \u2192 f u v \u2261 f x y\ncong\u2082 f refl refl = refl\n\ncong-app : \u2200 {A B : Set} {f g : A \u2192 B} \u2192 f \u2261 g \u2192 \u2200 (x : A) \u2192 f x \u2261 g x\ncong-app refl x = refl\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + m = m\n(suc n) + m = suc (n + m)\n\npostulate\n  +-identity : \u2200 (m : \u2115) \u2192 m + zero \u2261 m\n  +-suc : \u2200 (m n : \u2115) \u2192 m + suc n \u2261 suc (m + n)\n  +-comm : \u2200 (m n : \u2115) \u2192 m + n \u2261 n + m\n\n_\u2250_ : \u2200 {A : Set} (x y : A) \u2192 Set\u2081\n_\u2250_ {A} x y = \u2200 (P : A \u2192 Set) \u2192 P x \u2192 P y\n\nrefl-\u2250 : \u2200 {A : Set} {x : A} \u2192 x \u2250 x\nrefl-\u2250 P Px = Px\n\ntrans-\u2250 : \u2200 {A : Set} {x y z : A} \u2192 x \u2250 y \u2192 y \u2250 z \u2192 x \u2250 z\ntrans-\u2250 x\u2250y y\u2250z P Px = y\u2250z P (x\u2250y P Px)\n\nsym-\u2250 : \u2200 {A : Set} {x y : A} \u2192 x \u2250 y \u2192 y \u2250 x\nsym-\u2250 {A} {x} {y} x\u2250y P = Qy\n  where\n    Q : A \u2192 Set\n    Q z = P z \u2192 P x\n    Qx : Q x\n    Qx = refl-\u2250 P\n    Qy : Q y\n    Qy = x\u2250y Q Qx\n\nsubst : \u2200 {A : Set} {x y : A} (P : A \u2192 Set)\n  \u2192 x \u2261 y\n    ---------\n  \u2192 P x \u2192 P y\nsubst P refl px = px\n\n\u2261-implies-\u2250 : \u2200 {A : Set} {x y : A} \u2192 x \u2261 y \u2192 x \u2250 y\n\u2261-implies-\u2250 x\u2261y P = subst P x\u2261y\n\n\u2250-implies-\u2261 : \u2200 {A : Set} {x y : A} \u2192 x \u2250 y \u2192 x \u2261 y\n\u2250-implies-\u2261 {A} {x} {y} x\u2250y = Qy\n  where\n    Q : A \u2192 Set\n    Q z = x \u2261 z\n    Qx : Q x\n    Qx = refl\n    Qy : Q y\n    Qy = x\u2250y Q Qx\n\nopen import Level using (Level; _\u2294_) renaming (zero to lzero; suc to lsuc)\n\ndata _\u2261'_ {\u2113 : Level} {A : Set \u2113} (x : A) : A \u2192 Set \u2113 where\n  refl' : x \u2261' x\n\n", "meta": {"hexsha": "671283ba42c7038557fc1ec8d9ad35a24adb4aad", "size": 1715, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Ag04.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Ag04.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Ag04.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 21.1728395062, "max_line_length": 74, "alphanum_fraction": 0.4139941691, "num_tokens": 900, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026482819236, "lm_q2_score": 0.822189134878876, "lm_q1q2_score": 0.7541962708130167}}
{"text": "module TerminationListInsertionNaive where\n\ndata List (A : Set) : Set where\n  [] : List A\n  _::_ : A -> List A -> List A\n\ninfixr 50 _::_\n\n-- non-deterministic choice\npostulate\n  _\u2295_ : {A : Set} -> A -> A -> A  \ninfixl 10 _\u2295_\n\n-- a funny formulation of insert\n-- insert (a :: l)  inserts a into l \n--\n-- this example cannot be handled with subpatterns\n-- it is done with structured orders\n-- could also be done with sized types\n\ninsert : {A : Set} -> List A -> List A\ninsert [] = []\ninsert (a :: []) = a :: []\ninsert (a :: b :: bs) = a :: b :: bs \u2295        -- case a <= b \n                        b :: insert (a :: bs) -- case a > b\n\n\n-- list flattening\n-- termination using structured orders\nflat : {A : Set} -> List (List A) -> List A\nflat [] = []\nflat ([] :: ll) = flat ll\nflat ((x :: l) :: ll) = x :: flat (l :: ll)\n\n{- generates two recursive calls with the following call matrices\n\n  \n      [] :: ll         (x :: l)   ll            \n                                       \n  ll  <            l   <          .          \n                   ll  .          =\n\nduring composition, the second is collapsed to =, so the call graph is\nalready complete.  Both matrices are idempotent and contain a strictly\ndecreasing argument.  \n\nIt could also be done with sized types; lexicographic in (i,j)\nwith type\n\n  flat : {A : Set} -> (1 + List\u02b2 A \u00d7 List^i (List^\u221e A)) -> List^\u221e A\n\n\n-}\n", "meta": {"hexsha": "2e258e4904583087ad01650a12c3bdc30b499544", "size": 1374, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.4444444444, "max_line_length": 70, "alphanum_fraction": 0.5349344978, "num_tokens": 394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9173026550642019, "lm_q2_score": 0.822189121808099, "lm_q1q2_score": 0.7541962643994737}}
{"text": "\nmodule Naturals where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\ninfixl 60 _+_\ninfixl 80 _*_\n\n_+_ : Nat -> Nat -> Nat\nzero  + m = m\nsuc n + m = suc (n + m)\n\n_*_ : Nat -> Nat -> Nat\nzero  * m = zero\nsuc n * m = m + n * m\n\n{-# BUILTIN NATURAL  Nat  #-}\n{-# BUILTIN ZERO     zero #-}\n{-# BUILTIN SUC      suc  #-}\n{-# BUILTIN NATPLUS  _+_  #-}\n{-# BUILTIN NATTIMES _*_  #-}\n", "meta": {"hexsha": "8f4174eb590c0e79741d3b7a20625a278e88d9e5", "size": 385, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/HelloAgda/Naturals.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/AIM6/HelloAgda/Naturals.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM6/HelloAgda/Naturals.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.0416666667, "max_line_length": 29, "alphanum_fraction": 0.5272727273, "num_tokens": 142, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9539660923657094, "lm_q2_score": 0.79053032607222, "lm_q1q2_score": 0.7541391260597058}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Data.Quiver where\n\n-- A Quiver, also known as a multidigraph, is the \"underlying graph\" of\n-- a category. Note how a Quiver has a *setoid* of edges.\n\nopen import Level\nopen import Relation.Binary using (Rel; IsEquivalence; Setoid)\nimport Relation.Binary.Reasoning.Setoid as EqR\n\n-- a Quiver has vertices Obj and edges _\u21d2_, where edges form a setoid over _\u2248_.\nrecord Quiver o \u2113 e : Set (suc (o \u2294 \u2113 \u2294 e)) where\n  infix 4 _\u2248_ _\u21d2_\n\n  field\n    Obj   : Set o\n    _\u21d2_   : Rel Obj \u2113\n    _\u2248_   : \u2200 {A B} \u2192 Rel (A \u21d2 B) e\n    equiv : \u2200 {A B} \u2192 IsEquivalence (_\u2248_ {A} {B})\n\n  setoid : {A B : Obj} \u2192 Setoid _ _\n  setoid {A} {B} = record\n    { Carrier       = A \u21d2 B\n    ; _\u2248_           = _\u2248_\n    ; isEquivalence = equiv\n    }\n\n  module Equiv {A B : Obj} = IsEquivalence (equiv {A} {B})\n  module EdgeReasoning {A B : Obj} = EqR (setoid {A} {B})\n", "meta": {"hexsha": "3d262a18d164c441c2b1be348ecbf528128f7a4b", "size": 874, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Quiver.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Data/Quiver.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Data/Quiver.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 28.1935483871, "max_line_length": 79, "alphanum_fraction": 0.6018306636, "num_tokens": 316, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9304582554941718, "lm_q2_score": 0.8104789018037399, "lm_q1q2_score": 0.7541167850871401}}
{"text": "{-# OPTIONS --sized-types #-}\nopen import Relation.Binary.Core\n\nmodule SelectSort  {A : Set}\n                  (_\u2264_ : A \u2192 A \u2192 Set)\n                  (tot\u2264 : Total _\u2264_) where\n\nopen import Data.List\nopen import Data.Product\nopen import Data.Sum\nopen import Size\nopen import SList\nopen import SList.Order _\u2264_\n\nselect : {\u03b9 : Size} \u2192 A \u2192  SList A {\u03b9} \u2192 A \u00d7 SList A {\u03b9}\nselect x snil = (x , snil)\nselect x (y \u2219 ys) \n    with tot\u2264 x y\n... | inj\u2081 x\u2264y \n    with select x ys \nselect x (y \u2219 ys) | inj\u2081 x\u2264y  | (z , zs) = (z , y \u2219 zs)\nselect x (y \u2219 ys) | inj\u2082 y\u2264x \n    with select y ys\nselect x (y \u2219 ys) | inj\u2082 y\u2264x | (z , zs) = (z , x \u2219 zs) \n\nselectSort : {\u03b9 : Size} \u2192 SList A {\u03b9} \u2192 SList A {\u03b9}\nselectSort snil = snil\nselectSort (x \u2219 xs) \n    with select x xs\n... | (y , ys) = y \u2219 (selectSort ys)\n", "meta": {"hexsha": "ce2bfa5f1dd162215019bea1130537f74663d5d0", "size": 784, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/SelectSort.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/SelectSort.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/SelectSort.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2903225806, "max_line_length": 56, "alphanum_fraction": 0.5599489796, "num_tokens": 294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9504109770159683, "lm_q2_score": 0.7931059585194573, "lm_q1q2_score": 0.7537766089136635}}
{"text": "module Data.Nat.Extra where\n\nopen import Data.Nat\nopen import Data.Bool\n\nisZero : \u2115 \u2192 Bool\nisZero 0 = true\nisZero (suc _) = false\n", "meta": {"hexsha": "40af58dd8e2eabc63adbc5f03de4707eeb1f7fd0", "size": 130, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/Nat/Extra.agda", "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Data/Nat/Extra.agda", "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Data/Nat/Extra.agda", "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 14.4444444444, "max_line_length": 27, "alphanum_fraction": 0.7307692308, "num_tokens": 42, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9504109728022221, "lm_q2_score": 0.793105953629227, "lm_q1q2_score": 0.7537766009239877}}
{"text": "\nmodule Vec where\n\nopen import Star\nopen import Nat\n\ndata Step (A : Set) : Nat -> Nat -> Set where\n  step : (x : A){n : Nat} -> Step A (suc n) n\n\nVec : (A : Set) -> Nat -> Set\nVec A n = Star (Step A) n zero\n\n[] : {A : Set} -> Vec A zero\n[] = \u03b5\n\n_::_ : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n)\nx :: xs = step x \u2022 xs\n\n_+++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m)\n_+++_ {A}{m = m} xs ys = map +m step+m xs ++ ys\n  where\n    +m = \\z -> z + m\n    step+m : Step A =[ +m ]=> Step A\n    step+m (step x) = step x\n\nvec : {A : Set}{n : Nat} -> A -> Vec A n\nvec {n = \u03b5}     x = []\nvec {n = _ \u2022 n} x = x :: vec x\n\n_\u2297_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n\n\u03b5             \u2297 \u03b5             = []\n(step f \u2022 fs) \u2297 (step x \u2022 xs) = f x :: (fs \u2297 xs)\n\u03b5             \u2297 (() \u2022 _)\n\n{- Some proof about _-_ needed...\n\nvreverse : {A : Set}{n : Nat} -> Vec A n -> Vec A n\nvreverse {A}{n} xs = {! !} -- map i f (reverse xs)\n  where\n    i : Nat -> Nat\n    i m = n - m\n\n    f : Step A op =[ i ]=> Step A\n    f (step x) = {! !} -- step x\n-}", "meta": {"hexsha": "2585f460b73926fc88d2a8519873e79b08b54ddc", "size": 1063, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/AIM6/Path/Vec.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/AIM6/Path/Vec.agda", "max_issues_repo_name": "masondesu/agda", "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/AIM6/Path/Vec.agda", "max_forks_repo_name": "masondesu/agda", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6222222222, "max_line_length": 67, "alphanum_fraction": 0.4289746002, "num_tokens": 427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465170505204, "lm_q2_score": 0.8056321913146128, "lm_q1q2_score": 0.7535452641699016}}
{"text": "module Relation.Relation where\n\nopen import Level renaming (suc to lsuc)\nopen import Data.Product\n\n-- Partial equivalence relations.\nrecord ParRel {l l' : Level}{A : Set l}(R : A \u2192 A \u2192 Set l') : Set (l \u2294 l') where\n  field\n    symPf   : \u2200{x y} \u2192 R x y \u2192 R y x\n    transPf : \u2200{x y z} \u2192 R x y \u2192 R y z \u2192 R x z\n\n-- (Total) equivalence relation. \nrecord EqRel {l l' : Level}{A : Set l}(R : A \u2192 A \u2192 Set l') : Set (l \u2294 l') where\n  field\n    parEqPf : ParRel R\n    refPf   : \u2200{x} \u2192 R x x\n\nopen ParRel public\nopen EqRel public\n\n-- The product of two relations.\nProductRel : {l l' : Level}{A : Set l}{B : Set l'} \n  \u2192 (R : A \u2192 A \u2192 Set l) \n  \u2192 (R' : B \u2192 B \u2192 Set l') \n  \u2192 (A \u00d7 B \u2192 A \u00d7 B \u2192 Set (l \u2294 l'))\nProductRel R R' a b = (R (proj\u2081 a) (proj\u2081 b)) \u00d7 (R' (proj\u2082 a) (proj\u2082 b))\n\n-- The product of two partial equivalence relations is also a partial\n-- equivalence relation.\nProductRelIsParRel : {l l' : Level}{A : Set l}{B : Set l'} \n  \u2192 (R : A \u2192 A \u2192 Set l) \n  \u2192 (R' : B \u2192 B \u2192 Set l') \n  \u2192 ParRel R\n  \u2192 ParRel R'\n  \u2192 ParRel (ProductRel R R')\nProductRelIsParRel R R' erPF\u2081 erPF\u2082 = \n  record { symPf   = \u03bb x\u2081 \u2192 symPf erPF\u2081 (proj\u2081 x\u2081) , symPf erPF\u2082 (proj\u2082 x\u2081); \n           transPf = \u03bb x\u2081 x\u2082 \u2192 (transPf erPF\u2081 (proj\u2081 x\u2081) (proj\u2081 x\u2082)) , (transPf erPF\u2082 (proj\u2082 x\u2081) (proj\u2082 x\u2082)) }\n\n-- The product of two (total) equivalence relations is also a (total)\n-- equivalence relation.\nProductRelIsEqRel : {l l' : Level}{A : Set l}{B : Set l'} \n  \u2192 (R : A \u2192 A \u2192 Set l) \n  \u2192 (R' : B \u2192 B \u2192 Set l') \n  \u2192 EqRel R\n  \u2192 EqRel R'\n  \u2192 EqRel (ProductRel R R')\nProductRelIsEqRel R R' erPF\u2081 erPF\u2082 = \n  record { parEqPf = ProductRelIsParRel R R' (parEqPf erPF\u2081) (parEqPf erPF\u2082); \n           refPf   = \u03bb {x} \u2192 (refPf erPF\u2081 {proj\u2081 x}) , (refPf erPF\u2082 {proj\u2082 x}) }\n\n-- The restriction of a relation by a predicate.\n_\u2193_ : {l l' : Level}\n      {A : Set l} \n    \u2192 (R : A \u2192 A \u2192 Set l) \n    \u2192 (P : A \u2192 Set l') \n    \u2192 Set (l \u2294 l')\n_\u2193_ {A = A} R P = \u03a3[ f \u2208 A ] (P f)\n\n-- The restriction of a paritial equivalence is also a partial\n-- equivalence.\n\u2193ParRel : {l l' : Level}\n          {A : Set l} \n        \u2192 (R : A \u2192 A \u2192 Set l) \n        \u2192 (P : A \u2192 Set l') \n        \u2192 ParRel R\n        \u2192 ParRel (\u03bb (f g : R \u2193 P) \u2192 R (proj\u2081 f) (proj\u2081 g))\n\u2193ParRel R P prPF = record { symPf = \u03bb x\u2081 \u2192 symPf prPF x\u2081; transPf = \u03bb x\u2081 x\u2082 \u2192 transPf prPF x\u2081 x\u2082 }\n\n-- The restriction of an equivalence relation is also an equivalence\n-- relation.\n\u2193EqRel : {l l' : Level}\n         {A : Set l} \n       \u2192 (R : A \u2192 A \u2192 Set l) \n       \u2192 (P : A \u2192 Set l') \n       \u2192 EqRel R\n       \u2192 EqRel (\u03bb (f g : R \u2193 P) \u2192 R (proj\u2081 f) (proj\u2081 g))\n\u2193EqRel R P eqrPF = record { parEqPf = \u2193ParRel R P (parEqPf eqrPF); refPf = refPf eqrPF }\n", "meta": {"hexsha": "78fbd97ac608303b619e98dbaf6660cf030c7ac1", "size": 2621, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "setoid-cats/Relation/Relation.agda", "max_stars_repo_name": "heades/AUGL", "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "setoid-cats/Relation/Relation.agda", "max_issues_repo_name": "heades/AUGL", "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "setoid-cats/Relation/Relation.agda", "max_forks_repo_name": "heades/AUGL", "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1772151899, "max_line_length": 110, "alphanum_fraction": 0.550553224, "num_tokens": 1023, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797148356995, "lm_q2_score": 0.8267117940706734, "lm_q1q2_score": 0.7532830167726258}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nopen import Categories.Category\n\nmodule Categories.Diagram.Equalizer.Properties {o \u2113 e} (C : Category o \u2113 e) where\n\nopen import Categories.Diagram.Equalizer C\nopen import Categories.Morphism C\nopen import Categories.Morphism.Reasoning C\n\nprivate\n  module C = Category C\n  open C\n\n  variable\n    X Y Z : Obj\n    f g : X \u21d2 Y\n\nmodule _ (equalizer : Equalizer f g) where\n  open Equalizer equalizer\n  open HomReasoning\n\n  equalizer-\u2248\u21d2\u2248 : \u2200 {h} \u2192 arr \u2218 h \u2248 id \u2192 f \u2248 g\n  equalizer-\u2248\u21d2\u2248 {h} eq = begin\n    f             \u2248\u27e8 intro\u02b3 eq \u27e9\n    f \u2218 arr \u2218 h   \u2248\u27e8 pull\u02e1 equality \u27e9\n    (g \u2218 arr) \u2218 h \u2248\u27e8 cancel\u02b3 eq \u27e9\n    g             \u220e\n\nsection-equalizer : \u2200 {X Y} {f : Y \u21d2 X} {g : X \u21d2 Y} \u2192 f SectionOf g \u2192 IsEqualizer f (f \u2218 g) id\nsection-equalizer {X = X} {Y = Y} {f = f} {g = g} g\u2218f\u2248id = record\n  { equality = equality\n  ; equalize = equalize\n  ; universal = \u03bb {_} {_} {eq} \u2192 universal {eq = eq}\n  ; unique = unique\n  }\n  where\n    open HomReasoning\n\n    equality : (f \u2218 g) \u2218 f \u2248 id \u2218 f\n    equality = begin\n      (f \u2218 g) \u2218 f \u2248\u27e8 pull\u02b3 g\u2218f\u2248id \u27e9\n      f \u2218 id      \u2248\u27e8 id-comm \u27e9\n      id \u2218 f      \u220e\n\n    equalize : \u2200 {Z} {h : Z \u21d2 X} \u2192 (f \u2218 g) \u2218 h \u2248 id \u2218 h \u2192 Z \u21d2 Y \n    equalize {h = h} _ = g \u2218 h\n\n    universal : \u2200 {Z} {h : Z \u21d2 X} {eq : (f \u2218 g) \u2218 h \u2248 id \u2218 h} \u2192 h \u2248 f \u2218 g \u2218 h\n    universal {h = h} {eq = eq} = begin\n      h           \u2248\u02d8\u27e8 identity\u02e1 \u27e9\n      id \u2218 h      \u2248\u02d8\u27e8 eq \u27e9\n      (f \u2218 g) \u2218 h \u2248\u27e8 assoc \u27e9\n      f \u2218 g \u2218 h   \u220e\n\n    unique : \u2200 {Z} {h : Z \u21d2 X} {i : Z \u21d2 Y} \u2192 h \u2248 f \u2218 i \u2192 i \u2248 g \u2218 h\n    unique {h = h} {i = i} h\u2248g\u2218i = begin\n      i           \u2248\u27e8 intro\u02e1 g\u2218f\u2248id \u27e9\n      (g \u2218 f) \u2218 i \u2248\u27e8 pull\u02b3 (\u27fa h\u2248g\u2218i) \u27e9\n      g \u2218 h       \u220e\n", "meta": {"hexsha": "301c2131654ace3b2c9bb83fea497455df3fbb01", "size": 1647, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Diagram/Equalizer/Properties.agda", "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Diagram/Equalizer/Properties.agda", "max_issues_repo_name": "maxsnew/agda-categories", "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Diagram/Equalizer/Properties.agda", "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.0, "max_line_length": 94, "alphanum_fraction": 0.4851244687, "num_tokens": 722, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797027760039, "lm_q2_score": 0.8267117876664789, "lm_q1q2_score": 0.7532830009673611}}
{"text": "------------------------------------------------------------------------\n-- The Agda standard library\n--\n-- Coinductive \"natural\" numbers\n------------------------------------------------------------------------\n\nmodule Data.Conat where\n\nopen import Coinduction\nopen import Data.Nat using (\u2115; zero; suc)\nopen import Relation.Binary\n\n------------------------------------------------------------------------\n-- The type\n\ndata Co\u2115 : Set where\n  zero : Co\u2115\n  suc  : (n : \u221e Co\u2115) \u2192 Co\u2115\n\n------------------------------------------------------------------------\n-- Some operations\n\nfrom\u2115 : \u2115 \u2192 Co\u2115\nfrom\u2115 zero    = zero\nfrom\u2115 (suc n) = suc (\u266f from\u2115 n)\n\n\u221e\u2115 : Co\u2115\n\u221e\u2115 = suc (\u266f \u221e\u2115)\n\ninfixl 6 _+_\n\n_+_ : Co\u2115 \u2192 Co\u2115 \u2192 Co\u2115\nzero  + n = n\nsuc m + n = suc (\u266f (\u266d m + n))\n\n------------------------------------------------------------------------\n-- Equality\n\ndata _\u2248_ : Co\u2115 \u2192 Co\u2115 \u2192 Set where\n  zero :                                 zero  \u2248 zero\n  suc  : \u2200 {m n} (m\u2248n : \u221e (\u266d m \u2248 \u266d n)) \u2192 suc m \u2248 suc n\n\nsetoid : Setoid _ _\nsetoid = record\n  { Carrier       = Co\u2115\n  ; _\u2248_           = _\u2248_\n  ; isEquivalence = record\n    { refl  = refl\n    ; sym   = sym\n    ; trans = trans\n    }\n  }\n  where\n  refl : Reflexive _\u2248_\n  refl {zero}  = zero\n  refl {suc n} = suc (\u266f refl)\n\n  sym : Symmetric _\u2248_\n  sym zero      = zero\n  sym (suc m\u2248n) = suc (\u266f sym (\u266d m\u2248n))\n\n  trans : Transitive _\u2248_\n  trans zero      zero      = zero\n  trans (suc m\u2248n) (suc n\u2248k) = suc (\u266f trans (\u266d m\u2248n) (\u266d n\u2248k))\n", "meta": {"hexsha": "185e892390ce8b46d5a343286bffdfc5cc843fdf", "size": 1445, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Conat.agda", "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Conat.agda", "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Conat.agda", "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.2307692308, "max_line_length": 72, "alphanum_fraction": 0.3937716263, "num_tokens": 468, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897525789547, "lm_q2_score": 0.8006919949619792, "lm_q1q2_score": 0.75328282383223}}
{"text": "module 010-false-true where\n\n-- In Agda, types are theorems, and instances of types are proofs. The\n-- simplest theorem is the theorem which has no proof, and is useful\n-- to represent any contradictory situation. We declare False as an\n-- algebraic data type without constructors. If \"False\" has no\n-- constructors, then it also has no instances, and thereby perfectly\n-- serves our purpose.  Note that what we call here \"False\" is also\n-- sometimes also called bottom and is denoted by \u22a5.\n\ndata False : Set where\n\n-- The next simplest theorem is the trivial theorem which is always\n-- true. We declare it as an algebraic data type \"True\", with one\n-- constructor named \"trivial\".\n\ndata True : Set where\n  trivial : True\n", "meta": {"hexsha": "16614eee8cbdc71d71e5accfe0a94b010beb8d36", "size": 722, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "010-false-true.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "010-false-true.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "010-false-true.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.0, "max_line_length": 70, "alphanum_fraction": 0.7506925208, "num_tokens": 172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9591542887603537, "lm_q2_score": 0.785308578375437, "lm_q1q2_score": 0.7532320909490967}}
{"text": "module Numeral.Natural.Oper.FlooredDivision where\n\nimport Lvl\nopen import Data\nopen import Data.Boolean.Stmt\nopen import Logic.Propositional.Theorems\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper.Comparisons\nopen import Numeral.Natural.Oper.Comparisons.Proofs\nopen import Numeral.Natural.Relation.Order\nopen import Relator.Equals\n\ninfixl 10100 _\u230a/\u230b_\n\n-- Inductive definition of an algorithm for division.\n-- `[ d , b ] a' div b'` should be interpreted as following:\n--   `d` is the result of the algorithm that is being incremented as it runs.\n--   `b` is the predecessor of the original denominator. This is constant throughout the whole process.\n--   `a'` is the numerator. This is decremented as it runs.\n--   `b'` is the predecessor of the temporary denominator. This is decremented as it runs.\n-- By decrementing both `a'` and `b'`, and incrementing `d` when 'b`' reaches 0, it counts how many times `b` \"fits into\" `a`. \n-- Note: See Numeral.Natural.Oper.Modulo for a similiar algorithm used to determine the modulo.\n[_,_]_div_ : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 \u2115\n[ d , _ ] \ud835\udfce     div _     = d\n[ d , b ] \ud835\udc12(a') div \ud835\udfce     = [ \ud835\udc12(d) , b ] a' div b\n[ d , b ] \ud835\udc12(a') div \ud835\udc12(b') = [ d   , b ] a' div b'\n{-# BUILTIN NATDIVSUCAUX [_,_]_div_ #-}\n\n-- Floored division operation.\n_\u230a/\u230b_ : \u2115 \u2192 (m : \u2115) \u2192 .\u2983 _ : IsTrue(positive?(m)) \u2984 \u2192 \u2115\na \u230a/\u230b \ud835\udc12(m) = [ \ud835\udfce , m ] a div m\n\n_\u230a/\u230b\u2080_ : \u2115 \u2192 \u2115 \u2192 \u2115\n_ \u230a/\u230b\u2080 \ud835\udfce    = \ud835\udfce\na \u230a/\u230b\u2080 \ud835\udc12(m) = a \u230a/\u230b \ud835\udc12(m)\n{-# INLINE _\u230a/\u230b\u2080_ #-}\n", "meta": {"hexsha": "520841b7d5d06549b07ff7c2f5b25b4be908a75d", "size": 1441, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Oper/FlooredDivision.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.9459459459, "max_line_length": 127, "alphanum_fraction": 0.6592643997, "num_tokens": 532, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802350995702, "lm_q2_score": 0.8198933293122507, "lm_q1q2_score": 0.7530558178632853}}
{"text": "\nopen import Oscar.Prelude\nopen import Oscar.Class.Symmetry\nopen import Oscar.Class.Symmetrical\nimport Oscar.Data.Proposequality\n\nmodule Oscar.Class.Symmetrical.Symmetry where\n\nmodule _\n    {\ud835\udd2c} {\ud835\udd12 : \u00d8 \ud835\udd2c}\n    {\u2113} {_\u223c_ : \ud835\udd12 \u2192 \ud835\udd12 \u2192 \u00d8 \u2113}\n    \u2983 _ : Symmetry.class _\u223c_ \u2984\n  where\n\n  instance\n\n    Symmetrical\ud835\udce2ymmetry : Symmetrical _\u223c_ (\u03bb x\u223cy y\u223cx \u2192 x\u223cy \u2192 y\u223cx)\n    Symmetrical\ud835\udce2ymmetry .\ud835\udce2ymmetrical.symmetrical _ _ = symmetry\n", "meta": {"hexsha": "018866b9818becc3dc626aa9a9f476b01d04e9dc", "size": 414, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": ["RSA-MD"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_licenses": ["RSA-MD"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical/Symmetry.agda", "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": ["RSA-MD"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.7894736842, "max_line_length": 65, "alphanum_fraction": 0.6980676329, "num_tokens": 161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.934395157060208, "lm_q2_score": 0.805632181981183, "lm_q1q2_score": 0.7527788092150656}}
{"text": "Extensionality of a function of two arguments\n\n\\begin{code}\nextensionality2 : \u2200 {A B C : Set} \u2192 {f g : A \u2192 B \u2192 C} \u2192 (\u2200 (x : A) (y : B) \u2192 f x y \u2261 g x y) \u2192 f \u2261 g\nextensionality2 fxy\u2261gxy = extensionality (\u03bb x \u2192 extensionality (\u03bb y \u2192 fxy\u2261gxy x y))\n\\end{code}\n\nIsomorphism of all and exists.\n\\begin{code}\n\u00ac\u2203\u2200 : \u2200 {A : Set} {B : A \u2192 Set} \u2192 (\u00ac \u2203 (\u03bb (x : A) \u2192 B x)) \u2243 \u2200 (x : A) \u2192 \u00ac B x\n\u00ac\u2203\u2200 =\n  record\n    { to   =  \u03bb { \u00ac\u2203bx x bx \u2192 \u00ac\u2203bx (x , bx) }\n    ; fro  =  \u03bb { \u2200\u00acbx (x , bx) \u2192 \u2200\u00acbx x bx }\n    ; inv\u02e1 =  \u03bb { \u00ac\u2203bx \u2192 extensionality (\u03bb { (x , bx) \u2192 refl }) } \n    ; inv\u02b3 =  \u03bb { \u2200\u00acbx \u2192 refl } \n    }\n\\end{code}\n", "meta": {"hexsha": "c19bfe4ee0d44fbd5f928515486eddccedd81070", "size": 602, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "extra/extra/Isomorphisms.agda", "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 1003, "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_issues_repo_path": "extra/extra/Isomorphisms.agda", "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 323, "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_forks_repo_path": "extra/extra/Isomorphisms.agda", "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": 304, "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "avg_line_length": 31.6842105263, "max_line_length": 99, "alphanum_fraction": 0.4750830565, "num_tokens": 272, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.945801267121407, "lm_q2_score": 0.7956581073313275, "lm_q1q2_score": 0.75253444610939}}
{"text": "------------------------------------------------------------------------------\n-- Inductive PA arithmetic properties using Agsy\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\n-- Tested with the development version of the Agda standard library on\n-- 02 February 2012.\n\nmodule Agsy.PA.Inductive.Properties where\n\nopen import Data.Nat renaming ( suc to succ )\n\nopen import Relation.Binary.PropositionalEquality\nopen \u2261-Reasoning\n\n------------------------------------------------------------------------------\n\n+-rightIdentity : \u2200 n \u2192 n + zero \u2261 n  -- via Agsy {-c}\n+-rightIdentity zero     = refl\n+-rightIdentity (succ n) = cong succ (+-rightIdentity n)\n\n+-assoc : \u2200 m n o \u2192 m + n + o \u2261 m + (n + o)  -- via Agsy {-c}\n+-assoc zero     n o = refl\n+-assoc (succ m) n o = cong succ (+-assoc m n o)\n\nx+Sy\u2261S[x+y] : \u2200 m n \u2192 m + succ n \u2261 succ (m + n)  -- via Agsy {-c}\nx+Sy\u2261S[x+y] zero     n = refl\nx+Sy\u2261S[x+y] (succ m) n = cong succ (x+Sy\u2261S[x+y] m n)\n\n+-comm : \u2200 m n \u2192 m + n \u2261 n + m  -- via Agsy {-c -m}\n+-comm zero    n = sym (+-rightIdentity n)\n+-comm (succ m) n =\n  begin\n    succ (m + n) \u2261\u27e8 cong succ (+-comm m n) \u27e9\n    succ (n + m) \u2261\u27e8 sym (x+Sy\u2261S[x+y] n m) \u27e9\n    n + succ m\n  \u220e\n", "meta": {"hexsha": "31eb389fd2228102386c8345f88a758f1c696bbc", "size": 1378, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/Agsy/PA/Inductive/Properties.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/Agsy/PA/Inductive/Properties.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/Agsy/PA/Inductive/Properties.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 32.8095238095, "max_line_length": 78, "alphanum_fraction": 0.469521045, "num_tokens": 398, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8104789109591832, "lm_q1q2_score": 0.7524557487828178}}
{"text": "{-# OPTIONS --safe --without-K #-}\nopen import Relation.Binary\n\nmodule Data.List.Membership.Setoid.Disjoint {a p} (S : Setoid a p) where\nopen Setoid S renaming (Carrier to A)\nopen import Data.List using (List ; [])\nopen import Data.List.Membership.Setoid (S)\nopen import Data.List.Membership.Setoid.Trans (S)\nopen import Data.Empty\n\nopen import Function\n\n\nDisjoint : Rel (List A) _\nDisjoint xs ys = \u2200 {x} \u2192 x \u2208 xs \u2192 x \u2208 ys \u2192 \u22a5  \n\ndisjoint-sym : Symmetric Disjoint\ndisjoint-sym dis = flip dis\n\ndisjoint-[]\u02e1 : \u2200 {xs} \u2192 Disjoint xs []\ndisjoint-[]\u02e1 _ ()\n\ndisjoint-[]\u02b3 :  \u2200 {xs} \u2192 Disjoint [] xs\ndisjoint-[]\u02b3 ()\n\ndisjointness : \u2200 {xs ys} \u2192 Disjoint xs ys \u2192 \u2200 {x} \u2192 x \u2208 xs \u2192 \u2200 {y} \u2192 y \u2208 ys \u2192 x \u2248 y \u2192 \u22a5\ndisjointness xs\u22c8ys x\u2208xs y\u2208ys x\u2248y = xs\u22c8ys x\u2208xs (\u2248-trans-\u2208 x\u2248y y\u2208ys)\n\n", "meta": {"hexsha": "0ab83deeeb5ed638f202aa5b66b205b50250fdf4", "size": 764, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_stars_repo_name": "tizmd/agda-distinct-disjoint", "max_stars_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_issues_repo_name": "tizmd/agda-distinct-disjoint", "max_issues_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_forks_repo_name": "tizmd/agda-distinct-disjoint", "max_forks_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.3448275862, "max_line_length": 87, "alphanum_fraction": 0.6413612565, "num_tokens": 273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067211996142, "lm_q2_score": 0.7981867753392728, "lm_q1q2_score": 0.7522964005299111}}
{"text": "\nmodule Nat where\n\ndata Nat : Set where\n  zero : Nat\n  suc  : Nat -> Nat\n\ninfixl 60 _+_\ninfixl 70 _*_\n\n_+_ : Nat -> Nat -> Nat\nn + zero  = n\nn + suc m = suc (n + m)\n\n_*_ : Nat -> Nat -> Nat\nn * zero  = zero\nn * suc m = n * m + n\n\n{-# BUILTIN NATURAL Nat #-}\n{-# BUILTIN ZERO zero #-}\n{-# BUILTIN SUC suc #-}\n{-# BUILTIN NATPLUS _+_ #-}\n{-# BUILTIN NATTIMES _*_ #-}\n\n", "meta": {"hexsha": "394e2db5441f0949210c19f84c81268cdb42dfc1", "size": 366, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "examples/SummerSchool07/Lecture/Nat.agda", "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_issues_repo_path": "examples/SummerSchool07/Lecture/Nat.agda", "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/SummerSchool07/Lecture/Nat.agda", "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.64, "max_line_length": 28, "alphanum_fraction": 0.5409836066, "num_tokens": 131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9579122696813394, "lm_q2_score": 0.7853085758631159, "lm_q1q2_score": 0.7522567203052576}}
{"text": "open import Preliminaries\nopen import Preorder\n\nmodule PreorderExamples where\n\n-- there is a preorder on Unit\n\n  unit-p : Preorder Unit\n  unit-p = preorder (preorder-structure (\u03bb x x\u2081 \u2192 Unit) (\u03bb x \u2192 <>) (\u03bb x y z _ _ \u2192 <>))\n\n-- there is a preorder on Nat\n\n  _\u2264n_ : Nat \u2192 Nat \u2192 Set\n  _\u2264n_ Z Z = Unit\n  _\u2264n_ Z (S n) = Unit\n  _\u2264n_ (S m) Z = Void\n  _\u2264n_ (S m) (S n) = m \u2264n n\n\n  nat-refl : \u2200 (n : Nat) \u2192 n \u2264n n\n  nat-refl Z = <>\n  nat-refl (S n) = nat-refl n\n\n  nat-trans : \u2200 (m n p : Nat) \u2192 m \u2264n n \u2192 n \u2264n p \u2192 m \u2264n p\n  nat-trans Z Z Z x x\u2081 = <>\n  nat-trans Z Z (S p) x x\u2081 = <>\n  nat-trans Z (S n) Z x x\u2081 = <>\n  nat-trans Z (S n) (S p) x x\u2081 = <>\n  nat-trans (S m) Z Z () x\u2081\n  nat-trans (S m) Z (S p) () x\u2081\n  nat-trans (S m) (S n) Z x ()\n  nat-trans (S m) (S n) (S p) x x\u2081 = nat-trans m n p x x\u2081\n\n  nat-p : Preorder Nat\n  nat-p = preorder (preorder-structure (\u03bb m n \u2192 m \u2264n n) nat-refl nat-trans)\n", "meta": {"hexsha": "9c4eba6653e981781a3f0c829b3e52e226ca36e9", "size": 888, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "complexity-drafts/PreorderExamples.agda", "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_issues_repo_path": "complexity-drafts/PreorderExamples.agda", "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_forks_repo_path": "complexity-drafts/PreorderExamples.agda", "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3714285714, "max_line_length": 86, "alphanum_fraction": 0.5472972973, "num_tokens": 374, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.951142221377825, "lm_q2_score": 0.7905303186696748, "lm_q1q2_score": 0.7519067633659944}}
{"text": "module Extensions.VecFirst where\n\nopen import Data.Vec\nopen import Data.Product\nopen import Level\nopen import Relation.Nullary\nopen import Function using (_\u2218_; _$_)\n\n-- proof that an element is the first in a vector to satisfy the predicate B\ndata First {a b} {A : Set a} (B : A \u2192 Set b) : \u2200 {n} (x : A) \u2192 Vec A n \u2192 Set (a \u2294 b) where\n\n  here  : \u2200 {n} {x : A} \u2192 (p : B x) \u2192 (v : Vec A n) \u2192 First B x (x \u2237 v)\n  there : \u2200 {n x} {v : Vec A n} (x' : A) \u2192 \u00ac (B x') \u2192 First B x v \u2192 First B x (x' \u2237 v)\n\n-- more likable syntax for the above structure\nfirst_\u2208_\u21d4_ : \u2200 {n} {A : Set} \u2192 A \u2192 Vec A n \u2192 (B : A \u2192 Set) \u2192 Set \nfirst_\u2208_\u21d4_ x v p = First p x v\n\n-- a decision procedure to find the first element in a vector that satisfies a predicate\nfind : \u2200 {n} {A : Set} (P : A \u2192 Set) \u2192 ((a : A) \u2192 Dec (P a)) \u2192 (v : Vec A n) \u2192 \n       Dec (\u2203 \u03bb e \u2192 first e \u2208 v \u21d4 P)\nfind P dec [] = no (\u03bb{ (e , ()) })\nfind P dec (x \u2237 v) with dec x\nfind P dec (x \u2237 v) | yes px = yes (x , here px v)\nfind P dec (x \u2237 v) | no \u00acpx with find P dec v\nfind P dec (x \u2237 v) | no \u00acpx | yes firstv = yes (, there x \u00acpx (proj\u2082 firstv))\nfind P dec (x \u2237 v) | no \u00acpx | no \u00acfirstv = no $ helper \u00acpx \u00acfirstv\n  where\n    helper : \u00ac (P x) \u2192 \u00ac (\u2203 \u03bb e \u2192 First P e v) \u2192 \u00ac (\u2203 \u03bb e \u2192 First P e (x \u2237 v))\n    helper \u00acpx \u00acfirstv (.x , here p .v) = \u00acpx p\n    helper \u00acpx \u00acfirstv (u  , there ._ _ firstv) = \u00acfirstv (u , firstv)\n", "meta": {"hexsha": "36b25545000f38577fb2afaccd7fcb988b4be313", "size": 1358, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Extensions/VecFirst.agda", "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_issues_repo_path": "src/Extensions/VecFirst.agda", "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_forks_repo_path": "src/Extensions/VecFirst.agda", "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "avg_line_length": 42.4375, "max_line_length": 90, "alphanum_fraction": 0.5530191458, "num_tokens": 529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582574225517, "lm_q2_score": 0.8080672066194945, "lm_q1q2_score": 0.7518728049514839}}
{"text": "module x03-842Relations-hc where\n\n-- Library\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; cong; sym) -- added sym\nopen import Data.Nat using (\u2115; zero; suc; _+_)\nopen import Data.Nat.Properties using (+-comm)\n\n-- The less-than-or-equal-to relation.\n\ndata _\u2264_ : \u2115 \u2192 \u2115 \u2192 Set where\n\n  z\u2264n : \u2200 {n : \u2115}\n      --------\n    \u2192 zero \u2264 n\n\n  s\u2264s : \u2200 {m n : \u2115}\n    \u2192 m \u2264 n\n      -------------\n    \u2192 suc m \u2264 suc n\n\n-- Some examples.\n\n_ : 2 \u2264 4 -- can do just by refine\n_ = s\u2264s (s\u2264s z\u2264n)\n\n_ : 2 \u2264 4 -- with implicit args\n_ = s\u2264s {1} {3} (s\u2264s {0} {2} z\u2264n)\n\n_ : 2 \u2264 4 -- with named implicit args\n_ = s\u2264s {m = 1} {n = 3} (s\u2264s {m = 0} {n = 2} z\u2264n)\n\n_ : 2 \u2264 4 -- with some implicit named args\n_ = s\u2264s {n = 3} (s\u2264s {m = 0} z\u2264n)\n\ninfix 4 _\u2264_\n\n-- Inversion.\n\ninv-s\u2264s : \u2200 {m n : \u2115}\n  \u2192 suc m \u2264 suc n\n    -------------\n  \u2192 m \u2264 n\n\ninv-s\u2264s (s\u2264s x) = x\n\ninv-z\u2264n : \u2200 {m : \u2115}\n  \u2192 m \u2264 zero\n    --------\n  \u2192 m \u2261 zero\n\ninv-z\u2264n z\u2264n = refl\n\n-- Properties.\n\n-- Reflexivity.\n\n\u2264-refl : \u2200 {n : \u2115}\n    -----\n  \u2192 n \u2264 n\n\n\u2264-refl {zero} = z\u2264n\n\u2264-refl {suc n} = s\u2264s (\u2264-refl {n})\n\n-- Transitivity.\n\n\u2264-trans : \u2200 {m n p : \u2115} -- note implicit arguments\n  \u2192 m \u2264 n\n  \u2192 n \u2264 p\n    -----\n  \u2192 m \u2264 p\n\n\u2264-trans z\u2264n n\u2264p = z\u2264n\n\u2264-trans (s\u2264s m\u2264n) (s\u2264s n\u2264p) = s\u2264s (\u2264-trans m\u2264n n\u2264p)\n\n\u2264-trans\u2032 : \u2200 (m n p : \u2115) -- without implicit arguments\n  \u2192 m \u2264 n\n  \u2192 n \u2264 p\n    -----\n  \u2192 m \u2264 p\n\n\u2264-trans\u2032 .0 _ _ z\u2264n n\u2264p = z\u2264n\n\u2264-trans\u2032 (suc m) (suc n) (suc p) (s\u2264s m\u2264n) (s\u2264s n\u2264p) = s\u2264s (\u2264-trans\u2032 m n p m\u2264n n\u2264p)\n\n-- Antisymmetry.\n\n\u2264-antisym : \u2200 {m n : \u2115}\n  \u2192 m \u2264 n\n  \u2192 n \u2264 m\n    -----\n  \u2192 m \u2261 n\n\n\u2264-antisym z\u2264n z\u2264n = refl\n\u2264-antisym (s\u2264s m\u2264n) (s\u2264s n\u2264m) rewrite \u2264-antisym m\u2264n n\u2264m = refl\n\n-- Total ordering.\n\n-- A definition with parameters.\n\ndata Total (m n : \u2115) : Set where\n\n  forward :\n      m \u2264 n\n      ---------\n    \u2192 Total m n\n\n  flipped :\n      n \u2264 m\n      ---------\n    \u2192 Total m n\n\n-- An equivalent definition without parameters.\n\ndata Total\u2032 : \u2115 \u2192 \u2115 \u2192 Set where\n\n  forward\u2032 : \u2200 {m n : \u2115}\n    \u2192 m \u2264 n\n      ----------\n    \u2192 Total\u2032 m n\n\n  flipped\u2032 : \u2200 {m n : \u2115}\n    \u2192 n \u2264 m\n      ----------\n    \u2192 Total\u2032 m n\n\n-- Showing that \u2264 is a total order.\n\n\u2264-total : \u2200 (m n : \u2115) \u2192 Total m n -- introducing with clause\n\u2264-total zero n = forward z\u2264n\n\u2264-total (suc m) zero = flipped z\u2264n\n\u2264-total (suc m) (suc n) with \u2264-total m n\n... | forward x = forward (s\u2264s x)\n... | flipped x = flipped (s\u2264s x)\n\n\u2264-total\u2032 : \u2200 (m n : \u2115) \u2192 Total m n -- with helper function and where\n\u2264-total\u2032 zero n = forward z\u2264n\n\u2264-total\u2032 (suc m) zero = flipped z\u2264n\n\u2264-total\u2032 (suc m) (suc n) = helper (\u2264-total m n)\n  where\n    helper : Total m n \u2192 Total (suc m) (suc n)\n    helper (forward x) = forward (s\u2264s x)\n    helper (flipped x) = flipped (s\u2264s x)\n\n-- Splitting on n first gives different code (see PLFA or try it yourself).\n\n-- Monotonicity.\n\n+-mono\u02b3-\u2264 : \u2200 (m p q : \u2115)\n  \u2192 p \u2264 q\n    -------------\n  \u2192 m + p \u2264 m + q\n\n+-mono\u02b3-\u2264 zero p q p\u2264q = p\u2264q -- split on m\n+-mono\u02b3-\u2264 (suc m) p q p\u2264q = s\u2264s (+-mono\u02b3-\u2264 m p q p\u2264q) -- refine, recurse\n\n+-mono\u02e1-\u2264 : \u2200 (m n p : \u2115)\n  \u2192 m \u2264 n\n    -------------\n  \u2192 m + p \u2264 n + p\n\n+-mono\u02e1-\u2264 m n p m\u2264n rewrite +-comm m p | +-comm n p = +-mono\u02b3-\u2264 p m n m\u2264n -- use commutativity\n\n+-mono-\u2264 : \u2200 (m n p q : \u2115) -- combine above\n  \u2192 m \u2264 n\n  \u2192 p \u2264 q\n    -------------\n  \u2192 m + p \u2264 n + q\n\n+-mono-\u2264 m n p q m\u2264n p\u2264q = \u2264-trans (+-mono\u02b3-\u2264 m p q p\u2264q ) (+-mono\u02e1-\u2264 m n q m\u2264n)\n\n-- PLFA exercise: show *-mono-\u2264.\n\n-- Strict inequality.\n\ninfix 4 _<_\n\ndata _<_ : \u2115 \u2192 \u2115 \u2192 Set where\n\n  z<s : \u2200 {n : \u2115}\n      ------------\n    \u2192 zero < suc n\n\n  s<s : \u2200 {m n : \u2115}\n    \u2192 m < n\n      -------------\n    \u2192 suc m < suc n\n\n-- 842 exercise: LTTrans (1 point)\n-- Prove that < is transitive.\n-- Order of arguments changed from PLFA, to match \u2264-trans.\n\n<-trans : \u2200 {m n p : \u2115} \u2192 m < n \u2192 n < p \u2192 m < p -- TODO\n<-trans m<n n<p = {!!}\n\n-- 842 exercise: Trichotomy (2 points)\n-- Prove that either m < n, m \u2261 n, or m > n for all m and n.\n\ndata Trichotomy (m n : \u2115) : Set where\n  is-< : m < n \u2192 Trichotomy m n\n  is-\u2261 : m \u2261 n \u2192 Trichotomy m n\n  is-> : n < m \u2192 Trichotomy m n\n\n<-trichotomy : \u2200 (m n : \u2115) \u2192 Trichotomy m n -- TODO\n<-trichotomy m n = {!!}\n\n-- PLFA exercise: show +-mono-<.\n\n-- Prove that suc m \u2264 n implies m < n, and conversely,\n-- and do the same for (m \u2264 n) and (m < suc n).\n-- Hint: if you do the proofs in the order below, you can avoid induction\n-- for two of the four proofs.\n\n-- 842 exercise: LEtoLTS (1 point)\n\n\u2264-<-to : \u2200 {m n : \u2115} \u2192 m \u2264 n \u2192 m < suc n -- TODO\n\u2264-<-to m\u2264n = {!!}\n\n-- 842 exercise: LEStoLT (1 point)\n\n\u2264-<--to\u2032 : \u2200 {m n : \u2115} \u2192 suc m \u2264 n \u2192 m < n -- TODO\n\u2264-<--to\u2032 sm\u2264n = {!!}\n\n-- 842 exercise: LTtoSLE (1 point)\n\n\u2264-<-from : \u2200 {m n : \u2115} \u2192 m < n \u2192 suc m \u2264 n -- TODO\n\u2264-<-from m<n = {!!}\n\n-- 842 exercise: LTStoLE (1 point)\n\n\u2264-<-from\u2032 : \u2200 {m n : \u2115} \u2192 m < suc n \u2192 m \u2264 n -- TODO\n\u2264-<-from\u2032 m<sn = {!!}\n\n-- PLFA exercise: use the above to give a proof of <-trans that uses \u2264-trans. -- TODO\n\n-- Mutually recursive datatypes.\n-- Specify the types first, then give the definitions.\n\ndata even : \u2115 \u2192 Set\ndata odd  : \u2115 \u2192 Set\n\ndata even where\n\n  zero :\n      ---------\n      even zero\n\n  suc  : \u2200 {n : \u2115}\n    \u2192 odd n\n      ------------\n    \u2192 even (suc n)\n\ndata odd where\n\n  suc   : \u2200 {n : \u2115}\n    \u2192 even n\n      -----------\n    \u2192 odd (suc n)\n\n-- Theorems about these datatypes.\n-- The proofs are also mutually recursive.\n-- So we give the types first, then the implementations.\n\ne+e\u2261e : \u2200 {m n : \u2115}\n  \u2192 even m\n  \u2192 even n\n    ------------\n  \u2192 even (m + n)\n\no+e\u2261o : \u2200 {m n : \u2115}\n  \u2192 odd m\n  \u2192 even n\n    -----------\n  \u2192 odd (m + n)\n\ne+e\u2261e zero en = en\ne+e\u2261e (suc x) en = suc (o+e\u2261o x en)\n\no+e\u2261o (suc x) en = suc (e+e\u2261e x en)\n\n-- 842 exercise: OPOE (2 points)\n-- Prove that the sum of two odds is even.\n-- Hint: You will need to define another theorem and prove both\n--       by mutual induction, as with the theorems above.\n\no+o\u2261e : \u2200 {m n : \u2115} \u2192 odd m \u2192 odd n \u2192 even (m + n) -- TODO\no+o\u2261e om on = {!!}\n\n-- For remarks on which of these definitions are in the standard library, see PLFA.\n\n-- Here is the new Unicode used in this file.\n\n{-\n\n\u2264  U+2264  LESS-THAN OR EQUAL TO (\\<=, \\le)\n\u2265  U+2265  GREATER-THAN OR EQUAL TO (\\>=, \\ge)\n\u02e1  U+02E1  MODIFIER LETTER SMALL L (\\^l)\n\u02b3  U+02B3  MODIFIER LETTER SMALL R (\\^r)\n\n-}\n", "meta": {"hexsha": "a31d4d9a19ccd032e707c92b769a353b16ed4d31", "size": 6119, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03-842Relations-hc.agda", "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03-842Relations-hc.agda", "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x03-842Relations-hc.agda", "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "avg_line_length": 20.3289036545, "max_line_length": 94, "alphanum_fraction": 0.5066187286, "num_tokens": 2510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587993853654, "lm_q2_score": 0.8459424411924673, "lm_q1q2_score": 0.7518387883833423}}
{"text": "open import Data.Nat\nopen import Data.Nat.Show\nopen import IO\n\nmodule Ackermann where\n\nack : \u2115 -> \u2115 -> \u2115\nack zero n = n + 1\nack (suc m) zero = ack m 1\nack (suc m) (suc n) = ack m (ack (suc m) n)\n\nmain = run (putStrLn (show (ack 3 9)))\n", "meta": {"hexsha": "1528a75ff43c67a44eaae7745ecdc7d4a6865ec2", "size": 235, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Task/Ackermann-function/Agda/ackermann-function-1.agda", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Ackermann-function/Agda/ackermann-function-1.agda", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Ackermann-function/Agda/ackermann-function-1.agda", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 18.0769230769, "max_line_length": 43, "alphanum_fraction": 0.6340425532, "num_tokens": 90, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9603611620335328, "lm_q2_score": 0.7826624738835051, "lm_q1q2_score": 0.7516386428988024}}
{"text": "module natThms where\r\n\r\nopen import lib\r\n\r\n-- this function divides a natural number by 2, dropping any remainder\r\ndiv2 : \u2115 \u2192 \u2115\r\ndiv2 0 = 0\r\ndiv2 1 = 0\r\ndiv2 (suc (suc x)) = suc (div2 x)\r\n\r\ndiv2-double : \u2200(x : \u2115) \u2192 (div2 (x * 2)) \u2261 x\r\ndiv2-double zero = refl\r\ndiv2-double (suc x) rewrite div2-double (x)  = refl\r\n\r\n{- Hint: consider the same cases as in the definition of div2: 0, 1, (suc (suc x)).\r\n   The case for 1 is impossible, so you can just drop that case or use the \r\n   absurd pattern for the proof of is-even 1 \u2261 tt. -}\r\ndiv2-even : \u2200(x : \u2115) \u2192 is-even x \u2261 tt \u2192 div2 x \u2261 div2 (suc x)\r\ndiv2-even zero x = refl\r\ndiv2-even (suc (suc x))y rewrite div2-even x y = refl\r\n\r\n-- same hint as for div2-even, except now the 0 case is impossible\r\ndiv2-odd : \u2200(x : \u2115) \u2192 is-odd x \u2261 tt \u2192 div2 (suc x) \u2261 suc (div2 x)\r\ndiv2-odd (suc(suc x))y rewrite div2-odd x y = refl\r\ndiv2-odd (suc zero) y  = refl\r\n\r\n{- hint: do *not* do induction on x.  Look at the definitions of square and pow. \r\n   There are lemmas about multiplication in the IAL that will help you (nat-thms.agda). -}\r\nsquare-square : \u2200(x : \u2115) \u2192 square (square x) \u2261 x pow 4\r\nsquare-square x rewrite *1{x} | *assoc x x ( x * x )  = refl\r\n", "meta": {"hexsha": "b20cc2db270bf8c39040895da8d67a33b3a3c6df", "size": 1190, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "natThms.agda", "max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_stars_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "natThms.agda", "max_issues_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_issues_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "natThms.agda", "max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_forks_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3870967742, "max_line_length": 91, "alphanum_fraction": 0.6361344538, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9219218262741297, "lm_q2_score": 0.8152324826183822, "lm_q1q2_score": 0.7515806192135316}}
{"text": "module Numeral.Natural.Sequence where\n\nimport      Lvl\nopen import Data\nopen import Data.Either as Either using (_\u2016_)\nopen import Data.Tuple as Tuple using (_\u2a2f_ ; _,_)\nimport      Data.Tuple.Raise as Tuple\nopen import Functional\nopen import Numeral.Natural\nopen import Numeral.Natural.Oper\nopen import Numeral.Natural.Oper.FlooredDivision\nopen import Type\n\nprivate variable \u2113 \u2113\u2081 \u2113\u2082 : Lvl.Level\nprivate variable n : \u2115\nprivate variable A : Type{\u2113}\nprivate variable B : Type{\u2113}\n\n-- Alternates between the two sides, starting with the left.\n-- A countable bijection for the Either type.\n-- Examples:\n--   alternate\u2082(0) = Left(0)\n--   alternate\u2082(2) = Left(1)\n--   alternate\u2082(4) = Left(2)\n--   alternate\u2082(6) = Left(3)\n\n--   alternate\u2082(1) = Right(0)\n--   alternate\u2082(3) = Right(1)\n--   alternate\u2082(5) = Right(2)\n--   alternate\u2082(7) = Right(3)\nalternate\u2082 : \u2115 \u2192 (\u2115 \u2016 \u2115)\nalternate\u2082(0)       = Either.Left 0\nalternate\u2082(1)       = Either.Right 0\nalternate\u2082(\ud835\udc12(\ud835\udc12(n))) = Either.map \ud835\udc12 \ud835\udc12 (alternate\u2082 n)\n\n-- The inverse of `alternate\u2082`.\nunalternate\u2082 : (\u2115 \u2016 \u2115) \u2192 \u2115\nunalternate\u2082(Either.Left  n) = n \u22c5 2\nunalternate\u2082(Either.Right n) = \ud835\udc12(n \u22c5 2)\n\n-- Maps two natural numbers to a single one without overlaps by following the inverse diagonals downwards.\n-- A countable bijection for the tuple pairing type.\n-- Alternative forms:\n--   pairIndexing a b = a + (\u2211(\ud835\udd5f(a + b)) (i \u21a6 \ud835\udd5f-to-\u2115(i)))\n--   pairIndexing a b = a + ((a + b) * (a + b + 1) / 2)\n-- Example:\n--   Horizontal axis is `a` starting from 0.\n--   Vertical axis is `b` starting from 0.\n--   Cells are `pairIndexing a b`.\n--    0, 1, 3, 6,10,15\n--    2, 4, 7,11,16,..\n--    5, 8,12,17,   ..\n--    9,13,18,      ..\n--   14,19,         ..\n--   20,.. .. .. .. ..\n-- Termination:\n--   Decreases `a` until 0 while at the same time increases `b` (So `b` is at most `a`).\n--   Then the arguments is swapped, but using the predecessor of `b`.\n--   This means that `b` will eventually reach 0.\n{-# TERMINATING #-}\npairIndexing : \u2115 \u2192 \u2115 \u2192 \u2115\npairIndexing \ud835\udfce     \ud835\udfce     = \ud835\udfce\npairIndexing (\ud835\udc12 a) \ud835\udfce     = \ud835\udc12(pairIndexing \ud835\udfce a)\n{-# CATCHALL #-}\npairIndexing a     (\ud835\udc12 b) = \ud835\udc12(pairIndexing (\ud835\udc12 a) b)\n\n-- A sequence which fills a discrete two dimensional grid (a space bounded in two directions and infinite in the other two).\n-- It is the inverse of an uncurried `pairIndexing`.\n-- Example:\n--   \u2022-\u2192-\u2022 \u2197\u2192\u2022 \u2197\u2192\u2022\n--     \u2199 \u2197 \u2199 \u2197 \u2199\n--   \u2022\u2192\u2197 \u2022 \u2197 \u2022   \u2022\n--     \u2199 \u2197 \u2199\n--   \u2022\u2192\u2197 \u2022   \u2022   \u2022\ndiagonalFilling : \u2115 \u2192 (\u2115 \u2a2f \u2115)\ndiagonalFilling \ud835\udfce      = (\ud835\udfce , \ud835\udfce)\ndiagonalFilling (\ud835\udc12(n)) with diagonalFilling n\n... | (\ud835\udfce    , b) = (\ud835\udc12(b) , 0)\n... | (\ud835\udc12(a) , b) = (a , \ud835\udc12(b))\n\ntupleIndexing : (\u2115 Tuple.^ n) \u2192 \u2115\ntupleIndexing {\ud835\udfce}       <>      = \ud835\udfce\ntupleIndexing {\ud835\udc12(\ud835\udfce)}    x       = x\ntupleIndexing {\ud835\udc12(\ud835\udc12(n))} (x , y) = pairIndexing x (tupleIndexing {\ud835\udc12(n)} y)\n\nspaceFilling : \u2115 \u2192 (\u2115 Tuple.^ n)\nspaceFilling {\ud835\udfce}          _ = <>\nspaceFilling {\ud835\udc12(\ud835\udfce)}       i = i\nspaceFilling {\ud835\udc12(\ud835\udc12(n))}    i = Tuple.mapRight (spaceFilling {\ud835\udc12(n)}) (diagonalFilling i)\n\n\n-- Interleaves two sequences into one, alternating between the elements from each sequence.\ninterleave : (\u2115 \u2192 A) \u2192 (\u2115 \u2192 B) \u2192 (\u2115 \u2192 (A \u2016 B))\ninterleave af bf = Either.map af bf \u2218 alternate\u2082\n\npair : (\u2115 \u2192 A) \u2192 (\u2115 \u2192 B) \u2192 (\u2115 \u2192 (A \u2a2f B))\npair af bf = Tuple.map af bf \u2218 diagonalFilling\n", "meta": {"hexsha": "0d80a72c3e331c3d1ecefcfb36b263056abfbb00", "size": 3197, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Numeral/Natural/Sequence.agda", "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_issues_repo_path": "Numeral/Natural/Sequence.agda", "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Numeral/Natural/Sequence.agda", "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.6224489796, "max_line_length": 124, "alphanum_fraction": 0.6111979981, "num_tokens": 1206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9111797027760038, "lm_q2_score": 0.8244619242200082, "lm_q1q2_score": 0.7512329710609192}}
{"text": "{-# OPTIONS --safe --without-K #-}\n------------------------------------------------------------------------\n-- Group objects in a cartesian category.\n------------------------------------------------------------------------\n\nopen import Categories.Category\nopen import Categories.Category.Cartesian\n\nmodule Categories.Object.Group {o \u2113 e} {\ud835\udc9e : Category o \u2113 e} (C : Cartesian \ud835\udc9e) where\n\nopen import Level\n\nopen import Categories.Category.BinaryProducts \ud835\udc9e using (BinaryProducts)\nopen import Categories.Category.Cartesian.Monoidal\nopen import Categories.Object.Monoid (CartesianMonoidal.monoidal C)\nopen import Categories.Object.Terminal \ud835\udc9e\n\nopen Category \ud835\udc9e\nopen Cartesian C\nmodule \u03a0 = BinaryProducts products\nopen BinaryProducts products using (_\u00d7_; _\u2042_; \u27e8_,_\u27e9)\nopen Terminal terminal\n\nrecord IsGroup (G : Obj) : Set (\u2113 \u2294 e) where\n  -- any group object is also a monoid object\n  field\n    isMonoid : IsMonoid G\n\n  open IsMonoid isMonoid public\n       \n  field\n    -- inverse operation\n    \u03b9 : G \u21d2 G\n    -- \u03b9 is in fact an inverse\n    inverse\u02e1 : \u03b7 \u2218 ! \u2248 \u03bc \u2218 \u27e8 \u03b9 , id \u27e9\n    inverse\u02b3 : \u03b7 \u2218 ! \u2248 \u03bc \u2218 \u27e8 id , \u03b9 \u27e9\n\nrecord Group : Set (o \u2294 \u2113 \u2294 e) where\n  field\n    Carrier : Obj\n    isGroup : IsGroup Carrier\n\n  open IsGroup isGroup public\n\n  monoid : Monoid\n  monoid = record { isMonoid = isMonoid }\n\nopen Group\n\nrecord Group\u21d2 (G H : Group) : Set (\u2113 \u2294 e) where\n  field\n    arr : Carrier G \u21d2 Carrier H\n    preserves-\u03bc : arr \u2218 \u03bc G \u2248 \u03bc H \u2218 (arr \u2042 arr)\n    preserves-\u03b7 : arr \u2218 \u03b7 G \u2248 \u03b7 H\n    preserves-\u03b9 : arr \u2218 \u03b9 G \u2248 \u03b9 H \u2218 arr\n", "meta": {"hexsha": "b575714821a88ff4a856f51c632e6b83972e0539", "size": 1510, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Object/Group.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_issues_repo_path": "src/Categories/Object/Group.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Object/Group.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.9642857143, "max_line_length": 83, "alphanum_fraction": 0.6099337748, "num_tokens": 438, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533069832973, "lm_q2_score": 0.8056321866478979, "lm_q1q2_score": 0.7512143966520175}}
{"text": "{-# OPTIONS --without-K --exact-split --safe #-}\n\nmodule Fragment.Extensions.CSemigroup.Nat where\n\nopen import Relation.Binary.PropositionalEquality as PE using (_\u2261_)\n\ndata \u2115\u207a : Set where\n  one : \u2115\u207a\n  suc : \u2115\u207a \u2192 \u2115\u207a\n\ninfixl 6 _+_\n\n_+_ : \u2115\u207a \u2192 \u2115\u207a \u2192 \u2115\u207a\none   + x = suc x\nsuc x + y = suc (x + y)\n\n+-suc : \u2200 x y \u2192 x + suc y \u2261 suc (x + y)\n+-suc one     y = PE.refl\n+-suc (suc x) y = PE.cong suc (+-suc x y)\n\n+-one : \u2200 x \u2192 x + one \u2261 suc x\n+-one one     = PE.refl\n+-one (suc x) = PE.cong suc (+-one x)\n\n+-assoc : \u2200 x y z \u2192 (x + y) + z \u2261 x + (y + z)\n+-assoc one     _ _ = PE.refl\n+-assoc (suc x) y z = PE.cong suc (+-assoc x y z)\n\nopen PE.\u2261-Reasoning\n\n+-comm : \u2200 x y \u2192 x + y \u2261 y + x\n+-comm one one     = PE.refl\n+-comm one (suc y) = begin\n    one + (suc y) \u2261\u27e8\u27e9\n    suc (suc y)   \u2261\u27e8 PE.sym (PE.cong suc (+-one y)) \u27e9\n    suc (y + one) \u2261\u27e8 PE.sym PE.refl \u27e9\n    suc y + one   \u220e\n+-comm (suc x) y = begin\n    suc x + y     \u2261\u27e8\u27e9\n    suc (x + y)   \u2261\u27e8 PE.cong suc (+-comm x y) \u27e9\n    suc (y + x)   \u2261\u27e8 PE.sym (+-suc y x) \u27e9\n    y + suc x     \u220e\n", "meta": {"hexsha": "3cd6e613007cc05b2011f3e033aafb3d259b6eef", "size": 1020, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Fragment/Extensions/CSemigroup/Nat.agda", "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_issues_repo_path": "src/Fragment/Extensions/CSemigroup/Nat.agda", "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_forks_repo_path": "src/Fragment/Extensions/CSemigroup/Nat.agda", "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "avg_line_length": 23.7209302326, "max_line_length": 67, "alphanum_fraction": 0.4960784314, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9324533088603708, "lm_q2_score": 0.8056321796478255, "lm_q1q2_score": 0.7512143916370075}}
{"text": "{-# OPTIONS --without-K --safe #-}\nmodule Categories.Category.Unbundled where\n\n-- This is basically identical to Category, except that the\n-- Obj type is a parameter rather than a field.\n\nopen import Level\nopen import Function.Base using (flip)\n\nopen import Relation.Binary using (Rel; IsEquivalence)\n\nrecord Category {o : Level} (Obj : Set o) (\u2113 e : Level) : Set (suc (o \u2294 \u2113 \u2294 e)) where\n  eta-equality\n  infix  4 _\u2248_ _\u21d2_\n  infixr 9 _\u2218_\n\n  field\n    _\u21d2_ : Rel Obj \u2113\n    _\u2248_ : \u2200 {A B} \u2192 Rel (A \u21d2 B) e\n\n    id  : \u2200 {A} \u2192 (A \u21d2 A)\n    _\u2218_ : \u2200 {A B C} \u2192 (B \u21d2 C) \u2192 (A \u21d2 B) \u2192 (A \u21d2 C)\n\n  field\n    assoc     : \u2200 {A B C D} {f : A \u21d2 B} {g : B \u21d2 C} {h : C \u21d2 D} \u2192 (h \u2218 g) \u2218 f \u2248 h \u2218 (g \u2218 f)\n    -- We add a symmetric proof of associativity so that the opposite category of the\n    -- opposite category is definitionally equal to the original category. See how\n    -- `op` is implemented.\n    sym-assoc : \u2200 {A B C D} {f : A \u21d2 B} {g : B \u21d2 C} {h : C \u21d2 D} \u2192 h \u2218 (g \u2218 f) \u2248 (h \u2218 g) \u2218 f\n    identity\u02e1 : \u2200 {A B} {f : A \u21d2 B} \u2192 id \u2218 f \u2248 f\n    identity\u02b3 : \u2200 {A B} {f : A \u21d2 B} \u2192 f \u2218 id \u2248 f\n    -- We add a proof of \"neutral\" identity proof, in order to ensure the opposite of\n    -- constant functor is definitionally equal to itself.\n    identity\u00b2 : \u2200 {A} \u2192 id \u2218 id {A} \u2248 id {A}\n    equiv     : \u2200 {A B} \u2192 IsEquivalence (_\u2248_ {A} {B})\n    \u2218-resp-\u2248  : \u2200 {A B C} {f h : B \u21d2 C} {g i : A \u21d2 B} \u2192 f \u2248 h \u2192 g \u2248 i \u2192 f \u2218 g \u2248 h \u2218 i\n", "meta": {"hexsha": "8db4dbb7a5d5a729d9d02d49ca0e4c2c6d05cc34", "size": 1395, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Unbundled.agda", "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 279, "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_issues_repo_path": "src/Categories/Category/Unbundled.agda", "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 236, "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_forks_repo_path": "src/Categories/Category/Unbundled.agda", "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 64, "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "avg_line_length": 37.7027027027, "max_line_length": 91, "alphanum_fraction": 0.5405017921, "num_tokens": 544, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8774767874818408, "lm_q2_score": 0.8558511414521923, "lm_q1q2_score": 0.7509895101641362}}
{"text": "{-# OPTIONS --safe #-}\nmodule Mod where\n\nopen import Data.Fin\nopen import Data.Nat as \u2115\n  using (\u2115; zero; suc; z\u2264n; s\u2264s)\nopen import Relation.Binary.PropositionalEquality\nopen import Function\n\nprivate variable k : \u2115\n\nlast : Fin (suc k)\nlast {k = zero} = zero\nlast {k = suc _} = suc last\n\nnegate : Fin k -> Fin k\nnegate zero = zero\nnegate (suc zero) = last\nnegate (suc (suc n)) = inject\u2081 (negate (suc n))\n\nsubt : Fin k -> Fin k -> Fin k\nsubt n zero = n\nsubt zero (suc m) = negate (suc m)\nsubt (suc n) (suc m) with (compare n m)\n...| less _ _ = suc (subt n m)\n...| _ = inject\u2081 (subt n m)\n\nadd : Fin k -> Fin k -> Fin k\nadd n m = subt n (negate m)\n\nmultAux : \u2200{n} \u2192 \u2115 \u2192 (Fin n \u2192 Fin n) \u2192 Fin n \u2192 Fin n\nmultAux zero _ x = x\nmultAux (suc n) f x = multAux n f (f x)\n\nmult : Fin k -> Fin k -> Fin k\nmult zero m = zero\nmult (suc n) m = multAux (to\u2115 n) (add m) zero\n\nzer : Fin 5\nzer = zero\none : Fin 5\none = suc zero\ntwo : Fin 5\ntwo = suc (suc zero)\nthree : Fin 5\nthree = suc (suc (suc zero))\nfour : Fin 5\nfour = suc (suc (suc (suc zero)))\n", "meta": {"hexsha": "6ec124d5df04db871970d00ac8c8f2f46aeb620f", "size": 1031, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Agda/Mod.agda", "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_issues_repo_path": "Agda/Mod.agda", "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Agda/Mod.agda", "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "avg_line_length": 21.0408163265, "max_line_length": 52, "alphanum_fraction": 0.6149369544, "num_tokens": 396, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9407897442783527, "lm_q2_score": 0.7981867705385763, "lm_q1q2_score": 0.7509259277413515}}
{"text": "{-# OPTIONS --without-K --safe #-}\n\nmodule Categories.Category.Finite where\n\nopen import Level\nopen import Data.Nat using (\u2115)\nopen import Data.Fin\n\nopen import Categories.Adjoint.Equivalence\nopen import Categories.Category\nopen import Categories.Functor\nopen import Categories.Category.Finite.Fin\n\n-- definition of a finite category\n-- \n-- the idea is to require a functor from C to a category generated from a finite shape\n-- is the right adjoint.\n--\n-- Question: it seems to me right adjoint is enough, though the original plan is to\n-- use adjoint equivalence. intuitively, the shape category is an \"overapproximation\"\n-- of C, which is a very strong constraint. so requiring adjoint equivalence sounds an\n-- unnecessarily stronger constraint. is adjoint equivalence necessary?\n--\n-- Answer: probably yes. adjoint equivalence seems necessary as the notion needs to\n-- show that shapes are preserved.\n--\n-- c.f. Categories.Adjoint.Equivalence.Properties.\u22a3equiv-preserves-diagram\nrecord Finite {o \u2113 e} (C : Category o \u2113 e) : Set (o \u2294 \u2113 \u2294 e) where\n  field\n    shape : FinCatShape\n\n  open FinCatShape public renaming (size to \u2223Obj\u2223)\n\n  shapeCat : Category _ _ _\n  shapeCat = FinCategory shape\n\n  --\n  --   /------------\\\n  --  <      -       \\\n  -- C       |        S\n  --  \\      -       ^\n  --   \\------------/\n  --\n  field\n    \u22a3equiv : \u22a3Equivalence shapeCat C\n\n  module \u22a3equiv = \u22a3Equivalence \u22a3equiv\n  open \u22a3equiv public\n", "meta": {"hexsha": "6c9900f47a9f1b17a5414ffd4bf56a06b9cd9378", "size": 1422, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/Categories/Category/Finite.agda", "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Categories/Category/Finite.agda", "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Categories/Category/Finite.agda", "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.0204081633, "max_line_length": 86, "alphanum_fraction": 0.688466948, "num_tokens": 367, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037221561136, "lm_q2_score": 0.8104789155369047, "lm_q1q2_score": 0.7507496361908852}}
{"text": "module 020-equivalence where\n\n-- We need False to represent logical contradiction.\n\nopen import 010-false-true\n\n-- Next, we need to be able to work with equalities. Equalities are\n-- defined between objects of the same type. Two objects are equal if\n-- we have a proof of their equality. In Agda, we can represent this\n-- by means of a function which takes two instances of some type M,\n-- and maps this to a proof of equality.\n\n-- To be a reasonable model for equality, we demand that this function\n-- has the properties of an equivalence relation: (i) we must have a\n-- proof that every object r in M equals itself, (ii) given a proof\n-- that r == s, we must be able to prove that s == r, and (iii) given\n-- proofs of r == s and s == t, we must be able to prove that r == t.\n\n-- A convenient way to store all these properties, goes by means of a\n-- record, which is in essence a local parametrised module, where the\n-- parameters and fields correspond to postulates (theorems that can\n-- be stated without proof), and declarations are theorems derived\n-- from parameters and fields. A good question is, what should be a\n-- parameter, and what should be a field? Fields can be considered as\n-- named parameters, so probably anything that would otherwise not be\n-- obvious without name should go into a field.\n\n-- Here we declare the type and equality function (which maps pairs of\n-- elements to proofs) as parameters, and the equivalence axioms as\n-- fields. The parameter M is optional because it can be derived\n-- unambiguously from the type signature of the equality function.\n\nrecord Equivalence\n  {M : Set}\n  (_==_ : M -> M -> Set)\n  : Set1 where\n\n  {- axioms -}\n  field\n    refl : \u2200 {r} -> (r == r)\n    symm : \u2200 {r s} -> (r == s) -> (s == r)\n    trans : \u2200 {r s t} -> (r == s) -> (s == t) -> (r == t)\n\n  -- We have a proof of inequality if we can prove contradiction from\n  -- equality, and this is precisely how we define the inequality\n  -- relation.\n\n  _!=_ : M -> M -> Set\n  m != n = (m == n) -> False\n\n  -- Prove transitivity chains.\n  -- (TODO: Use a type dependent function for these chains.)\n  trans3 : \u2200 {r s t u}\n           -> (r == s) -> (s == t) -> (t == u) -> (r == u)\n  trans3 p1 p2 p3 = trans (trans p1 p2) p3\n  trans4 : \u2200 {r s t u v}\n           -> (r == s) -> (s == t) -> (t == u) -> (u == v) -> (r == v)\n  trans4 p1 p2 p3 p4 = trans (trans3 p1 p2 p3) p4\n  trans5 : \u2200 {r s t u v w}\n           -> (r == s) -> (s == t) -> (t == u) -> (u == v) -> (v == w)\n           -> (r == w)\n  trans5 p1 p2 p3 p4 p5 = trans (trans4 p1 p2 p3 p4) p5\n  trans6 : \u2200 {r s t u v w x}\n           -> (r == s) -> (s == t) -> (t == u) -> (u == v) -> (v == w)\n           -> (w == x) -> (r == x)\n  trans6 p1 p2 p3 p4 p5 p6 = trans (trans5 p1 p2 p3 p4 p5) p6\n\n-- Now we construct a trivial model of equivalence: two instances of a\n-- type are equivalent if they reduce to the same normal form. (Note\n-- that Agda reduces expressions to normal form for us.)\n\ndata _\u2261_ {A : Set} : A -> A -> Set where\n  refl : \u2200 {r} -> r \u2261 r\n\nthm-\u2261-is-equivalence : {A : Set} -> Equivalence {A} _\u2261_\nthm-\u2261-is-equivalence = record {\n  refl = refl;\n  symm = symm;\n  trans = trans\n  }\n  where\n    symm : \u2200 {r s} -> r \u2261 s -> s \u2261 r\n    symm refl = refl\n    trans : \u2200 {r s t} -> r \u2261 s -> s \u2261 t -> r \u2261 t\n    trans refl refl = refl\n", "meta": {"hexsha": "599546155a068df99375d53ad7ae899c6d4f697f", "size": 3297, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "020-equivalence.agda", "max_stars_repo_name": "mcmtroffaes/agda-proofs", "max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z", "max_issues_repo_path": "020-equivalence.agda", "max_issues_repo_name": "mcmtroffaes/agda-proofs", "max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "020-equivalence.agda", "max_forks_repo_name": "mcmtroffaes/agda-proofs", "max_forks_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.3372093023, "max_line_length": 70, "alphanum_fraction": 0.6078252957, "num_tokens": 1038, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037241905732, "lm_q2_score": 0.8104789063814616, "lm_q1q2_score": 0.7507496293590508}}
{"text": "-- Agda program using the Iowa Agda library\n\nopen import bool\n\nmodule PROOF-evendoublecoin\n  (Choice : Set)\n  (choose : Choice \u2192 \ud835\udd39)\n  (lchoice : Choice \u2192 Choice)\n  (rchoice : Choice \u2192 Choice)\n  where\n\nopen import eq\nopen import nat\nopen import list\nopen import maybe\n\n---------------------------------------------------------------------------\n-- Translated Curry operations:\n\nadd : \u2115 \u2192 \u2115 \u2192 \u2115\nadd zero x = x\nadd (suc y) z = suc (add y z)\n\ncoin : Choice \u2192 \u2115 \u2192 \u2115\ncoin c1 x = if choose c1 then x else suc x\n\ndouble : \u2115 \u2192 \u2115\ndouble x = add x x\n\neven : \u2115 \u2192 \ud835\udd39\neven zero = tt\neven (suc zero) = ff\neven (suc (suc x)) = even x\n\n---------------------------------------------------------------------------\n\nadd-suc : \u2200 (x y : \u2115) \u2192 add x (suc y) \u2261 suc (add x y)\nadd-suc zero y = refl\nadd-suc (suc x) y rewrite add-suc x y = refl\n\n-- auxiliary property for x+x instead of double:\neven-add-x-x : \u2200 (x : \u2115) \u2192 even (add x x) \u2261 tt\neven-add-x-x zero = refl\neven-add-x-x (suc x) rewrite add-suc x x | even-add-x-x x = refl\n\nevendoublecoin : (c1 : Choice) \u2192 (x : \u2115) \u2192 (even (double (coin c1 x))) \u2261 tt\nevendoublecoin c1 x rewrite even-add-x-x (coin c1 x) = refl\n\n---------------------------------------------------------------------------\n", "meta": {"hexsha": "ac4ee4d205a1dd99f5004efe35792271019b4114", "size": 1217, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "docs/src/tooldocs/verify/PROOF-evendoublecoin.agda", "max_stars_repo_name": "DouglasRMiles/pakcs_lib", "max_stars_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-06T18:32:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-21T22:25:28.000Z", "max_issues_repo_path": "docs/src/tooldocs/verify/PROOF-evendoublecoin.agda", "max_issues_repo_name": "DouglasRMiles/pakcs_lib", "max_issues_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-02-21T22:25:13.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-24T12:41:30.000Z", "max_forks_repo_path": "docs/src/tooldocs/verify/PROOF-evendoublecoin.agda", "max_forks_repo_name": "DouglasRMiles/pakcs_lib", "max_forks_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-09T16:02:18.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-09T16:02:18.000Z", "avg_line_length": 24.34, "max_line_length": 75, "alphanum_fraction": 0.5176663928, "num_tokens": 357, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9496693688269984, "lm_q2_score": 0.7905303186696747, "lm_q1q2_score": 0.7507424287696359}}
{"text": "open import Data.List\nopen import Data.Nat using (\u2115; zero; suc)\nopen import Data.Product\nopen import Data.Bool\nopen import Function using (id; _\u2218_)\nopen import Algebra\nopen import Level using (Level; _\u2294_)\n\n\nmodule test where\n\n    variable\n      a b c \u2113 c\u2082 \u2113\u2082 : Level\n      A : Set a\n      B : Set b\n      C : Set c\n      m n o p : \u2115\n\n-- Vector representation\n    \n    module Vector where\n        -- Inductive definition of a vector\n        data Vector (A : Set a) : (n : \u2115) \u2192 Set a where\n          [] : Vector A zero\n          _::_ :  A \u2192 Vector A n \u2192 Vector A (suc n)\n\n        infixr 5 _::_\n\n        vecLength : Vector A n \u2192 \u2115\n        vecLength {n = n} v = n\n\n        headV : Vector A (suc n) \u2192 A\n        headV (x :: _) = x\n\n        tailV : Vector A (suc n) \u2192 Vector A n\n        tailV (_ :: xs) = xs\n\n        -- Matrices are defined as vector of vectors\n        Matrix : (A : Set a) \u2192 (m n : \u2115) \u2192 Set a\n        Matrix A m n = Vector (Vector A m) n\n\n        matLength : Matrix A m n \u2192 \u2115 \u00d7 \u2115\n        matLength {m = m} {n = n} mat  = m , n\n\n        -- Some examples\n        v1 : Vector \u2115 4\n        v1 = 1 :: 3 :: 4 :: 5 :: []\n\n        m1 : Matrix \u2115 2 2\n        m1 =  (1 :: 2 :: []) :: (3 :: 4 :: []) :: []\n\n        -- Some standard functions for working with vectors\n        zipV : (A \u2192 B \u2192 C) \u2192 (Vector A n \u2192 Vector B n \u2192 Vector C n)\n        zipV f [] [] = []\n        zipV f (x :: xs) (y :: ys) = f x y :: zipV f xs ys\n\n        mapV : (A \u2192 B) \u2192 Vector A n \u2192 Vector B n\n        mapV f [] = []\n        mapV f (x :: v) = f x :: mapV f v\n\n        replicateV : A \u2192 Vector A n\n        replicateV {n = zero} x = []\n        replicateV {n = suc n} x = x :: replicateV x\n\n        transpose : Matrix A m n \u2192 Matrix A n m\n        transpose [] = replicateV []\n        transpose (x :: xs) = ((zipV _::_) x) (transpose xs)\n\n        -- Pointwise equality on vectors (lifting _\u223c_ from elements to vectors)\n        data EqV {A : Set a} (_\u223c_ : A \u2192 A \u2192 Set c) :\n                       \u2200 {m n} (xs : Vector A m) (ys : Vector A n) \u2192 Set (a \u2294 c)\n                       where\n          eq-[]  : EqV _\u223c_ [] []\n          eq-::  : \u2200 {m n x y} {xs : Vector A m} {ys : Vector A n}\n                  (x\u223cy : x \u223c y) (xs\u223cys : EqV _\u223c_ xs ys) \u2192\n                  EqV _\u223c_ (x :: xs) (y :: ys)\n                  \n-- Operations\n\n    module Operations (R : Ring c \u2113) where\n        open Ring R\n        open Vector\n\n        infixr 6 _+v_\n        infixr 7 _\u25c1_ _\u25c1\u2098_ _x_ _\u2297_ _*m_ \n\n        sumV : Vector Carrier n \u2192 Carrier\n        sumV {n = zero} v = 0#\n        sumV {n = suc n} (x :: xs) = x + sumV {n} xs\n\n        0v : Vector Carrier n\n        0v = replicateV 0#\n\n        0m : Matrix Carrier m n\n        0m = replicateV 0v\n\n        -- Vector addition\n        _+v_ : Vector Carrier n \u2192 Vector Carrier n  \u2192 Vector Carrier n\n        _+v_ = zipV _+_\n\n        -- Scale vector\n        _\u25c1_ : Carrier \u2192 Vector Carrier n \u2192 Vector Carrier n\n        c \u25c1 v = mapV (c *_) v\n\n        -- Dot product\n        _\u2022_ : Vector Carrier n \u2192 Vector Carrier n \u2192 Carrier\n        u \u2022 v = sumV (zipV _*_ u v)\n\n        -- Cross\n        _x_ : Vector Carrier 3 \u2192 Vector Carrier 3 \u2192 Vector Carrier 3\n        (v1 :: v2 :: v3 :: []) x (u1 :: u2 :: u3 :: []) = (v2 * u3 + -(v3 * u2) ::\n                                                           v3 * u1 + -(v1 * u3) ::\n                                                           v1 * u2 + -(v2 * u1) :: [])\n\n        -- Outer product\n        _\u2297_ : Vector Carrier m \u2192 Vector Carrier n \u2192 Matrix Carrier n m\n        _\u2297_ [] ys = []\n        _\u2297_ (x :: xs) ys = mapV (x *_) ys :: xs \u2297 ys\n\n        -- Scale matrix\n        _\u25c1\u2098_ : Carrier \u2192 Matrix Carrier m n \u2192 Matrix Carrier m n\n        c \u25c1\u2098 m = mapV (c \u25c1_) m\n\n        -- Add matrix/matrix\n        _+m_ : Matrix Carrier m n \u2192 Matrix Carrier m n \u2192 Matrix Carrier m n\n        _+m_ = zipV _+v_\n\n        -- Mul matrix/vector\n        _*mv_ : Matrix Carrier n m \u2192 Vector Carrier n \u2192 Vector Carrier m\n        [] *mv m = 0v\n        m *mv v = mapV (_\u2022 v) m\n\n        -- Mul matrix/matrix\n        _*m_ : {m n o : \u2115} \u2192 Matrix Carrier m n \u2192 Matrix Carrier m o \u2192 Matrix Carrier n o \n        _ *m [] = 0m\n        m1 *m m2 = mapV (m1 *mv_) m2 \n        \n        Sign = Carrier\n        altSumVHelp : Sign \u2192 Vector Carrier n \u2192 Carrier\n        altSumVHelp s [] = 0#\n        altSumVHelp s (x :: xs) = s * x + altSumVHelp (- s) xs\n\n        altSumV : Vector Carrier n \u2192 Carrier\n        altSumV = altSumVHelp 1# -- alternating sum: multiply every second term by minus one\n\n        -- submatricesStep : Matrix Carrier m (suc (suc n)) \u2192 Vector (Matrix Carrier m (suc n)) (suc (suc n))\n        submatricesStep : Matrix Carrier (suc (suc m)) n \u2192 Vector (Matrix Carrier (suc m) n) (suc (suc m)) \n\n        -- submatrices : Matrix Carrier m (suc n) \u2192 Vector (Matrix Carrier m n) (suc n)\n        submatrices : Matrix Carrier (suc m) n \u2192 Vector (Matrix Carrier m n) (suc m)\n        submatrices {\u2115.zero} {n} ma = replicateV [] :: []\n        submatrices {suc m} {n}  ma = submatricesStep ma\n\n        submatricesStep ma with mapV headV ma | mapV tailV ma \n        submatricesStep ma | heads | tails with submatrices tails\n        submatricesStep ma | heads | tails | rec = tails :: mapV (zipV _::_ heads) rec\n\n        -- Determinant\n        det : Matrix Carrier m m \u2192 Carrier\n        det [] = 1#\n        det (v :: m) = altSumV (zipV _*_ v (mapV det (submatrices m)))\n\n        module Property (a11 a12 a21 a22 : Carrier) where\n\n         m22 : Matrix Carrier 2 2\n         m22 = (a11 :: a12 :: []) :: (a21 :: a22 :: []) :: []\n         test : Carrier\n         test = det m22\n         \n        \n        -- Equality on our vectors is a lifted version of the\n        -- underlying equality of the ring of components.\n        _=v_ : Vector Carrier n \u2192 Vector Carrier m \u2192 Set (c \u2294 \u2113)\n        _=v_ = EqV _\u2248_\n        -- The equality type is basically just a vector of equality\n        -- proofs between pairs of corresponding elements.\n\n        -- Left and right proof of identity with vector addition\n        vectorAddIdentity\u02e1 : \u2200 {n} (v1 : Vector Carrier n) \u2192 (0v +v v1) =v v1\n        vectorAddIdentity\u02e1 [] = eq-[]\n        vectorAddIdentity\u02e1 (x1 :: v1) = eq-::(+-identity\u02e1 x1) (vectorAddIdentity\u02e1 v1)\n\n        vectorAddIdentity\u02b3 : \u2200 {n} (v1 : Vector Carrier n) \u2192 (v1 +v 0v) =v v1\n        vectorAddIdentity\u02b3 [] = eq-[]\n        vectorAddIdentity\u02b3 (x1 :: v1) = eq-::(+-identity\u02b3 x1) (vectorAddIdentity\u02b3 v1)\n        \n        -- Vector addition is commutative (statement, and inductive proof)\n        vectorAddComm : \u2200 {n} (v1 v2 : Vector Carrier n) \u2192\n                        (v1 +v v2) =v (v2 +v v1)\n        vectorAddComm [] [] = eq-[]\n        vectorAddComm (x1 :: v1) (x2 :: v2) =\n            eq-:: (+-comm x1 x2) (vectorAddComm v1 v2)\n\n        -- Vector addition is associative (statement, and inductive proof)\n        vectorAddAssoc : \u2200 {n} (v1 v2 v3 : Vector Carrier n) \u2192\n                         ((v1 +v v2) +v v3) =v (v1 +v (v2 +v v3))\n        vectorAddAssoc [] [] [] = eq-[]\n        vectorAddAssoc (x1 :: v1) (x2 :: v2) (x3 :: v3) =\n            eq-:: (+-assoc x1 x2 x3) (vectorAddAssoc v1 v2 v3)\n\n        dotComm : \u2200 {n} (v1 v2 : Vector Carrier n) \u2192 (v1 \u2022 v2) \u2248 (v2 \u2022 v1)\n        dotComm [] v2 = refl\n        dotComm (v1 :: vs) v2 = {!!} --hmmm\n\n        module Morphism (G : Group c \u2113) (H : Group c\u2082 \u2113\u2082) where\n          open Group G renaming (_\u2219_ to _*m_; \u03b5 to 0m)\n          open Group H renaming (_\u2219_ to _*_; \u03b5 to 0#)\n\n          \n         -- show the determinant is a homomorphism\n\n", "meta": {"hexsha": "9e5553c7d11bbd18d2aa102a38d855480bc44c6b", "size": 7454, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/test.agda", "max_stars_repo_name": "DSLsofMath/BScProj2021", "max_stars_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2022-02-27T11:56:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T22:46:54.000Z", "max_issues_repo_path": "agda/test.agda", "max_issues_repo_name": "DSLsofMath/BScProj2021", "max_issues_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/test.agda", "max_forks_repo_name": "DSLsofMath/BScProj2021", "max_forks_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-02T18:02:43.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T18:02:43.000Z", "avg_line_length": 35.1603773585, "max_line_length": 109, "alphanum_fraction": 0.5005366246, "num_tokens": 2397, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9207896802383028, "lm_q2_score": 0.8152324915965392, "lm_q1q2_score": 0.7506576652570521}}
{"text": "module BHeap.Properties {A : Set}(_\u2264_ : A \u2192 A \u2192 Set)  where\n\nopen import Bound.Lower A\nopen import Bound.Lower.Order _\u2264_ \nopen import BHeap _\u2264_ \nopen import Data.List\nopen import Data.Nat \nopen import Data.Sum \nopen import Nat.Sum\nopen import List.Permutation.Base A\nopen import List.Permutation.Base.Concatenation A\nopen import List.Permutation.Base.Equivalence A\nopen import List.Properties A\nopen import Relation.Binary.Core\nopen import Relation.Binary.PropositionalEquality\n\nlemma-merge-lf : {b : Bound}(tot\u2264 : Total _\u2264_)(h : BHeap b) \u2192 merge tot\u2264 h lf \u2261 h\nlemma-merge-lf _ lf = refl\nlemma-merge-lf _ (nd b\u2264x l r) = refl\n\nlemma-merge# : {b : Bound}(tot\u2264 : Total _\u2264_)(l r : BHeap b) \u2192 # (merge tot\u2264 l r) \u2261 # l + # r\nlemma-merge# _ lf r = refl\nlemma-merge# tot\u2264 l lf rewrite lemma-merge-lf tot\u2264 l | +id (# l) = refl\nlemma-merge# tot\u2264 (nd {x = y} x\u2264y l r) (nd {x = y'} x\u2264y' l' r') \n    with tot\u2264 y y'\n... | inj\u2081 y\u2264y' rewrite lemma-merge# tot\u2264 l r = refl\n... | inj\u2082 y'\u2264y rewrite lemma-merge# tot\u2264 l' r' | +assoc (# l + # r) (# l' + # r') = refl\n\nlemma-merge\u2264\u2032 : {b : Bound}{x : A}(tot\u2264 : Total _\u2264_)(b\u2264x : LeB b (val x))(l r : BHeap (val x)) \u2192 suc (# (merge tot\u2264 l r)) \u2264\u2032 # (nd b\u2264x l r)\nlemma-merge\u2264\u2032 tot\u2264 b\u2264x l r rewrite lemma-merge# tot\u2264 l r = \u2264\u2032-refl\n\nlemma-merge\u223c : {b : Bound}(tot\u2264 : Total _\u2264_)(l r : BHeap b) \u2192 flatten (merge tot\u2264 l r) \u223c (flatten l ++ flatten r)\nlemma-merge\u223c _ lf r = refl\u223c\nlemma-merge\u223c tot\u2264 l lf rewrite lemma-merge-lf tot\u2264 l | ++id (flatten l) = refl\u223c\nlemma-merge\u223c tot\u2264 (nd {x = y} b\u2264x l r) (nd {x = y'} b\u2264y' l' r') \n    with tot\u2264 y y'\n... | inj\u2081 y\u2264y' = lemma++\u223cr (\u223cx /head /head (lemma-merge\u223c tot\u2264 l r))\n... | inj\u2082 y'\u2264y = trans\u223c (lemma++\u223cl {xs = y' \u2237 (y \u2237 flatten l ++ flatten r)} (lemma-merge\u223c tot\u2264 l' r')) (\u223cx /head (lemma++/ {xs = y \u2237 flatten l ++ flatten r}) refl\u223c)\n", "meta": {"hexsha": "33f3a49df229bde81e36210219064c5eb40fa071", "size": 1795, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "agda/BHeap/Properties.agda", "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_issues_repo_path": "agda/BHeap/Properties.agda", "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "agda/BHeap/Properties.agda", "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 46.0256410256, "max_line_length": 165, "alphanum_fraction": 0.6128133705, "num_tokens": 731, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9005297834483234, "lm_q2_score": 0.8333246015211009, "lm_q1q2_score": 0.7504336229499573}}
{"text": "{-\n  My first Proof in Agda\n-}\n\n-- define Natural numbers\n\ndata \u2115 : Set where\n  zero : \u2115\n  suc : \u2115 \u2192 \u2115\n\n-- Simply defining 1\none : \u2115\none = suc(zero)\n\ntwo : \u2115\ntwo = suc(suc(zero))\n\n-- define addition of natural numbers\n\n_+_ : \u2115 \u2192 \u2115 \u2192 \u2115\nzero + n = n\n(suc m) + n = suc (m + n)\n\n\n-- Define equality\n\ndata _\u2261_ {A : Set} (a : A) : A \u2192 Set where\n  refl : a \u2261 a\n\n-- small test for equality\n\n-- oneplusoneistwo : one + one \u2261 two\n-- oneplusoneistwo = refl\n\n-- Prove n+0 = n\n", "meta": {"hexsha": "d7ca397f86765e0071cdde3c5b09d23c99e75ab9", "size": 464, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Hello-Agda.agda", "max_stars_repo_name": "adithyaselv/Learn-Agda", "max_stars_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Hello-Agda.agda", "max_issues_repo_name": "adithyaselv/Learn-Agda", "max_issues_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Hello-Agda.agda", "max_forks_repo_name": "adithyaselv/Learn-Agda", "max_forks_repo_head_hexsha": "c506d7e317366443d6d17be943b95e46409c1570", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 12.8888888889, "max_line_length": 42, "alphanum_fraction": 0.5818965517, "num_tokens": 169, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133464597458, "lm_q2_score": 0.7981867681382279, "lm_q1q2_score": 0.750226396340691}}
{"text": "------------------------------------------------------------------------------\n-- Propositional equality on inductive PA\n------------------------------------------------------------------------------\n\n{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\n-- This file contains some definitions which are reexported by\n-- PA.Inductive.Base.\n\nmodule PA.Inductive.Relation.Binary.PropositionalEquality where\n\nopen import Common.FOL.FOL using ( \u00ac_ )\nopen import PA.Inductive.Base.Core\n\ninfix 4 _\u2261_ _\u2262_\n\n------------------------------------------------------------------------------\n-- The identity type on PA.\ndata _\u2261_ (x : \u2115) : \u2115 \u2192 Set where\n  refl : x \u2261 x\n\n-- Inequality.\n_\u2262_ : \u2115 \u2192 \u2115 \u2192 Set\nx \u2262 y = \u00ac x \u2261 y\n{-# ATP definition _\u2262_ #-}\n\n-- Identity properties\n\nsym : \u2200 {x y} \u2192 x \u2261 y \u2192 y \u2261 x\nsym refl = refl\n\ntrans : \u2200 {x y z} \u2192 x \u2261 y \u2192 y \u2261 z \u2192 x \u2261 z\ntrans refl h = h\n\nsubst : (A : \u2115 \u2192 Set) \u2192 \u2200 {x y} \u2192 x \u2261 y \u2192 A x \u2192 A y\nsubst A refl Ax = Ax\n\ncong : (f : \u2115 \u2192 \u2115) \u2192 \u2200 {x y} \u2192 x \u2261 y \u2192 f x \u2261 f y\ncong f refl = refl\n\ncong\u2082 : (f : \u2115 \u2192 \u2115 \u2192 \u2115) \u2192 \u2200 {x x' y y'} \u2192 x \u2261 y \u2192 x' \u2261 y' \u2192 f x x' \u2261 f y y'\ncong\u2082 f refl refl = refl\n", "meta": {"hexsha": "39529018339db884ed4bb6615840b16f8a3642a8", "size": 1226, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/fot/PA/Inductive/Relation/Binary/PropositionalEquality.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "src/fot/PA/Inductive/Relation/Binary/PropositionalEquality.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "src/fot/PA/Inductive/Relation/Binary/PropositionalEquality.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 26.652173913, "max_line_length": 78, "alphanum_fraction": 0.4453507341, "num_tokens": 360, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9284087985746092, "lm_q2_score": 0.8080672135527632, "lm_q1q2_score": 0.7502167109020531}}
{"text": "{-# OPTIONS --safe --warning=error --without-K #-}\n\nopen import LogicalFormulae\nopen import Groups.Definition\nopen import Rings.Definition\nopen import Rings.IntegralDomains.Definition\nopen import Setoids.Setoids\nopen import Sets.EquivalenceRelations\n\n\nmodule Fields.FieldOfFractions.Addition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A \u2192 A \u2192 A} {_*_ : A \u2192 A \u2192 A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where\n\nopen import Fields.FieldOfFractions.Setoid I\n\nfieldOfFractionsPlus : fieldOfFractionsSet \u2192 fieldOfFractionsSet \u2192 fieldOfFractionsSet\nfieldOfFractionsSet.num (fieldOfFractionsPlus (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 })) = (a * d) + (b * c)\nfieldOfFractionsSet.denom (fieldOfFractionsPlus (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 })) = b * d\nfieldOfFractionsSet.denomNonzero (fieldOfFractionsPlus (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 })) = \u03bb pr \u2192 exFalso (d!=0 (IntegralDomain.intDom I pr b!=0))\n\n--record { num = ((a * d) + (b * c)) ; denom = b * d ; denomNonzero = \u03bb pr \u2192 exFalso (d!=0 (IntegralDomain.intDom I pr b!=0)) }\n\nplusWellDefined : {a b c d : fieldOfFractionsSet} \u2192 (Setoid._\u223c_ fieldOfFractionsSetoid a c) \u2192 (Setoid._\u223c_ fieldOfFractionsSetoid b d) \u2192 Setoid._\u223c_ fieldOfFractionsSetoid (fieldOfFractionsPlus a b) (fieldOfFractionsPlus c d)\nplusWellDefined {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} {record { num = e ; denom = f ; denomNonzero = f!=0 }} {record { num = g ; denom = h ; denomNonzero = h!=0 }} af=be ch=dg = need\n  where\n    open Setoid S\n    open Ring R\n    open Equivalence eq\n    have1 : (c * h) \u223c (d * g)\n    have1 = ch=dg\n    have2 : (a * f) \u223c (b * e)\n    have2 = af=be\n    need : (((a * d) + (b * c)) * (f * h)) \u223c ((b * d) * (((e * h) + (f * g))))\n    need = transitive (transitive (Ring.*Commutative R) (transitive (Ring.*DistributesOver+ R) (Group.+WellDefined (Ring.additiveGroup R) (transitive *Associative (transitive (*WellDefined (*Commutative) reflexive) (transitive (*WellDefined *Associative reflexive) (transitive (*WellDefined (*WellDefined have2 reflexive) reflexive) (transitive (symmetric *Associative) (transitive (*WellDefined reflexive *Commutative) (transitive *Associative (transitive (*WellDefined (transitive (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative)) *Associative) reflexive) (symmetric *Associative))))))))) (transitive *Commutative (transitive (transitive (symmetric *Associative) (*WellDefined reflexive (transitive (*WellDefined reflexive *Commutative) (transitive *Associative (transitive (*WellDefined have1 reflexive) (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative))))))) *Associative))))) (symmetric (Ring.*DistributesOver+ R))\n", "meta": {"hexsha": "50b9d3de1d020995ceaf5e4f297b309dbb7be4f6", "size": 2946, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Fields/FieldOfFractions/Addition.agda", "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_issues_repo_path": "Fields/FieldOfFractions/Addition.agda", "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 14, "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_forks_repo_path": "Fields/FieldOfFractions/Addition.agda", "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "avg_line_length": 86.6470588235, "max_line_length": 970, "alphanum_fraction": 0.6880515954, "num_tokens": 936, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087946129328, "lm_q2_score": 0.8080672089305841, "lm_q1q2_score": 0.7502167034094805}}
{"text": "module FRP.JS.Bool where\n\nopen import FRP.JS.Primitive public using ( Bool ; true ; false )\n\nnot : Bool \u2192 Bool\nnot true  = false\nnot false = true\n\n{-# COMPILED_JS not function(x) { return !x; } #-}\n\n_\u225f_ : Bool \u2192 Bool \u2192 Bool\ntrue  \u225f b = b\nfalse \u225f b = not b\n\n{-# COMPILED_JS _\u225f_ function(x) { return function(y) { return x === y; }; } #-}\n\nif_then_else_ : \u2200 {\u03b1} {A : Set \u03b1} \u2192 Bool \u2192 A \u2192 A \u2192 A\nif true  then t else f = t\nif false then t else f = f\n\n{-# COMPILED_JS if_then_else_ function(a) { return function(A) { return function(x) {\n  if (x) { return function(t) { return function(f) { return t; }; }; }\n  else { return function(t) { return function(f) { return f; }; }; }\n}; }; } #-}\n\n_\u2227_ : Bool \u2192 Bool \u2192 Bool\ntrue  \u2227 b = b\nfalse \u2227 b = false\n\n{-# COMPILED_JS _\u2227_ function(x) { return function(y) { return x && y; }; } #-}\n\n_\u2228_ : Bool \u2192 Bool \u2192 Bool\ntrue  \u2228 b = true\nfalse \u2228 b = b\n\n{-# COMPILED_JS _\u2228_ function(x) { return function(y) { return x || y; }; } #-}\n\n_xor_ : Bool \u2192 Bool \u2192 Bool\ntrue  xor b = not b\nfalse xor b = b\n\n_\u2260_ = _xor_\n\n{-# COMPILED_JS _xor_ function(x) { return function(y) { return x !== y; }; } #-}\n{-# COMPILED_JS _\u2260_ function(x) { return function(y) { return x !== y; }; } #-}\n", "meta": {"hexsha": "10cd888130166c22318e7abe37e44f4f68601f1e", "size": 1199, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "src/agda/FRP/JS/Bool.agda", "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": ["MIT", "BSD-3-Clause"], "max_stars_count": 63, "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_issues_repo_path": "src/agda/FRP/JS/Bool.agda", "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_licenses": ["MIT", "BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/agda/FRP/JS/Bool.agda", "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": ["MIT", "BSD-3-Clause"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "avg_line_length": 26.0652173913, "max_line_length": 85, "alphanum_fraction": 0.5863219349, "num_tokens": 406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9099070060380482, "lm_q2_score": 0.8244619242200082, "lm_q1q2_score": 0.7501836810593958}}
{"text": "module Self where\n\nimport Relation.Binary.PropositionalEquality as Eq\nopen Eq using (_\u2261_; refl; cong; sym)\n\ndata B : Set where\n  T : B\n  F : B\n\n_&&_ : B -> B -> B\ninfixl 20 _&&_\nT && T = T\nT && F = F\nF && _ = F\n\n_||_ : B -> B -> B\ninfixl 15 _||_\nT || _ = T\nF || T = T\nF || F = F\n\np||p\u2261p : \u2200 (p : B) -> p || p \u2261 p\np||p\u2261p T = refl\np||p\u2261p F = refl\n\np&&p\u2261p : \u2200 (p : B) -> p && p \u2261 p\np&&p\u2261p T = refl\np&&p\u2261p F = refl\n\n-- \u4ea4\u6362\u5f8b\n\na&&b\u2261b&&a : \u2200 (a b : B) -> a && b \u2261 b && a\na&&b\u2261b&&a T T = refl\na&&b\u2261b&&a T F = refl\na&&b\u2261b&&a F T = refl\na&&b\u2261b&&a F F = refl\n\na||b\u2261b||a : \u2200 (a b : B) -> a || b \u2261 b || a\na||b\u2261b||a T T = refl\na||b\u2261b||a T F = refl\na||b\u2261b||a F T = refl\na||b\u2261b||a F F = refl\n\nabc||abc : \u2200 (a b c : B) -> (a || b) || c \u2261 a || (b || c)\nabc||abc T b c = refl\nabc||abc F T c = refl\nabc||abc F F T = refl\nabc||abc F F F = refl\n\nabc&&abc : \u2200 (a b c : B) -> a && b && c \u2261 a && (b && c)\nabc&&abc T T T = refl\nabc&&abc T T F = refl\nabc&&abc T F c = refl\nabc&&abc F b c = refl\n\n-- \u5206\u914d\u5f8b\n\na&&b||c\u2261a&&b||a&&c : \u2200 (a b c : B) -> a && (b || c) \u2261 a && b || a && c\na&&b||c\u2261a&&b||a&&c T T c = refl\na&&b||c\u2261a&&b||a&&c T F T = refl\na&&b||c\u2261a&&b||a&&c T F F = refl\na&&b||c\u2261a&&b||a&&c F T c = refl\na&&b||c\u2261a&&b||a&&c F F c = refl\n\na||b&&c\u2261a||b&&a||c : \u2200 (a b c : B) -> a || b && c \u2261 (a || b) && (a || c)\na||b&&c\u2261a||b&&a||c T b c = refl\na||b&&c\u2261a||b&&a||c F T T = refl\na||b&&c\u2261a||b&&a||c F T F = refl\na||b&&c\u2261a||b&&a||c F F c = refl\n\nT&&p\u2261p : \u2200 (p : B) -> T && p \u2261 p\nT&&p\u2261p T = refl\nT&&p\u2261p F = refl\n\nF||p\u2261p : \u2200 (p : B) -> F || p \u2261 p\nF||p\u2261p T = refl\nF||p\u2261p F = refl\n\n\u00ac_ : B -> B\ninfix 25 \u00ac_\n\u00ac F = T\n\u00ac T = F\n\n-- \u8d1f\u8d1f\u5f97\u6b63\n\u00ac\u00acp\u2261p : \u2200 (p : B) -> \u00ac (\u00ac p) \u2261 p\n\u00ac\u00acp\u2261p T = refl\n\u00ac\u00acp\u2261p F = refl\n\n-- \u5fb7\u00b7\u6469\u6839\u5f8b\n\n\u00aca&&b\u2261\u00aca||\u00acb : \u2200 (a b : B) -> \u00ac (a && b) \u2261 \u00ac a || \u00ac b\n\u00aca&&b\u2261\u00aca||\u00acb T T = refl\n\u00aca&&b\u2261\u00aca||\u00acb T F = refl\n\u00aca&&b\u2261\u00aca||\u00acb F T = refl\n\u00aca&&b\u2261\u00aca||\u00acb F F = refl\n\n\u00aca||b\u2261\u00aca&&\u00acb : \u2200 (a b : B) -> \u00ac (a || b) \u2261 \u00ac a && \u00ac b\n\u00aca||b\u2261\u00aca&&\u00acb T T = refl\n\u00aca||b\u2261\u00aca&&\u00acb T F = refl\n\u00aca||b\u2261\u00aca&&\u00acb F T = refl\n\u00aca||b\u2261\u00aca&&\u00acb F F = refl\n\n-- \u81ea\u53cd\u5f8b\n\np&&\u00acp\u2261F : \u2200 (p : B) -> p && \u00ac p \u2261 F\np&&\u00acp\u2261F T = refl\np&&\u00acp\u2261F F = refl\n\n-- \u6392\u4e2d\u5f8b\n\n\u00acp||p\u2261T : \u2200 (p : B) -> \u00ac p || p \u2261 T\n\u00acp||p\u2261T T = refl\n\u00acp||p\u2261T F = refl\n\n-- \u8574\u542b \u5982\u679c .. \u5c31\n\n_to_ : B -> B -> B\ninfixl 10 _to_\nT to F = F\nT to T = T\nF to _ = T\n\n-- \u8574\u542b\u7b49\u503c\u63a8\u6f14\nptoq\u2261\u00acp||q : \u2200 (p q : B) -> p to q \u2261 \u00ac p || q\nptoq\u2261\u00acp||q T T = refl\nptoq\u2261\u00acp||q T F = refl\nptoq\u2261\u00acp||q F q = refl\n\nTtop\u2261p : \u2200 (p : B) -> T to p \u2261 p\nTtop\u2261p T = refl\nTtop\u2261p F = refl\n\nFtop\u2261T : \u2200 (p : B) -> F to p \u2261 T\nFtop\u2261T p = refl\n\n-- \u7b49\u4ef7\n\n_<>_ : B -> B -> B\ninfixl 10 _eq_\nT <> T = T\nF <> T = F\nT <> F = F\nF <> F = T\n\n-- \u7b49\u4ef7\u7b49\u503c\u5f0f\np<>q\u2261ptoq&&qtop : \u2200 (p q : B) -> p <> q \u2261 (p to q) && (q to p)\np<>q\u2261ptoq&&qtop T T = refl\np<>q\u2261ptoq&&qtop T F = refl\np<>q\u2261ptoq&&qtop F T = refl\np<>q\u2261ptoq&&qtop F F = refl\n\n-- lemma 01\n\np||q&&\u00acq\u2261p : \u2200 (p q : B) -> p || q && \u00ac q \u2261 p\np||q&&\u00acq\u2261p T T = refl\np||q&&\u00acq\u2261p T F = refl\np||q&&\u00acq\u2261p F q rewrite p&&\u00acp\u2261F q = refl\n\n-- proof 01\n\np&&q||p&&\u00acq\u2261p : \u2200 (p q : B) -> p && q || p && \u00ac q \u2261 p \np&&q||p&&\u00acq\u2261p T T = refl\np&&q||p&&\u00acq\u2261p T F = refl\np&&q||p&&\u00acq\u2261p F q = refl\n\n-- proof 02\n\natob\u2261\u00acbto\u00aca : \u2200 (a b : B) -> a to b \u2261 \u00ac b to \u00ac a\natob\u2261\u00acbto\u00aca a b\n  rewrite ptoq\u2261\u00acp||q a b\n    | ptoq\u2261\u00acp||q (\u00ac b) (\u00ac a)\n    | a||b\u2261b||a (\u00ac a) b\n    | \u00ac\u00acp\u2261p b = refl\n\nimplies\u2081 : \u2200 (p q r s : B) -> ((p to (q to r)) && (\u00ac s || p) && q) to (s to r) \u2261 T\nimplies\u2081 T T T T = refl\nimplies\u2081 T T T F = refl\nimplies\u2081 T T F s = refl\nimplies\u2081 T F T T = refl\nimplies\u2081 T F T F = refl\nimplies\u2081 T F F T = refl\nimplies\u2081 T F F F = refl\nimplies\u2081 F T T T = refl\nimplies\u2081 F T T F = refl\nimplies\u2081 F T F T = refl\nimplies\u2081 F T F F = refl\nimplies\u2081 F F r T = refl\nimplies\u2081 F F r F = refl\n", "meta": {"hexsha": "2852390130abeeb86119492fb2ee970ed59edf64", "size": 3575, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "Self.agda", "max_stars_repo_name": "kands-code/agda-exercise", "max_stars_repo_head_hexsha": "b3c9c4f678feac75af6f30d0dd941ab58b9f40dd", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Self.agda", "max_issues_repo_name": "kands-code/agda-exercise", "max_issues_repo_head_hexsha": "b3c9c4f678feac75af6f30d0dd941ab58b9f40dd", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Self.agda", "max_forks_repo_name": "kands-code/agda-exercise", "max_forks_repo_head_hexsha": "b3c9c4f678feac75af6f30d0dd941ab58b9f40dd", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.9153439153, "max_line_length": 82, "alphanum_fraction": 0.4321678322, "num_tokens": 2013, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094003735663, "lm_q2_score": 0.8397339656668287, "lm_q1q2_score": 0.7501422453431517}}
{"text": "{-# OPTIONS --exact-split              #-}\n{-# OPTIONS --no-sized-types           #-}\n{-# OPTIONS --no-universe-polymorphism #-}\n{-# OPTIONS --without-K                #-}\n\nmodule SL where\n\nopen import Data.Nat\nopen import Data.Product\nopen import Data.Sum\nopen import Relation.Binary.PropositionalEquality\n\n-- Example from: Hofmann and Streicher. The groupoid model refutes\n-- uniqueness of identity proofs.\nthm\u2081 : \u2200 n \u2192 n \u2261 0 \u228e \u03a3 \u2115 (\u03bb n' \u2192 n \u2261 suc n')\nthm\u2081 zero    = inj\u2081 refl\nthm\u2081 (suc n) = inj\u2082 (n , refl)\n\npostulate ind\u2115 : (P : \u2115 \u2192 Set) \u2192 P 0 \u2192 (\u2200 n \u2192 P n \u2192 P (suc n)) \u2192 \u2200 n \u2192 P n\n\nthm\u2082 : \u2200 n \u2192 n \u2261 0 \u228e \u03a3 \u2115 \u03bb n' \u2192 n \u2261 suc n'\nthm\u2082 = ind\u2115 P P0 is\n  where\n    P : \u2115 \u2192 Set\n    P m = m \u2261 0 \u228e \u03a3 \u2115 \u03bb m' \u2192 m \u2261 suc m'\n\n    P0 : P 0\n    P0 = inj\u2081 refl\n\n    is : \u2200 m \u2192 P m \u2192 P (suc m)\n    is m _ = inj\u2082 (m , refl)\n", "meta": {"hexsha": "a46d9efb64def5bcb16f802904a485a6a2536168", "size": 808, "ext": "agda", "lang": "Agda", "max_stars_repo_path": "notes/k-axiom/SL.agda", "max_stars_repo_name": "asr/fotc", "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_issues_repo_path": "notes/k-axiom/SL.agda", "max_issues_repo_name": "asr/fotc", "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_forks_repo_path": "notes/k-axiom/SL.agda", "max_forks_repo_name": "asr/fotc", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "avg_line_length": 25.25, "max_line_length": 74, "alphanum_fraction": 0.5457920792, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009596336302, "lm_q2_score": 0.8198933403143929, "lm_q1q2_score": 0.7501212038508606}}
