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
0 answers

How does the divide and conquer algorithm work?

I am confused with Divide and Conquer (the technique we apply to solve a problem using recursion) and Induction. Like if I am sorting an array using recursion, I will divide the whole array. Something like below: void sortv(vector &v){ …
0
votes
1 answer

Lemma about Sortedness of concatenated lists

I have the following inductive definition for sortedness of a list: Class DecTotalOrder (A : Type) := { leb : A -> A -> bool; leb_total_dec : forall x y, {leb x y}+{leb y x}; leb_antisym : forall x y, leb x y -> leb y x -> x = y; leb_trans…
Tilman Zuckmantel
  • 643
  • 1
  • 6
  • 18
0
votes
1 answer

How to use the rewrite command in coq for inner subexpressions?

I have a lemma telling that addition commutes: Lemma commute: for all x y, add x y = add y x. Now in my goal, I am trying to prove that: add (add x (S y)) z = add x (S (add y z)) I would like to use my lemma to rewrite the inner add on the left add…
mercury0114
  • 1,341
  • 2
  • 15
  • 29
0
votes
1 answer

How in Coq to make `simpl` command perform only one step reduction?

My definition of add is as follows: Fixpoint add n m := match n with | 0 => m | S p => add p (S m) end. Later in the file I am trying to prove the following goal: add (S n) 0 = S n I call simpl command expecting it to reduce add (S n) 0 to…
mercury0114
  • 1,341
  • 2
  • 15
  • 29
0
votes
1 answer

How to prove n + S m = S (n + m) in Coq

So, I am trying to learn Coq using the "Introduction to Computational Logic" script and I have been given an excercise. It is to prove the following: "forall a b, a + S b = S (a + b)". I am given a definition of "nat_ind": (p : nat -> Prop) …
0
votes
0 answers

Finding the Time Complexity of a recursive function using Induction

I have a recursive function: void review_func(double val){ if(val>=1.0){ review_func(val/2.0) } } I was able to solve its time complexity using induction and the master theorem. However I am pretty doubtful about the result I got from…
Monsi
  • 43
  • 5
0
votes
0 answers

Prove (2^n - 1) via induction

I have this program that, when run, has prints in this pattern: a(0) = 0 a(1) = 1 a(2) = 2 + a(1) = 3 a(3) = 3 + a(2) + a(1) = 3 + 3 + 1 = 7 a(4) = 4 + 3 + 3 + 1 = 15 At this point I observe that there is a pattern of it becoming O(2^n - 1).…
Coco Loco
  • 1
  • 3
0
votes
1 answer

How can I figure out loop invariant in my binary search implementation?

bool binsearch(int x) { int i = 0, j = N; while(i < j) { int m = (i+j)/2; if(arr[m] <= x) { if(arr[m] == x) return true; i = m+1; } else { j = m; } …
0
votes
1 answer

How to derive syntax of language (From the book Types and Programming Languages)?

I am reading the book Types and Programming Languages by Benjamin C. Pierce. the author talk about deriving syntax for a language in section 3. Section 3.2.3 has the following content. For each natural number i, define a set S1 as follows S0 = Empty…
Ashwin
  • 12,691
  • 31
  • 118
  • 190
0
votes
0 answers

Inductive proof, that a certain algorithm does not claim for a not 3-colorable graph to be 3-colorable

In theoratical informatics, we were given a certain algorithm in pseudocode: G = (V, E) is a undirected graph while(G has vertices with degree <=2) remove those vertices if(G is empty) Graph is 3-colorable else Graph may or may not be…
user2762996
  • 566
  • 1
  • 5
  • 16
0
votes
1 answer

How to uniformly map over an inductive graph?

This post is about fgl, the usual Haskell graph library. Suppose I have a graph and I want to label the leaves, a leaf being a vertex without outgoing edges. I draft the trivial predicate on a context: isLeaf :: Context a b -> Bool isLeaf (_, _, _,…
Ignat Insarov
  • 4,660
  • 18
  • 37
0
votes
2 answers

Proof by Induction that Knapsack recurrence returns optimum solution

I have to show by induction that if w < w_i then Opt(i,w) = Opt(i-1,w) , else Opt(i,w) = max{ Opt(i-1,w), Opt( i-1, w - w_i) + w_i) } produces the optimal solution for the Knapsack Problem (Dynamic Programming approach) I know how mathematical…
0
votes
1 answer

Understanding the induction on evidence in coq

I am working on the theorem ev_ev__ev in IndProp.v of Software Foundations (Vol 1: Logical Foundations). Theorem ev_ev__ev : forall n m, even (n+m) -> even n -> even m. Proof. intros n m Enm En. induction En as [| n' Hn' IHn']. - (* En: ev_0…
hengxin
  • 1,867
  • 2
  • 21
  • 42
0
votes
1 answer

A proof about a mutually inductive proposition

Consider the following code: Require Import List. Set Implicit Arguments. Inductive even_length {A : Type} : list A -> Prop:= | e_nil : even_length nil | e_cons : forall e l, odd_length l -> even_length (e::l) with odd_length {A : Type} : list A…
Rafael Castro
  • 579
  • 5
  • 14
0
votes
1 answer

C++ Induction Algorithm very slow and Dynamical Programming

I have a mathematical control problem which I solve through Backward induction. The mathematical problem is the following : with K less than n. And final conditions What is J(0,0,0) ? For this purpose I am using c++ and mingw 32 bit as a…
Al Bundy
  • 184
  • 1
  • 12