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.

43 questions
10
votes
2 answers

Proving that a reversible list is a palindrome in Coq

Here is my inductive definition of palindromes: Inductive pal { X : Type } : list X -> Prop := | pal0 : pal [] | pal1 : forall ( x : X ), pal [x] | pal2 : forall ( x : X ) ( l : list X ), pal l -> pal ( x :: l ++ [x] ). And the theorem I want…
user287393
  • 1,171
  • 5
  • 12
6
votes
1 answer

How to apply rewrite inside a specific subexpression?

I'm using the online book "Software Foundations" to learn about Coq. In the second chapter, it is asked to prove the "plus_assoc" theorem: Theorem plus_assoc : forall n m p : nat, n + (m + p) = (n + m) + p. I make use of two previously proven…
Fabian Pijcke
  • 2,217
  • 18
  • 25
2
votes
5 answers

IndProp: prove that Prop is not provable

The task. Suppose we give Coq the following definition: Inductive R2 : nat -> list nat -> Prop := | c1 : R2 0 [] | c2 : forall n l, R2 n l -> R2 (S n) (n :: l) | c3 : forall n l, R2 (S n) l -> R2 n l. Which of the following propositions are…
user4035
  • 19,332
  • 7
  • 51
  • 78
2
votes
1 answer

How to make coq simplify expressions inside an implication hypothesis

Im trying to prove the following lemma: Inductive even : nat → Prop := | ev_0 : even 0 | ev_SS (n : nat) (H : even n) : even (S (S n)). Lemma even_Sn_not_even_n : forall n, even (S n) <-> not (even n). Proof. intros n. split. + intros H.…
user4035
  • 19,332
  • 7
  • 51
  • 78
2
votes
3 answers

Logic: auxilliry lemma for tr_rev_correct

In Logic chapter a tail recursive version of reverse list function is introduced. We need to prove that it works correctly: Fixpoint rev_append {X} (l1 l2 : list X) : list X := match l1 with | [] => l2 | x :: l1' => rev_append l1' (x :: l2) …
user4035
  • 19,332
  • 7
  • 51
  • 78
2
votes
2 answers

Tactics: stuck in eqb_trans

Trying to solve eqb_trans I became stuck: Theorem eqb_trans : forall n m p, n =? m = true -> m =? p = true -> n =? p = true. Obviously, we should use eqb_true to solve it: Theorem eqb_true : forall n m, n =? m = true -> n =…
user4035
  • 19,332
  • 7
  • 51
  • 78
2
votes
3 answers

Church numerals

There are 4 exercises in Poly module related to Church numerals: Definition cnat := forall X : Type, (X -> X) -> X -> X. As far as I understand cnat is a function that takes a function f(x), it's argument x and returns it's value for this argument:…
user4035
  • 19,332
  • 7
  • 51
  • 78
2
votes
3 answers

coq Basics: bin_to_nat function

I am passing Logical Foundations course and became stuck upon the last excersize of Basics: Having binary number write a converter to it's unary representation: Inductive bin : Type := | Z | A (n : bin) | B (n : bin). Fixpoint bin_to_nat…
user4035
  • 19,332
  • 7
  • 51
  • 78
2
votes
2 answers

Software Foundations: proving leb_complete and leb_correct

I've been working through Volume 1 of Benjamin Pierce, et al., Software Foundations, and I've gotten stuck on a couple of problems in the chapter IndProp. Unfortunately, I don't know of a better place to ask: anyone have any hints? Theorem…
Tommy McGuire
  • 1,103
  • 11
  • 15
2
votes
1 answer

Mix-up of bool and Datatypes.bool after Require Import Omega

I'm going through software foundations and ran into an error. ERROR : The term "true" has type "bool" while it is expected to have type "Datatypes.bool" for the proof below. Theorem beq_nat_true : forall n m, beq_nat n m = true -> n = m. I…
1
vote
1 answer

How to apply a lemma to 2 hypothesis

Theorem ev_plus_plus : forall n m p, even (n+m) -> even (n+p) -> even (m+p). Proof. intros n m p Hnm Hnp. We get this: 1 subgoal (ID 189) n, m, p : nat Hnm : even (n + m) Hnp : even (n + p) ============================ even (m +…
user4035
  • 19,332
  • 7
  • 51
  • 78
1
vote
1 answer

How to define exp for Church Numerals in coq?

I am currently learning coq thanks to the Software Fondation's ebook. I successfully wrote the addition as follow: Definition cnat := forall X : Type, (X -> X) -> X -> X. Definition plus (n m : cnat) : cnat := fun (X : Type) (f : X -> X) (x : X)…
Potiron
  • 11
  • 2
1
vote
1 answer

How to set implicit parameters for constructor

Playing with nostutter excersizes I found another odd behaviour. Here is the code: Inductive nostutter {X:Type} : list X -> Prop := | ns_nil : nostutter [] | ns_one : forall (x : X), nostutter [x] | ns_cons: forall (x : X) (h : X) (t : list X),…
user4035
  • 19,332
  • 7
  • 51
  • 78
1
vote
1 answer

Understanding specialize tactic

Trying to comprehend the answer of @keep_learning I walked through this code step by step: Inductive nostutter {X:Type} : list X -> Prop := | ns_nil : nostutter [] | ns_one : forall (x : X), nostutter [x] | ns_cons: forall (x : X) (h : X) (t : list…
user4035
  • 19,332
  • 7
  • 51
  • 78
1
vote
1 answer

IndProp: re_not_empty_correct

Lemma re_not_empty_correct : forall T (re : @reg_exp T), (exists s, s =~ re) <-> re_not_empty re = true. Proof. split. - admit. (* I proved it myself *) - intros. induction re. + simpl in H. discriminate H. + exists []. apply…
user4035
  • 19,332
  • 7
  • 51
  • 78
1
2 3