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
1
vote
2 answers

Coq: defining more than two mutually recursive functions on inductive type

I am defining three mutually recursive functions on inductive type event, using two different ways: using with and fix keywords, however, Coq complains about principal argument and The reference ... was not found in ..., respectively. Two…
Khan
  • 303
  • 2
  • 14
1
vote
1 answer

Induction on lists - Proving Stronger Property (Haskell)

I'll say right off the bat this is for an assignment, and I'm not looking for an answer - just some direction, since I've been working on it for quite a while now. Given the following tail-recursive sum function: sumTR [ ] acc = acc sumTR (x:xs)…
1
vote
1 answer

Proof Structural Induction on IntSet union

Assume you have the following definition: abstract class IntSet { def incl(x: Int): IntSet def contains(x: Int): Boolean def union(other: IntSet): IntSet } case class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet { …
Salailah
  • 435
  • 7
  • 12
1
vote
1 answer

Improve recursive algorithm for finite products of primes

From the book How to Read and Do Proofs by Daniel Solow, I took the following problem: Any integer n >= 2 can be expressed as a finite product of primes. After looking at the proof by induction in the book, I tried then to implement an algorithm…
1
vote
1 answer

finding complexity using induction

I was asked to prove: for every n>=n0 and T(n) = T(an) + T(bn) + n for n>n0, a+b<1, its complexity is T(n) = O(n). Hint: prove by induction that: T(n) ≤ cn for a suitable c. I wanted to know how to prove by induction in this case. Thank you.
Rotem
  • 13
  • 3
1
vote
1 answer

Verifying a Dafny method that shifts a region of an array

I'm using Dafny to make a delete method where you receive: char array line the length of the array l a position at the number of characters to delete p First you delete the characters of line from at to at + p, and then you must move all the…
Miguel Morujão
  • 1,131
  • 1
  • 14
  • 39
1
vote
2 answers

Prove "rev (rev l) = l" in Coq

This is one of the exercise given to me, I got stuck almost immediately after doing an induction on l. I dont know what other assertion to make here. I'm not allowed to use advanced tactics like auto, intuition etc. Fixpoint snoc {A : Type} l a :…
1
vote
1 answer

Dafny and counting of occurrences

I've been looking at the use of lemmas in Dafny but am finding it hard to understand and obviously the below example doesn't verify, quite possibly because Dafny doesn't see the induction or something like a lemma to prove some property of count?…
vivichrist
  • 309
  • 2
  • 9
1
vote
1 answer

Inductive Proof that a recurrence isn't O(n) by showing it is Omega(nlogn)

Note: This is related to homework. I am attempting to show that T(n/3) + T(2n/3) + n >= cn , for all c > 0. When I attempted this, the base case failed (T(1) = 1 >= cn, for all c > 0, is not true). So to work around this, I thought to show that the…
user2303325
  • 766
  • 6
  • 18
1
vote
2 answers

Apply native induction principle in coq with several arguments

I'm reading the book Software Foundation. On the chapter "More on Induction", the authors talk about the induction principle generated by coq when a inductive type is define. An exercice is the following. Encapsulate the notion of association for…
Saroupille
  • 609
  • 8
  • 14
1
vote
1 answer

Structural Induction and Induction Hypothesis in Haskell

I am trying to prove 'ns' with the statement below using structual induction. All lists 'ns' are of type [Int] and all 'm' are of type Int. foldl (+) m ns = m + (sum ns) Definitions: sum :: [Int] -> Int -- summation of an Int list sum [] …
Sohaib
  • 25
  • 4
1
vote
1 answer

Proof of reverse binary strings?

If w : {1...L} → {0,1} is a binary string, the complement of w, denoted wC, is a string of length L defined by: wc(i) = 1 - w(i). The reverse of w, denoted wR, is the string of the length L defined by wR(i) = w(L + 1 - i). Use these definitions to…
1
vote
1 answer

Proof by induction on Context Free Grammars

So I have this problem I am working on regarding inductive proofs on Context Free Grammars. Given this grammar S-> aSb | SS | ab Prove using induction that no string generated by the grammar starts with abb. It's easy to see that this is in fact…
user3627858
  • 11
  • 1
  • 3
1
vote
1 answer

Prove using induction that the loop invariant holds

//Precondition: n > 0 //Postcondition: returns the minimum number of decial digits // necessary to write out the number n int countDigits(int n){ 1. int d = 0; 2. int val = n; 3. while(val != 0){ 4. val = val / 10; …
user3567126
  • 47
  • 1
  • 8
1
vote
2 answers

Proving/Disproving BigO, and BigTheta

I am having issues fully understanding how to prove some of the following statements. For instance I have a statement: n^2logn = O(n^2). Correct me if I am wrong, but this states that n^2 is bigO of n^2logn. Meaning that n^2 grows faster than…
Nick
  • 95
  • 3
  • 15