Questions tagged [logical-foundations]

Questions related to Logical Foundations course from the University of Pennsylvania

Logical Foundations course covers functional programming, basic concepts of logic, computer-assisted theorem proving, and Coq. First volume of the Software Foundations series.

52 questions
0
votes
1 answer

How can I prove excluded middle with the given hypothesis (forall P Q : Prop, (P -> Q) -> (~P \/ Q))?

I am currently confused about how to prove the following theorem: Theorem excluded_middle2 : (forall P Q : Prop, (P -> Q) -> (~P \/ Q)) -> (forall P, P \/ ~P). I am stuck here: Theorem excluded_middle2 : (forall P Q : Prop, (P -> Q) -> (~P \/…
0
votes
1 answer

Mix-up of bool and Datatypes.bool after Require Import coq libraries

2 I'm going through software foundations and ran into an error. (https://softwarefoundations.cis.upenn.edu/lf-current/Maps.html) From Coq Require Import Arith.Arith. From Coq Require Import Bool.Bool. Require Export Coq.Strings.String. From Coq…
Fusen
  • 311
  • 2
  • 3
  • 10
0
votes
1 answer

Coq proving nonsensical inductive property implication?

In IndProp.v from Logical Foundations we have the following inductive property: Inductive nostutter {X:Type} : list X -> Prop := | nos_nil : nostutter [] | nos_one : forall x, nostutter [x] | nos_cons : forall x h l, nostutter (h :: l) -> (x…
granduser
  • 67
  • 7
0
votes
1 answer

How does the grading script of the LF series work for manually graded exercises?

I am trying to figure out how the LF test scripts output the manually graded assignments when run from the terminal. For instance, if you look at Induction.v there is an exercise called plus_comm_informal I am trying to get the test script,…
Tejas Anil Shah
  • 1,421
  • 11
  • 20
0
votes
1 answer

Quick Chick eqBoolArrowA_correct theorem

Passing Quick Chick course from Software foundations I am stuck at the following theorem: Class Eq A := { eqb: A -> A -> bool; }. Instance eqBoolArrowA {A : Type} `{Eq A} : Eq (bool -> A) := { eqb f1 f2 := (andb (eqb (f1 false)…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

Coq: unary to binary convertion

Task: write a function to convert natural numbers to binary numbers. Inductive bin : Type := | Z | A (n : bin) | B (n : bin). (* Division by 2. Returns (quotient, remainder) *) Fixpoint div2_aux (n accum : nat) : (nat * nat) := match n…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

Instance of Ord typeclass for option

In volume 4 of Software foundations "QuickChick" we have the following excercise: Class Ord A `{Eq A} : Type := { le : A -> A -> bool }. (* Define [Ord] instances for options and pairs. *) (* So I am trying to do it *) Instance optionOrd {A :…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

Coq: help to formalize an informal proof

Theorem ev_ev__ev_full : forall n m, even (n+m) <-> (even n <-> even m). Proof. intros n m. split. - intros H. split. + intros H1. apply (ev_ev__ev n m H H1). + intros H1. rewrite plus_comm in H. apply (ev_ev__ev m n H H1). - intros…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

Rel: le_antisymmetric comprehension

Rel chapter from Logical foundations. I was given a solution to the excersize that I'm trying to comprehend: Definition antisymmetric {X: Type} (R: relation X) := forall a b : X, (R a b) -> (R b a) -> a = b. Theorem le_antisymmetric : …
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

Rev.v le_antisymmetric

I came to this point: Theorem le_antisymmetric : antisymmetric le. Proof. unfold antisymmetric. intros a b H1 H2. generalize dependent a. induction b as [|b' IH]. - intros. inversion H1. reflexivity. - intros. Output: b' : nat IH : forall…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

How to apply do tactic to a sequence

Diving deep into test_nostutter_1 excersize I found a way to solve it without repeat: Example test_nostutter_1: nostutter [3;1;4;1;5;6]. Proof. constructor 3. (* This will apply the tactics to the 2-nd subgoal *) 2: {apply eqb_neq. auto. } …
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

IndProp test_nostutter_4

The authors of the book have provided proofs for some unit tests for nostutter exercise. Unfortunately, they didn't provide explanations how they work. I was able to understand all the proofs but one: Inductive nostutter {X:Type} : list X -> Prop…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

apply tactics works, but the variables in goal and hypothesis are different

Playing with leb_complete theorem from IndProp I found the following weirdness: Theorem leb_complete : forall n m, n <=? m = true -> n <= m. Proof. induction n as [|n']. - intros. apply O_le_n. - induction m as [| m'] eqn:Em. + intros H.…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
3 answers

IndProp: ev_plus_plus

(** **** Exercise: 3 stars, standard, optional (ev_plus_plus) This exercise just requires applying existing lemmas. No induction or even case analysis is needed, though some of the rewriting may be tedious. *) Theorem ev_plus_plus :…
user4035
  • 22,508
  • 11
  • 59
  • 94
0
votes
1 answer

Logic: All definition and All_In theorem

Here is the task: Drawing inspiration from [In], write a recursive function [All] stating that some property [P] holds of all elements of a list [l]. To make sure your definition is correct, prove the [All_In] lemma below. (Of course, your…
user4035
  • 22,508
  • 11
  • 59
  • 94