Questions tagged [proof]

A mathematical proof is any mathematical argument which demonstrates the truth of a mathematical statement. Informal proofs are typically rendered in natural language and are held true by consensus; formal proofs are typically rendered symbolically and can be checked mechanically. "Proofs" can be valid or invalid; only the former kind constitutes actual proof, whereas the latter kind usually refers to a flawed attempt at proof.

828 questions
2
votes
1 answer

Proof of dynamic programming solution for Leetcode 818: Racecar

The problem is as follows: Problem: "Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R'…
2
votes
2 answers

How do I write ∀x ( P(x) and Q(x) ) in Coq?

I'm trying out Coq, but I'm not completely sure what I'm doing. Is: Theorem new_theorem : forall x, P:Prop /\ Q:Prop Equivalent to: ∀x ( P(x) and Q(x) ) Edit: I think they are.
Peter
  • 435
  • 1
  • 4
  • 9
2
votes
1 answer

How do I formally prove the safety of a Rust crate with generics and trait bounds?

How to give formal proofs by hand? Is there a language specification, as formal as formal logic, that we can build our proof on? For example, how do I know if this module panics? mod my_mod { use std::marker::PhantomData; …
2
votes
1 answer

Modular arithmetic proofs in agda

I'm trying to prove (n : ℕ) → ∃[ m ] n * n ≡ 3 * m + 2 → ⊥. Typically I would prove this by rewriting it in terms of congruence, and then splitting on each case. There doesn't seem to be a modular arithmetic module in agda-stdlib. How should I…
Ace shinigami
  • 1,374
  • 2
  • 12
  • 25
2
votes
1 answer

I'm trying to build a proof in Coq that two different permutation definitions are equivalent, but the non-inductive side is not working

The two definitions are these: Inductive perm : list nat -> list nat -> Prop := | perm_eq: forall l1, perm l1 l1 | perm_swap: forall x y l1, perm (x :: y :: l1) (y :: x :: l1) | perm_hd: forall x l1 l2, perm l1 l2 -> perm (x :: l1) (x :: l2) |…
Andrey
  • 21
  • 1
2
votes
1 answer

Proof of optimality of greedy algorithm for scheduling

Unable to come up with a formal proof of optimality for algorithm A for the given problem. Have convinced myself that it is possible to execute some optimal schedule O in increasing order of the events' deadline. But don't know how to formally prove…
Ajax
  • 123
  • 1
  • 7
2
votes
1 answer

Coq: Simpl in match pattern when having an inequality hypothesis

I have a definition involving match, similar like this: Definition five (n: nat): bool := match n with | 5 => true | _ => false end. I try to proof something similar like this: Theorem fiveT: forall (n: nat), n <> 5 -> five n = false. Proof.…
Leo G.
  • 33
  • 2
2
votes
2 answers

Can you check for duplicates by taking the sum of the array and then the product of the array?

Let's say we have an array of size N with values from 1 to N inside it. We want to check if this array has any duplicates. My friend suggested two ways that I showed him were wrong: Take the sum of the array and check it against the sum…
Majd Odeh
  • 181
  • 1
  • 11
2
votes
0 answers

Missing Order.Lattice function from Arend standard library added by Intellij IDEA plugin

I tried to prove some lemmas about Implicative Lattice and decided to use function meet-monotone from Order.Lattice.MeetSemilattice. I found this function in manually downloaded standard lib, but when I'm trying to use it in my code the syntax…
warmte
  • 21
  • 2
2
votes
0 answers

Coinductive principle for streams

I am trying to prove the following principle for stream predicates (defined in the standard library). From Coq Require Import Streams. Lemma mystream_ind : forall A (P : Stream A -> Prop), (forall s, ForAll P (tl s) -> ForAll P s) -> …
pjm
  • 269
  • 1
  • 8
2
votes
0 answers

Equivalence of Edit Distance and Alignment Distance

(from: https://math.mit.edu/classes/18.417/Slides/alignment.pdf) The slide on the 11th page talks about how the Edit Distance and the Alignment Distance are equivalent. I understand how to prove that the Edit Distance will always be less than or…
2
votes
0 answers

Does this strict weak ordering have a name (spoilers for a specific coding puzzle)

There is a coding puzzle I have encountered on one of those sites (I don't recall if it was leetcode or something else) which goes as follows: Given a list of strings, return the lexicographically smallest concatenation that uses each of the strings…
Cereal
  • 156
  • 7
2
votes
2 answers

Proving A → ¬ (¬ A ∧ B) in Lean

I am having a hard time proving A → ¬ (¬ A ∧ B) with the Lean theorem prover. I set it up like this: example : A → ¬ (¬ A ∧ B) := assume h1: ¬ (¬ A ∧ B), assume h2: A, assume h3: B, show false, from sorry I was unable to find examples to prove this…
2
votes
2 answers

Convert a Bits8 to a `Subset Nat (`LT` 256)`

I have the following module: module Nat256 import Data.DPair import Data.Bits public export bits8ToNat256 : Bits8 -> Subset Nat (`LT` 256) bits8ToNat256 i = case i of 0 => 0 1 => 1 2 => 2 3 => 3 4 => 4 5 => 5 6 => 6 …
Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196
2
votes
2 answers

How to write a 'safe' head in coq?

I'm trying to do something in Coq similar to this liquid Haskell trick, which defines a partial function but proves it's actually total: {-@ head :: {xs:[a] | len xs > 0} -> a @-} head (x:xs) = x Here is my first attempt, but Coq doesn't like it…
Felipe
  • 3,003
  • 2
  • 26
  • 44