logical-foundations

even_Sn_not_even_n - apply 1 hypothesis in another

末鹿安然 提交于 2020-03-23 12:22:30
问题 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 not. intros H1. induction H1 as [|n' E' IHn]. - inversion H. - inversion_clear H. apply IHn in H0. apply H0. + intros H. induction n as [|n' IHn]. - exfalso. apply H. apply ev_0. - apply evSS_inv'. Here is the result: 1 subgoal (ID 179) n' : nat H : ~ even (S

IndProp test_nostutter_4

别来无恙 提交于 2019-12-11 14:29:30
问题 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 := | ns_nil : nostutter [] | ns_one : forall (x : X), nostutter [x] | ns_cons: forall (x : X) (h : X) (t : list X), nostutter (h::t) -> x <> h -> nostutter (x::h::t). Example test_nostutter_4: not (nostutter [3;1;1;4]). Proof. intro. repeat match

Are Coq tacticals right associative or left associative?

你离开我真会死。 提交于 2019-12-11 07:21:14
问题 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 first? in particular I was trying to understand: Theorem In10 : In 10 [1;2;3;4;5;6;7;8;9;10]. Proof. repeat (try (left; reflexivity); right). Qed. 回答1: A good way of solving those problems on your own is to use tactics like idtac (always succeeds) and fail

Proving that a reversible list is a palindrome in Coq

断了今生、忘了曾经 提交于 2019-12-10 12:55:04
问题 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 to prove, from Software Foundations : Theorem rev_eq_pal : forall ( X : Type ) ( l : list X ), l = rev l -> pal l. My informal outlines of the proof are as follows: Suppose l0 is an arbitrary list such that l0 = rev l0 . Then one of the following three