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

Proving algorithm correctness by induction

I recently started reading a book on data structures and it starts off with an introduction in algorithms. In one exercise it asks to prove an algorithm by induction and a loop invariant. The algorithm in pseudocode is: Algorithm DEC2BIN(int n,…
Sovengarde
  • 27
  • 1
  • 2
  • 5
1
vote
1 answer

Dafny inductive lemma: cannot infer postcondition of induction hypothesis

I am trying to define the small-step semantics of a very simple language with arithmetic expressions (source code available here). For the sake of simplicity, we assume that the language only allows literals and the unary minus (-exp). datatype…
1
vote
1 answer

Doing a double induction in Coq properly

I am trying to prove the plus_n_Sm theorem from the Induction chapter in Software Foundations Theorem succ_is_plus_1: forall n: nat, S n = n + 1. Proof. induction n as [| n' ind_hyp]. - simpl. reflexivity. - simpl. rewrite <- ind_hyp.…
Gergely
  • 6,879
  • 6
  • 25
  • 35
1
vote
1 answer

What is an inductively defined data type?

What are some examples of inductive data types? How do inductive types differ from their non-inductive counterparts? What can they do that is impossible otherwise? When should they not be used? Code snippets in any language would be greatly…
1
vote
1 answer

How do I write a custom induction rule over a parameterized inductive set?

I'm trying to write a custom induction rule for an inductive set. Unfortunately, when I try to apply it with induction rule: my_induct_rule, I get an extra, impossible to prove case. I have the following: inductive iterate :: "('a ⇒ 'a ⇒ bool) ⇒ 'a…
Zyzzyva
  • 227
  • 1
  • 7
1
vote
2 answers

How can I prove irreflexivity of an inductively defined relation in Isabelle?

Consider as an example the following definition of inequality of natural numbers in Isabelle: inductive unequal :: "nat ⇒ nat ⇒ bool" where zero_suc: "unequal 0 (Suc _)" | suc_zero: "unequal (Suc _) 0" | suc_suc: "unequal n m ⟹ unequal (Suc…
Wolfgang Jeltsch
  • 781
  • 5
  • 10
1
vote
0 answers

How to prove by induction that binary search tree is of AVL type?

Could you please help how to prove by induction that current algorithm which tests if the binary search tree is of AVL type is correct? int checkHeight(TreeNode root){ if(root == null) return 0; int leftHeight :=…
1
vote
2 answers

Coq vector permutations

I need to reason about vectors' permutations in Coq. The standard library only includes permutation definitions for lists. As my first attempt, I tried to mimic it for vectors as: Inductive VPermutation: forall n, vector A n -> vector A n -> Prop…
krokodil
  • 1,326
  • 10
  • 18
1
vote
1 answer

Java Sigma Equation Solving sigma(i=1 to k)((-1)^i+1)(i)(i+1) Timedout for long values

Getting timedout error while calculating the value of sigma notation sigma(i=1 to k)((-1)^i+1)(i)(i+1) for very long values example :10^8 .Can any one guide me where I am doing wrong import java.io.*; import java.util.*; public class…
Dr.jeon
  • 15
  • 4
1
vote
1 answer

Induction rule case names (Isabelle)

Some induction rules have case names: the default one has case 0 and case (Suc n) for example. Given a rule, e.g. int_induct, how do I find out its case names (if, indeed, it has these) without looking in the theory containing this lemma?
IIM
  • 533
  • 3
  • 11
1
vote
1 answer

Coq: goal variable not transformed by induction when appearing on left side of arrow

I am trying to prove the following theorem by induction over l. It's an easy theorem on paper, however when I try to prove it in Coq I am not getting the induction goal I would expect. Theorem nodup_app__disjoint: forall {X: Type} (l: list X), …
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

Structural Induction - (zip xs ys)!!n = (xs!!n, ys!!n)

Given n >= 0 and n < min (length xs) (length ys) show that (zip xs ys)!!n = (xs!!n, ys!!n) with structural Induction over xs. Is it even possible to do this in a clean way? I cant find any spots where I can use the Induction Hypothesis.
jmply
  • 41
  • 6
1
vote
1 answer

To prove equality of functions

Given the two functions: sumOne 0 = 0 -- I.a sumOne m | m > 0 = sumOne (m-1) + m -- II.a endSum m = helpSum 0 m -- I.b where helpSum x 0 = x …
SOAP
  • 159
  • 1
  • 1
  • 5
1
vote
1 answer

Proof by induction with three base cases (Isabelle)

I want to be able to prove a statement by induction on n (of type nat). It consists of a conditional whose antecedent is only true for n >= 2. A conditional whose antecedent is false is always true. So I'd like to prove the cases n=0, n=1 and n=2…
IIM
  • 533
  • 3
  • 11
1
vote
2 answers

Induction Principle for Propositions with Lists (or: LNR for expressions with nested lists)

Disclaimer: I fear this post got quite long, however, I feel that in a smaller setup some valuable background information would be lost. I am currently trying to change my formalisation to use the locally nameless representation by Charguéraud et al…
ichistmeinname
  • 1,480
  • 10
  • 19