Questions tagged [induction]

Anything related to mathematical induction principle and techniques applied to computing. Please DO NOT USE this tag for math-only questions since they are off-topic on SO. This tag may be used for math-related questions only if it involves some programming activity or software tools (e.g. automatic theorem proving, etc.).

Anything related to mathematical induction principle and techniques applied to computing. Please DO NOT USE this tag for math-only questions since they are off-topic on SO. This tag may be used for math-related questions only if it involves some programming activity or software tools (e.g. automatic theorem proving, etc.).

262 questions
2
votes
2 answers

OCaml Proof by Structural Induction

Given the following function: let rec foo l1 l2 = match (l1,l2) with ([],ys) -> ys | (x::xs,ys) -> foo xs (x::ys)) Prove the following property: foo (foo xs ys) zs = foo ys (xs@zs) So far, I have completed the base case and…
David Farthing
  • 237
  • 2
  • 13
2
votes
4 answers

Induction on predicates with product type arguments

If I have a predicate like this: Inductive foo : nat -> nat -> Prop := | Foo : forall n, foo n n. then I can trivially use induction to prove some dummy lemmas: Lemma foo_refl : forall n n', foo n n' -> n = n'. Proof. intros. induction H. …
Pan Hania
  • 468
  • 4
  • 11
2
votes
2 answers

How to proof in Coq statements about given sets

How does one proof statements like the following one in COQ. Require Import Vector. Import VectorNotations. Require Import Fin. Definition v:=[1;2;3;4;5;6;7;8]. Lemma L: forall (x: Fin.t 8), (nth v x) > 0. Or, let's say you have a given list of…
Cryptostasis
  • 1,166
  • 6
  • 15
2
votes
1 answer

Haskell - Use induction to prove an implication

I've to prove by induction that no f xs ==> null (filter f xs) Where : filter p [] = [] filter p (x:xs) | p x = x : filter p xs | otherwise = filter p xs null [] = True; null _ = False no p [] = True no p (x:xs) | p x = False …
Fossa
  • 159
  • 1
  • 6
2
votes
1 answer

Using `dependent induction` tactic to keep information while doing induction

I have just run into the issue of the Coq induction discarding information about constructed terms while reading a proof from here. The authors used something like: remember (WHILE b DO c END) as cw eqn:Heqcw. to rewrite a hypothesis H before the…
thor
  • 21,418
  • 31
  • 87
  • 173
2
votes
2 answers

Prove length (h::l) = 1 + length l

I have trouble with these proofs that seem almost trivially obvious. For instance, in the inductive case if I assume the property in the title and I want to show: length (h'::h::l) = 1 + length (h::l) Where do I go from here? It is so obviously…
Connor
  • 59
  • 3
2
votes
0 answers

Induction proof of an Haskell custom function

I'm studying induction and I've some problems to figure out how to complete an induction proof of my "destutter" function that deletes consecutive duplicates in a list: destutter [] = [] …
Fossa
  • 159
  • 1
  • 6
2
votes
0 answers

Automatic inference of general rule based on examples

I am interested in the following problem that I would like to investigate. One problem I have is that I am not even sure what terms to search for for background information. I tried looking up grammar induction and similar techniques but they do not…
user10108
  • 21
  • 1
2
votes
1 answer

Introduction to Algorithms Third Edition - Exercise 2.3 -3 - Inductive proof of nlg(n)

I'm reading the book Introduction to Algorithms, Third Edition. In an exercise, we are asked to use inductive reasoning to prove T(n) = {2 if n = 2, 2T(n/2) + n if n > 2^k for k > 1} = nlgn Where lg is log base 2. The book provides the…
Mikey G
  • 181
  • 1
  • 9
2
votes
2 answers

Proof by induction with multiple lists

I am following the Functional Programming in Scala lecture on Coursera and at the end of the video 5.7, Martin Odersky asks to prove by induction the correctness of the following equation : (xs ++ ys) map f = (xs map f) ++ (ys map f) How to handle…
2
votes
1 answer

Structural induction for multi-way (rose) trees

Since multi-way trees can be defined as a recursive type: data RoseTree a = Node {leaf :: a, subTrees :: [RoseTree a]} is there a corresponding principle for performing structural induction on this type?
Rich Ashworth
  • 1,995
  • 4
  • 19
  • 29
2
votes
4 answers

How can I prove that elem z (xs ++ ys) == elem z xs || elem z ys?

I have the following: elem :: Eq a => a -> [a] -> Bool elem _ [] = False elem x (y:ys) = x == y || elem x ys How can I prove that for all x's y's and z's... elem z (xs ++ ys) == elem z xs || elem z ys I attempted to make the left side equivalent…
buydadip
  • 8,890
  • 22
  • 79
  • 154
2
votes
1 answer

Proving foldr f st (xs++ys) = f (foldr f st xs) (foldr f st ys)

I am trying to prove the following statement by structural induction: foldr f st (xs++yx) = f (foldr f st xs) (foldr f st ys) (foldr.3) However I am not even sure how to define foldr, so I am stuck as no definitions have been provided to me.…
Rumen Hristov
  • 867
  • 2
  • 13
  • 29
2
votes
1 answer

Proof through Number of Derivation Steps

Given G = {a, b, c, d}, {S, X, Y}, S, {S->XY, X->aXb, X->ab, Y->cYd, Y->cY, Y->cd}} Prove that |w|c-|w|d+|w|a≥|w|b |w|a is how many 'a's there are in the string. This makes sense that there will be more (or the same amount of) 'c's than 'd's as…
Matthew Cassar
  • 223
  • 2
  • 5
  • 13
2
votes
1 answer

equality on inductive types

How do I prove the following trivial lemma: Require Import Vector. Lemma t0_nil: forall A (x:t A 0), x = nil A. Proof. Qed. FAQ recommends decide equality and discriminate tactics but I could not find a way to apply either of them. For the…
krokodil
  • 1,326
  • 10
  • 18