## Why does `ev n (S(S n))' decrease the number and not increase it?

primitive recursive function examples
how to show a function is primitive recursive
zero function is a primitive recursive function
subtraction function is primitive recursive
introduction to recursive function theory in toc
multiplication is not a primitive recursive function
ackermann function
total computable function

I was going through the software foundations course and saw the following simple code:

```Inductive ev : nat -> Prop :=
| ev_0 : ev 0
| ev_SS : forall n : nat, ev n -> ev (S (S n)).
```

however, when the use the `apply ev_SS.` tactic on a proof that `ev 4` is true:

```Theorem ev_4 : ev 4.
Proof.  (* goal: ev 4*)
apply ev_SS. (* goal changed to: ev 2, why??? *)
apply ev_SS.
apply ev_0.
Qed.
```

the application of `ev_SS.` confuses me. If I plugged in a number to the "inference rule" I'd get it's increasing not decreasing:

```ev 2 == ev 2 -> ev (S (S 2)).
```

what am I misunderstanding?

Similarly, whats going on here:

```Theorem ev_4' : ev 4.
Proof.
apply (ev_SS 2 (ev_SS 0 ev_0)).
Qed.
```

Is there a better way in general to explore how transformations happen from one place to another in Coq? If I could do that I could inspect more clearly how things happen in the prover and why.

The tactic `apply` attempts to use the function/lemma/etc. to prove the current goal. In your case, the current goal was `ev 4`, so to use `ev_SS`, we need to match the conclusion of `ev_SS` with the goal. `ev_SS : forall n : nat, ev n -> ev (S (S n)).`, so the conclusion is `ev (S (S n))`. To match this with `ev 4`, `n` must be 2.

Once `apply` figures out what you still need to prove, it makes those things new goals. In this case, `ev_SS` takes as premises the natural number `n` and something of type `ev n`. Since it figured out that `n` must be 2, that leaves `ev 2` as the goal. The next usage of `apply` uses `n := 0`, so the remaining goal is `ev 0`. Finally, `ev_0` doesn't have any premises, so using `apply ev_0` leaves no remaining goals.

If that doesn't help, think about what the informal proof of this would look like. By definition, zero is an even number, and if n is an even number, n + 2 is even. How would we prove that 4 is even? Well, it's even because 2 is even. Why? 2 is even because 0 is even. Why? 0 is even by definition.

Theorem `ev_4'` has the whole proof term at once. `apply` sees that there's nothing more to prove, so there are no new goals. This usage of apply is exactly the same as the tactic `exact`.

To learn the details of how tactics work, I recommend reading the documentation. However, since the documentation often gets technical and lacks examples, it's important to read other people's Coq scripts and simply experiment yourself.

in maths I am more used to arriving at the goal from the hypothesis and then arriving at the conclusion that way. But it seems that in Coq we usually start with the goal, which seems backwards (though correct). Is that true in general for Coq or was it just for this example?

It's possible to work up from the premises rather than down from the goal using something like `set (ev_2 := ev_SS ev_0)`, then `exact (ev_SS ev_2)`. This might make a good separate question.

also why is ev_0 : ev 0 treated as a true proposition? Is it because its part of an inductive definition?

Yes. Remember that `ev` is defined as

```Inductive ev : nat -> Prop :=
| ev_0 : ev 0
| ev_SS : forall n : nat, ev n -> ev (S (S n)).
```

so `ev_0 : ev 0` by definition.

can you also explain to me what the syntax apply (ev_SS 2 (ev_SS 0 ev_0)). means?

This means "call the tactic `apply` with the argument `(ev_SS 2 (ev_SS 0 ev_0))`. In case you haven't realized yet, Coq uses the syntax `f x` in place of what's usually written `f(x)` in mathematics. Coq also uses currying to represent functions with multiple arguments. Instead of `f(x, y)`, we write `f x y`. This really means something like `f(x)(y)`, so that `f(x)` is a function that takes `y` as an argument. If we were to rewrite that line using the more conventional syntax, it would be `apply(ev_SS(2, ev_SS(0, ev_0)))`.

Chemistry of N-Thiosulfinylamines, TABLE IV Bond Lengths of Thiocumulenes X = S = Y X = S = Y N = S ( 8 ) S = 0 ( 8 ) Reference 4 eV ) , " it can be assigned to the terminal sulfur atom of the N  Enterprise value (EV) is a metric used to value a company and is usually considered a more accurate reflection of a company's value compared to market capitalization. The enterprise value of a

