<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Solving a Logic Problem with Coq</title>
	<atom:link href="http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/feed/" rel="self" type="application/rss+xml" />
	<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/</link>
	<description>software, programming languages, and other ideas</description>
	<lastBuildDate>Tue, 17 Nov 2009 16:15:58 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Magnus Hiie</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-1040</link>
		<dc:creator>Magnus Hiie</dc:creator>
		<pubDate>Wed, 28 Jan 2009 19:23:15 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-1040</guid>
		<description>I think your encoding of Given1 is not correct. You have:

Hypothesis Given1 : ~ Youngest Alice -&gt; Youngest Bill.

The text says: Alice is the youngest unless Bill is

Which IMO should translate to:

Hypothesis Given1 : ~ Youngest Bill -&gt; Youngest Alice.

I think the Lemma YoungBill (and the entire goal) cannot be proven without classical with this encoding anymore. It can be proved with double negative elimination.

Also, the firstorder tactic does not give an answer to this.</description>
		<content:encoded><![CDATA[<p>I think your encoding of Given1 is not correct. You have:</p>
<p>Hypothesis Given1 : ~ Youngest Alice -&gt; Youngest Bill.</p>
<p>The text says: Alice is the youngest unless Bill is</p>
<p>Which IMO should translate to:</p>
<p>Hypothesis Given1 : ~ Youngest Bill -&gt; Youngest Alice.</p>
<p>I think the Lemma YoungBill (and the entire goal) cannot be proven without classical with this encoding anymore. It can be proved with double negative elimination.</p>
<p>Also, the firstorder tactic does not give an answer to this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Snively</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-1026</link>
		<dc:creator>Paul Snively</dc:creator>
		<pubDate>Thu, 24 Jul 2008 15:38:19 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-1026</guid>
		<description>Sorry, yeah, I should have explained the transcript better. I&#039;ll try to be brief. Basically, Coq is a proof assistant using the natural deduction style. Given a set of definitions such as the Variables and Hypotheses in this problem, when you say what it is that you want to prove, Coq shows you the current context above the &quot;=========&quot; line, and the current (sub)goal below that line. Given the context, the Coq standard libraries, and possibly third-party libraries if necessary, you apply what are called &quot;tactics&quot; in an effort to prove, or at least simplify, the current subgoal, and you repeat until you don&#039;t have any subgoals left. What this process is &lt;em&gt;literally&lt;/em&gt; doing is constructing a term in Coq&#039;s logic, the Calculus of Inductive Constructions, piecemeal. This term is the actual proof. The stuff you, the user, are typing in is more properly called a &quot;proof script.&quot; So one thing cdsmith and I have shown is that there may be more than one proof script that will successfully construct a proof for a goal, and some of these scripts will be shorter than others. :-)

When cdsmith said &quot;Goal Oldest Alice /\ Youngest Bill.&quot; s/he was literally saying &quot;Here&#039;s a theorem I want to prove.&quot; &quot;Goal&quot; essentially introduces anonymous theorems, so that&#039;s where &quot;Unnamed_thm&quot; came from. S/he could also have said &quot;Theorem OldestAliceAndYoungestBill Oldest Alice /\ Youngest Bill&quot; and the prompt would have become &quot;OldestAliceAndYoungestBill &lt; &quot; instead. When you say you want to prove something to Coq, it goes into proof-editing mode and the prompt changes to reflect what you&#039;re proving. This is the context in which you ask Coq to apply tactics in an attempt to simplify (away) the current (sub)goal. Coq has a &lt;em&gt;lot&lt;/em&gt; of built-in tactics, and many, many more are available in libraries, but again, this is an &lt;em&gt;extremely&lt;/em&gt; simple puzzle, so the built-in ones are enough. cdsmith is a newcomer to Coq, so s/he used the most basic tactics that all of the introductory materials teach you about (intro, split, apply, exact...) and some understanding of both classical and intuitionistic logic variants of Pierce&#039;s law. What I did was to pull out one of Coq&#039;s sledgehammer tactics, &lt;a href=&quot;http://coq.inria.fr/V8.1pl3/refman/Reference-Manual010.html#@tactic129&quot; rel=&quot;nofollow&quot;&gt;firstorder&lt;/a&gt;, which implements a very powerful first-order proof-search procedure, the basis of which is documented in Pierre Corbineau&#039;s paper, &lt;a href=&quot;http://www.cs.ru.nl/~corbineau/ftp/publis/ljti-rr.ps&quot; rel=&quot;nofollow&quot;&gt;First-order reasoning in the Calculus of Inductive Constructions&lt;/a&gt;. So the firstorder tactic does automatically what cdsmith did somewhat more manually, although it&#039;s worth emphasizing that both cdsmith&#039;s proof script and mine generate a term in the Calculus of Inductive Constructions that is quite a bit larger than either script. :-) You can see the term by asking Coq to &quot;Print Unnamed_thm.&quot; after it is defined.

This, by the way, is another difference between Prolog and Coq: typically in Prolog, you just want the result(s) of the resolution, and in fact one of the nice things is you get to ask &quot;Who is oldest and who is youngest?&quot; In Coq, you have to say what you want to prove (&quot;I intend to prove that Alice is oldest and Bill is youngest&quot;), but you don&#039;t just get True/False, you also get the proof. When you&#039;re just doing logic, this probably doesn&#039;t matter much, but one of Coq&#039;s most interesting applications is that you can develop software with it that is proven correct, and then literally extract the code from the proof, in any of Scheme, Haskell, or OCaml. This code is &quot;correct by construction&quot; with respect to its specification in Coq, and in Coq, specifications can be &lt;em&gt;extremely&lt;/em&gt; strong, again thanks to the expressive power of the Calculus of Inductive Constructions. A nice example of this is this implementation of &lt;a href=&quot;http://www.lri.fr/~sozeau/research/russell/fingertrees.en.html&quot; rel=&quot;nofollow&quot;&gt;Finger Trees&lt;/a&gt; in Coq.

By the way, I hope you don&#039;t believe I&#039;m attempting to downplay the power of Prolog here&#8212;my point really is more about the simplicity of the puzzle. My copy of &quot;PROLOG Programming for Artificial Intelligence,&quot; 3rd edition, is about 6&quot; away from my right elbow, and I recently got ODBC working on my Mac OS X box, which means that I can play with &lt;a href=&quot;http://flora.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;FLORA-2&lt;/a&gt;&#039;s Persistent Module package. FLORA-2, in turn, relies on the &lt;a href=&quot;http://xsb.sourceforge.net&quot; rel=&quot;nofollow&quot;&gt;XSB&lt;/a&gt; Prolog system. I&#039;m a huge fan.

I hope this helps clarify what Coq and firstorder are a bit!</description>
		<content:encoded><![CDATA[<p>Sorry, yeah, I should have explained the transcript better. I&#8217;ll try to be brief. Basically, Coq is a proof assistant using the natural deduction style. Given a set of definitions such as the Variables and Hypotheses in this problem, when you say what it is that you want to prove, Coq shows you the current context above the &#8220;=========&#8221; line, and the current (sub)goal below that line. Given the context, the Coq standard libraries, and possibly third-party libraries if necessary, you apply what are called &#8220;tactics&#8221; in an effort to prove, or at least simplify, the current subgoal, and you repeat until you don&#8217;t have any subgoals left. What this process is <em>literally</em> doing is constructing a term in Coq&#8217;s logic, the Calculus of Inductive Constructions, piecemeal. This term is the actual proof. The stuff you, the user, are typing in is more properly called a &#8220;proof script.&#8221; So one thing cdsmith and I have shown is that there may be more than one proof script that will successfully construct a proof for a goal, and some of these scripts will be shorter than others. :-)</p>
<p>When cdsmith said &#8220;Goal Oldest Alice /\ Youngest Bill.&#8221; s/he was literally saying &#8220;Here&#8217;s a theorem I want to prove.&#8221; &#8220;Goal&#8221; essentially introduces anonymous theorems, so that&#8217;s where &#8220;Unnamed_thm&#8221; came from. S/he could also have said &#8220;Theorem OldestAliceAndYoungestBill Oldest Alice /\ Youngest Bill&#8221; and the prompt would have become &#8220;OldestAliceAndYoungestBill &lt; &#8221; instead. When you say you want to prove something to Coq, it goes into proof-editing mode and the prompt changes to reflect what you&#8217;re proving. This is the context in which you ask Coq to apply tactics in an attempt to simplify (away) the current (sub)goal. Coq has a <em>lot</em> of built-in tactics, and many, many more are available in libraries, but again, this is an <em>extremely</em> simple puzzle, so the built-in ones are enough. cdsmith is a newcomer to Coq, so s/he used the most basic tactics that all of the introductory materials teach you about (intro, split, apply, exact&#8230;) and some understanding of both classical and intuitionistic logic variants of Pierce&#8217;s law. What I did was to pull out one of Coq&#8217;s sledgehammer tactics, <a href="http://coq.inria.fr/V8.1pl3/refman/Reference-Manual010.html#@tactic129" rel="nofollow">firstorder</a>, which implements a very powerful first-order proof-search procedure, the basis of which is documented in Pierre Corbineau&#8217;s paper, <a href="http://www.cs.ru.nl/~corbineau/ftp/publis/ljti-rr.ps" rel="nofollow">First-order reasoning in the Calculus of Inductive Constructions</a>. So the firstorder tactic does automatically what cdsmith did somewhat more manually, although it&#8217;s worth emphasizing that both cdsmith&#8217;s proof script and mine generate a term in the Calculus of Inductive Constructions that is quite a bit larger than either script. :-) You can see the term by asking Coq to &#8220;Print Unnamed_thm.&#8221; after it is defined.</p>
<p>This, by the way, is another difference between Prolog and Coq: typically in Prolog, you just want the result(s) of the resolution, and in fact one of the nice things is you get to ask &#8220;Who is oldest and who is youngest?&#8221; In Coq, you have to say what you want to prove (&#8220;I intend to prove that Alice is oldest and Bill is youngest&#8221;), but you don&#8217;t just get True/False, you also get the proof. When you&#8217;re just doing logic, this probably doesn&#8217;t matter much, but one of Coq&#8217;s most interesting applications is that you can develop software with it that is proven correct, and then literally extract the code from the proof, in any of Scheme, Haskell, or OCaml. This code is &#8220;correct by construction&#8221; with respect to its specification in Coq, and in Coq, specifications can be <em>extremely</em> strong, again thanks to the expressive power of the Calculus of Inductive Constructions. A nice example of this is this implementation of <a href="http://www.lri.fr/~sozeau/research/russell/fingertrees.en.html" rel="nofollow">Finger Trees</a> in Coq.</p>
<p>By the way, I hope you don&#8217;t believe I&#8217;m attempting to downplay the power of Prolog here&mdash;my point really is more about the simplicity of the puzzle. My copy of &#8220;PROLOG Programming for Artificial Intelligence,&#8221; 3rd edition, is about 6&#8243; away from my right elbow, and I recently got ODBC working on my Mac OS X box, which means that I can play with <a href="http://flora.sourceforge.net/" rel="nofollow">FLORA-2</a>&#8217;s Persistent Module package. FLORA-2, in turn, relies on the <a href="http://xsb.sourceforge.net" rel="nofollow">XSB</a> Prolog system. I&#8217;m a huge fan.</p>
<p>I hope this helps clarify what Coq and firstorder are a bit!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pål GD</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-1025</link>
		<dc:creator>Pål GD</dc:creator>
		<pubDate>Thu, 24 Jul 2008 07:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-1025</guid>
		<description>Okay, but I didn&#039;t find your one line FOL, and I don&#039;t know Coq so I seriously don&#039;t see what you have done. What is &quot;Unnamed_thm&quot; and what is &quot;firstorder&quot;?</description>
		<content:encoded><![CDATA[<p>Okay, but I didn&#8217;t find your one line FOL, and I don&#8217;t know Coq so I seriously don&#8217;t see what you have done. What is &#8220;Unnamed_thm&#8221; and what is &#8220;firstorder&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Snively</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-1024</link>
		<dc:creator>Paul Snively</dc:creator>
		<pubDate>Thu, 24 Jul 2008 01:18:37 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-1024</guid>
		<description>Sure, but this misses the point: it tells us a lot about the simplicity of the example rather than anything particularly compelling about either Prolog or Coq. First of all, the point of Coq is not to fully automate proof, although the firstorder tactic does everything that Prolog&#039;s resolution does, and more. Secondly, precisely because the Calculus of Inductive Constructions is more expressive than the decidable fragment of first-order logic that Prolog treats, cdsmith had to make certain things that are implicit in Prolog explicit, e.g. that the children are members of a set, that these members are disjoint, that if &quot;youngest&quot; or &quot;oldest&quot; are true of one then they are not true of another, that &quot;youngest&quot; and &quot;oldest&quot; are opposites, and so on. But once these non-problem-specific things are encoded, the actual problem encoding&#8212;Given1 and Given2&#8212;are direct from the problem description, and firstorder does indeed completely automate the proof.

But again, you should ignore most of that, because all it shows is that Coq does &lt;em&gt;at least as much&lt;/em&gt; as Prolog. What Coq is really for is helping people prove things that can&#039;t be automatically proven at all, e.g. the four-color map theorem, or that a compiler for a programming language correctly compiles all possible source programs into their semantically-identical respective target programs.</description>
		<content:encoded><![CDATA[<p>Sure, but this misses the point: it tells us a lot about the simplicity of the example rather than anything particularly compelling about either Prolog or Coq. First of all, the point of Coq is not to fully automate proof, although the firstorder tactic does everything that Prolog&#8217;s resolution does, and more. Secondly, precisely because the Calculus of Inductive Constructions is more expressive than the decidable fragment of first-order logic that Prolog treats, cdsmith had to make certain things that are implicit in Prolog explicit, e.g. that the children are members of a set, that these members are disjoint, that if &#8220;youngest&#8221; or &#8220;oldest&#8221; are true of one then they are not true of another, that &#8220;youngest&#8221; and &#8220;oldest&#8221; are opposites, and so on. But once these non-problem-specific things are encoded, the actual problem encoding&mdash;Given1 and Given2&mdash;are direct from the problem description, and firstorder does indeed completely automate the proof.</p>
<p>But again, you should ignore most of that, because all it shows is that Coq does <em>at least as much</em> as Prolog. What Coq is really for is helping people prove things that can&#8217;t be automatically proven at all, e.g. the four-color map theorem, or that a compiler for a programming language correctly compiles all possible source programs into their semantically-identical respective target programs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pål GD</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-1023</link>
		<dc:creator>Pål GD</dc:creator>
		<pubDate>Wed, 23 Jul 2008 21:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-1023</guid>
		<description>Cool, Prolog does it in three lines total.</description>
		<content:encoded><![CDATA[<p>Cool, Prolog does it in three lines total.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Snively</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-1022</link>
		<dc:creator>Paul Snively</dc:creator>
		<pubDate>Wed, 23 Jul 2008 21:15:02 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-1022</guid>
		<description>FWIW, I posted a solution in Coq that, given the problem as formulated in this post, solves it with a single tactic: firstorder. My entire reply can be found &lt;a href=&quot;http://www.reddit.com/r/programming/comments/6t2ll/Solving_a_Logic_Problem_with_Coq/c04sm9a&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>FWIW, I posted a solution in Coq that, given the problem as formulated in this post, solves it with a single tactic: firstorder. My entire reply can be found <a href="http://www.reddit.com/r/programming/comments/6t2ll/Solving_a_Logic_Problem_with_Coq/c04sm9a" rel="nofollow">here</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pål GD</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-1021</link>
		<dc:creator>Pål GD</dc:creator>
		<pubDate>Wed, 23 Jul 2008 19:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-1021</guid>
		<description>Karl: Haha, my thought exactly. Been a while since I&#039;ve been working with prolog, but I ended up with something like you. That&#039;s what, 3 lines in Prolog vs. 30 in Coq? Coq has been outsmarted.</description>
		<content:encoded><![CDATA[<p>Karl: Haha, my thought exactly. Been a while since I&#8217;ve been working with prolog, but I ended up with something like you. That&#8217;s what, 3 lines in Prolog vs. 30 in Coq? Coq has been outsmarted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jedai</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-981</link>
		<dc:creator>Jedai</dc:creator>
		<pubDate>Thu, 15 May 2008 02:29:45 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-981</guid>
		<description>Coq means rooster (= cock out of the USA), it&#039;s a play on CoC (Calculus of Construction).</description>
		<content:encoded><![CDATA[<p>Coq means rooster (= cock out of the USA), it&#8217;s a play on CoC (Calculus of Construction).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-977</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Mon, 05 May 2008 04:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-977</guid>
		<description>Uh .. Prolog?

youngest(alice) :- not(oldest(alice)).
youngest(bill) :- not(oldest(bill)).
oldest(alice) :- not(youngest(carl)).

 ?- oldest(X),youngest(Y).
X = alice,
Y = bill.</description>
		<content:encoded><![CDATA[<p>Uh .. Prolog?</p>
<p>youngest(alice) :- not(oldest(alice)).<br />
youngest(bill) :- not(oldest(bill)).<br />
oldest(alice) :- not(youngest(carl)).</p>
<p> ?- oldest(X),youngest(Y).<br />
X = alice,<br />
Y = bill.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cdsmith</title>
		<link>http://cdsmith.wordpress.com/2008/05/04/solving-a-logic-problem-with-coq/#comment-976</link>
		<dc:creator>cdsmith</dc:creator>
		<pubDate>Mon, 05 May 2008 01:53:25 +0000</pubDate>
		<guid isPermaLink="false">http://cdsmith.wordpress.com/?p=50#comment-976</guid>
		<description>Leon, thanks.  Fixed.</description>
		<content:encoded><![CDATA[<p>Leon, thanks.  Fixed.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
