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

How do I apply inductive reasoning to `GHC.TypeLits.Nat`?

Consider this definition of zip for the usual vectors length indexed by Peano numerals: {-# language DataKinds #-} {-# language KindSignatures #-} {-# language GADTs #-} {-# language TypeOperators #-} {-# language…
Ignat Insarov
  • 4,660
  • 18
  • 37
5
votes
3 answers

Inductive Specification: Top-down vs Bottom-up vs Rules of Inference?

Please bear with me on this one. I am first going to describe an example from the book, and then ask my question at the end. According to the text on Programming Language Paradigms: Inductive specification is a powerful method of specifying a set…
Sahat Yalkabov
  • 32,654
  • 43
  • 110
  • 175
5
votes
3 answers

Generating finite lists of primes in Haskell

There are a lot topics on generating prime numbers in Haskell, but in my opinion, they all rely on 'isPrime' function, which, if we don't know the primes sequence yet, should look like: isPrime k = if k > 1 then null [ x | x <- [2,3..(div k 2) + 1],…
FoxZ322
  • 61
  • 4
5
votes
2 answers

Coq simpl / unfold only once. (Replace part of goal with the result of one iteration of a function.)

I am an instructor at university for a class titled Type Systems of Languages and the professor used the following example for inductive proofs in Type Theory on the board last lecture: Suppose, that there are natural numbers defined inductively…
Isti115
  • 2,418
  • 3
  • 29
  • 35
5
votes
2 answers

Proving the fusion law for unfold

I was reading Jeremy Gibbons' article on origami programming and I got stuck on exercise 3.7, which asks the reader to prove the fusion law for list unfolds: unfoldL p f g . h = unfoldL p' f' g' if p . h = p' f . h = f' g . h = h . g' The…
Dan Oneață
  • 968
  • 7
  • 14
5
votes
3 answers

Coq induction on modulo

I'm new with coq and i really have difficulty in applying the induction. as long as I can use theorems from the library, or tactics such as omega, all this is "not a problem". But as soon as these do not work, I'm always stuck. To be precise, now i…
best wish
  • 55
  • 5
5
votes
1 answer

Coq induction start at specific nat

I'm trying to learn coq so please assume I know nothing about it. If I have a lemma in coq that starts forall n m:nat, n>=1 -> m>=1 ... And I want to proceed by induction on n. How do I start the induction at 1? Currently when I use the "induction…
AvatarOfChronos
  • 867
  • 9
  • 24
5
votes
2 answers

What are inductive predicates?

How would you explain inductive predicates? What are they used for? What's the theory behind them? Are they only present in dependent type systems, or in other systems as well? Are they related to GADT's in some way? Why are they true by default in…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
5
votes
4 answers

Double induction in Coq

Basically, I would like to prove that following result: Lemma nat_ind_2 (P: nat -> Prop): P 0 -> P 1 -> (forall n, P n -> P (2+n)) -> forall n, P n. that is the recurrence scheme of the so called double induction. I tried to prove it applying…
5
votes
1 answer

Why must coq mutually inductive types have the same parameters?

Following Arthur's suggestion, I changed my Fixpoint relation to a mutual Inductive relation which "builds up" the different comparisons between games rather than "drilling down". But now I am receiving an entirely new error message: Error:…
dspyz
  • 5,280
  • 2
  • 25
  • 63
5
votes
1 answer

Substitution method for solving recurrences

First of all sorry for asking such a basic question. But I am having difficulties understanding substitution method for solving recurrences.I am following Introduction to Algo.s -CLRS. As I am not able to find enough examples and ambiguity is the…
Arjun Thakur
  • 345
  • 1
  • 5
  • 17
5
votes
2 answers

How do you use Induction to connect to a local SQLite database?

I'm trying to use Induction to connect to my local SQLite database however I've no idea of how to make the connection. In previous SQLite clients I've simply opened the database file. What properties should I be putting into these fields? My…
Peter Nixey
  • 16,187
  • 14
  • 79
  • 133
4
votes
3 answers

What's wrong with this inductive proof that mergesort is O(n)?

Comparison based sorting is big omega of nlog(n), so we know that mergesort can't be O(n). Nevertheless, I can't find the problem with the following proof: Proposition P(n): For a list of length n, mergesort takes O(n) time. P(0): merge sort on the…
rjkaplan
  • 3,138
  • 5
  • 27
  • 33
4
votes
1 answer

How does one use identity elimination (in agda) to prove Eckmann Hilton for higher dimensional paths in HoTT?

I'm trying to replicate the main lemma in the HoTT book (page 70) for proving the Eckmann Hilton Theorem, only using J (no pattern matching). It says "But, in general, the two ways of defining horizontal composition agree, α ⋆ β = α ⋆' β, as we can…
user5775230
4
votes
1 answer

How to define an inductive type mutually recursive with a function?

I want to define an inductive type Foo, with constructors accepting as arguments some properties. I want those properties to depend on inductive arguments of the type I am currently defining. I want to be able to collect some data from them inside…
Joald
  • 1,114
  • 10
  • 32
1
2
3
17 18