When you evaluate the term, "`n` will increase", but when you do an inductive proof, you ask "how did I get here?" And, if you have a proof that `ev (S (S n))` is true, then the only way you could have arrived there (if your logic is sound) is that also `ev n` is true.

Proceedings of the Tenth International Conference on Calorimetry , N 's 0 I N N. I-I-I r—l g I I S I i 50 52 54 56 58 60 62 64 65 68 70 50 52 54 58 58 45 – N 15 - o, is - S. 10 - N SS 5 - N ^{\, 5 - |--—s N- l–skişk-ı n r=r— 50 52 54 56 (3.07 eV) and 540 nm (2.30 eV) with widths of 0.76 and 0.19 eV respectively. Enterprise value-to-sales (EV/sales) is a valuation measure that compares the enterprise value (EV) of a company to its annual sales. EV-to-sales gives investors a quantifiable metric of how much

After reading more of the Coq documentation on tactics I think I was confused more in general about Coq tactics than about this specific example. It seems from my reading of what tactics are is that `tactics implement backward reasoning.` as it says in the documentation. From docs: `"to prove this I have to prove this and this". For instance, to prove A ∧ B, I have to prove A and I have to prove B.` So to prove `ev 4` we need to prove `ev 2` and so on. Apply just tries to match the current goal to whatever term we feed it and produce a certain number of subgoals we need to prove now prove or match.

I think the main thing is that because of the definition of `ev_SS` we know that if `ev 2` is true then because we defined the implication to be true `ev 2 => ev 4` then we can conclude `ev 4`. So we really only need to check that `ev 2` is true. If we do prove that then by Modus Ponens (MP) we know that `ev 4` is true. So this is why backwards reasoning "works" because we match the goals with the conclusion of some true inference rule and thus the goal is true when we show the premises are true (because of the inference rule). I am saying this because it seemed odd to me to start from the goal because we didn't know this was true (yet). Though, now I see we do show the goal is true by simply showing premises and matching the right inference rules. At least for this example.

I assume in general tactics implement some sort of backwards reasoning and we need to show the subgoals, not sure if its always an inference rule but I think the general idea makes sense to me right now though.

Abbott's Digest of All the New York Reports : With Tables of , The references are to the subject or title in the Digest , and to the paragraph . McKie v . People , ev . , 101 n . tain Ink Co . , contracts , ref . , 5 . Maier v . Homan Percival , 102 tachment , 39 n , ; bills , n . master and s . , 6 . N . Y . , 675​  Why electric? There are many reasons to consider an EV over an ICE car. The obvious one is the lack of localized emissions.

Fundamental Problems of Mesoscopic Physics, With these assumptions we can label the states \n, s) using the spin variable s Thus, from now on we use the notation T , instead of T . , , s—>s \n,s)—*\n,s) In s ± 1) to contribute to transport is with ng — ng — nTTM(n) and -r)eV < -Ephg  By running on electricity generated by fuels sourced within the United States instead of on foreign fossil fuels, EVs can go a long way toward increasing our national security. EVs are putting a dent in the \$25 billion sent overseas each month in exchange for foreign oil.

The Physics of Atoms and Quanta: Introduction to Experiments and , (b)N)"N po 1 2 3 A. =–(s , s) | y,(r). E[eV] – 57.76 –55.87 – 55.21 = X | W:(r)ó, V, (r)drjy:(r)ó, V,(r)dr" Eexp [eV] – 58.31 – 56.01 L + S . n : I -- / | | T ~a That is, L and S.) 15.7 Taylor expansion: 17.3 a) L – S coupling: (Vn(r) V(r-Hs) un(r)) = (y,(r)​  According to Bohr's theory, electrons of an atom revolve around the nucleus on certain orbits, or electron shells. Each orbit has its specific energy level, which is expressed as a negative value. This is because the electrons on the orbit are "captured" by the nucleus via electrostatic forces, and impedes the freedom of the electron.

IndProp: Inductively Defined Propositions, For example, the rule ev_SS says that, if n satisfies ev, then S (S n) also does. with "evidence constructors" ev_0 : ev 0 and ev_SS : ∀ n, ev n → ev (S (S n)). EV’s have a huge torque drop off at higher motor speeds, ICE’s GAIN torque through the powerband. This is why the Model S gets over taken through the quarter mile traps. It doesn’t have to be for race cars, but having the motor in the correct RPM range at highway speeds would be beneficial regardless of how or where the car is driven.