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
1
vote
1 answer

Proving MStar' in Logical Foundations (IndProp.v)

In Logical Foundations' chapter on Inductive Propositions, the exercise exp_match_ex1 involves the following definitions: Inductive reg_exp (T : Type) : Type := | EmptySet | EmptyStr | Char (t : T) | App (r1 r2 : reg_exp T) | Union (r1 r2…
user566206
  • 47
  • 4
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
  • 22,508
  • 11
  • 59
  • 94
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
  • 22,508
  • 11
  • 59
  • 94
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
  • 22,508
  • 11
  • 59
  • 94
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
  • 22,508
  • 11
  • 59
  • 94
1
vote
1 answer

even_Sn_not_even_n - apply 1 hypothesis in another

Unfortunately I got stuck again: 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. unfold…
user4035
  • 22,508
  • 11
  • 59
  • 94
1
vote
1 answer

How to split the length inequality hypothesis in the pumping lemma?

This is the 5 star exercise from Software Foundations. Lemma pumping : forall T (re : @reg_exp T) s, s =~ re -> pumping_constant re <= length s -> exists s1 s2 s3, s = s1 ++ s2 ++ s3 /\ s2 <> [] /\ forall m, s1 ++ napp m s2 ++ s3…
Marko Grdinić
  • 3,798
  • 3
  • 18
  • 21
1
vote
1 answer

Logic: All_In can't expand nested forall

I am facing a pretty strange problem: coq doesn't want to move forall variable into the context. In the old times it did: Example and_exercise : forall n m : nat, n + m = 0 -> n = 0 /\ m = 0. Proof. intros n m. It generates: n, m :…
user4035
  • 22,508
  • 11
  • 59
  • 94
1
vote
1 answer

Logic: In_example_2

Here is the code from the book: Example In_example_2 : forall n, In n [2; 4] -> exists n', n = 2 * n'. Proof. (* WORKED IN CLASS *) simpl. intros n [H | [H | []]]. - exists 1. rewrite <- H. reflexivity. - exists 2. rewrite <- H.…
user4035
  • 22,508
  • 11
  • 59
  • 94
1
vote
1 answer

Less then function

I am passing through coq course "Logical Foundations". Solving problem: Having less or equal function: Fixpoint leb (n m : nat) : bool := match n with | O => true | S n' => match m with | O => false | S m' => leb n' m' …
user4035
  • 22,508
  • 11
  • 59
  • 94
1
vote
1 answer

Inductive types carrying proofs

There is this one exercise in "Software Foundations" that I've been trying to solve correctly for some time now but I've actually hit a wall in terms of trying to write down the function being asked for. Here is the relevant part of the…
David K.
  • 6,153
  • 10
  • 47
  • 78
1
vote
1 answer

Are Coq tacticals right associative or left associative?

I was going through software foundations and got the example: repeat (try (left; reflexivity); right). and was confused what this meant. For example do we get: try [ (left; reflexivity); right ] or [try (left; reflexivity);] right second or…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
0
votes
1 answer

I have been stuck on MApp for pumping lemma

I have been trying to solve Pumping lemma in Coq. I was on the third subgoal, Mapp. Lemma pumping : forall T (re : reg_exp T) s, s =~ re -> pumping_constant re <= length s -> exists s1 s2 s3, s = s1 ++ s2 ++ s3 /\ s2 <> [] /\ …
0
votes
1 answer

Cannot focus on a remaining unfocused goal in Coq

I am trying to prove the pumping Lemma (which is one of the exercises of the Logical Foundations book). I thought I had completed the MStarApp case but the interpreter tells me that there are still unfocused goals remaining. Only I can't bring this…
user566206
  • 47
  • 4
0
votes
0 answers

Stuck at the MApp case in Logical Foundation's pumping lemma

I am teaching myself to use the Coq proof assistant through the Logical Foundations course. I am stuck trying to prove the MApp case of the pumping lemma. Lemma pumping : forall T (re : reg_exp T) s, s =~ re -> pumping_constant re <= length s…
user566206
  • 47
  • 4