Fascinating!<br><br>But it looks like you still &#39;cheat&#39; in your induction principles...<br><pre><a name="3768">
</a>×-induction : ∀{A B} {P : A × B → Set}
            → ((x : A) → (y : B) → P (x , y))
            → (p : A × B) → P p
×-induction {A} {B} {P} f p rewrite sym (×-η p) = f (fst p) (snd p)</pre>Can you somehow define<br><br>x-induction {A} {B} {P} f p = p (P p) f<br><br><br><div class="gmail_quote">On Tue, Sep 18, 2012 at 4:09 PM, Dan Doel <span dir="ltr">&lt;<a href="mailto:dan.doel@gmail.com" target="_blank">dan.doel@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This paper:<br>
<br>
    <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.957" target="_blank">http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.957</a><br>
<br>
Induction is Not Derivable in Second Order Dependent Type Theory,<br>
shows, well, that you can&#39;t encode naturals with a strong induction<br>
principle in said theory. At all, no matter what tricks you try.<br>
<br>
However, A Logic for Parametric Polymorphism,<br>
<br>
    <a href="http://www.era.lib.ed.ac.uk/bitstream/1842/205/1/Par_Poly.pdf" target="_blank">http://www.era.lib.ed.ac.uk/bitstream/1842/205/1/Par_Poly.pdf</a><br>
<br>
Indicates that in a type theory incorporating relational parametricity<br>
of its own types,  the induction principle for the ordinary<br>
Church-like encoding of natural numbers can be derived. I&#39;ve done some<br>
work here:<br>
<br>
    <a href="http://code.haskell.org/~dolio/agda-share/html/ParamInduction.html" target="_blank">http://code.haskell.org/~dolio/agda-share/html/ParamInduction.html</a><br>
<br>
for some simpler types (although, I&#39;ve been informed that sigma was<br>
novel, it not being a Simple Type), but haven&#39;t figured out natural<br>
numbers yet (I haven&#39;t actually studied the second paper above, which<br>
I was pointed to recently).<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Dan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Tue, Sep 18, 2012 at 5:41 PM, Ryan Ingram &lt;<a href="mailto:ryani.spam@gmail.com">ryani.spam@gmail.com</a>&gt; wrote:<br>
&gt; Oleg, do you have any references for the extension of lambda-encoding of<br>
&gt; data into dependently typed systems?<br>
&gt;<br>
&gt; In particular, consider Nat:<br>
&gt;<br>
&gt;     nat_elim :: forall P:(Nat -&gt; *). P 0 -&gt; (forall n:Nat. P n -&gt; P (succ<br>
&gt; n)) -&gt; (n:Nat) -&gt; P n<br>
&gt;<br>
&gt; The naive lambda-encoding of &#39;nat&#39; in the untyped lambda-calculus has<br>
&gt; exactly the correct form for passing to nat_elim:<br>
&gt;<br>
&gt;     nat_elim pZero pSucc n = n pZero pSucc<br>
&gt;<br>
&gt; with<br>
&gt;<br>
&gt;     zero :: Nat<br>
&gt;     zero pZero pSucc = pZero<br>
&gt;<br>
&gt;     succ :: Nat -&gt; Nat<br>
&gt;     succ n pZero pSucc = pSucc (n pZero pSucc)<br>
&gt;<br>
&gt; But trying to encode the numerals this way leads to &quot;Nat&quot; referring to its<br>
&gt; value in its type!<br>
&gt;<br>
&gt;    type Nat = forall P:(Nat  -&gt; *). P 0 -&gt; (forall n:Nat. P n -&gt; P (succ n))<br>
&gt; -&gt; P ???<br>
&gt;<br>
&gt; Is there a way out of this quagmire?  Or are we stuck defining actual<br>
&gt; datatypes if we want dependent types?<br>
&gt;<br>
&gt;   -- ryan<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Sep 18, 2012 at 1:27 AM, &lt;<a href="mailto:oleg@okmij.org">oleg@okmij.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; There has been a recent discussion of ``Church encoding&#39;&#39; of lists and<br>
&gt;&gt; the comparison with Scott encoding.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;d like to point out that what is often called Church encoding is<br>
&gt;&gt; actually Boehm-Berarducci encoding. That is, often seen<br>
&gt;&gt;<br>
&gt;&gt; &gt; newtype ChurchList a =<br>
&gt;&gt; &gt;     CL { cataCL :: forall r. (a -&gt; r -&gt; r) -&gt; r -&gt; r }<br>
&gt;&gt;<br>
&gt;&gt; (in <a href="http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs" target="_blank">http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs</a> )<br>
&gt;&gt;<br>
&gt;&gt; is _not_ Church encoding. First of all, Church encoding is not typed<br>
&gt;&gt; and it is not tight. The following article explains the other<br>
&gt;&gt; difference between the encodings<br>
&gt;&gt;<br>
&gt;&gt;         <a href="http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html" target="_blank">http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html</a><br>
&gt;&gt;<br>
&gt;&gt; Boehm-Berarducci encoding is very insightful and influential. The<br>
&gt;&gt; authors truly deserve credit.<br>
&gt;&gt;<br>
&gt;&gt; P.S. It is actually possible to write zip function using Boehm-Berarducci<br>
&gt;&gt; encoding:<br>
&gt;&gt;         <a href="http://okmij.org/ftp/ftp/Algorithms.html#zip-folds" target="_blank">http://okmij.org/ftp/ftp/Algorithms.html#zip-folds</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Haskell-Cafe mailing list<br>
&gt;&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Haskell-Cafe mailing list<br>
&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;<br>
</div></div></blockquote></div><br>