mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
242 lines
No EOL
58 KiB
HTML
242 lines
No EOL
58 KiB
HTML
<!DOCTYPE HTML>
|
||
<html><head><meta charset="utf-8"><title>Data.Nat.Base</title><link rel="stylesheet" href="Agda.css"></head><body><pre class="Agda"><a id="1" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="74" class="Comment">-- The Agda standard library</a>
|
||
<a id="103" class="Comment">--</a>
|
||
<a id="106" class="Comment">-- Natural numbers, basic types and operations</a>
|
||
<a id="153" class="Comment">------------------------------------------------------------------------</a>
|
||
|
||
<a id="227" class="Comment">-- See README.Data.Nat for examples of how to use and reason about</a>
|
||
<a id="294" class="Comment">-- naturals.</a>
|
||
|
||
<a id="308" class="Symbol">{-#</a> <a id="312" class="Keyword">OPTIONS</a> <a id="320" class="Pragma">--cubical-compatible</a> <a id="341" class="Pragma">--safe</a> <a id="348" class="Symbol">#-}</a>
|
||
|
||
<a id="353" class="Keyword">module</a> <a id="360" href="Data.Nat.Base.html" class="Module">Data.Nat.Base</a> <a id="374" class="Keyword">where</a>
|
||
|
||
<a id="381" class="Keyword">open</a> <a id="386" class="Keyword">import</a> <a id="393" href="Data.Bool.Base.html" class="Module">Data.Bool.Base</a> <a id="408" class="Keyword">using</a> <a id="414" class="Symbol">(</a><a id="415" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a><a id="419" class="Symbol">;</a> <a id="421" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a><a id="425" class="Symbol">;</a> <a id="427" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a><a id="432" class="Symbol">)</a>
|
||
<a id="434" class="Keyword">open</a> <a id="439" class="Keyword">import</a> <a id="446" href="Data.Empty.html" class="Module">Data.Empty</a> <a id="457" class="Keyword">using</a> <a id="463" class="Symbol">(</a><a id="464" href="Data.Empty.html#535" class="Datatype">⊥</a><a id="465" class="Symbol">)</a>
|
||
<a id="467" class="Keyword">open</a> <a id="472" class="Keyword">import</a> <a id="479" href="Data.Unit.Base.html" class="Module">Data.Unit.Base</a> <a id="494" class="Keyword">using</a> <a id="500" class="Symbol">(</a><a id="501" href="Agda.Builtin.Unit.html#158" class="Record">⊤</a><a id="502" class="Symbol">;</a> <a id="504" href="Agda.Builtin.Unit.html#195" class="InductiveConstructor">tt</a><a id="506" class="Symbol">)</a>
|
||
<a id="508" class="Keyword">open</a> <a id="513" class="Keyword">import</a> <a id="520" href="Level.html" class="Module">Level</a> <a id="526" class="Keyword">using</a> <a id="532" class="Symbol">(</a><a id="533" href="Level.html#521" class="Function">0ℓ</a><a id="535" class="Symbol">)</a>
|
||
<a id="537" class="Keyword">open</a> <a id="542" class="Keyword">import</a> <a id="549" href="Relation.Binary.Core.html" class="Module">Relation.Binary.Core</a> <a id="570" class="Keyword">using</a> <a id="576" class="Symbol">(</a><a id="577" href="Relation.Binary.Core.html#891" class="Function">Rel</a><a id="580" class="Symbol">)</a>
|
||
<a id="582" class="Keyword">open</a> <a id="587" class="Keyword">import</a> <a id="594" href="Relation.Binary.PropositionalEquality.Core.html" class="Module">Relation.Binary.PropositionalEquality.Core</a>
|
||
<a id="639" class="Keyword">using</a> <a id="645" class="Symbol">(</a><a id="646" href="Agda.Builtin.Equality.html#133" class="Datatype Operator">_≡_</a><a id="649" class="Symbol">;</a> <a id="651" href="Relation.Binary.PropositionalEquality.Core.html#839" class="Function Operator">_≢_</a><a id="654" class="Symbol">;</a> <a id="656" href="Agda.Builtin.Equality.html#190" class="InductiveConstructor">refl</a><a id="660" class="Symbol">)</a>
|
||
<a id="662" class="Keyword">open</a> <a id="667" class="Keyword">import</a> <a id="674" href="Relation.Nullary.html" class="Module">Relation.Nullary</a> <a id="691" class="Keyword">using</a> <a id="697" class="Symbol">(</a><a id="698" href="Relation.Nullary.html#665" class="Function Operator">¬_</a><a id="700" class="Symbol">)</a>
|
||
<a id="702" class="Keyword">open</a> <a id="707" class="Keyword">import</a> <a id="714" href="Relation.Nullary.Negation.Core.html" class="Module">Relation.Nullary.Negation.Core</a> <a id="745" class="Keyword">using</a> <a id="751" class="Symbol">(</a><a id="752" href="Relation.Nullary.Negation.Core.html#787" class="Function">contradiction</a><a id="765" class="Symbol">)</a>
|
||
<a id="767" class="Keyword">open</a> <a id="772" class="Keyword">import</a> <a id="779" href="Relation.Unary.html" class="Module">Relation.Unary</a> <a id="794" class="Keyword">using</a> <a id="800" class="Symbol">(</a><a id="801" href="Relation.Unary.html#1110" class="Function">Pred</a><a id="805" class="Symbol">)</a>
|
||
|
||
<a id="808" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="881" class="Comment">-- Types</a>
|
||
|
||
<a id="891" class="Keyword">open</a> <a id="896" class="Keyword">import</a> <a id="903" href="Agda.Builtin.Nat.html" class="Module">Agda.Builtin.Nat</a> <a id="920" class="Keyword">public</a>
|
||
<a id="929" class="Keyword">using</a> <a id="935" class="Symbol">(</a><a id="936" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a><a id="940" class="Symbol">;</a> <a id="942" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a><a id="945" class="Symbol">)</a> <a id="947" class="Keyword">renaming</a> <a id="956" class="Symbol">(</a><a id="957" href="Agda.Builtin.Nat.html#186" class="Datatype">Nat</a> <a id="961" class="Symbol">to</a> <a id="964" class="Datatype">ℕ</a><a id="965" class="Symbol">)</a>
|
||
|
||
<a id="968" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="1041" class="Comment">-- Boolean equality relation</a>
|
||
|
||
<a id="1071" class="Keyword">open</a> <a id="1076" class="Keyword">import</a> <a id="1083" href="Agda.Builtin.Nat.html" class="Module">Agda.Builtin.Nat</a> <a id="1100" class="Keyword">public</a>
|
||
<a id="1109" class="Keyword">using</a> <a id="1115" class="Symbol">()</a> <a id="1118" class="Keyword">renaming</a> <a id="1127" class="Symbol">(</a><a id="1128" href="Agda.Builtin.Nat.html#614" class="Primitive Operator">_==_</a> <a id="1133" class="Symbol">to</a> <a id="1136" class="Primitive Operator">_≡ᵇ_</a><a id="1140" class="Symbol">)</a>
|
||
|
||
<a id="1143" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="1216" class="Comment">-- Boolean ordering relation</a>
|
||
|
||
<a id="1246" class="Keyword">open</a> <a id="1251" class="Keyword">import</a> <a id="1258" href="Agda.Builtin.Nat.html" class="Module">Agda.Builtin.Nat</a> <a id="1275" class="Keyword">public</a>
|
||
<a id="1284" class="Keyword">using</a> <a id="1290" class="Symbol">()</a> <a id="1293" class="Keyword">renaming</a> <a id="1302" class="Symbol">(</a><a id="1303" href="Agda.Builtin.Nat.html#740" class="Primitive Operator">_<_</a> <a id="1307" class="Symbol">to</a> <a id="1310" class="Primitive Operator">_<ᵇ_</a><a id="1314" class="Symbol">)</a>
|
||
|
||
<a id="1317" class="Keyword">infix</a> <a id="1323" class="Number">4</a> <a id="1325" href="Data.Nat.Base.html#1330" class="Function Operator">_≤ᵇ_</a>
|
||
<a id="_≤ᵇ_"></a><a id="1330" href="Data.Nat.Base.html#1330" class="Function Operator">_≤ᵇ_</a> <a id="1335" class="Symbol">:</a> <a id="1337" class="Symbol">(</a><a id="1338" href="Data.Nat.Base.html#1338" class="Bound">m</a> <a id="1340" href="Data.Nat.Base.html#1340" class="Bound">n</a> <a id="1342" class="Symbol">:</a> <a id="1344" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a><a id="1345" class="Symbol">)</a> <a id="1347" class="Symbol">→</a> <a id="1349" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a>
|
||
<a id="1354" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="1360" href="Data.Nat.Base.html#1330" class="Function Operator">≤ᵇ</a> <a id="1363" href="Data.Nat.Base.html#1363" class="Bound">n</a> <a id="1365" class="Symbol">=</a> <a id="1367" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a>
|
||
<a id="1372" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="1376" href="Data.Nat.Base.html#1376" class="Bound">m</a> <a id="1378" href="Data.Nat.Base.html#1330" class="Function Operator">≤ᵇ</a> <a id="1381" href="Data.Nat.Base.html#1381" class="Bound">n</a> <a id="1383" class="Symbol">=</a> <a id="1385" href="Data.Nat.Base.html#1376" class="Bound">m</a> <a id="1387" href="Data.Nat.Base.html#1310" class="Primitive Operator"><ᵇ</a> <a id="1390" href="Data.Nat.Base.html#1381" class="Bound">n</a>
|
||
|
||
<a id="1393" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="1466" class="Comment">-- Standard ordering relations</a>
|
||
|
||
<a id="1498" class="Keyword">infix</a> <a id="1504" class="Number">4</a> <a id="1506" href="Data.Nat.Base.html#1544" class="Datatype Operator">_≤_</a> <a id="1510" href="Data.Nat.Base.html#1654" class="Function Operator">_<_</a> <a id="1514" href="Data.Nat.Base.html#1688" class="Function Operator">_≥_</a> <a id="1518" href="Data.Nat.Base.html#1718" class="Function Operator">_>_</a> <a id="1522" href="Data.Nat.Base.html#1748" class="Function Operator">_≰_</a> <a id="1526" href="Data.Nat.Base.html#1780" class="Function Operator">_≮_</a> <a id="1530" href="Data.Nat.Base.html#1812" class="Function Operator">_≱_</a> <a id="1534" href="Data.Nat.Base.html#1844" class="Function Operator">_≯_</a>
|
||
|
||
<a id="1539" class="Keyword">data</a> <a id="_≤_"></a><a id="1544" href="Data.Nat.Base.html#1544" class="Datatype Operator">_≤_</a> <a id="1548" class="Symbol">:</a> <a id="1550" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1554" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1556" href="Level.html#521" class="Function">0ℓ</a> <a id="1559" class="Keyword">where</a>
|
||
<a id="_≤_.z≤n"></a><a id="1567" href="Data.Nat.Base.html#1567" class="InductiveConstructor">z≤n</a> <a id="1571" class="Symbol">:</a> <a id="1573" class="Symbol">∀</a> <a id="1575" class="Symbol">{</a><a id="1576" href="Data.Nat.Base.html#1576" class="Bound">n</a><a id="1577" class="Symbol">}</a> <a id="1595" class="Symbol">→</a> <a id="1597" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="1603" href="Data.Nat.Base.html#1544" class="Datatype Operator">≤</a> <a id="1605" href="Data.Nat.Base.html#1576" class="Bound">n</a>
|
||
<a id="_≤_.s≤s"></a><a id="1609" href="Data.Nat.Base.html#1609" class="InductiveConstructor">s≤s</a> <a id="1613" class="Symbol">:</a> <a id="1615" class="Symbol">∀</a> <a id="1617" class="Symbol">{</a><a id="1618" href="Data.Nat.Base.html#1618" class="Bound">m</a> <a id="1620" href="Data.Nat.Base.html#1620" class="Bound">n</a><a id="1621" class="Symbol">}</a> <a id="1623" class="Symbol">(</a><a id="1624" href="Data.Nat.Base.html#1624" class="Bound">m≤n</a> <a id="1628" class="Symbol">:</a> <a id="1630" href="Data.Nat.Base.html#1618" class="Bound">m</a> <a id="1632" href="Data.Nat.Base.html#1544" class="Datatype Operator">≤</a> <a id="1634" href="Data.Nat.Base.html#1620" class="Bound">n</a><a id="1635" class="Symbol">)</a> <a id="1637" class="Symbol">→</a> <a id="1639" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="1643" href="Data.Nat.Base.html#1618" class="Bound">m</a> <a id="1645" href="Data.Nat.Base.html#1544" class="Datatype Operator">≤</a> <a id="1647" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="1651" href="Data.Nat.Base.html#1620" class="Bound">n</a>
|
||
|
||
<a id="_<_"></a><a id="1654" href="Data.Nat.Base.html#1654" class="Function Operator">_<_</a> <a id="1658" class="Symbol">:</a> <a id="1660" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1664" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1666" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="1669" href="Data.Nat.Base.html#1669" class="Bound">m</a> <a id="1671" href="Data.Nat.Base.html#1654" class="Function Operator"><</a> <a id="1673" href="Data.Nat.Base.html#1673" class="Bound">n</a> <a id="1675" class="Symbol">=</a> <a id="1677" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="1681" href="Data.Nat.Base.html#1669" class="Bound">m</a> <a id="1683" href="Data.Nat.Base.html#1544" class="Datatype Operator">≤</a> <a id="1685" href="Data.Nat.Base.html#1673" class="Bound">n</a>
|
||
|
||
<a id="_≥_"></a><a id="1688" href="Data.Nat.Base.html#1688" class="Function Operator">_≥_</a> <a id="1692" class="Symbol">:</a> <a id="1694" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1698" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1700" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="1703" href="Data.Nat.Base.html#1703" class="Bound">m</a> <a id="1705" href="Data.Nat.Base.html#1688" class="Function Operator">≥</a> <a id="1707" href="Data.Nat.Base.html#1707" class="Bound">n</a> <a id="1709" class="Symbol">=</a> <a id="1711" href="Data.Nat.Base.html#1707" class="Bound">n</a> <a id="1713" href="Data.Nat.Base.html#1544" class="Datatype Operator">≤</a> <a id="1715" href="Data.Nat.Base.html#1703" class="Bound">m</a>
|
||
|
||
<a id="_>_"></a><a id="1718" href="Data.Nat.Base.html#1718" class="Function Operator">_>_</a> <a id="1722" class="Symbol">:</a> <a id="1724" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1728" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1730" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="1733" href="Data.Nat.Base.html#1733" class="Bound">m</a> <a id="1735" href="Data.Nat.Base.html#1718" class="Function Operator">></a> <a id="1737" href="Data.Nat.Base.html#1737" class="Bound">n</a> <a id="1739" class="Symbol">=</a> <a id="1741" href="Data.Nat.Base.html#1737" class="Bound">n</a> <a id="1743" href="Data.Nat.Base.html#1654" class="Function Operator"><</a> <a id="1745" href="Data.Nat.Base.html#1733" class="Bound">m</a>
|
||
|
||
<a id="_≰_"></a><a id="1748" href="Data.Nat.Base.html#1748" class="Function Operator">_≰_</a> <a id="1752" class="Symbol">:</a> <a id="1754" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1758" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1760" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="1763" href="Data.Nat.Base.html#1763" class="Bound">a</a> <a id="1765" href="Data.Nat.Base.html#1748" class="Function Operator">≰</a> <a id="1767" href="Data.Nat.Base.html#1767" class="Bound">b</a> <a id="1769" class="Symbol">=</a> <a id="1771" href="Relation.Nullary.html#665" class="Function Operator">¬</a> <a id="1773" href="Data.Nat.Base.html#1763" class="Bound">a</a> <a id="1775" href="Data.Nat.Base.html#1544" class="Datatype Operator">≤</a> <a id="1777" href="Data.Nat.Base.html#1767" class="Bound">b</a>
|
||
|
||
<a id="_≮_"></a><a id="1780" href="Data.Nat.Base.html#1780" class="Function Operator">_≮_</a> <a id="1784" class="Symbol">:</a> <a id="1786" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1790" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1792" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="1795" href="Data.Nat.Base.html#1795" class="Bound">a</a> <a id="1797" href="Data.Nat.Base.html#1780" class="Function Operator">≮</a> <a id="1799" href="Data.Nat.Base.html#1799" class="Bound">b</a> <a id="1801" class="Symbol">=</a> <a id="1803" href="Relation.Nullary.html#665" class="Function Operator">¬</a> <a id="1805" href="Data.Nat.Base.html#1795" class="Bound">a</a> <a id="1807" href="Data.Nat.Base.html#1654" class="Function Operator"><</a> <a id="1809" href="Data.Nat.Base.html#1799" class="Bound">b</a>
|
||
|
||
<a id="_≱_"></a><a id="1812" href="Data.Nat.Base.html#1812" class="Function Operator">_≱_</a> <a id="1816" class="Symbol">:</a> <a id="1818" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1822" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1824" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="1827" href="Data.Nat.Base.html#1827" class="Bound">a</a> <a id="1829" href="Data.Nat.Base.html#1812" class="Function Operator">≱</a> <a id="1831" href="Data.Nat.Base.html#1831" class="Bound">b</a> <a id="1833" class="Symbol">=</a> <a id="1835" href="Relation.Nullary.html#665" class="Function Operator">¬</a> <a id="1837" href="Data.Nat.Base.html#1827" class="Bound">a</a> <a id="1839" href="Data.Nat.Base.html#1688" class="Function Operator">≥</a> <a id="1841" href="Data.Nat.Base.html#1831" class="Bound">b</a>
|
||
|
||
<a id="_≯_"></a><a id="1844" href="Data.Nat.Base.html#1844" class="Function Operator">_≯_</a> <a id="1848" class="Symbol">:</a> <a id="1850" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="1854" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="1856" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="1859" href="Data.Nat.Base.html#1859" class="Bound">a</a> <a id="1861" href="Data.Nat.Base.html#1844" class="Function Operator">≯</a> <a id="1863" href="Data.Nat.Base.html#1863" class="Bound">b</a> <a id="1865" class="Symbol">=</a> <a id="1867" href="Relation.Nullary.html#665" class="Function Operator">¬</a> <a id="1869" href="Data.Nat.Base.html#1859" class="Bound">a</a> <a id="1871" href="Data.Nat.Base.html#1718" class="Function Operator">></a> <a id="1873" href="Data.Nat.Base.html#1863" class="Bound">b</a>
|
||
|
||
<a id="1876" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="1949" class="Comment">-- Simple predicates</a>
|
||
|
||
<a id="1971" class="Comment">-- Defining `NonZero` in terms of `⊤` and `⊥` allows Agda to</a>
|
||
<a id="2032" class="Comment">-- automatically infer nonZero-ness for any natural of the form</a>
|
||
<a id="2096" class="Comment">-- `suc n`. Consequently in many circumstances this eliminates the need</a>
|
||
<a id="2168" class="Comment">-- to explicitly pass a proof when the NonZero argument is either an</a>
|
||
<a id="2237" class="Comment">-- implicit or an instance argument.</a>
|
||
<a id="2274" class="Comment">--</a>
|
||
<a id="2277" class="Comment">-- It could alternatively be defined using a datatype with an instance</a>
|
||
<a id="2348" class="Comment">-- constructor but then it would not be inferrable when passed as an</a>
|
||
<a id="2417" class="Comment">-- implicit argument.</a>
|
||
<a id="2439" class="Comment">--</a>
|
||
<a id="2442" class="Comment">-- See `Data.Nat.DivMod` for an example.</a>
|
||
|
||
<a id="NonZero"></a><a id="2484" href="Data.Nat.Base.html#2484" class="Function">NonZero</a> <a id="2492" class="Symbol">:</a> <a id="2494" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="2496" class="Symbol">→</a> <a id="2498" href="Agda.Primitive.html#320" class="Primitive">Set</a>
|
||
<a id="2502" href="Data.Nat.Base.html#2484" class="Function">NonZero</a> <a id="2510" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="2518" class="Symbol">=</a> <a id="2520" href="Data.Empty.html#535" class="Datatype">⊥</a>
|
||
<a id="2522" href="Data.Nat.Base.html#2484" class="Function">NonZero</a> <a id="2530" class="Symbol">(</a><a id="2531" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="2535" href="Data.Nat.Base.html#2535" class="Bound">x</a><a id="2536" class="Symbol">)</a> <a id="2538" class="Symbol">=</a> <a id="2540" href="Agda.Builtin.Unit.html#158" class="Record">⊤</a>
|
||
|
||
<a id="2543" class="Comment">-- Constructors</a>
|
||
|
||
<a id="≢-nonZero"></a><a id="2560" href="Data.Nat.Base.html#2560" class="Function">≢-nonZero</a> <a id="2570" class="Symbol">:</a> <a id="2572" class="Symbol">∀</a> <a id="2574" class="Symbol">{</a><a id="2575" href="Data.Nat.Base.html#2575" class="Bound">n</a><a id="2576" class="Symbol">}</a> <a id="2578" class="Symbol">→</a> <a id="2580" href="Data.Nat.Base.html#2575" class="Bound">n</a> <a id="2582" href="Relation.Binary.PropositionalEquality.Core.html#839" class="Function Operator">≢</a> <a id="2584" class="Number">0</a> <a id="2586" class="Symbol">→</a> <a id="2588" href="Data.Nat.Base.html#2484" class="Function">NonZero</a> <a id="2596" href="Data.Nat.Base.html#2575" class="Bound">n</a>
|
||
<a id="2598" href="Data.Nat.Base.html#2560" class="Function">≢-nonZero</a> <a id="2608" class="Symbol">{</a><a id="2609" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a><a id="2613" class="Symbol">}</a> <a id="2616" href="Data.Nat.Base.html#2616" class="Bound">0≢0</a> <a id="2620" class="Symbol">=</a> <a id="2622" href="Data.Nat.Base.html#2616" class="Bound">0≢0</a> <a id="2626" href="Agda.Builtin.Equality.html#190" class="InductiveConstructor">refl</a>
|
||
<a id="2631" href="Data.Nat.Base.html#2560" class="Function">≢-nonZero</a> <a id="2641" class="Symbol">{</a><a id="2642" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="2646" href="Data.Nat.Base.html#2646" class="Bound">n</a><a id="2647" class="Symbol">}</a> <a id="2649" href="Data.Nat.Base.html#2649" class="Bound">n≢0</a> <a id="2653" class="Symbol">=</a> <a id="2655" href="Agda.Builtin.Unit.html#195" class="InductiveConstructor">tt</a>
|
||
|
||
<a id=">-nonZero"></a><a id="2659" href="Data.Nat.Base.html#2659" class="Function">>-nonZero</a> <a id="2669" class="Symbol">:</a> <a id="2671" class="Symbol">∀</a> <a id="2673" class="Symbol">{</a><a id="2674" href="Data.Nat.Base.html#2674" class="Bound">n</a><a id="2675" class="Symbol">}</a> <a id="2677" class="Symbol">→</a> <a id="2679" href="Data.Nat.Base.html#2674" class="Bound">n</a> <a id="2681" href="Data.Nat.Base.html#1718" class="Function Operator">></a> <a id="2683" class="Number">0</a> <a id="2685" class="Symbol">→</a> <a id="2687" href="Data.Nat.Base.html#2484" class="Function">NonZero</a> <a id="2695" href="Data.Nat.Base.html#2674" class="Bound">n</a>
|
||
<a id="2697" href="Data.Nat.Base.html#2659" class="Function">>-nonZero</a> <a id="2707" class="Symbol">(</a><a id="2708" href="Data.Nat.Base.html#1609" class="InductiveConstructor">s≤s</a> <a id="2712" href="Data.Nat.Base.html#2712" class="Bound">0<n</a><a id="2715" class="Symbol">)</a> <a id="2717" class="Symbol">=</a> <a id="2719" href="Agda.Builtin.Unit.html#195" class="InductiveConstructor">tt</a>
|
||
|
||
<a id="2723" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="2796" class="Comment">-- Arithmetic</a>
|
||
|
||
<a id="2811" class="Keyword">open</a> <a id="2816" class="Keyword">import</a> <a id="2823" href="Agda.Builtin.Nat.html" class="Module">Agda.Builtin.Nat</a> <a id="2840" class="Keyword">public</a>
|
||
<a id="2849" class="Keyword">using</a> <a id="2855" class="Symbol">(</a><a id="2856" href="Agda.Builtin.Nat.html#319" class="Primitive Operator">_+_</a><a id="2859" class="Symbol">;</a> <a id="2861" href="Agda.Builtin.Nat.html#522" class="Primitive Operator">_*_</a><a id="2864" class="Symbol">)</a> <a id="2866" class="Keyword">renaming</a> <a id="2875" class="Symbol">(</a><a id="2876" href="Agda.Builtin.Nat.html#409" class="Primitive Operator">_-_</a> <a id="2880" class="Symbol">to</a> <a id="2883" class="Primitive Operator">_∸_</a><a id="2886" class="Symbol">)</a>
|
||
|
||
<a id="pred"></a><a id="2889" href="Data.Nat.Base.html#2889" class="Function">pred</a> <a id="2894" class="Symbol">:</a> <a id="2896" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="2898" class="Symbol">→</a> <a id="2900" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="2902" href="Data.Nat.Base.html#2889" class="Function">pred</a> <a id="2907" href="Data.Nat.Base.html#2907" class="Bound">n</a> <a id="2909" class="Symbol">=</a> <a id="2911" href="Data.Nat.Base.html#2907" class="Bound">n</a> <a id="2913" href="Data.Nat.Base.html#2883" class="Primitive Operator">∸</a> <a id="2915" class="Number">1</a>
|
||
|
||
<a id="2918" class="Keyword">infixl</a> <a id="2925" class="Number">7</a> <a id="2927" href="Data.Nat.Base.html#3166" class="Function Operator">_⊓_</a>
|
||
<a id="2931" class="Keyword">infixl</a> <a id="2938" class="Number">6</a> <a id="2940" href="Data.Nat.Base.html#3004" class="Function Operator">_+⋎_</a> <a id="2945" href="Data.Nat.Base.html#3072" class="Function Operator">_⊔_</a>
|
||
|
||
<a id="2950" class="Comment">-- Argument-swapping addition. Used by Data.Vec._⋎_.</a>
|
||
|
||
<a id="_+⋎_"></a><a id="3004" href="Data.Nat.Base.html#3004" class="Function Operator">_+⋎_</a> <a id="3009" class="Symbol">:</a> <a id="3011" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3013" class="Symbol">→</a> <a id="3015" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3017" class="Symbol">→</a> <a id="3019" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="3021" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="3027" href="Data.Nat.Base.html#3004" class="Function Operator">+⋎</a> <a id="3030" href="Data.Nat.Base.html#3030" class="Bound">n</a> <a id="3032" class="Symbol">=</a> <a id="3034" href="Data.Nat.Base.html#3030" class="Bound">n</a>
|
||
<a id="3036" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3040" href="Data.Nat.Base.html#3040" class="Bound">m</a> <a id="3042" href="Data.Nat.Base.html#3004" class="Function Operator">+⋎</a> <a id="3045" href="Data.Nat.Base.html#3045" class="Bound">n</a> <a id="3047" class="Symbol">=</a> <a id="3049" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3053" class="Symbol">(</a><a id="3054" href="Data.Nat.Base.html#3045" class="Bound">n</a> <a id="3056" href="Data.Nat.Base.html#3004" class="Function Operator">+⋎</a> <a id="3059" href="Data.Nat.Base.html#3040" class="Bound">m</a><a id="3060" class="Symbol">)</a>
|
||
|
||
<a id="3063" class="Comment">-- Max.</a>
|
||
|
||
<a id="_⊔_"></a><a id="3072" href="Data.Nat.Base.html#3072" class="Function Operator">_⊔_</a> <a id="3076" class="Symbol">:</a> <a id="3078" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3080" class="Symbol">→</a> <a id="3082" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3084" class="Symbol">→</a> <a id="3086" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="3088" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="3094" href="Data.Nat.Base.html#3072" class="Function Operator">⊔</a> <a id="3096" href="Data.Nat.Base.html#3096" class="Bound">n</a> <a id="3102" class="Symbol">=</a> <a id="3104" href="Data.Nat.Base.html#3096" class="Bound">n</a>
|
||
<a id="3106" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3110" href="Data.Nat.Base.html#3110" class="Bound">m</a> <a id="3112" href="Data.Nat.Base.html#3072" class="Function Operator">⊔</a> <a id="3114" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="3120" class="Symbol">=</a> <a id="3122" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3126" href="Data.Nat.Base.html#3110" class="Bound">m</a>
|
||
<a id="3128" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3132" href="Data.Nat.Base.html#3132" class="Bound">m</a> <a id="3134" href="Data.Nat.Base.html#3072" class="Function Operator">⊔</a> <a id="3136" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3140" href="Data.Nat.Base.html#3140" class="Bound">n</a> <a id="3142" class="Symbol">=</a> <a id="3144" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3148" class="Symbol">(</a><a id="3149" href="Data.Nat.Base.html#3132" class="Bound">m</a> <a id="3151" href="Data.Nat.Base.html#3072" class="Function Operator">⊔</a> <a id="3153" href="Data.Nat.Base.html#3140" class="Bound">n</a><a id="3154" class="Symbol">)</a>
|
||
|
||
<a id="3157" class="Comment">-- Min.</a>
|
||
|
||
<a id="_⊓_"></a><a id="3166" href="Data.Nat.Base.html#3166" class="Function Operator">_⊓_</a> <a id="3170" class="Symbol">:</a> <a id="3172" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3174" class="Symbol">→</a> <a id="3176" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3178" class="Symbol">→</a> <a id="3180" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="3182" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="3188" href="Data.Nat.Base.html#3166" class="Function Operator">⊓</a> <a id="3190" href="Data.Nat.Base.html#3190" class="Bound">n</a> <a id="3196" class="Symbol">=</a> <a id="3198" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a>
|
||
<a id="3203" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3207" href="Data.Nat.Base.html#3207" class="Bound">m</a> <a id="3209" href="Data.Nat.Base.html#3166" class="Function Operator">⊓</a> <a id="3211" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="3217" class="Symbol">=</a> <a id="3219" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a>
|
||
<a id="3224" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3228" href="Data.Nat.Base.html#3228" class="Bound">m</a> <a id="3230" href="Data.Nat.Base.html#3166" class="Function Operator">⊓</a> <a id="3232" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3236" href="Data.Nat.Base.html#3236" class="Bound">n</a> <a id="3238" class="Symbol">=</a> <a id="3240" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3244" class="Symbol">(</a><a id="3245" href="Data.Nat.Base.html#3228" class="Bound">m</a> <a id="3247" href="Data.Nat.Base.html#3166" class="Function Operator">⊓</a> <a id="3249" href="Data.Nat.Base.html#3236" class="Bound">n</a><a id="3250" class="Symbol">)</a>
|
||
|
||
<a id="3253" class="Comment">-- Division by 2, rounded downwards.</a>
|
||
|
||
<a id="⌊_/2⌋"></a><a id="3291" href="Data.Nat.Base.html#3291" class="Function Operator">⌊_/2⌋</a> <a id="3297" class="Symbol">:</a> <a id="3299" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3301" class="Symbol">→</a> <a id="3303" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="3305" href="Data.Nat.Base.html#3291" class="Function Operator">⌊</a> <a id="3307" class="Number">0</a> <a id="3309" href="Data.Nat.Base.html#3291" class="Function Operator">/2⌋</a> <a id="3323" class="Symbol">=</a> <a id="3325" class="Number">0</a>
|
||
<a id="3327" href="Data.Nat.Base.html#3291" class="Function Operator">⌊</a> <a id="3329" class="Number">1</a> <a id="3331" href="Data.Nat.Base.html#3291" class="Function Operator">/2⌋</a> <a id="3345" class="Symbol">=</a> <a id="3347" class="Number">0</a>
|
||
<a id="3349" href="Data.Nat.Base.html#3291" class="Function Operator">⌊</a> <a id="3351" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3355" class="Symbol">(</a><a id="3356" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3360" href="Data.Nat.Base.html#3360" class="Bound">n</a><a id="3361" class="Symbol">)</a> <a id="3363" href="Data.Nat.Base.html#3291" class="Function Operator">/2⌋</a> <a id="3367" class="Symbol">=</a> <a id="3369" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3373" href="Data.Nat.Base.html#3291" class="Function Operator">⌊</a> <a id="3375" href="Data.Nat.Base.html#3360" class="Bound">n</a> <a id="3377" href="Data.Nat.Base.html#3291" class="Function Operator">/2⌋</a>
|
||
|
||
<a id="3382" class="Comment">-- Division by 2, rounded upwards.</a>
|
||
|
||
<a id="⌈_/2⌉"></a><a id="3418" href="Data.Nat.Base.html#3418" class="Function Operator">⌈_/2⌉</a> <a id="3424" class="Symbol">:</a> <a id="3426" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3428" class="Symbol">→</a> <a id="3430" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="3432" href="Data.Nat.Base.html#3418" class="Function Operator">⌈</a> <a id="3434" href="Data.Nat.Base.html#3434" class="Bound">n</a> <a id="3436" href="Data.Nat.Base.html#3418" class="Function Operator">/2⌉</a> <a id="3440" class="Symbol">=</a> <a id="3442" href="Data.Nat.Base.html#3291" class="Function Operator">⌊</a> <a id="3444" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3448" href="Data.Nat.Base.html#3434" class="Bound">n</a> <a id="3450" href="Data.Nat.Base.html#3291" class="Function Operator">/2⌋</a>
|
||
|
||
<a id="3455" class="Comment">-- Naïve exponentiation</a>
|
||
|
||
<a id="_^_"></a><a id="3480" href="Data.Nat.Base.html#3480" class="Function Operator">_^_</a> <a id="3484" class="Symbol">:</a> <a id="3486" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3488" class="Symbol">→</a> <a id="3490" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3492" class="Symbol">→</a> <a id="3494" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="3496" href="Data.Nat.Base.html#3496" class="Bound">x</a> <a id="3498" href="Data.Nat.Base.html#3480" class="Function Operator">^</a> <a id="3500" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="3506" class="Symbol">=</a> <a id="3508" class="Number">1</a>
|
||
<a id="3510" href="Data.Nat.Base.html#3510" class="Bound">x</a> <a id="3512" href="Data.Nat.Base.html#3480" class="Function Operator">^</a> <a id="3514" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3518" href="Data.Nat.Base.html#3518" class="Bound">n</a> <a id="3520" class="Symbol">=</a> <a id="3522" href="Data.Nat.Base.html#3510" class="Bound">x</a> <a id="3524" href="Agda.Builtin.Nat.html#522" class="Primitive Operator">*</a> <a id="3526" href="Data.Nat.Base.html#3510" class="Bound">x</a> <a id="3528" href="Data.Nat.Base.html#3480" class="Function Operator">^</a> <a id="3530" href="Data.Nat.Base.html#3518" class="Bound">n</a>
|
||
|
||
<a id="3533" class="Comment">-- Distance</a>
|
||
|
||
<a id="∣_-_∣"></a><a id="3546" href="Data.Nat.Base.html#3546" class="Function Operator">∣_-_∣</a> <a id="3552" class="Symbol">:</a> <a id="3554" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3556" class="Symbol">→</a> <a id="3558" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3560" class="Symbol">→</a> <a id="3562" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="3564" href="Data.Nat.Base.html#3546" class="Function Operator">∣</a> <a id="3566" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="3572" href="Data.Nat.Base.html#3546" class="Function Operator">-</a> <a id="3574" href="Data.Nat.Base.html#3574" class="Bound">y</a> <a id="3580" href="Data.Nat.Base.html#3546" class="Function Operator">∣</a> <a id="3582" class="Symbol">=</a> <a id="3584" href="Data.Nat.Base.html#3574" class="Bound">y</a>
|
||
<a id="3586" href="Data.Nat.Base.html#3546" class="CatchallClause Function Operator">∣</a><a id="3587" class="CatchallClause"> </a><a id="3588" href="Data.Nat.Base.html#3588" class="CatchallClause Bound">x</a><a id="3589" class="CatchallClause"> </a><a id="3594" href="Data.Nat.Base.html#3546" class="CatchallClause Function Operator">-</a><a id="3595" class="CatchallClause"> </a><a id="3596" href="Agda.Builtin.Nat.html#204" class="CatchallClause InductiveConstructor">zero</a><a id="3600" class="CatchallClause"> </a><a id="3602" href="Data.Nat.Base.html#3546" class="CatchallClause Function Operator">∣</a> <a id="3604" class="Symbol">=</a> <a id="3606" href="Data.Nat.Base.html#3588" class="Bound">x</a>
|
||
<a id="3608" href="Data.Nat.Base.html#3546" class="Function Operator">∣</a> <a id="3610" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3614" href="Data.Nat.Base.html#3614" class="Bound">x</a> <a id="3616" href="Data.Nat.Base.html#3546" class="Function Operator">-</a> <a id="3618" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="3622" href="Data.Nat.Base.html#3622" class="Bound">y</a> <a id="3624" href="Data.Nat.Base.html#3546" class="Function Operator">∣</a> <a id="3626" class="Symbol">=</a> <a id="3628" href="Data.Nat.Base.html#3546" class="Function Operator">∣</a> <a id="3630" href="Data.Nat.Base.html#3614" class="Bound">x</a> <a id="3632" href="Data.Nat.Base.html#3546" class="Function Operator">-</a> <a id="3634" href="Data.Nat.Base.html#3622" class="Bound">y</a> <a id="3636" href="Data.Nat.Base.html#3546" class="Function Operator">∣</a>
|
||
|
||
<a id="3639" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="3712" class="Comment">-- Alternative definition of _≤_</a>
|
||
|
||
<a id="3746" class="Comment">-- The following definition of _≤_ is more suitable for well-founded</a>
|
||
<a id="3815" class="Comment">-- induction (see Data.Nat.Induction)</a>
|
||
|
||
<a id="3854" class="Keyword">infix</a> <a id="3860" class="Number">4</a> <a id="3862" href="Data.Nat.Base.html#3888" class="Datatype Operator">_≤′_</a> <a id="3867" href="Data.Nat.Base.html#4008" class="Function Operator">_<′_</a> <a id="3872" href="Data.Nat.Base.html#4045" class="Function Operator">_≥′_</a> <a id="3877" href="Data.Nat.Base.html#4078" class="Function Operator">_>′_</a>
|
||
|
||
<a id="3883" class="Keyword">data</a> <a id="_≤′_"></a><a id="3888" href="Data.Nat.Base.html#3888" class="Datatype Operator">_≤′_</a> <a id="3893" class="Symbol">(</a><a id="3894" href="Data.Nat.Base.html#3894" class="Bound">m</a> <a id="3896" class="Symbol">:</a> <a id="3898" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a><a id="3899" class="Symbol">)</a> <a id="3901" class="Symbol">:</a> <a id="3903" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="3905" class="Symbol">→</a> <a id="3907" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="3911" class="Keyword">where</a>
|
||
<a id="_≤′_.≤′-refl"></a><a id="3919" href="Data.Nat.Base.html#3919" class="InductiveConstructor">≤′-refl</a> <a id="3927" class="Symbol">:</a> <a id="3953" href="Data.Nat.Base.html#3894" class="Bound">m</a> <a id="3955" href="Data.Nat.Base.html#3888" class="Datatype Operator">≤′</a> <a id="3958" href="Data.Nat.Base.html#3894" class="Bound">m</a>
|
||
<a id="_≤′_.≤′-step"></a><a id="3962" href="Data.Nat.Base.html#3962" class="InductiveConstructor">≤′-step</a> <a id="3970" class="Symbol">:</a> <a id="3972" class="Symbol">∀</a> <a id="3974" class="Symbol">{</a><a id="3975" href="Data.Nat.Base.html#3975" class="Bound">n</a><a id="3976" class="Symbol">}</a> <a id="3978" class="Symbol">(</a><a id="3979" href="Data.Nat.Base.html#3979" class="Bound">m≤′n</a> <a id="3984" class="Symbol">:</a> <a id="3986" href="Data.Nat.Base.html#3894" class="Bound">m</a> <a id="3988" href="Data.Nat.Base.html#3888" class="Datatype Operator">≤′</a> <a id="3991" href="Data.Nat.Base.html#3975" class="Bound">n</a><a id="3992" class="Symbol">)</a> <a id="3994" class="Symbol">→</a> <a id="3996" href="Data.Nat.Base.html#3894" class="Bound">m</a> <a id="3998" href="Data.Nat.Base.html#3888" class="Datatype Operator">≤′</a> <a id="4001" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="4005" href="Data.Nat.Base.html#3975" class="Bound">n</a>
|
||
|
||
<a id="_<′_"></a><a id="4008" href="Data.Nat.Base.html#4008" class="Function Operator">_<′_</a> <a id="4013" class="Symbol">:</a> <a id="4015" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4019" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4021" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4024" href="Data.Nat.Base.html#4024" class="Bound">m</a> <a id="4026" href="Data.Nat.Base.html#4008" class="Function Operator"><′</a> <a id="4029" href="Data.Nat.Base.html#4029" class="Bound">n</a> <a id="4031" class="Symbol">=</a> <a id="4033" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="4037" href="Data.Nat.Base.html#4024" class="Bound">m</a> <a id="4039" href="Data.Nat.Base.html#3888" class="Datatype Operator">≤′</a> <a id="4042" href="Data.Nat.Base.html#4029" class="Bound">n</a>
|
||
|
||
<a id="_≥′_"></a><a id="4045" href="Data.Nat.Base.html#4045" class="Function Operator">_≥′_</a> <a id="4050" class="Symbol">:</a> <a id="4052" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4056" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4058" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4061" href="Data.Nat.Base.html#4061" class="Bound">m</a> <a id="4063" href="Data.Nat.Base.html#4045" class="Function Operator">≥′</a> <a id="4066" href="Data.Nat.Base.html#4066" class="Bound">n</a> <a id="4068" class="Symbol">=</a> <a id="4070" href="Data.Nat.Base.html#4066" class="Bound">n</a> <a id="4072" href="Data.Nat.Base.html#3888" class="Datatype Operator">≤′</a> <a id="4075" href="Data.Nat.Base.html#4061" class="Bound">m</a>
|
||
|
||
<a id="_>′_"></a><a id="4078" href="Data.Nat.Base.html#4078" class="Function Operator">_>′_</a> <a id="4083" class="Symbol">:</a> <a id="4085" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4089" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4091" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4094" href="Data.Nat.Base.html#4094" class="Bound">m</a> <a id="4096" href="Data.Nat.Base.html#4078" class="Function Operator">>′</a> <a id="4099" href="Data.Nat.Base.html#4099" class="Bound">n</a> <a id="4101" class="Symbol">=</a> <a id="4103" href="Data.Nat.Base.html#4099" class="Bound">n</a> <a id="4105" href="Data.Nat.Base.html#4008" class="Function Operator"><′</a> <a id="4108" href="Data.Nat.Base.html#4094" class="Bound">m</a>
|
||
|
||
<a id="4111" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="4184" class="Comment">-- Another alternative definition of _≤_</a>
|
||
|
||
<a id="4226" class="Keyword">record</a> <a id="_≤″_"></a><a id="4233" href="Data.Nat.Base.html#4233" class="Record Operator">_≤″_</a> <a id="4238" class="Symbol">(</a><a id="4239" href="Data.Nat.Base.html#4239" class="Bound">m</a> <a id="4241" href="Data.Nat.Base.html#4241" class="Bound">n</a> <a id="4243" class="Symbol">:</a> <a id="4245" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a><a id="4246" class="Symbol">)</a> <a id="4248" class="Symbol">:</a> <a id="4250" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="4254" class="Keyword">where</a>
|
||
<a id="4262" class="Keyword">constructor</a> <a id="less-than-or-equal"></a><a id="4274" href="Data.Nat.Base.html#4274" class="InductiveConstructor">less-than-or-equal</a>
|
||
<a id="4295" class="Keyword">field</a>
|
||
<a id="4305" class="Symbol">{</a><a id="_≤″_.k"></a><a id="4306" href="Data.Nat.Base.html#4306" class="Field">k</a><a id="4307" class="Symbol">}</a> <a id="4311" class="Symbol">:</a> <a id="4313" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a>
|
||
<a id="_≤″_.proof"></a><a id="4319" href="Data.Nat.Base.html#4319" class="Field">proof</a> <a id="4325" class="Symbol">:</a> <a id="4327" href="Data.Nat.Base.html#4239" class="Bound">m</a> <a id="4329" href="Agda.Builtin.Nat.html#319" class="Primitive Operator">+</a> <a id="4331" href="Data.Nat.Base.html#4306" class="Field">k</a> <a id="4333" href="Agda.Builtin.Equality.html#133" class="Datatype Operator">≡</a> <a id="4335" href="Data.Nat.Base.html#4241" class="Bound">n</a>
|
||
|
||
<a id="4338" class="Keyword">infix</a> <a id="4344" class="Number">4</a> <a id="4346" href="Data.Nat.Base.html#4233" class="Record Operator">_≤″_</a> <a id="4351" href="Data.Nat.Base.html#4367" class="Function Operator">_<″_</a> <a id="4356" href="Data.Nat.Base.html#4404" class="Function Operator">_≥″_</a> <a id="4361" href="Data.Nat.Base.html#4437" class="Function Operator">_>″_</a>
|
||
|
||
<a id="_<″_"></a><a id="4367" href="Data.Nat.Base.html#4367" class="Function Operator">_<″_</a> <a id="4372" class="Symbol">:</a> <a id="4374" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4378" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4380" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4383" href="Data.Nat.Base.html#4383" class="Bound">m</a> <a id="4385" href="Data.Nat.Base.html#4367" class="Function Operator"><″</a> <a id="4388" href="Data.Nat.Base.html#4388" class="Bound">n</a> <a id="4390" class="Symbol">=</a> <a id="4392" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="4396" href="Data.Nat.Base.html#4383" class="Bound">m</a> <a id="4398" href="Data.Nat.Base.html#4233" class="Record Operator">≤″</a> <a id="4401" href="Data.Nat.Base.html#4388" class="Bound">n</a>
|
||
|
||
<a id="_≥″_"></a><a id="4404" href="Data.Nat.Base.html#4404" class="Function Operator">_≥″_</a> <a id="4409" class="Symbol">:</a> <a id="4411" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4415" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4417" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4420" href="Data.Nat.Base.html#4420" class="Bound">m</a> <a id="4422" href="Data.Nat.Base.html#4404" class="Function Operator">≥″</a> <a id="4425" href="Data.Nat.Base.html#4425" class="Bound">n</a> <a id="4427" class="Symbol">=</a> <a id="4429" href="Data.Nat.Base.html#4425" class="Bound">n</a> <a id="4431" href="Data.Nat.Base.html#4233" class="Record Operator">≤″</a> <a id="4434" href="Data.Nat.Base.html#4420" class="Bound">m</a>
|
||
|
||
<a id="_>″_"></a><a id="4437" href="Data.Nat.Base.html#4437" class="Function Operator">_>″_</a> <a id="4442" class="Symbol">:</a> <a id="4444" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4448" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4450" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4453" href="Data.Nat.Base.html#4453" class="Bound">m</a> <a id="4455" href="Data.Nat.Base.html#4437" class="Function Operator">>″</a> <a id="4458" href="Data.Nat.Base.html#4458" class="Bound">n</a> <a id="4460" class="Symbol">=</a> <a id="4462" href="Data.Nat.Base.html#4458" class="Bound">n</a> <a id="4464" href="Data.Nat.Base.html#4367" class="Function Operator"><″</a> <a id="4467" href="Data.Nat.Base.html#4453" class="Bound">m</a>
|
||
|
||
<a id="4470" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="4543" class="Comment">-- Another alternative definition of _≤_</a>
|
||
|
||
<a id="4585" class="Comment">-- Useful for induction when you have an upper bound.</a>
|
||
|
||
<a id="4640" class="Keyword">data</a> <a id="_≤‴_"></a><a id="4645" href="Data.Nat.Base.html#4645" class="Datatype Operator">_≤‴_</a> <a id="4650" class="Symbol">:</a> <a id="4652" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4654" class="Symbol">→</a> <a id="4656" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4658" class="Symbol">→</a> <a id="4660" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="4664" class="Keyword">where</a>
|
||
<a id="_≤‴_.≤‴-refl"></a><a id="4672" href="Data.Nat.Base.html#4672" class="InductiveConstructor">≤‴-refl</a> <a id="4680" class="Symbol">:</a> <a id="4682" class="Symbol">∀{</a><a id="4684" href="Data.Nat.Base.html#4684" class="Bound">m</a><a id="4685" class="Symbol">}</a> <a id="4687" class="Symbol">→</a> <a id="4689" href="Data.Nat.Base.html#4684" class="Bound">m</a> <a id="4691" href="Data.Nat.Base.html#4645" class="Datatype Operator">≤‴</a> <a id="4694" href="Data.Nat.Base.html#4684" class="Bound">m</a>
|
||
<a id="_≤‴_.≤‴-step"></a><a id="4698" href="Data.Nat.Base.html#4698" class="InductiveConstructor">≤‴-step</a> <a id="4706" class="Symbol">:</a> <a id="4708" class="Symbol">∀{</a><a id="4710" href="Data.Nat.Base.html#4710" class="Bound">m</a> <a id="4712" href="Data.Nat.Base.html#4712" class="Bound">n</a><a id="4713" class="Symbol">}</a> <a id="4715" class="Symbol">→</a> <a id="4717" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="4721" href="Data.Nat.Base.html#4710" class="Bound">m</a> <a id="4723" href="Data.Nat.Base.html#4645" class="Datatype Operator">≤‴</a> <a id="4726" href="Data.Nat.Base.html#4712" class="Bound">n</a> <a id="4728" class="Symbol">→</a> <a id="4730" href="Data.Nat.Base.html#4710" class="Bound">m</a> <a id="4732" href="Data.Nat.Base.html#4645" class="Datatype Operator">≤‴</a> <a id="4735" href="Data.Nat.Base.html#4712" class="Bound">n</a>
|
||
|
||
<a id="4738" class="Keyword">infix</a> <a id="4744" class="Number">4</a> <a id="4746" href="Data.Nat.Base.html#4645" class="Datatype Operator">_≤‴_</a> <a id="4751" href="Data.Nat.Base.html#4767" class="Function Operator">_<‴_</a> <a id="4756" href="Data.Nat.Base.html#4804" class="Function Operator">_≥‴_</a> <a id="4761" href="Data.Nat.Base.html#4837" class="Function Operator">_>‴_</a>
|
||
|
||
<a id="_<‴_"></a><a id="4767" href="Data.Nat.Base.html#4767" class="Function Operator">_<‴_</a> <a id="4772" class="Symbol">:</a> <a id="4774" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4778" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4780" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4783" href="Data.Nat.Base.html#4783" class="Bound">m</a> <a id="4785" href="Data.Nat.Base.html#4767" class="Function Operator"><‴</a> <a id="4788" href="Data.Nat.Base.html#4788" class="Bound">n</a> <a id="4790" class="Symbol">=</a> <a id="4792" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="4796" href="Data.Nat.Base.html#4783" class="Bound">m</a> <a id="4798" href="Data.Nat.Base.html#4645" class="Datatype Operator">≤‴</a> <a id="4801" href="Data.Nat.Base.html#4788" class="Bound">n</a>
|
||
|
||
<a id="_≥‴_"></a><a id="4804" href="Data.Nat.Base.html#4804" class="Function Operator">_≥‴_</a> <a id="4809" class="Symbol">:</a> <a id="4811" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4815" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4817" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4820" href="Data.Nat.Base.html#4820" class="Bound">m</a> <a id="4822" href="Data.Nat.Base.html#4804" class="Function Operator">≥‴</a> <a id="4825" href="Data.Nat.Base.html#4825" class="Bound">n</a> <a id="4827" class="Symbol">=</a> <a id="4829" href="Data.Nat.Base.html#4825" class="Bound">n</a> <a id="4831" href="Data.Nat.Base.html#4645" class="Datatype Operator">≤‴</a> <a id="4834" href="Data.Nat.Base.html#4820" class="Bound">m</a>
|
||
|
||
<a id="_>‴_"></a><a id="4837" href="Data.Nat.Base.html#4837" class="Function Operator">_>‴_</a> <a id="4842" class="Symbol">:</a> <a id="4844" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="4848" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="4850" href="Level.html#521" class="Function">0ℓ</a>
|
||
<a id="4853" href="Data.Nat.Base.html#4853" class="Bound">m</a> <a id="4855" href="Data.Nat.Base.html#4837" class="Function Operator">>‴</a> <a id="4858" href="Data.Nat.Base.html#4858" class="Bound">n</a> <a id="4860" class="Symbol">=</a> <a id="4862" href="Data.Nat.Base.html#4858" class="Bound">n</a> <a id="4864" href="Data.Nat.Base.html#4767" class="Function Operator"><‴</a> <a id="4867" href="Data.Nat.Base.html#4853" class="Bound">m</a>
|
||
|
||
<a id="4870" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="4943" class="Comment">-- A comparison view. Taken from "View from the left"</a>
|
||
<a id="4997" class="Comment">-- (McBride/McKinna); details may differ.</a>
|
||
|
||
<a id="5040" class="Keyword">data</a> <a id="Ordering"></a><a id="5045" href="Data.Nat.Base.html#5045" class="Datatype">Ordering</a> <a id="5054" class="Symbol">:</a> <a id="5056" href="Relation.Binary.Core.html#891" class="Function">Rel</a> <a id="5060" href="Data.Nat.Base.html#964" class="Datatype">ℕ</a> <a id="5062" href="Level.html#521" class="Function">0ℓ</a> <a id="5065" class="Keyword">where</a>
|
||
<a id="Ordering.less"></a><a id="5073" href="Data.Nat.Base.html#5073" class="InductiveConstructor">less</a> <a id="5081" class="Symbol">:</a> <a id="5083" class="Symbol">∀</a> <a id="5085" href="Data.Nat.Base.html#5085" class="Bound">m</a> <a id="5087" href="Data.Nat.Base.html#5087" class="Bound">k</a> <a id="5089" class="Symbol">→</a> <a id="5091" href="Data.Nat.Base.html#5045" class="Datatype">Ordering</a> <a id="5100" href="Data.Nat.Base.html#5085" class="Bound">m</a> <a id="5102" class="Symbol">(</a><a id="5103" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5107" class="Symbol">(</a><a id="5108" href="Data.Nat.Base.html#5085" class="Bound">m</a> <a id="5110" href="Agda.Builtin.Nat.html#319" class="Primitive Operator">+</a> <a id="5112" href="Data.Nat.Base.html#5087" class="Bound">k</a><a id="5113" class="Symbol">))</a>
|
||
<a id="Ordering.equal"></a><a id="5118" href="Data.Nat.Base.html#5118" class="InductiveConstructor">equal</a> <a id="5126" class="Symbol">:</a> <a id="5128" class="Symbol">∀</a> <a id="5130" href="Data.Nat.Base.html#5130" class="Bound">m</a> <a id="5134" class="Symbol">→</a> <a id="5136" href="Data.Nat.Base.html#5045" class="Datatype">Ordering</a> <a id="5145" href="Data.Nat.Base.html#5130" class="Bound">m</a> <a id="5147" href="Data.Nat.Base.html#5130" class="Bound">m</a>
|
||
<a id="Ordering.greater"></a><a id="5151" href="Data.Nat.Base.html#5151" class="InductiveConstructor">greater</a> <a id="5159" class="Symbol">:</a> <a id="5161" class="Symbol">∀</a> <a id="5163" href="Data.Nat.Base.html#5163" class="Bound">m</a> <a id="5165" href="Data.Nat.Base.html#5165" class="Bound">k</a> <a id="5167" class="Symbol">→</a> <a id="5169" href="Data.Nat.Base.html#5045" class="Datatype">Ordering</a> <a id="5178" class="Symbol">(</a><a id="5179" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5183" class="Symbol">(</a><a id="5184" href="Data.Nat.Base.html#5163" class="Bound">m</a> <a id="5186" href="Agda.Builtin.Nat.html#319" class="Primitive Operator">+</a> <a id="5188" href="Data.Nat.Base.html#5165" class="Bound">k</a><a id="5189" class="Symbol">))</a> <a id="5192" href="Data.Nat.Base.html#5163" class="Bound">m</a>
|
||
|
||
<a id="compare"></a><a id="5195" href="Data.Nat.Base.html#5195" class="Function">compare</a> <a id="5203" class="Symbol">:</a> <a id="5205" class="Symbol">∀</a> <a id="5207" href="Data.Nat.Base.html#5207" class="Bound">m</a> <a id="5209" href="Data.Nat.Base.html#5209" class="Bound">n</a> <a id="5211" class="Symbol">→</a> <a id="5213" href="Data.Nat.Base.html#5045" class="Datatype">Ordering</a> <a id="5222" href="Data.Nat.Base.html#5207" class="Bound">m</a> <a id="5224" href="Data.Nat.Base.html#5209" class="Bound">n</a>
|
||
<a id="5226" href="Data.Nat.Base.html#5195" class="Function">compare</a> <a id="5234" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="5242" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="5250" class="Symbol">=</a> <a id="5252" href="Data.Nat.Base.html#5118" class="InductiveConstructor">equal</a> <a id="5260" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a>
|
||
<a id="5265" href="Data.Nat.Base.html#5195" class="Function">compare</a> <a id="5273" class="Symbol">(</a><a id="5274" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5278" href="Data.Nat.Base.html#5278" class="Bound">m</a><a id="5279" class="Symbol">)</a> <a id="5281" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="5289" class="Symbol">=</a> <a id="5291" href="Data.Nat.Base.html#5151" class="InductiveConstructor">greater</a> <a id="5299" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="5304" href="Data.Nat.Base.html#5278" class="Bound">m</a>
|
||
<a id="5306" href="Data.Nat.Base.html#5195" class="Function">compare</a> <a id="5314" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="5322" class="Symbol">(</a><a id="5323" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5327" href="Data.Nat.Base.html#5327" class="Bound">n</a><a id="5328" class="Symbol">)</a> <a id="5330" class="Symbol">=</a> <a id="5332" href="Data.Nat.Base.html#5073" class="InductiveConstructor">less</a> <a id="5340" href="Agda.Builtin.Nat.html#204" class="InductiveConstructor">zero</a> <a id="5345" href="Data.Nat.Base.html#5327" class="Bound">n</a>
|
||
<a id="5347" href="Data.Nat.Base.html#5195" class="Function">compare</a> <a id="5355" class="Symbol">(</a><a id="5356" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5360" href="Data.Nat.Base.html#5360" class="Bound">m</a><a id="5361" class="Symbol">)</a> <a id="5363" class="Symbol">(</a><a id="5364" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5368" href="Data.Nat.Base.html#5368" class="Bound">n</a><a id="5369" class="Symbol">)</a> <a id="5371" class="Keyword">with</a> <a id="5376" href="Data.Nat.Base.html#5195" class="Function">compare</a> <a id="5384" href="Data.Nat.Base.html#5360" class="Bound">m</a> <a id="5386" href="Data.Nat.Base.html#5368" class="Bound">n</a>
|
||
<a id="5388" class="Symbol">...</a> <a id="5392" class="Symbol">|</a> <a id="5394" href="Data.Nat.Base.html#5073" class="InductiveConstructor">less</a> <a id="5402" href="Data.Nat.Base.html#5402" class="Bound">m</a> <a id="5404" href="Data.Nat.Base.html#5404" class="Bound">k</a> <a id="5406" class="Symbol">=</a> <a id="5408" href="Data.Nat.Base.html#5073" class="InductiveConstructor">less</a> <a id="5413" class="Symbol">(</a><a id="5414" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5418" href="Data.Nat.Base.html#5402" class="Bound">m</a><a id="5419" class="Symbol">)</a> <a id="5421" href="Data.Nat.Base.html#5404" class="Bound">k</a>
|
||
<a id="5423" class="Symbol">...</a> <a id="5427" class="Symbol">|</a> <a id="5429" href="Data.Nat.Base.html#5118" class="InductiveConstructor">equal</a> <a id="5437" href="Data.Nat.Base.html#5437" class="Bound">m</a> <a id="5441" class="Symbol">=</a> <a id="5443" href="Data.Nat.Base.html#5118" class="InductiveConstructor">equal</a> <a id="5449" class="Symbol">(</a><a id="5450" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5454" href="Data.Nat.Base.html#5437" class="Bound">m</a><a id="5455" class="Symbol">)</a>
|
||
<a id="5457" class="Symbol">...</a> <a id="5461" class="Symbol">|</a> <a id="5463" href="Data.Nat.Base.html#5151" class="InductiveConstructor">greater</a> <a id="5471" href="Data.Nat.Base.html#5471" class="Bound">n</a> <a id="5473" href="Data.Nat.Base.html#5473" class="Bound">k</a> <a id="5475" class="Symbol">=</a> <a id="5477" href="Data.Nat.Base.html#5151" class="InductiveConstructor">greater</a> <a id="5485" class="Symbol">(</a><a id="5486" href="Agda.Builtin.Nat.html#217" class="InductiveConstructor">suc</a> <a id="5490" href="Data.Nat.Base.html#5471" class="Bound">n</a><a id="5491" class="Symbol">)</a> <a id="5493" href="Data.Nat.Base.html#5473" class="Bound">k</a>
|
||
</pre></body></html> |