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
0
votes
1 answer

Coq induction hypothesis is wrong

I'm trying to prove a simple induction on two lists, and for some reason Coq writes the induction hypothesis wrong. Here is my proof: Lemma eqb_list_true_iff_left_to_right : forall A (eqb : A -> A -> bool), (forall a1 a2, eqb a1 a2 = true <->…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
0
votes
1 answer

Coq: How to produce a strong polymorphic dependent type hypothesis

I have been having some problems with dependent induction because a "weak hypothesis". For example : I have a dependent complete foldable list : Inductive list (A : Type) (f : A -> A -> A) : A -> Type := |Acons : forall {x x'' : A} (y' : A) (cons'…
Tiago Campos
  • 503
  • 3
  • 14
0
votes
1 answer

Proof by induction that every non-empty tree of height h contains fewer than 2^n+1 nodes

I am stuck on the induction case of a problem. The problem: Define the height of a tree as the maximum number of edges between the root and any leaf. We consider the height of an empty tree to be -1, and the height of a tree consisting of a…
0
votes
1 answer

Where are are the errors in my inductive proof?

I was asked the following question on an exam and it was only marked wrong with no other marks on it. I went to see the TA who marked it and he could only tell me that it was wrong. I suspect that he did not have the time to explain it to me. This…
0
votes
3 answers

Tokens in a bag

We have n tokens. Every token is either red, blue, or green. These n tokens are in a bag Repeat the following until the bag is empty: 1) If there are more than two tokens in the bag. take two random tokens out of the bag. Otherwise, empty the…
stebben
  • 11
  • 1
0
votes
0 answers

Induction hypothesis and the operator %

In the program https://rise4fun.com/Dafny/tlpls Dafny is not able to infer the induction hypothesis from the recursive call to the lemma. Moreover, what is more surprising is in MVS, if you change assert by assume, and again by assert, then the…
jiplucap
  • 155
  • 7
0
votes
0 answers

scala: proving two functions with structural induction

I have the following two functions in scala: def sum(ls: List[Int]): Int = ls match { case Nil => 0 case l::ls => l + sum(ls) } def turn(ls: List[Int]) : List[Int] = ls match { case Nil => List() case l::ls => append(turn(ls),…
MBD
  • 95
  • 3
  • 10
0
votes
1 answer

proving the correctness of this recursive algorithm using induction

int sumHelper(int n, int a) { if (n==0) return a; else return sumHelper(n-1, a + n*n); } int sumSqr(int n) { return sumHelper(n, 0); } Guys, I am supposed to prove this piece of code which uses tail recursion to sum up the square of…
Manny
  • 11
  • 1
  • 5
0
votes
1 answer

Proving the partial correctness of the program

Below is the function that finds max number in the array, so prof taught us to prove the partial correctness. He gave the solution proving the loop invariant is maintained. Can any body explain me the solution? find_max (a: ARRAY [INTEGER]):…
Noor Ahmed
  • 11
  • 1
0
votes
1 answer

Recurrence with logs T(n) = T(logn)+log(log(n))

How to find T(n)=Θ(f(n)) for the recurrence T(n) = T(logn)+log(log(n))? I think T(n)= Θ(log(n)) but the proof is the hard part for me. I'm going to attempt to prove by substitution but please help me with that. I also tried a proof by induction…
Sudocode
  • 69
  • 2
  • 10
0
votes
1 answer

Structual induction in Haskell

Can anyone give me an example of Structural induction in Haskell? I can't find nothing online about it, I have been given a hypothesis but having trouble formulating the base case. The hypothesis is: For all lists xs of type [a] and all x of type a…
AlonErebos
  • 17
  • 6
0
votes
1 answer

How can I combine rule induction with variable generalization in Isabelle?

In Isabelle, I can generalize variables in induction proofs using the arbitrary keyword. This definitely works for ordinary induction, like in apply (induction n arbitrary: m). I can also have rule induction, like in apply (induction rule:…
Wolfgang Jeltsch
  • 781
  • 5
  • 10
0
votes
0 answers

Prove Number of Multiplications in Exponentiation by Squaring Algorithm

I am trying to find the number of multiplications required when executing an algorithm which uses Exponentiation by Squaring I was reading about on Wikipedia. The section, Computational Complexity, mentions that the algorithm requires at most…
Mant1c0r3
  • 129
  • 1
  • 5
0
votes
0 answers

Proof by Induction that for a full non-empty binary tree (N nodes, L leafs), N = 2L - 1

So I assume the base case is N = 1? I'm starting with 2L-1=2L-3+2=[2(L-1)-1]+2, but I don't know where to go from there. How should I go about the induction proof? Thanks!
0
votes
1 answer

Is it possible to jointly recurse on a pair of variables in Coq?

Let's say that I'm trying to prove the following: Theorem le_s_n : forall n m, S n <= S m -> n <= m. I feel like it might be productive to perform induction on the pair (n, m). The cases would be something like (0, 0), (0, S m'), (S n', 0), and (S…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46